rx: fix atomics on darwin 84/13084/2
authorMarcio Barbosa <mbarbosa@sinenomine.net>
Mon, 14 May 2018 19:46:26 +0000 (16:46 -0300)
committerBenjamin Kaduk <kaduk@mit.edu>
Sun, 3 Jun 2018 14:09:19 +0000 (10:09 -0400)
commit002844c5f5f0e4b5ff578182c82e2c5e4d21c1d9
tree7205e1dc08ef05a89d23b4c1ef3edce902f31b04
parentc201f8d7a96b1f3ab0cb24dc15edb22f84ef1838
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+).

Reviewed-on: https://gerrit.openafs.org/13063
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit c16423ec4e678e5cb01dc99f4115065f8ef6caf7)

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