Skip to content

Commit 373fb09

Browse files
authored
Merge pull request #10522 from oharboe/bazel-cpp-portability-scip
bazel: fix more latent C++ compiler errors surfaced on Ubuntu 26.04 LTS
2 parents 790d5d7 + f604ab0 commit 373fb09

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

MODULE.bazel

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,3 +266,12 @@ single_version_override(
266266
patches = ["//bazel:boost_context_disable_parse_headers.patch"],
267267
version = BOOST_VERSION,
268268
)
269+
270+
# scip 9.2.3's tinycthread uses bare C11 <threads.h> names. Backport
271+
# scipopt/scip@cc917e07 (TNY_ prefix) until a fixed release lands in BCR.
272+
single_version_override(
273+
module_name = "scip",
274+
patch_strip = 1,
275+
patches = ["//bazel:scip_tinycthread_tny_prefix.patch"],
276+
version = "9.2.3",
277+
)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Backport scipopt/scip@cc917e07: prefix tinycthread once_flag/call_once
2+
with TNY_ to avoid clash with C11 <threads.h>. Drop when included in a
3+
BCR scip release > 9.2.3.
4+
5+
diff --git a/src/tinycthread/tinycthread.c b/src/tinycthread/tinycthread.c
6+
--- a/src/tinycthread/tinycthread.c
7+
+++ b/src/tinycthread/tinycthread.c
8+
@@ -895,7 +895,7 @@ int _tthread_timespec_get(struct timespec *ts, int base)
9+
#endif /* _TTHREAD_EMULATE_TIMESPEC_GET_ */
10+
11+
#if defined(_TTHREAD_WIN32_)
12+
-void call_once(once_flag *flag, void (*func)(void))
13+
+void TNY_call_once(TNY_once_flag *flag, void (*func)(void))
14+
{
15+
/* The idea here is that we use a spin lock (via the
16+
InterlockedCompareExchange function) to restrict access to the
17+
diff --git a/src/tinycthread/tinycthread.h b/src/tinycthread/tinycthread.h
18+
--- a/src/tinycthread/tinycthread.h
19+
+++ b/src/tinycthread/tinycthread.h
20+
@@ -447,11 +447,11 @@ int tss_set(tss_t key, void *val);
21+
typedef struct {
22+
LONG volatile status;
23+
CRITICAL_SECTION lock;
24+
- } once_flag;
25+
- #define ONCE_FLAG_INIT {0,}
26+
+ } TNY_once_flag;
27+
+ #define TNY_ONCE_FLAG_INIT {0,}
28+
#else
29+
- #define once_flag pthread_once_t
30+
- #define ONCE_FLAG_INIT PTHREAD_ONCE_INIT
31+
+ #define TNY_once_flag pthread_once_t
32+
+ #define TNY_ONCE_FLAG_INIT PTHREAD_ONCE_INIT
33+
#endif
34+
35+
/** Invoke a callback exactly once
36+
@@ -460,9 +460,9 @@ int tss_set(tss_t key, void *val);
37+
* @param func Callback to invoke.
38+
*/
39+
#if defined(_TTHREAD_WIN32_)
40+
- void call_once(once_flag *flag, void (*func)(void));
41+
+ void TNY_call_once(TNY_once_flag *flag, void (*func)(void));
42+
#else
43+
- #define call_once(flag,func) pthread_once(flag,func)
44+
+ #define TNY_call_once(flag,func) pthread_once(flag,func)
45+
#endif
46+
47+
#ifdef __cplusplus

0 commit comments

Comments
 (0)