aboutsummaryrefslogtreecommitdiffstats
path: root/emulator/opengl/shared/OpenglOsUtils
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@google.com>2014-03-10 15:26:00 +0100
committerDavid 'Digit' Turner <digit@google.com>2014-03-11 18:02:57 +0100
commit47752bc9b62d974d82ba10bfc3633b72d10afcbd (patch)
treee5dbd1b3f20ff54654e6f5f2db2a0805431a7845 /emulator/opengl/shared/OpenglOsUtils
parentaac93f1585bc9bdf8a57b6ed3c47c24f56a3990a (diff)
downloadsdk-47752bc9b62d974d82ba10bfc3633b72d10afcbd.zip
sdk-47752bc9b62d974d82ba10bfc3633b72d10afcbd.tar.gz
sdk-47752bc9b62d974d82ba10bfc3633b72d10afcbd.tar.bz2
emulator/opengl: Remove Android-specific thread_store.
This patch removes the use of the 'thread_store' class from <utils/threads.h> by providing its own implementation instead under shared/emugl/common/thread_store.h, plus appropriate unit tests. Note that unlike the Android version, this properly destroys the thread-local values on thread exit (instead of leaking them). + Provide a LazyInstance class used to perform thread-safe lazy initialization of static variables without the use of C++ constructors. Change-Id: Iabe01fbd713c6872b5fe245d7255c3c03749a88a
Diffstat (limited to 'emulator/opengl/shared/OpenglOsUtils')
-rw-r--r--emulator/opengl/shared/OpenglOsUtils/Android.mk7
-rw-r--r--emulator/opengl/shared/OpenglOsUtils/osThreadUnix.cpp3
-rw-r--r--emulator/opengl/shared/OpenglOsUtils/osThreadWin.cpp3
3 files changed, 11 insertions, 2 deletions
diff --git a/emulator/opengl/shared/OpenglOsUtils/Android.mk b/emulator/opengl/shared/OpenglOsUtils/Android.mk
index 8a6c18b..d8807d0 100644
--- a/emulator/opengl/shared/OpenglOsUtils/Android.mk
+++ b/emulator/opengl/shared/OpenglOsUtils/Android.mk
@@ -10,6 +10,7 @@ LOCAL_PATH := $(call my-dir)
host_common_SRC_FILES := osDynLibrary.cpp
host_common_LDLIBS :=
+host_common_INCLUDES := $(LOCAL_PATH)
ifeq ($(HOST_OS),windows)
host_common_SRC_FILES += \
@@ -29,15 +30,17 @@ endif
### 32-bit host library ####
$(call emugl-begin-host-static-library,libOpenglOsUtils)
- $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
+ $(call emugl-export,C_INCLUDES,$(host_common_INCLUDES))
LOCAL_SRC_FILES = $(host_common_SRC_FILES)
$(call emugl-export,LDLIBS,$(host_common_LDLIBS))
+ $(call emugl-import,libemugl_common)
$(call emugl-end-module)
### 64-bit host library ####
$(call emugl-begin-host-static-library,lib64OpenglOsUtils)
- $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
+ $(call emugl-export,C_INCLUDES,$(host_common_INCLUDES))
LOCAL_SRC_FILES = $(host_common_SRC_FILES)
$(call emugl-export,LDLIBS,$(host_common_LDLIBS))
$(call emugl-export,CFLAGS,-m64)
+ $(call emugl-import,lib64emugl_common)
$(call emugl-end-module)
diff --git a/emulator/opengl/shared/OpenglOsUtils/osThreadUnix.cpp b/emulator/opengl/shared/OpenglOsUtils/osThreadUnix.cpp
index 8cd73a9..ef2bebc 100644
--- a/emulator/opengl/shared/OpenglOsUtils/osThreadUnix.cpp
+++ b/emulator/opengl/shared/OpenglOsUtils/osThreadUnix.cpp
@@ -15,6 +15,8 @@
*/
#include "osThread.h"
+#include "emugl/common/thread_store.h"
+
#include <stdint.h>
namespace osUtils {
@@ -88,6 +90,7 @@ Thread::thread_main(void *p_arg)
self->m_exitStatus = ret;
pthread_mutex_unlock(&self->m_lock);
+ ::emugl::ThreadStore::OnThreadExit();
return (void*)(uintptr_t)ret;
}
diff --git a/emulator/opengl/shared/OpenglOsUtils/osThreadWin.cpp b/emulator/opengl/shared/OpenglOsUtils/osThreadWin.cpp
index 2d563f8..1a30b97 100644
--- a/emulator/opengl/shared/OpenglOsUtils/osThreadWin.cpp
+++ b/emulator/opengl/shared/OpenglOsUtils/osThreadWin.cpp
@@ -15,6 +15,8 @@
*/
#include "osThread.h"
+#include "emugl/common/thread_store.h"
+
namespace osUtils {
Thread::Thread() :
@@ -95,6 +97,7 @@ Thread::thread_main(void *p_arg)
Thread *self = (Thread *)p_arg;
int ret = self->Main();
self->m_isRunning = false;
+ ::emugl::ThreadStore::OnThreadExit();
return ret;
}