Skip to content

Commit 1c66c3b

Browse files
committed
m4/ax_tls_support.m4: Check that thread-local pointers to classes are usable.
configure: Regenerate.
1 parent f00a99c commit 1c66c3b

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

configure

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10343,6 +10343,11 @@ else
1034310343
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1034410344
/* end confdefs.h. */
1034510345

10346+
// check that pointers to classes work as well
10347+
struct S { S () { } void foo () { } int member; };
10348+
extern thread_local S * p_s;
10349+
thread_local S * p_s = 0;
10350+
1034610351
extern thread_local int x;
1034710352
thread_local int * ptr = 0;
1034810353
int foo () { ptr = &x; return x; }
@@ -10353,6 +10358,7 @@ main ()
1035310358
{
1035410359
x = 2;
1035510360
foo ();
10361+
p_s = new S;
1035610362
;
1035710363
return 0;
1035810364
}
@@ -10394,6 +10400,11 @@ else
1039410400
#endif
1039510401
#endif
1039610402

10403+
// check that pointers to classes work as well
10404+
struct S { S () { } void foo () { } int member; };
10405+
extern __thread S * p_s;
10406+
__thread S * p_s = 0;
10407+
1039710408
extern __thread int x;
1039810409
__thread int * ptr = 0;
1039910410
int foo () { ptr = &x; return x; }
@@ -10404,6 +10415,7 @@ main ()
1040410415
{
1040510416
x = 2;
1040610417
foo ();
10418+
p_s = new S;
1040710419

1040810420
;
1040910421
return 0;
@@ -10446,6 +10458,11 @@ else
1044610458
# error Please fail.
1044710459
And extra please fail.
1044810460
#else
10461+
// check that pointers to classes work as well
10462+
struct S { S () { } void foo () { } int member; };
10463+
extern __declspec(thread) S * p_s;
10464+
__declspec(thread) S * p_s = 0;
10465+
1044910466
extern __declspec(thread) int x;
1045010467
__declspec(thread) int * ptr = 0;
1045110468
int foo () { ptr = &x; return x; }
@@ -10457,6 +10474,7 @@ main ()
1045710474
{
1045810475
x = 2;
1045910476
foo ();
10477+
p_s = new S;
1046010478
;
1046110479
return 0;
1046210480
}

m4/ax_tls_support.m4

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,19 @@ AC_CACHE_CHECK([for thread_local], [ac_cv_thread_local],
1515
AC_LINK_IFELSE(
1616
[AC_LANG_PROGRAM(
1717
[[
18+
// check that pointers to classes work as well
19+
struct S { S () { } void foo () { } int member; };
20+
extern thread_local S * p_s;
21+
thread_local S * p_s = 0;
22+
1823
extern thread_local int x;
1924
thread_local int * ptr = 0;
2025
int foo () { ptr = &x; return x; }
2126
thread_local int x = 1;
2227
]],
2328
[[x = 2;
24-
foo ();]])],
29+
foo ();
30+
p_s = new S;]])],
2531
[ac_cv_thread_local=yes
2632
ax_tls_support=yes],
2733
[ac_cv_thread_local=no],
@@ -43,13 +49,19 @@ AC_CACHE_CHECK([for __thread], [ac_cv__thread_keyword], [
4349
#endif
4450
#endif
4551
52+
// check that pointers to classes work as well
53+
struct S { S () { } void foo () { } int member; };
54+
extern __thread S * p_s;
55+
__thread S * p_s = 0;
56+
4657
extern __thread int x;
4758
__thread int * ptr = 0;
4859
int foo () { ptr = &x; return x; }
4960
__thread int x = 1;
5061
]],
5162
[[x = 2;
5263
foo ();
64+
p_s = new S;
5365
]])],
5466
[ac_cv__thread_keyword=yes
5567
ax_tls_support=yes],
@@ -71,14 +83,20 @@ AC_CACHE_CHECK([for __declspec(thread)], [ac_cv_declspec_thread], [
7183
# error Please fail.
7284
And extra please fail.
7385
#else
86+
// check that pointers to classes work as well
87+
struct S { S () { } void foo () { } int member; };
88+
extern __declspec(thread) S * p_s;
89+
__declspec(thread) S * p_s = 0;
90+
7491
extern __declspec(thread) int x;
7592
__declspec(thread) int * ptr = 0;
7693
int foo () { ptr = &x; return x; }
7794
__declspec(thread) int x = 1;
7895
#endif
7996
]],
8097
[[x = 2;
81-
foo ();]])],
98+
foo ();
99+
p_s = new S;]])],
82100
[ac_cv_declspec_thread=yes
83101
ax_tls_support=yes],
84102
[ac_cv_declspec_thread=no],

0 commit comments

Comments
 (0)