driverName = loader_driverName;
}
- psc->driver = driOpenDriver(driverName);
- if (psc->driver == NULL) {
- ErrorMessageF("driver pointer missing\n");
- goto handle_error;
- }
-
- extensions = driGetDriverExtensions(psc->driver, driverName);
+ extensions = driOpenDriver(driverName, &psc->driver);
if (extensions == NULL)
goto handle_error;
goto handle_error;
}
- psc->driver = driOpenDriver(driverName);
- if (psc->driver == NULL) {
- ErrorMessageF("driver pointer missing\n");
- goto handle_error;
- }
-
- extensions = driGetDriverExtensions(psc->driver, driverName);
+ extensions = driOpenDriver(driverName, &psc->driver);
if (extensions == NULL)
goto handle_error;
#define GL_LIB_NAME "libGL.so.1"
#endif
+static const __DRIextension **
+driGetDriverExtensions(void *handle, const char *driver_name);
+
/**
* Try to \c dlopen the named driver.
*
* order to find the driver.
*
* \param driverName - a name like "i965", "radeon", "nouveau", etc.
+ * \param out_driver_handle - Address to return the resulting dlopen() handle.
*
* \returns
- * A handle from \c dlopen, or \c NULL if driver file not found.
+ * The __DRIextension entrypoint table for the driver, or \c NULL if driver
+ * file not found.
*/
-_X_HIDDEN void *
-driOpenDriver(const char *driverName)
+_X_HIDDEN const __DRIextension **
+driOpenDriver(const char *driverName, void **out_driver_handle)
{
void *glhandle, *handle;
const char *libPaths, *p, *next;
if (glhandle)
dlclose(glhandle);
- return handle;
+ const __DRIextension **extensions = driGetDriverExtensions(handle,
+ driverName);
+ if (!extensions) {
+ dlclose(handle);
+ handle = NULL;
+ }
+
+ *out_driver_handle = handle;
+ return extensions;
}
-_X_HIDDEN const __DRIextension **
+static const __DRIextension **
driGetDriverExtensions(void *handle, const char *driver_name)
{
const __DRIextension **extensions = NULL;
#define ErrorMessageF(...) dri_message(_LOADER_WARNING, __VA_ARGS__)
#define CriticalErrorMessageF(...) dri_message(_LOADER_FATAL, __VA_ARGS__)
-extern void *driOpenDriver(const char *driverName);
-
-extern const __DRIextension **
-driGetDriverExtensions(void *handle, const char *driver_name);
+extern const __DRIextension **driOpenDriver(const char *driverName,
+ void **out_driver_handle);
extern bool
dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
static char *
get_driver_config(const char *driverName)
{
- void *handle = driOpenDriver(driverName);
- const __DRIextension **extensions;
-
- if (!handle)
- return NULL;
-
+ void *handle;
char *config = NULL;
-
- extensions = driGetDriverExtensions(handle, driverName);
+ const __DRIextension **extensions = driOpenDriver(driverName, &handle);
if (extensions) {
for (int i = 0; extensions[i]; i++) {
if (strcmp(extensions[i]->name, __DRI_CONFIG_OPTIONS) != 0)
goto cleanup;
}
- psc->driver = driOpenDriver(driverName);
- if (psc->driver == NULL)
- goto cleanup;
-
- extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS);
+ extensions = driOpenDriver(driverName, &psc->driver);
if (extensions == NULL) {
ErrorMessageF("driver exports no extensions (%s)\n", dlerror());
goto cleanup;
#define SWRAST_DRIVER_NAME "swrast"
-static void *
-driOpenSwrast(void)
-{
- void *driver = NULL;
-
- if (driver == NULL)
- driver = driOpenDriver(SWRAST_DRIVER_NAME);
-
- return driver;
-}
-
static const struct glx_screen_vtable drisw_screen_vtable = {
.create_context = drisw_create_context,
.create_context_attribs = drisw_create_context_attribs,
return NULL;
}
- psc->driver = driOpenSwrast();
- if (psc->driver == NULL)
- goto handle_error;
-
- extensions = driGetDriverExtensions(psc->driver, SWRAST_DRIVER_NAME);
+ extensions = driOpenDriver(SWRAST_DRIVER_NAME, &psc->driver);
if (extensions == NULL)
goto handle_error;