Ticket #8233: pthreadpatch10.12.2011.patch

File pthreadpatch10.12.2011.patch, 3.3 KB (added by unitedroad, 9 years ago)

patch for pthread_attr_getguardsize

  • headers/posix/pthread.h

    diff --git a/headers/posix/pthread.h b/headers/posix/pthread.h
    index cc5b900..b62bbd7 100644
    a b extern int pthread_attr_getschedparam(const pthread_attr_t *attr,  
    185185extern int pthread_attr_setschedparam(pthread_attr_t *attr,
    186186    const struct sched_param *param);
    187187
     188extern int pthread_attr_getguardsize(const pthread_attr_t *attr,
     189    size_t *guardsize);
     190
    188191#if 0   /* Unimplemented attribute functions: */
    189192
    190193/* [TPS] */
    extern int pthread_attr_getschedpolicy(const pthread_attr_t *attr,  
    197200extern int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy);
    198201
    199202/* [XSI] */
    200 extern int pthread_attr_getguardsize(const pthread_attr_t *attr,
    201     size_t *guardsize);
     203
    202204extern int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize);
    203205
    204206/* [TSA] */
  • headers/private/libroot/pthread_private.h

    diff --git a/headers/private/libroot/pthread_private.h b/headers/private/libroot/pthread_private.h
    index f50bd28..1ddc00c 100644
    a b typedef struct _pthread_attr {  
    4040    int32       detach_state;
    4141    int32       sched_priority;
    4242    size_t      stack_size;
     43    size_t      guard_size;
    4344} pthread_attr;
    4445
    4546typedef struct _pthread_rwlockattr {
  • headers/private/system/thread_defs.h

    diff --git a/headers/private/system/thread_defs.h b/headers/private/system/thread_defs.h
    index 9f1b527..5d43c90 100644
    a b struct thread_creation_attributes {  
    5050    void*       args2;
    5151    void*       stack_address;
    5252    size_t      stack_size;
     53    size_t      guard_size;
    5354    pthread_t   pthread;
    5455    uint32      flags;
    5556};
  • src/system/libroot/posix/pthread/pthread.cpp

    diff --git a/src/system/libroot/posix/pthread/pthread.cpp b/src/system/libroot/posix/pthread/pthread.cpp
    index 4c5104a..db03fd8 100644
    a b __pthread_init_creation_attributes(const pthread_attr_t* pthreadAttributes,  
    119119    attributes->stack_size = attr->stack_size;
    120120    attributes->pthread = thread;
    121121    attributes->flags = 0;
     122    attributes->guard_size = attr->guard_size;
    122123
    123124    if (thread != NULL && attr->detach_state == PTHREAD_CREATE_DETACHED)
    124125        thread->flags |= THREAD_DETACHED;
    get_pthread_thread_id(pthread_t thread)  
    295296{
    296297    return thread->id;
    297298}
     299
     300int thread_attr_getguardsize(const pthread_attr_t *attr,
     301    size_t *guardsize)
     302{
     303    *guardsize=USER_STACK_SIZE*B_PAGE_SIZE;
     304    return 0;
     305}
  • src/system/libroot/posix/pthread/pthread_attr.c

    diff --git a/src/system/libroot/posix/pthread/pthread_attr.c b/src/system/libroot/posix/pthread/pthread_attr.c
    index 3054690..9d16698 100644
    a b pthread_attr_init(pthread_attr_t *_attr)  
    3030    attr->detach_state = PTHREAD_CREATE_JOINABLE;
    3131    attr->sched_priority = B_NORMAL_PRIORITY;
    3232    attr->stack_size = USER_STACK_SIZE;
     33    attr->guard_size = USER_STACK_GUARD_PAGES * PAGE_SIZE;
    3334
    3435    *_attr = attr;
    3536    return B_OK;
    pthread_attr_setstacksize(pthread_attr_t *_attr, size_t stacksize)  
    112113    return 0;
    113114}
    114115
     116int
     117pthread_attr_getguardsize(const pthread_attr_t *_attr, size_t *guardsize)
     118{
     119    pthread_attr *attr;
     120
     121    if (_attr == NULL || (attr = *_attr) == NULL)
     122        return B_BAD_VALUE;
     123
     124    *guardsize = attr->guard_size;
     125
     126    return 0;
     127}
    115128
    116129int
    117130pthread_attr_getscope(const pthread_attr_t *attr, int *contentionScope)