summaryrefslogtreecommitdiff
path: root/src/test/icaltm_test.c
diff options
context:
space:
mode:
authorMarkus Minichmayr <markus@tapkey.com>2022-10-10 19:01:06 +0200
committerMarkus Minichmayr <markus@tapkey.com>2022-11-21 23:04:29 +0100
commit5f36bf12f93f480f1f957b884c8f7f69da64648c (patch)
tree761bfde85219d24452fc2151a652a87bea5b68e0 /src/test/icaltm_test.c
parente3b0f174abbf03962c6cb42db44ec23452b1784c (diff)
downloadlibical-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 'src/test/icaltm_test.c')
-rw-r--r--src/test/icaltm_test.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test/icaltm_test.c b/src/test/icaltm_test.c
index 74bea858..e98e7f6a 100644
--- a/src/test/icaltm_test.c
+++ b/src/test/icaltm_test.c
@@ -16,7 +16,9 @@
#include <pthread.h>
+#if ICAL_SYNC_MODE != ICAL_SYNC_MODE_THREADLOCAL
static icaltimezone *zone, *utc;
+#endif
static void *test_tread(void *user_data)
{
@@ -24,6 +26,14 @@ static void *test_tread(void *user_data)
int ii;
_unused(user_data);
+
+#if ICAL_SYNC_MODE == ICAL_SYNC_MODE_THREADLOCAL
+ // In thread-local mode all initialization must be done per thread, so we do it here, rather
+ // than in main().
+ icaltimezone* zone = icaltimezone_get_builtin_timezone("America/New_York");
+ icaltimezone* utc = icaltimezone_get_utc_timezone();
+#endif
+
itt = icaltime_from_string("19710203T040506");
itt.zone = zone;
@@ -39,8 +49,12 @@ int main(void)
pthread_t thread[2];
int ii;
+#if ICAL_SYNC_MODE != ICAL_SYNC_MODE_THREADLOCAL
+ // In thread-local mode all initialization must be done per thread.
+ // In all other modes we do the initialization of built in timezones here.
zone = icaltimezone_get_builtin_timezone("America/New_York");
utc = icaltimezone_get_utc_timezone();
+#endif
for (ii = 0; ii < 2; ii++) {
pthread_create(&thread[ii], NULL, test_tread, NULL);