restore FASTCALL stuff
[mesa.git] / src / glx / x11 / glxext.c
index 1754efa0c262d52b523205974417f86974c14c22..eb6e870e9840a3a1b522b78585dc628d48dce0ef 100644 (file)
 
 #include "glxclient.h"
 #include <stdio.h>
-#include <Xext.h>
-#include <extutil.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
 #include <assert.h>
 #include "indirect_init.h"
 #include "glapi.h"
-#ifdef XTHREADS
-# include "Xthreads.h"
-#elif defined(PTHREADS)
-# include <pthread.h>
-#endif
 #include "glxextensions.h"
 #include "glcontextmodes.h"
 #include "glheader.h"
@@ -111,6 +106,10 @@ static int _mesa_sparc_needs_init = 1;
 #define INIT_MESA_SPARC
 #endif
 
+#ifdef GLX_DIRECT_RENDERING
+static __DRIscreen *__glXFindDRIScreen(__DRInativeDisplay *dpy, int scrn);
+#endif /* GLX_DIRECT_RENDERING */
+
 static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
     GLXDrawable read, GLXContext gc);
 
@@ -146,7 +145,7 @@ static __GLapi *IndirectAPI = NULL;
  * Current context management and locking
  */
 
-#if defined( XTHREADS )
+#if defined( USE_XTHREADS )
 
 /* thread safe */
 static GLboolean TSDinitialized = GL_FALSE;
@@ -667,6 +666,42 @@ filter_modes( __GLcontextModes ** server_modes,
 }
 
 
+/**
+ * Implement \c __DRIinterfaceMethods::getProcAddress.
+ */
+static __DRIfuncPtr get_proc_address( const char * proc_name )
+{
+    if (strcmp( proc_name, "glxEnableExtension" ) == 0) {
+       return (__DRIfuncPtr) __glXScrEnableExtension;
+    }
+    
+    return NULL;
+}
+
+
+/**
+ * Table of functions exported by the loader to the driver.
+ */
+static const __DRIinterfaceMethods interface_methods = {
+    get_proc_address,
+
+    _gl_context_modes_create,
+    _gl_context_modes_destroy,
+      
+    __glXFindDRIScreen,
+    __glXWindowExists,
+      
+    XF86DRICreateContextWithConfig,
+    XF86DRIDestroyContext,
+
+    XF86DRICreateDrawable,
+    XF86DRIDestroyDrawable,
+    XF86DRIGetDrawableInfo,
+
+    __glXGetUST,
+    glXGetMscRateOML,
+};
+
 
 /**
  * Perform the required libGL-side initialization and call the client-side
@@ -693,7 +728,7 @@ CallCreateNewScreen(Display *dpy, int scrn, __DRIscreen *psc,
     __DRIscreenPrivate *psp = NULL;
 #ifndef GLX_USE_APPLEGL
     drm_handle_t hSAREA;
-    drmAddress pSAREA;
+    drmAddress pSAREA = MAP_FAILED;
     char *BusID;
     __DRIversion   ddx_version;
     __DRIversion   dri_version;
@@ -714,6 +749,7 @@ CallCreateNewScreen(Display *dpy, int scrn, __DRIscreen *psc,
     err_msg = "XF86DRIOpenConnection";
     err_extra = NULL;
 
+    framebuffer.base = MAP_FAILED;
     framebuffer.dev_priv = NULL;
 
     if (XF86DRIOpenConnection(dpy, scrn, &hSAREA, &BusID)) {
@@ -819,6 +855,7 @@ CallCreateNewScreen(Display *dpy, int scrn, __DRIscreen *psc,
                                                             pSAREA,
                                                             fd,
                                                             api_ver,
+                                                            & interface_methods,
                                                             & driver_modes );
 
                                    filter_modes( & configs->configs,
@@ -1070,7 +1107,7 @@ __GLXdisplayPrivate *__glXInitialize(Display* dpy)
     XEDataObject dataObj;
     int major, minor;
 
-#if defined(XTHREADS)
+#if defined(USE_XTHREADS)
     {
         static int firstCall = 1;
         if (firstCall) {
@@ -1552,7 +1589,9 @@ USED static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
 
        oldGC->currentContextTag = 0;
     }
-    
+
+    _glapi_check_multithread();
+
 #ifdef GLX_DIRECT_RENDERING
     /* Unbind the old direct rendering context */
     if (oldGC->isDirect) {
@@ -1572,7 +1611,6 @@ USED static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
        }
     } else {
 #endif
-        _glapi_check_multithread();
        /* Send a glXMakeCurrent request to bind the new context. */
        LockDisplay(dpy);
 
@@ -1729,8 +1767,7 @@ USED static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
 }
 
 
-PUBLIC Bool GLX_PREFIX(glXMakeCurrent)(Display *dpy, GLXDrawable draw,
-                                       GLXContext gc)
+PUBLIC Bool glXMakeCurrent(Display *dpy, GLXDrawable draw, GLXContext gc)
 {
     return MakeContextCurrent( dpy, draw, draw, gc );
 }