- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/invoke.c
r212c2187 rdeca0f5 29 29 extern void __suspend_internal(void); 30 30 extern void __leave_coroutine( struct coroutine_desc * ); 31 extern void __finish_creation( struct coroutine_desc * );31 extern void __finish_creation( struct thread_desc * ); 32 32 extern void __leave_thread_monitor( struct thread_desc * this ); 33 33 extern void disable_interrupts(); … … 46 46 47 47 cor->state = Active; 48 49 enable_interrupts( __cfaabi_dbg_ctx );50 48 51 49 main( this ); … … 93 91 // First suspend, once the thread arrives here, 94 92 // the function pointer to main can be invalidated without risk 95 __finish_creation(&thrd->self_cor); 96 97 // Restore the last to NULL, we clobbered because of the thunk problem 98 thrd->self_cor.last = NULL; 93 __finish_creation( thrd ); 99 94 100 95 // Officially start the thread by enabling preemption … … 122 117 void (*invoke)(void *) 123 118 ) { 124 struct coStack_t* stack = &get_coroutine( this )->stack; 119 struct coroutine_desc * cor = get_coroutine( this ); 120 struct __stack_t * stack = cor->stack.storage; 125 121 126 122 #if defined( __i386 ) … … 128 124 struct FakeStack { 129 125 void *fixedRegisters[3]; // fixed registers ebx, edi, esi (popped on 1st uSwitch, values unimportant) 130 uint32_t mxcr; // SSE Status and Control bits (control bits are preserved across function calls)131 uint16_t fcw; // X97 FPU control word (preserved across function calls)132 126 void *rturn; // where to go on return from uSwitch 133 127 void *dummyReturn; // fake return compiler would have pushed on call to uInvoke … … 136 130 }; 137 131 138 ((struct machine_context_t *)stack->context)->SP = (char *)stack->base - sizeof( struct FakeStack );139 ((struct machine_context_t *)stack->context)->FP = NULL; // terminate stack with NULL fp132 cor->context.SP = (char *)stack->base - sizeof( struct FakeStack ); 133 cor->context.FP = NULL; // terminate stack with NULL fp 140 134 141 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->dummyReturn = NULL;142 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->argument[0] = this; // argument to invoke 143 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->rturn = invoke;144 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->mxcr = 0x1F80; //Vol. 2A 3-520145 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fcw = 0x037F; //Vol. 1 8-7135 struct FakeStack *fs = (struct FakeStack *)cor->context.SP; 136 137 fs->dummyReturn = NULL; 138 fs->argument[0] = this; // argument to invoke 139 fs->rturn = invoke; 146 140 147 141 #elif defined( __x86_64 ) … … 149 143 struct FakeStack { 150 144 void *fixedRegisters[5]; // fixed registers rbx, r12, r13, r14, r15 151 uint32_t mxcr; // SSE Status and Control bits (control bits are preserved across function calls)152 uint16_t fcw; // X97 FPU control word (preserved across function calls)153 145 void *rturn; // where to go on return from uSwitch 154 146 void *dummyReturn; // NULL return address to provide proper alignment 155 147 }; 156 148 157 ((struct machine_context_t *)stack->context)->SP = (char *)stack->base - sizeof( struct FakeStack );158 ((struct machine_context_t *)stack->context)->FP = NULL; // terminate stack with NULL fp149 cor->context.SP = (char *)stack->base - sizeof( struct FakeStack ); 150 cor->context.FP = NULL; // terminate stack with NULL fp 159 151 160 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->dummyReturn = NULL;161 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->rturn = CtxInvokeStub; 162 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fixedRegisters[0] = this;163 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fixedRegisters[1] = invoke;164 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->mxcr = 0x1F80; //Vol. 2A 3-520165 ((struct FakeStack *)(((struct machine_context_t *)stack->context)->SP))->fcw = 0x037F; //Vol. 1 8-7152 struct FakeStack *fs = (struct FakeStack *)cor->context.SP; 153 154 fs->dummyReturn = NULL; 155 fs->rturn = CtxInvokeStub; 156 fs->fixedRegisters[0] = this; 157 fs->fixedRegisters[1] = invoke; 166 158 167 159 #elif defined( __ARM_ARCH ) … … 173 165 }; 174 166 175 ((struct machine_context_t *)stack->context)->SP = (char *)stack->base - sizeof( struct FakeStack );176 ((struct machine_context_t *)stack->context)->FP = NULL;167 cor->context.SP = (char *)stack->base - sizeof( struct FakeStack ); 168 cor->context.FP = NULL; 177 169 178 struct FakeStack *fs = (struct FakeStack *) ((struct machine_context_t *)stack->context)->SP;170 struct FakeStack *fs = (struct FakeStack *)cor->context.SP; 179 171 180 172 fs->intRegs[8] = CtxInvokeStub;
Note: See TracChangeset
for help on using the changeset viewer.