]> git.cworth.org Git - glaze/commitdiff
Rename glaze.c to glaze-gl.c
authorCarl Worth <cworth@cworth.org>
Mon, 12 Aug 2013 19:22:00 +0000 (12:22 -0700)
committerCarl Worth <cworth@cworth.org>
Mon, 12 Aug 2013 19:22:00 +0000 (12:22 -0700)
I'm planning to add a new glaze library with a "glaze.h" header file,
so it will be natural to have its implementation in glaze.c. To
prepare for that, I'm renaming the OpenGL API implementation from
glaze.c to glaze-gl.c.

Makefile
glaze-gl.c [new file with mode: 0644]
glaze.c [deleted file]

index bd7064f04eaa3d71e6339611dc4838ea27123faf..c9db5c8f7a18300d037c542b54b7d689376d825e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,11 +6,11 @@ TARGETS = lib64/libGL.so.1 lib32/libGL.so.1
 
 all: $(TARGETS)
 
-lib64/libGL.so.1: glaze.c glapi.def
+lib64/libGL.so.1: glaze-gl.c glapi.def
        mkdir -p lib64
        $(CC) $(CFLAGS) -m64 -fPIC -shared -Wl,-Bsymbolic -o $@ $<
 
-lib32/libGL.so.1: glaze.c specs/gl.def
+lib32/libGL.so.1: glaze-gl.c specs/gl.def
        mkdir -p lib32
        $(CC) $(CFLAGS) -m32 -fPIC -shared -Wl,-Bsymbolic -o $@ $<
 
diff --git a/glaze-gl.c b/glaze-gl.c
new file mode 100644 (file)
index 0000000..0c2eada
--- /dev/null
@@ -0,0 +1,102 @@
+/* Copyright © 2013, Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#define _GNU_SOURCE
+#include <dlfcn.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+void *libgl_handle;
+void *wrapper_handle;
+
+static void
+open_libgl_handle (void)
+{
+       const char *path;
+
+       if (libgl_handle)
+               return;
+
+       path = getenv ("GLAZE_LIBGL");
+       if (path == NULL) {
+               fprintf (stderr, "GLAZE_LIBGL unset. Please set to path of real libGL.so under glaze.\n");
+               exit (1);
+       }
+
+       libgl_handle = dlopen (path, RTLD_LAZY | RTLD_GLOBAL);
+       if (libgl_handle == NULL) {
+               fprintf (stderr, "Error: Failed to dlopen %s\n", path);
+               exit (1);
+       }
+}
+
+static void
+open_wrapper_handle (void)
+{
+       const char *path;
+
+       if (wrapper_handle)
+               return;
+
+       path = getenv ("GLAZE_WRAPPER");
+       if (path == NULL) {
+               fprintf (stderr, "GLAZE_WRAPPER unset. Please set to path of real libGL.so under glaze.\n");
+               exit (1);
+       }
+
+       wrapper_handle = dlopen (path, RTLD_LAZY);
+       if (wrapper_handle == NULL) {
+               fprintf (stderr, "Error: Failed to dlopen %s\n", path);
+               exit (1);
+       }
+}
+
+static void
+glaze_init (void) __attribute__((constructor));
+
+static void
+glaze_init (void)
+{
+       open_libgl_handle ();
+       open_wrapper_handle ();
+}
+
+static void *
+resolve (const char *name)
+{
+       void *symbol;
+
+       /* The wrapper gets first choice on all symbols. */
+       symbol = dlsym (wrapper_handle, name);
+       if (symbol)
+               return symbol;
+
+       return dlsym (libgl_handle, name);
+}
+
+#define GLAZE_API(name)                                                        \
+void * name() __attribute__((ifunc(#name "_resolver")));               \
+static void *                                                          \
+name ## _resolver (void) { return resolve (#name); }
+
+#include "specs/gl.def"
+#include "specs/glx.def"
diff --git a/glaze.c b/glaze.c
deleted file mode 100644 (file)
index 0c2eada..0000000
--- a/glaze.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/* Copyright © 2013, Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#define _GNU_SOURCE
-#include <dlfcn.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-
-void *libgl_handle;
-void *wrapper_handle;
-
-static void
-open_libgl_handle (void)
-{
-       const char *path;
-
-       if (libgl_handle)
-               return;
-
-       path = getenv ("GLAZE_LIBGL");
-       if (path == NULL) {
-               fprintf (stderr, "GLAZE_LIBGL unset. Please set to path of real libGL.so under glaze.\n");
-               exit (1);
-       }
-
-       libgl_handle = dlopen (path, RTLD_LAZY | RTLD_GLOBAL);
-       if (libgl_handle == NULL) {
-               fprintf (stderr, "Error: Failed to dlopen %s\n", path);
-               exit (1);
-       }
-}
-
-static void
-open_wrapper_handle (void)
-{
-       const char *path;
-
-       if (wrapper_handle)
-               return;
-
-       path = getenv ("GLAZE_WRAPPER");
-       if (path == NULL) {
-               fprintf (stderr, "GLAZE_WRAPPER unset. Please set to path of real libGL.so under glaze.\n");
-               exit (1);
-       }
-
-       wrapper_handle = dlopen (path, RTLD_LAZY);
-       if (wrapper_handle == NULL) {
-               fprintf (stderr, "Error: Failed to dlopen %s\n", path);
-               exit (1);
-       }
-}
-
-static void
-glaze_init (void) __attribute__((constructor));
-
-static void
-glaze_init (void)
-{
-       open_libgl_handle ();
-       open_wrapper_handle ();
-}
-
-static void *
-resolve (const char *name)
-{
-       void *symbol;
-
-       /* The wrapper gets first choice on all symbols. */
-       symbol = dlsym (wrapper_handle, name);
-       if (symbol)
-               return symbol;
-
-       return dlsym (libgl_handle, name);
-}
-
-#define GLAZE_API(name)                                                        \
-void * name() __attribute__((ifunc(#name "_resolver")));               \
-static void *                                                          \
-name ## _resolver (void) { return resolve (#name); }
-
-#include "specs/gl.def"
-#include "specs/glx.def"