From: <ric...@us...> - 2009-11-02 05:34:28
|
Revision: 1045 http://loki-lib.svn.sourceforge.net/loki-lib/?rev=1045&view=rev Author: rich_sposato Date: 2009-11-02 05:34:21 +0000 (Mon, 02 Nov 2009) Log Message: ----------- Added new header to Loki. Added Paths: ----------- trunk/include/loki/ThreadLocal.h Added: trunk/include/loki/ThreadLocal.h =================================================================== --- trunk/include/loki/ThreadLocal.h (rev 0) +++ trunk/include/loki/ThreadLocal.h 2009-11-02 05:34:21 UTC (rev 1045) @@ -0,0 +1,69 @@ +//////////////////////////////////////////////////////////////////////////////// +// The Loki Library +// Copyright (c) 2009 by Rich Sposato +// Permission to use, copy, modify, distribute and sell this software for any +// purpose is hereby granted without fee, provided that the above copyright +// notice appear in all copies and that both that copyright notice and this +// permission notice appear in supporting documentation. +// The author makes no representations about the +// suitability of this software for any purpose. It is provided "as is" +// without express or implied warranty. +//////////////////////////////////////////////////////////////////////////////// + +#ifndef LOKI_THREAD_LOCAL_H_INCLUDED +#define LOKI_THREAD_LOCAL_H_INCLUDED + +// $Id$ + + +// ---------------------------------------------------------------------------- + +// First assume the compiler does allow thread-local storage by #defining the +// macro which allows compiler to see the code inside this file. +// Then #undefine the macro for compilers which are known for not supporting +// thread-local storage. +#define LOKI_THINKS_COMPILER_ALLOWS_THREAD_LOCAL_STORAGE 1 + +// The __APPLE__ macro does not refer to a compiler, but to the Apple OSX operating system. +#if defined( __APPLE__ ) + #warning "GCC for Apple does not allow thread_local storage, so you can not use some parts of Loki." + #undef COMPILER_ALLOWS_THREAD_LOCAL_STORAGE +#endif + +#if ( defined( __CYGWIN__ ) && ( __GNUC__ <= 3 ) ) + #warning "Older versions of GCC for Cygwin do not allow thread_local storage, so you can not use some parts of Loki." + #undef COMPILER_ALLOWS_THREAD_LOCAL_STORAGE +#endif + +#if defined( LOKI_THINKS_COMPILER_ALLOWS_THREAD_LOCAL_STORAGE ) && !defined( LOKI_THREAD_LOCAL ) + +/** @par thread_local Keyword + Some parts of Loki require compilers to provide thread local storage - meaning + each thread gets its own copy of the data. The next version of C++ will have + a new keyword, thread_local for that purpose. Some existing compilers already + provide thread local storage using different syntax, so these lines use + thread_local to mimic that syntax. If your compiler provides thread local + storage but using different syntax besides "thread_local", you may want to + modify these lines. If your compiler does not support thread local storage, + you can't use some parts of Loki. + */ + #if defined( _MSC_VER ) + #if ( _MSC_VER >= 1300 ) + #define LOKI_THREAD_LOCAL __declspec( thread ) + #else + #error "Only Visual Studio versions 7.0 and after supported." + #endif + + #elif ( __GNUC__ ) + #define LOKI_THREAD_LOCAL __thread + + #else + #warning "Check if your compiler provides thread local storage." + #define LOKI_THREAD_LOCAL thread_local + #endif + +#endif // if compiler allows thread_local storage and LOKI_THREAD_LOCAL macro not defined yet + +// ---------------------------------------------------------------------------- + +#endif // end file guardian This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2009-11-20 06:35:37
|
Revision: 1056 http://loki-lib.svn.sourceforge.net/loki-lib/?rev=1056&view=rev Author: rich_sposato Date: 2009-11-20 06:35:29 +0000 (Fri, 20 Nov 2009) Log Message: ----------- Added warning to suggest running ThreadLocal test project. Modified Paths: -------------- trunk/include/loki/ThreadLocal.h Modified: trunk/include/loki/ThreadLocal.h =================================================================== --- trunk/include/loki/ThreadLocal.h 2009-11-20 06:33:15 UTC (rev 1055) +++ trunk/include/loki/ThreadLocal.h 2009-11-20 06:35:29 UTC (rev 1056) @@ -20,7 +20,7 @@ // First assume the compiler does allow thread-local storage by #defining the // macro which allows compiler to see the code inside this file. -// Then #undefine the macro for compilers which are known for not supporting +// Then #undef the macro for compilers which are known for not supporting // thread-local storage. #define LOKI_THINKS_COMPILER_ALLOWS_THREAD_LOCAL_STORAGE 1 @@ -59,6 +59,7 @@ #else #warning "Check if your compiler provides thread local storage." + #warning "Run ThreadLocal test project to see if the compiler implements thread_local correctly." #define LOKI_THREAD_LOCAL thread_local #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2011-06-21 03:35:36
|
Revision: 1087 http://loki-lib.svn.sourceforge.net/loki-lib/?rev=1087&view=rev Author: rich_sposato Date: 2011-06-21 03:35:30 +0000 (Tue, 21 Jun 2011) Log Message: ----------- Changed preprocessor statements to provide clarity. Modified Paths: -------------- trunk/include/loki/ThreadLocal.h Modified: trunk/include/loki/ThreadLocal.h =================================================================== --- trunk/include/loki/ThreadLocal.h 2011-06-21 03:32:19 UTC (rev 1086) +++ trunk/include/loki/ThreadLocal.h 2011-06-21 03:35:30 UTC (rev 1087) @@ -20,19 +20,28 @@ // First assume the compiler does allow thread-local storage by #defining the // macro which allows compiler to see the code inside this file. -// Then #undef the macro for compilers which are known for not supporting -// thread-local storage. +// Then #undef the macro for compilers which do not support thread-local +// storage or do not implement it correctly. #define LOKI_THINKS_COMPILER_ALLOWS_THREAD_LOCAL_STORAGE 1 -// The __APPLE__ macro does not refer to a compiler, but to the Apple OSX operating system. -#if defined( __APPLE__ ) - #warning "GCC for Apple does not allow thread_local storage, so you can not use some parts of Loki." - #undef COMPILER_ALLOWS_THREAD_LOCAL_STORAGE -#endif +#if defined( __GNUC__ ) + // The __APPLE__ macro does not refer to a compiler, but to the Apple OSX operating system. + #if defined( __APPLE__ ) + #warning "GCC for Apple does not allow thread_local storage, so you can not use some parts of Loki." + #undef COMPILER_ALLOWS_THREAD_LOCAL_STORAGE -#if ( defined( __CYGWIN__ ) && ( __GNUC__ <= 3 ) ) - #warning "Older versions of GCC for Cygwin do not allow thread_local storage, so you can not use some parts of Loki." - #undef COMPILER_ALLOWS_THREAD_LOCAL_STORAGE + #elif defined( __CYGWIN__ ) + #if ( __GNUC__ <= 3 ) + #warning "Older versions of GCC for Cygwin do not allow thread_local storage, so you can not use some parts of Loki." + #undef COMPILER_ALLOWS_THREAD_LOCAL_STORAGE + #endif + + #elif ( __GNUC__ == 4 ) // GNU versions other than Cygwin. + #if ( __GNUC_MINOR__ == 4 ) + #warning "GCC version 4.4 implements thread_local storage incorrectly, so you can not use some parts of Loki." + #undef COMPILER_ALLOWS_THREAD_LOCAL_STORAGE + #endif + #endif #endif #if defined( LOKI_THINKS_COMPILER_ALLOWS_THREAD_LOCAL_STORAGE ) && !defined( LOKI_THREAD_LOCAL ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ric...@us...> - 2011-09-29 20:40:19
|
Revision: 1119 http://loki-lib.svn.sourceforge.net/loki-lib/?rev=1119&view=rev Author: rich_sposato Date: 2011-09-29 20:40:13 +0000 (Thu, 29 Sep 2011) Log Message: ----------- Changed check for GCC version 4.4 Modified Paths: -------------- trunk/include/loki/ThreadLocal.h Modified: trunk/include/loki/ThreadLocal.h =================================================================== --- trunk/include/loki/ThreadLocal.h 2011-09-29 20:36:38 UTC (rev 1118) +++ trunk/include/loki/ThreadLocal.h 2011-09-29 20:40:13 UTC (rev 1119) @@ -34,25 +34,28 @@ // macro which allows compiler to see the code inside this file. // Then #undef the macro for compilers which do not support thread-local // storage or do not implement it correctly. -#define LOKI_THINKS_COMPILER_ALLOWS_THREAD_LOCAL_STORAGE 1 +#define LOKI_THINKS_COMPILER_ALLOWS_THREAD_LOCAL_STORAGE 1 #if defined( __GNUC__ ) // The __APPLE__ macro does not refer to a compiler, but to the Apple OSX operating system. #if defined( __APPLE__ ) #warning "GCC for Apple does not allow thread_local storage, so you can not use some parts of Loki." - #undef COMPILER_ALLOWS_THREAD_LOCAL_STORAGE + #undef LOKI_THINKS_COMPILER_ALLOWS_THREAD_LOCAL_STORAGE #elif defined( __CYGWIN__ ) #if ( __GNUC__ <= 3 ) #warning "Older versions of GCC for Cygwin do not allow thread_local storage, so you can not use some parts of Loki." - #undef COMPILER_ALLOWS_THREAD_LOCAL_STORAGE + #undef LOKI_THINKS_COMPILER_ALLOWS_THREAD_LOCAL_STORAGE #endif #elif ( __GNUC__ == 4 ) // GNU versions other than Cygwin. - #if ( __GNUC_MINOR__ == 4 ) - #warning "GCC version 4.4 implements thread_local storage incorrectly, so you can not use some parts of Loki." - #undef COMPILER_ALLOWS_THREAD_LOCAL_STORAGE - #endif + #if ( __GNUC_MINOR__ < 4 ) + #warning "GCC versions before 4.4 implement thread_local storage incorrectly, so you can not use some parts of Loki." + #undef LOKI_THINKS_COMPILER_ALLOWS_THREAD_LOCAL_STORAGE + #elif ( __GNUC_MINOR__ == 4 ) + #warning "GCC version 4.4 implements thread_local storage incorrectly for some platforms but not others." + #endif + #endif #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |