summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2011-10-18 14:25:52 +0200
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2011-10-18 14:26:37 +0200
commitca1798e77b6fa99dbb010f202a057f75415afd52 (patch)
treefd998975a9b61fd22fd115f21bcfb9badee32d5f
parent37959759f5860d0a6cac087443062e550385b6d4 (diff)
downloadlibva-ca1798e77b6fa99dbb010f202a057f75415afd52.tar.gz
va: generate __vaDriverInit_*() function name at run-time.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
-rw-r--r--configure.ac8
-rw-r--r--va/va.c17
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;