glx: move __glXGetUST into the DRI1 code

This is only used from the __DRI_SYSTEM_TIME loader extension, which
only the DRI1 drivers ever looked for.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7219>
diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c
index a5fae27..bcab5f6 100644
--- a/src/glx/dri_common.c
+++ b/src/glx/dri_common.c
@@ -114,23 +114,6 @@
    return extensions;
 }
 
-static GLboolean
-__driGetMSCRate(__DRIdrawable *draw,
-		int32_t * numerator, int32_t * denominator,
-		void *loaderPrivate)
-{
-   __GLXDRIdrawable *glxDraw = loaderPrivate;
-
-   return __glxGetMscRate(glxDraw->psc, numerator, denominator);
-}
-
-_X_HIDDEN const __DRIsystemTimeExtension systemTimeExtension = {
-   .base = {__DRI_SYSTEM_TIME, 1 },
-
-   .getUST              = __glXGetUST,
-   .getMSCRate          = __driGetMSCRate
-};
-
 #define __ATTRIB(attrib, field) \
     { attrib, offsetof(struct glx_config, field) }
 
diff --git a/src/glx/dri_common.h b/src/glx/dri_common.h
index 6c634d8..24af8a9 100644
--- a/src/glx/dri_common.h
+++ b/src/glx/dri_common.h
@@ -63,8 +63,6 @@
 extern void
 driReleaseDrawables(struct glx_context *gc);
 
-extern const __DRIsystemTimeExtension systemTimeExtension;
-
 extern void dri_message(int level, const char *f, ...) PRINTFLIKE(2, 3);
 
 #define InfoMessageF(...) dri_message(_LOADER_INFO, __VA_ARGS__)
diff --git a/src/glx/dri_glx.c b/src/glx/dri_glx.c
index 3e08735..53de8f0 100644
--- a/src/glx/dri_glx.c
+++ b/src/glx/dri_glx.c
@@ -42,6 +42,7 @@
 #include "dri2.h"
 #include "dri_sarea.h"
 #include <dlfcn.h>
+#include <sys/time.h>
 #include <sys/types.h>
 #include <sys/mman.h>
 #include "xf86drm.h"
@@ -278,6 +279,55 @@
    return e ? e->config : NULL;
 }
 
+/**
+ * Get the unadjusted system time (UST).  Currently, the UST is measured in
+ * microseconds since Epoc.  The actual resolution of the UST may vary from
+ * system to system, and the units may vary from release to release.
+ * Drivers should not call this function directly.  They should instead use
+ * \c glXGetProcAddress to obtain a pointer to the function.
+ *
+ * \param ust Location to store the 64-bit UST
+ * \returns Zero on success or a negative errno value on failure.
+ *
+ * \sa glXGetProcAddress, PFNGLXGETUSTPROC
+ *
+ * \since Internal API version 20030317.
+ */
+static int
+__glXGetUST(int64_t * ust)
+{
+   struct timeval tv;
+
+   if (ust == NULL) {
+      return -EFAULT;
+   }
+
+   if (gettimeofday(&tv, NULL) == 0) {
+      ust[0] = (tv.tv_sec * 1000000) + tv.tv_usec;
+      return 0;
+   }
+   else {
+      return -errno;
+   }
+}
+
+static GLboolean
+__driGetMSCRate(__DRIdrawable *draw,
+		int32_t * numerator, int32_t * denominator,
+		void *loaderPrivate)
+{
+   __GLXDRIdrawable *glxDraw = loaderPrivate;
+
+   return __glxGetMscRate(glxDraw->psc, numerator, denominator);
+}
+
+static const __DRIsystemTimeExtension systemTimeExtension = {
+   .base = {__DRI_SYSTEM_TIME, 1 },
+
+   .getUST              = __glXGetUST,
+   .getMSCRate          = __driGetMSCRate
+};
+
 static GLboolean
 has_damage_post(Display * dpy)
 {
diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h
index 41edf17..ea7668f 100644
--- a/src/glx/glxclient.h
+++ b/src/glx/glxclient.h
@@ -775,9 +775,6 @@
 extern const char __glXGLClientVersion[];
 extern const char __glXGLClientExtensions[];
 
-/* Get the unadjusted system time */
-extern int __glXGetUST(int64_t * ust);
-
 extern GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
                                     int32_t * numerator,
                                     int32_t * denominator);
diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c
index a8c51cb..4b96b38 100644
--- a/src/glx/glxcmds.c
+++ b/src/glx/glxcmds.c
@@ -45,7 +45,6 @@
 #include "apple/apple_glx.h"
 #include "util/debug.h"
 #else
-#include <sys/time.h>
 #ifndef GLX_USE_WINDOWSGL
 #include <X11/extensions/xf86vmode.h>
 #endif /* GLX_USE_WINDOWSGL */
@@ -2650,40 +2649,6 @@
           (procName), glXGetProcAddressARB)
 
 #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
-/**
- * Get the unadjusted system time (UST).  Currently, the UST is measured in
- * microseconds since Epoc.  The actual resolution of the UST may vary from
- * system to system, and the units may vary from release to release.
- * Drivers should not call this function directly.  They should instead use
- * \c glXGetProcAddress to obtain a pointer to the function.
- *
- * \param ust Location to store the 64-bit UST
- * \returns Zero on success or a negative errno value on failure.
- *
- * \sa glXGetProcAddress, PFNGLXGETUSTPROC
- *
- * \since Internal API version 20030317.
- */
-_X_HIDDEN int
-__glXGetUST(int64_t * ust)
-{
-   struct timeval tv;
-
-   if (ust == NULL) {
-      return -EFAULT;
-   }
-
-   if (gettimeofday(&tv, NULL) == 0) {
-      ust[0] = (tv.tv_sec * 1000000) + tv.tv_usec;
-      return 0;
-   }
-   else {
-      return -errno;
-   }
-}
-#endif /* GLX_DIRECT_RENDERING */
-
-#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
 
 PUBLIC int
 MesaGLInteropGLXQueryDeviceInfo(Display *dpy, GLXContext context,