source: src/libcfa/concurrency/invoke.h@ 2d59d53

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 2d59d53 was 80d9e49, checked in by Thierry Delisle <tdelisle@…>, 9 years ago

Coroutines no longer require virtual pointers or any code beyond the get_coroutine routine

  • Property mode set to 100644
File size: 1.6 KB
Line 
1#include <stdbool.h>
2#include <stdint.h>
3
4#ifdef __CFORALL__
5extern "C" {
6#endif
7
8#if ! defined(__CFA_INVOKE_PRIVATE__)
9#ifndef _INVOKE_H_
10#define _INVOKE_H_
11
12 struct coStack_t {
13 unsigned int size; // size of stack
14 void *storage; // pointer to stack
15 void *limit; // stack grows towards stack limit
16 void *base; // base of stack
17 void *context; // address of cfa_context_t
18 void *top; // address of top of storage
19 bool userStack;
20 };
21
22 enum coroutine_state { Start, Inactive, Active, Halt, Primed };
23
24 struct coroutine {
25 struct coStack_t stack;
26 const char *name; // textual name for coroutine/task, initialized by uC++ generated code
27 int errno_; // copy of global UNIX variable errno
28 enum coroutine_state state; // current execution status for coroutine
29 bool notHalted; // indicate if execuation state is not halted
30
31 struct coroutine *starter; // first coroutine to resume this one
32 struct coroutine *last; // last coroutine to resume this one
33 };
34
35#endif //_INVOKE_H_
36#else //! defined(__CFA_INVOKE_PRIVATE__)
37#ifndef _INVOKE_PRIVATE_H_
38#define _INVOKE_PRIVATE_H_
39
40 struct machine_context_t {
41 void *SP;
42 void *FP;
43 void *PC;
44 };
45
46 // assembler routines that performs the context switch
47 extern void coInvokeStub( void );
48 void CtxSwitch( void *from, void *to ) asm ("CtxSwitch");
49
50#endif //_INVOKE_PRIVATE_H_
51#endif //! defined(__CFA_INVOKE_PRIVATE__)
52#ifdef __CFORALL__
53}
54#endif
Note: See TracBrowser for help on using the repository browser.