bug 894382 - support libudev.so.1 in Linux Gamepad backend. r=karlt
authorTed Mielczarek <ted@mielczarek.org>
Mon, 29 Jul 2013 09:04:56 -0400
changeset 152630 12920f3feadc9926cbe0c4b6cef8c7adbcbdee08
parent 152629 4fae10b5214809f28936213c26ca49a1d6bfed1c
child 152631 e80edaac389923fbfbeff054ac391dfaae4b262e
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs894382
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 894382 - support libudev.so.1 in Linux Gamepad backend. r=karlt
hal/linux/udev.h
--- a/hal/linux/udev.h
+++ b/hal/linux/udev.h
@@ -7,28 +7,39 @@
  * linking directly to it and use dlopen instead.
  */
 
 #ifndef HAL_LINUX_UDEV_H_
 #define HAL_LINUX_UDEV_H_
 
 #include <dlfcn.h>
 
+#include "mozilla/Util.h"
+
 namespace mozilla {
 
 struct udev;
 struct udev_device;
 struct udev_enumerate;
 struct udev_list_entry;
 struct udev_monitor;
 
 class udev_lib {
  public:
-  udev_lib() : lib(dlopen("libudev.so.0", RTLD_LAZY | RTLD_GLOBAL)),
-               udev(NULL) {
+  udev_lib() : lib(nullptr),
+               udev(nullptr) {
+    // Be careful about ABI compat! 0 -> 1 didn't change any
+    // symbols this code relies on, per:
+    // https://lists.fedoraproject.org/pipermail/devel/2012-June/168227.html
+    const char* lib_names[] = {"libudev.so.0", "libudev.so.1"};
+    for (unsigned i = 0; i < ArrayLength(lib_names); i++) {
+      lib = dlopen(lib_names[i], RTLD_LAZY | RTLD_GLOBAL);
+      if (lib)
+        break;
+    }
     if (lib && LoadSymbols())
       udev = udev_new();
   }
 
   ~udev_lib() {
     if (udev) {
       udev_unref(udev);
     }