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
@@ -3,9 +3,9 @@
3
3
  * Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
4
4
  * Copyright © 2007-2008 Daniel Drake <dsd@gentoo.org>
5
5
  * Copyright © 2012 Pete Batard <pete@akeo.ie>
6
- * Copyright © 2012-2018 Nathan Hjelm <hjelmn@cs.unm.edu>
6
+ * Copyright © 2012-2023 Nathan Hjelm <hjelmn@cs.unm.edu>
7
7
  * Copyright © 2014-2020 Chris Dickens <christopher.a.dickens@gmail.com>
8
- * For more information, please visit: http://libusb.info
8
+ * For more information, please visit: https://libusb.info
9
9
  *
10
10
  * This library is free software; you can redistribute it and/or
11
11
  * modify it under the terms of the GNU Lesser General Public
@@ -50,9 +50,9 @@ typedef SSIZE_T ssize_t;
50
50
  #include <time.h>
51
51
 
52
52
  #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
53
- #define ZERO_SIZED_ARRAY /* [] - valid C99 code */
53
+ #define LIBUSB_FLEXIBLE_ARRAY /* [] - valid C99 code */
54
54
  #else
55
- #define ZERO_SIZED_ARRAY 0 /* [0] - non-standard, but usually working code */
55
+ #define LIBUSB_FLEXIBLE_ARRAY 0 /* [0] - non-standard, but usually working code */
56
56
  #endif /* __STDC_VERSION__ */
57
57
 
58
58
  /* 'interface' might be defined as a macro on Windows, so we need to
@@ -74,6 +74,8 @@ typedef SSIZE_T ssize_t;
74
74
  #define LIBUSB_DEPRECATED_FOR(f) __attribute__ ((deprecated ("Use " #f " instead")))
75
75
  #elif defined(__GNUC__) && (__GNUC__ >= 3)
76
76
  #define LIBUSB_DEPRECATED_FOR(f) __attribute__ ((deprecated))
77
+ #elif defined(_MSC_VER)
78
+ #define LIBUSB_DEPRECATED_FOR(f) __declspec(deprecated("Use " #f " instead"))
77
79
  #else
78
80
  #define LIBUSB_DEPRECATED_FOR(f)
79
81
  #endif /* __GNUC__ */
@@ -118,20 +120,25 @@ typedef SSIZE_T ssize_t;
118
120
  */
119
121
  #if defined(_WIN32) || defined(__CYGWIN__)
120
122
  #define LIBUSB_CALL WINAPI
123
+ #define LIBUSB_CALLV WINAPIV
121
124
  #else
122
125
  #define LIBUSB_CALL
126
+ #define LIBUSB_CALLV
123
127
  #endif /* _WIN32 || __CYGWIN__ */
124
128
 
125
129
  /** \def LIBUSB_API_VERSION
126
130
  * \ingroup libusb_misc
127
131
  * libusb's API version.
128
132
  *
129
- * Since version 1.0.13, to help with feature detection, libusb defines
133
+ * Since version 1.0.18, to help with feature detection, libusb defines
130
134
  * a LIBUSB_API_VERSION macro that gets increased every time there is a
131
135
  * significant change to the API, such as the introduction of a new call,
132
136
  * the definition of a new macro/enum member, or any other element that
133
137
  * libusb applications may want to detect at compilation time.
134
138
  *
139
+ * Between versions 1.0.13 and 1.0.17 (inclusive) the older spelling of
140
+ * LIBUSBX_API_VERSION was used.
141
+ *
135
142
  * The macro is typically used in an application as follows:
136
143
  * \code
137
144
  * #if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01001234)
@@ -141,10 +148,34 @@ typedef SSIZE_T ssize_t;
141
148
  *
142
149
  * Internally, LIBUSB_API_VERSION is defined as follows:
143
150
  * (libusb major << 24) | (libusb minor << 16) | (16 bit incremental)
151
+ *
152
+ * The incremental component has changed as follows:
153
+ * <ul>
154
+ * <li>libusbx version 1.0.13: LIBUSBX_API_VERSION = 0x01000100
155
+ * <li>libusbx version 1.0.14: LIBUSBX_API_VERSION = 0x010000FF
156
+ * <li>libusbx version 1.0.15: LIBUSBX_API_VERSION = 0x01000101
157
+ * <li>libusbx version 1.0.16: LIBUSBX_API_VERSION = 0x01000102
158
+ * <li>libusbx version 1.0.17: LIBUSBX_API_VERSION = 0x01000102
159
+ * <li>libusb version 1.0.18: LIBUSB_API_VERSION = 0x01000102
160
+ * <li>libusb version 1.0.19: LIBUSB_API_VERSION = 0x01000103
161
+ * <li>libusb version 1.0.20: LIBUSB_API_VERSION = 0x01000104
162
+ * <li>libusb version 1.0.21: LIBUSB_API_VERSION = 0x01000105
163
+ * <li>libusb version 1.0.22: LIBUSB_API_VERSION = 0x01000106
164
+ * <li>libusb version 1.0.23: LIBUSB_API_VERSION = 0x01000107
165
+ * <li>libusb version 1.0.24: LIBUSB_API_VERSION = 0x01000108
166
+ * <li>libusb version 1.0.25: LIBUSB_API_VERSION = 0x01000109
167
+ * <li>libusb version 1.0.26: LIBUSB_API_VERSION = 0x01000109
168
+ * <li>libusb version 1.0.27: LIBUSB_API_VERSION = 0x0100010A
169
+ * </ul>
144
170
  */
145
- #define LIBUSB_API_VERSION 0x01000109
171
+ #define LIBUSB_API_VERSION 0x0100010A
146
172
 
147
- /* The following is kept for compatibility, but will be deprecated in the future */
173
+ /** \def LIBUSBX_API_VERSION
174
+ * \ingroup libusb_misc
175
+ *
176
+ * This is the older spelling, kept for backwards compatibility of code
177
+ * needing to test for older library versions where the newer spelling
178
+ * did not exist. */
148
179
  #define LIBUSBX_API_VERSION LIBUSB_API_VERSION
149
180
 
150
181
  #if defined(__cplusplus)
@@ -265,6 +296,10 @@ enum libusb_descriptor_type {
265
296
  /** Endpoint descriptor. See libusb_endpoint_descriptor. */
266
297
  LIBUSB_DT_ENDPOINT = 0x05,
267
298
 
299
+ /** Interface Association Descriptor.
300
+ * See libusb_interface_association_descriptor */
301
+ LIBUSB_DT_INTERFACE_ASSOCIATION = 0x0b,
302
+
268
303
  /** BOS descriptor */
269
304
  LIBUSB_DT_BOS = 0x0f,
270
305
 
@@ -305,6 +340,7 @@ enum libusb_descriptor_type {
305
340
  #define LIBUSB_BT_USB_2_0_EXTENSION_SIZE 7
306
341
  #define LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE 10
307
342
  #define LIBUSB_BT_CONTAINER_ID_SIZE 20
343
+ #define LIBUSB_BT_PLATFORM_DESCRIPTOR_MIN_SIZE 20
308
344
 
309
345
  /* We unwrap the BOS => define its max size */
310
346
  #define LIBUSB_DT_BOS_MAX_SIZE \
@@ -523,7 +559,10 @@ enum libusb_bos_type {
523
559
  LIBUSB_BT_SS_USB_DEVICE_CAPABILITY = 0x03,
524
560
 
525
561
  /** Container ID type */
526
- LIBUSB_BT_CONTAINER_ID = 0x04
562
+ LIBUSB_BT_CONTAINER_ID = 0x04,
563
+
564
+ /** Platform descriptor */
565
+ LIBUSB_BT_PLATFORM_DESCRIPTOR = 0x05
527
566
  };
528
567
 
529
568
  /** \ingroup libusb_desc
@@ -628,6 +667,65 @@ struct libusb_endpoint_descriptor {
628
667
  int extra_length;
629
668
  };
630
669
 
670
+ /** \ingroup libusb_desc
671
+ * A structure representing the standard USB interface association descriptor.
672
+ * This descriptor is documented in section 9.6.4 of the USB 3.0 specification.
673
+ * All multiple-byte fields are represented in host-endian format.
674
+ */
675
+ struct libusb_interface_association_descriptor {
676
+ /** Size of this descriptor (in bytes) */
677
+ uint8_t bLength;
678
+
679
+ /** Descriptor type. Will have value
680
+ * \ref libusb_descriptor_type::LIBUSB_DT_INTERFACE_ASSOCIATION
681
+ * LIBUSB_DT_INTERFACE_ASSOCIATION in this context. */
682
+ uint8_t bDescriptorType;
683
+
684
+ /** Interface number of the first interface that is associated
685
+ * with this function */
686
+ uint8_t bFirstInterface;
687
+
688
+ /** Number of contiguous interfaces that are associated with
689
+ * this function */
690
+ uint8_t bInterfaceCount;
691
+
692
+ /** USB-IF class code for this function.
693
+ * A value of zero is not allowed in this descriptor.
694
+ * If this field is 0xff, the function class is vendor-specific.
695
+ * All other values are reserved for assignment by the USB-IF.
696
+ */
697
+ uint8_t bFunctionClass;
698
+
699
+ /** USB-IF subclass code for this function.
700
+ * If this field is not set to 0xff, all values are reserved
701
+ * for assignment by the USB-IF
702
+ */
703
+ uint8_t bFunctionSubClass;
704
+
705
+ /** USB-IF protocol code for this function.
706
+ * These codes are qualified by the values of the bFunctionClass
707
+ * and bFunctionSubClass fields.
708
+ */
709
+ uint8_t bFunctionProtocol;
710
+
711
+ /** Index of string descriptor describing this function */
712
+ uint8_t iFunction;
713
+ };
714
+
715
+ /** \ingroup libusb_desc
716
+ * Structure containing an array of 0 or more interface association
717
+ * descriptors
718
+ */
719
+ struct libusb_interface_association_descriptor_array {
720
+ /** Array of interface association descriptors. The size of this array
721
+ * is determined by the length field.
722
+ */
723
+ const struct libusb_interface_association_descriptor *iad;
724
+
725
+ /** Number of interface association descriptors contained. Read-only. */
726
+ int length;
727
+ };
728
+
631
729
  /** \ingroup libusb_desc
632
730
  * A structure representing the standard USB interface descriptor. This
633
731
  * descriptor is documented in section 9.6.5 of the USB 3.0 specification.
@@ -786,7 +884,7 @@ struct libusb_bos_dev_capability_descriptor {
786
884
  uint8_t bDevCapabilityType;
787
885
 
788
886
  /** Device Capability data (bLength - 3 bytes) */
789
- uint8_t dev_capability_data[ZERO_SIZED_ARRAY];
887
+ uint8_t dev_capability_data[LIBUSB_FLEXIBLE_ARRAY];
790
888
  };
791
889
 
792
890
  /** \ingroup libusb_desc
@@ -811,7 +909,7 @@ struct libusb_bos_descriptor {
811
909
  uint8_t bNumDeviceCaps;
812
910
 
813
911
  /** bNumDeviceCap Device Capability Descriptors */
814
- struct libusb_bos_dev_capability_descriptor *dev_capability[ZERO_SIZED_ARRAY];
912
+ struct libusb_bos_dev_capability_descriptor *dev_capability[LIBUSB_FLEXIBLE_ARRAY];
815
913
  };
816
914
 
817
915
  /** \ingroup libusb_desc
@@ -908,6 +1006,34 @@ struct libusb_container_id_descriptor {
908
1006
  uint8_t ContainerID[16];
909
1007
  };
910
1008
 
1009
+ /** \ingroup libusb_desc
1010
+ * A structure representing a Platform descriptor.
1011
+ * This descriptor is documented in section 9.6.2.4 of the USB 3.2 specification.
1012
+ */
1013
+ struct libusb_platform_descriptor {
1014
+ /** Size of this descriptor (in bytes) */
1015
+ uint8_t bLength;
1016
+
1017
+ /** Descriptor type. Will have value
1018
+ * \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY
1019
+ * LIBUSB_DT_DEVICE_CAPABILITY in this context. */
1020
+ uint8_t bDescriptorType;
1021
+
1022
+ /** Capability type. Will have value
1023
+ * \ref libusb_capability_type::LIBUSB_BT_PLATFORM_DESCRIPTOR
1024
+ * LIBUSB_BT_CONTAINER_ID in this context. */
1025
+ uint8_t bDevCapabilityType;
1026
+
1027
+ /** Reserved field */
1028
+ uint8_t bReserved;
1029
+
1030
+ /** 128 bit UUID */
1031
+ uint8_t PlatformCapabilityUUID[16];
1032
+
1033
+ /** Capability data (bLength - 20) */
1034
+ uint8_t CapabilityData[LIBUSB_FLEXIBLE_ARRAY];
1035
+ };
1036
+
911
1037
  /** \ingroup libusb_asyncio
912
1038
  * Setup packet for control transfers. */
913
1039
  #if defined(_MSC_VER) || defined(__WATCOMC__)
@@ -982,7 +1108,7 @@ struct libusb_version {
982
1108
  * libusb_exit() will not destroy resources that the other user is still
983
1109
  * using.
984
1110
  *
985
- * Sessions are created by libusb_init() and destroyed through libusb_exit().
1111
+ * Sessions are created by libusb_init_context() and destroyed through libusb_exit().
986
1112
  * If your application is guaranteed to only ever include a single libusb
987
1113
  * user (i.e. you), you do not have to worry about contexts: pass NULL in
988
1114
  * every function call where a context is required, and the default context
@@ -1187,7 +1313,8 @@ enum libusb_transfer_flags {
1187
1313
  *
1188
1314
  * This flag is currently only supported on Linux.
1189
1315
  * On other systems, libusb_submit_transfer() will return
1190
- * LIBUSB_ERROR_NOT_SUPPORTED for every transfer where this flag is set.
1316
+ * \ref LIBUSB_ERROR_NOT_SUPPORTED for every transfer where this
1317
+ * flag is set.
1191
1318
  *
1192
1319
  * Available since libusb-1.0.9.
1193
1320
  */
@@ -1284,7 +1411,7 @@ struct libusb_transfer {
1284
1411
  int num_iso_packets;
1285
1412
 
1286
1413
  /** Isochronous packet descriptors, for isochronous transfers only. */
1287
- struct libusb_iso_packet_descriptor iso_packet_desc[ZERO_SIZED_ARRAY];
1414
+ struct libusb_iso_packet_descriptor iso_packet_desc[LIBUSB_FLEXIBLE_ARRAY];
1288
1415
  };
1289
1416
 
1290
1417
  /** \ingroup libusb_misc
@@ -1345,6 +1472,79 @@ enum libusb_log_cb_mode {
1345
1472
  LIBUSB_LOG_CB_CONTEXT = (1 << 1)
1346
1473
  };
1347
1474
 
1475
+ /** \ingroup libusb_lib
1476
+ * Available option values for libusb_set_option() and libusb_init_context().
1477
+ */
1478
+ enum libusb_option {
1479
+ /** Set the log message verbosity.
1480
+ *
1481
+ * This option must be provided an argument of type \ref libusb_log_level.
1482
+ * The default level is LIBUSB_LOG_LEVEL_NONE, which means no messages are ever
1483
+ * printed. If you choose to increase the message verbosity level, ensure
1484
+ * that your application does not close the stderr file descriptor.
1485
+ *
1486
+ * You are advised to use level LIBUSB_LOG_LEVEL_WARNING. libusb is conservative
1487
+ * with its message logging and most of the time, will only log messages that
1488
+ * explain error conditions and other oddities. This will help you debug
1489
+ * your software.
1490
+ *
1491
+ * If the LIBUSB_DEBUG environment variable was set when libusb was
1492
+ * initialized, this option does nothing: the message verbosity is fixed
1493
+ * to the value in the environment variable.
1494
+ *
1495
+ * If libusb was compiled without any message logging, this option does
1496
+ * nothing: you'll never get any messages.
1497
+ *
1498
+ * If libusb was compiled with verbose debug message logging, this option
1499
+ * does nothing: you'll always get messages from all levels.
1500
+ */
1501
+ LIBUSB_OPTION_LOG_LEVEL = 0,
1502
+
1503
+ /** Use the UsbDk backend for a specific context, if available.
1504
+ *
1505
+ * This option should be set at initialization with libusb_init_context()
1506
+ * otherwise unspecified behavior may occur.
1507
+ *
1508
+ * Only valid on Windows. Ignored on all other platforms.
1509
+ */
1510
+ LIBUSB_OPTION_USE_USBDK = 1,
1511
+
1512
+ /** Do not scan for devices
1513
+ *
1514
+ * With this option set, libusb will skip scanning devices in
1515
+ * libusb_init_context().
1516
+ *
1517
+ * Hotplug functionality will also be deactivated.
1518
+ *
1519
+ * The option is useful in combination with libusb_wrap_sys_device(),
1520
+ * which can access a device directly without prior device scanning.
1521
+ *
1522
+ * This is typically needed on Android, where access to USB devices
1523
+ * is limited.
1524
+ *
1525
+ * This option should only be used with libusb_init_context()
1526
+ * otherwise unspecified behavior may occur.
1527
+ *
1528
+ * Only valid on Linux. Ignored on all other platforms.
1529
+ */
1530
+ LIBUSB_OPTION_NO_DEVICE_DISCOVERY = 2,
1531
+
1532
+ #define LIBUSB_OPTION_WEAK_AUTHORITY LIBUSB_OPTION_NO_DEVICE_DISCOVERY
1533
+
1534
+ /** Set the context log callback function.
1535
+ *
1536
+ * Set the log callback function either on a context or globally. This
1537
+ * option must be provided an argument of type \ref libusb_log_cb.
1538
+ * Using this option with a NULL context is equivalent to calling
1539
+ * libusb_set_log_cb() with mode \ref LIBUSB_LOG_CB_GLOBAL.
1540
+ * Using it with a non-NULL context is equivalent to calling
1541
+ * libusb_set_log_cb() with mode \ref LIBUSB_LOG_CB_CONTEXT.
1542
+ */
1543
+ LIBUSB_OPTION_LOG_CB = 3,
1544
+
1545
+ LIBUSB_OPTION_MAX = 4
1546
+ };
1547
+
1348
1548
  /** \ingroup libusb_lib
1349
1549
  * Callback function for handling log messages.
1350
1550
  * \param ctx the context which is related to the log message, or NULL if it
@@ -1359,10 +1559,25 @@ enum libusb_log_cb_mode {
1359
1559
  typedef void (LIBUSB_CALL *libusb_log_cb)(libusb_context *ctx,
1360
1560
  enum libusb_log_level level, const char *str);
1361
1561
 
1562
+ /** \ingroup libusb_lib
1563
+ * Structure used for setting options through \ref libusb_init_context.
1564
+ *
1565
+ */
1566
+ struct libusb_init_option {
1567
+ /** Which option to set */
1568
+ enum libusb_option option;
1569
+ /** An integer value used by the option (if applicable). */
1570
+ union {
1571
+ int ival;
1572
+ libusb_log_cb log_cbval;
1573
+ } value;
1574
+ };
1575
+
1362
1576
  int LIBUSB_CALL libusb_init(libusb_context **ctx);
1577
+ int LIBUSB_CALL libusb_init_context(libusb_context **ctx, const struct libusb_init_option options[], int num_options);
1363
1578
  void LIBUSB_CALL libusb_exit(libusb_context *ctx);
1364
- LIBUSB_DEPRECATED_FOR(libusb_set_option)
1365
1579
  void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
1580
+ /* may be deprecated in the future in favor of lubusb_init_context()+libusb_set_option() */
1366
1581
  void LIBUSB_CALL libusb_set_log_cb(libusb_context *ctx, libusb_log_cb cb, int mode);
1367
1582
  const struct libusb_version * LIBUSB_CALL libusb_get_version(void);
1368
1583
  int LIBUSB_CALL libusb_has_capability(uint32_t capability);
@@ -1415,6 +1630,11 @@ int LIBUSB_CALL libusb_get_container_id_descriptor(libusb_context *ctx,
1415
1630
  struct libusb_container_id_descriptor **container_id);
1416
1631
  void LIBUSB_CALL libusb_free_container_id_descriptor(
1417
1632
  struct libusb_container_id_descriptor *container_id);
1633
+ int LIBUSB_CALL libusb_get_platform_descriptor(libusb_context *ctx,
1634
+ struct libusb_bos_dev_capability_descriptor *dev_cap,
1635
+ struct libusb_platform_descriptor **platform_descriptor);
1636
+ void LIBUSB_CALL libusb_free_platform_descriptor(
1637
+ struct libusb_platform_descriptor *platform_descriptor);
1418
1638
  uint8_t LIBUSB_CALL libusb_get_bus_number(libusb_device *dev);
1419
1639
  uint8_t LIBUSB_CALL libusb_get_port_number(libusb_device *dev);
1420
1640
  int LIBUSB_CALL libusb_get_port_numbers(libusb_device *dev, uint8_t *port_numbers, int port_numbers_len);
@@ -1427,6 +1647,15 @@ int LIBUSB_CALL libusb_get_max_packet_size(libusb_device *dev,
1427
1647
  unsigned char endpoint);
1428
1648
  int LIBUSB_CALL libusb_get_max_iso_packet_size(libusb_device *dev,
1429
1649
  unsigned char endpoint);
1650
+ int LIBUSB_CALL libusb_get_max_alt_packet_size(libusb_device *dev,
1651
+ int interface_number, int alternate_setting, unsigned char endpoint);
1652
+
1653
+ int LIBUSB_CALL libusb_get_interface_association_descriptors(libusb_device *dev,
1654
+ uint8_t config_index, struct libusb_interface_association_descriptor_array **iad_array);
1655
+ int LIBUSB_CALL libusb_get_active_interface_association_descriptors(libusb_device *dev,
1656
+ struct libusb_interface_association_descriptor_array **iad_array);
1657
+ void LIBUSB_CALL libusb_free_interface_association_descriptors(
1658
+ struct libusb_interface_association_descriptor_array *iad_array);
1430
1659
 
1431
1660
  int LIBUSB_CALL libusb_wrap_sys_device(libusb_context *ctx, intptr_t sys_dev, libusb_device_handle **dev_handle);
1432
1661
  int LIBUSB_CALL libusb_open(libusb_device *dev, libusb_device_handle **dev_handle);
@@ -2036,7 +2265,7 @@ typedef int (LIBUSB_CALL *libusb_hotplug_callback_fn)(libusb_context *ctx,
2036
2265
  * \param[in] cb_fn the function to be invoked on a matching event/device
2037
2266
  * \param[in] user_data user data to pass to the callback function
2038
2267
  * \param[out] callback_handle pointer to store the handle of the allocated callback (can be NULL)
2039
- * \returns LIBUSB_SUCCESS on success LIBUSB_ERROR code on failure
2268
+ * \returns \ref LIBUSB_SUCCESS on success LIBUSB_ERROR code on failure
2040
2269
  */
2041
2270
  int LIBUSB_CALL libusb_hotplug_register_callback(libusb_context *ctx,
2042
2271
  int events, int flags,
@@ -2069,67 +2298,7 @@ void LIBUSB_CALL libusb_hotplug_deregister_callback(libusb_context *ctx,
2069
2298
  void * LIBUSB_CALL libusb_hotplug_get_user_data(libusb_context *ctx,
2070
2299
  libusb_hotplug_callback_handle callback_handle);
2071
2300
 
2072
- /** \ingroup libusb_lib
2073
- * Available option values for libusb_set_option().
2074
- */
2075
- enum libusb_option {
2076
- /** Set the log message verbosity.
2077
- *
2078
- * The default level is LIBUSB_LOG_LEVEL_NONE, which means no messages are ever
2079
- * printed. If you choose to increase the message verbosity level, ensure
2080
- * that your application does not close the stderr file descriptor.
2081
- *
2082
- * You are advised to use level LIBUSB_LOG_LEVEL_WARNING. libusb is conservative
2083
- * with its message logging and most of the time, will only log messages that
2084
- * explain error conditions and other oddities. This will help you debug
2085
- * your software.
2086
- *
2087
- * If the LIBUSB_DEBUG environment variable was set when libusb was
2088
- * initialized, this function does nothing: the message verbosity is fixed
2089
- * to the value in the environment variable.
2090
- *
2091
- * If libusb was compiled without any message logging, this function does
2092
- * nothing: you'll never get any messages.
2093
- *
2094
- * If libusb was compiled with verbose debug message logging, this function
2095
- * does nothing: you'll always get messages from all levels.
2096
- */
2097
- LIBUSB_OPTION_LOG_LEVEL = 0,
2098
-
2099
- /** Use the UsbDk backend for a specific context, if available.
2100
- *
2101
- * This option should be set immediately after calling libusb_init(), otherwise
2102
- * unspecified behavior may occur.
2103
- *
2104
- * Only valid on Windows.
2105
- */
2106
- LIBUSB_OPTION_USE_USBDK = 1,
2107
-
2108
- /** Do not scan for devices
2109
- *
2110
- * With this option set, libusb will skip scanning devices in
2111
- * libusb_init(). Must be set before calling libusb_init().
2112
- *
2113
- * Hotplug functionality will also be deactivated.
2114
- *
2115
- * The option is useful in combination with libusb_wrap_sys_device(),
2116
- * which can access a device directly without prior device scanning.
2117
- *
2118
- * This is typically needed on Android, where access to USB devices
2119
- * is limited.
2120
- *
2121
- * For LIBUSB_API_VERSION 0x01000108 it was called LIBUSB_OPTION_WEAK_AUTHORITY
2122
- *
2123
- * Only valid on Linux.
2124
- */
2125
- LIBUSB_OPTION_NO_DEVICE_DISCOVERY = 2,
2126
-
2127
- #define LIBUSB_OPTION_WEAK_AUTHORITY LIBUSB_OPTION_NO_DEVICE_DISCOVERY
2128
-
2129
- LIBUSB_OPTION_MAX = 3
2130
- };
2131
-
2132
- int LIBUSB_CALL libusb_set_option(libusb_context *ctx, enum libusb_option option, ...);
2301
+ int LIBUSB_CALLV libusb_set_option(libusb_context *ctx, enum libusb_option option, ...);
2133
2302
 
2134
2303
  #ifdef _MSC_VER
2135
2304
  #pragma warning(pop)
@@ -73,7 +73,7 @@
73
73
  #endif
74
74
 
75
75
  /* The following is used to silence warnings for unused variables */
76
- #if defined(UNREFERENCED_PARAMETER)
76
+ #if defined(UNREFERENCED_PARAMETER) && !defined(__GNUC__)
77
77
  #define UNUSED(var) UNREFERENCED_PARAMETER(var)
78
78
  #else
79
79
  #define UNUSED(var) do { (void)(var); } while(0)
@@ -128,6 +128,7 @@ typedef atomic_long usbi_atomic_t;
128
128
  * return_type LIBUSB_CALL function_name(params);
129
129
  */
130
130
  #define API_EXPORTED LIBUSB_CALL DEFAULT_VISIBILITY
131
+ #define API_EXPORTEDV LIBUSB_CALLV DEFAULT_VISIBILITY
131
132
 
132
133
  #ifdef __cplusplus
133
134
  extern "C" {
@@ -321,10 +322,10 @@ void usbi_log(struct libusb_context *ctx, enum libusb_log_level level,
321
322
 
322
323
  #else /* ENABLE_LOGGING */
323
324
 
324
- #define usbi_err(ctx, ...) UNUSED(ctx)
325
- #define usbi_warn(ctx, ...) UNUSED(ctx)
326
- #define usbi_info(ctx, ...) UNUSED(ctx)
327
- #define usbi_dbg(ctx, ...) do {} while (0)
325
+ #define usbi_err(ctx, ...) do { (void)(ctx); } while(0)
326
+ #define usbi_warn(ctx, ...) do { (void)(ctx); } while(0)
327
+ #define usbi_info(ctx, ...) do { (void)(ctx); } while(0)
328
+ #define usbi_dbg(ctx, ...) do { (void)(ctx); } while(0)
328
329
 
329
330
  #endif /* ENABLE_LOGGING */
330
331
 
@@ -379,7 +380,7 @@ struct libusb_context {
379
380
  struct list_head flying_transfers;
380
381
  /* Note paths taking both this and usbi_transfer->lock must always
381
382
  * take this lock first */
382
- usbi_mutex_t flying_transfers_lock;
383
+ usbi_mutex_t flying_transfers_lock; /* for flying_transfers and timeout_flags */
383
384
 
384
385
  #if !defined(PLATFORM_WINDOWS)
385
386
  /* user callbacks for pollfd changes */
@@ -533,7 +534,7 @@ static inline void usbi_localize_device_descriptor(struct libusb_device_descript
533
534
  desc->bcdDevice = libusb_le16_to_cpu(desc->bcdDevice);
534
535
  }
535
536
 
536
- #ifdef HAVE_CLOCK_GETTIME
537
+ #if defined(HAVE_CLOCK_GETTIME) && !defined(__APPLE__)
537
538
  static inline void usbi_get_monotonic_time(struct timespec *tp)
538
539
  {
539
540
  ASSERT_EQ(clock_gettime(CLOCK_MONOTONIC, tp), 0);
@@ -562,8 +563,11 @@ void usbi_get_real_time(struct timespec *tp);
562
563
  * 2. struct usbi_transfer
563
564
  * 3. struct libusb_transfer (which includes iso packets) [variable size]
564
565
  *
565
- * from a libusb_transfer, you can get the usbi_transfer by rewinding the
566
- * appropriate number of bytes.
566
+ * You can convert between them with the macros:
567
+ * TRANSFER_PRIV_TO_USBI_TRANSFER
568
+ * USBI_TRANSFER_TO_TRANSFER_PRIV
569
+ * USBI_TRANSFER_TO_LIBUSB_TRANSFER
570
+ * LIBUSB_TRANSFER_TO_USBI_TRANSFER
567
571
  */
568
572
 
569
573
  struct usbi_transfer {
@@ -574,7 +578,7 @@ struct usbi_transfer {
574
578
  int transferred;
575
579
  uint32_t stream_id;
576
580
  uint32_t state_flags; /* Protected by usbi_transfer->lock */
577
- uint32_t timeout_flags; /* Protected by the flying_stransfers_lock */
581
+ uint32_t timeout_flags; /* Protected by the flying_transfers_lock */
578
582
 
579
583
  /* The device reference is held until destruction for logging
580
584
  * even after dev_handle is set to NULL. */
@@ -616,10 +620,21 @@ enum usbi_transfer_timeout_flags {
616
620
  USBI_TRANSFER_TIMED_OUT = 1U << 2,
617
621
  };
618
622
 
623
+ #define TRANSFER_PRIV_TO_USBI_TRANSFER(transfer_priv) \
624
+ ((struct usbi_transfer *) \
625
+ ((unsigned char *)(transfer_priv) \
626
+ + PTR_ALIGN(sizeof(*transfer_priv))))
627
+
628
+ #define USBI_TRANSFER_TO_TRANSFER_PRIV(itransfer) \
629
+ ((unsigned char *) \
630
+ ((unsigned char *)(itransfer) \
631
+ - PTR_ALIGN(usbi_backend.transfer_priv_size)))
632
+
619
633
  #define USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer) \
620
634
  ((struct libusb_transfer *) \
621
635
  ((unsigned char *)(itransfer) \
622
636
  + PTR_ALIGN(sizeof(struct usbi_transfer))))
637
+
623
638
  #define LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer) \
624
639
  ((struct usbi_transfer *) \
625
640
  ((unsigned char *)(transfer) \
@@ -678,7 +693,7 @@ struct usbi_interface_descriptor {
678
693
  struct usbi_string_descriptor {
679
694
  uint8_t bLength;
680
695
  uint8_t bDescriptorType;
681
- uint16_t wData[ZERO_SIZED_ARRAY];
696
+ uint16_t wData[LIBUSB_FLEXIBLE_ARRAY];
682
697
  } LIBUSB_PACKED;
683
698
 
684
699
  struct usbi_bos_descriptor {
@@ -813,6 +828,7 @@ struct usbi_option {
813
828
  int is_set;
814
829
  union {
815
830
  int ival;
831
+ libusb_log_cb log_cbval;
816
832
  } arg;
817
833
  };
818
834
 
@@ -891,7 +907,7 @@ static inline void *usbi_get_transfer_priv(struct usbi_transfer *itransfer)
891
907
  struct discovered_devs {
892
908
  size_t len;
893
909
  size_t capacity;
894
- struct libusb_device *devices[ZERO_SIZED_ARRAY];
910
+ struct libusb_device *devices[LIBUSB_FLEXIBLE_ARRAY];
895
911
  };
896
912
 
897
913
  struct discovered_devs *discovered_devs_append(
@@ -1180,6 +1196,8 @@ struct usbi_os_backend {
1180
1196
  * claiming, no other drivers/applications can use the interface because
1181
1197
  * we now "own" it.
1182
1198
  *
1199
+ * This function gets called with dev_handle->lock locked!
1200
+ *
1183
1201
  * Return:
1184
1202
  * - 0 on success
1185
1203
  * - LIBUSB_ERROR_NOT_FOUND if the interface does not exist
@@ -1199,6 +1217,8 @@ struct usbi_os_backend {
1199
1217
  * You will only ever be asked to release an interface which was
1200
1218
  * successfully claimed earlier.
1201
1219
  *
1220
+ * This function gets called with dev_handle->lock locked!
1221
+ *
1202
1222
  * Return:
1203
1223
  * - 0 on success
1204
1224
  * - LIBUSB_ERROR_NO_DEVICE if the device has been disconnected since it
@@ -1335,7 +1355,7 @@ struct usbi_os_backend {
1335
1355
  *
1336
1356
  * This function must not block.
1337
1357
  *
1338
- * This function gets called with the flying_transfers_lock locked!
1358
+ * This function gets called with itransfer->lock locked!
1339
1359
  *
1340
1360
  * Return:
1341
1361
  * - 0 on success
@@ -1349,6 +1369,8 @@ struct usbi_os_backend {
1349
1369
  * This function must not block. The transfer cancellation must complete
1350
1370
  * later, resulting in a call to usbi_handle_transfer_cancellation()
1351
1371
  * from the context of handle_events.
1372
+ *
1373
+ * This function gets called with itransfer->lock locked!
1352
1374
  */
1353
1375
  int (*cancel_transfer)(struct usbi_transfer *itransfer);
1354
1376