- File:
-
- 1 edited
-
libcfa/src/concurrency/invoke.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/invoke.h
rdeca0f5 r212c2187 62 62 #endif 63 63 64 struct __stack_context_t { 65 void * SP; 66 void * FP; 67 }; 68 69 // low adresses : +----------------------+ <- start of allocation 70 // | optional guard page | 71 // +----------------------+ <- __stack_t.limit 72 // | | 73 // | /\ /\ /\ | 74 // | || || || | 75 // | | 76 // | program stack | 77 // | | 78 // __stack_info_t.storage -> +----------------------+ <- __stack_t.base 79 // | __stack_t | 80 // high adresses : +----------------------+ <- end of allocation 81 82 struct __stack_t { 83 // stack grows towards stack limit 84 void * limit; 85 86 // base of stack 87 void * base; 88 }; 89 90 struct __stack_info_t { 91 // pointer to stack 92 struct __stack_t * storage; 64 struct coStack_t { 65 size_t size; // size of stack 66 void * storage; // pointer to stack 67 void * limit; // stack grows towards stack limit 68 void * base; // base of stack 69 void * context; // address of cfa_context_t 70 void * top; // address of top of storage 71 bool userStack; // whether or not the user allocated the stack 93 72 }; 94 73 … … 96 75 97 76 struct coroutine_desc { 98 // context that is switch during a CtxSwitch99 struct __stack_context_t context;100 101 77 // stack information of the coroutine 102 struct __stack_info_t stack;103 104 // textual name for coroutine/task 78 struct coStack_t stack; 79 80 // textual name for coroutine/task, initialized by uC++ generated code 105 81 const char * name; 82 83 // copy of global UNIX variable errno 84 int errno_; 106 85 107 86 // current execution status for coroutine 108 87 enum coroutine_state state; 109 110 88 // first coroutine to resume this one 111 89 struct coroutine_desc * starter; … … 161 139 struct thread_desc { 162 140 // Core threading fields 163 // context that is switch during a CtxSwitch164 struct __stack_context_t context;165 166 // current execution status for coroutine167 enum coroutine_state state;168 169 //SKULLDUGGERY errno is not save in the thread data structure because returnToKernel appears to be the only function to require saving and restoring it170 171 141 // coroutine body used to store context 172 142 struct coroutine_desc self_cor; … … 260 230 // assembler routines that performs the context switch 261 231 extern void CtxInvokeStub( void ); 262 extern void CtxSwitch( struct __stack_context_t * from, struct __stack_context_t* to ) asm ("CtxSwitch");232 void CtxSwitch( void * from, void * to ) asm ("CtxSwitch"); 263 233 // void CtxStore ( void * this ) asm ("CtxStore"); 264 234 // void CtxRet ( void * dst ) asm ("CtxRet"); 235 236 #if defined( __i386 ) 237 #define CtxGet( ctx ) __asm__ ( \ 238 "movl %%esp,%0\n" \ 239 "movl %%ebp,%1\n" \ 240 : "=rm" (ctx.SP), "=rm" (ctx.FP) ) 241 #elif defined( __x86_64 ) 242 #define CtxGet( ctx ) __asm__ ( \ 243 "movq %%rsp,%0\n" \ 244 "movq %%rbp,%1\n" \ 245 : "=rm" (ctx.SP), "=rm" (ctx.FP) ) 246 #elif defined( __ARM_ARCH ) 247 #define CtxGet( ctx ) __asm__ ( \ 248 "mov %0,%%sp\n" \ 249 "mov %1,%%r11\n" \ 250 : "=rm" (ctx.SP), "=rm" (ctx.FP) ) 251 #else 252 #error unknown hardware architecture 253 #endif 265 254 266 255 #endif //_INVOKE_PRIVATE_H_
Note:
See TracChangeset
for help on using the changeset viewer.