Skip to content

Commit 7b776b5

Browse files
Ethan NicholasSkia Commit-Bot
Ethan Nicholas
authored and
Skia Commit-Bot
committed
Created SKSL_USE_THREAD_LOCAL define
Upcoming CLs are going to add more thread_locals to SkSL, so it makes sense to bake this test into a convenient define. Change-Id: I5c878b16ecc0cd6f5dfeab37d16734cb9fd270bd Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339717 Commit-Queue: Ethan Nicholas <[email protected]> Commit-Queue: John Stiles <[email protected]> Auto-Submit: Ethan Nicholas <[email protected]> Reviewed-by: John Stiles <[email protected]>
1 parent 0c2cc23 commit 7b776b5

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

src/sksl/SkSLDefines.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@
2828
#define NORETURN __attribute__((__noreturn__))
2929
#endif
3030

31+
#if defined(SK_BUILD_FOR_IOS) && \
32+
(!defined(__IPHONE_9_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0)
33+
#define SKSL_USE_THREAD_LOCAL 0
34+
#else
35+
#define SKSL_USE_THREAD_LOCAL 1
36+
#endif
37+
3138
using SKSL_INT = int32_t;
3239
using SKSL_FLOAT = float;
3340

src/sksl/SkSLPool.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,25 @@
77

88
#include "src/sksl/SkSLPool.h"
99

10+
#include "src/sksl/SkSLDefines.h"
11+
1012
#define VLOG(...) // printf(__VA_ARGS__)
1113

1214
namespace SkSL {
1315

14-
#if defined(SK_BUILD_FOR_IOS) && \
15-
(!defined(__IPHONE_9_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0)
16+
#if SKSL_USE_THREAD_LOCAL
17+
18+
static thread_local MemoryPool* sMemPool = nullptr;
19+
20+
static MemoryPool* get_thread_local_memory_pool() {
21+
return sMemPool;
22+
}
23+
24+
static void set_thread_local_memory_pool(MemoryPool* memPool) {
25+
sMemPool = memPool;
26+
}
27+
28+
#else
1629

1730
#include <pthread.h>
1831

@@ -36,19 +49,7 @@ static void set_thread_local_memory_pool(MemoryPool* poolData) {
3649
pthread_setspecific(get_pthread_key(), poolData);
3750
}
3851

39-
#else
40-
41-
static thread_local MemoryPool* sMemPool = nullptr;
42-
43-
static MemoryPool* get_thread_local_memory_pool() {
44-
return sMemPool;
45-
}
46-
47-
static void set_thread_local_memory_pool(MemoryPool* memPool) {
48-
sMemPool = memPool;
49-
}
50-
51-
#endif
52+
#endif // SKSL_USE_THREAD_LOCAL
5253

5354
Pool::~Pool() {
5455
if (get_thread_local_memory_pool() == fMemPool.get()) {

0 commit comments

Comments
 (0)