Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/main/pjlib/src/pj/os_core_unix.c

    • Property svn:keywords deleted
    r3 r1  
    1 /* $Id$ 
     1/* $Header: /pjproject-0.3/pjlib/src/pj/os_core_unix.c 11    10/29/05 10:27p Bennylp $ */ 
     2/*  
     3 * $Log: /pjproject-0.3/pjlib/src/pj/os_core_unix.c $  
     4 *  
     5 * 11    10/29/05 10:27p Bennylp 
     6 * Fixed misc warnings. 
     7 *  
     8 * 10    10/29/05 11:51a Bennylp 
     9 * Version 0.3-pre2. 
     10 *  
     11 * 9     10/14/05 12:26a Bennylp 
     12 * Finished error code framework, some fixes in ioqueue, etc. Pretty 
     13 * major. 
    214 * 
    315 */ 
     
    2133 
    2234#define __USE_GNU 
    23 //uncomment this to get pthread_mutexattr_settype declaration. 
    24 //unfortunately this causes syntax error in pthread.h! :( 
    25 //#define __USE_UNIX98 
    2635#include <pthread.h> 
    2736 
     
    166175#if PJ_HAS_THREADS 
    167176    char stack_ptr; 
    168     pj_status_t rc; 
    169177    pj_thread_t *thread = (pj_thread_t *)desc; 
    170178    pj_str_t thread_name = pj_str((char*)cstr_thread_name); 
     
    183191 
    184192    /* Initialize and set the thread entry. */ 
    185     pj_memset(desc, 0, sizeof(struct pj_thread_t)); 
     193    pj_memset(desc, 0, sizeof(pj_thread_desc)); 
    186194    thread->thread = pthread_self(); 
    187195 
     
    191199        pj_sprintf(thread->obj_name, "thr%p", (void*)thread->thread); 
    192200     
    193     rc = pj_thread_local_set(thread_tls_id, thread); 
    194     if (rc != PJ_SUCCESS) 
    195         return rc; 
     201    pj_thread_local_set(thread_tls_id, thread); 
    196202 
    197203#if defined(PJ_OS_HAS_CHECK_STACK) && PJ_OS_HAS_CHECK_STACK!=0 
     
    208214    pj_thread_t *thread = (pj_thread_t*)desc; 
    209215    *ptr_thread = thread; 
    210     return PJ_SUCCESS; 
     216    return SUCCESS; 
    211217#endif 
    212218} 
     
    225231        return rc; 
    226232    } 
    227     return pj_thread_register("thr%p", (long*)&main_thread, &dummy); 
     233    return pj_thread_register("thr%p", (pj_uint8_t*)&main_thread, &dummy); 
    228234#else 
    229235    PJ_LOG(2,(THIS_FILE, "Thread init error. Threading is not enabled!")); 
     
    242248    pj_thread_t *rec = param; 
    243249    void *result; 
    244     pj_status_t rc; 
    245250 
    246251#if defined(PJ_OS_HAS_CHECK_STACK) && PJ_OS_HAS_CHECK_STACK!=0 
     
    249254 
    250255    /* Set current thread id. */ 
    251     rc = pj_thread_local_set(thread_tls_id, rec); 
    252     if (rc != PJ_SUCCESS) { 
    253         pj_assert(!"Thread TLS ID is not set (pj_init() error?)"); 
    254     } 
     256    pj_thread_local_set(thread_tls_id, rec); 
    255257 
    256258    /* Check if suspension is required. */ 
     
    658660 * pj_thread_local_set() 
    659661 */ 
    660 PJ_DEF(pj_status_t) pj_thread_local_set(long index, void *value) 
     662PJ_DEF(void) pj_thread_local_set(long index, void *value) 
    661663{ 
    662664    //Can't check stack because this function is called in the 
     
    664666    //PJ_CHECK_STACK(); 
    665667#if PJ_HAS_THREADS 
    666     int rc=pthread_setspecific(index, value); 
    667     return rc==0 ? PJ_SUCCESS : PJ_RETURN_OS_ERROR(rc); 
     668    pthread_setspecific(index, value); 
    668669#else 
    669670    pj_assert(index >= 0 && index < MAX_THREADS); 
    670671    tls[index] = value; 
    671     return PJ_SUCCESS; 
    672672#endif 
    673673} 
     
    706706{ 
    707707#if PJ_HAS_THREADS 
    708     pthread_mutexattr_t attr; 
    709     int rc; 
    710  
    711     PJ_CHECK_STACK(); 
    712  
    713     pthread_mutexattr_init(&attr); 
     708    PJ_UNUSED_ARG(type); 
     709 
     710    PJ_CHECK_STACK(); 
    714711 
    715712    if (type == PJ_MUTEX_SIMPLE) { 
    716 #if defined(PJ_LINUX) && PJ_LINUX!=0 
    717         rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_FAST_NP); 
    718 #else 
    719         rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL); 
    720 #endif 
     713        pthread_mutex_t the_mutex = PTHREAD_MUTEX_INITIALIZER; 
     714        mutex->mutex = the_mutex; 
    721715    } else { 
    722 #if defined(PJ_LINUX) && PJ_LINUX!=0 
    723         rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP); 
    724 #else 
    725         rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); 
    726 #endif 
    727     } 
    728      
    729     if (rc != 0) { 
    730         return PJ_RETURN_OS_ERROR(rc); 
    731     } 
    732  
    733     rc = pthread_mutex_init(&mutex->mutex, &attr); 
    734     if (rc != 0) { 
    735         return PJ_RETURN_OS_ERROR(rc); 
     716        pthread_mutex_t the_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; 
     717        mutex->mutex = the_mutex; 
    736718    } 
    737719     
Note: See TracChangeset for help on using the changeset viewer.