]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
atomic: add and sub return their result
authorCasey Bodley <casey@linuxbox.com>
Thu, 4 Sep 2014 15:10:46 +0000 (11:10 -0400)
committerMatt Benjamin <matt@cohortfs.com>
Wed, 14 Jan 2015 21:40:20 +0000 (16:40 -0500)
Signed-off-by: Casey Bodley <casey@linuxbox.com>
Signed-off-by: Matt Benjamin <matt@cohortfs.com>
src/include/atomic.h

index c1650bef51ae7c5e4709dac156a9a400928647a1..960123e6e3679829bf2da6269132169eb5d584be 100644 (file)
@@ -100,12 +100,12 @@ namespace ceph {
     AO_t dec() {
       return AO_fetch_and_sub1_write(&val) - 1;
     }
-    void add(AO_t add_me) {
-      AO_fetch_and_add(&val, add_me);
+    AO_t add(AO_t add_me) {
+      return AO_fetch_and_add(&val, add_me) + add_me;
     }
-    void sub(AO_t sub_me) {
+    AO_t sub(AO_t sub_me) {
       AO_t negsub = 0 - sub_me;
-      AO_fetch_and_add_write(&val, (AO_t)negsub);
+      return AO_fetch_and_add_write(&val, negsub) + negsub;
     }
     AO_t read() const {
       // cast away const on the pointer.  this is only needed to build