diff --git a/nsprpub/pr/include/md/_pth.h b/nsprpub/pr/include/md/_pth.h index 214fb9f98d2..c1c40893e49 100644 --- a/nsprpub/pr/include/md/_pth.h +++ b/nsprpub/pr/include/md/_pth.h @@ -54,14 +54,22 @@ * Mutex and condition attributes are not supported. The attr * argument to pthread_mutex_init() and pthread_cond_init() must * be passed as NULL. + * + * The memset calls in PTHREAD_MUTEX_INIT and PTHREAD_COND_INIT + * are to work around BSDI's using a single bit to indicate a mutex + * or condition variable is initialized. This entire BSDI section + * will go away when BSDI releases updated threads libraries for + * BSD/OS 3.1 and 4.0. */ #define PTHREAD_MUTEXATTR_INIT(x) 0 #define PTHREAD_MUTEXATTR_DESTROY(x) /* */ -#define PTHREAD_MUTEX_INIT(m, a) pthread_mutex_init(&(m), NULL) -#define PTHREAD_MUTEX_IS_LOCKED(m) (EBUSY == pthread_mutex_trylock(&(m))) +#define PTHREAD_MUTEX_INIT(m, a) (memset(&(m), 0, sizeof(m)), \ + pthread_mutex_init(&(m), NULL)) +#define PTHREAD_MUTEX_IS_LOCKED(m) (EBUSY == pthread_mutex_trylock(&(m))) #define PTHREAD_CONDATTR_INIT(x) 0 #define PTHREAD_CONDATTR_DESTROY(x) /* */ -#define PTHREAD_COND_INIT(m, a) pthread_cond_init(&(m), NULL) +#define PTHREAD_COND_INIT(m, a) (memset(&(m), 0, sizeof(m)), \ + pthread_cond_init(&(m), NULL)) #else #define PTHREAD_MUTEXATTR_INIT pthread_mutexattr_init #define PTHREAD_MUTEXATTR_DESTROY pthread_mutexattr_destroy