Ignore:
File:
1 edited

Legend:

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

    r5614a191 r09ae8a6  
    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         extern size_t __cfa_page_size;
    125         extern int __map_prot;
    126 }
     124}
     125
     126extern size_t __page_size;
     127extern int __map_prot;
    127128
    128129//-----------------------------------------------------------------------------
     
    573574}
    574575
     576extern size_t __page_size;
    575577void ^?{}(processor & this) with( this ){
    576578        /* paranoid */ verify( !__atomic_load_n(&do_terminate, __ATOMIC_ACQUIRE) );
     
    734736        check( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute
    735737
    736         size_t stacksize = DEFAULT_STACK_SIZE;
     738        size_t stacksize = max( PTHREAD_STACK_MIN, DEFAULT_STACK_SIZE );
    737739
    738740        void * stack;
    739741        #if CFA_PROCESSOR_USE_MMAP
    740                 stacksize = ceiling( stacksize, __cfa_page_size ) + __cfa_page_size;
     742                stacksize = ceiling( stacksize, __page_size ) + __page_size;
    741743                stack = mmap(0p, stacksize, __map_prot, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
    742744                if(stack == ((void*)-1)) {
    743745                        abort( "pthread stack creation : internal error, mmap failure, error(%d) %s.", errno, strerror( errno ) );
    744746                }
    745                 if ( mprotect( stack, __cfa_page_size, PROT_NONE ) == -1 ) {
     747                if ( mprotect( stack, __page_size, PROT_NONE ) == -1 ) {
    746748                        abort( "pthread stack creation : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );
    747749                } // if
    748750        #else
    749751                __cfaabi_dbg_debug_do(
    750                         stack = memalign( __cfa_page_size, stacksize + __cfa_page_size );
     752                        stack = memalign( __page_size, stacksize + __page_size );
    751753                        // pthread has no mechanism to create the guard page in user supplied stack.
    752                         if ( mprotect( stack, __cfa_page_size, PROT_NONE ) == -1 ) {
     754                        if ( mprotect( stack, __page_size, PROT_NONE ) == -1 ) {
    753755                                abort( "mprotect : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );
    754756                        } // if
     
    777779                check( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" );
    778780                assert( stacksize >= PTHREAD_STACK_MIN );
    779                 stacksize += __cfa_page_size;
     781                stacksize += __page_size;
    780782
    781783                if(munmap(stack, stacksize) == -1) {
     
    785787                __cfaabi_dbg_debug_do(
    786788                        // pthread has no mechanism to create the guard page in user supplied stack.
    787                         if ( mprotect( stack, __cfa_page_size, __map_prot ) == -1 ) {
     789                        if ( mprotect( stack, __page_size, __map_prot ) == -1 ) {
    788790                                abort( "mprotect : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );
    789791                        } // if
Note: See TracChangeset for help on using the changeset viewer.