diff options
author | Markus Minichmayr <markus@tapkey.com> | 2022-10-10 19:01:06 +0200 |
---|---|---|
committer | Allen Winter <allen.winter@kdab.com> | 2022-11-22 05:12:15 -0500 |
commit | 108c485248f28557cd864dd13da9acd510758620 (patch) | |
tree | 761bfde85219d24452fc2151a652a87bea5b68e0 /config.h.cmake | |
parent | 2fdae45ec8f231bb418238f20556da2ad54d9d17 (diff) | |
download | libical-git-108c485248f28557cd864dd13da9acd510758620.tar.gz |
CMAKE option LIBICAL_SYNC_MODE_THREADLOCAL: Allow compiling all global variables with thread-local storage, thus avoiding the need for synchronization.
Diffstat (limited to 'config.h.cmake')
-rw-r--r-- | config.h.cmake | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/config.h.cmake b/config.h.cmake index 0e7306cc..93ac378d 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -583,5 +583,34 @@ typedef ssize_t IO_SSIZE_T; #define ICALMEMORY_DEFAULT_REALLOC realloc #define ICALMEMORY_DEFAULT_FREE free -/* ICAL_GLOBAL_VAR is applied to global variables, therefore allows specifying custom storage attributes. */ + +#cmakedefine LIBICAL_SYNCMODE_THREADLOCAL 1 + +#define ICAL_SYNC_MODE_NONE 1 +#define ICAL_SYNC_MODE_PTHREAD 2 +#define ICAL_SYNC_MODE_THREADLOCAL 3 + +#ifdef LIBICAL_SYNCMODE_THREADLOCAL +#define ICAL_SYNC_MODE ICAL_SYNC_MODE_THREADLOCAL +#elif HAVE_PTHREAD == 1 +#define ICAL_SYNC_MODE ICAL_SYNC_MODE_PTHREAD +#else +#define ICAL_SYNC_MODE ICAL_SYNC_MODE_NONE +#endif + +#if ICAL_SYNC_MODE == ICAL_SYNC_MODE_THREADLOCAL +#if defined(_MSC_VER) +#define ICAL_GLOBAL_VAR __declspec(thread) +#endif +#if defined(__GNUC__) +#define ICAL_GLOBAL_VAR __thread +#endif +#ifndef ICAL_GLOBAL_VAR +/* thread_local has been introduced with C11. Starting with C23 it will become a keyword and + we won't need to include threads.h then. */ +#include <threads.h> +#define ICAL_GLOBAL_VAR thread_local +#endif +#else #define ICAL_GLOBAL_VAR +#endif |