File tree 14 files changed +39
-12
lines changed
utils/bazel/llvm-project-overlay/libc
14 files changed +39
-12
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ add_object_library(
44
44
DEPENDS
45
45
.message_mapper
46
46
.platform_errors
47
+ libc.src.__support.common
47
48
libc.src.__support.CPP.span
48
49
libc.src.__support.CPP.string_view
49
50
libc.src.__support.CPP.stringstream
@@ -60,6 +61,7 @@ add_object_library(
60
61
.message_mapper
61
62
.platform_signals
62
63
libc.include .signal
64
+ libc.src.__support.common
63
65
libc.src.__support.CPP.span
64
66
libc.src.__support.CPP.string_view
65
67
libc.src.__support.CPP.stringstream
Original file line number Diff line number Diff line change 14
14
#include " src/__support/CPP/stringstream.h"
15
15
#include " src/__support/StringUtil/message_mapper.h"
16
16
#include " src/__support/integer_to_string.h"
17
+ #include " src/__support/macros/attributes.h"
17
18
18
19
#include < stddef.h>
19
20
@@ -31,7 +32,7 @@ constexpr size_t max_buff_size() {
31
32
// This is to hold error strings that have to be custom built. It may be
32
33
// rewritten on every call to strerror (or other error to string function).
33
34
constexpr size_t ERR_BUFFER_SIZE = max_buff_size();
34
- thread_local char error_buffer[ERR_BUFFER_SIZE];
35
+ LIBC_THREAD_LOCAL char error_buffer[ERR_BUFFER_SIZE];
35
36
36
37
constexpr size_t TOTAL_STR_LEN = total_str_len(PLATFORM_ERRORS);
37
38
Original file line number Diff line number Diff line change 14
14
#include " src/__support/CPP/stringstream.h"
15
15
#include " src/__support/StringUtil/message_mapper.h"
16
16
#include " src/__support/integer_to_string.h"
17
+ #include " src/__support/macros/attributes.h"
17
18
18
19
#include < signal.h>
19
20
#include < stddef.h>
@@ -32,7 +33,7 @@ constexpr size_t max_buff_size() {
32
33
// This is to hold signal strings that have to be custom built. It may be
33
34
// rewritten on every call to strsignal (or other signal to string function).
34
35
constexpr size_t SIG_BUFFER_SIZE = max_buff_size();
35
- thread_local char signal_buffer[SIG_BUFFER_SIZE];
36
+ LIBC_THREAD_LOCAL char signal_buffer[SIG_BUFFER_SIZE];
36
37
37
38
constexpr size_t TOTAL_STR_LEN = total_str_len(PLATFORM_SIGNALS);
38
39
Original file line number Diff line number Diff line change 17
17
#ifndef LLVM_LIBC_SUPPORT_MACROS_ATTRIBUTES_H
18
18
#define LLVM_LIBC_SUPPORT_MACROS_ATTRIBUTES_H
19
19
20
+ #include " properties/architectures.h"
21
+
20
22
#define LIBC_INLINE inline
21
23
#define LIBC_INLINE_ASM __asm__ __volatile__
22
24
#define LIBC_UNUSED __attribute__ ((unused))
23
25
26
+ #ifdef LIBC_TARGET_ARCH_IS_GPU
27
+ #define LIBC_THREAD_LOCAL
28
+ #else
29
+ #define LIBC_THREAD_LOCAL thread_local
30
+ #endif
31
+
24
32
#endif // LLVM_LIBC_SUPPORT_MACROS_ATTRIBUTES_H
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ if(TARGET libc.src.__support.threads.${LIBC_TARGET_OS}.thread)
48
48
DEPENDS
49
49
.mutex
50
50
.${LIBC_TARGET_OS} .thread
51
+ libc.src.__support.common
51
52
libc.src.__support.fixedvector
52
53
libc.src.__support.CPP.array
53
54
libc.src.__support.CPP.optional
Original file line number Diff line number Diff line change 12
12
#include " src/__support/CPP/array.h"
13
13
#include " src/__support/CPP/optional.h"
14
14
#include " src/__support/fixedvector.h"
15
+ #include " src/__support/macros/attributes.h"
15
16
16
17
namespace __llvm_libc {
17
18
18
- thread_local Thread self;
19
+ LIBC_THREAD_LOCAL Thread self;
19
20
20
21
namespace {
21
22
@@ -99,7 +100,7 @@ struct TSSValueUnit {
99
100
: active(true ), payload(p), dtor(d) {}
100
101
};
101
102
102
- static thread_local cpp::array<TSSValueUnit, TSS_KEY_COUNT> tss_values;
103
+ static LIBC_THREAD_LOCAL cpp::array<TSSValueUnit, TSS_KEY_COUNT> tss_values;
103
104
104
105
} // anonymous namespace
105
106
@@ -128,7 +129,7 @@ class ThreadAtExitCallbackMgr {
128
129
}
129
130
};
130
131
131
- static thread_local ThreadAtExitCallbackMgr atexit_callback_mgr;
132
+ static LIBC_THREAD_LOCAL ThreadAtExitCallbackMgr atexit_callback_mgr;
132
133
133
134
// The function __cxa_thread_atexit is provided by C++ runtimes like libcxxabi.
134
135
// It is used by thread local object runtime to register destructor calls. To
Original file line number Diff line number Diff line change 13
13
#include " src/__support/CPP/optional.h"
14
14
#include " src/__support/CPP/string_view.h"
15
15
#include " src/__support/CPP/stringstream.h"
16
+ #include " src/__support/macros/attributes.h"
16
17
#include " src/__support/macros/properties/architectures.h"
17
18
18
19
#include < linux/param.h> // for exec_pagesize.
@@ -225,7 +226,7 @@ struct Thread {
225
226
int get_name (cpp::StringStream &name) const ;
226
227
};
227
228
228
- extern thread_local Thread self;
229
+ extern LIBC_THREAD_LOCAL Thread self;
229
230
230
231
// Platforms should implement this function.
231
232
[[noreturn]] void thread_exit (ThreadReturnValue retval, ThreadStyle style);
Original file line number Diff line number Diff line change @@ -6,4 +6,5 @@ add_entrypoint_object(
6
6
libc_errno.h # Include this
7
7
DEPENDS
8
8
libc.include .errno
9
+ libc.src.__support.common
9
10
)
Original file line number Diff line number Diff line change 6
6
//
7
7
// ===----------------------------------------------------------------------===//
8
8
9
+ #include " src/__support/macros/attributes.h"
9
10
#include " src/__support/macros/properties/architectures.h"
10
11
11
12
namespace __llvm_libc {
@@ -29,13 +30,13 @@ extern "C" {
29
30
#ifdef LIBC_TARGET_ARCH_IS_GPU
30
31
ErrnoConsumer __llvmlibc_errno;
31
32
#else
32
- thread_local int __llvmlibc_errno;
33
+ LIBC_THREAD_LOCAL int __llvmlibc_errno;
33
34
#endif // LIBC_TARGET_ARCH_IS_GPU
34
35
#else
35
36
#ifdef LIBC_TARGET_ARCH_IS_GPU
36
37
ErrnoConsumer __llvmlibc_internal_errno;
37
38
#else
38
- thread_local int __llvmlibc_internal_errno;
39
+ LIBC_THREAD_LOCAL int __llvmlibc_internal_errno;
39
40
#endif // LIBC_TARGET_ARCH_IS_GPU
40
41
#endif
41
42
} // extern "C"
Original file line number Diff line number Diff line change 9
9
#ifndef LLVM_LIBC_SRC_ERRNO_LLVMLIBC_ERRNO_H
10
10
#define LLVM_LIBC_SRC_ERRNO_LLVMLIBC_ERRNO_H
11
11
12
+ #include " src/__support/macros/attributes.h"
12
13
#include " src/__support/macros/properties/architectures.h"
13
14
14
15
#include < errno.h>
@@ -42,7 +43,7 @@ namespace __llvm_libc {
42
43
extern " C" ErrnoConsumer __llvmlibc_internal_errno;
43
44
#else // LIBC_TARGET_ARCH_IS_GPU
44
45
extern " C" {
45
- extern thread_local int __llvmlibc_internal_errno;
46
+ extern LIBC_THREAD_LOCAL int __llvmlibc_internal_errno;
46
47
} // extern "C"
47
48
#endif
48
49
Original file line number Diff line number Diff line change @@ -218,6 +218,8 @@ add_object_library(
218
218
rand_util.cpp
219
219
HDRS
220
220
rand_util.h
221
+ DEPENDS
222
+ libc.src.__support.common
221
223
)
222
224
223
225
add_entrypoint_object(
Original file line number Diff line number Diff line change 7
7
// ===----------------------------------------------------------------------===//
8
8
9
9
#include " src/stdlib/rand_util.h"
10
+ #include " src/__support/macros/attributes.h"
10
11
11
12
namespace __llvm_libc {
12
13
13
- thread_local unsigned long rand_next;
14
+ LIBC_THREAD_LOCAL unsigned long rand_next;
14
15
15
16
} // namespace __llvm_libc
Original file line number Diff line number Diff line change 9
9
#ifndef LLVM_LIBC_SRC_STDLIB_RAND_UTIL_H
10
10
#define LLVM_LIBC_SRC_STDLIB_RAND_UTIL_H
11
11
12
+ #include " src/__support/macros/attributes.h"
13
+
12
14
namespace __llvm_libc {
13
15
14
- extern thread_local unsigned long rand_next;
16
+ extern LIBC_THREAD_LOCAL unsigned long rand_next;
15
17
16
18
} // namespace __llvm_libc
17
19
Original file line number Diff line number Diff line change @@ -93,7 +93,10 @@ libc_support_library(
93
93
libc_support_library (
94
94
name = "__support_macros_attributes" ,
95
95
hdrs = ["src/__support/macros/attributes.h" ],
96
- deps = [":libc_root" ],
96
+ deps = [
97
+ ":__support_macros_properties_architectures" ,
98
+ ":libc_root"
99
+ ],
97
100
)
98
101
99
102
libc_support_library (
@@ -827,6 +830,7 @@ libc_function(
827
830
hdrs = ["src/errno/libc_errno.h" ],
828
831
deps = [
829
832
":__support_common" ,
833
+ ":__support_macros_attributes" ,
830
834
":__support_macros_properties_architectures" ,
831
835
],
832
836
)
You can’t perform that action at this time.
0 commit comments