src/git/thread-utils.h


Log

Author Commit Date CI Message
Shawn O. Pearce d44cfd46 2008-12-31T13:16:31 Cleanup our header inclusion order to ensure pthread.h is early If we are using threads we need to make sure pthread.h comes in before just about anything else. Some platforms enable macros that alter what other headers define. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce a1d34bc0 2008-12-30T21:49:38 Support building on Mac OS X by using pthread_getspecific for TLS The Mach-O format does not permit gcc to implement the __thread TLS specification, so we must instead emulate it using a single int cell allocated from memory and stored inside of the thread specific data associated with the current pthread. What makes this tricky is git_errno must be a valid lvalue, so we really need to return a pointer to the caller and deference it as part of the git_errno macro. The GCC-specific __attribute__((constructor)) extension is used to ensure the pthread_key_t is allocated before any Git functions are executed in the library, as this is necessary to access our thread specific storage. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce b3039bee 2008-12-30T21:25:13 Cleanup formatting in our head files to be more consistent Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Ramsay Jones b72ca267 2008-11-29T19:21:24 Diasble TLS on cygwin Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Acked-by: Andreas Ericsson <ae@op5.se> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Ramsay Jones 17643760 2008-11-29T19:20:07 Use __CHECKER__ to detect when sparse is running Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Acked-by: Andreas Ericsson <ae@op5.se> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Andreas Ericsson ae234862 2008-11-18T22:20:15 Add an embryo of a TLS-aware error handling system This adds the per-thread global variable git_errno to the system, which callers can examine to get information about an error. Two helper functions are added to reduce LoC-count for the library code itself. Also, some exceptions are made for running sparse on GIT_TLS definitions, since it doesn't grok thread-local variables at all. Signed-off-by: Andreas Ericsson <ae@op5.se> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Andreas Ericsson 36f0f61f 2008-11-18T19:06:25 Add compiler/platform agnostic thread-local storage It doesn't cover all cases, but we can work on those as we go along. For now, gcc, MSVC++, Intel C/C++, IBM XL C/C++, Sun Studio C/C++ and Borland C++ Builder are the supported compilers (although we boldly assume that they all are of a recent enough version to support thread-local storage). This is intended to be used in upcoming patches that implement graceful (but TLS-dependant) error-handling in the library. As an added bonus, we also bring the online_cpus() function from git.git to detect the number of usable cpu's. Signed-off-by: Andreas Ericsson <ae@op5.se> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>