66 *
77 * Copyright (c) 1994, Regents of the University of California
88 *
9- * $Id: ipc.h,v 1.2 1996/07/20 08:35:24 scrappy Exp $
9+ * $Id: ipc.h,v 1.3 1996/07/22 22:59:43 scrappy Exp $
1010 *
1111 * NOTES
1212 * This file is very architecture-specific. This stuff should actually
3030 * atomic test-and-set instruction). However, we have only written
3131 * spinlock code for the architectures listed.
3232 */
33- #if ( defined(PORTNAME_aix ) || \
33+ #if defined(PORTNAME_aix ) || \
3434 defined(PORTNAME_alpha ) || \
35+ defined(PORTNAME_BSD44_derived ) || \
36+ defined(PORTNAME_bsdi ) || \
3537 defined(PORTNAME_hpux ) || \
38+ defined(PORTNAME_i386_solaris ) || \
3639 defined(PORTNAME_irix5 ) || \
40+ defined(PORTNAME_linux ) || \
3741 defined(PORTNAME_next ) || \
3842 defined(PORTNAME_sparc ) || \
39- defined(PORTNAME_sparc_solaris ) || \
40- (defined(__i386__ ) && defined(__GNUC__ ))) && \
41- !defined(PORTNAME_i386_solaris )
43+ defined(PORTNAME_sparc_solaris )
4244#define HAS_TEST_AND_SET
4345#endif
4446
4547#if defined(HAS_TEST_AND_SET )
4648
47- #if defined(PORTNAME_next )
48- /*
49- * Use Mach mutex routines since these are, in effect, test-and-set
50- * spinlocks.
51- */
52- #undef NEVER /* definition in cthreads.h conflicts with parse.h */
53- #include <mach/cthreads.h>
54-
55- typedef struct mutex slock_t ;
56- #else /* next */
5749#if defined(PORTNAME_aix )
5850/*
5951 * The AIX C library has the cs(3) builtin for compare-and-set that
6052 * operates on ints.
6153 */
6254typedef unsigned int slock_t ;
6355#else /* aix */
56+
6457#if defined(PORTNAME_alpha )
6558#include <sys/mman.h>
6659typedef msemaphore slock_t ;
6760#else /* alpha */
61+
6862#if defined(PORTNAME_hpux )
6963/*
7064 * The PA-RISC "semaphore" for the LDWCX instruction is 4 bytes aligned
7165 * to a 16-byte boundary.
7266 */
7367typedef struct { int sem [4 ]; } slock_t ;
7468#else /* hpux */
69+
7570#if defined(PORTNAME_irix5 )
7671#include <abi_mutex.h>
7772typedef abilock_t slock_t ;
7873#else /* irix5 */
74+
75+ #if defined(PORTNAME_next )
76+ /*
77+ * Use Mach mutex routines since these are, in effect, test-and-set
78+ * spinlocks.
79+ */
80+ #undef NEVER /* definition in cthreads.h conflicts with parse.h */
81+ #include <mach/cthreads.h>
82+ typedef struct mutex slock_t ;
83+ #else /* next */
84+
7985/*
8086 * On all other architectures spinlocks are a single byte.
8187 */
8288typedef unsigned char slock_t ;
89+
90+ #endif /* next */
8391#endif /* irix5 */
8492#endif /* hpux */
8593#endif /* alpha */
8694#endif /* aix */
87- #endif /* next */
8895
8996extern void S_LOCK (slock_t * lock );
9097extern void S_UNLOCK (slock_t * lock );
9198extern void S_INIT_LOCK (slock_t * lock );
9299
93- #if defined(PORTNAME_hpux ) || defined(PORTNAME_alpha ) || defined(PORTNAME_irix5 ) || defined(PORTNAME_next )
100+ #if defined(PORTNAME_alpha ) || \
101+ defined(PORTNAME_hpux ) || \
102+ defined(PORTNAME_irix5 ) || \
103+ defined(PORTNAME_next )
94104extern int S_LOCK_FREE (slock_t * lock );
95- #else /* PORTNAME_hpux */
105+ #else
96106#define S_LOCK_FREE (lock ) ((*lock) == 0)
97- #endif /* PORTNAME_hpux */
107+ #endif
98108
99109#endif /* HAS_TEST_AND_SET */
100110
@@ -108,9 +118,10 @@ extern int S_LOCK_FREE(slock_t *lock);
108118 defined(PORTNAME_aix ) || \
109119 defined(PORTNAME_alpha ) || \
110120 defined(PORTNAME_hpux ) || \
121+ defined(PORTNAME_i386_solaris ) || \
111122 defined(PORTNAME_sparc_solaris ) || \
112- defined(WIN32 ) || \
113- defined(PORTNAME_ultrix4 )
123+ defined(PORTNAME_ultrix4 ) || \
124+ defined(WIN32 )
114125union semun {
115126 int val ;
116127 struct semid_ds * buf ;
0 commit comments