Changeset 90152a4 for libcfa/src/concurrency/invoke.h
- Timestamp:
- Aug 27, 2018, 4:40:34 PM (7 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- b7c89aa
- Parents:
- f9feab8 (diff), 305581d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/invoke.h
rf9feab8 r90152a4 10 10 // Created On : Tue Jan 17 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 21 22:28:56 201713 // Update Count : 114 // 15 16 #include "bits/containers.h "17 #include "bits/defs.h "18 #include "bits/locks.h "12 // Last Modified On : Sat May 19 08:23:21 2018 13 // Update Count : 31 14 // 15 16 #include "bits/containers.hfa" 17 #include "bits/defs.hfa" 18 #include "bits/locks.hfa" 19 19 20 20 #ifdef __cforall … … 25 25 #ifndef _INVOKE_H_ 26 26 #define _INVOKE_H_ 27 28 #ifdef __ARM_ARCH 29 // function prototypes are only really used by these macros on ARM 30 void disable_global_interrupts(); 31 void enable_global_interrupts(); 32 33 #define TL_GET( member ) ( { __typeof__( kernelTLS.member ) target; \ 34 disable_global_interrupts(); \ 35 target = kernelTLS.member; \ 36 enable_global_interrupts(); \ 37 target; } ) 38 #define TL_SET( member, value ) disable_global_interrupts(); \ 39 kernelTLS.member = value; \ 40 enable_global_interrupts(); 41 #else 42 #define TL_GET( member ) kernelTLS.member 43 #define TL_SET( member, value ) kernelTLS.member = value; 44 #endif 27 45 28 46 #ifdef __cforall … … 30 48 static inline struct thread_desc * & get_next( struct thread_desc & this ); 31 49 static inline struct __condition_criterion_t * & get_next( struct __condition_criterion_t & this ); 50 51 extern thread_local struct KernelThreadData { 52 struct coroutine_desc * volatile this_coroutine; 53 struct thread_desc * volatile this_thread; 54 struct processor * volatile this_processor; 55 56 struct { 57 volatile unsigned short disable_count; 58 volatile bool enabled; 59 volatile bool in_progress; 60 } preemption_state; 61 } kernelTLS; 32 62 } 63 64 static inline struct coroutine_desc * volatile active_coroutine() { return TL_GET( this_coroutine ); } 65 static inline struct thread_desc * volatile active_thread () { return TL_GET( this_thread ); } 66 static inline struct processor * volatile active_processor() { return TL_GET( this_processor ); } // UNSAFE 33 67 #endif 34 68 35 69 struct coStack_t { 36 // size of stack 37 size_t size; 38 39 // pointer to stack 40 void *storage; 41 42 // stack grows towards stack limit 43 void *limit; 44 45 // base of stack 46 void *base; 47 48 // address of cfa_context_t 49 void *context; 50 51 // address of top of storage 52 void *top; 53 54 // whether or not the user allocated the stack 55 bool userStack; 70 size_t size; // size of stack 71 void * storage; // pointer to stack 72 void * limit; // stack grows towards stack limit 73 void * base; // base of stack 74 void * context; // address of cfa_context_t 75 void * top; // address of top of storage 76 bool userStack; // whether or not the user allocated the stack 56 77 }; 57 78 … … 59 80 60 81 struct coroutine_desc { 61 // stack information of the coroutine 62 struct coStack_t stack; 63 64 // textual name for coroutine/task, initialized by uC++ generated code 65 const char *name; 66 67 // copy of global UNIX variable errno 68 int errno_; 69 70 // current execution status for coroutine 71 enum coroutine_state state; 72 73 // first coroutine to resume this one 74 struct coroutine_desc * starter; 75 76 // last coroutine to resume this one 77 struct coroutine_desc * last; 82 struct coStack_t stack; // stack information of the coroutine 83 const char * name; // textual name for coroutine/task, initialized by uC++ generated code 84 int errno_; // copy of global UNIX variable errno 85 enum coroutine_state state; // current execution status for coroutine 86 struct coroutine_desc * starter; // first coroutine to resume this one 87 struct coroutine_desc * last; // last coroutine to resume this one 78 88 }; 79 89 … … 83 93 84 94 // list of acceptable functions, null if any 85 __ small_array_t(struct __acceptable_t) __cfa_anonymous_object;95 __cfa_anonymous_object( __small_array_t(struct __acceptable_t) ); 86 96 }; 87 97 … … 111 121 struct __monitor_group_t { 112 122 // currently held monitors 113 __ small_array_t(monitor_desc*) __cfa_anonymous_object;123 __cfa_anonymous_object( __small_array_t(monitor_desc*) ); 114 124 115 125 // last function that acquired monitors … … 122 132 struct coroutine_desc self_cor; 123 133 134 // current active context 135 struct coroutine_desc * curr_cor; 136 124 137 // monitor body used for mutual exclusion 125 138 struct monitor_desc self_mon; … … 127 140 // pointer to monitor with sufficient lifetime for current monitors 128 141 struct monitor_desc * self_mon_p; 142 143 // pointer to the cluster on which the thread is running 144 struct cluster * curr_cluster; 129 145 130 146 // monitors currently held by this thread … … 134 150 // instrusive link field for threads 135 151 struct thread_desc * next; 152 153 struct { 154 struct thread_desc * next; 155 struct thread_desc * prev; 156 } node; 136 157 }; 137 158 … … 140 161 static inline thread_desc * & get_next( thread_desc & this ) { 141 162 return this.next; 163 } 164 165 static inline [thread_desc *&, thread_desc *& ] __get( thread_desc & this ) { 166 return this.node.[next, prev]; 142 167 } 143 168 … … 193 218 void CtxSwitch( void * from, void * to ) asm ("CtxSwitch"); 194 219 195 #if defined( __x86_64__ ) 220 #if defined( __i386 ) 221 #define CtxGet( ctx ) __asm__ ( \ 222 "movl %%esp,%0\n" \ 223 "movl %%ebp,%1\n" \ 224 : "=rm" (ctx.SP), "=rm" (ctx.FP) ) 225 #elif defined( __x86_64 ) 196 226 #define CtxGet( ctx ) __asm__ ( \ 197 227 "movq %%rsp,%0\n" \ 198 228 "movq %%rbp,%1\n" \ 199 229 : "=rm" (ctx.SP), "=rm" (ctx.FP) ) 200 #elif defined( __ i386__)230 #elif defined( __ARM_ARCH ) 201 231 #define CtxGet( ctx ) __asm__ ( \ 202 "mov l %%esp,%0\n" \203 "mov l %%ebp,%1\n" \232 "mov %0,%%sp\n" \ 233 "mov %1,%%r11\n" \ 204 234 : "=rm" (ctx.SP), "=rm" (ctx.FP) ) 235 #else 236 #error unknown hardware architecture 205 237 #endif 206 238
Note:
See TracChangeset
for help on using the changeset viewer.