[Wine-patches] [eterwine] Prevent using libusb.h if libusb-1.0 library is not found.
Alexander Morozov
amorozov на etersoft.ru
Пт Май 4 16:58:54 MSK 2012
---
configure | 22 +++++----------------
configure.ac | 6 +++---
dlls/mountmgr.sys/usbhub.c | 44 +++++++++++++++++++++---------------------
include/config.h.in | 7 ++-----
programs/services/services.c | 8 ++++----
5 files changed, 36 insertions(+), 51 deletions(-)
diff --git a/configure b/configure
index ef66f16..32de0c7 100755
--- a/configure
+++ b/configure
@@ -10149,14 +10149,9 @@ USBINCL=""
if test "x$with_usb" != "xno"
then
- for ac_header in usb.h
-do :
- ac_fn_c_check_header_mongrel "$LINENO" "usb.h" "ac_cv_header_usb_h" "$ac_includes_default"
+ ac_fn_c_check_header_mongrel "$LINENO" "usb.h" "ac_cv_header_usb_h" "$ac_includes_default"
if test "x$ac_cv_header_usb_h" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_USB_H 1
-_ACEOF
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for usb_init in -lusb" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for usb_init in -lusb" >&5
$as_echo_n "checking for usb_init in -lusb... " >&6; }
if ${ac_cv_lib_usb_usb_init+:} false; then :
$as_echo_n "(cached) " >&6
@@ -10201,7 +10196,6 @@ fi
fi
-done
ac_save_CPPFLAGS="$CPPFLAGS"
if test "$PKG_CONFIG" != "false"
@@ -10210,14 +10204,9 @@ done
ac_usb_libs="`$PKG_CONFIG --libs libusb-1.0`"
CPPFLAGS="$ac_usb_incl $CPPFLAGS"
fi
- for ac_header in libusb.h
-do :
- ac_fn_c_check_header_mongrel "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default"
+ ac_fn_c_check_header_mongrel "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default"
if test "x$ac_cv_header_libusb_h" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBUSB_H 1
-_ACEOF
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libusb_init in -lusb-1.0" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libusb_init in -lusb-1.0" >&5
$as_echo_n "checking for libusb_init in -lusb-1.0... " >&6; }
if ${ac_cv_lib_usb_1_0_libusb_init+:} false; then :
$as_echo_n "(cached) " >&6
@@ -10255,7 +10244,7 @@ fi
$as_echo "$ac_cv_lib_usb_1_0_libusb_init" >&6; }
if test "x$ac_cv_lib_usb_1_0_libusb_init" = xyes; then :
-$as_echo "#define HAVE_LIBUSB 1" >>confdefs.h
+$as_echo "#define HAVE_LIBUSB_1 1" >>confdefs.h
USBLIBS="$ac_usb_libs"
USBINCL="$ac_usb_incl"
@@ -10263,7 +10252,6 @@ fi
fi
-done
CPPFLAGS="$ac_save_CPPFLAGS"
fi
diff --git a/configure.ac b/configure.ac
index f2d5291..775319a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1342,7 +1342,7 @@ AC_SUBST(USBLIBS,"")
AC_SUBST(USBINCL,"")
if test "x$with_usb" != "xno"
then
- AC_CHECK_HEADERS([usb.h],
+ AC_CHECK_HEADER(usb.h,
AC_CHECK_LIB(usb, usb_init,
[AC_DEFINE(HAVE_LIBUSB, 1, [Define if you have the libusb library and header])
USBLIBS="-lusb"]))
@@ -1353,9 +1353,9 @@ then
ac_usb_libs="`$PKG_CONFIG --libs libusb-1.0`"
CPPFLAGS="$ac_usb_incl $CPPFLAGS"
fi
- AC_CHECK_HEADERS([libusb.h],
+ AC_CHECK_HEADER(libusb.h,
AC_CHECK_LIB(usb-1.0, libusb_init,
- [AC_DEFINE(HAVE_LIBUSB, 1, [Define if you have the libusb library and header])
+ [AC_DEFINE(HAVE_LIBUSB_1, 1, [Define if you have the libusb-1.0 library and header])
USBLIBS="$ac_usb_libs"
USBINCL="$ac_usb_incl"]))
CPPFLAGS="$ac_save_CPPFLAGS"
diff --git a/dlls/mountmgr.sys/usbhub.c b/dlls/mountmgr.sys/usbhub.c
index 197e039..1ce0c2b 100644
--- a/dlls/mountmgr.sys/usbhub.c
+++ b/dlls/mountmgr.sys/usbhub.c
@@ -22,9 +22,9 @@
#include <stdio.h>
#include <stdlib.h>
-#ifdef HAVE_LIBUSB_H
+#ifdef HAVE_LIBUSB_1
#include <libusb.h>
-#elif defined(HAVE_USB_H)
+#elif defined(HAVE_LIBUSB)
#include <usb.h>
#undef USB_ENDPOINT_TYPE_MASK
#undef USB_ENDPOINT_TYPE_CONTROL
@@ -52,7 +52,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(usbhub);
-#ifdef HAVE_LIBUSB
+#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1)
extern NTSTATUS CDECL __wine_add_device( DRIVER_OBJECT *driver, DEVICE_OBJECT *dev );
extern DRIVER_OBJECT * CDECL __wine_get_driver_object( const WCHAR *service );
@@ -81,7 +81,7 @@ struct DeviceInstance
char *instance_id;
WCHAR *service;
DEVICE_OBJECT *pdo;
-#ifdef HAVE_LIBUSB_H
+#ifdef HAVE_LIBUSB_1
libusb_device *dev;
#else
struct usb_device *dev;
@@ -136,7 +136,7 @@ static void add_data( unsigned char **dst, ULONG *dst_size, const void *src, ULO
*dst_size -= copy;
}
-#ifdef HAVE_LIBUSB_H
+#ifdef HAVE_LIBUSB_1
struct DeviceInstance *get_device_by_index( libusb_device *device,
ULONG connection_index, ULONG *addr )
@@ -157,7 +157,7 @@ struct DeviceInstance *get_device_by_index( libusb_device *device,
return NULL;
}
-#else /* HAVE_LIBUSB_H */
+#else /* HAVE_LIBUSB_1 */
struct DeviceInstance *get_device_by_index( struct usb_device *device,
ULONG connection_index, ULONG *addr )
@@ -178,7 +178,7 @@ struct DeviceInstance *get_device_by_index( struct usb_device *device,
return NULL;
}
-#endif /* HAVE_LIBUSB_H */
+#endif /* HAVE_LIBUSB_1 */
static NTSTATUS get_root_hub_name( struct HCDInstance *instance, void *buff,
ULONG size, ULONG_PTR *outsize )
@@ -215,7 +215,7 @@ static NTSTATUS get_node_info( void *buff, ULONG size, ULONG_PTR *outsize )
return STATUS_SUCCESS;
}
-#ifdef HAVE_LIBUSB_H
+#ifdef HAVE_LIBUSB_1
static NTSTATUS get_node_conn_info( struct DeviceInstance *inst, void *buff,
ULONG size, ULONG_PTR *outsize )
@@ -266,7 +266,7 @@ static NTSTATUS get_node_conn_info( struct DeviceInstance *inst, void *buff,
return status;
}
-#else /* HAVE_LIBUSB_H */
+#else /* HAVE_LIBUSB_1 */
static NTSTATUS get_node_conn_info( struct DeviceInstance *inst, void *buff,
ULONG size, ULONG_PTR *outsize )
@@ -309,7 +309,7 @@ static NTSTATUS get_node_conn_info( struct DeviceInstance *inst, void *buff,
return status;
}
-#endif /* HAVE_LIBUSB_H */
+#endif /* HAVE_LIBUSB_1 */
static NTSTATUS get_node_conn_driverkey_name( struct DeviceInstance *inst,
void *buff, ULONG size, ULONG_PTR *outsize )
@@ -439,7 +439,7 @@ done:
return status;
}
-#ifdef HAVE_LIBUSB_H
+#ifdef HAVE_LIBUSB_1
static NTSTATUS WINAPI usbhub_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
{
@@ -814,7 +814,7 @@ done:
return status;
}
-#else /* HAVE_LIBUSB_H */
+#else /* HAVE_LIBUSB_1 */
static NTSTATUS WINAPI usbhub_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
{
@@ -1193,7 +1193,7 @@ done:
return status;
}
-#endif /* HAVE_LIBUSB_H */
+#endif /* HAVE_LIBUSB_1 */
static NTSTATUS WINAPI usbhub_dispatch_pnp( DEVICE_OBJECT *device, IRP *irp )
{
@@ -1743,7 +1743,7 @@ static void stop_device_driver( struct DeviceInstance *instance )
}
else
HeapFree( GetProcessHeap(), 0, instance->instance_id );
-#ifdef HAVE_LIBUSB_H
+#ifdef HAVE_LIBUSB_1
libusb_unref_device( instance->dev );
#endif
list_remove( &instance->entry );
@@ -1778,7 +1778,7 @@ static int add_to_remove_list( struct DeviceInstance *it, struct list *remove )
return 0;
}
-#ifdef HAVE_LIBUSB_H
+#ifdef HAVE_LIBUSB_1
static int initialize_libusb(void)
{
@@ -1867,7 +1867,7 @@ end:
}
}
-#else /* HAVE_LIBUSB_H */
+#else /* HAVE_LIBUSB_1 */
static int initialize_libusb(void)
{
@@ -1959,9 +1959,9 @@ end:
}
}
-#endif /* HAVE_LIBUSB_H */
+#endif /* HAVE_LIBUSB_1 */
-#else /* HAVE_LIBUSB */
+#else /* defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1) */
void add_usb_devices(void)
{
@@ -1971,9 +1971,9 @@ void remove_usb_devices(void)
{
}
-#endif /* HAVE_LIBUSB */
+#endif /* defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1) */
-#ifdef HAVE_LIBUSB
+#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1)
static DWORD CALLBACK initialize_usbhub( void *arg )
{
@@ -1998,11 +1998,11 @@ static DWORD CALLBACK initialize_usbhub( void *arg )
return 0;
}
-#endif /* HAVE_LIBUSB */
+#endif /* defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1) */
NTSTATUS WINAPI usbhub_driver_entry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
{
-#ifdef HAVE_LIBUSB
+#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1)
HANDLE thread;
usbhub_driver = driver;
diff --git a/include/config.h.in b/include/config.h.in
index eca7465..f060af9 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -359,8 +359,8 @@
/* Define if you have the libusb library and header */
#undef HAVE_LIBUSB
-/* Define to 1 if you have the <libusb.h> header file. */
-#undef HAVE_LIBUSB_H
+/* Define if you have the libusb-1.0 library and header */
+#undef HAVE_LIBUSB_1
/* Define if you have the libxml2 library */
#undef HAVE_LIBXML2
@@ -1043,9 +1043,6 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
-/* Define to 1 if you have the <usb.h> header file. */
-#undef HAVE_USB_H
-
/* Define to 1 if you have the `usleep' function. */
#undef HAVE_USLEEP
diff --git a/programs/services/services.c b/programs/services/services.c
index 7d88a1a..1fb6ed2 100644
--- a/programs/services/services.c
+++ b/programs/services/services.c
@@ -263,7 +263,7 @@ DWORD scmdatabase_remove_service(struct scmdatabase *db, struct service_entry *s
static void scmdatabase_autostart_services(struct scmdatabase *db)
{
-#ifdef HAVE_LIBUSB
+#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1)
static const WCHAR usbhub_started_event[] = {'_','_','w','i','n','e',
'_','U','s','b','h','u','b','S','t','a','r','t','e','d',0};
static const WCHAR mountmgr[] = {'M','o','u','n','t','M','g','r',0};
@@ -305,7 +305,7 @@ static void scmdatabase_autostart_services(struct scmdatabase *db)
size = i;
for (i = 0; i < size; i++)
{
-#ifdef HAVE_LIBUSB
+#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1)
HANDLE event = NULL;
#endif
DWORD err;
@@ -313,7 +313,7 @@ static void scmdatabase_autostart_services(struct scmdatabase *db)
service = services_list[i];
argv[0] = service->name;
argv[1] = NULL;
-#ifdef HAVE_LIBUSB
+#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1)
if (!strcmpW(service->name, mountmgr))
event = CreateEventW(NULL, TRUE, FALSE, usbhub_started_event);
#endif
@@ -321,7 +321,7 @@ static void scmdatabase_autostart_services(struct scmdatabase *db)
if (err != ERROR_SUCCESS)
WINE_FIXME("Auto-start service %s failed to start: %d\n",
wine_dbgstr_w(service->name), err);
-#ifdef HAVE_LIBUSB
+#if defined(HAVE_LIBUSB) || defined(HAVE_LIBUSB_1)
else if (event)
{
WaitForSingleObject(event, 30000);
--
1.7.9.4
Подробная информация о списке рассылки Wine-patches