summaryrefslogtreecommitdiff
path: root/cpp/demo/Freeze/customEvictor/CurrentDatabase.cpp
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2007-12-07 12:40:03 -0500
committerBernard Normier <bernard@zeroc.com>2007-12-07 12:40:03 -0500
commitcf8ffff040a98a7c6fe9ea31154029723533a361 (patch)
treef56d88d32661b200b44034411e662f3271c09e56 /cpp/demo/Freeze/customEvictor/CurrentDatabase.cpp
parentAdded Glacier2 administration option (diff)
downloadice-cf8ffff040a98a7c6fe9ea31154029723533a361.tar.bz2
ice-cf8ffff040a98a7c6fe9ea31154029723533a361.tar.xz
ice-cf8ffff040a98a7c6fe9ea31154029723533a361.zip
Fixed bug #2546
Diffstat (limited to 'cpp/demo/Freeze/customEvictor/CurrentDatabase.cpp')
-rw-r--r--cpp/demo/Freeze/customEvictor/CurrentDatabase.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/cpp/demo/Freeze/customEvictor/CurrentDatabase.cpp b/cpp/demo/Freeze/customEvictor/CurrentDatabase.cpp
index f4b93be87ea..29841adce59 100644
--- a/cpp/demo/Freeze/customEvictor/CurrentDatabase.cpp
+++ b/cpp/demo/Freeze/customEvictor/CurrentDatabase.cpp
@@ -22,13 +22,18 @@ using namespace IceUtil;
#define __thread __declspec(thread)
#endif
+//
+// GCC on MacOS doesn't support __thread; and on HP-UX with aC++, there
+// is strange compiler or linker bug when using __thread.
+//
+#if defined(__HP_aCC) || defined(__APPLE__)
+ #define USE_PTHREAD_KEY 1
+#endif
+
namespace
{
-#ifdef __HP_aCC
-//
-// Strange HP aCC (or linker) bug, so we use directly the pthread calls
-//
+#ifdef USE_PTHREAD_KEY
pthread_key_t dbKey;
#else
__thread Database* db = 0;
@@ -41,7 +46,7 @@ CurrentDatabase::CurrentDatabase(const Ice::CommunicatorPtr& comm, const string&
_envName(envName),
_dbName(dbName)
{
-#ifdef __HP_aCC
+#ifdef USE_PTHREAD_KEY
int rs = pthread_key_create(&dbKey, 0);
assert(rs == 0);
#endif
@@ -58,7 +63,7 @@ CurrentDatabase::~CurrentDatabase()
Database&
CurrentDatabase::get()
{
-#ifdef __HP_aCC
+#ifdef USE_PTHREAD_KEY
Database* db = static_cast<Database*>(pthread_getspecific(dbKey));
#endif
@@ -69,7 +74,7 @@ CurrentDatabase::get()
Mutex::Lock sync(_dbListMutex);
_dbList.push_back(db);
-#ifdef __HP_aCC
+#ifdef USE_PTHREAD_KEY
int rs = pthread_setspecific(dbKey, db);
assert(rs == 0);
#endif