diff options
author | Markus Minichmayr <markus@tapkey.com> | 2022-10-10 19:01:06 +0200 |
---|---|---|
committer | Markus Minichmayr <markus@tapkey.com> | 2022-11-21 23:04:29 +0100 |
commit | 5f36bf12f93f480f1f957b884c8f7f69da64648c (patch) | |
tree | 761bfde85219d24452fc2151a652a87bea5b68e0 /config.h.cmake | |
parent | e3b0f174abbf03962c6cb42db44ec23452b1784c (diff) | |
download | libical-git-concurrency_mode_threadlocal.tar.gz |
CMAKE option LIBICAL_SYNC_MODE_THREADLOCAL: Allow compiling all global variables with thread-local storage, thus avoiding the need for synchronization.concurrency_mode_threadlocal
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 |