mirror of
https://github.com/json-c/json-c.git
synced 2026-04-07 22:39:08 +08:00
Merge pull request #617 from besser82/topic/besser82/option_disable_tls
Add an option to disable the use of thread-local storage.
This commit is contained in:
@@ -83,10 +83,11 @@ COMMAND make package_source
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Enable or disable features. By default, all features are turned off.
|
# Enable or disable features. By default, all features are turned off.
|
||||||
option(ENABLE_RDRAND "Enable RDRAND Hardware RNG Hash Seed" OFF)
|
option(DISABLE_BSYMBOLIC "Avoid linking with -Bsymbolic-function." OFF)
|
||||||
option(ENABLE_THREADING "Enable partial threading support." OFF)
|
option(DISABLE_THREAD_LOCAL_STORAGE "Disable using Thread-Local Storage (HAVE___THREAD)." OFF)
|
||||||
option(DISABLE_WERROR "Avoid treating compiler warnings as fatal errors" OFF)
|
option(DISABLE_WERROR "Avoid treating compiler warnings as fatal errors." OFF)
|
||||||
option(DISABLE_BSYMBOLIC "Avoid linking with -Bsymbolic-function" OFF)
|
option(ENABLE_RDRAND "Enable RDRAND Hardware RNG Hash Seed." OFF)
|
||||||
|
option(ENABLE_THREADING "Enable partial threading support." OFF)
|
||||||
|
|
||||||
if (UNIX OR MINGW OR CYGWIN)
|
if (UNIX OR MINGW OR CYGWIN)
|
||||||
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
|
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
|
||||||
@@ -217,14 +218,16 @@ check_c_source_compiles(
|
|||||||
"int main() { int i, x = 0; i = __sync_add_and_fetch(&x,1); return x; }"
|
"int main() { int i, x = 0; i = __sync_add_and_fetch(&x,1); return x; }"
|
||||||
HAVE_ATOMIC_BUILTINS)
|
HAVE_ATOMIC_BUILTINS)
|
||||||
|
|
||||||
check_c_source_compiles(
|
if (NOT DISABLE_THREAD_LOCAL_STORAGE)
|
||||||
"__thread int x = 0; int main() { return 0; }"
|
check_c_source_compiles(
|
||||||
HAVE___THREAD)
|
"__thread int x = 0; int main() { return 0; }"
|
||||||
|
HAVE___THREAD)
|
||||||
|
|
||||||
if (HAVE___THREAD)
|
if (HAVE___THREAD)
|
||||||
set(SPEC___THREAD __thread)
|
set(SPEC___THREAD __thread)
|
||||||
elseif (MSVC)
|
elseif (MSVC)
|
||||||
set(SPEC___THREAD __declspec(thread))
|
set(SPEC___THREAD __declspec(thread))
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Hardware random number is not available on Windows? Says, config.h.win32. Best to preserve compatibility.
|
# Hardware random number is not available on Windows? Says, config.h.win32. Best to preserve compatibility.
|
||||||
|
|||||||
21
README.md
21
README.md
@@ -93,16 +93,17 @@ CMake Options <a name="CMake"></a>
|
|||||||
The json-c library is built with [CMake](https://cmake.org/cmake-tutorial/),
|
The json-c library is built with [CMake](https://cmake.org/cmake-tutorial/),
|
||||||
which can take a few options.
|
which can take a few options.
|
||||||
|
|
||||||
Variable | Type | Description
|
Variable | Type | Description
|
||||||
---------------------|--------|--------------
|
-----------------------------|--------|--------------
|
||||||
CMAKE_INSTALL_PREFIX | String | The install location.
|
CMAKE_INSTALL_PREFIX | String | The install location.
|
||||||
CMAKE_BUILD_TYPE | String | Defaults to "debug"
|
CMAKE_BUILD_TYPE | String | Defaults to "debug".
|
||||||
BUILD_SHARED_LIBS | Bool | The default build generates a dynamic (dll/so) library. Set this to OFF to create a static library only.
|
BUILD_SHARED_LIBS | Bool | The default build generates a dynamic (dll/so) library. Set this to OFF to create a static library only.
|
||||||
BUILD_STATIC_LIBS | Bool | The default build generates a static (lib/a) library. Set this to OFF to create a shared library only.
|
BUILD_STATIC_LIBS | Bool | The default build generates a static (lib/a) library. Set this to OFF to create a shared library only.
|
||||||
ENABLE_RDRAND | Bool | Enable RDRAND Hardware RNG Hash Seed
|
DISABLE_BSYMBOLIC | Bool | Disable use of -Bsymbolic-functions.
|
||||||
ENABLE_THREADING | Bool | Enable partial threading support
|
DISABLE_THREAD_LOCAL_STORAGE | Bool | Disable use of Thread-Local Storage (HAVE___THREAD).
|
||||||
DISABLE_WERROR | Bool | Disable use of -Werror
|
DISABLE_WERROR | Bool | Disable use of -Werror.
|
||||||
DISABLE_BSYMBOLIC | Bool | Disable use of -Bsymbolic-functions
|
ENABLE_RDRAND | Bool | Enable RDRAND Hardware RNG Hash Seed.
|
||||||
|
ENABLE_THREADING | Bool | Enable partial threading support.
|
||||||
|
|
||||||
Pass these options as `-D` on CMake's command-line.
|
Pass these options as `-D` on CMake's command-line.
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ int main()
|
|||||||
#else
|
#else
|
||||||
// Just fake it up, so the output matches.
|
// Just fake it up, so the output matches.
|
||||||
printf("obj.to_string(with thread format)=%s\n", "T0.52X");
|
printf("obj.to_string(with thread format)=%s\n", "T0.52X");
|
||||||
|
printf("obj.to_string(long thread format)=%s\n", "Ttttttttttttt0.52xxxxxxxxxxxxxxxxxxX");
|
||||||
printf("obj.to_string(back to global format)=%s\n", "x0.524y");
|
printf("obj.to_string(back to global format)=%s\n", "x0.524y");
|
||||||
#endif
|
#endif
|
||||||
if (json_c_set_serialization_double_format(NULL, JSON_C_OPTION_GLOBAL) < 0)
|
if (json_c_set_serialization_double_format(NULL, JSON_C_OPTION_GLOBAL) < 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user