00001 00005 #ifndef __UIUC_UJCONTEXT_H 00006 #define __UIUC_UJCONTEXT_H 00007 00008 #include <setjmp.h> 00009 00010 #ifdef __cplusplus 00011 extern "C" { 00012 #endif 00013 00015 typedef struct uJcontext_stack_t { 00016 void *ss_sp; 00017 int ss_flags; 00018 size_t ss_size; 00019 } uJcontext_stack_t; 00020 00022 typedef void (*uJcontext_fn_t)(void *a1,void *a2); 00023 00025 typedef struct uJcontext_t { 00026 uJcontext_stack_t uc_stack; 00027 struct uJcontext_t *uc_link; /* not implemented */ 00028 int uc_flags, uc_sigmask; /* not implemented */ 00029 00030 /* Non-standard fields */ 00031 void (*uc_swap)(struct uJcontext_t *newContext); 00032 00033 /* Storage for processor registers, etc. when thread not running */ 00034 jmp_buf _uc_jmp_buf; 00035 00036 /* Only used to start the thread; useless afterwards */ 00037 uJcontext_fn_t _uc_fn; /* user function to call */ 00038 void *_uc_args[2]; /* user arguments to pass in */ 00039 } uJcontext_t; 00040 00042 typedef void (*uJcontext_swap_fn_t)(struct uJcontext_t *newContext); 00043 00044 /* Get user context and store it in variable pointed to by UCP. */ 00045 extern int getJcontext (uJcontext_t *__ucp) ; 00046 00047 /* Set user context from information of variable pointed to by UCP. */ 00048 extern int setJcontext (const uJcontext_t *__ucp) ; 00049 00050 /* Save current context in context variable pointed to by OUCP and set 00051 context from variable pointed to by UCP. */ 00052 extern int swapJcontext (uJcontext_t * __oucp, 00053 const uJcontext_t * __ucp) ; 00054 00055 /* Manipulate user context UCP to continue with calling functions FUNC 00056 and the ARGC-1 parameters following ARGC when the context is used 00057 the next time in `setcontext' or `swapcontext'. 00058 00059 UGLY NONSTANDARD HACK: always take two arguments, a1 and a2. 00060 */ 00061 extern void makeJcontext (uJcontext_t *__ucp, uJcontext_fn_t func, 00062 int __argc, void *a1,void *a2); 00063 00064 #ifdef __cplusplus 00065 }; 00066 #endif 00067 00068 #endif