From 5f36bf12f93f480f1f957b884c8f7f69da64648c Mon Sep 17 00:00:00 2001 From: Markus Minichmayr Date: Mon, 10 Oct 2022 19:01:06 +0200 Subject: CMAKE option LIBICAL_SYNC_MODE_THREADLOCAL: Allow compiling all global variables with thread-local storage, thus avoiding the need for synchronization. --- src/test/icaltm_test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/test/icaltm_test.c') 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 +#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); -- cgit v1.2.1