Changeset 5614a191
- Timestamp:
- Feb 17, 2022, 12:56:46 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- 8ee163e2
- Parents:
- 3263e2a4
- Location:
- libcfa/src
- Files:
-
- 2 added
- 2 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/Makefile.am
r3263e2a4 r5614a191 72 72 common.hfa \ 73 73 fstream.hfa \ 74 heap.hfa \75 74 iostream.hfa \ 76 75 iterator.hfa \ … … 102 101 startup.hfa \ 103 102 virtual.c \ 104 virtual.h 103 virtual.h \ 104 heap.cc \ 105 heap.h 105 106 106 107 # not all platforms support concurrency, add option do disable it … … 172 173 173 174 -include $(libdeps) 175 -include $(DEPDIR)/heap.Plo 174 176 175 177 thread_libdeps = $(join \ -
libcfa/src/concurrency/coroutine.cfa
r3263e2a4 r5614a191 85 85 // minimum feasible stack size in bytes 86 86 static const size_t MinStackSize = 1000; 87 extern size_t __page_size; // architecture pagesize HACK, should go in proper runtime singleton 88 extern int __map_prot; 87 88 extern "C" { 89 extern size_t __cfa_page_size; // architecture pagesize HACK, should go in proper runtime singleton 90 extern int __map_prot; 91 } 89 92 90 93 void __stack_prepare( __stack_info_t * this, size_t create_size ); … … 157 160 [void *, size_t] __stack_alloc( size_t storageSize ) { 158 161 const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment 159 assert(__ page_size != 0l);162 assert(__cfa_page_size != 0l); 160 163 size_t size = libCeiling( storageSize, 16 ) + stack_data_size; 161 size = ceiling(size, __ page_size);164 size = ceiling(size, __cfa_page_size); 162 165 163 166 // If we are running debug, we also need to allocate a guardpage to catch stack overflows. 164 167 void * storage; 165 168 #if CFA_COROUTINE_USE_MMAP 166 storage = mmap(0p, size + __ page_size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);169 storage = mmap(0p, size + __cfa_page_size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); 167 170 if(storage == ((void*)-1)) { 168 171 abort( "coroutine stack creation : internal error, mmap failure, error(%d) %s.", errno, strerror( errno ) ); 169 172 } 170 if ( mprotect( storage, __ page_size, PROT_NONE ) == -1 ) {173 if ( mprotect( storage, __cfa_page_size, PROT_NONE ) == -1 ) { 171 174 abort( "coroutine stack creation : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) ); 172 175 } // if 173 storage = (void *)(((intptr_t)storage) + __ page_size);176 storage = (void *)(((intptr_t)storage) + __cfa_page_size); 174 177 #else 175 178 __cfaabi_dbg_debug_do( 176 storage = memalign( __ page_size, size + __page_size );179 storage = memalign( __cfa_page_size, size + __cfa_page_size ); 177 180 ); 178 181 __cfaabi_dbg_no_debug_do( … … 181 184 182 185 __cfaabi_dbg_debug_do( 183 if ( mprotect( storage, __ page_size, PROT_NONE ) == -1 ) {186 if ( mprotect( storage, __cfa_page_size, PROT_NONE ) == -1 ) { 184 187 abort( "__stack_alloc : internal error, mprotect failure, error(%d) %s.", (int)errno, strerror( (int)errno ) ); 185 188 } 186 storage = (void *)(((intptr_t)storage) + __ page_size);189 storage = (void *)(((intptr_t)storage) + __cfa_page_size); 187 190 ); 188 191 #endif … … 198 201 #if CFA_COROUTINE_USE_MMAP 199 202 size_t size = ((intptr_t)this->storage->base) - ((intptr_t)this->storage->limit) + sizeof(__stack_t); 200 storage = (void *)(((intptr_t)storage) - __ page_size);201 if(munmap(storage, size + __ page_size) == -1) {203 storage = (void *)(((intptr_t)storage) - __cfa_page_size); 204 if(munmap(storage, size + __cfa_page_size) == -1) { 202 205 abort( "coroutine stack destruction : internal error, munmap failure, error(%d) %s.", errno, strerror( errno ) ); 203 206 } 204 207 #else 205 208 __cfaabi_dbg_debug_do( 206 storage = (char*)(storage) - __ page_size;207 if ( mprotect( storage, __ page_size, __map_prot ) == -1 ) {209 storage = (char*)(storage) - __cfa_page_size; 210 if ( mprotect( storage, __cfa_page_size, __map_prot ) == -1 ) { 208 211 abort( "(coStack_t *)%p.^?{}() : internal error, mprotect failure, error(%d) %s.", &this, errno, strerror( errno ) ); 209 212 } -
libcfa/src/concurrency/kernel/startup.cfa
r3263e2a4 r5614a191 122 122 extern "C" { 123 123 struct { __dllist_t(cluster) list; __spinlock_t lock; } __cfa_dbg_global_clusters; 124 } 125 126 extern size_t __page_size; 127 extern int __map_prot; 124 extern size_t __cfa_page_size; 125 extern int __map_prot; 126 } 128 127 129 128 //----------------------------------------------------------------------------- … … 574 573 } 575 574 576 extern size_t __page_size;577 575 void ^?{}(processor & this) with( this ){ 578 576 /* paranoid */ verify( !__atomic_load_n(&do_terminate, __ATOMIC_ACQUIRE) ); … … 740 738 void * stack; 741 739 #if CFA_PROCESSOR_USE_MMAP 742 stacksize = ceiling( stacksize, __ page_size ) + __page_size;740 stacksize = ceiling( stacksize, __cfa_page_size ) + __cfa_page_size; 743 741 stack = mmap(0p, stacksize, __map_prot, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); 744 742 if(stack == ((void*)-1)) { 745 743 abort( "pthread stack creation : internal error, mmap failure, error(%d) %s.", errno, strerror( errno ) ); 746 744 } 747 if ( mprotect( stack, __ page_size, PROT_NONE ) == -1 ) {745 if ( mprotect( stack, __cfa_page_size, PROT_NONE ) == -1 ) { 748 746 abort( "pthread stack creation : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) ); 749 747 } // if 750 748 #else 751 749 __cfaabi_dbg_debug_do( 752 stack = memalign( __ page_size, stacksize + __page_size );750 stack = memalign( __cfa_page_size, stacksize + __cfa_page_size ); 753 751 // pthread has no mechanism to create the guard page in user supplied stack. 754 if ( mprotect( stack, __ page_size, PROT_NONE ) == -1 ) {752 if ( mprotect( stack, __cfa_page_size, PROT_NONE ) == -1 ) { 755 753 abort( "mprotect : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) ); 756 754 } // if … … 779 777 check( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" ); 780 778 assert( stacksize >= PTHREAD_STACK_MIN ); 781 stacksize += __ page_size;779 stacksize += __cfa_page_size; 782 780 783 781 if(munmap(stack, stacksize) == -1) { … … 787 785 __cfaabi_dbg_debug_do( 788 786 // pthread has no mechanism to create the guard page in user supplied stack. 789 if ( mprotect( stack, __ page_size, __map_prot ) == -1 ) {787 if ( mprotect( stack, __cfa_page_size, __map_prot ) == -1 ) { 790 788 abort( "mprotect : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) ); 791 789 } // if -
libcfa/src/startup.cfa
r3263e2a4 r5614a191 27 27 void __cfaabi_appready_startup( void ) { 28 28 tzset(); // initialize time global variables 29 #ifdef __CFA_DEBUG__ 29 #ifdef __CFA_DEBUG__FIXME 30 30 extern void heapAppStart(); 31 31 heapAppStart(); 32 #endif // __CFA_DEBUG__ 32 #endif // __CFA_DEBUG__FIXME 33 33 } // __cfaabi_appready_startup 34 34 35 35 void __cfaabi_appready_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_APPREADY ) )); 36 36 void __cfaabi_appready_shutdown( void ) { 37 #ifdef __CFA_DEBUG__ 37 #ifdef __CFA_DEBUG__FIXME 38 38 extern void heapAppStop(); 39 39 heapAppStop(); 40 #endif // __CFA_DEBUG__ 40 #endif // __CFA_DEBUG__FIXME 41 41 } // __cfaabi_appready_shutdown 42 42 -
libcfa/src/stdhdr/malloc.h
r3263e2a4 r5614a191 18 18 } // extern "C" 19 19 20 #include <heap.h fa>20 #include <heap.h> 21 21 22 22 // Local Variables: // -
libcfa/src/stdlib.hfa
r3263e2a4 r5614a191 21 21 22 22 #include <stdlib.h> // *alloc, strto*, ato* 23 #include <heap.h fa>23 #include <heap.h> 24 24 25 25
Note: See TracChangeset
for help on using the changeset viewer.