src: Replace virAtomicIntGet() with g_atomic_int_get()

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Michal Privoznik 2020-01-31 17:07:00 +01:00
parent 18a6f18280
commit 8567ff1f5c
3 changed files with 9 additions and 18 deletions

View File

@ -601,7 +601,7 @@ virNWFilterSnoopReqFree(virNWFilterSnoopReqPtr req)
if (!req) if (!req)
return; return;
if (virAtomicIntGet(&req->refctr) != 0) if (g_atomic_int_get(&req->refctr) != 0)
return; return;
/* free all leases */ /* free all leases */
@ -1477,7 +1477,7 @@ virNWFilterDHCPSnoopThread(void *req0)
unsigned int diff; unsigned int diff;
/* submit packet to worker thread */ /* submit packet to worker thread */
if (virAtomicIntGet(&pcapConf[i].qCtr) > if (g_atomic_int_get(&pcapConf[i].qCtr) >
pcapConf[i].maxQSize) { pcapConf[i].maxQSize) {
if (last_displayed_queue - time(0) > 10) { if (last_displayed_queue - time(0) > 10) {
last_displayed_queue = time(0); last_displayed_queue = time(0);
@ -1778,7 +1778,7 @@ virNWFilterSnoopLeaseFileSave(virNWFilterSnoopIPLeasePtr ipl)
/* keep dead leases at < ~95% of file size */ /* keep dead leases at < ~95% of file size */
if (virAtomicIntInc(&virNWFilterSnoopState.wLeases) >= if (virAtomicIntInc(&virNWFilterSnoopState.wLeases) >=
virAtomicIntGet(&virNWFilterSnoopState.nLeases) * 20) g_atomic_int_get(&virNWFilterSnoopState.nLeases) * 20)
virNWFilterSnoopLeaseFileLoad(); /* load & refresh lease file */ virNWFilterSnoopLeaseFileLoad(); /* load & refresh lease file */
err_exit: err_exit:
@ -1809,7 +1809,7 @@ virNWFilterSnoopPruneIter(const void *payload,
/* /*
* have the entry removed if it has no leases and no one holds a ref * have the entry removed if it has no leases and no one holds a ref
*/ */
del_req = ((req->start == NULL) && (virAtomicIntGet(&req->refctr) == 0)); del_req = ((req->start == NULL) && (g_atomic_int_get(&req->refctr) == 0));
virNWFilterSnoopReqUnlock(req); virNWFilterSnoopReqUnlock(req);
@ -1973,9 +1973,9 @@ virNWFilterSnoopLeaseFileLoad(void)
static void static void
virNWFilterSnoopJoinThreads(void) virNWFilterSnoopJoinThreads(void)
{ {
while (virAtomicIntGet(&virNWFilterSnoopState.nThreads) != 0) { while (g_atomic_int_get(&virNWFilterSnoopState.nThreads) != 0) {
VIR_WARN("Waiting for snooping threads to terminate: %u", VIR_WARN("Waiting for snooping threads to terminate: %u",
virAtomicIntGet(&virNWFilterSnoopState.nThreads)); g_atomic_int_get(&virNWFilterSnoopState.nThreads));
g_usleep(1000 * 1000); g_usleep(1000 * 1000);
} }
} }

View File

@ -26,15 +26,6 @@
#include "internal.h" #include "internal.h"
/**
* virAtomicIntGet:
* Gets the current value of atomic.
*
* This call acts as a full compiler and hardware memory barrier
* (before the get)
*/
#define virAtomicIntGet(v) g_atomic_int_get(v)
/** /**
* virAtomicIntSet: * virAtomicIntSet:
* Sets the value of atomic to newval. * Sets the value of atomic to newval.

View File

@ -154,7 +154,7 @@ virSystemdHasMachined(void)
int ret; int ret;
int val; int val;
val = virAtomicIntGet(&virSystemdHasMachinedCachedValue); val = g_atomic_int_get(&virSystemdHasMachinedCachedValue);
if (val != -1) if (val != -1)
return val; return val;
@ -176,7 +176,7 @@ virSystemdHasLogind(void)
int ret; int ret;
int val; int val;
val = virAtomicIntGet(&virSystemdHasLogindCachedValue); val = g_atomic_int_get(&virSystemdHasLogindCachedValue);
if (val != -1) if (val != -1)
return val; return val;
@ -352,7 +352,7 @@ int virSystemdCreateMachine(const char *name,
*/ */
VIR_DEBUG("Attempting to create machine via systemd"); VIR_DEBUG("Attempting to create machine via systemd");
if (virAtomicIntGet(&hasCreateWithNetwork)) { if (g_atomic_int_get(&hasCreateWithNetwork)) {
virError error; virError error;
memset(&error, 0, sizeof(error)); memset(&error, 0, sizeof(error));