From: <sv...@ww...> - 2005-11-13 20:37:25
|
Author: mkrose Date: 2005-11-13 12:37:18 -0800 (Sun, 13 Nov 2005) New Revision: 1671 Modified: trunk/CSP/SimData/Source/ThreadUtil.cpp Log: More pthread_t tweaks for windows. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1671 Modified: trunk/CSP/SimData/Source/ThreadUtil.cpp =================================================================== --- trunk/CSP/SimData/Source/ThreadUtil.cpp 2005-11-13 18:01:44 UTC (rev 1670) +++ trunk/CSP/SimData/Source/ThreadUtil.cpp 2005-11-13 20:37:18 UTC (rev 1671) @@ -72,18 +72,19 @@ unsigned long pthread_t_to_ulong(pthread_t const &id) { #ifdef PTW32_VERSION // pthreads-win32 - return static_cast<unsigned long>(id.p); // pointer to the thread object + // treat the pointer to the thread object as an integer id + if (sizeof(unsigned long) == sizeof(void*)) return *reinterpret_cast<const unsigned long*>(id.p); #else // if pthread_t is small, assume it is a simple numeric id. if (sizeof(pthread_t) == sizeof(unsigned long)) return *reinterpret_cast<const unsigned long*>(&id); if (sizeof(pthread_t) == sizeof(unsigned)) return *reinterpret_cast<const unsigned*>(&id); +#endif // for other implementations that define pthread_t as a struct, return a 32-bit hash of // the pthread_t structure. this is dangerous, since the structure may contain mutable // data that is unrelated to the thread identity (e.g., a reference count). the posix // standard doesn't provide any good options in this case. feel free to special case // specific pthread libraries using more #ifdef branches above if necessary. return hash_uint32(reinterpret_cast<const char*>(&id), sizeof(pthread_t)); -#endif } NAMESPACE_SIMDATA_END |