aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 8118303 was
8118303,
checked in by Thierry Delisle <tdelisle@…>, 6 years ago
|
First prototype of cfa threads running (1 thread on 1 processor)
|
-
Property mode set to
100644
|
File size:
1.7 KB
|
Rev | Line | |
---|
[5c81105] | 1 | #include <stdbool.h> |
---|
| 2 | #include <stdint.h> |
---|
[78b3f52] | 3 | |
---|
[5c81105] | 4 | #ifdef __CFORALL__ |
---|
| 5 | extern "C" { |
---|
| 6 | #endif |
---|
| 7 | |
---|
| 8 | #if ! defined(__CFA_INVOKE_PRIVATE__) |
---|
[78b3f52] | 9 | #ifndef _INVOKE_H_ |
---|
| 10 | #define _INVOKE_H_ |
---|
| 11 | |
---|
[596f987b] | 12 | #define unlikely(x) __builtin_expect(!!(x), 0) |
---|
| 13 | |
---|
| 14 | struct coStack_t { |
---|
[5c81105] | 15 | unsigned int size; // size of stack |
---|
| 16 | void *storage; // pointer to stack |
---|
| 17 | void *limit; // stack grows towards stack limit |
---|
| 18 | void *base; // base of stack |
---|
| 19 | void *context; // address of cfa_context_t |
---|
| 20 | void *top; // address of top of storage |
---|
| 21 | bool userStack; |
---|
| 22 | }; |
---|
[78b3f52] | 23 | |
---|
[80d9e49] | 24 | enum coroutine_state { Start, Inactive, Active, Halt, Primed }; |
---|
[78b3f52] | 25 | |
---|
[5c81105] | 26 | struct coroutine { |
---|
| 27 | struct coStack_t stack; |
---|
| 28 | const char *name; // textual name for coroutine/task, initialized by uC++ generated code |
---|
| 29 | int errno_; // copy of global UNIX variable errno |
---|
| 30 | enum coroutine_state state; // current execution status for coroutine |
---|
| 31 | bool notHalted; // indicate if execuation state is not halted |
---|
[78b3f52] | 32 | |
---|
[5c81105] | 33 | struct coroutine *starter; // first coroutine to resume this one |
---|
| 34 | struct coroutine *last; // last coroutine to resume this one |
---|
| 35 | }; |
---|
[78b3f52] | 36 | |
---|
[8118303] | 37 | struct thread_h { |
---|
| 38 | struct coroutine c; |
---|
| 39 | }; |
---|
| 40 | |
---|
[5c81105] | 41 | #endif //_INVOKE_H_ |
---|
| 42 | #else //! defined(__CFA_INVOKE_PRIVATE__) |
---|
| 43 | #ifndef _INVOKE_PRIVATE_H_ |
---|
| 44 | #define _INVOKE_PRIVATE_H_ |
---|
| 45 | |
---|
[596f987b] | 46 | struct machine_context_t { |
---|
[5c81105] | 47 | void *SP; |
---|
| 48 | void *FP; |
---|
| 49 | void *PC; |
---|
| 50 | }; |
---|
[78b3f52] | 51 | |
---|
[5c81105] | 52 | // assembler routines that performs the context switch |
---|
[b58a5772] | 53 | extern void CtxInvokeStub( void ); |
---|
[5c81105] | 54 | void CtxSwitch( void *from, void *to ) asm ("CtxSwitch"); |
---|
[78b3f52] | 55 | |
---|
[5c81105] | 56 | #endif //_INVOKE_PRIVATE_H_ |
---|
| 57 | #endif //! defined(__CFA_INVOKE_PRIVATE__) |
---|
| 58 | #ifdef __CFORALL__ |
---|
| 59 | } |
---|
| 60 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.