Skip to contentSkip to conversation

glib-2.0: Backport patches C++ variant of g_atomic_int_compare_and_exchange()

PATCH New Khem Raj 1 participant 1 message Apr 1, 2022

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 glib-2.0: Backport patches C++ variant of g_atomic_int_compare_and_exchange()

This fixes a regression when glib-2.0 was used with clang.

---
 ...s-for-typechecking-with-atomic-compa.patch | 64 +++++++++++++++++
 ...variant-of-g_atomic_int_compare_and_.patch | 70 +++++++++++++++++++
 meta/recipes-core/glib-2.0/glib-2.0_2.72.0.bb |  2 +
 3 files changed, 136 insertions(+)
 create mode 100644 meta/recipes-core/glib-2.0/glib-2.0/0001-tests-Add-C-tests-for-typechecking-with-atomic-compa.patch
 create mode 100644 meta/recipes-core/glib-2.0/glib-2.0/0002-gatomic-Add-a-C-variant-of-g_atomic_int_compare_and_.patch
meta/recipes-core/glib-2.0/glib-2.0/0001-tests-Add-C-tests-for-typechecking-with-atomic-compa.patch new file +64 -0
new file mode 100644
index 00000000000..4842f462e14
@@ -0,0 +1,64 @@
+From 44b4bcd56d7ac2bd8ebf00e9fa433ad897d68216 Mon Sep 17 00:00:00 2001
+From: Philip Withnall <[email protected]>
+Date: Fri, 1 Apr 2022 13:44:45 +0100
+Subject: [PATCH 1/2] tests: Add C++ tests for typechecking with atomic compare
+ and exchanges
+
+Signed-off-by: Philip Withnall <[email protected]>
+
+Helps: #2625
+Upstream-Status: Submitted [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2578]
+Signed-off-by: Khem Raj <[email protected]>
+---
+ glib/tests/cxx.cpp | 28 ++++++++++++++++++++++++++++
+ 1 file changed, 28 insertions(+)
+
+diff --git a/glib/tests/cxx.cpp b/glib/tests/cxx.cpp
+index be0a6bfa1..7d7f27c91 100644
+--- a/glib/tests/cxx.cpp
++++ b/glib/tests/cxx.cpp
+@@ -53,6 +53,32 @@ test_typeof (void)
+ #endif
+ }
+ 
++static void
++test_atomic_pointer_compare_and_exchange (void)
++{
++  const gchar *str1 = "str1";
++  const gchar *str2 = "str2";
++  const gchar *atomic_string = str1;
++
++  g_test_message ("Test that g_atomic_pointer_compare_and_exchange() with a "
++                  "non-void* pointer doesn’t have any compiler warnings in C++ mode");
++
++  g_assert_true (g_atomic_pointer_compare_and_exchange (&atomic_string, str1, str2));
++  g_assert_true (atomic_string == str2);
++}
++
++static void
++test_atomic_int_compare_and_exchange (void)
++{
++  gint atomic_int = 5;
++
++  g_test_message ("Test that g_atomic_int_compare_and_exchange() doesn’t have "
++                  "any compiler warnings in C++ mode");
++
++  g_assert_true (g_atomic_int_compare_and_exchange (&atomic_int, 5, 50));
++  g_assert_cmpint (atomic_int, ==, 50);
++}
++
+ int
+ main (int argc, char *argv[])
+ {
+@@ -63,6 +89,8 @@ main (int argc, char *argv[])
+ #endif
+ 
+   g_test_add_func ("/C++/typeof", test_typeof);
++  g_test_add_func ("/C++/atomic-pointer-compare-and-exchange", test_atomic_pointer_compare_and_exchange);
++  g_test_add_func ("/C++/atomic-int-compare-and-exchange", test_atomic_int_compare_and_exchange);
+ 
+   return g_test_run ();
+ }
+-- 
+2.35.1
+
meta/recipes-core/glib-2.0/glib-2.0/0002-gatomic-Add-a-C-variant-of-g_atomic_int_compare_and_.patch new file +70 -0

70 lines not on this page · raw message

meta/recipes-core/glib-2.0/glib-2.0_2.72.0.bb +2 -0
index 8b7016ec0fe..62479e3c3f6 100644
@@ -16,6 +16,8 @@ SRC_URI = "${GNOME_MIRROR}/glib/${SHRT_VER}/glib-${PV}.tar.xz \
            file://0001-Do-not-write-bindir-into-pkg-config-files.patch \
            file://0001-meson-Run-atomics-test-on-clang-as-well.patch \
            file://0001-gio-tests-resources.c-comment-out-a-build-host-only-.patch \
+           file://0001-tests-Add-C-tests-for-typechecking-with-atomic-compa.patch \
+           file://0002-gatomic-Add-a-C-variant-of-g_atomic_int_compare_and_.patch \
            "
 SRC_URI:append:class-native = " file://relocate-modules.patch"
 
Signature · 1 line
2.35.1