Changeset 16cfd8c
- Timestamp:
- Apr 21, 2016, 4:54:33 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 8a74081
- Parents:
- 8c8b614
- Location:
- src/examples/gc_no_raii
- Files:
-
- 4 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
src/examples/gc_no_raii/src/allocate-pool.c
r8c8b614 r16cfd8c 2 2 #define _DARWIN_C_SOURCE /* for MAP_ANON on OS X */ 3 3 4 #ifdef __cforall 5 extern "C"{ 6 #else 7 #error missing cfa define 8 #endif 4 9 5 10 /* for standards info */ … … 24 29 #if _POSIX_VERSION 25 30 #include <sys/mman.h> 26 #endif27 28 #ifdef CFA29 extern "C"{30 31 #endif 31 32 … … 59 60 } 60 61 61 #ifdef CFA62 #ifdef __cforall 62 63 } 63 64 #endif -
src/examples/gc_no_raii/src/allocate-pool.h
r8c8b614 r16cfd8c 2 2 #define _GGGGC_ALlOCATE_POOL_H_ 3 3 4 #ifdef __c plusplus4 #ifdef __cforall 5 5 extern "C" { 6 6 #endif … … 8 8 void* pal_allocPool(size_t size, int mustSucceed); 9 9 10 #ifdef __c plusplus10 #ifdef __cforall 11 11 } 12 12 #endif -
src/examples/gc_no_raii/src/internal/collector.c
r8c8b614 r16cfd8c 1 1 #include "collector.h" 2 2 3 #i nclude <stdbool.h>4 #include <stdint.h> 5 # include <stdlib.h>3 #ifdef __cforall 4 extern "C" { 5 #endif 6 6 #include <string.h> 7 8 #include <fstream> 7 #ifdef __cforall 8 } 9 #endif 9 10 10 11 #include "state.h" … … 138 139 139 140 intptr_t* ref = &field->ptr; 140 //push_back(worklist, ref);141 push_back(worklist, ref); 141 142 142 143 field = field->next; -
src/examples/gc_no_raii/src/internal/collector.h
r8c8b614 r16cfd8c 1 1 #pragma once 2 2 3 #include <stddef.h> 4 #include <stdint.h> 3 #include <stdlib> 5 4 6 5 #include "tools.h" … … 14 13 #include "tools/worklist.h" 15 14 16 inline bool gc_is_managed(void* address)15 static inline bool gc_is_managed(void* address) 17 16 { 18 17 return gc_is_in_heap(gc_get_state(), address); 19 18 } 20 19 21 inline gc_object_header* gc_get_object_ptr(void* ptr)20 static inline gc_object_header* gc_get_object_ptr(void* ptr) 22 21 { 23 22 void* clean = gc_get_aligned_ptr(ptr); … … 25 24 } 26 25 27 inline struct gc_memory_pool* gc_pool_of(void* address)26 static inline struct gc_memory_pool* gc_pool_of(void* address) 28 27 { 29 28 return (struct gc_memory_pool*)(((intptr_t)address) & POOL_PTR_MASK); 30 29 } 31 30 32 inline void gc_conditional_collect()31 static inline void gc_conditional_collect() 33 32 { 34 33 if(gc_needs_collect(gc_get_state())) -
src/examples/gc_no_raii/src/internal/gc_tools.h
r8c8b614 r16cfd8c 7 7 #include "globals.h" 8 8 9 inline bool gc_is_aligned(void* address)9 static inline bool gc_is_aligned(void* address) 10 10 { 11 11 return (((intptr_t)address) & (~OBJECT_PTR_MASK)) == 0; 12 12 } 13 13 14 inline void* gc_get_aligned_ptr(void* address)14 static inline void* gc_get_aligned_ptr(void* address) 15 15 { 16 16 return (void*)(((intptr_t)address) & (OBJECT_PTR_MASK)); 17 17 } 18 18 19 inline void* gc_write_aligned_ptr(void** reference, void* address)19 static inline void* gc_write_aligned_ptr(void** reference, void* address) 20 20 { 21 21 size_t ref_last_bits = ((intptr_t)*reference) & (~OBJECT_PTR_MASK); … … 28 28 } 29 29 30 inline size_t gc_compute_size(size_t size)30 static inline size_t gc_compute_size(size_t size) 31 31 { 32 32 size_t word_size = ((size - 1) / OBJECT_ALLIGNMENT) + 1; -
src/examples/gc_no_raii/src/internal/memory_pool.h
r8c8b614 r16cfd8c 1 1 #pragma once 2 2 3 extern "C" { 4 #include <stdbool.h> 3 5 #include <stdint.h> 6 } 4 7 5 8 #include "tools.h" 6 9 7 // #include "card_table.h" 8 #include "collector.h" 10 #include "card_table.h" 9 11 #include "globals.h" 10 11 typedef int cardtable_ptr_t; 12 #include "state.h" 12 13 13 14 struct gc_memory_pool … … 18 19 uint8_t type_code; 19 20 20 card table_ptr_tcards;21 card_table_t* cards; 21 22 22 23 uint8_t* end_p; … … 25 26 }; 26 27 27 void gc_memory_pool_ctor(gc_memory_pool *const this,28 size_t size,29 gc_memory_pool* next,30 gc_memory_pool* mirror,31 28 void ctor( gc_memory_pool *const this, 29 size_t size, 30 gc_memory_pool* next, 31 gc_memory_pool* mirror, 32 uint8_t type 32 33 ); 34 35 void dtor(gc_memory_pool *const this); 33 36 34 37 struct gc_pool_object_iterator 35 38 { 36 37 39 struct gc_object_header* object; 38 40 #if _DEBUG … … 43 45 44 46 45 void gc_pool_object_iterator_ctor( 47 void ctor( 48 gc_pool_object_iterator* const this, 46 49 struct gc_object_header* start_object 47 50 #if _DEBUG … … 53 56 bool ?!=?(const gc_pool_object_iterator lhs, const gc_pool_object_iterator rhs); 54 57 55 gc_pool_object_iterator begin(gc_memory_pool* const );58 gc_pool_object_iterator begin(gc_memory_pool* const this); 56 59 gc_pool_object_iterator end(gc_memory_pool* const); 57 60 … … 61 64 struct gc_object_header* *?(gc_pool_object_iterator it); 62 65 63 inline bool gc_pool_is_from_space(const gc_memory_pool* pool)66 static inline bool gc_pool_is_from_space(const gc_memory_pool* pool) 64 67 { 65 68 return gc_from_space_code(gc_get_state()) == pool->type_code; 66 69 } 67 70 68 void gc_reset_pool(gc_memory_pool* pool);71 void gc_reset_pool(gc_memory_pool* const pool); 69 72 70 inline size_t gc_pool_size_used(const gc_memory_pool* pool)73 static inline size_t gc_pool_size_used(const gc_memory_pool* pool) 71 74 { 72 75 return pool->free_p - pool->start_p; 73 76 } 74 77 75 inline size_t gc_pool_size_total(const gc_memory_pool* pool)78 static inline size_t gc_pool_size_total(const gc_memory_pool* pool) 76 79 { 77 80 return pool->end_p - pool->start_p; 78 81 } 79 82 80 inline size_t gc_pool_size_left(const gc_memory_pool* pool)83 static inline size_t gc_pool_size_left(const gc_memory_pool* pool) 81 84 { 82 85 return pool->end_p - pool->free_p; 83 86 } 84 87 85 void* gc_pool_allocate(gc_memory_pool* pool, size_t size, bool zero);88 void* gc_pool_allocate(gc_memory_pool* const pool, size_t size, bool zero); 86 89 87 gc_pool_object_iterator gc_pool_iterator_for(gc_memory_pool* pool, void* member); 88 89 gc_pool_object_iterator gc_pool_end(gc_memory_pool* pool); 90 gc_pool_object_iterator gc_pool_iterator_for(gc_memory_pool* const pool, void* member); -
src/examples/gc_no_raii/src/internal/object_header.c
r8c8b614 r16cfd8c 6 6 #include "gcpointers.h" 7 7 8 placement_copy_ctor(void* address, const gc_object_header* const other)8 void ctor(gc_object_header* const this, size_t inSize) 9 9 { 10 gc_object_header* const this = (gc_object_header*)address;11 10 #if _DEBUG 12 11 this->canary_start = CANARY_VALUE; 13 12 #endif 13 14 this->size = inSize; 15 this->root_chain = NULL; 16 this->type_chain = NULL; 17 this->forward = NULL; 18 this->is_forwarded = false; 19 20 #if _DEBUG 21 this->canary_end = CANARY_VALUE; 22 #endif 23 } 24 25 void copy_ctor(gc_object_header* const this, const gc_object_header* const other) 26 { 27 #if _DEBUG 28 this->canary_start = CANARY_VALUE; 29 #endif 30 14 31 this->size = other->size; 15 32 this->root_chain = other->root_chain; … … 17 34 this->forward = NULL; 18 35 this->is_forwarded = false; 36 19 37 #if _DEBUG 20 38 this->canary_end = CANARY_VALUE; 21 39 #endif 40 41 gcpointer_t* root = this->root_chain; 42 while(root) 22 43 { 23 gcpointer_t* root = this->root_chain; 24 while(root) 25 { 26 check(get_object_ptr(root->ptr) == other); 27 intptr_t int_this = (intptr_t)this; 28 intptr_t int_next = int_this + sizeof(gc_object_header); 29 intptr_t* root_ptr = root->ptr; 30 *root_ptr = int_next; 44 check(get_object_ptr(root->ptr) == other); 45 root->ptr = ((intptr_t)this) + sizeof(gc_object_header); 31 46 32 33 34 47 check(get_object_ptr(root->ptr) == this); 48 root = root->next; 49 } 35 50 36 51 gcpointer_t* type = other->type_chain; 37 52 38 39 40 53 while(type) 54 { 55 check((intptr_t)type < (intptr_t)((intptr_t)other + other->size)); 41 56 42 43 57 size_t offset = (intptr_t)type - (intptr_t)other; 58 check(offset < size); 44 59 45 60 gcpointer_t* member_ptr = (gcpointer_t*)( (intptr_t)this + offset ); 46 61 47 62 if(!this->type_chain) this->type_chain = member_ptr; 48 63 49 50 64 size_t next_offset = type->next ? (intptr_t)type->next - (intptr_t)other : 0; 65 check(next_offset < size); 51 66 52 67 gcpointer_t* next_ptr = type->next ? (gcpointer_t*)((intptr_t)this + next_offset) : NULL; 53 68 54 55 69 member_ptr->ptr = type->ptr; 70 member_ptr->next = next_ptr; 56 71 57 58 72 type = type->next; 73 } 59 74 60 check(is_valide(this)); 61 } 75 check(is_valide(this)); 62 76 } 63 77 -
src/examples/gc_no_raii/src/internal/object_header.h
r8c8b614 r16cfd8c 30 30 }; 31 31 32 gc_object_header* placement_ctor(void* address, size_t size); 33 gc_object_header* placement_copy_ctor(void* address, const gc_object_header* const other); 32 void ctor(gc_object_header* const this, size_t size); 33 void copy_ctor(gc_object_header* const this, const gc_object_header* const other); 34 35 static inline gc_object_header* placement_ctor(void* address, size_t size) 36 { 37 gc_object_header* const this = (gc_object_header* const) address; 38 ctor(this, size); 39 return this; 40 } 41 42 static inline gc_object_header* placement_copy_ctor(void* address, const gc_object_header* const other) 43 { 44 gc_object_header* const this = (gc_object_header* const) address; 45 copy_ctor(this, other); 46 return this; 47 } -
src/examples/gc_no_raii/src/internal/state.c
r8c8b614 r16cfd8c 12 12 #include "globals.h" 13 13 #include "memory_pool.h" 14 // #include "memory_pool_iterator.h"15 14 #include "object_header.h" 16 15 … … 46 45 } 47 46 48 bool gc_state_is_in_heap(const gc_state* const this, void* address) 47 void dtor(gc_state *const this) 48 { 49 dtor(&this->pools_table); 50 this->is_initialized = false; 51 } 52 53 bool gc_is_in_heap(const gc_state* const this, const void* const address) 49 54 { 50 55 gc_memory_pool* target_pool = gc_pool_of(address); … … 56 61 } 57 62 58 bool gc_ state_is_in_to_space(const gc_state* const this, void*address)63 bool gc_is_in_to_space(const gc_state* const this, const void* const address) 59 64 { 60 65 gc_memory_pool* target_pool = gc_pool_of(address); … … 73 78 gc_memory_pool* pool = gc_pool_of(member); 74 79 gc_pool_object_iterator it = gc_pool_iterator_for(pool, member); 75 gc_pool_object_iterator end = gc_pool_end(pool);80 gc_pool_object_iterator end = end(pool); 76 81 77 82 while(it != end) … … 94 99 } 95 100 96 void* gc_try_allocate(gc_state *const this, size_t size)101 void* gc_try_allocate(gc_state* const this, size_t size) 97 102 { 98 103 gc_memory_pool* pool = this->from_space; … … 109 114 } 110 115 111 void gc_ state_allocate_pool(gc_state *const this)116 void gc_allocate_pool(gc_state *const this) 112 117 { 113 118 gc_memory_pool* old_from_space = this->from_space; … … 117 122 this->to_space = (gc_memory_pool*)(pal_allocPool(POOL_SIZE_BYTES, 1)); 118 123 119 gc_memory_pool_ctor(this->from_space, POOL_SIZE_BYTES, old_from_space, this->to_space, this->from_code);120 gc_memory_pool_ctor(this->to_space, POOL_SIZE_BYTES, old_to_space, this->from_space, (~this->from_code) & 0x01);124 ctor(this->from_space, POOL_SIZE_BYTES, old_from_space, this->to_space, this->from_code); 125 ctor(this->to_space, POOL_SIZE_BYTES, old_to_space, this->from_space, (~this->from_code) & 0x01); 121 126 122 127 this->total_space += gc_pool_size_used(this->from_space); … … 126 131 } 127 132 128 void gc_ state_collect(gc_state* const this)133 void gc_collect(gc_state* const this) 129 134 { 130 135 // DEBUG("collecting"); … … 149 154 gc_state_calc_usage(this); 150 155 151 if(gc_needs_collect(this)) gc_ state_allocate_pool(this);156 if(gc_needs_collect(this)) gc_allocate_pool(this); 152 157 153 158 // DEBUG("done"); … … 281 286 while(potential_ref < (void**)pool->m_free) 282 287 { 283 check(!gc_is_in_heap( *potential_ref));288 check(!gc_is_in_heap(this, *potential_ref)); 284 289 potential_ref++; 285 290 } -
src/examples/gc_no_raii/src/internal/state.h
r8c8b614 r16cfd8c 7 7 #include "vector.h" 8 8 9 typedef vector(struct gc_memory_pool*, heap_allocator(struct gc_memory_pool*)) pools_table_t;9 // typedef vector(struct gc_memory_pool*, heap_allocator(struct gc_memory_pool*)) pools_table_t; 10 10 11 11 struct gc_state … … 19 19 size_t used_space; 20 20 21 pools_table_t pools_table;21 // pools_table_t pools_table; 22 22 size_t pools_table_count; 23 23 }; 24 24 25 void ctor(struct gc_state* state); 25 void ctor(gc_state* const state); 26 27 void dtor(gc_state* const state); 26 28 27 29 gc_state* gc_get_state(); 28 30 29 inline bool gc_needs_collect(gc_state* state)31 static inline bool gc_needs_collect(gc_state* state) 30 32 { 31 33 return state->used_space * 2 > state->total_space; 32 34 } 33 35 34 void gc_collect(gc_state* state);36 void gc_collect(gc_state* const this); 35 37 36 void* gc_try_allocate(gc_state* state, size_t size);38 void* gc_try_allocate(gc_state* const this, size_t size); 37 39 38 void gc_allocate_pool(gc_state* state);40 void gc_allocate_pool(gc_state* const state); 39 41 40 bool gc_is_in_heap(const gc_state* state, void*address);42 bool gc_is_in_heap(const gc_state* const state, const void* const address); 41 43 42 bool gc_is_in_to_space(const gc_state* state, void*address);44 bool gc_is_in_to_space(const gc_state* const state, const void* const address); 43 45 44 inline uint8_t gc_from_space_code(const gc_state *const this)46 static inline uint8_t gc_from_space_code(const gc_state *const this) 45 47 { 46 48 return this->from_code; … … 49 51 struct gc_object_header* gc_get_object_for_ref(gc_state* state, void*); 50 52 51 inline void gc_register_allocation(gc_state* state, size_t size)53 static inline void gc_register_allocation(gc_state* state, size_t size) 52 54 { 53 55 state->used_space += size; -
src/examples/gc_no_raii/src/tools.h
r8c8b614 r16cfd8c 27 27 28 28 forall(otype T | has_equal(T), otype InputIterator | InputIterator_t(T, InputIterator)) 29 inline InputIterator find( InputIterator first, const InputIterator* const last, T val)29 static inline InputIterator find( InputIterator first, const InputIterator* const last, T val) 30 30 { 31 31 while ( first != *last) -
src/examples/gc_no_raii/src/vector.c
r8c8b614 r16cfd8c 1 1 #include "vector.h" 2 3 #include <stdlib> 2 4 3 5 //------------------------------------------------------------------------------ 4 6 //Initialization 5 7 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 6 void vector_ctor(vector(T, allocator_t) *const this)8 void ctor(vector(T, allocator_t) *const this) 7 9 { 8 10 ctor(&this->storage); … … 13 15 void dtor(vector(T, allocator_t) *const this) 14 16 { 17 clear(this); 15 18 dtor(&this->storage); 16 19 } … … 55 58 void dtor(heap_allocator(T) *const this) 56 59 { 57 free( (void*)this->storage);60 free(this->storage); 58 61 } 59 62 -
src/examples/gc_no_raii/src/vector.h
r8c8b614 r16cfd8c 1 1 #pragma once 2 2 3 #include <assert.h> 4 #include <stdbool.h> 5 #include <stddef.h> 6 #include <stdlib.h> 3 #include <stdlib> 7 4 8 5 #define DESTROY(x) … … 24 21 size_t size; 25 22 }; 26 27 //------------------------------------------------------------------------------ 28 //Initialization 29 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 30 void ctor(vector(T, allocator_t) *const this); 31 32 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 33 void dtor(vector(T, allocator_t) *const this); 34 35 //------------------------------------------------------------------------------ 36 //Capacity 37 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 38 inline bool empty(vector(T, allocator_t) *const this) 39 { 40 return this->size == 0; 41 } 42 43 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 44 inline bool size(vector(T, allocator_t) *const this) 45 { 46 return this->size; 47 } 48 49 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 50 inline void reserve(vector(T, allocator_t) *const this, size_t size) 51 { 52 realloc(&this->storage, this->size+1); 53 } 54 55 //------------------------------------------------------------------------------ 56 //Element access 57 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 58 inline T at(vector(T, allocator_t) *const this, size_t index) 59 { 60 // assert(index < this->size); 61 return data(&this->storage)[index]; 62 } 63 64 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 65 inline T ?[?](vector(T, allocator_t) *const this, size_t index) 66 { 67 return data(&this->storage)[index]; 68 } 69 70 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 71 inline T front(vector(T, allocator_t) *const this) 72 { 73 return data(&this->storage)[0]; 74 } 75 76 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 77 inline T back(vector(T, allocator_t) *const this) 78 { 79 return data(&this->storage)[this->size - 1]; 80 } 81 82 //------------------------------------------------------------------------------ 83 //Modifiers 84 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 85 void push_back(vector(T, allocator_t) *const this, T value); 86 87 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 88 void pop_back(vector(T, allocator_t) *const this); 89 90 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 91 void clear(vector(T, allocator_t) *const this); 92 93 //------------------------------------------------------------------------------ 94 //Iterators 95 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 96 inline T* begin(vector(T, allocator_t) *const this) 97 { 98 return data(&this->storage); 99 } 100 101 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 102 inline const T* cbegin(const vector(T, allocator_t) *const this) 103 { 104 return data(&this->storage); 105 } 106 107 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 108 inline T* end(vector(T, allocator_t) *const this) 109 { 110 return data(&this->storage) + this->size; 111 } 112 113 forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 114 inline const T* cend(const vector(T, allocator_t) *const this) 115 { 116 return data(&this->storage) + this->size; 117 } 118 119 //------------------------------------------------------------------------------ 120 //Allocator 121 forall(otype T) 122 struct heap_allocator 123 { 124 T* storage; 125 size_t capacity; 126 }; 127 128 forall(otype T) 129 void ctor(heap_allocator(T) *const this); 130 131 forall(otype T) 132 void dtor(heap_allocator(T) *const this); 133 134 forall(otype T) 135 void realloc(heap_allocator(T) *const this, size_t size); 136 137 forall(otype T) 138 inline T* data(heap_allocator(T) *const this) 139 { 140 return this->storage; 141 } 23 // 24 // //------------------------------------------------------------------------------ 25 // //Initialization 26 // forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 27 // void ctor(vector(T, allocator_t) *const this); 28 // 29 // forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 30 // void dtor(vector(T, allocator_t) *const this); 31 // 32 // //------------------------------------------------------------------------------ 33 // //Capacity 34 // forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 35 // static inline bool empty(vector(T, allocator_t) *const this) 36 // { 37 // return this->size == 0; 38 // } 39 // 40 // forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 41 // static inline bool size(vector(T, allocator_t) *const this) 42 // { 43 // return this->size; 44 // } 45 // 46 // forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 47 // static inline void reserve(vector(T, allocator_t) *const this, size_t size) 48 // { 49 // realloc(&this->storage, this->size+1); 50 // } 51 // 52 // //------------------------------------------------------------------------------ 53 // //Element access 54 // forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 55 // static inline T at(vector(T, allocator_t) *const this, size_t index) 56 // { 57 // return data(&this->storage)[index]; 58 // } 59 // 60 // forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 61 // static inline T ?[?](vector(T, allocator_t) *const this, size_t index) 62 // { 63 // return data(&this->storage)[index]; 64 // } 65 // 66 // forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 67 // static inline T front(vector(T, allocator_t) *const this) 68 // { 69 // return data(&this->storage)[0]; 70 // } 71 // 72 // forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 73 // static inline T back(vector(T, allocator_t) *const this) 74 // { 75 // return data(&this->storage)[this->size - 1]; 76 // } 77 // 78 // //------------------------------------------------------------------------------ 79 // //Modifiers 80 // forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 81 // void push_back(vector(T, allocator_t) *const this, T value); 82 // 83 // forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 84 // void pop_back(vector(T, allocator_t) *const this); 85 // 86 // forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 87 // void clear(vector(T, allocator_t) *const this); 88 // 89 // //------------------------------------------------------------------------------ 90 // //Iterators 91 // forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 92 // static inline T* begin(vector(T, allocator_t) *const this) 93 // { 94 // return data(&this->storage); 95 // } 96 // 97 // forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 98 // static inline const T* cbegin(const vector(T, allocator_t) *const this) 99 // { 100 // return data(&this->storage); 101 // } 102 // 103 // forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 104 // static inline T* end(vector(T, allocator_t) *const this) 105 // { 106 // return data(&this->storage) + this->size; 107 // } 108 // 109 // forall(otype T, otype allocator_t | allocator_c(T, allocator_t)) 110 // static inline const T* cend(const vector(T, allocator_t) *const this) 111 // { 112 // return data(&this->storage) + this->size; 113 // } 114 // 115 // //------------------------------------------------------------------------------ 116 // //Allocator 117 // forall(otype T) 118 // struct heap_allocator 119 // { 120 // T* storage; 121 // size_t capacity; 122 // }; 123 // 124 // forall(otype T) 125 // void ctor(heap_allocator(T) *const this); 126 // 127 // forall(otype T) 128 // void dtor(heap_allocator(T) *const this); 129 // 130 // forall(otype T) 131 // void realloc(heap_allocator(T) *const this, size_t size); 132 // 133 // forall(otype T) 134 // static inline T* data(heap_allocator(T) *const this) 135 // { 136 // return this->storage; 137 // }
Note: See TracChangeset
for help on using the changeset viewer.