Changes in / [a6fe3de:89e6ffc]


Ignore:
Location:
src
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • src/examples/gc_no_raii/src/internal/card_table.h

    ra6fe3de r89e6ffc  
    1818};
    1919
    20 static inline void ?{}(card_table_t* this)
     20static inline void ctor_card(card_table_t* const this)
    2121{
    2222        this->count = 0;
    2323}
    2424
    25 static inline void ^?{}(card_table_t* this)
     25static inline void dtor_card(card_table_t* const this)
    2626{
    2727
  • src/examples/gc_no_raii/src/internal/memory_pool.c

    ra6fe3de r89e6ffc  
    1111const size_t gc_pool_header_size = (size_t)(  &(((gc_memory_pool*)NULL)->start_p) );
    1212
    13 void ?{}(gc_memory_pool* this, size_t size, gc_memory_pool* next, gc_memory_pool* mirror, uint8_t type)
     13void ctor(gc_memory_pool *const this, size_t size, gc_memory_pool* next, gc_memory_pool* mirror, uint8_t type)
    1414{
    1515        this->mirror = mirror;
     
    1717        this->type_code = type;
    1818
    19         this->cards = ( (card_table_t*)malloc(sizeof(card_table_t)) ){};
     19        card_table_t* new = (card_table_t*)malloc(sizeof(card_table_t));
     20        this->cards = new;
     21        ctor_card(this->cards);
    2022
    2123        this->end_p = ((uint8_t*)this) + size;
     
    2729}
    2830
    29 void ^?{}(gc_memory_pool* this)
     31void dtor(gc_memory_pool *const this)
    3032{
    31         ^(&this->cards){};
     33        dtor_card(this->cards);
    3234        free(this->cards);
    3335}
  • src/examples/gc_no_raii/src/internal/memory_pool.h

    ra6fe3de r89e6ffc  
    2727};
    2828
    29 void ?{}(       gc_memory_pool* this,
     29void ctor(      gc_memory_pool *const this,
    3030                size_t size,
    3131                gc_memory_pool* next,
     
    3434        );
    3535
    36 void ^?{}(gc_memory_pool* this);
     36void dtor(gc_memory_pool *const this);
    3737
    3838struct gc_pool_object_iterator
  • src/examples/gc_no_raii/src/internal/state.c

    ra6fe3de r89e6ffc  
    131131
    132132      this->from_space = (gc_memory_pool*)(pal_allocPool(POOL_SIZE_BYTES, 1));
    133       this->to_space   = (gc_memory_pool*)(pal_allocPool(POOL_SIZE_BYTES, 1));
    134 
    135       this->from_space{ POOL_SIZE_BYTES, old_from_space, this->to_space,   this->from_code };
    136       this->to_space  { POOL_SIZE_BYTES, old_to_space,   this->from_space, (~this->from_code) & 0x01 };
     133      this->to_space = (gc_memory_pool*)(pal_allocPool(POOL_SIZE_BYTES, 1));
     134
     135      ctor(this->from_space, POOL_SIZE_BYTES, old_from_space, this->to_space,   this->from_code);
     136      ctor(this->to_space,   POOL_SIZE_BYTES, old_to_space,   this->from_space, (~this->from_code) & 0x01);
    137137
    138138        this->total_space += gc_pool_size_used(this->from_space);
  • src/libcfa/containers/vector

    ra6fe3de r89e6ffc  
    2020}
    2121
     22#define DESTROY(x)
     23
    2224//------------------------------------------------------------------------------
    2325//Declaration
    2426trait allocator_c(otype T, otype allocator_t)
    2527{
    26         void realloc_storage(allocator_t*, size_t);
    27         T* data(allocator_t*);
     28        void ctor(allocator_t* const);
     29        void dtor(allocator_t* const);
     30        void realloc_storage(allocator_t* const, size_t);
     31        T* data(allocator_t* const);
    2832};
    29 
    30 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    31 struct vector;
    32 
    33 //------------------------------------------------------------------------------
    34 //Initialization
    35 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    36 void ?{}(vector(T, allocator_t)* this);
    37 
    38 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    39 void ?{}(vector(T, allocator_t)* this, vector(T, allocator_t) rhs);
    40 
    41 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    42 vector(T, allocator_t) ?=?(vector(T, allocator_t)* this, vector(T, allocator_t) rhs);
    43 
    44 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    45 void ^?{}(vector(T, allocator_t)* this);
    4633
    4734forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     
    5340
    5441//------------------------------------------------------------------------------
     42//Initialization
     43forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     44void ctor(vector(T, allocator_t) *const this);
     45
     46forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
     47void dtor(vector(T, allocator_t) *const this);
     48
     49//------------------------------------------------------------------------------
    5550//Capacity
    5651forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    57 static inline bool empty(vector(T, allocator_t)* this)
     52static inline bool empty(vector(T, allocator_t) *const this)
    5853{
    5954        return this->size == 0;
     
    6156
    6257forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    63 static inline size_t size(vector(T, allocator_t)* this)
     58static inline size_t size(vector(T, allocator_t) *const this)
    6459{
    6560        return this->size;
     
    6762
    6863forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    69 static inline void reserve(vector(T, allocator_t)* this, size_t size)
     64static inline void reserve(vector(T, allocator_t) *const this, size_t size)
    7065{
    7166        realloc_storage(&this->storage, this->size+1);
     
    7570//Element access
    7671forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    77 static inline T at(vector(T, allocator_t)* this, size_t index)
     72static inline T at(vector(T, allocator_t) *const this, size_t index)
    7873{
    7974        return data(&this->storage)[index];
     
    8176
    8277forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    83 static inline T ?[?](vector(T, allocator_t)* this, size_t index)
     78static inline T ?[?](vector(T, allocator_t) *const this, size_t index)
    8479{
    8580        return data(&this->storage)[index];
     
    8782
    8883forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    89 static inline T front(vector(T, allocator_t)* this)
     84static inline T front(vector(T, allocator_t) *const this)
    9085{
    9186        return data(&this->storage)[0];
     
    9388
    9489forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    95 static inline T back(vector(T, allocator_t)* this)
     90static inline T back(vector(T, allocator_t) *const this)
    9691{
    9792        return data(&this->storage)[this->size - 1];
     
    10196//Modifiers
    10297forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    103 void push_back(vector(T, allocator_t)* this, T value);
     98void push_back(vector(T, allocator_t) *const this, T value);
    10499
    105100forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    106 void pop_back(vector(T, allocator_t)* this);
     101void pop_back(vector(T, allocator_t) *const this);
    107102
    108103forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    109 void clear(vector(T, allocator_t)* this);
     104void clear(vector(T, allocator_t) *const this);
    110105
    111106//------------------------------------------------------------------------------
    112107//Iterators
    113108forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    114 static inline T* begin(vector(T, allocator_t)* this)
     109static inline T* begin(vector(T, allocator_t) *const this)
    115110{
    116111        return data(&this->storage);
     
    118113
    119114forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    120 static inline const T* cbegin(const vector(T, allocator_t)* this)
     115static inline const T* cbegin(const vector(T, allocator_t) *const this)
    121116{
    122117        return data(&this->storage);
     
    124119
    125120forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    126 static inline T* end(vector(T, allocator_t)* this)
     121static inline T* end(vector(T, allocator_t) *const this)
    127122{
    128123        return data(&this->storage) + this->size;
     
    130125
    131126forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    132 static inline const T* cend(const vector(T, allocator_t)* this)
     127static inline const T* cend(const vector(T, allocator_t) *const this)
    133128{
    134129        return data(&this->storage) + this->size;
     
    145140
    146141forall(otype T)
    147 void ?{}(heap_allocator(T)* this);
     142void ctor(heap_allocator(T) *const this);
    148143
    149144forall(otype T)
    150 void ?{}(heap_allocator(T)* this, heap_allocator(T) rhs);
     145void dtor(heap_allocator(T) *const this);
    151146
    152147forall(otype T)
    153 heap_allocator(T) ?=?(heap_allocator(T)* this, heap_allocator(T) rhs);
     148void realloc_storage(heap_allocator(T) *const this, size_t size);
    154149
    155150forall(otype T)
    156 void ^?{}(heap_allocator(T)* this);
    157 
    158 forall(otype T)
    159 void realloc_storage(heap_allocator(T)* this, size_t size);
    160 
    161 forall(otype T)
    162 static inline T* data(heap_allocator(T)* this)
     151static inline T* data(heap_allocator(T) *const this)
    163152{
    164153        return this->storage;
  • src/libcfa/containers/vector.c

    ra6fe3de r89e6ffc  
    1818#include <stdlib>
    1919
    20 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    21 void copy_internal(vector(T, allocator_t)* this, vector(T, allocator_t)* other);
    22 
    2320//------------------------------------------------------------------------------
    2421//Initialization
    2522forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    26 void ?{}(vector(T, allocator_t)* this)
     23void ctor(vector(T, allocator_t) *const this)
    2724{
    28         (&this->storage){};
     25        ctor(&this->storage);
    2926        this->size = 0;
    3027}
    3128
    3229forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    33 void ?{}(vector(T, allocator_t)* this, vector(T, allocator_t) rhs)
    34 {
    35         (&this->storage){ rhs.storage };
    36         copy_internal(this, &rhs);
    37 }
    38 
    39 // forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    40 // vector(T, allocator_t) ?=?(vector(T, allocator_t)* this, vector(T, allocator_t) rhs)
    41 // {
    42 //      (&this->storage){};
    43 //      copy_internal(this, &rhs);
    44 //      return *this;
    45 // }
    46 
    47 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    48 void ^?{}(vector(T, allocator_t)* this)
     30void dtor(vector(T, allocator_t) *const this)
    4931{
    5032        clear(this);
    51         ^(&this->storage){};
     33        dtor(&this->storage);
    5234}
    5335
     
    5537//Modifiers
    5638forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    57 void push_back(vector(T, allocator_t)* this, T value)
     39void push_back(vector(T, allocator_t) *const this, T value)
    5840{
    5941        realloc_storage(&this->storage, this->size+1);
     
    6345
    6446forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    65 void pop_back(vector(T, allocator_t)* this)
     47void pop_back(vector(T, allocator_t) *const this)
    6648{
    6749        this->size--;
    68         ^(&data(&this->storage)[this->size]){};
     50        DESTROY(data(&this->storage)[this->size]);
    6951}
    7052
    7153forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    72 void clear(vector(T, allocator_t)* this)
     54void clear(vector(T, allocator_t) *const this)
    7355{
    7456        for(size_t i = 0; i < this->size; i++)
    7557        {
    76                 ^(&data(&this->storage)[this->size]){};
     58                DESTROY(data(&this->storage)[this->size]);
    7759        }
    7860        this->size = 0;
     
    8062
    8163//------------------------------------------------------------------------------
    82 //Internal Helpers
    83 
    84 forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
    85 void copy_internal(vector(T, allocator_t)* this, vector(T, allocator_t)* other)
    86 {
    87         this->size = other->size;
    88         for(size_t i = 0; i < this->size; i++) {
    89                 (&data(&this->storage)[this->size]){ data(&other->storage)[other->size] };
    90         }
    91 }
    92 
    93 //------------------------------------------------------------------------------
    9464//Allocator
    9565forall(otype T)
    96 void ?{}(heap_allocator(T)* this)
     66void ctor(heap_allocator(T) *const this)
    9767{
    9868        this->storage = 0;
     
    10171
    10272forall(otype T)
    103 void ?{}(heap_allocator(T)* this, heap_allocator(T) rhs)
    104 {
    105         this->capacity = rhs.capacity;
    106         this->storage = (T*)realloc((void*)this->storage, this->capacity * sizeof(T));
    107 }
    108 
    109 forall(otype T)
    110 heap_allocator(T) ?=?(heap_allocator(T)* this, heap_allocator(T) rhs)
    111 {
    112         this->capacity = rhs.capacity;
    113         this->storage = (T*)realloc((void*)this->storage, this->capacity * sizeof(T));
    114         return *this;
    115 }
    116 
    117 forall(otype T)
    118 void ^?{}(heap_allocator(T)* this)
     73void dtor(heap_allocator(T) *const this)
    11974{
    12075        free(this->storage);
     
    12277
    12378forall(otype T)
    124 inline void realloc_storage(heap_allocator(T)* this, size_t size)
     79inline void realloc_storage(heap_allocator(T) *const this, size_t size)
    12580{
    12681        enum { GROWTH_RATE = 2 };
  • src/tests/libcfa_vector.c

    ra6fe3de r89e6ffc  
    1 //
     1// 
    22// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 //
    7 // libcfa_vector.c --
    8 //
     6// 
     7// libcfa_vector.c -- 
     8// 
    99// Author           : Thierry Delisle
    1010// Created On       : Mon Jul  4 23:36:19 2016
     
    1212// Last Modified On : Tue Jul  5 15:08:05 2016
    1313// Update Count     : 26
    14 //
     14// 
    1515
    1616#include <fstream>
     
    2828int main() {
    2929        vector( int, heap_allocator(int) ) iv;
     30        ctor( &iv );
    3031
    3132        assert( empty( &iv ) );
Note: See TracChangeset for help on using the changeset viewer.