[Wine-patches] [eterhack] Prevent using libusb.h if libusb-1.0 library is not found.
Alexander Morozov
amorozov на etersoft.ru
Ср Май 2 21:02:41 MSK 2012
---
configure | 22 +++++---------------
configure.ac | 6 +++---
dlls/mountmgr.sys/usbhub.c | 46 +++++++++++++++++++++---------------------
include/config.h.in | 7 ++-----
programs/services/services.c | 8 ++++----
5 files changed, 37 insertions(+), 52 deletions(-)
diff --git a/configure b/configure
index 29c54ff..255789b 100755
--- a/configure
+++ b/configure
@@ -10158,14 +10158,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
@@ -10210,7 +10205,6 @@ fi
fi
-done
ac_save_CPPFLAGS="$CPPFLAGS"
if test "$PKG_CONFIG" != "false"
@@ -10219,14 +10213,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
@@ -10264,7 +10253,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"
@@ -10272,7 +10261,6 @@ fi
fi
-done
CPPFLAGS="$ac_save_CPPFLAGS"
fi
diff --git a/configure.ac b/configure.ac
index 3311add..cf57bfd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1347,7 +1347,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"]))
@@ -1358,9 +1358,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 cc8db98..9a25e91 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
@@ -53,7 +53,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 );
@@ -92,7 +92,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;
@@ -147,7 +147,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 )
@@ -168,7 +168,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 )
@@ -189,7 +189,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 )
@@ -226,7 +226,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 )
@@ -277,7 +277,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 )
@@ -320,7 +320,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 )
@@ -486,7 +486,7 @@ done:
return status;
}
-#ifdef HAVE_LIBUSB_H
+#ifdef HAVE_LIBUSB_1
static NTSTATUS WINAPI usbhub_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
{
@@ -861,7 +861,7 @@ done:
return status;
}
-#else /* HAVE_LIBUSB_H */
+#else /* HAVE_LIBUSB_1 */
static NTSTATUS WINAPI usbhub_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
{
@@ -1240,7 +1240,7 @@ done:
return status;
}
-#endif /* HAVE_LIBUSB_H */
+#endif /* HAVE_LIBUSB_1 */
static BOOL is_root_dev( DEVICE_OBJECT *device )
{
@@ -1661,7 +1661,7 @@ static char *new_instance_id( USHORT vid, USHORT pid )
return ret;
}
-#ifdef HAVE_LIBUSB_H
+#ifdef HAVE_LIBUSB_1
static BOOL is_mass_storage( libusb_device *dev )
{
@@ -1950,7 +1950,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 );
@@ -1998,7 +1998,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)
{
@@ -2088,7 +2088,7 @@ end:
}
}
-#else /* HAVE_LIBUSB_H */
+#else /* HAVE_LIBUSB_1 */
static int initialize_libusb(void)
{
@@ -2181,9 +2181,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)
{
@@ -2193,9 +2193,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 )
{
@@ -2221,11 +2221,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 5e6ad31..96d6063 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -362,8 +362,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
@@ -1046,9 +1046,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 7e61be0..a517d1f 100644
--- a/programs/services/services.c
+++ b/programs/services/services.c
@@ -264,7 +264,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};
@@ -306,7 +306,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;
@@ -314,7 +314,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
@@ -322,7 +322,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