usb 2.12.0 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/README.md +1 -1
  3. package/dist/index.js +6 -2
  4. package/dist/index.js.map +1 -1
  5. package/dist/usb/bindings.js +1 -1
  6. package/dist/usb/bindings.js.map +1 -1
  7. package/dist/usb/capability.js.map +1 -1
  8. package/dist/usb/device.js.map +1 -1
  9. package/dist/usb/endpoint.d.ts +1 -0
  10. package/dist/usb/endpoint.js +2 -2
  11. package/dist/usb/endpoint.js.map +1 -1
  12. package/dist/usb/index.js.map +1 -1
  13. package/dist/usb/interface.js +2 -2
  14. package/dist/usb/interface.js.map +1 -1
  15. package/dist/webusb/index.d.ts +2 -2
  16. package/dist/webusb/index.js.map +1 -1
  17. package/dist/webusb/webusb-device.js +10 -10
  18. package/dist/webusb/webusb-device.js.map +1 -1
  19. package/libusb/.codespellrc +3 -0
  20. package/libusb/.private/appveyor_build.sh +5 -1
  21. package/libusb/.private/ci-build.sh +26 -1
  22. package/libusb/.private/ci-container-build.sh +2 -5
  23. package/libusb/.private/wbs.txt +5 -8
  24. package/libusb/AUTHORS +22 -0
  25. package/libusb/ChangeLog +19 -2
  26. package/libusb/HACKING +25 -0
  27. package/libusb/INSTALL_WIN.txt +11 -10
  28. package/libusb/NEWS +2 -2
  29. package/libusb/README +3 -2
  30. package/libusb/README.git +1 -1
  31. package/libusb/Xcode/common.xcconfig +8 -1
  32. package/libusb/Xcode/config.h +0 -6
  33. package/libusb/Xcode/debug.xcconfig +4 -1
  34. package/libusb/Xcode/libusb.xcconfig +1 -1
  35. package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +60 -30
  36. package/libusb/Xcode/libusb_debug.xcconfig +1 -1
  37. package/libusb/Xcode/libusb_release.xcconfig +1 -1
  38. package/libusb/Xcode/release.xcconfig +1 -1
  39. package/libusb/appveyor.yml +33 -9
  40. package/libusb/configure.ac +68 -37
  41. package/libusb/examples/dpfp.c +2 -2
  42. package/libusb/examples/fxload.c +2 -2
  43. package/libusb/examples/hotplugtest.c +28 -13
  44. package/libusb/examples/listdevs.c +1 -1
  45. package/libusb/examples/sam3u_benchmark.c +1 -1
  46. package/libusb/examples/testlibusb.c +1 -1
  47. package/libusb/examples/xusb.c +74 -19
  48. package/libusb/libusb/Makefile.am +11 -1
  49. package/libusb/libusb/core.c +364 -186
  50. package/libusb/libusb/descriptor.c +276 -16
  51. package/libusb/libusb/hotplug.c +5 -4
  52. package/libusb/libusb/io.c +72 -61
  53. package/libusb/libusb/libusb-1.0.def +14 -1
  54. package/libusb/libusb/libusb.h +245 -76
  55. package/libusb/libusb/libusbi.h +35 -13
  56. package/libusb/libusb/os/darwin_usb.c +542 -279
  57. package/libusb/libusb/os/darwin_usb.h +44 -115
  58. package/libusb/libusb/os/emscripten_webusb.cpp +870 -0
  59. package/libusb/libusb/os/events_posix.c +40 -0
  60. package/libusb/libusb/os/events_posix.h +3 -0
  61. package/libusb/libusb/os/linux_usbfs.c +27 -16
  62. package/libusb/libusb/os/netbsd_usb.c +36 -36
  63. package/libusb/libusb/os/openbsd_usb.c +34 -34
  64. package/libusb/libusb/os/sunos_usb.c +25 -15
  65. package/libusb/libusb/os/threads_posix.c +1 -5
  66. package/libusb/libusb/os/windows_common.c +13 -5
  67. package/libusb/libusb/os/windows_common.h +8 -0
  68. package/libusb/libusb/os/windows_winusb.c +366 -174
  69. package/libusb/libusb/os/windows_winusb.h +13 -9
  70. package/libusb/libusb/strerror.c +5 -5
  71. package/libusb/libusb/sync.c +24 -19
  72. package/libusb/libusb/version.h +1 -1
  73. package/libusb/libusb/version_nano.h +1 -1
  74. package/libusb/msvc/Base.props +60 -0
  75. package/libusb/msvc/Configuration.Application.props +7 -0
  76. package/libusb/msvc/Configuration.Base.props +47 -0
  77. package/libusb/msvc/Configuration.DynamicLibrary.props +21 -0
  78. package/libusb/msvc/Configuration.StaticLibrary.props +7 -0
  79. package/libusb/msvc/ProjectConfigurations.Base.props +69 -0
  80. package/libusb/msvc/build_all.ps1 +17 -0
  81. package/libusb/msvc/config.h +2 -2
  82. package/libusb/msvc/dpfp.vcxproj +33 -0
  83. package/libusb/msvc/dpfp_threaded.vcxproj +38 -0
  84. package/libusb/msvc/fxload.vcxproj +46 -0
  85. package/libusb/msvc/getopt.vcxproj +33 -0
  86. package/libusb/msvc/hotplugtest.vcxproj +32 -0
  87. package/libusb/msvc/init_context.vcxproj +35 -0
  88. package/libusb/msvc/libusb.sln +542 -0
  89. package/libusb/msvc/libusb_dll.vcxproj +61 -0
  90. package/libusb/msvc/libusb_static.vcxproj +49 -0
  91. package/libusb/msvc/listdevs.vcxproj +32 -0
  92. package/libusb/msvc/sam3u_benchmark.vcxproj +33 -0
  93. package/libusb/msvc/set_option.vcxproj +35 -0
  94. package/libusb/msvc/stress.vcxproj +35 -0
  95. package/libusb/msvc/stress_mt.vcxproj +33 -0
  96. package/libusb/msvc/testlibusb.vcxproj +32 -0
  97. package/libusb/msvc/xusb.vcxproj +38 -0
  98. package/libusb/tests/Makefile.am +25 -3
  99. package/libusb/tests/init_context.c +153 -0
  100. package/libusb/tests/macos.c +130 -0
  101. package/libusb/tests/set_option.c +253 -0
  102. package/libusb/tests/stress.c +17 -14
  103. package/libusb/tests/stress_mt.c +265 -0
  104. package/libusb/tests/testlib.c +1 -1
  105. package/libusb/tests/umockdev.c +9 -9
  106. package/libusb/tests/webusb-test-shim/index.js +12 -0
  107. package/libusb/tests/webusb-test-shim/package-lock.json +50 -0
  108. package/libusb/tests/webusb-test-shim/package.json +10 -0
  109. package/package.json +7 -7
  110. package/prebuilds/android-arm/node.napi.armv7.node +0 -0
  111. package/prebuilds/android-arm64/node.napi.armv8.node +0 -0
  112. package/prebuilds/darwin-x64+arm64/node.napi.node +0 -0
  113. package/prebuilds/linux-arm/node.napi.armv6.node +0 -0
  114. package/prebuilds/linux-arm/node.napi.armv7.node +0 -0
  115. package/prebuilds/linux-arm64/node.napi.armv8.node +0 -0
  116. package/prebuilds/linux-ia32/node.napi.node +0 -0
  117. package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
  118. package/prebuilds/linux-x64/node.napi.musl.node +0 -0
  119. package/prebuilds/win32-arm64/node.napi.node +0 -0
  120. package/prebuilds/win32-ia32/node.napi.node +0 -0
  121. package/prebuilds/win32-x64/node.napi.node +0 -0
  122. package/src/device.cc +15 -5
  123. package/libusb/msvc/dpfp_2013.vcxproj +0 -87
  124. package/libusb/msvc/dpfp_2013.vcxproj.filters +0 -26
  125. package/libusb/msvc/dpfp_2015.vcxproj +0 -87
  126. package/libusb/msvc/dpfp_2015.vcxproj.filters +0 -26
  127. package/libusb/msvc/dpfp_2017.vcxproj +0 -106
  128. package/libusb/msvc/dpfp_2017.vcxproj.filters +0 -26
  129. package/libusb/msvc/dpfp_2019.vcxproj +0 -106
  130. package/libusb/msvc/dpfp_2019.vcxproj.filters +0 -26
  131. package/libusb/msvc/dpfp_threaded_2013.vcxproj +0 -87
  132. package/libusb/msvc/dpfp_threaded_2013.vcxproj.filters +0 -26
  133. package/libusb/msvc/dpfp_threaded_2015.vcxproj +0 -87
  134. package/libusb/msvc/dpfp_threaded_2015.vcxproj.filters +0 -26
  135. package/libusb/msvc/dpfp_threaded_2017.vcxproj +0 -106
  136. package/libusb/msvc/dpfp_threaded_2017.vcxproj.filters +0 -26
  137. package/libusb/msvc/dpfp_threaded_2019.vcxproj +0 -106
  138. package/libusb/msvc/dpfp_threaded_2019.vcxproj.filters +0 -26
  139. package/libusb/msvc/fxload_2013.vcxproj +0 -94
  140. package/libusb/msvc/fxload_2013.vcxproj.filters +0 -35
  141. package/libusb/msvc/fxload_2015.vcxproj +0 -94
  142. package/libusb/msvc/fxload_2015.vcxproj.filters +0 -35
  143. package/libusb/msvc/fxload_2017.vcxproj +0 -113
  144. package/libusb/msvc/fxload_2017.vcxproj.filters +0 -35
  145. package/libusb/msvc/fxload_2019.vcxproj +0 -113
  146. package/libusb/msvc/fxload_2019.vcxproj.filters +0 -35
  147. package/libusb/msvc/getopt_2013.vcxproj +0 -72
  148. package/libusb/msvc/getopt_2013.vcxproj.filters +0 -26
  149. package/libusb/msvc/getopt_2015.vcxproj +0 -73
  150. package/libusb/msvc/getopt_2015.vcxproj.filters +0 -26
  151. package/libusb/msvc/getopt_2017.vcxproj +0 -92
  152. package/libusb/msvc/getopt_2017.vcxproj.filters +0 -26
  153. package/libusb/msvc/getopt_2019.vcxproj +0 -92
  154. package/libusb/msvc/getopt_2019.vcxproj.filters +0 -26
  155. package/libusb/msvc/hotplugtest_2013.vcxproj +0 -86
  156. package/libusb/msvc/hotplugtest_2013.vcxproj.filters +0 -23
  157. package/libusb/msvc/hotplugtest_2015.vcxproj +0 -86
  158. package/libusb/msvc/hotplugtest_2015.vcxproj.filters +0 -23
  159. package/libusb/msvc/hotplugtest_2017.vcxproj +0 -105
  160. package/libusb/msvc/hotplugtest_2017.vcxproj.filters +0 -23
  161. package/libusb/msvc/hotplugtest_2019.vcxproj +0 -105
  162. package/libusb/msvc/hotplugtest_2019.vcxproj.filters +0 -23
  163. package/libusb/msvc/libusb_2013.sln +0 -137
  164. package/libusb/msvc/libusb_2015.sln +0 -137
  165. package/libusb/msvc/libusb_2017.sln +0 -240
  166. package/libusb/msvc/libusb_2019.sln +0 -240
  167. package/libusb/msvc/libusb_dll_2013.vcxproj +0 -104
  168. package/libusb/msvc/libusb_dll_2013.vcxproj.filters +0 -94
  169. package/libusb/msvc/libusb_dll_2015.vcxproj +0 -105
  170. package/libusb/msvc/libusb_dll_2015.vcxproj.filters +0 -94
  171. package/libusb/msvc/libusb_dll_2017.vcxproj +0 -124
  172. package/libusb/msvc/libusb_dll_2017.vcxproj.filters +0 -94
  173. package/libusb/msvc/libusb_dll_2019.vcxproj +0 -124
  174. package/libusb/msvc/libusb_dll_2019.vcxproj.filters +0 -94
  175. package/libusb/msvc/libusb_static_2013.vcxproj +0 -94
  176. package/libusb/msvc/libusb_static_2013.vcxproj.filters +0 -80
  177. package/libusb/msvc/libusb_static_2015.vcxproj +0 -95
  178. package/libusb/msvc/libusb_static_2015.vcxproj.filters +0 -80
  179. package/libusb/msvc/libusb_static_2017.vcxproj +0 -114
  180. package/libusb/msvc/libusb_static_2017.vcxproj.filters +0 -80
  181. package/libusb/msvc/libusb_static_2019.vcxproj +0 -114
  182. package/libusb/msvc/libusb_static_2019.vcxproj.filters +0 -80
  183. package/libusb/msvc/listdevs_2013.vcxproj +0 -86
  184. package/libusb/msvc/listdevs_2013.vcxproj.filters +0 -23
  185. package/libusb/msvc/listdevs_2015.vcxproj +0 -86
  186. package/libusb/msvc/listdevs_2015.vcxproj.filters +0 -23
  187. package/libusb/msvc/listdevs_2017.vcxproj +0 -105
  188. package/libusb/msvc/listdevs_2017.vcxproj.filters +0 -23
  189. package/libusb/msvc/listdevs_2019.vcxproj +0 -105
  190. package/libusb/msvc/listdevs_2019.vcxproj.filters +0 -23
  191. package/libusb/msvc/sam3u_benchmark_2013.vcxproj +0 -87
  192. package/libusb/msvc/sam3u_benchmark_2013.vcxproj.filters +0 -26
  193. package/libusb/msvc/sam3u_benchmark_2015.vcxproj +0 -87
  194. package/libusb/msvc/sam3u_benchmark_2015.vcxproj.filters +0 -26
  195. package/libusb/msvc/sam3u_benchmark_2017.vcxproj +0 -106
  196. package/libusb/msvc/sam3u_benchmark_2017.vcxproj.filters +0 -26
  197. package/libusb/msvc/sam3u_benchmark_2019.vcxproj +0 -106
  198. package/libusb/msvc/sam3u_benchmark_2019.vcxproj.filters +0 -26
  199. package/libusb/msvc/stress_2013.vcxproj +0 -89
  200. package/libusb/msvc/stress_2013.vcxproj.filters +0 -32
  201. package/libusb/msvc/stress_2015.vcxproj +0 -89
  202. package/libusb/msvc/stress_2015.vcxproj.filters +0 -32
  203. package/libusb/msvc/stress_2017.vcxproj +0 -108
  204. package/libusb/msvc/stress_2017.vcxproj.filters +0 -32
  205. package/libusb/msvc/stress_2019.vcxproj +0 -108
  206. package/libusb/msvc/stress_2019.vcxproj.filters +0 -32
  207. package/libusb/msvc/testlibusb_2013.vcxproj +0 -86
  208. package/libusb/msvc/testlibusb_2013.vcxproj.filters +0 -23
  209. package/libusb/msvc/testlibusb_2015.vcxproj +0 -86
  210. package/libusb/msvc/testlibusb_2015.vcxproj.filters +0 -23
  211. package/libusb/msvc/testlibusb_2017.vcxproj +0 -105
  212. package/libusb/msvc/testlibusb_2017.vcxproj.filters +0 -23
  213. package/libusb/msvc/testlibusb_2019.vcxproj +0 -105
  214. package/libusb/msvc/testlibusb_2019.vcxproj.filters +0 -23
  215. package/libusb/msvc/xusb_2013.vcxproj +0 -86
  216. package/libusb/msvc/xusb_2013.vcxproj.filters +0 -23
  217. package/libusb/msvc/xusb_2015.vcxproj +0 -86
  218. package/libusb/msvc/xusb_2015.vcxproj.filters +0 -23
  219. package/libusb/msvc/xusb_2017.vcxproj +0 -105
  220. package/libusb/msvc/xusb_2017.vcxproj.filters +0 -23
  221. package/libusb/msvc/xusb_2019.vcxproj +0 -105
  222. package/libusb/msvc/xusb_2019.vcxproj.filters +0 -23
  223. package/prebuilds/android-arm/usb.armv7.node +0 -0
  224. package/prebuilds/android-arm64/usb.armv8.node +0 -0
  225. package/prebuilds/darwin-x64+arm64/usb.node +0 -0
  226. package/prebuilds/linux-arm/usb.armv6.node +0 -0
  227. package/prebuilds/linux-arm/usb.armv7.node +0 -0
  228. package/prebuilds/linux-arm64/usb.armv8.node +0 -0
  229. package/prebuilds/linux-ia32/usb.node +0 -0
  230. package/prebuilds/linux-x64/usb.glibc.node +0 -0
  231. package/prebuilds/linux-x64/usb.musl.node +0 -0
  232. package/prebuilds/win32-arm64/usb.node +0 -0
  233. package/prebuilds/win32-ia32/usb.node +0 -0
  234. package/prebuilds/win32-x64/usb.node +0 -0
@@ -16,7 +16,7 @@ LU_DEFINE_VERSION_ATOM([LIBUSB_MICRO])
16
16
  LU_DEFINE_VERSION_RC_ATOM([LIBUSB_RC])
17
17
 
18
18
  AC_PREREQ([2.69])
19
- AC_INIT([libusb-1.0], [LIBUSB_MAJOR[.]LIBUSB_MINOR[.]LIBUSB_MICRO[]LIBUSB_RC], [libusb-devel@lists.sourceforge.net], [libusb-1.0], [http://libusb.info])
19
+ AC_INIT([libusb-1.0], [LIBUSB_MAJOR[.]LIBUSB_MINOR[.]LIBUSB_MICRO[]LIBUSB_RC], [libusb-devel@lists.sourceforge.net], [libusb-1.0], [https://libusb.info])
20
20
  AC_CONFIG_HEADERS([config.h])
21
21
  AC_CONFIG_SRCDIR([libusb/core.c])
22
22
  AC_CONFIG_MACRO_DIR([m4])
@@ -31,9 +31,9 @@ dnl Library versioning
31
31
  dnl These numbers should be tweaked on every release. Read carefully:
32
32
  dnl http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
33
33
  dnl http://sourceware.org/autobook/autobook/autobook_91.html
34
- lt_current=3
34
+ lt_current=4
35
35
  lt_revision=0
36
- lt_age=3
36
+ lt_age=4
37
37
  LT_LDFLAGS="-version-info ${lt_current}:${lt_revision}:${lt_age} -no-undefined"
38
38
 
39
39
  m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
@@ -83,6 +83,17 @@ case $host in
83
83
  backend=haiku
84
84
  platform=posix
85
85
  ;;
86
+ wasm*-emscripten)
87
+ AC_MSG_RESULT([Emscripten])
88
+ backend=emscripten
89
+ platform=posix
90
+ ;;
91
+ wasm*-unknown-none)
92
+ AC_MSG_ERROR([
93
+ --host=$host_alias is not accepted as it might become ambiguous in the future.
94
+ Please use an explicit --host=$host_cpu-emscripten instead.
95
+ ])
96
+ ;;
86
97
  *-linux* | *-uclinux*)
87
98
  dnl on Android Linux, some functions are in different places
88
99
  case $host in
@@ -123,7 +134,7 @@ case $host in
123
134
  backend=windows
124
135
  platform=windows
125
136
  test "x$enable_shared" = xyes && create_import_lib=yes
126
- EXTRA_CFLAGS="-mwin32 -fno-omit-frame-pointer"
137
+ EXTRA_CFLAGS="-fno-omit-frame-pointer"
127
138
  EXTRA_LDFLAGS="-static-libgcc"
128
139
  ;;
129
140
  *)
@@ -138,7 +149,11 @@ esac
138
149
  if test "x$platform" = xposix; then
139
150
  AC_DEFINE([PLATFORM_POSIX], [1], [Define to 1 if compiling for a POSIX platform.])
140
151
  AC_CHECK_TYPES([nfds_t], [], [], [[#include <poll.h>]])
141
- AC_CHECK_FUNCS([pipe2])
152
+ if test "x$backend" != xemscripten; then
153
+ # pipe2 is detected as present on Emscripten, but it isn't actually ported and always
154
+ # returns an error. https://github.com/emscripten-core/emscripten/issues/14824
155
+ AC_CHECK_FUNCS([pipe2])
156
+ fi
142
157
  dnl Some compilers do not support the '-pthread' option so check for it here
143
158
  saved_CFLAGS="${CFLAGS}"
144
159
  CFLAGS="-Wall -Werror -pthread"
@@ -153,7 +168,21 @@ if test "x$platform" = xposix; then
153
168
  AC_SEARCH_LIBS([pthread_create], [pthread],
154
169
  [test "x$ac_cv_search_pthread_create" != "xnone required" && AC_SUBST(THREAD_LIBS, [-lpthread])],
155
170
  [], [])
156
- AC_SEARCH_LIBS([__atomic_fetch_add_4], [atomic])
171
+ dnl Check for new-style atomic builtins. We first check without linking to -latomic.
172
+ AC_MSG_CHECKING(whether __atomic_load_n is supported)
173
+ AC_LINK_IFELSE([AC_LANG_SOURCE([[
174
+ #include <stdint.h>
175
+ int main() {
176
+ struct {
177
+ uint64_t *v;
178
+ } x;
179
+ return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) &
180
+ (int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL);
181
+ }]])], GCC_ATOMIC_BUILTINS_SUPPORTED=yes, GCC_ATOMIC_BUILTINS_SUPPORTED=no)
182
+ AC_MSG_RESULT($GCC_ATOMIC_BUILTINS_SUPPORTED)
183
+ if test "x$GCC_ATOMIC_BUILTINS_SUPPORTED" != xyes; then
184
+ AC_SEARCH_LIBS([__atomic_fetch_add_4], [atomic])
185
+ fi
157
186
  elif test "x$platform" = xwindows; then
158
187
  AC_DEFINE([PLATFORM_WINDOWS], [1], [Define to 1 if compiling for a Windows platform.])
159
188
  else
@@ -181,12 +210,14 @@ linux)
181
210
  AC_CHECK_LIB([udev], [udev_new], [], [AC_MSG_ERROR([udev support requested but libudev not installed])])
182
211
 
183
212
  # We can build umockdev tests (if available)
184
- PKG_PROG_PKG_CONFIG
185
- PKG_CHECK_MODULES(UMOCKDEV, umockdev-1.0 >= 0.16.0, ac_have_umockdev=yes, ac_have_umockdev=no)
186
- PKG_CHECK_MODULES(UMOCKDEV_HOTPLUG, umockdev-1.0 >= 0.17.7, ac_umockdev_hotplug=yes, ac_umockdev_hotplug=no)
187
- if test "x$ac_umockdev_hotplug" = xyes; then
188
- AC_DEFINE([UMOCKDEV_HOTPLUG], [1], [UMockdev hotplug code is not racy])
189
- fi
213
+ m4_ifdef([PKG_PROG_PKG_CONFIG],[
214
+ PKG_PROG_PKG_CONFIG
215
+ PKG_CHECK_MODULES([UMOCKDEV], [umockdev-1.0 >= 0.16.0], [ac_have_umockdev=yes], [ac_have_umockdev=no])
216
+ PKG_CHECK_MODULES([UMOCKDEV_HOTPLUG], [umockdev-1.0 >= 0.17.7], [ac_umockdev_hotplug=yes], [ac_umockdev_hotplug=no])
217
+ if test $ac_umockdev_hotplug = yes; then
218
+ AC_DEFINE([UMOCKDEV_HOTPLUG], [1], [UMockdev hotplug code is not racy])
219
+ fi
220
+ ], [])
190
221
  else
191
222
  AC_CHECK_HEADERS([asm/types.h])
192
223
  AC_CHECK_HEADER([linux/netlink.h], [], [AC_MSG_ERROR([Linux netlink header not found])])
@@ -199,7 +230,13 @@ sunos)
199
230
  windows)
200
231
  AC_CHECK_TYPES([struct timespec], [], [], [[#include <time.h>]])
201
232
  AC_DEFINE([_WIN32_WINNT], [_WIN32_WINNT_VISTA], [Define to the oldest supported Windows version.])
202
- LT_LDFLAGS="${LT_LDFLAGS} -avoid-version -Wl,--add-stdcall-alias"
233
+ LT_LDFLAGS="${LT_LDFLAGS} -avoid-version"
234
+ ;;
235
+ emscripten)
236
+ # Note: LT_LDFLAGS is not enough here because we need link flags for executable.
237
+ EM_LDFLAGS="--bind -s ASYNCIFY"
238
+ AM_LDFLAGS="${AM_LDFLAGS} ${EM_LDFLAGS} -s ASSERTIONS -s ALLOW_MEMORY_GROWTH"
239
+ LIBS="${LIBS} ${EM_LDFLAGS}"
203
240
  ;;
204
241
  *)
205
242
  dnl no special handling required
@@ -209,29 +246,9 @@ esac
209
246
  dnl headers not available on all platforms but required on others
210
247
  AC_CHECK_HEADERS([sys/time.h])
211
248
 
212
- if test "x$platform" = xposix; then
213
- dnl check availability of clock_gettime()
214
- if test "x$backend" = xdarwin; then
215
- dnl need to verify that OS X target is 10.12 or later for clock_gettime()
216
- AC_MSG_CHECKING([whether OS X target version is 10.12 or later])
217
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
218
- #include <AvailabilityMacros.h>
219
- #if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
220
- # error "Target OS X version is too old"
221
- #endif
222
- ], [])],
223
- [AC_MSG_RESULT([yes])
224
- osx_10_12_or_later=yes],
225
- [AC_MSG_RESULT([no])
226
- osx_10_12_or_later=])
227
- if test "x$osx_10_12_or_later" = xyes; then
228
- AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes], [have_clock_gettime=])
229
- else
230
- AC_MSG_NOTICE([clock_gettime() is not available on target OS X version])
231
- fi
232
- else
233
- AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes], [AC_MSG_ERROR([clock_gettime() is required on this platform])])
234
- fi
249
+ dnl check availability of clock_gettime(), except don't bother on Darwin, because the result is not used.
250
+ if test "x$platform" = xposix && test "x$backend" != xdarwin; then
251
+ AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes], [AC_MSG_ERROR([clock_gettime() is required on this platform])])
235
252
 
236
253
  if test "x$have_clock_gettime" = xyes; then
237
254
  dnl the clock_gettime() function needs certain clock IDs defined
@@ -366,7 +383,7 @@ AC_ARG_ENABLE([tests-build],
366
383
 
367
384
  AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != xno])
368
385
  AM_CONDITIONAL([BUILD_TESTS], [test "x$build_tests" != xno])
369
- AM_CONDITIONAL([BUILD_UMOCKDEV_TEST], [test "x$ac_have_umockdev" = xyes -a "x$log_enabled" != xno])
386
+ AM_CONDITIONAL([BUILD_UMOCKDEV_TEST], [test "x$ac_have_umockdev" = xyes -a "x$log_enabled" != xno -a "x$debug_log_enabled" != xyes])
370
387
  AM_CONDITIONAL([CREATE_IMPORT_LIB], [test "x$create_import_lib" = xyes])
371
388
  AM_CONDITIONAL([OS_DARWIN], [test "x$backend" = xdarwin])
372
389
  AM_CONDITIONAL([OS_HAIKU], [test "x$backend" = xhaiku])
@@ -376,6 +393,7 @@ AM_CONDITIONAL([OS_NULL], [test "x$backend" = xnull])
376
393
  AM_CONDITIONAL([OS_OPENBSD], [test "x$backend" = xopenbsd])
377
394
  AM_CONDITIONAL([OS_SUNOS], [test "x$backend" = xsunos])
378
395
  AM_CONDITIONAL([OS_WINDOWS], [test "x$backend" = xwindows])
396
+ AM_CONDITIONAL([OS_EMSCRIPTEN], [test "x$backend" = xemscripten])
379
397
  AM_CONDITIONAL([PLATFORM_POSIX], [test "x$platform" = xposix])
380
398
  AM_CONDITIONAL([PLATFORM_WINDOWS], [test "x$platform" = xwindows])
381
399
  AM_CONDITIONAL([USE_UDEV], [test "x$use_udev" = xyes])
@@ -391,6 +409,18 @@ if test "x$backend" = xwindows; then
391
409
  CFLAGS="${saved_CFLAGS}"
392
410
  fi
393
411
 
412
+ dnl Some linkers do not support the '--add-stdcall-alias' option so check for it here
413
+ if test "x$backend" = xwindows; then
414
+ saved_CFLAGS="${CFLAGS}"
415
+ CFLAGS="-Wl,--add-stdcall-alias"
416
+ AC_MSG_CHECKING([if linker supports --add-stdcall-alias])
417
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
418
+ [AC_MSG_RESULT([yes])
419
+ LT_LDFLAGS="${LT_LDFLAGS} -Wl,--add-stdcall-alias"],
420
+ [AC_MSG_RESULT([no])])
421
+ CFLAGS="${saved_CFLAGS}"
422
+ fi
423
+
394
424
  SHARED_CFLAGS="-Wall -Wextra -Wshadow -Wunused -Wwrite-strings -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=init-self -Werror=missing-prototypes -Werror=strict-prototypes -Werror=undef -Werror=uninitialized"
395
425
 
396
426
  AM_CPPFLAGS="${EXTRA_CPPFLAGS}"
@@ -403,6 +433,7 @@ AM_CXXFLAGS="-std=${c_dialect}++11 ${EXTRA_CFLAGS} ${SHARED_CFLAGS} -Wmissing-de
403
433
  AC_SUBST(AM_CXXFLAGS)
404
434
 
405
435
  AC_SUBST(LT_LDFLAGS)
436
+ AC_SUBST(AM_LDFLAGS)
406
437
 
407
438
  AC_SUBST([EXTRA_LDFLAGS])
408
439
 
@@ -53,7 +53,7 @@ static inline semaphore_t semaphore_create(void)
53
53
  sem_t *semaphore;
54
54
  char name[50];
55
55
 
56
- sprintf(name, "/org.libusb.example.dpfp_threaded:%d", (int)getpid());
56
+ snprintf(name, sizeof(name), "/org.libusb.example.dpfp_threaded:%d", (int)getpid());
57
57
  semaphore = sem_open(name, O_CREAT | O_EXCL, 0, 0);
58
58
  if (semaphore == SEM_FAILED)
59
59
  return NULL;
@@ -601,7 +601,7 @@ int main(void)
601
601
  {
602
602
  int r;
603
603
 
604
- r = libusb_init(NULL);
604
+ r = libusb_init_context(/*ctx=*/NULL, /*options=*/NULL, /*num_options=*/0);
605
605
  if (r < 0) {
606
606
  fprintf(stderr, "failed to initialise libusb %d - %s\n", r, libusb_strerror(r));
607
607
  exit(1);
@@ -172,9 +172,9 @@ int main(int argc, char*argv[])
172
172
  }
173
173
 
174
174
  /* open the device using libusb */
175
- status = libusb_init(NULL);
175
+ status = libusb_init_context(/*ctx=*/NULL, /*options=*/NULL, /*num_options=*/0);
176
176
  if (status < 0) {
177
- logerror("libusb_init() failed: %s\n", libusb_error_name(status));
177
+ logerror("libusb_init_context() failed: %s\n", libusb_error_name(status));
178
178
  return -1;
179
179
  }
180
180
  libusb_set_option(NULL, LIBUSB_OPTION_LOG_LEVEL, verbose);
@@ -37,12 +37,14 @@ static int LIBUSB_CALL hotplug_callback(libusb_context *ctx, libusb_device *dev,
37
37
  (void)user_data;
38
38
 
39
39
  rc = libusb_get_device_descriptor(dev, &desc);
40
- if (LIBUSB_SUCCESS != rc) {
41
- fprintf (stderr, "Error getting device descriptor\n");
40
+ if (LIBUSB_SUCCESS == rc) {
41
+ printf ("Device attached: %04x:%04x\n", desc.idVendor, desc.idProduct);
42
+ } else {
43
+ printf ("Device attached\n");
44
+ fprintf (stderr, "Error getting device descriptor: %s\n",
45
+ libusb_strerror((enum libusb_error)rc));
42
46
  }
43
47
 
44
- printf ("Device attached: %04x:%04x\n", desc.idVendor, desc.idProduct);
45
-
46
48
  if (handle) {
47
49
  libusb_close (handle);
48
50
  handle = NULL;
@@ -50,7 +52,8 @@ static int LIBUSB_CALL hotplug_callback(libusb_context *ctx, libusb_device *dev,
50
52
 
51
53
  rc = libusb_open (dev, &handle);
52
54
  if (LIBUSB_SUCCESS != rc) {
53
- fprintf (stderr, "Error opening device\n");
55
+ fprintf (stderr, "No access to device: %s\n",
56
+ libusb_strerror((enum libusb_error)rc));
54
57
  }
55
58
 
56
59
  done++;
@@ -60,12 +63,22 @@ static int LIBUSB_CALL hotplug_callback(libusb_context *ctx, libusb_device *dev,
60
63
 
61
64
  static int LIBUSB_CALL hotplug_callback_detach(libusb_context *ctx, libusb_device *dev, libusb_hotplug_event event, void *user_data)
62
65
  {
66
+ struct libusb_device_descriptor desc;
67
+ int rc;
68
+
63
69
  (void)ctx;
64
70
  (void)dev;
65
71
  (void)event;
66
72
  (void)user_data;
67
73
 
68
- printf ("Device detached\n");
74
+ rc = libusb_get_device_descriptor(dev, &desc);
75
+ if (LIBUSB_SUCCESS == rc) {
76
+ printf ("Device detached: %04x:%04x\n", desc.idVendor, desc.idProduct);
77
+ } else {
78
+ printf ("Device detached\n");
79
+ fprintf (stderr, "Error getting device descriptor: %s\n",
80
+ libusb_strerror((enum libusb_error)rc));
81
+ }
69
82
 
70
83
  if (handle) {
71
84
  libusb_close (handle);
@@ -83,14 +96,15 @@ int main(int argc, char *argv[])
83
96
  int product_id, vendor_id, class_id;
84
97
  int rc;
85
98
 
86
- vendor_id = (argc > 1) ? (int)strtol (argv[1], NULL, 0) : 0x045a;
87
- product_id = (argc > 2) ? (int)strtol (argv[2], NULL, 0) : 0x5005;
99
+ vendor_id = (argc > 1) ? (int)strtol (argv[1], NULL, 0) : LIBUSB_HOTPLUG_MATCH_ANY;
100
+ product_id = (argc > 2) ? (int)strtol (argv[2], NULL, 0) : LIBUSB_HOTPLUG_MATCH_ANY;
88
101
  class_id = (argc > 3) ? (int)strtol (argv[3], NULL, 0) : LIBUSB_HOTPLUG_MATCH_ANY;
89
102
 
90
- rc = libusb_init (NULL);
91
- if (rc < 0)
103
+ rc = libusb_init_context(/*ctx=*/NULL, /*options=*/NULL, /*num_options=*/0);
104
+ if (LIBUSB_SUCCESS != rc)
92
105
  {
93
- printf("failed to initialise libusb: %s\n", libusb_error_name(rc));
106
+ printf ("failed to initialise libusb: %s\n",
107
+ libusb_strerror((enum libusb_error)rc));
94
108
  return EXIT_FAILURE;
95
109
  }
96
110
 
@@ -118,8 +132,9 @@ int main(int argc, char *argv[])
118
132
 
119
133
  while (done < 2) {
120
134
  rc = libusb_handle_events (NULL);
121
- if (rc < 0)
122
- printf("libusb_handle_events() failed: %s\n", libusb_error_name(rc));
135
+ if (LIBUSB_SUCCESS != rc)
136
+ printf ("libusb_handle_events() failed: %s\n",
137
+ libusb_strerror((enum libusb_error)rc));
123
138
  }
124
139
 
125
140
  if (handle) {
@@ -55,7 +55,7 @@ int main(void)
55
55
  int r;
56
56
  ssize_t cnt;
57
57
 
58
- r = libusb_init(NULL);
58
+ r = libusb_init_context(/*ctx=*/NULL, /*options=*/NULL, /*num_options=*/0);
59
59
  if (r < 0)
60
60
  return r;
61
61
 
@@ -191,7 +191,7 @@ int main(void)
191
191
  (void)signal(SIGINT, sig_hdlr);
192
192
  #endif
193
193
 
194
- rc = libusb_init(NULL);
194
+ rc = libusb_init_context(/*ctx=*/NULL, /*options=*/NULL, /*num_options=*/0);
195
195
  if (rc < 0) {
196
196
  fprintf(stderr, "Error initializing libusb: %s\n", libusb_error_name(rc));
197
197
  exit(1);
@@ -287,7 +287,7 @@ int main(int argc, char *argv[])
287
287
  }
288
288
  }
289
289
 
290
- r = libusb_init(NULL);
290
+ r = libusb_init_context(/*ctx=*/NULL, /*options=*/NULL, /*num_options=*/0);
291
291
  if (r < 0)
292
292
  return r;
293
293
 
@@ -465,20 +465,23 @@ static int test_mass_storage(libusb_device_handle *handle, uint8_t endpoint_in,
465
465
  unsigned char *data;
466
466
  FILE *fd;
467
467
 
468
- printf("Reading Max LUN:\n");
468
+ printf("\nReading Max LUN:\n");
469
469
  r = libusb_control_transfer(handle, LIBUSB_ENDPOINT_IN|LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_RECIPIENT_INTERFACE,
470
470
  BOMS_GET_MAX_LUN, 0, 0, &lun, 1, 1000);
471
471
  // Some devices send a STALL instead of the actual value.
472
472
  // In such cases we should set lun to 0.
473
- if (r == 0) {
473
+ if (r == LIBUSB_ERROR_PIPE) {
474
474
  lun = 0;
475
+ printf(" Stalled, setting Max LUN to 0\n");
475
476
  } else if (r < 0) {
476
- perr(" Failed: %s", libusb_strerror((enum libusb_error)r));
477
+ perr(" Failed.\n");
478
+ return r;
479
+ } else {
480
+ printf(" Max LUN = %d\n", lun);
477
481
  }
478
- printf(" Max LUN = %d\n", lun);
479
482
 
480
483
  // Send Inquiry
481
- printf("Sending Inquiry:\n");
484
+ printf("\nSending Inquiry:\n");
482
485
  memset(buffer, 0, sizeof(buffer));
483
486
  memset(cdb, 0, sizeof(cdb));
484
487
  cdb[0] = 0x12; // Inquiry
@@ -502,7 +505,7 @@ static int test_mass_storage(libusb_device_handle *handle, uint8_t endpoint_in,
502
505
  }
503
506
 
504
507
  // Read capacity
505
- printf("Reading Capacity:\n");
508
+ printf("\nReading Capacity:\n");
506
509
  memset(buffer, 0, sizeof(buffer));
507
510
  memset(cdb, 0, sizeof(cdb));
508
511
  cdb[0] = 0x25; // Read Capacity
@@ -526,7 +529,7 @@ static int test_mass_storage(libusb_device_handle *handle, uint8_t endpoint_in,
526
529
  }
527
530
 
528
531
  // Send Read
529
- printf("Attempting to read %u bytes:\n", block_size);
532
+ printf("\nAttempting to read %u bytes:\n", block_size);
530
533
  memset(cdb, 0, sizeof(cdb));
531
534
 
532
535
  cdb[0] = 0x28; // Read(10)
@@ -789,6 +792,20 @@ static void print_device_cap(struct libusb_bos_dev_capability_descriptor *dev_ca
789
792
  }
790
793
  break;
791
794
  }
795
+ case LIBUSB_BT_PLATFORM_DESCRIPTOR: {
796
+ struct libusb_platform_descriptor *platform_descriptor = NULL;
797
+ libusb_get_platform_descriptor(NULL, dev_cap, &platform_descriptor);
798
+ if (platform_descriptor) {
799
+ printf(" Platform descriptor:\n");
800
+ printf(" bLength : %d\n", platform_descriptor->bLength);
801
+ printf(" PlatformCapabilityUUID : %s\n", uuid_to_string(platform_descriptor->PlatformCapabilityUUID));
802
+ display_buffer_hex(&platform_descriptor->CapabilityData[0], platform_descriptor->bLength - 20);
803
+ printf("\n");
804
+ libusb_free_platform_descriptor(platform_descriptor);
805
+ }
806
+ break;
807
+
808
+ }
792
809
  default:
793
810
  printf(" Unknown BOS device capability %02x:\n", dev_cap->bDevCapabilityType);
794
811
  }
@@ -916,12 +933,25 @@ static int test_device(uint16_t vid, uint16_t pid)
916
933
  libusb_set_auto_detach_kernel_driver(handle, 1);
917
934
  for (iface = 0; iface < nb_ifaces; iface++)
918
935
  {
919
- int ret = libusb_kernel_driver_active(handle, iface);
920
- printf("\nKernel driver attached for interface %d: %d\n", iface, ret);
936
+ int ret;
937
+
938
+ printf("\nKernel driver attached for interface %d: ", iface);
939
+ ret = libusb_kernel_driver_active(handle, iface);
940
+ if (ret == 0)
941
+ printf("none\n");
942
+ else if (ret == 1)
943
+ printf("yes\n");
944
+ else if (ret == LIBUSB_ERROR_NOT_SUPPORTED)
945
+ printf("(not supported)\n");
946
+ else
947
+ perr("\n Failed (error %d) %s\n", ret,
948
+ libusb_strerror((enum libusb_error) ret));
949
+
921
950
  printf("\nClaiming interface %d...\n", iface);
922
951
  r = libusb_claim_interface(handle, iface);
923
952
  if (r != LIBUSB_SUCCESS) {
924
- perr(" Failed.\n");
953
+ perr(" Failed (error %d) %s\n", ret,
954
+ libusb_strerror((enum libusb_error) ret));
925
955
  }
926
956
  }
927
957
 
@@ -946,6 +976,32 @@ static int test_device(uint16_t vid, uint16_t pid)
946
976
  printf(" no descriptor\n");
947
977
  }
948
978
 
979
+ // Read IADs
980
+ printf("\nReading interface association descriptors (IADs) for first configuration:\n");
981
+ struct libusb_interface_association_descriptor_array *iad_array;
982
+ r = libusb_get_interface_association_descriptors(dev, 0, &iad_array);
983
+ if (r == LIBUSB_SUCCESS) {
984
+ printf(" nb IADs: %d\n", iad_array->length);
985
+ for (i=0; i<iad_array->length;i++) {
986
+ const struct libusb_interface_association_descriptor *iad = &iad_array->iad[i];
987
+ printf(" IAD %d:\n", i);
988
+ printf(" bFirstInterface: %u\n", iad->bFirstInterface);
989
+ printf(" bInterfaceCount: %u\n", iad->bInterfaceCount);
990
+ printf(" bFunctionClass: %02X\n", iad->bFunctionClass);
991
+ printf(" bFunctionSubClass: %02X\n", iad->bFunctionSubClass);
992
+ printf(" bFunctionProtocol: %02X\n", iad->bFunctionProtocol);
993
+ if (iad->iFunction) {
994
+ if (libusb_get_string_descriptor_ascii(handle, iad->iFunction, (unsigned char*)string, sizeof(string)) > 0)
995
+ printf(" iFunction: %u (%s)\n", iad->iFunction, string);
996
+ else
997
+ printf(" iFunction: %u (libusb_get_string_descriptor_ascii failed!)\n", iad->iFunction);
998
+ }
999
+ else
1000
+ printf(" iFunction: 0\n");
1001
+ }
1002
+ libusb_free_interface_association_descriptors(iad_array);
1003
+ }
1004
+
949
1005
  switch(test_mode) {
950
1006
  case USE_PS3:
951
1007
  CALL_CHECK_CLOSE(display_ps3_status(handle), handle);
@@ -979,7 +1035,6 @@ static int test_device(uint16_t vid, uint16_t pid)
979
1035
 
980
1036
  int main(int argc, char** argv)
981
1037
  {
982
- static char debug_env_str[] = "LIBUSB_DEBUG=4"; // LIBUSB_LOG_LEVEL_DEBUG
983
1038
  bool show_help = false;
984
1039
  bool debug_mode = false;
985
1040
  const struct libusb_version* version;
@@ -1103,17 +1158,17 @@ int main(int argc, char** argv)
1103
1158
  return 0;
1104
1159
  }
1105
1160
 
1106
- // xusb is commonly used as a debug tool, so it's convenient to have debug output during libusb_init(),
1107
- // but since we can't call on libusb_set_option() before libusb_init(), we use the env variable method
1108
- old_dbg_str = getenv("LIBUSB_DEBUG");
1161
+ version = libusb_get_version();
1162
+ printf("Using libusb v%d.%d.%d.%d\n\n", version->major, version->minor, version->micro, version->nano);
1163
+
1164
+ // xusb is commonly used as a debug tool, so it's convenient to have debug output during libusb_init_context().
1109
1165
  if (debug_mode) {
1110
- if (putenv(debug_env_str) != 0)
1111
- printf("Unable to set debug level\n");
1166
+ const struct libusb_init_option options = {.option = LIBUSB_OPTION_LOG_LEVEL, .value = {.ival = LIBUSB_LOG_LEVEL_DEBUG}};
1167
+ r = libusb_init_context(/*ctx=*/NULL, /*options=*/&options, /*num_options=*/1);
1168
+ } else {
1169
+ r = libusb_init_context(/*ctx=*/NULL, /*options=*/NULL, /*num_options=*/0);
1112
1170
  }
1113
1171
 
1114
- version = libusb_get_version();
1115
- printf("Using libusb v%d.%d.%d.%d\n\n", version->major, version->minor, version->micro, version->nano);
1116
- r = libusb_init(NULL);
1117
1172
  if (r < 0)
1118
1173
  return r;
1119
1174
 
@@ -20,6 +20,7 @@ OS_DARWIN_SRC = os/darwin_usb.h os/darwin_usb.c
20
20
  OS_HAIKU_SRC = os/haiku_usb.h os/haiku_usb_backend.cpp \
21
21
  os/haiku_pollfs.cpp os/haiku_usb_raw.h os/haiku_usb_raw.cpp
22
22
  OS_LINUX_SRC = os/linux_usbfs.h os/linux_usbfs.c
23
+ OS_EMSCRIPTEN_SRC = os/emscripten_webusb.cpp
23
24
  OS_NETBSD_SRC = os/netbsd_usb.c
24
25
  OS_NULL_SRC = os/null_usb.c
25
26
  OS_OPENBSD_SRC = os/openbsd_usb.c
@@ -33,8 +34,10 @@ if OS_DARWIN
33
34
  OS_SRC = $(OS_DARWIN_SRC)
34
35
  endif
35
36
 
37
+ noinst_LTLIBRARIES =
38
+
36
39
  if OS_HAIKU
37
- noinst_LTLIBRARIES = libusb_haiku.la
40
+ noinst_LTLIBRARIES += libusb_haiku.la
38
41
  libusb_haiku_la_SOURCES = $(OS_HAIKU_SRC)
39
42
  libusb_1_0_la_LIBADD = libusb_haiku.la
40
43
  endif
@@ -48,6 +51,13 @@ OS_SRC += os/linux_netlink.c
48
51
  endif
49
52
  endif
50
53
 
54
+ if OS_EMSCRIPTEN
55
+ noinst_LTLIBRARIES += libusb_emscripten.la
56
+ libusb_emscripten_la_SOURCES = $(OS_EMSCRIPTEN_SRC)
57
+ AM_CXXFLAGS += -std=c++20
58
+ libusb_1_0_la_LIBADD = libusb_emscripten.la
59
+ endif
60
+
51
61
  if OS_NETBSD
52
62
  OS_SRC = $(OS_NETBSD_SRC)
53
63
  endif