Based on android-ia and rebased to KitKat.
: \
);
+#elif defined(__i386__)
+
+ /* Tell gcc 4.4+ to always omit the frame pointer to have working code
+ * independ of compiler flag
+ */
+ #define API_ENTRY(_api) __attribute__((noinline)) \
+ __attribute__((optimize("omit-frame-pointer"))) \
+ _api
+
+ /* pop %%ebp only because x86 doesn't support naked functions */
+ /* 4.4+ supports __attribute__((optimize)) that disable function
+ * prologues
+ */
+ #if __GNUC__ < 4 || \
+ (__GNUC__ == 4 && __GNUC_MINOR__ < 4 )
+ #define PROLOGUE "pop %%ebp \n"
+ #else
+ #define PROLOGUE ""
+ #endif
+
+ #define CALL_GL_EXTENSION_API(_api) \
+ asm volatile( \
+ PROLOGUE \
+ "movl %%gs:0, %%ecx \n" \
+ "movl %c[tls](%%ecx), %%eax \n" \
+ "test %%eax, %%eax \n" \
+ "je out" #_api " \n" \
+ "movl %c[api](%%eax), %%ecx \n" \
+ "test %%ecx, %%ecx \n" \
+ "je out" #_api " \n" \
+ "jmp *%%ecx \n" \
+ "out" #_api ": ret \n" \
+ : \
+ : [tls] "i"(TLS_SLOT_OPENGL_API*4), \
+ [api] "i"(__builtin_offsetof(gl_hooks_t, \
+ ext.extensions[_api])) \
+ : \
+ );
+
#elif defined(__mips__)
#define API_ENTRY(_api) __attribute__((noinline)) _api
: \
);
+#elif defined(__i386__) && !USE_SLOW_BINDING
+
+ /* Tell gcc 4.4+ to always omit the frame pointer to have working code
+ * independ of compiler flag
+ */
+ #define API_ENTRY(_api) __attribute__((noinline)) \
+ __attribute__((optimize("omit-frame-pointer"))) \
+ _api
+
+ /* pop %%ebp only because x86 doesn't support naked functions */
+ /* 4.4+ supports __attribute__((optimize)) that disable function
+ * prologues
+ */
+ #if __GNUC__ < 4 || \
+ (__GNUC__ == 4 && __GNUC_MINOR__ < 4 )
+ #define PROLOGUE "pop %%ebp \n"
+ #else
+ #define PROLOGUE ""
+ #endif
+
+ #define CALL_GL_API(_api, ...) \
+ asm volatile( \
+ PROLOGUE \
+ "movl %%gs:0, %%ecx \n" \
+ "movl %c[tls](%%ecx), %%eax \n" \
+ "test %%eax, %%eax \n" \
+ "je out" #_api " \n" \
+ "movl %c[api](%%eax), %%ecx \n" \
+ "jmp *%%ecx \n" \
+ "out" #_api ": ret \n" \
+ : \
+ : [tls] "i"(TLS_SLOT_OPENGL_API*4), \
+ [api] "i"(__builtin_offsetof(gl_hooks_t, gl._api)) \
+ : \
+ );
+
#elif defined(__mips__) && !USE_SLOW_BINDING
#define API_ENTRY(_api) __attribute__((noinline)) _api
: \
);
+#elif defined(__i386__) && !USE_SLOW_BINDING
+
+ /* Tell gcc 4.4+ to always omit the frame pointer to have working code
+ * independ of compiler flag
+ */
+ #define API_ENTRY(_api) __attribute__((noinline)) \
+ __attribute__((optimize("omit-frame-pointer"))) \
+ _api
+
+ /* pop %%ebp only because x86 doesn't support naked functions */
+ /* 4.4+ supports __attribute__((optimize)) that disable function
+ * prologues
+ */
+ #if __GNUC__ < 4 || \
+ (__GNUC__ == 4 && __GNUC_MINOR__ < 4 )
+ #define PROLOGUE "pop %%ebp \n"
+ #else
+ #define PROLOGUE ""
+ #endif
+
+ #define CALL_GL_API(_api, ...) \
+ asm volatile( \
+ PROLOGUE \
+ "movl %%gs:0, %%ecx \n" \
+ "movl %c[tls](%%ecx), %%eax \n" \
+ "test %%eax, %%eax \n" \
+ "je out" #_api " \n" \
+ "movl %c[api](%%eax), %%ecx \n" \
+ "jmp *%%ecx \n" \
+ "out" #_api ": ret \n" \
+ : \
+ : [tls] "i"(TLS_SLOT_OPENGL_API*4), \
+ [api] "i"(__builtin_offsetof(gl_hooks_t, gl._api)) \
+ : \
+ );
+
#elif defined(__mips__) && !USE_SLOW_BINDING
#define API_ENTRY(_api) __attribute__((noinline)) _api