mirror of
https://github.com/python/cpython.git
synced 2025-11-03 19:34:08 +00:00
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.
This commit is contained in:
parent
c501583dfa
commit
9e46e56264
1 changed files with 22 additions and 1 deletions
|
|
@ -32,6 +32,7 @@ PERFORMANCE OF THIS SOFTWARE.
|
||||||
/* Posix threads interface */
|
/* Posix threads interface */
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -113,11 +114,28 @@ typedef struct {
|
||||||
pthread_mutex_t mut;
|
pthread_mutex_t mut;
|
||||||
} pthread_lock;
|
} 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.
|
* 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()
|
static void _init_thread _P0()
|
||||||
{
|
{
|
||||||
#if defined(_AIX) && defined(__GNUC__)
|
#if defined(_AIX) && defined(__GNUC__)
|
||||||
|
|
@ -125,6 +143,8 @@ static void _init_thread _P0()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* !_HAVE_BSDI */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Thread support.
|
* Thread support.
|
||||||
*/
|
*/
|
||||||
|
|
@ -234,6 +254,7 @@ type_lock allocate_lock _P0()
|
||||||
init_thread();
|
init_thread();
|
||||||
|
|
||||||
lock = (pthread_lock *) malloc(sizeof(pthread_lock));
|
lock = (pthread_lock *) malloc(sizeof(pthread_lock));
|
||||||
|
memset((void *)lock, '\0', sizeof(pthread_lock));
|
||||||
if (lock) {
|
if (lock) {
|
||||||
lock->locked = 0;
|
lock->locked = 0;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue