Ignore:
File:
1 edited

Legend:

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

    r83a071f9 r6b0b624  
    1 //                              -*- Mode: CFA -*-
    21//
    32// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    109// Author           : Thierry Delisle
    1110// Created On       : Mon Nov 28 12:27:26 2016
    12 // Last Modified By : Thierry Delisle
    13 // Last Modified On : Mon Nov 28 12:27:26 2016
    14 // Update Count     : 0
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Jul 21 22:34:57 2017
     13// Update Count     : 1
    1514//
    1615
     
    2625}
    2726
    28 #include "kernel"
    29 #include "libhdr.h"
     27#include "kernel_private.h"
    3028
    3129#define __CFA_INVOKE_PRIVATE__
    3230#include "invoke.h"
    3331
    34 extern volatile thread_local processor * this_processor;
    3532
    3633//-----------------------------------------------------------------------------
     
    4340//-----------------------------------------------------------------------------
    4441// Coroutine ctors and dtors
    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;
     42void ?{}(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;
    5350}
    5451
    55 void ?{}(coStack_t& this, size_t size) {
     52void ?{}(coStack_t* this, size_t size) {
    5653        this{};
    57         this.size = size;
     54        this->size = size;
    5855
    59         create_stack(&this, this.size);
     56        create_stack(this, this->size);
    6057}
    6158
    62 void ?{}(coroutine_desc& this) {
     59void ?{}(coroutine_desc* this) {
    6360        this{ "Anonymous Coroutine" };
    6461}
    6562
    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;
     63void ?{}(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;
    7269}
    7370
    74 void ?{}(coroutine_desc& this, size_t size) {
     71void ?{}(coroutine_desc* this, size_t size) {
    7572        this{};
    76         (this.stack){size};
     73        (&this->stack){size};
    7774}
    7875
    79 void ^?{}(coStack_t& this) {
    80         if ( ! this.userStack ) {
     76void ^?{}(coStack_t* this) {
     77        if ( ! this->userStack ) {
    8178                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 ) );
     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 ) );
    8481                        }
    8582                );
    86                 free( this.storage );
     83                free( this->storage );
    8784        }
    8885}
    8986
    90 void ^?{}(coroutine_desc& this) {}
     87void ^?{}(coroutine_desc* this) {}
    9188
    9289// Part of the Public API
    9390// Not inline since only ever called once per coroutine
    9491forall(dtype T | is_coroutine(T))
    95 void prime(T& cor) {
     92void prime(T* cor) {
    9693        coroutine_desc* this = get_coroutine(cor);
    9794        assert(this->state == Start);
Note: See TracChangeset for help on using the changeset viewer.