Changeset 242a902 for src/libcfa/concurrency/coroutine.c
- Timestamp:
- Jul 18, 2017, 4:35:52 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- f19339e
- Parents:
- 795d450
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/coroutine.c
r795d450 r242a902 43 43 //----------------------------------------------------------------------------- 44 44 // Coroutine ctors and dtors 45 void ?{}(coStack_t *this) {46 this ->size = 65000; // size of stack47 this ->storage = NULL; // pointer to stack48 this ->limit = NULL; // stack grows towards stack limit49 this ->base = NULL; // base of stack50 this ->context = NULL; // address of cfa_context_t51 this ->top = NULL; // address of top of storage52 this ->userStack = false;45 void ?{}(coStack_t& this) { 46 this.size = 65000; // size of stack 47 this.storage = NULL; // pointer to stack 48 this.limit = NULL; // stack grows towards stack limit 49 this.base = NULL; // base of stack 50 this.context = NULL; // address of cfa_context_t 51 this.top = NULL; // address of top of storage 52 this.userStack = false; 53 53 } 54 54 55 void ?{}(coStack_t *this, size_t size) {55 void ?{}(coStack_t& this, size_t size) { 56 56 this{}; 57 this ->size = size;57 this.size = size; 58 58 59 create_stack( this, this->size);59 create_stack(&this, this.size); 60 60 } 61 61 62 void ?{}(coroutine_desc *this) {62 void ?{}(coroutine_desc& this) { 63 63 this{ "Anonymous Coroutine" }; 64 64 } 65 65 66 void ?{}(coroutine_desc *this, const char * name) {67 this ->name = name;68 this ->errno_ = 0;69 this ->state = Start;70 this ->starter = NULL;71 this ->last = NULL;66 void ?{}(coroutine_desc& this, const char * name) { 67 this.name = name; 68 this.errno_ = 0; 69 this.state = Start; 70 this.starter = NULL; 71 this.last = NULL; 72 72 } 73 73 74 void ?{}(coroutine_desc *this, size_t size) {74 void ?{}(coroutine_desc& this, size_t size) { 75 75 this{}; 76 ( &this->stack){size};76 (this.stack){size}; 77 77 } 78 78 79 void ^?{}(coStack_t *this) {79 void ^?{}(coStack_t& this) { 80 80 if ( ! this->userStack ) { 81 81 LIB_DEBUG_DO( 82 if ( mprotect( this ->storage, pageSize, PROT_READ | PROT_WRITE ) == -1 ) {83 abortf( "(coStack_t *)%p.^?{}() : internal error, mprotect failure, error(%d) %s.", this, errno, strerror( errno ) );82 if ( mprotect( this.storage, pageSize, PROT_READ | PROT_WRITE ) == -1 ) { 83 abortf( "(coStack_t *)%p.^?{}() : internal error, mprotect failure, error(%d) %s.", &this, errno, strerror( errno ) ); 84 84 } 85 85 ); 86 free( this ->storage );86 free( this.storage ); 87 87 } 88 88 } 89 89 90 void ^?{}(coroutine_desc *this) {}90 void ^?{}(coroutine_desc& this) {} 91 91 92 92 // Part of the Public API
Note: See TracChangeset
for help on using the changeset viewer.