Drop GLcontext typedef and use struct gl_context instead
[mesa.git] / src / mapi / glapi / glapi.h
index a74884d595ae57a35744d9359041819092f0e0df..8cca50487c4bc529624e5ab50165209980f068d1 100644 (file)
 #ifndef _GLAPI_H
 #define _GLAPI_H
 
-#ifndef MAPI_GLAPI_CURRENT
-#define MAPI_GLAPI_CURRENT
+
+/* opengl.dll does not export _glapi_* */
+#if defined(_WIN32)
+#define _GLAPI_NO_EXPORTS
 #endif
 
+#ifdef _GLAPI_NO_EXPORTS
+#  define _GLAPI_EXPORT
+#else /* _GLAPI_NO_EXPORTS */
+#  ifdef _WIN32
+#    ifdef _GLAPI_DLL_EXPORTS
+#      define _GLAPI_EXPORT __declspec(dllexport)
+#    else
+#      define _GLAPI_EXPORT __declspec(dllimport)
+#    endif
+#  elif defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
+#    define _GLAPI_EXPORT __attribute__((visibility("default")))
+#  else
+#    define _GLAPI_EXPORT
+#  endif
+#endif /* _GLAPI_NO_EXPORTS */
+
+
+/* Is this needed?  It is incomplete anyway. */
 #ifdef USE_MGL_NAMESPACE
 #define _glapi_set_dispatch _mglapi_set_dispatch
 #define _glapi_get_dispatch _mglapi_get_dispatch
 #define _glapi_Context _mglapi_Context
 #endif
 
-#include "mapi/u_current.h"
 #include "glapi/glthread.h"
 
 typedef void (*_glapi_proc)(void);
+struct _glapi_table;
+
+
+#if defined (GLX_USE_TLS)
+
+_GLAPI_EXPORT extern __thread struct _glapi_table * _glapi_tls_Dispatch
+    __attribute__((tls_model("initial-exec")));
+
+_GLAPI_EXPORT extern __thread void * _glapi_tls_Context
+    __attribute__((tls_model("initial-exec")));
+
+_GLAPI_EXPORT extern const struct _glapi_table *_glapi_Dispatch;
+_GLAPI_EXPORT extern const void *_glapi_Context;
+
+# define GET_DISPATCH() _glapi_tls_Dispatch
+# define GET_CURRENT_CONTEXT(C)  struct gl_context *C = (struct gl_context *) _glapi_tls_Context
+
+#else
+
+_GLAPI_EXPORT extern struct _glapi_table *_glapi_Dispatch;
+_GLAPI_EXPORT extern void *_glapi_Context;
+
+# ifdef THREADS
+
+#  define GET_DISPATCH() \
+     (likely(_glapi_Dispatch) ? _glapi_Dispatch : _glapi_get_dispatch())
+
+#  define GET_CURRENT_CONTEXT(C)  struct gl_context *C = (struct gl_context *) \
+     (likely(_glapi_Context) ? _glapi_Context : _glapi_get_context())
+
+# else
+
+#  define GET_DISPATCH() _glapi_Dispatch
+#  define GET_CURRENT_CONTEXT(C)  struct gl_context *C = (struct gl_context *) _glapi_Context
+
+# endif
+
+#endif /* defined (GLX_USE_TLS) */
+
+
+void
+_glapi_destroy_multithread(void);
+
 
-#define GET_DISPATCH() ((struct _glapi_table *) u_current_get())
-#define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) u_current_get_user()
+_GLAPI_EXPORT void
+_glapi_check_multithread(void);
 
-PUBLIC unsigned int
+
+_GLAPI_EXPORT void
+_glapi_set_context(void *context);
+
+
+_GLAPI_EXPORT void *
+_glapi_get_context(void);
+
+
+_GLAPI_EXPORT void
+_glapi_set_dispatch(struct _glapi_table *dispatch);
+
+
+_GLAPI_EXPORT struct _glapi_table *
+_glapi_get_dispatch(void);
+
+
+_GLAPI_EXPORT unsigned int
 _glapi_get_dispatch_table_size(void);
 
 
-PUBLIC int
+_GLAPI_EXPORT int
 _glapi_add_dispatch( const char * const * function_names,
                     const char * parameter_signature );
 
-PUBLIC int
+_GLAPI_EXPORT int
 _glapi_get_proc_offset(const char *funcName);
 
 
-PUBLIC _glapi_proc
+_GLAPI_EXPORT _glapi_proc
 _glapi_get_proc_address(const char *funcName);
 
 
-PUBLIC const char *
+_GLAPI_EXPORT const char *
 _glapi_get_proc_name(unsigned int offset);
 
 
-#endif
+_GLAPI_EXPORT unsigned long
+_glthread_GetID(void);
+
+
+/*
+ * These stubs are kept so that the old DRI drivers still load.
+ */
+_GLAPI_EXPORT void
+_glapi_noop_enable_warnings(unsigned char enable);
+
+
+_GLAPI_EXPORT void
+_glapi_set_warning_func(_glapi_proc func);
+
+
+#endif /* _GLAPI_H */