1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2014 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "nel/misc/tds.h"
23 #include "nel/misc/debug.h"
26 # ifndef NL_COMP_MINGW
30 #endif // NL_OS_WINDOWS
39 // *********************************************************
43 /* Please no assert in the constructor because it is called by the NeL memory allocator constructor */
45 _Handle
= TlsAlloc ();
46 TlsSetValue (_Handle
, NULL
);
47 #else // NL_OS_WINDOWS
48 // nldebug("CTDS::CTDS...");
49 nlverify(pthread_key_create (&_Key
, NULL
) == 0);
50 // nldebug("CTDS::CTDS : create a new key %u", _Key);
51 pthread_setspecific(_Key
, NULL
);
52 #endif // NL_OS_WINDOWS
55 // *********************************************************
60 nlverify (TlsFree (_Handle
) != 0);
61 #else // NL_OS_WINDOWS
62 // nldebug("CTDS::~CTDS : deleting key %u", _Key);
63 nlverify (pthread_key_delete (_Key
) == 0);
64 #endif // NL_OS_WINDOWS
67 // *********************************************************
69 void *CTDS::getPointer () const
72 return TlsGetValue (_Handle
);
73 #else // NL_OS_WINDOWS
74 // nldebug("CTDS::getPointer for key %u...", _Key);
75 void *ret
= pthread_getspecific (_Key
);
76 // nldebug("CTDS::getPointer returing value %p", ret);
78 #endif // NL_OS_WINDOWS
81 // *********************************************************
83 void CTDS::setPointer (void* pointer
)
86 nlverify (TlsSetValue (_Handle
, pointer
) != 0);
87 #else // NL_OS_WINDOWS
88 // nldebug("CTDS::setPointer for key %u to value %p", _Key, pointer);
89 nlverify (pthread_setspecific (_Key
, pointer
) == 0);
90 #endif // NL_OS_WINDOWS
93 // *********************************************************