[Title] Added a threading module (using __thread)
authorHaegeun Park <haegeun.park@samsung.com>
Wed, 10 Oct 2012 10:16:22 +0000 (03:16 -0700)
committerHaegeun Park <haegeun.park@samsung.com>
Wed, 10 Oct 2012 10:16:22 +0000 (03:16 -0700)
[Issue#] -
[Problem] -
[Cause] -
[Solution]
This module uses compiler specific Thread-Local-Variable (__thread)
instead of pthread_getspecific().
To revert, needs makefile modification.

CMakeLists.txt
Makefile
src/coregl_thread_pthread_and_gcc_tlv.c [new file with mode: 0644]
src/modules/fastpath/coregl_fastpath.c

index 068524a..eb72279 100644 (file)
@@ -24,7 +24,7 @@ SET(CMAKE_SKIP_BUILD_RPATH TRUE)
 SET(COREGL "COREGL")
 SET(SRCS_common
                src/coregl.c
-               src/coregl_thread_pthread.c
+               src/coregl_thread_pthread_and_gcc_tlv.c
                src/coregl_trace.c
                src/coregl_export.c
                src/coregl_export_egl.c
index a168876..6d06635 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,7 @@ LDFLAGS = -g -O2 -fvisibility=hidden -Wall -std=c99 -ldl -lpthread
 
 SOURCES = \
                src/coregl.c \
-               src/coregl_thread_pthread.c \
+               src/coregl_thread_pthread_and_gcc_tlv.c \
                src/coregl_trace.c \
                src/coregl_export.c \
                src/coregl_export_egl.c \
diff --git a/src/coregl_thread_pthread_and_gcc_tlv.c b/src/coregl_thread_pthread_and_gcc_tlv.c
new file mode 100644 (file)
index 0000000..7092b8f
--- /dev/null
@@ -0,0 +1,59 @@
+#include "coregl_internal.h"
+
+//////////////////////////////////////////////////////////////////////////
+// Need implement this
+int mutex_lock(Mutex *mt);
+int mutex_unlock(Mutex *mt);
+int get_current_thread();
+int set_current_thread_state(GLThreadState *tstate);
+GLThreadState * get_current_thread_state();
+//////////////////////////////////////////////////////////////////////////
+
+static __thread GLThreadState *per_thread_state = NULL;
+
+int
+mutex_lock(Mutex *mt)
+{
+       int ret = 0;
+
+       if (pthread_mutex_lock(mt) == 0)
+               ret = 1;
+       else
+               ret = 0;
+
+       return ret;
+}
+
+int
+mutex_unlock(Mutex *mt)
+{
+       int ret = 0;
+
+       if (pthread_mutex_unlock(mt) == 0)
+               ret = 1;
+       else
+               ret = 0;
+
+       return ret;
+}
+
+int
+get_current_thread()
+{
+       return pthread_self();
+}
+
+int
+set_current_thread_state(GLThreadState *tstate)
+{
+       per_thread_state = tstate;
+       return 1;
+}
+
+GLThreadState *
+get_current_thread_state()
+{
+       return per_thread_state;
+}
+
+
index b5ccde6..f18eb06 100644 (file)
@@ -885,7 +885,7 @@ extern void *tracepath_api_trace_end(const char *name, void *hint, int trace_tot
                int err = _orig_fastpath_glGetError(); \
                if (err != GL_NO_ERROR) \
                { \
-                       printf("\E[0;31;1mERROR(GL %p) : %s returns GL error 0x%X\E[0m\n", oldctx->cstate, #func, err); \
+                       ERR("\E[0;31;1mERROR(GL %p) : %s returns GL error 0x%X\E[0m\n", oldctx->cstate, #func, err); \
                        goto finish; \
                } \
        }