Bug 719273. Avoid including windows header files into sampler.h. r=ehsan

The windows headers do inconvenient things like:
#define CreateEvent CreateEventW

We'd like to avoid this.
This commit is contained in:
Jeff Muizelaar 2012-01-19 00:43:03 -05:00
parent b2f5553e7a
commit 5a364c1545

View File

@ -41,10 +41,17 @@
#if defined(XP_WIN)
// This file will get included in any file that wants to add
// a profiler mark. In order to not bring <windows.h> together
// we just include windef.h and winbase.h which are sufficient
// we could include windef.h and winbase.h which are sufficient
// to get the prototypes for the Tls* functions.
# include <windef.h>
# include <winbase.h>
// # include <windef.h>
// # include <winbase.h>
// Unfortunately, even including these headers causes
// us to add a bunch of ugly to our namespace. e.g #define CreateEvent CreateEventW
extern "C" {
__declspec(dllimport) void * __stdcall TlsGetValue(unsigned long);
__declspec(dllimport) int __stdcall TlsSetValue(unsigned long, void *);
__declspec(dllimport) unsigned long __stdcall TlsAlloc();
};
#else
# include <pthread.h>
# include <signal.h>
@ -62,7 +69,7 @@ namespace tls {
#if defined(XP_WIN)
typedef DWORD key;
typedef unsigned long key;
template <typename T>
static T* get(key mykey) {
@ -76,7 +83,7 @@ static bool set(key mykey, const T* value) {
static inline bool create(key* mykey) {
key newkey = TlsAlloc();
if (newkey == TLS_OUT_OF_INDEXES) {
if (newkey == (unsigned long)0xFFFFFFFF /* TLS_OUT_OF_INDEXES */) {
return false;
}
*mykey = newkey;