| OLD | NEW |
| 1 /** | 1 /** |
| 2 * threads.c: set of generic threading related routines | 2 * threads.c: set of generic threading related routines |
| 3 * | 3 * |
| 4 * See Copyright for the status of this software. | 4 * See Copyright for the status of this software. |
| 5 * | 5 * |
| 6 * Gary Pennington <Gary.Pennington@uk.sun.com> | 6 * Gary Pennington <Gary.Pennington@uk.sun.com> |
| 7 * daniel@veillard.com | 7 * daniel@veillard.com |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 #define IN_LIBXML | 10 #define IN_LIBXML |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 #if defined(SOLARIS) | 41 #if defined(SOLARIS) |
| 42 #include <note.h> | 42 #include <note.h> |
| 43 #endif | 43 #endif |
| 44 | 44 |
| 45 /* #define DEBUG_THREADS */ | 45 /* #define DEBUG_THREADS */ |
| 46 | 46 |
| 47 #ifdef HAVE_PTHREAD_H | 47 #ifdef HAVE_PTHREAD_H |
| 48 | 48 |
| 49 static int libxml_is_threaded = -1; | 49 static int libxml_is_threaded = -1; |
| 50 #ifdef __GNUC__ | 50 #if defined(__GNUC__) && defined(__GLIBC__) |
| 51 #ifdef linux | 51 #ifdef linux |
| 52 #if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (__GNUC__ > 3) | 52 #if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (__GNUC__ > 3) |
| 53 extern int pthread_once (pthread_once_t *__once_control, | 53 extern int pthread_once (pthread_once_t *__once_control, |
| 54 void (*__init_routine) (void)) | 54 void (*__init_routine) (void)) |
| 55 __attribute((weak)); | 55 __attribute((weak)); |
| 56 extern void *pthread_getspecific (pthread_key_t __key) | 56 extern void *pthread_getspecific (pthread_key_t __key) |
| 57 __attribute((weak)); | 57 __attribute((weak)); |
| 58 extern int pthread_setspecific (pthread_key_t __key, | 58 extern int pthread_setspecific (pthread_key_t __key, |
| 59 __const void *__pointer) | 59 __const void *__pointer) |
| 60 __attribute((weak)); | 60 __attribute((weak)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 82 extern pthread_t pthread_self () | 82 extern pthread_t pthread_self () |
| 83 __attribute((weak)); | 83 __attribute((weak)); |
| 84 extern int pthread_key_create () | 84 extern int pthread_key_create () |
| 85 __attribute((weak)); | 85 __attribute((weak)); |
| 86 extern int pthread_key_delete () | 86 extern int pthread_key_delete () |
| 87 __attribute((weak)); | 87 __attribute((weak)); |
| 88 extern int pthread_cond_signal () | 88 extern int pthread_cond_signal () |
| 89 __attribute((weak)); | 89 __attribute((weak)); |
| 90 #endif | 90 #endif |
| 91 #endif /* linux */ | 91 #endif /* linux */ |
| 92 #endif /* __GNUC__ */ | 92 #endif /* defined(__GNUC__) && defined(__GLIBC__) */ |
| 93 #endif /* HAVE_PTHREAD_H */ | 93 #endif /* HAVE_PTHREAD_H */ |
| 94 | 94 |
| 95 /* | 95 /* |
| 96 * TODO: this module still uses malloc/free and not xmlMalloc/xmlFree | 96 * TODO: this module still uses malloc/free and not xmlMalloc/xmlFree |
| 97 * to avoid some crazyness since xmlMalloc/xmlFree may actually | 97 * to avoid some crazyness since xmlMalloc/xmlFree may actually |
| 98 * be hosted on allocated blocks needing them for the allocation ... | 98 * be hosted on allocated blocks needing them for the allocation ... |
| 99 */ | 99 */ |
| 100 | 100 |
| 101 /* | 101 /* |
| 102 * xmlMutex are a simple mutual exception locks | 102 * xmlMutex are a simple mutual exception locks |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 pthread_mutex_lock(&tok->lock); | 408 pthread_mutex_lock(&tok->lock); |
| 409 tok->held--; | 409 tok->held--; |
| 410 if (tok->held == 0) { | 410 if (tok->held == 0) { |
| 411 if (tok->waiters) | 411 if (tok->waiters) |
| 412 pthread_cond_signal(&tok->cv); | 412 pthread_cond_signal(&tok->cv); |
| 413 memset(&tok->tid, 0, sizeof(tok->tid)); | 413 memset(&tok->tid, 0, sizeof(tok->tid)); |
| 414 } | 414 } |
| 415 pthread_mutex_unlock(&tok->lock); | 415 pthread_mutex_unlock(&tok->lock); |
| 416 #elif defined HAVE_WIN32_THREADS | 416 #elif defined HAVE_WIN32_THREADS |
| 417 if (tok->count > 0) { | 417 if (tok->count > 0) { |
| 418 tok->count--; |
| 418 LeaveCriticalSection(&tok->cs); | 419 LeaveCriticalSection(&tok->cs); |
| 419 tok->count--; | |
| 420 } | 420 } |
| 421 #elif defined HAVE_BEOS_THREADS | 421 #elif defined HAVE_BEOS_THREADS |
| 422 if (tok->lock->tid == find_thread(NULL)) { | 422 if (tok->lock->tid == find_thread(NULL)) { |
| 423 tok->count--; | 423 tok->count--; |
| 424 if (tok->count == 0) { | 424 if (tok->count == 0) { |
| 425 xmlMutexUnlock(tok->lock); | 425 xmlMutexUnlock(tok->lock); |
| 426 } | 426 } |
| 427 return; | 427 return; |
| 428 } | 428 } |
| 429 #endif | 429 #endif |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 free(p); | 1030 free(p); |
| 1031 } | 1031 } |
| 1032 } | 1032 } |
| 1033 break; | 1033 break; |
| 1034 } | 1034 } |
| 1035 return TRUE; | 1035 return TRUE; |
| 1036 } | 1036 } |
| 1037 #endif | 1037 #endif |
| 1038 #define bottom_threads | 1038 #define bottom_threads |
| 1039 #include "elfgcchack.h" | 1039 #include "elfgcchack.h" |
| OLD | NEW |