-
-/*
- * Path to the true OpenGL framework
- */
-static const char *libgl_filename = "/System/Library/Frameworks/OpenGL.framework/OpenGL";
-
-
-/*
- * Handle to the true OpenGL framework.
- */
-static void *libgl_handle = NULL;
-
-
-/*
- * Lookup a libGL symbol
- */
-static void * __dlsym(const char *symbol)
-{
- void *result;
-
- if (!libgl_handle) {
- /*
- * Unfortunately we can't just dlopen the true dynamic library because
- * DYLD_LIBRARY_PATH/DYLD_FRAMEWORK_PATH take precedence, even for
- * absolute paths. So we create a temporary symlink, and dlopen that
- * instead.
- */
-
- char temp_filename[] = "/tmp/tmp.XXXXXX";
-
- if (mktemp(temp_filename) != NULL) {
- if (symlink(libgl_filename, temp_filename) == 0) {
- libgl_handle = dlopen(temp_filename, RTLD_LOCAL | RTLD_NOW | RTLD_FIRST);
- remove(temp_filename);
- }
- }
-
- if (!libgl_handle) {
- OS::DebugMessage("apitrace: error: couldn't load %s\n", libgl_filename);
- OS::Abort();
- return NULL;
- }
- }
-
- result = dlsym(libgl_handle, symbol);
-
- if (result == dlsym(RTLD_SELF, symbol)) {
- OS::DebugMessage("apitrace: error: symbol lookup recursion\n");
- OS::Abort();
- return NULL;
- }
-
- return result;
-}
-
-