xref: /OK3568_Linux_fs/buildroot/package/liburcu/0002-fix-don-t-use-C-thread_local-on-MacOs.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunFrom e915ab84fd0c02d37504f3eb1e1f3be93ea6dc37 Mon Sep 17 00:00:00 2001
2*4882a593SmuzhiyunFrom: Michael Jeanson <mjeanson@efficios.com>
3*4882a593SmuzhiyunDate: Thu, 9 Sep 2021 12:11:16 -0400
4*4882a593SmuzhiyunSubject: [PATCH] fix: don't use C++ thread_local on MacOs
5*4882a593Smuzhiyun
6*4882a593SmuzhiyunRecent versions of Apple's clang++ do support 'thread_local' but the
7*4882a593Smuzhiyunimplementation generates additional helper symbols. This is a problem
8*4882a593Smuzhiyunwhen accessing an extern TLS variable in a C++ compile unit that is
9*4882a593Smuzhiyunprovided by a C library that doesn't have those extra symbols.
10*4882a593Smuzhiyun
11*4882a593SmuzhiyunFallback to using '__thread' on MacOs.
12*4882a593Smuzhiyun
13*4882a593SmuzhiyunChange-Id: I87cb5b3c9293f7bf66f7115f453b546dd793a449
14*4882a593SmuzhiyunSigned-off-by: Michael Jeanson <mjeanson@efficios.com>
15*4882a593SmuzhiyunSigned-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun[Retrieved from:
18*4882a593Smuzhiyunhttps://github.com/urcu/userspace-rcu/commit/e915ab84fd0c02d37504f3eb1e1f3be93ea6dc37]
19*4882a593SmuzhiyunSigned-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
20*4882a593Smuzhiyun---
21*4882a593Smuzhiyun include/urcu/tls-compat.h | 7 ++++++-
22*4882a593Smuzhiyun 1 file changed, 6 insertions(+), 1 deletion(-)
23*4882a593Smuzhiyun
24*4882a593Smuzhiyundiff --git a/include/urcu/tls-compat.h b/include/urcu/tls-compat.h
25*4882a593Smuzhiyunindex 24ef1b9a..25cf375a 100644
26*4882a593Smuzhiyun--- a/include/urcu/tls-compat.h
27*4882a593Smuzhiyun+++ b/include/urcu/tls-compat.h
28*4882a593Smuzhiyun@@ -34,7 +34,12 @@ extern "C" {
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun #ifdef CONFIG_RCU_TLS
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun-#if defined (__cplusplus) && (__cplusplus >= 201103L)
33*4882a593Smuzhiyun+/*
34*4882a593Smuzhiyun+ * Don't use C++ 'thread_local' on MacOs, the implementation is incompatible
35*4882a593Smuzhiyun+ * with C and will result in a link error when accessing an extern variable
36*4882a593Smuzhiyun+ * provided by the C library from C++ code.
37*4882a593Smuzhiyun+ */
38*4882a593Smuzhiyun+#if defined (__cplusplus) && (__cplusplus >= 201103L) && !defined(__APPLE__)
39*4882a593Smuzhiyun # define URCU_TLS_STORAGE_CLASS	thread_local
40*4882a593Smuzhiyun #elif defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
41*4882a593Smuzhiyun # define URCU_TLS_STORAGE_CLASS	_Thread_local
42