From ca1798e77b6fa99dbb010f202a057f75415afd52 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Tue, 18 Oct 2011 14:25:52 +0200 Subject: [PATCH] va: generate __vaDriverInit_*() function name at run-time. Signed-off-by: Gwenole Beauchesne --- configure.ac | 8 -------- va/va.c | 17 ++++++++++++++--- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index e618337..00b047b 100644 --- a/configure.ac +++ b/configure.ac @@ -125,14 +125,6 @@ AM_CONDITIONAL(USE_GLX, test "$USE_GLX" = "yes") USE_EGL="yes" AM_CONDITIONAL(USE_EGL, test "$USE_EGL" = "yes") - -# Make sure drivers use the correctly versioned __vaDriverInit*() function name -VA_DRIVER_INIT_FUNC="__vaDriverInit_${LIBVA_MAJOR_VERSION}_${LIBVA_MINOR_VERSION}" -AC_DEFINE_UNQUOTED([VA_DRIVER_INIT_FUNC], [$VA_DRIVER_INIT_FUNC], - [Defined to the versioned __vaDriverInit function name]) -AC_DEFINE_UNQUOTED([VA_DRIVER_INIT_FUNC_S], ["$VA_DRIVER_INIT_FUNC"], - [Defined to the versioned __vaDriverInit function name (in string form)]) - # We only need the headers, we don't link against the DRM libraries LIBVA_CFLAGS="$DRM_CFLAGS" AC_SUBST(LIBVA_CFLAGS) diff --git a/va/va.c b/va/va.c index 450b88f..aab00f0 100644 --- a/va/va.c +++ b/va/va.c @@ -149,6 +149,13 @@ static Bool va_checkString(const char* value, char *variable) return True; } +static inline int +va_getDriverInitName(char *name, int namelen, int major, int minor) +{ + int ret = snprintf(name, namelen, "__vaDriverInit_%d_%d", major, minor); + return ret > 0 && ret < namelen; +} + static VAStatus va_getDriverName(VADisplay dpy, char **driver_name) { VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; @@ -193,10 +200,14 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name) if (0 == access( driver_path, F_OK)) va_errorMessage("dlopen of %s failed: %s\n", driver_path, dlerror()); } else { - VADriverInit init_func; - init_func = (VADriverInit) dlsym(handle, VA_DRIVER_INIT_FUNC_S); + VADriverInit init_func = NULL; + char init_func_s[256]; + if (va_getDriverInitName(init_func_s, sizeof(init_func_s), + VA_MAJOR_VERSION, VA_MINOR_VERSION)) + init_func = (VADriverInit) dlsym(handle, init_func_s); if (!init_func) { - va_errorMessage("%s has no function %s\n", driver_path, VA_DRIVER_INIT_FUNC_S); + va_errorMessage("%s has no function %s\n", + driver_path, init_func_s); dlclose(handle); } else { struct VADriverVTable *vtable = ctx->vtable; -- 2.7.4