source: src/libcfa/concurrency/invoke.h@ 59239b8

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 59239b8 was 0157ca7, checked in by Thierry Delisle <tdelisle@…>, 9 years ago

Fixed incorrectly hand-mangled name

  • Property mode set to 100644
File size: 2.8 KB
RevLine 
[0157ca7]1// -*- Mode: C -*-
[8def349]2//
3// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
4//
5// The contents of this file are covered under the licence agreement in the
6// file "LICENCE" distributed with Cforall.
7//
8// invoke.h --
9//
10// Author : Thierry Delisle
11// Created On : Tue Jan 17 12:27:26 2016
12// Last Modified By : Thierry Delisle
13// Last Modified On : --
14// Update Count : 0
15//
16
[5c81105]17#include <stdbool.h>
18#include <stdint.h>
[78b3f52]19
[5c81105]20#ifdef __CFORALL__
21extern "C" {
22#endif
23
24#if ! defined(__CFA_INVOKE_PRIVATE__)
[78b3f52]25#ifndef _INVOKE_H_
26#define _INVOKE_H_
27
[596f987b]28 #define unlikely(x) __builtin_expect(!!(x), 0)
[8def349]29 #define thread_local _Thread_local
[bd98b58]30 #define SCHEDULER_CAPACITY 10
31
32 struct simple_thread_list {
[e15df4c]33 struct thread * head;
34 struct thread ** tail;
[bd98b58]35 };
36
37 #ifdef __CFORALL__
38 extern "Cforall" {
39 void ?{}( struct simple_thread_list * );
[e15df4c]40 void append( struct simple_thread_list *, struct thread * );
41 struct thread * pop_head( struct simple_thread_list * );
[bd98b58]42 }
43 #endif
[596f987b]44
45 struct coStack_t {
[5c81105]46 unsigned int size; // size of stack
47 void *storage; // pointer to stack
48 void *limit; // stack grows towards stack limit
49 void *base; // base of stack
50 void *context; // address of cfa_context_t
51 void *top; // address of top of storage
52 bool userStack;
53 };
[78b3f52]54
[80d9e49]55 enum coroutine_state { Start, Inactive, Active, Halt, Primed };
[78b3f52]56
[5c81105]57 struct coroutine {
58 struct coStack_t stack;
59 const char *name; // textual name for coroutine/task, initialized by uC++ generated code
60 int errno_; // copy of global UNIX variable errno
61 enum coroutine_state state; // current execution status for coroutine
62 bool notHalted; // indicate if execuation state is not halted
[78b3f52]63
[5c81105]64 struct coroutine *starter; // first coroutine to resume this one
65 struct coroutine *last; // last coroutine to resume this one
66 };
[78b3f52]67
[bd98b58]68 struct simple_lock {
69 struct simple_thread_list blocked;
70 };
71
[e15df4c]72 struct thread {
[8118303]73 struct coroutine c;
[bd98b58]74 struct simple_lock lock;
[e15df4c]75 struct thread * next;
[8118303]76 };
77
[5c81105]78#endif //_INVOKE_H_
79#else //! defined(__CFA_INVOKE_PRIVATE__)
80#ifndef _INVOKE_PRIVATE_H_
81#define _INVOKE_PRIVATE_H_
82
[596f987b]83 struct machine_context_t {
[5c81105]84 void *SP;
85 void *FP;
86 void *PC;
87 };
[78b3f52]88
[5c81105]89 // assembler routines that performs the context switch
[b58a5772]90 extern void CtxInvokeStub( void );
[eb2e723]91 void CtxSwitch( void * from, void * to ) asm ("CtxSwitch");
92 void CtxGet( void * this ) asm ("CtxGet");
[78b3f52]93
[5c81105]94#endif //_INVOKE_PRIVATE_H_
95#endif //! defined(__CFA_INVOKE_PRIVATE__)
96#ifdef __CFORALL__
97}
98#endif
Note: See TracBrowser for help on using the repository browser.