Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/kernel/startup.cfa

    r09ae8a6 r5614a191  
    1818
    1919// C Includes
    20 #include <errno.h>                                      // errno
     20#include <errno.h>                                                                              // errno
    2121#include <signal.h>
    22 #include <string.h>                                     // strerror
    23 #include <unistd.h>                                     // sysconf
     22#include <string.h>                                                                             // strerror
     23#include <unistd.h>                                                                             // sysconf
    2424
    2525extern "C" {
    26         #include <limits.h>                             // PTHREAD_STACK_MIN
    27         #include <unistd.h>                             // syscall
    28         #include <sys/eventfd.h>                        // eventfd
    29         #include <sys/mman.h>                           // mprotect
    30         #include <sys/resource.h>                       // getrlimit
     26        #include <limits.h>                                                                     // PTHREAD_STACK_MIN
     27        #include <unistd.h>                                                                     // syscall
     28        #include <sys/eventfd.h>                                                        // eventfd
     29        #include <sys/mman.h>                                                           // mprotect
     30        #include <sys/resource.h>                                                       // getrlimit
    3131}
    3232
    3333// CFA Includes
    3434#include "kernel_private.hfa"
    35 #include "startup.hfa"                                  // STARTUP_PRIORITY_XXX
     35#include "startup.hfa"                                                                  // STARTUP_PRIORITY_XXX
    3636#include "limits.hfa"
    3737#include "math.hfa"
     
    122122extern "C" {
    123123        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}
    128127
    129128//-----------------------------------------------------------------------------
     
    574573}
    575574
    576 extern size_t __page_size;
    577575void ^?{}(processor & this) with( this ){
    578576        /* paranoid */ verify( !__atomic_load_n(&do_terminate, __ATOMIC_ACQUIRE) );
     
    736734        check( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute
    737735
    738         size_t stacksize = max( PTHREAD_STACK_MIN, DEFAULT_STACK_SIZE );
     736        size_t stacksize = DEFAULT_STACK_SIZE;
    739737
    740738        void * stack;
    741739        #if CFA_PROCESSOR_USE_MMAP
    742                 stacksize = ceiling( stacksize, __page_size ) + __page_size;
     740                stacksize = ceiling( stacksize, __cfa_page_size ) + __cfa_page_size;
    743741                stack = mmap(0p, stacksize, __map_prot, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
    744742                if(stack == ((void*)-1)) {
    745743                        abort( "pthread stack creation : internal error, mmap failure, error(%d) %s.", errno, strerror( errno ) );
    746744                }
    747                 if ( mprotect( stack, __page_size, PROT_NONE ) == -1 ) {
     745                if ( mprotect( stack, __cfa_page_size, PROT_NONE ) == -1 ) {
    748746                        abort( "pthread stack creation : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );
    749747                } // if
    750748        #else
    751749                __cfaabi_dbg_debug_do(
    752                         stack = memalign( __page_size, stacksize + __page_size );
     750                        stack = memalign( __cfa_page_size, stacksize + __cfa_page_size );
    753751                        // 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 ) {
    755753                                abort( "mprotect : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );
    756754                        } // if
     
    779777                check( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" );
    780778                assert( stacksize >= PTHREAD_STACK_MIN );
    781                 stacksize += __page_size;
     779                stacksize += __cfa_page_size;
    782780
    783781                if(munmap(stack, stacksize) == -1) {
     
    787785                __cfaabi_dbg_debug_do(
    788786                        // 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 ) {
    790788                                abort( "mprotect : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );
    791789                        } // if
Note: See TracChangeset for help on using the changeset viewer.