зеркало из https://github.com/mozilla/gecko-dev.git
101 строка
2.5 KiB
Diff
101 строка
2.5 KiB
Diff
Simple ossource implementation using NSPR
|
|
|
|
diff --git a/gfx/angle/src/compiler/osinclude.h b/gfx/angle/src/compiler/osinclude.h
|
|
--- a/gfx/angle/src/compiler/osinclude.h
|
|
+++ b/gfx/angle/src/compiler/osinclude.h
|
|
@@ -7,8 +7,14 @@
|
|
#ifndef __OSINCLUDE_H
|
|
#define __OSINCLUDE_H
|
|
|
|
+#ifdef ANGLE_USE_NSPR
|
|
+
|
|
+#include "prthread.h"
|
|
+
|
|
+#else
|
|
+
|
|
//
|
|
-// This file contains contains the window's specific datatypes and
|
|
+// This file contains contains windows specific datatypes and
|
|
// declares any windows specific functions.
|
|
//
|
|
|
|
@@ -32,12 +38,17 @@
|
|
#include <errno.h>
|
|
#endif // ANGLE_OS_WIN
|
|
|
|
+#endif // ANGLE_USE_NSPR
|
|
+
|
|
#include "compiler/debug.h"
|
|
|
|
//
|
|
// Thread Local Storage Operations
|
|
//
|
|
-#if defined(ANGLE_OS_WIN)
|
|
+#if defined(ANGLE_USE_NSPR)
|
|
+typedef PRUintn OS_TLSIndex;
|
|
+#define OS_INVALID_TLS_INDEX 0xFFFFFFFF
|
|
+#elif defined(ANGLE_OS_WIN)
|
|
typedef DWORD OS_TLSIndex;
|
|
#define OS_INVALID_TLS_INDEX (TLS_OUT_OF_INDEXES)
|
|
#elif defined(ANGLE_OS_POSIX)
|
|
@@ -52,7 +63,9 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
|
|
inline void* OS_GetTLSValue(OS_TLSIndex nIndex)
|
|
{
|
|
assert(nIndex != OS_INVALID_TLS_INDEX);
|
|
-#if defined(ANGLE_OS_WIN)
|
|
+#if defined(ANGLE_USE_NSPR)
|
|
+ return PR_GetThreadPrivate(nIndex);
|
|
+#elif defined(ANGLE_OS_WIN)
|
|
return TlsGetValue(nIndex);
|
|
#elif defined(ANGLE_OS_POSIX)
|
|
return pthread_getspecific(nIndex);
|
|
diff --git a/gfx/angle/src/compiler/ossource_nspr.cpp b/gfx/angle/src/compiler/ossource_nspr.cpp
|
|
new file mode 100644
|
|
--- /dev/null
|
|
+++ b/gfx/angle/src/compiler/ossource_nspr.cpp
|
|
@@ -0,0 +1,44 @@
|
|
+//
|
|
+// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
|
|
+// Use of this source code is governed by a BSD-style license that can be
|
|
+// found in the LICENSE file.
|
|
+//
|
|
+
|
|
+//
|
|
+// This file contains the posix specific functions
|
|
+//
|
|
+#include "compiler/osinclude.h"
|
|
+
|
|
+//
|
|
+// Thread Local Storage Operations
|
|
+//
|
|
+OS_TLSIndex OS_AllocTLSIndex()
|
|
+{
|
|
+ PRUintn index;
|
|
+ PRStatus status = PR_NewThreadPrivateIndex(&index, NULL);
|
|
+
|
|
+ if (status) {
|
|
+ assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
|
|
+ return OS_INVALID_TLS_INDEX;
|
|
+ }
|
|
+
|
|
+ return index;
|
|
+}
|
|
+
|
|
+
|
|
+bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
|
|
+{
|
|
+ if (nIndex == OS_INVALID_TLS_INDEX) {
|
|
+ assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ return PR_SetThreadPrivate(nIndex, lpvValue) == 0;
|
|
+}
|
|
+
|
|
+
|
|
+bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
|
|
+{
|
|
+ // Can't delete TLS keys with nspr
|
|
+ return true;
|
|
+}
|