Use __CHECKER__ to detect when sparse is running
[libgit2.git] / src / git / thread-utils.h
blobbc4153d7a1038ee96648f97f75aff45c22501412
1 #ifndef INCLUDE_git_thread_utils_h__
2 #define INCLUDE_git_thread_utils_h__
3 /*
4 * How TLS works is compiler+platform dependant
5 * Sources: http://en.wikipedia.org/wiki/Thread-Specific_Storage
6 * http://predef.sourceforge.net/precomp.html
7 */
8 #define GIT_HAS_TLS 1
9 #if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) || \
10 defined(__xlc__) || defined(__xlC__)
11 # define GIT_TLS __thread
12 #elif defined(__INTEL_COMPILER)
13 # if defined(_WIN32) || defined(_WIN32_CE)
14 # define GIT_TLS __declspec(thread)
15 # else
16 # define GIT_TLS __thread
17 # endif
18 #elif defined(_WIN32) || defined(_WIN32_CE) || defined(__BORLANDC__)
19 # define GIT_TLS __declspec(thread)
20 #else
21 # undef GIT_HAS_TLS
22 # define GIT_TLS /* nothing: tls vars are thread-global */
23 #endif
25 /* sparse doesn't grok thread-local variables */
26 #if defined(__CHECKER__)
27 # undef GIT_HAS_TLS
28 # undef GIT_TLS
29 # define GIT_TLS
30 #endif
32 #endif /* INCLUDE_git_thread_utils_h__ */