Skip to content

Commit 0ed9aaa

Browse files
andrewkatsonJames Sharpe
andauthored
Add in custom glib patch (#1211)
Co-authored-by: James Sharpe <[email protected]>
1 parent df265bb commit 0ed9aaa

File tree

2 files changed

+126
-0
lines changed

2 files changed

+126
-0
lines changed

toolchains/built_toolchains.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,9 @@ cc_import(
320320

321321
# This patch is required as rules_foreign_cc runs in MSYS2 on Windows and MSYS2's "mkdir" is used
322322
Label("//toolchains:pkgconfig-makefile-vc.patch"),
323+
324+
# This patch fixes explicit integer conversion which causes errors in clang >= 15 and gcc >= 14
325+
Label("//toolchains:pkgconfig-builtin-glib-int-conversion.patch"),
323326
],
324327
urls = [
325328
"https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz",
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
diff -Naur glib/glib/gatomic.c glib/glib/gatomic.c
2+
--- glib/glib/gatomic.c 2016-04-11 21:39:26.000000000 +0000
3+
+++ glib/glib/gatomic.c 2024-05-03 18:15:37.295886468 +0000
4+
@@ -385,7 +385,7 @@
5+
*
6+
* Since: 2.30
7+
**/
8+
-gssize
9+
+gintptr
10+
(g_atomic_pointer_add) (volatile void *atomic,
11+
gssize val)
12+
{
13+
@@ -409,11 +409,11 @@
14+
*
15+
* Since: 2.30
16+
**/
17+
-gsize
18+
+guintptr
19+
(g_atomic_pointer_and) (volatile void *atomic,
20+
gsize val)
21+
{
22+
- return g_atomic_pointer_and ((volatile gpointer *) atomic, val);
23+
+ return g_atomic_pointer_and ((gpointer *) atomic, val);
24+
}
25+
26+
/**
27+
@@ -433,11 +433,11 @@
28+
*
29+
* Since: 2.30
30+
**/
31+
-gsize
32+
+guintptr
33+
(g_atomic_pointer_or) (volatile void *atomic,
34+
gsize val)
35+
{
36+
- return g_atomic_pointer_or ((volatile gpointer *) atomic, val);
37+
+ return g_atomic_pointer_or ((gpointer *) atomic, val);
38+
}
39+
40+
/**
41+
@@ -457,11 +457,11 @@
42+
*
43+
* Since: 2.30
44+
**/
45+
-gsize
46+
+guintptr
47+
(g_atomic_pointer_xor) (volatile void *atomic,
48+
gsize val)
49+
{
50+
- return g_atomic_pointer_xor ((volatile gpointer *) atomic, val);
51+
+ return g_atomic_pointer_xor ((gpointer *) atomic, val);
52+
}
53+
54+
#elif defined (G_PLATFORM_WIN32)
55+
diff -Naur glib/glib/gatomic.h glib/glib/gatomic.h
56+
--- glib/glib/gatomic.h 2016-04-11 21:39:26.000000000 +0000
57+
+++ glib/glib/gatomic.h 2024-05-03 18:15:37.295886468 +0000
58+
@@ -66,16 +66,16 @@
59+
gpointer oldval,
60+
gpointer newval);
61+
GLIB_AVAILABLE_IN_ALL
62+
-gssize g_atomic_pointer_add (volatile void *atomic,
63+
+gintptr g_atomic_pointer_add (volatile void *atomic,
64+
gssize val);
65+
GLIB_AVAILABLE_IN_2_30
66+
-gsize g_atomic_pointer_and (volatile void *atomic,
67+
+guintptr g_atomic_pointer_and (volatile void *atomic,
68+
gsize val);
69+
GLIB_AVAILABLE_IN_2_30
70+
-gsize g_atomic_pointer_or (volatile void *atomic,
71+
+guintptr g_atomic_pointer_or (volatile void *atomic,
72+
gsize val);
73+
GLIB_AVAILABLE_IN_ALL
74+
-gsize g_atomic_pointer_xor (volatile void *atomic,
75+
+guintptr g_atomic_pointer_xor (volatile void *atomic,
76+
gsize val);
77+
78+
GLIB_DEPRECATED_IN_2_30_FOR(g_atomic_add)
79+
@@ -167,28 +167,34 @@
80+
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
81+
(void) (0 ? (gpointer) *(atomic) : 0); \
82+
(void) (0 ? (val) ^ (val) : 0); \
83+
- (gssize) __sync_fetch_and_add ((atomic), (val)); \
84+
+ (guintptr) __atomic_fetch_add ((atomic), (val), __ATOMIC_SEQ_CST); \
85+
}))
86+
#define g_atomic_pointer_and(atomic, val) \
87+
(G_GNUC_EXTENSION ({ \
88+
+ guintptr *gapa_atomic = (guintptr *) atomic; \
89+
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
90+
- (void) (0 ? (gpointer) *(atomic) : 0); \
91+
- (void) (0 ? (val) ^ (val) : 0); \
92+
- (gsize) __sync_fetch_and_and ((atomic), (val)); \
93+
+ G_STATIC_ASSERT (sizeof *(atomic) == sizeof (guintptr)); \
94+
+ (void) (0 ? (gpointer) *(atomic) : NULL); \
95+
+ (void) (0 ? (val) ^ (val) : 1); \
96+
+ (guintptr) __atomic_fetch_and (gapa_atomic, (val), __ATOMIC_SEQ_CST); \
97+
}))
98+
#define g_atomic_pointer_or(atomic, val) \
99+
(G_GNUC_EXTENSION ({ \
100+
+ guintptr *gapa_atomic = (guintptr *) atomic; \
101+
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
102+
- (void) (0 ? (gpointer) *(atomic) : 0); \
103+
- (void) (0 ? (val) ^ (val) : 0); \
104+
- (gsize) __sync_fetch_and_or ((atomic), (val)); \
105+
+ G_STATIC_ASSERT (sizeof *(atomic) == sizeof (guintptr)); \
106+
+ (void) (0 ? (gpointer) *(atomic) : NULL); \
107+
+ (void) (0 ? (val) ^ (val) : 1); \
108+
+ (guintptr) __atomic_fetch_or (gapa_atomic, (val), __ATOMIC_SEQ_CST); \
109+
}))
110+
#define g_atomic_pointer_xor(atomic, val) \
111+
(G_GNUC_EXTENSION ({ \
112+
+ guintptr *gapa_atomic = (guintptr *) atomic; \
113+
G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \
114+
- (void) (0 ? (gpointer) *(atomic) : 0); \
115+
- (void) (0 ? (val) ^ (val) : 0); \
116+
- (gsize) __sync_fetch_and_xor ((atomic), (val)); \
117+
+ G_STATIC_ASSERT (sizeof *(atomic) == sizeof (guintptr)); \
118+
+ (void) (0 ? (gpointer) *(atomic) : NULL); \
119+
+ (void) (0 ? (val) ^ (val) : 1); \
120+
+ (guintptr) __atomic_fetch_xor (gapa_atomic, (val), __ATOMIC_SEQ_CST); \
121+
}))
122+
123+
#else /* defined(G_ATOMIC_LOCK_FREE) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) */

0 commit comments

Comments
 (0)