Bug 719164 - Silence glxtest to get rid of spurious messages from the GL - r=glandium

This commit is contained in:
Benoit Jacob 2012-02-08 21:55:34 -05:00
parent 5a18638917
commit 9f48a1240f

View File

@ -59,6 +59,8 @@
#include <dlfcn.h>
#include "nscore.h"
#include <fcntl.h>
#ifdef __SUNPRO_CC
#include <stdio.h>
#endif
@ -110,20 +112,29 @@ x_error_handler(Display *, XErrorEvent *ev)
static void glxtest()
{
// we want to redirect to /dev/null stdout, stderr, and while we're at it,
// any PR logging file descriptors. To that effect, we redirect all positive
// file descriptors up to what open() returns here. In particular, 1 is stdout and 2 is stderr.
int fd = open("/dev/null", O_WRONLY);
for (int i = 1; i < fd; i++)
dup2(fd, i);
close(fd);
///// Open libGL and load needed symbols /////
#ifdef __OpenBSD__
void *libgl = dlopen("libGL.so", RTLD_LAZY);
#define LIBGL_FILENAME "libGL.so"
#else
void *libgl = dlopen("libGL.so.1", RTLD_LAZY);
#define LIBGL_FILENAME "libGL.so.1"
#endif
void *libgl = dlopen(LIBGL_FILENAME, RTLD_LAZY);
if (!libgl)
fatal_error("Unable to load libGL.so.1");
fatal_error("Unable to load " LIBGL_FILENAME);
typedef void* (* PFNGLXGETPROCADDRESS) (const char *);
PFNGLXGETPROCADDRESS glXGetProcAddress = cast<PFNGLXGETPROCADDRESS>(dlsym(libgl, "glXGetProcAddress"));
if (!glXGetProcAddress)
fatal_error("Unable to find glXGetProcAddress in libGL.so.1");
fatal_error("Unable to find glXGetProcAddress in " LIBGL_FILENAME);
typedef GLXFBConfig* (* PFNGLXQUERYEXTENSION) (Display *, int *, int *);
PFNGLXQUERYEXTENSION glXQueryExtension = cast<PFNGLXQUERYEXTENSION>(glXGetProcAddress("glXQueryExtension"));