Define OSATOMIC_USE_INLINED to get usable atomics on DARWIN 33/12433/3
authorDave Botsch <botsch@cnf.cornell.edu>
Thu, 3 Nov 2016 16:22:21 +0000 (12:22 -0400)
committerBenjamin Kaduk <kaduk@mit.edu>
Sun, 27 Nov 2016 07:48:02 +0000 (02:48 -0500)
In Mac OS 10.12, legacy interfaces for atomic operations have been
deprecated. Defining OSATOMIC_USE_INLINED gets us inline implementations
of the OSAtomic interfaces in terms of the <stdatomic.h> primitives.
This is a transition convenience.

Also indent preprocessor directives within the main DARWIN block to
improve readability.

Change-Id: Id10ae007d5427486f1b0a307a04a90f263201150
Reviewed-on: https://gerrit.openafs.org/12433
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/rx/rx_atomic.h

index dfcb064..5bf35fe 100644 (file)
@@ -184,14 +184,21 @@ rx_atomic_test_and_clear_bit(rx_atomic_t *atomic, int bit) {
 
 #elif defined(AFS_DARWIN80_ENV) || defined(AFS_USR_DARWIN80_ENV)
 
-#include <libkern/OSAtomic.h>
-#if defined(KERNEL) && !defined(UKERNEL)
-#define OSAtomicIncrement32 OSIncrementAtomic
-#define OSAtomicAdd32 OSAddAtomic
-#define OSAtomicDecrement32 OSDecrementAtomic
-#define OSAtomicOr32 OSBitOrAtomic
-#define OSAtomicAnd32 OSBitAndAtomic
-#endif
+# if defined (AFS_DARWIN160_ENV) || defined(AFS_USR_DARWIN160_ENV)
+#  define OSATOMIC_USE_INLINED 1
+# else
+
+#  if defined(KERNEL) && !defined(UKERNEL)
+#   define OSAtomicIncrement32 OSIncrementAtomic
+#   define OSAtomicAdd32 OSAddAtomic
+#   define OSAtomicDecrement32 OSDecrementAtomic
+#   define OSAtomicOr32 OSBitOrAtomic
+#   define OSAtomicAnd32 OSBitAndAtomic
+#  endif
+
+# endif /* end defined DARWIN160 */
+
+# include <libkern/OSAtomic.h>
 
 typedef struct {
     volatile int var;