aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/include
diff options
context:
space:
mode:
authorCalvin Rose <calsrose@gmail.com>2025-05-11 08:37:15 -0500
committerCalvin Rose <calsrose@gmail.com>2025-05-11 08:37:15 -0500
commit3d3e880f52e4b40540b7722b6fc0f58aa5bd7443 (patch)
tree41e08f9851fa965077bcaf94583fe14aff85c605 /src/include
parentMerge pull request #1594 from sogaiu/tweak-docstrings (diff)
Allow configuration of JANET_THREAD_LOCAL. Address #1595
This is to better allow configuration on various, unknown compilers. Previously, we hardcoded how thread local storage was specified for a few different compilers, but we were not following and C standard. In C11, there is a standardized storage specifier _Thread_local for this storage class, however this is now deprecated in various C++ compilers for a new keyword, confusingly. Janet also does not claim to require the C11 standard, so for maximum flexibilty, the storage specifier must be specified at configure time.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/janet.h8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/include/janet.h b/src/include/janet.h
index 672552d1..8e6ca968 100644
--- a/src/include/janet.h
+++ b/src/include/janet.h
@@ -170,14 +170,12 @@ extern "C" {
/* Also enable the thread library only if not single-threaded */
#ifdef JANET_SINGLE_THREADED
#define JANET_THREAD_LOCAL
-#undef JANET_THREADS
-#elif defined(__GNUC__)
+#elif !(defined(JANET_THREAD_LOCAL)) && defined(__GNUC__)
#define JANET_THREAD_LOCAL __thread
-#elif defined(_MSC_BUILD)
+#elif !(defined(JANET_THREAD_LOCAL)) && defined(_MSC_BUILD)
#define JANET_THREAD_LOCAL __declspec(thread)
-#else
+#elif !(defined(JANET_THREAD_LOCAL))
#define JANET_THREAD_LOCAL
-#undef JANET_THREADS
#endif
/* Enable or disable dynamic module loading. Enabled by default. */