auto import from //branches/cupcake/...@126645
diff --git a/opengl/libGLES_CM/Android.mk b/opengl/libGLES_CM/Android.mk
index a0081ef..e350e02 100644
--- a/opengl/libGLES_CM/Android.mk
+++ b/opengl/libGLES_CM/Android.mk
@@ -15,7 +15,9 @@
 # needed on sim build because of weird logging issues
 ifeq ($(TARGET_SIMULATOR),true)
 else
-	LOCAL_SHARED_LIBRARIES += libdl
+    LOCAL_SHARED_LIBRARIES += libdl
+    # we need to access the Bionic private header <bionic_tls.h>
+    LOCAL_CFLAGS += -I$(LOCAL_PATH)/../../../../bionic/libc/private
 endif
 
 include $(BUILD_SHARED_LIBRARY)
diff --git a/opengl/libGLES_CM/gl_wrapper.cpp b/opengl/libGLES_CM/gl_wrapper.cpp
index 3b7f45e..3197535 100644
--- a/opengl/libGLES_CM/gl_wrapper.cpp
+++ b/opengl/libGLES_CM/gl_wrapper.cpp
@@ -203,7 +203,8 @@
 
 #if defined(HAVE_ANDROID_OS) && !USE_SLOW_BINDING && !GL_LOGGER
 
-#include <sys/tls.h>
+/* special private C library header */
+#include <bionic_tls.h>
 // We have a dedicated TLS slot in bionic
 static inline void setGlThreadSpecific(gl_hooks_t const *value) {
     ((uint32_t *)__get_tls())[TLS_SLOT_OPENGL_API] = (uint32_t)value;
diff --git a/opengl/libagl/Android.mk b/opengl/libagl/Android.mk
index a3dff76..99efe4c 100644
--- a/opengl/libagl/Android.mk
+++ b/opengl/libagl/Android.mk
@@ -27,6 +27,11 @@
 	LOCAL_CFLAGS += -fstrict-aliasing
 endif
 
+ifneq ($(TARGET_SIMULATOR),true)
+    # we need to access the private Bionic header <bionic_tls.h>
+    LOCAL_CFLAGS += -I$(LOCAL_PATH)/../../../../bionic/libc/private
+endif
+
 LOCAL_SHARED_LIBRARIES := libcutils libutils libpixelflinger
 LOCAL_LDLIBS := -lpthread -ldl
 LOCAL_MODULE:= libagl