[PATCH 6/7] src: Drop virAtomicIntDecAndTest() with g_atomic_int_dec_and_test()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/libxl/libxl_domain.c          |  2 +-
 src/lxc/lxc_process.c             |  2 +-
 src/nwfilter/nwfilter_dhcpsnoop.c |  8 ++++----
 src/qemu/qemu_process.c           |  2 +-
 src/util/viratomic.h              | 11 -----------
 src/util/virobject.c              |  2 +-
 6 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 8885af451f..d53363dc02 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -878,7 +878,7 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver,
 
     priv->ignoreDeathEvent = false;
 
-    if (virAtomicIntDecAndTest(&driver->nactive) && driver->inhibitCallback)
+    if (!!g_atomic_int_dec_and_test(&driver->nactive) && driver->inhibitCallback)
         driver->inhibitCallback(false, driver->inhibitOpaque);
 
     if ((vm->def->ngraphics == 1) &&
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 2bb2216dc0..d8ddea6d24 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -208,7 +208,7 @@ static void virLXCProcessCleanup(virLXCDriverPtr driver,
     vm->pid = -1;
     vm->def->id = -1;
 
-    if (virAtomicIntDecAndTest(&driver->nactive) && driver->inhibitCallback)
+    if (!!g_atomic_int_dec_and_test(&driver->nactive) && driver->inhibitCallback)
         driver->inhibitCallback(false, driver->inhibitOpaque);
 
     virLXCDomainReAttachHostDevices(driver, vm->def);
diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c
index f73913ec9e..c4341ee3e2 100644
--- a/src/nwfilter/nwfilter_dhcpsnoop.c
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -692,7 +692,7 @@ virNWFilterSnoopReqPut(virNWFilterSnoopReqPtr req)
 
     virNWFilterSnoopLock();
 
-    if (virAtomicIntDecAndTest(&req->refctr)) {
+    if (!!g_atomic_int_dec_and_test(&req->refctr)) {
         /*
          * delete the request:
          * - if we don't find req on the global list anymore
@@ -868,7 +868,7 @@ virNWFilterSnoopReqLeaseDel(virNWFilterSnoopReqPtr req,
  skip_instantiate:
     VIR_FREE(ipl);
 
-    ignore_value(virAtomicIntDecAndTest(&virNWFilterSnoopState.nLeases));
+    ignore_value(!!g_atomic_int_dec_and_test(&virNWFilterSnoopState.nLeases));
 
  lease_not_found:
     VIR_FREE(ipstr);
@@ -1142,7 +1142,7 @@ static void virNWFilterDHCPDecodeWorker(void *jobdata, void *opaque)
                        _("Instantiation of rules failed on "
                          "interface '%s'"), req->binding->portdevname);
     }
-    ignore_value(virAtomicIntDecAndTest(job->qCtr));
+    ignore_value(!!g_atomic_int_dec_and_test(job->qCtr));
     VIR_FREE(job);
 }
 
@@ -1543,7 +1543,7 @@ virNWFilterDHCPSnoopThread(void *req0)
             pcap_close(pcapConf[i].handle);
     }
 
-    ignore_value(virAtomicIntDecAndTest(&virNWFilterSnoopState.nThreads));
+    ignore_value(!!g_atomic_int_dec_and_test(&virNWFilterSnoopState.nThreads));
 
     return;
 }
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 20c4e3bb5d..ed14ce5ea2 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -7313,7 +7313,7 @@ void qemuProcessStop(virQEMUDriverPtr driver,
 
     qemuProcessBuildDestroyMemoryPaths(driver, vm, NULL, false);
 
-    if (virAtomicIntDecAndTest(&driver->nactive) && driver->inhibitCallback)
+    if (!!g_atomic_int_dec_and_test(&driver->nactive) && driver->inhibitCallback)
         driver->inhibitCallback(false, driver->inhibitOpaque);
 
     /* Wake up anything waiting on domain condition */
diff --git a/src/util/viratomic.h b/src/util/viratomic.h
index 152cfcd903..1ddc7019f9 100644
--- a/src/util/viratomic.h
+++ b/src/util/viratomic.h
@@ -26,17 +26,6 @@
 
 #include "internal.h"
 
-/**
- * virAtomicIntDecAndTest:
- * Decrements the value of atomic by 1.
- *
- * Think of this operation as an atomic version of
- * { *atomic -= 1; return *atomic == 0; }
- *
- * This call acts as a full compiler and hardware memory barrier.
- */
-#define virAtomicIntDecAndTest(i) (!!g_atomic_int_dec_and_test(i))
-
 /**
  * virAtomicIntCompareExchange:
  * Compares atomic to oldval and, if equal, sets it to newval. If
diff --git a/src/util/virobject.c b/src/util/virobject.c
index 9185d3e92e..7749d89243 100644
--- a/src/util/virobject.c
+++ b/src/util/virobject.c
@@ -344,7 +344,7 @@ virObjectUnref(void *anyobj)
     if (VIR_OBJECT_NOTVALID(obj))
         return false;
 
-    bool lastRef = virAtomicIntDecAndTest(&obj->u.s.refs);
+    bool lastRef = !!g_atomic_int_dec_and_test(&obj->u.s.refs);
     PROBE(OBJECT_UNREF, "obj=%p", obj);
     if (lastRef) {
         PROBE(OBJECT_DISPOSE, "obj=%p", obj);
-- 
2.24.1





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux