Mercurial > cpython-lru_cache-weakref
diff Python/thread_pthread.h @ 9290:2340f615da8f legacy-trunk
BSDI specific patches, inspired by Nigel Head and otto@mail.olympus.net.
Also (non-BSDI specific):
- Change the CHECK_STATUS() macro so it tests for nonzero error codes
instead of negative error codes only (this was needed for BSDI, but
appears to be correct according to the PTHREADS spec).
- use memset() to zero out the allocated lock structure. Again, this
was needed for BSDI, but can't hurt elsewhere either.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 07 Oct 1998 16:39:47 +0000 |
| parents | 4d2cb212c8d1 |
| children | 877d23bd5bdc |
line wrap: on
line diff
--- a/Python/thread_pthread.h Wed Oct 07 16:36:14 1998 +0000 +++ b/Python/thread_pthread.h Wed Oct 07 16:39:47 1998 +0000 @@ -32,6 +32,7 @@ /* Posix threads interface */ #include <stdlib.h> +#include <string.h> #include <pthread.h> @@ -113,11 +114,28 @@ pthread_mutex_t mut; } pthread_lock; -#define CHECK_STATUS(name) if (status < 0) { perror(name); error=1; } +#define CHECK_STATUS(name) if (status != 0) { perror(name); error = 1; } /* * Initialization. */ + +#ifdef _HAVE_BSDI +static void _noop() +{ +} + +static void _init_thread _P0() +{ + /* DO AN INIT BY STARTING THE THREAD */ + static int dummy = 0; + pthread_t thread1; + pthread_create(&thread1, NULL, (void *) _noop, &dummy); + pthread_join(thread1, NULL); +} + +#else /* !_HAVE_BSDI */ + static void _init_thread _P0() { #if defined(_AIX) && defined(__GNUC__) @@ -125,6 +143,8 @@ #endif } +#endif /* !_HAVE_BSDI */ + /* * Thread support. */ @@ -234,6 +254,7 @@ init_thread(); lock = (pthread_lock *) malloc(sizeof(pthread_lock)); + memset((void *)lock, '\0', sizeof(pthread_lock)); if (lock) { lock->locked = 0;
