Changes in pjproject/main/pjlib/src/pj/os_core_unix.c [1:3]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/main/pjlib/src/pj/os_core_unix.c
- Property svn:keywords set to Author
r1 r3 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. 1 /* $Id$ 14 2 * 15 3 */ … … 33 21 34 22 #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 35 26 #include <pthread.h> 36 27 … … 175 166 #if PJ_HAS_THREADS 176 167 char stack_ptr; 168 pj_status_t rc; 177 169 pj_thread_t *thread = (pj_thread_t *)desc; 178 170 pj_str_t thread_name = pj_str((char*)cstr_thread_name); … … 191 183 192 184 /* Initialize and set the thread entry. */ 193 pj_memset(desc, 0, sizeof( pj_thread_desc));185 pj_memset(desc, 0, sizeof(struct pj_thread_t)); 194 186 thread->thread = pthread_self(); 195 187 … … 199 191 pj_sprintf(thread->obj_name, "thr%p", (void*)thread->thread); 200 192 201 pj_thread_local_set(thread_tls_id, thread); 193 rc = pj_thread_local_set(thread_tls_id, thread); 194 if (rc != PJ_SUCCESS) 195 return rc; 202 196 203 197 #if defined(PJ_OS_HAS_CHECK_STACK) && PJ_OS_HAS_CHECK_STACK!=0 … … 214 208 pj_thread_t *thread = (pj_thread_t*)desc; 215 209 *ptr_thread = thread; 216 return SUCCESS;210 return PJ_SUCCESS; 217 211 #endif 218 212 } … … 231 225 return rc; 232 226 } 233 return pj_thread_register("thr%p", ( pj_uint8_t*)&main_thread, &dummy);227 return pj_thread_register("thr%p", (long*)&main_thread, &dummy); 234 228 #else 235 229 PJ_LOG(2,(THIS_FILE, "Thread init error. Threading is not enabled!")); … … 248 242 pj_thread_t *rec = param; 249 243 void *result; 244 pj_status_t rc; 250 245 251 246 #if defined(PJ_OS_HAS_CHECK_STACK) && PJ_OS_HAS_CHECK_STACK!=0 … … 254 249 255 250 /* Set current thread id. */ 256 pj_thread_local_set(thread_tls_id, rec); 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 } 257 255 258 256 /* Check if suspension is required. */ … … 660 658 * pj_thread_local_set() 661 659 */ 662 PJ_DEF( void) pj_thread_local_set(long index, void *value)660 PJ_DEF(pj_status_t) pj_thread_local_set(long index, void *value) 663 661 { 664 662 //Can't check stack because this function is called in the … … 666 664 //PJ_CHECK_STACK(); 667 665 #if PJ_HAS_THREADS 668 pthread_setspecific(index, value); 666 int rc=pthread_setspecific(index, value); 667 return rc==0 ? PJ_SUCCESS : PJ_RETURN_OS_ERROR(rc); 669 668 #else 670 669 pj_assert(index >= 0 && index < MAX_THREADS); 671 670 tls[index] = value; 671 return PJ_SUCCESS; 672 672 #endif 673 673 } … … 706 706 { 707 707 #if PJ_HAS_THREADS 708 PJ_UNUSED_ARG(type); 709 710 PJ_CHECK_STACK(); 708 pthread_mutexattr_t attr; 709 int rc; 710 711 PJ_CHECK_STACK(); 712 713 pthread_mutexattr_init(&attr); 711 714 712 715 if (type == PJ_MUTEX_SIMPLE) { 713 pthread_mutex_t the_mutex = PTHREAD_MUTEX_INITIALIZER; 714 mutex->mutex = the_mutex; 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 715 721 } else { 716 pthread_mutex_t the_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; 717 mutex->mutex = the_mutex; 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); 718 736 } 719 737
Note: See TracChangeset
for help on using the changeset viewer.