diff options
| author | matt <matt@NetBSD.org> | 2008-08-02 19:46:30 +0000 |
|---|---|---|
| committer | matt <matt@NetBSD.org> | 2008-08-02 19:46:30 +0000 |
| commit | 2b0c4dcffd752dbe8e0a4bfdf09e44fc4adb011b (patch) | |
| tree | f5afd018848f92fffb9e06035aa32c25b30e9167 /lib/libpthread/pthread_types.h | |
| parent | 2d2693ed5b4b64f04e21305bc839d0511a540d2e (diff) | |
Change pthread_mutex_t to use the amount of space as and be congruent to
the version used in the SA version of pthreads. This preserves binary
compatibility between both versions of the library.
Diffstat (limited to 'lib/libpthread/pthread_types.h')
| -rw-r--r-- | lib/libpthread/pthread_types.h | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/lib/libpthread/pthread_types.h b/lib/libpthread/pthread_types.h index 919a15bd56a..cf49d0270a4 100644 --- a/lib/libpthread/pthread_types.h +++ b/lib/libpthread/pthread_types.h @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_types.h,v 1.12 2008/06/05 23:38:51 ad Exp $ */ +/* $NetBSD: pthread_types.h,v 1.13 2008/08/02 19:46:30 matt Exp $ */ /*- * Copyright (c) 2001, 2008 The NetBSD Foundation, Inc. @@ -84,21 +84,53 @@ struct __pthread_attr_st { }; /* - * ptm_lock will never be spun on: it's locked with - * pthread__simple_lock_try() or not at all. + * ptm_owner is the actual lock field which is locked via CAS operation. + * This structure's layout is designed to compatible with the previous + * version used in SA pthreads. */ +#ifdef __CPU_SIMPLE_LOCK_PAD +/* + * If __SIMPLE_UNLOCKED != 0 and we have to pad, we have to worry about + * endianness. Currently that isn't an issue but put in a check in case + * something changes in the future. + */ +#if __SIMPLELOCK_UNLOCKED != 0 +#error __CPU_SIMPLE_LOCK_PAD incompatible with __SIMPLELOCK_UNLOCKED == 0 +#endif +#endif struct __pthread_mutex_st { unsigned int ptm_magic; - unsigned int ptm_errorcheck; - unsigned int ptm_recursed; - pthread_t * volatile ptm_waiters; + pthread_spin_t ptm_errorcheck; +#ifdef __CPU_SIMPLE_LOCK_PAD + uint8_t ptm_pad1[3]; +#endif + pthread_spin_t ptm_interlock; /* unused - backwards compat */ +#ifdef __CPU_SIMPLE_LOCK_PAD + uint8_t ptm_pad2[3]; +#endif volatile pthread_t ptm_owner; + pthread_t * volatile ptm_waiters; + unsigned int ptm_recursed; + void *ptm_spare2; /* unused - backwards compat */ }; #define _PT_MUTEX_MAGIC 0x33330003 #define _PT_MUTEX_DEAD 0xDEAD0003 -#define _PTHREAD_MUTEX_INITIALIZER { _PT_MUTEX_MAGIC, 0, 0, NULL, NULL } +#ifdef __CPU_SIMPLE_LOCK_PAD +#define _PTHREAD_MUTEX_INITIALIZER { _PT_MUTEX_MAGIC, \ + __SIMPLELOCK_UNLOCKED, { 0, 0, 0 }, \ + __SIMPLELOCK_UNLOCKED, { 0, 0, 0 }, \ + NULL, NULL, 0, NULL \ + } +#else +#define _PTHREAD_MUTEX_INITIALIZER { _PT_MUTEX_MAGIC, \ + __SIMPLELOCK_UNLOCKED, \ + __SIMPLELOCK_UNLOCKED, \ + NULL, NULL, 0, NULL \ + } +#endif /* __CPU_SIMPLE_LOCK_PAD */ + struct __pthread_mutexattr_st { unsigned int ptma_magic; |
