rx: fix atomics on darwin 63/13063/3
authorMarcio Barbosa <mbarbosa@sinenomine.net>
Mon, 14 May 2018 19:46:26 +0000 (16:46 -0300)
committerBenjamin Kaduk <kaduk@mit.edu>
Tue, 15 May 2018 22:39:20 +0000 (18:39 -0400)
commitc16423ec4e678e5cb01dc99f4115065f8ef6caf7
treec649e40b475b792f7c55ae6aede9073ca1596d3f
parent96a4bee20d42484148d163b85ca049dcc980a7a5
rx: fix atomics on darwin

As described by commit b2a21422129ca1eeeb5ea1a1f7b08b537fd2a9f7, the API
used for atomic operations in kernel space is not the same as the one
used in user space. To fix this problem, the commit mentioned above
introduced macros to correct the name of these functions in kernel space.
Unfortunately, the return value of the functions used in kernel space is
not the same as the ones used in user space. Generally speaking, the
kernel space atomic functions return the original value of the variable
received as an argument before the operation in question. On the other
hand, the user space atomic functions return the new value, after the
operation has been performed. To fix this problem, this commit provides
a new set of inline functions (only used in kernel space) with the
expected return values.

Also, in order to get the inline implementations of the OSAtomic
interfaces in terms of the <stdatomic.h> primitives, commit
74f837fd943ddfa20d349a83d6286a0183cb4663 defines OSATOMIC_USE_INLINED
on OS X 10.12. However, the definition of this macro only affects the
user space legacy interfaces for atomic operations. The kernel space
interfaces for atomics are not deprecated and OSATOMIC_USE_INLINED does
not affect these functions. To fix this problem, only define
OSATOMIC_USE_INLINED in user space (OS X 10.12+).

Change-Id: Ia6cbc76daa7068625dc9f6dff385d0568d6503bd
Reviewed-on: https://gerrit.openafs.org/13063
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
src/rx/rx_atomic.h