Changes in pjproject/main/pjlib/src/pj/os_core_unix.c [3:1]
- 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. 2 14 * 3 15 */ … … 21 33 22 34 #define __USE_GNU 23 //uncomment this to get pthread_mutexattr_settype declaration.24 //unfortunately this causes syntax error in pthread.h! :(25 //#define __USE_UNIX9826 35 #include <pthread.h> 27 36 … … 166 175 #if PJ_HAS_THREADS 167 176 char stack_ptr; 168 pj_status_t rc;169 177 pj_thread_t *thread = (pj_thread_t *)desc; 170 178 pj_str_t thread_name = pj_str((char*)cstr_thread_name); … … 183 191 184 192 /* 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)); 186 194 thread->thread = pthread_self(); 187 195 … … 191 199 pj_sprintf(thread->obj_name, "thr%p", (void*)thread->thread); 192 200 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); 196 202 197 203 #if defined(PJ_OS_HAS_CHECK_STACK) && PJ_OS_HAS_CHECK_STACK!=0 … … 208 214 pj_thread_t *thread = (pj_thread_t*)desc; 209 215 *ptr_thread = thread; 210 return PJ_SUCCESS;216 return SUCCESS; 211 217 #endif 212 218 } … … 225 231 return rc; 226 232 } 227 return pj_thread_register("thr%p", ( long*)&main_thread, &dummy);233 return pj_thread_register("thr%p", (pj_uint8_t*)&main_thread, &dummy); 228 234 #else 229 235 PJ_LOG(2,(THIS_FILE, "Thread init error. Threading is not enabled!")); … … 242 248 pj_thread_t *rec = param; 243 249 void *result; 244 pj_status_t rc;245 250 246 251 #if defined(PJ_OS_HAS_CHECK_STACK) && PJ_OS_HAS_CHECK_STACK!=0 … … 249 254 250 255 /* 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); 255 257 256 258 /* Check if suspension is required. */ … … 658 660 * pj_thread_local_set() 659 661 */ 660 PJ_DEF( pj_status_t) pj_thread_local_set(long index, void *value)662 PJ_DEF(void) pj_thread_local_set(long index, void *value) 661 663 { 662 664 //Can't check stack because this function is called in the … … 664 666 //PJ_CHECK_STACK(); 665 667 #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); 668 669 #else 669 670 pj_assert(index >= 0 && index < MAX_THREADS); 670 671 tls[index] = value; 671 return PJ_SUCCESS;672 672 #endif 673 673 } … … 706 706 { 707 707 #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(); 714 711 715 712 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; 721 715 } 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; 736 718 } 737 719
Note: See TracChangeset
for help on using the changeset viewer.