Hello community, here is the log from the commit of package libusb-compat for openSUSE:Factory checked in at 2015-07-16 17:17:21 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libusb-compat (Old) and /work/SRC/openSUSE:Factory/.libusb-compat.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libusb-compat" Changes: -------- --- /work/SRC/openSUSE:Factory/libusb-compat/libusb-compat.changes 2015-06-23 11:55:12.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.libusb-compat.new/libusb-compat.changes 2015-07-16 17:17:22.000000000 +0200 @@ -1,0 +2,7 @@ +Thu Jul 9 18:26:32 CEST 2015 - [email protected] + +- Fix libusb-compat-hide-libusb-1_0.patch: Ensure that inline + functions inside libusb-1.0/libusb.h use wrapped calls. + It should fix all triggered build failures. + +------------------------------------------------------------------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libusb-compat.spec ++++++ --- /var/tmp/diff_new_pack.cQMa0i/_old 2015-07-16 17:17:22.000000000 +0200 +++ /var/tmp/diff_new_pack.cQMa0i/_new 2015-07-16 17:17:22.000000000 +0200 @@ -90,8 +90,7 @@ %patch0 -p1 %patch1 -p1 %patch2 -p1 -# disabled, as it causes the lib to fail to load due to symbols of libusb 1.0 not being available in the end -#patch3 -p1 +%patch3 -p1 %build autoreconf -f -i ++++++ libusb-compat-hide-libusb-1_0.patch ++++++ --- /var/tmp/diff_new_pack.cQMa0i/_old 2015-07-16 17:17:22.000000000 +0200 +++ /var/tmp/diff_new_pack.cQMa0i/_new 2015-07-16 17:17:22.000000000 +0200 @@ -1,10 +1,8 @@ -https://sourceforge.net/p/libusb/mailman/message/34106038/ +https://sourceforge.net/p/libusb/mailman/message/34281276/ -From: Stanislav Brabec <[email protected]> -To: "[email protected]" <[email protected]> -Date: Tue, 12 May 2015 17:19:05 +0200 -Subject: [libusb] [PATCH][libusb-compat-0.1][TRY2] Prevent libusb-1.0 - library symbol clash +From: Stanislav Brabec <[email protected]> +Date: Thu, 09 Jul 2015 18:21:56 +0200 +Subject: [libusb] [PATCH][libusb-compat-0.1][TRY3] Prevent libusb-1.0 library symbol clash List-Id: Development discussion for libusb <libusb-devel.lists.sourceforge.net> libusb-1.0 uses functions like libusb_open. These names are generic, and @@ -27,6 +25,9 @@ (It could be theoretically possible to introduce clashes with libdl, but it is much less probable.) +To wrap symbols inside static inline functions inside libusb.h, the +Makefile generates a modified version if libusb.h. + How to reproduce: Take testlibusb.c from libusb-0.1.12/tests and replace print_device @@ -35,33 +36,43 @@ Reference: https://bugzilla.opensuse.org/show_bug.cgi?id=596411 -Signed-off-by: Stanislav Brabec <[email protected]> +Signed-off-by: Stanislav Brabec <[email protected]> --- - configure.ac | 14 ++++ - libusb/Makefile.am | 6 +- - libusb/core.c | 14 ++++ - libusb/libusb-dload.h | 203 ++++++++++++++++++++++++++++++++++++++++++++++ - m4/au_check_lib_soname.m4 | 43 ++++++++++ - m4/au_have_gnu_errno.m4 | 17 ++++ - 6 files changed, 296 insertions(+), 1 deletion(-) + configure.ac | 23 +++++++++ + libusb/Makefile.am | 11 +++- + libusb/core.c | 14 ++++++ + libusb/libusb-dload.h | 124 ++++++++++++++++++++++++++++++++++++++++++++++ + m4/au_check_lib_soname.m4 | 43 ++++++++++++++++ + m4/au_have_gnu_errno.m4 | 17 +++++++ + 6 files changed, 231 insertions(+), 1 deletion(-) create mode 100644 libusb/libusb-dload.h create mode 100644 m4/au_check_lib_soname.m4 create mode 100644 m4/au_have_gnu_errno.m4 diff --git a/configure.ac b/configure.ac -index debfef2..3c26903 100644 +index debfef2..18a86c2 100644 --- a/configure.ac +++ b/configure.ac -@@ -26,6 +26,20 @@ PKG_CHECK_MODULES([LIBUSB_1_0], libusb-1.0 >= 0.9.1) +@@ -25,6 +25,29 @@ AC_SUBST(LIBUSB01_VERSION) + PKG_CHECK_MODULES([LIBUSB_1_0], libusb-1.0 >= 0.9.1) AC_SUBST(LIBUSB_1_0_CFLAGS) AC_SUBST(LIBUSB_1_0_LIBS) - ++# dlopen wrapper needs a location of libusb.h. ++# Setting of LIBUSB_H variable can override pkg-config. ++if test x"$LIBUSB_H" = x ; then ++ LIBUSB_H=`echo "$LIBUSB_1_0_CFLAGS" | sed 's/^.*-I//;s/ .*//'`/libusb.h ++fi ++AC_CHECK_FILE([$LIBUSB_H], [ ++ AC_SUBST([LIBUSB_H])], [ ++ LIBUSB_H=""]) ++ +# Checks for dynamic loading of libusb-1.0 +ac_save_LIBS="$LIBS" +AC_CHECK_HEADER([dlfcn.h], [ -+ AC_CHECK_LIB([dl], [dlopen], [ -+ AC_CHECK_LIB([dl], [dlsym], [ -+ AU_CHECK_LIB_SONAME([LIBUSB_1_0], [usb-1.0], [libusb_open])])])]) ++ AS_IF([test x"$LIBUSB_H" != x], [ ++ AC_CHECK_LIB([dl], [dlopen], [ ++ AC_CHECK_LIB([dl], [dlsym], [ ++ AU_CHECK_LIB_SONAME([LIBUSB_1_0], [usb-1.0], [libusb_open])])])])]) +LIBS="$ac_save_LIBS" +if test x"$LIBUSB_1_0_SONAME" != x ; then + AC_DEFINE_UNQUOTED([LIBUSB_1_0_SONAME], ["$LIBUSB_1_0_SONAME"], [SONAME of libusb-1.0. If defined, libusb-1.0 can be hidden.]) @@ -69,15 +80,14 @@ +AM_CONDITIONAL([USE_LIBUSB_1_0_DLOAD], [test x"$LIBUSB_1_0_SONAME" != x]) + +AU_HAVE_GNU_ERRNO_H -+ + # Message logging AC_ARG_ENABLE([log], [AS_HELP_STRING([--disable-log], [disable all logging])], - [log_enabled=$enableval], diff --git a/libusb/Makefile.am b/libusb/Makefile.am -index 33a609a..4585025 100644 +index 33a609a..39da7c2 100644 --- a/libusb/Makefile.am +++ b/libusb/Makefile.am -@@ -1,9 +1,13 @@ +@@ -1,9 +1,18 @@ include_HEADERS = usb.h lib_LTLIBRARIES = libusb.la @@ -86,27 +96,33 @@ libusb_la_CFLAGS = -fvisibility=hidden $(AM_CFLAGS) $(LIBUSB_1_0_CFLAGS) +if USE_LIBUSB_1_0_DLOAD +libusb_la_LIBADD = -ldl ++BUILT_SOURCES = libusb-wrapped.h +else libusb_la_LIBADD = $(LIBUSB_1_0_LIBS) +endif libusb_la_LDFLAGS = -version-info $(LT_MAJOR):$(LT_REVISION):$(LT_AGE) \ -release 0.1 ++# Rewrite libusb.h to refer to wrapped calls. ++libusb-wrapped.h: $(LIBUSB_H) $(srcdir)/Makefile.am ++ $(SED) 's/return libusb_control_transfer/return (dl_libusb_control_transfer)/;s/\tlibusb_transfer_set_stream_id/\t(dl_libusb_transfer_set_stream_id)/;/LIBUSB_CALL libusb/{s/(/)(/;s/LIBUSB_CALL /(*dl_/;}' <$< >$@ ++CONFIG_CLEAN_FILES = libusb-wrapped.h diff --git a/libusb/core.c b/libusb/core.c -index e6e500b..8b5470a 100644 +index e6e500b..b516f59 100644 --- a/libusb/core.c +++ b/libusb/core.c -@@ -31,6 +31,10 @@ - #include "usb.h" - #include "usbi.h" +@@ -26,7 +26,11 @@ + #include <stdio.h> + #include <string.h> +#ifdef LIBUSB_1_0_SONAME +#include "libusb-dload.h" ++#else + #include <libusb.h> +#endif -+ - static libusb_context *ctx = NULL; - static int usb_debug = 0; + #include "usb.h" + #include "usbi.h" @@ -61,12 +65,22 @@ API_EXPORTED struct usb_bus *usb_busses = NULL; #define compat_err(e) -(errno=libusb_to_errno(e)) @@ -132,163 +148,84 @@ static int libusb_to_errno(int result) diff --git a/libusb/libusb-dload.h b/libusb/libusb-dload.h new file mode 100644 -index 0000000..8524645 +index 0000000..a45a7b2 --- /dev/null +++ b/libusb/libusb-dload.h -@@ -0,0 +1,203 @@ +@@ -0,0 +1,124 @@ ++/* -*- Mode: C; c-basic-offset:8 ; indent-tabs-mode:t -*- */ ++/* ++ * Dynamic library wrapper hiding library symbols from libusb-1.O ++ * Copyright (C) 2015 Stanislav Brabec <[email protected]> ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ */ ++ +#include "config.h" -+#include <libusb.h> -+#include <stdlib.h> -+#include <stdio.h> -+#include <string.h> -+#include <errno.h> -+#include <dlfcn.h> + -+#define libusb_bulk_transfer (dl_libusb_bulk_transfer) -+static int (*dl_libusb_bulk_transfer)(libusb_device_handle *dev_handle, -+ unsigned char endpoint, unsigned char *data, int length, -+ int *actual_length, unsigned int timeout); ++/* Include libusb.h with wrapped inlined calls and declarations in style ++ * needed for dlopen references */ ++#include "libusb-wrapped.h" + ++/* Now make defines to force use of these wrappers */ ++#define libusb_bulk_transfer (dl_libusb_bulk_transfer) +#define libusb_claim_interface (dl_libusb_claim_interface) -+static int (*dl_libusb_claim_interface)(libusb_device_handle *dev, -+ int interface_number); -+ +#define libusb_release_interface (dl_libusb_release_interface) -+static int (*dl_libusb_release_interface)(libusb_device_handle *dev, -+ int interface_number); -+ +#define libusb_clear_halt (dl_libusb_clear_halt) -+static int (*dl_libusb_clear_halt)(libusb_device_handle *dev, -+ unsigned char endpoint); -+ +#define libusb_reset_device (dl_libusb_reset_device) -+static int (*dl_libusb_reset_device)(libusb_device_handle *dev); -+ +#define libusb_get_bus_number (dl_libusb_get_bus_number) -+static uint8_t (*libusb_get_bus_number)(libusb_device *dev); -+ +#define libusb_open (dl_libusb_open) -+static int (*libusb_open)(libusb_device *dev, libusb_device_handle **handle); -+ +#define libusb_close (dl_libusb_close) -+static void (*dl_libusb_close)(libusb_device_handle *dev_handle); -+ +#define libusb_set_configuration (dl_libusb_set_configuration) -+static int (*dl_libusb_set_configuration)(libusb_device_handle *dev, -+ int configuration); -+ +#define libusb_control_transfer (dl_libusb_control_transfer) -+static int (*dl_libusb_control_transfer)(libusb_device_handle *dev_handle, -+ uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, -+ unsigned char *data, uint16_t wLength, unsigned int timeout); -+ +#define libusb_detach_kernel_driver (dl_libusb_detach_kernel_driver) -+static int (*dl_libusb_detach_kernel_driver)(libusb_device_handle *dev, -+ int interface_number); -+ +#define libusb_exit (dl_libusb_exit) -+static void (*dl_libusb_exit)(libusb_context *ctx); -+ +#define libusb_set_debug (dl_libusb_set_debug) -+static void (*dl_libusb_set_debug)(libusb_context *ctx, int level); -+ +#define libusb_free_config_descriptor (dl_libusb_free_config_descriptor) -+static void (*dl_libusb_free_config_descriptor)( -+ struct libusb_config_descriptor *config); -+ +#define libusb_free_device_list (dl_libusb_free_device_list) -+static void (*dl_libusb_free_device_list)(libusb_device **list, -+ int unref_devices); -+ +#define libusb_ref_device (dl_libusb_ref_device) -+static libusb_device * (*dl_libusb_ref_device)(libusb_device *dev); -+ +#define libusb_unref_device (dl_libusb_unref_device) -+static void (*dl_libusb_unref_device)(libusb_device *dev); -+ +#define libusb_get_config_descriptor (dl_libusb_get_config_descriptor) -+static int (*dl_libusb_get_config_descriptor)(libusb_device *dev, -+ uint8_t config_index, struct libusb_config_descriptor **config); -+ +#define libusb_free_config_descriptor (dl_libusb_free_config_descriptor) -+static void (*dl_libusb_free_config_descriptor)( -+ struct libusb_config_descriptor *config); -+ +#define libusb_get_device_address (dl_libusb_get_device_address) -+static uint8_t (*dl_libusb_get_device_address)(libusb_device *dev); -+ +#define libusb_get_device_descriptor (dl_libusb_get_device_descriptor) -+static int (*dl_libusb_get_device_descriptor)(libusb_device *dev, -+ struct libusb_device_descriptor *desc); -+ +#define libusb_get_device_list (dl_libusb_get_device_list) -+static ssize_t (*dl_libusb_get_device_list)(libusb_context *ctx, -+ libusb_device ***list); -+ +#define libusb_free_device_list (dl_libusb_free_device_list) -+static void (*dl_libusb_free_device_list)(libusb_device **list, -+ int unref_devices); -+ +#define libusb_get_string_descriptor_ascii (dl_libusb_get_string_descriptor_ascii) -+static int (*dl_libusb_get_string_descriptor_ascii)(libusb_device_handle *dev, -+ uint8_t desc_index, unsigned char *data, int length); -+ +#define libusb_init (dl_libusb_init) -+static int (*dl_libusb_init)(libusb_context **ctx); -+ +#define libusb_exit (dl_libusb_exit) -+static void (*dl_libusb_exit)(libusb_context *ctx); -+ +#define libusb_set_debug (dl_libusb_set_debug) -+static void (*dl_libusb_set_debug)(libusb_context *ctx, int level); -+ +#define libusb_interrupt_transfer (dl_libusb_interrupt_transfer) -+static int (*dl_libusb_interrupt_transfer)(libusb_device_handle *dev_handle, -+ unsigned char endpoint, unsigned char *data, int length, -+ int *actual_length, unsigned int timeout); -+ +#define libusb_kernel_driver_active (dl_libusb_kernel_driver_active) -+static int (*dl_libusb_kernel_driver_active)(libusb_device_handle *dev, -+ int interface_number); -+ +#define libusb_detach_kernel_driver (dl_libusb_detach_kernel_driver) -+static int (*dl_libusb_detach_kernel_driver)(libusb_device_handle *dev, -+ int interface_number); -+ +#define libusb_ref_device (dl_libusb_ref_device) -+static libusb_device * (*dl_libusb_ref_device)(libusb_device *dev); -+ +#define libusb_unref_device (dl_libusb_unref_device) -+static void (*dl_libusb_unref_device)(libusb_device *dev); -+ +#define libusb_release_interface (dl_libusb_release_interface) -+static int (*dl_libusb_release_interface)(libusb_device_handle *dev, -+ int interface_number); -+ +#define libusb_reset_device (dl_libusb_reset_device) -+static int (*dl_libusb_reset_device)(libusb_device_handle *dev); -+ +#define libusb_set_configuration (dl_libusb_set_configuration) -+static int (*dl_libusb_set_configuration)(libusb_device_handle *dev, -+ int configuration); -+ +#define libusb_claim_interface (dl_libusb_claim_interface) -+static int (*dl_libusb_claim_interface)(libusb_device_handle *dev, -+ int interface_number); -+ +#define libusb_set_debug (dl_libusb_set_debug) -+static void (*dl_libusb_set_debug)(libusb_context *ctx, int level); -+ +#define libusb_set_interface_alt_setting (dl_libusb_set_interface_alt_setting) -+static int (*dl_libusb_set_interface_alt_setting)(libusb_device_handle *dev, -+ int interface_number, int alternate_setting); -+ +#define libusb_clear_halt (dl_libusb_clear_halt) -+static int (*dl_libusb_clear_halt)(libusb_device_handle *dev, -+ unsigned char endpoint); -+ +#define libusb_unref_device (dl_libusb_unref_device) -+static void (*dl_libusb_unref_device)(libusb_device *dev); ++ ++/* And finally handle the wrapping itself */ ++#include <stdlib.h> ++#include <stdio.h> ++#include <string.h> ++#include <errno.h> ++#include <dlfcn.h> + +static void *libusb_dl_handle; + @@ -412,4 +349,5 @@ + ]) +]) -- -2.3.7 +2.4.5 +
