diff options
author | Niels de Vos <ndevos@redhat.com> | 2017-03-29 13:44:03 +0200 |
---|---|---|
committer | Jeff Darcy <jeff@pl.atyp.us> | 2017-04-05 09:14:26 -0400 |
commit | 93e3c9abce1a02ac724afa382751852fa5edf713 (patch) | |
tree | 887c599c2a31ab65a2f0b2440e5f3fe8b6061afc /libglusterfs/src/globals.h | |
parent | d6b88e9b8b02813620c3c1a2ea49d58d29062b3e (diff) |
libglusterfs: provide standardized atomic operations
The current macros ATOMIC_INCREMENT() and ATOMIC_DECREMENT() expect a
lock as first argument. There are at least two issues with this
approach:
1. this lock is unused on architectures that have atomic operations
2. some structures use a single lock for multiple variables
By defining a gf_atomic_t type, the unused lock can be removed, saving a
few bytes on modern architectures.
Because the gf_atomic_t type locates the lock for the variable (in case
of older architectures), each variable is protected the same on all
architectures. This makes the behaviour across all architectures more
equal (per variable locking, by a gf_lock_t or compiler optimization).
BUG: 1437037
Change-Id: Ic164892b06ea676e6a9566f8a98b7faf0efe76d6
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: https://review.gluster.org/16963
Smoke: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Xavier Hernandez <xhernandez@datalab.es>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Jeff Darcy <jeff@pl.atyp.us>
Diffstat (limited to 'libglusterfs/src/globals.h')
-rw-r--r-- | libglusterfs/src/globals.h | 17 |
1 files changed, 0 insertions, 17 deletions
diff --git a/libglusterfs/src/globals.h b/libglusterfs/src/globals.h index 1c8547265d1..24ce0683f7a 100644 --- a/libglusterfs/src/globals.h +++ b/libglusterfs/src/globals.h @@ -90,23 +90,6 @@ #define THIS (*__glusterfs_this_location()) #define DECLARE_OLD_THIS xlator_t *old_THIS = THIS -/* - * a more comprehensive feature test is shown at - * http://lists.iptel.org/pipermail/semsdev/2010-October/005075.html - * this is sufficient for RHEL5 i386 builds - */ -#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) && !defined(__i386__) -# define INCREMENT_ATOMIC(lk, op) __sync_add_and_fetch(&op, 1) -# define DECREMENT_ATOMIC(lk, op) __sync_sub_and_fetch(&op, 1) -#else -/* These are only here for old gcc, e.g. on RHEL5 i386. - * We're not ever going to use this in an if stmt, - * but let's be pedantically correct for style points */ -# define INCREMENT_ATOMIC(lk, op) do { LOCK (&lk); ++op; UNLOCK (&lk); } while (0) -/* this is a gcc 'statement expression', it works with llvm/clang too */ -# define DECREMENT_ATOMIC(lk, op) ({ LOCK (&lk); --op; UNLOCK (&lk); op; }) -#endif - xlator_t **__glusterfs_this_location (void); xlator_t *glusterfs_this_get (void); int glusterfs_this_set (xlator_t *); |