Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/coroutine.c

    r6b0b624 r83a071f9  
     1//                              -*- Mode: CFA -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Mon Nov 28 12:27:26 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 21 22:34:57 2017
    13 // Update Count     : 1
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : Mon Nov 28 12:27:26 2016
     14// Update Count     : 0
    1415//
    1516
     
    2526}
    2627
    27 #include "kernel_private.h"
     28#include "kernel"
     29#include "libhdr.h"
    2830
    2931#define __CFA_INVOKE_PRIVATE__
    3032#include "invoke.h"
    3133
     34extern volatile thread_local processor * this_processor;
    3235
    3336//-----------------------------------------------------------------------------
     
    4043//-----------------------------------------------------------------------------
    4144// Coroutine ctors and dtors
    42 void ?{}(coStack_t* this) {
    43         this->size              = 65000;        // size of stack
    44         this->storage   = NULL; // pointer to stack
    45         this->limit             = NULL; // stack grows towards stack limit
    46         this->base              = NULL; // base of stack
    47         this->context   = NULL; // address of cfa_context_t
    48         this->top               = NULL; // address of top of storage
    49         this->userStack = false;
     45void ?{}(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;
    5053}
    5154
    52 void ?{}(coStack_t* this, size_t size) {
     55void ?{}(coStack_t& this, size_t size) {
    5356        this{};
    54         this->size = size;
     57        this.size = size;
    5558
    56         create_stack(this, this->size);
     59        create_stack(&this, this.size);
    5760}
    5861
    59 void ?{}(coroutine_desc* this) {
     62void ?{}(coroutine_desc& this) {
    6063        this{ "Anonymous Coroutine" };
    6164}
    6265
    63 void ?{}(coroutine_desc* this, const char * name) {
    64         this->name = name;
    65         this->errno_ = 0;
    66         this->state = Start;
    67         this->starter = NULL;
    68         this->last = NULL;
     66void ?{}(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;
    6972}
    7073
    71 void ?{}(coroutine_desc* this, size_t size) {
     74void ?{}(coroutine_desc& this, size_t size) {
    7275        this{};
    73         (&this->stack){size};
     76        (this.stack){size};
    7477}
    7578
    76 void ^?{}(coStack_t* this) {
    77         if ( ! this->userStack ) {
     79void ^?{}(coStack_t& this) {
     80        if ( ! this.userStack ) {
    7881                LIB_DEBUG_DO(
    79                         if ( mprotect( this->storage, pageSize, PROT_READ | PROT_WRITE ) == -1 ) {
    80                                 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 ) );
    8184                        }
    8285                );
    83                 free( this->storage );
     86                free( this.storage );
    8487        }
    8588}
    8689
    87 void ^?{}(coroutine_desc* this) {}
     90void ^?{}(coroutine_desc& this) {}
    8891
    8992// Part of the Public API
    9093// Not inline since only ever called once per coroutine
    9194forall(dtype T | is_coroutine(T))
    92 void prime(T* cor) {
     95void prime(T& cor) {
    9396        coroutine_desc* this = get_coroutine(cor);
    9497        assert(this->state == Start);
Note: See TracChangeset for help on using the changeset viewer.