From nobody Thu May 9 01:12:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1580539027227799.5600695788942; Fri, 31 Jan 2020 22:37:07 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-1-SlVucXPTOoGRVIYfE9bsbA-1; Sat, 01 Feb 2020 01:36:09 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2606A107ACC5; Sat, 1 Feb 2020 06:36:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 003C010840DF; Sat, 1 Feb 2020 06:36:03 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A105D85CF5; Sat, 1 Feb 2020 06:36:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0116Xtja012457 for ; Sat, 1 Feb 2020 01:33:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id B3A2584791; Sat, 1 Feb 2020 06:33:55 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-34.brq.redhat.com [10.40.204.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 355FC77932 for ; Sat, 1 Feb 2020 06:33:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580539026; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ToemGnTvuyV2jwnlRd34lTmg6ruQDAy1RvZL/4DDzIk=; b=MbYGQ98MxuqWPWdZY2u3+fs57xQtkAz0TSwphnGJkz8v7G5fWNtwbg4kKCz02U0cWnhzo5 E8kI5mou0bB9XriDMW+EzITGItued3apQzHaqGMS4V2FkEIsqLuHYYS72xJuAV0rVLra2i Mpk7w5rr3/hZ7Hj1fPaSSTMbLhSWYmo= From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/7] test_driver: Replace virAtomicIntAdd() with virAtomicIntInc() Date: Sat, 1 Feb 2020 07:33:43 +0100 Message-Id: <7af746a747506a7057348429f64fb7a92d04dd6d.1580538782.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: SlVucXPTOoGRVIYfE9bsbA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Instead of calling virAtomicIntAdd(&var, 1); we can call virAtomicIntInc(&var) directly. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/test/test_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 47c1fc588f..6f617592f3 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -695,7 +695,7 @@ testDomainStartState(testDriverPtr privconn, int ret =3D -1; =20 virDomainObjSetState(dom, VIR_DOMAIN_RUNNING, reason); - dom->def->id =3D virAtomicIntAdd(&privconn->nextDomID, 1); + dom->def->id =3D virAtomicIntInc(&privconn->nextDomID); =20 if (virDomainObjSetDefTransient(privconn->xmlopt, dom, NULL) < 0) { --=20 2.24.1 From nobody Thu May 9 01:12:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580538962917150.67251297970495; Fri, 31 Jan 2020 22:36:02 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-221-4nl9NMqHPhKe0JxRnvRxHQ-1; Sat, 01 Feb 2020 01:35:59 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E44611005510; Sat, 1 Feb 2020 06:35:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B9D0760BE1; Sat, 1 Feb 2020 06:35:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 70B4018089CF; Sat, 1 Feb 2020 06:35:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0116Xu8m012465 for ; Sat, 1 Feb 2020 01:33:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 90C7384791; Sat, 1 Feb 2020 06:33:56 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-34.brq.redhat.com [10.40.204.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 11C2877932 for ; Sat, 1 Feb 2020 06:33:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580538961; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=DzIpqdnXIINwAHWOMOwWYnFZZFucA8rUFoiWubWu5Cs=; b=Dd7fRx/SLeY1tA7BbI7z036aLzFLNQ6U7FGZSt29hnozhYl0EohKXyYZhG/DdWJmIqEI58 8QbQYue4qWSsnmy9A6PSf7GJAkEhVGI82oUbuS0BnAA72gWDPpweHHpfbi55qInkdMA51u mr4DgMMdUJsw77PhJb40tEZzIoqsJzg= From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/7] tests: Drop viratomictest Date: Sat, 1 Feb 2020 07:33:44 +0100 Message-Id: <6c54f4a26202430cb940686fa8a585641fb0caf5.1580538782.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: 4nl9NMqHPhKe0JxRnvRxHQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In future commits our virAtomic* APIs will be replaced with their GLib variants. Instead of trying to update the test after each commit and eventually removing the test anyway, remove it upfront and save the hassle. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- tests/Makefile.am | 5 -- tests/viratomictest.c | 175 ------------------------------------------ 2 files changed, 180 deletions(-) delete mode 100644 tests/viratomictest.c diff --git a/tests/Makefile.am b/tests/Makefile.am index 19705c6b76..ef49b122cd 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -179,7 +179,6 @@ test_programs =3D virshtest sockettest \ virhostcputest virbuftest \ commandtest seclabeltest \ virhashtest virconftest \ - viratomictest \ utiltest shunloadtest \ virtimetest viruritest virkeyfiletest \ viralloctest \ @@ -1456,10 +1455,6 @@ virhashtest_SOURCES =3D \ virhashtest.c virhashdata.h testutils.h testutils.c virhashtest_LDADD =3D $(LDADDS) =20 -viratomictest_SOURCES =3D \ - viratomictest.c testutils.h testutils.c -viratomictest_LDADD =3D $(LDADDS) - virbitmaptest_SOURCES =3D \ virbitmaptest.c testutils.h testutils.c virbitmaptest_LDADD =3D $(LDADDS) diff --git a/tests/viratomictest.c b/tests/viratomictest.c deleted file mode 100644 index e30df66cd7..0000000000 --- a/tests/viratomictest.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (C) 2011-2013 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - */ - -#include - -#include -#include - -#include "testutils.h" - -#include "viratomic.h" -#include "virrandom.h" -#include "virthread.h" - -static int -testTypes(const void *data G_GNUC_UNUSED) -{ - unsigned int u, u2; - int s, s2; - bool res; - -#define testAssertEq(a, b) \ - if (!(a =3D=3D b)) \ - return -1; - virAtomicIntSet(&u, 5); - u2 =3D virAtomicIntGet(&u); - testAssertEq(u2, 5); - - res =3D virAtomicIntCompareExchange(&u, 6, 7); - if (res) - return -1; - testAssertEq(u, 5); - - testAssertEq(virAtomicIntAdd(&u, 1), 5); - testAssertEq(u, 6); - - testAssertEq(virAtomicIntInc(&u), 6); - testAssertEq(u, 7); - - res =3D virAtomicIntDecAndTest(&u); - if (res) - return -1; - testAssertEq(u, 6); - - u2 =3D virAtomicIntAnd(&u, 5); - testAssertEq(u2, 6); - testAssertEq(u, 4); - - u2 =3D virAtomicIntOr(&u, 8); - testAssertEq(u2, 4); - testAssertEq(u, 12); - - u2 =3D virAtomicIntXor(&u, 4); - testAssertEq(u2, 12); - testAssertEq(u, 8); - - virAtomicIntSet(&s, 5); - s2 =3D virAtomicIntGet(&s); - testAssertEq(s2, 5); - - res =3D virAtomicIntCompareExchange(&s, 6, 7); - if (res) - return -1; - testAssertEq(s, 5); - - virAtomicIntAdd(&s, 1); - testAssertEq(s, 6); - - virAtomicIntInc(&s); - testAssertEq(s, 7); - - res =3D virAtomicIntDecAndTest(&s); - if (res) - return -1; - testAssertEq(s, 6); - - s2 =3D virAtomicIntAnd(&s, 5); - testAssertEq(s2, 6); - testAssertEq(s, 4); - - s2 =3D virAtomicIntOr(&s, 8); - testAssertEq(s2, 4); - testAssertEq(s, 12); - - s2 =3D virAtomicIntXor(&s, 4); - testAssertEq(s2, 12); - testAssertEq(s, 8); - - return 0; -} - -#define THREADS 10 -#define ROUNDS 10000 - -volatile int bucket[THREADS]; -volatile int atomic; - -static void -thread_func(void *data) -{ - int idx =3D (intptr_t)data; - size_t i; - int d; - - for (i =3D 0; i < ROUNDS; i++) { - d =3D virRandomBits(7); - bucket[idx] +=3D d; - virAtomicIntAdd(&atomic, d); -#ifdef WIN32 - SleepEx(0, 0); -#else - sched_yield(); -#endif - } -} - -static int -testThreads(const void *data G_GNUC_UNUSED) -{ - int sum; - size_t i; - virThread threads[THREADS]; - - atomic =3D 0; - for (i =3D 0; i < THREADS; i++) - bucket[i] =3D 0; - - for (i =3D 0; i < THREADS; i++) { - if (virThreadCreate(&(threads[i]), true, thread_func, (void*)(intp= tr_t)i) < 0) - return -1; - } - - for (i =3D 0; i < THREADS; i++) - virThreadJoin(&threads[i]); - - sum =3D 0; - for (i =3D 0; i < THREADS; i++) - sum +=3D bucket[i]; - - if (sum !=3D atomic) - return -1; - - return 0; -} - -static int -mymain(void) -{ - int ret =3D 0; - - if (virTestRun("types", testTypes, NULL) < 0) - ret =3D -1; - if (virTestRun("threads", testThreads, NULL) < 0) - ret =3D -1; - - return ret; -} - -VIR_TEST_MAIN(mymain) --=20 2.24.1 From nobody Thu May 9 01:12:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580538976865293.6980218554694; Fri, 31 Jan 2020 22:36:16 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-295-jqyKQkDsOFOhpGlYY7Fp5w-1; Sat, 01 Feb 2020 01:36:13 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 98C0E1005510; Sat, 1 Feb 2020 06:36:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6F3225D9E5; Sat, 1 Feb 2020 06:36:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 17DD518089CE; Sat, 1 Feb 2020 06:36:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0116XvNW012475 for ; Sat, 1 Feb 2020 01:33:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6CDF377932; Sat, 1 Feb 2020 06:33:57 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-34.brq.redhat.com [10.40.204.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2B0286420 for ; Sat, 1 Feb 2020 06:33:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580538975; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=wRS5cag+H/33M/d9dM6CVaZSksLUD1v18CPWtjG3HAQ=; b=DnViWaxdYs6SrFFbeZPNU4zBoiTDN0yvWS28DSL4IhwKXO51xrKBlQBAnq+GUHYb9p01xR Us0gYNKHtOSdyMbXVVHHenpETGnnTtMAvWm7AK6YcsPAZgJNUdgp9OxL3zHyVlmYSbr5kd KGdNz4sDtE7h61akyhgxvVgHiTgQT0o= From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/7] src: Replace virAtomicIntGet() with g_atomic_int_get() Date: Sat, 1 Feb 2020 07:33:45 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: jqyKQkDsOFOhpGlYY7Fp5w-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/nwfilter/nwfilter_dhcpsnoop.c | 12 ++++++------ src/util/viratomic.h | 9 --------- src/util/virsystemd.c | 6 +++--- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcp= snoop.c index a1c0c0189e..074cffecb2 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -601,7 +601,7 @@ virNWFilterSnoopReqFree(virNWFilterSnoopReqPtr req) if (!req) return; =20 - if (virAtomicIntGet(&req->refctr) !=3D 0) + if (g_atomic_int_get(&req->refctr) !=3D 0) return; =20 /* free all leases */ @@ -1477,7 +1477,7 @@ virNWFilterDHCPSnoopThread(void *req0) unsigned int diff; =20 /* submit packet to worker thread */ - if (virAtomicIntGet(&pcapConf[i].qCtr) > + if (g_atomic_int_get(&pcapConf[i].qCtr) > pcapConf[i].maxQSize) { if (last_displayed_queue - time(0) > 10) { last_displayed_queue =3D time(0); @@ -1778,7 +1778,7 @@ virNWFilterSnoopLeaseFileSave(virNWFilterSnoopIPLease= Ptr ipl) =20 /* keep dead leases at < ~95% of file size */ if (virAtomicIntInc(&virNWFilterSnoopState.wLeases) >=3D - virAtomicIntGet(&virNWFilterSnoopState.nLeases) * 20) + g_atomic_int_get(&virNWFilterSnoopState.nLeases) * 20) virNWFilterSnoopLeaseFileLoad(); /* load & refresh lease file */ =20 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 */ - del_req =3D ((req->start =3D=3D NULL) && (virAtomicIntGet(&req->refctr= ) =3D=3D 0)); + del_req =3D ((req->start =3D=3D NULL) && (g_atomic_int_get(&req->refct= r) =3D=3D 0)); =20 virNWFilterSnoopReqUnlock(req); =20 @@ -1973,9 +1973,9 @@ virNWFilterSnoopLeaseFileLoad(void) static void virNWFilterSnoopJoinThreads(void) { - while (virAtomicIntGet(&virNWFilterSnoopState.nThreads) !=3D 0) { + while (g_atomic_int_get(&virNWFilterSnoopState.nThreads) !=3D 0) { VIR_WARN("Waiting for snooping threads to terminate: %u", - virAtomicIntGet(&virNWFilterSnoopState.nThreads)); + g_atomic_int_get(&virNWFilterSnoopState.nThreads)); g_usleep(1000 * 1000); } } diff --git a/src/util/viratomic.h b/src/util/viratomic.h index 12b116a6cd..6c1764f7bf 100644 --- a/src/util/viratomic.h +++ b/src/util/viratomic.h @@ -26,15 +26,6 @@ =20 #include "internal.h" =20 -/** - * 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: * Sets the value of atomic to newval. diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c index a9ff782fb8..5b66094de5 100644 --- a/src/util/virsystemd.c +++ b/src/util/virsystemd.c @@ -154,7 +154,7 @@ virSystemdHasMachined(void) int ret; int val; =20 - val =3D virAtomicIntGet(&virSystemdHasMachinedCachedValue); + val =3D g_atomic_int_get(&virSystemdHasMachinedCachedValue); if (val !=3D -1) return val; =20 @@ -176,7 +176,7 @@ virSystemdHasLogind(void) int ret; int val; =20 - val =3D virAtomicIntGet(&virSystemdHasLogindCachedValue); + val =3D g_atomic_int_get(&virSystemdHasLogindCachedValue); if (val !=3D -1) return val; =20 @@ -352,7 +352,7 @@ int virSystemdCreateMachine(const char *name, */ =20 VIR_DEBUG("Attempting to create machine via systemd"); - if (virAtomicIntGet(&hasCreateWithNetwork)) { + if (g_atomic_int_get(&hasCreateWithNetwork)) { virError error; memset(&error, 0, sizeof(error)); =20 --=20 2.24.1 From nobody Thu May 9 01:12:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580538958586547.5244039228241; Fri, 31 Jan 2020 22:35:58 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-31-yKRyQOw_OkOeq-9EykYbxw-1; Sat, 01 Feb 2020 01:35:55 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BE5E41005512; Sat, 1 Feb 2020 06:35:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4ED6419488; Sat, 1 Feb 2020 06:35:49 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id AFEA81809567; Sat, 1 Feb 2020 06:35:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0116XwVh012484 for ; Sat, 1 Feb 2020 01:33:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id 489FD84791; Sat, 1 Feb 2020 06:33:58 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-34.brq.redhat.com [10.40.204.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE4EF77932 for ; Sat, 1 Feb 2020 06:33:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580538957; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=wJoDpPHaM8b2y3kcySgcnJIuhCf/7bJGykkZuVEvea8=; b=hu3+pGWKU+Zd7QAAFeK2ead90wesNPC0/ly4WuQwEqmscUWSftg0lpTI9Y0KOJgPKRdPAV +0rMt2F2gV45WweitkCWYHQsRdCfIMB8CrFYGrTQ3qZ66IdLEOT5WVQ5R4uSUDUCDTG3FM SXOCUeT0/P3YSb0DkzLLc19LQu7Xe7I= From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/7] src: Replace virAtomicIntSet() with g_atomic_int_set() Date: Sat, 1 Feb 2020 07:33:46 +0100 Message-Id: <7fd9b2527a3c049452f5ab2b9ed133246d64e3bf.1580538782.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: yKRyQOw_OkOeq-9EykYbxw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/nwfilter/nwfilter_dhcpsnoop.c | 2 +- src/test/test_driver.c | 4 ++-- src/util/viratomic.h | 9 --------- src/util/virobject.c | 2 +- src/util/virsystemd.c | 10 +++++----- 5 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcp= snoop.c index 074cffecb2..b82779609d 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -1884,7 +1884,7 @@ virNWFilterSnoopLeaseFileRefresh(void) TMPLEASEFILE, LEASEFILE); unlink(TMPLEASEFILE); } - virAtomicIntSet(&virNWFilterSnoopState.wLeases, 0); + g_atomic_int_set(&virNWFilterSnoopState.wLeases, 0); =20 skip_rename: virNWFilterSnoopLeaseFileOpen(); diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 6f617592f3..4e159157d7 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -106,7 +106,7 @@ struct _testDriver { size_t numAuths; testAuthPtr auths; =20 - /* virAtomic access only */ + /* g_atomic access only */ volatile int nextDomID; =20 /* immutable pointer, immutable object after being initialized with @@ -448,7 +448,7 @@ testDriverNew(void) !(ret->pools =3D virStoragePoolObjListNew())) goto error; =20 - virAtomicIntSet(&ret->nextDomID, 1); + g_atomic_int_set(&ret->nextDomID, 1); =20 return ret; =20 diff --git a/src/util/viratomic.h b/src/util/viratomic.h index 6c1764f7bf..2811447a29 100644 --- a/src/util/viratomic.h +++ b/src/util/viratomic.h @@ -26,15 +26,6 @@ =20 #include "internal.h" =20 -/** - * virAtomicIntSet: - * Sets the value of atomic to newval. - * - * This call acts as a full compiler and hardware memory barrier - * (after the set) - */ -#define virAtomicIntSet(i, newv) g_atomic_int_set(i, newv) - /** * virAtomicIntInc: * Increments the value of atomic by 1. diff --git a/src/util/virobject.c b/src/util/virobject.c index 5af14234f2..8cece6e735 100644 --- a/src/util/virobject.c +++ b/src/util/virobject.c @@ -246,7 +246,7 @@ virObjectNew(virClassPtr klass) =20 obj->u.s.magic =3D klass->magic; obj->klass =3D klass; - virAtomicIntSet(&obj->u.s.refs, 1); + g_atomic_int_set(&obj->u.s.refs, 1); =20 PROBE(OBJECT_NEW, "obj=3D%p classname=3D%s", obj, obj->klass->name); =20 diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c index 5b66094de5..6b47f4fa36 100644 --- a/src/util/virsystemd.c +++ b/src/util/virsystemd.c @@ -160,13 +160,13 @@ virSystemdHasMachined(void) =20 if ((ret =3D virDBusIsServiceEnabled("org.freedesktop.machine1")) < 0)= { if (ret =3D=3D -2) - virAtomicIntSet(&virSystemdHasMachinedCachedValue, -2); + g_atomic_int_set(&virSystemdHasMachinedCachedValue, -2); return ret; } =20 if ((ret =3D virDBusIsServiceRegistered("org.freedesktop.systemd1")) = =3D=3D -1) return ret; - virAtomicIntSet(&virSystemdHasMachinedCachedValue, ret); + g_atomic_int_set(&virSystemdHasMachinedCachedValue, ret); return ret; } =20 @@ -183,14 +183,14 @@ virSystemdHasLogind(void) ret =3D virDBusIsServiceEnabled("org.freedesktop.login1"); if (ret < 0) { if (ret =3D=3D -2) - virAtomicIntSet(&virSystemdHasLogindCachedValue, -2); + g_atomic_int_set(&virSystemdHasLogindCachedValue, -2); return ret; } =20 if ((ret =3D virDBusIsServiceRegistered("org.freedesktop.login1")) =3D= =3D -1) return ret; =20 - virAtomicIntSet(&virSystemdHasLogindCachedValue, ret); + g_atomic_int_set(&virSystemdHasLogindCachedValue, ret); return ret; } =20 @@ -386,7 +386,7 @@ int virSystemdCreateMachine(const char *name, VIR_INFO("CreateMachineWithNetwork isn't supported, switch= ing " "to legacy CreateMachine method for systemd-machi= ned"); virResetError(&error); - virAtomicIntSet(&hasCreateWithNetwork, 0); + g_atomic_int_set(&hasCreateWithNetwork, 0); /* Could re-structure without Using goto, but this * avoids another atomic read which would trigger * another memory barrier */ --=20 2.24.1 From nobody Thu May 9 01:12:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580538968800734.4074306537667; Fri, 31 Jan 2020 22:36:08 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-287-iTu8iUvcNuK8x5RqD_8NzA-1; Sat, 01 Feb 2020 01:36:05 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BB19F8010CB; Sat, 1 Feb 2020 06:35:57 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F40C60BE1; Sat, 1 Feb 2020 06:35:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 3ACBD18089D5; Sat, 1 Feb 2020 06:35:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0116XxFh012491 for ; Sat, 1 Feb 2020 01:33:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2718D84791; Sat, 1 Feb 2020 06:33:59 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-34.brq.redhat.com [10.40.204.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B3CA77932 for ; Sat, 1 Feb 2020 06:33:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580538967; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=qe0/px7YagKGmK84Eh+jRN1hIlEHe1pK1jreRGSqOWA=; b=GPdyZK3soURVgg+x/S3fJzvPBk17isE3Y1eK293WXZvKGA7S0x2PVag/vmc9sIwEQOKCia 1fHCkX4kHBPNO9Yk65203q3WTI6Fxwf7zh0HR47PzZDKzJbspfZc4Fue+Qn1uUnEZS2SSW oQARG9xxqO/VbT//5Dy8Iqqz/1z8dSY= From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 5/7] src: Replace virAtomicIntInc() with g_atomic_int_add() Date: Sat, 1 Feb 2020 07:33:47 +0100 Message-Id: <7892773bae7749bd8a63681bc3f7e7e3ed905aab.1580538782.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: iTu8iUvcNuK8x5RqD_8NzA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/libxl/libxl_domain.c | 2 +- src/libxl/libxl_driver.c | 2 +- src/lxc/lxc_process.c | 4 ++-- src/nwfilter/nwfilter_dhcpsnoop.c | 10 +++++----- src/qemu/qemu_process.c | 4 ++-- src/test/test_driver.c | 2 +- src/util/viratomic.h | 11 ----------- src/util/virobject.c | 4 ++-- src/util/virprocess.c | 2 +- 9 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index d63eca0bd6..8885af451f 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -1471,7 +1471,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) goto destroy_dom; =20 - if (virAtomicIntInc(&driver->nactive) =3D=3D 0 && driver->inhibitCallb= ack) + if (g_atomic_int_add(&driver->nactive, 1) =3D=3D 0 && driver->inhibitC= allback) driver->inhibitCallback(true, driver->inhibitOpaque); =20 /* finally we can call the 'started' hook script if any */ diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index da9a640db5..41cbb67e3a 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -446,7 +446,7 @@ libxlReconnectDomain(virDomainObjPtr vm, virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_UNKNOWN); =20 - if (virAtomicIntInc(&driver->nactive) =3D=3D 0 && driver->inhibitCallb= ack) + if (g_atomic_int_add(&driver->nactive, 1) =3D=3D 0 && driver->inhibitC= allback) driver->inhibitCallback(true, driver->inhibitOpaque); =20 /* Enable domain death events */ diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 2e860e2fae..2bb2216dc0 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -1468,7 +1468,7 @@ int virLXCProcessStart(virConnectPtr conn, if (virCommandHandshakeNotify(cmd) < 0) goto cleanup; =20 - if (virAtomicIntInc(&driver->nactive) =3D=3D 0 && driver->inhibitCallb= ack) + if (g_atomic_int_add(&driver->nactive, 1) =3D=3D 0 && driver->inhibitC= allback) driver->inhibitCallback(true, driver->inhibitOpaque); =20 if (lxcContainerWaitForContinue(handshakefds[0]) < 0) { @@ -1670,7 +1670,7 @@ virLXCProcessReconnectDomain(virDomainObjPtr vm, virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_UNKNOWN); =20 - if (virAtomicIntInc(&driver->nactive) =3D=3D 0 && driver->inhibitC= allback) + if (g_atomic_int_add(&driver->nactive, 1) =3D=3D 0 && driver->inhi= bitCallback) driver->inhibitCallback(true, driver->inhibitOpaque); =20 if (!(priv->monitor =3D virLXCProcessConnectMonitor(driver, vm))) diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcp= snoop.c index b82779609d..f73913ec9e 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -541,7 +541,7 @@ virNWFilterSnoopReqLeaseTimerRun(virNWFilterSnoopReqPtr= req) static void virNWFilterSnoopReqGet(virNWFilterSnoopReqPtr req) { - virAtomicIntInc(&req->refctr); + g_atomic_int_add(&req->refctr, 1); } =20 /* @@ -756,7 +756,7 @@ virNWFilterSnoopReqLeaseAdd(virNWFilterSnoopReqPtr req, /* put the lease on the req's list */ virNWFilterSnoopIPLeaseTimerAdd(pl); =20 - virAtomicIntInc(&virNWFilterSnoopState.nLeases); + g_atomic_int_add(&virNWFilterSnoopState.nLeases, 1); =20 exit: if (update_leasefile) @@ -1172,7 +1172,7 @@ virNWFilterSnoopDHCPDecodeJobSubmit(virThreadPoolPtr = pool, ret =3D virThreadPoolSendJob(pool, 0, job); =20 if (ret =3D=3D 0) - virAtomicIntInc(qCtr); + g_atomic_int_add(qCtr, 1); else VIR_FREE(job); =20 @@ -1649,7 +1649,7 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr tech= driver, =20 threadPuts =3D true; =20 - virAtomicIntInc(&virNWFilterSnoopState.nThreads); + g_atomic_int_add(&virNWFilterSnoopState.nThreads, 1); =20 req->threadkey =3D virNWFilterSnoopActivate(req); if (!req->threadkey) { @@ -1777,7 +1777,7 @@ virNWFilterSnoopLeaseFileSave(virNWFilterSnoopIPLease= Ptr ipl) goto err_exit; =20 /* keep dead leases at < ~95% of file size */ - if (virAtomicIntInc(&virNWFilterSnoopState.wLeases) >=3D + if (g_atomic_int_add(&virNWFilterSnoopState.wLeases, 1) >=3D g_atomic_int_get(&virNWFilterSnoopState.nLeases) * 20) virNWFilterSnoopLeaseFileLoad(); /* load & refresh lease file */ =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 57a60c568a..20c4e3bb5d 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5571,7 +5571,7 @@ qemuProcessInit(virQEMUDriverPtr driver, qemuDomainSetFakeReboot(driver, vm, false); virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_STAR= TING_UP); =20 - if (virAtomicIntInc(&driver->nactive) =3D=3D 0 && driver->inhibitC= allback) + if (g_atomic_int_add(&driver->nactive, 1) =3D=3D 0 && driver->inhi= bitCallback) driver->inhibitCallback(true, driver->inhibitOpaque); =20 /* Run an early hook to set-up missing devices */ @@ -8146,7 +8146,7 @@ qemuProcessReconnect(void *opaque) goto error; } =20 - if (virAtomicIntInc(&driver->nactive) =3D=3D 0 && driver->inhibitCallb= ack) + if (g_atomic_int_add(&driver->nactive, 1) =3D=3D 0 && driver->inhibitC= allback) driver->inhibitCallback(true, driver->inhibitOpaque); =20 cleanup: diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 4e159157d7..ba157c0686 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -695,7 +695,7 @@ testDomainStartState(testDriverPtr privconn, int ret =3D -1; =20 virDomainObjSetState(dom, VIR_DOMAIN_RUNNING, reason); - dom->def->id =3D virAtomicIntInc(&privconn->nextDomID); + dom->def->id =3D g_atomic_int_add(&privconn->nextDomID, 1); =20 if (virDomainObjSetDefTransient(privconn->xmlopt, dom, NULL) < 0) { diff --git a/src/util/viratomic.h b/src/util/viratomic.h index 2811447a29..152cfcd903 100644 --- a/src/util/viratomic.h +++ b/src/util/viratomic.h @@ -26,17 +26,6 @@ =20 #include "internal.h" =20 -/** - * virAtomicIntInc: - * Increments the value of atomic by 1. - * - * Think of this operation as an atomic version of - * { tmp =3D *atomic; *atomic +=3D 1; return tmp; } - * - * This call acts as a full compiler and hardware memory barrier. - */ -#define virAtomicIntInc(i) g_atomic_int_add(i, 1) - /** * virAtomicIntDecAndTest: * Decrements the value of atomic by 1. diff --git a/src/util/virobject.c b/src/util/virobject.c index 8cece6e735..9185d3e92e 100644 --- a/src/util/virobject.c +++ b/src/util/virobject.c @@ -182,7 +182,7 @@ virClassNew(virClassPtr parent, goto error; =20 klass->parent =3D parent; - klass->magic =3D virAtomicIntInc(&magicCounter); + klass->magic =3D g_atomic_int_add(&magicCounter, 1); if (klass->magic > 0xCAFEFFFF) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("too many object classes defined")); @@ -382,7 +382,7 @@ virObjectRef(void *anyobj) =20 if (VIR_OBJECT_NOTVALID(obj)) return NULL; - virAtomicIntInc(&obj->u.s.refs); + g_atomic_int_add(&obj->u.s.refs, 1); PROBE(OBJECT_REF, "obj=3D%p", obj); return anyobj; } diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 60419538e2..689db4f19d 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -1048,7 +1048,7 @@ int virProcessGetStartTime(pid_t pid, unsigned long long *timestamp) { static int warned; - if (virAtomicIntInc(&warned) =3D=3D 0) { + if (g_atomic_int_add(&warned, 1) =3D=3D 0) { VIR_WARN("Process start time of pid %lld not available on this pla= tform", (long long) pid); } --=20 2.24.1 From nobody Thu May 9 01:12:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (205.139.110.61 [205.139.110.61]) by mx.zohomail.com with SMTPS id 1580539024546950.8424993665152; Fri, 31 Jan 2020 22:37:04 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-199-YweqnYBVPUKaI9mkSWcW4A-1; Sat, 01 Feb 2020 01:36:18 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 23BC9100551A; Sat, 1 Feb 2020 06:36:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E07905C1BB; Sat, 1 Feb 2020 06:36:12 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7C2F018089D7; Sat, 1 Feb 2020 06:36:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0116Y0gj012506 for ; Sat, 1 Feb 2020 01:34:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0440B84791; Sat, 1 Feb 2020 06:34:00 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-34.brq.redhat.com [10.40.204.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A70D77932 for ; Sat, 1 Feb 2020 06:33:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580539023; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=D8eZ56a4tn/qkkAzTGbnb9M9X6VcrqsurXHh6RD7QDQ=; b=GTIK9Ir//nEaxBqQBcj3K0SqH1laIDwNe7DFLOa6acSNxzKUSiETiIfY10Cqgwg9HBGQT1 y45QGIjxvhKt75jGAsKoGdfQKas814citWJu2o3Fsv0s5lLiG/rRA5wsZqfgMaNZwYr71m b2vIycnOFLzqjWt8WsNj0GZbYNx0LdE= From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 6/7] src: Drop virAtomicIntDecAndTest() with g_atomic_int_dec_and_test() Date: Sat, 1 Feb 2020 07:33:48 +0100 Message-Id: <2c276e00de80091b57842a300056256d51bb64bf.1580538782.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: YweqnYBVPUKaI9mkSWcW4A-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- 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, =20 priv->ignoreDeathEvent =3D false; =20 - if (virAtomicIntDecAndTest(&driver->nactive) && driver->inhibitCallbac= k) + if (!!g_atomic_int_dec_and_test(&driver->nactive) && driver->inhibitCa= llback) driver->inhibitCallback(false, driver->inhibitOpaque); =20 if ((vm->def->ngraphics =3D=3D 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 =3D -1; vm->def->id =3D -1; =20 - if (virAtomicIntDecAndTest(&driver->nactive) && driver->inhibitCallbac= k) + if (!!g_atomic_int_dec_and_test(&driver->nactive) && driver->inhibitCa= llback) driver->inhibitCallback(false, driver->inhibitOpaque); =20 virLXCDomainReAttachHostDevices(driver, vm->def); diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcp= snoop.c index f73913ec9e..c4341ee3e2 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -692,7 +692,7 @@ virNWFilterSnoopReqPut(virNWFilterSnoopReqPtr req) =20 virNWFilterSnoopLock(); =20 - 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); =20 - ignore_value(virAtomicIntDecAndTest(&virNWFilterSnoopState.nLeases)); + ignore_value(!!g_atomic_int_dec_and_test(&virNWFilterSnoopState.nLease= s)); =20 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); } =20 @@ -1543,7 +1543,7 @@ virNWFilterDHCPSnoopThread(void *req0) pcap_close(pcapConf[i].handle); } =20 - ignore_value(virAtomicIntDecAndTest(&virNWFilterSnoopState.nThreads)); + ignore_value(!!g_atomic_int_dec_and_test(&virNWFilterSnoopState.nThrea= ds)); =20 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, =20 qemuProcessBuildDestroyMemoryPaths(driver, vm, NULL, false); =20 - if (virAtomicIntDecAndTest(&driver->nactive) && driver->inhibitCallbac= k) + if (!!g_atomic_int_dec_and_test(&driver->nactive) && driver->inhibitCa= llback) driver->inhibitCallback(false, driver->inhibitOpaque); =20 /* 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 @@ =20 #include "internal.h" =20 -/** - * virAtomicIntDecAndTest: - * Decrements the value of atomic by 1. - * - * Think of this operation as an atomic version of - * { *atomic -=3D 1; return *atomic =3D=3D 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; =20 - bool lastRef =3D virAtomicIntDecAndTest(&obj->u.s.refs); + bool lastRef =3D !!g_atomic_int_dec_and_test(&obj->u.s.refs); PROBE(OBJECT_UNREF, "obj=3D%p", obj); if (lastRef) { PROBE(OBJECT_DISPOSE, "obj=3D%p", obj); --=20 2.24.1 From nobody Thu May 9 01:12:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580538986524853.8540640887582; Fri, 31 Jan 2020 22:36:26 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-65-2fOphmMPP7yalRw0XecicQ-1; Sat, 01 Feb 2020 01:36:23 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5FBB213E6; Sat, 1 Feb 2020 06:36:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2C17E86442; Sat, 1 Feb 2020 06:36:17 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CAE081808878; Sat, 1 Feb 2020 06:36:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0116Y063012511 for ; Sat, 1 Feb 2020 01:34:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id D593177932; Sat, 1 Feb 2020 06:34:00 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-34.brq.redhat.com [10.40.204.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 567A486420 for ; Sat, 1 Feb 2020 06:34:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580538985; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=D/Q0F43zJ/jT4CoLsVfi9mSSOM8Avh61mCW6uxskInI=; b=PrTW8kGwV+k3X6eM0FgGB+o1vw75EJM5eebmYpoSFSjh1GpJmJkEGfmvJFTfrtv54dbkqK IY+xvSfQ7xXOmVmU2SLTiGac1r8GiuaDMeaS6lFNYtbolEM3jrrnQ4LS6VsbPqehuIAU6s CnykJXXTpLLRGjcPfU+OJP/LKYPQB98= From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 7/7] Drop virAtomic module Date: Sat, 1 Feb 2020 07:33:49 +0100 Message-Id: <67ddbce46f9b2c6d5f9c63ac3adc9b492d487107.1580538782.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: 2fOphmMPP7yalRw0XecicQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Now, that every use of virAtomic was replaced with its g_atomic equivalent, let's remove the module. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- configure.ac | 1 - m4/virt-atomic.m4 | 77 -------------------------- src/Makefile.am | 6 --- src/libvirt_atomic.syms | 11 ---- src/libxl/libxl_domain.c | 1 - src/libxl/libxl_driver.c | 1 - src/lxc/lxc_process.c | 1 - src/nwfilter/nwfilter_dhcpsnoop.c | 1 - src/qemu/qemu_conf.c | 1 - src/qemu/qemu_domain.c | 1 - src/qemu/qemu_process.c | 1 - src/test/test_driver.c | 1 - src/util/Makefile.inc.am | 2 - src/util/viratomic.c | 35 ------------ src/util/viratomic.h | 90 ------------------------------- src/util/virobject.c | 1 - src/util/virprocess.c | 1 - src/util/virsystemd.c | 1 - 18 files changed, 233 deletions(-) delete mode 100644 m4/virt-atomic.m4 delete mode 100644 src/libvirt_atomic.syms delete mode 100644 src/util/viratomic.c delete mode 100644 src/util/viratomic.h diff --git a/configure.ac b/configure.ac index b1f75fa751..5bd9bc841a 100644 --- a/configure.ac +++ b/configure.ac @@ -302,7 +302,6 @@ LIBVIRT_ARG_YAJL =20 LIBVIRT_CHECK_ACL LIBVIRT_CHECK_APPARMOR -LIBVIRT_CHECK_ATOMIC LIBVIRT_CHECK_ATTR LIBVIRT_CHECK_AUDIT LIBVIRT_CHECK_BASH_COMPLETION diff --git a/m4/virt-atomic.m4 b/m4/virt-atomic.m4 deleted file mode 100644 index d96f7a2bac..0000000000 --- a/m4/virt-atomic.m4 +++ /dev/null @@ -1,77 +0,0 @@ -dnl The atomic implementation check -dnl -dnl Copyright (C) 2016 Red Hat, Inc. -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library. If not, see -dnl . -dnl - -AC_DEFUN([LIBVIRT_CHECK_ATOMIC], [ - AC_REQUIRE([LIBVIRT_CHECK_PTHREAD]) - - dnl We need to decide at configure time if libvirt will use real atomic - dnl operations ("lock free") or emulated ones with a mutex. - dnl - dnl Note that the atomic ops are only available with GCC on x86 when - dnl using -march=3Di486 or higher. If we detect that the atomic ops are - dnl not available but would be available given the right flags, we want - dnl to abort and advise the user to fix their CFLAGS. It's better to do - dnl that then to silently fall back on emulated atomic ops just because - dnl the user had the wrong build environment. - - atomic_ops=3D - - AC_MSG_CHECKING([for atomic ops implementation]) - - AC_TRY_COMPILE([], [__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4;],[ - atomic_ops=3Dgcc - ],[]) - - if test "$atomic_ops" =3D "" ; then - SAVE_CFLAGS=3D"${CFLAGS}" - CFLAGS=3D"-march=3Di486" - AC_TRY_COMPILE([], - [__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4;], - [AC_MSG_ERROR([Libvirt must be built with -march=3Di486= or later.])], - []) - CFLAGS=3D"${SAVE_CFLAGS}" - - case "$host" in - *-*-mingw* | *-*-msvc* ) - atomic_ops=3Dwin32 - ;; - *) - if test "$ac_cv_header_pthread_h" =3D "yes" ; then - atomic_ops=3Dpthread - else - AC_MSG_ERROR([Libvirt must be built with GCC or have pthread.h o= n non-Win32 platforms]) - fi - ;; - esac - fi - - case "$atomic_ops" in - gcc) - AC_DEFINE([VIR_ATOMIC_OPS_GCC],[1],[Use GCC atomic ops]) - ;; - win32) - AC_DEFINE([VIR_ATOMIC_OPS_WIN32],[1],[Use Win32 atomic ops]) - ;; - pthread) - AC_DEFINE([VIR_ATOMIC_OPS_PTHREAD],[1],[Use pthread atomic ops emula= tion]) - ;; - esac - AM_CONDITIONAL([WITH_ATOMIC_OPS_PTHREAD],[test "$atomic_ops" =3D "pthrea= d"]) - AC_MSG_RESULT([$atomic_ops]) -]) diff --git a/src/Makefile.am b/src/Makefile.am index 58355c5337..7bb6127ca4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -390,12 +390,6 @@ else ! WITH_SSH2 SYM_FILES +=3D $(srcdir)/libvirt_libssh2.syms endif ! WITH_SSH2 =20 -if WITH_ATOMIC_OPS_PTHREAD -USED_SYM_FILES +=3D $(srcdir)/libvirt_atomic.syms -else ! WITH_ATOMIC_OPS_PTHREAD -SYM_FILES +=3D $(srcdir)/libvirt_atomic.syms -endif ! WITH_ATOMIC_OPS_PTHREAD - if WITH_LIBSSH USED_SYM_FILES +=3D $(srcdir)/libvirt_libssh.syms else ! WITH_LIBSSH diff --git a/src/libvirt_atomic.syms b/src/libvirt_atomic.syms deleted file mode 100644 index e2c23637d1..0000000000 --- a/src/libvirt_atomic.syms +++ /dev/null @@ -1,11 +0,0 @@ -# -# These symbols are dependent upon !VIR_ATOMIC_OPS_GCC. -# - -# util/viratomic.h -virAtomicLock; - -# Let emacs know we want case-insensitive sorting -# Local Variables: -# sort-fold-case: t -# End: diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index d53363dc02..c8b68665af 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -26,7 +26,6 @@ #include "libxl_capabilities.h" =20 #include "viralloc.h" -#include "viratomic.h" #include "virfile.h" #include "virerror.h" #include "virhook.h" diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 41cbb67e3a..2b06f1be1e 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -50,7 +50,6 @@ #include "virstring.h" #include "virsysinfo.h" #include "viraccessapicheck.h" -#include "viratomic.h" #include "virhostdev.h" #include "virpidfile.h" #include "locking/domain_lock.h" diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index d8ddea6d24..da2541e684 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -48,7 +48,6 @@ #include "lxc_hostdev.h" #include "virhook.h" #include "virstring.h" -#include "viratomic.h" #include "virprocess.h" #include "virsystemd.h" #include "netdev_bandwidth_conf.h" diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcp= snoop.c index c4341ee3e2..e7f5b511ae 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -55,7 +55,6 @@ #include "nwfilter_ipaddrmap.h" #include "virnetdev.h" #include "virfile.h" -#include "viratomic.h" #include "virsocketaddr.h" #include "virthreadpool.h" #include "configmake.h" diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 0b119cbe78..024f3c1634 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -45,7 +45,6 @@ #include "virfile.h" #include "virsocket.h" #include "virstring.h" -#include "viratomic.h" #include "storage_conf.h" #include "configmake.h" =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d3045b4bcd..cb691ca048 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -51,7 +51,6 @@ #include "virstoragefile.h" #include "virstring.h" #include "virthreadjob.h" -#include "viratomic.h" #include "virprocess.h" #include "vircrypto.h" #include "virrandom.h" diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index ed14ce5ea2..ddcc763cfd 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -79,7 +79,6 @@ #include "virnetdevopenvswitch.h" #include "virnetdevmidonet.h" #include "virbitmap.h" -#include "viratomic.h" #include "virnuma.h" #include "virstring.h" #include "virhostdev.h" diff --git a/src/test/test_driver.c b/src/test/test_driver.c index ba157c0686..6a629988ef 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -59,7 +59,6 @@ #include "virstring.h" #include "cpu/cpu.h" #include "virauth.h" -#include "viratomic.h" #include "virdomainobjlist.h" #include "virinterfaceobj.h" #include "virhostcpu.h" diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am index 528c9f6cfe..2abdca548c 100644 --- a/src/util/Makefile.inc.am +++ b/src/util/Makefile.inc.am @@ -11,8 +11,6 @@ UTIL_SOURCES =3D \ util/virarch.h \ util/virarptable.c \ util/virarptable.h \ - util/viratomic.c \ - util/viratomic.h \ util/viraudit.c \ util/viraudit.h \ util/virauth.c \ diff --git a/src/util/viratomic.c b/src/util/viratomic.c deleted file mode 100644 index 278a749b6e..0000000000 --- a/src/util/viratomic.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * viratomic.c: atomic integer operations - * - * Copyright (C) 2012 Red Hat, Inc. - * - * Based on code taken from GLib 2.32, under the LGPLv2+ - * - * Copyright (C) 2011 Ryan Lortie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - */ - -#include - -#include "viratomic.h" - - -#ifdef VIR_ATOMIC_OPS_PTHREAD - -pthread_mutex_t virAtomicLock =3D PTHREAD_MUTEX_INITIALIZER; - -#endif diff --git a/src/util/viratomic.h b/src/util/viratomic.h deleted file mode 100644 index 1ddc7019f9..0000000000 --- a/src/util/viratomic.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * viratomic.h: atomic integer operations - * - * Copyright (C) 2012-2020 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see - * . - * - * APIs in this header should no longer be used. Direct - * use of the g_atomic APIs is preferred & existing code - * should be converted as needed. - */ - -#pragma once - -#include "internal.h" - -/** - * virAtomicIntCompareExchange: - * Compares atomic to oldval and, if equal, sets it to newval. If - * atomic was not equal to oldval then no change occurs. - * - * This compare and exchange is done atomically. - * - * Think of this operation as an atomic version of - * { if (*atomic =3D=3D oldval) { *atomic =3D newval; return true; } - * else return false; } - * - * This call acts as a full compiler and hardware memory barrier. - */ -#define virAtomicIntCompareExchange(i, oldi, newi) \ - (!!g_atomic_int_compare_and_exchange(i, oldi, newi)) - -/** - * virAtomicIntAdd: - * Atomically adds val to the value of atomic. - * - * Think of this operation as an atomic version of - * { tmp =3D *atomic; *atomic +=3D val; return tmp; } - * - * This call acts as a full compiler and hardware memory barrier. - */ -#define virAtomicIntAdd(i, v) g_atomic_int_add(i, v) - -/** - * virAtomicIntAnd: - * Performs an atomic bitwise 'and' of the value of atomic - * and val, storing the result back in atomic. - * - * This call acts as a full compiler and hardware memory barrier. - * - * Think of this operation as an atomic version of - * { tmp =3D *atomic; *atomic &=3D val; return tmp; } - */ -#define virAtomicIntAnd(i, v) g_atomic_int_and(i, v) - -/** - * virAtomicIntOr: - * Performs an atomic bitwise 'or' of the value of atomic - * and val, storing the result back in atomic. - * - * Think of this operation as an atomic version of - * { tmp =3D *atomic; *atomic |=3D val; return tmp; } - * - * This call acts as a full compiler and hardware memory barrier. - */ -#define virAtomicIntOr(i, v) g_atomic_int_or(i, v) - -/** - * virAtomicIntXor: - * Performs an atomic bitwise 'xor' of the value of atomic - * and val, storing the result back in atomic. - * - * Think of this operation as an atomic version of - * { tmp =3D *atomic; *atomic ^=3D val; return tmp; } - * - * This call acts as a full compiler and hardware memory barrier. - */ -#define virAtomicIntXor(i, v) g_atomic_int_xor(i, v) diff --git a/src/util/virobject.c b/src/util/virobject.c index 7749d89243..c71781550f 100644 --- a/src/util/virobject.c +++ b/src/util/virobject.c @@ -25,7 +25,6 @@ #include "virobject.h" #include "virthread.h" #include "viralloc.h" -#include "viratomic.h" #include "virerror.h" #include "virlog.h" #include "virprobe.h" diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 689db4f19d..23e149def4 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -57,7 +57,6 @@ # include #endif =20 -#include "viratomic.h" #include "virprocess.h" #include "virerror.h" #include "viralloc.h" diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c index 6b47f4fa36..1d41ed34f7 100644 --- a/src/util/virsystemd.c +++ b/src/util/virsystemd.c @@ -25,7 +25,6 @@ #include "virsystemdpriv.h" =20 #include "virsystemd.h" -#include "viratomic.h" #include "virbuffer.h" #include "virdbus.h" #include "virstring.h" --=20 2.24.1