ADT
aaron-thesis
arm-eh
ast-experimental
cleanup-dtors
deferred_resn
demangler
enum
forall-pointer-decay
jacob/cs343-translation
jenkins-sandbox
new-ast
new-ast-unique-expr
new-env
no_list
persistent-indexer
pthread-emulation
qualifiedEnum
resolv-new
with_gc
Last change
on this file since ff2d7341 was 596f987b, checked in by Thierry Delisle <tdelisle@…>, 9 years ago |
Some optimization and clean-up of coroutines
|
-
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 |
|
---|
[5c81105] | 37 | #endif //_INVOKE_H_
|
---|
| 38 | #else //! defined(__CFA_INVOKE_PRIVATE__)
|
---|
| 39 | #ifndef _INVOKE_PRIVATE_H_
|
---|
| 40 | #define _INVOKE_PRIVATE_H_
|
---|
| 41 |
|
---|
[596f987b] | 42 | struct machine_context_t {
|
---|
[5c81105] | 43 | void *SP;
|
---|
| 44 | void *FP;
|
---|
| 45 | void *PC;
|
---|
| 46 | };
|
---|
[78b3f52] | 47 |
|
---|
[5c81105] | 48 | // assembler routines that performs the context switch
|
---|
[b58a5772] | 49 | extern void CtxInvokeStub( void );
|
---|
[5c81105] | 50 | void CtxSwitch( void *from, void *to ) asm ("CtxSwitch");
|
---|
[78b3f52] | 51 |
|
---|
[5c81105] | 52 | #endif //_INVOKE_PRIVATE_H_
|
---|
| 53 | #endif //! defined(__CFA_INVOKE_PRIVATE__)
|
---|
| 54 | #ifdef __CFORALL__
|
---|
| 55 | }
|
---|
| 56 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.