aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2020-12-16 17:14:33 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2020-12-16 17:14:33 +0000
commite128647bb772438d4383735837b1c20142339799 (patch)
tree52ec0a57e51dc3f785544baf9463e49199238df9
parent1c5621e417a1f78f2523e2da4aa54359666b4e16 (diff)
parent80719bb5e6cd497c37dadccdd51ccec2dd38c1d3 (diff)
downloadlibusb-e128647bb772438d4383735837b1c20142339799.tar.gz
Merge "Upgrade libusb to v1.0.24"
-rw-r--r--.gitattributes8
-rw-r--r--.gitignore10
-rwxr-xr-x.private/appveyor_build.sh22
-rw-r--r--.private/bd.cmd89
-rwxr-xr-x[-rw-r--r--].private/bm.sh2
-rwxr-xr-x.private/bwince.cmd57
-rwxr-xr-x.private/ci-build.sh67
-rwxr-xr-x.private/post-rewrite.sh4
-rwxr-xr-x.private/pre-commit.sh4
-rw-r--r--.private/wbs.txt23
-rwxr-xr-x.private/wbs_wince.txt42
-rw-r--r--.travis.yml56
-rw-r--r--AUTHORS56
-rw-r--r--Android.bp8
-rw-r--r--Brewfile4
-rw-r--r--ChangeLog28
-rw-r--r--INSTALL_WIN.txt66
-rw-r--r--METADATA6
-rw-r--r--Makefile.am42
-rw-r--r--[l---------]README33
-rw-r--r--README.git6
l---------[-rw-r--r--]README.md33
-rw-r--r--Xcode/common.xcconfig42
-rw-r--r--Xcode/config.h38
-rw-r--r--Xcode/libusb.xcodeproj/project.pbxproj585
-rw-r--r--android/config.h66
-rw-r--r--android/jni/Android.mk2
-rw-r--r--android/jni/Application.mk16
-rw-r--r--android/jni/examples.mk59
-rw-r--r--android/jni/libusb.mk13
-rw-r--r--android/jni/tests.mk31
-rw-r--r--appveyor.yml95
-rw-r--r--appveyor_cygwin.bat11
-rw-r--r--appveyor_minGW.bat19
-rwxr-xr-xautogen.sh2
-rwxr-xr-xbootstrap.sh6
-rw-r--r--configure.ac509
-rw-r--r--darwin/config.h135
-rw-r--r--doc/Makefile.am9
-rw-r--r--doc/Makefile.in22
-rw-r--r--doc/doxygen.cfg.in530
-rw-r--r--examples/Makefile.am19
-rw-r--r--examples/dpfp.c324
-rw-r--r--examples/dpfp_threaded.c557
-rw-r--r--examples/ezusb.c6
-rw-r--r--examples/ezusb.h23
-rw-r--r--examples/fxload.c9
-rw-r--r--examples/hotplugtest.c2
-rw-r--r--examples/sam3u_benchmark.c77
-rw-r--r--[-rwxr-xr-x]examples/testlibusb.c242
-rw-r--r--examples/xusb.c34
-rw-r--r--libusb/Makefile.am125
-rw-r--r--libusb/Makefile.am.extra26
-rw-r--r--libusb/core.c461
-rw-r--r--libusb/descriptor.c778
-rw-r--r--libusb/hotplug.c88
-rw-r--r--libusb/hotplug.h10
-rw-r--r--libusb/io.c975
-rw-r--r--libusb/libusb-1.0.def4
-rw-r--r--libusb/libusb-1.0.rc10
-rw-r--r--libusb/libusb.h499
-rw-r--r--libusb/libusbi.h778
-rw-r--r--libusb/os/darwin_usb.c424
-rw-r--r--libusb/os/darwin_usb.h2
-rw-r--r--libusb/os/events_posix.c300
-rw-r--r--libusb/os/events_posix.h59
-rw-r--r--libusb/os/events_windows.c214
-rw-r--r--libusb/os/events_windows.h (renamed from msvc/missing.h)36
-rw-r--r--libusb/os/haiku_pollfs.cpp13
-rw-r--r--libusb/os/haiku_usb.h24
-rw-r--r--libusb/os/haiku_usb_backend.cpp67
-rw-r--r--libusb/os/haiku_usb_raw.cpp196
-rw-r--r--libusb/os/linux_netlink.c104
-rw-r--r--libusb/os/linux_udev.c124
-rw-r--r--libusb/os/linux_usbfs.c1836
-rw-r--r--libusb/os/linux_usbfs.h131
-rw-r--r--libusb/os/netbsd_usb.c251
-rw-r--r--libusb/os/null_usb.c111
-rw-r--r--libusb/os/openbsd_usb.c167
-rw-r--r--libusb/os/poll_posix.c84
-rw-r--r--libusb/os/poll_posix.h14
-rw-r--r--libusb/os/poll_windows.c447
-rw-r--r--libusb/os/poll_windows.h98
-rw-r--r--libusb/os/sunos_usb.c510
-rw-r--r--libusb/os/sunos_usb.h1
-rw-r--r--libusb/os/threads_posix.c113
-rw-r--r--libusb/os/threads_posix.h42
-rw-r--r--libusb/os/threads_windows.c104
-rw-r--r--libusb/os/threads_windows.h64
-rw-r--r--libusb/os/wince_usb.c888
-rw-r--r--libusb/os/wince_usb.h126
-rw-r--r--libusb/os/windows_common.c886
-rw-r--r--libusb/os/windows_common.h345
-rw-r--r--libusb/os/windows_nt_common.c1010
-rw-r--r--libusb/os/windows_nt_common.h110
-rw-r--r--libusb/os/windows_nt_shared_types.h147
-rw-r--r--libusb/os/windows_usbdk.c427
-rw-r--r--libusb/os/windows_usbdk.h7
-rw-r--r--libusb/os/windows_winusb.c2198
-rw-r--r--libusb/os/windows_winusb.h269
-rw-r--r--libusb/strerror.c50
-rw-r--r--libusb/sync.c39
-rw-r--r--libusb/version.h2
-rw-r--r--libusb/version_nano.h2
-rw-r--r--linux/config.h134
-rw-r--r--msvc/.gitattributes3
-rw-r--r--msvc/appveyor.bat27
-rw-r--r--msvc/config.h47
-rw-r--r--msvc/ddk_build.cmd219
-rw-r--r--msvc/dpfp_2013.vcxproj (renamed from msvc/hotplugtest_2012.vcxproj)24
-rw-r--r--msvc/dpfp_2013.vcxproj.filters26
-rw-r--r--msvc/dpfp_2015.vcxproj (renamed from msvc/listdevs_2010.vcxproj)23
-rw-r--r--msvc/dpfp_2015.vcxproj.filters26
-rw-r--r--msvc/dpfp_2017.vcxproj106
-rw-r--r--msvc/dpfp_2017.vcxproj.filters26
-rw-r--r--msvc/dpfp_2019.vcxproj106
-rw-r--r--msvc/dpfp_2019.vcxproj.filters26
-rw-r--r--msvc/dpfp_threaded_2013.vcxproj87
-rw-r--r--msvc/dpfp_threaded_2013.vcxproj.filters26
-rw-r--r--msvc/dpfp_threaded_2015.vcxproj87
-rw-r--r--msvc/dpfp_threaded_2015.vcxproj.filters26
-rw-r--r--msvc/dpfp_threaded_2017.vcxproj106
-rw-r--r--msvc/dpfp_threaded_2017.vcxproj.filters26
-rw-r--r--msvc/dpfp_threaded_2019.vcxproj (renamed from msvc/fxload_2012.vcxproj)49
-rw-r--r--msvc/dpfp_threaded_2019.vcxproj.filters26
-rw-r--r--msvc/errno.h102
-rw-r--r--msvc/fxload_2013.vcxproj9
-rw-r--r--msvc/fxload_2013.vcxproj.filters35
-rw-r--r--msvc/fxload_2015.vcxproj9
-rw-r--r--msvc/fxload_2015.vcxproj.filters35
-rw-r--r--msvc/fxload_2017.vcxproj13
-rw-r--r--msvc/fxload_2017.vcxproj.filters35
-rw-r--r--msvc/fxload_2019.vcxproj (renamed from msvc/fxload_2010.vcxproj)35
-rw-r--r--msvc/fxload_2019.vcxproj.filters35
-rw-r--r--msvc/fxload_sources23
-rw-r--r--msvc/getopt/getopt.c (renamed from examples/getopt/getopt.c)0
-rw-r--r--msvc/getopt/getopt.h (renamed from examples/getopt/getopt.h)0
-rw-r--r--msvc/getopt/getopt1.c (renamed from examples/getopt/getopt1.c)0
-rw-r--r--msvc/getopt_2005.vcproj288
-rw-r--r--msvc/getopt_2010.vcxproj72
-rw-r--r--msvc/getopt_2013.vcxproj9
-rw-r--r--msvc/getopt_2013.vcxproj.filters26
-rw-r--r--msvc/getopt_2015.vcxproj8
-rw-r--r--msvc/getopt_2015.vcxproj.filters26
-rw-r--r--msvc/getopt_2017.vcxproj14
-rw-r--r--msvc/getopt_2017.vcxproj.filters26
-rw-r--r--msvc/getopt_2019.vcxproj (renamed from msvc/getopt_2012.vcxproj)31
-rw-r--r--msvc/getopt_2019.vcxproj.filters26
-rw-r--r--msvc/getopt_sources24
-rw-r--r--msvc/hotplugtest_2013.vcxproj9
-rw-r--r--msvc/hotplugtest_2013.vcxproj.filters23
-rw-r--r--msvc/hotplugtest_2015.vcxproj9
-rw-r--r--msvc/hotplugtest_2015.vcxproj.filters23
-rw-r--r--msvc/hotplugtest_2017.vcxproj13
-rw-r--r--msvc/hotplugtest_2017.vcxproj.filters23
-rw-r--r--msvc/hotplugtest_2019.vcxproj105
-rw-r--r--msvc/hotplugtest_2019.vcxproj.filters23
-rw-r--r--msvc/hotplugtest_sources20
-rw-r--r--msvc/inttypes.h295
-rw-r--r--msvc/libusb.dsw71
-rw-r--r--msvc/libusb_2005.sln95
-rw-r--r--msvc/libusb_2010.sln105
-rw-r--r--msvc/libusb_2012.sln105
-rw-r--r--msvc/libusb_2013.sln70
-rw-r--r--msvc/libusb_2015.sln72
-rw-r--r--msvc/libusb_2017.sln126
-rw-r--r--msvc/libusb_2019.sln240
-rw-r--r--msvc/libusb_dll.dsp194
-rw-r--r--msvc/libusb_dll_2005.vcproj464
-rw-r--r--msvc/libusb_dll_2012.vcxproj107
-rw-r--r--msvc/libusb_dll_2013.vcxproj14
-rw-r--r--msvc/libusb_dll_2013.vcxproj.filters97
-rw-r--r--msvc/libusb_dll_2015.vcxproj13
-rw-r--r--msvc/libusb_dll_2015.vcxproj.filters97
-rw-r--r--msvc/libusb_dll_2017.vcxproj21
-rw-r--r--msvc/libusb_dll_2017.vcxproj.filters97
-rw-r--r--msvc/libusb_dll_2019.vcxproj (renamed from msvc/libusb_dll_2010.vcxproj)35
-rw-r--r--msvc/libusb_dll_2019.vcxproj.filters97
-rw-r--r--msvc/libusb_dll_wince.vcproj1251
-rw-r--r--msvc/libusb_sources43
-rw-r--r--msvc/libusb_static.dsp174
-rw-r--r--msvc/libusb_static_2005.vcproj390
-rw-r--r--msvc/libusb_static_2012.vcxproj98
-rw-r--r--msvc/libusb_static_2013.vcxproj13
-rw-r--r--msvc/libusb_static_2013.vcxproj.filters83
-rw-r--r--msvc/libusb_static_2015.vcxproj12
-rw-r--r--msvc/libusb_static_2015.vcxproj.filters83
-rw-r--r--msvc/libusb_static_2017.vcxproj12
-rw-r--r--msvc/libusb_static_2017.vcxproj.filters83
-rw-r--r--msvc/libusb_static_2019.vcxproj (renamed from msvc/libusb_static_2010.vcxproj)34
-rw-r--r--msvc/libusb_static_2019.vcxproj.filters83
-rw-r--r--msvc/libusb_static_wince.vcproj1179
-rw-r--r--msvc/libusb_wince.sln246
-rw-r--r--msvc/listdevs.dsp103
-rw-r--r--msvc/listdevs_2005.vcproj360
-rw-r--r--msvc/listdevs_2013.vcxproj9
-rw-r--r--msvc/listdevs_2013.vcxproj.filters23
-rw-r--r--msvc/listdevs_2015.vcxproj9
-rw-r--r--msvc/listdevs_2015.vcxproj.filters23
-rw-r--r--msvc/listdevs_2017.vcxproj13
-rw-r--r--msvc/listdevs_2017.vcxproj.filters23
-rw-r--r--msvc/listdevs_2019.vcxproj105
-rw-r--r--msvc/listdevs_2019.vcxproj.filters23
-rw-r--r--msvc/listdevs_sources20
-rw-r--r--msvc/listdevs_wince.vcproj1120
-rw-r--r--msvc/missing.c80
-rw-r--r--msvc/sam3u_benchmark_2013.vcxproj (renamed from msvc/listdevs_2012.vcxproj)22
-rw-r--r--msvc/sam3u_benchmark_2013.vcxproj.filters26
-rw-r--r--msvc/sam3u_benchmark_2015.vcxproj (renamed from msvc/hotplugtest_2010.vcxproj)21
-rw-r--r--msvc/sam3u_benchmark_2015.vcxproj.filters26
-rw-r--r--msvc/sam3u_benchmark_2017.vcxproj106
-rw-r--r--msvc/sam3u_benchmark_2017.vcxproj.filters26
-rw-r--r--msvc/sam3u_benchmark_2019.vcxproj106
-rw-r--r--msvc/sam3u_benchmark_2019.vcxproj.filters26
-rw-r--r--msvc/stdint.h256
-rw-r--r--msvc/stress_2005.vcproj390
-rw-r--r--msvc/stress_2012.vcxproj87
-rw-r--r--msvc/stress_2013.vcxproj6
-rw-r--r--msvc/stress_2013.vcxproj.filters32
-rw-r--r--msvc/stress_2015.vcxproj6
-rw-r--r--msvc/stress_2015.vcxproj.filters32
-rw-r--r--msvc/stress_2017.vcxproj10
-rw-r--r--msvc/stress_2017.vcxproj.filters32
-rw-r--r--msvc/stress_2019.vcxproj (renamed from msvc/stress_2010.vcxproj)30
-rw-r--r--msvc/stress_2019.vcxproj.filters32
-rw-r--r--msvc/stress_sources21
-rw-r--r--msvc/stress_wince.vcproj1128
-rw-r--r--msvc/testlibusb_2012.vcxproj83
-rw-r--r--msvc/testlibusb_2013.vcxproj9
-rw-r--r--msvc/testlibusb_2013.vcxproj.filters23
-rw-r--r--msvc/testlibusb_2015.vcxproj9
-rw-r--r--msvc/testlibusb_2015.vcxproj.filters23
-rw-r--r--msvc/testlibusb_2017.vcxproj13
-rw-r--r--msvc/testlibusb_2017.vcxproj.filters23
-rw-r--r--msvc/testlibusb_2019.vcxproj (renamed from msvc/testlibusb_2010.vcxproj)33
-rw-r--r--msvc/testlibusb_2019.vcxproj.filters23
-rw-r--r--msvc/testlibusb_sources20
-rw-r--r--msvc/xusb.dsp102
-rw-r--r--msvc/xusb_2005.vcproj344
-rw-r--r--msvc/xusb_2012.vcxproj83
-rw-r--r--msvc/xusb_2013.vcxproj9
-rw-r--r--msvc/xusb_2013.vcxproj.filters23
-rw-r--r--msvc/xusb_2015.vcxproj9
-rw-r--r--msvc/xusb_2015.vcxproj.filters23
-rw-r--r--msvc/xusb_2017.vcxproj13
-rw-r--r--msvc/xusb_2017.vcxproj.filters23
-rw-r--r--msvc/xusb_2019.vcxproj (renamed from msvc/xusb_2010.vcxproj)33
-rw-r--r--msvc/xusb_2019.vcxproj.filters23
-rw-r--r--msvc/xusb_sources20
-rw-r--r--msvc/xusb_wince.vcproj1120
-rw-r--r--test0
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/libusb_testlib.h55
-rw-r--r--tests/stress.c102
-rw-r--r--tests/testlib.c249
-rwxr-xr-xtravis-autogen.sh39
-rw-r--r--windows/config.h132
257 files changed, 13275 insertions, 22218 deletions
diff --git a/.gitattributes b/.gitattributes
index fa0f57d..f93e0b6 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,11 +1,7 @@
-*.sh eol=lf
*.ac eol=lf
*.am eol=lf
-*.dsw eol=crlf
-*.dsp eol=crlf whitespace=space-before-tab
-*.sln eol=crlf
-*.vcproj eol=crlf
-*.vcxproj* eol=crlf
+*.bat eol=crlf
+*.sh eol=lf
.gitattributes export-ignore
.gitignore export-ignore
INSTALL_WIN.txt eol=crlf
diff --git a/.gitignore b/.gitignore
index bb70fa9..343a446 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
.libs
Makefile
Makefile.in
+!doc/Makefile.in
*.la
*.lo
*.o
@@ -37,14 +38,17 @@ examples/hotplugtest
examples/sam3u_benchmark
examples/testlibusb
tests/stress
+android/libs
+android/obj
*.exe
*.pc
-doc/html
+doc/api-1.0
*.plg
*.ncb
*.opt
Debug
Release
+*.db
*.user
*.suo
*.sdf
@@ -54,7 +58,11 @@ Release
*.orig
.dirstamp
.amend
+.DS_Store
+Xcode/build
+xcshareddata
xcuserdata
*.xcuserdatad
*.xccheckout
*.xcscmblueprint
+*.xcworkspace
diff --git a/.private/appveyor_build.sh b/.private/appveyor_build.sh
new file mode 100755
index 0000000..44ca46b
--- /dev/null
+++ b/.private/appveyor_build.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+set -eu
+
+buildsys="${1}-${Platform}"
+
+if [ "${buildsys}" == "MinGW-Win32" ]; then
+ export PATH="/c/mingw-w64/i686-6.3.0-posix-dwarf-rt_v5-rev1/mingw32/bin:${PATH}"
+elif [ "${buildsys}" == "MinGW-x64" ]; then
+ export PATH="/c/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin:${PATH}"
+fi
+
+builddir="build-${buildsys}"
+installdir="${PWD}/libusb-${buildsys}"
+
+cd libusb
+
+echo "Bootstrapping ..."
+./bootstrap.sh
+echo ""
+
+exec .private/ci-build.sh --build-dir "${builddir}" --install -- "--prefix=${installdir}"
diff --git a/.private/bd.cmd b/.private/bd.cmd
deleted file mode 100644
index d02ce23..0000000
--- a/.private/bd.cmd
+++ /dev/null
@@ -1,89 +0,0 @@
-@echo off
-rem produce the DDK binary files for snapshots
-rem !!!THIS SCRIPT IS FOR INTERNAL DEVELOPER USE ONLY!!!
-
-if NOT x%DDK_TARGET_OS%==xWinXP goto usage
-
-set IWD=%~dp0
-cd ..
-mkdir E:\dailies\%DATE%
-for %%A in (MS32 MS64) do mkdir E:\dailies\%DATE%\%%A
-for %%A in (MS32 MS64) do mkdir E:\dailies\%DATE%\%%A\static
-for %%A in (MS32 MS64) do mkdir E:\dailies\%DATE%\%%A\dll
-for %%A in (source bin32 bin64) do mkdir E:\dailies\%DATE%\examples\%%A
-copy examples\listdevs.c E:\dailies\%DATE%\examples\source
-copy examples\xusb.c E:\dailies\%DATE%\examples\source
-copy examples\ezusb.? E:\dailies\%DATE%\examples\source
-copy examples\fxload.c E:\dailies\%DATE%\examples\source
-copy msvc\stdint.h E:\dailies\%DATE%\examples\source
-copy .private\wbs.txt E:\dailies\%DATE%\README.txt
-
-set ORG_BUILD_ALT_DIR=%BUILD_ALT_DIR%
-set ORG_BUILDARCH=%_BUILDARCH%
-set ORG_PATH=%PATH%
-set ORG_BUILD_DEFAULT_TARGETS=%BUILD_DEFAULT_TARGETS%
-
-set 386=1
-set AMD64=
-set BUILD_DEFAULT_TARGETS=-386
-set _AMD64bit=
-set _BUILDARCH=x86
-set PATH=%BASEDIR%\bin\x86;%BASEDIR%\bin\x86\x86
-
-cd msvc
-call ddk_build
-cd ..
-
-@echo off
-copy Win32\Release\lib\libusb-1.0.lib E:\dailies\%DATE%\MS32\static
-copy Win32\Release\examples\listdevs.exe E:\dailies\%DATE%\examples\bin32
-copy Win32\Release\examples\xusb.exe E:\dailies\%DATE%\examples\bin32
-copy Win32\Release\examples\fxload.exe E:\dailies\%DATE%\examples\bin32
-
-cd msvc
-call ddk_build DLL
-cd ..
-
-@echo off
-copy Win32\Release\lib\libusb-1.0.lib E:\dailies\%DATE%\MS32\dll
-copy Win32\Release\dll\libusb-1.0.dll E:\dailies\%DATE%\MS32\dll
-copy Win32\Release\dll\libusb-1.0.pdb E:\dailies\%DATE%\MS32\dll
-
-set 386=
-set AMD64=1
-set BUILD_DEFAULT_TARGETS=-amd64
-set _AMD64bit=true
-set _BUILDARCH=AMD64
-set PATH=%BASEDIR%\bin\x86\amd64;%BASEDIR%\bin\x86
-
-cd msvc
-call ddk_build
-cd ..
-
-@echo off
-copy x64\Release\lib\libusb-1.0.lib E:\dailies\%DATE%\MS64\static
-copy x64\Release\examples\listdevs.exe E:\dailies\%DATE%\examples\bin64
-copy x64\Release\examples\xusb.exe E:\dailies\%DATE%\examples\bin64
-copy x64\Release\examples\fxload.exe E:\dailies\%DATE%\examples\bin64
-
-cd msvc
-call ddk_build DLL
-cd ..
-
-@echo off
-copy x64\Release\lib\libusb-1.0.lib E:\dailies\%DATE%\MS64\dll
-copy x64\Release\dll\libusb-1.0.dll E:\dailies\%DATE%\MS64\dll
-copy x64\Release\dll\libusb-1.0.pdb E:\dailies\%DATE%\MS64\dll
-
-set BUILD_ALT_DIR=%ORG_BUILD_ALT_DIR%
-set _BUILDARCH=%ORG_BUILDARCH%
-set PATH=%ORG_PATH%
-set BUILD_DEFAULT_TARGETS=%ORG_BUILD_DEFAULT_TARGETS%
-
-goto done
-
-:usage
-echo must be run in a WXP build environment!
-
-:done
-cd %IWD% \ No newline at end of file
diff --git a/.private/bm.sh b/.private/bm.sh
index 520c3a5..0f45a98 100644..100755
--- a/.private/bm.sh
+++ b/.private/bm.sh
@@ -51,4 +51,4 @@ mkdir -p $target/dll
cp -v libusb/.libs/libusb-1.0.a $target/static
cp -v libusb/.libs/libusb-1.0.dll $target/dll
cp -v libusb/.libs/libusb-1.0.dll.a $target/dll
-cd $PWD \ No newline at end of file
+cd $PWD
diff --git a/.private/bwince.cmd b/.private/bwince.cmd
deleted file mode 100755
index 0cc7477..0000000
--- a/.private/bwince.cmd
+++ /dev/null
@@ -1,57 +0,0 @@
-@echo off
-rem produce the Win CE binary files for snapshots
-rem !!!THIS SCRIPT IS FOR INTERNAL DEVELOPER USE ONLY!!!
-
-if "x%VSINSTALLDIR%"=="x" goto usage
-
-if "x%WINCE_TARGET_DIR_BASE%"=="x" set WINCE_TARGET_DIR_BASE=E:\dailies
-if "x%WINCE_TARGET_ARCHES%"=="x" set WINCE_TARGET_ARCHES=ARMV4I MIPSII MIPSII_FP MIPSIV MIPSIV_FP SH4 x86
-
-
-set WINCE_TARGET_DIR=%WINCE_TARGET_DIR_BASE%\%DATE:/=-%
-set MSBUILD_CMD=msbuild.exe
-set MSBUILD_TARGET=Rebuild
-set MSBUILD_CONFIGURATION=Release
-set WINCE_SLN=msvc\libusb_wince.sln
-set PLATFORM_PREFIX=STANDARDSDK_500 (
-set PLATFORM_POSTFIX=)
-
-
-set PWD=%~dp0
-cd ..
-
-mkdir %WINCE_TARGET_DIR%
-mkdir %WINCE_TARGET_DIR%\include\libusb-1.0
-copy libusb\libusb-1.0.def %WINCE_TARGET_DIR%
-copy libusb\libusb.h %WINCE_TARGET_DIR%\include\libusb-1.0
-for %%A in (%WINCE_TARGET_ARCHES%) do mkdir %WINCE_TARGET_DIR%\%%A
-for %%A in (%WINCE_TARGET_ARCHES%) do mkdir %WINCE_TARGET_DIR%\%%A\static
-for %%A in (%WINCE_TARGET_ARCHES%) do mkdir %WINCE_TARGET_DIR%\%%A\dll
-for %%A in (%WINCE_TARGET_ARCHES%) do mkdir %WINCE_TARGET_DIR%\examples\%%A
-mkdir %WINCE_TARGET_DIR%\examples\source
-copy examples\listdevs.c %WINCE_TARGET_DIR%\examples\source
-copy examples\xusb.c %WINCE_TARGET_DIR%\examples\source
-copy msvc\stdint.h %WINCE_TARGET_DIR%\examples\source
-copy .private\wbs_wince.txt %WINCE_TARGET_DIR%\README.txt
-copy COPYING %WINCE_TARGET_DIR%\COPYING
-
-rem Perform the rebuild
-for %%A in (%WINCE_TARGET_ARCHES%) do %MSBUILD_CMD% %WINCE_SLN% /property:Platform="%PLATFORM_PREFIX%%%A%PLATFORM_POSTFIX%" /property:Configuration=%MSBUILD_CONFIGURATION% /target:%MSBUILD_TARGET%"
-
-
-rem Copy across the binaries
-for %%A in (%WINCE_TARGET_ARCHES%) do (
- copy %%A\%MSBUILD_CONFIGURATION%\lib\libusb-1.0.lib %WINCE_TARGET_DIR%\%%A\static
- copy %%A\%MSBUILD_CONFIGURATION%\examples\listdevs.exe %WINCE_TARGET_DIR%\examples\%%A
- copy %%A\%MSBUILD_CONFIGURATION%\examples\xusb.exe %WINCE_TARGET_DIR%\examples\%%A
- copy %%A\%MSBUILD_CONFIGURATION%\dll\libusb-1.0.lib %WINCE_TARGET_DIR%\%%A\dll
- copy %%A\%MSBUILD_CONFIGURATION%\dll\libusb-1.0.dll %WINCE_TARGET_DIR%\%%A\dll
- copy %%A\%MSBUILD_CONFIGURATION%\dll\libusb-1.0.pdb %WINCE_TARGET_DIR%\%%A\dll )
-
-goto done
-
-:usage
-echo must be run in a Visual Studio 2005 build environment!
-
-:done
-cd %PWD% \ No newline at end of file
diff --git a/.private/ci-build.sh b/.private/ci-build.sh
new file mode 100755
index 0000000..8a0da6b
--- /dev/null
+++ b/.private/ci-build.sh
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+set -e
+
+builddir=
+install=no
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ --build-dir)
+ if [ $# -lt 2 ]; then
+ echo "ERROR: missing argument for --build-dir option" >&2
+ exit 1
+ fi
+ builddir=$2
+ shift 2
+ ;;
+ --install)
+ install=yes
+ shift
+ ;;
+ --)
+ shift
+ break;
+ ;;
+ *)
+ echo "ERROR: Unexpected argument: $1" >&2
+ exit 1
+ esac
+done
+
+if [ -z "${builddir}" ]; then
+ echo "ERROR: --build-dir option not specified" >&2
+ exit 1
+fi
+
+if [ -e "${builddir}" ]; then
+ echo "ERROR: directory entry named '${builddir}' already exists" >&2
+ exit 1
+fi
+
+mkdir "${builddir}"
+cd "${builddir}"
+
+cflags="-O2"
+
+# enable extra warnings
+cflags+=" -Winline"
+cflags+=" -Wmissing-include-dirs"
+cflags+=" -Wnested-externs"
+cflags+=" -Wpointer-arith"
+cflags+=" -Wredundant-decls"
+cflags+=" -Wswitch-enum"
+
+echo ""
+echo "Configuring ..."
+CFLAGS="${cflags}" ../configure --enable-examples-build --enable-tests-build "$@"
+
+echo ""
+echo "Building ..."
+make -j4 -k
+
+if [ "${install}" = "yes" ]; then
+ echo ""
+ echo "Installing ..."
+ make install
+fi
diff --git a/.private/post-rewrite.sh b/.private/post-rewrite.sh
index 0ac4847..60ec3e4 100755
--- a/.private/post-rewrite.sh
+++ b/.private/post-rewrite.sh
@@ -14,6 +14,10 @@
# derivative branch, such as one you would create for private development.
#
+if [ -n "$LIBUSB_SKIP_NANO" ]; then
+ exit 0
+fi
+
case "$1" in
amend)
# Check if a .amend exists. If none, create one and warn user to re-commit.
diff --git a/.private/pre-commit.sh b/.private/pre-commit.sh
index 346d48a..48328f8 100755
--- a/.private/pre-commit.sh
+++ b/.private/pre-commit.sh
@@ -26,6 +26,10 @@
BRANCH_OFFSET=10000
################################################################################
+if [ -n "$LIBUSB_SKIP_NANO" ]; then
+ exit 0
+fi
+
if [ "$BASH_VERSION" = '' ]; then
TYPE_CMD="type git >/dev/null 2>&1"
else
diff --git a/.private/wbs.txt b/.private/wbs.txt
index 2ad8395..752e6da 100644
--- a/.private/wbs.txt
+++ b/.private/wbs.txt
@@ -2,7 +2,7 @@
*********************************************************************
* The latest version of this snapshot can always be downloaded at: *
- * https://sourceforge.net/projects/libusb/files/ *
+ * https://github.com/libusb/libusb/releases *
*********************************************************************
o Visual Studio:
@@ -24,24 +24,6 @@ o Visual Studio:
remember that you need to have a copy of the DLL either in the runtime
directory or in system32
-o WDK/DDK:
- - The following is an example of a sources files that you can use to compile
- a libusb 1.0 based console application. In this sample ..\libusb\ is the
- directory where you would have copied libusb.h as well as the relevant
- libusb-1.0.lib
-
- TARGETNAME=your_app
- TARGETTYPE=PROGRAM
- USE_MSVCRT=1
- UMTYPE=console
- INCLUDES=..\libusb;$(DDK_INC_PATH)
- TARGETLIBS=..\libusb\libusb-1.0.lib
- SOURCES=your_app.c
-
- - Note that if you plan to use libCMT instead of MSVCRT (USE_LIBCMT=1 instead
- of USE_MSVCRT=1), you will need to recompile libusb to use libCMT. This can
- easily be achieved, in the DDK environment, by running 'ddk_build /MT'
-
o MinGW/cygwin
- Copy libusb.h, from include/libusb-1.0/ to your default include directory,
and copy the MinGW32/ or MinGW64/ .a files to your default library directory.
@@ -55,6 +37,9 @@ o Additional information:
- For some libusb samples (including source), please have a look in examples/
- For additional information on the libusb 1.0 Windows backend please visit:
http://windows.libusb.info
+ - Using the UsbDk backend is now a run-time choice rather than a compile-time
+ choice. For additional information, including example usage, please visit:
+ http://windows.libusb.info/#Driver_Installation
- The MinGW and MS generated DLLs are fully interchangeable, provided that you
use the import libs provided or generate one from the .def also provided.
- If you find any issue, please visit http://libusb.info/ and check the
diff --git a/.private/wbs_wince.txt b/.private/wbs_wince.txt
deleted file mode 100755
index 5b5e3cb..0000000
--- a/.private/wbs_wince.txt
+++ /dev/null
@@ -1,42 +0,0 @@
- libusb 1.0 Windows CE binary snapshot - README
-
- *********************************************************************
- * The latest version of this snapshot can always be downloaded at: *
- * https://sourceforge.net/projects/libusb/files/ *
- *********************************************************************
-
-The binaries contained in this snapshot are licensed under the
-GNU Lesser General Public License version 2.1 or, at your option, any later
-version (see COPYING for further details). The source code for these binaries
-is available for download at the same location as this binary snapshot.
-
-o Visual Studio:
- - Open existing or create a new project for your application
- - Copy libusb.h, from the include\libusb-1.0\ directory, into your project and
- make sure that the location where the file reside appears in the 'Additional
- Include Directories' section (Configuration Properties -> C/C++ -> General).
- - Copy the relevant .lib file from ARMV4I, MIPSII, MIPSII_FP, MIPSIV, MIPSIV_FP,
- SH4 or x86 and add 'libusb-1.0.lib' to your 'Additional Dependencies'
- (Configuration Properties -> Linker -> Input). Also make sure that the
- directory where libusb-1.0.lib resides is added to 'Additional Library
- Directories' (Configuration Properties -> Linker -> General)
- - If you use the static version of the libusb library, make sure that
- 'Runtime Library' is set to 'Multi-threaded DLL (/MD)' (Configuration
- Properties -> C/C++ -> Code Generation).
- NB: If your application requires /MT (Multi-threaded/libCMT), you need to
- recompile a static libusb 1.0 library from source.
- - Compile and run your application. If you use the DLL version of libusb-1.0,
- remember that you need to have a copy of the DLL either in the runtime
- directory or in system32
-
-o Additional information:
- - The libusb 1.0 API documentation can be accessed at:
- http://api.libusb.info
- - For some libusb samples (including source), please have a look in examples/
- - For additional information on the libusb 1.0 Windows backend please visit:
- http://windows.libusb.info
- - It is necessary to install the CE USB Kernel Wrapper driver for libusb to
- function on a device. This is obtainable from:
- https://github.com/RealVNC/CEUSBKWrapper
- - If you find any issue, please visit http://libusb.info/ and check the
- Support section
diff --git a/.travis.yml b/.travis.yml
index f5d194a..35326e3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,49 +1,59 @@
language: c
+git:
+ depth: 1
+
matrix:
include:
- os: linux
- dist: trusty
- sudo: required
+ dist: focal
+ compiler: clang
+ - os: linux
+ dist: focal
compiler: gcc
- os: linux
- dist: trusty
- sudo: required
+ dist: bionic
compiler: clang
- - os: osx
- osx_image: xcode8
+ - os: linux
+ dist: bionic
compiler: gcc
- - os: osx
- osx_image: xcode8
+ - os: linux
+ dist: xenial
compiler: clang
- - os: osx
- osx_image: xcode7.1
+ - os: linux
+ dist: xenial
compiler: gcc
- os: osx
- osx_image: xcode7.1
+ osx_image: xcode12.2
compiler: clang
- os: osx
- osx_image: beta-xcode6.2
- compiler: gcc
+ osx_image: xcode11.3
+ compiler: clang
- os: osx
- osx_image: beta-xcode6.2
+ osx_image: xcode9.4
compiler: clang
addons:
- homebrew:
- update: true
- brewfile: true
apt:
packages:
- autoconf
- automake
- libtool
- - m4
- libudev-dev
- sources:
- - ubuntu-toolchain-r-test
+ - m4
+ homebrew:
+ packages:
+ - autoconf
+ - automake
+ - libtool
+ - m4
+ update: true
+
+before_script:
+ - ./bootstrap.sh
script:
- - ./autogen.sh && make clean && make
- - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./travis-autogen.sh --disable-udev && make clean && make ; fi
- - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cd Xcode && xcodebuild -project libusb.xcodeproj ; fi
+ - if [ "$TRAVIS_OS_NAME" = "linux" ]; then .private/ci-build.sh --build-dir build-netlink -- --disable-udev; fi
+ - if [ "$TRAVIS_OS_NAME" = "linux" ]; then .private/ci-build.sh --build-dir build-udev -- --enable-udev; fi
+ - if [ "$TRAVIS_OS_NAME" = "osx" ]; then .private/ci-build.sh --build-dir build; fi
+ - if [ "$TRAVIS_OS_NAME" = "osx" ]; then cd Xcode && xcodebuild -project libusb.xcodeproj; fi
diff --git a/AUTHORS b/AUTHORS
index e90ad9b..a366189 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -11,11 +11,18 @@ Copyright © 2012-2013 Toby Gray <toby.gray@realvnc.com>
Copyright © 2013-2018 Chris Dickens <christopher.a.dickens@gmail.com>
Other contributors:
+Aaron Luft
Adrian Bunk
+Adrien Destugues
Akshay Jaggi
Alan Ott
Alan Stern
+Aleksandr Mezin
+Alexander Pyhalov
+Alexander Schlarb
+Alexander Stein
Alex Vatchenko
+Andrew Aldridge
Andrew Fernandes
Andy Chunyu
Andy McFadden
@@ -25,18 +32,25 @@ Anthony Clay
Antonio Ospite
Artem Egorkine
Aurelien Jarno
+Axel Gembe
+Aymeric Vincent
+Baruch Siach
Bastien Nocera
Bei Zhang
+Bence Csokas
Benjamin Dobell
Brent Rector
Carl Karsten
+Chris Zhu
Christophe Zeitouny
+Chunyu Xie
Colin Walters
Dave Camarillo
David Engraf
-David Moore
Davidlohr Bueso
+David Moore
Dmitry Fleytman
+Dmitry Kostjuchenko
Doug Johnston
Evan Hunter
Federico Manzan
@@ -44,60 +58,85 @@ Felipe Balbi
Florian Albrechtskirchinger
Francesco Montorsi
Francisco Facioni
+Frank Li
+Frederik Carlier
Gaurav Gupta
Graeme Gill
+Greg Kroah-Hartman
Gustavo Zacarias
Hans Ulrich Niedermann
+Harry Mallon
Hector Martin
Hoi-Ho Chan
+Ido Yariv
+Igor Anokhin
+Ihor Dutchak
Ilya Konstantinov
Jakub Klama
James Hanko
Jeffrey Nichols
+Jie Zhang
Johann Richard
+John Keeping
John Sheu
+Jonas Malaco
Jonathon Jongsma
Joost Muller
Josh Gao
Joshua Blake
+Joshua Hou
+Juan Cruz Viotti
Justin Bischoff
-KIMURA Masaru
Karsten Koenig
+Kenjiro Tsuji
+KIMURA Masaru
Konrad Rzepecki
Kuangye Guo
Lars Kanis
Lars Wirzenius
Lei Chen
+Léo Lam
Luca Longinotti
Marcus Meissner
Markus Heidelberg
Martin Ettl
Martin Koegler
+Martin Thierer
Matthew Stapleton
Matthias Bolte
Michel Zou
Mike Frysinger
Mikhail Gusarov
+Mikolaj Kucharski
Morgan Leborgne
Moritz Fischer
-Ларионов Даниил
+Nia Alarie
Nicholas Corgan
Omri Iluz
Orin Eman
+Patrick Stewart
Paul Fertser
+Paul Qureshi
Pekka Nikander
+Philémon Favrod
+Pino Toscano
Rob Walker
Romain Vimont
Roman Kalashnikov
+Saleem Rashid
Sameeh Jubran
Sean McBride
Sebastian Pipping
+Sebastian von Ohr
Sergey Serb
Simon Haggett
Simon Newton
+Slash Gordon
Stefan Agner
Stefan Tauner
Steinar H. Gunderson
+Stephen Groat
+Theo Buehler
Thomas Röfer
Tim Hutt
Tim Roberts
@@ -106,14 +145,25 @@ Toby Peterson
Tormod Volden
Trygve Laugstøl
Uri Lublin
+Uwe Bonnes
Vasily Khoruzhick
Vegard Storheil Eriksen
Venkatesh Shukla
Vianney le Clément de Saint-Marcq
Victor Toso
+Vinicius Tinti
Vitali Lovich
+Vladimir Beloborodov
+William Orr
William Skellenger
Xiaofan Chen
+Zhiqiang Liu
Zoltán Kovács
+Сергей Валерьевич
+Ларионов Даниил
Роман Донченко
+liangyunwang
parafin
+RipleyTom
+saur0n
+winterrace
diff --git a/Android.bp b/Android.bp
index 74c3e9c..8a0ef0c 100644
--- a/Android.bp
+++ b/Android.bp
@@ -28,8 +28,8 @@ cc_library {
target: {
linux: {
srcs: [
+ "libusb/os/events_posix.c",
"libusb/os/linux_usbfs.c",
- "libusb/os/poll_posix.c",
"libusb/os/threads_posix.c",
"libusb/os/linux_netlink.c",
],
@@ -45,8 +45,8 @@ cc_library {
darwin: {
srcs: [
+ "libusb/os/events_posix.c",
"libusb/os/darwin_usb.c",
- "libusb/os/poll_posix.c",
"libusb/os/threads_posix.c",
],
@@ -83,9 +83,9 @@ cc_library {
windows: {
srcs: [
- "libusb/os/poll_windows.c",
+ "libusb/os/events_windows.c",
"libusb/os/threads_windows.c",
- "libusb/os/windows_nt_common.c",
+ "libusb/os/windows_common.c",
"libusb/os/windows_usbdk.c",
"libusb/os/windows_winusb.c",
],
diff --git a/Brewfile b/Brewfile
deleted file mode 100644
index c028148..0000000
--- a/Brewfile
+++ /dev/null
@@ -1,4 +0,0 @@
-brew 'automake'
-brew 'libtool'
-brew 'autoconf'
-brew 'm4'
diff --git a/ChangeLog b/ChangeLog
index 0999d07..df47bd5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,30 @@
For detailed information about the changes below, please see the git log or
visit: http://log.libusb.info
+2020-12-09: v1.0.24
+* Add new platform abstraction (#252)
+* Add Null POSIX backend
+* Add support for eventfd
+* Add support for thread IDs on Haiku, NetBSD and Solaris
+* New API libusb_hotplug_get_user_data()
+* Darwin (macOS): Fix race condition that results in segmentation fault (#701)
+* Darwin (macOS): Fix stale descriptor information post reset (#733)
+* Darwin (macOS): use IOUSBDevice as darwin_device_class explicitly (#693)
+* Linux: Drop support for kernel older than 2.6.32
+* Linux: Provide an event thread name (#689)
+* Linux: Wait until all USBs have been reaped before freeing them (#607)
+* NetBSD: Recognize device timeouts (#710)
+* OpenBSD: Allow opening ugen devices multiple times (#763)
+* OpenBSD: Support libusb_get_port_number() (#764)
+* SunOS: Fix a memory leak (#756)
+* SunOS: Various fixes (#627, #628, #629)
+* Windows: Add Visual Studio 2019 support
+* Windows: Drop support for WinCE and Visual Studio older than 2013
+* Windows: Drop support for Windows XP
+* Windows: Support building all examples using Visual Studio (#151)
+* Documentation fixes and improvements
+* Various other bug fixes and improvements
+
2019-08-28: v1.0.23
* Add German translation (#446)
* Add Hungarian translation (#493)
@@ -22,7 +46,7 @@ visit: http://log.libusb.info
* Windows: Add support for isochronous transfers with WinUSB
* Various other bug fixes and improvements
-2018-03-24: v1.0.22:
+2018-03-24: v1.0.22
* New libusb_set_option() API
* Fix transfer timeout not being cleared upon resubmission
* Report super speed plus devices on modern Linux and macOS
@@ -40,7 +64,7 @@ visit: http://log.libusb.info
* Windows: Support cancelation of individual transfers (Vista and later)
* Various other bug fixes and improvements
-2016-10-01: v1.0.21:
+2016-10-01: v1.0.21
* Core: Refactor code related to transfer flags and timeout handling
* Darwin: Ignore root hub simulation devices
* Darwin: Improved support for OS X El Capitan
diff --git a/INSTALL_WIN.txt b/INSTALL_WIN.txt
index 9376dd5..3ee364d 100644
--- a/INSTALL_WIN.txt
+++ b/INSTALL_WIN.txt
@@ -1,73 +1,51 @@
Installation Instructions for Windows
*************************************
-If you are compiling for MinGW or cygwin, please refer to the INSTALL file.
+If you are compiling for MinGW or cygwin, please refer to the INSTALL file,
+which is automatically generated by autotools (e.g. running bootstrap.sh).
If you are using Microsoft Visual Studio:
- Open the relevant solution file in /msvc:
- libusb.dsw for MSVC6, libusb_2005.sln for Visual Studio 2005 or 2008,
- libusb_2010.sln for Visual Studio 2010,
- libusb_2012.sln for Visual Studio 2012 or later,
- libusb_wince.sln for Windows CE support in Visual Studio 2005.
+ libusb_2013.sln for Visual Studio 2013,
+ libusb_2015.sln for Visual Studio 2015,
+ libusb_2017.sln for Visual Studio 2017,
+ libusb_2019.sln for Visual Studio 2019 or later.
- If you want to debug the library, uncomment the ENABLE_DEBUG_LOGGING define
in msvc\config.h
- Select your configuration and compile the project
-Note that if you are using Visual Studio Express, you may have to install the
-Windows SDK to be able to compile the 64 bit version of the library.
+Installing and building libusb via vcpkg
+****************************************
-If you are using the freely available Windows DDK/WDK (Driver Development Kit)
-- If you want to debug the library, uncomment the ENABLE_DEBUG_LOGGING define
- in msvc\config.h
-- Open one of the relevant Free Build or Checked Build prompt for your target
- platform
-- Navigate to the msvc\ directory where the ddk_build.cmd file is located, and
- run 'ddk_build'
-- To produce a DLL rather than a static library, use: 'ddk_build DLL'
-- To produce a static library that uses LIBCMT[d] instead of MSVCRT[d] (/MT[d]
- vs /MD[d] in Visual Studio) use: 'ddk_build /MT'
+You can download and install libusb using the vcpkg dependency manager:
-Note that using the Windows DDK, it is possible to compile both the 32 and 64
-bit versions of the library.
+ git clone https://github.com/Microsoft/vcpkg.git
+ cd vcpkg
+ ./bootstrap-vcpkg.bat
+ ./vcpkg integrate install
+ vcpkg install libusb
-If you are building for Windows CE then you will need the Windows CE Standard 5.00 SDK.
+The libusb port in vcpkg is kept up to date by Microsoft team members and
+community contributors. If the version is out of date, please create an issue
+or pull request (https://github.com/Microsoft/vcpkg) on the vcpkg repository.
Destination directories
***********************
-The 32 bit binaries compiled either from Visual Studio or the DDK are placed in
-a Win32\ directory at the root of the library
-The 64 bit binaries are placed in an x64\ directory
-Windows CE binaries are placed in one of the following directories, depending
-on the target processor: ARMV4I, MIPSII, MIPSII_FP, MIPSIV, MIPSIV_FP, SH4 or x86.
-
+The 32-bit binaries are placed in a Win32\ directory at the root of the
+library.
+The 64-bit binaries are placed in a x64\ directory.
Troubleshooting
***************
If the compilation process complains about missing libraries, ensure that the
default library paths for your project points to the relevant directories.
-If needed, these libraries can be obtained by installing either the latest
-Windows SDK or the DDK (Links provided at the end of this file).
-
-For Windows CE it is necessary to install the CE USB Kernel Wrapper driver for
-libusb to function on a device.
+If needed, these libraries can be obtained by installing the latest Windows
+SDK.
Links
*****
Additional information related to the Windows backend:
http://windows.libusb.info
-
-Latest Windows Driver (Development) Kit (WDK):
- http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=36a2630f-5d56-43b5-b996-7633f2ec14ff
-
-Latest Microsoft Windows SDK:
- http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=c17ba869-9671-4330-a63e-1fd44e0e2505
-
-Windows CE Standard 5.00 SDK:
- http://www.microsoft.com/en-gb/download/details.aspx?id=17310
-
-Windows CE USB Kernel Wrapper Driver:
- https://github.com/RealVNC/CEUSBKWrapper
-
diff --git a/METADATA b/METADATA
index f8b4ad1..5c9b974 100644
--- a/METADATA
+++ b/METADATA
@@ -9,11 +9,11 @@ third_party {
type: GIT
value: "https://github.com/libusb/libusb"
}
- version: "v1.0.23"
+ version: "v1.0.24"
license_type: RESTRICTED
last_upgrade_date {
year: 2020
- month: 3
- day: 18
+ month: 12
+ day: 10
}
}
diff --git a/Makefile.am b/Makefile.am
index 0155625..09d7cf5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,10 +1,8 @@
AUTOMAKE_OPTIONS = dist-bzip2 no-dist-gzip
ACLOCAL_AMFLAGS = -I m4
-DISTCLEANFILES = libusb-1.0.pc
-EXTRA_DIST = TODO PORTING msvc libusb/libusb-1.0.def libusb/version_nano.h \
- examples/getopt/getopt.c examples/getopt/getopt1.c examples/getopt/getopt.h \
- android Xcode
-SUBDIRS = libusb doc
+EXTRA_DIST = INSTALL_WIN.txt PORTING doc/libusb.png \
+ android msvc Xcode
+SUBDIRS = libusb
if BUILD_EXAMPLES
SUBDIRS += examples
@@ -14,15 +12,39 @@ if BUILD_TESTS
SUBDIRS += tests
endif
-pkgconfigdir=$(libdir)/pkgconfig
-pkgconfig_DATA=libusb-1.0.pc
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libusb-1.0.pc
-.PHONY: dist-up
+# The package name is libusb-1.0, but we want the distribution
+# to be created as libusb-x.y.z instead of libusb-1.0-x.y.z
+distdir = libusb-$(VERSION)
+
+# Ensure any generated docs are cleaned out
+# We need this here because make does not recurse into doc/
+clean-local:
+ rm -rf doc/$(DOXYGEN_HTMLDIR)
+
+# Use dist-hook to accomplish the following things for the dist recipe:
+# 1) Remove the GitHub Markdown from the README file
+# 2) Remove the .gitattributes file from the msvc directory
+dist-hook:
+ chmod u+w $(distdir)/README $(distdir)/msvc
+ $(SED) -i.orig -e '/Build Status/d' $(distdir)/README
+ $(SED) -i.orig -e '/^$$/N;/^\n$$/D' $(distdir)/README
+ $(SED) -i.orig -e 's/\[\([A-Z]*\)\](\1)/\1/' $(distdir)/README
+ rm -f $(distdir)/README.orig
+ rm -f $(distdir)/msvc/.gitattributes
reldir = .release/$(distdir)
-dist-up: dist
+sfurl = frs.sourceforge.net:/home/frs/project/libusb/libusb-1.0
+.PHONY: dist-upload
+dist-upload: dist
rm -rf $(reldir)
mkdir -p $(reldir)
cp $(distdir).tar.bz2 $(reldir)
- rsync -rv $(reldir) frs.sourceforge.net:/home/frs/project/l/li/libusb/libusb-1.0/
+ if [ -z "$$SF_USER" ]; then \
+ rsync -rv $(reldir) $(sfurl); \
+ else \
+ rsync -rv $(reldir) $$SF_USER@$(sfurl); \
+ fi
rm -rf $(reldir)
diff --git a/README b/README
index 42061c0..a47b4bd 120000..100644
--- a/README
+++ b/README
@@ -1 +1,32 @@
-README.md \ No newline at end of file
+# libusb
+
+[![Build Status](https://travis-ci.org/libusb/libusb.svg?branch=master)](https://travis-ci.org/libusb/libusb)
+[![Build Status](https://ci.appveyor.com/api/projects/status/xvrfam94jii4a6lw?svg=true)](https://ci.appveyor.com/project/LudovicRousseau/libusb)
+[![Coverity Scan Build Status](https://scan.coverity.com/projects/2180/badge.svg)](https://scan.coverity.com/projects/libusb-libusb)
+
+libusb is a library for USB device access from Linux, macOS,
+Windows, OpenBSD/NetBSD, Haiku and Solaris userspace.
+It is written in C (Haiku backend in C++) and licensed under the GNU
+Lesser General Public License version 2.1 or, at your option, any later
+version (see [COPYING](COPYING)).
+
+libusb is abstracted internally in such a way that it can hopefully
+be ported to other operating systems. Please see the [PORTING](PORTING)
+file for more information.
+
+libusb homepage:
+http://libusb.info/
+
+Developers will wish to consult the API documentation:
+http://api.libusb.info
+
+Use the mailing list for questions, comments, etc:
+http://mailing-list.libusb.info
+
+- Hans de Goede <hdegoede@redhat.com>
+- Xiaofan Chen <xiaofanc@gmail.com>
+- Ludovic Rousseau <ludovic.rousseau@gmail.com>
+- Nathan Hjelm <hjelmn@cs.unm.edu>
+- Chris Dickens <christopher.a.dickens@gmail.com>
+
+(Please use the mailing list rather than mailing developers directly)
diff --git a/README.git b/README.git
index eab938c..d67d374 100644
--- a/README.git
+++ b/README.git
@@ -33,9 +33,9 @@ public account on github, if you don't have one already, and then fork a new
libusb repository under this account from https://github.com/libusb/libusb.
Then you can create a git branch for your work, that we will be able to better
-reference and test.
+reference and test.
We also suggest that, if you are planning to bring in a large development, you
try to involve the libusb community early by letting the mailing list know, as
-you may find that other people might be eager to help you out.
-See http://mailing-list.libusb.info for details on how to join the mailing list. \ No newline at end of file
+you may find that other people might be eager to help you out.
+See http://mailing-list.libusb.info for details on how to join the mailing list.
diff --git a/README.md b/README.md
index 0e7228a..100b938 100644..120000
--- a/README.md
+++ b/README.md
@@ -1,32 +1 @@
-# libusb
-
-[![Build Status](https://travis-ci.org/libusb/libusb.svg?branch=master)](https://travis-ci.org/libusb/libusb)
-[![Build status](https://ci.appveyor.com/api/projects/status/xvrfam94jii4a6lw?svg=true)](https://ci.appveyor.com/project/LudovicRousseau/libusb)
-[![Coverity Scan Build Status](https://scan.coverity.com/projects/2180/badge.svg)](https://scan.coverity.com/projects/libusb-libusb)
-
-libusb is a library for USB device access from Linux, macOS,
-Windows, OpenBSD/NetBSD and Haiku userspace.
-It is written in C (Haiku backend in C++) and licensed under the GNU
-Lesser General Public License version 2.1 or, at your option, any later
-version (see [COPYING](COPYING)).
-
-libusb is abstracted internally in such a way that it can hopefully
-be ported to other operating systems. Please see the [PORTING](PORTING)
-file for more information.
-
-libusb homepage:
-http://libusb.info/
-
-Developers will wish to consult the API documentation:
-http://api.libusb.info
-
-Use the mailing list for questions, comments, etc:
-http://mailing-list.libusb.info
-
-- Hans de Goede <hdegoede@redhat.com>
-- Xiaofan Chen <xiaofanc@gmail.com>
-- Ludovic Rousseau <ludovic.rousseau@gmail.com>
-- Nathan Hjelm <hjelmn@cs.unm.edu>
-- Chris Dickens <christopher.a.dickens@gmail.com>
-
-(Please use the mailing list rather than mailing developers directly)
+README \ No newline at end of file
diff --git a/Xcode/common.xcconfig b/Xcode/common.xcconfig
index 2c7ff3c..54e7fb2 100644
--- a/Xcode/common.xcconfig
+++ b/Xcode/common.xcconfig
@@ -17,45 +17,49 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-// libusb does not follow C99 strict aliasing rules, so disable it.
-GCC_STRICT_ALIASING = NO
-
-// Use C99 dialect.
-GCC_C_LANGUAGE_STANDARD = c99
+// Use GNU11 dialect.
+GCC_C_LANGUAGE_STANDARD = gnu11
// Don't search user paths with <> style #includes.
ALWAYS_SEARCH_USER_PATHS = NO
+// Enable weak references for Objective-C
+CLANG_ENABLE_OBJC_WEAK = YES
+
+// Compiler errors.
+GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES
+
// Compiler warnings.
GCC_WARN_64_TO_32_BIT_CONVERSION = YES
+GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES
+GCC_WARN_ABOUT_MISSING_NEWLINE = YES
+GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES
GCC_WARN_ABOUT_RETURN_TYPE = YES
-GCC_WARN_UNINITIALIZED_AUTOS = YES
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES
-GCC_WARN_SHADOW = YES
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES
-GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES
-GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES
-GCC_WARN_ABOUT_MISSING_NEWLINE = YES
+GCC_WARN_SHADOW = YES
+GCC_WARN_UNINITIALIZED_AUTOS = YES
GCC_WARN_UNKNOWN_PRAGMAS = YES
GCC_WARN_UNUSED_FUNCTION = YES
GCC_WARN_UNUSED_LABEL = YES
-GCC_WARN_UNUSED_VARIABLE = YES
GCC_WARN_UNUSED_PARAMETER = YES
-CLANG_WARN_EMPTY_BODY = YES
+GCC_WARN_UNUSED_VARIABLE = YES
+CLANG_WARN_ASSIGN_ENUM = YES
+CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES
+CLANG_WARN_BOOL_CONVERSION = YES
+CLANG_WARN_COMMA = YES
CLANG_WARN_CONSTANT_CONVERSION = YES
-CLANG_WARN_ENUM_CONVERSION = YES
-CLANG_WARN_INT_CONVERSION = YES
CLANG_WARN_DOCUMENTATION_COMMENTS = YES
-CLANG_WARN_BOOL_CONVERSION = YES
-CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES
+CLANG_WARN_EMPTY_BODY = YES
+CLANG_WARN_ENUM_CONVERSION = YES
CLANG_WARN_FLOAT_CONVERSION = YES
-CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES
CLANG_WARN_INFINITE_RECURSION = YES
-CLANG_WARN_ASSIGN_ENUM = YES
+CLANG_WARN_INT_CONVERSION = YES
+CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES
CLANG_WARN_STRICT_PROTOTYPES = YES
-CLANG_WARN_COMMA = YES
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES
// Static analyzer warnings.
+CLANG_ANALYZER_NONNULL = YES
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES
diff --git a/Xcode/config.h b/Xcode/config.h
index 14d1527..59f3463 100644
--- a/Xcode/config.h
+++ b/Xcode/config.h
@@ -1,25 +1,37 @@
/* config.h. Manually generated for Xcode. */
-/* Default visibility */
-#define DEFAULT_VISIBILITY /**/
+#include <AvailabilityMacros.h>
-/* Message logging */
+/* Define to the attribute for default visibility. */
+#define DEFAULT_VISIBILITY __attribute__ ((visibility ("default")))
+
+/* Define to 1 to enable message logging. */
#define ENABLE_LOGGING 1
-/* Define to 1 if you have the <poll.h> header file. */
-#define HAVE_POLL_H 1
+/* On 10.12 and later, use newly available clock_*() functions */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+/* Define to 1 if you have the `clock_gettime' function. */
+#define HAVE_CLOCK_GETTIME 1
+#endif
+
+/* On 10.6 and later, use newly available pthread_threadid_np() function */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
+/* Define to 1 if you have the 'pthread_threadid_np' function. */
+#define HAVE_PTHREAD_THREADID_NP 1
+#endif
+
+/* Define to 1 if the system has the type `nfds_t'. */
+#define HAVE_NFDS_T 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
-/* Darwin backend */
-#define OS_DARWIN 1
-
-/* type of second poll() argument */
-#define POLL_NFDS_TYPE nfds_t
+/* Define to 1 if compiling for a POSIX platform. */
+#define PLATFORM_POSIX 1
-/* Use POSIX Threads */
-#define THREADS_POSIX 1
+/* Define to the attribute for enabling parameter checks on printf-like
+ functions. */
+#define PRINTF_FORMAT(a, b) __attribute__ ((__format__ (__printf__, a, b)))
-/* Use GNU extensions */
+/* Enable GNU extensions. */
#define _GNU_SOURCE 1
diff --git a/Xcode/libusb.xcodeproj/project.pbxproj b/Xcode/libusb.xcodeproj/project.pbxproj
index 25dfd64..fcda7e2 100644
--- a/Xcode/libusb.xcodeproj/project.pbxproj
+++ b/Xcode/libusb.xcodeproj/project.pbxproj
@@ -13,13 +13,16 @@
buildPhases = (
);
dependencies = (
- 006AD4281C8C5BBC007F8C6A /* PBXTargetDependency */,
008FC0371628BC9A00BC5BE2 /* PBXTargetDependency */,
- 008FC0391628BC9A00BC5BE2 /* PBXTargetDependency */,
008FC03B1628BC9A00BC5BE2 /* PBXTargetDependency */,
008FC03D1628BC9A00BC5BE2 /* PBXTargetDependency */,
008FC03F1628BC9A00BC5BE2 /* PBXTargetDependency */,
+ 006AD4281C8C5BBC007F8C6A /* PBXTargetDependency */,
008FC0411628BC9A00BC5BE2 /* PBXTargetDependency */,
+ 20468D8E24329E3800650534 /* PBXTargetDependency */,
+ 008A23DE236C8619004854AA /* PBXTargetDependency */,
+ 20468D9024329E3F00650534 /* PBXTargetDependency */,
+ 008FC0391628BC9A00BC5BE2 /* PBXTargetDependency */,
);
name = all;
productName = all;
@@ -27,17 +30,17 @@
/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
- 006AD4241C8C5AAE007F8C6A /* hotplugtest.c in Sources */ = {isa = PBXBuildFile; fileRef = 006AD4231C8C5AAE007F8C6A /* hotplugtest.c */; };
006AD4251C8C5AC4007F8C6A /* hotplugtest.c in Sources */ = {isa = PBXBuildFile; fileRef = 006AD4231C8C5AAE007F8C6A /* hotplugtest.c */; };
006AD4261C8C5AD9007F8C6A /* libusb-1.0.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 008FBF311628B79300BC5BE2 /* libusb-1.0.0.dylib */; };
+ 008A23DA236C85AF004854AA /* stress.c in Sources */ = {isa = PBXBuildFile; fileRef = 008A23C6236C8445004854AA /* stress.c */; };
+ 008A23DB236C85AF004854AA /* testlib.c in Sources */ = {isa = PBXBuildFile; fileRef = 008A23CB236C849A004854AA /* testlib.c */; };
008FBF861628B7E800BC5BE2 /* core.c in Sources */ = {isa = PBXBuildFile; fileRef = 008FBF541628B7E800BC5BE2 /* core.c */; };
008FBF871628B7E800BC5BE2 /* descriptor.c in Sources */ = {isa = PBXBuildFile; fileRef = 008FBF551628B7E800BC5BE2 /* descriptor.c */; };
008FBF881628B7E800BC5BE2 /* io.c in Sources */ = {isa = PBXBuildFile; fileRef = 008FBF561628B7E800BC5BE2 /* io.c */; };
- 008FBF891628B7E800BC5BE2 /* libusb.h in Headers */ = {isa = PBXBuildFile; fileRef = 008FBF5A1628B7E800BC5BE2 /* libusb.h */; };
+ 008FBF891628B7E800BC5BE2 /* libusb.h in Headers */ = {isa = PBXBuildFile; fileRef = 008FBF5A1628B7E800BC5BE2 /* libusb.h */; settings = {ATTRIBUTES = (Public, ); }; };
008FBF901628B7E800BC5BE2 /* libusbi.h in Headers */ = {isa = PBXBuildFile; fileRef = 008FBF671628B7E800BC5BE2 /* libusbi.h */; };
008FBF921628B7E800BC5BE2 /* darwin_usb.c in Sources */ = {isa = PBXBuildFile; fileRef = 008FBF6C1628B7E800BC5BE2 /* darwin_usb.c */; };
008FBF931628B7E800BC5BE2 /* darwin_usb.h in Headers */ = {isa = PBXBuildFile; fileRef = 008FBF6D1628B7E800BC5BE2 /* darwin_usb.h */; };
- 008FBF971628B7E800BC5BE2 /* poll_posix.h in Headers */ = {isa = PBXBuildFile; fileRef = 008FBF711628B7E800BC5BE2 /* poll_posix.h */; };
008FBF9A1628B7E800BC5BE2 /* threads_posix.c in Sources */ = {isa = PBXBuildFile; fileRef = 008FBF741628B7E800BC5BE2 /* threads_posix.c */; };
008FBF9B1628B7E800BC5BE2 /* threads_posix.h in Headers */ = {isa = PBXBuildFile; fileRef = 008FBF751628B7E800BC5BE2 /* threads_posix.h */; };
008FBFA01628B7E800BC5BE2 /* sync.c in Sources */ = {isa = PBXBuildFile; fileRef = 008FBF7A1628B7E800BC5BE2 /* sync.c */; };
@@ -48,20 +51,21 @@
008FBFA91628B88000BC5BE2 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 008FBFA81628B88000BC5BE2 /* IOKit.framework */; };
008FBFAB1628B8CB00BC5BE2 /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 008FBFAA1628B8CB00BC5BE2 /* libobjc.dylib */; };
008FBFEF1628BA3500BC5BE2 /* xusb.c in Sources */ = {isa = PBXBuildFile; fileRef = 008FBFED1628BA0E00BC5BE2 /* xusb.c */; };
- 008FBFF01628BA3A00BC5BE2 /* libusb-1.0.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 008FBF311628B79300BC5BE2 /* libusb-1.0.0.dylib */; };
008FBFFF1628BB9600BC5BE2 /* dpfp.c in Sources */ = {isa = PBXBuildFile; fileRef = 008FBFD71628BA0E00BC5BE2 /* dpfp.c */; };
- 008FC0001628BBCD00BC5BE2 /* libusb-1.0.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 008FBF311628B79300BC5BE2 /* libusb-1.0.0.dylib */; };
- 008FC00F1628BBE400BC5BE2 /* dpfp_threaded.c in Sources */ = {isa = PBXBuildFile; fileRef = 008FBFDB1628BA0E00BC5BE2 /* dpfp_threaded.c */; };
- 008FC0101628BBE900BC5BE2 /* libusb-1.0.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 008FBF311628B79300BC5BE2 /* libusb-1.0.0.dylib */; };
008FC01F1628BC1500BC5BE2 /* fxload.c in Sources */ = {isa = PBXBuildFile; fileRef = 008FBFE11628BA0E00BC5BE2 /* fxload.c */; };
- 008FC0201628BC1B00BC5BE2 /* libusb-1.0.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 008FBF311628B79300BC5BE2 /* libusb-1.0.0.dylib */; };
008FC0211628BC5200BC5BE2 /* ezusb.c in Sources */ = {isa = PBXBuildFile; fileRef = 008FBFDC1628BA0E00BC5BE2 /* ezusb.c */; };
008FC0301628BC7400BC5BE2 /* listdevs.c in Sources */ = {isa = PBXBuildFile; fileRef = 008FBFE71628BA0E00BC5BE2 /* listdevs.c */; };
- 008FC0311628BC7800BC5BE2 /* libusb-1.0.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 008FBF311628B79300BC5BE2 /* libusb-1.0.0.dylib */; };
1438D77A17A2ED9F00166101 /* hotplug.c in Sources */ = {isa = PBXBuildFile; fileRef = 1438D77817A2ED9F00166101 /* hotplug.c */; };
1438D77B17A2ED9F00166101 /* hotplug.h in Headers */ = {isa = PBXBuildFile; fileRef = 1438D77917A2ED9F00166101 /* hotplug.h */; };
- 1438D77D17A2EDCD00166101 /* poll_posix.c in Sources */ = {isa = PBXBuildFile; fileRef = 1438D77C17A2EDCD00166101 /* poll_posix.c */; };
1438D77F17A2F0EA00166101 /* strerror.c in Sources */ = {isa = PBXBuildFile; fileRef = 1438D77E17A2F0EA00166101 /* strerror.c */; };
+ 2018D95F24E453BA001589B2 /* events_posix.c in Sources */ = {isa = PBXBuildFile; fileRef = 2018D95E24E453BA001589B2 /* events_posix.c */; };
+ 2018D96124E453D0001589B2 /* events_posix.h in Headers */ = {isa = PBXBuildFile; fileRef = 2018D96024E453D0001589B2 /* events_posix.h */; };
+ 20468D70243298C100650534 /* sam3u_benchmark.c in Sources */ = {isa = PBXBuildFile; fileRef = 20468D6E243298C100650534 /* sam3u_benchmark.c */; };
+ 20468D7E2432990100650534 /* testlibusb.c in Sources */ = {isa = PBXBuildFile; fileRef = 20468D7C2432990000650534 /* testlibusb.c */; };
+ 20951C0325630F5F00ED6351 /* dpfp.c in Sources */ = {isa = PBXBuildFile; fileRef = 008FBFD71628BA0E00BC5BE2 /* dpfp.c */; settings = {COMPILER_FLAGS = "-DDPFP_THREADED"; }; };
+ 20951C0625630F8F00ED6351 /* ezusb.h in Headers */ = {isa = PBXBuildFile; fileRef = 008FBFDD1628BA0E00BC5BE2 /* ezusb.h */; };
+ 20951C0F25630FD300ED6351 /* libusb_testlib.h in Headers */ = {isa = PBXBuildFile; fileRef = 008A23CA236C849A004854AA /* libusb_testlib.h */; };
+ 20951C152563125200ED6351 /* libusb.h in Headers */ = {isa = PBXBuildFile; fileRef = 008FBF5A1628B7E800BC5BE2 /* libusb.h */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -72,6 +76,13 @@
remoteGlobalIDString = 006AD41B1C8C5A90007F8C6A;
remoteInfo = hotplugtest;
};
+ 008A23DD236C8619004854AA /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 008FBF281628B79300BC5BE2 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 008A23D2236C8594004854AA;
+ remoteInfo = stress;
+ };
008FC0361628BC9A00BC5BE2 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 008FBF281628B79300BC5BE2 /* Project object */;
@@ -149,68 +160,57 @@
remoteGlobalIDString = 008FBF301628B79300BC5BE2;
remoteInfo = libusb;
};
-/* End PBXContainerItemProxy section */
-
-/* Begin PBXCopyFilesBuildPhase section */
- 006AD41A1C8C5A90007F8C6A /* CopyFiles */ = {
- isa = PBXCopyFilesBuildPhase;
- buildActionMask = 2147483647;
- dstPath = /usr/share/man/man1/;
- dstSubfolderSpec = 0;
- files = (
- );
- runOnlyForDeploymentPostprocessing = 1;
+ 20468D812432999C00650534 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 008FBF281628B79300BC5BE2 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 008FBF301628B79300BC5BE2;
+ remoteInfo = libusb;
};
- 008FBFBB1628B9FE00BC5BE2 /* CopyFiles */ = {
- isa = PBXCopyFilesBuildPhase;
- buildActionMask = 2147483647;
- dstPath = /usr/share/man/man1/;
- dstSubfolderSpec = 0;
- files = (
- );
- runOnlyForDeploymentPostprocessing = 1;
+ 20468D83243299A900650534 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 008FBF281628B79300BC5BE2 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 008FBF301628B79300BC5BE2;
+ remoteInfo = libusb;
};
- 008FBFF31628BB8B00BC5BE2 /* CopyFiles */ = {
- isa = PBXCopyFilesBuildPhase;
- buildActionMask = 2147483647;
- dstPath = /usr/share/man/man1/;
- dstSubfolderSpec = 0;
- files = (
- );
- runOnlyForDeploymentPostprocessing = 1;
+ 20468D85243299B200650534 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 008FBF281628B79300BC5BE2 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 008FBF301628B79300BC5BE2;
+ remoteInfo = libusb;
};
- 008FC0031628BBDB00BC5BE2 /* CopyFiles */ = {
- isa = PBXCopyFilesBuildPhase;
- buildActionMask = 2147483647;
- dstPath = /usr/share/man/man1/;
- dstSubfolderSpec = 0;
- files = (
- );
- runOnlyForDeploymentPostprocessing = 1;
+ 20468D87243299BA00650534 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 008FBF281628B79300BC5BE2 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 008FBF301628B79300BC5BE2;
+ remoteInfo = libusb;
};
- 008FC0131628BC0300BC5BE2 /* CopyFiles */ = {
- isa = PBXCopyFilesBuildPhase;
- buildActionMask = 2147483647;
- dstPath = /usr/share/man/man1/;
- dstSubfolderSpec = 0;
- files = (
- );
- runOnlyForDeploymentPostprocessing = 1;
+ 20468D8D24329E3800650534 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 008FBF281628B79300BC5BE2 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 20468D66243298AE00650534;
+ remoteInfo = sam3u_benchmark;
};
- 008FC0241628BC6B00BC5BE2 /* CopyFiles */ = {
- isa = PBXCopyFilesBuildPhase;
- buildActionMask = 2147483647;
- dstPath = /usr/share/man/man1/;
- dstSubfolderSpec = 0;
- files = (
- );
- runOnlyForDeploymentPostprocessing = 1;
+ 20468D8F24329E3F00650534 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 008FBF281628B79300BC5BE2 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 20468D74243298D300650534;
+ remoteInfo = testlibusb;
};
-/* End PBXCopyFilesBuildPhase section */
+/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
006AD41C1C8C5A90007F8C6A /* hotplugtest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = hotplugtest; sourceTree = BUILT_PRODUCTS_DIR; };
006AD4231C8C5AAE007F8C6A /* hotplugtest.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = hotplugtest.c; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
+ 008A23C6236C8445004854AA /* stress.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = stress.c; sourceTree = "<group>"; usesTabs = 1; };
+ 008A23CA236C849A004854AA /* libusb_testlib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libusb_testlib.h; sourceTree = "<group>"; usesTabs = 1; };
+ 008A23CB236C849A004854AA /* testlib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testlib.c; sourceTree = "<group>"; usesTabs = 1; };
+ 008A23D3236C8594004854AA /* stress */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = stress; sourceTree = BUILT_PRODUCTS_DIR; };
008FBF311628B79300BC5BE2 /* libusb-1.0.0.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = "libusb-1.0.0.dylib"; sourceTree = BUILT_PRODUCTS_DIR; };
008FBF541628B7E800BC5BE2 /* core.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = core.c; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
008FBF551628B7E800BC5BE2 /* descriptor.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = descriptor.c; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
@@ -219,7 +219,6 @@
008FBF671628B7E800BC5BE2 /* libusbi.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = libusbi.h; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
008FBF6C1628B7E800BC5BE2 /* darwin_usb.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.c; path = darwin_usb.c; sourceTree = "<group>"; tabWidth = 2; usesTabs = 0; };
008FBF6D1628B7E800BC5BE2 /* darwin_usb.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; path = darwin_usb.h; sourceTree = "<group>"; tabWidth = 2; usesTabs = 0; };
- 008FBF711628B7E800BC5BE2 /* poll_posix.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = poll_posix.h; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
008FBF741628B7E800BC5BE2 /* threads_posix.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = threads_posix.c; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
008FBF751628B7E800BC5BE2 /* threads_posix.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = threads_posix.h; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
008FBF7A1628B7E800BC5BE2 /* sync.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = sync.c; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
@@ -230,20 +229,18 @@
008FBFA81628B88000BC5BE2 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; };
008FBFAA1628B8CB00BC5BE2 /* libobjc.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libobjc.dylib; path = usr/lib/libobjc.dylib; sourceTree = SDKROOT; };
008FBFBD1628B9FE00BC5BE2 /* xusb */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = xusb; sourceTree = BUILT_PRODUCTS_DIR; };
- 008FBFD71628BA0E00BC5BE2 /* dpfp.c */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = dpfp.c; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
- 008FBFDB1628BA0E00BC5BE2 /* dpfp_threaded.c */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = dpfp_threaded.c; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
- 008FBFDC1628BA0E00BC5BE2 /* ezusb.c */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = ezusb.c; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
- 008FBFDD1628BA0E00BC5BE2 /* ezusb.h */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = ezusb.h; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
- 008FBFE11628BA0E00BC5BE2 /* fxload.c */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = fxload.c; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
- 008FBFE71628BA0E00BC5BE2 /* listdevs.c */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = listdevs.c; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
- 008FBFED1628BA0E00BC5BE2 /* xusb.c */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = xusb.c; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
+ 008FBFD71628BA0E00BC5BE2 /* dpfp.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = dpfp.c; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
+ 008FBFDC1628BA0E00BC5BE2 /* ezusb.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = ezusb.c; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
+ 008FBFDD1628BA0E00BC5BE2 /* ezusb.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = ezusb.h; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
+ 008FBFE11628BA0E00BC5BE2 /* fxload.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = fxload.c; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
+ 008FBFE71628BA0E00BC5BE2 /* listdevs.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = listdevs.c; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
+ 008FBFED1628BA0E00BC5BE2 /* xusb.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = xusb.c; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
008FBFF51628BB8B00BC5BE2 /* dpfp */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = dpfp; sourceTree = BUILT_PRODUCTS_DIR; };
008FC0051628BBDB00BC5BE2 /* dpfp_threaded */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = dpfp_threaded; sourceTree = BUILT_PRODUCTS_DIR; };
008FC0151628BC0300BC5BE2 /* fxload */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = fxload; sourceTree = BUILT_PRODUCTS_DIR; };
008FC0261628BC6B00BC5BE2 /* listdevs */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = listdevs; sourceTree = BUILT_PRODUCTS_DIR; };
1438D77817A2ED9F00166101 /* hotplug.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = hotplug.c; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
1438D77917A2ED9F00166101 /* hotplug.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = hotplug.h; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
- 1438D77C17A2EDCD00166101 /* poll_posix.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = poll_posix.c; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
1438D77E17A2F0EA00166101 /* strerror.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.c; path = strerror.c; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
1443EE8416417E63007E0579 /* common.xcconfig */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = text.xcconfig; path = common.xcconfig; sourceTree = SOURCE_ROOT; tabWidth = 4; usesTabs = 1; };
1443EE8516417E63007E0579 /* debug.xcconfig */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = text.xcconfig; path = debug.xcconfig; sourceTree = SOURCE_ROOT; tabWidth = 4; usesTabs = 1; };
@@ -251,6 +248,12 @@
1443EE8716417E63007E0579 /* libusb.xcconfig */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = text.xcconfig; path = libusb.xcconfig; sourceTree = SOURCE_ROOT; tabWidth = 4; usesTabs = 1; };
1443EE8816417E63007E0579 /* release.xcconfig */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = text.xcconfig; path = release.xcconfig; sourceTree = SOURCE_ROOT; tabWidth = 4; usesTabs = 1; };
1443EE8916417EA6007E0579 /* libusb_release.xcconfig */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = text.xcconfig; path = libusb_release.xcconfig; sourceTree = SOURCE_ROOT; tabWidth = 4; usesTabs = 1; };
+ 2018D95E24E453BA001589B2 /* events_posix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = events_posix.c; sourceTree = "<group>"; };
+ 2018D96024E453D0001589B2 /* events_posix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = events_posix.h; sourceTree = "<group>"; };
+ 20468D67243298AE00650534 /* sam3u_benchmark */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = sam3u_benchmark; sourceTree = BUILT_PRODUCTS_DIR; };
+ 20468D6E243298C100650534 /* sam3u_benchmark.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sam3u_benchmark.c; sourceTree = "<group>"; usesTabs = 1; };
+ 20468D75243298D300650534 /* testlibusb */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testlibusb; sourceTree = BUILT_PRODUCTS_DIR; };
+ 20468D7C2432990000650534 /* testlibusb.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testlibusb.c; sourceTree = "<group>"; usesTabs = 1; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -262,6 +265,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 008A23D0236C8594004854AA /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 006AD4261C8C5AD9007F8C6A /* libusb-1.0.0.dylib in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
008FBF2E1628B79300BC5BE2 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@@ -276,7 +287,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
- 008FBFF01628BA3A00BC5BE2 /* libusb-1.0.0.dylib in Frameworks */,
+ 006AD4261C8C5AD9007F8C6A /* libusb-1.0.0.dylib in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -284,7 +295,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
- 008FC0001628BBCD00BC5BE2 /* libusb-1.0.0.dylib in Frameworks */,
+ 006AD4261C8C5AD9007F8C6A /* libusb-1.0.0.dylib in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -292,7 +303,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
- 008FC0101628BBE900BC5BE2 /* libusb-1.0.0.dylib in Frameworks */,
+ 006AD4261C8C5AD9007F8C6A /* libusb-1.0.0.dylib in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -300,7 +311,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
- 008FC0201628BC1B00BC5BE2 /* libusb-1.0.0.dylib in Frameworks */,
+ 006AD4261C8C5AD9007F8C6A /* libusb-1.0.0.dylib in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -308,13 +319,40 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
- 008FC0311628BC7800BC5BE2 /* libusb-1.0.0.dylib in Frameworks */,
+ 006AD4261C8C5AD9007F8C6A /* libusb-1.0.0.dylib in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 20468D64243298AE00650534 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 006AD4261C8C5AD9007F8C6A /* libusb-1.0.0.dylib in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 20468D72243298D300650534 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 006AD4261C8C5AD9007F8C6A /* libusb-1.0.0.dylib in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
+ 001B1F09236C836000F231DC /* tests */ = {
+ isa = PBXGroup;
+ children = (
+ 008A23CA236C849A004854AA /* libusb_testlib.h */,
+ 008A23C6236C8445004854AA /* stress.c */,
+ 008A23CB236C849A004854AA /* testlib.c */,
+ );
+ name = tests;
+ path = ../tests;
+ sourceTree = "<group>";
+ };
008FBF261628B79300BC5BE2 = {
isa = PBXGroup;
children = (
@@ -322,6 +360,7 @@
008FBFA41628B84200BC5BE2 /* config.h */,
008FBF3B1628B7E800BC5BE2 /* libusb */,
008FBFC81628BA0E00BC5BE2 /* examples */,
+ 001B1F09236C836000F231DC /* tests */,
1443EE8A16419057007E0579 /* Apple */,
008FBF321628B79300BC5BE2 /* Products */,
);
@@ -331,12 +370,15 @@
isa = PBXGroup;
children = (
008FBF311628B79300BC5BE2 /* libusb-1.0.0.dylib */,
- 008FBFBD1628B9FE00BC5BE2 /* xusb */,
008FBFF51628BB8B00BC5BE2 /* dpfp */,
008FC0051628BBDB00BC5BE2 /* dpfp_threaded */,
008FC0151628BC0300BC5BE2 /* fxload */,
008FC0261628BC6B00BC5BE2 /* listdevs */,
006AD41C1C8C5A90007F8C6A /* hotplugtest */,
+ 008A23D3236C8594004854AA /* stress */,
+ 20468D67243298AE00650534 /* sam3u_benchmark */,
+ 20468D75243298D300650534 /* testlibusb */,
+ 008FBFBD1628B9FE00BC5BE2 /* xusb */,
);
name = Products;
sourceTree = "<group>";
@@ -366,8 +408,8 @@
children = (
008FBF6C1628B7E800BC5BE2 /* darwin_usb.c */,
008FBF6D1628B7E800BC5BE2 /* darwin_usb.h */,
- 1438D77C17A2EDCD00166101 /* poll_posix.c */,
- 008FBF711628B7E800BC5BE2 /* poll_posix.h */,
+ 2018D95E24E453BA001589B2 /* events_posix.c */,
+ 2018D96024E453D0001589B2 /* events_posix.h */,
008FBF741628B7E800BC5BE2 /* threads_posix.c */,
008FBF751628B7E800BC5BE2 /* threads_posix.h */,
);
@@ -377,13 +419,14 @@
008FBFC81628BA0E00BC5BE2 /* examples */ = {
isa = PBXGroup;
children = (
- 008FBFDB1628BA0E00BC5BE2 /* dpfp_threaded.c */,
008FBFD71628BA0E00BC5BE2 /* dpfp.c */,
008FBFDC1628BA0E00BC5BE2 /* ezusb.c */,
008FBFDD1628BA0E00BC5BE2 /* ezusb.h */,
008FBFE11628BA0E00BC5BE2 /* fxload.c */,
006AD4231C8C5AAE007F8C6A /* hotplugtest.c */,
008FBFE71628BA0E00BC5BE2 /* listdevs.c */,
+ 20468D6E243298C100650534 /* sam3u_benchmark.c */,
+ 20468D7C2432990000650534 /* testlibusb.c */,
008FBFED1628BA0E00BC5BE2 /* xusb.c */,
);
name = examples;
@@ -423,14 +466,97 @@
buildActionMask = 2147483647;
files = (
008FBF891628B7E800BC5BE2 /* libusb.h in Headers */,
- 008FBF901628B7E800BC5BE2 /* libusbi.h in Headers */,
+ 008FBFA51628B84200BC5BE2 /* config.h in Headers */,
008FBF931628B7E800BC5BE2 /* darwin_usb.h in Headers */,
- 008FBF971628B7E800BC5BE2 /* poll_posix.h in Headers */,
+ 2018D96124E453D0001589B2 /* events_posix.h in Headers */,
+ 1438D77B17A2ED9F00166101 /* hotplug.h in Headers */,
+ 008FBF901628B7E800BC5BE2 /* libusbi.h in Headers */,
008FBF9B1628B7E800BC5BE2 /* threads_posix.h in Headers */,
008FBFA11628B7E800BC5BE2 /* version.h in Headers */,
008FBFA21628B7E800BC5BE2 /* version_nano.h in Headers */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 20951BFF25630EBE00ED6351 /* Headers */ = {
+ isa = PBXHeadersBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
008FBFA51628B84200BC5BE2 /* config.h in Headers */,
- 1438D77B17A2ED9F00166101 /* hotplug.h in Headers */,
+ 20951C152563125200ED6351 /* libusb.h in Headers */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 20951C0125630F4100ED6351 /* Headers */ = {
+ isa = PBXHeadersBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 008FBFA51628B84200BC5BE2 /* config.h in Headers */,
+ 20951C152563125200ED6351 /* libusb.h in Headers */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 20951C0425630F7600ED6351 /* Headers */ = {
+ isa = PBXHeadersBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 008FBFA51628B84200BC5BE2 /* config.h in Headers */,
+ 20951C0625630F8F00ED6351 /* ezusb.h in Headers */,
+ 20951C152563125200ED6351 /* libusb.h in Headers */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 20951C0725630F9D00ED6351 /* Headers */ = {
+ isa = PBXHeadersBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 008FBFA51628B84200BC5BE2 /* config.h in Headers */,
+ 20951C152563125200ED6351 /* libusb.h in Headers */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 20951C0925630FA900ED6351 /* Headers */ = {
+ isa = PBXHeadersBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 008FBFA51628B84200BC5BE2 /* config.h in Headers */,
+ 20951C152563125200ED6351 /* libusb.h in Headers */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 20951C0B25630FB400ED6351 /* Headers */ = {
+ isa = PBXHeadersBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 008FBFA51628B84200BC5BE2 /* config.h in Headers */,
+ 20951C152563125200ED6351 /* libusb.h in Headers */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 20951C0D25630FC000ED6351 /* Headers */ = {
+ isa = PBXHeadersBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 008FBFA51628B84200BC5BE2 /* config.h in Headers */,
+ 20951C0F25630FD300ED6351 /* libusb_testlib.h in Headers */,
+ 20951C152563125200ED6351 /* libusb.h in Headers */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 20951C1025630FE300ED6351 /* Headers */ = {
+ isa = PBXHeadersBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 008FBFA51628B84200BC5BE2 /* config.h in Headers */,
+ 20951C152563125200ED6351 /* libusb.h in Headers */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 20951C1225630FEE00ED6351 /* Headers */ = {
+ isa = PBXHeadersBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 008FBFA51628B84200BC5BE2 /* config.h in Headers */,
+ 20951C152563125200ED6351 /* libusb.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -441,26 +567,45 @@
isa = PBXNativeTarget;
buildConfigurationList = 006AD4221C8C5A90007F8C6A /* Build configuration list for PBXNativeTarget "hotplugtest" */;
buildPhases = (
+ 20951C0725630F9D00ED6351 /* Headers */,
006AD4181C8C5A90007F8C6A /* Sources */,
006AD4191C8C5A90007F8C6A /* Frameworks */,
- 006AD41A1C8C5A90007F8C6A /* CopyFiles */,
);
buildRules = (
);
dependencies = (
+ 20468D822432999C00650534 /* PBXTargetDependency */,
);
name = hotplugtest;
productName = hotplugtest;
productReference = 006AD41C1C8C5A90007F8C6A /* hotplugtest */;
productType = "com.apple.product-type.tool";
};
+ 008A23D2236C8594004854AA /* stress */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 008A23D7236C8594004854AA /* Build configuration list for PBXNativeTarget "stress" */;
+ buildPhases = (
+ 20951C0D25630FC000ED6351 /* Headers */,
+ 008A23CF236C8594004854AA /* Sources */,
+ 008A23D0236C8594004854AA /* Frameworks */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ 20468D86243299B200650534 /* PBXTargetDependency */,
+ );
+ name = stress;
+ productName = stress;
+ productReference = 008A23D3236C8594004854AA /* stress */;
+ productType = "com.apple.product-type.tool";
+ };
008FBF301628B79300BC5BE2 /* libusb */ = {
isa = PBXNativeTarget;
buildConfigurationList = 008FBF351628B79300BC5BE2 /* Build configuration list for PBXNativeTarget "libusb" */;
buildPhases = (
+ 008FBF2F1628B79300BC5BE2 /* Headers */,
008FBF2D1628B79300BC5BE2 /* Sources */,
008FBF2E1628B79300BC5BE2 /* Frameworks */,
- 008FBF2F1628B79300BC5BE2 /* Headers */,
);
buildRules = (
);
@@ -475,9 +620,9 @@
isa = PBXNativeTarget;
buildConfigurationList = 008FBFC61628B9FE00BC5BE2 /* Build configuration list for PBXNativeTarget "xusb" */;
buildPhases = (
+ 20951C1225630FEE00ED6351 /* Headers */,
008FBFB91628B9FE00BC5BE2 /* Sources */,
008FBFBA1628B9FE00BC5BE2 /* Frameworks */,
- 008FBFBB1628B9FE00BC5BE2 /* CopyFiles */,
);
buildRules = (
);
@@ -493,9 +638,9 @@
isa = PBXNativeTarget;
buildConfigurationList = 008FBFFC1628BB8C00BC5BE2 /* Build configuration list for PBXNativeTarget "dpfp" */;
buildPhases = (
+ 20951BFF25630EBE00ED6351 /* Headers */,
008FBFF11628BB8B00BC5BE2 /* Sources */,
008FBFF21628BB8B00BC5BE2 /* Frameworks */,
- 008FBFF31628BB8B00BC5BE2 /* CopyFiles */,
);
buildRules = (
);
@@ -511,9 +656,9 @@
isa = PBXNativeTarget;
buildConfigurationList = 008FC00C1628BBDB00BC5BE2 /* Build configuration list for PBXNativeTarget "dpfp_threaded" */;
buildPhases = (
+ 20951C0125630F4100ED6351 /* Headers */,
008FC0011628BBDB00BC5BE2 /* Sources */,
008FC0021628BBDB00BC5BE2 /* Frameworks */,
- 008FC0031628BBDB00BC5BE2 /* CopyFiles */,
);
buildRules = (
);
@@ -529,9 +674,9 @@
isa = PBXNativeTarget;
buildConfigurationList = 008FC01C1628BC0300BC5BE2 /* Build configuration list for PBXNativeTarget "fxload" */;
buildPhases = (
+ 20951C0425630F7600ED6351 /* Headers */,
008FC0111628BC0300BC5BE2 /* Sources */,
008FC0121628BC0300BC5BE2 /* Frameworks */,
- 008FC0131628BC0300BC5BE2 /* CopyFiles */,
);
buildRules = (
);
@@ -547,9 +692,9 @@
isa = PBXNativeTarget;
buildConfigurationList = 008FC02D1628BC6B00BC5BE2 /* Build configuration list for PBXNativeTarget "listdevs" */;
buildPhases = (
+ 20951C0925630FA900ED6351 /* Headers */,
008FC0221628BC6B00BC5BE2 /* Sources */,
008FC0231628BC6B00BC5BE2 /* Frameworks */,
- 008FC0241628BC6B00BC5BE2 /* CopyFiles */,
);
buildRules = (
);
@@ -561,26 +706,72 @@
productReference = 008FC0261628BC6B00BC5BE2 /* listdevs */;
productType = "com.apple.product-type.tool";
};
+ 20468D66243298AE00650534 /* sam3u_benchmark */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 20468D6B243298AE00650534 /* Build configuration list for PBXNativeTarget "sam3u_benchmark" */;
+ buildPhases = (
+ 20951C0B25630FB400ED6351 /* Headers */,
+ 20468D63243298AE00650534 /* Sources */,
+ 20468D64243298AE00650534 /* Frameworks */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ 20468D84243299A900650534 /* PBXTargetDependency */,
+ );
+ name = sam3u_benchmark;
+ productName = sam3u_benchmark;
+ productReference = 20468D67243298AE00650534 /* sam3u_benchmark */;
+ productType = "com.apple.product-type.tool";
+ };
+ 20468D74243298D300650534 /* testlibusb */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 20468D79243298D300650534 /* Build configuration list for PBXNativeTarget "testlibusb" */;
+ buildPhases = (
+ 20951C1025630FE300ED6351 /* Headers */,
+ 20468D71243298D300650534 /* Sources */,
+ 20468D72243298D300650534 /* Frameworks */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ 20468D88243299BA00650534 /* PBXTargetDependency */,
+ );
+ name = testlibusb;
+ productName = testlibusb;
+ productReference = 20468D75243298D300650534 /* testlibusb */;
+ productType = "com.apple.product-type.tool";
+ };
/* End PBXNativeTarget section */
/* Begin PBXProject section */
008FBF281628B79300BC5BE2 /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 0450;
+ LastUpgradeCheck = 1120;
ORGANIZATIONNAME = libusb;
TargetAttributes = {
006AD41B1C8C5A90007F8C6A = {
CreatedOnToolsVersion = 7.2.1;
};
+ 008A23D2236C8594004854AA = {
+ CreatedOnToolsVersion = 11.2;
+ };
+ 20468D66243298AE00650534 = {
+ CreatedOnToolsVersion = 10.1;
+ };
+ 20468D74243298D300650534 = {
+ CreatedOnToolsVersion = 10.1;
+ };
};
};
buildConfigurationList = 008FBF2B1628B79300BC5BE2 /* Build configuration list for PBXProject "libusb" */;
compatibilityVersion = "Xcode 3.1";
- developmentRegion = English;
+ developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
+ Base,
);
mainGroup = 008FBF261628B79300BC5BE2;
productRefGroup = 008FBF321628B79300BC5BE2 /* Products */;
@@ -588,12 +779,15 @@
projectRoot = "";
targets = (
008FBF301628B79300BC5BE2 /* libusb */,
- 008FBFBC1628B9FE00BC5BE2 /* xusb */,
008FBFF41628BB8B00BC5BE2 /* dpfp */,
008FC0041628BBDB00BC5BE2 /* dpfp_threaded */,
008FC0141628BC0300BC5BE2 /* fxload */,
- 008FC0251628BC6B00BC5BE2 /* listdevs */,
006AD41B1C8C5A90007F8C6A /* hotplugtest */,
+ 008FC0251628BC6B00BC5BE2 /* listdevs */,
+ 20468D66243298AE00650534 /* sam3u_benchmark */,
+ 008A23D2236C8594004854AA /* stress */,
+ 20468D74243298D300650534 /* testlibusb */,
+ 008FBFBC1628B9FE00BC5BE2 /* xusb */,
008FC0321628BC9400BC5BE2 /* all */,
);
};
@@ -608,20 +802,28 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 008A23CF236C8594004854AA /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 008A23DA236C85AF004854AA /* stress.c in Sources */,
+ 008A23DB236C85AF004854AA /* testlib.c in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
008FBF2D1628B79300BC5BE2 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
008FBF861628B7E800BC5BE2 /* core.c in Sources */,
- 008FBF871628B7E800BC5BE2 /* descriptor.c in Sources */,
- 008FBF881628B7E800BC5BE2 /* io.c in Sources */,
008FBF921628B7E800BC5BE2 /* darwin_usb.c in Sources */,
- 008FBF9A1628B7E800BC5BE2 /* threads_posix.c in Sources */,
- 008FBFA01628B7E800BC5BE2 /* sync.c in Sources */,
+ 008FBF871628B7E800BC5BE2 /* descriptor.c in Sources */,
+ 2018D95F24E453BA001589B2 /* events_posix.c in Sources */,
1438D77A17A2ED9F00166101 /* hotplug.c in Sources */,
- 1438D77D17A2EDCD00166101 /* poll_posix.c in Sources */,
+ 008FBF881628B7E800BC5BE2 /* io.c in Sources */,
1438D77F17A2F0EA00166101 /* strerror.c in Sources */,
- 006AD4241C8C5AAE007F8C6A /* hotplugtest.c in Sources */,
+ 008FBFA01628B7E800BC5BE2 /* sync.c in Sources */,
+ 008FBF9A1628B7E800BC5BE2 /* threads_posix.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -645,7 +847,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 008FC00F1628BBE400BC5BE2 /* dpfp_threaded.c in Sources */,
+ 20951C0325630F5F00ED6351 /* dpfp.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -666,6 +868,22 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 20468D63243298AE00650534 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 20468D70243298C100650534 /* sam3u_benchmark.c in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 20468D71243298D300650534 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 20468D7E2432990100650534 /* testlibusb.c in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
@@ -674,6 +892,11 @@
target = 006AD41B1C8C5A90007F8C6A /* hotplugtest */;
targetProxy = 006AD4271C8C5BBC007F8C6A /* PBXContainerItemProxy */;
};
+ 008A23DE236C8619004854AA /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 008A23D2236C8594004854AA /* stress */;
+ targetProxy = 008A23DD236C8619004854AA /* PBXContainerItemProxy */;
+ };
008FC0371628BC9A00BC5BE2 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 008FBF301628B79300BC5BE2 /* libusb */;
@@ -729,6 +952,36 @@
target = 008FBF301628B79300BC5BE2 /* libusb */;
targetProxy = 1443EE931641927D007E0579 /* PBXContainerItemProxy */;
};
+ 20468D822432999C00650534 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 008FBF301628B79300BC5BE2 /* libusb */;
+ targetProxy = 20468D812432999C00650534 /* PBXContainerItemProxy */;
+ };
+ 20468D84243299A900650534 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 008FBF301628B79300BC5BE2 /* libusb */;
+ targetProxy = 20468D83243299A900650534 /* PBXContainerItemProxy */;
+ };
+ 20468D86243299B200650534 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 008FBF301628B79300BC5BE2 /* libusb */;
+ targetProxy = 20468D85243299B200650534 /* PBXContainerItemProxy */;
+ };
+ 20468D88243299BA00650534 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 008FBF301628B79300BC5BE2 /* libusb */;
+ targetProxy = 20468D87243299BA00650534 /* PBXContainerItemProxy */;
+ };
+ 20468D8E24329E3800650534 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 20468D66243298AE00650534 /* sam3u_benchmark */;
+ targetProxy = 20468D8D24329E3800650534 /* PBXContainerItemProxy */;
+ };
+ 20468D9024329E3F00650534 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 20468D74243298D300650534 /* testlibusb */;
+ targetProxy = 20468D8F24329E3F00650534 /* PBXContainerItemProxy */;
+ };
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
@@ -736,6 +989,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 1443EE8516417E63007E0579 /* debug.xcconfig */;
buildSettings = {
+ CODE_SIGN_IDENTITY = "-";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
@@ -744,6 +998,25 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 1443EE8816417E63007E0579 /* release.xcconfig */;
buildSettings = {
+ CODE_SIGN_IDENTITY = "-";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Release;
+ };
+ 008A23D8236C8594004854AA /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 1443EE8516417E63007E0579 /* debug.xcconfig */;
+ buildSettings = {
+ CODE_SIGN_IDENTITY = "-";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Debug;
+ };
+ 008A23D9236C8594004854AA /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 1443EE8816417E63007E0579 /* release.xcconfig */;
+ buildSettings = {
+ CODE_SIGN_IDENTITY = "-";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
@@ -752,6 +1025,18 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 1443EE8516417E63007E0579 /* debug.xcconfig */;
buildSettings = {
+ CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ ONLY_ACTIVE_ARCH = YES;
};
name = Debug;
};
@@ -759,6 +1044,16 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 1443EE8816417E63007E0579 /* release.xcconfig */;
buildSettings = {
+ CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
};
name = Release;
};
@@ -766,6 +1061,10 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 1443EE8616417E63007E0579 /* libusb_debug.xcconfig */;
buildSettings = {
+ OTHER_CFLAGS = (
+ "-fvisibility=hidden",
+ "-pthread",
+ );
};
name = Debug;
};
@@ -773,6 +1072,10 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 1443EE8916417EA6007E0579 /* libusb_release.xcconfig */;
buildSettings = {
+ OTHER_CFLAGS = (
+ "-fvisibility=hidden",
+ "-pthread",
+ );
};
name = Release;
};
@@ -780,6 +1083,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 1443EE8516417E63007E0579 /* debug.xcconfig */;
buildSettings = {
+ CODE_SIGN_IDENTITY = "-";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
@@ -788,6 +1092,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 1443EE8816417E63007E0579 /* release.xcconfig */;
buildSettings = {
+ CODE_SIGN_IDENTITY = "-";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
@@ -796,6 +1101,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 1443EE8516417E63007E0579 /* debug.xcconfig */;
buildSettings = {
+ CODE_SIGN_IDENTITY = "-";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
@@ -804,6 +1110,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 1443EE8816417E63007E0579 /* release.xcconfig */;
buildSettings = {
+ CODE_SIGN_IDENTITY = "-";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
@@ -812,6 +1119,8 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 1443EE8516417E63007E0579 /* debug.xcconfig */;
buildSettings = {
+ CODE_SIGN_IDENTITY = "-";
+ OTHER_CFLAGS = "-pthread";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
@@ -820,6 +1129,8 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 1443EE8816417E63007E0579 /* release.xcconfig */;
buildSettings = {
+ CODE_SIGN_IDENTITY = "-";
+ OTHER_CFLAGS = "-pthread";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
@@ -828,6 +1139,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 1443EE8516417E63007E0579 /* debug.xcconfig */;
buildSettings = {
+ CODE_SIGN_IDENTITY = "-";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
@@ -836,6 +1148,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 1443EE8816417E63007E0579 /* release.xcconfig */;
buildSettings = {
+ CODE_SIGN_IDENTITY = "-";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
@@ -844,6 +1157,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 1443EE8516417E63007E0579 /* debug.xcconfig */;
buildSettings = {
+ CODE_SIGN_IDENTITY = "-";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
@@ -852,6 +1166,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 1443EE8816417E63007E0579 /* release.xcconfig */;
buildSettings = {
+ CODE_SIGN_IDENTITY = "-";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
@@ -859,13 +1174,47 @@
008FC0341628BC9400BC5BE2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
008FC0351628BC9400BC5BE2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ };
+ name = Release;
+ };
+ 20468D6C243298AE00650534 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 1443EE8516417E63007E0579 /* debug.xcconfig */;
+ buildSettings = {
+ CODE_SIGN_IDENTITY = "-";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Debug;
+ };
+ 20468D6D243298AE00650534 /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 1443EE8816417E63007E0579 /* release.xcconfig */;
+ buildSettings = {
+ CODE_SIGN_IDENTITY = "-";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Release;
+ };
+ 20468D7A243298D300650534 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 1443EE8516417E63007E0579 /* debug.xcconfig */;
+ buildSettings = {
+ CODE_SIGN_IDENTITY = "-";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Debug;
+ };
+ 20468D7B243298D300650534 /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 1443EE8816417E63007E0579 /* release.xcconfig */;
+ buildSettings = {
+ CODE_SIGN_IDENTITY = "-";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
@@ -880,6 +1229,16 @@
006AD4211C8C5A90007F8C6A /* Release */,
);
defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 008A23D7236C8594004854AA /* Build configuration list for PBXNativeTarget "stress" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 008A23D8236C8594004854AA /* Debug */,
+ 008A23D9236C8594004854AA /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
};
008FBF2B1628B79300BC5BE2 /* Build configuration list for PBXProject "libusb" */ = {
isa = XCConfigurationList;
@@ -953,6 +1312,24 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
+ 20468D6B243298AE00650534 /* Build configuration list for PBXNativeTarget "sam3u_benchmark" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 20468D6C243298AE00650534 /* Debug */,
+ 20468D6D243298AE00650534 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 20468D79243298D300650534 /* Build configuration list for PBXNativeTarget "testlibusb" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 20468D7A243298D300650534 /* Debug */,
+ 20468D7B243298D300650534 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
/* End XCConfigurationList section */
};
rootObject = 008FBF281628B79300BC5BE2 /* Project object */;
diff --git a/android/config.h b/android/config.h
index 0dd35e2..1092f65 100644
--- a/android/config.h
+++ b/android/config.h
@@ -17,59 +17,39 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-/* Start with debug message logging enabled */
-/* #undef ENABLE_DEBUG_LOGGING */
-
-/* Message logging */
-#define ENABLE_LOGGING
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#define HAVE_DLFCN_H 1
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
+/* Define to the attribute for default visibility. */
+#define DEFAULT_VISIBILITY __attribute__ ((visibility ("default")))
-/* Linux backend */
-#define OS_LINUX 1
-
-/* Enable output to system log */
-#define USE_SYSTEM_LOGGING_FACILITY 1
-
-/* type of second poll() argument */
-#define POLL_NFDS_TYPE nfds_t
+/* Define to 1 to start with debug message logging enabled. */
+/* #undef ENABLE_DEBUG_LOGGING */
-/* Use POSIX Threads */
-#define THREADS_POSIX 1
+/* Define to 1 to enable message logging. */
+#define ENABLE_LOGGING 1
-/* Default visibility */
-#define DEFAULT_VISIBILITY __attribute__((visibility("default")))
+/* Define to 1 if you have the <asm/types.h> header file. */
+#define HAVE_ASM_TYPES_H 1
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
+/* Define to 1 if you have the `clock_gettime' function. */
+#define HAVE_CLOCK_GETTIME 1
-/* Define to 1 if you have the <poll.h> header file. */
-#define HAVE_POLL_H 1
+/* Define to 1 if the system has the type `nfds_t'. */
+#define HAVE_NFDS_T 1
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
+/* Define to 1 if you have the `pipe2' function. */
+#define HAVE_PIPE2 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define to 1 if you have the <linux/filter.h> header file. */
-#define HAVE_LINUX_FILTER_H 1
+/* Define to 1 if compiling for a POSIX platform. */
+#define PLATFORM_POSIX 1
-/* Define to 1 if you have the <linux/netlink.h> header file. */
-#define HAVE_LINUX_NETLINK_H 1
+/* Define to the attribute for enabling parameter checks on printf-like
+ functions. */
+#define PRINTF_FORMAT(a, b) __attribute__ ((__format__ (__printf__, a, b)))
-/* Define to 1 if you have the <asm/types.h> header file. */
-#define HAVE_ASM_TYPES_H 1
+/* Define to 1 to output logging messages to the systemwide log. */
+#define USE_SYSTEM_LOGGING_FACILITY 1
-/* Define to 1 if you have the <sys/socket.h> header file. */
-#define HAVE_SYS_SOCKET_H 1
+/* Enable GNU extensions. */
+#define _GNU_SOURCE 1
diff --git a/android/jni/Android.mk b/android/jni/Android.mk
index 6a32b50..29146b2 100644
--- a/android/jni/Android.mk
+++ b/android/jni/Android.mk
@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
-LOCAL_PATH:= $(call my-dir)
+LOCAL_PATH := $(call my-dir)
include $(LOCAL_PATH)/libusb.mk
include $(LOCAL_PATH)/examples.mk
diff --git a/android/jni/Application.mk b/android/jni/Application.mk
index f972a9e..c113726 100644
--- a/android/jni/Application.mk
+++ b/android/jni/Application.mk
@@ -18,6 +18,22 @@
APP_ABI := all
+APP_CFLAGS := \
+ -std=gnu11 \
+ -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
+
# Workaround for MIPS toolchain linker being unable to find liblog dependency
# of shared object in NDK versions at least up to r9.
#
diff --git a/android/jni/examples.mk b/android/jni/examples.mk
index 05609cc..30b5c84 100644
--- a/android/jni/examples.mk
+++ b/android/jni/examples.mk
@@ -16,119 +16,128 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
-LOCAL_PATH:= $(call my-dir)
-LIBUSB_ROOT_REL:= ../..
-LIBUSB_ROOT_ABS:= $(LOCAL_PATH)/../..
+LOCAL_PATH := $(call my-dir)
+LIBUSB_ROOT_REL := ../..
+LIBUSB_ROOT_ABS := $(LOCAL_PATH)/../..
-# listdevs
+# dpfp
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- $(LIBUSB_ROOT_REL)/examples/listdevs.c
+ $(LIBUSB_ROOT_REL)/examples/dpfp.c
LOCAL_C_INCLUDES += \
+ $(LOCAL_PATH)/.. \
$(LIBUSB_ROOT_ABS)
LOCAL_SHARED_LIBRARIES += libusb1.0
-LOCAL_MODULE:= listdevs
+LOCAL_MODULE := dpfp
include $(BUILD_EXECUTABLE)
-# xusb
+# dpfp_threaded
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- $(LIBUSB_ROOT_REL)/examples/xusb.c
+ $(LIBUSB_ROOT_REL)/examples/dpfp.c
LOCAL_C_INCLUDES += \
+ $(LOCAL_PATH)/.. \
$(LIBUSB_ROOT_ABS)
+LOCAL_CFLAGS := -DDPFP_THREADED -pthread
+
LOCAL_SHARED_LIBRARIES += libusb1.0
-LOCAL_MODULE:= xusb
+LOCAL_MODULE := dpfp_threaded
include $(BUILD_EXECUTABLE)
-# hotplugtest
+# fxload
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- $(LIBUSB_ROOT_REL)/examples/hotplugtest.c
+ $(LIBUSB_ROOT_REL)/examples/ezusb.c \
+ $(LIBUSB_ROOT_REL)/examples/fxload.c
LOCAL_C_INCLUDES += \
+ $(LOCAL_PATH)/.. \
$(LIBUSB_ROOT_ABS)
LOCAL_SHARED_LIBRARIES += libusb1.0
-LOCAL_MODULE:= hotplugtest
+LOCAL_MODULE := fxload
include $(BUILD_EXECUTABLE)
-# fxload
+# hotplugtest
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- $(LIBUSB_ROOT_REL)/examples/fxload.c \
- $(LIBUSB_ROOT_REL)/examples/ezusb.c
+ $(LIBUSB_ROOT_REL)/examples/hotplugtest.c
LOCAL_C_INCLUDES += \
+ $(LOCAL_PATH)/.. \
$(LIBUSB_ROOT_ABS)
LOCAL_SHARED_LIBRARIES += libusb1.0
-LOCAL_MODULE:= fxload
+LOCAL_MODULE := hotplugtest
include $(BUILD_EXECUTABLE)
-# sam3u_benchmake
+# listdevs
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- $(LIBUSB_ROOT_REL)/examples/sam3u_benchmark.c
+ $(LIBUSB_ROOT_REL)/examples/listdevs.c
LOCAL_C_INCLUDES += \
+ $(LOCAL_PATH)/.. \
$(LIBUSB_ROOT_ABS)
LOCAL_SHARED_LIBRARIES += libusb1.0
-LOCAL_MODULE:= sam3u_benchmark
+LOCAL_MODULE := listdevs
include $(BUILD_EXECUTABLE)
-# dpfp
+# sam3u_benchmark
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- $(LIBUSB_ROOT_REL)/examples/dpfp.c
+ $(LIBUSB_ROOT_REL)/examples/sam3u_benchmark.c
LOCAL_C_INCLUDES += \
+ $(LOCAL_PATH)/.. \
$(LIBUSB_ROOT_ABS)
LOCAL_SHARED_LIBRARIES += libusb1.0
-LOCAL_MODULE:= dpfp
+LOCAL_MODULE := sam3u_benchmark
include $(BUILD_EXECUTABLE)
-# dpfp_threaded
+# xusb
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- $(LIBUSB_ROOT_REL)/examples/dpfp_threaded.c
+ $(LIBUSB_ROOT_REL)/examples/xusb.c
LOCAL_C_INCLUDES += \
+ $(LOCAL_PATH)/.. \
$(LIBUSB_ROOT_ABS)
LOCAL_SHARED_LIBRARIES += libusb1.0
-LOCAL_MODULE:= dpfp_threaded
+LOCAL_MODULE := xusb
include $(BUILD_EXECUTABLE)
diff --git a/android/jni/libusb.mk b/android/jni/libusb.mk
index f4896b2..dacf1ee 100644
--- a/android/jni/libusb.mk
+++ b/android/jni/libusb.mk
@@ -16,17 +16,14 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
-LOCAL_PATH:= $(call my-dir)
-LIBUSB_ROOT_REL:= ../..
-LIBUSB_ROOT_ABS:= $(LOCAL_PATH)/../..
+LOCAL_PATH := $(call my-dir)
+LIBUSB_ROOT_REL := ../..
+LIBUSB_ROOT_ABS := $(LOCAL_PATH)/../..
# libusb
include $(CLEAR_VARS)
-LIBUSB_ROOT_REL:= ../..
-LIBUSB_ROOT_ABS:= $(LOCAL_PATH)/../..
-
LOCAL_SRC_FILES := \
$(LIBUSB_ROOT_REL)/libusb/core.c \
$(LIBUSB_ROOT_REL)/libusb/descriptor.c \
@@ -35,7 +32,7 @@ LOCAL_SRC_FILES := \
$(LIBUSB_ROOT_REL)/libusb/sync.c \
$(LIBUSB_ROOT_REL)/libusb/strerror.c \
$(LIBUSB_ROOT_REL)/libusb/os/linux_usbfs.c \
- $(LIBUSB_ROOT_REL)/libusb/os/poll_posix.c \
+ $(LIBUSB_ROOT_REL)/libusb/os/events_posix.c \
$(LIBUSB_ROOT_REL)/libusb/os/threads_posix.c \
$(LIBUSB_ROOT_REL)/libusb/os/linux_netlink.c
@@ -47,6 +44,8 @@ LOCAL_C_INCLUDES += \
LOCAL_EXPORT_C_INCLUDES := \
$(LIBUSB_ROOT_ABS)/libusb
+LOCAL_CFLAGS := -fvisibility=hidden -pthread
+
LOCAL_LDLIBS := -llog
LOCAL_MODULE := libusb1.0
diff --git a/android/jni/tests.mk b/android/jni/tests.mk
index 93d5516..b42bd1c 100644
--- a/android/jni/tests.mk
+++ b/android/jni/tests.mk
@@ -16,41 +16,24 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
-LOCAL_PATH:= $(call my-dir)
-LIBUSB_ROOT_REL:= ../..
-LIBUSB_ROOT_ABS:= $(LOCAL_PATH)/../..
-
-# testlib
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- $(LIBUSB_ROOT_REL)/tests/testlib.c
-
-LOCAL_C_INCLUDES += \
- $(LIBUSB_ROOT_ABS)/tests
-
-LOCAL_EXPORT_C_INCLUDES := \
- $(LIBUSB_ROOT_ABS)/tests
-
-LOCAL_MODULE := testlib
-
-include $(BUILD_STATIC_LIBRARY)
-
+LOCAL_PATH := $(call my-dir)
+LIBUSB_ROOT_REL := ../..
+LIBUSB_ROOT_ABS := $(LOCAL_PATH)/../..
# stress
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- $(LIBUSB_ROOT_REL)/tests/stress.c
+ $(LIBUSB_ROOT_REL)/tests/stress.c \
+ $(LIBUSB_ROOT_REL)/tests/testlib.c
LOCAL_C_INCLUDES += \
+ $(LOCAL_PATH)/.. \
$(LIBUSB_ROOT_ABS)
LOCAL_SHARED_LIBRARIES += libusb1.0
-LOCAL_STATIC_LIBRARIES += testlib
-LOCAL_MODULE:= stress
+LOCAL_MODULE := stress
include $(BUILD_EXECUTABLE)
diff --git a/appveyor.yml b/appveyor.yml
index 0e6113e..36cfa96 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,41 +1,72 @@
version: 1.0.{build}
-configuration:
-- Debug
-- Release
+image:
+ - Visual Studio 2013
+ - Visual Studio 2015
+ - Visual Studio 2017
+ - Visual Studio 2019
platform:
-- x64
-- Win32
+ - Win32
+ - x64
+configuration:
+ - Debug
+ - Release
+clone_depth: 1
build:
- project: msvc\libusb_2013.sln
parallel: true
- verbosity: detailed
-environment:
- matrix:
- - libusb_2015: msvc\libusb_2015.sln
- libusb_2013: msvc\libusb_2013.sln
- libusb_2012: msvc\libusb_2012.sln
- libusb_2010: msvc\libusb_2010.sln
-install:
-
-- cmd: >-
- rem Copying libusb to cygwin home directory
-
- xcopy /S C:\projects\libusb C:\cygwin\home\appveyor\
-
- rem Copying libusb to MinGW home directory
-
- xcopy /S C:\projects\libusb C:\msys64\home\appveyor\
-
-build_script:
-- cmd: >-
- msbuild %libusb_2015% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
+for:
+ -
+ matrix:
+ only:
+ - image: Visual Studio 2013
+ build:
+ project: msvc\libusb_2013.sln
- msbuild %libusb_2013% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
+ -
+ matrix:
+ only:
+ - image: Visual Studio 2015
+ configuration: Debug
+ build:
+ project: msvc\libusb_2015.sln
- msbuild %libusb_2012% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
+ -
+ matrix:
+ only:
+ - image: Visual Studio 2015
+ platform: Win32
+ configuration: Release
+ install:
+ - cmd: xcopy /S /I "%APPVEYOR_BUILD_FOLDER%" C:\msys64\home\appveyor\libusb
+ - cmd: xcopy /S /I "%APPVEYOR_BUILD_FOLDER%" C:\cygwin\home\appveyor\libusb
+ build_script:
+ - cmd: msbuild "%APPVEYOR_BUILD_FOLDER%\msvc\libusb_2015.sln" /m /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
+ - cmd: C:\msys64\usr\bin\bash -l "%APPVEYOR_BUILD_FOLDER%\.private\appveyor_build.sh" MinGW
+ - cmd: C:\cygwin\bin\bash -l "%APPVEYOR_BUILD_FOLDER%\.private\appveyor_build.sh" cygwin
- msvc/appveyor.bat
+ -
+ matrix:
+ only:
+ - image: Visual Studio 2015
+ platform: x64
+ configuration: Release
+ install:
+ - cmd: xcopy /S /I "%APPVEYOR_BUILD_FOLDER%" C:\msys64\home\appveyor\libusb
+ - cmd: xcopy /S /I "%APPVEYOR_BUILD_FOLDER%" C:\cygwin64\home\appveyor\libusb
+ build_script:
+ - cmd: msbuild "%APPVEYOR_BUILD_FOLDER%\msvc\libusb_2015.sln" /m /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
+ - cmd: C:\msys64\usr\bin\bash -l "%APPVEYOR_BUILD_FOLDER%\.private\appveyor_build.sh" MinGW
+ - cmd: C:\cygwin64\bin\bash -l "%APPVEYOR_BUILD_FOLDER%\.private\appveyor_build.sh" cygwin
- appveyor_minGW.bat
+ -
+ matrix:
+ only:
+ - image: Visual Studio 2017
+ build:
+ project: msvc\libusb_2017.sln
- appveyor_cygwin.bat
+ -
+ matrix:
+ only:
+ - image: Visual Studio 2019
+ build:
+ project: msvc\libusb_2019.sln
diff --git a/appveyor_cygwin.bat b/appveyor_cygwin.bat
deleted file mode 100644
index a6fed52..0000000
--- a/appveyor_cygwin.bat
+++ /dev/null
@@ -1,11 +0,0 @@
-echo on
-SetLocal EnableDelayedExpansion
-
-if [%Configuration%] NEQ [Release] exit 0
-if [%Platform%] NEQ [Win32] exit 0
-
-C:\cygwin\bin\bash -e -l -c "./bootstrap.sh" || exit /B
-C:\cygwin\bin\bash -e -l -c "mkdir build-Win32-cygwin" || exit /B
-C:\cygwin\bin\bash -e -l -c "cd build-Win32-cygwin && ../configure --enable-examples-build --enable-tests-build" || exit /B
-C:\cygwin\bin\bash -e -l -c "cd build-Win32-cygwin && make -j4" || exit /B
-C:\cygwin\bin\bash -e -l -c "cd build-Win32-cygwin && make install" || exit /B
diff --git a/appveyor_minGW.bat b/appveyor_minGW.bat
deleted file mode 100644
index bdb4750..0000000
--- a/appveyor_minGW.bat
+++ /dev/null
@@ -1,19 +0,0 @@
-echo on
-SetLocal EnableDelayedExpansion
-
-if [%Configuration%] NEQ [Release] exit 0
-
-if [%Platform%] NEQ [x64] goto Win32
-C:\msys64\usr\bin\bash -e -l -c "./bootstrap.sh" || exit /B
-C:\msys64\usr\bin\bash -e -l -c "mkdir build-x64" || exit /B
-C:\msys64\usr\bin\bash -e -l -c "cd build-x64 && ../configure --prefix=/mingw64 --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32" || exit /B
-C:\msys64\usr\bin\bash -e -l -c "cd build-x64 && make -j4" || exit /B
-C:\msys64\usr\bin\bash -e -l -c "cd build-x64 && make install" || exit /B
-
-:Win32
-if [%Platform%] NEQ [Win32] exit 0
-C:\msys64\usr\bin\bash -e -l -c "./bootstrap.sh" || exit /B
-C:\msys64\usr\bin\bash -e -l -c "mkdir build-Win32" || exit /B
-C:\msys64\usr\bin\bash -e -l -c "cd build-Win32 && ../configure --prefix=/mingw32 --build=i686-w64-mingw32 --host=i686-w64-mingw32" || exit /B
-C:\msys64\usr\bin\bash -e -l -c "cd build-Win32 && make -j4" || exit /B
-C:\msys64\usr\bin\bash -e -l -c "cd build-Win32 && make install" || exit /B
diff --git a/autogen.sh b/autogen.sh
index 24f39ee..62d68e5 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -3,6 +3,6 @@
set -e
./bootstrap.sh
-if test -z "$NOCONFIGURE"; then
+if [ -z "$NOCONFIGURE" ]; then
exec ./configure --enable-examples-build --enable-tests-build "$@"
fi
diff --git a/bootstrap.sh b/bootstrap.sh
index dc56539..cfd2b45 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -1,6 +1,8 @@
#!/bin/sh
-if ! test -d m4 ; then
+set -e
+
+if [ ! -d m4 ]; then
mkdir m4
fi
-autoreconf -ivf || exit 1
+exec autoreconf -ivf
diff --git a/configure.ac b/configure.ac
index da8a158..5b880f6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,312 +15,365 @@ LU_DEFINE_VERSION_ATOM([LIBUSB_MINOR])
LU_DEFINE_VERSION_ATOM([LIBUSB_MICRO])
LU_DEFINE_VERSION_RC_ATOM([LIBUSB_RC])
-AC_INIT([libusb],[LIBUSB_MAJOR[.]LIBUSB_MINOR[.]LIBUSB_MICRO[]LIBUSB_RC],[libusb-devel@lists.sourceforge.net],[libusb],[http://libusb.info])
-
-# Library versioning
-# These numbers should be tweaked on every release. Read carefully:
-# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
-# http://sourceware.org/autobook/autobook/autobook_91.html
-lt_current=2
-lt_revision=0
-lt_age=2
-LTLDFLAGS="-version-info ${lt_current}:${lt_revision}:${lt_age}"
-
-AM_INIT_AUTOMAKE
-
+AC_PREREQ([2.69])
+AC_INIT([libusb-1.0], [LIBUSB_MAJOR[.]LIBUSB_MINOR[.]LIBUSB_MICRO[]LIBUSB_RC], [libusb-devel@lists.sourceforge.net], [libusb-1.0], [http://libusb.info])
+AC_CONFIG_HEADERS([config.h])
AC_CONFIG_SRCDIR([libusb/core.c])
AC_CONFIG_MACRO_DIR([m4])
-AC_CONFIG_HEADERS([config.h])
-m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
-
-AC_PREREQ([2.69])
AC_PROG_CC
AC_PROG_CXX
+AC_C_INLINE
+AM_INIT_AUTOMAKE
LT_INIT
LT_LANG([Windows Resource])
-AC_C_INLINE
-AM_PROG_CC_C_O
-AC_DEFINE([_GNU_SOURCE], 1, [Use GNU extensions])
-LTLDFLAGS="${LTLDFLAGS} -no-undefined"
+dnl Library versioning
+dnl These numbers should be tweaked on every release. Read carefully:
+dnl http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
+dnl http://sourceware.org/autobook/autobook/autobook_91.html
+lt_current=3
+lt_revision=0
+lt_age=3
+LT_LDFLAGS="-version-info ${lt_current}:${lt_revision}:${lt_age} -no-undefined"
-AC_MSG_CHECKING([operating system])
+m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
-dnl on linux-android platform, some functions are in different places
-case $host in
-*-linux-android*)
- AC_MSG_RESULT([This is a Linux-Android system])
- is_backend_android=yes
- ;;
-*)
- is_backend_android=no
-esac
+EXTRA_CPPFLAGS=
+EXTRA_CFLAGS=
+
+dnl check for -std=gnu11 compiler support (optional)
+dnl note that we don't just check if the compiler accepts '-std=x11'
+dnl but also that it supports the _Thread_local keyword because some compilers
+dnl (e.g. gcc 4.8) accept the command line option but do not implement TLS
+saved_CFLAGS="${CFLAGS}"
+CFLAGS="-std=gnu11"
+AC_MSG_CHECKING([if $CC supports -std=gnu11])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_Thread_local int x;], [x = 42;])],
+ [AC_MSG_RESULT([yes])
+ c_dialect=gnu],
+ [AC_MSG_RESULT([no])
+ c_dialect=])
+if test "x$c_dialect" != xgnu; then
+ dnl fallback check for -std=c11 compiler support (required)
+ CFLAGS="-std=c11"
+ AC_MSG_CHECKING([if $CC supports -std=c11])
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_Thread_local int x;], [x = 42;])],
+ [AC_MSG_RESULT([yes])],
+ [AC_MSG_RESULT([no])
+ AC_MSG_ERROR([compiler with C11 support is required to build libusb])])
+ c_dialect=c
+fi
+CFLAGS="${saved_CFLAGS}"
+
+AC_DEFINE([_GNU_SOURCE], [1], [Enable GNU extensions.])
+AC_DEFINE([DEFAULT_VISIBILITY], [__attribute__ ((visibility ("default")))], [Define to the attribute for default visibility.])
+AC_DEFINE([PRINTF_FORMAT(a, b)], [__attribute__ ((__format__ (__printf__, a, b)))], [Define to the attribute for enabling parameter checks on printf-like functions.])
+create_import_lib=
+is_android_linux=
+AC_MSG_CHECKING([operating system])
case $host in
-*-linux* | *-uclinux*)
- AC_MSG_RESULT([Linux])
- backend=linux
- threads=posix
- ;;
*-darwin*)
AC_MSG_RESULT([Darwin/Mac OS X])
backend=darwin
- threads=posix
+ platform=posix
;;
-*-openbsd*)
- AC_MSG_RESULT([OpenBSD])
- backend=openbsd
- threads=posix
+*-haiku*)
+ AC_MSG_RESULT([Haiku])
+ backend=haiku
+ platform=posix
+ ;;
+*-linux* | *-uclinux*)
+ dnl on Android Linux, some functions are in different places
+ case $host in
+ *-linux-android*)
+ AC_MSG_RESULT([Android Linux])
+ is_android_linux=yes
+ ;;
+ *)
+ AC_MSG_RESULT([Linux])
+ ;;
+ esac
+ backend=linux
+ platform=posix
;;
*-netbsd*)
AC_MSG_RESULT([NetBSD])
backend=netbsd
- threads=posix
+ platform=posix
;;
-*-mingw* | *msys*)
- AC_MSG_RESULT([Windows])
- backend=windows
- threads=windows
- create_import_lib=yes
- AM_CFLAGS="${AM_CFLAGS} -fno-omit-frame-pointer"
- ;;
-*-cygwin*)
- AC_MSG_RESULT([Cygwin (using Windows backend)])
- backend=windows
- threads=posix
- ;;
-*-haiku*)
- AC_MSG_RESULT([Haiku])
- backend=haiku
- threads=posix
+*-openbsd*)
+ AC_MSG_RESULT([OpenBSD])
+ backend=openbsd
+ platform=posix
;;
*-solaris*)
AC_MSG_RESULT([SunOS])
backend=sunos
- threads=posix
+ platform=posix
+ ;;
+*-cygwin*)
+ AC_MSG_RESULT([Windows (using Cygwin)])
+ backend=windows
+ platform=windows
+ EXTRA_CFLAGS="-mwin32"
+ ;;
+*-mingw* | *msys*)
+ AC_MSG_RESULT([Windows])
+ backend=windows
+ platform=windows
+ test "x$enable_shared" = xyes && create_import_lib=yes
+ EXTRA_CFLAGS="-mwin32 -fno-omit-frame-pointer"
;;
*)
- AC_MSG_ERROR([unsupported operating system $host])
+ AC_MSG_RESULT([Null])
+ AC_MSG_WARN([The host being compiled for is not supported.])
+ AC_MSG_WARN([The library may compile but will not function in any useful manner.])
+ backend=null
+ platform=posix
+ ;;
esac
+if test "x$platform" = xposix; then
+ AC_DEFINE([PLATFORM_POSIX], [1], [Define to 1 if compiling for a POSIX platform.])
+ AC_CHECK_TYPES([nfds_t], [], [], [[#include <poll.h>]])
+ AC_CHECK_FUNCS([pipe2])
+ dnl Some compilers do not support the '-pthread' option so check for it here
+ saved_CFLAGS="${CFLAGS}"
+ CFLAGS="-Wall -Werror -pthread"
+ AC_MSG_CHECKING([if $CC recognizes -pthread])
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
+ [AC_MSG_RESULT([yes])
+ AC_SUBST(THREAD_CFLAGS, [-pthread])],
+ [AC_MSG_RESULT([no])])
+ CFLAGS="${saved_CFLAGS}"
+ dnl Android Linux and Darwin provide pthread functions directly in libc
+ dnl glibc also provides some pthread functions directly, so search for a thread-specific function
+ AC_SEARCH_LIBS([pthread_create], [pthread],
+ [test "x$ac_cv_search_pthread_create" != "xnone required" && AC_SUBST(THREAD_LIBS, [-lpthread])],
+ [], [])
+elif test "x$platform" = xwindows; then
+ AC_DEFINE([PLATFORM_WINDOWS], [1], [Define to 1 if compiling for a Windows platform.])
+else
+ AC_MSG_ERROR([Unknown platform])
+fi
+
case $backend in
+darwin)
+ AC_CHECK_FUNCS([pthread_threadid_np])
+ LIBS="${LIBS} -lobjc -Wl,-framework,IOKit -Wl,-framework,CoreFoundation"
+ ;;
+haiku)
+ LIBS="${LIBS} -lbe"
+ ;;
linux)
- AC_DEFINE(OS_LINUX, 1, [Linux backend])
- AC_SUBST(OS_LINUX)
- AC_SEARCH_LIBS([clock_gettime], [rt], [], [], [-pthread])
+ AC_SEARCH_LIBS([clock_gettime], [rt], [], [], [])
+ AC_CHECK_FUNCS([pthread_setname_np])
AC_ARG_ENABLE([udev],
[AC_HELP_STRING([--enable-udev], [use udev for device enumeration and hotplug support (recommended) [default=yes]])],
- [], [enable_udev=yes])
- if test "x$enable_udev" = xyes ; then
- # system has udev. use it or fail!
- AC_CHECK_HEADERS([libudev.h], [], [AC_MSG_ERROR([udev support requested but libudev header not installed])])
- AC_CHECK_LIB([udev], [udev_new], [], [AC_MSG_ERROR([udev support requested but libudev not installed])])
- AC_DEFINE(USE_UDEV, 1, [Use udev for device enumeration/hotplug])
- else
- AC_CHECK_HEADERS([asm/types.h], [], [])
- AC_CHECK_HEADERS([sys/socket.h linux/netlink.h], [], [AC_MSG_ERROR([Linux netlink headers not found])], [
-#ifdef HAVE_ASM_TYPES_H
-#include <asm/types.h>
-#endif
-#include <sys/socket.h>
-])
- fi
- AC_SUBST(USE_UDEV)
-
- if test "x$is_backend_android" != xyes; then
- THREAD_CFLAGS="-pthread"
- LIBS="${LIBS} -pthread"
+ [use_udev=$enableval], [use_udev=yes])
+ if test "x$use_udev" = xyes; then
+ dnl system has udev. use it or fail!
+ AC_CHECK_HEADER([libudev.h], [], [AC_MSG_ERROR([udev support requested but libudev header not installed])])
+ AC_CHECK_LIB([udev], [udev_new], [], [AC_MSG_ERROR([udev support requested but libudev not installed])])
+ else
+ AC_CHECK_HEADERS([asm/types.h])
+ AC_CHECK_HEADER([linux/netlink.h], [], [AC_MSG_ERROR([Linux netlink header not found])])
+ AC_CHECK_HEADER([sys/socket.h], [], [AC_MSG_ERROR([Linux socket header not found])])
fi
-
- AC_CHECK_HEADERS([poll.h])
- AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
- ;;
-darwin)
- AC_DEFINE(OS_DARWIN, 1, [Darwin backend])
- AC_SUBST(OS_DARWIN)
- LIBS="-lobjc -Wl,-framework,IOKit -Wl,-framework,CoreFoundation"
- LTLDFLAGS="${LTLDFLAGS} -Wl,-prebind"
- AC_CHECK_HEADERS([poll.h])
- AC_CHECK_TYPE([nfds_t],
- [AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])],
- [AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[type of second poll() argument])],
- [#include <poll.h>])
- ;;
-openbsd)
- AC_DEFINE(OS_OPENBSD, 1, [OpenBSD backend])
- AC_SUBST(OS_OPENBSD)
- THREAD_CFLAGS="-pthread"
- LIBS="-pthread"
- AC_CHECK_HEADERS([poll.h])
- AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
;;
sunos)
- AC_DEFINE(OS_SUNOS, 1, [SunOS backend])
- AC_SUBST(OS_SUNOS)
- THREAD_CFLAGS="-pthread"
- LIBS="-pthread -ldevinfo"
- AC_CHECK_HEADERS([poll.h])
- AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
- ;;
-netbsd)
- AC_DEFINE(OS_NETBSD, 1, [NetBSD backend])
- AC_SUBST(OS_NETBSD)
- THREAD_CFLAGS="-pthread"
- LIBS="-pthread"
- AC_CHECK_HEADERS([poll.h])
- AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
+ LIBS="${LIBS} -ldevinfo"
;;
windows)
- AC_DEFINE(OS_WINDOWS, 1, [Windows backend])
- AC_SUBST(OS_WINDOWS)
- LIBS=""
- LTLDFLAGS="${LTLDFLAGS} -avoid-version -Wl,--add-stdcall-alias"
- AC_DEFINE([POLL_NFDS_TYPE],[unsigned int],[type of second poll() argument])
- AC_DEFINE([WINVER], 0x0501, [Oldest Windows version supported])
- AC_DEFINE([_WIN32_WINNT], 0x0501, [Oldest Windows version supported])
+ AC_CHECK_TYPES([struct timespec], [], [], [[#include <time.h>]])
+ AC_DEFINE([_WIN32_WINNT], [_WIN32_WINNT_VISTA], [Define to the oldest supported Windows version.])
+ LT_LDFLAGS="${LT_LDFLAGS} -avoid-version -Wl,--add-stdcall-alias"
;;
-haiku)
- AC_DEFINE(OS_HAIKU, 1, [Haiku backend])
- AC_SUBST(OS_HAIKU)
- LIBS="${LIBS} -lbe"
- AC_CHECK_HEADERS([poll.h])
- AC_DEFINE([POLL_NFDS_TYPE],[nfds_t],[type of second poll() argument])
+*)
+ dnl no special handling required
;;
esac
-AC_SUBST(LIBS)
-
-AM_CONDITIONAL(OS_LINUX, test "x$backend" = xlinux)
-AM_CONDITIONAL(OS_DARWIN, test "x$backend" = xdarwin)
-AM_CONDITIONAL(OS_OPENBSD, test "x$backend" = xopenbsd)
-AM_CONDITIONAL(OS_SUNOS, test "x$backend" = xsunos)
-AM_CONDITIONAL(OS_NETBSD, test "x$backend" = xnetbsd)
-AM_CONDITIONAL(OS_WINDOWS, test "x$backend" = xwindows)
-AM_CONDITIONAL(OS_HAIKU, test "x$backend" = xhaiku)
-AM_CONDITIONAL(THREADS_POSIX, test "x$threads" = xposix)
-AM_CONDITIONAL(CREATE_IMPORT_LIB, test "x$create_import_lib" = xyes)
-AM_CONDITIONAL(USE_UDEV, test "x$enable_udev" = xyes)
-if test "x$threads" = xposix; then
- AC_DEFINE(THREADS_POSIX, 1, [Use POSIX Threads])
-fi
-
-# timerfd
-AC_CHECK_HEADER([sys/timerfd.h], [timerfd_h=1], [timerfd_h=0])
-AC_ARG_ENABLE([timerfd],
- [AS_HELP_STRING([--enable-timerfd],
- [use timerfd for timing [default=auto]])],
- [use_timerfd=$enableval], [use_timerfd=auto])
+dnl headers not available on all platforms but required on others
+AC_CHECK_HEADERS([sys/time.h])
-if test "x$use_timerfd" = xyes -a "x$timerfd_h" = x0; then
- AC_MSG_ERROR([timerfd header not available; glibc 2.9+ required])
+if test "x$platform" = xposix; then
+ dnl the clock_gettime() function needs certain clock IDs defined
+ AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes], [have_clock_gettime=])
+ if test "x$have_clock_gettime" = xyes; then
+ AC_CHECK_DECL([CLOCK_MONOTONIC], [], [AC_MSG_ERROR([C library headers missing definition for CLOCK_MONOTONIC])], [[#include <time.h>]])
+ dnl use the monotonic clock for condition variable timed waits if possible
+ AC_CHECK_FUNCS([pthread_condattr_setclock], [need_clock_realtime=], [need_clock_realtime=yes])
+ if test "x$need_clock_realtime" = xyes; then
+ AC_CHECK_DECL([CLOCK_REALTIME], [], [AC_MSG_ERROR([C library headers missing definition for CLOCK_REALTIME])], [[#include <time.h>]])
+ fi
+ elif test "x$backend" != xdarwin; then
+ AC_MSG_ERROR([clock_gettime() is required on this platform])
+ fi
fi
-AC_CHECK_DECLS([TFD_NONBLOCK, TFD_CLOEXEC], [tfd_hdr_ok=yes], [tfd_hdr_ok=no], [#include <sys/timerfd.h>])
-if test "x$use_timerfd" = xyes -a "x$tfd_hdr_ok" = xno; then
- AC_MSG_ERROR([timerfd header not usable; glibc 2.9+ required])
+dnl eventfd support
+if test "x$backend" = xlinux || test "x$backend" = xsunos; then
+ AC_ARG_ENABLE([eventfd],
+ [AS_HELP_STRING([--enable-eventfd], [use eventfd for signalling [default=auto]])],
+ [use_eventfd=$enableval],
+ [use_eventfd=auto])
+ if test "x$use_eventfd" != xno; then
+ AC_CHECK_HEADER([sys/eventfd.h], [eventfd_h=yes], [eventfd_h=])
+ if test "x$eventfd_h" = xyes; then
+ AC_CHECK_DECLS([EFD_NONBLOCK, EFD_CLOEXEC], [eventfd_h_ok=yes], [eventfd_h_ok=], [[#include <sys/eventfd.h>]])
+ if test "x$eventfd_h_ok" = xyes; then
+ AC_CHECK_FUNC([eventfd], [eventfd_ok=yes], [eventfd_ok=])
+ if test "x$eventfd_ok" = xyes; then
+ AC_DEFINE([HAVE_EVENTFD], [1], [Define to 1 if the system has eventfd functionality.])
+ elif test "x$use_eventfd" = xyes; then
+ AC_MSG_ERROR([eventfd() function not found; glibc 2.9+ required])
+ fi
+ elif test "x$use_eventfd" = xyes; then
+ AC_MSG_ERROR([eventfd header not usable; glibc 2.9+ required])
+ fi
+ elif test "x$use_eventfd" = xyes; then
+ AC_MSG_ERROR([eventfd header not available; glibc 2.9+ required])
+ fi
+ fi
+ AC_MSG_CHECKING([whether to use eventfd for signalling])
+ if test "x$use_eventfd" = xno; then
+ AC_MSG_RESULT([no (disabled by user)])
+ elif test "x$eventfd_h" != xyes; then
+ AC_MSG_RESULT([no (header not available)])
+ elif test "x$eventfd_h_ok" != xyes; then
+ AC_MSG_RESULT([no (header not usable)])
+ elif test "x$eventfd_ok" != xyes; then
+ AC_MSG_RESULT([no (functions not available)])
+ else
+ AC_MSG_RESULT([yes])
+ fi
fi
-AC_MSG_CHECKING([whether to use timerfd for timing])
-if test "x$use_timerfd" = xno; then
- AC_MSG_RESULT([no (disabled by user)])
-else
- if test "x$timerfd_h" = x1 -a "x$tfd_hdr_ok" = xyes; then
- AC_MSG_RESULT([yes])
- AC_DEFINE(USBI_TIMERFD_AVAILABLE, 1, [timerfd headers available])
- else
+dnl timerfd support
+if test "x$backend" = xlinux || test "x$backend" = xsunos; then
+ AC_ARG_ENABLE([timerfd],
+ [AS_HELP_STRING([--enable-timerfd], [use timerfd for timing [default=auto]])],
+ [use_timerfd=$enableval],
+ [use_timerfd=auto])
+ if test "x$use_timerfd" != xno; then
+ AC_CHECK_HEADER([sys/timerfd.h], [timerfd_h=yes], [timerfd_h=])
+ if test "x$timerfd_h" = xyes; then
+ AC_CHECK_DECLS([TFD_NONBLOCK, TFD_CLOEXEC], [timerfd_h_ok=yes], [timerfd_h_ok=], [[#include <sys/timerfd.h>]])
+ if test "x$timerfd_h_ok" = xyes; then
+ AC_CHECK_FUNC([timerfd_create], [timerfd_ok=yes], [timerfd_ok=])
+ if test "x$timerfd_ok" = xyes; then
+ AC_DEFINE([HAVE_TIMERFD], [1], [Define to 1 if the system has timerfd functionality.])
+ elif test "x$use_timerfd" = xyes; then
+ AC_MSG_ERROR([timerfd_create() function not found; glibc 2.9+ required])
+ fi
+ elif test "x$use_timerfd" = xyes; then
+ AC_MSG_ERROR([timerfd header not usable; glibc 2.9+ required])
+ fi
+ elif test "x$use_timerfd" = xyes; then
+ AC_MSG_ERROR([timerfd header not available; glibc 2.9+ required])
+ fi
+ fi
+ AC_MSG_CHECKING([whether to use timerfd for timing])
+ if test "x$use_timerfd" = xno; then
+ AC_MSG_RESULT([no (disabled by user)])
+ elif test "x$timerfd_h" != xyes; then
AC_MSG_RESULT([no (header not available)])
+ elif test "x$timerfd_h_ok" != xyes; then
+ AC_MSG_RESULT([no (header not usable)])
+ elif test "x$timerfd_ok" != xyes; then
+ AC_MSG_RESULT([no (functions not available)])
+ else
+ AC_MSG_RESULT([yes])
fi
fi
-AC_CHECK_FUNCS([pipe2])
-AC_CHECK_TYPES([struct timespec])
-
-# Message logging
-AC_ARG_ENABLE([log], [AS_HELP_STRING([--disable-log], [disable all logging])],
+dnl Message logging
+AC_ARG_ENABLE([log],
+ [AS_HELP_STRING([--disable-log], [disable all logging])],
[log_enabled=$enableval],
[log_enabled=yes])
if test "x$log_enabled" != xno; then
- AC_DEFINE([ENABLE_LOGGING], 1, [Message logging])
+ AC_DEFINE([ENABLE_LOGGING], [1], [Define to 1 to enable message logging.])
fi
-AC_ARG_ENABLE([debug-log], [AS_HELP_STRING([--enable-debug-log],
- [start with debug message logging enabled [default=no]])],
+AC_ARG_ENABLE([debug-log],
+ [AS_HELP_STRING([--enable-debug-log], [start with debug message logging enabled [default=no]])],
[debug_log_enabled=$enableval],
[debug_log_enabled=no])
if test "x$debug_log_enabled" != xno; then
- AC_DEFINE([ENABLE_DEBUG_LOGGING], 1, [Start with debug message logging enabled])
+ AC_DEFINE([ENABLE_DEBUG_LOGGING], [1], [Define to 1 to start with debug message logging enabled.])
fi
-AC_ARG_ENABLE([system-log], [AS_HELP_STRING([--enable-system-log],
- [output logging messages to system wide log, if supported by the OS [default=no]])],
+AC_ARG_ENABLE([system-log],
+ [AS_HELP_STRING([--enable-system-log], [output logging messages to the systemwide log, if supported by the OS [default=no]])],
[system_log_enabled=$enableval],
[system_log_enabled=no])
if test "x$system_log_enabled" != xno; then
- AC_DEFINE([USE_SYSTEM_LOGGING_FACILITY], 1, [Enable output to system log])
-
- # Check if syslog is available in standard C library
- AC_CHECK_HEADERS(syslog.h)
- AC_CHECK_FUNC([syslog], [have_syslog=yes], [have_syslog=no])
- if test "x$have_syslog" != xno; then
- AC_DEFINE([HAVE_SYSLOG_FUNC], 1, [syslog() function available])
+ AC_DEFINE([USE_SYSTEM_LOGGING_FACILITY], [1], [Define to 1 to output logging messages to the systemwide log.])
+ if test "x$backend" != xwindows && test "x$is_android_linux" != xyes; then
+ dnl Check if syslog is available in standard C library
+ AC_CHECK_HEADER([syslog.h], [syslog_h=yes], [syslog_h=])
+ if test "x$syslog_h" = xyes; then
+ AC_CHECK_FUNCS([syslog])
+ fi
fi
fi
-# Examples build
-AC_ARG_ENABLE([examples-build], [AS_HELP_STRING([--enable-examples-build],
- [build example applications [default=no]])],
+dnl Examples build
+AC_ARG_ENABLE([examples-build],
+ [AS_HELP_STRING([--enable-examples-build], [build example applications [default=no]])],
[build_examples=$enableval],
[build_examples=no])
-AM_CONDITIONAL(BUILD_EXAMPLES, test "x$build_examples" != xno)
-# Tests build
-AC_ARG_ENABLE([tests-build], [AS_HELP_STRING([--enable-tests-build],
- [build test applications [default=no]])],
+dnl Tests build
+AC_ARG_ENABLE([tests-build],
+ [AS_HELP_STRING([--enable-tests-build], [build test applications [default=no]])],
[build_tests=$enableval],
[build_tests=no])
-AM_CONDITIONAL(BUILD_TESTS, test "x$build_tests" != xno)
-# headers not available on all platforms but required on others
-AC_CHECK_HEADERS([sys/time.h])
+AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" != xno])
+AM_CONDITIONAL([BUILD_TESTS], [test "x$build_tests" != xno])
+AM_CONDITIONAL([CREATE_IMPORT_LIB], [test "x$create_import_lib" = xyes])
+AM_CONDITIONAL([OS_DARWIN], [test "x$backend" = xdarwin])
+AM_CONDITIONAL([OS_HAIKU], [test "x$backend" = xhaiku])
+AM_CONDITIONAL([OS_LINUX], [test "x$backend" = xlinux])
+AM_CONDITIONAL([OS_NETBSD], [test "x$backend" = xnetbsd])
+AM_CONDITIONAL([OS_NULL], [test "x$backend" = xnull])
+AM_CONDITIONAL([OS_OPENBSD], [test "x$backend" = xopenbsd])
+AM_CONDITIONAL([OS_SUNOS], [test "x$backend" = xsunos])
+AM_CONDITIONAL([OS_WINDOWS], [test "x$backend" = xwindows])
+AM_CONDITIONAL([PLATFORM_POSIX], [test "x$platform" = xposix])
+AM_CONDITIONAL([PLATFORM_WINDOWS], [test "x$platform" = xwindows])
+AM_CONDITIONAL([USE_UDEV], [test "x$use_udev" = xyes])
+
+dnl The -Wcast-function-type warning causes a flurry of warnings when compiling
+dnl Windows with GCC 8 or later because of dynamically loaded functions
+if test "x$backend" = xwindows; then
+ saved_CFLAGS="${CFLAGS}"
+ CFLAGS="-Werror -Wcast-function-type"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
+ [EXTRA_CFLAGS="${EXTRA_CFLAGS} -Wno-cast-function-type"],
+ [])
+ CFLAGS="${saved_CFLAGS}"
+fi
-# sigaction not available on MinGW
-AC_CHECK_FUNC([sigaction], [have_sigaction=yes], [have_sigaction=no])
-AM_CONDITIONAL(HAVE_SIGACTION, test "x$have_sigaction" = xyes)
+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"
-# check for -fvisibility=hidden compiler support (GCC >= 3.4)
-saved_cflags="$CFLAGS"
-# -Werror required for cygwin
-CFLAGS="$CFLAGS -Werror -fvisibility=hidden"
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
- [VISIBILITY_CFLAGS="-fvisibility=hidden"
- AC_DEFINE([DEFAULT_VISIBILITY], [__attribute__((visibility("default")))], [Default visibility])],
- [VISIBILITY_CFLAGS=""
- AC_DEFINE([DEFAULT_VISIBILITY], [], [Default visibility])],
- ])
-CFLAGS="$saved_cflags"
+AM_CPPFLAGS="${EXTRA_CPPFLAGS}"
+AC_SUBST(AM_CPPFLAGS)
-# check for -Wno-pointer-sign compiler support (GCC >= 4)
-saved_cflags="$CFLAGS"
-CFLAGS="$CFLAGS -Wno-pointer-sign"
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
- nopointersign_cflags="-Wno-pointer-sign", nopointersign_cflags="")
-CFLAGS="$saved_cflags"
+AM_CFLAGS="-std=${c_dialect}11 ${EXTRA_CFLAGS} ${SHARED_CFLAGS}"
+AC_SUBST(AM_CFLAGS)
-# check for -std=gnu99 compiler support
-saved_cflags="$CFLAGS"
-CFLAGS="-std=gnu99"
-AC_MSG_CHECKING([whether CC supports -std=gnu99])
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
- [AC_MSG_RESULT([yes])]
- [AM_CFLAGS="${AM_CFLAGS} -std=gnu99"],
- [AC_MSG_RESULT([no])]
-)
-CFLAGS="$saved_cflags"
+AM_CXXFLAGS="-std=${c_dialect}++11 ${EXTRA_CFLAGS} ${SHARED_CFLAGS} -Wmissing-declarations"
+AC_SUBST(AM_CXXFLAGS)
-AM_CFLAGS="${AM_CFLAGS} -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration $nopointersign_cflags -Wshadow ${THREAD_CFLAGS} ${VISIBILITY_CFLAGS}"
+AC_SUBST(LT_LDFLAGS)
-AC_SUBST(AM_CFLAGS)
-AC_SUBST(LTLDFLAGS)
+dnl set name of html output directory for doxygen
+AC_SUBST(DOXYGEN_HTMLDIR, [api-1.0])
AC_CONFIG_FILES([libusb-1.0.pc])
AC_CONFIG_FILES([Makefile])
diff --git a/darwin/config.h b/darwin/config.h
index bd8a0f9..a5beef2 100644
--- a/darwin/config.h
+++ b/darwin/config.h
@@ -1,23 +1,42 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
-/* Default visibility */
-#define DEFAULT_VISIBILITY __attribute__((visibility("default")))
+/* Define to the attribute for default visibility. */
+#define DEFAULT_VISIBILITY __attribute__ ((visibility ("default")))
-/* Start with debug message logging enabled */
+/* Define to 1 to start with debug message logging enabled. */
/* #undef ENABLE_DEBUG_LOGGING */
-/* Message logging */
+/* Define to 1 to enable message logging. */
#define ENABLE_LOGGING 1
/* Define to 1 if you have the <asm/types.h> header file. */
/* #undef HAVE_ASM_TYPES_H */
+/* Define to 1 if you have the `clock_gettime' function. */
+#define HAVE_CLOCK_GETTIME 1
+
+/* Define to 1 if you have the declaration of `EFD_CLOEXEC', and to 0 if you
+ don't. */
+/* #undef HAVE_DECL_EFD_CLOEXEC */
+
+/* Define to 1 if you have the declaration of `EFD_NONBLOCK', and to 0 if you
+ don't. */
+/* #undef HAVE_DECL_EFD_NONBLOCK */
+
+/* Define to 1 if you have the declaration of `TFD_CLOEXEC', and to 0 if you
+ don't. */
+/* #undef HAVE_DECL_TFD_CLOEXEC */
+
+/* Define to 1 if you have the declaration of `TFD_NONBLOCK', and to 0 if you
+ don't. */
+/* #undef HAVE_DECL_TFD_NONBLOCK */
+
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
-/* Define to 1 if you have the `gettimeofday' function. */
-#define HAVE_GETTIMEOFDAY 1
+/* Define to 1 if the system has eventfd functionality. */
+/* #undef HAVE_EVENTFD */
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
@@ -25,20 +44,23 @@
/* Define to 1 if you have the `udev' library (-ludev). */
/* #undef HAVE_LIBUDEV */
-/* Define to 1 if you have the <libudev.h> header file. */
-/* #undef HAVE_LIBUDEV_H */
-
-/* Define to 1 if you have the <linux/netlink.h> header file. */
-/* #undef HAVE_LINUX_NETLINK_H */
-
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
-/* Define to 1 if you have the <poll.h> header file. */
-#define HAVE_POLL_H 1
+/* Define to 1 if the system has the type `nfds_t'. */
+#define HAVE_NFDS_T 1
-/* Define to 1 if you have the <signal.h> header file. */
-#define HAVE_SIGNAL_H 1
+/* Define to 1 if you have the `pipe2' function. */
+/* #undef HAVE_PIPE2 */
+
+/* Define to 1 if you have the `pthread_condattr_setclock' function. */
+/* #undef HAVE_PTHREAD_CONDATTR_SETCLOCK */
+
+/* Define to 1 if you have the `pthread_setname_np' function. */
+/* #undef HAVE_PTHREAD_SETNAME_NP */
+
+/* Define to 1 if you have the `pthread_threadid_np' function. */
+#define HAVE_PTHREAD_THREADID_NP 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
@@ -53,16 +75,10 @@
#define HAVE_STRING_H 1
/* Define to 1 if the system has the type `struct timespec'. */
-#define HAVE_STRUCT_TIMESPEC 1
-
-/* syslog() function available */
-#define HAVE_SYSLOG_FUNC 1
+/* #undef HAVE_STRUCT_TIMESPEC */
-/* Define to 1 if you have the <syslog.h> header file. */
-#define HAVE_SYSLOG_H 1
-
-/* Define to 1 if you have the <sys/socket.h> header file. */
-/* #undef HAVE_SYS_SOCKET_H */
+/* Define to 1 if you have the `syslog' function. */
+/* #undef HAVE_SYSLOG */
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
@@ -73,84 +89,61 @@
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
+/* Define to 1 if the system has timerfd functionality. */
+/* #undef HAVE_TIMERFD */
+
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#define LT_OBJDIR ".libs/"
-/* Darwin backend */
-#define OS_DARWIN 1
-
-/* Haiku backend */
-/* #undef OS_HAIKU */
-
-/* Linux backend */
-/* #undef OS_LINUX */
-
-/* NetBSD backend */
-/* #undef OS_NETBSD */
-
-/* OpenBSD backend */
-/* #undef OS_OPENBSD */
-
-/* SunOS backend */
-/* #undef OS_SUNOS */
-
-/* Windows backend */
-/* #undef OS_WINDOWS */
-
/* Name of package */
-#define PACKAGE "libusb"
+#define PACKAGE "libusb-1.0"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "libusb-devel@lists.sourceforge.net"
/* Define to the full name of this package. */
-#define PACKAGE_NAME "libusb"
+#define PACKAGE_NAME "libusb-1.0"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "libusb 1.0.21-rc5"
+#define PACKAGE_STRING "libusb-1.0 1.0.24"
/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "libusb"
+#define PACKAGE_TARNAME "libusb-1.0"
/* Define to the home page for this package. */
#define PACKAGE_URL "http://libusb.info"
/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.0.21-rc5"
+#define PACKAGE_VERSION "1.0.24"
-/* type of second poll() argument */
-#define POLL_NFDS_TYPE nfds_t
+/* Define to 1 if compiling for a POSIX platform. */
+#define PLATFORM_POSIX 1
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
+/* Define to 1 if compiling for a Windows platform. */
+/* #undef PLATFORM_WINDOWS */
-/* Use POSIX Threads */
-#define THREADS_POSIX 1
+/* Define to the attribute for enabling parameter checks on printf-like
+ functions. */
+#define PRINTF_FORMAT(a, b) __attribute__ ((__format__ (__printf__, a, b)))
-/* timerfd headers available */
-/* #undef USBI_TIMERFD_AVAILABLE */
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
-/* Enable output to system log */
+/* Define to 1 to output logging messages to the systemwide log. */
/* #undef USE_SYSTEM_LOGGING_FACILITY */
-/* Use udev for device enumeration/hotplug */
-/* #undef USE_UDEV */
-
-/* Use UsbDk Windows backend */
-/* #undef USE_USBDK */
-
/* Version number of package */
-#define VERSION "1.0.21-rc5"
-
-/* Oldest Windows version supported */
-/* #undef WINVER */
+#define VERSION "1.0.24"
-/* Use GNU extensions */
+/* Enable GNU extensions. */
#define _GNU_SOURCE 1
+/* Define to the oldest supported Windows version. */
+/* #undef _WIN32_WINNT */
+
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
diff --git a/doc/Makefile.am b/doc/Makefile.am
deleted file mode 100644
index 76211f2..0000000
--- a/doc/Makefile.am
+++ /dev/null
@@ -1,9 +0,0 @@
-EXTRA_DIST = doxygen.cfg.in
-
-docs: doxygen.cfg
- doxygen $^
-
-docs-upload: docs
- ln -s html api-1.0
- scp -r api-1.0 pbatard@web.sourceforge.net:/home/project-web/libusb/htdocs
- rm -f api-1.0
diff --git a/doc/Makefile.in b/doc/Makefile.in
new file mode 100644
index 0000000..45c3209
--- /dev/null
+++ b/doc/Makefile.in
@@ -0,0 +1,22 @@
+LIBUSB_SRC_DIR = @top_srcdir@/libusb
+EXCLUDED_FILES = hotplug.h libusbi.h version.h version_nano.h
+LIBUSB_SRC = $(wildcard $(LIBUSB_SRC_DIR)/*.c) $(wildcard $(LIBUSB_SRC_DIR)/*.h)
+LIBUSB_DOC_SRC = $(filter-out $(addprefix $(LIBUSB_SRC_DIR)/,$(EXCLUDED_FILES)),$(LIBUSB_SRC))
+
+docs: @DOXYGEN_HTMLDIR@
+
+@DOXYGEN_HTMLDIR@: doxygen.cfg @top_srcdir@/doc/libusb.png $(LIBUSB_DOC_SRC)
+ doxygen $<
+
+sfurl = web.sourceforge.net:/home/project-web/libusb/htdocs
+docs-upload: @DOXYGEN_HTMLDIR@
+ if [ -z "$$SF_USER" ]; then \
+ rsync -rv --delete $< $(sfurl); \
+ else \
+ rsync -rv --delete $< $$SF_USER@$(sfurl); \
+ fi
+
+clean:
+ rm -rf @DOXYGEN_HTMLDIR@
+
+.PHONY: clean docs docs-upload
diff --git a/doc/doxygen.cfg.in b/doc/doxygen.cfg.in
index d26ae33..569e465 100644
--- a/doc/doxygen.cfg.in
+++ b/doc/doxygen.cfg.in
@@ -1,4 +1,4 @@
-# Doxyfile 1.8.8
+# Doxyfile 1.8.16
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project.
@@ -17,11 +17,11 @@
# Project related configuration options
#---------------------------------------------------------------------------
-# This tag specifies the encoding used for all characters in the config file
-# that follow. The default is UTF-8 which is also the encoding used for all text
-# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv
-# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv
-# for the list of possible encodings.
+# This tag specifies the encoding used for all characters in the configuration
+# file that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# https://www.gnu.org/software/libiconv/ for the list of possible encodings.
# The default value is: UTF-8.
DOXYFILE_ENCODING = UTF-8
@@ -32,13 +32,13 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.
-PROJECT_NAME =
+PROJECT_NAME = libusb
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER =
+PROJECT_NUMBER = @PACKAGE_VERSION@
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
@@ -46,12 +46,12 @@ PROJECT_NUMBER =
PROJECT_BRIEF = "A cross-platform user library to access USB devices"
-# With the PROJECT_LOGO tag one can specify an logo or icon that is included in
-# the documentation. The maximum height of the logo should not exceed 55 pixels
-# and the maximum width should not exceed 200 pixels. Doxygen will copy the logo
-# to the output directory.
+# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
+# in the documentation. The maximum height of the logo should not exceed 55
+# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
+# the logo to the output directory.
-PROJECT_LOGO = libusb.png
+PROJECT_LOGO = @top_srcdir@/doc/libusb.png
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
# into which the generated documentation will be written. If a relative path is
@@ -60,7 +60,7 @@ PROJECT_LOGO = libusb.png
OUTPUT_DIRECTORY =
-# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub-
+# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and
# will distribute the generated files over these directories. Enabling this
# option can be useful when feeding doxygen a huge amount of source files, where
@@ -93,14 +93,22 @@ ALLOW_UNICODE_NAMES = NO
OUTPUT_LANGUAGE = English
-# If the BRIEF_MEMBER_DESC tag is set to YES doxygen will include brief member
+# The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all generated output in the proper direction.
+# Possible values are: None, LTR, RTL and Context.
+# The default value is: None.
+
+OUTPUT_TEXT_DIRECTION = None
+
+# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member
# descriptions after the members that are listed in the file and class
# documentation (similar to Javadoc). Set to NO to disable this.
# The default value is: YES.
BRIEF_MEMBER_DESC = YES
-# If the REPEAT_BRIEF tag is set to YES doxygen will prepend the brief
+# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief
# description of a member or function before the detailed description
#
# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
@@ -135,7 +143,7 @@ ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
-# If the FULL_PATH_NAMES tag is set to YES doxygen will prepend the full path
+# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path
# before files name in the file list and in the header files. If set to NO the
# shortest path that makes the file name unique will be used
# The default value is: YES.
@@ -179,6 +187,16 @@ SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = YES
+# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line
+# such as
+# /***************
+# as being the beginning of a Javadoc-style comment "banner". If set to NO, the
+# Javadoc-style will behave just like regular comments and it will not be
+# interpreted by doxygen.
+# The default value is: NO.
+
+JAVADOC_BANNER = NO
+
# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
# line (until the first dot) of a Qt-style comment as the brief description. If
# set to NO, the Qt-style will behave just like regular Qt-style comments (thus
@@ -205,9 +223,9 @@ MULTILINE_CPP_IS_BRIEF = NO
INHERIT_DOCS = YES
-# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce a
-# new page for each member. If set to NO, the documentation of a member will be
-# part of the file/class/namespace that contains it.
+# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new
+# page for each member. If set to NO, the documentation of a member will be part
+# of the file/class/namespace that contains it.
# The default value is: NO.
SEPARATE_MEMBER_PAGES = NO
@@ -226,7 +244,12 @@ TAB_SIZE = 4
# will allow you to put the command \sideeffect (or @sideeffect) in the
# documentation, which will result in a user-defined paragraph with heading
# "Side Effects:". You can put \n's in the value part of an alias to insert
-# newlines.
+# newlines (in the resulting output). You can put ^^ in the value part of an
+# alias to insert a newline as if a physical newline was in the original file.
+# When you need a literal { or } or , in the value part of an alias you have to
+# escape them by means of a backslash (\), this can lead to conflicts with the
+# commands \{ and \} for these it is advised to use the version @{ and @} or use
+# a double escape (\\{ and \\})
ALIASES =
@@ -264,19 +287,28 @@ OPTIMIZE_FOR_FORTRAN = NO
OPTIMIZE_OUTPUT_VHDL = NO
+# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice
+# sources only. Doxygen will then generate output that is more tailored for that
+# language. For instance, namespaces will be presented as modules, types will be
+# separated into more groups, etc.
+# The default value is: NO.
+
+OPTIMIZE_OUTPUT_SLICE = NO
+
# Doxygen selects the parser to use depending on the extension of the files it
# parses. With this tag you can assign which parser to use for a given
# extension. Doxygen has a built-in mapping, but you can override or extend it
# using this tag. The format is ext=language, where ext is a file extension, and
# language is one of the parsers supported by doxygen: IDL, Java, Javascript,
-# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran:
-# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran:
-# Fortran. In the later case the parser tries to guess whether the code is fixed
-# or free formatted code, this is the default for Fortran type files), VHDL. For
-# instance to make doxygen treat .inc files as Fortran files (default is PHP),
-# and .f files as C (default is Fortran), use: inc=Fortran f=C.
+# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice,
+# Fortran (fixed format Fortran: FortranFixed, free formatted Fortran:
+# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser
+# tries to guess whether the code is fixed or free formatted code, this is the
+# default for Fortran type files), VHDL, tcl. For instance to make doxygen treat
+# .inc files as Fortran files (default is PHP), and .f files as C (default is
+# Fortran), use: inc=Fortran f=C.
#
-# Note For files without extension you can use no_extension as a placeholder.
+# Note: For files without extension you can use no_extension as a placeholder.
#
# Note that for custom extensions you also need to set FILE_PATTERNS otherwise
# the files are not read by doxygen.
@@ -285,7 +317,7 @@ EXTENSION_MAPPING =
# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments
# according to the Markdown format, which allows for more readable
-# documentation. See http://daringfireball.net/projects/markdown/ for details.
+# documentation. See https://daringfireball.net/projects/markdown/ for details.
# The output of markdown processing is further processed by doxygen, so you can
# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in
# case of backward compatibilities issues.
@@ -293,10 +325,19 @@ EXTENSION_MAPPING =
MARKDOWN_SUPPORT = YES
+# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up
+# to that level are automatically included in the table of contents, even if
+# they do not have an id attribute.
+# Note: This feature currently applies only to Markdown headings.
+# Minimum value: 0, maximum value: 99, default value: 5.
+# This tag requires that the tag MARKDOWN_SUPPORT is set to YES.
+
+TOC_INCLUDE_HEADINGS = 5
+
# When enabled doxygen tries to link words that correspond to documented
# classes, or namespaces to their corresponding documentation. Such a link can
-# be prevented in individual cases by by putting a % sign in front of the word
-# or globally by setting AUTOLINK_SUPPORT to NO.
+# be prevented in individual cases by putting a % sign in front of the word or
+# globally by setting AUTOLINK_SUPPORT to NO.
# The default value is: YES.
AUTOLINK_SUPPORT = YES
@@ -318,7 +359,7 @@ BUILTIN_STL_SUPPORT = NO
CPP_CLI_SUPPORT = NO
# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
-# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen
+# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen
# will parse them like normal C++ but will assume all classes use public instead
# of private inheritance when no explicit protection keyword is present.
# The default value is: NO.
@@ -336,13 +377,20 @@ SIP_SUPPORT = NO
IDL_PROPERTY_SUPPORT = YES
# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
-# tag is set to YES, then doxygen will reuse the documentation of the first
+# tag is set to YES then doxygen will reuse the documentation of the first
# member in the group (if any) for the other members of the group. By default
# all members of a group must be documented explicitly.
# The default value is: NO.
DISTRIBUTE_GROUP_DOC = NO
+# If one adds a struct or class to a group and this option is enabled, then also
+# any nested class or struct is added to the same group. By default this option
+# is disabled and one has to add nested compounds explicitly via \ingroup.
+# The default value is: NO.
+
+GROUP_NESTED_COMPOUNDS = NO
+
# Set the SUBGROUPING tag to YES to allow class member groups of the same type
# (for instance a group of public functions) to be put as a subgroup of that
# type (e.g. under the Public Functions section). Set it to NO to prevent
@@ -401,7 +449,7 @@ LOOKUP_CACHE_SIZE = 0
# Build related configuration options
#---------------------------------------------------------------------------
-# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in
# documentation are documented, even if no documentation was available. Private
# class members and static file members will be hidden unless the
# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES.
@@ -411,35 +459,41 @@ LOOKUP_CACHE_SIZE = 0
EXTRACT_ALL = NO
-# If the EXTRACT_PRIVATE tag is set to YES all private members of a class will
+# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will
# be included in the documentation.
# The default value is: NO.
EXTRACT_PRIVATE = NO
-# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal
+# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual
+# methods of a class will be included in the documentation.
+# The default value is: NO.
+
+EXTRACT_PRIV_VIRTUAL = NO
+
+# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal
# scope will be included in the documentation.
# The default value is: NO.
EXTRACT_PACKAGE = NO
-# If the EXTRACT_STATIC tag is set to YES all static members of a file will be
+# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be
# included in the documentation.
# The default value is: NO.
EXTRACT_STATIC = YES
-# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) defined
-# locally in source files will be included in the documentation. If set to NO
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
+# locally in source files will be included in the documentation. If set to NO,
# only classes defined in header files are included. Does not have any effect
# for Java sources.
# The default value is: YES.
EXTRACT_LOCAL_CLASSES = YES
-# This flag is only useful for Objective-C code. When set to YES local methods,
+# This flag is only useful for Objective-C code. If set to YES, local methods,
# which are defined in the implementation section but not in the interface are
-# included in the documentation. If set to NO only methods in the interface are
+# included in the documentation. If set to NO, only methods in the interface are
# included.
# The default value is: NO.
@@ -464,21 +518,21 @@ HIDE_UNDOC_MEMBERS = NO
# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all
# undocumented classes that are normally visible in the class hierarchy. If set
-# to NO these classes will be included in the various overviews. This option has
-# no effect if EXTRACT_ALL is enabled.
+# to NO, these classes will be included in the various overviews. This option
+# has no effect if EXTRACT_ALL is enabled.
# The default value is: NO.
HIDE_UNDOC_CLASSES = NO
# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
-# (class|struct|union) declarations. If set to NO these declarations will be
+# (class|struct|union) declarations. If set to NO, these declarations will be
# included in the documentation.
# The default value is: NO.
HIDE_FRIEND_COMPOUNDS = NO
# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any
-# documentation blocks found inside the body of a function. If set to NO these
+# documentation blocks found inside the body of a function. If set to NO, these
# blocks will be appended to the function's detailed documentation block.
# The default value is: NO.
@@ -492,21 +546,28 @@ HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file
-# names in lower-case letters. If set to YES upper-case letters are also
+# names in lower-case letters. If set to YES, upper-case letters are also
# allowed. This is useful if you have classes or files whose names only differ
# in case and if your file system supports case sensitive file names. Windows
-# and Mac users are advised to set this option to NO.
+# (including Cygwin) ands Mac users are advised to set this option to NO.
# The default value is: system dependent.
CASE_SENSE_NAMES = YES
# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with
-# their full class and namespace scopes in the documentation. If set to YES the
+# their full class and namespace scopes in the documentation. If set to YES, the
# scope will be hidden.
# The default value is: NO.
HIDE_SCOPE_NAMES = NO
+# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will
+# append additional text to a page's title, such as Class Reference. If set to
+# YES the compound reference will be hidden.
+# The default value is: NO.
+
+HIDE_COMPOUND_REFERENCE= NO
+
# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of
# the files that are included by a file in the documentation of that file.
# The default value is: YES.
@@ -534,14 +595,14 @@ INLINE_INFO = YES
# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the
# (detailed) documentation of file and class members alphabetically by member
-# name. If set to NO the members will appear in declaration order.
+# name. If set to NO, the members will appear in declaration order.
# The default value is: YES.
SORT_MEMBER_DOCS = NO
# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief
# descriptions of file, namespace and class members alphabetically by member
-# name. If set to NO the members will appear in declaration order. Note that
+# name. If set to NO, the members will appear in declaration order. Note that
# this will also influence the order of the classes in the class list.
# The default value is: NO.
@@ -586,27 +647,25 @@ SORT_BY_SCOPE_NAME = NO
STRICT_PROTO_MATCHING = NO
-# The GENERATE_TODOLIST tag can be used to enable ( YES) or disable ( NO) the
-# todo list. This list is created by putting \todo commands in the
-# documentation.
+# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo
+# list. This list is created by putting \todo commands in the documentation.
# The default value is: YES.
GENERATE_TODOLIST = YES
-# The GENERATE_TESTLIST tag can be used to enable ( YES) or disable ( NO) the
-# test list. This list is created by putting \test commands in the
-# documentation.
+# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test
+# list. This list is created by putting \test commands in the documentation.
# The default value is: YES.
GENERATE_TESTLIST = YES
-# The GENERATE_BUGLIST tag can be used to enable ( YES) or disable ( NO) the bug
+# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug
# list. This list is created by putting \bug commands in the documentation.
# The default value is: YES.
GENERATE_BUGLIST = YES
-# The GENERATE_DEPRECATEDLIST tag can be used to enable ( YES) or disable ( NO)
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO)
# the deprecated list. This list is created by putting \deprecated commands in
# the documentation.
# The default value is: YES.
@@ -631,8 +690,8 @@ ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at
-# the bottom of the documentation of classes and structs. If set to YES the list
-# will mention the files that were used to generate the documentation.
+# the bottom of the documentation of classes and structs. If set to YES, the
+# list will mention the files that were used to generate the documentation.
# The default value is: YES.
SHOW_USED_FILES = YES
@@ -677,7 +736,7 @@ LAYOUT_FILE =
# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
# the reference definitions. This must be a list of .bib files. The .bib
# extension is automatically appended if omitted. This requires the bibtex tool
-# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info.
+# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info.
# For LaTeX the style of the bibliography can be controlled using
# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
# search path. See also \cite for info how to create references.
@@ -696,7 +755,7 @@ CITE_BIB_FILES =
QUIET = YES
# The WARNINGS tag can be used to turn on/off the warning messages that are
-# generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES
+# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES
# this implies that the warnings are on.
#
# Tip: Turn warnings on while writing the documentation.
@@ -704,7 +763,7 @@ QUIET = YES
WARNINGS = YES
-# If the WARN_IF_UNDOCUMENTED tag is set to YES, then doxygen will generate
+# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate
# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag
# will automatically be disabled.
# The default value is: YES.
@@ -721,12 +780,19 @@ WARN_IF_DOC_ERROR = YES
# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that
# are documented, but have no documentation for their parameters or return
-# value. If set to NO doxygen will only warn about wrong or incomplete parameter
-# documentation, but not about the absence of documentation.
+# value. If set to NO, doxygen will only warn about wrong or incomplete
+# parameter documentation, but not about the absence of documentation. If
+# EXTRACT_ALL is set to YES then this flag will automatically be disabled.
# The default value is: NO.
WARN_NO_PARAMDOC = NO
+# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when
+# a warning is encountered.
+# The default value is: NO.
+
+WARN_AS_ERROR = NO
+
# The WARN_FORMAT tag determines the format of the warning messages that doxygen
# can produce. The string should contain the $file, $line, and $text tags, which
# will be replaced by the file and line number from which the warning originated
@@ -750,7 +816,7 @@ WARN_LOGFILE =
# The INPUT tag is used to specify the files and/or directories that contain
# documented source files. You may enter file names like myfile.cpp or
# directories like /usr/src/myproject. Separate the files or directories with
-# spaces.
+# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.
INPUT = @top_srcdir@/libusb
@@ -758,7 +824,7 @@ INPUT = @top_srcdir@/libusb
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
# libiconv (or the iconv built into libc) for the transcoding. See the libiconv
-# documentation (see: http://www.gnu.org/software/libiconv) for the list of
+# documentation (see: https://www.gnu.org/software/libiconv/) for the list of
# possible encodings.
# The default value is: UTF-8.
@@ -766,14 +832,20 @@ INPUT_ENCODING = UTF-8
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and
-# *.h) to filter out the source-files in the directories. If left blank the
-# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii,
-# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp,
-# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown,
-# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf,
-# *.qsf, *.as and *.js.
+# *.h) to filter out the source-files in the directories.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# read by doxygen.
+#
+# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,
+# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,
+# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc,
+# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08,
+# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, *.qsf and *.ice.
-FILE_PATTERNS =
+FILE_PATTERNS = *.c \
+ *.h
# The RECURSIVE tag can be used to specify whether or not subdirectories should
# be searched for input files as well.
@@ -788,8 +860,11 @@ RECURSIVE = NO
# Note that relative paths are relative to the directory from which doxygen is
# run.
-EXCLUDE = @top_srcdir@/libusb/libusbi.h \
- @top_srcdir@/libusb/hotplug.h
+EXCLUDE = @top_srcdir@/libusb/hotplug.h \
+ @top_srcdir@/libusb/libusbi.h \
+ @top_srcdir@/libusb/version.h \
+ @top_srcdir@/libusb/version_nano.h \
+ @top_srcdir@/libusb/os
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
@@ -858,6 +933,10 @@ IMAGE_PATH =
# Note that the filter must not add or remove lines; it is applied before the
# code is scanned, but not when the output code is generated. If lines are added
# or removed, the anchors will not be placed correctly.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# properly processed by doxygen.
INPUT_FILTER =
@@ -867,11 +946,15 @@ INPUT_FILTER =
# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how
# filters are used. If the FILTER_PATTERNS tag is empty or if none of the
# patterns match the file name, INPUT_FILTER is applied.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# properly processed by doxygen.
FILTER_PATTERNS =
# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
-# INPUT_FILTER ) will also be used to filter the input files that are used for
+# INPUT_FILTER) will also be used to filter the input files that are used for
# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES).
# The default value is: NO.
@@ -919,7 +1002,7 @@ INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
# If the REFERENCED_BY_RELATION tag is set to YES then for each documented
-# function all documented functions referencing it will be listed.
+# entity all documented functions referencing it will be listed.
# The default value is: NO.
REFERENCED_BY_RELATION = NO
@@ -931,7 +1014,7 @@ REFERENCED_BY_RELATION = NO
REFERENCES_RELATION = NO
# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set
-# to YES, then the hyperlinks from functions in REFERENCES_RELATION and
+# to YES then the hyperlinks from functions in REFERENCES_RELATION and
# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will
# link to the documentation.
# The default value is: YES.
@@ -951,12 +1034,12 @@ SOURCE_TOOLTIPS = YES
# If the USE_HTAGS tag is set to YES then the references to source code will
# point to the HTML generated by the htags(1) tool instead of doxygen built-in
# source browser. The htags tool is part of GNU's global source tagging system
-# (see http://www.gnu.org/software/global/global.html). You will need version
+# (see https://www.gnu.org/software/global/global.html). You will need version
# 4.8.6 or higher.
#
# To use it do the following:
# - Install the latest version of global
-# - Enable SOURCE_BROWSER and USE_HTAGS in the config file
+# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file
# - Make sure the INPUT points to the root of the source tree
# - Run doxygen as normal
#
@@ -1008,7 +1091,7 @@ IGNORE_PREFIX =
# Configuration options related to the HTML output
#---------------------------------------------------------------------------
-# If the GENERATE_HTML tag is set to YES doxygen will generate HTML output
+# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output
# The default value is: YES.
GENERATE_HTML = YES
@@ -1019,7 +1102,7 @@ GENERATE_HTML = YES
# The default directory is: html.
# This tag requires that the tag GENERATE_HTML is set to YES.
-HTML_OUTPUT = html
+HTML_OUTPUT = @DOXYGEN_HTMLDIR@
# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each
# generated HTML page (for example: .htm, .php, .asp).
@@ -1074,10 +1157,10 @@ HTML_STYLESHEET =
# cascading style sheets that are included after the standard style sheets
# created by doxygen. Using this option one can overrule certain style aspects.
# This is preferred over using HTML_STYLESHEET since it does not replace the
-# standard style sheet and is therefor more robust against future updates.
+# standard style sheet and is therefore more robust against future updates.
# Doxygen will copy the style sheet files to the output directory.
-# Note: The order of the extra stylesheet files is of importance (e.g. the last
-# stylesheet in the list overrules the setting of the previous ones in the
+# Note: The order of the extra style sheet files is of importance (e.g. the last
+# style sheet in the list overrules the setting of the previous ones in the
# list). For an example see the documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.
@@ -1094,9 +1177,9 @@ HTML_EXTRA_STYLESHEET =
HTML_EXTRA_FILES =
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
-# will adjust the colors in the stylesheet and background images according to
+# will adjust the colors in the style sheet and background images according to
# this color. Hue is specified as an angle on a colorwheel, see
-# http://en.wikipedia.org/wiki/Hue for more information. For instance the value
+# https://en.wikipedia.org/wiki/Hue for more information. For instance the value
# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
# purple, and 360 is red again.
# Minimum value: 0, maximum value: 359, default value: 220.
@@ -1125,12 +1208,24 @@ HTML_COLORSTYLE_GAMMA = 80
# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
# page will contain the date and time when the page was generated. Setting this
-# to NO can help when comparing the output of multiple runs.
-# The default value is: YES.
+# to YES can help to show when doxygen was last run and thus if the
+# documentation is up to date.
+# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_TIMESTAMP = YES
+# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML
+# documentation will contain a main index with vertical navigation menus that
+# are dynamically created via Javascript. If disabled, the navigation index will
+# consists of multiple levels of tabs that are statically embedded in every HTML
+# page. Disable this option to support browsers that do not have Javascript,
+# like the Qt help browser.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_DYNAMIC_MENUS = YES
+
# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
# documentation will contain sections that can be hidden and shown after the
# page has loaded.
@@ -1154,13 +1249,13 @@ HTML_INDEX_NUM_ENTRIES = 100
# If the GENERATE_DOCSET tag is set to YES, additional index files will be
# generated that can be used as input for Apple's Xcode 3 integrated development
-# environment (see: http://developer.apple.com/tools/xcode/), introduced with
-# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a
+# environment (see: https://developer.apple.com/xcode/), introduced with OSX
+# 10.5 (Leopard). To create a documentation set, doxygen will generate a
# Makefile in the HTML output directory. Running make will produce the docset in
# that directory and running make install will install the docset in
# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at
-# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
-# for more information.
+# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy
+# genXcode/_index.html for more information.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
@@ -1199,7 +1294,7 @@ DOCSET_PUBLISHER_NAME = Publisher
# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three
# additional HTML index files: index.hhp, index.hhc, and index.hhk. The
# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop
-# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on
+# (see: https://www.microsoft.com/en-us/download/details.aspx?id=21138) on
# Windows.
#
# The HTML Help Workshop contains a compiler that can convert all HTML output
@@ -1222,28 +1317,28 @@ GENERATE_HTMLHELP = NO
CHM_FILE =
# The HHC_LOCATION tag can be used to specify the location (absolute path
-# including file name) of the HTML help compiler ( hhc.exe). If non-empty
+# including file name) of the HTML help compiler (hhc.exe). If non-empty,
# doxygen will try to run the HTML help compiler on the generated index.hhp.
# The file has to be specified with full path.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
HHC_LOCATION =
-# The GENERATE_CHI flag controls if a separate .chi index file is generated (
-# YES) or that it should be included in the master .chm file ( NO).
+# The GENERATE_CHI flag controls if a separate .chi index file is generated
+# (YES) or that it should be included in the master .chm file (NO).
# The default value is: NO.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
GENERATE_CHI = NO
-# The CHM_INDEX_ENCODING is used to encode HtmlHelp index ( hhk), content ( hhc)
+# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc)
# and project file content.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
CHM_INDEX_ENCODING =
-# The BINARY_TOC flag controls whether a binary table of contents is generated (
-# YES) or a normal table of contents ( NO) in the .chm file. Furthermore it
+# The BINARY_TOC flag controls whether a binary table of contents is generated
+# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it
# enables the Previous and Next buttons.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
@@ -1275,7 +1370,7 @@ QCH_FILE =
# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
# Project output. For more information please see Qt Help Project / Namespace
-# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace).
+# (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace).
# The default value is: org.doxygen.Project.
# This tag requires that the tag GENERATE_QHP is set to YES.
@@ -1283,7 +1378,7 @@ QHP_NAMESPACE = org.doxygen.Project
# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
# Help Project output. For more information please see Qt Help Project / Virtual
-# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual-
+# Folders (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-
# folders).
# The default value is: doc.
# This tag requires that the tag GENERATE_QHP is set to YES.
@@ -1292,7 +1387,7 @@ QHP_VIRTUAL_FOLDER = doc
# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
# filter to add. For more information please see Qt Help Project / Custom
-# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
+# Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-
# filters).
# This tag requires that the tag GENERATE_QHP is set to YES.
@@ -1300,7 +1395,7 @@ QHP_CUST_FILTER_NAME =
# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
# custom filter to add. For more information please see Qt Help Project / Custom
-# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
+# Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-
# filters).
# This tag requires that the tag GENERATE_QHP is set to YES.
@@ -1308,7 +1403,7 @@ QHP_CUST_FILTER_ATTRS =
# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
# project's filter section matches. Qt Help Project / Filter Attributes (see:
-# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes).
+# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes).
# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_SECT_FILTER_ATTRS =
@@ -1357,7 +1452,7 @@ DISABLE_INDEX = NO
# index structure (just like the one that is generated for HTML Help). For this
# to work a browser that supports JavaScript, DHTML, CSS and frames is required
# (i.e. any modern browser). Windows users are probably better off using the
-# HTML help feature. Via custom stylesheets (see HTML_EXTRA_STYLESHEET) one can
+# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can
# further fine-tune the look of the index. As an example, the default style
# sheet generated by doxygen has an example that shows how to put an image at
# the root of the tree instead of the PROJECT_NAME. Since the tree basically has
@@ -1385,7 +1480,7 @@ ENUM_VALUES_PER_LINE = 4
TREEVIEW_WIDTH = 250
-# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open links to
+# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to
# external symbols imported via tag files in a separate window.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
@@ -1401,7 +1496,7 @@ EXT_LINKS_IN_WINDOW = NO
FORMULA_FONTSIZE = 10
-# Use the FORMULA_TRANPARENT tag to determine whether or not the images
+# Use the FORMULA_TRANSPARENT tag to determine whether or not the images
# generated for formulas are transparent PNGs. Transparent PNGs are not
# supported properly for IE 6.0, but are supported on all modern browsers.
#
@@ -1413,8 +1508,8 @@ FORMULA_FONTSIZE = 10
FORMULA_TRANSPARENT = YES
# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
-# http://www.mathjax.org) which uses client side Javascript for the rendering
-# instead of using prerendered bitmaps. Use this if you do not have LaTeX
+# https://www.mathjax.org) which uses client side Javascript for the rendering
+# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
# installed or if you want to formulas look prettier in the HTML output. When
# enabled you may also need to install MathJax separately and configure the path
# to it using the MATHJAX_RELPATH option.
@@ -1440,8 +1535,8 @@ MATHJAX_FORMAT = HTML-CSS
# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
# Content Delivery Network so you can quickly see the result without installing
# MathJax. However, it is strongly recommended to install a local copy of
-# MathJax from http://www.mathjax.org before deployment.
-# The default value is: http://cdn.mathjax.org/mathjax/latest.
+# MathJax from https://www.mathjax.org before deployment.
+# The default value is: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/.
# This tag requires that the tag USE_MATHJAX is set to YES.
MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
@@ -1500,9 +1595,9 @@ SERVER_BASED_SEARCH = NO
# external search engine pointed to by the SEARCHENGINE_URL option to obtain the
# search results.
#
-# Doxygen ships with an example indexer ( doxyindexer) and search engine
+# Doxygen ships with an example indexer (doxyindexer) and search engine
# (doxysearch.cgi) which are based on the open source search engine library
-# Xapian (see: http://xapian.org/).
+# Xapian (see: https://xapian.org/).
#
# See the section "External Indexing and Searching" for details.
# The default value is: NO.
@@ -1513,9 +1608,9 @@ EXTERNAL_SEARCH = NO
# The SEARCHENGINE_URL should point to a search engine hosted by a web server
# which will return the search results when EXTERNAL_SEARCH is enabled.
#
-# Doxygen ships with an example indexer ( doxyindexer) and search engine
+# Doxygen ships with an example indexer (doxyindexer) and search engine
# (doxysearch.cgi) which are based on the open source search engine library
-# Xapian (see: http://xapian.org/). See the section "External Indexing and
+# Xapian (see: https://xapian.org/). See the section "External Indexing and
# Searching" for details.
# This tag requires that the tag SEARCHENGINE is set to YES.
@@ -1551,7 +1646,7 @@ EXTRA_SEARCH_MAPPINGS =
# Configuration options related to the LaTeX output
#---------------------------------------------------------------------------
-# If the GENERATE_LATEX tag is set to YES doxygen will generate LaTeX output.
+# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output.
# The default value is: YES.
GENERATE_LATEX = NO
@@ -1567,22 +1662,36 @@ LATEX_OUTPUT = latex
# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
# invoked.
#
-# Note that when enabling USE_PDFLATEX this option is only used for generating
-# bitmaps for formulas in the HTML output, but not in the Makefile that is
-# written to the output directory.
-# The default file is: latex.
+# Note that when not enabling USE_PDFLATEX the default is latex when enabling
+# USE_PDFLATEX the default is pdflatex and when in the later case latex is
+# chosen this is overwritten by pdflatex. For specific output languages the
+# default can have been set differently, this depends on the implementation of
+# the output language.
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_CMD_NAME = latex
# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate
# index for LaTeX.
+# Note: This tag is used in the Makefile / make.bat.
+# See also: LATEX_MAKEINDEX_CMD for the part in the generated output file
+# (.tex).
# The default file is: makeindex.
# This tag requires that the tag GENERATE_LATEX is set to YES.
MAKEINDEX_CMD_NAME = makeindex
-# If the COMPACT_LATEX tag is set to YES doxygen generates more compact LaTeX
+# The LATEX_MAKEINDEX_CMD tag can be used to specify the command name to
+# generate index for LaTeX. In case there is no backslash (\) as first character
+# it will be automatically added in the LaTeX code.
+# Note: This tag is used in the generated output file (.tex).
+# See also: MAKEINDEX_CMD_NAME for the part in the Makefile / make.bat.
+# The default value is: makeindex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_MAKEINDEX_CMD = makeindex
+
+# If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX
# documents. This may be useful for small projects and may help to save some
# trees in general.
# The default value is: NO.
@@ -1600,9 +1709,12 @@ COMPACT_LATEX = NO
PAPER_TYPE = a4wide
# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names
-# that should be included in the LaTeX output. To get the times font for
-# instance you can specify
-# EXTRA_PACKAGES=times
+# that should be included in the LaTeX output. The package can be specified just
+# by its name or with the correct syntax as to be used with the LaTeX
+# \usepackage command. To get the times font for instance you can specify :
+# EXTRA_PACKAGES=times or EXTRA_PACKAGES={times}
+# To use the option intlimits with the amsmath package you can specify:
+# EXTRA_PACKAGES=[intlimits]{amsmath}
# If left blank no extra packages will be included.
# This tag requires that the tag GENERATE_LATEX is set to YES.
@@ -1617,9 +1729,9 @@ EXTRA_PACKAGES =
# Note: Only use a user-defined header if you know what you are doing! The
# following commands have a special meaning inside the header: $title,
# $datetime, $date, $doxygenversion, $projectname, $projectnumber,
-# $projectbrief, $projectlogo. Doxygen will replace $title with the empy string,
-# for the replacement values of the other commands the user is refered to
-# HTML_HEADER.
+# $projectbrief, $projectlogo. Doxygen will replace $title with the empty
+# string, for the replacement values of the other commands the user is referred
+# to HTML_HEADER.
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_HEADER =
@@ -1635,6 +1747,17 @@ LATEX_HEADER =
LATEX_FOOTER =
+# The LATEX_EXTRA_STYLESHEET tag can be used to specify additional user-defined
+# LaTeX style sheets that are included after the standard style sheets created
+# by doxygen. Using this option one can overrule certain style aspects. Doxygen
+# will copy the style sheet files to the output directory.
+# Note: The order of the extra style sheet files is of importance (e.g. the last
+# style sheet in the list overrules the setting of the previous ones in the
+# list).
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_EXTRA_STYLESHEET =
+
# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or
# other source files which should be copied to the LATEX_OUTPUT output
# directory. Note that the files will be copied as-is; there are no commands or
@@ -1653,7 +1776,7 @@ LATEX_EXTRA_FILES =
PDF_HYPERLINKS = NO
# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
-# the PDF file directly from the LaTeX files. Set this option to YES to get a
+# the PDF file directly from the LaTeX files. Set this option to YES, to get a
# higher quality PDF documentation.
# The default value is: YES.
# This tag requires that the tag GENERATE_LATEX is set to YES.
@@ -1688,17 +1811,33 @@ LATEX_SOURCE_CODE = NO
# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
# bibliography, e.g. plainnat, or ieeetr. See
-# http://en.wikipedia.org/wiki/BibTeX and \cite for more info.
+# https://en.wikipedia.org/wiki/BibTeX and \cite for more info.
# The default value is: plain.
# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_BIB_STYLE = plain
+# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated
+# page will contain the date and time when the page was generated. Setting this
+# to NO can help when comparing the output of multiple runs.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_TIMESTAMP = NO
+
+# The LATEX_EMOJI_DIRECTORY tag is used to specify the (relative or absolute)
+# path from which the emoji images will be read. If a relative path is entered,
+# it will be relative to the LATEX_OUTPUT directory. If left blank the
+# LATEX_OUTPUT directory will be used.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_EMOJI_DIRECTORY =
+
#---------------------------------------------------------------------------
# Configuration options related to the RTF output
#---------------------------------------------------------------------------
-# If the GENERATE_RTF tag is set to YES doxygen will generate RTF output. The
+# If the GENERATE_RTF tag is set to YES, doxygen will generate RTF output. The
# RTF output is optimized for Word 97 and may not look too pretty with other RTF
# readers/editors.
# The default value is: NO.
@@ -1713,7 +1852,7 @@ GENERATE_RTF = NO
RTF_OUTPUT = rtf
-# If the COMPACT_RTF tag is set to YES doxygen generates more compact RTF
+# If the COMPACT_RTF tag is set to YES, doxygen generates more compact RTF
# documents. This may be useful for small projects and may help to save some
# trees in general.
# The default value is: NO.
@@ -1733,9 +1872,9 @@ COMPACT_RTF = NO
RTF_HYPERLINKS = NO
-# Load stylesheet definitions from file. Syntax is similar to doxygen's config
-# file, i.e. a series of assignments. You only have to provide replacements,
-# missing definitions are set to their default value.
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# configuration file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
#
# See also section "Doxygen usage" for information on how to generate the
# default style sheet that doxygen normally uses.
@@ -1744,17 +1883,27 @@ RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
# Set optional variables used in the generation of an RTF document. Syntax is
-# similar to doxygen's config file. A template extensions file can be generated
-# using doxygen -e rtf extensionFile.
+# similar to doxygen's configuration file. A template extensions file can be
+# generated using doxygen -e rtf extensionFile.
# This tag requires that the tag GENERATE_RTF is set to YES.
RTF_EXTENSIONS_FILE =
+# If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code
+# with syntax highlighting in the RTF output.
+#
+# Note that which sources are shown also depends on other settings such as
+# SOURCE_BROWSER.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_SOURCE_CODE = NO
+
#---------------------------------------------------------------------------
# Configuration options related to the man page output
#---------------------------------------------------------------------------
-# If the GENERATE_MAN tag is set to YES doxygen will generate man pages for
+# If the GENERATE_MAN tag is set to YES, doxygen will generate man pages for
# classes and files.
# The default value is: NO.
@@ -1798,7 +1947,7 @@ MAN_LINKS = NO
# Configuration options related to the XML output
#---------------------------------------------------------------------------
-# If the GENERATE_XML tag is set to YES doxygen will generate an XML file that
+# If the GENERATE_XML tag is set to YES, doxygen will generate an XML file that
# captures the structure of the code including all documentation.
# The default value is: NO.
@@ -1812,7 +1961,7 @@ GENERATE_XML = NO
XML_OUTPUT = xml
-# If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program
+# If the XML_PROGRAMLISTING tag is set to YES, doxygen will dump the program
# listings (including syntax highlighting and cross-referencing information) to
# the XML output. Note that enabling this will significantly increase the size
# of the XML output.
@@ -1821,11 +1970,18 @@ XML_OUTPUT = xml
XML_PROGRAMLISTING = YES
+# If the XML_NS_MEMB_FILE_SCOPE tag is set to YES, doxygen will include
+# namespace members in file scope as well, matching the HTML output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_XML is set to YES.
+
+XML_NS_MEMB_FILE_SCOPE = NO
+
#---------------------------------------------------------------------------
# Configuration options related to the DOCBOOK output
#---------------------------------------------------------------------------
-# If the GENERATE_DOCBOOK tag is set to YES doxygen will generate Docbook files
+# If the GENERATE_DOCBOOK tag is set to YES, doxygen will generate Docbook files
# that can be used to generate PDF.
# The default value is: NO.
@@ -1839,7 +1995,7 @@ GENERATE_DOCBOOK = NO
DOCBOOK_OUTPUT = docbook
-# If the DOCBOOK_PROGRAMLISTING tag is set to YES doxygen will include the
+# If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the
# program listings (including syntax highlighting and cross-referencing
# information) to the DOCBOOK output. Note that enabling this will significantly
# increase the size of the DOCBOOK output.
@@ -1852,10 +2008,10 @@ DOCBOOK_PROGRAMLISTING = NO
# Configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
-# If the GENERATE_AUTOGEN_DEF tag is set to YES doxygen will generate an AutoGen
-# Definitions (see http://autogen.sf.net) file that captures the structure of
-# the code including all documentation. Note that this feature is still
-# experimental and incomplete at the moment.
+# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an
+# AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures
+# the structure of the code including all documentation. Note that this feature
+# is still experimental and incomplete at the moment.
# The default value is: NO.
GENERATE_AUTOGEN_DEF = NO
@@ -1864,7 +2020,7 @@ GENERATE_AUTOGEN_DEF = NO
# Configuration options related to the Perl module output
#---------------------------------------------------------------------------
-# If the GENERATE_PERLMOD tag is set to YES doxygen will generate a Perl module
+# If the GENERATE_PERLMOD tag is set to YES, doxygen will generate a Perl module
# file that captures the structure of the code including all documentation.
#
# Note that this feature is still experimental and incomplete at the moment.
@@ -1872,7 +2028,7 @@ GENERATE_AUTOGEN_DEF = NO
GENERATE_PERLMOD = NO
-# If the PERLMOD_LATEX tag is set to YES doxygen will generate the necessary
+# If the PERLMOD_LATEX tag is set to YES, doxygen will generate the necessary
# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI
# output from the Perl module output.
# The default value is: NO.
@@ -1880,9 +2036,9 @@ GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
-# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be nicely
+# If the PERLMOD_PRETTY tag is set to YES, the Perl module output will be nicely
# formatted so it can be parsed by a human reader. This is useful if you want to
-# understand what is going on. On the other hand, if this tag is set to NO the
+# understand what is going on. On the other hand, if this tag is set to NO, the
# size of the Perl module output will be much smaller and Perl will parse it
# just the same.
# The default value is: YES.
@@ -1902,14 +2058,14 @@ PERLMOD_MAKEVAR_PREFIX =
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
-# If the ENABLE_PREPROCESSING tag is set to YES doxygen will evaluate all
+# If the ENABLE_PREPROCESSING tag is set to YES, doxygen will evaluate all
# C-preprocessor directives found in the sources and include files.
# The default value is: YES.
ENABLE_PREPROCESSING = YES
-# If the MACRO_EXPANSION tag is set to YES doxygen will expand all macro names
-# in the source code. If set to NO only conditional compilation will be
+# If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names
+# in the source code. If set to NO, only conditional compilation will be
# performed. Macro expansion can be done in a controlled way by setting
# EXPAND_ONLY_PREDEF to YES.
# The default value is: NO.
@@ -1925,7 +2081,7 @@ MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
-# If the SEARCH_INCLUDES tag is set to YES the includes files in the
+# If the SEARCH_INCLUDES tag is set to YES, the include files in the
# INCLUDE_PATH will be searched if a #include is found.
# The default value is: YES.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
@@ -1956,8 +2112,9 @@ INCLUDE_FILE_PATTERNS =
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
PREDEFINED = API_EXPORTED= \
+ DEFAULT_VISIBILITY= \
LIBUSB_CALL= \
- DEFAULT_VISIBILITY=
+ LIBUSB_PACKED=
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
# tag can be used to specify a list of macro names that should be expanded. The
@@ -2003,37 +2160,32 @@ TAGFILES =
GENERATE_TAGFILE =
-# If the ALLEXTERNALS tag is set to YES all external class will be listed in the
-# class index. If set to NO only the inherited external classes will be listed.
+# If the ALLEXTERNALS tag is set to YES, all external class will be listed in
+# the class index. If set to NO, only the inherited external classes will be
+# listed.
# The default value is: NO.
ALLEXTERNALS = NO
-# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed in
-# the modules index. If set to NO, only the current project's groups will be
+# If the EXTERNAL_GROUPS tag is set to YES, all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will be
# listed.
# The default value is: YES.
EXTERNAL_GROUPS = YES
-# If the EXTERNAL_PAGES tag is set to YES all external pages will be listed in
+# If the EXTERNAL_PAGES tag is set to YES, all external pages will be listed in
# the related pages index. If set to NO, only the current project's pages will
# be listed.
# The default value is: YES.
EXTERNAL_PAGES = YES
-# The PERL_PATH should be the absolute path and name of the perl script
-# interpreter (i.e. the result of 'which perl').
-# The default file (with absolute path) is: /usr/bin/perl.
-
-PERL_PATH = /usr/bin/perl
-
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
-# If the CLASS_DIAGRAMS tag is set to YES doxygen will generate a class diagram
+# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram
# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to
# NO turns the diagrams off. Note that this option also works with HAVE_DOT
# disabled, but it is recommended to install and use dot, since it yields more
@@ -2042,15 +2194,6 @@ PERL_PATH = /usr/bin/perl
CLASS_DIAGRAMS = YES
-# You can define message sequence charts within doxygen comments using the \msc
-# command. Doxygen will then run the mscgen tool (see:
-# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the
-# documentation. The MSCGEN_PATH tag allows you to specify the directory where
-# the mscgen tool resides. If left empty the tool is assumed to be found in the
-# default search path.
-
-MSCGEN_PATH =
-
# You can include diagrams made with dia in doxygen documentation. Doxygen will
# then run dia to produce the diagram and insert it in the documentation. The
# DIA_PATH tag allows you to specify the directory where the dia binary resides.
@@ -2058,7 +2201,7 @@ MSCGEN_PATH =
DIA_PATH =
-# If set to YES, the inheritance and collaboration graphs will hide inheritance
+# If set to YES the inheritance and collaboration graphs will hide inheritance
# and usage relations if the target is undocumented or is not a class.
# The default value is: YES.
@@ -2131,7 +2274,7 @@ COLLABORATION_GRAPH = YES
GROUP_GRAPHS = YES
-# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# If the UML_LOOK tag is set to YES, doxygen will generate inheritance and
# collaboration diagrams in a style similar to the OMG's Unified Modeling
# Language.
# The default value is: NO.
@@ -2183,7 +2326,8 @@ INCLUDED_BY_GRAPH = YES
#
# Note that enabling this option will significantly increase the time of a run.
# So in most cases it will be better to enable call graphs for selected
-# functions only using the \callgraph command.
+# functions only using the \callgraph command. Disabling a call graph can be
+# accomplished by means of the command \hidecallgraph.
# The default value is: NO.
# This tag requires that the tag HAVE_DOT is set to YES.
@@ -2194,7 +2338,8 @@ CALL_GRAPH = NO
#
# Note that enabling this option will significantly increase the time of a run.
# So in most cases it will be better to enable caller graphs for selected
-# functions only using the \callergraph command.
+# functions only using the \callergraph command. Disabling a caller graph can be
+# accomplished by means of the command \hidecallergraph.
# The default value is: NO.
# This tag requires that the tag HAVE_DOT is set to YES.
@@ -2217,11 +2362,15 @@ GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
-# generated by dot.
+# generated by dot. For an explanation of the image formats see the section
+# output formats in the documentation of the dot tool (Graphviz (see:
+# http://www.graphviz.org/)).
# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order
# to make the SVG files visible in IE 9+ (other browsers do not have this
# requirement).
-# Possible values are: png, jpg, gif and svg.
+# Possible values are: png, jpg, gif, svg, png:gd, png:gd:gd, png:cairo,
+# png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and
+# png:gdiplus:gdiplus.
# The default value is: png.
# This tag requires that the tag HAVE_DOT is set to YES.
@@ -2269,10 +2418,19 @@ DIAFILE_DIRS =
# PlantUML is not used or called during a preprocessing step. Doxygen will
# generate a warning when it encounters a \startuml command in this case and
# will not generate output for the diagram.
-# This tag requires that the tag HAVE_DOT is set to YES.
PLANTUML_JAR_PATH =
+# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a
+# configuration file for plantuml.
+
+PLANTUML_CFG_FILE =
+
+# When using plantuml, the specified paths are searched for files specified by
+# the !include statement in a plantuml block.
+
+PLANTUML_INCLUDE_PATH =
+
# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes
# that will be shown in the graph. If the number of nodes in a graph becomes
# larger than this value, doxygen will truncate the graph, which is visualized
@@ -2309,7 +2467,7 @@ MAX_DOT_GRAPH_DEPTH = 0
DOT_TRANSPARENT = NO
-# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output
# files in one run (i.e. multiple -o and -T options on the command line). This
# makes dot run faster, but since only newer versions of dot (>1.8.10) support
# this, this feature is disabled by default.
@@ -2326,7 +2484,7 @@ DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES
-# If the DOT_CLEANUP tag is set to YES doxygen will remove the intermediate dot
+# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot
# files that are used to generate the various graphs.
# The default value is: YES.
# This tag requires that the tag HAVE_DOT is set to YES.
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 6185d00..540b027 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -1,19 +1,12 @@
AM_CPPFLAGS = -I$(top_srcdir)/libusb
LDADD = ../libusb/libusb-1.0.la
+LIBS =
-noinst_PROGRAMS = listdevs xusb fxload hotplugtest testlibusb
+noinst_PROGRAMS = dpfp dpfp_threaded fxload hotplugtest listdevs sam3u_benchmark testlibusb xusb
-if HAVE_SIGACTION
-noinst_PROGRAMS += dpfp
-
-if THREADS_POSIX
-dpfp_threaded_CFLAGS = $(AM_CFLAGS)
-noinst_PROGRAMS += dpfp_threaded
-endif
-
-sam3u_benchmark_SOURCES = sam3u_benchmark.c
-noinst_PROGRAMS += sam3u_benchmark
-endif
+dpfp_threaded_CPPFLAGS = $(AM_CPPFLAGS) -DDPFP_THREADED
+dpfp_threaded_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
+dpfp_threaded_LDADD = $(LDADD) $(THREAD_LIBS)
+dpfp_threaded_SOURCES = dpfp.c
fxload_SOURCES = ezusb.c ezusb.h fxload.c
-fxload_CFLAGS = $(THREAD_CFLAGS) $(AM_CFLAGS)
diff --git a/examples/dpfp.c b/examples/dpfp.c
index 77f9476..a3a76df 100644
--- a/examples/dpfp.c
+++ b/examples/dpfp.c
@@ -1,6 +1,8 @@
/*
* libusb example program to manipulate U.are.U 4000B fingerprint scanner.
* Copyright © 2007 Daniel Drake <dsd@gentoo.org>
+ * Copyright © 2016 Nathan Hjelm <hjelmn@mac.com>
+ * Copyright © 2020 Chris Dickens <christopher.a.dickens@gmail.com>
*
* Basic image capture program only, does not consider the powerup quirks or
* the fact that image encryption may be enabled. Not expected to work
@@ -21,14 +23,121 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <config.h>
+
#include <errno.h>
#include <signal.h>
-#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "libusb.h"
+#if defined(_MSC_VER)
+#define snprintf _snprintf
+#endif
+
+#if defined(DPFP_THREADED)
+#if defined(PLATFORM_POSIX)
+#include <fcntl.h>
+#include <pthread.h>
+#include <semaphore.h>
+#include <unistd.h>
+
+#define THREAD_RETURN_VALUE NULL
+typedef sem_t * semaphore_t;
+typedef pthread_t thread_t;
+
+static inline semaphore_t semaphore_create(void)
+{
+ sem_t *semaphore;
+ char name[50];
+
+ sprintf(name, "/org.libusb.example.dpfp_threaded:%d", (int)getpid());
+ semaphore = sem_open(name, O_CREAT | O_EXCL, 0, 0);
+ if (semaphore == SEM_FAILED)
+ return NULL;
+ /* Remove semaphore so that it does not persist after process exits */
+ (void)sem_unlink(name);
+ return semaphore;
+}
+
+static inline void semaphore_give(semaphore_t semaphore)
+{
+ (void)sem_post(semaphore);
+}
+
+static inline void semaphore_take(semaphore_t semaphore)
+{
+ (void)sem_wait(semaphore);
+}
+
+static inline void semaphore_destroy(semaphore_t semaphore)
+{
+ (void)sem_close(semaphore);
+}
+
+static inline int thread_create(thread_t *thread,
+ void *(*thread_entry)(void *arg), void *arg)
+{
+ return pthread_create(thread, NULL, thread_entry, arg) == 0 ? 0 : -1;
+}
+
+static inline void thread_join(thread_t thread)
+{
+ (void)pthread_join(thread, NULL);
+}
+#elif defined(PLATFORM_WINDOWS)
+#define THREAD_RETURN_VALUE 0
+typedef HANDLE semaphore_t;
+typedef HANDLE thread_t;
+
+#if defined(__CYGWIN__)
+typedef DWORD thread_return_t;
+#else
+#include <process.h>
+typedef unsigned thread_return_t;
+#endif
+
+static inline semaphore_t semaphore_create(void)
+{
+ return CreateSemaphore(NULL, 0, 1, NULL);
+}
+
+static inline void semaphore_give(semaphore_t semaphore)
+{
+ (void)ReleaseSemaphore(semaphore, 1, NULL);
+}
+
+static inline void semaphore_take(semaphore_t semaphore)
+{
+ (void)WaitForSingleObject(semaphore, INFINITE);
+}
+
+static inline void semaphore_destroy(semaphore_t semaphore)
+{
+ (void)CloseHandle(semaphore);
+}
+
+static inline int thread_create(thread_t *thread,
+ thread_return_t (__stdcall *thread_entry)(void *arg), void *arg)
+{
+#if defined(__CYGWIN__)
+ *thread = CreateThread(NULL, 0, thread_entry, arg, 0, NULL);
+#else
+ *thread = (HANDLE)_beginthreadex(NULL, 0, thread_entry, arg, 0, NULL);
+#endif
+ return *thread != NULL ? 0 : -1;
+}
+
+static inline void thread_join(thread_t thread)
+{
+ (void)WaitForSingleObject(thread, INFINITE);
+ (void)CloseHandle(thread);
+}
+#endif
+#endif
+
#define EP_INTR (1 | LIBUSB_ENDPOINT_IN)
#define EP_DATA (2 | LIBUSB_ENDPOINT_IN)
#define CTRL_IN (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_IN)
@@ -57,25 +166,65 @@ enum {
};
static int state = 0;
-static struct libusb_device_handle *devh = NULL;
+static libusb_device_handle *devh = NULL;
static unsigned char imgbuf[0x1b340];
static unsigned char irqbuf[INTR_LENGTH];
static struct libusb_transfer *img_transfer = NULL;
static struct libusb_transfer *irq_transfer = NULL;
static int img_idx = 0;
-static int do_exit = 0;
+static volatile sig_atomic_t do_exit = 0;
+
+#if defined(DPFP_THREADED)
+static semaphore_t exit_semaphore;
+static thread_t poll_thread;
+#endif
+
+static void request_exit(sig_atomic_t code)
+{
+ do_exit = code;
+#if defined(DPFP_THREADED)
+ semaphore_give(exit_semaphore);
+#endif
+}
+
+#if defined(DPFP_THREADED)
+#if defined(PLATFORM_POSIX)
+static void *poll_thread_main(void *arg)
+#elif defined(PLATFORM_WINDOWS)
+static thread_return_t __stdcall poll_thread_main(void *arg)
+#endif
+{
+ (void)arg;
+
+ printf("poll thread running\n");
+
+ while (!do_exit) {
+ struct timeval tv = { 1, 0 };
+ int r;
+
+ r = libusb_handle_events_timeout(NULL, &tv);
+ if (r < 0) {
+ request_exit(2);
+ break;
+ }
+ }
+
+ printf("poll thread shutting down\n");
+ return THREAD_RETURN_VALUE;
+}
+#endif
static int find_dpfp_device(void)
{
devh = libusb_open_device_with_vid_pid(NULL, 0x05ba, 0x000a);
- return devh ? 0 : -EIO;
+ return devh ? 0 : -ENODEV;
}
static int print_f0_data(void)
{
unsigned char data[0x10];
+ size_t i;
int r;
- unsigned int i;
r = libusb_control_transfer(devh, CTRL_IN, USB_RQ, 0xf0, 0, data,
sizeof(data), 0);
@@ -83,14 +232,14 @@ static int print_f0_data(void)
fprintf(stderr, "F0 error %d\n", r);
return r;
}
- if ((unsigned int) r < sizeof(data)) {
+ if (r < (int)sizeof(data)) {
fprintf(stderr, "short read (%d)\n", r);
return -1;
}
printf("F0 data:");
for (i = 0; i < sizeof(data); i++)
- printf("%02x ", data[i]);
+ printf(" %02x", data[i]);
printf("\n");
return 0;
}
@@ -104,7 +253,7 @@ static int get_hwstat(unsigned char *status)
fprintf(stderr, "read hwstat error %d\n", r);
return r;
}
- if ((unsigned int) r < 1) {
+ if (r < 1) {
fprintf(stderr, "short read (%d)\n", r);
return -1;
}
@@ -123,8 +272,8 @@ static int set_hwstat(unsigned char data)
fprintf(stderr, "set hwstat error %d\n", r);
return r;
}
- if ((unsigned int) r < 1) {
- fprintf(stderr, "short write (%d)", r);
+ if (r < 1) {
+ fprintf(stderr, "short write (%d)\n", r);
return -1;
}
@@ -134,15 +283,15 @@ static int set_hwstat(unsigned char data)
static int set_mode(unsigned char data)
{
int r;
- printf("set mode %02x\n", data);
+ printf("set mode %02x\n", data);
r = libusb_control_transfer(devh, CTRL_OUT, USB_RQ, 0x4e, 0, &data, 1, 0);
if (r < 0) {
fprintf(stderr, "set mode error %d\n", r);
return r;
}
- if ((unsigned int) r < 1) {
- fprintf(stderr, "short write (%d)", r);
+ if (r < 1) {
+ fprintf(stderr, "short write (%d)\n", r);
return -1;
}
@@ -153,18 +302,18 @@ static void LIBUSB_CALL cb_mode_changed(struct libusb_transfer *transfer)
{
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
fprintf(stderr, "mode change transfer not completed!\n");
- do_exit = 2;
+ request_exit(2);
}
printf("async cb_mode_changed length=%d actual_length=%d\n",
transfer->length, transfer->actual_length);
if (next_state() < 0)
- do_exit = 2;
+ request_exit(2);
}
static int set_mode_async(unsigned char data)
{
- unsigned char *buf = (unsigned char*) malloc(LIBUSB_CONTROL_SETUP_SIZE + 1);
+ unsigned char *buf = malloc(LIBUSB_CONTROL_SETUP_SIZE + 1);
struct libusb_transfer *transfer;
if (!buf)
@@ -203,7 +352,7 @@ static int do_sync_intr(unsigned char *data)
return -1;
}
- printf("recv interrupt %04x\n", *((uint16_t *) data));
+ printf("recv interrupt %04x\n", *((uint16_t *)data));
return 0;
}
@@ -223,17 +372,17 @@ static int sync_intr(unsigned char type)
static int save_to_file(unsigned char *data)
{
- FILE *fd;
+ FILE *f;
char filename[64];
snprintf(filename, sizeof(filename), "finger%d.pgm", img_idx++);
- fd = fopen(filename, "w");
- if (!fd)
+ f = fopen(filename, "w");
+ if (!f)
return -1;
- fputs("P5 384 289 255 ", fd);
- (void) fwrite(data + 64, 1, 384*289, fd);
- fclose(fd);
+ fputs("P5 384 289 255 ", f);
+ (void)fwrite(data + 64, 1, 384*289, f);
+ fclose(f);
printf("saved image to %s\n", filename);
return 0;
}
@@ -241,6 +390,7 @@ static int save_to_file(unsigned char *data)
static int next_state(void)
{
int r = 0;
+
printf("old state: %d\n", state);
switch (state) {
case STATE_AWAIT_IRQ_FINGER_REMOVED:
@@ -282,57 +432,60 @@ static void LIBUSB_CALL cb_irq(struct libusb_transfer *transfer)
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
fprintf(stderr, "irq transfer status %d?\n", transfer->status);
- do_exit = 2;
- libusb_free_transfer(transfer);
- irq_transfer = NULL;
- return;
+ goto err_free_transfer;
}
printf("IRQ callback %02x\n", irqtype);
switch (state) {
case STATE_AWAIT_IRQ_FINGER_DETECTED:
if (irqtype == 0x01) {
- if (next_state() < 0) {
- do_exit = 2;
- return;
- }
+ if (next_state() < 0)
+ goto err_free_transfer;
} else {
printf("finger-on-sensor detected in wrong state!\n");
}
break;
case STATE_AWAIT_IRQ_FINGER_REMOVED:
if (irqtype == 0x02) {
- if (next_state() < 0) {
- do_exit = 2;
- return;
- }
+ if (next_state() < 0)
+ goto err_free_transfer;
} else {
printf("finger-on-sensor detected in wrong state!\n");
}
break;
}
if (libusb_submit_transfer(irq_transfer) < 0)
- do_exit = 2;
+ goto err_free_transfer;
+
+ return;
+
+err_free_transfer:
+ libusb_free_transfer(transfer);
+ irq_transfer = NULL;
+ request_exit(2);
}
static void LIBUSB_CALL cb_img(struct libusb_transfer *transfer)
{
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
fprintf(stderr, "img transfer status %d?\n", transfer->status);
- do_exit = 2;
- libusb_free_transfer(transfer);
- img_transfer = NULL;
- return;
+ goto err_free_transfer;
}
printf("Image callback\n");
save_to_file(imgbuf);
- if (next_state() < 0) {
- do_exit = 2;
- return;
- }
+ if (next_state() < 0)
+ goto err_free_transfer;
+
if (libusb_submit_transfer(img_transfer) < 0)
- do_exit = 2;
+ goto err_free_transfer;
+
+ return;
+
+err_free_transfer:
+ libusb_free_transfer(transfer);
+ img_transfer = NULL;
+ request_exit(2);
}
static int init_capture(void)
@@ -413,17 +566,33 @@ static void sighandler(int signum)
{
(void)signum;
- do_exit = 1;
+ request_exit(1);
}
-int main(void)
+static void setup_signals(void)
{
+#if defined(PLATFORM_POSIX)
struct sigaction sigact;
+
+ sigact.sa_handler = sighandler;
+ sigemptyset(&sigact.sa_mask);
+ sigact.sa_flags = 0;
+ (void)sigaction(SIGINT, &sigact, NULL);
+ (void)sigaction(SIGTERM, &sigact, NULL);
+ (void)sigaction(SIGQUIT, &sigact, NULL);
+#else
+ (void)signal(SIGINT, sighandler);
+ (void)signal(SIGTERM, sighandler);
+#endif
+}
+
+int main(void)
+{
int r;
r = libusb_init(NULL);
if (r < 0) {
- fprintf(stderr, "failed to initialise libusb\n");
+ fprintf(stderr, "failed to initialise libusb %d - %s\n", r, libusb_strerror(r));
exit(1);
}
@@ -435,7 +604,7 @@ int main(void)
r = libusb_claim_interface(devh, 0);
if (r < 0) {
- fprintf(stderr, "usb_claim_interface error %d\n", r);
+ fprintf(stderr, "claim interface error %d - %s\n", r, libusb_strerror(r));
goto out;
}
printf("claimed interface\n");
@@ -449,45 +618,66 @@ int main(void)
goto out_deinit;
/* async from here onwards */
+ setup_signals();
r = alloc_transfers();
if (r < 0)
goto out_deinit;
+#if defined(DPFP_THREADED)
+ exit_semaphore = semaphore_create();
+ if (!exit_semaphore) {
+ fprintf(stderr, "failed to initialise semaphore\n");
+ goto out_deinit;
+ }
+
+ r = thread_create(&poll_thread, poll_thread_main, NULL);
+ if (r) {
+ semaphore_destroy(exit_semaphore);
+ goto out_deinit;
+ }
+
r = init_capture();
if (r < 0)
- goto out_deinit;
+ request_exit(2);
- sigact.sa_handler = sighandler;
- sigemptyset(&sigact.sa_mask);
- sigact.sa_flags = 0;
- sigaction(SIGINT, &sigact, NULL);
- sigaction(SIGTERM, &sigact, NULL);
- sigaction(SIGQUIT, &sigact, NULL);
+ while (!do_exit)
+ semaphore_take(exit_semaphore);
+#else
+ r = init_capture();
+ if (r < 0)
+ goto out_deinit;
while (!do_exit) {
r = libusb_handle_events(NULL);
if (r < 0)
- goto out_deinit;
+ request_exit(2);
}
+#endif
printf("shutting down...\n");
- if (irq_transfer) {
- r = libusb_cancel_transfer(irq_transfer);
- if (r < 0)
- goto out_deinit;
- }
+#if defined(DPFP_THREADED)
+ thread_join(poll_thread);
+ semaphore_destroy(exit_semaphore);
+#endif
if (img_transfer) {
r = libusb_cancel_transfer(img_transfer);
if (r < 0)
- goto out_deinit;
+ fprintf(stderr, "failed to cancel transfer %d - %s\n", r, libusb_strerror(r));
}
- while (irq_transfer || img_transfer)
+ if (irq_transfer) {
+ r = libusb_cancel_transfer(irq_transfer);
+ if (r < 0)
+ fprintf(stderr, "failed to cancel transfer %d - %s\n", r, libusb_strerror(r));
+ }
+
+ while (img_transfer || irq_transfer) {
if (libusb_handle_events(NULL) < 0)
break;
+ }
if (do_exit == 1)
r = 0;
@@ -495,8 +685,10 @@ int main(void)
r = 1;
out_deinit:
- libusb_free_transfer(img_transfer);
- libusb_free_transfer(irq_transfer);
+ if (img_transfer)
+ libusb_free_transfer(img_transfer);
+ if (irq_transfer)
+ libusb_free_transfer(irq_transfer);
set_mode(0);
set_hwstat(0x80);
out_release:
diff --git a/examples/dpfp_threaded.c b/examples/dpfp_threaded.c
deleted file mode 100644
index ee6aad0..0000000
--- a/examples/dpfp_threaded.c
+++ /dev/null
@@ -1,557 +0,0 @@
-/*
- * libusb example program to manipulate U.are.U 4000B fingerprint scanner.
- * Copyright © 2007 Daniel Drake <dsd@gentoo.org>
- * Copyright © 2016 Nathan Hjelm <hjelmn@mac.com>
- *
- * Basic image capture program only, does not consider the powerup quirks or
- * the fact that image encryption may be enabled. Not expected to work
- * flawlessly all of the time.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <errno.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <signal.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-
-#include "libusb.h"
-
-#define EP_INTR (1 | LIBUSB_ENDPOINT_IN)
-#define EP_DATA (2 | LIBUSB_ENDPOINT_IN)
-#define CTRL_IN (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_IN)
-#define CTRL_OUT (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT)
-#define USB_RQ 0x04
-#define INTR_LENGTH 64
-#define SEM_NAME "/org.libusb.example.dpfp_threaded"
-
-enum {
- MODE_INIT = 0x00,
- MODE_AWAIT_FINGER_ON = 0x10,
- MODE_AWAIT_FINGER_OFF = 0x12,
- MODE_CAPTURE = 0x20,
- MODE_SHUT_UP = 0x30,
- MODE_READY = 0x80,
-};
-
-static int next_state(void);
-
-enum {
- STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_ON = 1,
- STATE_AWAIT_IRQ_FINGER_DETECTED,
- STATE_AWAIT_MODE_CHANGE_CAPTURE,
- STATE_AWAIT_IMAGE,
- STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_OFF,
- STATE_AWAIT_IRQ_FINGER_REMOVED,
-};
-
-static int state = 0;
-static struct libusb_device_handle *devh = NULL;
-static unsigned char imgbuf[0x1b340];
-static unsigned char irqbuf[INTR_LENGTH];
-static struct libusb_transfer *img_transfer = NULL;
-static struct libusb_transfer *irq_transfer = NULL;
-static int img_idx = 0;
-static volatile sig_atomic_t do_exit = 0;
-
-static pthread_t poll_thread;
-static sem_t *exit_sem;
-
-static void request_exit(sig_atomic_t code)
-{
- do_exit = code;
- sem_post(exit_sem);
-}
-
-static void *poll_thread_main(void *arg)
-{
- int r = 0;
- printf("poll thread running\n");
-
- (void)arg;
-
- while (!do_exit) {
- struct timeval tv = { 1, 0 };
- r = libusb_handle_events_timeout(NULL, &tv);
- if (r < 0) {
- request_exit(2);
- break;
- }
- }
-
- printf("poll thread shutting down\n");
- return NULL;
-}
-
-static int find_dpfp_device(void)
-{
- devh = libusb_open_device_with_vid_pid(NULL, 0x05ba, 0x000a);
- return devh ? 0 : -EIO;
-}
-
-static int print_f0_data(void)
-{
- unsigned char data[0x10];
- int r;
- unsigned int i;
-
- r = libusb_control_transfer(devh, CTRL_IN, USB_RQ, 0xf0, 0, data,
- sizeof(data), 0);
- if (r < 0) {
- fprintf(stderr, "F0 error %d\n", r);
- return r;
- }
- if ((unsigned int) r < sizeof(data)) {
- fprintf(stderr, "short read (%d)\n", r);
- return -1;
- }
-
- printf("F0 data:");
- for (i = 0; i < sizeof(data); i++)
- printf("%02x ", data[i]);
- printf("\n");
- return 0;
-}
-
-static int get_hwstat(unsigned char *status)
-{
- int r;
-
- r = libusb_control_transfer(devh, CTRL_IN, USB_RQ, 0x07, 0, status, 1, 0);
- if (r < 0) {
- fprintf(stderr, "read hwstat error %d\n", r);
- return r;
- }
- if ((unsigned int) r < 1) {
- fprintf(stderr, "short read (%d)\n", r);
- return -1;
- }
-
- printf("hwstat reads %02x\n", *status);
- return 0;
-}
-
-static int set_hwstat(unsigned char data)
-{
- int r;
-
- printf("set hwstat to %02x\n", data);
- r = libusb_control_transfer(devh, CTRL_OUT, USB_RQ, 0x07, 0, &data, 1, 0);
- if (r < 0) {
- fprintf(stderr, "set hwstat error %d\n", r);
- return r;
- }
- if ((unsigned int) r < 1) {
- fprintf(stderr, "short write (%d)", r);
- return -1;
- }
-
- return 0;
-}
-
-static int set_mode(unsigned char data)
-{
- int r;
- printf("set mode %02x\n", data);
-
- r = libusb_control_transfer(devh, CTRL_OUT, USB_RQ, 0x4e, 0, &data, 1, 0);
- if (r < 0) {
- fprintf(stderr, "set mode error %d\n", r);
- return r;
- }
- if ((unsigned int) r < 1) {
- fprintf(stderr, "short write (%d)", r);
- return -1;
- }
-
- return 0;
-}
-
-static void LIBUSB_CALL cb_mode_changed(struct libusb_transfer *transfer)
-{
- if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
- fprintf(stderr, "mode change transfer not completed!\n");
- request_exit(2);
- }
-
- printf("async cb_mode_changed length=%d actual_length=%d\n",
- transfer->length, transfer->actual_length);
- if (next_state() < 0)
- request_exit(2);
-}
-
-static int set_mode_async(unsigned char data)
-{
- unsigned char *buf = (unsigned char*) malloc(LIBUSB_CONTROL_SETUP_SIZE + 1);
- struct libusb_transfer *transfer;
-
- if (!buf)
- return -ENOMEM;
-
- transfer = libusb_alloc_transfer(0);
- if (!transfer) {
- free(buf);
- return -ENOMEM;
- }
-
- printf("async set mode %02x\n", data);
- libusb_fill_control_setup(buf, CTRL_OUT, USB_RQ, 0x4e, 0, 1);
- buf[LIBUSB_CONTROL_SETUP_SIZE] = data;
- libusb_fill_control_transfer(transfer, devh, buf, cb_mode_changed, NULL,
- 1000);
-
- transfer->flags = LIBUSB_TRANSFER_SHORT_NOT_OK
- | LIBUSB_TRANSFER_FREE_BUFFER | LIBUSB_TRANSFER_FREE_TRANSFER;
- return libusb_submit_transfer(transfer);
-}
-
-static int do_sync_intr(unsigned char *data)
-{
- int r;
- int transferred;
-
- r = libusb_interrupt_transfer(devh, EP_INTR, data, INTR_LENGTH,
- &transferred, 1000);
- if (r < 0) {
- fprintf(stderr, "intr error %d\n", r);
- return r;
- }
- if (transferred < INTR_LENGTH) {
- fprintf(stderr, "short read (%d)\n", r);
- return -1;
- }
-
- printf("recv interrupt %04x\n", *((uint16_t *) data));
- return 0;
-}
-
-static int sync_intr(unsigned char type)
-{
- int r;
- unsigned char data[INTR_LENGTH];
-
- while (1) {
- r = do_sync_intr(data);
- if (r < 0)
- return r;
- if (data[0] == type)
- return 0;
- }
-}
-
-static int save_to_file(unsigned char *data)
-{
- FILE *fd;
- char filename[64];
-
- snprintf(filename, sizeof(filename), "finger%d.pgm", img_idx++);
- fd = fopen(filename, "w");
- if (!fd)
- return -1;
-
- fputs("P5 384 289 255 ", fd);
- (void) fwrite(data + 64, 1, 384*289, fd);
- fclose(fd);
- printf("saved image to %s\n", filename);
- return 0;
-}
-
-static int next_state(void)
-{
- int r = 0;
- printf("old state: %d\n", state);
- switch (state) {
- case STATE_AWAIT_IRQ_FINGER_REMOVED:
- state = STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_ON;
- r = set_mode_async(MODE_AWAIT_FINGER_ON);
- break;
- case STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_ON:
- state = STATE_AWAIT_IRQ_FINGER_DETECTED;
- break;
- case STATE_AWAIT_IRQ_FINGER_DETECTED:
- state = STATE_AWAIT_MODE_CHANGE_CAPTURE;
- r = set_mode_async(MODE_CAPTURE);
- break;
- case STATE_AWAIT_MODE_CHANGE_CAPTURE:
- state = STATE_AWAIT_IMAGE;
- break;
- case STATE_AWAIT_IMAGE:
- state = STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_OFF;
- r = set_mode_async(MODE_AWAIT_FINGER_OFF);
- break;
- case STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_OFF:
- state = STATE_AWAIT_IRQ_FINGER_REMOVED;
- break;
- default:
- printf("unrecognised state %d\n", state);
- }
- if (r < 0) {
- fprintf(stderr, "error detected changing state\n");
- return r;
- }
-
- printf("new state: %d\n", state);
- return 0;
-}
-
-static void LIBUSB_CALL cb_irq(struct libusb_transfer *transfer)
-{
- unsigned char irqtype = transfer->buffer[0];
-
- if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
- fprintf(stderr, "irq transfer status %d?\n", transfer->status);
- irq_transfer = NULL;
- request_exit(2);
- return;
- }
-
- printf("IRQ callback %02x\n", irqtype);
- switch (state) {
- case STATE_AWAIT_IRQ_FINGER_DETECTED:
- if (irqtype == 0x01) {
- if (next_state() < 0) {
- request_exit(2);
- return;
- }
- } else {
- printf("finger-on-sensor detected in wrong state!\n");
- }
- break;
- case STATE_AWAIT_IRQ_FINGER_REMOVED:
- if (irqtype == 0x02) {
- if (next_state() < 0) {
- request_exit(2);
- return;
- }
- } else {
- printf("finger-on-sensor detected in wrong state!\n");
- }
- break;
- }
- if (libusb_submit_transfer(irq_transfer) < 0)
- request_exit(2);
-}
-
-static void LIBUSB_CALL cb_img(struct libusb_transfer *transfer)
-{
- if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
- fprintf(stderr, "img transfer status %d?\n", transfer->status);
- img_transfer = NULL;
- request_exit(2);
- return;
- }
-
- printf("Image callback\n");
- save_to_file(imgbuf);
- if (next_state() < 0) {
- request_exit(2);
- return;
- }
- if (libusb_submit_transfer(img_transfer) < 0)
- request_exit(2);
-}
-
-static int init_capture(void)
-{
- int r;
-
- r = libusb_submit_transfer(irq_transfer);
- if (r < 0)
- return r;
-
- r = libusb_submit_transfer(img_transfer);
- if (r < 0) {
- libusb_cancel_transfer(irq_transfer);
- while (irq_transfer)
- if (libusb_handle_events(NULL) < 0)
- break;
- return r;
- }
-
- /* start state machine */
- state = STATE_AWAIT_IRQ_FINGER_REMOVED;
- return next_state();
-}
-
-static int do_init(void)
-{
- unsigned char status;
- int r;
-
- r = get_hwstat(&status);
- if (r < 0)
- return r;
-
- if (!(status & 0x80)) {
- r = set_hwstat(status | 0x80);
- if (r < 0)
- return r;
- r = get_hwstat(&status);
- if (r < 0)
- return r;
- }
-
- status &= ~0x80;
- r = set_hwstat(status);
- if (r < 0)
- return r;
-
- r = get_hwstat(&status);
- if (r < 0)
- return r;
-
- r = sync_intr(0x56);
- if (r < 0)
- return r;
-
- return 0;
-}
-
-static int alloc_transfers(void)
-{
- img_transfer = libusb_alloc_transfer(0);
- if (!img_transfer)
- return -ENOMEM;
-
- irq_transfer = libusb_alloc_transfer(0);
- if (!irq_transfer)
- return -ENOMEM;
-
- libusb_fill_bulk_transfer(img_transfer, devh, EP_DATA, imgbuf,
- sizeof(imgbuf), cb_img, NULL, 0);
- libusb_fill_interrupt_transfer(irq_transfer, devh, EP_INTR, irqbuf,
- sizeof(irqbuf), cb_irq, NULL, 0);
-
- return 0;
-}
-
-static void sighandler(int signum)
-{
- (void)signum;
-
- request_exit(1);
-}
-
-int main(void)
-{
- struct sigaction sigact;
- int r = 1;
-
- exit_sem = sem_open (SEM_NAME, O_CREAT, 0);
- if (!exit_sem) {
- fprintf(stderr, "failed to initialise semaphore error %d", errno);
- exit(1);
- }
-
- /* only using this semaphore in this process so go ahead and unlink it now */
- sem_unlink (SEM_NAME);
-
- r = libusb_init(NULL);
- if (r < 0) {
- fprintf(stderr, "failed to initialise libusb\n");
- exit(1);
- }
-
- r = find_dpfp_device();
- if (r < 0) {
- fprintf(stderr, "Could not find/open device\n");
- goto out;
- }
-
- r = libusb_claim_interface(devh, 0);
- if (r < 0) {
- fprintf(stderr, "usb_claim_interface error %d %s\n", r, strerror(-r));
- goto out;
- }
- printf("claimed interface\n");
-
- r = print_f0_data();
- if (r < 0)
- goto out_release;
-
- r = do_init();
- if (r < 0)
- goto out_deinit;
-
- /* async from here onwards */
-
- sigact.sa_handler = sighandler;
- sigemptyset(&sigact.sa_mask);
- sigact.sa_flags = 0;
- sigaction(SIGINT, &sigact, NULL);
- sigaction(SIGTERM, &sigact, NULL);
- sigaction(SIGQUIT, &sigact, NULL);
-
- r = pthread_create(&poll_thread, NULL, poll_thread_main, NULL);
- if (r)
- goto out_deinit;
-
- r = alloc_transfers();
- if (r < 0) {
- request_exit(1);
- pthread_join(poll_thread, NULL);
- goto out_deinit;
- }
-
- r = init_capture();
- if (r < 0) {
- request_exit(1);
- pthread_join(poll_thread, NULL);
- goto out_deinit;
- }
-
- while (!do_exit)
- sem_wait(exit_sem);
-
- printf("shutting down...\n");
- pthread_join(poll_thread, NULL);
-
- r = libusb_cancel_transfer(irq_transfer);
- if (r < 0) {
- request_exit(1);
- goto out_deinit;
- }
-
- r = libusb_cancel_transfer(img_transfer);
- if (r < 0) {
- request_exit(1);
- goto out_deinit;
- }
-
- while (img_transfer || irq_transfer)
- if (libusb_handle_events(NULL) < 0)
- break;
-
- if (do_exit == 1)
- r = 0;
- else
- r = 1;
-
-out_deinit:
- libusb_free_transfer(img_transfer);
- libusb_free_transfer(irq_transfer);
- set_mode(0);
- set_hwstat(0x80);
-out_release:
- libusb_release_interface(devh, 0);
-out:
- libusb_close(devh);
- libusb_exit(NULL);
- return r >= 0 ? r : -r;
-}
diff --git a/examples/ezusb.c b/examples/ezusb.c
index 4fe9e65..6abd47d 100644
--- a/examples/ezusb.c
+++ b/examples/ezusb.c
@@ -20,6 +20,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+
+#include <config.h>
+
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
@@ -29,9 +32,6 @@
#include "libusb.h"
#include "ezusb.h"
-extern void logerror(const char *format, ...)
- __attribute__ ((format(printf, 1, 2)));
-
/*
* This file contains functions for uploading firmware into Cypress
* EZ-USB microcontrollers. These chips use control endpoint 0 and vendor
diff --git a/examples/ezusb.h b/examples/ezusb.h
index 129bc9a..62062c4 100644
--- a/examples/ezusb.h
+++ b/examples/ezusb.h
@@ -20,23 +20,10 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-#if !defined(_MSC_VER)
+
+#include <config.h>
+
#include <stdbool.h>
-#else
-#define __attribute__(x)
-#if !defined(bool)
-#define bool int
-#endif
-#if !defined(true)
-#define true (1 == 1)
-#endif
-#if !defined(false)
-#define false (!true)
-#endif
-#if defined(_PREFAST_)
-#pragma warning(disable:28193)
-#endif
-#endif
#define FX_TYPE_UNDEFINED -1
#define FX_TYPE_AN21 0 /* Original AnchorChips parts */
@@ -59,7 +46,7 @@
extern "C" {
#endif
-/*
+/*
* Automatically identified devices (VID, PID, type, designation).
* TODO: Could use some validation. Also where's the FX2?
*/
@@ -113,6 +100,8 @@ extern int ezusb_load_eeprom(libusb_device_handle *device,
/* Verbosity level (default 1). Can be increased or decreased with options v/q */
extern int verbose;
+extern void logerror(const char *format, ...) PRINTF_FORMAT(1, 2);
+
#ifdef __cplusplus
}
#endif
diff --git a/examples/fxload.c b/examples/fxload.c
index 1cea9c3..541c3d3 100644
--- a/examples/fxload.c
+++ b/examples/fxload.c
@@ -21,6 +21,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#include <config.h>
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -32,7 +34,7 @@
#include "libusb.h"
#include "ezusb.h"
-#if !defined(_WIN32) || defined(__CYGWIN__ )
+#if !defined(_WIN32) || defined(__CYGWIN__)
#include <syslog.h>
static bool dosyslog = false;
#include <strings.h>
@@ -48,14 +50,11 @@ static bool dosyslog = false;
#endif
void logerror(const char *format, ...)
- __attribute__ ((format (__printf__, 1, 2)));
-
-void logerror(const char *format, ...)
{
va_list ap;
va_start(ap, format);
-#if !defined(_WIN32) || defined(__CYGWIN__ )
+#if !defined(_WIN32) || defined(__CYGWIN__)
if (dosyslog)
vsyslog(LOG_ERR, format, ap);
else
diff --git a/examples/hotplugtest.c b/examples/hotplugtest.c
index 4d0db5e..94f7e56 100644
--- a/examples/hotplugtest.c
+++ b/examples/hotplugtest.c
@@ -95,7 +95,7 @@ int main(int argc, char *argv[])
}
if (!libusb_has_capability (LIBUSB_CAP_HAS_HOTPLUG)) {
- printf ("Hotplug capabilites are not supported on this platform\n");
+ printf ("Hotplug capabilities are not supported on this platform\n");
libusb_exit (NULL);
return EXIT_FAILURE;
}
diff --git a/examples/sam3u_benchmark.c b/examples/sam3u_benchmark.c
index 43d286a..33e8913 100644
--- a/examples/sam3u_benchmark.c
+++ b/examples/sam3u_benchmark.c
@@ -22,24 +22,54 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
+#include <config.h>
+
#include <errno.h>
#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include <time.h>
-#include <libusb.h>
-
+#include "libusb.h"
#define EP_DATA_IN 0x82
#define EP_ISO_IN 0x86
-static int do_exit = 0;
+static volatile sig_atomic_t do_exit = 0;
static struct libusb_device_handle *devh = NULL;
static unsigned long num_bytes = 0, num_xfer = 0;
static struct timeval tv_start;
+static void get_timestamp(struct timeval *tv)
+{
+#if defined(PLATFORM_WINDOWS)
+ static LARGE_INTEGER frequency;
+ LARGE_INTEGER counter;
+
+ if (!frequency.QuadPart)
+ QueryPerformanceFrequency(&frequency);
+
+ QueryPerformanceCounter(&counter);
+ counter.QuadPart *= 1000000;
+ counter.QuadPart /= frequency.QuadPart;
+
+ tv->tv_sec = (long)(counter.QuadPart / 1000000ULL);
+ tv->tv_usec = (long)(counter.QuadPart % 1000000ULL);
+#elif defined(HAVE_CLOCK_GETTIME)
+ struct timespec ts;
+
+ (void)clock_gettime(CLOCK_MONOTONIC, &ts);
+ tv->tv_sec = ts.tv_sec;
+ tv->tv_usec = (int)(ts.tv_nsec / 1000L);
+#else
+ gettimeofday(tv, NULL);
+#endif
+}
+
static void LIBUSB_CALL cb_xfr(struct libusb_transfer *xfr)
{
int i;
@@ -103,7 +133,7 @@ static int benchmark_in(uint8_t ep)
libusb_fill_bulk_transfer(xfr, devh, ep, buf,
sizeof(buf), cb_xfr, NULL, 0);
- gettimeofday(&tv_start, NULL);
+ get_timestamp(&tv_start);
/* NOTE: To reach maximum possible performance the program must
* submit *multiple* transfers here, not just one.
@@ -125,36 +155,39 @@ static int benchmark_in(uint8_t ep)
static void measure(void)
{
struct timeval tv_stop;
- unsigned int diff_msec;
+ unsigned long diff_msec;
- gettimeofday(&tv_stop, NULL);
+ get_timestamp(&tv_stop);
- diff_msec = (tv_stop.tv_sec - tv_start.tv_sec)*1000;
- diff_msec += (tv_stop.tv_usec - tv_start.tv_usec)/1000;
+ diff_msec = (tv_stop.tv_sec - tv_start.tv_sec) * 1000L;
+ diff_msec += (tv_stop.tv_usec - tv_start.tv_usec) / 1000L;
- printf("%lu transfers (total %lu bytes) in %u miliseconds => %lu bytes/sec\n",
- num_xfer, num_bytes, diff_msec, (num_bytes*1000)/diff_msec);
+ printf("%lu transfers (total %lu bytes) in %lu milliseconds => %lu bytes/sec\n",
+ num_xfer, num_bytes, diff_msec, (num_bytes * 1000L) / diff_msec);
}
static void sig_hdlr(int signum)
{
- switch (signum) {
- case SIGINT:
- measure();
- do_exit = 1;
- break;
- }
+ (void)signum;
+
+ measure();
+ do_exit = 1;
}
-int main(int argc, char **argv)
+int main(void)
{
int rc;
+
+#if defined(PLATFORM_POSIX)
struct sigaction sigact;
sigact.sa_handler = sig_hdlr;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = 0;
- sigaction(SIGINT, &sigact, NULL);
+ (void)sigaction(SIGINT, &sigact, NULL);
+#else
+ (void)signal(SIGINT, sig_hdlr);
+#endif
rc = libusb_init(NULL);
if (rc < 0) {
@@ -184,7 +217,7 @@ int main(int argc, char **argv)
/* Measurement has already been done by the signal handler. */
- libusb_release_interface(devh, 0);
+ libusb_release_interface(devh, 2);
out:
if (devh)
libusb_close(devh);
diff --git a/examples/testlibusb.c b/examples/testlibusb.c
index 6501a12..ba00f90 100755..100644
--- a/examples/testlibusb.c
+++ b/examples/testlibusb.c
@@ -21,18 +21,14 @@
#include <string.h>
#include "libusb.h"
-#if defined(_MSC_VER) && (_MSC_VER < 1900)
-#define snprintf _snprintf
-#endif
-
int verbose = 0;
static void print_endpoint_comp(const struct libusb_ss_endpoint_companion_descriptor *ep_comp)
{
printf(" USB 3.0 Endpoint Companion:\n");
- printf(" bMaxBurst: %d\n", ep_comp->bMaxBurst);
- printf(" bmAttributes: 0x%02x\n", ep_comp->bmAttributes);
- printf(" wBytesPerInterval: %d\n", ep_comp->wBytesPerInterval);
+ printf(" bMaxBurst: %u\n", ep_comp->bMaxBurst);
+ printf(" bmAttributes: %02xh\n", ep_comp->bmAttributes);
+ printf(" wBytesPerInterval: %u\n", ep_comp->wBytesPerInterval);
}
static void print_endpoint(const struct libusb_endpoint_descriptor *endpoint)
@@ -40,21 +36,20 @@ static void print_endpoint(const struct libusb_endpoint_descriptor *endpoint)
int i, ret;
printf(" Endpoint:\n");
- printf(" bEndpointAddress: %02xh\n", endpoint->bEndpointAddress);
- printf(" bmAttributes: %02xh\n", endpoint->bmAttributes);
- printf(" wMaxPacketSize: %d\n", endpoint->wMaxPacketSize);
- printf(" bInterval: %d\n", endpoint->bInterval);
- printf(" bRefresh: %d\n", endpoint->bRefresh);
- printf(" bSynchAddress: %d\n", endpoint->bSynchAddress);
+ printf(" bEndpointAddress: %02xh\n", endpoint->bEndpointAddress);
+ printf(" bmAttributes: %02xh\n", endpoint->bmAttributes);
+ printf(" wMaxPacketSize: %u\n", endpoint->wMaxPacketSize);
+ printf(" bInterval: %u\n", endpoint->bInterval);
+ printf(" bRefresh: %u\n", endpoint->bRefresh);
+ printf(" bSynchAddress: %u\n", endpoint->bSynchAddress);
for (i = 0; i < endpoint->extra_length;) {
if (LIBUSB_DT_SS_ENDPOINT_COMPANION == endpoint->extra[i + 1]) {
struct libusb_ss_endpoint_companion_descriptor *ep_comp;
ret = libusb_get_ss_endpoint_companion_descriptor(NULL, endpoint, &ep_comp);
- if (LIBUSB_SUCCESS != ret) {
+ if (LIBUSB_SUCCESS != ret)
continue;
- }
print_endpoint_comp(ep_comp);
@@ -70,13 +65,13 @@ static void print_altsetting(const struct libusb_interface_descriptor *interface
uint8_t i;
printf(" Interface:\n");
- printf(" bInterfaceNumber: %d\n", interface->bInterfaceNumber);
- printf(" bAlternateSetting: %d\n", interface->bAlternateSetting);
- printf(" bNumEndpoints: %d\n", interface->bNumEndpoints);
- printf(" bInterfaceClass: %d\n", interface->bInterfaceClass);
- printf(" bInterfaceSubClass: %d\n", interface->bInterfaceSubClass);
- printf(" bInterfaceProtocol: %d\n", interface->bInterfaceProtocol);
- printf(" iInterface: %d\n", interface->iInterface);
+ printf(" bInterfaceNumber: %u\n", interface->bInterfaceNumber);
+ printf(" bAlternateSetting: %u\n", interface->bAlternateSetting);
+ printf(" bNumEndpoints: %u\n", interface->bNumEndpoints);
+ printf(" bInterfaceClass: %u\n", interface->bInterfaceClass);
+ printf(" bInterfaceSubClass: %u\n", interface->bInterfaceSubClass);
+ printf(" bInterfaceProtocol: %u\n", interface->bInterfaceProtocol);
+ printf(" iInterface: %u\n", interface->iInterface);
for (i = 0; i < interface->bNumEndpoints; i++)
print_endpoint(&interface->endpoint[i]);
@@ -85,58 +80,58 @@ static void print_altsetting(const struct libusb_interface_descriptor *interface
static void print_2_0_ext_cap(struct libusb_usb_2_0_extension_descriptor *usb_2_0_ext_cap)
{
printf(" USB 2.0 Extension Capabilities:\n");
- printf(" bDevCapabilityType: %d\n", usb_2_0_ext_cap->bDevCapabilityType);
- printf(" bmAttributes: 0x%x\n", usb_2_0_ext_cap->bmAttributes);
+ printf(" bDevCapabilityType: %u\n", usb_2_0_ext_cap->bDevCapabilityType);
+ printf(" bmAttributes: %08xh\n", usb_2_0_ext_cap->bmAttributes);
}
static void print_ss_usb_cap(struct libusb_ss_usb_device_capability_descriptor *ss_usb_cap)
{
printf(" USB 3.0 Capabilities:\n");
- printf(" bDevCapabilityType: %d\n", ss_usb_cap->bDevCapabilityType);
- printf(" bmAttributes: 0x%x\n", ss_usb_cap->bmAttributes);
- printf(" wSpeedSupported: 0x%x\n", ss_usb_cap->wSpeedSupported);
- printf(" bFunctionalitySupport: %d\n", ss_usb_cap->bFunctionalitySupport);
- printf(" bU1devExitLat: %d\n", ss_usb_cap->bU1DevExitLat);
- printf(" bU2devExitLat: %d\n", ss_usb_cap->bU2DevExitLat);
+ printf(" bDevCapabilityType: %u\n", ss_usb_cap->bDevCapabilityType);
+ printf(" bmAttributes: %02xh\n", ss_usb_cap->bmAttributes);
+ printf(" wSpeedSupported: %u\n", ss_usb_cap->wSpeedSupported);
+ printf(" bFunctionalitySupport: %u\n", ss_usb_cap->bFunctionalitySupport);
+ printf(" bU1devExitLat: %u\n", ss_usb_cap->bU1DevExitLat);
+ printf(" bU2devExitLat: %u\n", ss_usb_cap->bU2DevExitLat);
}
static void print_bos(libusb_device_handle *handle)
{
struct libusb_bos_descriptor *bos;
+ uint8_t i;
int ret;
ret = libusb_get_bos_descriptor(handle, &bos);
- if (0 > ret) {
+ if (ret < 0)
return;
- }
printf(" Binary Object Store (BOS):\n");
- printf(" wTotalLength: %d\n", bos->wTotalLength);
- printf(" bNumDeviceCaps: %d\n", bos->bNumDeviceCaps);
+ printf(" wTotalLength: %u\n", bos->wTotalLength);
+ printf(" bNumDeviceCaps: %u\n", bos->bNumDeviceCaps);
- if(bos->dev_capability[0]->bDevCapabilityType == LIBUSB_BT_USB_2_0_EXTENSION) {
+ for (i = 0; i < bos->bNumDeviceCaps; i++) {
+ struct libusb_bos_dev_capability_descriptor *dev_cap = bos->dev_capability[i];
- struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension;
- ret = libusb_get_usb_2_0_extension_descriptor(NULL, bos->dev_capability[0],&usb_2_0_extension);
- if (0 > ret) {
- return;
- }
+ if (dev_cap->bDevCapabilityType == LIBUSB_BT_USB_2_0_EXTENSION) {
+ struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension;
- print_2_0_ext_cap(usb_2_0_extension);
- libusb_free_usb_2_0_extension_descriptor(usb_2_0_extension);
- }
+ ret = libusb_get_usb_2_0_extension_descriptor(NULL, dev_cap, &usb_2_0_extension);
+ if (ret < 0)
+ return;
- if(bos->dev_capability[0]->bDevCapabilityType == LIBUSB_BT_SS_USB_DEVICE_CAPABILITY) {
+ print_2_0_ext_cap(usb_2_0_extension);
+ libusb_free_usb_2_0_extension_descriptor(usb_2_0_extension);
+ } else if (dev_cap->bDevCapabilityType == LIBUSB_BT_SS_USB_DEVICE_CAPABILITY) {
+ struct libusb_ss_usb_device_capability_descriptor *ss_dev_cap;
- struct libusb_ss_usb_device_capability_descriptor *dev_cap;
- ret = libusb_get_ss_usb_device_capability_descriptor(NULL, bos->dev_capability[0],&dev_cap);
- if (0 > ret) {
- return;
- }
+ ret = libusb_get_ss_usb_device_capability_descriptor(NULL, dev_cap, &ss_dev_cap);
+ if (ret < 0)
+ return;
- print_ss_usb_cap(dev_cap);
- libusb_free_ss_usb_device_capability_descriptor(dev_cap);
- }
+ print_ss_usb_cap(ss_dev_cap);
+ libusb_free_ss_usb_device_capability_descriptor(ss_dev_cap);
+ }
+ }
libusb_free_bos_descriptor(bos);
}
@@ -154,79 +149,71 @@ static void print_configuration(struct libusb_config_descriptor *config)
uint8_t i;
printf(" Configuration:\n");
- printf(" wTotalLength: %d\n", config->wTotalLength);
- printf(" bNumInterfaces: %d\n", config->bNumInterfaces);
- printf(" bConfigurationValue: %d\n", config->bConfigurationValue);
- printf(" iConfiguration: %d\n", config->iConfiguration);
- printf(" bmAttributes: %02xh\n", config->bmAttributes);
- printf(" MaxPower: %d\n", config->MaxPower);
+ printf(" wTotalLength: %u\n", config->wTotalLength);
+ printf(" bNumInterfaces: %u\n", config->bNumInterfaces);
+ printf(" bConfigurationValue: %u\n", config->bConfigurationValue);
+ printf(" iConfiguration: %u\n", config->iConfiguration);
+ printf(" bmAttributes: %02xh\n", config->bmAttributes);
+ printf(" MaxPower: %u\n", config->MaxPower);
for (i = 0; i < config->bNumInterfaces; i++)
print_interface(&config->interface[i]);
}
-static int print_device(libusb_device *dev, int level)
+static void print_device(libusb_device *dev, libusb_device_handle *handle)
{
struct libusb_device_descriptor desc;
- libusb_device_handle *handle = NULL;
- char description[260];
- char string[256];
+ unsigned char string[256];
+ const char *speed;
int ret;
uint8_t i;
+ switch (libusb_get_device_speed(dev)) {
+ case LIBUSB_SPEED_LOW: speed = "1.5M"; break;
+ case LIBUSB_SPEED_FULL: speed = "12M"; break;
+ case LIBUSB_SPEED_HIGH: speed = "480M"; break;
+ case LIBUSB_SPEED_SUPER: speed = "5G"; break;
+ case LIBUSB_SPEED_SUPER_PLUS: speed = "10G"; break;
+ default: speed = "Unknown";
+ }
+
ret = libusb_get_device_descriptor(dev, &desc);
if (ret < 0) {
fprintf(stderr, "failed to get device descriptor");
- return -1;
+ return;
}
- ret = libusb_open(dev, &handle);
- if (LIBUSB_SUCCESS == ret) {
+ printf("Dev (bus %u, device %u): %04X - %04X speed: %s\n",
+ libusb_get_bus_number(dev), libusb_get_device_address(dev),
+ desc.idVendor, desc.idProduct, speed);
+
+ if (!handle)
+ libusb_open(dev, &handle);
+
+ if (handle) {
if (desc.iManufacturer) {
ret = libusb_get_string_descriptor_ascii(handle, desc.iManufacturer, string, sizeof(string));
if (ret > 0)
- snprintf(description, sizeof(description), "%s - ", string);
- else
- snprintf(description, sizeof(description), "%04X - ",
- desc.idVendor);
+ printf(" Manufacturer: %s\n", (char *)string);
}
- else
- snprintf(description, sizeof(description), "%04X - ",
- desc.idVendor);
if (desc.iProduct) {
ret = libusb_get_string_descriptor_ascii(handle, desc.iProduct, string, sizeof(string));
if (ret > 0)
- snprintf(description + strlen(description), sizeof(description) -
- strlen(description), "%s", string);
- else
- snprintf(description + strlen(description), sizeof(description) -
- strlen(description), "%04X", desc.idProduct);
+ printf(" Product: %s\n", (char *)string);
}
- else
- snprintf(description + strlen(description), sizeof(description) -
- strlen(description), "%04X", desc.idProduct);
- }
- else {
- snprintf(description, sizeof(description), "%04X - %04X",
- desc.idVendor, desc.idProduct);
- }
- printf("%.*sDev (bus %d, device %d): %s\n", level * 2, " ",
- libusb_get_bus_number(dev), libusb_get_device_address(dev), description);
-
- if (handle && verbose) {
- if (desc.iSerialNumber) {
+ if (desc.iSerialNumber && verbose) {
ret = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, string, sizeof(string));
if (ret > 0)
- printf("%.*s - Serial Number: %s\n", level * 2,
- " ", string);
+ printf(" Serial Number: %s\n", (char *)string);
}
}
if (verbose) {
for (i = 0; i < desc.bNumConfigurations; i++) {
struct libusb_config_descriptor *config;
+
ret = libusb_get_config_descriptor(dev, i, &config);
if (LIBUSB_SUCCESS != ret) {
printf(" Couldn't retrieve descriptors\n");
@@ -238,40 +225,87 @@ static int print_device(libusb_device *dev, int level)
libusb_free_config_descriptor(config);
}
- if (handle && desc.bcdUSB >= 0x0201) {
+ if (handle && desc.bcdUSB >= 0x0201)
print_bos(handle);
- }
}
if (handle)
libusb_close(handle);
+}
+
+#ifdef __linux__
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+static int test_wrapped_device(const char *device_name)
+{
+ libusb_device_handle *handle;
+ int r, fd;
+ fd = open(device_name, O_RDWR);
+ if (fd < 0) {
+ printf("Error could not open %s: %s\n", device_name, strerror(errno));
+ return 1;
+ }
+ r = libusb_wrap_sys_device(NULL, fd, &handle);
+ if (r) {
+ printf("Error wrapping device: %s: %s\n", device_name, libusb_strerror(r));
+ close(fd);
+ return 1;
+ }
+ print_device(libusb_get_device(handle), handle);
+ close(fd);
return 0;
}
+#else
+static int test_wrapped_device(const char *device_name)
+{
+ (void)device_name;
+ printf("Testing wrapped devices is not supported on your platform\n");
+ return 1;
+}
+#endif
int main(int argc, char *argv[])
{
+ const char *device_name = NULL;
libusb_device **devs;
ssize_t cnt;
int r, i;
- if (argc > 1 && !strcmp(argv[1], "-v"))
- verbose = 1;
+ for (i = 1; i < argc; i++) {
+ if (!strcmp(argv[i], "-v")) {
+ verbose = 1;
+ } else if (!strcmp(argv[i], "-d") && (i + 1) < argc) {
+ i++;
+ device_name = argv[i];
+ } else {
+ printf("Usage %s [-v] [-d </dev/bus/usb/...>]\n", argv[0]);
+ printf("Note use -d to test libusb_wrap_sys_device()\n");
+ return 1;
+ }
+ }
r = libusb_init(NULL);
if (r < 0)
return r;
- cnt = libusb_get_device_list(NULL, &devs);
- if (cnt < 0)
- return (int)cnt;
+ if (device_name) {
+ r = test_wrapped_device(device_name);
+ } else {
+ cnt = libusb_get_device_list(NULL, &devs);
+ if (cnt < 0) {
+ libusb_exit(NULL);
+ return 1;
+ }
- for (i = 0; devs[i]; ++i) {
- print_device(devs[i], 0);
- }
+ for (i = 0; devs[i]; i++)
+ print_device(devs[i], NULL);
- libusb_free_device_list(devs, 1);
+ libusb_free_device_list(devs, 1);
+ }
libusb_exit(NULL);
- return 0;
+ return r;
}
diff --git a/examples/xusb.c b/examples/xusb.c
index a1d9f4a..bf328fe 100644
--- a/examples/xusb.c
+++ b/examples/xusb.c
@@ -18,36 +18,21 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <stdarg.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
-#include <stdarg.h>
+#include <time.h>
#include "libusb.h"
-#if defined(_WIN32)
-#define msleep(msecs) Sleep(msecs)
-#else
-#include <time.h>
-#define msleep(msecs) nanosleep(&(struct timespec){msecs / 1000, (msecs * 1000000) % 1000000000UL}, NULL);
-#endif
-
#if defined(_MSC_VER)
#define snprintf _snprintf
#define putenv _putenv
#endif
-#if !defined(bool)
-#define bool int
-#endif
-#if !defined(true)
-#define true (1 == 1)
-#endif
-#if !defined(false)
-#define false (!true)
-#endif
-
// Future versions of libusb will use usb_interface instead of interface
// in libusb_config_descriptor => catter for that
#define usb_interface interface
@@ -58,6 +43,16 @@ static bool extra_info = false;
static bool force_device_request = false; // For WCID descriptor queries
static const char* binary_name = NULL;
+static inline void msleep(int msecs)
+{
+#if defined(_WIN32)
+ Sleep(msecs);
+#else
+ const struct timespec ts = { msecs / 1000, (msecs % 1000) * 1000000L };
+ nanosleep(&ts, NULL);
+#endif
+}
+
static void perr(char const *format, ...)
{
va_list args;
@@ -976,6 +971,7 @@ static int test_device(uint16_t vid, uint16_t pid)
int main(int argc, char** argv)
{
+ static char debug_env_str[] = "LIBUSB_DEBUG=4"; // LIBUSB_LOG_LEVEL_DEBUG
bool show_help = false;
bool debug_mode = false;
const struct libusb_version* version;
@@ -1103,7 +1099,7 @@ int main(int argc, char** argv)
// but since we can't call on libusb_set_option() before libusb_init(), we use the env variable method
old_dbg_str = getenv("LIBUSB_DEBUG");
if (debug_mode) {
- if (putenv("LIBUSB_DEBUG=4") != 0) // LIBUSB_LOG_LEVEL_DEBUG
+ if (putenv(debug_env_str) != 0)
printf("Unable to set debug level\n");
}
diff --git a/libusb/Makefile.am b/libusb/Makefile.am
index e4da62e..c78006e 100644
--- a/libusb/Makefile.am
+++ b/libusb/Makefile.am
@@ -1,101 +1,88 @@
-all: libusb-1.0.la libusb-1.0.dll
-
AUTOMAKE_OPTIONS = subdir-objects
-lib_LTLIBRARIES = libusb-1.0.la
+AM_CFLAGS += -fvisibility=hidden $(THREAD_CFLAGS)
+AM_CXXFLAGS += -fvisibility=hidden $(THREAD_CFLAGS)
-POSIX_POLL_SRC = os/poll_posix.h os/poll_posix.c
-POSIX_THREADS_SRC = os/threads_posix.h os/threads_posix.c
-WINDOWS_POLL_SRC = os/poll_windows.h os/poll_windows.c
-WINDOWS_THREADS_SRC = os/threads_windows.h os/threads_windows.c
-LINUX_USBFS_SRC = os/linux_usbfs.h os/linux_usbfs.c
-DARWIN_USB_SRC = os/darwin_usb.h os/darwin_usb.c
-OPENBSD_USB_SRC = os/openbsd_usb.c
-NETBSD_USB_SRC = os/netbsd_usb.c
-SUNOS_USB_SRC = os/sunos_usb.c os/sunos_usb.h
-WINDOWS_USB_SRC = libusb-1.0.def libusb-1.0.rc \
- os/windows_common.h \
- os/windows_nt_common.h os/windows_nt_common.c \
- os/windows_nt_shared_types.h \
- os/windows_usbdk.h os/windows_usbdk.c \
- os/windows_winusb.h os/windows_winusb.c
-WINCE_USB_SRC = os/wince_usb.h os/wince_usb.c
-HAIKU_USB_SRC = os/haiku_usb.h os/haiku_usb_backend.cpp \
- os/haiku_usb_raw.h os/haiku_usb_raw.cpp os/haiku_pollfs.cpp
-
-EXTRA_DIST = $(POSIX_POLL_SRC) $(POSIX_THREADS_SRC) \
- $(WINDOWS_POLL_SRC) $(WINDOWS_THREADS_SRC) \
- $(LINUX_USBFS_SRC) $(DARWIN_USB_SRC) \
- $(OPENBSD_USB_SRC) $(NETBSD_USB_SRC) \
- $(WINDOWS_USB_SRC) $(WINCE_USB_SRC) \
- $(HAIKU_USB_SRC) \
- os/linux_udev.c os/linux_netlink.c
+lib_LTLIBRARIES = libusb-1.0.la
-if OS_LINUX
+POSIX_PLATFORM_SRC = os/events_posix.h os/events_posix.c \
+ os/threads_posix.h os/threads_posix.c
+WINDOWS_PLATFORM_SRC = os/events_windows.h os/events_windows.c \
+ os/threads_windows.h os/threads_windows.c
-if USE_UDEV
-OS_SRC = $(LINUX_USBFS_SRC) os/linux_udev.c
+if PLATFORM_POSIX
+PLATFORM_SRC = $(POSIX_PLATFORM_SRC)
else
-OS_SRC = $(LINUX_USBFS_SRC) os/linux_netlink.c
+PLATFORM_SRC = $(WINDOWS_PLATFORM_SRC)
endif
-endif
+OS_DARWIN_SRC = os/darwin_usb.h os/darwin_usb.c
+OS_HAIKU_SRC = os/haiku_usb.h os/haiku_usb_backend.cpp \
+ os/haiku_pollfs.cpp os/haiku_usb_raw.h os/haiku_usb_raw.cpp
+OS_LINUX_SRC = os/linux_usbfs.h os/linux_usbfs.c
+OS_NETBSD_SRC = os/netbsd_usb.c
+OS_NULL_SRC = os/null_usb.c
+OS_OPENBSD_SRC = os/openbsd_usb.c
+OS_SUNOS_SRC = os/sunos_usb.h os/sunos_usb.c
+OS_WINDOWS_SRC = libusb-1.0.def libusb-1.0.rc \
+ os/windows_common.h os/windows_common.c \
+ os/windows_usbdk.h os/windows_usbdk.c \
+ os/windows_winusb.h os/windows_winusb.c
if OS_DARWIN
-OS_SRC = $(DARWIN_USB_SRC)
-AM_CFLAGS_EXT = -no-cpp-precomp
+OS_SRC = $(OS_DARWIN_SRC)
endif
-if OS_OPENBSD
-OS_SRC = $(OPENBSD_USB_SRC)
+if OS_HAIKU
+noinst_LTLIBRARIES = libusb_haiku.la
+libusb_haiku_la_SOURCES = $(OS_HAIKU_SRC)
+libusb_1_0_la_LIBADD = libusb_haiku.la
+endif
+
+if OS_LINUX
+OS_SRC = $(OS_LINUX_SRC)
+if USE_UDEV
+OS_SRC += os/linux_udev.c
+else
+OS_SRC += os/linux_netlink.c
+endif
endif
if OS_NETBSD
-OS_SRC = $(NETBSD_USB_SRC)
+OS_SRC = $(OS_NETBSD_SRC)
endif
-if OS_SUNOS
-OS_SRC = $(SUNOS_USB_SRC)
+if OS_NULL
+OS_SRC = $(OS_NULL_SRC)
endif
-if OS_HAIKU
-noinst_LTLIBRARIES = libusb_haiku.la
-libusb_haiku_la_SOURCES = $(HAIKU_USB_SRC)
-libusb_1_0_la_LIBADD = libusb_haiku.la
+if OS_OPENBSD
+OS_SRC = $(OS_OPENBSD_SRC)
+endif
+
+if OS_SUNOS
+OS_SRC = $(OS_SUNOS_SRC)
endif
if OS_WINDOWS
-OS_SRC = $(WINDOWS_USB_SRC)
+OS_SRC = $(OS_WINDOWS_SRC)
-.rc.lo:
- $(AM_V_GEN)$(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --tag=RC --mode=compile $(RC) $(RCFLAGS) -i $< -o $@
+include Makefile.am.extra
-libusb-1.0.rc: version.h version_nano.h
-endif
+# Dependencies for compiling libusb-1.0.lo from libusb-1.0.rc
+-include ./$(DEPDIR)/libusb-1.0.Plo
-libusb-1.0.dll: libusb-1.0.def libusb-1.0.la
if CREATE_IMPORT_LIB
+all-local: .libs/libusb-1.0.dll.a
# Rebuild the import lib from the .def so that MS and MinGW DLLs can be interchanged
- $(AM_V_GEN)$(DLLTOOL) $(DLLTOOLFLAGS) --kill-at --input-def $(srcdir)/libusb-1.0.def --dllname $@ --output-lib .libs/$@.a
+.libs/libusb-1.0.dll.a: libusb-1.0.def libusb-1.0.la
+ $(AM_V_DLLTOOL)$(DLLTOOL) $(DLLTOOLFLAGS) --kill-at --input-def $< --dllname libusb-1.0.dll --output-lib $@
endif
-
-if OS_WINDOWS
-POLL_SRC = $(WINDOWS_POLL_SRC)
-else
-POLL_SRC = $(POSIX_POLL_SRC)
-endif
-
-if THREADS_POSIX
-THREADS_SRC = $(POSIX_THREADS_SRC)
-else
-THREADS_SRC = $(WINDOWS_THREADS_SRC)
endif
-libusb_1_0_la_CFLAGS = $(AM_CFLAGS)
-libusb_1_0_la_LDFLAGS = $(LTLDFLAGS)
-libusb_1_0_la_SOURCES = libusbi.h libusb.h version.h version_nano.h \
+libusb_1_0_la_LDFLAGS = $(LT_LDFLAGS)
+libusb_1_0_la_SOURCES = libusbi.h version.h version_nano.h \
core.c descriptor.c hotplug.h hotplug.c io.c strerror.c sync.c \
- $(POLL_SRC) $(THREADS_SRC) $(OS_SRC)
+ $(PLATFORM_SRC) $(OS_SRC)
-hdrdir = $(includedir)/libusb-1.0
-hdr_HEADERS = libusb.h
+pkginclude_HEADERS = libusb.h
diff --git a/libusb/Makefile.am.extra b/libusb/Makefile.am.extra
new file mode 100644
index 0000000..a5c1490
--- /dev/null
+++ b/libusb/Makefile.am.extra
@@ -0,0 +1,26 @@
+AM_V_DLLTOOL = $(am__v_DLLTOOL_$(V))
+am__v_DLLTOOL_ = $(am__v_DLLTOOL_$(AM_DEFAULT_VERBOSITY))
+am__v_DLLTOOL_0 = @echo " DLLTOOL " $@;
+am__v_DLLTOOL_1 =
+
+AM_V_RC = $(am__v_RC_$(V))
+am__v_RC_ = $(am__v_RC_$(AM_DEFAULT_VERBOSITY))
+am__v_RC_0 = @echo " RC " $@;
+am__v_RC_1 =
+
+LTRC = $(LIBTOOL) $(AM_V_lt) --tag=RC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(RC) $(AM_RCFLAGS) \
+ $(RCFLAGS)
+
+RCPPARGS = \
+ --preprocessor-arg -MT \
+ --preprocessor-arg $@ \
+ --preprocessor-arg -MD \
+ --preprocessor-arg -MP \
+ --preprocessor-arg -MF \
+ --preprocessor-arg $$depbase.Tpo
+
+.rc.lo:
+ $(AM_V_RC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+ $(LTRC) $(RCPPARGS) -i $< -o $@ &&\
+ $(am__mv) $$depbase.Tpo $$depbase.Plo
diff --git a/libusb/core.c b/libusb/core.c
index 741bf99..07d459c 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -20,39 +20,28 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "config.h"
+#include "libusbi.h"
+#include "hotplug.h"
+#include "version.h"
-#include <errno.h>
-#include <stdarg.h>
+#ifdef __ANDROID__
+#include <android/log.h>
+#endif
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#ifdef HAVE_SYSLOG_H
+#ifdef HAVE_SYSLOG
#include <syslog.h>
#endif
-#ifdef __ANDROID__
-#include <android/log.h>
-#endif
-
-#include "libusbi.h"
-#include "hotplug.h"
-
-struct libusb_context *usbi_default_context = NULL;
+struct libusb_context *usbi_default_context;
static const struct libusb_version libusb_version_internal =
{ LIBUSB_MAJOR, LIBUSB_MINOR, LIBUSB_MICRO, LIBUSB_NANO,
LIBUSB_RC, "http://libusb.info" };
-static int default_context_refcnt = 0;
+static int default_context_refcnt;
static usbi_mutex_static_t default_context_lock = USBI_MUTEX_INITIALIZER;
-static struct timespec timestamp_origin = { 0, 0 };
-#ifndef USE_SYSTEM_LOGGING_FACILITY
-static libusb_log_cb log_handler = NULL;
+static struct timespec timestamp_origin;
+#if defined(ENABLE_LOGGING) && !defined(USE_SYSTEM_LOGGING_FACILITY)
+static libusb_log_cb log_handler;
#endif
usbi_mutex_static_t active_contexts_lock = USBI_MUTEX_INITIALIZER;
@@ -64,7 +53,7 @@ struct list_head active_contexts_list;
* \section intro Introduction
*
* libusb is an open source library that allows you to communicate with USB
- * devices from userspace. For more info, see the
+ * devices from user space. For more info, see the
* <a href="http://libusb.info">libusb homepage</a>.
*
* This documentation is aimed at application developers wishing to
@@ -168,6 +157,36 @@ struct list_head active_contexts_list;
/**
* \page libusb_caveats Caveats
*
+ * \section threadsafety Thread safety
+ *
+ * libusb is designed to be completely thread-safe, but as with any API it
+ * cannot prevent a user from sabotaging themselves, either intentionally or
+ * otherwise.
+ *
+ * Observe the following general guidelines:
+ *
+ * - Calls to functions that release a resource (e.g. libusb_close(),
+ * libusb_free_config_descriptor()) should not be called concurrently on
+ * the same resource. This is no different than concurrently calling free()
+ * on the same allocated pointer.
+ * - Each individual \ref libusb_transfer should be prepared by a single
+ * thread. In other words, no two threads should ever be concurrently
+ * filling out the fields of a \ref libusb_transfer. You can liken this to
+ * calling sprintf() with the same destination buffer from multiple threads.
+ * The results will likely not be what you want unless the input parameters
+ * are all the same, but its best to avoid this situation entirely.
+ * - Both the \ref libusb_transfer structure and its associated data buffer
+ * should not be accessed between the time the transfer is submitted and the
+ * time the completion callback is invoked. You can think of "ownership" of
+ * these things as being transferred to libusb while the transfer is active.
+ * - The various "setter" functions (e.g. libusb_set_log_cb(),
+ * libusb_set_pollfd_notifiers()) should not be called concurrently on the
+ * resource. Though doing so will not lead to any undefined behavior, it
+ * will likely produce results that the application does not expect.
+ *
+ * Rules for multiple threads and asynchronous I/O are detailed
+ * \ref libusb_mtasync "here".
+ *
* \section fork Fork considerations
*
* libusb is <em>not</em> designed to work across fork() calls. Depending on
@@ -194,12 +213,12 @@ struct list_head active_contexts_list;
* you when this has happened, so if someone else resets your device it will
* not be clear to your own program why the device state has changed.
*
- * Ultimately, this is a limitation of writing drivers in userspace.
+ * Ultimately, this is a limitation of writing drivers in user space.
* Separation from the USB stack in the underlying kernel makes it difficult
* for the operating system to deliver such notifications to your program.
* The Linux kernel USB stack allows such reset notifications to be delivered
* to in-kernel USB drivers, but it is not clear how such notifications could
- * be delivered to second-class drivers that live in userspace.
+ * be delivered to second-class drivers that live in user space.
*
* \section blockonly Blocking-only functionality
*
@@ -442,6 +461,7 @@ if (cfg != desired)
* - libusb_unlock_event_waiters()
* - libusb_unref_device()
* - libusb_wait_for_event()
+ * - libusb_wrap_sys_device()
*
* \section Structures
* - libusb_bos_descriptor
@@ -470,6 +490,7 @@ if (cfg != desired)
* - \ref libusb_class_code
* - \ref libusb_descriptor_type
* - \ref libusb_endpoint_direction
+ * - \ref libusb_endpoint_transfer_type
* - \ref libusb_error
* - \ref libusb_iso_sync_type
* - \ref libusb_iso_usage_type
@@ -678,17 +699,12 @@ struct libusb_device *usbi_alloc_device(struct libusb_context *ctx,
unsigned long session_id)
{
size_t priv_size = usbi_backend.device_priv_size;
- struct libusb_device *dev = calloc(1, sizeof(*dev) + priv_size);
- int r;
+ struct libusb_device *dev = calloc(1, PTR_ALIGN(sizeof(*dev)) + priv_size);
if (!dev)
return NULL;
- r = usbi_mutex_init(&dev->lock);
- if (r) {
- free(dev);
- return NULL;
- }
+ usbi_mutex_init(&dev->lock);
dev->ctx = ctx;
dev->refcnt = 1;
@@ -746,21 +762,22 @@ void usbi_disconnect_device(struct libusb_device *dev)
* to the discovered device list. */
int usbi_sanitize_device(struct libusb_device *dev)
{
- int r;
uint8_t num_configurations;
- r = usbi_device_cache_descriptor(dev);
- if (r < 0)
- return r;
+ if (dev->device_descriptor.bLength != LIBUSB_DT_DEVICE_SIZE ||
+ dev->device_descriptor.bDescriptorType != LIBUSB_DT_DEVICE) {
+ usbi_err(DEVICE_CTX(dev), "invalid device descriptor");
+ return LIBUSB_ERROR_IO;
+ }
num_configurations = dev->device_descriptor.bNumConfigurations;
if (num_configurations > USB_MAXCONFIG) {
usbi_err(DEVICE_CTX(dev), "too many configurations");
return LIBUSB_ERROR_IO;
- } else if (0 == num_configurations)
+ } else if (0 == num_configurations) {
usbi_dbg("zero configurations, maybe an unauthorized device");
+ }
- dev->num_configurations = num_configurations;
return 0;
}
@@ -774,11 +791,12 @@ struct libusb_device *usbi_get_device_by_session_id(struct libusb_context *ctx,
struct libusb_device *ret = NULL;
usbi_mutex_lock(&ctx->usb_devs_lock);
- list_for_each_entry(dev, &ctx->usb_devs, list, struct libusb_device)
+ for_each_device(ctx, dev) {
if (dev->session_data == session_id) {
ret = libusb_ref_device(dev);
break;
}
+ }
usbi_mutex_unlock(&ctx->usb_devs_lock);
return ret;
@@ -811,12 +829,14 @@ ssize_t API_EXPORTED libusb_get_device_list(libusb_context *ctx,
struct libusb_device **ret;
int r = 0;
ssize_t i, len;
- USBI_GET_CONTEXT(ctx);
- usbi_dbg("");
+
+ usbi_dbg(" ");
if (!discdevs)
return LIBUSB_ERROR_NO_MEM;
+ ctx = usbi_get_context(ctx);
+
if (libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) {
/* backend provides hotplug support */
struct libusb_device *dev;
@@ -825,7 +845,7 @@ ssize_t API_EXPORTED libusb_get_device_list(libusb_context *ctx,
usbi_backend.hotplug_poll();
usbi_mutex_lock(&ctx->usb_devs_lock);
- list_for_each_entry(dev, &ctx->usb_devs, list, struct libusb_device) {
+ for_each_device(ctx, dev) {
discdevs = discovered_devs_append(discdevs, dev);
if (!discdevs) {
@@ -929,7 +949,7 @@ uint8_t API_EXPORTED libusb_get_port_number(libusb_device *dev)
* \returns LIBUSB_ERROR_OVERFLOW if the array is too small
*/
int API_EXPORTED libusb_get_port_numbers(libusb_device *dev,
- uint8_t* port_numbers, int port_numbers_len)
+ uint8_t *port_numbers, int port_numbers_len)
{
int i = port_numbers_len;
struct libusb_context *ctx = DEVICE_CTX(dev);
@@ -952,10 +972,10 @@ int API_EXPORTED libusb_get_port_numbers(libusb_device *dev,
}
/** \ingroup libusb_dev
- * Deprecated please use libusb_get_port_numbers instead.
+ * \deprecated Please use \ref libusb_get_port_numbers() instead.
*/
int API_EXPORTED libusb_get_port_path(libusb_context *ctx, libusb_device *dev,
- uint8_t* port_numbers, uint8_t port_numbers_len)
+ uint8_t *port_numbers, uint8_t port_numbers_len)
{
UNUSED(ctx);
@@ -970,7 +990,7 @@ int API_EXPORTED libusb_get_port_path(libusb_context *ctx, libusb_device *dev,
* function and make sure that you only access the parent before issuing
* \ref libusb_free_device_list(). The reason is that libusb currently does
* not maintain a permanent list of device instances, and therefore can
- * only guarantee that parents are fully instantiated within a
+ * only guarantee that parents are fully instantiated within a
* libusb_get_device_list() - libusb_free_device_list() block.
*/
DEFAULT_VISIBILITY
@@ -1102,7 +1122,7 @@ int API_EXPORTED libusb_get_max_iso_packet_size(libusb_device *dev,
struct libusb_config_descriptor *config;
const struct libusb_endpoint_descriptor *ep;
struct libusb_ss_endpoint_companion_descriptor *ss_ep_cmp;
- enum libusb_transfer_type ep_type;
+ enum libusb_endpoint_transfer_type ep_type;
uint16_t val;
int r;
int speed;
@@ -1120,8 +1140,8 @@ int API_EXPORTED libusb_get_max_iso_packet_size(libusb_device *dev,
goto out;
}
- speed = libusb_get_device_speed( dev );
- if (speed == LIBUSB_SPEED_SUPER) {
+ speed = libusb_get_device_speed(dev);
+ if (speed >= LIBUSB_SPEED_SUPER) {
r = libusb_get_ss_endpoint_companion_descriptor(dev->ctx, ep, &ss_ep_cmp);
if (r == LIBUSB_SUCCESS) {
r = ss_ep_cmp->wBytesPerInterval;
@@ -1130,13 +1150,13 @@ int API_EXPORTED libusb_get_max_iso_packet_size(libusb_device *dev,
}
/* If the device isn't a SuperSpeed device or retrieving the SS endpoint didn't worked. */
- if (speed != LIBUSB_SPEED_SUPER || r < 0) {
+ if (speed < LIBUSB_SPEED_SUPER || r < 0) {
val = ep->wMaxPacketSize;
- ep_type = (enum libusb_transfer_type) (ep->bmAttributes & 0x3);
+ ep_type = (enum libusb_endpoint_transfer_type) (ep->bmAttributes & 0x3);
r = val & 0x07ff;
- if (ep_type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS
- || ep_type == LIBUSB_TRANSFER_TYPE_INTERRUPT)
+ if (ep_type == LIBUSB_ENDPOINT_TRANSFER_TYPE_ISOCHRONOUS
+ || ep_type == LIBUSB_ENDPOINT_TRANSFER_TYPE_INTERRUPT)
r *= (1 + ((val >> 11) & 3));
}
@@ -1193,49 +1213,14 @@ void API_EXPORTED libusb_unref_device(libusb_device *dev)
}
}
-/*
- * Signal the event pipe so that the event handling thread will be
- * interrupted to process an internal event.
- */
-int usbi_signal_event(struct libusb_context *ctx)
-{
- unsigned char dummy = 1;
- ssize_t r;
-
- /* write some data on event pipe to interrupt event handlers */
- r = usbi_write(ctx->event_pipe[1], &dummy, sizeof(dummy));
- if (r != sizeof(dummy)) {
- usbi_warn(ctx, "internal signalling write failed");
- return LIBUSB_ERROR_IO;
- }
-
- return 0;
-}
-
-/*
- * Clear the event pipe so that the event handling will no longer be
- * interrupted.
- */
-int usbi_clear_event(struct libusb_context *ctx)
-{
- unsigned char dummy;
- ssize_t r;
-
- /* read some data on event pipe to clear it */
- r = usbi_read(ctx->event_pipe[0], &dummy, sizeof(dummy));
- if (r != sizeof(dummy)) {
- usbi_warn(ctx, "internal signalling read failed");
- return LIBUSB_ERROR_IO;
- }
-
- return 0;
-}
-
/** \ingroup libusb_dev
* Wrap a platform-specific system device handle and obtain a libusb device
* handle for the underlying device. The handle allows you to use libusb to
* perform I/O on the device in question.
*
+ * Must call libusb_set_option(NULL, LIBUSB_OPTION_WEAK_AUTHORITY)
+ * before libusb_init if don't have authority to access the usb device directly.
+ *
* On Linux, the system device handle must be a valid file descriptor opened
* on the device node.
*
@@ -1265,31 +1250,23 @@ int API_EXPORTED libusb_wrap_sys_device(libusb_context *ctx, intptr_t sys_dev,
struct libusb_device_handle *_dev_handle;
size_t priv_size = usbi_backend.device_handle_priv_size;
int r;
- usbi_dbg("wrap_sys_device %p", (void *)sys_dev);
- USBI_GET_CONTEXT(ctx);
+ usbi_dbg("wrap_sys_device 0x%" PRIxPTR, (uintptr_t)sys_dev);
+
+ ctx = usbi_get_context(ctx);
if (!usbi_backend.wrap_sys_device)
return LIBUSB_ERROR_NOT_SUPPORTED;
- _dev_handle = malloc(sizeof(*_dev_handle) + priv_size);
+ _dev_handle = calloc(1, PTR_ALIGN(sizeof(*_dev_handle)) + priv_size);
if (!_dev_handle)
return LIBUSB_ERROR_NO_MEM;
- r = usbi_mutex_init(&_dev_handle->lock);
- if (r) {
- free(_dev_handle);
- return LIBUSB_ERROR_OTHER;
- }
-
- _dev_handle->dev = NULL;
- _dev_handle->auto_detach_kernel_driver = 0;
- _dev_handle->claimed_interfaces = 0;
- memset(&_dev_handle->os_priv, 0, priv_size);
+ usbi_mutex_init(&_dev_handle->lock);
r = usbi_backend.wrap_sys_device(ctx, _dev_handle, sys_dev);
if (r < 0) {
- usbi_dbg("wrap_sys_device %p returns %d", (void *)sys_dev, r);
+ usbi_dbg("wrap_sys_device 0x%" PRIxPTR " returns %d", (uintptr_t)sys_dev, r);
usbi_mutex_destroy(&_dev_handle->lock);
free(_dev_handle);
return r;
@@ -1335,20 +1312,13 @@ int API_EXPORTED libusb_open(libusb_device *dev,
return LIBUSB_ERROR_NO_DEVICE;
}
- _dev_handle = malloc(sizeof(*_dev_handle) + priv_size);
+ _dev_handle = calloc(1, PTR_ALIGN(sizeof(*_dev_handle)) + priv_size);
if (!_dev_handle)
return LIBUSB_ERROR_NO_MEM;
- r = usbi_mutex_init(&_dev_handle->lock);
- if (r) {
- free(_dev_handle);
- return LIBUSB_ERROR_OTHER;
- }
+ usbi_mutex_init(&_dev_handle->lock);
_dev_handle->dev = libusb_ref_device(dev);
- _dev_handle->auto_detach_kernel_driver = 0;
- _dev_handle->claimed_interfaces = 0;
- memset(&_dev_handle->os_priv, 0, priv_size);
r = usbi_backend.open(_dev_handle);
if (r < 0) {
@@ -1429,7 +1399,7 @@ static void do_close(struct libusb_context *ctx,
usbi_mutex_lock(&ctx->flying_transfers_lock);
/* safe iteration because transfers may be being deleted */
- list_for_each_entry_safe(itransfer, tmp, &ctx->flying_transfers, list, struct usbi_transfer) {
+ for_each_transfer_safe(ctx, itransfer, tmp) {
struct libusb_transfer *transfer =
USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
@@ -1487,12 +1457,12 @@ static void do_close(struct libusb_context *ctx,
void API_EXPORTED libusb_close(libusb_device_handle *dev_handle)
{
struct libusb_context *ctx;
+ unsigned int event_flags;
int handling_events;
- int pending_events;
if (!dev_handle)
return;
- usbi_dbg("");
+ usbi_dbg(" ");
ctx = HANDLE_CTX(dev_handle);
handling_events = usbi_handling_events(ctx);
@@ -1509,10 +1479,11 @@ void API_EXPORTED libusb_close(libusb_device_handle *dev_handle)
/* Record that we are closing a device.
* Only signal an event if there are no prior pending events. */
usbi_mutex_lock(&ctx->event_data_lock);
- pending_events = usbi_pending_events(ctx);
- ctx->device_close++;
- if (!pending_events)
- usbi_signal_event(ctx);
+ event_flags = ctx->event_flags;
+ if (!ctx->device_close++)
+ ctx->event_flags |= USBI_EVENT_DEVICE_CLOSE;
+ if (!event_flags)
+ usbi_signal_event(&ctx->event);
usbi_mutex_unlock(&ctx->event_data_lock);
/* take event handling lock */
@@ -1526,10 +1497,10 @@ void API_EXPORTED libusb_close(libusb_device_handle *dev_handle)
/* We're done with closing this device.
* Clear the event pipe if there are no further pending events. */
usbi_mutex_lock(&ctx->event_data_lock);
- ctx->device_close--;
- pending_events = usbi_pending_events(ctx);
- if (!pending_events)
- usbi_clear_event(ctx);
+ if (!--ctx->device_close)
+ ctx->event_flags &= ~USBI_EVENT_DEVICE_CLOSE;
+ if (!ctx->event_flags)
+ usbi_clear_event(&ctx->event);
usbi_mutex_unlock(&ctx->event_data_lock);
/* Release event handling lock and wake up event waiters */
@@ -1574,29 +1545,30 @@ int API_EXPORTED libusb_get_configuration(libusb_device_handle *dev_handle,
int *config)
{
int r = LIBUSB_ERROR_NOT_SUPPORTED;
+ uint8_t tmp = 0;
- usbi_dbg("");
+ usbi_dbg(" ");
if (usbi_backend.get_configuration)
- r = usbi_backend.get_configuration(dev_handle, config);
+ r = usbi_backend.get_configuration(dev_handle, &tmp);
if (r == LIBUSB_ERROR_NOT_SUPPORTED) {
- uint8_t tmp = 0;
usbi_dbg("falling back to control message");
r = libusb_control_transfer(dev_handle, LIBUSB_ENDPOINT_IN,
LIBUSB_REQUEST_GET_CONFIGURATION, 0, 0, &tmp, 1, 1000);
- if (r == 0) {
+ if (r == 1) {
+ r = 0;
+ } else if (r == 0) {
usbi_err(HANDLE_CTX(dev_handle), "zero bytes returned in ctrl transfer?");
r = LIBUSB_ERROR_IO;
- } else if (r == 1) {
- r = 0;
- *config = tmp;
} else {
usbi_dbg("control failed, error %d", r);
}
}
- if (r == 0)
- usbi_dbg("active config %d", *config);
+ if (r == 0) {
+ usbi_dbg("active config %u", tmp);
+ *config = (int)tmp;
+ }
return r;
}
@@ -1615,6 +1587,11 @@ int API_EXPORTED libusb_get_configuration(libusb_device_handle *dev_handle,
* causing most USB-related device state to be reset (altsetting reset to zero,
* endpoint halts cleared, toggles reset).
*
+ * Not all backends support setting the configuration from user space, which
+ * will be indicated by the return code LIBUSB_ERROR_NOT_SUPPORTED. As this
+ * suggests that the platform is handling the device configuration itself,
+ * this error should generally be safe to ignore.
+ *
* You cannot change/reset configuration if your application has claimed
* interfaces. It is advised to set the desired configuration before claiming
* interfaces.
@@ -1644,6 +1621,8 @@ int API_EXPORTED libusb_get_configuration(libusb_device_handle *dev_handle,
* \returns 0 on success
* \returns LIBUSB_ERROR_NOT_FOUND if the requested configuration does not exist
* \returns LIBUSB_ERROR_BUSY if interfaces are currently claimed
+ * \returns LIBUSB_ERROR_NOT_SUPPORTED if setting or changing the configuration
+ * is not supported by the backend
* \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
* \returns another LIBUSB_ERROR code on other failure
* \see libusb_set_auto_detach_kernel_driver()
@@ -1652,6 +1631,8 @@ int API_EXPORTED libusb_set_configuration(libusb_device_handle *dev_handle,
int configuration)
{
usbi_dbg("configuration %d", configuration);
+ if (configuration < -1 || configuration > (int)UINT8_MAX)
+ return LIBUSB_ERROR_INVALID_PARAM;
return usbi_backend.set_configuration(dev_handle, configuration);
}
@@ -1689,7 +1670,7 @@ int API_EXPORTED libusb_claim_interface(libusb_device_handle *dev_handle,
int r = 0;
usbi_dbg("interface %d", interface_number);
- if (interface_number >= USB_MAXINTERFACES)
+ if (interface_number < 0 || interface_number >= USB_MAXINTERFACES)
return LIBUSB_ERROR_INVALID_PARAM;
if (!dev_handle->dev->attached)
@@ -1699,7 +1680,7 @@ int API_EXPORTED libusb_claim_interface(libusb_device_handle *dev_handle,
if (dev_handle->claimed_interfaces & (1U << interface_number))
goto out;
- r = usbi_backend.claim_interface(dev_handle, interface_number);
+ r = usbi_backend.claim_interface(dev_handle, (uint8_t)interface_number);
if (r == 0)
dev_handle->claimed_interfaces |= 1U << interface_number;
@@ -1733,7 +1714,7 @@ int API_EXPORTED libusb_release_interface(libusb_device_handle *dev_handle,
int r;
usbi_dbg("interface %d", interface_number);
- if (interface_number >= USB_MAXINTERFACES)
+ if (interface_number < 0 || interface_number >= USB_MAXINTERFACES)
return LIBUSB_ERROR_INVALID_PARAM;
usbi_mutex_lock(&dev_handle->lock);
@@ -1742,7 +1723,7 @@ int API_EXPORTED libusb_release_interface(libusb_device_handle *dev_handle,
goto out;
}
- r = usbi_backend.release_interface(dev_handle, interface_number);
+ r = usbi_backend.release_interface(dev_handle, (uint8_t)interface_number);
if (r == 0)
dev_handle->claimed_interfaces &= ~(1U << interface_number);
@@ -1777,7 +1758,9 @@ int API_EXPORTED libusb_set_interface_alt_setting(libusb_device_handle *dev_hand
{
usbi_dbg("interface %d altsetting %d",
interface_number, alternate_setting);
- if (interface_number >= USB_MAXINTERFACES)
+ if (interface_number < 0 || interface_number >= USB_MAXINTERFACES)
+ return LIBUSB_ERROR_INVALID_PARAM;
+ if (alternate_setting < 0 || alternate_setting > (int)UINT8_MAX)
return LIBUSB_ERROR_INVALID_PARAM;
usbi_mutex_lock(&dev_handle->lock);
@@ -1792,8 +1775,8 @@ int API_EXPORTED libusb_set_interface_alt_setting(libusb_device_handle *dev_hand
}
usbi_mutex_unlock(&dev_handle->lock);
- return usbi_backend.set_interface_altsetting(dev_handle, interface_number,
- alternate_setting);
+ return usbi_backend.set_interface_altsetting(dev_handle,
+ (uint8_t)interface_number, (uint8_t)alternate_setting);
}
/** \ingroup libusb_dev
@@ -1843,11 +1826,14 @@ int API_EXPORTED libusb_clear_halt(libusb_device_handle *dev_handle,
*/
int API_EXPORTED libusb_reset_device(libusb_device_handle *dev_handle)
{
- usbi_dbg("");
+ usbi_dbg(" ");
if (!dev_handle->dev->attached)
return LIBUSB_ERROR_NO_DEVICE;
- return usbi_backend.reset_device(dev_handle);
+ if (usbi_backend.reset_device)
+ return usbi_backend.reset_device(dev_handle);
+ else
+ return LIBUSB_ERROR_NOT_SUPPORTED;
}
/** \ingroup libusb_asyncio
@@ -1874,7 +1860,10 @@ int API_EXPORTED libusb_reset_device(libusb_device_handle *dev_handle)
int API_EXPORTED libusb_alloc_streams(libusb_device_handle *dev_handle,
uint32_t num_streams, unsigned char *endpoints, int num_endpoints)
{
- usbi_dbg("streams %u eps %d", (unsigned) num_streams, num_endpoints);
+ usbi_dbg("streams %u eps %d", (unsigned)num_streams, num_endpoints);
+
+ if (!num_streams || !endpoints || num_endpoints <= 0)
+ return LIBUSB_ERROR_INVALID_PARAM;
if (!dev_handle->dev->attached)
return LIBUSB_ERROR_NO_DEVICE;
@@ -1903,6 +1892,9 @@ int API_EXPORTED libusb_free_streams(libusb_device_handle *dev_handle,
{
usbi_dbg("eps %d", num_endpoints);
+ if (!endpoints || num_endpoints <= 0)
+ return LIBUSB_ERROR_INVALID_PARAM;
+
if (!dev_handle->dev->attached)
return LIBUSB_ERROR_NO_DEVICE;
@@ -1925,7 +1917,7 @@ int API_EXPORTED libusb_free_streams(libusb_device_handle *dev_handle,
* the same cache lines) when a transfer is in progress, although it is legal
* to have several transfers going on within the same memory block.
*
- * Will return NULL on failure. Many systems do not support such zerocopy
+ * Will return NULL on failure. Many systems do not support such zero-copy
* and will always return NULL. Memory allocated with this function must be
* freed with \ref libusb_dev_mem_free. Specifically, this means that the
* flag \ref LIBUSB_TRANSFER_FREE_BUFFER cannot be used to free memory allocated
@@ -1989,11 +1981,14 @@ int API_EXPORTED libusb_kernel_driver_active(libusb_device_handle *dev_handle,
{
usbi_dbg("interface %d", interface_number);
+ if (interface_number < 0 || interface_number >= USB_MAXINTERFACES)
+ return LIBUSB_ERROR_INVALID_PARAM;
+
if (!dev_handle->dev->attached)
return LIBUSB_ERROR_NO_DEVICE;
if (usbi_backend.kernel_driver_active)
- return usbi_backend.kernel_driver_active(dev_handle, interface_number);
+ return usbi_backend.kernel_driver_active(dev_handle, (uint8_t)interface_number);
else
return LIBUSB_ERROR_NOT_SUPPORTED;
}
@@ -2024,11 +2019,14 @@ int API_EXPORTED libusb_detach_kernel_driver(libusb_device_handle *dev_handle,
{
usbi_dbg("interface %d", interface_number);
+ if (interface_number < 0 || interface_number >= USB_MAXINTERFACES)
+ return LIBUSB_ERROR_INVALID_PARAM;
+
if (!dev_handle->dev->attached)
return LIBUSB_ERROR_NO_DEVICE;
if (usbi_backend.detach_kernel_driver)
- return usbi_backend.detach_kernel_driver(dev_handle, interface_number);
+ return usbi_backend.detach_kernel_driver(dev_handle, (uint8_t)interface_number);
else
return LIBUSB_ERROR_NOT_SUPPORTED;
}
@@ -2058,11 +2056,14 @@ int API_EXPORTED libusb_attach_kernel_driver(libusb_device_handle *dev_handle,
{
usbi_dbg("interface %d", interface_number);
+ if (interface_number < 0 || interface_number >= USB_MAXINTERFACES)
+ return LIBUSB_ERROR_INVALID_PARAM;
+
if (!dev_handle->dev->attached)
return LIBUSB_ERROR_NO_DEVICE;
if (usbi_backend.attach_kernel_driver)
- return usbi_backend.attach_kernel_driver(dev_handle, interface_number);
+ return usbi_backend.attach_kernel_driver(dev_handle, (uint8_t)interface_number);
else
return LIBUSB_ERROR_NOT_SUPPORTED;
}
@@ -2106,7 +2107,7 @@ int API_EXPORTED libusb_set_auto_detach_kernel_driver(
void API_EXPORTED libusb_set_debug(libusb_context *ctx, int level)
{
#if defined(ENABLE_LOGGING) && !defined(ENABLE_DEBUG_LOGGING)
- USBI_GET_CONTEXT(ctx);
+ ctx = usbi_get_context(ctx);
if (!ctx->debug_fixed) {
level = CLAMP(level, LIBUSB_LOG_LEVEL_NONE, LIBUSB_LOG_LEVEL_DEBUG);
ctx->debug = (enum libusb_log_level)level;
@@ -2141,23 +2142,24 @@ void API_EXPORTED libusb_set_debug(libusb_context *ctx, int level)
void API_EXPORTED libusb_set_log_cb(libusb_context *ctx, libusb_log_cb cb,
int mode)
{
+#if defined(ENABLE_LOGGING) && (!defined(ENABLE_DEBUG_LOGGING) || !defined(USE_SYSTEM_LOGGING_FACILITY))
#if !defined(USE_SYSTEM_LOGGING_FACILITY)
- if (mode & LIBUSB_LOG_CB_GLOBAL) {
+ if (mode & LIBUSB_LOG_CB_GLOBAL)
log_handler = cb;
- }
#endif
-#if defined(ENABLE_LOGGING) && !defined(ENABLE_DEBUG_LOGGING)
+#if !defined(ENABLE_DEBUG_LOGGING)
if (mode & LIBUSB_LOG_CB_CONTEXT) {
- USBI_GET_CONTEXT(ctx);
+ ctx = usbi_get_context(ctx);
ctx->log_handler = cb;
}
#else
UNUSED(ctx);
-#if defined(USE_SYSTEM_LOGGING_FACILITY)
+#endif
+#else
+ UNUSED(ctx);
UNUSED(cb);
UNUSED(mode);
#endif
-#endif
}
/** \ingroup libusb_lib
@@ -2178,6 +2180,7 @@ void API_EXPORTED libusb_set_log_cb(libusb_context *ctx, libusb_log_cb cb,
* \returns LIBUSB_ERROR_INVALID_PARAM if the option or arguments are invalid
* \returns LIBUSB_ERROR_NOT_SUPPORTED if the option is valid but not supported
* on this platform
+ * \returns LIBUSB_ERROR_NOT_FOUND if LIBUSB_OPTION_USE_USBDK is valid on this platform but UsbDk is not available
*/
int API_EXPORTED libusb_set_option(libusb_context *ctx,
enum libusb_option option, ...)
@@ -2185,7 +2188,7 @@ int API_EXPORTED libusb_set_option(libusb_context *ctx,
int arg, r = LIBUSB_SUCCESS;
va_list ap;
- USBI_GET_CONTEXT(ctx);
+ ctx = usbi_get_context(ctx);
va_start(ap, option);
switch (option) {
@@ -2203,6 +2206,7 @@ int API_EXPORTED libusb_set_option(libusb_context *ctx,
/* Handle all backend-specific options here */
case LIBUSB_OPTION_USE_USBDK:
+ case LIBUSB_OPTION_WEAK_AUTHORITY:
if (usbi_backend.set_option)
r = usbi_backend.set_option(ctx, option, ap);
else
@@ -2260,9 +2264,8 @@ int API_EXPORTED libusb_init(libusb_context **context)
usbi_mutex_static_lock(&default_context_lock);
- if (!timestamp_origin.tv_sec) {
- usbi_backend.clock_gettime(USBI_CLOCK_REALTIME, &timestamp_origin);
- }
+ if (!timestamp_origin.tv_sec)
+ usbi_get_monotonic_time(&timestamp_origin);
if (!context && usbi_default_context) {
usbi_dbg("reusing default context");
@@ -2271,7 +2274,7 @@ int API_EXPORTED libusb_init(libusb_context **context)
return 0;
}
- ctx = calloc(1, sizeof(*ctx) + priv_size);
+ ctx = calloc(1, PTR_ALIGN(sizeof(*ctx)) + priv_size);
if (!ctx) {
r = LIBUSB_ERROR_NO_MEM;
goto err_unlock;
@@ -2304,7 +2307,7 @@ int API_EXPORTED libusb_init(libusb_context **context)
usbi_mutex_static_lock(&active_contexts_lock);
if (first_init) {
first_init = 0;
- list_init (&active_contexts_list);
+ list_init(&active_contexts_list);
}
list_add (&ctx->list, &active_contexts_list);
usbi_mutex_static_unlock(&active_contexts_lock);
@@ -2336,11 +2339,11 @@ err_free_ctx:
}
usbi_mutex_static_lock(&active_contexts_lock);
- list_del (&ctx->list);
+ list_del(&ctx->list);
usbi_mutex_static_unlock(&active_contexts_lock);
usbi_mutex_lock(&ctx->usb_devs_lock);
- list_for_each_entry_safe(dev, next, &ctx->usb_devs, list, struct libusb_device) {
+ for_each_device_safe(ctx, dev, next) {
list_del(&dev->list);
libusb_unref_device(dev);
}
@@ -2361,19 +2364,26 @@ err_unlock:
* before your application terminates.
* \param ctx the context to deinitialize, or NULL for the default context
*/
-void API_EXPORTED libusb_exit(struct libusb_context *ctx)
+void API_EXPORTED libusb_exit(libusb_context *ctx)
{
struct libusb_device *dev, *next;
struct timeval tv = { 0, 0 };
int destroying_default_context = 0;
- usbi_dbg("");
- USBI_GET_CONTEXT(ctx);
+ usbi_dbg(" ");
+
+ ctx = usbi_get_context(ctx);
/* if working with default context, only actually do the deinitialization
* if we're the last user */
usbi_mutex_static_lock(&default_context_lock);
if (ctx == usbi_default_context) {
+ if (!usbi_default_context) {
+ usbi_dbg("no default context, not initialized?");
+ usbi_mutex_static_unlock(&default_context_lock);
+ return;
+ }
+
if (--default_context_refcnt > 0) {
usbi_dbg("not destroying default context");
usbi_mutex_static_unlock(&default_context_lock);
@@ -2389,12 +2399,12 @@ void API_EXPORTED libusb_exit(struct libusb_context *ctx)
*/
destroying_default_context = 1;
} else {
- // Unlock default context, as we're not modifying it.
+ /* Unlock default context, as we're not modifying it. */
usbi_mutex_static_unlock(&default_context_lock);
- }
+ }
usbi_mutex_static_lock(&active_contexts_lock);
- list_del (&ctx->list);
+ list_del(&ctx->list);
usbi_mutex_static_unlock(&active_contexts_lock);
if (libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) {
@@ -2413,7 +2423,7 @@ void API_EXPORTED libusb_exit(struct libusb_context *ctx)
libusb_handle_events_timeout(ctx, &tv);
usbi_mutex_lock(&ctx->usb_devs_lock);
- list_for_each_entry_safe(dev, next, &ctx->usb_devs, list, struct libusb_device) {
+ for_each_device_safe(ctx, dev, next) {
list_del(&dev->list);
libusb_unref_device(dev);
}
@@ -2471,94 +2481,90 @@ int API_EXPORTED libusb_has_capability(uint32_t capability)
#ifdef LIBUSB_PRINTF_WIN32
/*
* Prior to VS2015, Microsoft did not provide the snprintf() function and
- * provided a vsnprintf() that did not guarantee NULL-terminated output.
+ * provided a vsnprintf() that did not guarantee NUL-terminated output.
* Microsoft did provide a _snprintf() function, but again it did not
* guarantee NULL-terminated output.
*
- * The below implementations guarantee NULL-terminated output and are
+ * The below implementations guarantee NUL-terminated output and are
* C99 compliant.
*/
int usbi_snprintf(char *str, size_t size, const char *format, ...)
{
- va_list ap;
+ va_list args;
int ret;
- va_start(ap, format);
- ret = usbi_vsnprintf(str, size, format, ap);
- va_end(ap);
+ va_start(args, format);
+ ret = usbi_vsnprintf(str, size, format, args);
+ va_end(args);
return ret;
}
-int usbi_vsnprintf(char *str, size_t size, const char *format, va_list ap)
+int usbi_vsnprintf(char *str, size_t size, const char *format, va_list args)
{
int ret;
- ret = _vsnprintf(str, size, format, ap);
+ ret = _vsnprintf(str, size, format, args);
if (ret < 0 || ret == (int)size) {
- /* Output is truncated, ensure buffer is NULL-terminated and
+ /* Output is truncated, ensure buffer is NUL-terminated and
* determine how many characters would have been written. */
str[size - 1] = '\0';
if (ret < 0)
- ret = _vsnprintf(NULL, 0, format, ap);
+ ret = _vsnprintf(NULL, 0, format, args);
}
return ret;
}
#endif /* LIBUSB_PRINTF_WIN32 */
-static void usbi_log_str(enum libusb_log_level level, const char *str)
+static void log_str(enum libusb_log_level level, const char *str)
{
#if defined(USE_SYSTEM_LOGGING_FACILITY)
-#if defined(OS_WINDOWS) || defined(OS_WINCE)
-#if !defined(UNICODE)
- OutputDebugStringA(str);
-#else
- WCHAR wbuf[USBI_MAX_LOG_LEN];
- if (MultiByteToWideChar(CP_UTF8, 0, str, -1, wbuf, sizeof(wbuf)) != 0)
- OutputDebugStringW(wbuf);
-#endif
-#elif defined(__ANDROID__)
- int priority = ANDROID_LOG_UNKNOWN;
+#if defined(__ANDROID__)
+ int priority;
switch (level) {
- case LIBUSB_LOG_LEVEL_NONE: return;
+ case LIBUSB_LOG_LEVEL_NONE: return; /* Impossible, but keeps compiler happy */
case LIBUSB_LOG_LEVEL_ERROR: priority = ANDROID_LOG_ERROR; break;
case LIBUSB_LOG_LEVEL_WARNING: priority = ANDROID_LOG_WARN; break;
case LIBUSB_LOG_LEVEL_INFO: priority = ANDROID_LOG_INFO; break;
case LIBUSB_LOG_LEVEL_DEBUG: priority = ANDROID_LOG_DEBUG; break;
+ default: priority = ANDROID_LOG_UNKNOWN;
}
__android_log_write(priority, "libusb", str);
-#elif defined(HAVE_SYSLOG_FUNC)
- int syslog_level = LOG_INFO;
+#elif defined(_WIN32)
+ UNUSED(level);
+ OutputDebugStringA(str);
+#elif defined(HAVE_SYSLOG)
+ int syslog_level;
switch (level) {
- case LIBUSB_LOG_LEVEL_NONE: return;
+ case LIBUSB_LOG_LEVEL_NONE: return; /* Impossible, but keeps compiler happy */
case LIBUSB_LOG_LEVEL_ERROR: syslog_level = LOG_ERR; break;
case LIBUSB_LOG_LEVEL_WARNING: syslog_level = LOG_WARNING; break;
case LIBUSB_LOG_LEVEL_INFO: syslog_level = LOG_INFO; break;
case LIBUSB_LOG_LEVEL_DEBUG: syslog_level = LOG_DEBUG; break;
+ default: syslog_level = LOG_INFO;
}
syslog(syslog_level, "%s", str);
#else /* All of gcc, Clang, Xcode seem to use #warning */
#warning System logging is not supported on this platform. Logging to stderr will be used instead.
+ UNUSED(level);
fputs(str, stderr);
#endif
#else
/* Global log handler */
- if (log_handler != NULL)
+ if (log_handler)
log_handler(NULL, level, str);
else
fputs(str, stderr);
#endif /* USE_SYSTEM_LOGGING_FACILITY */
- UNUSED(level);
}
-void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
+static void log_v(struct libusb_context *ctx, enum libusb_log_level level,
const char *function, const char *format, va_list args)
{
const char *prefix;
char buf[USBI_MAX_LOG_LEN];
- struct timespec now;
int global_debug, header_len, text_len;
static int has_debug_header_been_displayed = 0;
@@ -2566,41 +2572,22 @@ void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
global_debug = 1;
UNUSED(ctx);
#else
- enum libusb_log_level ctx_level = LIBUSB_LOG_LEVEL_NONE;
+ enum libusb_log_level ctx_level;
- USBI_GET_CONTEXT(ctx);
+ ctx = usbi_get_context(ctx);
if (ctx)
ctx_level = ctx->debug;
else
ctx_level = get_env_debug_level();
- if (ctx_level == LIBUSB_LOG_LEVEL_NONE)
- return;
- if (level == LIBUSB_LOG_LEVEL_WARNING && ctx_level < LIBUSB_LOG_LEVEL_WARNING)
- return;
- if (level == LIBUSB_LOG_LEVEL_INFO && ctx_level < LIBUSB_LOG_LEVEL_INFO)
- return;
- if (level == LIBUSB_LOG_LEVEL_DEBUG && ctx_level < LIBUSB_LOG_LEVEL_DEBUG)
+ if (ctx_level < level)
return;
global_debug = (ctx_level == LIBUSB_LOG_LEVEL_DEBUG);
#endif
- usbi_backend.clock_gettime(USBI_CLOCK_REALTIME, &now);
- if ((global_debug) && (!has_debug_header_been_displayed)) {
- has_debug_header_been_displayed = 1;
- usbi_log_str(LIBUSB_LOG_LEVEL_DEBUG, "[timestamp] [threadID] facility level [function call] <message>" USBI_LOG_LINE_END);
- usbi_log_str(LIBUSB_LOG_LEVEL_DEBUG, "--------------------------------------------------------------------------------" USBI_LOG_LINE_END);
- }
- if (now.tv_nsec < timestamp_origin.tv_nsec) {
- now.tv_sec--;
- now.tv_nsec += 1000000000L;
- }
- now.tv_sec -= timestamp_origin.tv_sec;
- now.tv_nsec -= timestamp_origin.tv_nsec;
-
switch (level) {
- case LIBUSB_LOG_LEVEL_NONE:
+ case LIBUSB_LOG_LEVEL_NONE: /* Impossible, but keeps compiler happy */
return;
case LIBUSB_LOG_LEVEL_ERROR:
prefix = "error";
@@ -2620,21 +2607,31 @@ void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
}
if (global_debug) {
+ struct timespec timestamp;
+
+ if (!has_debug_header_been_displayed) {
+ has_debug_header_been_displayed = 1;
+ log_str(LIBUSB_LOG_LEVEL_DEBUG, "[timestamp] [threadID] facility level [function call] <message>" USBI_LOG_LINE_END);
+ log_str(LIBUSB_LOG_LEVEL_DEBUG, "--------------------------------------------------------------------------------" USBI_LOG_LINE_END);
+ }
+
+ usbi_get_monotonic_time(&timestamp);
+ TIMESPEC_SUB(&timestamp, &timestamp_origin, &timestamp);
+
header_len = snprintf(buf, sizeof(buf),
"[%2ld.%06ld] [%08x] libusb: %s [%s] ",
- (long)now.tv_sec, (long)(now.tv_nsec / 1000L), usbi_get_tid(), prefix, function);
+ (long)timestamp.tv_sec, (long)(timestamp.tv_nsec / 1000L), usbi_get_tid(), prefix, function);
} else {
header_len = snprintf(buf, sizeof(buf),
"libusb: %s [%s] ", prefix, function);
}
if (header_len < 0 || header_len >= (int)sizeof(buf)) {
- /* Somehow snprintf failed to write to the buffer,
+ /* Somehow snprintf() failed to write to the buffer,
* remove the header so something useful is output. */
header_len = 0;
}
- /* Make sure buffer is NUL terminated */
- buf[header_len] = '\0';
+
text_len = vsnprintf(buf + header_len, sizeof(buf) - (size_t)header_len,
format, args);
if (text_len < 0 || text_len + header_len >= (int)sizeof(buf)) {
@@ -2648,9 +2645,9 @@ void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
}
strcpy(buf + header_len + text_len, USBI_LOG_LINE_END);
- usbi_log_str(level, buf);
+ log_str(level, buf);
- /* Per context log handler */
+ /* Per-context log handler */
#ifndef ENABLE_DEBUG_LOGGING
if (ctx && ctx->log_handler)
ctx->log_handler(ctx, level, buf);
@@ -2662,9 +2659,9 @@ void usbi_log(struct libusb_context *ctx, enum libusb_log_level level,
{
va_list args;
- va_start (args, format);
- usbi_log_v(ctx, level, function, format, args);
- va_end (args);
+ va_start(args, format);
+ log_v(ctx, level, function, format, args);
+ va_end(args);
}
#endif /* ENABLE_LOGGING */
diff --git a/libusb/descriptor.c b/libusb/descriptor.c
index 53905e6..ecd9441 100644
--- a/libusb/descriptor.c
+++ b/libusb/descriptor.c
@@ -19,91 +19,73 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <config.h>
+#include "libusbi.h"
-#include <errno.h>
-#include <stdint.h>
-#include <stdlib.h>
#include <string.h>
-#include "libusbi.h"
-
-#define DESC_HEADER_LENGTH 2
-#define DEVICE_DESC_LENGTH 18
-#define CONFIG_DESC_LENGTH 9
-#define INTERFACE_DESC_LENGTH 9
-#define ENDPOINT_DESC_LENGTH 7
-#define ENDPOINT_AUDIO_DESC_LENGTH 9
+#define DESC_HEADER_LENGTH 2
/** @defgroup libusb_desc USB descriptors
* This page details how to examine the various standard USB descriptors
* for detected devices
*/
-/* set host_endian if the w values are already in host endian format,
- * as opposed to bus endian. */
-int usbi_parse_descriptor(const unsigned char *source, const char *descriptor,
- void *dest, int host_endian)
+#define READ_LE16(p) ((uint16_t) \
+ (((uint16_t)((p)[1]) << 8) | \
+ ((uint16_t)((p)[0]))))
+
+#define READ_LE32(p) ((uint32_t) \
+ (((uint32_t)((p)[3]) << 24) | \
+ ((uint32_t)((p)[2]) << 16) | \
+ ((uint32_t)((p)[1]) << 8) | \
+ ((uint32_t)((p)[0]))))
+
+static void parse_descriptor(const void *source, const char *descriptor, void *dest)
{
- const unsigned char *sp = source;
- unsigned char *dp = dest;
- uint16_t w;
- const char *cp;
- uint32_t d;
-
- for (cp = descriptor; *cp; cp++) {
- switch (*cp) {
- case 'b': /* 8-bit byte */
- *dp++ = *sp++;
- break;
- case 'w': /* 16-bit word, convert from little endian to CPU */
- dp += ((uintptr_t)dp & 1); /* Align to word boundary */
-
- if (host_endian) {
- memcpy(dp, sp, 2);
- } else {
- w = (uint16_t)((sp[1] << 8) | sp[0]);
- *((uint16_t *)dp) = w;
- }
- sp += 2;
- dp += 2;
- break;
- case 'd': /* 32-bit word, convert from little endian to CPU */
- dp += ((uintptr_t)dp & 1); /* Align to word boundary */
-
- if (host_endian) {
- memcpy(dp, sp, 4);
- } else {
- d = (uint32_t)((sp[3] << 24) | (sp[2] << 16) |
- (sp[1] << 8) | sp[0]);
- *((uint32_t *)dp) = d;
- }
- sp += 4;
- dp += 4;
- break;
- case 'u': /* 16 byte UUID */
- memcpy(dp, sp, 16);
- sp += 16;
- dp += 16;
- break;
+ const uint8_t *sp = source;
+ uint8_t *dp = dest;
+ char field_type;
+
+ while (*descriptor) {
+ field_type = *descriptor++;
+ switch (field_type) {
+ case 'b': /* 8-bit byte */
+ *dp++ = *sp++;
+ break;
+ case 'w': /* 16-bit word, convert from little endian to CPU */
+ dp += ((uintptr_t)dp & 1); /* Align to 16-bit word boundary */
+
+ *((uint16_t *)dp) = READ_LE16(sp);
+ sp += 2;
+ dp += 2;
+ break;
+ case 'd': /* 32-bit word, convert from little endian to CPU */
+ dp += 4 - ((uintptr_t)dp & 3); /* Align to 32-bit word boundary */
+
+ *((uint32_t *)dp) = READ_LE32(sp);
+ sp += 4;
+ dp += 4;
+ break;
+ case 'u': /* 16 byte UUID */
+ memcpy(dp, sp, 16);
+ sp += 16;
+ dp += 16;
+ break;
}
}
-
- return (int) (sp - source);
}
static void clear_endpoint(struct libusb_endpoint_descriptor *endpoint)
{
- free((void *) endpoint->extra);
+ free((void *)endpoint->extra);
}
static int parse_endpoint(struct libusb_context *ctx,
- struct libusb_endpoint_descriptor *endpoint, unsigned char *buffer,
- int size, int host_endian)
+ struct libusb_endpoint_descriptor *endpoint, const uint8_t *buffer, int size)
{
- struct usb_descriptor_header header;
- unsigned char *extra;
- unsigned char *begin;
+ const struct usbi_descriptor_header *header;
+ const uint8_t *begin;
+ void *extra;
int parsed = 0;
int len;
@@ -113,75 +95,69 @@ static int parse_endpoint(struct libusb_context *ctx,
return LIBUSB_ERROR_IO;
}
- usbi_parse_descriptor(buffer, "bb", &header, 0);
- if (header.bDescriptorType != LIBUSB_DT_ENDPOINT) {
- usbi_err(ctx, "unexpected descriptor %x (expected %x)",
- header.bDescriptorType, LIBUSB_DT_ENDPOINT);
+ header = (const struct usbi_descriptor_header *)buffer;
+ if (header->bDescriptorType != LIBUSB_DT_ENDPOINT) {
+ usbi_err(ctx, "unexpected descriptor 0x%x (expected 0x%x)",
+ header->bDescriptorType, LIBUSB_DT_ENDPOINT);
return parsed;
- }
- if (header.bLength > size) {
- usbi_warn(ctx, "short endpoint descriptor read %d/%d",
- size, header.bLength);
- return parsed;
- }
- if (header.bLength >= ENDPOINT_AUDIO_DESC_LENGTH)
- usbi_parse_descriptor(buffer, "bbbbwbbb", endpoint, host_endian);
- else if (header.bLength >= ENDPOINT_DESC_LENGTH)
- usbi_parse_descriptor(buffer, "bbbbwb", endpoint, host_endian);
- else {
- usbi_err(ctx, "invalid endpoint bLength (%d)", header.bLength);
+ } else if (header->bLength < LIBUSB_DT_ENDPOINT_SIZE) {
+ usbi_err(ctx, "invalid endpoint bLength (%u)", header->bLength);
return LIBUSB_ERROR_IO;
+ } else if (header->bLength > size) {
+ usbi_warn(ctx, "short endpoint descriptor read %d/%u",
+ size, header->bLength);
+ return parsed;
}
- buffer += header.bLength;
- size -= header.bLength;
- parsed += header.bLength;
+ if (header->bLength >= LIBUSB_DT_ENDPOINT_AUDIO_SIZE)
+ parse_descriptor(buffer, "bbbbwbbb", endpoint);
+ else
+ parse_descriptor(buffer, "bbbbwb", endpoint);
+
+ buffer += header->bLength;
+ size -= header->bLength;
+ parsed += header->bLength;
/* Skip over the rest of the Class Specific or Vendor Specific */
/* descriptors */
begin = buffer;
while (size >= DESC_HEADER_LENGTH) {
- usbi_parse_descriptor(buffer, "bb", &header, 0);
- if (header.bLength < DESC_HEADER_LENGTH) {
- usbi_err(ctx, "invalid extra ep desc len (%d)",
- header.bLength);
+ header = (const struct usbi_descriptor_header *)buffer;
+ if (header->bLength < DESC_HEADER_LENGTH) {
+ usbi_err(ctx, "invalid extra ep desc len (%u)",
+ header->bLength);
return LIBUSB_ERROR_IO;
- } else if (header.bLength > size) {
- usbi_warn(ctx, "short extra ep desc read %d/%d",
- size, header.bLength);
+ } else if (header->bLength > size) {
+ usbi_warn(ctx, "short extra ep desc read %d/%u",
+ size, header->bLength);
return parsed;
}
/* If we find another "proper" descriptor then we're done */
- if ((header.bDescriptorType == LIBUSB_DT_ENDPOINT) ||
- (header.bDescriptorType == LIBUSB_DT_INTERFACE) ||
- (header.bDescriptorType == LIBUSB_DT_CONFIG) ||
- (header.bDescriptorType == LIBUSB_DT_DEVICE))
+ if (header->bDescriptorType == LIBUSB_DT_ENDPOINT ||
+ header->bDescriptorType == LIBUSB_DT_INTERFACE ||
+ header->bDescriptorType == LIBUSB_DT_CONFIG ||
+ header->bDescriptorType == LIBUSB_DT_DEVICE)
break;
- usbi_dbg("skipping descriptor %x", header.bDescriptorType);
- buffer += header.bLength;
- size -= header.bLength;
- parsed += header.bLength;
+ usbi_dbg("skipping descriptor 0x%x", header->bDescriptorType);
+ buffer += header->bLength;
+ size -= header->bLength;
+ parsed += header->bLength;
}
/* Copy any unknown descriptors into a storage area for drivers */
/* to later parse */
len = (int)(buffer - begin);
- if (len <= 0) {
- endpoint->extra = NULL;
- endpoint->extra_length = 0;
+ if (len <= 0)
return parsed;
- }
extra = malloc((size_t)len);
- endpoint->extra = extra;
- if (!extra) {
- endpoint->extra_length = 0;
+ if (!extra)
return LIBUSB_ERROR_NO_MEM;
- }
memcpy(extra, begin, len);
+ endpoint->extra = extra;
endpoint->extra_length = len;
return parsed;
@@ -190,47 +166,45 @@ static int parse_endpoint(struct libusb_context *ctx,
static void clear_interface(struct libusb_interface *usb_interface)
{
int i;
- int j;
if (usb_interface->altsetting) {
for (i = 0; i < usb_interface->num_altsetting; i++) {
struct libusb_interface_descriptor *ifp =
(struct libusb_interface_descriptor *)
usb_interface->altsetting + i;
- free((void *) ifp->extra);
+
+ free((void *)ifp->extra);
if (ifp->endpoint) {
+ uint8_t j;
+
for (j = 0; j < ifp->bNumEndpoints; j++)
clear_endpoint((struct libusb_endpoint_descriptor *)
ifp->endpoint + j);
}
- free((void *) ifp->endpoint);
+ free((void *)ifp->endpoint);
}
}
- free((void *) usb_interface->altsetting);
+ free((void *)usb_interface->altsetting);
usb_interface->altsetting = NULL;
}
static int parse_interface(libusb_context *ctx,
- struct libusb_interface *usb_interface, unsigned char *buffer, int size,
- int host_endian)
+ struct libusb_interface *usb_interface, const uint8_t *buffer, int size)
{
- int i;
int len;
int r;
int parsed = 0;
int interface_number = -1;
- struct usb_descriptor_header header;
+ const struct usbi_descriptor_header *header;
+ const struct usbi_interface_descriptor *if_desc;
struct libusb_interface_descriptor *ifp;
- unsigned char *begin;
+ const uint8_t *begin;
- usb_interface->num_altsetting = 0;
+ while (size >= LIBUSB_DT_INTERFACE_SIZE) {
+ struct libusb_interface_descriptor *altsetting;
- while (size >= INTERFACE_DESC_LENGTH) {
- struct libusb_interface_descriptor *altsetting =
- (struct libusb_interface_descriptor *) usb_interface->altsetting;
- altsetting = usbi_reallocf(altsetting,
- sizeof(struct libusb_interface_descriptor) *
- ((size_t)usb_interface->num_altsetting + 1));
+ altsetting = realloc((void *)usb_interface->altsetting,
+ sizeof(*altsetting) * (size_t)(usb_interface->num_altsetting + 1));
if (!altsetting) {
r = LIBUSB_ERROR_NO_MEM;
goto err;
@@ -238,25 +212,22 @@ static int parse_interface(libusb_context *ctx,
usb_interface->altsetting = altsetting;
ifp = altsetting + usb_interface->num_altsetting;
- usbi_parse_descriptor(buffer, "bbbbbbbbb", ifp, 0);
+ parse_descriptor(buffer, "bbbbbbbbb", ifp);
if (ifp->bDescriptorType != LIBUSB_DT_INTERFACE) {
- usbi_err(ctx, "unexpected descriptor %x (expected %x)",
+ usbi_err(ctx, "unexpected descriptor 0x%x (expected 0x%x)",
ifp->bDescriptorType, LIBUSB_DT_INTERFACE);
return parsed;
- }
- if (ifp->bLength < INTERFACE_DESC_LENGTH) {
- usbi_err(ctx, "invalid interface bLength (%d)",
+ } else if (ifp->bLength < LIBUSB_DT_INTERFACE_SIZE) {
+ usbi_err(ctx, "invalid interface bLength (%u)",
ifp->bLength);
r = LIBUSB_ERROR_IO;
goto err;
- }
- if (ifp->bLength > size) {
- usbi_warn(ctx, "short intf descriptor read %d/%d",
+ } else if (ifp->bLength > size) {
+ usbi_warn(ctx, "short intf descriptor read %d/%u",
size, ifp->bLength);
return parsed;
- }
- if (ifp->bNumEndpoints > USB_MAXENDPOINTS) {
- usbi_err(ctx, "too many endpoints (%d)", ifp->bNumEndpoints);
+ } else if (ifp->bNumEndpoints > USB_MAXENDPOINTS) {
+ usbi_err(ctx, "too many endpoints (%u)", ifp->bNumEndpoints);
r = LIBUSB_ERROR_IO;
goto err;
}
@@ -278,61 +249,65 @@ static int parse_interface(libusb_context *ctx,
/* Skip over any interface, class or vendor descriptors */
while (size >= DESC_HEADER_LENGTH) {
- usbi_parse_descriptor(buffer, "bb", &header, 0);
- if (header.bLength < DESC_HEADER_LENGTH) {
+ header = (const struct usbi_descriptor_header *)buffer;
+ if (header->bLength < DESC_HEADER_LENGTH) {
usbi_err(ctx,
- "invalid extra intf desc len (%d)",
- header.bLength);
+ "invalid extra intf desc len (%u)",
+ header->bLength);
r = LIBUSB_ERROR_IO;
goto err;
- } else if (header.bLength > size) {
+ } else if (header->bLength > size) {
usbi_warn(ctx,
- "short extra intf desc read %d/%d",
- size, header.bLength);
+ "short extra intf desc read %d/%u",
+ size, header->bLength);
return parsed;
}
/* If we find another "proper" descriptor then we're done */
- if ((header.bDescriptorType == LIBUSB_DT_INTERFACE) ||
- (header.bDescriptorType == LIBUSB_DT_ENDPOINT) ||
- (header.bDescriptorType == LIBUSB_DT_CONFIG) ||
- (header.bDescriptorType == LIBUSB_DT_DEVICE))
+ if (header->bDescriptorType == LIBUSB_DT_INTERFACE ||
+ header->bDescriptorType == LIBUSB_DT_ENDPOINT ||
+ header->bDescriptorType == LIBUSB_DT_CONFIG ||
+ header->bDescriptorType == LIBUSB_DT_DEVICE)
break;
- buffer += header.bLength;
- parsed += header.bLength;
- size -= header.bLength;
+ buffer += header->bLength;
+ parsed += header->bLength;
+ size -= header->bLength;
}
/* Copy any unknown descriptors into a storage area for */
/* drivers to later parse */
len = (int)(buffer - begin);
if (len > 0) {
- ifp->extra = malloc((size_t)len);
- if (!ifp->extra) {
+ void *extra = malloc((size_t)len);
+
+ if (!extra) {
r = LIBUSB_ERROR_NO_MEM;
goto err;
}
- memcpy((unsigned char *) ifp->extra, begin, len);
+
+ memcpy(extra, begin, len);
+ ifp->extra = extra;
ifp->extra_length = len;
}
if (ifp->bNumEndpoints > 0) {
struct libusb_endpoint_descriptor *endpoint;
- endpoint = calloc(ifp->bNumEndpoints, sizeof(struct libusb_endpoint_descriptor));
- ifp->endpoint = endpoint;
+ uint8_t i;
+
+ endpoint = calloc(ifp->bNumEndpoints, sizeof(*endpoint));
if (!endpoint) {
r = LIBUSB_ERROR_NO_MEM;
goto err;
}
+ ifp->endpoint = endpoint;
for (i = 0; i < ifp->bNumEndpoints; i++) {
- r = parse_endpoint(ctx, endpoint + i, buffer, size,
- host_endian);
+ r = parse_endpoint(ctx, endpoint + i, buffer, size);
if (r < 0)
goto err;
if (r == 0) {
- ifp->bNumEndpoints = (uint8_t)i;
+ ifp->bNumEndpoints = i;
break;
}
@@ -343,10 +318,10 @@ static int parse_interface(libusb_context *ctx,
}
/* We check to see if it's an alternate to this one */
- ifp = (struct libusb_interface_descriptor *) buffer;
+ if_desc = (const struct usbi_interface_descriptor *)buffer;
if (size < LIBUSB_DT_INTERFACE_SIZE ||
- ifp->bDescriptorType != LIBUSB_DT_INTERFACE ||
- ifp->bInterfaceNumber != interface_number)
+ if_desc->bDescriptorType != LIBUSB_DT_INTERFACE ||
+ if_desc->bInterfaceNumber != interface_number)
return parsed;
}
@@ -358,23 +333,23 @@ err:
static void clear_configuration(struct libusb_config_descriptor *config)
{
- int i;
+ uint8_t i;
+
if (config->interface) {
for (i = 0; i < config->bNumInterfaces; i++)
clear_interface((struct libusb_interface *)
config->interface + i);
}
- free((void *) config->interface);
- free((void *) config->extra);
+ free((void *)config->interface);
+ free((void *)config->extra);
}
static int parse_configuration(struct libusb_context *ctx,
- struct libusb_config_descriptor *config, unsigned char *buffer,
- int size, int host_endian)
+ struct libusb_config_descriptor *config, const uint8_t *buffer, int size)
{
- int i;
+ uint8_t i;
int r;
- struct usb_descriptor_header header;
+ const struct usbi_descriptor_header *header;
struct libusb_interface *usb_interface;
if (size < LIBUSB_DT_CONFIG_SIZE) {
@@ -383,95 +358,89 @@ static int parse_configuration(struct libusb_context *ctx,
return LIBUSB_ERROR_IO;
}
- usbi_parse_descriptor(buffer, "bbwbbbbb", config, host_endian);
+ parse_descriptor(buffer, "bbwbbbbb", config);
if (config->bDescriptorType != LIBUSB_DT_CONFIG) {
- usbi_err(ctx, "unexpected descriptor %x (expected %x)",
+ usbi_err(ctx, "unexpected descriptor 0x%x (expected 0x%x)",
config->bDescriptorType, LIBUSB_DT_CONFIG);
return LIBUSB_ERROR_IO;
- }
- if (config->bLength < LIBUSB_DT_CONFIG_SIZE) {
- usbi_err(ctx, "invalid config bLength (%d)", config->bLength);
+ } else if (config->bLength < LIBUSB_DT_CONFIG_SIZE) {
+ usbi_err(ctx, "invalid config bLength (%u)", config->bLength);
return LIBUSB_ERROR_IO;
- }
- if (config->bLength > size) {
- usbi_err(ctx, "short config descriptor read %d/%d",
+ } else if (config->bLength > size) {
+ usbi_err(ctx, "short config descriptor read %d/%u",
size, config->bLength);
return LIBUSB_ERROR_IO;
- }
- if (config->bNumInterfaces > USB_MAXINTERFACES) {
- usbi_err(ctx, "too many interfaces (%d)", config->bNumInterfaces);
+ } else if (config->bNumInterfaces > USB_MAXINTERFACES) {
+ usbi_err(ctx, "too many interfaces (%u)", config->bNumInterfaces);
return LIBUSB_ERROR_IO;
}
- usb_interface = calloc(config->bNumInterfaces, sizeof(struct libusb_interface));
- config->interface = usb_interface;
+ usb_interface = calloc(config->bNumInterfaces, sizeof(*usb_interface));
if (!usb_interface)
return LIBUSB_ERROR_NO_MEM;
+ config->interface = usb_interface;
+
buffer += config->bLength;
size -= config->bLength;
- config->extra = NULL;
- config->extra_length = 0;
-
for (i = 0; i < config->bNumInterfaces; i++) {
int len;
- unsigned char *begin;
+ const uint8_t *begin;
/* Skip over the rest of the Class Specific or Vendor */
/* Specific descriptors */
begin = buffer;
while (size >= DESC_HEADER_LENGTH) {
- usbi_parse_descriptor(buffer, "bb", &header, 0);
-
- if (header.bLength < DESC_HEADER_LENGTH) {
+ header = (const struct usbi_descriptor_header *)buffer;
+ if (header->bLength < DESC_HEADER_LENGTH) {
usbi_err(ctx,
- "invalid extra config desc len (%d)",
- header.bLength);
+ "invalid extra config desc len (%u)",
+ header->bLength);
r = LIBUSB_ERROR_IO;
goto err;
- } else if (header.bLength > size) {
+ } else if (header->bLength > size) {
usbi_warn(ctx,
- "short extra config desc read %d/%d",
- size, header.bLength);
- config->bNumInterfaces = (uint8_t)i;
+ "short extra config desc read %d/%u",
+ size, header->bLength);
+ config->bNumInterfaces = i;
return size;
}
/* If we find another "proper" descriptor then we're done */
- if ((header.bDescriptorType == LIBUSB_DT_ENDPOINT) ||
- (header.bDescriptorType == LIBUSB_DT_INTERFACE) ||
- (header.bDescriptorType == LIBUSB_DT_CONFIG) ||
- (header.bDescriptorType == LIBUSB_DT_DEVICE))
+ if (header->bDescriptorType == LIBUSB_DT_ENDPOINT ||
+ header->bDescriptorType == LIBUSB_DT_INTERFACE ||
+ header->bDescriptorType == LIBUSB_DT_CONFIG ||
+ header->bDescriptorType == LIBUSB_DT_DEVICE)
break;
- usbi_dbg("skipping descriptor 0x%x", header.bDescriptorType);
- buffer += header.bLength;
- size -= header.bLength;
+ usbi_dbg("skipping descriptor 0x%x", header->bDescriptorType);
+ buffer += header->bLength;
+ size -= header->bLength;
}
/* Copy any unknown descriptors into a storage area for */
/* drivers to later parse */
len = (int)(buffer - begin);
if (len > 0) {
- /* FIXME: We should realloc and append here */
- if (!config->extra_length) {
- config->extra = malloc((size_t)len);
- if (!config->extra) {
- r = LIBUSB_ERROR_NO_MEM;
- goto err;
- }
+ uint8_t *extra = realloc((void *)config->extra,
+ (size_t)(config->extra_length + len));
- memcpy((unsigned char *) config->extra, begin, len);
- config->extra_length = len;
+ if (!extra) {
+ r = LIBUSB_ERROR_NO_MEM;
+ goto err;
}
+
+ memcpy(extra + config->extra_length, begin, len);
+ config->extra = extra;
+ config->extra_length += len;
}
- r = parse_interface(ctx, usb_interface + i, buffer, size, host_endian);
+ r = parse_interface(ctx, usb_interface + i, buffer, size);
if (r < 0)
goto err;
if (r == 0) {
- config->bNumInterfaces = (uint8_t)i;
+ config->bNumInterfaces = i;
break;
}
@@ -487,16 +456,15 @@ err:
}
static int raw_desc_to_config(struct libusb_context *ctx,
- unsigned char *buf, int size, int host_endian,
- struct libusb_config_descriptor **config)
+ const uint8_t *buf, int size, struct libusb_config_descriptor **config)
{
- struct libusb_config_descriptor *_config = malloc(sizeof(*_config));
+ struct libusb_config_descriptor *_config = calloc(1, sizeof(*_config));
int r;
if (!_config)
return LIBUSB_ERROR_NO_MEM;
- r = parse_configuration(ctx, _config, buf, size, host_endian);
+ r = parse_configuration(ctx, _config, buf, size);
if (r < 0) {
usbi_err(ctx, "parse_configuration failed with error %d", r);
free(_config);
@@ -509,23 +477,43 @@ static int raw_desc_to_config(struct libusb_context *ctx,
return LIBUSB_SUCCESS;
}
-int usbi_device_cache_descriptor(libusb_device *dev)
+static int get_active_config_descriptor(struct libusb_device *dev,
+ uint8_t *buffer, size_t size)
{
- int r, host_endian = 0;
+ int r = usbi_backend.get_active_config_descriptor(dev, buffer, size);
- r = usbi_backend.get_device_descriptor(dev, (unsigned char *) &dev->device_descriptor,
- &host_endian);
if (r < 0)
return r;
- if (!host_endian) {
- dev->device_descriptor.bcdUSB = libusb_le16_to_cpu(dev->device_descriptor.bcdUSB);
- dev->device_descriptor.idVendor = libusb_le16_to_cpu(dev->device_descriptor.idVendor);
- dev->device_descriptor.idProduct = libusb_le16_to_cpu(dev->device_descriptor.idProduct);
- dev->device_descriptor.bcdDevice = libusb_le16_to_cpu(dev->device_descriptor.bcdDevice);
+ if (r < LIBUSB_DT_CONFIG_SIZE) {
+ usbi_err(DEVICE_CTX(dev), "short config descriptor read %d/%d",
+ r, LIBUSB_DT_CONFIG_SIZE);
+ return LIBUSB_ERROR_IO;
+ } else if (r != (int)size) {
+ usbi_warn(DEVICE_CTX(dev), "short config descriptor read %d/%d",
+ r, (int)size);
}
- return LIBUSB_SUCCESS;
+ return r;
+}
+
+static int get_config_descriptor(struct libusb_device *dev, uint8_t config_idx,
+ uint8_t *buffer, size_t size)
+{
+ int r = usbi_backend.get_config_descriptor(dev, config_idx, buffer, size);
+
+ if (r < 0)
+ return r;
+ if (r < LIBUSB_DT_CONFIG_SIZE) {
+ usbi_err(DEVICE_CTX(dev), "short config descriptor read %d/%d",
+ r, LIBUSB_DT_CONFIG_SIZE);
+ return LIBUSB_ERROR_IO;
+ } else if (r != (int)size) {
+ usbi_warn(DEVICE_CTX(dev), "short config descriptor read %d/%d",
+ r, (int)size);
+ }
+
+ return r;
}
/** \ingroup libusb_desc
@@ -543,9 +531,10 @@ int usbi_device_cache_descriptor(libusb_device *dev)
int API_EXPORTED libusb_get_device_descriptor(libusb_device *dev,
struct libusb_device_descriptor *desc)
{
- usbi_dbg("");
- memcpy((unsigned char *) desc, (unsigned char *) &dev->device_descriptor,
- sizeof (dev->device_descriptor));
+ usbi_dbg(" ");
+ static_assert(sizeof(dev->device_descriptor) == LIBUSB_DT_DEVICE_SIZE,
+ "struct libusb_device_descriptor is not expected size");
+ *desc = dev->device_descriptor;
return 0;
}
@@ -566,31 +555,23 @@ int API_EXPORTED libusb_get_device_descriptor(libusb_device *dev,
int API_EXPORTED libusb_get_active_config_descriptor(libusb_device *dev,
struct libusb_config_descriptor **config)
{
- struct libusb_config_descriptor _config;
- unsigned char tmp[LIBUSB_DT_CONFIG_SIZE];
- unsigned char *buf = NULL;
- int host_endian = 0;
+ union usbi_config_desc_buf _config;
+ uint16_t config_len;
+ uint8_t *buf;
int r;
- r = usbi_backend.get_active_config_descriptor(dev, tmp,
- LIBUSB_DT_CONFIG_SIZE, &host_endian);
+ r = get_active_config_descriptor(dev, _config.buf, sizeof(_config.buf));
if (r < 0)
return r;
- if (r < LIBUSB_DT_CONFIG_SIZE) {
- usbi_err(dev->ctx, "short config descriptor read %d/%d",
- r, LIBUSB_DT_CONFIG_SIZE);
- return LIBUSB_ERROR_IO;
- }
- usbi_parse_descriptor(tmp, "bbw", &_config, host_endian);
- buf = malloc(_config.wTotalLength);
+ config_len = libusb_le16_to_cpu(_config.desc.wTotalLength);
+ buf = malloc(config_len);
if (!buf)
return LIBUSB_ERROR_NO_MEM;
- r = usbi_backend.get_active_config_descriptor(dev, buf,
- _config.wTotalLength, &host_endian);
+ r = get_active_config_descriptor(dev, buf, config_len);
if (r >= 0)
- r = raw_desc_to_config(dev->ctx, buf, r, host_endian, config);
+ r = raw_desc_to_config(DEVICE_CTX(dev), buf, r, config);
free(buf);
return r;
@@ -615,70 +596,32 @@ int API_EXPORTED libusb_get_active_config_descriptor(libusb_device *dev,
int API_EXPORTED libusb_get_config_descriptor(libusb_device *dev,
uint8_t config_index, struct libusb_config_descriptor **config)
{
- struct libusb_config_descriptor _config;
- unsigned char tmp[LIBUSB_DT_CONFIG_SIZE];
- unsigned char *buf = NULL;
- int host_endian = 0;
+ union usbi_config_desc_buf _config;
+ uint16_t config_len;
+ uint8_t *buf;
int r;
- usbi_dbg("index %d", config_index);
- if (config_index >= dev->num_configurations)
+ usbi_dbg("index %u", config_index);
+ if (config_index >= dev->device_descriptor.bNumConfigurations)
return LIBUSB_ERROR_NOT_FOUND;
- r = usbi_backend.get_config_descriptor(dev, config_index, tmp,
- LIBUSB_DT_CONFIG_SIZE, &host_endian);
+ r = get_config_descriptor(dev, config_index, _config.buf, sizeof(_config.buf));
if (r < 0)
return r;
- if (r < LIBUSB_DT_CONFIG_SIZE) {
- usbi_err(dev->ctx, "short config descriptor read %d/%d",
- r, LIBUSB_DT_CONFIG_SIZE);
- return LIBUSB_ERROR_IO;
- }
- usbi_parse_descriptor(tmp, "bbw", &_config, host_endian);
- buf = malloc(_config.wTotalLength);
+ config_len = libusb_le16_to_cpu(_config.desc.wTotalLength);
+ buf = malloc(config_len);
if (!buf)
return LIBUSB_ERROR_NO_MEM;
- r = usbi_backend.get_config_descriptor(dev, config_index, buf,
- _config.wTotalLength, &host_endian);
+ r = get_config_descriptor(dev, config_index, buf, config_len);
if (r >= 0)
- r = raw_desc_to_config(dev->ctx, buf, r, host_endian, config);
+ r = raw_desc_to_config(DEVICE_CTX(dev), buf, r, config);
free(buf);
return r;
}
-/* iterate through all configurations, returning the index of the configuration
- * matching a specific bConfigurationValue in the idx output parameter, or -1
- * if the config was not found.
- * returns 0 on success or a LIBUSB_ERROR code
- */
-int usbi_get_config_index_by_value(struct libusb_device *dev,
- uint8_t bConfigurationValue, int *idx)
-{
- uint8_t i;
-
- usbi_dbg("value %d", bConfigurationValue);
- for (i = 0; i < dev->num_configurations; i++) {
- unsigned char tmp[6];
- int host_endian;
- int r = usbi_backend.get_config_descriptor(dev, i, tmp, sizeof(tmp),
- &host_endian);
- if (r < 0) {
- *idx = -1;
- return r;
- }
- if (tmp[5] == bConfigurationValue) {
- *idx = i;
- return 0;
- }
- }
-
- *idx = -1;
- return 0;
-}
-
/** \ingroup libusb_desc
* Get a USB configuration descriptor with a specific bConfigurationValue.
* This is a non-blocking function which does not involve any requests being
@@ -699,24 +642,33 @@ int usbi_get_config_index_by_value(struct libusb_device *dev,
int API_EXPORTED libusb_get_config_descriptor_by_value(libusb_device *dev,
uint8_t bConfigurationValue, struct libusb_config_descriptor **config)
{
- int r, idx, host_endian;
- unsigned char *buf = NULL;
+ uint8_t idx;
+ int r;
if (usbi_backend.get_config_descriptor_by_value) {
+ void *buf;
+
r = usbi_backend.get_config_descriptor_by_value(dev,
- bConfigurationValue, &buf, &host_endian);
+ bConfigurationValue, &buf);
if (r < 0)
return r;
- return raw_desc_to_config(dev->ctx, buf, r, host_endian, config);
+
+ return raw_desc_to_config(DEVICE_CTX(dev), buf, r, config);
}
- r = usbi_get_config_index_by_value(dev, bConfigurationValue, &idx);
- if (r < 0)
- return r;
- else if (idx == -1)
- return LIBUSB_ERROR_NOT_FOUND;
- else
- return libusb_get_config_descriptor(dev, (uint8_t) idx, config);
+ usbi_dbg("value %u", bConfigurationValue);
+ for (idx = 0; idx < dev->device_descriptor.bNumConfigurations; idx++) {
+ union usbi_config_desc_buf _config;
+
+ r = get_config_descriptor(dev, idx, _config.buf, sizeof(_config.buf));
+ if (r < 0)
+ return r;
+
+ if (_config.desc.bConfigurationValue == bConfigurationValue)
+ return libusb_get_config_descriptor(dev, idx, config);
+ }
+
+ return LIBUSB_ERROR_NOT_FOUND;
}
/** \ingroup libusb_desc
@@ -751,37 +703,41 @@ void API_EXPORTED libusb_free_config_descriptor(
* \returns another LIBUSB_ERROR code on error
*/
int API_EXPORTED libusb_get_ss_endpoint_companion_descriptor(
- struct libusb_context *ctx,
+ libusb_context *ctx,
const struct libusb_endpoint_descriptor *endpoint,
struct libusb_ss_endpoint_companion_descriptor **ep_comp)
{
- struct usb_descriptor_header header;
+ struct usbi_descriptor_header *header;
+ const uint8_t *buffer = endpoint->extra;
int size = endpoint->extra_length;
- const unsigned char *buffer = endpoint->extra;
*ep_comp = NULL;
while (size >= DESC_HEADER_LENGTH) {
- usbi_parse_descriptor(buffer, "bb", &header, 0);
- if (header.bLength < 2 || header.bLength > size) {
- usbi_err(ctx, "invalid descriptor length %d",
- header.bLength);
- return LIBUSB_ERROR_IO;
- }
- if (header.bDescriptorType != LIBUSB_DT_SS_ENDPOINT_COMPANION) {
- buffer += header.bLength;
- size -= header.bLength;
+ header = (struct usbi_descriptor_header *)buffer;
+ if (header->bDescriptorType != LIBUSB_DT_SS_ENDPOINT_COMPANION) {
+ if (header->bLength < DESC_HEADER_LENGTH) {
+ usbi_err(ctx, "invalid descriptor length %u",
+ header->bLength);
+ return LIBUSB_ERROR_IO;
+ }
+ buffer += header->bLength;
+ size -= header->bLength;
continue;
- }
- if (header.bLength < LIBUSB_DT_SS_ENDPOINT_COMPANION_SIZE) {
- usbi_err(ctx, "invalid ss-ep-comp-desc length %d",
- header.bLength);
+ } else if (header->bLength < LIBUSB_DT_SS_ENDPOINT_COMPANION_SIZE) {
+ usbi_err(ctx, "invalid ss-ep-comp-desc length %u",
+ header->bLength);
+ return LIBUSB_ERROR_IO;
+ } else if (header->bLength > size) {
+ usbi_err(ctx, "short ss-ep-comp-desc read %d/%u",
+ size, header->bLength);
return LIBUSB_ERROR_IO;
}
+
*ep_comp = malloc(sizeof(**ep_comp));
- if (*ep_comp == NULL)
+ if (!*ep_comp)
return LIBUSB_ERROR_NO_MEM;
- usbi_parse_descriptor(buffer, "bbbbw", *ep_comp, 0);
+ parse_descriptor(buffer, "bbbbw", *ep_comp);
return LIBUSB_SUCCESS;
}
return LIBUSB_ERROR_NOT_FOUND;
@@ -803,11 +759,12 @@ void API_EXPORTED libusb_free_ss_endpoint_companion_descriptor(
static int parse_bos(struct libusb_context *ctx,
struct libusb_bos_descriptor **bos,
- unsigned char *buffer, int size, int host_endian)
+ const uint8_t *buffer, int size)
{
- struct libusb_bos_descriptor bos_header, *_bos;
- struct libusb_bos_dev_capability_descriptor dev_cap;
- int i;
+ struct libusb_bos_descriptor *_bos;
+ const struct usbi_bos_descriptor *bos_desc;
+ const struct usbi_descriptor_header *header;
+ uint8_t i;
if (size < LIBUSB_DT_BOS_SIZE) {
usbi_err(ctx, "short bos descriptor read %d/%d",
@@ -815,66 +772,61 @@ static int parse_bos(struct libusb_context *ctx,
return LIBUSB_ERROR_IO;
}
- usbi_parse_descriptor(buffer, "bbwb", &bos_header, host_endian);
- if (bos_header.bDescriptorType != LIBUSB_DT_BOS) {
- usbi_err(ctx, "unexpected descriptor %x (expected %x)",
- bos_header.bDescriptorType, LIBUSB_DT_BOS);
+ bos_desc = (const struct usbi_bos_descriptor *)buffer;
+ if (bos_desc->bDescriptorType != LIBUSB_DT_BOS) {
+ usbi_err(ctx, "unexpected descriptor 0x%x (expected 0x%x)",
+ bos_desc->bDescriptorType, LIBUSB_DT_BOS);
return LIBUSB_ERROR_IO;
- }
- if (bos_header.bLength < LIBUSB_DT_BOS_SIZE) {
- usbi_err(ctx, "invalid bos bLength (%d)", bos_header.bLength);
+ } else if (bos_desc->bLength < LIBUSB_DT_BOS_SIZE) {
+ usbi_err(ctx, "invalid bos bLength (%u)", bos_desc->bLength);
return LIBUSB_ERROR_IO;
- }
- if (bos_header.bLength > size) {
- usbi_err(ctx, "short bos descriptor read %d/%d",
- size, bos_header.bLength);
+ } else if (bos_desc->bLength > size) {
+ usbi_err(ctx, "short bos descriptor read %d/%u",
+ size, bos_desc->bLength);
return LIBUSB_ERROR_IO;
}
- _bos = calloc (1,
- sizeof(*_bos) + bos_header.bNumDeviceCaps * sizeof(void *));
+ _bos = calloc(1, sizeof(*_bos) + bos_desc->bNumDeviceCaps * sizeof(void *));
if (!_bos)
return LIBUSB_ERROR_NO_MEM;
- usbi_parse_descriptor(buffer, "bbwb", _bos, host_endian);
- buffer += bos_header.bLength;
- size -= bos_header.bLength;
+ parse_descriptor(buffer, "bbwb", _bos);
+ buffer += _bos->bLength;
+ size -= _bos->bLength;
/* Get the device capability descriptors */
- for (i = 0; i < bos_header.bNumDeviceCaps; i++) {
+ for (i = 0; i < _bos->bNumDeviceCaps; i++) {
if (size < LIBUSB_DT_DEVICE_CAPABILITY_SIZE) {
usbi_warn(ctx, "short dev-cap descriptor read %d/%d",
size, LIBUSB_DT_DEVICE_CAPABILITY_SIZE);
break;
}
- usbi_parse_descriptor(buffer, "bbb", &dev_cap, host_endian);
- if (dev_cap.bDescriptorType != LIBUSB_DT_DEVICE_CAPABILITY) {
- usbi_warn(ctx, "unexpected descriptor %x (expected %x)",
- dev_cap.bDescriptorType, LIBUSB_DT_DEVICE_CAPABILITY);
+ header = (const struct usbi_descriptor_header *)buffer;
+ if (header->bDescriptorType != LIBUSB_DT_DEVICE_CAPABILITY) {
+ usbi_warn(ctx, "unexpected descriptor 0x%x (expected 0x%x)",
+ header->bDescriptorType, LIBUSB_DT_DEVICE_CAPABILITY);
break;
- }
- if (dev_cap.bLength < LIBUSB_DT_DEVICE_CAPABILITY_SIZE) {
- usbi_err(ctx, "invalid dev-cap bLength (%d)",
- dev_cap.bLength);
+ } else if (header->bLength < LIBUSB_DT_DEVICE_CAPABILITY_SIZE) {
+ usbi_err(ctx, "invalid dev-cap bLength (%u)",
+ header->bLength);
libusb_free_bos_descriptor(_bos);
return LIBUSB_ERROR_IO;
- }
- if (dev_cap.bLength > size) {
- usbi_warn(ctx, "short dev-cap descriptor read %d/%d",
- size, dev_cap.bLength);
+ } else if (header->bLength > size) {
+ usbi_warn(ctx, "short dev-cap descriptor read %d/%u",
+ size, header->bLength);
break;
}
- _bos->dev_capability[i] = malloc(dev_cap.bLength);
+ _bos->dev_capability[i] = malloc(header->bLength);
if (!_bos->dev_capability[i]) {
libusb_free_bos_descriptor(_bos);
return LIBUSB_ERROR_NO_MEM;
}
- memcpy(_bos->dev_capability[i], buffer, dev_cap.bLength);
- buffer += dev_cap.bLength;
- size -= dev_cap.bLength;
+ memcpy(_bos->dev_capability[i], buffer, header->bLength);
+ buffer += header->bLength;
+ size -= header->bLength;
}
- _bos->bNumDeviceCaps = (uint8_t)i;
+ _bos->bNumDeviceCaps = i;
*bos = _bos;
return LIBUSB_SUCCESS;
@@ -894,16 +846,14 @@ static int parse_bos(struct libusb_context *ctx,
int API_EXPORTED libusb_get_bos_descriptor(libusb_device_handle *dev_handle,
struct libusb_bos_descriptor **bos)
{
- struct libusb_bos_descriptor _bos;
- uint8_t bos_header[LIBUSB_DT_BOS_SIZE] = {0};
- unsigned char *bos_data = NULL;
- const int host_endian = 0;
+ union usbi_bos_desc_buf _bos;
+ uint16_t bos_len;
+ uint8_t *bos_data;
int r;
/* Read the BOS. This generates 2 requests on the bus,
* one for the header, and one for the full BOS */
- r = libusb_get_descriptor(dev_handle, LIBUSB_DT_BOS, 0, bos_header,
- LIBUSB_DT_BOS_SIZE);
+ r = libusb_get_descriptor(dev_handle, LIBUSB_DT_BOS, 0, _bos.buf, sizeof(_bos.buf));
if (r < 0) {
if (r != LIBUSB_ERROR_PIPE)
usbi_err(HANDLE_CTX(dev_handle), "failed to read BOS (%d)", r);
@@ -915,19 +865,22 @@ int API_EXPORTED libusb_get_bos_descriptor(libusb_device_handle *dev_handle,
return LIBUSB_ERROR_IO;
}
- usbi_parse_descriptor(bos_header, "bbwb", &_bos, host_endian);
- usbi_dbg("found BOS descriptor: size %d bytes, %d capabilities",
- _bos.wTotalLength, _bos.bNumDeviceCaps);
- bos_data = calloc(_bos.wTotalLength, 1);
- if (bos_data == NULL)
+ bos_len = libusb_le16_to_cpu(_bos.desc.wTotalLength);
+ usbi_dbg("found BOS descriptor: size %u bytes, %u capabilities",
+ bos_len, _bos.desc.bNumDeviceCaps);
+ bos_data = calloc(1, bos_len);
+ if (!bos_data)
return LIBUSB_ERROR_NO_MEM;
- r = libusb_get_descriptor(dev_handle, LIBUSB_DT_BOS, 0, bos_data,
- _bos.wTotalLength);
- if (r >= 0)
- r = parse_bos(HANDLE_CTX(dev_handle), bos, bos_data, r, host_endian);
- else
+ r = libusb_get_descriptor(dev_handle, LIBUSB_DT_BOS, 0, bos_data, bos_len);
+ if (r >= 0) {
+ if (r != (int)bos_len)
+ usbi_warn(HANDLE_CTX(dev_handle), "short BOS read %d/%u",
+ r, bos_len);
+ r = parse_bos(HANDLE_CTX(dev_handle), bos, bos_data, r);
+ } else {
usbi_err(HANDLE_CTX(dev_handle), "failed to read BOS (%d)", r);
+ }
free(bos_data);
return r;
@@ -942,7 +895,7 @@ int API_EXPORTED libusb_get_bos_descriptor(libusb_device_handle *dev_handle,
*/
void API_EXPORTED libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos)
{
- int i;
+ uint8_t i;
if (!bos)
return;
@@ -966,21 +919,19 @@ void API_EXPORTED libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos)
* \returns a LIBUSB_ERROR code on error
*/
int API_EXPORTED libusb_get_usb_2_0_extension_descriptor(
- struct libusb_context *ctx,
+ libusb_context *ctx,
struct libusb_bos_dev_capability_descriptor *dev_cap,
struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension)
{
struct libusb_usb_2_0_extension_descriptor *_usb_2_0_extension;
- const int host_endian = 0;
if (dev_cap->bDevCapabilityType != LIBUSB_BT_USB_2_0_EXTENSION) {
- usbi_err(ctx, "unexpected bDevCapabilityType %x (expected %x)",
+ usbi_err(ctx, "unexpected bDevCapabilityType 0x%x (expected 0x%x)",
dev_cap->bDevCapabilityType,
LIBUSB_BT_USB_2_0_EXTENSION);
return LIBUSB_ERROR_INVALID_PARAM;
- }
- if (dev_cap->bLength < LIBUSB_BT_USB_2_0_EXTENSION_SIZE) {
- usbi_err(ctx, "short dev-cap descriptor read %d/%d",
+ } else if (dev_cap->bLength < LIBUSB_BT_USB_2_0_EXTENSION_SIZE) {
+ usbi_err(ctx, "short dev-cap descriptor read %u/%d",
dev_cap->bLength, LIBUSB_BT_USB_2_0_EXTENSION_SIZE);
return LIBUSB_ERROR_IO;
}
@@ -989,8 +940,7 @@ int API_EXPORTED libusb_get_usb_2_0_extension_descriptor(
if (!_usb_2_0_extension)
return LIBUSB_ERROR_NO_MEM;
- usbi_parse_descriptor((unsigned char *)dev_cap, "bbbd",
- _usb_2_0_extension, host_endian);
+ parse_descriptor(dev_cap, "bbbd", _usb_2_0_extension);
*usb_2_0_extension = _usb_2_0_extension;
return LIBUSB_SUCCESS;
@@ -1024,21 +974,19 @@ void API_EXPORTED libusb_free_usb_2_0_extension_descriptor(
* \returns a LIBUSB_ERROR code on error
*/
int API_EXPORTED libusb_get_ss_usb_device_capability_descriptor(
- struct libusb_context *ctx,
+ libusb_context *ctx,
struct libusb_bos_dev_capability_descriptor *dev_cap,
struct libusb_ss_usb_device_capability_descriptor **ss_usb_device_cap)
{
struct libusb_ss_usb_device_capability_descriptor *_ss_usb_device_cap;
- const int host_endian = 0;
if (dev_cap->bDevCapabilityType != LIBUSB_BT_SS_USB_DEVICE_CAPABILITY) {
- usbi_err(ctx, "unexpected bDevCapabilityType %x (expected %x)",
+ usbi_err(ctx, "unexpected bDevCapabilityType 0x%x (expected 0x%x)",
dev_cap->bDevCapabilityType,
LIBUSB_BT_SS_USB_DEVICE_CAPABILITY);
return LIBUSB_ERROR_INVALID_PARAM;
- }
- if (dev_cap->bLength < LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE) {
- usbi_err(ctx, "short dev-cap descriptor read %d/%d",
+ } else if (dev_cap->bLength < LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE) {
+ usbi_err(ctx, "short dev-cap descriptor read %u/%d",
dev_cap->bLength, LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE);
return LIBUSB_ERROR_IO;
}
@@ -1047,8 +995,7 @@ int API_EXPORTED libusb_get_ss_usb_device_capability_descriptor(
if (!_ss_usb_device_cap)
return LIBUSB_ERROR_NO_MEM;
- usbi_parse_descriptor((unsigned char *)dev_cap, "bbbbwbbw",
- _ss_usb_device_cap, host_endian);
+ parse_descriptor(dev_cap, "bbbbwbbw", _ss_usb_device_cap);
*ss_usb_device_cap = _ss_usb_device_cap;
return LIBUSB_SUCCESS;
@@ -1082,21 +1029,19 @@ void API_EXPORTED libusb_free_ss_usb_device_capability_descriptor(
* \returns 0 on success
* \returns a LIBUSB_ERROR code on error
*/
-int API_EXPORTED libusb_get_container_id_descriptor(struct libusb_context *ctx,
+int API_EXPORTED libusb_get_container_id_descriptor(libusb_context *ctx,
struct libusb_bos_dev_capability_descriptor *dev_cap,
struct libusb_container_id_descriptor **container_id)
{
struct libusb_container_id_descriptor *_container_id;
- const int host_endian = 0;
if (dev_cap->bDevCapabilityType != LIBUSB_BT_CONTAINER_ID) {
- usbi_err(ctx, "unexpected bDevCapabilityType %x (expected %x)",
+ usbi_err(ctx, "unexpected bDevCapabilityType 0x%x (expected 0x%x)",
dev_cap->bDevCapabilityType,
LIBUSB_BT_CONTAINER_ID);
return LIBUSB_ERROR_INVALID_PARAM;
- }
- if (dev_cap->bLength < LIBUSB_BT_CONTAINER_ID_SIZE) {
- usbi_err(ctx, "short dev-cap descriptor read %d/%d",
+ } else if (dev_cap->bLength < LIBUSB_BT_CONTAINER_ID_SIZE) {
+ usbi_err(ctx, "short dev-cap descriptor read %u/%d",
dev_cap->bLength, LIBUSB_BT_CONTAINER_ID_SIZE);
return LIBUSB_ERROR_IO;
}
@@ -1105,8 +1050,7 @@ int API_EXPORTED libusb_get_container_id_descriptor(struct libusb_context *ctx,
if (!_container_id)
return LIBUSB_ERROR_NO_MEM;
- usbi_parse_descriptor((unsigned char *)dev_cap, "bbbbu",
- _container_id, host_endian);
+ parse_descriptor(dev_cap, "bbbbu", _container_id);
*container_id = _container_id;
return LIBUSB_SUCCESS;
@@ -1141,9 +1085,9 @@ void API_EXPORTED libusb_free_container_id_descriptor(
int API_EXPORTED libusb_get_string_descriptor_ascii(libusb_device_handle *dev_handle,
uint8_t desc_index, unsigned char *data, int length)
{
- unsigned char tbuf[255]; /* Some devices choke on size > 255 */
+ union usbi_string_desc_buf str;
int r, si, di;
- uint16_t langid;
+ uint16_t langid, wdata;
/* Asking for the zero'th index is special - it returns a string
* descriptor that contains all the language IDs supported by the
@@ -1157,35 +1101,37 @@ int API_EXPORTED libusb_get_string_descriptor_ascii(libusb_device_handle *dev_ha
if (desc_index == 0)
return LIBUSB_ERROR_INVALID_PARAM;
- r = libusb_get_string_descriptor(dev_handle, 0, 0, tbuf, sizeof(tbuf));
+ r = libusb_get_string_descriptor(dev_handle, 0, 0, str.buf, 4);
if (r < 0)
return r;
-
- if (r < 4)
+ else if (r != 4 || str.desc.bLength < 4)
return LIBUSB_ERROR_IO;
+ else if (str.desc.bDescriptorType != LIBUSB_DT_STRING)
+ return LIBUSB_ERROR_IO;
+ else if (str.desc.bLength & 1)
+ usbi_warn(HANDLE_CTX(dev_handle), "suspicious bLength %u for string descriptor", str.desc.bLength);
- langid = (uint16_t)(tbuf[2] | (tbuf[3] << 8));
-
- r = libusb_get_string_descriptor(dev_handle, desc_index, langid, tbuf,
- sizeof(tbuf));
+ langid = libusb_le16_to_cpu(str.desc.wData[0]);
+ r = libusb_get_string_descriptor(dev_handle, desc_index, langid, str.buf, sizeof(str.buf));
if (r < 0)
return r;
-
- if (tbuf[1] != LIBUSB_DT_STRING)
+ else if (r < DESC_HEADER_LENGTH || str.desc.bLength > r)
return LIBUSB_ERROR_IO;
-
- if (tbuf[0] > r)
+ else if (str.desc.bDescriptorType != LIBUSB_DT_STRING)
return LIBUSB_ERROR_IO;
+ else if ((str.desc.bLength & 1) || str.desc.bLength != r)
+ usbi_warn(HANDLE_CTX(dev_handle), "suspicious bLength %u for string descriptor", str.desc.bLength);
di = 0;
- for (si = 2; si < tbuf[0]; si += 2) {
+ for (si = 2; si < str.desc.bLength; si += 2) {
if (di >= (length - 1))
break;
- if ((tbuf[si] & 0x80) || (tbuf[si + 1])) /* non-ASCII */
- data[di++] = '?';
+ wdata = libusb_le16_to_cpu(str.desc.wData[di]);
+ if (wdata < 0x80)
+ data[di++] = (unsigned char)wdata;
else
- data[di++] = tbuf[si];
+ data[di++] = '?'; /* non-ASCII */
}
data[di] = 0;
diff --git a/libusb/hotplug.c b/libusb/hotplug.c
index a4320bc..e3e5e76 100644
--- a/libusb/hotplug.c
+++ b/libusb/hotplug.c
@@ -19,17 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <config.h>
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#include <assert.h>
-
#include "libusbi.h"
#include "hotplug.h"
@@ -48,7 +37,7 @@
* Version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102, has added support
* for hotplug events on <b>some</b> platforms (you should test if your platform
* supports hotplug notification by calling \ref libusb_has_capability() with
- * parameter \ref LIBUSB_CAP_HAS_HOTPLUG).
+ * parameter \ref LIBUSB_CAP_HAS_HOTPLUG).
*
* This interface allows you to request notification for the arrival and departure
* of matching USB devices.
@@ -61,8 +50,8 @@
* expecting additional events. Returning 0 will rearm the callback and 1 will cause
* the callback to be deregistered. Note that when callbacks are called from
* libusb_hotplug_register_callback() because of the \ref LIBUSB_HOTPLUG_ENUMERATE
- * flag, the callback return value is ignored, iow you cannot cause a callback
- * to be deregistered by returning 1 when it is called from
+ * flag, the callback return value is ignored. In other words, you cannot cause a
+ * callback to be deregistered by returning 1 when it is called from
* libusb_hotplug_register_callback().
*
* Callbacks for a particular context are automatically deregistered by libusb_exit().
@@ -154,6 +143,13 @@ int main (void) {
\endcode
*/
+#define VALID_HOTPLUG_EVENTS \
+ (LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | \
+ LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT)
+
+#define VALID_HOTPLUG_FLAGS \
+ (LIBUSB_HOTPLUG_ENUMERATE)
+
static int usbi_hotplug_match_cb(struct libusb_context *ctx,
struct libusb_device *dev, libusb_hotplug_event event,
struct libusb_hotplug_callback *hotplug_cb)
@@ -188,7 +184,7 @@ void usbi_hotplug_match(struct libusb_context *ctx, struct libusb_device *dev,
usbi_mutex_lock(&ctx->hotplug_cbs_lock);
- list_for_each_entry_safe(hotplug_cb, next, &ctx->hotplug_cbs, list, struct libusb_hotplug_callback) {
+ for_each_hotplug_cb_safe(ctx, hotplug_cb, next) {
if (hotplug_cb->flags & USBI_HOTPLUG_NEEDS_FREE) {
/* process deregistration in usbi_hotplug_deregister() */
continue;
@@ -210,8 +206,8 @@ void usbi_hotplug_match(struct libusb_context *ctx, struct libusb_device *dev,
void usbi_hotplug_notification(struct libusb_context *ctx, struct libusb_device *dev,
libusb_hotplug_event event)
{
- int pending_events;
struct libusb_hotplug_message *message = calloc(1, sizeof(*message));
+ unsigned int event_flags;
if (!message) {
usbi_err(ctx, "error allocating hotplug message");
@@ -224,15 +220,16 @@ void usbi_hotplug_notification(struct libusb_context *ctx, struct libusb_device
/* Take the event data lock and add this message to the list.
* Only signal an event if there are no prior pending events. */
usbi_mutex_lock(&ctx->event_data_lock);
- pending_events = usbi_pending_events(ctx);
+ event_flags = ctx->event_flags;
+ ctx->event_flags |= USBI_EVENT_HOTPLUG_MSG_PENDING;
list_add_tail(&message->list, &ctx->hotplug_msgs);
- if (!pending_events)
- usbi_signal_event(ctx);
+ if (!event_flags)
+ usbi_signal_event(&ctx->event);
usbi_mutex_unlock(&ctx->event_data_lock);
}
int API_EXPORTED libusb_hotplug_register_callback(libusb_context *ctx,
- libusb_hotplug_event events, libusb_hotplug_flag flags,
+ int events, int flags,
int vendor_id, int product_id, int dev_class,
libusb_hotplug_callback_fn cb_fn, void *user_data,
libusb_hotplug_callback_handle *callback_handle)
@@ -240,8 +237,8 @@ int API_EXPORTED libusb_hotplug_register_callback(libusb_context *ctx,
struct libusb_hotplug_callback *new_callback;
/* check for sane values */
- if ((!events || (~(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT) & events)) ||
- (flags && (~LIBUSB_HOTPLUG_ENUMERATE & flags)) ||
+ if ((!events || (~VALID_HOTPLUG_EVENTS & events)) ||
+ (~VALID_HOTPLUG_FLAGS & flags) ||
(LIBUSB_HOTPLUG_MATCH_ANY != vendor_id && (~0xffff & vendor_id)) ||
(LIBUSB_HOTPLUG_MATCH_ANY != product_id && (~0xffff & product_id)) ||
(LIBUSB_HOTPLUG_MATCH_ANY != dev_class && (~0xff & dev_class)) ||
@@ -254,7 +251,7 @@ int API_EXPORTED libusb_hotplug_register_callback(libusb_context *ctx,
return LIBUSB_ERROR_NOT_SUPPORTED;
}
- USBI_GET_CONTEXT(ctx);
+ ctx = usbi_get_context(ctx);
new_callback = calloc(1, sizeof(*new_callback));
if (!new_callback) {
@@ -319,7 +316,7 @@ int API_EXPORTED libusb_hotplug_register_callback(libusb_context *ctx,
return LIBUSB_SUCCESS;
}
-void API_EXPORTED libusb_hotplug_deregister_callback(struct libusb_context *ctx,
+void API_EXPORTED libusb_hotplug_deregister_callback(libusb_context *ctx,
libusb_hotplug_callback_handle callback_handle)
{
struct libusb_hotplug_callback *hotplug_cb;
@@ -330,12 +327,12 @@ void API_EXPORTED libusb_hotplug_deregister_callback(struct libusb_context *ctx,
return;
}
- USBI_GET_CONTEXT(ctx);
-
usbi_dbg("deregister hotplug cb %d", callback_handle);
+ ctx = usbi_get_context(ctx);
+
usbi_mutex_lock(&ctx->hotplug_cbs_lock);
- list_for_each_entry(hotplug_cb, &ctx->hotplug_cbs, list, struct libusb_hotplug_callback) {
+ for_each_hotplug_cb(ctx, hotplug_cb) {
if (callback_handle == hotplug_cb->handle) {
/* Mark this callback for deregistration */
hotplug_cb->flags |= USBI_HOTPLUG_NEEDS_FREE;
@@ -345,23 +342,50 @@ void API_EXPORTED libusb_hotplug_deregister_callback(struct libusb_context *ctx,
usbi_mutex_unlock(&ctx->hotplug_cbs_lock);
if (deregistered) {
- int pending_events;
+ unsigned int event_flags;
usbi_mutex_lock(&ctx->event_data_lock);
- pending_events = usbi_pending_events(ctx);
+ event_flags = ctx->event_flags;
ctx->event_flags |= USBI_EVENT_HOTPLUG_CB_DEREGISTERED;
- if (!pending_events)
- usbi_signal_event(ctx);
+ if (!event_flags)
+ usbi_signal_event(&ctx->event);
usbi_mutex_unlock(&ctx->event_data_lock);
}
}
+DEFAULT_VISIBILITY
+void * LIBUSB_CALL libusb_hotplug_get_user_data(libusb_context *ctx,
+ libusb_hotplug_callback_handle callback_handle)
+{
+ struct libusb_hotplug_callback *hotplug_cb;
+ void *user_data = NULL;
+
+ /* check for hotplug support */
+ if (!libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) {
+ return NULL;
+ }
+
+ usbi_dbg("get hotplug user data %d", callback_handle);
+
+ ctx = usbi_get_context(ctx);
+
+ usbi_mutex_lock(&ctx->hotplug_cbs_lock);
+ for_each_hotplug_cb(ctx, hotplug_cb) {
+ if (callback_handle == hotplug_cb->handle) {
+ user_data = hotplug_cb->user_data;
+ }
+ }
+ usbi_mutex_unlock(&ctx->hotplug_cbs_lock);
+
+ return user_data;
+}
+
void usbi_hotplug_deregister(struct libusb_context *ctx, int forced)
{
struct libusb_hotplug_callback *hotplug_cb, *next;
usbi_mutex_lock(&ctx->hotplug_cbs_lock);
- list_for_each_entry_safe(hotplug_cb, next, &ctx->hotplug_cbs, list, struct libusb_hotplug_callback) {
+ for_each_hotplug_cb_safe(ctx, hotplug_cb, next) {
if (forced || (hotplug_cb->flags & USBI_HOTPLUG_NEEDS_FREE)) {
usbi_dbg("freeing hotplug cb %p with handle %d", hotplug_cb,
hotplug_cb->handle);
diff --git a/libusb/hotplug.h b/libusb/hotplug.h
index 75b2695..161f7e5 100644
--- a/libusb/hotplug.h
+++ b/libusb/hotplug.h
@@ -90,10 +90,16 @@ struct libusb_hotplug_message {
struct list_head list;
};
+#define for_each_hotplug_cb(ctx, c) \
+ for_each_helper(c, &(ctx)->hotplug_cbs, struct libusb_hotplug_callback)
+
+#define for_each_hotplug_cb_safe(ctx, c, n) \
+ for_each_safe_helper(c, n, &(ctx)->hotplug_cbs, struct libusb_hotplug_callback)
+
void usbi_hotplug_deregister(struct libusb_context *ctx, int forced);
void usbi_hotplug_match(struct libusb_context *ctx, struct libusb_device *dev,
- libusb_hotplug_event event);
+ libusb_hotplug_event event);
void usbi_hotplug_notification(struct libusb_context *ctx, struct libusb_device *dev,
- libusb_hotplug_event event);
+ libusb_hotplug_event event);
#endif
diff --git a/libusb/io.c b/libusb/io.c
index 978b09a..0e960dd 100644
--- a/libusb/io.c
+++ b/libusb/io.c
@@ -21,22 +21,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <config.h>
-
-#include <assert.h>
-#include <errno.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#ifdef USBI_TIMERFD_AVAILABLE
-#include <unistd.h>
-#include <sys/timerfd.h>
-#endif
-
#include "libusbi.h"
#include "hotplug.h"
@@ -89,7 +73,7 @@
* a single function call. When the function call returns, the transfer has
* completed and you can parse the results.
*
- * If you have used the libusb-0.1 before, this I/O style will seem familar to
+ * If you have used the libusb-0.1 before, this I/O style will seem familiar to
* you. libusb-0.1 only offered a synchronous interface.
*
* In our input device example, to read button presses you might write code
@@ -115,7 +99,7 @@ if (r == 0 && actual_length == sizeof(data)) {
* sleeping for that long. Execution will be tied up inside the library -
* the entire thread will be useless for that duration.
*
- * Another issue is that by tieing up the thread with that single transaction
+ * Another issue is that by tying up the thread with that single transaction
* there is no possibility of performing I/O with multiple endpoints and/or
* multiple devices simultaneously, unless you resort to creating one thread
* per transaction.
@@ -333,9 +317,40 @@ if (r == 0 && actual_length == sizeof(data)) {
* Freeing the transfer after it has been cancelled but before cancellation
* has completed will result in undefined behaviour.
*
+ * \attention
* When a transfer is cancelled, some of the data may have been transferred.
- * libusb will communicate this to you in the transfer callback. Do not assume
- * that no data was transferred.
+ * libusb will communicate this to you in the transfer callback.
+ * <b>Do not assume that no data was transferred.</b>
+ *
+ * \section asyncpartial Partial data transfer resulting from cancellation
+ *
+ * As noted above, some of the data may have been transferred at the time a
+ * transfer is cancelled. It is helpful to see how this is possible if you
+ * consider a bulk transfer to an endpoint with a packet size of 64 bytes.
+ * Supposing you submit a 512-byte transfer to this endpoint, the operating
+ * system will divide this transfer up into 8 separate 64-byte frames that the
+ * host controller will schedule for the device to transfer data. If this
+ * transfer is cancelled while the device is transferring data, a subset of
+ * these frames may be descheduled from the host controller before the device
+ * has the opportunity to finish transferring data to the host.
+ *
+ * What your application should do with a partial data transfer is a policy
+ * decision; there is no single answer that satisfies the needs of every
+ * application. The data that was successfully transferred should be
+ * considered entirely valid, but your application must decide what to do with
+ * the remaining data that was not transferred. Some possible actions to take
+ * are:
+ * - Resubmit another transfer for the remaining data, possibly with a shorter
+ * timeout
+ * - Discard the partially transferred data and report an error
+ *
+ * \section asynctimeout Timeouts
+ *
+ * When a transfer times out, libusb internally notes this and attempts to
+ * cancel the transfer. As noted in \ref asyncpartial "above", it is possible
+ * that some of the data may actually have been transferred. Your application
+ * should <b>always</b> check how much data was actually transferred once the
+ * transfer completes and act accordingly.
*
* \section bulk_overflows Overflows on device-to-host bulk/interrupt endpoints
*
@@ -393,7 +408,7 @@ if (r == 0 && actual_length == sizeof(data)) {
* wLength of the setup packet, rather than the size of the data buffer. So,
* if your wLength was 4, your transfer's <tt>length</tt> was 12, then you
* should expect an <tt>actual_length</tt> of 4 to indicate that the data was
- * transferred in entirity.
+ * transferred in entirety.
*
* To simplify parsing of setup packets and obtaining the data from the
* correct offset, you may wish to use the libusb_control_transfer_get_data()
@@ -472,14 +487,21 @@ if (r == 0 && actual_length == sizeof(data)) {
* libusb_get_iso_packet_buffer() and libusb_get_iso_packet_buffer_simple()
* functions may help you here.
*
- * <b>Note</b>: Some operating systems (e.g. Linux) may impose limits on the
- * length of individual isochronous packets and/or the total length of the
- * isochronous transfer. Such limits can be difficult for libusb to detect,
- * so the library will simply try and submit the transfer as set up by you.
- * If the transfer fails to submit because it is too large,
+ * \section asynclimits Transfer length limitations
+ *
+ * Some operating systems may impose limits on the length of the transfer data
+ * buffer or, in the case of isochronous transfers, the length of individual
+ * isochronous packets. Such limits can be difficult for libusb to detect, so
+ * in most cases the library will simply try and submit the transfer as set up
+ * by you. If the transfer fails to submit because it is too large,
* libusb_submit_transfer() will return
* \ref libusb_error::LIBUSB_ERROR_INVALID_PARAM "LIBUSB_ERROR_INVALID_PARAM".
*
+ * The following are known limits for control transfer lengths. Note that this
+ * length includes the 8-byte setup packet.
+ * - Linux (4,096 bytes)
+ * - Windows (4,096 bytes)
+ *
* \section asyncmem Memory caveats
*
* In most circumstances, it is not safe to use stack memory for transfer
@@ -520,7 +542,14 @@ if (r == 0 && actual_length == sizeof(data)) {
* application must call into when libusb has work do to. This gives libusb
* the opportunity to reap pending transfers, invoke callbacks, etc.
*
- * There are 2 different approaches to dealing with libusb_handle_events:
+ * \note
+ * All event handling is performed by whichever thread calls the
+ * libusb_handle_events() function. libusb does not invoke any callbacks
+ * outside of this context. Consequently, any callbacks will be run on the
+ * thread that calls the libusb_handle_events() function.
+ *
+ * When to call the libusb_handle_events() function depends on which model
+ * your application decides to use. The 2 different approaches:
*
* -# Repeatedly call libusb_handle_events() in blocking mode from a dedicated
* thread.
@@ -541,7 +570,7 @@ if (r == 0 && actual_length == sizeof(data)) {
*
* Lets begin with stating the obvious: If you're going to use a separate
* thread for libusb event handling, your callback functions MUST be
- * threadsafe.
+ * thread-safe.
*
* Other then that doing event handling from a separate thread, is mostly
* simple. You can use an event thread function as follows:
@@ -781,7 +810,7 @@ while (user has not requested application exit) {
* system calls. This is directly exposed at the
* \ref libusb_asyncio "asynchronous interface" but it is important to note that the
* \ref libusb_syncio "synchronous interface" is implemented on top of the
- * asynchonrous interface, therefore the same considerations apply.
+ * asynchronous interface, therefore the same considerations apply.
*
* The issue is that if two or more threads are concurrently calling poll()
* or select() on libusb's file descriptors then only one of those threads
@@ -889,6 +918,11 @@ void myfunc() {
* do is submit a single transfer and wait for its completion, then using
* one of the synchronous I/O functions is much easier.
*
+ * \note
+ * The `completed` variable must be modified while holding the event lock,
+ * otherwise a race condition can still exist. It is simplest to do so from
+ * within the transfer callback as shown above.
+ *
* \section eventlock The events lock
*
* The problem is when we consider the fact that libusb exposes file
@@ -986,7 +1020,7 @@ printf("completed!\n");
* event handling), because the event waiter seems to have taken the event
* waiters lock while waiting for an event. However, the system does support
* multiple event waiters, because libusb_wait_for_event() actually drops
- * the lock while waiting, and reaquires it before continuing.
+ * the lock while waiting, and reacquires it before continuing.
*
* We have now implemented code which can dynamically handle situations where
* nobody is handling events (so we should do it ourselves), and it can also
@@ -1131,46 +1165,40 @@ int usbi_io_init(struct libusb_context *ctx)
usbi_mutex_init(&ctx->event_data_lock);
usbi_tls_key_create(&ctx->event_handling_key);
list_init(&ctx->flying_transfers);
- list_init(&ctx->ipollfds);
- list_init(&ctx->removed_ipollfds);
+ list_init(&ctx->event_sources);
+ list_init(&ctx->removed_event_sources);
list_init(&ctx->hotplug_msgs);
list_init(&ctx->completed_transfers);
- /* FIXME should use an eventfd on kernels that support it */
- r = usbi_pipe(ctx->event_pipe);
- if (r < 0) {
- r = LIBUSB_ERROR_OTHER;
+ r = usbi_create_event(&ctx->event);
+ if (r < 0)
goto err;
- }
- r = usbi_add_pollfd(ctx, ctx->event_pipe[0], POLLIN);
+ r = usbi_add_event_source(ctx, USBI_EVENT_OS_HANDLE(&ctx->event), USBI_EVENT_POLL_EVENTS);
if (r < 0)
- goto err_close_pipe;
-
-#ifdef USBI_TIMERFD_AVAILABLE
- ctx->timerfd = timerfd_create(usbi_backend.get_timerfd_clockid(),
- TFD_NONBLOCK | TFD_CLOEXEC);
- if (ctx->timerfd >= 0) {
- usbi_dbg("using timerfd for timeouts");
- r = usbi_add_pollfd(ctx, ctx->timerfd, POLLIN);
+ goto err_destroy_event;
+
+#ifdef HAVE_OS_TIMER
+ r = usbi_create_timer(&ctx->timer);
+ if (r == 0) {
+ usbi_dbg("using timer for timeouts");
+ r = usbi_add_event_source(ctx, USBI_TIMER_OS_HANDLE(&ctx->timer), USBI_TIMER_POLL_EVENTS);
if (r < 0)
- goto err_close_timerfd;
+ goto err_destroy_timer;
} else {
- usbi_dbg("timerfd not available (code %d error %d)", ctx->timerfd, errno);
- ctx->timerfd = -1;
+ usbi_dbg("timer not available for timeouts");
}
#endif
return 0;
-#ifdef USBI_TIMERFD_AVAILABLE
-err_close_timerfd:
- close(ctx->timerfd);
- usbi_remove_pollfd(ctx, ctx->event_pipe[0]);
+#ifdef HAVE_OS_TIMER
+err_destroy_timer:
+ usbi_destroy_timer(&ctx->timer);
+ usbi_remove_event_source(ctx, USBI_EVENT_OS_HANDLE(&ctx->event));
#endif
-err_close_pipe:
- usbi_close(ctx->event_pipe[0]);
- usbi_close(ctx->event_pipe[1]);
+err_destroy_event:
+ usbi_destroy_event(&ctx->event);
err:
usbi_mutex_destroy(&ctx->flying_transfers_lock);
usbi_mutex_destroy(&ctx->events_lock);
@@ -1181,65 +1209,54 @@ err:
return r;
}
-static void cleanup_removed_pollfds(struct libusb_context *ctx)
+static void cleanup_removed_event_sources(struct libusb_context *ctx)
{
- struct usbi_pollfd *ipollfd, *tmp;
- list_for_each_entry_safe(ipollfd, tmp, &ctx->removed_ipollfds, list, struct usbi_pollfd) {
- list_del(&ipollfd->list);
- free(ipollfd);
+ struct usbi_event_source *ievent_source, *tmp;
+
+ for_each_removed_event_source_safe(ctx, ievent_source, tmp) {
+ list_del(&ievent_source->list);
+ free(ievent_source);
}
}
void usbi_io_exit(struct libusb_context *ctx)
{
- usbi_remove_pollfd(ctx, ctx->event_pipe[0]);
- usbi_close(ctx->event_pipe[0]);
- usbi_close(ctx->event_pipe[1]);
-#ifdef USBI_TIMERFD_AVAILABLE
- if (usbi_using_timerfd(ctx)) {
- usbi_remove_pollfd(ctx, ctx->timerfd);
- close(ctx->timerfd);
+#ifdef HAVE_OS_TIMER
+ if (usbi_using_timer(ctx)) {
+ usbi_remove_event_source(ctx, USBI_TIMER_OS_HANDLE(&ctx->timer));
+ usbi_destroy_timer(&ctx->timer);
}
#endif
+ usbi_remove_event_source(ctx, USBI_EVENT_OS_HANDLE(&ctx->event));
+ usbi_destroy_event(&ctx->event);
usbi_mutex_destroy(&ctx->flying_transfers_lock);
usbi_mutex_destroy(&ctx->events_lock);
usbi_mutex_destroy(&ctx->event_waiters_lock);
usbi_cond_destroy(&ctx->event_waiters_cond);
usbi_mutex_destroy(&ctx->event_data_lock);
usbi_tls_key_delete(ctx->event_handling_key);
- free(ctx->pollfds);
- cleanup_removed_pollfds(ctx);
+ cleanup_removed_event_sources(ctx);
+ free(ctx->event_data);
}
-static int calculate_timeout(struct usbi_transfer *transfer)
+static void calculate_timeout(struct usbi_transfer *itransfer)
{
- int r;
- struct timespec current_time;
unsigned int timeout =
- USBI_TRANSFER_TO_LIBUSB_TRANSFER(transfer)->timeout;
+ USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer)->timeout;
if (!timeout) {
- timerclear(&transfer->timeout);
- return 0;
- }
-
- r = usbi_backend.clock_gettime(USBI_CLOCK_MONOTONIC, &current_time);
- if (r < 0) {
- usbi_err(ITRANSFER_CTX(transfer),
- "failed to read monotonic clock, errno=%d", errno);
- return r;
+ TIMESPEC_CLEAR(&itransfer->timeout);
+ return;
}
- current_time.tv_sec += timeout / 1000;
- current_time.tv_nsec += (timeout % 1000) * 1000000;
+ usbi_get_monotonic_time(&itransfer->timeout);
- while (current_time.tv_nsec >= 1000000000) {
- current_time.tv_nsec -= 1000000000;
- current_time.tv_sec++;
+ itransfer->timeout.tv_sec += timeout / 1000U;
+ itransfer->timeout.tv_nsec += (timeout % 1000U) * 1000000L;
+ if (itransfer->timeout.tv_nsec >= NSEC_PER_SEC) {
+ ++itransfer->timeout.tv_sec;
+ itransfer->timeout.tv_nsec -= NSEC_PER_SEC;
}
-
- TIMESPEC_TO_TIMEVAL(&transfer->timeout, &current_time);
- return 0;
}
/** \ingroup libusb_asyncio
@@ -1269,23 +1286,28 @@ DEFAULT_VISIBILITY
struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer(
int iso_packets)
{
- struct libusb_transfer *transfer;
- size_t os_alloc_size;
+ size_t priv_size;
size_t alloc_size;
+ unsigned char *ptr;
struct usbi_transfer *itransfer;
+ struct libusb_transfer *transfer;
assert(iso_packets >= 0);
+ if (iso_packets < 0)
+ return NULL;
- os_alloc_size = usbi_backend.transfer_priv_size;
- alloc_size = sizeof(struct usbi_transfer)
+ priv_size = PTR_ALIGN(usbi_backend.transfer_priv_size);
+ alloc_size = priv_size
+ + sizeof(struct usbi_transfer)
+ sizeof(struct libusb_transfer)
- + (sizeof(struct libusb_iso_packet_descriptor) * (size_t)iso_packets)
- + os_alloc_size;
- itransfer = calloc(1, alloc_size);
- if (!itransfer)
+ + (sizeof(struct libusb_iso_packet_descriptor) * (size_t)iso_packets);
+ ptr = calloc(1, alloc_size);
+ if (!ptr)
return NULL;
+ itransfer = (struct usbi_transfer *)(ptr + priv_size);
itransfer->num_iso_packets = iso_packets;
+ itransfer->priv = ptr;
usbi_mutex_init(&itransfer->lock);
transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
usbi_dbg("transfer %p", transfer);
@@ -1312,6 +1334,9 @@ struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer(
void API_EXPORTED libusb_free_transfer(struct libusb_transfer *transfer)
{
struct usbi_transfer *itransfer;
+ size_t priv_size;
+ unsigned char *ptr;
+
if (!transfer)
return;
@@ -1321,58 +1346,46 @@ void API_EXPORTED libusb_free_transfer(struct libusb_transfer *transfer)
itransfer = LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer);
usbi_mutex_destroy(&itransfer->lock);
- free(itransfer);
-}
-
-#ifdef USBI_TIMERFD_AVAILABLE
-static int disarm_timerfd(struct libusb_context *ctx)
-{
- const struct itimerspec disarm_timer = { { 0, 0 }, { 0, 0 } };
- int r;
- usbi_dbg("");
- r = timerfd_settime(ctx->timerfd, 0, &disarm_timer, NULL);
- if (r < 0)
- return LIBUSB_ERROR_OTHER;
- else
- return 0;
+ priv_size = PTR_ALIGN(usbi_backend.transfer_priv_size);
+ ptr = (unsigned char *)itransfer - priv_size;
+ assert(ptr == itransfer->priv);
+ free(ptr);
}
-/* iterates through the flying transfers, and rearms the timerfd based on the
+/* iterates through the flying transfers, and rearms the timer based on the
* next upcoming timeout.
* must be called with flying_list locked.
* returns 0 on success or a LIBUSB_ERROR code on failure.
*/
-static int arm_timerfd_for_next_timeout(struct libusb_context *ctx)
+#ifdef HAVE_OS_TIMER
+static int arm_timer_for_next_timeout(struct libusb_context *ctx)
{
- struct usbi_transfer *transfer;
+ struct usbi_transfer *itransfer;
- list_for_each_entry(transfer, &ctx->flying_transfers, list, struct usbi_transfer) {
- struct timeval *cur_tv = &transfer->timeout;
+ if (!usbi_using_timer(ctx))
+ return 0;
+
+ for_each_transfer(ctx, itransfer) {
+ struct timespec *cur_ts = &itransfer->timeout;
/* if we've reached transfers of infinite timeout, then we have no
* arming to do */
- if (!timerisset(cur_tv))
- goto disarm;
+ if (!TIMESPEC_IS_SET(cur_ts))
+ break;
/* act on first transfer that has not already been handled */
- if (!(transfer->timeout_flags & (USBI_TRANSFER_TIMEOUT_HANDLED | USBI_TRANSFER_OS_HANDLES_TIMEOUT))) {
- int r;
- const struct itimerspec it = { {0, 0},
- { cur_tv->tv_sec, cur_tv->tv_usec * 1000 } };
- usbi_dbg("next timeout originally %dms", USBI_TRANSFER_TO_LIBUSB_TRANSFER(transfer)->timeout);
- r = timerfd_settime(ctx->timerfd, TFD_TIMER_ABSTIME, &it, NULL);
- if (r < 0)
- return LIBUSB_ERROR_OTHER;
- return 0;
+ if (!(itransfer->timeout_flags & (USBI_TRANSFER_TIMEOUT_HANDLED | USBI_TRANSFER_OS_HANDLES_TIMEOUT))) {
+ usbi_dbg("next timeout originally %ums", USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer)->timeout);
+ return usbi_arm_timer(&ctx->timer, cur_ts);
}
}
-disarm:
- return disarm_timerfd(ctx);
+ usbi_dbg("no timeouts, disarming timer");
+ return usbi_disarm_timer(&ctx->timer);
}
#else
-static int arm_timerfd_for_next_timeout(struct libusb_context *ctx)
+static inline int arm_timer_for_next_timeout(struct libusb_context *ctx)
{
UNUSED(ctx);
return 0;
@@ -1382,40 +1395,36 @@ static int arm_timerfd_for_next_timeout(struct libusb_context *ctx)
/* add a transfer to the (timeout-sorted) active transfers list.
* This function will return non 0 if fails to update the timer,
* in which case the transfer is *not* on the flying_transfers list. */
-static int add_to_flying_list(struct usbi_transfer *transfer)
+static int add_to_flying_list(struct usbi_transfer *itransfer)
{
struct usbi_transfer *cur;
- struct timeval *timeout = &transfer->timeout;
- struct libusb_context *ctx = ITRANSFER_CTX(transfer);
- int r;
+ struct timespec *timeout = &itransfer->timeout;
+ struct libusb_context *ctx = ITRANSFER_CTX(itransfer);
+ int r = 0;
int first = 1;
- r = calculate_timeout(transfer);
- if (r)
- return r;
+ calculate_timeout(itransfer);
/* if we have no other flying transfers, start the list with this one */
if (list_empty(&ctx->flying_transfers)) {
- list_add(&transfer->list, &ctx->flying_transfers);
+ list_add(&itransfer->list, &ctx->flying_transfers);
goto out;
}
/* if we have infinite timeout, append to end of list */
- if (!timerisset(timeout)) {
- list_add_tail(&transfer->list, &ctx->flying_transfers);
+ if (!TIMESPEC_IS_SET(timeout)) {
+ list_add_tail(&itransfer->list, &ctx->flying_transfers);
/* first is irrelevant in this case */
goto out;
}
/* otherwise, find appropriate place in list */
- list_for_each_entry(cur, &ctx->flying_transfers, list, struct usbi_transfer) {
+ for_each_transfer(ctx, cur) {
/* find first timeout that occurs after the transfer in question */
- struct timeval *cur_tv = &cur->timeout;
+ struct timespec *cur_ts = &cur->timeout;
- if (!timerisset(cur_tv) || (cur_tv->tv_sec > timeout->tv_sec) ||
- (cur_tv->tv_sec == timeout->tv_sec &&
- cur_tv->tv_usec > timeout->tv_usec)) {
- list_add_tail(&transfer->list, &cur->list);
+ if (!TIMESPEC_IS_SET(cur_ts) || TIMESPEC_CMP(cur_ts, timeout, >)) {
+ list_add_tail(&itransfer->list, &cur->list);
goto out;
}
first = 0;
@@ -1423,28 +1432,22 @@ static int add_to_flying_list(struct usbi_transfer *transfer)
/* first is 0 at this stage (list not empty) */
/* otherwise we need to be inserted at the end */
- list_add_tail(&transfer->list, &ctx->flying_transfers);
+ list_add_tail(&itransfer->list, &ctx->flying_transfers);
out:
-#ifdef USBI_TIMERFD_AVAILABLE
- if (first && usbi_using_timerfd(ctx) && timerisset(timeout)) {
+#ifdef HAVE_OS_TIMER
+ if (first && usbi_using_timer(ctx) && TIMESPEC_IS_SET(timeout)) {
/* if this transfer has the lowest timeout of all active transfers,
- * rearm the timerfd with this transfer's timeout */
- const struct itimerspec it = { {0, 0},
- { timeout->tv_sec, timeout->tv_usec * 1000 } };
- usbi_dbg("arm timerfd for timeout in %dms (first in line)",
- USBI_TRANSFER_TO_LIBUSB_TRANSFER(transfer)->timeout);
- r = timerfd_settime(ctx->timerfd, TFD_TIMER_ABSTIME, &it, NULL);
- if (r < 0) {
- usbi_warn(ctx, "failed to arm first timerfd (errno %d)", errno);
- r = LIBUSB_ERROR_OTHER;
- }
+ * rearm the timer with this transfer's timeout */
+ usbi_dbg("arm timer for timeout in %ums (first in line)",
+ USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer)->timeout);
+ r = usbi_arm_timer(&ctx->timer, timeout);
}
#else
UNUSED(first);
#endif
if (r)
- list_del(&transfer->list);
+ list_del(&itransfer->list);
return r;
}
@@ -1453,18 +1456,18 @@ out:
* This function will *always* remove the transfer from the
* flying_transfers list. It will return a LIBUSB_ERROR code
* if it fails to update the timer for the next timeout. */
-static int remove_from_flying_list(struct usbi_transfer *transfer)
+static int remove_from_flying_list(struct usbi_transfer *itransfer)
{
- struct libusb_context *ctx = ITRANSFER_CTX(transfer);
- int rearm_timerfd;
+ struct libusb_context *ctx = ITRANSFER_CTX(itransfer);
+ int rearm_timer;
int r = 0;
usbi_mutex_lock(&ctx->flying_transfers_lock);
- rearm_timerfd = (timerisset(&transfer->timeout) &&
- list_first_entry(&ctx->flying_transfers, struct usbi_transfer, list) == transfer);
- list_del(&transfer->list);
- if (usbi_using_timerfd(ctx) && rearm_timerfd)
- r = arm_timerfd_for_next_timeout(ctx);
+ rearm_timer = (TIMESPEC_IS_SET(&itransfer->timeout) &&
+ list_first_entry(&ctx->flying_transfers, struct usbi_transfer, list) == itransfer);
+ list_del(&itransfer->list);
+ if (rearm_timer)
+ r = arm_timer_for_next_timeout(ctx);
usbi_mutex_unlock(&ctx->flying_transfers_lock);
return r;
@@ -1481,7 +1484,7 @@ static int remove_from_flying_list(struct usbi_transfer *transfer)
* \returns LIBUSB_ERROR_NOT_SUPPORTED if the transfer flags are not supported
* by the operating system.
* \returns LIBUSB_ERROR_INVALID_PARAM if the transfer size is larger than
- * the operating system and/or hardware can support
+ * the operating system and/or hardware can support (see \ref asynclimits)
* \returns another LIBUSB_ERROR code on other failure
*/
int API_EXPORTED libusb_submit_transfer(struct libusb_transfer *transfer)
@@ -1664,7 +1667,7 @@ int usbi_handle_transfer_completion(struct usbi_transfer *itransfer,
r = remove_from_flying_list(itransfer);
if (r < 0)
- usbi_err(ITRANSFER_CTX(itransfer), "failed to set timer for next timeout, errno=%d", errno);
+ usbi_err(ITRANSFER_CTX(itransfer), "failed to set timer for next timeout");
usbi_mutex_lock(&itransfer->lock);
itransfer->state_flags &= ~USBI_TRANSFER_IN_FLIGHT;
@@ -1701,41 +1704,42 @@ int usbi_handle_transfer_completion(struct usbi_transfer *itransfer,
* Do not call this function with the usbi_transfer lock held. User-specified
* callback functions may attempt to directly resubmit the transfer, which
* will attempt to take the lock. */
-int usbi_handle_transfer_cancellation(struct usbi_transfer *transfer)
+int usbi_handle_transfer_cancellation(struct usbi_transfer *itransfer)
{
- struct libusb_context *ctx = ITRANSFER_CTX(transfer);
+ struct libusb_context *ctx = ITRANSFER_CTX(itransfer);
uint8_t timed_out;
usbi_mutex_lock(&ctx->flying_transfers_lock);
- timed_out = transfer->timeout_flags & USBI_TRANSFER_TIMED_OUT;
+ timed_out = itransfer->timeout_flags & USBI_TRANSFER_TIMED_OUT;
usbi_mutex_unlock(&ctx->flying_transfers_lock);
/* if the URB was cancelled due to timeout, report timeout to the user */
if (timed_out) {
usbi_dbg("detected timeout cancellation");
- return usbi_handle_transfer_completion(transfer, LIBUSB_TRANSFER_TIMED_OUT);
+ return usbi_handle_transfer_completion(itransfer, LIBUSB_TRANSFER_TIMED_OUT);
}
/* otherwise its a normal async cancel */
- return usbi_handle_transfer_completion(transfer, LIBUSB_TRANSFER_CANCELLED);
+ return usbi_handle_transfer_completion(itransfer, LIBUSB_TRANSFER_CANCELLED);
}
/* Add a completed transfer to the completed_transfers list of the
* context and signal the event. The backend's handle_transfer_completion()
* function will be called the next time an event handler runs. */
-void usbi_signal_transfer_completion(struct usbi_transfer *transfer)
+void usbi_signal_transfer_completion(struct usbi_transfer *itransfer)
{
- libusb_device_handle *dev_handle = USBI_TRANSFER_TO_LIBUSB_TRANSFER(transfer)->dev_handle;
+ libusb_device_handle *dev_handle = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer)->dev_handle;
if (dev_handle) {
struct libusb_context *ctx = HANDLE_CTX(dev_handle);
- int pending_events;
+ unsigned int event_flags;
usbi_mutex_lock(&ctx->event_data_lock);
- pending_events = usbi_pending_events(ctx);
- list_add_tail(&transfer->completed_list, &ctx->completed_transfers);
- if (!pending_events)
- usbi_signal_event(ctx);
+ event_flags = ctx->event_flags;
+ ctx->event_flags |= USBI_EVENT_TRANSFER_COMPLETED;
+ list_add_tail(&itransfer->completed_list, &ctx->completed_transfers);
+ if (!event_flags)
+ usbi_signal_event(&ctx->event);
usbi_mutex_unlock(&ctx->event_data_lock);
}
}
@@ -1763,7 +1767,8 @@ int API_EXPORTED libusb_try_lock_events(libusb_context *ctx)
{
int r;
unsigned int ru;
- USBI_GET_CONTEXT(ctx);
+
+ ctx = usbi_get_context(ctx);
/* is someone else waiting to close a device? if so, don't let this thread
* start event handling */
@@ -1776,7 +1781,7 @@ int API_EXPORTED libusb_try_lock_events(libusb_context *ctx)
}
r = usbi_mutex_trylock(&ctx->events_lock);
- if (r)
+ if (!r)
return 1;
ctx->event_handler_active = 1;
@@ -1803,7 +1808,7 @@ int API_EXPORTED libusb_try_lock_events(libusb_context *ctx)
*/
void API_EXPORTED libusb_lock_events(libusb_context *ctx)
{
- USBI_GET_CONTEXT(ctx);
+ ctx = usbi_get_context(ctx);
usbi_mutex_lock(&ctx->events_lock);
ctx->event_handler_active = 1;
}
@@ -1818,7 +1823,7 @@ void API_EXPORTED libusb_lock_events(libusb_context *ctx)
*/
void API_EXPORTED libusb_unlock_events(libusb_context *ctx)
{
- USBI_GET_CONTEXT(ctx);
+ ctx = usbi_get_context(ctx);
ctx->event_handler_active = 0;
usbi_mutex_unlock(&ctx->events_lock);
@@ -1854,7 +1859,8 @@ void API_EXPORTED libusb_unlock_events(libusb_context *ctx)
int API_EXPORTED libusb_event_handling_ok(libusb_context *ctx)
{
unsigned int r;
- USBI_GET_CONTEXT(ctx);
+
+ ctx = usbi_get_context(ctx);
/* is someone else waiting to close a device? if so, don't let this thread
* continue event handling */
@@ -1882,7 +1888,8 @@ int API_EXPORTED libusb_event_handling_ok(libusb_context *ctx)
int API_EXPORTED libusb_event_handler_active(libusb_context *ctx)
{
unsigned int r;
- USBI_GET_CONTEXT(ctx);
+
+ ctx = usbi_get_context(ctx);
/* is someone else waiting to close a device? if so, don't let this thread
* start event handling -- indicate that event handling is happening */
@@ -1909,16 +1916,17 @@ int API_EXPORTED libusb_event_handler_active(libusb_context *ctx)
*/
void API_EXPORTED libusb_interrupt_event_handler(libusb_context *ctx)
{
- int pending_events;
- USBI_GET_CONTEXT(ctx);
+ unsigned int event_flags;
- usbi_dbg("");
+ usbi_dbg(" ");
+
+ ctx = usbi_get_context(ctx);
usbi_mutex_lock(&ctx->event_data_lock);
- pending_events = usbi_pending_events(ctx);
+ event_flags = ctx->event_flags;
ctx->event_flags |= USBI_EVENT_USER_INTERRUPT;
- if (!pending_events)
- usbi_signal_event(ctx);
+ if (!event_flags)
+ usbi_signal_event(&ctx->event);
usbi_mutex_unlock(&ctx->event_data_lock);
}
@@ -1934,7 +1942,7 @@ void API_EXPORTED libusb_interrupt_event_handler(libusb_context *ctx)
*
* You only need to use this lock if you are developing an application
* which calls poll() or select() on libusb's file descriptors directly,
- * <b>and</b> may potentially be handling events from 2 threads simultaenously.
+ * <b>and</b> may potentially be handling events from 2 threads simultaneously.
* If you stick to libusb's event handling loop functions (e.g.
* libusb_handle_events()) then you do not need to be concerned with this
* locking.
@@ -1944,7 +1952,7 @@ void API_EXPORTED libusb_interrupt_event_handler(libusb_context *ctx)
*/
void API_EXPORTED libusb_lock_event_waiters(libusb_context *ctx)
{
- USBI_GET_CONTEXT(ctx);
+ ctx = usbi_get_context(ctx);
usbi_mutex_lock(&ctx->event_waiters_lock);
}
@@ -1955,7 +1963,7 @@ void API_EXPORTED libusb_lock_event_waiters(libusb_context *ctx)
*/
void API_EXPORTED libusb_unlock_event_waiters(libusb_context *ctx)
{
- USBI_GET_CONTEXT(ctx);
+ ctx = usbi_get_context(ctx);
usbi_mutex_unlock(&ctx->event_waiters_lock);
}
@@ -1982,25 +1990,28 @@ void API_EXPORTED libusb_unlock_event_waiters(libusb_context *ctx)
* indicates unlimited timeout.
* \returns 0 after a transfer completes or another thread stops event handling
* \returns 1 if the timeout expired
+ * \returns LIBUSB_ERROR_INVALID_PARAM if timeval is invalid
* \ref libusb_mtasync
*/
int API_EXPORTED libusb_wait_for_event(libusb_context *ctx, struct timeval *tv)
{
int r;
- USBI_GET_CONTEXT(ctx);
- if (tv == NULL) {
+ ctx = usbi_get_context(ctx);
+ if (!tv) {
usbi_cond_wait(&ctx->event_waiters_cond, &ctx->event_waiters_lock);
return 0;
}
+ if (!TIMEVAL_IS_VALID(tv))
+ return LIBUSB_ERROR_INVALID_PARAM;
+
r = usbi_cond_timedwait(&ctx->event_waiters_cond,
&ctx->event_waiters_lock, tv);
-
if (r < 0)
- return r;
- else
- return (r == ETIMEDOUT);
+ return r == LIBUSB_ERROR_TIMEOUT;
+
+ return 0;
}
static void handle_timeout(struct usbi_transfer *itransfer)
@@ -2015,78 +2026,149 @@ static void handle_timeout(struct usbi_transfer *itransfer)
itransfer->timeout_flags |= USBI_TRANSFER_TIMED_OUT;
else
usbi_warn(TRANSFER_CTX(transfer),
- "async cancel failed %d errno=%d", r, errno);
+ "async cancel failed %d", r);
}
-static int handle_timeouts_locked(struct libusb_context *ctx)
+static void handle_timeouts_locked(struct libusb_context *ctx)
{
- int r;
- struct timespec systime_ts;
- struct timeval systime;
- struct usbi_transfer *transfer;
+ struct timespec systime;
+ struct usbi_transfer *itransfer;
if (list_empty(&ctx->flying_transfers))
- return 0;
+ return;
/* get current time */
- r = usbi_backend.clock_gettime(USBI_CLOCK_MONOTONIC, &systime_ts);
- if (r < 0)
- return r;
-
- TIMESPEC_TO_TIMEVAL(&systime, &systime_ts);
+ usbi_get_monotonic_time(&systime);
/* iterate through flying transfers list, finding all transfers that
* have expired timeouts */
- list_for_each_entry(transfer, &ctx->flying_transfers, list, struct usbi_transfer) {
- struct timeval *cur_tv = &transfer->timeout;
+ for_each_transfer(ctx, itransfer) {
+ struct timespec *cur_ts = &itransfer->timeout;
/* if we've reached transfers of infinite timeout, we're all done */
- if (!timerisset(cur_tv))
- return 0;
+ if (!TIMESPEC_IS_SET(cur_ts))
+ return;
/* ignore timeouts we've already handled */
- if (transfer->timeout_flags & (USBI_TRANSFER_TIMEOUT_HANDLED | USBI_TRANSFER_OS_HANDLES_TIMEOUT))
+ if (itransfer->timeout_flags & (USBI_TRANSFER_TIMEOUT_HANDLED | USBI_TRANSFER_OS_HANDLES_TIMEOUT))
continue;
/* if transfer has non-expired timeout, nothing more to do */
- if ((cur_tv->tv_sec > systime.tv_sec) ||
- (cur_tv->tv_sec == systime.tv_sec &&
- cur_tv->tv_usec > systime.tv_usec))
- return 0;
+ if (TIMESPEC_CMP(cur_ts, &systime, >))
+ return;
/* otherwise, we've got an expired timeout to handle */
- handle_timeout(transfer);
+ handle_timeout(itransfer);
}
- return 0;
}
-static int handle_timeouts(struct libusb_context *ctx)
+static void handle_timeouts(struct libusb_context *ctx)
{
- int r;
- USBI_GET_CONTEXT(ctx);
+ ctx = usbi_get_context(ctx);
usbi_mutex_lock(&ctx->flying_transfers_lock);
- r = handle_timeouts_locked(ctx);
+ handle_timeouts_locked(ctx);
usbi_mutex_unlock(&ctx->flying_transfers_lock);
+}
+
+static int handle_event_trigger(struct libusb_context *ctx)
+{
+ struct list_head hotplug_msgs;
+ int r = 0;
+
+ usbi_dbg("event triggered");
+
+ list_init(&hotplug_msgs);
+
+ /* take the the event data lock while processing events */
+ usbi_mutex_lock(&ctx->event_data_lock);
+
+ /* check if someone modified the event sources */
+ if (ctx->event_flags & USBI_EVENT_EVENT_SOURCES_MODIFIED)
+ usbi_dbg("someone updated the event sources");
+
+ if (ctx->event_flags & USBI_EVENT_USER_INTERRUPT) {
+ usbi_dbg("someone purposefully interrupted");
+ ctx->event_flags &= ~USBI_EVENT_USER_INTERRUPT;
+ }
+
+ /* check if someone is closing a device */
+ if (ctx->event_flags & USBI_EVENT_DEVICE_CLOSE)
+ usbi_dbg("someone is closing a device");
+
+ /* check for any pending hotplug messages */
+ if (ctx->event_flags & USBI_EVENT_HOTPLUG_MSG_PENDING) {
+ usbi_dbg("hotplug message received");
+ ctx->event_flags &= ~USBI_EVENT_HOTPLUG_MSG_PENDING;
+ assert(!list_empty(&ctx->hotplug_msgs));
+ list_cut(&hotplug_msgs, &ctx->hotplug_msgs);
+ }
+
+ /* complete any pending transfers */
+ if (ctx->event_flags & USBI_EVENT_TRANSFER_COMPLETED) {
+ struct usbi_transfer *itransfer, *tmp;
+ struct list_head completed_transfers;
+
+ assert(!list_empty(&ctx->completed_transfers));
+ list_cut(&completed_transfers, &ctx->completed_transfers);
+ usbi_mutex_unlock(&ctx->event_data_lock);
+
+ __for_each_completed_transfer_safe(&completed_transfers, itransfer, tmp) {
+ list_del(&itransfer->completed_list);
+ r = usbi_backend.handle_transfer_completion(itransfer);
+ if (r) {
+ usbi_err(ctx, "backend handle_transfer_completion failed with error %d", r);
+ break;
+ }
+ }
+
+ usbi_mutex_lock(&ctx->event_data_lock);
+ if (!list_empty(&completed_transfers)) {
+ /* an error occurred, put the remaining transfers back on the list */
+ list_splice_front(&completed_transfers, &ctx->completed_transfers);
+ } else if (list_empty(&ctx->completed_transfers)) {
+ ctx->event_flags &= ~USBI_EVENT_TRANSFER_COMPLETED;
+ }
+ }
+
+ /* if no further pending events, clear the event */
+ if (!ctx->event_flags)
+ usbi_clear_event(&ctx->event);
+
+ usbi_mutex_unlock(&ctx->event_data_lock);
+
+ /* process the hotplug messages, if any */
+ while (!list_empty(&hotplug_msgs)) {
+ struct libusb_hotplug_message *message =
+ list_first_entry(&hotplug_msgs, struct libusb_hotplug_message, list);
+
+ usbi_hotplug_match(ctx, message->device, message->event);
+
+ /* the device left, dereference the device */
+ if (message->event == LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT)
+ libusb_unref_device(message->device);
+
+ list_del(&message->list);
+ free(message);
+ }
+
return r;
}
-#ifdef USBI_TIMERFD_AVAILABLE
-static int handle_timerfd_trigger(struct libusb_context *ctx)
+#ifdef HAVE_OS_TIMER
+static int handle_timer_trigger(struct libusb_context *ctx)
{
int r;
usbi_mutex_lock(&ctx->flying_transfers_lock);
/* process the timeout that just happened */
- r = handle_timeouts_locked(ctx);
- if (r < 0)
- goto out;
+ handle_timeouts_locked(ctx);
- /* arm for next timeout*/
- r = arm_timerfd_for_next_timeout(ctx);
+ /* arm for next timeout */
+ r = arm_timer_for_next_timeout(ctx);
-out:
usbi_mutex_unlock(&ctx->flying_transfers_lock);
+
return r;
}
#endif
@@ -2095,81 +2177,38 @@ out:
* doing the same thing. */
static int handle_events(struct libusb_context *ctx, struct timeval *tv)
{
- int r;
- struct usbi_pollfd *ipollfd;
- POLL_NFDS_TYPE nfds = 0;
- POLL_NFDS_TYPE internal_nfds;
- struct pollfd *fds = NULL;
- int i = -1;
- int timeout_ms;
+ struct usbi_reported_events reported_events;
+ int r, timeout_ms;
/* prevent attempts to recursively handle events (e.g. calling into
* libusb_handle_events() from within a hotplug or transfer callback) */
- usbi_mutex_lock(&ctx->event_data_lock);
- r = 0;
if (usbi_handling_events(ctx))
- r = LIBUSB_ERROR_BUSY;
- else
- usbi_start_event_handling(ctx);
- usbi_mutex_unlock(&ctx->event_data_lock);
-
- if (r)
- return r;
-
- /* there are certain fds that libusb uses internally, currently:
- *
- * 1) event pipe
- * 2) timerfd
- *
- * the backend will never need to attempt to handle events on these fds, so
- * we determine how many fds are in use internally for this context and when
- * handle_events() is called in the backend, the pollfd list and count will
- * be adjusted to skip over these internal fds */
- if (usbi_using_timerfd(ctx))
- internal_nfds = 2;
- else
- internal_nfds = 1;
+ return LIBUSB_ERROR_BUSY;
- /* only reallocate the poll fds when the list of poll fds has been modified
- * since the last poll, otherwise reuse them to save the additional overhead */
+ /* only reallocate the event source data when the list of event sources has
+ * been modified since the last handle_events(), otherwise reuse them to
+ * save the additional overhead */
usbi_mutex_lock(&ctx->event_data_lock);
- /* clean up removed poll fds */
- cleanup_removed_pollfds(ctx);
- if (ctx->event_flags & USBI_EVENT_POLLFDS_MODIFIED) {
- usbi_dbg("poll fds modified, reallocating");
+ if (ctx->event_flags & USBI_EVENT_EVENT_SOURCES_MODIFIED) {
+ usbi_dbg("event sources modified, reallocating event data");
- free(ctx->pollfds);
- ctx->pollfds = NULL;
+ /* free anything removed since we last ran */
+ cleanup_removed_event_sources(ctx);
- /* sanity check - it is invalid for a context to have fewer than the
- * required internal fds (memory corruption?) */
- assert(ctx->pollfds_cnt >= internal_nfds);
-
- ctx->pollfds = calloc(ctx->pollfds_cnt, sizeof(*ctx->pollfds));
- if (!ctx->pollfds) {
+ r = usbi_alloc_event_data(ctx);
+ if (r) {
usbi_mutex_unlock(&ctx->event_data_lock);
- r = LIBUSB_ERROR_NO_MEM;
- goto done;
- }
-
- list_for_each_entry(ipollfd, &ctx->ipollfds, list, struct usbi_pollfd) {
- struct libusb_pollfd *pollfd = &ipollfd->pollfd;
- i++;
- ctx->pollfds[i].fd = pollfd->fd;
- ctx->pollfds[i].events = pollfd->events;
+ return r;
}
/* reset the flag now that we have the updated list */
- ctx->event_flags &= ~USBI_EVENT_POLLFDS_MODIFIED;
+ ctx->event_flags &= ~USBI_EVENT_EVENT_SOURCES_MODIFIED;
- /* if no further pending events, clear the event pipe so that we do
- * not immediately return from poll */
- if (!usbi_pending_events(ctx))
- usbi_clear_event(ctx);
+ /* if no further pending events, clear the event so that we do
+ * not immediately return from the wait function */
+ if (!ctx->event_flags)
+ usbi_clear_event(&ctx->event);
}
- fds = ctx->pollfds;
- nfds = ctx->pollfds_cnt;
- usbi_inc_fds_ref(fds, nfds);
usbi_mutex_unlock(&ctx->event_data_lock);
timeout_ms = (int)(tv->tv_sec * 1000) + (tv->tv_usec / 1000);
@@ -2178,145 +2217,47 @@ static int handle_events(struct libusb_context *ctx, struct timeval *tv)
if (tv->tv_usec % 1000)
timeout_ms++;
- usbi_dbg("poll() %d fds with timeout in %dms", (int)nfds, timeout_ms);
- r = usbi_poll(fds, nfds, timeout_ms);
- usbi_dbg("poll() returned %d", r);
- if (r == 0) {
- r = handle_timeouts(ctx);
- goto done;
- } else if (r == -1 && errno == EINTR) {
- r = LIBUSB_ERROR_INTERRUPTED;
- goto done;
- } else if (r < 0) {
- usbi_err(ctx, "poll failed %d err=%d", r, errno);
- r = LIBUSB_ERROR_IO;
- goto done;
- }
+ reported_events.event_bits = 0;
- /* fds[0] is always the event pipe */
- if (fds[0].revents) {
- struct list_head hotplug_msgs;
- struct usbi_transfer *itransfer;
- int hotplug_cb_deregistered = 0;
- int ret = 0;
+ usbi_start_event_handling(ctx);
- list_init(&hotplug_msgs);
-
- usbi_dbg("caught a fish on the event pipe");
-
- /* take the the event data lock while processing events */
- usbi_mutex_lock(&ctx->event_data_lock);
-
- /* check if someone added a new poll fd */
- if (ctx->event_flags & USBI_EVENT_POLLFDS_MODIFIED)
- usbi_dbg("someone updated the poll fds");
-
- if (ctx->event_flags & USBI_EVENT_USER_INTERRUPT) {
- usbi_dbg("someone purposely interrupted");
- ctx->event_flags &= ~USBI_EVENT_USER_INTERRUPT;
- }
-
- if (ctx->event_flags & USBI_EVENT_HOTPLUG_CB_DEREGISTERED) {
- usbi_dbg("someone unregistered a hotplug cb");
- ctx->event_flags &= ~USBI_EVENT_HOTPLUG_CB_DEREGISTERED;
- hotplug_cb_deregistered = 1;
- }
-
- /* check if someone is closing a device */
- if (ctx->device_close)
- usbi_dbg("someone is closing a device");
-
- /* check for any pending hotplug messages */
- if (!list_empty(&ctx->hotplug_msgs)) {
- usbi_dbg("hotplug message received");
- list_cut(&hotplug_msgs, &ctx->hotplug_msgs);
- }
-
- /* complete any pending transfers */
- while (ret == 0 && !list_empty(&ctx->completed_transfers)) {
- itransfer = list_first_entry(&ctx->completed_transfers, struct usbi_transfer, completed_list);
- list_del(&itransfer->completed_list);
- usbi_mutex_unlock(&ctx->event_data_lock);
- ret = usbi_backend.handle_transfer_completion(itransfer);
- if (ret)
- usbi_err(ctx, "backend handle_transfer_completion failed with error %d", ret);
- usbi_mutex_lock(&ctx->event_data_lock);
- }
-
- /* if no further pending events, clear the event pipe */
- if (!usbi_pending_events(ctx))
- usbi_clear_event(ctx);
-
- usbi_mutex_unlock(&ctx->event_data_lock);
-
- if (hotplug_cb_deregistered)
- usbi_hotplug_deregister(ctx, 0);
-
- /* process the hotplug messages, if any */
- while (!list_empty(&hotplug_msgs)) {
- struct libusb_hotplug_message *message =
- list_first_entry(&hotplug_msgs, struct libusb_hotplug_message, list);
-
- usbi_hotplug_match(ctx, message->device, message->event);
-
- /* the device left, dereference the device */
- if (LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT == message->event)
- libusb_unref_device(message->device);
-
- list_del(&message->list);
- free(message);
+ r = usbi_wait_for_events(ctx, &reported_events, timeout_ms);
+ if (r != LIBUSB_SUCCESS) {
+ if (r == LIBUSB_ERROR_TIMEOUT) {
+ handle_timeouts(ctx);
+ r = LIBUSB_SUCCESS;
}
+ goto done;
+ }
- if (ret) {
+ if (reported_events.event_triggered) {
+ r = handle_event_trigger(ctx);
+ if (r) {
/* return error code */
- r = ret;
goto done;
}
-
- if (0 == --r)
- goto done;
}
-#ifdef USBI_TIMERFD_AVAILABLE
- /* on timerfd configurations, fds[1] is the timerfd */
- if (usbi_using_timerfd(ctx) && fds[1].revents) {
- /* timerfd indicates that a timeout has expired */
- int ret;
- usbi_dbg("timerfd triggered");
-
- ret = handle_timerfd_trigger(ctx);
- if (ret < 0) {
+#ifdef HAVE_OS_TIMER
+ if (reported_events.timer_triggered) {
+ r = handle_timer_trigger(ctx);
+ if (r) {
/* return error code */
- r = ret;
goto done;
}
-
- if (0 == --r)
- goto done;
}
#endif
- list_for_each_entry(ipollfd, &ctx->removed_ipollfds, list, struct usbi_pollfd) {
- for (i = internal_nfds ; i < nfds ; ++i) {
- if (ipollfd->pollfd.fd == fds[i].fd) {
- /* pollfd was removed between the creation of the fd
- * array and here. remove any triggered revent as
- * it is no longer relevant */
- usbi_dbg("pollfd %d was removed. ignoring raised events",
- fds[i].fd);
- fds[i].revents = 0;
- break;
- }
- }
- }
+ if (!reported_events.num_ready)
+ goto done;
- r = usbi_backend.handle_events(ctx, fds + internal_nfds, nfds - internal_nfds, r);
+ r = usbi_backend.handle_events(ctx, reported_events.event_data,
+ reported_events.event_data_count, reported_events.num_ready);
if (r)
usbi_err(ctx, "backend handle_events failed with error %d", r);
done:
usbi_end_event_handling(ctx);
- usbi_dec_fds_ref(fds, nfds);
return r;
}
@@ -2370,7 +2311,9 @@ static int get_next_timeout(libusb_context *ctx, struct timeval *tv,
* \param tv the maximum time to block waiting for events, or an all zero
* timeval struct for non-blocking mode
* \param completed pointer to completion integer to check, or NULL
- * \returns 0 on success, or a LIBUSB_ERROR code on failure
+ * \returns 0 on success
+ * \returns LIBUSB_ERROR_INVALID_PARAM if timeval is invalid
+ * \returns another LIBUSB_ERROR code on other failure
* \ref libusb_mtasync
*/
int API_EXPORTED libusb_handle_events_timeout_completed(libusb_context *ctx,
@@ -2379,11 +2322,15 @@ int API_EXPORTED libusb_handle_events_timeout_completed(libusb_context *ctx,
int r;
struct timeval poll_timeout;
- USBI_GET_CONTEXT(ctx);
+ if (!TIMEVAL_IS_VALID(tv))
+ return LIBUSB_ERROR_INVALID_PARAM;
+
+ ctx = usbi_get_context(ctx);
r = get_next_timeout(ctx, tv, &poll_timeout);
if (r) {
/* timeout already expired */
- return handle_timeouts(ctx);
+ handle_timeouts(ctx);
+ return 0;
}
retry:
@@ -2421,9 +2368,8 @@ already_done:
if (r < 0)
return r;
else if (r == 1)
- return handle_timeouts(ctx);
- else
- return 0;
+ handle_timeouts(ctx);
+ return 0;
}
/** \ingroup libusb_poll
@@ -2450,7 +2396,7 @@ int API_EXPORTED libusb_handle_events_timeout(libusb_context *ctx,
/** \ingroup libusb_poll
* Handle any pending events in blocking mode. There is currently a timeout
- * hardcoded at 60 seconds but we plan to make it unlimited in future. For
+ * hard-coded at 60 seconds but we plan to make it unlimited in future. For
* finer control over whether this function is blocking or non-blocking, or
* for control over the timeout, use libusb_handle_events_timeout_completed()
* instead.
@@ -2507,7 +2453,9 @@ int API_EXPORTED libusb_handle_events_completed(libusb_context *ctx,
* \param ctx the context to operate on, or NULL for the default context
* \param tv the maximum time to block waiting for events, or zero for
* non-blocking mode
- * \returns 0 on success, or a LIBUSB_ERROR code on failure
+ * \returns 0 on success
+ * \returns LIBUSB_ERROR_INVALID_PARAM if timeval is invalid
+ * \returns another LIBUSB_ERROR code on other failure
* \ref libusb_mtasync
*/
int API_EXPORTED libusb_handle_events_locked(libusb_context *ctx,
@@ -2516,11 +2464,15 @@ int API_EXPORTED libusb_handle_events_locked(libusb_context *ctx,
int r;
struct timeval poll_timeout;
- USBI_GET_CONTEXT(ctx);
+ if (!TIMEVAL_IS_VALID(tv))
+ return LIBUSB_ERROR_INVALID_PARAM;
+
+ ctx = usbi_get_context(ctx);
r = get_next_timeout(ctx, tv, &poll_timeout);
if (r) {
/* timeout already expired */
- return handle_timeouts(ctx);
+ handle_timeouts(ctx);
+ return 0;
}
return handle_events(ctx, &poll_timeout);
@@ -2556,13 +2508,8 @@ int API_EXPORTED libusb_handle_events_locked(libusb_context *ctx,
*/
int API_EXPORTED libusb_pollfds_handle_timeouts(libusb_context *ctx)
{
-#if defined(USBI_TIMERFD_AVAILABLE)
- USBI_GET_CONTEXT(ctx);
- return usbi_using_timerfd(ctx);
-#else
- UNUSED(ctx);
- return 0;
-#endif
+ ctx = usbi_get_context(ctx);
+ return usbi_using_timer(ctx);
}
/** \ingroup libusb_poll
@@ -2596,14 +2543,12 @@ int API_EXPORTED libusb_pollfds_handle_timeouts(libusb_context *ctx)
int API_EXPORTED libusb_get_next_timeout(libusb_context *ctx,
struct timeval *tv)
{
- struct usbi_transfer *transfer;
- struct timespec cur_ts;
- struct timeval cur_tv;
- struct timeval next_timeout = { 0, 0 };
- int r;
+ struct usbi_transfer *itransfer;
+ struct timespec systime;
+ struct timespec next_timeout = { 0, 0 };
- USBI_GET_CONTEXT(ctx);
- if (usbi_using_timerfd(ctx))
+ ctx = usbi_get_context(ctx);
+ if (usbi_using_timer(ctx))
return 0;
usbi_mutex_lock(&ctx->flying_transfers_lock);
@@ -2614,36 +2559,32 @@ int API_EXPORTED libusb_get_next_timeout(libusb_context *ctx,
}
/* find next transfer which hasn't already been processed as timed out */
- list_for_each_entry(transfer, &ctx->flying_transfers, list, struct usbi_transfer) {
- if (transfer->timeout_flags & (USBI_TRANSFER_TIMEOUT_HANDLED | USBI_TRANSFER_OS_HANDLES_TIMEOUT))
+ for_each_transfer(ctx, itransfer) {
+ if (itransfer->timeout_flags & (USBI_TRANSFER_TIMEOUT_HANDLED | USBI_TRANSFER_OS_HANDLES_TIMEOUT))
continue;
- /* if we've reached transfers of infinte timeout, we're done looking */
- if (!timerisset(&transfer->timeout))
+ /* if we've reached transfers of infinite timeout, we're done looking */
+ if (!TIMESPEC_IS_SET(&itransfer->timeout))
break;
- next_timeout = transfer->timeout;
+ next_timeout = itransfer->timeout;
break;
}
usbi_mutex_unlock(&ctx->flying_transfers_lock);
- if (!timerisset(&next_timeout)) {
+ if (!TIMESPEC_IS_SET(&next_timeout)) {
usbi_dbg("no URB with timeout or all handled by OS; no timeout!");
return 0;
}
- r = usbi_backend.clock_gettime(USBI_CLOCK_MONOTONIC, &cur_ts);
- if (r < 0) {
- usbi_err(ctx, "failed to read monotonic clock, errno=%d", errno);
- return 0;
- }
- TIMESPEC_TO_TIMEVAL(&cur_tv, &cur_ts);
+ usbi_get_monotonic_time(&systime);
- if (!timercmp(&cur_tv, &next_timeout, <)) {
+ if (!TIMESPEC_CMP(&systime, &next_timeout, <)) {
usbi_dbg("first timeout already expired");
timerclear(tv);
} else {
- timersub(&next_timeout, &cur_tv, tv);
+ TIMESPEC_SUB(&next_timeout, &systime, &next_timeout);
+ TIMESPEC_TO_TIMEVAL(tv, &next_timeout);
usbi_dbg("next timeout in %ld.%06lds", (long)tv->tv_sec, (long)tv->tv_usec);
}
@@ -2675,79 +2616,92 @@ void API_EXPORTED libusb_set_pollfd_notifiers(libusb_context *ctx,
libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb,
void *user_data)
{
- USBI_GET_CONTEXT(ctx);
+#if !defined(PLATFORM_WINDOWS)
+ ctx = usbi_get_context(ctx);
ctx->fd_added_cb = added_cb;
ctx->fd_removed_cb = removed_cb;
ctx->fd_cb_user_data = user_data;
+#else
+ usbi_err(ctx, "external polling of libusb's internal event sources " \
+ "is not yet supported on Windows");
+ UNUSED(added_cb);
+ UNUSED(removed_cb);
+ UNUSED(user_data);
+#endif
}
/*
* Interrupt the iteration of the event handling thread, so that it picks
- * up the fd change. Callers of this function must hold the event_data_lock.
+ * up the event source change. Callers of this function must hold the event_data_lock.
*/
-static void usbi_fd_notification(struct libusb_context *ctx)
+static void usbi_event_source_notification(struct libusb_context *ctx)
{
- int pending_events;
+ unsigned int event_flags;
/* Record that there is a new poll fd.
* Only signal an event if there are no prior pending events. */
- pending_events = usbi_pending_events(ctx);
- ctx->event_flags |= USBI_EVENT_POLLFDS_MODIFIED;
- if (!pending_events)
- usbi_signal_event(ctx);
+ event_flags = ctx->event_flags;
+ ctx->event_flags |= USBI_EVENT_EVENT_SOURCES_MODIFIED;
+ if (!event_flags)
+ usbi_signal_event(&ctx->event);
}
-/* Add a file descriptor to the list of file descriptors to be monitored.
- * events should be specified as a bitmask of events passed to poll(), e.g.
+/* Add an event source to the list of event sources to be monitored.
+ * poll_events should be specified as a bitmask of events passed to poll(), e.g.
* POLLIN and/or POLLOUT. */
-int usbi_add_pollfd(struct libusb_context *ctx, int fd, short events)
+int usbi_add_event_source(struct libusb_context *ctx, usbi_os_handle_t os_handle, short poll_events)
{
- struct usbi_pollfd *ipollfd = malloc(sizeof(*ipollfd));
- if (!ipollfd)
+ struct usbi_event_source *ievent_source = malloc(sizeof(*ievent_source));
+
+ if (!ievent_source)
return LIBUSB_ERROR_NO_MEM;
- usbi_dbg("add fd %d events %d", fd, events);
- ipollfd->pollfd.fd = fd;
- ipollfd->pollfd.events = events;
+ usbi_dbg("add " USBI_OS_HANDLE_FORMAT_STRING " events %d", os_handle, poll_events);
+ ievent_source->data.os_handle = os_handle;
+ ievent_source->data.poll_events = poll_events;
usbi_mutex_lock(&ctx->event_data_lock);
- list_add_tail(&ipollfd->list, &ctx->ipollfds);
- ctx->pollfds_cnt++;
- usbi_fd_notification(ctx);
+ list_add_tail(&ievent_source->list, &ctx->event_sources);
+ usbi_event_source_notification(ctx);
usbi_mutex_unlock(&ctx->event_data_lock);
+#if !defined(PLATFORM_WINDOWS)
if (ctx->fd_added_cb)
- ctx->fd_added_cb(fd, events, ctx->fd_cb_user_data);
+ ctx->fd_added_cb(os_handle, poll_events, ctx->fd_cb_user_data);
+#endif
+
return 0;
}
-/* Remove a file descriptor from the list of file descriptors to be polled. */
-void usbi_remove_pollfd(struct libusb_context *ctx, int fd)
+/* Remove an event source from the list of event sources to be monitored. */
+void usbi_remove_event_source(struct libusb_context *ctx, usbi_os_handle_t os_handle)
{
- struct usbi_pollfd *ipollfd;
+ struct usbi_event_source *ievent_source;
int found = 0;
- usbi_dbg("remove fd %d", fd);
+ usbi_dbg("remove " USBI_OS_HANDLE_FORMAT_STRING, os_handle);
usbi_mutex_lock(&ctx->event_data_lock);
- list_for_each_entry(ipollfd, &ctx->ipollfds, list, struct usbi_pollfd)
- if (ipollfd->pollfd.fd == fd) {
+ for_each_event_source(ctx, ievent_source) {
+ if (ievent_source->data.os_handle == os_handle) {
found = 1;
break;
}
+ }
if (!found) {
- usbi_dbg("couldn't find fd %d to remove", fd);
+ usbi_dbg("couldn't find " USBI_OS_HANDLE_FORMAT_STRING " to remove", os_handle);
usbi_mutex_unlock(&ctx->event_data_lock);
return;
}
- list_del(&ipollfd->list);
- list_add_tail(&ipollfd->list, &ctx->removed_ipollfds);
- ctx->pollfds_cnt--;
- usbi_fd_notification(ctx);
+ list_del(&ievent_source->list);
+ list_add_tail(&ievent_source->list, &ctx->removed_event_sources);
+ usbi_event_source_notification(ctx);
usbi_mutex_unlock(&ctx->event_data_lock);
+#if !defined(PLATFORM_WINDOWS)
if (ctx->fd_removed_cb)
- ctx->fd_removed_cb(fd, ctx->fd_cb_user_data);
+ ctx->fd_removed_cb(os_handle, ctx->fd_cb_user_data);
+#endif
}
/** \ingroup libusb_poll
@@ -2769,28 +2723,36 @@ DEFAULT_VISIBILITY
const struct libusb_pollfd ** LIBUSB_CALL libusb_get_pollfds(
libusb_context *ctx)
{
-#ifndef OS_WINDOWS
+#if !defined(PLATFORM_WINDOWS)
struct libusb_pollfd **ret = NULL;
- struct usbi_pollfd *ipollfd;
- size_t i = 0;
- USBI_GET_CONTEXT(ctx);
+ struct usbi_event_source *ievent_source;
+ size_t i;
+
+ static_assert(sizeof(struct usbi_event_source_data) == sizeof(struct libusb_pollfd),
+ "mismatch between usbi_event_source_data and libusb_pollfd sizes");
+
+ ctx = usbi_get_context(ctx);
usbi_mutex_lock(&ctx->event_data_lock);
- ret = calloc(ctx->pollfds_cnt + 1, sizeof(struct libusb_pollfd *));
+ i = 0;
+ for_each_event_source(ctx, ievent_source)
+ i++;
+
+ ret = calloc(i + 1, sizeof(struct libusb_pollfd *));
if (!ret)
goto out;
- list_for_each_entry(ipollfd, &ctx->ipollfds, list, struct usbi_pollfd)
- ret[i++] = (struct libusb_pollfd *) ipollfd;
- ret[ctx->pollfds_cnt] = NULL;
+ i = 0;
+ for_each_event_source(ctx, ievent_source)
+ ret[i++] = (struct libusb_pollfd *)ievent_source;
out:
usbi_mutex_unlock(&ctx->event_data_lock);
- return (const struct libusb_pollfd **) ret;
+ return (const struct libusb_pollfd **)ret;
#else
- usbi_err(ctx, "external polling of libusb's internal descriptors "\
- "is not yet supported on Windows platforms");
+ usbi_err(ctx, "external polling of libusb's internal event sources " \
+ "is not yet supported on Windows");
return NULL;
#endif
}
@@ -2808,7 +2770,11 @@ out:
*/
void API_EXPORTED libusb_free_pollfds(const struct libusb_pollfd **pollfds)
{
+#if !defined(PLATFORM_WINDOWS)
free((void *)pollfds);
+#else
+ UNUSED(pollfds);
+#endif
}
/* Backends may call this from handle_events to report disconnection of a
@@ -2817,6 +2783,7 @@ void API_EXPORTED libusb_free_pollfds(const struct libusb_pollfd **pollfds)
*/
void usbi_handle_disconnect(struct libusb_device_handle *dev_handle)
{
+ struct libusb_context *ctx = HANDLE_CTX(dev_handle);
struct usbi_transfer *cur;
struct usbi_transfer *to_cancel;
@@ -2838,8 +2805,8 @@ void usbi_handle_disconnect(struct libusb_device_handle *dev_handle)
while (1) {
to_cancel = NULL;
- usbi_mutex_lock(&HANDLE_CTX(dev_handle)->flying_transfers_lock);
- list_for_each_entry(cur, &HANDLE_CTX(dev_handle)->flying_transfers, list, struct usbi_transfer)
+ usbi_mutex_lock(&ctx->flying_transfers_lock);
+ for_each_transfer(ctx, cur) {
if (USBI_TRANSFER_TO_LIBUSB_TRANSFER(cur)->dev_handle == dev_handle) {
usbi_mutex_lock(&cur->lock);
if (cur->state_flags & USBI_TRANSFER_IN_FLIGHT)
@@ -2849,7 +2816,8 @@ void usbi_handle_disconnect(struct libusb_device_handle *dev_handle)
if (to_cancel)
break;
}
- usbi_mutex_unlock(&HANDLE_CTX(dev_handle)->flying_transfers_lock);
+ }
+ usbi_mutex_unlock(&ctx->flying_transfers_lock);
if (!to_cancel)
break;
@@ -2862,5 +2830,4 @@ void usbi_handle_disconnect(struct libusb_device_handle *dev_handle)
usbi_mutex_unlock(&to_cancel->lock);
usbi_handle_transfer_completion(to_cancel, LIBUSB_TRANSFER_NO_DEVICE);
}
-
}
diff --git a/libusb/libusb-1.0.def b/libusb/libusb-1.0.def
index 6eba4ff..700a8bc 100644
--- a/libusb/libusb-1.0.def
+++ b/libusb/libusb-1.0.def
@@ -116,6 +116,8 @@ EXPORTS
libusb_has_capability@4 = libusb_has_capability
libusb_hotplug_deregister_callback
libusb_hotplug_deregister_callback@8 = libusb_hotplug_deregister_callback
+ libusb_hotplug_get_user_data
+ libusb_hotplug_get_user_data@8 = libusb_hotplug_get_user_data
libusb_hotplug_register_callback
libusb_hotplug_register_callback@36 = libusb_hotplug_register_callback
libusb_init
@@ -176,3 +178,5 @@ EXPORTS
libusb_unref_device@4 = libusb_unref_device
libusb_wait_for_event
libusb_wait_for_event@8 = libusb_wait_for_event
+ libusb_wrap_sys_device
+ libusb_wrap_sys_device@12 = libusb_wrap_sys_device
diff --git a/libusb/libusb-1.0.rc b/libusb/libusb-1.0.rc
index 3dce6d5..bcb10fa 100644
--- a/libusb/libusb-1.0.rc
+++ b/libusb/libusb-1.0.rc
@@ -1,27 +1,19 @@
/*
- * For Windows: input this file to the Resoure Compiler to produce a binary
+ * For Windows: input this file to the Resource Compiler to produce a binary
* .res file. This is then embedded in the resultant library (like any other
* compilation object).
* The information can then be queried using standard APIs and can also be
* viewed with utilities such as Windows Explorer.
*/
-#ifndef _WIN32_WCE
#include "winresrc.h"
-#endif
#include "version.h"
#ifndef LIBUSB_VERSIONSTRING
#define LU_STR(s) #s
#define LU_XSTR(s) LU_STR(s)
-#if LIBUSB_NANO > 0
#define LIBUSB_VERSIONSTRING \
LU_XSTR(LIBUSB_MAJOR) "." LU_XSTR(LIBUSB_MINOR) "." \
LU_XSTR(LIBUSB_MICRO) "." LU_XSTR(LIBUSB_NANO) LIBUSB_RC "\0"
-#else
-#define LIBUSB_VERSIONSTRING \
- LU_XSTR(LIBUSB_MAJOR) "." LU_XSTR(LIBUSB_MINOR) "." \
- LU_XSTR(LIBUSB_MICRO) LIBUSB_RC "\0"
-#endif
#endif
VS_VERSION_INFO VERSIONINFO
diff --git a/libusb/libusb.h b/libusb/libusb.h
index 8a6b0bf..1308571 100644
--- a/libusb/libusb.h
+++ b/libusb/libusb.h
@@ -4,6 +4,7 @@
* Copyright © 2007-2008 Daniel Drake <dsd@gentoo.org>
* Copyright © 2012 Pete Batard <pete@akeo.ie>
* Copyright © 2012-2018 Nathan Hjelm <hjelmn@cs.unm.edu>
+ * Copyright © 2014-2020 Chris Dickens <christopher.a.dickens@gmail.com>
* For more information, please visit: http://libusb.info
*
* This library is free software; you can redistribute it and/or
@@ -24,55 +25,36 @@
#ifndef LIBUSB_H
#define LIBUSB_H
-#ifdef _MSC_VER
+#if defined(_MSC_VER)
/* on MS environments, the inline keyword is available in C++ only */
#if !defined(__cplusplus)
#define inline __inline
#endif
-/* ssize_t is also not available (copy/paste from MinGW) */
-#ifndef _SSIZE_T_DEFINED
-#define _SSIZE_T_DEFINED
-#undef ssize_t
-#ifdef _WIN64
- typedef __int64 ssize_t;
-#else
- typedef int ssize_t;
-#endif /* _WIN64 */
-#endif /* _SSIZE_T_DEFINED */
+/* ssize_t is also not available */
+#include <basetsd.h>
+typedef SSIZE_T ssize_t;
#endif /* _MSC_VER */
-/* stdint.h is not available on older MSVC */
-#if defined(_MSC_VER) && (_MSC_VER < 1600) && (!defined(_STDINT)) && (!defined(_STDINT_H))
-typedef unsigned __int8 uint8_t;
-typedef unsigned __int16 uint16_t;
-typedef unsigned __int32 uint32_t;
-#else
+#include <limits.h>
#include <stdint.h>
-#endif
-
-#if !defined(_WIN32_WCE)
#include <sys/types.h>
-#endif
-
-#if defined(__linux__) || defined(__APPLE__) || defined(__CYGWIN__) || defined(__HAIKU__)
+#if !defined(_MSC_VER)
#include <sys/time.h>
#endif
-
#include <time.h>
-#include <limits.h>
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
#define ZERO_SIZED_ARRAY /* [] - valid C99 code */
#else
#define ZERO_SIZED_ARRAY 0 /* [0] - non-standard, but usually working code */
-#endif
+#endif /* __STDC_VERSION__ */
/* 'interface' might be defined as a macro on Windows, so we need to
* undefine it so as not to break the current libusb API, because
* libusb_config_descriptor has an 'interface' member
* As this can be problematic if you include windows.h after libusb.h
* in your sources, we force windows.h to be included first. */
-#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
+#if defined(_WIN32) || defined(__CYGWIN__)
#include <windows.h>
#if defined(interface)
#undef interface
@@ -80,17 +62,22 @@ typedef unsigned __int32 uint32_t;
#if !defined(__CYGWIN__)
#include <winsock.h>
#endif
-#endif
+#endif /* _WIN32 || __CYGWIN__ */
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
-#define LIBUSB_DEPRECATED_FOR(f) \
- __attribute__((deprecated("Use " #f " instead")))
-#elif __GNUC__ >= 3
-#define LIBUSB_DEPRECATED_FOR(f) __attribute__((deprecated))
+#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
+#define LIBUSB_DEPRECATED_FOR(f) __attribute__ ((deprecated ("Use " #f " instead")))
+#elif defined(__GNUC__) && (__GNUC__ >= 3)
+#define LIBUSB_DEPRECATED_FOR(f) __attribute__ ((deprecated))
#else
#define LIBUSB_DEPRECATED_FOR(f)
#endif /* __GNUC__ */
+#if defined(__GNUC__)
+#define LIBUSB_PACKED __attribute__ ((packed))
+#else
+#define LIBUSB_PACKED
+#endif /* __GNUC__ */
+
/** \def LIBUSB_CALL
* \ingroup libusb_misc
* libusb's Windows calling convention.
@@ -123,11 +110,11 @@ typedef unsigned __int32 uint32_t;
* return type, before the function name. See internal documentation for
* API_EXPORTED.
*/
-#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
+#if defined(_WIN32) || defined(__CYGWIN__)
#define LIBUSB_CALL WINAPI
#else
#define LIBUSB_CALL
-#endif
+#endif /* _WIN32 || __CYGWIN__ */
/** \def LIBUSB_API_VERSION
* \ingroup libusb_misc
@@ -149,12 +136,12 @@ typedef unsigned __int32 uint32_t;
* Internally, LIBUSB_API_VERSION is defined as follows:
* (libusb major << 24) | (libusb minor << 16) | (16 bit incremental)
*/
-#define LIBUSB_API_VERSION 0x01000107
+#define LIBUSB_API_VERSION 0x01000108
/* The following is kept for compatibility, but will be deprecated in the future */
#define LIBUSBX_API_VERSION LIBUSB_API_VERSION
-#ifdef __cplusplus
+#if defined(__cplusplus)
extern "C" {
#endif
@@ -196,35 +183,35 @@ enum libusb_class_code {
* this bDeviceClass value indicates that each interface specifies its
* own class information and all interfaces operate independently.
*/
- LIBUSB_CLASS_PER_INTERFACE = 0,
+ LIBUSB_CLASS_PER_INTERFACE = 0x00,
/** Audio class */
- LIBUSB_CLASS_AUDIO = 1,
+ LIBUSB_CLASS_AUDIO = 0x01,
/** Communications class */
- LIBUSB_CLASS_COMM = 2,
+ LIBUSB_CLASS_COMM = 0x02,
/** Human Interface Device class */
- LIBUSB_CLASS_HID = 3,
+ LIBUSB_CLASS_HID = 0x03,
/** Physical */
- LIBUSB_CLASS_PHYSICAL = 5,
-
- /** Printer class */
- LIBUSB_CLASS_PRINTER = 7,
+ LIBUSB_CLASS_PHYSICAL = 0x05,
/** Image class */
- LIBUSB_CLASS_PTP = 6, /* legacy name from libusb-0.1 usb.h */
- LIBUSB_CLASS_IMAGE = 6,
+ LIBUSB_CLASS_IMAGE = 0x06,
+ LIBUSB_CLASS_PTP = 0x06, /* legacy name from libusb-0.1 usb.h */
+
+ /** Printer class */
+ LIBUSB_CLASS_PRINTER = 0x07,
/** Mass storage class */
- LIBUSB_CLASS_MASS_STORAGE = 8,
+ LIBUSB_CLASS_MASS_STORAGE = 0x08,
/** Hub class */
- LIBUSB_CLASS_HUB = 9,
+ LIBUSB_CLASS_HUB = 0x09,
/** Data class */
- LIBUSB_CLASS_DATA = 10,
+ LIBUSB_CLASS_DATA = 0x0a,
/** Smart Card */
LIBUSB_CLASS_SMART_CARD = 0x0b,
@@ -244,6 +231,9 @@ enum libusb_class_code {
/** Wireless class */
LIBUSB_CLASS_WIRELESS = 0xe0,
+ /** Miscellaneous class */
+ LIBUSB_CLASS_MISCELLANEOUS = 0xef,
+
/** Application class */
LIBUSB_CLASS_APPLICATION = 0xfe,
@@ -311,12 +301,13 @@ enum libusb_descriptor_type {
#define LIBUSB_BT_CONTAINER_ID_SIZE 20
/* We unwrap the BOS => define its max size */
-#define LIBUSB_DT_BOS_MAX_SIZE ((LIBUSB_DT_BOS_SIZE) +\
- (LIBUSB_BT_USB_2_0_EXTENSION_SIZE) +\
- (LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE) +\
- (LIBUSB_BT_CONTAINER_ID_SIZE))
+#define LIBUSB_DT_BOS_MAX_SIZE \
+ (LIBUSB_DT_BOS_SIZE + \
+ LIBUSB_BT_USB_2_0_EXTENSION_SIZE + \
+ LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE + \
+ LIBUSB_BT_CONTAINER_ID_SIZE)
-#define LIBUSB_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */
+#define LIBUSB_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */
#define LIBUSB_ENDPOINT_DIR_MASK 0x80
/** \ingroup libusb_desc
@@ -324,34 +315,31 @@ enum libusb_descriptor_type {
* \ref libusb_endpoint_descriptor::bEndpointAddress "endpoint address" scheme.
*/
enum libusb_endpoint_direction {
- /** In: device-to-host */
- LIBUSB_ENDPOINT_IN = 0x80,
-
/** Out: host-to-device */
- LIBUSB_ENDPOINT_OUT = 0x00
+ LIBUSB_ENDPOINT_OUT = 0x00,
+
+ /** In: device-to-host */
+ LIBUSB_ENDPOINT_IN = 0x80
};
-#define LIBUSB_TRANSFER_TYPE_MASK 0x03 /* in bmAttributes */
+#define LIBUSB_TRANSFER_TYPE_MASK 0x03 /* in bmAttributes */
/** \ingroup libusb_desc
* Endpoint transfer type. Values for bits 0:1 of the
* \ref libusb_endpoint_descriptor::bmAttributes "endpoint attributes" field.
*/
-enum libusb_transfer_type {
+enum libusb_endpoint_transfer_type {
/** Control endpoint */
- LIBUSB_TRANSFER_TYPE_CONTROL = 0,
+ LIBUSB_ENDPOINT_TRANSFER_TYPE_CONTROL = 0x0,
/** Isochronous endpoint */
- LIBUSB_TRANSFER_TYPE_ISOCHRONOUS = 1,
+ LIBUSB_ENDPOINT_TRANSFER_TYPE_ISOCHRONOUS = 0x1,
/** Bulk endpoint */
- LIBUSB_TRANSFER_TYPE_BULK = 2,
+ LIBUSB_ENDPOINT_TRANSFER_TYPE_BULK = 0x2,
/** Interrupt endpoint */
- LIBUSB_TRANSFER_TYPE_INTERRUPT = 3,
-
- /** Stream endpoint */
- LIBUSB_TRANSFER_TYPE_BULK_STREAM = 4,
+ LIBUSB_ENDPOINT_TRANSFER_TYPE_INTERRUPT = 0x3
};
/** \ingroup libusb_misc
@@ -386,20 +374,20 @@ enum libusb_standard_request {
LIBUSB_REQUEST_SET_CONFIGURATION = 0x09,
/** Return the selected alternate setting for the specified interface */
- LIBUSB_REQUEST_GET_INTERFACE = 0x0A,
+ LIBUSB_REQUEST_GET_INTERFACE = 0x0a,
/** Select an alternate interface for the specified interface */
- LIBUSB_REQUEST_SET_INTERFACE = 0x0B,
+ LIBUSB_REQUEST_SET_INTERFACE = 0x0b,
/** Set then report an endpoint's synchronization frame */
- LIBUSB_REQUEST_SYNCH_FRAME = 0x0C,
+ LIBUSB_REQUEST_SYNCH_FRAME = 0x0c,
/** Sets both the U1 and U2 Exit Latency */
LIBUSB_REQUEST_SET_SEL = 0x30,
/** Delay from the time a host transmits a packet to the time it is
* received by the device. */
- LIBUSB_SET_ISOCH_DELAY = 0x31,
+ LIBUSB_SET_ISOCH_DELAY = 0x31
};
/** \ingroup libusb_misc
@@ -435,10 +423,10 @@ enum libusb_request_recipient {
LIBUSB_RECIPIENT_ENDPOINT = 0x02,
/** Other */
- LIBUSB_RECIPIENT_OTHER = 0x03,
+ LIBUSB_RECIPIENT_OTHER = 0x03
};
-#define LIBUSB_ISO_SYNC_TYPE_MASK 0x0C
+#define LIBUSB_ISO_SYNC_TYPE_MASK 0x0c
/** \ingroup libusb_desc
* Synchronization type for isochronous endpoints. Values for bits 2:3 of the
@@ -447,19 +435,19 @@ enum libusb_request_recipient {
*/
enum libusb_iso_sync_type {
/** No synchronization */
- LIBUSB_ISO_SYNC_TYPE_NONE = 0,
+ LIBUSB_ISO_SYNC_TYPE_NONE = 0x0,
/** Asynchronous */
- LIBUSB_ISO_SYNC_TYPE_ASYNC = 1,
+ LIBUSB_ISO_SYNC_TYPE_ASYNC = 0x1,
/** Adaptive */
- LIBUSB_ISO_SYNC_TYPE_ADAPTIVE = 2,
+ LIBUSB_ISO_SYNC_TYPE_ADAPTIVE = 0x2,
/** Synchronous */
- LIBUSB_ISO_SYNC_TYPE_SYNC = 3
+ LIBUSB_ISO_SYNC_TYPE_SYNC = 0x3
};
-#define LIBUSB_ISO_USAGE_TYPE_MASK 0x30
+#define LIBUSB_ISO_USAGE_TYPE_MASK 0x30
/** \ingroup libusb_desc
* Usage type for isochronous endpoints. Values for bits 4:5 of the
@@ -468,13 +456,68 @@ enum libusb_iso_sync_type {
*/
enum libusb_iso_usage_type {
/** Data endpoint */
- LIBUSB_ISO_USAGE_TYPE_DATA = 0,
+ LIBUSB_ISO_USAGE_TYPE_DATA = 0x0,
/** Feedback endpoint */
- LIBUSB_ISO_USAGE_TYPE_FEEDBACK = 1,
+ LIBUSB_ISO_USAGE_TYPE_FEEDBACK = 0x1,
/** Implicit feedback Data endpoint */
- LIBUSB_ISO_USAGE_TYPE_IMPLICIT = 2,
+ LIBUSB_ISO_USAGE_TYPE_IMPLICIT = 0x2
+};
+
+/** \ingroup libusb_desc
+ * Supported speeds (wSpeedSupported) bitfield. Indicates what
+ * speeds the device supports.
+ */
+enum libusb_supported_speed {
+ /** Low speed operation supported (1.5MBit/s). */
+ LIBUSB_LOW_SPEED_OPERATION = (1 << 0),
+
+ /** Full speed operation supported (12MBit/s). */
+ LIBUSB_FULL_SPEED_OPERATION = (1 << 1),
+
+ /** High speed operation supported (480MBit/s). */
+ LIBUSB_HIGH_SPEED_OPERATION = (1 << 2),
+
+ /** Superspeed operation supported (5000MBit/s). */
+ LIBUSB_SUPER_SPEED_OPERATION = (1 << 3)
+};
+
+/** \ingroup libusb_desc
+ * Masks for the bits of the
+ * \ref libusb_usb_2_0_extension_descriptor::bmAttributes "bmAttributes" field
+ * of the USB 2.0 Extension descriptor.
+ */
+enum libusb_usb_2_0_extension_attributes {
+ /** Supports Link Power Management (LPM) */
+ LIBUSB_BM_LPM_SUPPORT = (1 << 1)
+};
+
+/** \ingroup libusb_desc
+ * Masks for the bits of the
+ * \ref libusb_ss_usb_device_capability_descriptor::bmAttributes "bmAttributes" field
+ * field of the SuperSpeed USB Device Capability descriptor.
+ */
+enum libusb_ss_usb_device_capability_attributes {
+ /** Supports Latency Tolerance Messages (LTM) */
+ LIBUSB_BM_LTM_SUPPORT = (1 << 1)
+};
+
+/** \ingroup libusb_desc
+ * USB capability types
+ */
+enum libusb_bos_type {
+ /** Wireless USB device capability */
+ LIBUSB_BT_WIRELESS_USB_DEVICE_CAPABILITY = 0x01,
+
+ /** USB 2.0 extensions */
+ LIBUSB_BT_USB_2_0_EXTENSION = 0x02,
+
+ /** SuperSpeed USB device capability */
+ LIBUSB_BT_SS_USB_DEVICE_CAPABILITY = 0x03,
+
+ /** Container ID type */
+ LIBUSB_BT_CONTAINER_ID = 0x04
};
/** \ingroup libusb_desc
@@ -547,17 +590,15 @@ struct libusb_endpoint_descriptor {
/** The address of the endpoint described by this descriptor. Bits 0:3 are
* the endpoint number. Bits 4:6 are reserved. Bit 7 indicates direction,
- * see \ref libusb_endpoint_direction.
- */
+ * see \ref libusb_endpoint_direction. */
uint8_t bEndpointAddress;
/** Attributes which apply to the endpoint when it is configured using
* the bConfigurationValue. Bits 0:1 determine the transfer type and
- * correspond to \ref libusb_transfer_type. Bits 2:3 are only used for
- * isochronous endpoints and correspond to \ref libusb_iso_sync_type.
+ * correspond to \ref libusb_endpoint_transfer_type. Bits 2:3 are only used
+ * for isochronous endpoints and correspond to \ref libusb_iso_sync_type.
* Bits 4:5 are also only used for isochronous endpoints and correspond to
- * \ref libusb_iso_usage_type. Bits 6:7 are reserved.
- */
+ * \ref libusb_iso_usage_type. Bits 6:7 are reserved. */
uint8_t bmAttributes;
/** Maximum packet size this endpoint is capable of sending/receiving. */
@@ -698,7 +739,6 @@ struct libusb_config_descriptor {
* host-endian format.
*/
struct libusb_ss_endpoint_companion_descriptor {
-
/** Size of this descriptor (in bytes) */
uint8_t bLength;
@@ -707,19 +747,18 @@ struct libusb_ss_endpoint_companion_descriptor {
* this context. */
uint8_t bDescriptorType;
-
/** The maximum number of packets the endpoint can send or
* receive as part of a burst. */
uint8_t bMaxBurst;
- /** In bulk EP: bits 4:0 represents the maximum number of
- * streams the EP supports. In isochronous EP: bits 1:0
- * represents the Mult - a zero based value that determines
- * the maximum number of packets within a service interval */
+ /** In bulk EP: bits 4:0 represents the maximum number of
+ * streams the EP supports. In isochronous EP: bits 1:0
+ * represents the Mult - a zero based value that determines
+ * the maximum number of packets within a service interval */
uint8_t bmAttributes;
- /** The total number of bytes this EP will transfer every
- * service interval. valid only for periodic EPs. */
+ /** The total number of bytes this EP will transfer every
+ * service interval. Valid only for periodic EPs. */
uint16_t wBytesPerInterval;
};
@@ -730,15 +769,18 @@ struct libusb_ss_endpoint_companion_descriptor {
*/
struct libusb_bos_dev_capability_descriptor {
/** Size of this descriptor (in bytes) */
- uint8_t bLength;
+ uint8_t bLength;
+
/** Descriptor type. Will have value
* \ref libusb_descriptor_type::LIBUSB_DT_DEVICE_CAPABILITY
* LIBUSB_DT_DEVICE_CAPABILITY in this context. */
- uint8_t bDescriptorType;
+ uint8_t bDescriptorType;
+
/** Device Capability type */
- uint8_t bDevCapabilityType;
+ uint8_t bDevCapabilityType;
+
/** Device Capability data (bLength - 3 bytes) */
- uint8_t dev_capability_data[ZERO_SIZED_ARRAY];
+ uint8_t dev_capability_data[ZERO_SIZED_ARRAY];
};
/** \ingroup libusb_desc
@@ -789,7 +831,7 @@ struct libusb_usb_2_0_extension_descriptor {
* A value of one in a bit location indicates a feature is
* supported; a value of zero indicates it is not supported.
* See \ref libusb_usb_2_0_extension_attributes. */
- uint32_t bmAttributes;
+ uint32_t bmAttributes;
};
/** \ingroup libusb_desc
@@ -854,7 +896,7 @@ struct libusb_container_id_descriptor {
uint8_t bDevCapabilityType;
/** Reserved field */
- uint8_t bReserved;
+ uint8_t bReserved;
/** 128 bit UUID */
uint8_t ContainerID[16];
@@ -862,6 +904,9 @@ struct libusb_container_id_descriptor {
/** \ingroup libusb_asyncio
* Setup packet for control transfers. */
+#if defined(_MSC_VER)
+#pragma pack(push, 1)
+#endif
struct libusb_control_setup {
/** Request type. Bits 0:4 determine recipient, see
* \ref libusb_request_recipient. Bits 5:6 determine type, see
@@ -886,7 +931,10 @@ struct libusb_control_setup {
/** Number of bytes to transfer */
uint16_t wLength;
-};
+} LIBUSB_PACKED;
+#if defined(_MSC_VER)
+#pragma pack(pop)
+#endif
#define LIBUSB_CONTROL_SETUP_SIZE (sizeof(struct libusb_control_setup))
@@ -916,7 +964,7 @@ struct libusb_version {
const char *rc;
/** For ABI compatibility only. */
- const char* describe;
+ const char *describe;
};
/** \ingroup libusb_lib
@@ -986,62 +1034,7 @@ enum libusb_speed {
LIBUSB_SPEED_SUPER = 4,
/** The device is operating at super speed plus (10000MBit/s). */
- LIBUSB_SPEED_SUPER_PLUS = 5,
-};
-
-/** \ingroup libusb_dev
- * Supported speeds (wSpeedSupported) bitfield. Indicates what
- * speeds the device supports.
- */
-enum libusb_supported_speed {
- /** Low speed operation supported (1.5MBit/s). */
- LIBUSB_LOW_SPEED_OPERATION = 1,
-
- /** Full speed operation supported (12MBit/s). */
- LIBUSB_FULL_SPEED_OPERATION = 2,
-
- /** High speed operation supported (480MBit/s). */
- LIBUSB_HIGH_SPEED_OPERATION = 4,
-
- /** Superspeed operation supported (5000MBit/s). */
- LIBUSB_SUPER_SPEED_OPERATION = 8,
-};
-
-/** \ingroup libusb_dev
- * Masks for the bits of the
- * \ref libusb_usb_2_0_extension_descriptor::bmAttributes "bmAttributes" field
- * of the USB 2.0 Extension descriptor.
- */
-enum libusb_usb_2_0_extension_attributes {
- /** Supports Link Power Management (LPM) */
- LIBUSB_BM_LPM_SUPPORT = 2,
-};
-
-/** \ingroup libusb_dev
- * Masks for the bits of the
- * \ref libusb_ss_usb_device_capability_descriptor::bmAttributes "bmAttributes" field
- * field of the SuperSpeed USB Device Capability descriptor.
- */
-enum libusb_ss_usb_device_capability_attributes {
- /** Supports Latency Tolerance Messages (LTM) */
- LIBUSB_BM_LTM_SUPPORT = 2,
-};
-
-/** \ingroup libusb_dev
- * USB capability types
- */
-enum libusb_bos_type {
- /** Wireless USB device capability */
- LIBUSB_BT_WIRELESS_USB_DEVICE_CAPABILITY = 1,
-
- /** USB 2.0 extensions */
- LIBUSB_BT_USB_2_0_EXTENSION = 2,
-
- /** SuperSpeed USB device capability */
- LIBUSB_BT_SS_USB_DEVICE_CAPABILITY = 3,
-
- /** Container ID type */
- LIBUSB_BT_CONTAINER_ID = 4,
+ LIBUSB_SPEED_SUPER_PLUS = 5
};
/** \ingroup libusb_misc
@@ -1095,13 +1088,32 @@ enum libusb_error {
message strings in strerror.c when adding new error codes here. */
/** Other error */
- LIBUSB_ERROR_OTHER = -99,
+ LIBUSB_ERROR_OTHER = -99
};
/* Total number of error codes in enum libusb_error */
#define LIBUSB_ERROR_COUNT 14
/** \ingroup libusb_asyncio
+ * Transfer type */
+enum libusb_transfer_type {
+ /** Control transfer */
+ LIBUSB_TRANSFER_TYPE_CONTROL = 0U,
+
+ /** Isochronous transfer */
+ LIBUSB_TRANSFER_TYPE_ISOCHRONOUS = 1U,
+
+ /** Bulk transfer */
+ LIBUSB_TRANSFER_TYPE_BULK = 2U,
+
+ /** Interrupt transfer */
+ LIBUSB_TRANSFER_TYPE_INTERRUPT = 3U,
+
+ /** Bulk stream transfer */
+ LIBUSB_TRANSFER_TYPE_BULK_STREAM = 4U
+};
+
+/** \ingroup libusb_asyncio
* Transfer status codes */
enum libusb_transfer_status {
/** Transfer completed without error. Note that this does not indicate
@@ -1125,7 +1137,7 @@ enum libusb_transfer_status {
LIBUSB_TRANSFER_NO_DEVICE,
/** Device sent more data than requested */
- LIBUSB_TRANSFER_OVERFLOW,
+ LIBUSB_TRANSFER_OVERFLOW
/* NB! Remember to update libusb_error_name()
when adding new status codes here. */
@@ -1135,19 +1147,19 @@ enum libusb_transfer_status {
* libusb_transfer.flags values */
enum libusb_transfer_flags {
/** Report short frames as errors */
- LIBUSB_TRANSFER_SHORT_NOT_OK = 1U << 0,
+ LIBUSB_TRANSFER_SHORT_NOT_OK = (1U << 0),
/** Automatically free() transfer buffer during libusb_free_transfer().
* Note that buffers allocated with libusb_dev_mem_alloc() should not
* be attempted freed in this way, since free() is not an appropriate
* way to release such memory. */
- LIBUSB_TRANSFER_FREE_BUFFER = 1U << 1,
+ LIBUSB_TRANSFER_FREE_BUFFER = (1U << 1),
/** Automatically call libusb_free_transfer() after callback returns.
* If this flag is set, it is illegal to call libusb_free_transfer()
* from your transfer callback, as this will result in a double-free
* when this flag is acted upon. */
- LIBUSB_TRANSFER_FREE_TRANSFER = 1U << 2,
+ LIBUSB_TRANSFER_FREE_TRANSFER = (1U << 2),
/** Terminate transfers that are a multiple of the endpoint's
* wMaxPacketSize with an extra zero length packet. This is useful
@@ -1172,7 +1184,7 @@ enum libusb_transfer_flags {
*
* Available since libusb-1.0.9.
*/
- LIBUSB_TRANSFER_ADD_ZERO_PACKET = 1U << 3,
+ LIBUSB_TRANSFER_ADD_ZERO_PACKET = (1U << 3)
};
/** \ingroup libusb_asyncio
@@ -1217,7 +1229,7 @@ struct libusb_transfer {
/** Address of the endpoint where this transfer will be sent. */
unsigned char endpoint;
- /** Type of the endpoint from \ref libusb_transfer_type */
+ /** Type of the transfer from \ref libusb_transfer_type */
unsigned char type;
/** Timeout for this transfer in milliseconds. A value of 0 indicates no
@@ -1245,7 +1257,16 @@ struct libusb_transfer {
* fails, or is cancelled. */
libusb_transfer_cb_fn callback;
- /** User context data to pass to the callback function. */
+ /** User context data. Useful for associating specific data to a transfer
+ * that can be accessed from within the callback function.
+ *
+ * This field may be set manually or is taken as the `user_data` parameter
+ * of the following functions:
+ * - libusb_fill_bulk_transfer()
+ * - libusb_fill_bulk_stream_transfer()
+ * - libusb_fill_control_transfer()
+ * - libusb_fill_interrupt_transfer()
+ * - libusb_fill_iso_transfer() */
void *user_data;
/** Data buffer */
@@ -1266,33 +1287,40 @@ struct libusb_transfer {
*/
enum libusb_capability {
/** The libusb_has_capability() API is available. */
- LIBUSB_CAP_HAS_CAPABILITY = 0x0000,
+ LIBUSB_CAP_HAS_CAPABILITY = 0x0000U,
+
/** Hotplug support is available on this platform. */
- LIBUSB_CAP_HAS_HOTPLUG = 0x0001,
+ LIBUSB_CAP_HAS_HOTPLUG = 0x0001U,
+
/** The library can access HID devices without requiring user intervention.
* Note that before being able to actually access an HID device, you may
* still have to call additional libusb functions such as
* \ref libusb_detach_kernel_driver(). */
- LIBUSB_CAP_HAS_HID_ACCESS = 0x0100,
- /** The library supports detaching of the default USB driver, using
+ LIBUSB_CAP_HAS_HID_ACCESS = 0x0100U,
+
+ /** The library supports detaching of the default USB driver, using
* \ref libusb_detach_kernel_driver(), if one is set by the OS kernel */
- LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER = 0x0101
+ LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER = 0x0101U
};
/** \ingroup libusb_lib
* Log message levels.
- * - LIBUSB_LOG_LEVEL_NONE (0) : no messages ever printed by the library (default)
- * - LIBUSB_LOG_LEVEL_ERROR (1) : error messages are printed to stderr
- * - LIBUSB_LOG_LEVEL_WARNING (2) : warning and error messages are printed to stderr
- * - LIBUSB_LOG_LEVEL_INFO (3) : informational messages are printed to stderr
- * - LIBUSB_LOG_LEVEL_DEBUG (4) : debug and informational messages are printed to stderr
*/
enum libusb_log_level {
+ /** (0) : No messages ever emitted by the library (default) */
LIBUSB_LOG_LEVEL_NONE = 0,
+
+ /** (1) : Error messages are emitted */
LIBUSB_LOG_LEVEL_ERROR = 1,
+
+ /** (2) : Warning and error messages are emitted */
LIBUSB_LOG_LEVEL_WARNING = 2,
+
+ /** (3) : Informational, warning and error messages are emitted */
LIBUSB_LOG_LEVEL_INFO = 3,
- LIBUSB_LOG_LEVEL_DEBUG = 4,
+
+ /** (4) : All messages are emitted */
+ LIBUSB_LOG_LEVEL_DEBUG = 4
};
/** \ingroup libusb_lib
@@ -1300,12 +1328,11 @@ enum libusb_log_level {
* \see libusb_set_log_cb()
*/
enum libusb_log_cb_mode {
+ /** Callback function handling all log messages. */
+ LIBUSB_LOG_CB_GLOBAL = (1 << 0),
- /** Callback function handling all log mesages. */
- LIBUSB_LOG_CB_GLOBAL = 1 << 0,
-
- /** Callback function handling context related log mesages. */
- LIBUSB_LOG_CB_CONTEXT = 1 << 1
+ /** Callback function handling context related log messages. */
+ LIBUSB_LOG_CB_CONTEXT = (1 << 1)
};
/** \ingroup libusb_lib
@@ -1328,7 +1355,7 @@ const struct libusb_version * LIBUSB_CALL libusb_get_version(void);
int LIBUSB_CALL libusb_has_capability(uint32_t capability);
const char * LIBUSB_CALL libusb_error_name(int errcode);
int LIBUSB_CALL libusb_setlocale(const char *locale);
-const char * LIBUSB_CALL libusb_strerror(enum libusb_error errcode);
+const char * LIBUSB_CALL libusb_strerror(int errcode);
ssize_t LIBUSB_CALL libusb_get_device_list(libusb_context *ctx,
libusb_device ***list);
@@ -1350,7 +1377,7 @@ int LIBUSB_CALL libusb_get_config_descriptor_by_value(libusb_device *dev,
void LIBUSB_CALL libusb_free_config_descriptor(
struct libusb_config_descriptor *config);
int LIBUSB_CALL libusb_get_ss_endpoint_companion_descriptor(
- struct libusb_context *ctx,
+ libusb_context *ctx,
const struct libusb_endpoint_descriptor *endpoint,
struct libusb_ss_endpoint_companion_descriptor **ep_comp);
void LIBUSB_CALL libusb_free_ss_endpoint_companion_descriptor(
@@ -1359,27 +1386,27 @@ int LIBUSB_CALL libusb_get_bos_descriptor(libusb_device_handle *dev_handle,
struct libusb_bos_descriptor **bos);
void LIBUSB_CALL libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos);
int LIBUSB_CALL libusb_get_usb_2_0_extension_descriptor(
- struct libusb_context *ctx,
+ libusb_context *ctx,
struct libusb_bos_dev_capability_descriptor *dev_cap,
struct libusb_usb_2_0_extension_descriptor **usb_2_0_extension);
void LIBUSB_CALL libusb_free_usb_2_0_extension_descriptor(
struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension);
int LIBUSB_CALL libusb_get_ss_usb_device_capability_descriptor(
- struct libusb_context *ctx,
+ libusb_context *ctx,
struct libusb_bos_dev_capability_descriptor *dev_cap,
struct libusb_ss_usb_device_capability_descriptor **ss_usb_device_cap);
void LIBUSB_CALL libusb_free_ss_usb_device_capability_descriptor(
struct libusb_ss_usb_device_capability_descriptor *ss_usb_device_cap);
-int LIBUSB_CALL libusb_get_container_id_descriptor(struct libusb_context *ctx,
+int LIBUSB_CALL libusb_get_container_id_descriptor(libusb_context *ctx,
struct libusb_bos_dev_capability_descriptor *dev_cap,
struct libusb_container_id_descriptor **container_id);
void LIBUSB_CALL libusb_free_container_id_descriptor(
struct libusb_container_id_descriptor *container_id);
uint8_t LIBUSB_CALL libusb_get_bus_number(libusb_device *dev);
uint8_t LIBUSB_CALL libusb_get_port_number(libusb_device *dev);
-int LIBUSB_CALL libusb_get_port_numbers(libusb_device *dev, uint8_t* port_numbers, int port_numbers_len);
+int LIBUSB_CALL libusb_get_port_numbers(libusb_device *dev, uint8_t *port_numbers, int port_numbers_len);
LIBUSB_DEPRECATED_FOR(libusb_get_port_numbers)
-int LIBUSB_CALL libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t* path, uint8_t path_length);
+int LIBUSB_CALL libusb_get_port_path(libusb_context *ctx, libusb_device *dev, uint8_t *path, uint8_t path_length);
libusb_device * LIBUSB_CALL libusb_get_parent(libusb_device *dev);
uint8_t LIBUSB_CALL libusb_get_device_address(libusb_device *dev);
int LIBUSB_CALL libusb_get_device_speed(libusb_device *dev);
@@ -1463,7 +1490,7 @@ static inline unsigned char *libusb_control_transfer_get_data(
static inline struct libusb_control_setup *libusb_control_transfer_get_setup(
struct libusb_transfer *transfer)
{
- return (struct libusb_control_setup *)(void *) transfer->buffer;
+ return (struct libusb_control_setup *)(void *)transfer->buffer;
}
/** \ingroup libusb_asyncio
@@ -1493,7 +1520,7 @@ static inline void libusb_fill_control_setup(unsigned char *buffer,
uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex,
uint16_t wLength)
{
- struct libusb_control_setup *setup = (struct libusb_control_setup *)(void *) buffer;
+ struct libusb_control_setup *setup = (struct libusb_control_setup *)(void *)buffer;
setup->bmRequestType = bmRequestType;
setup->bRequest = bRequest;
setup->wValue = libusb_cpu_to_le16(wValue);
@@ -1543,7 +1570,7 @@ static inline void libusb_fill_control_transfer(
unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_data,
unsigned int timeout)
{
- struct libusb_control_setup *setup = (struct libusb_control_setup *)(void *) buffer;
+ struct libusb_control_setup *setup = (struct libusb_control_setup *)(void *)buffer;
transfer->dev_handle = dev_handle;
transfer->endpoint = 0;
transfer->type = LIBUSB_TRANSFER_TYPE_CONTROL;
@@ -1682,6 +1709,7 @@ static inline void libusb_set_iso_packet_lengths(
struct libusb_transfer *transfer, unsigned int length)
{
int i;
+
for (i = 0; i < transfer->num_iso_packets; i++)
transfer->iso_packet_desc[i].length = length;
}
@@ -1896,7 +1924,7 @@ void LIBUSB_CALL libusb_set_pollfd_notifiers(libusb_context *ctx,
* Callbacks handles are generated by libusb_hotplug_register_callback()
* and can be used to deregister callbacks. Callback handles are unique
* per libusb_context and it is safe to call libusb_hotplug_deregister_callback()
- * on an already deregisted callback.
+ * on an already deregistered callback.
*
* Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
*
@@ -1908,29 +1936,30 @@ typedef int libusb_hotplug_callback_handle;
*
* Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
*
- * Flags for hotplug events */
+ * Hotplug events */
typedef enum {
- /** Default value when not using any flags. */
- LIBUSB_HOTPLUG_NO_FLAGS = 0U,
+ /** A device has been plugged in and is ready to use */
+ LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED = (1 << 0),
- /** Arm the callback and fire it for all matching currently attached devices. */
- LIBUSB_HOTPLUG_ENUMERATE = 1U << 0,
-} libusb_hotplug_flag;
+ /** A device has left and is no longer available.
+ * It is the user's responsibility to call libusb_close on any handle associated with a disconnected device.
+ * It is safe to call libusb_get_device_descriptor on a device that has left */
+ LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT = (1 << 1)
+} libusb_hotplug_event;
/** \ingroup libusb_hotplug
*
* Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
*
- * Hotplug events */
+ * Hotplug flags */
typedef enum {
- /** A device has been plugged in and is ready to use */
- LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED = 0x01U,
+ /** Arm the callback and fire it for all matching currently attached devices. */
+ LIBUSB_HOTPLUG_ENUMERATE = (1 << 0)
+} libusb_hotplug_flag;
- /** A device has left and is no longer available.
- * It is the user's responsibility to call libusb_close on any handle associated with a disconnected device.
- * It is safe to call libusb_get_device_descriptor on a device that has left */
- LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT = 0x02U,
-} libusb_hotplug_event;
+/** \ingroup libusb_hotplug
+ * Convenience macro when not using any flags */
+#define LIBUSB_HOTPLUG_NO_FLAGS 0
/** \ingroup libusb_hotplug
* Wildcard matching for hotplug events */
@@ -1959,9 +1988,7 @@ typedef enum {
* returning 1 will cause this callback to be deregistered
*/
typedef int (LIBUSB_CALL *libusb_hotplug_callback_fn)(libusb_context *ctx,
- libusb_device *device,
- libusb_hotplug_event event,
- void *user_data);
+ libusb_device *device, libusb_hotplug_event event, void *user_data);
/** \ingroup libusb_hotplug
* Register a hotplug callback function
@@ -1986,9 +2013,10 @@ typedef int (LIBUSB_CALL *libusb_hotplug_callback_fn)(libusb_context *ctx,
* Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
*
* \param[in] ctx context to register this callback with
- * \param[in] events bitwise or of events that will trigger this callback. See \ref
- * libusb_hotplug_event
- * \param[in] flags hotplug callback flags. See \ref libusb_hotplug_flag
+ * \param[in] events bitwise or of hotplug events that will trigger this callback.
+ * See \ref libusb_hotplug_event
+ * \param[in] flags bitwise or of hotplug flags that affect registration.
+ * See \ref libusb_hotplug_flag
* \param[in] vendor_id the vendor id to match or \ref LIBUSB_HOTPLUG_MATCH_ANY
* \param[in] product_id the product id to match or \ref LIBUSB_HOTPLUG_MATCH_ANY
* \param[in] dev_class the device class to match or \ref LIBUSB_HOTPLUG_MATCH_ANY
@@ -1998,13 +2026,10 @@ typedef int (LIBUSB_CALL *libusb_hotplug_callback_fn)(libusb_context *ctx,
* \returns LIBUSB_SUCCESS on success LIBUSB_ERROR code on failure
*/
int LIBUSB_CALL libusb_hotplug_register_callback(libusb_context *ctx,
- libusb_hotplug_event events,
- libusb_hotplug_flag flags,
- int vendor_id, int product_id,
- int dev_class,
- libusb_hotplug_callback_fn cb_fn,
- void *user_data,
- libusb_hotplug_callback_handle *callback_handle);
+ int events, int flags,
+ int vendor_id, int product_id, int dev_class,
+ libusb_hotplug_callback_fn cb_fn, void *user_data,
+ libusb_hotplug_callback_handle *callback_handle);
/** \ingroup libusb_hotplug
* Deregisters a hotplug callback.
@@ -2018,7 +2043,18 @@ int LIBUSB_CALL libusb_hotplug_register_callback(libusb_context *ctx,
* \param[in] callback_handle the handle of the callback to deregister
*/
void LIBUSB_CALL libusb_hotplug_deregister_callback(libusb_context *ctx,
- libusb_hotplug_callback_handle callback_handle);
+ libusb_hotplug_callback_handle callback_handle);
+
+/** \ingroup libusb_hotplug
+ * Gets the user_data associated with a hotplug callback.
+ *
+ * Since version v1.0.24 \ref LIBUSB_API_VERSION >= 0x01000108
+ *
+ * \param[in] ctx context this callback is registered with
+ * \param[in] callback_handle the handle of the callback to get the user_data of
+ */
+void * LIBUSB_CALL libusb_hotplug_get_user_data(libusb_context *ctx,
+ libusb_hotplug_callback_handle callback_handle);
/** \ingroup libusb_lib
* Available option values for libusb_set_option().
@@ -2045,7 +2081,7 @@ enum libusb_option {
* If libusb was compiled with verbose debug message logging, this function
* does nothing: you'll always get messages from all levels.
*/
- LIBUSB_OPTION_LOG_LEVEL,
+ LIBUSB_OPTION_LOG_LEVEL = 0,
/** Use the UsbDk backend for a specific context, if available.
*
@@ -2054,12 +2090,23 @@ enum libusb_option {
*
* Only valid on Windows.
*/
- LIBUSB_OPTION_USE_USBDK,
+ LIBUSB_OPTION_USE_USBDK = 1,
+
+ /** Set libusb has weak authority. With this option, libusb will skip
+ * scan devices in libusb_init.
+ *
+ * This option should be set before calling libusb_init(), otherwise
+ * libusb_init will failed. Normally libusb_wrap_sys_device need set
+ * this option.
+ *
+ * Only valid on Linux-based operating system, such as Android.
+ */
+ LIBUSB_OPTION_WEAK_AUTHORITY = 2
};
int LIBUSB_CALL libusb_set_option(libusb_context *ctx, enum libusb_option option, ...);
-#ifdef __cplusplus
+#if defined(__cplusplus)
}
#endif
diff --git a/libusb/libusbi.h b/libusb/libusbi.h
index 0a677bd..491114b 100644
--- a/libusb/libusbi.h
+++ b/libusb/libusbi.h
@@ -3,7 +3,8 @@
* Copyright © 2007-2009 Daniel Drake <dsd@gentoo.org>
* Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
* Copyright © 2019 Nathan Hjelm <hjelmn@cs.umm.edu>
- * Copyright © 2019 Google LLC. All rights reserved.
+ * Copyright © 2019-2020 Google LLC. All rights reserved.
+ * Copyright © 2020 Chris Dickens <christopher.a.dickens@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -25,34 +26,70 @@
#include <config.h>
-#include <stdlib.h>
#include <assert.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <time.h>
+#include <inttypes.h>
#include <stdarg.h>
-#ifdef HAVE_POLL_H
-#include <poll.h>
-#endif
-#ifdef HAVE_MISSING_H
-#include <missing.h>
+#include <stddef.h>
+#include <stdlib.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
#endif
#include "libusb.h"
-#include "version.h"
-/* Attribute to ensure that a structure member is aligned to a natural
- * pointer alignment. Used for os_priv member. */
-#if defined(_MSC_VER)
-#if defined(_WIN64)
-#define PTR_ALIGNED __declspec(align(8))
+/* Not all C standard library headers define static_assert in assert.h
+ * Additionally, Visual Studio treats static_assert as a keyword.
+ */
+#if !defined(__cplusplus) && !defined(static_assert) && !defined(_MSC_VER)
+#define static_assert(cond, msg) _Static_assert(cond, msg)
+#endif
+
+#ifdef NDEBUG
+#define ASSERT_EQ(expression, value) (void)expression
+#define ASSERT_NE(expression, value) (void)expression
#else
-#define PTR_ALIGNED __declspec(align(4))
+#define ASSERT_EQ(expression, value) assert(expression == value)
+#define ASSERT_NE(expression, value) assert(expression != value)
+#endif
+
+#define container_of(ptr, type, member) \
+ ((type *)((uintptr_t)(ptr) - (uintptr_t)offsetof(type, member)))
+
+#ifndef ARRAYSIZE
+#define ARRAYSIZE(array) (sizeof(array) / sizeof(array[0]))
#endif
-#elif defined(__GNUC__) && (__GNUC__ >= 3)
-#define PTR_ALIGNED __attribute__((aligned(sizeof(void *))))
+
+#ifndef CLAMP
+#define CLAMP(val, min, max) \
+ ((val) < (min) ? (min) : ((val) > (max) ? (max) : (val)))
+#endif
+
+#ifndef MIN
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
+#ifndef MAX
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#endif
+
+/* The following is used to silence warnings for unused variables */
+#if defined(UNREFERENCED_PARAMETER)
+#define UNUSED(var) UNREFERENCED_PARAMETER(var)
#else
-#define PTR_ALIGNED
+#define UNUSED(var) do { (void)(var); } while(0)
+#endif
+
+/* Macro to align a value up to the next multiple of the size of a pointer */
+#define PTR_ALIGN(v) \
+ (((v) + (sizeof(void *) - 1)) & ~(sizeof(void *) - 1))
+
+/* Internal abstractions for event handling and thread synchronization */
+#if defined(PLATFORM_POSIX)
+#include "os/events_posix.h"
+#include "os/threads_posix.h"
+#elif defined(PLATFORM_WINDOWS)
+#include "os/events_windows.h"
+#include "os/threads_windows.h"
#endif
/* Inside the libusb code, mark all public functions as follows:
@@ -64,22 +101,10 @@
*/
#define API_EXPORTED LIBUSB_CALL DEFAULT_VISIBILITY
-/* Macro to decorate printf-like functions, in order to get
- * compiler warnings about format string mistakes.
- */
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
-#define USBI_PRINTFLIKE(formatarg, firstvararg) \
- __attribute__((__format__ (__printf__, formatarg, firstvararg)))
-#else
-#define USBI_PRINTFLIKE(formatarg, firstvararg)
-#endif
-
#ifdef __cplusplus
extern "C" {
#endif
-#define DEVICE_DESC_LENGTH 18
-
#define USB_MAXENDPOINTS 32
#define USB_MAXINTERFACES 32
#define USB_MAXCONFIG 8
@@ -93,13 +118,6 @@ extern "C" {
/* Terminator for log lines */
#define USBI_LOG_LINE_END "\n"
-/* The following is used to silence warnings for unused variables */
-#define UNUSED(var) do { (void)(var); } while(0)
-
-#if !defined(ARRAYSIZE)
-#define ARRAYSIZE(array) (sizeof(array) / sizeof(array[0]))
-#endif
-
struct list_head {
struct list_head *prev, *next;
};
@@ -110,11 +128,14 @@ struct list_head {
* member - the list_head element in "type"
*/
#define list_entry(ptr, type, member) \
- ((type *)((uintptr_t)(ptr) - (uintptr_t)offsetof(type, member)))
+ container_of(ptr, type, member)
#define list_first_entry(ptr, type, member) \
list_entry((ptr)->next, type, member)
+#define list_next_entry(ptr, type, member) \
+ list_entry((ptr)->member.next, type, member)
+
/* Get each entry from a list
* pos - A structure pointer has a "member" element
* head - list head
@@ -122,15 +143,24 @@ struct list_head {
* type - the type of the first parameter
*/
#define list_for_each_entry(pos, head, member, type) \
- for (pos = list_entry((head)->next, type, member); \
+ for (pos = list_first_entry(head, type, member); \
&pos->member != (head); \
- pos = list_entry(pos->member.next, type, member))
+ pos = list_next_entry(pos, type, member))
#define list_for_each_entry_safe(pos, n, head, member, type) \
- for (pos = list_entry((head)->next, type, member), \
- n = list_entry(pos->member.next, type, member); \
+ for (pos = list_first_entry(head, type, member), \
+ n = list_next_entry(pos, type, member); \
&pos->member != (head); \
- pos = n, n = list_entry(n->member.next, type, member))
+ pos = n, n = list_next_entry(n, type, member))
+
+/* Helper macros to iterate over a list. The structure pointed
+ * to by "pos" must have a list_head member named "list".
+ */
+#define for_each_helper(pos, head, type) \
+ list_for_each_entry(pos, head, list, type)
+
+#define for_each_safe_helper(pos, n, head, type) \
+ list_for_each_entry_safe(pos, n, head, list, type)
#define list_empty(entry) ((entry)->next == (entry))
@@ -167,8 +197,10 @@ static inline void list_del(struct list_head *entry)
static inline void list_cut(struct list_head *list, struct list_head *head)
{
- if (list_empty(head))
+ if (list_empty(head)) {
+ list_init(list);
return;
+ }
list->next = head->next;
list->next->prev = list;
@@ -178,31 +210,52 @@ static inline void list_cut(struct list_head *list, struct list_head *head)
list_init(head);
}
+static inline void list_splice_front(struct list_head *list, struct list_head *head)
+{
+ list->next->prev = head;
+ list->prev->next = head->next;
+ head->next->prev = list->prev;
+ head->next = list->next;
+}
+
static inline void *usbi_reallocf(void *ptr, size_t size)
{
void *ret = realloc(ptr, size);
+
if (!ret)
free(ptr);
return ret;
}
-#define container_of(ptr, type, member) ({ \
- const typeof( ((type *)0)->member ) *mptr = (ptr); \
- (type *)( (char *)mptr - offsetof(type,member) );})
-
-#ifndef CLAMP
-#define CLAMP(val, min, max) ((val) < (min) ? (min) : ((val) > (max) ? (max) : (val)))
-#endif
-#ifndef MIN
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#if !defined(USEC_PER_SEC)
+#define USEC_PER_SEC 1000000L
#endif
-#ifndef MAX
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
+
+#if !defined(NSEC_PER_SEC)
+#define NSEC_PER_SEC 1000000000L
#endif
-#define TIMESPEC_IS_SET(ts) ((ts)->tv_sec != 0 || (ts)->tv_nsec != 0)
+#define TIMEVAL_IS_VALID(tv) \
+ ((tv)->tv_sec >= 0 && \
+ (tv)->tv_usec >= 0 && (tv)->tv_usec < USEC_PER_SEC)
+
+#define TIMESPEC_IS_SET(ts) ((ts)->tv_sec || (ts)->tv_nsec)
+#define TIMESPEC_CLEAR(ts) (ts)->tv_sec = (ts)->tv_nsec = 0
+#define TIMESPEC_CMP(a, b, CMP) \
+ (((a)->tv_sec == (b)->tv_sec) \
+ ? ((a)->tv_nsec CMP (b)->tv_nsec) \
+ : ((a)->tv_sec CMP (b)->tv_sec))
+#define TIMESPEC_SUB(a, b, result) \
+ do { \
+ (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
+ (result)->tv_nsec = (a)->tv_nsec - (b)->tv_nsec; \
+ if ((result)->tv_nsec < 0L) { \
+ --(result)->tv_sec; \
+ (result)->tv_nsec += NSEC_PER_SEC; \
+ } \
+ } while (0)
-#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
+#if defined(PLATFORM_WINDOWS)
#define TIMEVAL_TV_SEC_TYPE long
#else
#define TIMEVAL_TV_SEC_TYPE time_t
@@ -213,94 +266,51 @@ static inline void *usbi_reallocf(void *ptr, size_t size)
#define TIMESPEC_TO_TIMEVAL(tv, ts) \
do { \
(tv)->tv_sec = (TIMEVAL_TV_SEC_TYPE) (ts)->tv_sec; \
- (tv)->tv_usec = (ts)->tv_nsec / 1000; \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000L; \
} while (0)
#endif
#ifdef ENABLE_LOGGING
#if defined(_MSC_VER) && (_MSC_VER < 1900)
+#include <stdio.h>
#define snprintf usbi_snprintf
#define vsnprintf usbi_vsnprintf
int usbi_snprintf(char *dst, size_t size, const char *format, ...);
-int usbi_vsnprintf(char *dst, size_t size, const char *format, va_list ap);
+int usbi_vsnprintf(char *dst, size_t size, const char *format, va_list args);
#define LIBUSB_PRINTF_WIN32
#endif /* defined(_MSC_VER) && (_MSC_VER < 1900) */
void usbi_log(struct libusb_context *ctx, enum libusb_log_level level,
- const char *function, const char *format, ...) USBI_PRINTFLIKE(4, 5);
-
-void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
- const char *function, const char *format, va_list args) USBI_PRINTFLIKE(4, 0);
+ const char *function, const char *format, ...) PRINTF_FORMAT(4, 5);
-#if !defined(_MSC_VER) || (_MSC_VER >= 1400)
+#define _usbi_log(ctx, level, ...) usbi_log(ctx, level, __func__, __VA_ARGS__)
-#define _usbi_log(ctx, level, ...) usbi_log(ctx, level, __FUNCTION__, __VA_ARGS__)
-
-#define usbi_err(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_ERROR, __VA_ARGS__)
-#define usbi_warn(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_WARNING, __VA_ARGS__)
-#define usbi_info(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_INFO, __VA_ARGS__)
-#define usbi_dbg(...) _usbi_log(NULL, LIBUSB_LOG_LEVEL_DEBUG, __VA_ARGS__)
-
-#else /* !defined(_MSC_VER) || (_MSC_VER >= 1400) */
-
-#define LOG_BODY(ctxt, level) \
-{ \
- va_list args; \
- va_start(args, format); \
- usbi_log_v(ctxt, level, "", format, args); \
- va_end(args); \
-}
-
-static inline void usbi_err(struct libusb_context *ctx, const char *format, ...)
- LOG_BODY(ctx, LIBUSB_LOG_LEVEL_ERROR)
-static inline void usbi_warn(struct libusb_context *ctx, const char *format, ...)
- LOG_BODY(ctx, LIBUSB_LOG_LEVEL_WARNING)
-static inline void usbi_info(struct libusb_context *ctx, const char *format, ...)
- LOG_BODY(ctx, LIBUSB_LOG_LEVEL_INFO)
-static inline void usbi_dbg(const char *format, ...)
- LOG_BODY(NULL, LIBUSB_LOG_LEVEL_DEBUG)
-
-#endif /* !defined(_MSC_VER) || (_MSC_VER >= 1400) */
+#define usbi_err(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_ERROR, __VA_ARGS__)
+#define usbi_warn(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_WARNING, __VA_ARGS__)
+#define usbi_info(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_INFO, __VA_ARGS__)
+#define usbi_dbg(...) _usbi_log(NULL, LIBUSB_LOG_LEVEL_DEBUG, __VA_ARGS__)
#else /* ENABLE_LOGGING */
-#define usbi_err(ctx, ...) do { (void)ctx; } while (0)
-#define usbi_warn(ctx, ...) do { (void)ctx; } while (0)
-#define usbi_info(ctx, ...) do { (void)ctx; } while (0)
-#define usbi_dbg(...) do {} while (0)
+#define usbi_err(ctx, ...) UNUSED(ctx)
+#define usbi_warn(ctx, ...) UNUSED(ctx)
+#define usbi_info(ctx, ...) UNUSED(ctx)
+#define usbi_dbg(...) do {} while (0)
#endif /* ENABLE_LOGGING */
-#define USBI_GET_CONTEXT(ctx) \
- do { \
- if (!(ctx)) \
- (ctx) = usbi_default_context; \
- } while(0)
-
#define DEVICE_CTX(dev) ((dev)->ctx)
#define HANDLE_CTX(handle) (DEVICE_CTX((handle)->dev))
#define TRANSFER_CTX(transfer) (HANDLE_CTX((transfer)->dev_handle))
-#define ITRANSFER_CTX(transfer) \
- (TRANSFER_CTX(USBI_TRANSFER_TO_LIBUSB_TRANSFER(transfer)))
+#define ITRANSFER_CTX(itransfer) \
+ (TRANSFER_CTX(USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer)))
#define IS_EPIN(ep) (0 != ((ep) & LIBUSB_ENDPOINT_IN))
#define IS_EPOUT(ep) (!IS_EPIN(ep))
#define IS_XFERIN(xfer) (0 != ((xfer)->endpoint & LIBUSB_ENDPOINT_IN))
#define IS_XFEROUT(xfer) (!IS_XFERIN(xfer))
-/* Internal abstraction for thread synchronization */
-#if defined(THREADS_POSIX)
-#include "os/threads_posix.h"
-#elif defined(OS_WINDOWS) || defined(OS_WINCE)
-#include "os/threads_windows.h"
-#endif
-
-extern struct libusb_context *usbi_default_context;
-
-/* Forward declaration for use in context (fully defined inside poll abstraction) */
-struct pollfd;
-
struct libusb_context {
#if defined(ENABLE_LOGGING) && !defined(ENABLE_DEBUG_LOGGING)
enum libusb_log_level debug;
@@ -308,8 +318,14 @@ struct libusb_context {
libusb_log_cb log_handler;
#endif
- /* internal event pipe, used for signalling occurrence of an internal event. */
- int event_pipe[2];
+ /* used for signalling occurrence of an internal event. */
+ usbi_event_t event;
+
+#ifdef HAVE_OS_TIMER
+ /* used for timeout handling, if supported by OS.
+ * this timer is maintained to trigger on the next pending timeout */
+ usbi_timer_t timer;
+#endif
struct list_head usb_devs;
usbi_mutex_t usb_devs_lock;
@@ -333,10 +349,12 @@ struct libusb_context {
* take this lock first */
usbi_mutex_t flying_transfers_lock;
+#if !defined(PLATFORM_WINDOWS)
/* user callbacks for pollfd changes */
libusb_pollfd_added_cb fd_added_cb;
libusb_pollfd_removed_cb fd_removed_cb;
void *fd_cb_user_data;
+#endif
/* ensures that only one thread is handling events at any one time */
usbi_mutex_t events_lock;
@@ -364,14 +382,17 @@ struct libusb_context {
* in order to safely close a device. Protected by event_data_lock. */
unsigned int device_close;
- /* list and count of poll fds and an array of poll fd structures that is
- * (re)allocated as necessary prior to polling. Protected by event_data_lock. */
- struct list_head ipollfds;
- /* list of pollfds that have been removed. keeps track of pollfd changes
- * between the poll call and */
- struct list_head removed_ipollfds;
- struct pollfd *pollfds;
- POLL_NFDS_TYPE pollfds_cnt;
+ /* A list of currently active event sources. Protected by event_data_lock. */
+ struct list_head event_sources;
+
+ /* A list of event sources that have been removed since the last time
+ * event sources were waited on. Protected by event_data_lock. */
+ struct list_head removed_event_sources;
+
+ /* A pointer and count to platform-specific data used for monitoring event
+ * sources. Only accessed during event handling. */
+ void *event_data;
+ unsigned int event_data_cnt;
/* A list of pending hotplug messages. Protected by event_data_lock. */
struct list_head hotplug_msgs;
@@ -379,48 +400,54 @@ struct libusb_context {
/* A list of pending completed transfers. Protected by event_data_lock. */
struct list_head completed_transfers;
-#ifdef USBI_TIMERFD_AVAILABLE
- /* used for timeout handling, if supported by OS.
- * this timerfd is maintained to trigger on the next pending timeout */
- int timerfd;
-#endif
-
struct list_head list;
-
- PTR_ALIGNED unsigned char os_priv[ZERO_SIZED_ARRAY];
};
+extern struct libusb_context *usbi_default_context;
+
+extern struct list_head active_contexts_list;
+extern usbi_mutex_static_t active_contexts_lock;
+
+static inline struct libusb_context *usbi_get_context(struct libusb_context *ctx)
+{
+ return ctx ? ctx : usbi_default_context;
+}
+
enum usbi_event_flags {
- /* The list of pollfds has been modified */
- USBI_EVENT_POLLFDS_MODIFIED = 1U << 0,
+ /* The list of event sources has been modified */
+ USBI_EVENT_EVENT_SOURCES_MODIFIED = 1U << 0,
/* The user has interrupted the event handler */
USBI_EVENT_USER_INTERRUPT = 1U << 1,
/* A hotplug callback deregistration is pending */
USBI_EVENT_HOTPLUG_CB_DEREGISTERED = 1U << 2,
-};
-/* Macros for managing event handling state */
-#define usbi_handling_events(ctx) \
- (usbi_tls_key_get((ctx)->event_handling_key) != NULL)
+ /* One or more hotplug messages are pending */
+ USBI_EVENT_HOTPLUG_MSG_PENDING = 1U << 3,
+
+ /* One or more completed transfers are pending */
+ USBI_EVENT_TRANSFER_COMPLETED = 1U << 4,
-#define usbi_start_event_handling(ctx) \
- usbi_tls_key_set((ctx)->event_handling_key, ctx)
+ /* A device is in the process of being closed */
+ USBI_EVENT_DEVICE_CLOSE = 1U << 5,
+};
-#define usbi_end_event_handling(ctx) \
- usbi_tls_key_set((ctx)->event_handling_key, NULL)
+/* Macros for managing event handling state */
+static inline int usbi_handling_events(struct libusb_context *ctx)
+{
+ return usbi_tls_key_get(ctx->event_handling_key) != NULL;
+}
-/* Update the following macro if new event sources are added */
-#define usbi_pending_events(ctx) \
- ((ctx)->event_flags || (ctx)->device_close \
- || !list_empty(&(ctx)->hotplug_msgs) || !list_empty(&(ctx)->completed_transfers))
+static inline void usbi_start_event_handling(struct libusb_context *ctx)
+{
+ usbi_tls_key_set(ctx->event_handling_key, ctx);
+}
-#ifdef USBI_TIMERFD_AVAILABLE
-#define usbi_using_timerfd(ctx) ((ctx)->timerfd >= 0)
-#else
-#define usbi_using_timerfd(ctx) (0)
-#endif
+static inline void usbi_end_event_handling(struct libusb_context *ctx)
+{
+ usbi_tls_key_set(ctx->event_handling_key, NULL);
+}
struct libusb_device {
/* lock protects refcnt, everything else is finalized at initialization
@@ -429,12 +456,11 @@ struct libusb_device {
int refcnt;
struct libusb_context *ctx;
+ struct libusb_device *parent_dev;
uint8_t bus_number;
uint8_t port_number;
- struct libusb_device* parent_dev;
uint8_t device_address;
- uint8_t num_configurations;
enum libusb_speed speed;
struct list_head list;
@@ -442,8 +468,6 @@ struct libusb_device {
struct libusb_device_descriptor device_descriptor;
int attached;
-
- PTR_ALIGNED unsigned char os_priv[ZERO_SIZED_ARRAY];
};
struct libusb_device_handle {
@@ -454,37 +478,61 @@ struct libusb_device_handle {
struct list_head list;
struct libusb_device *dev;
int auto_detach_kernel_driver;
-
- PTR_ALIGNED unsigned char os_priv[ZERO_SIZED_ARRAY];
};
-enum {
- USBI_CLOCK_MONOTONIC,
- USBI_CLOCK_REALTIME
-};
+/* Function called by backend during device initialization to convert
+ * multi-byte fields in the device descriptor to host-endian format.
+ */
+static inline void usbi_localize_device_descriptor(struct libusb_device_descriptor *desc)
+{
+ desc->bcdUSB = libusb_le16_to_cpu(desc->bcdUSB);
+ desc->idVendor = libusb_le16_to_cpu(desc->idVendor);
+ desc->idProduct = libusb_le16_to_cpu(desc->idProduct);
+ desc->bcdDevice = libusb_le16_to_cpu(desc->bcdDevice);
+}
+
+#ifdef HAVE_CLOCK_GETTIME
+static inline void usbi_get_monotonic_time(struct timespec *tp)
+{
+ ASSERT_EQ(clock_gettime(CLOCK_MONOTONIC, tp), 0);
+}
+static inline void usbi_get_real_time(struct timespec *tp)
+{
+ ASSERT_EQ(clock_gettime(CLOCK_REALTIME, tp), 0);
+}
+#else
+/* If the platform doesn't provide the clock_gettime() function, the backend
+ * must provide its own clock implementations. Two clock functions are
+ * required:
+ *
+ * usbi_get_monotonic_time(): returns the time since an unspecified starting
+ * point (usually boot) that is monotonically
+ * increasing.
+ * usbi_get_real_time(): returns the time since system epoch.
+ */
+void usbi_get_monotonic_time(struct timespec *tp);
+void usbi_get_real_time(struct timespec *tp);
+#endif
/* in-memory transfer layout:
*
- * 1. struct usbi_transfer
- * 2. struct libusb_transfer (which includes iso packets) [variable size]
- * 3. os private data [variable size]
+ * 1. os private data
+ * 2. struct usbi_transfer
+ * 3. struct libusb_transfer (which includes iso packets) [variable size]
*
* from a libusb_transfer, you can get the usbi_transfer by rewinding the
* appropriate number of bytes.
- * the usbi_transfer includes the number of allocated packets, so you can
- * determine the size of the transfer and hence the start and length of the
- * OS-private data.
*/
struct usbi_transfer {
int num_iso_packets;
struct list_head list;
struct list_head completed_list;
- struct timeval timeout;
+ struct timespec timeout;
int transferred;
uint32_t stream_id;
- uint8_t state_flags; /* Protected by usbi_transfer->lock */
- uint8_t timeout_flags; /* Protected by the flying_stransfers_lock */
+ uint32_t state_flags; /* Protected by usbi_transfer->lock */
+ uint32_t timeout_flags; /* Protected by the flying_stransfers_lock */
/* this lock is held during libusb_submit_transfer() and
* libusb_cancel_transfer() (allowing the OS backend to prevent duplicate
@@ -496,6 +544,8 @@ struct usbi_transfer {
* Note paths taking both this and the flying_transfers_lock must
* always take the flying_transfers_lock first */
usbi_mutex_t lock;
+
+ void *priv;
};
enum usbi_transfer_state_flags {
@@ -520,28 +570,98 @@ enum usbi_transfer_timeout_flags {
USBI_TRANSFER_TIMED_OUT = 1U << 2,
};
-#define USBI_TRANSFER_TO_LIBUSB_TRANSFER(transfer) \
- ((struct libusb_transfer *)(((unsigned char *)(transfer)) \
- + sizeof(struct usbi_transfer)))
-#define LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer) \
- ((struct usbi_transfer *)(((unsigned char *)(transfer)) \
- - sizeof(struct usbi_transfer)))
+#define USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer) \
+ ((struct libusb_transfer *) \
+ ((unsigned char *)(itransfer) \
+ + PTR_ALIGN(sizeof(struct usbi_transfer))))
+#define LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer) \
+ ((struct usbi_transfer *) \
+ ((unsigned char *)(transfer) \
+ - PTR_ALIGN(sizeof(struct usbi_transfer))))
+
+#ifdef _MSC_VER
+#pragma pack(push, 1)
+#endif
-static inline void *usbi_transfer_get_os_priv(struct usbi_transfer *transfer)
-{
- assert(transfer->num_iso_packets >= 0);
- return ((unsigned char *)transfer) + sizeof(struct usbi_transfer)
- + sizeof(struct libusb_transfer)
- + ((size_t)transfer->num_iso_packets
- * sizeof(struct libusb_iso_packet_descriptor));
-}
+/* All standard descriptors have these 2 fields in common */
+struct usbi_descriptor_header {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+} LIBUSB_PACKED;
+
+struct usbi_device_descriptor {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ uint16_t bcdUSB;
+ uint8_t bDeviceClass;
+ uint8_t bDeviceSubClass;
+ uint8_t bDeviceProtocol;
+ uint8_t bMaxPacketSize0;
+ uint16_t idVendor;
+ uint16_t idProduct;
+ uint16_t bcdDevice;
+ uint8_t iManufacturer;
+ uint8_t iProduct;
+ uint8_t iSerialNumber;
+ uint8_t bNumConfigurations;
+} LIBUSB_PACKED;
+
+struct usbi_configuration_descriptor {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ uint16_t wTotalLength;
+ uint8_t bNumInterfaces;
+ uint8_t bConfigurationValue;
+ uint8_t iConfiguration;
+ uint8_t bmAttributes;
+ uint8_t bMaxPower;
+} LIBUSB_PACKED;
+
+struct usbi_interface_descriptor {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ uint8_t bInterfaceNumber;
+ uint8_t bAlternateSetting;
+ uint8_t bNumEndpoints;
+ uint8_t bInterfaceClass;
+ uint8_t bInterfaceSubClass;
+ uint8_t bInterfaceProtocol;
+ uint8_t iInterface;
+} LIBUSB_PACKED;
+
+struct usbi_string_descriptor {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ uint16_t wData[ZERO_SIZED_ARRAY];
+} LIBUSB_PACKED;
+
+struct usbi_bos_descriptor {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ uint16_t wTotalLength;
+ uint8_t bNumDeviceCaps;
+} LIBUSB_PACKED;
+
+#ifdef _MSC_VER
+#pragma pack(pop)
+#endif
+
+union usbi_config_desc_buf {
+ struct usbi_configuration_descriptor desc;
+ uint8_t buf[LIBUSB_DT_CONFIG_SIZE];
+ uint16_t align; /* Force 2-byte alignment */
+};
-/* bus structures */
+union usbi_string_desc_buf {
+ struct usbi_string_descriptor desc;
+ uint8_t buf[255]; /* Some devices choke on size > 255 */
+ uint16_t align; /* Force 2-byte alignment */
+};
-/* All standard descriptors have these 2 fields in common */
-struct usb_descriptor_header {
- uint8_t bLength;
- uint8_t bDescriptorType;
+union usbi_bos_desc_buf {
+ struct usbi_bos_descriptor desc;
+ uint8_t buf[LIBUSB_DT_BOS_SIZE];
+ uint16_t align; /* Force 2-byte alignment */
};
/* shared data and functions */
@@ -558,39 +678,88 @@ void usbi_handle_disconnect(struct libusb_device_handle *dev_handle);
int usbi_handle_transfer_completion(struct usbi_transfer *itransfer,
enum libusb_transfer_status status);
-int usbi_handle_transfer_cancellation(struct usbi_transfer *transfer);
-void usbi_signal_transfer_completion(struct usbi_transfer *transfer);
-
-int usbi_parse_descriptor(const unsigned char *source, const char *descriptor,
- void *dest, int host_endian);
-int usbi_device_cache_descriptor(libusb_device *dev);
-int usbi_get_config_index_by_value(struct libusb_device *dev,
- uint8_t bConfigurationValue, int *idx);
-
-void usbi_connect_device (struct libusb_device *dev);
-void usbi_disconnect_device (struct libusb_device *dev);
-
-int usbi_signal_event(struct libusb_context *ctx);
-int usbi_clear_event(struct libusb_context *ctx);
-
-/* Internal abstraction for poll (needs struct usbi_transfer on Windows) */
-#if defined(OS_LINUX) || defined(OS_DARWIN) || defined(OS_OPENBSD) || defined(OS_NETBSD) ||\
- defined(OS_HAIKU) || defined(OS_SUNOS)
-#include <unistd.h>
-#include "os/poll_posix.h"
-#elif defined(OS_WINDOWS) || defined(OS_WINCE)
-#include "os/poll_windows.h"
-#endif
+int usbi_handle_transfer_cancellation(struct usbi_transfer *itransfer);
+void usbi_signal_transfer_completion(struct usbi_transfer *itransfer);
-struct usbi_pollfd {
- /* must come first */
- struct libusb_pollfd pollfd;
+void usbi_connect_device(struct libusb_device *dev);
+void usbi_disconnect_device(struct libusb_device *dev);
+struct usbi_event_source {
+ struct usbi_event_source_data {
+ usbi_os_handle_t os_handle;
+ short poll_events;
+ } data;
struct list_head list;
};
-int usbi_add_pollfd(struct libusb_context *ctx, int fd, short events);
-void usbi_remove_pollfd(struct libusb_context *ctx, int fd);
+int usbi_add_event_source(struct libusb_context *ctx, usbi_os_handle_t os_handle,
+ short poll_events);
+void usbi_remove_event_source(struct libusb_context *ctx, usbi_os_handle_t os_handle);
+
+/* OS event abstraction */
+
+int usbi_create_event(usbi_event_t *event);
+void usbi_destroy_event(usbi_event_t *event);
+void usbi_signal_event(usbi_event_t *event);
+void usbi_clear_event(usbi_event_t *event);
+
+#ifdef HAVE_OS_TIMER
+int usbi_create_timer(usbi_timer_t *timer);
+void usbi_destroy_timer(usbi_timer_t *timer);
+int usbi_arm_timer(usbi_timer_t *timer, const struct timespec *timeout);
+int usbi_disarm_timer(usbi_timer_t *timer);
+#endif
+
+static inline int usbi_using_timer(struct libusb_context *ctx)
+{
+#ifdef HAVE_OS_TIMER
+ return usbi_timer_valid(&ctx->timer);
+#else
+ UNUSED(ctx);
+ return 0;
+#endif
+}
+
+struct usbi_reported_events {
+ union {
+ struct {
+ unsigned int event_triggered:1;
+#ifdef HAVE_OS_TIMER
+ unsigned int timer_triggered:1;
+#endif
+ };
+ unsigned int event_bits;
+ };
+ void *event_data;
+ unsigned int event_data_count;
+ unsigned int num_ready;
+};
+
+int usbi_alloc_event_data(struct libusb_context *ctx);
+int usbi_wait_for_events(struct libusb_context *ctx,
+ struct usbi_reported_events *reported_events, int timeout_ms);
+
+/* accessor functions for structure private data */
+
+static inline void *usbi_get_context_priv(struct libusb_context *ctx)
+{
+ return (unsigned char *)ctx + PTR_ALIGN(sizeof(*ctx));
+}
+
+static inline void *usbi_get_device_priv(struct libusb_device *dev)
+{
+ return (unsigned char *)dev + PTR_ALIGN(sizeof(*dev));
+}
+
+static inline void *usbi_get_device_handle_priv(struct libusb_device_handle *dev_handle)
+{
+ return (unsigned char *)dev_handle + PTR_ALIGN(sizeof(*dev_handle));
+}
+
+static inline void *usbi_get_transfer_priv(struct usbi_transfer *itransfer)
+{
+ return itransfer->priv;
+}
/* device discovery */
@@ -725,7 +894,7 @@ struct usbi_os_backend {
* and other operations so that those operations can happen (hopefully)
* without hiccup. This is also a good place to inform libusb that it
* should monitor certain file descriptors related to this device -
- * see the usbi_add_pollfd() function.
+ * see the usbi_add_event_source() function.
*
* Your backend should also initialize the device structure
* (dev_handle->dev), which is NULL at the beginning of the call.
@@ -754,7 +923,7 @@ struct usbi_os_backend {
* and other operations so that those operations can happen (hopefully)
* without hiccup. This is also a good place to inform libusb that it
* should monitor certain file descriptors related to this device -
- * see the usbi_add_pollfd() function.
+ * see the usbi_add_event_source() function.
*
* This function should not generate any bus I/O and should not block.
*
@@ -775,38 +944,14 @@ struct usbi_os_backend {
/* Close a device such that the handle cannot be used again. Your backend
* should destroy any resources that were allocated in the open path.
- * This may also be a good place to call usbi_remove_pollfd() to inform
- * libusb of any file descriptors associated with this device that should
- * no longer be monitored.
+ * This may also be a good place to call usbi_remove_event_source() to
+ * inform libusb of any event sources associated with this device that
+ * should no longer be monitored.
*
* This function is called when the user closes a device handle.
*/
void (*close)(struct libusb_device_handle *dev_handle);
- /* Retrieve the device descriptor from a device.
- *
- * The descriptor should be retrieved from memory, NOT via bus I/O to the
- * device. This means that you may have to cache it in a private structure
- * during get_device_list enumeration. Alternatively, you may be able
- * to retrieve it from a kernel interface (some Linux setups can do this)
- * still without generating bus I/O.
- *
- * This function is expected to write DEVICE_DESC_LENGTH (18) bytes into
- * buffer, which is guaranteed to be big enough.
- *
- * This function is called when sanity-checking a device before adding
- * it to the list of discovered devices, and also when the user requests
- * to read the device descriptor.
- *
- * This function is expected to return the descriptor in bus-endian format
- * (LE). If it returns the multi-byte values in host-endian format,
- * set the host_endian output parameter to "1".
- *
- * Return 0 on success or a LIBUSB_ERROR code on failure.
- */
- int (*get_device_descriptor)(struct libusb_device *device,
- unsigned char *buffer, int *host_endian);
-
/* Get the ACTIVE configuration descriptor for a device.
*
* The descriptor should be retrieved from memory, NOT via bus I/O to the
@@ -819,8 +964,7 @@ struct usbi_os_backend {
* return an error code.
*
* This function is expected to return the descriptor in bus-endian format
- * (LE). If it returns the multi-byte values in host-endian format,
- * set the host_endian output parameter to "1".
+ * (LE).
*
* Return:
* - 0 on success
@@ -828,7 +972,7 @@ struct usbi_os_backend {
* - another LIBUSB_ERROR code on other failure
*/
int (*get_active_config_descriptor)(struct libusb_device *device,
- unsigned char *buffer, size_t len, int *host_endian);
+ void *buffer, size_t len);
/* Get a specific configuration descriptor for a device.
*
@@ -846,14 +990,12 @@ struct usbi_os_backend {
* return an error code.
*
* This function is expected to return the descriptor in bus-endian format
- * (LE). If it returns the multi-byte values in host-endian format,
- * set the host_endian output parameter to "1".
+ * (LE).
*
* Return the length read on success or a LIBUSB_ERROR code on failure.
*/
int (*get_config_descriptor)(struct libusb_device *device,
- uint8_t config_index, unsigned char *buffer, size_t len,
- int *host_endian);
+ uint8_t config_index, void *buffer, size_t len);
/* Like get_config_descriptor but then by bConfigurationValue instead
* of by index.
@@ -868,8 +1010,7 @@ struct usbi_os_backend {
* or a LIBUSB_ERROR code on failure.
*/
int (*get_config_descriptor_by_value)(struct libusb_device *device,
- uint8_t bConfigurationValue, unsigned char **buffer,
- int *host_endian);
+ uint8_t bConfigurationValue, void **buffer);
/* Get the bConfigurationValue for the active configuration for a device.
* Optional. This should only be implemented if you can retrieve it from
@@ -888,7 +1029,7 @@ struct usbi_os_backend {
* blocking
* - another LIBUSB_ERROR code on other failure.
*/
- int (*get_configuration)(struct libusb_device_handle *dev_handle, int *config);
+ int (*get_configuration)(struct libusb_device_handle *dev_handle, uint8_t *config);
/* Set the active configuration for a device.
*
@@ -924,7 +1065,7 @@ struct usbi_os_backend {
* was opened
* - another LIBUSB_ERROR code on other failure
*/
- int (*claim_interface)(struct libusb_device_handle *dev_handle, int interface_number);
+ int (*claim_interface)(struct libusb_device_handle *dev_handle, uint8_t interface_number);
/* Release a previously claimed interface.
*
@@ -941,7 +1082,7 @@ struct usbi_os_backend {
* was opened
* - another LIBUSB_ERROR code on other failure
*/
- int (*release_interface)(struct libusb_device_handle *dev_handle, int interface_number);
+ int (*release_interface)(struct libusb_device_handle *dev_handle, uint8_t interface_number);
/* Set the alternate setting for an interface.
*
@@ -958,7 +1099,7 @@ struct usbi_os_backend {
* - another LIBUSB_ERROR code on other failure
*/
int (*set_interface_altsetting)(struct libusb_device_handle *dev_handle,
- int interface_number, int altsetting);
+ uint8_t interface_number, uint8_t altsetting);
/* Clear a halt/stall condition on an endpoint.
*
@@ -974,13 +1115,13 @@ struct usbi_os_backend {
int (*clear_halt)(struct libusb_device_handle *dev_handle,
unsigned char endpoint);
- /* Perform a USB port reset to reinitialize a device.
+ /* Perform a USB port reset to reinitialize a device. Optional.
*
* If possible, the device handle should still be usable after the reset
* completes, assuming that the device descriptors did not change during
* reset and all previous interface state can be restored.
*
- * If something changes, or you cannot easily locate/verify the resetted
+ * If something changes, or you cannot easily locate/verify the reset
* device, return LIBUSB_ERROR_NOT_FOUND. This prompts the application
* to close the old handle and re-enumerate the device.
*
@@ -1003,12 +1144,11 @@ struct usbi_os_backend {
/* Allocate persistent DMA memory for the given device, suitable for
* zerocopy. May return NULL on failure. Optional to implement.
*/
- unsigned char *(*dev_mem_alloc)(struct libusb_device_handle *handle,
- size_t len);
+ void *(*dev_mem_alloc)(struct libusb_device_handle *handle, size_t len);
/* Free memory allocated by dev_mem_alloc. */
- int (*dev_mem_free)(struct libusb_device_handle *handle,
- unsigned char *buffer, size_t len);
+ int (*dev_mem_free)(struct libusb_device_handle *handle, void *buffer,
+ size_t len);
/* Determine if a kernel driver is active on an interface. Optional.
*
@@ -1023,7 +1163,7 @@ struct usbi_os_backend {
* - another LIBUSB_ERROR code on other failure
*/
int (*kernel_driver_active)(struct libusb_device_handle *dev_handle,
- int interface_number);
+ uint8_t interface_number);
/* Detach a kernel driver from an interface. Optional.
*
@@ -1039,7 +1179,7 @@ struct usbi_os_backend {
* - another LIBUSB_ERROR code on other failure
*/
int (*detach_kernel_driver)(struct libusb_device_handle *dev_handle,
- int interface_number);
+ uint8_t interface_number);
/* Attach a kernel driver to an interface. Optional.
*
@@ -1056,7 +1196,7 @@ struct usbi_os_backend {
* - another LIBUSB_ERROR code on other failure
*/
int (*attach_kernel_driver)(struct libusb_device_handle *dev_handle,
- int interface_number);
+ uint8_t interface_number);
/* Destroy a device. Optional.
*
@@ -1101,21 +1241,22 @@ struct usbi_os_backend {
*/
void (*clear_transfer_priv)(struct usbi_transfer *itransfer);
- /* Handle any pending events on file descriptors. Optional.
+ /* Handle any pending events on event sources. Optional.
*
- * Provide this function when file descriptors directly indicate device
- * or transfer activity. If your backend does not have such file descriptors,
+ * Provide this function when event sources directly indicate device
+ * or transfer activity. If your backend does not have such event sources,
* implement the handle_transfer_completion function below.
*
* This involves monitoring any active transfers and processing their
* completion or cancellation.
*
- * The function is passed an array of pollfd structures (size nfds)
- * as a result of the poll() system call. The num_ready parameter
- * indicates the number of file descriptors that have reported events
- * (i.e. the poll() return value). This should be enough information
- * for you to determine which actions need to be taken on the currently
- * active transfers.
+ * The function is passed a pointer that represents platform-specific
+ * data for monitoring event sources (size count). This data is to be
+ * (re)allocated as necessary when event sources are modified.
+ * The num_ready parameter indicates the number of event sources that
+ * have reported events. This should be enough information for you to
+ * determine which actions need to be taken on the currently active
+ * transfers.
*
* For any cancelled transfers, call usbi_handle_transfer_cancellation().
* For completed transfers, call usbi_handle_transfer_completion().
@@ -1134,13 +1275,13 @@ struct usbi_os_backend {
* Return 0 on success, or a LIBUSB_ERROR code on failure.
*/
int (*handle_events)(struct libusb_context *ctx,
- struct pollfd *fds, POLL_NFDS_TYPE nfds, int num_ready);
+ void *event_data, unsigned int count, unsigned int num_ready);
/* Handle transfer completion. Optional.
*
- * Provide this function when there are no file descriptors available
- * that directly indicate device or transfer activity. If your backend does
- * have such file descriptors, implement the handle_events function above.
+ * Provide this function when there are no event sources available that
+ * directly indicate device or transfer activity. If your backend does
+ * have such event sources, implement the handle_events function above.
*
* Your backend must tell the library when a transfer has completed by
* calling usbi_signal_transfer_completion(). You should store any private
@@ -1161,47 +1302,68 @@ struct usbi_os_backend {
*/
int (*handle_transfer_completion)(struct usbi_transfer *itransfer);
- /* Get time from specified clock. At least two clocks must be implemented
- by the backend: USBI_CLOCK_REALTIME, and USBI_CLOCK_MONOTONIC.
-
- Description of clocks:
- USBI_CLOCK_REALTIME : clock returns time since system epoch.
- USBI_CLOCK_MONOTONIC: clock returns time since unspecified start
- time (usually boot).
- */
- int (*clock_gettime)(int clkid, struct timespec *tp);
-
-#ifdef USBI_TIMERFD_AVAILABLE
- /* clock ID of the clock that should be used for timerfd */
- clockid_t (*get_timerfd_clockid)(void);
-#endif
-
/* Number of bytes to reserve for per-context private backend data.
- * This private data area is accessible through the "os_priv" field of
- * struct libusb_context. */
+ * This private data area is accessible by calling
+ * usbi_get_context_priv() on the libusb_context instance.
+ */
size_t context_priv_size;
/* Number of bytes to reserve for per-device private backend data.
- * This private data area is accessible through the "os_priv" field of
- * struct libusb_device. */
+ * This private data area is accessible by calling
+ * usbi_get_device_priv() on the libusb_device instance.
+ */
size_t device_priv_size;
/* Number of bytes to reserve for per-handle private backend data.
- * This private data area is accessible through the "os_priv" field of
- * struct libusb_device. */
+ * This private data area is accessible by calling
+ * usbi_get_device_handle_priv() on the libusb_device_handle instance.
+ */
size_t device_handle_priv_size;
/* Number of bytes to reserve for per-transfer private backend data.
* This private data area is accessible by calling
- * usbi_transfer_get_os_priv() on the appropriate usbi_transfer instance.
+ * usbi_get_transfer_priv() on the usbi_transfer instance.
*/
size_t transfer_priv_size;
};
extern const struct usbi_os_backend usbi_backend;
-extern struct list_head active_contexts_list;
-extern usbi_mutex_static_t active_contexts_lock;
+#define for_each_context(c) \
+ for_each_helper(c, &active_contexts_list, struct libusb_context)
+
+#define for_each_device(ctx, d) \
+ for_each_helper(d, &(ctx)->usb_devs, struct libusb_device)
+
+#define for_each_device_safe(ctx, d, n) \
+ for_each_safe_helper(d, n, &(ctx)->usb_devs, struct libusb_device)
+
+#define for_each_open_device(ctx, h) \
+ for_each_helper(h, &(ctx)->open_devs, struct libusb_device_handle)
+
+#define __for_each_transfer(list, t) \
+ for_each_helper(t, (list), struct usbi_transfer)
+
+#define for_each_transfer(ctx, t) \
+ __for_each_transfer(&(ctx)->flying_transfers, t)
+
+#define __for_each_transfer_safe(list, t, n) \
+ for_each_safe_helper(t, n, (list), struct usbi_transfer)
+
+#define for_each_transfer_safe(ctx, t, n) \
+ __for_each_transfer_safe(&(ctx)->flying_transfers, t, n)
+
+#define __for_each_completed_transfer_safe(list, t, n) \
+ list_for_each_entry_safe(t, n, (list), completed_list, struct usbi_transfer)
+
+#define for_each_event_source(ctx, e) \
+ for_each_helper(e, &(ctx)->event_sources, struct usbi_event_source)
+
+#define for_each_removed_event_source(ctx, e) \
+ for_each_helper(e, &(ctx)->removed_event_sources, struct usbi_event_source)
+
+#define for_each_removed_event_source_safe(ctx, e, n) \
+ for_each_safe_helper(e, n, &(ctx)->removed_event_sources, struct usbi_event_source)
#ifdef __cplusplus
}
diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c
index 7fdf88f..e415589 100644
--- a/libusb/os/darwin_usb.c
+++ b/libusb/os/darwin_usb.c
@@ -1,8 +1,8 @@
/* -*- Mode: C; indent-tabs-mode:nil -*- */
/*
* darwin backend for libusb 1.0
- * Copyright © 2008-2019 Nathan Hjelm <hjelmn@users.sourceforge.net>
- * Copyright © 2019 Google LLC. All rights reserved.
+ * Copyright © 2008-2020 Nathan Hjelm <hjelmn@cs.unm.edu>
+ * Copyright © 2019-2020 Google LLC. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -19,11 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "config.h"
+#include <config.h>
#include <assert.h>
#include <time.h>
#include <ctype.h>
-#include <errno.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
@@ -47,56 +46,37 @@
#include <objc/objc-auto.h>
#endif
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
-/* Apple deprecated the darwin atomics in 10.12 in favor of C11 atomics */
-#include <stdatomic.h>
-#define libusb_darwin_atomic_fetch_add(x, y) atomic_fetch_add(x, y)
-
-_Atomic int32_t initCount = ATOMIC_VAR_INIT(0);
-#else
-/* use darwin atomics if the target is older than 10.12 */
-#include <libkern/OSAtomic.h>
-
-/* OSAtomicAdd32Barrier returns the new value */
-#define libusb_darwin_atomic_fetch_add(x, y) (OSAtomicAdd32Barrier(y, x) - y)
-
-static volatile int32_t initCount = 0;
-
-#endif
-
-/* On 10.12 and later, use newly available clock_*() functions */
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
-#define OSX_USE_CLOCK_GETTIME 1
-#else
-#define OSX_USE_CLOCK_GETTIME 0
-#endif
-
#include "darwin_usb.h"
+static pthread_mutex_t libusb_darwin_init_mutex = PTHREAD_MUTEX_INITIALIZER;
+static int init_count = 0;
+
/* async event thread */
static pthread_mutex_t libusb_darwin_at_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t libusb_darwin_at_cond = PTHREAD_COND_INITIALIZER;
-#if !OSX_USE_CLOCK_GETTIME
+#if !defined(HAVE_CLOCK_GETTIME)
static clock_serv_t clock_realtime;
static clock_serv_t clock_monotonic;
#endif
+#define LIBUSB_DARWIN_STARTUP_FAILURE ((CFRunLoopRef) -1)
+
static CFRunLoopRef libusb_darwin_acfl = NULL; /* event cf loop */
static CFRunLoopSourceRef libusb_darwin_acfls = NULL; /* shutdown signal for event cf loop */
static usbi_mutex_t darwin_cached_devices_lock = PTHREAD_MUTEX_INITIALIZER;
-static struct list_head darwin_cached_devices = {&darwin_cached_devices, &darwin_cached_devices};
-static const char *darwin_device_class = kIOUSBDeviceClassName;
+static struct list_head darwin_cached_devices;
+static const char *darwin_device_class = "IOUSBDevice";
-#define DARWIN_CACHED_DEVICE(a) ((struct darwin_cached_device *) (((struct darwin_device_priv *)((a)->os_priv))->dev))
+#define DARWIN_CACHED_DEVICE(a) (((struct darwin_device_priv *)usbi_get_device_priv((a)))->dev)
/* async event thread */
static pthread_t libusb_darwin_at;
-static int darwin_get_config_descriptor(struct libusb_device *dev, uint8_t config_index, unsigned char *buffer, size_t len, int *host_endian);
-static int darwin_claim_interface(struct libusb_device_handle *dev_handle, int iface);
-static int darwin_release_interface(struct libusb_device_handle *dev_handle, int iface);
+static int darwin_get_config_descriptor(struct libusb_device *dev, uint8_t config_index, void *buffer, size_t len);
+static int darwin_claim_interface(struct libusb_device_handle *dev_handle, uint8_t iface);
+static int darwin_release_interface(struct libusb_device_handle *dev_handle, uint8_t iface);
static int darwin_reset_device(struct libusb_device_handle *dev_handle);
static void darwin_async_io_callback (void *refcon, IOReturn result, void *arg0);
@@ -141,6 +121,8 @@ static const char *darwin_error_str (IOReturn result) {
return "out of resources";
case kIOUSBHighSpeedSplitError:
return "high speed split error";
+ case kIOUSBUnknownPipeErr:
+ return "pipe ref not recognized";
default:
snprintf(string_buffer, sizeof(string_buffer), "unknown error (0x%x)", result);
return string_buffer;
@@ -168,6 +150,7 @@ static enum libusb_error darwin_to_libusb (IOReturn result) {
case kIOReturnAborted:
case kIOReturnError:
case kIOUSBNoAsyncPortErr:
+ case kIOUSBUnknownPipeErr:
default:
return LIBUSB_ERROR_OTHER;
}
@@ -193,7 +176,7 @@ static void darwin_ref_cached_device(struct darwin_cached_device *cached_dev) {
}
static int ep_to_pipeRef(struct libusb_device_handle *dev_handle, uint8_t ep, uint8_t *pipep, uint8_t *ifcp, struct darwin_interface **interface_out) {
- struct darwin_device_handle_priv *priv = (struct darwin_device_handle_priv *)dev_handle->os_priv;
+ struct darwin_device_handle_priv *priv = usbi_get_device_handle_priv(dev_handle);
/* current interface */
struct darwin_interface *cInterface;
@@ -353,7 +336,7 @@ static void darwin_devices_attached (void *ptr, io_iterator_t add_devices) {
}
/* add this device to each active context's device list */
- list_for_each_entry(ctx, &active_contexts_list, list, struct libusb_context) {
+ for_each_context(ctx) {
process_new_device (ctx, cached_device, old_session_id);
}
@@ -397,7 +380,7 @@ static void darwin_devices_detached (void *ptr, io_iterator_t rem_devices) {
if (old_device->in_reenumerate) {
/* device is re-enumerating. do not dereference the device at this time. libusb_reset_device()
* will deref if needed. */
- usbi_dbg ("detected device detatched due to re-enumeration");
+ usbi_dbg ("detected device detached due to re-enumeration");
/* the device object is no longer usable so go ahead and release it */
if (old_device->device) {
@@ -419,7 +402,7 @@ static void darwin_devices_detached (void *ptr, io_iterator_t rem_devices) {
continue;
}
- list_for_each_entry(ctx, &active_contexts_list, list, struct libusb_context) {
+ for_each_context(ctx) {
usbi_dbg ("notifying context %p of device disconnect", ctx);
dev = usbi_get_device_by_session_id(ctx, (unsigned long) session);
@@ -453,10 +436,20 @@ static void darwin_clear_iterator (io_iterator_t iter) {
IOObjectRelease (device);
}
+static void darwin_fail_startup(void) {
+ pthread_mutex_lock (&libusb_darwin_at_mutex);
+ libusb_darwin_acfl = LIBUSB_DARWIN_STARTUP_FAILURE;
+ pthread_cond_signal (&libusb_darwin_at_cond);
+ pthread_mutex_unlock (&libusb_darwin_at_mutex);
+ pthread_exit (NULL);
+}
+
static void *darwin_event_thread_main (void *arg0) {
IOReturn kresult;
struct libusb_context *ctx = (struct libusb_context *)arg0;
CFRunLoopRef runloop;
+ CFRunLoopSourceRef libusb_shutdown_cfsource;
+ CFRunLoopSourceContext libusb_shutdown_cfsourcectx;
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
/* Set this thread's name, so it can be seen in the debugger
@@ -475,7 +468,6 @@ static void *darwin_event_thread_main (void *arg0) {
#endif
/* hotplug (device arrival/removal) sources */
- CFRunLoopSourceContext libusb_shutdown_cfsourcectx;
CFRunLoopSourceRef libusb_notification_cfsource;
io_notification_port_t libusb_notification_port;
io_iterator_t libusb_rem_device_iterator;
@@ -490,8 +482,8 @@ static void *darwin_event_thread_main (void *arg0) {
memset(&libusb_shutdown_cfsourcectx, 0, sizeof(libusb_shutdown_cfsourcectx));
libusb_shutdown_cfsourcectx.info = runloop;
libusb_shutdown_cfsourcectx.perform = (void (*)(void *))CFRunLoopStop;
- libusb_darwin_acfls = CFRunLoopSourceCreate(NULL, 0, &libusb_shutdown_cfsourcectx);
- CFRunLoopAddSource(runloop, libusb_darwin_acfls, kCFRunLoopDefaultMode);
+ libusb_shutdown_cfsource = CFRunLoopSourceCreate(NULL, 0, &libusb_shutdown_cfsourcectx);
+ CFRunLoopAddSource(runloop, libusb_shutdown_cfsource, kCFRunLoopDefaultMode);
/* add the notification port to the run loop */
libusb_notification_port = IONotificationPortCreate (kIOMasterPortDefault);
@@ -506,8 +498,9 @@ static void *darwin_event_thread_main (void *arg0) {
if (kresult != kIOReturnSuccess) {
usbi_err (ctx, "could not add hotplug event source: %s", darwin_error_str (kresult));
-
- pthread_exit (NULL);
+ CFRelease (libusb_shutdown_cfsource);
+ CFRelease (runloop);
+ darwin_fail_startup ();
}
/* create notifications for attached devices */
@@ -518,8 +511,9 @@ static void *darwin_event_thread_main (void *arg0) {
if (kresult != kIOReturnSuccess) {
usbi_err (ctx, "could not add hotplug event source: %s", darwin_error_str (kresult));
-
- pthread_exit (NULL);
+ CFRelease (libusb_shutdown_cfsource);
+ CFRelease (runloop);
+ darwin_fail_startup ();
}
/* arm notifiers */
@@ -531,6 +525,7 @@ static void *darwin_event_thread_main (void *arg0) {
/* signal the main thread that the hotplug runloop has been created. */
pthread_mutex_lock (&libusb_darwin_at_mutex);
libusb_darwin_acfl = runloop;
+ libusb_darwin_acfls = libusb_shutdown_cfsource;
pthread_cond_signal (&libusb_darwin_at_cond);
pthread_mutex_unlock (&libusb_darwin_at_mutex);
@@ -539,11 +534,18 @@ static void *darwin_event_thread_main (void *arg0) {
usbi_dbg ("darwin event thread exiting");
+ /* signal the main thread that the hotplug runloop has finished. */
+ pthread_mutex_lock (&libusb_darwin_at_mutex);
+ libusb_darwin_acfls = NULL;
+ libusb_darwin_acfl = NULL;
+ pthread_cond_signal (&libusb_darwin_at_cond);
+ pthread_mutex_unlock (&libusb_darwin_at_mutex);
+
/* remove the notification cfsource */
CFRunLoopRemoveSource(runloop, libusb_notification_cfsource, kCFRunLoopDefaultMode);
/* remove the shutdown cfsource */
- CFRunLoopRemoveSource(runloop, libusb_darwin_acfls, kCFRunLoopDefaultMode);
+ CFRunLoopRemoveSource(runloop, libusb_shutdown_cfsource, kCFRunLoopDefaultMode);
/* delete notification port */
IONotificationPortDestroy (libusb_notification_port);
@@ -552,83 +554,116 @@ static void *darwin_event_thread_main (void *arg0) {
IOObjectRelease (libusb_rem_device_iterator);
IOObjectRelease (libusb_add_device_iterator);
- CFRelease (libusb_darwin_acfls);
+ CFRelease (libusb_shutdown_cfsource);
CFRelease (runloop);
- libusb_darwin_acfls = NULL;
- libusb_darwin_acfl = NULL;
-
pthread_exit (NULL);
}
/* cleanup function to destroy cached devices */
-static void __attribute__((destructor)) _darwin_finalize(void) {
+static void darwin_cleanup_devices(void) {
struct darwin_cached_device *dev, *next;
- usbi_mutex_lock(&darwin_cached_devices_lock);
list_for_each_entry_safe(dev, next, &darwin_cached_devices, list, struct darwin_cached_device) {
darwin_deref_cached_device(dev);
}
- usbi_mutex_unlock(&darwin_cached_devices_lock);
+
+ darwin_cached_devices.prev = darwin_cached_devices.next = NULL;
}
static int darwin_init(struct libusb_context *ctx) {
+ bool first_init;
int rc;
- rc = darwin_scan_devices (ctx);
- if (LIBUSB_SUCCESS != rc) {
- return rc;
- }
+ pthread_mutex_lock (&libusb_darwin_init_mutex);
- if (libusb_darwin_atomic_fetch_add (&initCount, 1) == 0) {
-#if !OSX_USE_CLOCK_GETTIME
- /* create the clocks that will be used if clock_gettime() is not available */
- host_name_port_t host_self;
+ first_init = (1 == ++init_count);
- host_self = mach_host_self();
- host_get_clock_service(host_self, CALENDAR_CLOCK, &clock_realtime);
- host_get_clock_service(host_self, SYSTEM_CLOCK, &clock_monotonic);
- mach_port_deallocate(mach_task_self(), host_self);
+ do {
+ if (first_init) {
+ assert (NULL == darwin_cached_devices.next);
+ list_init (&darwin_cached_devices);
+
+#if !defined(HAVE_CLOCK_GETTIME)
+ /* create the clocks that will be used if clock_gettime() is not available */
+ host_name_port_t host_self;
+
+ host_self = mach_host_self();
+ host_get_clock_service(host_self, CALENDAR_CLOCK, &clock_realtime);
+ host_get_clock_service(host_self, SYSTEM_CLOCK, &clock_monotonic);
+ mach_port_deallocate(mach_task_self(), host_self);
#endif
+ }
- pthread_create (&libusb_darwin_at, NULL, darwin_event_thread_main, ctx);
+ rc = darwin_scan_devices (ctx);
+ if (LIBUSB_SUCCESS != rc)
+ break;
- pthread_mutex_lock (&libusb_darwin_at_mutex);
- while (!libusb_darwin_acfl)
- pthread_cond_wait (&libusb_darwin_at_cond, &libusb_darwin_at_mutex);
- pthread_mutex_unlock (&libusb_darwin_at_mutex);
+ if (first_init) {
+ rc = pthread_create (&libusb_darwin_at, NULL, darwin_event_thread_main, ctx);
+ if (0 != rc) {
+ usbi_err (ctx, "could not create event thread, error %d", rc);
+ rc = LIBUSB_ERROR_OTHER;
+ break;
+ }
+
+ pthread_mutex_lock (&libusb_darwin_at_mutex);
+ while (!libusb_darwin_acfl)
+ pthread_cond_wait (&libusb_darwin_at_cond, &libusb_darwin_at_mutex);
+ if (libusb_darwin_acfl == LIBUSB_DARWIN_STARTUP_FAILURE) {
+ libusb_darwin_acfl = NULL;
+ rc = LIBUSB_ERROR_OTHER;
+ }
+ pthread_mutex_unlock (&libusb_darwin_at_mutex);
+
+ if (0 != rc)
+ pthread_join (libusb_darwin_at, NULL);
+ }
+ } while (0);
+
+ if (LIBUSB_SUCCESS != rc) {
+ if (first_init) {
+ darwin_cleanup_devices ();
+#if !defined(HAVE_CLOCK_GETTIME)
+ mach_port_deallocate(mach_task_self(), clock_realtime);
+ mach_port_deallocate(mach_task_self(), clock_monotonic);
+#endif
+ }
+ --init_count;
}
+ pthread_mutex_unlock (&libusb_darwin_init_mutex);
+
return rc;
}
static void darwin_exit (struct libusb_context *ctx) {
UNUSED(ctx);
- if (libusb_darwin_atomic_fetch_add (&initCount, -1) == 1) {
-#if !OSX_USE_CLOCK_GETTIME
- mach_port_deallocate(mach_task_self(), clock_realtime);
- mach_port_deallocate(mach_task_self(), clock_monotonic);
-#endif
+ pthread_mutex_lock (&libusb_darwin_init_mutex);
+
+ if (0 == --init_count) {
/* stop the event runloop and wait for the thread to terminate. */
- CFRunLoopSourceSignal(libusb_darwin_acfls);
+ pthread_mutex_lock (&libusb_darwin_at_mutex);
+ CFRunLoopSourceSignal (libusb_darwin_acfls);
CFRunLoopWakeUp (libusb_darwin_acfl);
+ while (libusb_darwin_acfl)
+ pthread_cond_wait (&libusb_darwin_at_cond, &libusb_darwin_at_mutex);
+ pthread_mutex_unlock (&libusb_darwin_at_mutex);
pthread_join (libusb_darwin_at, NULL);
- }
-}
-
-static int darwin_get_device_descriptor(struct libusb_device *dev, unsigned char *buffer, int *host_endian) {
- struct darwin_cached_device *priv = DARWIN_CACHED_DEVICE(dev);
- /* return cached copy */
- memmove (buffer, &(priv->dev_descriptor), DEVICE_DESC_LENGTH);
+ darwin_cleanup_devices ();
- *host_endian = 0;
+#if !defined(HAVE_CLOCK_GETTIME)
+ mach_port_deallocate(mach_task_self(), clock_realtime);
+ mach_port_deallocate(mach_task_self(), clock_monotonic);
+#endif
+ }
- return LIBUSB_SUCCESS;
+ pthread_mutex_unlock (&libusb_darwin_init_mutex);
}
-static int get_configuration_index (struct libusb_device *dev, int config_value) {
+static int get_configuration_index (struct libusb_device *dev, UInt8 config_value) {
struct darwin_cached_device *priv = DARWIN_CACHED_DEVICE(dev);
UInt8 i, numConfig;
IOUSBConfigurationDescriptorPtr desc;
@@ -650,7 +685,7 @@ static int get_configuration_index (struct libusb_device *dev, int config_value)
return LIBUSB_ERROR_NOT_FOUND;
}
-static int darwin_get_active_config_descriptor(struct libusb_device *dev, unsigned char *buffer, size_t len, int *host_endian) {
+static int darwin_get_active_config_descriptor(struct libusb_device *dev, void *buffer, size_t len) {
struct darwin_cached_device *priv = DARWIN_CACHED_DEVICE(dev);
int config_index;
@@ -662,10 +697,10 @@ static int darwin_get_active_config_descriptor(struct libusb_device *dev, unsign
return config_index;
assert(config_index >= 0 && config_index <= UINT8_MAX);
- return darwin_get_config_descriptor (dev, (UInt8)config_index, buffer, len, host_endian);
+ return darwin_get_config_descriptor (dev, (UInt8)config_index, buffer, len);
}
-static int darwin_get_config_descriptor(struct libusb_device *dev, uint8_t config_index, unsigned char *buffer, size_t len, int *host_endian) {
+static int darwin_get_config_descriptor(struct libusb_device *dev, uint8_t config_index, void *buffer, size_t len) {
struct darwin_cached_device *priv = DARWIN_CACHED_DEVICE(dev);
IOUSBConfigurationDescriptorPtr desc;
IOReturn kresult;
@@ -681,9 +716,6 @@ static int darwin_get_config_descriptor(struct libusb_device *dev, uint8_t confi
len = libusb_le16_to_cpu(desc->wTotalLength);
memmove (buffer, desc, len);
-
- /* GetConfigurationDescriptorPtr returns the descriptor in USB bus order */
- *host_endian = 0;
}
ret = darwin_to_libusb (kresult);
@@ -710,7 +742,8 @@ static enum libusb_error darwin_check_configuration (struct libusb_context *ctx,
/* checking the configuration of a root hub simulation takes ~1 s in 10.11. the device is
not usable anyway */
- if (0x05ac == dev->dev_descriptor.idVendor && 0x8005 == dev->dev_descriptor.idProduct) {
+ if (0x05ac == libusb_le16_to_cpu (dev->dev_descriptor.idVendor) &&
+ 0x8005 == libusb_le16_to_cpu (dev->dev_descriptor.idProduct)) {
usbi_dbg ("ignoring configuration on root hub simulation");
dev->active_config = 0;
return LIBUSB_SUCCESS;
@@ -753,7 +786,7 @@ static enum libusb_error darwin_check_configuration (struct libusb_context *ctx,
} else
/* not configured */
dev->active_config = 0;
-
+
usbi_dbg ("active config: %u, first config: %u", dev->active_config, dev->first_config);
return LIBUSB_SUCCESS;
@@ -891,14 +924,14 @@ static enum libusb_error darwin_cache_device_descriptor (struct darwin_cached_de
usbi_dbg ("cached device descriptor:");
usbi_dbg (" bDescriptorType: 0x%02x", dev->dev_descriptor.bDescriptorType);
- usbi_dbg (" bcdUSB: 0x%04x", dev->dev_descriptor.bcdUSB);
+ usbi_dbg (" bcdUSB: 0x%04x", libusb_le16_to_cpu (dev->dev_descriptor.bcdUSB));
usbi_dbg (" bDeviceClass: 0x%02x", dev->dev_descriptor.bDeviceClass);
usbi_dbg (" bDeviceSubClass: 0x%02x", dev->dev_descriptor.bDeviceSubClass);
usbi_dbg (" bDeviceProtocol: 0x%02x", dev->dev_descriptor.bDeviceProtocol);
usbi_dbg (" bMaxPacketSize0: 0x%02x", dev->dev_descriptor.bMaxPacketSize0);
- usbi_dbg (" idVendor: 0x%04x", dev->dev_descriptor.idVendor);
- usbi_dbg (" idProduct: 0x%04x", dev->dev_descriptor.idProduct);
- usbi_dbg (" bcdDevice: 0x%04x", dev->dev_descriptor.bcdDevice);
+ usbi_dbg (" idVendor: 0x%04x", libusb_le16_to_cpu (dev->dev_descriptor.idVendor));
+ usbi_dbg (" idProduct: 0x%04x", libusb_le16_to_cpu (dev->dev_descriptor.idProduct));
+ usbi_dbg (" bcdDevice: 0x%04x", libusb_le16_to_cpu (dev->dev_descriptor.bcdDevice));
usbi_dbg (" iManufacturer: 0x%02x", dev->dev_descriptor.iManufacturer);
usbi_dbg (" iProduct: 0x%02x", dev->dev_descriptor.iProduct);
usbi_dbg (" iSerialNumber: 0x%02x", dev->dev_descriptor.iSerialNumber);
@@ -1035,7 +1068,8 @@ static enum libusb_error darwin_get_cached_device(io_service_t service, struct d
if (new_device->can_enumerate) {
snprintf(new_device->sys_path, 20, "%03i-%04x-%04x-%02x-%02x", new_device->address,
- new_device->dev_descriptor.idVendor, new_device->dev_descriptor.idProduct,
+ libusb_le16_to_cpu (new_device->dev_descriptor.idVendor),
+ libusb_le16_to_cpu (new_device->dev_descriptor.idProduct),
new_device->dev_descriptor.bDeviceClass, new_device->dev_descriptor.bDeviceSubClass);
}
} while (0);
@@ -1075,7 +1109,7 @@ static enum libusb_error process_new_device (struct libusb_context *ctx, struct
return LIBUSB_ERROR_NO_MEM;
}
- priv = (struct darwin_device_priv *)dev->os_priv;
+ priv = usbi_get_device_priv(dev);
priv->dev = cached_device;
darwin_ref_cached_device (priv->dev);
@@ -1084,9 +1118,15 @@ static enum libusb_error process_new_device (struct libusb_context *ctx, struct
assert(cached_device->address <= UINT8_MAX);
dev->device_address = (uint8_t)cached_device->address;
} else {
- priv = (struct darwin_device_priv *)dev->os_priv;
+ priv = usbi_get_device_priv(dev);
}
+ static_assert(sizeof(dev->device_descriptor) == sizeof(cached_device->dev_descriptor),
+ "mismatch between libusb and IOKit device descriptor sizes");
+ memcpy(&dev->device_descriptor, &cached_device->dev_descriptor, LIBUSB_DT_DEVICE_SIZE);
+ usbi_localize_device_descriptor(&dev->device_descriptor);
+ dev->session_data = cached_device->session;
+
if (cached_device->parent_session > 0) {
dev->parent_dev = usbi_get_device_by_session_id (ctx, (unsigned long) cached_device->parent_session);
} else {
@@ -1156,7 +1196,7 @@ static enum libusb_error darwin_scan_devices(struct libusb_context *ctx) {
}
static int darwin_open (struct libusb_device_handle *dev_handle) {
- struct darwin_device_handle_priv *priv = (struct darwin_device_handle_priv *)dev_handle->os_priv;
+ struct darwin_device_handle_priv *priv = usbi_get_device_handle_priv(dev_handle);
struct darwin_cached_device *dpriv = DARWIN_CACHED_DEVICE(dev_handle->dev);
IOReturn kresult;
@@ -1205,7 +1245,7 @@ static int darwin_open (struct libusb_device_handle *dev_handle) {
}
static void darwin_close (struct libusb_device_handle *dev_handle) {
- struct darwin_device_handle_priv *priv = (struct darwin_device_handle_priv *)dev_handle->os_priv;
+ struct darwin_device_handle_priv *priv = usbi_get_device_handle_priv(dev_handle);
struct darwin_cached_device *dpriv = DARWIN_CACHED_DEVICE(dev_handle->dev);
IOReturn kresult;
int i;
@@ -1244,10 +1284,10 @@ static void darwin_close (struct libusb_device_handle *dev_handle) {
}
}
-static int darwin_get_configuration(struct libusb_device_handle *dev_handle, int *config) {
+static int darwin_get_configuration(struct libusb_device_handle *dev_handle, uint8_t *config) {
struct darwin_cached_device *dpriv = DARWIN_CACHED_DEVICE(dev_handle->dev);
- *config = (int) dpriv->active_config;
+ *config = dpriv->active_config;
return LIBUSB_SUCCESS;
}
@@ -1255,9 +1295,10 @@ static int darwin_get_configuration(struct libusb_device_handle *dev_handle, int
static enum libusb_error darwin_set_configuration(struct libusb_device_handle *dev_handle, int config) {
struct darwin_cached_device *dpriv = DARWIN_CACHED_DEVICE(dev_handle->dev);
IOReturn kresult;
- int i;
+ uint8_t i;
- assert(config >= 0 && config <= UINT8_MAX);
+ if (config == -1)
+ config = 0;
/* Setting configuration will invalidate the interface, so we need
to reclaim it. First, dispose of existing interfaces, if any. */
@@ -1279,7 +1320,7 @@ static enum libusb_error darwin_set_configuration(struct libusb_device_handle *d
return LIBUSB_SUCCESS;
}
-static IOReturn darwin_get_interface (usb_device_t **darwin_device, int ifc, io_service_t *usbInterfacep) {
+static IOReturn darwin_get_interface (usb_device_t **darwin_device, uint8_t ifc, io_service_t *usbInterfacep) {
IOUSBFindInterfaceRequest request;
IOReturn kresult;
io_iterator_t interface_iterator;
@@ -1316,8 +1357,8 @@ static IOReturn darwin_get_interface (usb_device_t **darwin_device, int ifc, io_
return kIOReturnSuccess;
}
-static enum libusb_error get_endpoints (struct libusb_device_handle *dev_handle, int iface) {
- struct darwin_device_handle_priv *priv = (struct darwin_device_handle_priv *)dev_handle->os_priv;
+static enum libusb_error get_endpoints (struct libusb_device_handle *dev_handle, uint8_t iface) {
+ struct darwin_device_handle_priv *priv = usbi_get_device_handle_priv(dev_handle);
/* current interface */
struct darwin_interface *cInterface = &priv->interfaces[iface];
@@ -1376,21 +1417,19 @@ static enum libusb_error get_endpoints (struct libusb_device_handle *dev_handle,
return LIBUSB_SUCCESS;
}
-static int darwin_claim_interface(struct libusb_device_handle *dev_handle, int iface) {
+static int darwin_claim_interface(struct libusb_device_handle *dev_handle, uint8_t iface) {
struct darwin_cached_device *dpriv = DARWIN_CACHED_DEVICE(dev_handle->dev);
- struct darwin_device_handle_priv *priv = (struct darwin_device_handle_priv *)dev_handle->os_priv;
+ struct darwin_device_handle_priv *priv = usbi_get_device_handle_priv(dev_handle);
io_service_t usbInterface = IO_OBJECT_NULL;
IOReturn kresult;
enum libusb_error ret;
IOCFPlugInInterface **plugInInterface = NULL;
SInt32 score;
- assert(iface >= 0 && iface <= UINT8_MAX);
-
/* current interface */
struct darwin_interface *cInterface = &priv->interfaces[iface];
- kresult = darwin_get_interface (dpriv->device, (uint8_t)iface, &usbInterface);
+ kresult = darwin_get_interface (dpriv->device, iface, &usbInterface);
if (kresult != kIOReturnSuccess)
return darwin_to_libusb (kresult);
@@ -1399,13 +1438,13 @@ static int darwin_claim_interface(struct libusb_device_handle *dev_handle, int i
usbi_info (HANDLE_CTX (dev_handle), "no interface found; setting configuration: %d", dpriv->first_config);
/* set the configuration */
- ret = darwin_set_configuration (dev_handle, dpriv->first_config);
+ ret = darwin_set_configuration (dev_handle, (int) dpriv->first_config);
if (ret != LIBUSB_SUCCESS) {
usbi_err (HANDLE_CTX (dev_handle), "could not set configuration");
return ret;
}
- kresult = darwin_get_interface (dpriv->device, (uint8_t)iface, &usbInterface);
+ kresult = darwin_get_interface (dpriv->device, iface, &usbInterface);
if (kresult != kIOReturnSuccess) {
usbi_err (HANDLE_CTX (dev_handle), "darwin_get_interface: %s", darwin_error_str(kresult));
return darwin_to_libusb (kresult);
@@ -1483,8 +1522,8 @@ static int darwin_claim_interface(struct libusb_device_handle *dev_handle, int i
return LIBUSB_SUCCESS;
}
-static int darwin_release_interface(struct libusb_device_handle *dev_handle, int iface) {
- struct darwin_device_handle_priv *priv = (struct darwin_device_handle_priv *)dev_handle->os_priv;
+static int darwin_release_interface(struct libusb_device_handle *dev_handle, uint8_t iface) {
+ struct darwin_device_handle_priv *priv = usbi_get_device_handle_priv(dev_handle);
IOReturn kresult;
/* current interface */
@@ -1516,8 +1555,8 @@ static int darwin_release_interface(struct libusb_device_handle *dev_handle, int
return darwin_to_libusb (kresult);
}
-static int darwin_set_interface_altsetting(struct libusb_device_handle *dev_handle, int iface, int altsetting) {
- struct darwin_device_handle_priv *priv = (struct darwin_device_handle_priv *)dev_handle->os_priv;
+static int darwin_set_interface_altsetting(struct libusb_device_handle *dev_handle, uint8_t iface, uint8_t altsetting) {
+ struct darwin_device_handle_priv *priv = usbi_get_device_handle_priv(dev_handle);
IOReturn kresult;
enum libusb_error ret;
@@ -1527,8 +1566,7 @@ static int darwin_set_interface_altsetting(struct libusb_device_handle *dev_hand
if (!cInterface->interface)
return LIBUSB_ERROR_NO_DEVICE;
- assert(altsetting >= 0 && altsetting <= UINT8_MAX);
- kresult = (*(cInterface->interface))->SetAlternateInterface (cInterface->interface, (UInt8)altsetting);
+ kresult = (*(cInterface->interface))->SetAlternateInterface (cInterface->interface, altsetting);
if (kresult != kIOReturnSuccess)
darwin_reset_device (dev_handle);
@@ -1568,7 +1606,7 @@ static int darwin_clear_halt(struct libusb_device_handle *dev_handle, unsigned c
static int darwin_restore_state (struct libusb_device_handle *dev_handle, int8_t active_config,
unsigned long claimed_interfaces) {
struct darwin_cached_device *dpriv = DARWIN_CACHED_DEVICE(dev_handle->dev);
- struct darwin_device_handle_priv *priv = (struct darwin_device_handle_priv *)dev_handle->os_priv;
+ struct darwin_device_handle_priv *priv = usbi_get_device_handle_priv(dev_handle);
int open_count = dpriv->open_count;
int ret;
@@ -1603,16 +1641,16 @@ static int darwin_restore_state (struct libusb_device_handle *dev_handle, int8_t
usbi_dbg ("darwin/restore_state: reclaiming interfaces");
if (claimed_interfaces) {
- for (int iface = 0 ; iface < USB_MAXINTERFACES ; ++iface) {
+ for (uint8_t iface = 0 ; iface < USB_MAXINTERFACES ; ++iface) {
if (!(claimed_interfaces & (1U << iface))) {
continue;
}
- usbi_dbg ("darwin/restore_state: re-claiming interface %d", iface);
+ usbi_dbg ("darwin/restore_state: re-claiming interface %u", iface);
ret = darwin_claim_interface (dev_handle, iface);
if (LIBUSB_SUCCESS != ret) {
- usbi_dbg ("darwin/restore_state: could not claim interface %d", iface);
+ usbi_dbg ("darwin/restore_state: could not claim interface %u", iface);
return LIBUSB_ERROR_NOT_FOUND;
}
@@ -1688,14 +1726,13 @@ static int darwin_reset_device(struct libusb_device_handle *dev_handle) {
return darwin_restore_state (dev_handle, active_config, claimed_interfaces);
}
-static int darwin_kernel_driver_active(struct libusb_device_handle *dev_handle, int interface) {
+static int darwin_kernel_driver_active(struct libusb_device_handle *dev_handle, uint8_t interface) {
struct darwin_cached_device *dpriv = DARWIN_CACHED_DEVICE(dev_handle->dev);
io_service_t usbInterface;
CFTypeRef driver;
IOReturn kresult;
- assert(interface >= 0 && interface <= UINT8_MAX);
- kresult = darwin_get_interface (dpriv->device, (uint8_t)interface, &usbInterface);
+ kresult = darwin_get_interface (dpriv->device, interface, &usbInterface);
if (kresult != kIOReturnSuccess) {
usbi_err (HANDLE_CTX (dev_handle), "darwin_get_interface: %s", darwin_error_str(kresult));
@@ -1715,21 +1752,8 @@ static int darwin_kernel_driver_active(struct libusb_device_handle *dev_handle,
return 0;
}
-/* attaching/detaching kernel drivers is not currently supported (maybe in the future?) */
-static int darwin_attach_kernel_driver (struct libusb_device_handle *dev_handle, int interface) {
- UNUSED(dev_handle);
- UNUSED(interface);
- return LIBUSB_ERROR_NOT_SUPPORTED;
-}
-
-static int darwin_detach_kernel_driver (struct libusb_device_handle *dev_handle, int interface) {
- UNUSED(dev_handle);
- UNUSED(interface);
- return LIBUSB_ERROR_NOT_SUPPORTED;
-}
-
static void darwin_destroy_device(struct libusb_device *dev) {
- struct darwin_device_priv *dpriv = (struct darwin_device_priv *) dev->os_priv;
+ struct darwin_device_priv *dpriv = usbi_get_device_priv(dev);
if (dpriv->dev) {
/* need to hold the lock in case this is the last reference to the device */
@@ -1745,11 +1769,16 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer) {
IOReturn ret;
uint8_t transferType;
- /* None of the values below are used in libusbx for bulk transfers */
- uint8_t direction, number, interval, pipeRef;
+ uint8_t pipeRef;
uint16_t maxPacketSize;
struct darwin_interface *cInterface;
+#if InterfaceVersion >= 550
+ IOUSBEndpointProperties pipeProperties = {.bVersion = kUSBEndpointPropertiesVersion3};
+#else
+ /* None of the values below are used in libusb for bulk transfers */
+ uint8_t direction, number, interval;
+#endif
if (ep_to_pipeRef (transfer->dev_handle, transfer->endpoint, &pipeRef, NULL, &cInterface) != 0) {
usbi_err (TRANSFER_CTX (transfer), "endpoint not found on any open interface");
@@ -1757,8 +1786,15 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer) {
return LIBUSB_ERROR_NOT_FOUND;
}
+#if InterfaceVersion >= 550
+ ret = (*(cInterface->interface))->GetPipePropertiesV3 (cInterface->interface, pipeRef, &pipeProperties);
+
+ transferType = pipeProperties.bTransferType;
+ maxPacketSize = pipeProperties.wMaxPacketSize;
+#else
ret = (*(cInterface->interface))->GetPipeProperties (cInterface->interface, pipeRef, &direction, &number,
&transferType, &maxPacketSize, &interval);
+#endif
if (ret) {
usbi_err (TRANSFER_CTX (transfer), "bulk transfer failed (dir = %s): %s (code = 0x%08x)", IS_XFERIN(transfer) ? "In" : "Out",
@@ -1834,7 +1870,7 @@ static int submit_stream_transfer(struct usbi_transfer *itransfer) {
static int submit_iso_transfer(struct usbi_transfer *itransfer) {
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct darwin_transfer_priv *tpriv = usbi_transfer_get_os_priv(itransfer);
+ struct darwin_transfer_priv *tpriv = usbi_get_transfer_priv(itransfer);
IOReturn kresult;
uint8_t direction, number, interval, pipeRef, transferType;
@@ -1926,7 +1962,7 @@ static int submit_control_transfer(struct usbi_transfer *itransfer) {
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
struct libusb_control_setup *setup = (struct libusb_control_setup *) transfer->buffer;
struct darwin_cached_device *dpriv = DARWIN_CACHED_DEVICE(transfer->dev_handle->dev);
- struct darwin_transfer_priv *tpriv = usbi_transfer_get_os_priv(itransfer);
+ struct darwin_transfer_priv *tpriv = usbi_get_transfer_priv(itransfer);
IOReturn kresult;
@@ -2058,20 +2094,10 @@ static int darwin_cancel_transfer(struct usbi_transfer *itransfer) {
}
}
-static void darwin_clear_transfer_priv (struct usbi_transfer *itransfer) {
- struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct darwin_transfer_priv *tpriv = usbi_transfer_get_os_priv(itransfer);
-
- if (transfer->type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS && tpriv->isoc_framelist) {
- free (tpriv->isoc_framelist);
- tpriv->isoc_framelist = NULL;
- }
-}
-
static void darwin_async_io_callback (void *refcon, IOReturn result, void *arg0) {
struct usbi_transfer *itransfer = (struct usbi_transfer *)refcon;
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct darwin_transfer_priv *tpriv = usbi_transfer_get_os_priv(itransfer);
+ struct darwin_transfer_priv *tpriv = usbi_get_transfer_priv(itransfer);
usbi_dbg ("an async io operation has completed");
@@ -2120,73 +2146,62 @@ static enum libusb_transfer_status darwin_transfer_status (struct usbi_transfer
static int darwin_handle_transfer_completion (struct usbi_transfer *itransfer) {
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct darwin_transfer_priv *tpriv = usbi_transfer_get_os_priv(itransfer);
- bool isIsoc = LIBUSB_TRANSFER_TYPE_ISOCHRONOUS == transfer->type;
- bool isBulk = LIBUSB_TRANSFER_TYPE_BULK == transfer->type;
- bool isControl = LIBUSB_TRANSFER_TYPE_CONTROL == transfer->type;
- bool isInterrupt = LIBUSB_TRANSFER_TYPE_INTERRUPT == transfer->type;
- int i;
+ struct darwin_transfer_priv *tpriv = usbi_get_transfer_priv(itransfer);
+ const unsigned char max_transfer_type = LIBUSB_TRANSFER_TYPE_BULK_STREAM;
+ const char *transfer_types[max_transfer_type + 1] = {"control", "isoc", "bulk", "interrupt", "bulk-stream"};
+ bool is_isoc = LIBUSB_TRANSFER_TYPE_ISOCHRONOUS == transfer->type;
- if (!isIsoc && !isBulk && !isControl && !isInterrupt) {
+ if (transfer->type > max_transfer_type) {
usbi_err (TRANSFER_CTX(transfer), "unknown endpoint type %d", transfer->type);
return LIBUSB_ERROR_INVALID_PARAM;
}
- usbi_dbg ("handling %s completion with kernel status %d",
- isControl ? "control" : isBulk ? "bulk" : isIsoc ? "isoc" : "interrupt", tpriv->result);
+ if (NULL == tpriv) {
+ usbi_err (TRANSFER_CTX(transfer), "malformed request is missing transfer priv");
+ return LIBUSB_ERROR_INVALID_PARAM;
+ }
+
+ usbi_dbg ("handling transfer completion type %s with kernel status %d", transfer_types[transfer->type], tpriv->result);
if (kIOReturnSuccess == tpriv->result || kIOReturnUnderrun == tpriv->result) {
- if (isIsoc && tpriv->isoc_framelist) {
+ if (is_isoc && tpriv->isoc_framelist) {
/* copy isochronous results back */
- for (i = 0; i < transfer->num_iso_packets ; i++) {
+ for (int i = 0; i < transfer->num_iso_packets ; i++) {
struct libusb_iso_packet_descriptor *lib_desc = &transfer->iso_packet_desc[i];
lib_desc->status = darwin_transfer_status (itransfer, tpriv->isoc_framelist[i].frStatus);
lib_desc->actual_length = tpriv->isoc_framelist[i].frActCount;
}
- } else if (!isIsoc)
+ } else if (!is_isoc) {
itransfer->transferred += tpriv->size;
+ }
}
/* it is ok to handle cancelled transfers without calling usbi_handle_transfer_cancellation (we catch timeout transfers) */
return usbi_handle_transfer_completion (itransfer, darwin_transfer_status (itransfer, tpriv->result));
}
-static int darwin_clock_gettime(int clk_id, struct timespec *tp) {
-#if !OSX_USE_CLOCK_GETTIME
+#if !defined(HAVE_CLOCK_GETTIME)
+void usbi_get_monotonic_time(struct timespec *tp) {
mach_timespec_t sys_time;
- clock_serv_t clock_ref;
-
- switch (clk_id) {
- case USBI_CLOCK_REALTIME:
- /* CLOCK_REALTIME represents time since the epoch */
- clock_ref = clock_realtime;
- break;
- case USBI_CLOCK_MONOTONIC:
- /* use system boot time as reference for the monotonic clock */
- clock_ref = clock_monotonic;
- break;
- default:
- return LIBUSB_ERROR_INVALID_PARAM;
- }
- clock_get_time (clock_ref, &sys_time);
+ /* use system boot time as reference for the monotonic clock */
+ clock_get_time (clock_monotonic, &sys_time);
tp->tv_sec = sys_time.tv_sec;
tp->tv_nsec = sys_time.tv_nsec;
+}
- return LIBUSB_SUCCESS;
-#else
- switch (clk_id) {
- case USBI_CLOCK_MONOTONIC:
- return clock_gettime(CLOCK_MONOTONIC, tp);
- case USBI_CLOCK_REALTIME:
- return clock_gettime(CLOCK_REALTIME, tp);
- default:
- return LIBUSB_ERROR_INVALID_PARAM;
- }
-#endif
+void usbi_get_real_time(struct timespec *tp) {
+ mach_timespec_t sys_time;
+
+ /* CLOCK_REALTIME represents time since the epoch */
+ clock_get_time (clock_realtime, &sys_time);
+
+ tp->tv_sec = sys_time.tv_sec;
+ tp->tv_nsec = sys_time.tv_nsec;
}
+#endif
#if InterfaceVersion >= 550
static int darwin_alloc_streams (struct libusb_device_handle *dev_handle, uint32_t num_streams, unsigned char *endpoints,
@@ -2196,7 +2211,7 @@ static int darwin_alloc_streams (struct libusb_device_handle *dev_handle, uint32
uint8_t pipeRef;
int rc, i;
- /* find the mimimum number of supported streams on the endpoint list */
+ /* find the minimum number of supported streams on the endpoint list */
for (i = 0 ; i < num_endpoints ; ++i) {
if (0 != (rc = ep_to_pipeRef (dev_handle, endpoints[i], &pipeRef, NULL, &cInterface))) {
return rc;
@@ -2252,8 +2267,6 @@ const struct usbi_os_backend usbi_backend = {
.caps = 0,
.init = darwin_init,
.exit = darwin_exit,
- .get_device_list = NULL, /* not needed */
- .get_device_descriptor = darwin_get_device_descriptor,
.get_active_config_descriptor = darwin_get_active_config_descriptor,
.get_config_descriptor = darwin_get_config_descriptor,
.hotplug_poll = darwin_hotplug_poll,
@@ -2275,19 +2288,14 @@ const struct usbi_os_backend usbi_backend = {
#endif
.kernel_driver_active = darwin_kernel_driver_active,
- .detach_kernel_driver = darwin_detach_kernel_driver,
- .attach_kernel_driver = darwin_attach_kernel_driver,
.destroy_device = darwin_destroy_device,
.submit_transfer = darwin_submit_transfer,
.cancel_transfer = darwin_cancel_transfer,
- .clear_transfer_priv = darwin_clear_transfer_priv,
.handle_transfer_completion = darwin_handle_transfer_completion,
- .clock_gettime = darwin_clock_gettime,
-
.device_priv_size = sizeof(struct darwin_device_priv),
.device_handle_priv_size = sizeof(struct darwin_device_handle_priv),
.transfer_priv_size = sizeof(struct darwin_transfer_priv),
diff --git a/libusb/os/darwin_usb.h b/libusb/os/darwin_usb.h
index 3d76baf..b799bfd 100644
--- a/libusb/os/darwin_usb.h
+++ b/libusb/os/darwin_usb.h
@@ -162,7 +162,7 @@ struct darwin_cached_device {
char sys_path[21];
usb_device_t **device;
int open_count;
- UInt8 first_config, active_config, port;
+ UInt8 first_config, active_config, port;
int can_enumerate;
int refcount;
bool in_reenumerate;
diff --git a/libusb/os/events_posix.c b/libusb/os/events_posix.c
new file mode 100644
index 0000000..b74189b
--- /dev/null
+++ b/libusb/os/events_posix.c
@@ -0,0 +1,300 @@
+/*
+ * libusb event abstraction on POSIX platforms
+ *
+ * Copyright © 2020 Chris Dickens <christopher.a.dickens@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libusbi.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#ifdef HAVE_EVENTFD
+#include <sys/eventfd.h>
+#endif
+#ifdef HAVE_TIMERFD
+#include <sys/timerfd.h>
+#endif
+#include <unistd.h>
+
+#ifdef HAVE_EVENTFD
+#define EVENT_READ_FD(e) ((e)->eventfd)
+#define EVENT_WRITE_FD(e) ((e)->eventfd)
+#else
+#define EVENT_READ_FD(e) ((e)->pipefd[0])
+#define EVENT_WRITE_FD(e) ((e)->pipefd[1])
+#endif
+
+#ifdef HAVE_NFDS_T
+typedef nfds_t usbi_nfds_t;
+#else
+typedef unsigned int usbi_nfds_t;
+#endif
+
+int usbi_create_event(usbi_event_t *event)
+{
+#ifdef HAVE_EVENTFD
+ event->eventfd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
+ if (event->eventfd == -1) {
+ usbi_err(NULL, "failed to create eventfd, errno=%d", errno);
+ return LIBUSB_ERROR_OTHER;
+ }
+
+ return 0;
+#else
+#if defined(HAVE_PIPE2)
+ int ret = pipe2(event->pipefd, O_CLOEXEC);
+#else
+ int ret = pipe(event->pipefd);
+#endif
+
+ if (ret != 0) {
+ usbi_err(NULL, "failed to create pipe, errno=%d", errno);
+ return LIBUSB_ERROR_OTHER;
+ }
+
+#if !defined(HAVE_PIPE2) && defined(FD_CLOEXEC)
+ ret = fcntl(event->pipefd[0], F_GETFD);
+ if (ret == -1) {
+ usbi_err(NULL, "failed to get pipe fd flags, errno=%d", errno);
+ goto err_close_pipe;
+ }
+ ret = fcntl(event->pipefd[0], F_SETFD, ret | FD_CLOEXEC);
+ if (ret == -1) {
+ usbi_err(NULL, "failed to set pipe fd flags, errno=%d", errno);
+ goto err_close_pipe;
+ }
+
+ ret = fcntl(event->pipefd[1], F_GETFD);
+ if (ret == -1) {
+ usbi_err(NULL, "failed to get pipe fd flags, errno=%d", errno);
+ goto err_close_pipe;
+ }
+ ret = fcntl(event->pipefd[1], F_SETFD, ret | FD_CLOEXEC);
+ if (ret == -1) {
+ usbi_err(NULL, "failed to set pipe fd flags, errno=%d", errno);
+ goto err_close_pipe;
+ }
+#endif
+
+ ret = fcntl(event->pipefd[1], F_GETFL);
+ if (ret == -1) {
+ usbi_err(NULL, "failed to get pipe fd status flags, errno=%d", errno);
+ goto err_close_pipe;
+ }
+ ret = fcntl(event->pipefd[1], F_SETFL, ret | O_NONBLOCK);
+ if (ret == -1) {
+ usbi_err(NULL, "failed to set pipe fd status flags, errno=%d", errno);
+ goto err_close_pipe;
+ }
+
+ return 0;
+
+err_close_pipe:
+ close(event->pipefd[1]);
+ close(event->pipefd[0]);
+ return LIBUSB_ERROR_OTHER;
+#endif
+}
+
+void usbi_destroy_event(usbi_event_t *event)
+{
+#ifdef HAVE_EVENTFD
+ if (close(event->eventfd) == -1)
+ usbi_warn(NULL, "failed to close eventfd, errno=%d", errno);
+#else
+ if (close(event->pipefd[1]) == -1)
+ usbi_warn(NULL, "failed to close pipe write end, errno=%d", errno);
+ if (close(event->pipefd[0]) == -1)
+ usbi_warn(NULL, "failed to close pipe read end, errno=%d", errno);
+#endif
+}
+
+void usbi_signal_event(usbi_event_t *event)
+{
+ uint64_t dummy = 1;
+ ssize_t r;
+
+ r = write(EVENT_WRITE_FD(event), &dummy, sizeof(dummy));
+ if (r != sizeof(dummy))
+ usbi_warn(NULL, "event write failed");
+}
+
+void usbi_clear_event(usbi_event_t *event)
+{
+ uint64_t dummy;
+ ssize_t r;
+
+ r = read(EVENT_READ_FD(event), &dummy, sizeof(dummy));
+ if (r != sizeof(dummy))
+ usbi_warn(NULL, "event read failed");
+}
+
+#ifdef HAVE_TIMERFD
+int usbi_create_timer(usbi_timer_t *timer)
+{
+ timer->timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC);
+ if (timer->timerfd == -1) {
+ usbi_warn(NULL, "failed to create timerfd, errno=%d", errno);
+ return LIBUSB_ERROR_OTHER;
+ }
+
+ return 0;
+}
+
+void usbi_destroy_timer(usbi_timer_t *timer)
+{
+ if (close(timer->timerfd) == -1)
+ usbi_warn(NULL, "failed to close timerfd, errno=%d", errno);
+}
+
+int usbi_arm_timer(usbi_timer_t *timer, const struct timespec *timeout)
+{
+ const struct itimerspec it = { { 0, 0 }, { timeout->tv_sec, timeout->tv_nsec } };
+
+ if (timerfd_settime(timer->timerfd, TFD_TIMER_ABSTIME, &it, NULL) == -1) {
+ usbi_warn(NULL, "failed to arm timerfd, errno=%d", errno);
+ return LIBUSB_ERROR_OTHER;
+ }
+
+ return 0;
+}
+
+int usbi_disarm_timer(usbi_timer_t *timer)
+{
+ const struct itimerspec it = { { 0, 0 }, { 0, 0 } };
+
+ if (timerfd_settime(timer->timerfd, 0, &it, NULL) == -1) {
+ usbi_warn(NULL, "failed to disarm timerfd, errno=%d", errno);
+ return LIBUSB_ERROR_OTHER;
+ }
+
+ return 0;
+}
+#endif
+
+int usbi_alloc_event_data(struct libusb_context *ctx)
+{
+ struct usbi_event_source *ievent_source;
+ struct pollfd *fds;
+ size_t i = 0;
+
+ if (ctx->event_data) {
+ free(ctx->event_data);
+ ctx->event_data = NULL;
+ }
+
+ ctx->event_data_cnt = 0;
+ for_each_event_source(ctx, ievent_source)
+ ctx->event_data_cnt++;
+
+ fds = calloc(ctx->event_data_cnt, sizeof(*fds));
+ if (!fds)
+ return LIBUSB_ERROR_NO_MEM;
+
+ for_each_event_source(ctx, ievent_source) {
+ fds[i].fd = ievent_source->data.os_handle;
+ fds[i].events = ievent_source->data.poll_events;
+ i++;
+ }
+
+ ctx->event_data = fds;
+ return 0;
+}
+
+int usbi_wait_for_events(struct libusb_context *ctx,
+ struct usbi_reported_events *reported_events, int timeout_ms)
+{
+ struct pollfd *fds = ctx->event_data;
+ usbi_nfds_t nfds = (usbi_nfds_t)ctx->event_data_cnt;
+ int internal_fds, num_ready;
+
+ usbi_dbg("poll() %u fds with timeout in %dms", (unsigned int)nfds, timeout_ms);
+ num_ready = poll(fds, nfds, timeout_ms);
+ usbi_dbg("poll() returned %d", num_ready);
+ if (num_ready == 0) {
+ if (usbi_using_timer(ctx))
+ goto done;
+ return LIBUSB_ERROR_TIMEOUT;
+ } else if (num_ready == -1) {
+ if (errno == EINTR)
+ return LIBUSB_ERROR_INTERRUPTED;
+ usbi_err(ctx, "poll() failed, errno=%d", errno);
+ return LIBUSB_ERROR_IO;
+ }
+
+ /* fds[0] is always the internal signalling event */
+ if (fds[0].revents) {
+ reported_events->event_triggered = 1;
+ num_ready--;
+ } else {
+ reported_events->event_triggered = 0;
+ }
+
+#ifdef HAVE_OS_TIMER
+ /* on timer configurations, fds[1] is the timer */
+ if (usbi_using_timer(ctx) && fds[1].revents) {
+ reported_events->timer_triggered = 1;
+ num_ready--;
+ } else {
+ reported_events->timer_triggered = 0;
+ }
+#endif
+
+ if (!num_ready)
+ goto done;
+
+ /* the backend will never need to attempt to handle events on the
+ * library's internal file descriptors, so we determine how many are
+ * in use internally for this context and skip these when passing any
+ * remaining pollfds to the backend. */
+ internal_fds = usbi_using_timer(ctx) ? 2 : 1;
+ fds += internal_fds;
+ nfds -= internal_fds;
+
+ usbi_mutex_lock(&ctx->event_data_lock);
+ if (ctx->event_flags & USBI_EVENT_EVENT_SOURCES_MODIFIED) {
+ struct usbi_event_source *ievent_source;
+
+ for_each_removed_event_source(ctx, ievent_source) {
+ usbi_nfds_t n;
+
+ for (n = 0; n < nfds; n++) {
+ if (ievent_source->data.os_handle != fds[n].fd)
+ continue;
+ if (!fds[n].revents)
+ continue;
+ /* pollfd was removed between the creation of the fds array and
+ * here. remove triggered revent as it is no longer relevant. */
+ usbi_dbg("fd %d was removed, ignoring raised events", fds[n].fd);
+ fds[n].revents = 0;
+ num_ready--;
+ break;
+ }
+ }
+ }
+ usbi_mutex_unlock(&ctx->event_data_lock);
+
+ if (num_ready) {
+ assert(num_ready > 0);
+ reported_events->event_data = fds;
+ reported_events->event_data_count = (unsigned int)nfds;
+ }
+
+done:
+ reported_events->num_ready = num_ready;
+ return LIBUSB_SUCCESS;
+}
diff --git a/libusb/os/events_posix.h b/libusb/os/events_posix.h
new file mode 100644
index 0000000..d81b5c4
--- /dev/null
+++ b/libusb/os/events_posix.h
@@ -0,0 +1,59 @@
+/*
+ * libusb event abstraction on POSIX platforms
+ *
+ * Copyright © 2020 Chris Dickens <christopher.a.dickens@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef LIBUSB_EVENTS_POSIX_H
+#define LIBUSB_EVENTS_POSIX_H
+
+#include <poll.h>
+
+typedef int usbi_os_handle_t;
+#define USBI_OS_HANDLE_FORMAT_STRING "fd %d"
+
+#ifdef HAVE_EVENTFD
+typedef struct usbi_event {
+ int eventfd;
+} usbi_event_t;
+#define USBI_EVENT_OS_HANDLE(e) ((e)->eventfd)
+#define USBI_EVENT_POLL_EVENTS POLLIN
+#define USBI_INVALID_EVENT { -1 }
+#else
+typedef struct usbi_event {
+ int pipefd[2];
+} usbi_event_t;
+#define USBI_EVENT_OS_HANDLE(e) ((e)->pipefd[0])
+#define USBI_EVENT_POLL_EVENTS POLLIN
+#define USBI_INVALID_EVENT { { -1, -1 } }
+#endif
+
+#ifdef HAVE_TIMERFD
+#define HAVE_OS_TIMER 1
+typedef struct usbi_timer {
+ int timerfd;
+} usbi_timer_t;
+#define USBI_TIMER_OS_HANDLE(t) ((t)->timerfd)
+#define USBI_TIMER_POLL_EVENTS POLLIN
+
+static inline int usbi_timer_valid(usbi_timer_t *timer)
+{
+ return timer->timerfd >= 0;
+}
+#endif
+
+#endif
diff --git a/libusb/os/events_windows.c b/libusb/os/events_windows.c
new file mode 100644
index 0000000..81d8b87
--- /dev/null
+++ b/libusb/os/events_windows.c
@@ -0,0 +1,214 @@
+/*
+ * libusb event abstraction on Microsoft Windows
+ *
+ * Copyright © 2020 Chris Dickens <christopher.a.dickens@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <config.h>
+
+#include "libusbi.h"
+#include "windows_common.h"
+
+int usbi_create_event(usbi_event_t *event)
+{
+ event->hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ if (event->hEvent == NULL) {
+ usbi_err(NULL, "CreateEvent failed: %s", windows_error_str(0));
+ return LIBUSB_ERROR_OTHER;
+ }
+
+ return 0;
+}
+
+void usbi_destroy_event(usbi_event_t *event)
+{
+ if (!CloseHandle(event->hEvent))
+ usbi_warn(NULL, "CloseHandle failed: %s", windows_error_str(0));
+}
+
+void usbi_signal_event(usbi_event_t *event)
+{
+ if (!SetEvent(event->hEvent))
+ usbi_warn(NULL, "SetEvent failed: %s", windows_error_str(0));
+}
+
+void usbi_clear_event(usbi_event_t *event)
+{
+ if (!ResetEvent(event->hEvent))
+ usbi_warn(NULL, "ResetEvent failed: %s", windows_error_str(0));
+}
+
+#ifdef HAVE_OS_TIMER
+int usbi_create_timer(usbi_timer_t *timer)
+{
+ timer->hTimer = CreateWaitableTimer(NULL, TRUE, NULL);
+ if (timer->hTimer == NULL) {
+ usbi_warn(NULL, "CreateWaitableTimer failed: %s", windows_error_str(0));
+ return LIBUSB_ERROR_OTHER;
+ }
+
+ return 0;
+}
+
+void usbi_destroy_timer(usbi_timer_t *timer)
+{
+ if (!CloseHandle(timer->hTimer))
+ usbi_warn(NULL, "CloseHandle failed: %s", windows_error_str(0));
+}
+
+int usbi_arm_timer(usbi_timer_t *timer, const struct timespec *timeout)
+{
+ struct timespec systime, remaining;
+ FILETIME filetime;
+ LARGE_INTEGER dueTime;
+
+ /* Transfer timeouts are based on the monotonic clock and the waitable
+ * timers on the system clock. This requires a conversion between the
+ * two, so we calculate the remaining time relative to the monotonic
+ * clock and calculate an absolute system time for the timer expiration.
+ * Note that if the timeout has already passed, the remaining time will
+ * be negative and thus an absolute system time in the past will be set.
+ * This works just as intended because the timer becomes signalled
+ * immediately. */
+ usbi_get_monotonic_time(&systime);
+
+ TIMESPEC_SUB(timeout, &systime, &remaining);
+
+ GetSystemTimeAsFileTime(&filetime);
+ dueTime.LowPart = filetime.dwLowDateTime;
+ dueTime.HighPart = filetime.dwHighDateTime;
+ dueTime.QuadPart += (remaining.tv_sec * 10000000LL) + (remaining.tv_nsec / 100LL);
+
+ if (!SetWaitableTimer(timer->hTimer, &dueTime, 0, NULL, NULL, FALSE)) {
+ usbi_warn(NULL, "SetWaitableTimer failed: %s", windows_error_str(0));
+ return LIBUSB_ERROR_OTHER;
+ }
+
+ return 0;
+}
+
+int usbi_disarm_timer(usbi_timer_t *timer)
+{
+ LARGE_INTEGER dueTime;
+
+ /* A manual-reset waitable timer will stay in the signalled state until
+ * another call to SetWaitableTimer() is made. It is possible that the
+ * timer has already expired by the time we come in to disarm it, so to
+ * be entirely sure the timer is disarmed and not in the signalled state,
+ * we will set it with an impossibly large expiration and immediately
+ * cancel. */
+ dueTime.QuadPart = LLONG_MAX;
+ if (!SetWaitableTimer(timer->hTimer, &dueTime, 0, NULL, NULL, FALSE)) {
+ usbi_warn(NULL, "SetWaitableTimer failed: %s", windows_error_str(0));
+ return LIBUSB_ERROR_OTHER;
+ }
+
+ if (!CancelWaitableTimer(timer->hTimer)) {
+ usbi_warn(NULL, "SetWaitableTimer failed: %s", windows_error_str(0));
+ return LIBUSB_ERROR_OTHER;
+ }
+
+ return 0;
+}
+#endif
+
+int usbi_alloc_event_data(struct libusb_context *ctx)
+{
+ struct usbi_event_source *ievent_source;
+ HANDLE *handles;
+ size_t i = 0;
+
+ /* Event sources are only added during usbi_io_init(). We should not
+ * be running this function again if the event data has already been
+ * allocated. */
+ if (ctx->event_data) {
+ usbi_warn(ctx, "program assertion failed - event data already allocated");
+ return LIBUSB_ERROR_OTHER;
+ }
+
+ ctx->event_data_cnt = 0;
+ for_each_event_source(ctx, ievent_source)
+ ctx->event_data_cnt++;
+
+ /* We only expect up to two HANDLEs to wait on, one for the internal
+ * signalling event and the other for the timer. */
+ if (ctx->event_data_cnt != 1 && ctx->event_data_cnt != 2) {
+ usbi_err(ctx, "program assertion failed - expected exactly 1 or 2 HANDLEs");
+ return LIBUSB_ERROR_OTHER;
+ }
+
+ handles = calloc(ctx->event_data_cnt, sizeof(HANDLE));
+ if (!handles)
+ return LIBUSB_ERROR_NO_MEM;
+
+ for_each_event_source(ctx, ievent_source) {
+ handles[i] = ievent_source->data.os_handle;
+ i++;
+ }
+
+ ctx->event_data = handles;
+ return 0;
+}
+
+int usbi_wait_for_events(struct libusb_context *ctx,
+ struct usbi_reported_events *reported_events, int timeout_ms)
+{
+ HANDLE *handles = ctx->event_data;
+ DWORD num_handles = (DWORD)ctx->event_data_cnt;
+ DWORD result;
+
+ usbi_dbg("WaitForMultipleObjects() for %lu HANDLEs with timeout in %dms", ULONG_CAST(num_handles), timeout_ms);
+ result = WaitForMultipleObjects(num_handles, handles, FALSE, (DWORD)timeout_ms);
+ usbi_dbg("WaitForMultipleObjects() returned %lu", ULONG_CAST(result));
+ if (result == WAIT_TIMEOUT) {
+ if (usbi_using_timer(ctx))
+ goto done;
+ return LIBUSB_ERROR_TIMEOUT;
+ } else if (result == WAIT_FAILED) {
+ usbi_err(ctx, "WaitForMultipleObjects() failed: %s", windows_error_str(0));
+ return LIBUSB_ERROR_IO;
+ }
+
+ result -= WAIT_OBJECT_0;
+
+ /* handles[0] is always the internal signalling event */
+ if (result == 0)
+ reported_events->event_triggered = 1;
+ else
+ reported_events->event_triggered = 0;
+
+#ifdef HAVE_OS_TIMER
+ /* on timer configurations, handles[1] is the timer */
+ if (usbi_using_timer(ctx)) {
+ /* The WaitForMultipleObjects() function reports the index of
+ * the first object that became signalled. If the internal
+ * signalling event was reported, we need to also check and
+ * report whether the timer is in the signalled state. */
+ if (result == 1 || WaitForSingleObject(handles[1], 0) == WAIT_OBJECT_0)
+ reported_events->timer_triggered = 1;
+ else
+ reported_events->timer_triggered = 0;
+ } else {
+ reported_events->timer_triggered = 0;
+ }
+#endif
+
+done:
+ /* no events are ever reported to the backend */
+ reported_events->num_ready = 0;
+ return LIBUSB_SUCCESS;
+}
diff --git a/msvc/missing.h b/libusb/os/events_windows.h
index 183b9d3..0c5e0b0 100644
--- a/msvc/missing.h
+++ b/libusb/os/events_windows.h
@@ -1,6 +1,7 @@
/*
- * Header file for missing WinCE functionality
- * Copyright © 2012-2013 RealVNC Ltd.
+ * libusb event abstraction on Microsoft Windows
+ *
+ * Copyright © 2020 Chris Dickens <christopher.a.dickens@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -17,16 +18,29 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef MISSING_H
-#define MISSING_H
+#ifndef LIBUSB_EVENTS_WINDOWS_H
+#define LIBUSB_EVENTS_WINDOWS_H
-/* Windows CE doesn't have SleepEx() - Fallback to Sleep() */
-#define SleepEx(m, a) Sleep(m)
+typedef HANDLE usbi_os_handle_t;
+#define USBI_OS_HANDLE_FORMAT_STRING "HANDLE %p"
-/* Windows CE doesn't have any APIs to query environment variables.
- *
- * This contains a registry based implementation of getenv.
- */
-char *getenv(const char *name);
+typedef struct usbi_event {
+ HANDLE hEvent;
+} usbi_event_t;
+#define USBI_EVENT_OS_HANDLE(e) ((e)->hEvent)
+#define USBI_EVENT_POLL_EVENTS 0
+#define USBI_INVALID_EVENT { INVALID_HANDLE_VALUE }
+
+#define HAVE_OS_TIMER 1
+typedef struct usbi_timer {
+ HANDLE hTimer;
+} usbi_timer_t;
+#define USBI_TIMER_OS_HANDLE(t) ((t)->hTimer)
+#define USBI_TIMER_POLL_EVENTS 0
+
+static inline int usbi_timer_valid(usbi_timer_t *timer)
+{
+ return timer->hTimer != NULL;
+}
#endif
diff --git a/libusb/os/haiku_pollfs.cpp b/libusb/os/haiku_pollfs.cpp
index e0c7713..cb4fda8 100644
--- a/libusb/os/haiku_pollfs.cpp
+++ b/libusb/os/haiku_pollfs.cpp
@@ -97,7 +97,7 @@ WatchedEntry::WatchedEntry(BMessenger *messenger, entry_ref *ref)
unsigned long session_id = (unsigned long)&fDevice;
usbi_mutex_lock(&active_contexts_lock);
- list_for_each_entry(ctx, &active_contexts_list, list, struct libusb_context) {
+ for_each_context(ctx) {
struct libusb_device *dev = usbi_get_device_by_session_id(ctx, session_id);
if (dev) {
usbi_dbg("using previously allocated device with location %lu", session_id);
@@ -110,7 +110,7 @@ WatchedEntry::WatchedEntry(BMessenger *messenger, entry_ref *ref)
usbi_dbg("device allocation failed");
continue;
}
- *((USBDevice **)dev->os_priv) = fDevice;
+ *((USBDevice **)usbi_get_device_priv(dev)) = fDevice;
// Calculate pseudo-device-address
int addr, tmp;
@@ -125,9 +125,14 @@ WatchedEntry::WatchedEntry(BMessenger *messenger, entry_ref *ref)
addr += tmp + 1;
parent_path.GetParent(&parent_path);
}
- sscanf(path.Path(), "/dev/bus/usb/%d", &dev->bus_number);
+ sscanf(path.Path(), "/dev/bus/usb/%hhu", &dev->bus_number);
dev->device_address = addr - (dev->bus_number + 1);
+ static_assert(sizeof(dev->device_descriptor) == sizeof(usb_device_descriptor),
+ "mismatch between libusb and OS device descriptor sizes");
+ memcpy(&dev->device_descriptor, fDevice->Descriptor(), LIBUSB_DT_DEVICE_SIZE);
+ usbi_localize_device_descriptor(&dev->device_descriptor);
+
if (usbi_sanitize_device(dev) < 0) {
usbi_dbg("device sanitization failed");
libusb_unref_device(dev);
@@ -167,7 +172,7 @@ WatchedEntry::~WatchedEntry()
unsigned long session_id = (unsigned long)&fDevice;
usbi_mutex_lock(&active_contexts_lock);
- list_for_each_entry(ctx, &active_contexts_list, list, struct libusb_context) {
+ for_each_context(ctx) {
dev = usbi_get_device_by_session_id(ctx, session_id);
if (dev != NULL) {
usbi_disconnect_device(dev);
diff --git a/libusb/os/haiku_usb.h b/libusb/os/haiku_usb.h
index f15e58e..2dd5177 100644
--- a/libusb/os/haiku_usb.h
+++ b/libusb/os/haiku_usb.h
@@ -38,22 +38,22 @@ public:
const char* Location() const;
uint8 CountConfigurations() const;
const usb_device_descriptor* Descriptor() const;
- const usb_configuration_descriptor* ConfigurationDescriptor(uint32) const;
+ const usb_configuration_descriptor* ConfigurationDescriptor(uint8) const;
const usb_configuration_descriptor* ActiveConfiguration() const;
uint8 EndpointToIndex(uint8) const;
uint8 EndpointToInterface(uint8) const;
- int ClaimInterface(int);
- int ReleaseInterface(int);
- int CheckInterfacesFree(int);
- int SetActiveConfiguration(int);
- int ActiveConfigurationIndex() const;
+ int ClaimInterface(uint8);
+ int ReleaseInterface(uint8);
+ int CheckInterfacesFree(uint8);
+ void SetActiveConfiguration(uint8);
+ uint8 ActiveConfigurationIndex() const;
bool InitCheck();
private:
int Initialise();
unsigned int fClaimedInterfaces; // Max Interfaces can be 32. Using a bitmask
usb_device_descriptor fDeviceDescriptor;
unsigned char** fConfigurationDescriptors;
- int fActiveConfiguration;
+ uint8 fActiveConfiguration;
char* fPath;
map<uint8,uint8> fConfigToIndex;
map<uint8,uint8>* fEndpointToIndex;
@@ -65,11 +65,11 @@ class USBDeviceHandle {
public:
USBDeviceHandle(USBDevice *dev);
virtual ~USBDeviceHandle();
- int ClaimInterface(int);
- int ReleaseInterface(int);
- int SetConfiguration(int);
- int SetAltSetting(int, int);
- int ClearHalt(int);
+ int ClaimInterface(uint8);
+ int ReleaseInterface(uint8);
+ int SetConfiguration(uint8);
+ int SetAltSetting(uint8, uint8);
+ int ClearHalt(uint8);
status_t SubmitTransfer(struct usbi_transfer *);
status_t CancelTransfer(USBTransfer *);
bool InitCheck();
diff --git a/libusb/os/haiku_usb_backend.cpp b/libusb/os/haiku_usb_backend.cpp
index 539a996..8bbf3e0 100644
--- a/libusb/os/haiku_usb_backend.cpp
+++ b/libusb/os/haiku_usb_backend.cpp
@@ -26,7 +26,7 @@
#include "haiku_usb.h"
-int _errno_to_libusb(int status)
+static int _errno_to_libusb(int status)
{
return status;
}
@@ -127,7 +127,7 @@ USBTransfer::Do(int fRawFD)
int i;
usb_iso_packet_descriptor *packetDescriptors = new usb_iso_packet_descriptor[fLibusbTransfer->num_iso_packets];
for (i = 0; i < fLibusbTransfer->num_iso_packets; i++) {
- if ((int16)(fLibusbTransfer->iso_packet_desc[i]).length != (fLibusbTransfer->iso_packet_desc[i]).length) {
+ if ((fLibusbTransfer->iso_packet_desc[i]).length > (unsigned int)INT16_MAX) {
fUsbiTransfer->transferred = -1;
usbi_err(TRANSFER_CTX(fLibusbTransfer), "failed isochronous transfer");
break;
@@ -201,7 +201,7 @@ status_t
USBDeviceHandle::SubmitTransfer(struct usbi_transfer *itransfer)
{
USBTransfer *transfer = new USBTransfer(itransfer, fUSBDevice);
- *((USBTransfer **)usbi_transfer_get_os_priv(itransfer)) = transfer;
+ *((USBTransfer **)usbi_get_transfer_priv(itransfer)) = transfer;
BAutolock locker(fTransfersLock);
fTransfers.AddItem(transfer);
release_sem(fTransfersSem);
@@ -215,16 +215,16 @@ USBDeviceHandle::CancelTransfer(USBTransfer *transfer)
fTransfersLock.Lock();
bool removed = fTransfers.RemoveItem(transfer);
fTransfersLock.Unlock();
- if(removed)
+ if (removed)
usbi_signal_transfer_completion(transfer->UsbiTransfer());
return LIBUSB_SUCCESS;
}
USBDeviceHandle::USBDeviceHandle(USBDevice *dev)
:
- fTransfersThread(-1),
fUSBDevice(dev),
fClaimedInterfaces(0),
+ fTransfersThread(-1),
fInitCheck(false)
{
fRawFD = open(dev->Location(), O_RDWR | O_CLOEXEC);
@@ -242,7 +242,7 @@ USBDeviceHandle::~USBDeviceHandle()
{
if (fRawFD > 0)
close(fRawFD);
- for(int i = 0; i < 32; i++) {
+ for (int i = 0; i < 32; i++) {
if (fClaimedInterfaces & (1U << i))
ReleaseInterface(i);
}
@@ -252,7 +252,7 @@ USBDeviceHandle::~USBDeviceHandle()
}
int
-USBDeviceHandle::ClaimInterface(int inumber)
+USBDeviceHandle::ClaimInterface(uint8 inumber)
{
int status = fUSBDevice->ClaimInterface(inumber);
if (status == LIBUSB_SUCCESS)
@@ -261,7 +261,7 @@ USBDeviceHandle::ClaimInterface(int inumber)
}
int
-USBDeviceHandle::ReleaseInterface(int inumber)
+USBDeviceHandle::ReleaseInterface(uint8 inumber)
{
fUSBDevice->ReleaseInterface(inumber);
fClaimedInterfaces &= ~(1U << inumber);
@@ -269,10 +269,10 @@ USBDeviceHandle::ReleaseInterface(int inumber)
}
int
-USBDeviceHandle::SetConfiguration(int config)
+USBDeviceHandle::SetConfiguration(uint8 config)
{
int config_index = fUSBDevice->CheckInterfacesFree(config);
- if(config_index == LIBUSB_ERROR_BUSY || config_index == LIBUSB_ERROR_NOT_FOUND)
+ if (config_index == LIBUSB_ERROR_BUSY || config_index == LIBUSB_ERROR_NOT_FOUND)
return config_index;
usb_raw_command command;
command.config.config_index = config_index;
@@ -280,12 +280,12 @@ USBDeviceHandle::SetConfiguration(int config)
command.config.status != B_USB_RAW_STATUS_SUCCESS) {
return _errno_to_libusb(command.config.status);
}
- fUSBDevice->SetActiveConfiguration(config_index);
+ fUSBDevice->SetActiveConfiguration((uint8)config_index);
return LIBUSB_SUCCESS;
}
int
-USBDeviceHandle::SetAltSetting(int inumber, int alt)
+USBDeviceHandle::SetAltSetting(uint8 inumber, uint8 alt)
{
usb_raw_command command;
command.alternate.config_index = fUSBDevice->ActiveConfigurationIndex();
@@ -295,7 +295,7 @@ USBDeviceHandle::SetAltSetting(int inumber, int alt)
usbi_err(NULL, "Error retrieving active alternate interface");
return _errno_to_libusb(command.alternate.status);
}
- if (command.alternate.alternate_info == alt) {
+ if (command.alternate.alternate_info == (uint32)alt) {
usbi_dbg("Setting alternate interface successful");
return LIBUSB_SUCCESS;
}
@@ -309,9 +309,8 @@ USBDeviceHandle::SetAltSetting(int inumber, int alt)
return LIBUSB_SUCCESS;
}
-
int
-USBDevice::ClearHalt(int endpoint)
+USBDeviceHandle::ClearHalt(uint8 endpoint)
{
usb_raw_command command;
command.control.request_type = USB_REQTYPE_ENDPOINT_OUT;
@@ -324,15 +323,16 @@ USBDevice::ClearHalt(int endpoint)
command.control.status != B_USB_RAW_STATUS_SUCCESS) {
return _errno_to_libusb(command.control.status);
}
+ return LIBUSB_SUCCESS;
}
USBDevice::USBDevice(const char *path)
:
- fPath(NULL),
- fActiveConfiguration(0), //0?
- fConfigurationDescriptors(NULL),
fClaimedInterfaces(0),
+ fConfigurationDescriptors(NULL),
+ fActiveConfiguration(0), //0?
+ fPath(NULL),
fEndpointToIndex(NULL),
fEndpointToInterface(NULL),
fInitCheck(false)
@@ -345,7 +345,7 @@ USBDevice::~USBDevice()
{
free(fPath);
if (fConfigurationDescriptors) {
- for(int i = 0; i < fDeviceDescriptor.num_configurations; i++) {
+ for (uint8 i = 0; i < fDeviceDescriptor.num_configurations; i++) {
if (fConfigurationDescriptors[i])
delete fConfigurationDescriptors[i];
}
@@ -382,7 +382,7 @@ USBDevice::Descriptor() const
}
const usb_configuration_descriptor *
-USBDevice::ConfigurationDescriptor(uint32 index) const
+USBDevice::ConfigurationDescriptor(uint8 index) const
{
if (index > CountConfigurations())
return NULL;
@@ -395,13 +395,13 @@ USBDevice::ActiveConfiguration() const
return (usb_configuration_descriptor *) fConfigurationDescriptors[fActiveConfiguration];
}
-int
+uint8
USBDevice::ActiveConfigurationIndex() const
{
return fActiveConfiguration;
}
-int USBDevice::ClaimInterface(int interface)
+int USBDevice::ClaimInterface(uint8 interface)
{
if (interface > ActiveConfiguration()->number_interfaces)
return LIBUSB_ERROR_NOT_FOUND;
@@ -411,27 +411,26 @@ int USBDevice::ClaimInterface(int interface)
return LIBUSB_SUCCESS;
}
-int USBDevice::ReleaseInterface(int interface)
+int USBDevice::ReleaseInterface(uint8 interface)
{
fClaimedInterfaces &= ~(1U << interface);
return LIBUSB_SUCCESS;
}
int
-USBDevice::CheckInterfacesFree(int config)
+USBDevice::CheckInterfacesFree(uint8 config)
{
if (fConfigToIndex.count(config) == 0)
return LIBUSB_ERROR_NOT_FOUND;
if (fClaimedInterfaces == 0)
- return fConfigToIndex[(uint8)config];
+ return fConfigToIndex[config];
return LIBUSB_ERROR_BUSY;
}
-int
-USBDevice::SetActiveConfiguration(int config_index)
+void
+USBDevice::SetActiveConfiguration(uint8 config_index)
{
fActiveConfiguration = config_index;
- return LIBUSB_SUCCESS;
}
uint8
@@ -463,7 +462,7 @@ USBDevice::Initialise() //Do we need more error checking, etc? How to report?
fConfigurationDescriptors = new(std::nothrow) unsigned char *[fDeviceDescriptor.num_configurations];
fEndpointToIndex = new(std::nothrow) map<uint8,uint8> [fDeviceDescriptor.num_configurations];
fEndpointToInterface = new(std::nothrow) map<uint8,uint8> [fDeviceDescriptor.num_configurations];
- for (int i = 0; i < fDeviceDescriptor.num_configurations; i++) {
+ for (uint8 i = 0; i < fDeviceDescriptor.num_configurations; i++) {
usb_configuration_descriptor tmp_config;
command.config.descriptor = &tmp_config;
command.config.config_index = i;
@@ -479,14 +478,14 @@ USBDevice::Initialise() //Do we need more error checking, etc? How to report?
command.config_etc.descriptor = (usb_configuration_descriptor*)fConfigurationDescriptors[i];
command.config_etc.length = tmp_config.total_length;
command.config_etc.config_index = i;
- if (ioctl(fRawFD, B_USB_COMMAND_GET_CONFIGURATION_DESCRIPTOR_ETC, &command, sizeof(command)) ||
+ if (ioctl(fRawFD, B_USB_RAW_COMMAND_GET_CONFIGURATION_DESCRIPTOR_ETC, &command, sizeof(command)) ||
command.config_etc.status != B_USB_RAW_STATUS_SUCCESS) {
usbi_err(NULL, "failed retrieving full configuration descriptor");
close(fRawFD);
return B_ERROR;
}
- for (int j = 0; j < tmp_config.number_interfaces; j++) {
+ for (uint8 j = 0; j < tmp_config.number_interfaces; j++) {
command.alternate.config_index = i;
command.alternate.interface_index = j;
if (ioctl(fRawFD, B_USB_RAW_COMMAND_GET_ALT_INTERFACE_COUNT, &command, sizeof(command)) ||
@@ -495,8 +494,8 @@ USBDevice::Initialise() //Do we need more error checking, etc? How to report?
close(fRawFD);
return B_ERROR;
}
- int num_alternate = command.alternate.alternate_info;
- for (int k = 0; k < num_alternate; k++) {
+ uint8 num_alternate = (uint8)command.alternate.alternate_info;
+ for (uint8 k = 0; k < num_alternate; k++) {
usb_interface_descriptor tmp_interface;
command.interface_etc.config_index = i;
command.interface_etc.interface_index = j;
@@ -508,7 +507,7 @@ USBDevice::Initialise() //Do we need more error checking, etc? How to report?
close(fRawFD);
return B_ERROR;
}
- for (int l = 0; l < tmp_interface.num_endpoints; l++) {
+ for (uint8 l = 0; l < tmp_interface.num_endpoints; l++) {
usb_endpoint_descriptor tmp_endpoint;
command.endpoint_etc.config_index = i;
command.endpoint_etc.interface_index = j;
diff --git a/libusb/os/haiku_usb_raw.cpp b/libusb/os/haiku_usb_raw.cpp
index 67b270d..bce706c 100644
--- a/libusb/os/haiku_usb_raw.cpp
+++ b/libusb/os/haiku_usb_raw.cpp
@@ -30,11 +30,12 @@ USBRoster gUsbRoster;
int32 gInitCount = 0;
static int haiku_get_config_descriptor(struct libusb_device *, uint8_t,
- unsigned char *, size_t, int *);
+ void *, size_t);
static int
haiku_init(struct libusb_context *ctx)
{
+ UNUSED(ctx);
if (atomic_add(&gInitCount, 1) == 0)
return gUsbRoster.Start();
return LIBUSB_SUCCESS;
@@ -51,7 +52,7 @@ haiku_exit(struct libusb_context *ctx)
static int
haiku_open(struct libusb_device_handle *dev_handle)
{
- USBDevice *dev = *((USBDevice **)dev_handle->dev->os_priv);
+ USBDevice *dev = *((USBDevice **)usbi_get_device_priv(dev_handle->dev));
USBDeviceHandle *handle = new(std::nothrow) USBDeviceHandle(dev);
if (handle == NULL)
return LIBUSB_ERROR_NO_MEM;
@@ -59,93 +60,79 @@ haiku_open(struct libusb_device_handle *dev_handle)
delete handle;
return LIBUSB_ERROR_NO_DEVICE;
}
- *((USBDeviceHandle **)dev_handle->os_priv) = handle;
+ *((USBDeviceHandle **)usbi_get_device_handle_priv(dev_handle)) = handle;
return LIBUSB_SUCCESS;
}
static void
haiku_close(struct libusb_device_handle *dev_handle)
{
- USBDeviceHandle *handle = *((USBDeviceHandle **)dev_handle->os_priv);
+ USBDeviceHandle **pHandle = (USBDeviceHandle **)usbi_get_device_handle_priv(dev_handle);
+ USBDeviceHandle *handle = *pHandle;
if (handle == NULL)
return;
delete handle;
- *((USBDeviceHandle **)dev_handle->os_priv) = NULL;
-}
-
-static int
-haiku_get_device_descriptor(struct libusb_device *device, unsigned char *buffer, int *host_endian)
-{
- USBDevice *dev = *((USBDevice **)device->os_priv);
- memcpy(buffer, dev->Descriptor(), DEVICE_DESC_LENGTH);
- *host_endian = 0;
- return LIBUSB_SUCCESS;
+ *pHandle = NULL;
}
static int
-haiku_get_active_config_descriptor(struct libusb_device *device, unsigned char *buffer, size_t len, int *host_endian)
+haiku_get_active_config_descriptor(struct libusb_device *device, void *buffer, size_t len)
{
- USBDevice *dev = *((USBDevice **)device->os_priv);
- return haiku_get_config_descriptor(device, dev->ActiveConfigurationIndex(), buffer, len, host_endian);
+ USBDevice *dev = *((USBDevice **)usbi_get_device_priv(device));
+ return haiku_get_config_descriptor(device, dev->ActiveConfigurationIndex(), buffer, len);
}
static int
-haiku_get_config_descriptor(struct libusb_device *device, uint8_t config_index, unsigned char *buffer, size_t len, int *host_endian)
+haiku_get_config_descriptor(struct libusb_device *device, uint8_t config_index, void *buffer, size_t len)
{
- USBDevice *dev = *((USBDevice **)device->os_priv);
+ USBDevice *dev = *((USBDevice **)usbi_get_device_priv(device));
const usb_configuration_descriptor *config = dev->ConfigurationDescriptor(config_index);
if (config == NULL) {
usbi_err(DEVICE_CTX(device), "failed getting configuration descriptor");
- return LIBUSB_ERROR_INVALID_PARAM;
+ return LIBUSB_ERROR_IO;
}
if (len > config->total_length) {
len = config->total_length;
}
memcpy(buffer, config, len);
- *host_endian = 0;
return len;
}
static int
haiku_set_configuration(struct libusb_device_handle *dev_handle, int config)
{
- USBDeviceHandle *handle= *((USBDeviceHandle **)dev_handle->os_priv);
- return handle->SetConfiguration(config);
+ USBDeviceHandle *handle= *((USBDeviceHandle **)usbi_get_device_handle_priv(dev_handle));
+ if (config <= 0)
+ return LIBUSB_ERROR_NOT_SUPPORTED; // cannot unconfigure
+ return handle->SetConfiguration((uint8)config);
}
static int
-haiku_claim_interface(struct libusb_device_handle *dev_handle, int interface_number)
+haiku_claim_interface(struct libusb_device_handle *dev_handle, uint8_t interface_number)
{
- USBDeviceHandle *handle = *((USBDeviceHandle **)dev_handle->os_priv);
+ USBDeviceHandle *handle = *((USBDeviceHandle **)usbi_get_device_handle_priv(dev_handle));
return handle->ClaimInterface(interface_number);
}
static int
-haiku_set_altsetting(struct libusb_device_handle *dev_handle, int interface_number, int altsetting)
+haiku_set_altsetting(struct libusb_device_handle *dev_handle, uint8_t interface_number, uint8_t altsetting)
{
- USBDeviceHandle *handle = *((USBDeviceHandle **)dev_handle->os_priv);
+ USBDeviceHandle *handle = *((USBDeviceHandle **)usbi_get_device_handle_priv(dev_handle));
return handle->SetAltSetting(interface_number, altsetting);
}
static int
haiku_clear_halt(struct libusb_device_handle *dev_handle, unsigned char endpoint)
{
- USBDeviceHandle *handle = *((USBDeviceHandle **)dev_handle->os_priv);
+ USBDeviceHandle *handle = *((USBDeviceHandle **)usbi_get_device_handle_priv(dev_handle));
return handle->ClearHalt(endpoint);
}
static int
-haiku_reset_device(struct libusb_device_handle *dev_handle)
-{
- /* TODO */
- return LIBUSB_ERROR_NOT_SUPPORTED;
-}
-
-static int
-haiku_release_interface(struct libusb_device_handle *dev_handle, int interface_number)
+haiku_release_interface(struct libusb_device_handle *dev_handle, uint8_t interface_number)
{
- USBDeviceHandle *handle = *((USBDeviceHandle **)dev_handle->os_priv);
- haiku_set_altsetting(dev_handle,interface_number, 0);
+ USBDeviceHandle *handle = *((USBDeviceHandle **)usbi_get_device_handle_priv(dev_handle));
+ haiku_set_altsetting(dev_handle, interface_number, 0);
return handle->ReleaseInterface(interface_number);
}
@@ -153,7 +140,7 @@ static int
haiku_submit_transfer(struct usbi_transfer *itransfer)
{
struct libusb_transfer *fLibusbTransfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- USBDeviceHandle *fDeviceHandle = *((USBDeviceHandle **)fLibusbTransfer->dev_handle->os_priv);
+ USBDeviceHandle *fDeviceHandle = *((USBDeviceHandle **)usbi_get_device_handle_priv(fLibusbTransfer->dev_handle));
return fDeviceHandle->SubmitTransfer(itransfer);
}
@@ -161,27 +148,20 @@ static int
haiku_cancel_transfer(struct usbi_transfer *itransfer)
{
struct libusb_transfer *fLibusbTransfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- USBDeviceHandle *fDeviceHandle = *((USBDeviceHandle **)fLibusbTransfer->dev_handle->os_priv);
- return fDeviceHandle->CancelTransfer(*((USBTransfer **)usbi_transfer_get_os_priv(itransfer)));
-}
-
-static void
-haiku_clear_transfer_priv(struct usbi_transfer *itransfer)
-{
- USBTransfer *transfer = *((USBTransfer **)usbi_transfer_get_os_priv(itransfer));
- delete transfer;
- *((USBTransfer **)usbi_transfer_get_os_priv(itransfer)) = NULL;
+ USBDeviceHandle *fDeviceHandle = *((USBDeviceHandle **)usbi_get_device_handle_priv(fLibusbTransfer->dev_handle));
+ return fDeviceHandle->CancelTransfer(*((USBTransfer **)usbi_get_transfer_priv(itransfer)));
}
static int
haiku_handle_transfer_completion(struct usbi_transfer *itransfer)
{
- USBTransfer *transfer = *((USBTransfer **)usbi_transfer_get_os_priv(itransfer));
+ USBTransfer **pTransfer = (USBTransfer **)usbi_get_transfer_priv(itransfer);
+ USBTransfer *transfer = *pTransfer;
usbi_mutex_lock(&itransfer->lock);
if (transfer->IsCancelled()) {
delete transfer;
- *((USBTransfer **)usbi_transfer_get_os_priv(itransfer)) = NULL;
+ *pTransfer = NULL;
usbi_mutex_unlock(&itransfer->lock);
if (itransfer->transferred < 0)
itransfer->transferred = 0;
@@ -194,74 +174,58 @@ haiku_handle_transfer_completion(struct usbi_transfer *itransfer)
itransfer->transferred = 0;
}
delete transfer;
- *((USBTransfer **)usbi_transfer_get_os_priv(itransfer)) = NULL;
+ *pTransfer = NULL;
usbi_mutex_unlock(&itransfer->lock);
return usbi_handle_transfer_completion(itransfer, status);
}
-static int
-haiku_clock_gettime(int clkid, struct timespec *tp)
-{
- if (clkid == USBI_CLOCK_REALTIME)
- return clock_gettime(CLOCK_REALTIME, tp);
- if (clkid == USBI_CLOCK_MONOTONIC)
- return clock_gettime(CLOCK_MONOTONIC, tp);
- return LIBUSB_ERROR_INVALID_PARAM;
-}
-
const struct usbi_os_backend usbi_backend = {
- .name = "Haiku usbfs",
- .caps = 0,
- .init = haiku_init,
- .exit = haiku_exit,
- .set_option = NULL,
- .get_device_list = NULL,
- .hotplug_poll = NULL,
- .wrap_sys_device = NULL,
- .open = haiku_open,
- .close = haiku_close,
- .get_device_descriptor = haiku_get_device_descriptor,
- .get_active_config_descriptor = haiku_get_active_config_descriptor,
- .get_config_descriptor = haiku_get_config_descriptor,
- .get_config_descriptor_by_value = NULL,
-
-
- .get_configuration = NULL,
- .set_configuration = haiku_set_configuration,
- .claim_interface = haiku_claim_interface,
- .release_interface = haiku_release_interface,
-
- .set_interface_altsetting = haiku_set_altsetting,
- .clear_halt = haiku_clear_halt,
- .reset_device = haiku_reset_device,
-
- .alloc_streams = NULL,
- .free_streams = NULL,
-
- .dev_mem_alloc = NULL,
- .dev_mem_free = NULL,
-
- .kernel_driver_active = NULL,
- .detach_kernel_driver = NULL,
- .attach_kernel_driver = NULL,
-
- .destroy_device = NULL,
-
- .submit_transfer = haiku_submit_transfer,
- .cancel_transfer = haiku_cancel_transfer,
- .clear_transfer_priv = haiku_clear_transfer_priv,
-
- .handle_events = NULL,
- .handle_transfer_completion = haiku_handle_transfer_completion,
-
- .clock_gettime = haiku_clock_gettime,
-
-#ifdef USBI_TIMERFD_AVAILABLE
- .get_timerfd_clockid = NULL,
-#endif
-
- .context_priv_size = 0,
- .device_priv_size = sizeof(USBDevice *),
- .device_handle_priv_size = sizeof(USBDeviceHandle *),
- .transfer_priv_size = sizeof(USBTransfer *),
+ /*.name =*/ "Haiku usbfs",
+ /*.caps =*/ 0,
+ /*.init =*/ haiku_init,
+ /*.exit =*/ haiku_exit,
+ /*.set_option =*/ NULL,
+ /*.get_device_list =*/ NULL,
+ /*.hotplug_poll =*/ NULL,
+ /*.wrap_sys_device =*/ NULL,
+ /*.open =*/ haiku_open,
+ /*.close =*/ haiku_close,
+
+ /*.get_active_config_descriptor =*/ haiku_get_active_config_descriptor,
+ /*.get_config_descriptor =*/ haiku_get_config_descriptor,
+ /*.get_config_descriptor_by_value =*/ NULL,
+
+ /*.get_configuration =*/ NULL,
+ /*.set_configuration =*/ haiku_set_configuration,
+
+ /*.claim_interface =*/ haiku_claim_interface,
+ /*.release_interface =*/ haiku_release_interface,
+ /*.set_interface_altsetting =*/ haiku_set_altsetting,
+
+ /*.clear_halt =*/ haiku_clear_halt,
+ /*.reset_device =*/ NULL,
+
+ /*.alloc_streams =*/ NULL,
+ /*.free_streams =*/ NULL,
+
+ /*.dev_mem_alloc =*/ NULL,
+ /*.dev_mem_free =*/ NULL,
+
+ /*.kernel_driver_active =*/ NULL,
+ /*.detach_kernel_driver =*/ NULL,
+ /*.attach_kernel_driver =*/ NULL,
+
+ /*.destroy_device =*/ NULL,
+
+ /*.submit_transfer =*/ haiku_submit_transfer,
+ /*.cancel_transfer =*/ haiku_cancel_transfer,
+ /*.clear_transfer_priv =*/ NULL,
+
+ /*.handle_events =*/ NULL,
+ /*.handle_transfer_completion =*/ haiku_handle_transfer_completion,
+
+ /*.context_priv_size =*/ 0,
+ /*.device_priv_size =*/ sizeof(USBDevice *),
+ /*.device_handle_priv_size =*/ sizeof(USBDeviceHandle *),
+ /*.transfer_priv_size =*/ sizeof(USBTransfer *),
};
diff --git a/libusb/os/linux_netlink.c b/libusb/os/linux_netlink.c
index c1ad1ec..77c83c5 100644
--- a/libusb/os/linux_netlink.c
+++ b/libusb/os/linux_netlink.c
@@ -21,27 +21,21 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <config.h>
+#include "libusbi.h"
+#include "linux_usbfs.h"
-#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <poll.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <pthread.h>
#include <string.h>
#include <unistd.h>
-#include <sys/types.h>
#ifdef HAVE_ASM_TYPES_H
#include <asm/types.h>
#endif
-
-#include <sys/socket.h>
#include <linux/netlink.h>
-
-#include "libusbi.h"
-#include "linux_usbfs.h"
+#include <sys/socket.h>
#define NL_GROUP_KERNEL 1
@@ -54,7 +48,7 @@
#endif
static int linux_netlink_socket = -1;
-static int netlink_control_pipe[2] = { -1, -1 };
+static usbi_event_t netlink_control_event = USBI_INVALID_EVENT;
static pthread_t libusb_linux_event_thread;
static void *linux_netlink_event_thread_main(void *arg);
@@ -68,12 +62,12 @@ static int set_fd_cloexec_nb(int fd, int socktype)
if (!(socktype & SOCK_CLOEXEC)) {
flags = fcntl(fd, F_GETFD);
if (flags == -1) {
- usbi_err(NULL, "failed to get netlink fd flags (%d)", errno);
+ usbi_err(NULL, "failed to get netlink fd flags, errno=%d", errno);
return -1;
}
if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) {
- usbi_err(NULL, "failed to set netlink fd flags (%d)", errno);
+ usbi_err(NULL, "failed to set netlink fd flags, errno=%d", errno);
return -1;
}
}
@@ -83,12 +77,12 @@ static int set_fd_cloexec_nb(int fd, int socktype)
if (!(socktype & SOCK_NONBLOCK)) {
flags = fcntl(fd, F_GETFL);
if (flags == -1) {
- usbi_err(NULL, "failed to get netlink fd status flags (%d)", errno);
+ usbi_err(NULL, "failed to get netlink fd status flags, errno=%d", errno);
return -1;
}
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1) {
- usbi_err(NULL, "failed to set netlink fd status flags (%d)", errno);
+ usbi_err(NULL, "failed to set netlink fd status flags, errno=%d", errno);
return -1;
}
}
@@ -111,7 +105,7 @@ int linux_netlink_start_event_monitor(void)
}
if (linux_netlink_socket == -1) {
- usbi_err(NULL, "failed to create netlink socket (%d)", errno);
+ usbi_err(NULL, "failed to create netlink socket, errno=%d", errno);
goto err;
}
@@ -121,35 +115,33 @@ int linux_netlink_start_event_monitor(void)
ret = bind(linux_netlink_socket, (struct sockaddr *)&sa_nl, sizeof(sa_nl));
if (ret == -1) {
- usbi_err(NULL, "failed to bind netlink socket (%d)", errno);
+ usbi_err(NULL, "failed to bind netlink socket, errno=%d", errno);
goto err_close_socket;
}
ret = setsockopt(linux_netlink_socket, SOL_SOCKET, SO_PASSCRED, &opt, sizeof(opt));
if (ret == -1) {
- usbi_err(NULL, "failed to set netlink socket SO_PASSCRED option (%d)", errno);
+ usbi_err(NULL, "failed to set netlink socket SO_PASSCRED option, errno=%d", errno);
goto err_close_socket;
}
- ret = usbi_pipe(netlink_control_pipe);
+ ret = usbi_create_event(&netlink_control_event);
if (ret) {
- usbi_err(NULL, "failed to create netlink control pipe");
+ usbi_err(NULL, "failed to create netlink control event");
goto err_close_socket;
}
ret = pthread_create(&libusb_linux_event_thread, NULL, linux_netlink_event_thread_main, NULL);
if (ret != 0) {
usbi_err(NULL, "failed to create netlink event thread (%d)", ret);
- goto err_close_pipe;
+ goto err_destroy_event;
}
return LIBUSB_SUCCESS;
-err_close_pipe:
- close(netlink_control_pipe[0]);
- close(netlink_control_pipe[1]);
- netlink_control_pipe[0] = -1;
- netlink_control_pipe[1] = -1;
+err_destroy_event:
+ usbi_destroy_event(&netlink_control_event);
+ netlink_control_event = (usbi_event_t)USBI_INVALID_EVENT;
err_close_socket:
close(linux_netlink_socket);
linux_netlink_socket = -1;
@@ -159,28 +151,23 @@ err:
int linux_netlink_stop_event_monitor(void)
{
- char dummy = 1;
- ssize_t r;
+ int ret;
assert(linux_netlink_socket != -1);
- /* Write some dummy data to the control pipe and
- * wait for the thread to exit */
- r = write(netlink_control_pipe[1], &dummy, sizeof(dummy));
- if (r <= 0)
- usbi_warn(NULL, "netlink control pipe signal failed");
+ /* Signal the control event and wait for the thread to exit */
+ usbi_signal_event(&netlink_control_event);
- pthread_join(libusb_linux_event_thread, NULL);
+ ret = pthread_join(libusb_linux_event_thread, NULL);
+ if (ret)
+ usbi_warn(NULL, "failed to join netlink event thread (%d)", ret);
+
+ usbi_destroy_event(&netlink_control_event);
+ netlink_control_event = (usbi_event_t)USBI_INVALID_EVENT;
close(linux_netlink_socket);
linux_netlink_socket = -1;
- /* close and reset control pipe */
- close(netlink_control_pipe[0]);
- close(netlink_control_pipe[1]);
- netlink_control_pipe[0] = -1;
- netlink_control_pipe[1] = -1;
-
return LIBUSB_SUCCESS;
}
@@ -314,7 +301,7 @@ static int linux_netlink_read_message(void)
len = recvmsg(linux_netlink_socket, &msg, 0);
if (len == -1) {
if (errno != EAGAIN && errno != EINTR)
- usbi_err(NULL, "error receiving message from netlink (%d)", errno);
+ usbi_err(NULL, "error receiving message from netlink, errno=%d", errno);
return -1;
}
@@ -359,33 +346,38 @@ static int linux_netlink_read_message(void)
static void *linux_netlink_event_thread_main(void *arg)
{
- char dummy;
- int r;
- ssize_t nb;
struct pollfd fds[] = {
- { .fd = netlink_control_pipe[0],
- .events = POLLIN },
+ { .fd = USBI_EVENT_OS_HANDLE(&netlink_control_event),
+ .events = USBI_EVENT_POLL_EVENTS },
{ .fd = linux_netlink_socket,
.events = POLLIN },
};
+ int r;
UNUSED(arg);
+#if defined(HAVE_PTHREAD_SETNAME_NP)
+ r = pthread_setname_np(pthread_self(), "libusb_event");
+ if (r)
+ usbi_warn(NULL, "failed to set hotplug event thread name, error=%d", r);
+#endif
+
usbi_dbg("netlink event thread entering");
- while ((r = poll(fds, 2, -1)) >= 0 || errno == EINTR) {
- if (r < 0) {
- /* temporary failure */
- continue;
+ while (1) {
+ r = poll(fds, 2, -1);
+ if (r == -1) {
+ /* check for temporary failure */
+ if (errno == EINTR)
+ continue;
+ usbi_err(NULL, "poll() failed, errno=%d", errno);
+ break;
}
- if (fds[0].revents & POLLIN) {
- /* activity on control pipe, read the byte and exit */
- nb = read(netlink_control_pipe[0], &dummy, sizeof(dummy));
- if (nb <= 0)
- usbi_warn(NULL, "netlink control pipe read failed");
+ if (fds[0].revents) {
+ /* activity on control event, exit */
break;
}
- if (fds[1].revents & POLLIN) {
+ if (fds[1].revents) {
usbi_mutex_static_lock(&linux_hotplug_lock);
linux_netlink_read_message();
usbi_mutex_static_unlock(&linux_hotplug_lock);
diff --git a/libusb/os/linux_udev.c b/libusb/os/linux_udev.c
index bea03e3..beb2f05 100644
--- a/libusb/os/linux_udev.c
+++ b/libusb/os/linux_udev.c
@@ -20,36 +20,25 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <config.h>
+#include "libusbi.h"
+#include "linux_usbfs.h"
-#include <assert.h>
-#include <ctype.h>
-#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
+#include <libudev.h>
#include <poll.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <pthread.h>
#include <string.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/utsname.h>
-#include <sys/socket.h>
#include <unistd.h>
-#include <libudev.h>
-
-#include "libusbi.h"
-#include "linux_usbfs.h"
/* udev context */
static struct udev *udev_ctx = NULL;
static int udev_monitor_fd = -1;
-static int udev_control_pipe[2] = {-1, -1};
+static usbi_event_t udev_control_event = USBI_INVALID_EVENT;
static struct udev_monitor *udev_monitor = NULL;
static pthread_t linux_event_thread;
-static void udev_hotplug_event(struct udev_device* udev_dev);
+static void udev_hotplug_event(struct udev_device *udev_dev);
static void *linux_udev_event_thread_main(void *arg);
int linux_udev_start_event_monitor(void)
@@ -86,12 +75,12 @@ int linux_udev_start_event_monitor(void)
/* Make sure the udev file descriptor is marked as CLOEXEC */
r = fcntl(udev_monitor_fd, F_GETFD);
if (r == -1) {
- usbi_err(NULL, "geting udev monitor fd flags (%d)", errno);
+ usbi_err(NULL, "failed to get udev monitor fd flags, errno=%d", errno);
goto err_free_monitor;
}
if (!(r & FD_CLOEXEC)) {
if (fcntl(udev_monitor_fd, F_SETFD, r | FD_CLOEXEC) == -1) {
- usbi_err(NULL, "setting udev monitor fd flags (%d)", errno);
+ usbi_err(NULL, "failed to set udev monitor fd flags, errno=%d", errno);
goto err_free_monitor;
}
}
@@ -101,33 +90,33 @@ int linux_udev_start_event_monitor(void)
* so make sure this is set */
r = fcntl(udev_monitor_fd, F_GETFL);
if (r == -1) {
- usbi_err(NULL, "getting udev monitor fd status flags (%d)", errno);
+ usbi_err(NULL, "failed to get udev monitor fd status flags, errno=%d", errno);
goto err_free_monitor;
}
if (!(r & O_NONBLOCK)) {
if (fcntl(udev_monitor_fd, F_SETFL, r | O_NONBLOCK) == -1) {
- usbi_err(NULL, "setting udev monitor fd status flags (%d)", errno);
+ usbi_err(NULL, "failed to set udev monitor fd status flags, errno=%d", errno);
goto err_free_monitor;
}
}
- r = usbi_pipe(udev_control_pipe);
+ r = usbi_create_event(&udev_control_event);
if (r) {
- usbi_err(NULL, "could not create udev control pipe");
+ usbi_err(NULL, "failed to create udev control event");
goto err_free_monitor;
}
r = pthread_create(&linux_event_thread, NULL, linux_udev_event_thread_main, NULL);
if (r) {
- usbi_err(NULL, "creating hotplug event thread (%d)", r);
- goto err_close_pipe;
+ usbi_err(NULL, "failed to create hotplug event thread (%d)", r);
+ goto err_destroy_event;
}
return LIBUSB_SUCCESS;
-err_close_pipe:
- close(udev_control_pipe[0]);
- close(udev_control_pipe[1]);
+err_destroy_event:
+ usbi_destroy_event(&udev_control_event);
+ udev_control_event = (usbi_event_t)USBI_INVALID_EVENT;
err_free_monitor:
udev_monitor_unref(udev_monitor);
udev_monitor = NULL;
@@ -141,20 +130,21 @@ err:
int linux_udev_stop_event_monitor(void)
{
- char dummy = 1;
int r;
assert(udev_ctx != NULL);
assert(udev_monitor != NULL);
assert(udev_monitor_fd != -1);
- /* Write some dummy data to the control pipe and
- * wait for the thread to exit */
- r = write(udev_control_pipe[1], &dummy, sizeof(dummy));
- if (r <= 0) {
- usbi_warn(NULL, "udev control pipe signal failed");
- }
- pthread_join(linux_event_thread, NULL);
+ /* Signal the control event and wait for the thread to exit */
+ usbi_signal_event(&udev_control_event);
+
+ r = pthread_join(linux_event_thread, NULL);
+ if (r)
+ usbi_warn(NULL, "failed to join hotplug event thread (%d)", r);
+
+ usbi_destroy_event(&udev_control_event);
+ udev_control_event = (usbi_event_t)USBI_INVALID_EVENT;
/* Release the udev monitor */
udev_monitor_unref(udev_monitor);
@@ -165,44 +155,44 @@ int linux_udev_stop_event_monitor(void)
udev_unref(udev_ctx);
udev_ctx = NULL;
- /* close and reset control pipe */
- close(udev_control_pipe[0]);
- close(udev_control_pipe[1]);
- udev_control_pipe[0] = -1;
- udev_control_pipe[1] = -1;
-
return LIBUSB_SUCCESS;
}
static void *linux_udev_event_thread_main(void *arg)
{
- char dummy;
- int r;
- ssize_t nb;
- struct udev_device* udev_dev;
struct pollfd fds[] = {
- {.fd = udev_control_pipe[0],
- .events = POLLIN},
- {.fd = udev_monitor_fd,
- .events = POLLIN},
+ { .fd = USBI_EVENT_OS_HANDLE(&udev_control_event),
+ .events = USBI_EVENT_POLL_EVENTS },
+ { .fd = udev_monitor_fd,
+ .events = POLLIN },
};
+ struct udev_device *udev_dev;
+ int r;
- usbi_dbg("udev event thread entering.");
+ UNUSED(arg);
- while ((r = poll(fds, 2, -1)) >= 0 || errno == EINTR) {
- if (r < 0) {
- /* temporary failure */
- continue;
+#if defined(HAVE_PTHREAD_SETNAME_NP)
+ r = pthread_setname_np(pthread_self(), "libusb_event");
+ if (r)
+ usbi_warn(NULL, "failed to set hotplug event thread name, error=%d", r);
+#endif
+
+ usbi_dbg("udev event thread entering");
+
+ while (1) {
+ r = poll(fds, 2, -1);
+ if (r == -1) {
+ /* check for temporary failure */
+ if (errno == EINTR)
+ continue;
+ usbi_err(NULL, "poll() failed, errno=%d", errno);
+ break;
}
- if (fds[0].revents & POLLIN) {
- /* activity on control pipe, read the byte and exit */
- nb = read(udev_control_pipe[0], &dummy, sizeof(dummy));
- if (nb <= 0) {
- usbi_warn(NULL, "udev control pipe read failed");
- }
+ if (fds[0].revents) {
+ /* activity on control event, exit */
break;
}
- if (fds[1].revents & POLLIN) {
+ if (fds[1].revents) {
usbi_mutex_static_lock(&linux_hotplug_lock);
udev_dev = udev_monitor_receive_device(udev_monitor);
if (udev_dev)
@@ -235,10 +225,10 @@ static int udev_device_info(struct libusb_context *ctx, int detached,
dev_node, *sys_name, -1);
}
-static void udev_hotplug_event(struct udev_device* udev_dev)
+static void udev_hotplug_event(struct udev_device *udev_dev)
{
- const char* udev_action;
- const char* sys_name = NULL;
+ const char *udev_action;
+ const char *sys_name = NULL;
uint8_t busnum = 0, devaddr = 0;
int detached;
int r;
@@ -262,6 +252,8 @@ static void udev_hotplug_event(struct udev_device* udev_dev)
linux_hotplug_enumerate(busnum, devaddr, sys_name);
} else if (detached) {
linux_device_disconnected(busnum, devaddr);
+ } else if (strncmp(udev_action, "bind", 4) == 0) {
+ /* silently ignore "known unhandled" action */
} else {
usbi_err(NULL, "ignoring udev action %s", udev_action);
}
@@ -315,7 +307,7 @@ int linux_udev_scan_devices(struct libusb_context *ctx)
void linux_udev_hotplug_poll(void)
{
- struct udev_device* udev_dev;
+ struct udev_device *udev_dev;
usbi_mutex_static_lock(&linux_hotplug_lock);
do {
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c
index 63fe592..fb2ed53 100644
--- a/libusb/os/linux_usbfs.c
+++ b/libusb/os/linux_usbfs.c
@@ -5,6 +5,7 @@
* Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
* Copyright © 2013 Nathan Hjelm <hjelmn@mac.com>
* Copyright © 2012-2013 Hans de Goede <hdegoede@redhat.com>
+ * Copyright © 2020 Chris Dickens <christopher.a.dickens@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -21,26 +22,21 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "config.h"
+#include "libusbi.h"
+#include "linux_usbfs.h"
-#include <assert.h>
+#include <alloca.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
-#include <poll.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/types.h>
#include <sys/utsname.h>
-#include <time.h>
-
-#include "libusbi.h"
-#include "linux_usbfs.h"
+#include <sys/vfs.h>
+#include <unistd.h>
/* sysfs vs usbfs:
* opening a usbfs node causes the device to be resumed, so we attempt to
@@ -76,7 +72,8 @@
* In sysfs all descriptors are bus-endian.
*/
-static const char *usbfs_path = NULL;
+#define USBDEV_PATH "/dev"
+#define USB_DEVTMPFS_PATH "/dev/bus/usb"
/* use usbdev*.* device names in /dev instead of the usbfs bus directories */
static int usbdev_names = 0;
@@ -86,67 +83,33 @@ static int usbdev_names = 0;
* (commit 3612242e527eb47ee4756b5350f8bdf791aa5ede) increased this value to
* 8,192 bytes to support higher bandwidth devices. Linux 3.10
* (commit e2e2f0ea1c935edcf53feb4c4c8fdb4f86d57dd9) further increased this
- * value to 49,152 bytes to support super speed devices.
+ * value to 49,152 bytes to support super speed devices. Linux 5.2
+ * (commit 8a1dbc8d91d3d1602282c7e6b4222c7759c916fa) even further increased
+ * this value to 98,304 bytes to support super speed plus devices.
*/
static unsigned int max_iso_packet_len = 0;
-/* Linux 2.6.23 adds support for O_CLOEXEC when opening files, which marks the
- * close-on-exec flag in the underlying file descriptor. */
-static int supports_flag_cloexec = -1;
-
-/* Linux 2.6.32 adds support for a bulk continuation URB flag. this basically
- * allows us to mark URBs as being part of a specific logical transfer when
- * we submit them to the kernel. then, on any error except a cancellation, all
- * URBs within that transfer will be cancelled and no more URBs will be
- * accepted for the transfer, meaning that no more data can creep in.
- *
- * The BULK_CONTINUATION flag must be set on all URBs within a bulk transfer
- * (in either direction) except the first.
- * For IN transfers, we must also set SHORT_NOT_OK on all URBs except the
- * last; it means that the kernel should treat a short reply as an error.
- * For OUT transfers, SHORT_NOT_OK must not be set. it isn't needed (OUT
- * transfers can't be short unless there's already some sort of error), and
- * setting this flag is disallowed (a kernel with USB debugging enabled will
- * reject such URBs).
- */
-static int supports_flag_bulk_continuation = -1;
-
-/* Linux 2.6.31 fixes support for the zero length packet URB flag. This
- * allows us to mark URBs that should be followed by a zero length data
- * packet, which can be required by device- or class-specific protocols.
- */
-static int supports_flag_zero_packet = -1;
-
-/* clock ID for monotonic clock, as not all clock sources are available on all
- * systems. appropriate choice made at initialization time. */
-static clockid_t monotonic_clkid = -1;
-
-/* Linux 2.6.22 (commit 83f7d958eab2fbc6b159ee92bf1493924e1d0f72) adds a busnum
- * to sysfs, so we can relate devices. This also implies that we can read
- * the active configuration through bConfigurationValue */
-static int sysfs_can_relate_devices = -1;
-
-/* Linux 2.6.26 (commit 217a9081d8e69026186067711131b77f0ce219ed) adds all
- * config descriptors (rather then just the active config) to the sysfs
- * descriptors file, so from then on we can use them. */
-static int sysfs_has_descriptors = -1;
+/* is sysfs available (mounted) ? */
+static int sysfs_available = -1;
/* how many times have we initted (and not exited) ? */
static int init_count = 0;
+#ifdef __ANDROID__
+/* have no authority to operate usb device directly */
+static int weak_authority = 0;
+#endif
+
/* Serialize hotplug start/stop */
static usbi_mutex_static_t linux_hotplug_startstop_lock = USBI_MUTEX_INITIALIZER;
/* Serialize scan-devices, event-thread, and poll */
usbi_mutex_static_t linux_hotplug_lock = USBI_MUTEX_INITIALIZER;
-static int linux_start_event_monitor(void);
-static int linux_stop_event_monitor(void);
static int linux_scan_devices(struct libusb_context *ctx);
-static int sysfs_scan_device(struct libusb_context *ctx, const char *devname);
-static int detach_kernel_driver_and_claim(struct libusb_device_handle *, int);
+static int detach_kernel_driver_and_claim(struct libusb_device_handle *, uint8_t);
-#if !defined(USE_UDEV)
-static int linux_default_scan_devices (struct libusb_context *ctx);
+#if !defined(HAVE_LIBUDEV)
+static int linux_default_scan_devices(struct libusb_context *ctx);
#endif
struct kernel_version {
@@ -155,11 +118,17 @@ struct kernel_version {
int sublevel;
};
+struct config_descriptor {
+ struct usbi_configuration_descriptor *desc;
+ size_t actual_len;
+};
+
struct linux_device_priv {
char *sysfs_dir;
- unsigned char *descriptors;
- int descriptors_len;
- int active_config; /* cache val for !sysfs_can_relate_devices */
+ void *descriptors;
+ size_t descriptors_len;
+ struct config_descriptor *config_descriptors;
+ uint8_t active_config; /* cache val for !sysfs_available */
};
struct linux_device_handle_priv {
@@ -200,52 +169,42 @@ struct linux_transfer_priv {
int iso_packet_offset;
};
-static int _open(const char *path, int flags)
-{
-#if defined(O_CLOEXEC)
- if (supports_flag_cloexec)
- return open(path, flags | O_CLOEXEC);
- else
-#endif
- return open(path, flags);
-}
-
-static int _get_usbfs_fd(struct libusb_device *dev, mode_t mode, int silent)
+static int get_usbfs_fd(struct libusb_device *dev, mode_t mode, int silent)
{
struct libusb_context *ctx = DEVICE_CTX(dev);
- char path[PATH_MAX];
+ char path[24];
int fd;
- int delay = 10000;
if (usbdev_names)
- snprintf(path, PATH_MAX, "%s/usbdev%d.%d",
- usbfs_path, dev->bus_number, dev->device_address);
+ sprintf(path, USBDEV_PATH "/usbdev%u.%u",
+ dev->bus_number, dev->device_address);
else
- snprintf(path, PATH_MAX, "%s/%03d/%03d",
- usbfs_path, dev->bus_number, dev->device_address);
+ sprintf(path, USB_DEVTMPFS_PATH "/%03u/%03u",
+ dev->bus_number, dev->device_address);
- fd = _open(path, mode);
+ fd = open(path, mode | O_CLOEXEC);
if (fd != -1)
return fd; /* Success */
if (errno == ENOENT) {
- if (!silent)
- usbi_err(ctx, "File doesn't exist, wait %d ms and try again", delay/1000);
-
+ const long delay_ms = 10L;
+ const struct timespec delay_ts = { 0L, delay_ms * 1000L * 1000L };
+
+ if (!silent)
+ usbi_err(ctx, "File doesn't exist, wait %ld ms and try again", delay_ms);
+
/* Wait 10ms for USB device path creation.*/
- nanosleep(&(struct timespec){delay / 1000000, (delay * 1000) % 1000000000UL}, NULL);
+ nanosleep(&delay_ts, NULL);
- fd = _open(path, mode);
+ fd = open(path, mode | O_CLOEXEC);
if (fd != -1)
return fd; /* Success */
}
-
+
if (!silent) {
- usbi_err(ctx, "libusb couldn't open USB device %s: %s",
- path, strerror(errno));
+ usbi_err(ctx, "libusb couldn't open USB device %s, errno=%d", path, errno);
if (errno == EACCES && mode == O_RDWR)
- usbi_err(ctx, "libusb requires write access to USB "
- "device nodes.");
+ usbi_err(ctx, "libusb requires write access to USB device nodes");
}
if (errno == EACCES)
@@ -255,87 +214,69 @@ static int _get_usbfs_fd(struct libusb_device *dev, mode_t mode, int silent)
return LIBUSB_ERROR_IO;
}
-static struct linux_device_priv *_device_priv(struct libusb_device *dev)
-{
- return (struct linux_device_priv *) dev->os_priv;
-}
-
-static struct linux_device_handle_priv *_device_handle_priv(
- struct libusb_device_handle *handle)
-{
- return (struct linux_device_handle_priv *) handle->os_priv;
-}
-
/* check dirent for a /dev/usbdev%d.%d name
* optionally return bus/device on success */
-static int _is_usbdev_entry(struct dirent *entry, int *bus_p, int *dev_p)
+static int is_usbdev_entry(const char *name, uint8_t *bus_p, uint8_t *dev_p)
{
int busnum, devnum;
- if (sscanf(entry->d_name, "usbdev%d.%d", &busnum, &devnum) != 2)
+ if (sscanf(name, "usbdev%d.%d", &busnum, &devnum) != 2)
+ return 0;
+ if (busnum < 0 || busnum > UINT8_MAX || devnum < 0 || devnum > UINT8_MAX) {
+ usbi_dbg("invalid usbdev format '%s'", name);
return 0;
+ }
- usbi_dbg("found: %s", entry->d_name);
- if (bus_p != NULL)
- *bus_p = busnum;
- if (dev_p != NULL)
- *dev_p = devnum;
+ usbi_dbg("found: %s", name);
+ if (bus_p)
+ *bus_p = (uint8_t)busnum;
+ if (dev_p)
+ *dev_p = (uint8_t)devnum;
return 1;
}
-static int check_usb_vfs(const char *dirname)
+static const char *find_usbfs_path(void)
{
+ const char *path;
DIR *dir;
struct dirent *entry;
- int found = 0;
- dir = opendir(dirname);
- if (!dir)
- return 0;
+ path = USB_DEVTMPFS_PATH;
+ dir = opendir(path);
+ if (dir) {
+ while ((entry = readdir(dir))) {
+ if (entry->d_name[0] == '.')
+ continue;
- while ((entry = readdir(dir)) != NULL) {
- if (entry->d_name[0] == '.')
- continue;
+ /* We assume if we find any files that it must be the right place */
+ break;
+ }
- /* We assume if we find any files that it must be the right place */
- found = 1;
- break;
- }
+ closedir(dir);
- closedir(dir);
- return found;
-}
+ if (entry)
+ return path;
+ }
-static const char *find_usbfs_path(void)
-{
- const char *path = "/dev/bus/usb";
- const char *ret = NULL;
+ /* look for /dev/usbdev*.* if the normal place fails */
+ path = USBDEV_PATH;
+ dir = opendir(path);
+ if (dir) {
+ while ((entry = readdir(dir))) {
+ if (entry->d_name[0] == '.')
+ continue;
- if (check_usb_vfs(path)) {
- ret = path;
- } else {
- path = "/proc/bus/usb";
- if (check_usb_vfs(path))
- ret = path;
- }
-
- /* look for /dev/usbdev*.* if the normal places fail */
- if (ret == NULL) {
- struct dirent *entry;
- DIR *dir;
-
- path = "/dev";
- dir = opendir(path);
- if (dir != NULL) {
- while ((entry = readdir(dir)) != NULL) {
- if (_is_usbdev_entry(entry, NULL, NULL)) {
- /* found one; that's enough */
- ret = path;
- usbdev_names = 1;
- break;
- }
+ if (is_usbdev_entry(entry->d_name, NULL, NULL)) {
+ /* found one; that's enough */
+ break;
}
- closedir(dir);
+ }
+
+ closedir(dir);
+
+ if (entry) {
+ usbdev_names = 1;
+ return path;
}
}
@@ -344,34 +285,11 @@ static const char *find_usbfs_path(void)
* simply assume /dev/bus/usb rather then making libusb_init fail.
* Make the same assumption for Android where SELinux policies might block us
* from reading /dev on newer devices. */
-#if defined(USE_UDEV) || defined(__ANDROID__)
- if (ret == NULL)
- ret = "/dev/bus/usb";
-#endif
-
- if (ret != NULL)
- usbi_dbg("found usbfs at %s", ret);
-
- return ret;
-}
-
-/* the monotonic clock is not usable on all systems (e.g. embedded ones often
- * seem to lack it). fall back to REALTIME if we have to. */
-static clockid_t find_monotonic_clock(void)
-{
-#ifdef CLOCK_MONOTONIC
- struct timespec ts;
- int r;
-
- /* Linux 2.6.28 adds CLOCK_MONOTONIC_RAW but we don't use it
- * because it's not available through timerfd */
- r = clock_gettime(CLOCK_MONOTONIC, &ts);
- if (r == 0)
- return CLOCK_MONOTONIC;
- usbi_dbg("monotonic clock doesn't work, errno %d", errno);
+#if defined(HAVE_LIBUDEV) || defined(__ANDROID__)
+ return USB_DEVTMPFS_PATH;
+#else
+ return NULL;
#endif
-
- return CLOCK_REALTIME;
}
static int get_kernel_version(struct libusb_context *ctx,
@@ -381,18 +299,16 @@ static int get_kernel_version(struct libusb_context *ctx,
int atoms;
if (uname(&uts) < 0) {
- usbi_err(ctx, "uname failed, errno %d", errno);
+ usbi_err(ctx, "uname failed, errno=%d", errno);
return -1;
}
atoms = sscanf(uts.release, "%d.%d.%d", &ver->major, &ver->minor, &ver->sublevel);
- if (atoms < 1) {
+ if (atoms < 2) {
usbi_err(ctx, "failed to parse uname release '%s'", uts.release);
return -1;
}
- if (atoms < 2)
- ver->minor = -1;
if (atoms < 3)
ver->sublevel = -1;
@@ -410,16 +326,14 @@ static int kernel_version_ge(const struct kernel_version *ver,
return 0;
/* kmajor == major */
- if (ver->minor == -1 && ver->sublevel == -1)
- return 0 == minor && 0 == sublevel;
- else if (ver->minor > minor)
+ if (ver->minor > minor)
return 1;
else if (ver->minor < minor)
return 0;
/* kminor == minor */
if (ver->sublevel == -1)
- return 0 == sublevel;
+ return sublevel == 0;
return ver->sublevel >= sublevel;
}
@@ -427,77 +341,56 @@ static int kernel_version_ge(const struct kernel_version *ver,
static int op_init(struct libusb_context *ctx)
{
struct kernel_version kversion;
- struct stat statbuf;
+ const char *usbfs_path;
int r;
- usbfs_path = find_usbfs_path();
- if (!usbfs_path) {
- usbi_err(ctx, "could not find usbfs");
- return LIBUSB_ERROR_OTHER;
- }
-
- if (monotonic_clkid == -1)
- monotonic_clkid = find_monotonic_clock();
-
if (get_kernel_version(ctx, &kversion) < 0)
return LIBUSB_ERROR_OTHER;
- if (supports_flag_cloexec == -1) {
- /* O_CLOEXEC flag available from Linux 2.6.23 */
- supports_flag_cloexec = kernel_version_ge(&kversion,2,6,23);
- }
-
- if (supports_flag_bulk_continuation == -1) {
- /* bulk continuation URB flag available from Linux 2.6.32 */
- supports_flag_bulk_continuation = kernel_version_ge(&kversion,2,6,32);
+ if (!kernel_version_ge(&kversion, 2, 6, 32)) {
+ usbi_err(ctx, "kernel version is too old (reported as %d.%d.%d)",
+ kversion.major, kversion.minor,
+ kversion.sublevel != -1 ? kversion.sublevel : 0);
+ return LIBUSB_ERROR_NOT_SUPPORTED;
}
- if (supports_flag_bulk_continuation)
- usbi_dbg("bulk continuation flag supported");
-
- if (-1 == supports_flag_zero_packet) {
- /* zero length packet URB flag fixed since Linux 2.6.31 */
- supports_flag_zero_packet = kernel_version_ge(&kversion,2,6,31);
+ usbfs_path = find_usbfs_path();
+ if (!usbfs_path) {
+ usbi_err(ctx, "could not find usbfs");
+ return LIBUSB_ERROR_OTHER;
}
- if (supports_flag_zero_packet)
- usbi_dbg("zero length packet flag supported");
+ usbi_dbg("found usbfs at %s", usbfs_path);
if (!max_iso_packet_len) {
- if (kernel_version_ge(&kversion,3,10,0))
+ if (kernel_version_ge(&kversion, 5, 2, 0))
+ max_iso_packet_len = 98304;
+ else if (kernel_version_ge(&kversion, 3, 10, 0))
max_iso_packet_len = 49152;
- else if (kernel_version_ge(&kversion,2,6,18))
- max_iso_packet_len = 8192;
else
- max_iso_packet_len = 1023;
+ max_iso_packet_len = 8192;
}
usbi_dbg("max iso packet length is (likely) %u bytes", max_iso_packet_len);
- if (-1 == sysfs_has_descriptors) {
- /* sysfs descriptors has all descriptors since Linux 2.6.26 */
- sysfs_has_descriptors = kernel_version_ge(&kversion,2,6,26);
- }
-
- if (-1 == sysfs_can_relate_devices) {
- /* sysfs has busnum since Linux 2.6.22 */
- sysfs_can_relate_devices = kernel_version_ge(&kversion,2,6,22);
- }
+ if (sysfs_available == -1) {
+ struct statfs statfsbuf;
- if (sysfs_can_relate_devices || sysfs_has_descriptors) {
- r = stat(SYSFS_DEVICE_PATH, &statbuf);
- if (r != 0 || !S_ISDIR(statbuf.st_mode)) {
+ r = statfs(SYSFS_MOUNT_PATH, &statfsbuf);
+ if (r == 0 && statfsbuf.f_type == SYSFS_MAGIC) {
+ usbi_dbg("sysfs is available");
+ sysfs_available = 1;
+ } else {
usbi_warn(ctx, "sysfs not mounted");
- sysfs_can_relate_devices = 0;
- sysfs_has_descriptors = 0;
+ sysfs_available = 0;
}
}
- if (sysfs_can_relate_devices)
- usbi_dbg("sysfs can relate devices");
-
- if (sysfs_has_descriptors)
- usbi_dbg("sysfs has complete descriptors");
+#ifdef __ANDROID__
+ if (weak_authority) {
+ return LIBUSB_SUCCESS;
+ }
+#endif
usbi_mutex_static_lock(&linux_hotplug_startstop_lock);
r = LIBUSB_SUCCESS;
@@ -511,8 +404,9 @@ static int op_init(struct libusb_context *ctx)
init_count++;
else if (init_count == 0)
linux_stop_event_monitor();
- } else
+ } else {
usbi_err(ctx, "error starting hotplug event monitor");
+ }
usbi_mutex_static_unlock(&linux_hotplug_startstop_lock);
return r;
@@ -525,42 +419,38 @@ static void op_exit(struct libusb_context *ctx)
assert(init_count != 0);
if (!--init_count) {
/* tear down event handler */
- (void)linux_stop_event_monitor();
+ linux_stop_event_monitor();
}
usbi_mutex_static_unlock(&linux_hotplug_startstop_lock);
}
-static int linux_start_event_monitor(void)
+static int op_set_option(struct libusb_context *ctx, enum libusb_option option, va_list ap)
{
-#if defined(USE_UDEV)
- return linux_udev_start_event_monitor();
-#elif !defined(__ANDROID__)
- return linux_netlink_start_event_monitor();
-#else
- return LIBUSB_SUCCESS;
-#endif
-}
+ UNUSED(ctx);
+ UNUSED(ap);
-static int linux_stop_event_monitor(void)
-{
-#if defined(USE_UDEV)
- return linux_udev_stop_event_monitor();
-#elif !defined(__ANDROID__)
- return linux_netlink_stop_event_monitor();
+#ifdef __ANDROID__
+ if (option == LIBUSB_OPTION_WEAK_AUTHORITY) {
+ usbi_dbg("set libusb has weak authority");
+ weak_authority = 1;
+ return LIBUSB_SUCCESS;
+ }
#else
- return LIBUSB_SUCCESS;
+ UNUSED(option);
#endif
+
+ return LIBUSB_ERROR_NOT_SUPPORTED;
}
static int linux_scan_devices(struct libusb_context *ctx)
{
- int ret = 0;
+ int ret;
usbi_mutex_static_lock(&linux_hotplug_lock);
-#if defined(USE_UDEV)
+#if defined(HAVE_LIBUDEV)
ret = linux_udev_scan_devices(ctx);
-#elif !defined(__ANDROID__)
+#else
ret = linux_default_scan_devices(ctx);
#endif
@@ -571,25 +461,24 @@ static int linux_scan_devices(struct libusb_context *ctx)
static void op_hotplug_poll(void)
{
-#if defined(USE_UDEV)
- linux_udev_hotplug_poll();
-#elif !defined(__ANDROID__)
- linux_netlink_hotplug_poll();
-#endif
+ linux_hotplug_poll();
}
-static int _open_sysfs_attr(struct libusb_device *dev, const char *attr)
+static int open_sysfs_attr(struct libusb_context *ctx,
+ const char *sysfs_dir, const char *attr)
{
- struct linux_device_priv *priv = _device_priv(dev);
- char filename[PATH_MAX];
+ char filename[256];
int fd;
- snprintf(filename, PATH_MAX, "%s/%s/%s",
- SYSFS_DEVICE_PATH, priv->sysfs_dir, attr);
- fd = _open(filename, O_RDONLY);
+ snprintf(filename, sizeof(filename), SYSFS_DEVICE_PATH "/%s/%s", sysfs_dir, attr);
+ fd = open(filename, O_RDONLY | O_CLOEXEC);
if (fd < 0) {
- usbi_err(DEVICE_CTX(dev),
- "open %s failed ret=%d errno=%d", filename, fd, errno);
+ if (errno == ENOENT) {
+ /* File doesn't exist. Assume the device has been
+ disconnected (see trac ticket #70). */
+ return LIBUSB_ERROR_NO_DEVICE;
+ }
+ usbi_err(ctx, "open %s failed, errno=%d", filename, errno);
return LIBUSB_ERROR_IO;
}
@@ -597,291 +486,323 @@ static int _open_sysfs_attr(struct libusb_device *dev, const char *attr)
}
/* Note only suitable for attributes which always read >= 0, < 0 is error */
-static int __read_sysfs_attr(struct libusb_context *ctx,
- const char *devname, const char *attr)
+static int read_sysfs_attr(struct libusb_context *ctx,
+ const char *sysfs_dir, const char *attr, int max_value, int *value_p)
{
- char filename[PATH_MAX];
- FILE *f;
- int fd, r, value;
+ char buf[20], *endptr;
+ long value;
+ ssize_t r;
+ int fd;
- snprintf(filename, PATH_MAX, "%s/%s/%s", SYSFS_DEVICE_PATH,
- devname, attr);
- fd = _open(filename, O_RDONLY);
- if (fd == -1) {
- if (errno == ENOENT) {
- /* File doesn't exist. Assume the device has been
- disconnected (see trac ticket #70). */
+ fd = open_sysfs_attr(ctx, sysfs_dir, attr);
+ if (fd < 0)
+ return fd;
+
+ r = read(fd, buf, sizeof(buf));
+ if (r < 0) {
+ r = errno;
+ close(fd);
+ if (r == ENODEV)
return LIBUSB_ERROR_NO_DEVICE;
- }
- usbi_err(ctx, "open %s failed errno=%d", filename, errno);
+ usbi_err(ctx, "attribute %s read failed, errno=%zd", attr, r);
return LIBUSB_ERROR_IO;
}
+ close(fd);
- f = fdopen(fd, "r");
- if (f == NULL) {
- usbi_err(ctx, "fdopen %s failed errno=%d", filename, errno);
- close(fd);
- return LIBUSB_ERROR_OTHER;
+ if (r == 0) {
+ /* Certain attributes (e.g. bConfigurationValue) are not
+ * populated if the device is not configured. */
+ *value_p = -1;
+ return 0;
}
- r = fscanf(f, "%d", &value);
- fclose(f);
- if (r != 1) {
- usbi_err(ctx, "fscanf %s returned %d, errno=%d", attr, r, errno);
- return LIBUSB_ERROR_NO_DEVICE; /* For unplug race (trac #70) */
- }
- if (value < 0) {
- usbi_err(ctx, "%s contains a negative value", filename);
+ /* The kernel does *not* NULL-terminate the string, but every attribute
+ * should be terminated with a newline character. */
+ if (!isdigit(buf[0])) {
+ usbi_err(ctx, "attribute %s doesn't have numeric value?", attr);
+ return LIBUSB_ERROR_IO;
+ } else if (buf[r - 1] != '\n') {
+ usbi_err(ctx, "attribute %s doesn't end with newline?", attr);
return LIBUSB_ERROR_IO;
}
+ buf[r - 1] = '\0';
- return value;
+ errno = 0;
+ value = strtol(buf, &endptr, 10);
+ if (value < 0 || value > (long)max_value || errno) {
+ usbi_err(ctx, "attribute %s contains an invalid value: '%s'", attr, buf);
+ return LIBUSB_ERROR_INVALID_PARAM;
+ } else if (*endptr != '\0') {
+ /* Consider the value to be valid if the remainder is a '.'
+ * character followed by numbers. This occurs, for example,
+ * when reading the "speed" attribute for a low-speed device
+ * (e.g. "1.5") */
+ if (*endptr == '.' && isdigit(*(endptr + 1))) {
+ endptr++;
+ while (isdigit(*endptr))
+ endptr++;
+ }
+ if (*endptr != '\0') {
+ usbi_err(ctx, "attribute %s contains an invalid value: '%s'", attr, buf);
+ return LIBUSB_ERROR_INVALID_PARAM;
+ }
+ }
+
+ *value_p = (int)value;
+ return 0;
}
-static int op_get_device_descriptor(struct libusb_device *dev,
- unsigned char *buffer, int *host_endian)
+static int sysfs_scan_device(struct libusb_context *ctx, const char *devname)
{
- struct linux_device_priv *priv = _device_priv(dev);
+ uint8_t busnum, devaddr;
+ int ret;
- *host_endian = (priv->sysfs_dir && sysfs_has_descriptors) ? 0 : 1;
- memcpy(buffer, priv->descriptors, DEVICE_DESC_LENGTH);
+ ret = linux_get_device_address(ctx, 0, &busnum, &devaddr, NULL, devname, -1);
+ if (ret != LIBUSB_SUCCESS)
+ return ret;
- return 0;
+ return linux_enumerate_device(ctx, busnum, devaddr, devname);
}
/* read the bConfigurationValue for a device */
-static int sysfs_get_active_config(struct libusb_device *dev, int *config)
+static int sysfs_get_active_config(struct libusb_device *dev, uint8_t *config)
{
- char *endptr;
- char tmp[5] = {0, 0, 0, 0, 0};
- long num;
- int fd;
- ssize_t r;
-
- fd = _open_sysfs_attr(dev, "bConfigurationValue");
- if (fd < 0)
- return fd;
+ struct linux_device_priv *priv = usbi_get_device_priv(dev);
+ int ret, tmp;
- r = read(fd, tmp, sizeof(tmp));
- close(fd);
- if (r < 0) {
- usbi_err(DEVICE_CTX(dev),
- "read bConfigurationValue failed ret=%zd errno=%d", r, errno);
- return LIBUSB_ERROR_IO;
- } else if (r == 0) {
- usbi_dbg("device unconfigured");
- *config = -1;
- return 0;
- }
+ ret = read_sysfs_attr(DEVICE_CTX(dev), priv->sysfs_dir, "bConfigurationValue",
+ UINT8_MAX, &tmp);
+ if (ret < 0)
+ return ret;
- if (tmp[sizeof(tmp) - 1] != 0) {
- usbi_err(DEVICE_CTX(dev), "not null-terminated?");
- return LIBUSB_ERROR_IO;
- } else if (tmp[0] == 0) {
- usbi_err(DEVICE_CTX(dev), "no configuration value?");
- return LIBUSB_ERROR_IO;
- }
+ if (tmp == -1)
+ tmp = 0; /* unconfigured */
- num = strtol(tmp, &endptr, 10);
- if (endptr == tmp) {
- usbi_err(DEVICE_CTX(dev), "error converting '%s' to integer", tmp);
- return LIBUSB_ERROR_IO;
- }
+ *config = (uint8_t)tmp;
- *config = (int) num;
return 0;
}
-int linux_get_device_address (struct libusb_context *ctx, int detached,
- uint8_t *busnum, uint8_t *devaddr,const char *dev_node,
+int linux_get_device_address(struct libusb_context *ctx, int detached,
+ uint8_t *busnum, uint8_t *devaddr, const char *dev_node,
const char *sys_name, int fd)
{
- char proc_path[PATH_MAX], fd_path[PATH_MAX];
- int sysfs_attr;
- ssize_t r;
+ int sysfs_val;
+ int r;
usbi_dbg("getting address for device: %s detached: %d", sys_name, detached);
/* can't use sysfs to read the bus and device number if the
* device has been detached */
- if (!sysfs_can_relate_devices || detached || NULL == sys_name) {
- if (NULL == dev_node && fd >= 0) {
+ if (!sysfs_available || detached || !sys_name) {
+ if (!dev_node && fd >= 0) {
+ char *fd_path = alloca(PATH_MAX);
+ char proc_path[32];
+
/* try to retrieve the device node from fd */
- snprintf(proc_path, PATH_MAX, "/proc/self/fd/%d", fd);
- r = readlink(proc_path, fd_path, PATH_MAX);
- if (r > 0)
+ sprintf(proc_path, "/proc/self/fd/%d", fd);
+ r = readlink(proc_path, fd_path, PATH_MAX - 1);
+ if (r > 0) {
+ fd_path[r] = '\0';
dev_node = fd_path;
+ }
}
- if (NULL == dev_node) {
+
+ if (!dev_node)
return LIBUSB_ERROR_OTHER;
- }
/* will this work with all supported kernel versions? */
- if (!strncmp(dev_node, "/dev/bus/usb", 12)) {
- sscanf (dev_node, "/dev/bus/usb/%hhu/%hhu", busnum, devaddr);
- } else if (!strncmp(dev_node, "/proc/bus/usb", 13)) {
- sscanf (dev_node, "/proc/bus/usb/%hhu/%hhu", busnum, devaddr);
- } else {
+ if (!strncmp(dev_node, "/dev/bus/usb", 12))
+ sscanf(dev_node, "/dev/bus/usb/%hhu/%hhu", busnum, devaddr);
+ else
return LIBUSB_ERROR_OTHER;
- }
return LIBUSB_SUCCESS;
}
usbi_dbg("scan %s", sys_name);
- sysfs_attr = __read_sysfs_attr(ctx, sys_name, "busnum");
- if (0 > sysfs_attr)
- return sysfs_attr;
- if (sysfs_attr > 255)
- return LIBUSB_ERROR_INVALID_PARAM;
- *busnum = (uint8_t) sysfs_attr;
-
- sysfs_attr = __read_sysfs_attr(ctx, sys_name, "devnum");
- if (0 > sysfs_attr)
- return sysfs_attr;
- if (sysfs_attr > 255)
- return LIBUSB_ERROR_INVALID_PARAM;
+ r = read_sysfs_attr(ctx, sys_name, "busnum", UINT8_MAX, &sysfs_val);
+ if (r < 0)
+ return r;
+ *busnum = (uint8_t)sysfs_val;
- *devaddr = (uint8_t) sysfs_attr;
+ r = read_sysfs_attr(ctx, sys_name, "devnum", UINT8_MAX, &sysfs_val);
+ if (r < 0)
+ return r;
+ *devaddr = (uint8_t)sysfs_val;
- usbi_dbg("bus=%d dev=%d", *busnum, *devaddr);
+ usbi_dbg("bus=%u dev=%u", *busnum, *devaddr);
return LIBUSB_SUCCESS;
}
-/* Return offset of the next descriptor with the given type */
-static int seek_to_next_descriptor(struct libusb_context *ctx,
- uint8_t descriptor_type, unsigned char *buffer, int size)
+/* Return offset of the next config descriptor */
+static int seek_to_next_config(struct libusb_context *ctx,
+ uint8_t *buffer, size_t len)
{
- struct usb_descriptor_header header;
- int i;
+ struct usbi_descriptor_header *header;
+ int offset = 0;
- for (i = 0; size >= 0; i += header.bLength, size -= header.bLength) {
- if (size == 0)
- return LIBUSB_ERROR_NOT_FOUND;
+ while (len > 0) {
+ if (len < 2) {
+ usbi_err(ctx, "short descriptor read %zu/2", len);
+ return LIBUSB_ERROR_IO;
+ }
+
+ header = (struct usbi_descriptor_header *)buffer;
+ if (header->bDescriptorType == LIBUSB_DT_CONFIG)
+ return offset;
- if (size < 2) {
- usbi_err(ctx, "short descriptor read %d/2", size);
+ if (len < header->bLength) {
+ usbi_err(ctx, "bLength overflow by %zu bytes",
+ (size_t)header->bLength - len);
return LIBUSB_ERROR_IO;
}
- usbi_parse_descriptor(buffer + i, "bb", &header, 0);
- if (i && header.bDescriptorType == descriptor_type)
- return i;
+ offset += header->bLength;
+ buffer += header->bLength;
+ len -= header->bLength;
}
- usbi_err(ctx, "bLength overflow by %d bytes", -size);
+
+ usbi_err(ctx, "config descriptor not found");
return LIBUSB_ERROR_IO;
}
-/* Return offset to next config */
-static int seek_to_next_config(struct libusb_device *dev,
- unsigned char *buffer, int size)
+static int parse_config_descriptors(struct libusb_device *dev)
{
struct libusb_context *ctx = DEVICE_CTX(dev);
- struct linux_device_priv *priv = _device_priv(dev);
- struct libusb_config_descriptor config;
+ struct linux_device_priv *priv = usbi_get_device_priv(dev);
+ struct usbi_device_descriptor *device_desc;
+ uint8_t idx, num_configs;
+ uint8_t *buffer;
+ size_t remaining;
- if (size == 0)
- return LIBUSB_ERROR_NOT_FOUND;
+ device_desc = priv->descriptors;
+ num_configs = device_desc->bNumConfigurations;
- if (size < LIBUSB_DT_CONFIG_SIZE) {
- usbi_err(ctx, "short descriptor read %d/%d",
- size, LIBUSB_DT_CONFIG_SIZE);
- return LIBUSB_ERROR_IO;
- }
+ if (num_configs == 0)
+ return 0; /* no configurations? */
- usbi_parse_descriptor(buffer, "bbwbbbbb", &config, 0);
- if (config.bDescriptorType != LIBUSB_DT_CONFIG) {
- usbi_err(ctx, "descriptor is not a config desc (type 0x%02x)",
- config.bDescriptorType);
- return LIBUSB_ERROR_IO;
- }
+ priv->config_descriptors = malloc(num_configs * sizeof(priv->config_descriptors[0]));
+ if (!priv->config_descriptors)
+ return LIBUSB_ERROR_NO_MEM;
- /*
- * In usbfs the config descriptors are config.wTotalLength bytes apart,
- * with any short reads from the device appearing as holes in the file.
- *
- * In sysfs wTotalLength is ignored, instead the kernel returns a
- * config descriptor with verified bLength fields, with descriptors
- * with an invalid bLength removed.
- */
- if (priv->sysfs_dir && sysfs_has_descriptors) {
- int next = seek_to_next_descriptor(ctx, LIBUSB_DT_CONFIG,
- buffer, size);
- if (next == LIBUSB_ERROR_NOT_FOUND)
- next = size;
- if (next < 0)
- return next;
-
- if (next != config.wTotalLength)
- usbi_warn(ctx, "config length mismatch wTotalLength "
- "%d real %d", config.wTotalLength, next);
- return next;
- } else {
- if (config.wTotalLength < LIBUSB_DT_CONFIG_SIZE) {
- usbi_err(ctx, "invalid wTotalLength %d",
- config.wTotalLength);
+ buffer = (uint8_t *)priv->descriptors + LIBUSB_DT_DEVICE_SIZE;
+ remaining = priv->descriptors_len - LIBUSB_DT_DEVICE_SIZE;
+
+ for (idx = 0; idx < num_configs; idx++) {
+ struct usbi_configuration_descriptor *config_desc;
+ uint16_t config_len;
+
+ if (remaining < LIBUSB_DT_CONFIG_SIZE) {
+ usbi_err(ctx, "short descriptor read %zu/%d",
+ remaining, LIBUSB_DT_CONFIG_SIZE);
+ return LIBUSB_ERROR_IO;
+ }
+
+ config_desc = (struct usbi_configuration_descriptor *)buffer;
+ if (config_desc->bDescriptorType != LIBUSB_DT_CONFIG) {
+ usbi_err(ctx, "descriptor is not a config desc (type 0x%02x)",
+ config_desc->bDescriptorType);
+ return LIBUSB_ERROR_IO;
+ } else if (config_desc->bLength < LIBUSB_DT_CONFIG_SIZE) {
+ usbi_err(ctx, "invalid descriptor bLength %u",
+ config_desc->bLength);
+ return LIBUSB_ERROR_IO;
+ }
+
+ config_len = libusb_le16_to_cpu(config_desc->wTotalLength);
+ if (config_len < LIBUSB_DT_CONFIG_SIZE) {
+ usbi_err(ctx, "invalid wTotalLength %u", config_len);
return LIBUSB_ERROR_IO;
- } else if (config.wTotalLength > size) {
- usbi_warn(ctx, "short descriptor read %d/%d",
- size, config.wTotalLength);
- return size;
- } else
- return config.wTotalLength;
+ }
+
+ if (priv->sysfs_dir) {
+ /*
+ * In sysfs wTotalLength is ignored, instead the kernel returns a
+ * config descriptor with verified bLength fields, with descriptors
+ * with an invalid bLength removed.
+ */
+ uint16_t sysfs_config_len;
+ int offset;
+
+ if (num_configs > 1 && idx < num_configs - 1) {
+ offset = seek_to_next_config(ctx, buffer + LIBUSB_DT_CONFIG_SIZE,
+ remaining - LIBUSB_DT_CONFIG_SIZE);
+ if (offset < 0)
+ return offset;
+ sysfs_config_len = (uint16_t)offset;
+ } else {
+ sysfs_config_len = (uint16_t)remaining;
+ }
+
+ if (config_len != sysfs_config_len) {
+ usbi_warn(ctx, "config length mismatch wTotalLength %u real %u",
+ config_len, sysfs_config_len);
+ config_len = sysfs_config_len;
+ }
+ } else {
+ /*
+ * In usbfs the config descriptors are wTotalLength bytes apart,
+ * with any short reads from the device appearing as holes in the file.
+ */
+ if (config_len > remaining) {
+ usbi_warn(ctx, "short descriptor read %zu/%u", remaining, config_len);
+ config_len = (uint16_t)remaining;
+ }
+ }
+
+ priv->config_descriptors[idx].desc = config_desc;
+ priv->config_descriptors[idx].actual_len = config_len;
+
+ buffer += config_len;
+ remaining -= config_len;
}
+
+ return LIBUSB_SUCCESS;
}
static int op_get_config_descriptor_by_value(struct libusb_device *dev,
- uint8_t value, unsigned char **buffer, int *host_endian)
-{
- struct linux_device_priv *priv = _device_priv(dev);
- unsigned char *descriptors = priv->descriptors;
- int size = priv->descriptors_len;
- struct libusb_config_descriptor *config;
-
- *buffer = NULL;
- /* Unlike the device desc. config descs. are always in raw format */
- *host_endian = 0;
-
- /* Skip device header */
- descriptors += DEVICE_DESC_LENGTH;
- size -= DEVICE_DESC_LENGTH;
-
- /* Seek till the config is found, or till "EOF" */
- while (1) {
- int next = seek_to_next_config(dev, descriptors, size);
- if (next < 0)
- return next;
- config = (struct libusb_config_descriptor *)descriptors;
- if (config->bConfigurationValue == value) {
- *buffer = descriptors;
- return next;
+ uint8_t value, void **buffer)
+{
+ struct linux_device_priv *priv = usbi_get_device_priv(dev);
+ struct config_descriptor *config;
+ uint8_t idx;
+
+ for (idx = 0; idx < dev->device_descriptor.bNumConfigurations; idx++) {
+ config = &priv->config_descriptors[idx];
+ if (config->desc->bConfigurationValue == value) {
+ *buffer = config->desc;
+ return (int)config->actual_len;
}
- size -= next;
- descriptors += next;
}
+
+ return LIBUSB_ERROR_NOT_FOUND;
}
static int op_get_active_config_descriptor(struct libusb_device *dev,
- unsigned char *buffer, size_t len, int *host_endian)
+ void *buffer, size_t len)
{
- struct linux_device_priv *priv = _device_priv(dev);
- int r, config;
- unsigned char *config_desc;
+ struct linux_device_priv *priv = usbi_get_device_priv(dev);
+ void *config_desc;
+ uint8_t active_config;
+ int r;
- if (priv->sysfs_dir && sysfs_can_relate_devices) {
- r = sysfs_get_active_config(dev, &config);
+ if (priv->sysfs_dir) {
+ r = sysfs_get_active_config(dev, &active_config);
if (r < 0)
return r;
} else {
/* Use cached bConfigurationValue */
- config = priv->active_config;
+ active_config = priv->active_config;
}
- if (config == -1)
+
+ if (active_config == 0) {
+ usbi_err(DEVICE_CTX(dev), "device unconfigured");
return LIBUSB_ERROR_NOT_FOUND;
+ }
- r = op_get_config_descriptor_by_value(dev, config, &config_desc,
- host_endian);
+ r = op_get_config_descriptor_by_value(dev, active_config, &config_desc);
if (r < 0)
return r;
@@ -891,40 +812,25 @@ static int op_get_active_config_descriptor(struct libusb_device *dev,
}
static int op_get_config_descriptor(struct libusb_device *dev,
- uint8_t config_index, unsigned char *buffer, size_t len, int *host_endian)
+ uint8_t config_index, void *buffer, size_t len)
{
- struct linux_device_priv *priv = _device_priv(dev);
- unsigned char *descriptors = priv->descriptors;
- int i, r, size = priv->descriptors_len;
-
- /* Unlike the device desc. config descs. are always in raw format */
- *host_endian = 0;
-
- /* Skip device header */
- descriptors += DEVICE_DESC_LENGTH;
- size -= DEVICE_DESC_LENGTH;
+ struct linux_device_priv *priv = usbi_get_device_priv(dev);
+ struct config_descriptor *config;
- /* Seek till the config is found, or till "EOF" */
- for (i = 0; ; i++) {
- r = seek_to_next_config(dev, descriptors, size);
- if (r < 0)
- return r;
- if (i == config_index)
- break;
- size -= r;
- descriptors += r;
- }
+ if (config_index >= dev->device_descriptor.bNumConfigurations)
+ return LIBUSB_ERROR_NOT_FOUND;
- len = MIN(len, (size_t)r);
- memcpy(buffer, descriptors, len);
+ config = &priv->config_descriptors[config_index];
+ len = MIN(len, config->actual_len);
+ memcpy(buffer, config->desc, len);
return len;
}
/* send a control message to retrieve active configuration */
static int usbfs_get_active_config(struct libusb_device *dev, int fd)
{
- struct linux_device_priv *priv = _device_priv(dev);
- unsigned char active_config = 0;
+ struct linux_device_priv *priv = usbi_get_device_priv(dev);
+ uint8_t active_config = 0;
int r;
struct usbfs_ctrltransfer ctrl = {
@@ -943,35 +849,49 @@ static int usbfs_get_active_config(struct libusb_device *dev, int fd)
return LIBUSB_ERROR_NO_DEVICE;
/* we hit this error path frequently with buggy devices :( */
- usbi_warn(DEVICE_CTX(dev),
- "get_configuration failed ret=%d errno=%d", r, errno);
- priv->active_config = -1;
- } else {
- if (active_config > 0) {
- priv->active_config = active_config;
- } else {
- /* some buggy devices have a configuration 0, but we're
- * reaching into the corner of a corner case here, so let's
- * not support buggy devices in these circumstances.
- * stick to the specs: a configuration value of 0 means
- * unconfigured. */
- usbi_warn(DEVICE_CTX(dev),
- "active cfg 0? assuming unconfigured device");
- priv->active_config = -1;
- }
+ usbi_warn(DEVICE_CTX(dev), "get configuration failed, errno=%d", errno);
+ } else if (active_config == 0) {
+ /* some buggy devices have a configuration 0, but we're
+ * reaching into the corner of a corner case here, so let's
+ * not support buggy devices in these circumstances.
+ * stick to the specs: a configuration value of 0 means
+ * unconfigured. */
+ usbi_warn(DEVICE_CTX(dev), "active cfg 0? assuming unconfigured device");
}
+ priv->active_config = active_config;
+
return LIBUSB_SUCCESS;
}
+static enum libusb_speed usbfs_get_speed(struct libusb_context *ctx, int fd)
+{
+ int r;
+
+ r = ioctl(fd, IOCTL_USBFS_GET_SPEED, NULL);
+ switch (r) {
+ case USBFS_SPEED_UNKNOWN: return LIBUSB_SPEED_UNKNOWN;
+ case USBFS_SPEED_LOW: return LIBUSB_SPEED_LOW;
+ case USBFS_SPEED_FULL: return LIBUSB_SPEED_FULL;
+ case USBFS_SPEED_HIGH: return LIBUSB_SPEED_HIGH;
+ case USBFS_SPEED_WIRELESS: return LIBUSB_SPEED_HIGH;
+ case USBFS_SPEED_SUPER: return LIBUSB_SPEED_SUPER;
+ case USBFS_SPEED_SUPER_PLUS: return LIBUSB_SPEED_SUPER_PLUS;
+ default:
+ usbi_warn(ctx, "Error getting device speed: %d", r);
+ }
+
+ return LIBUSB_SPEED_UNKNOWN;
+}
+
static int initialize_device(struct libusb_device *dev, uint8_t busnum,
uint8_t devaddr, const char *sysfs_dir, int wrapped_fd)
{
- struct linux_device_priv *priv = _device_priv(dev);
+ struct linux_device_priv *priv = usbi_get_device_priv(dev);
struct libusb_context *ctx = DEVICE_CTX(dev);
- int descriptors_size = 512; /* Begin with a 1024 byte alloc */
- int fd, speed;
- ssize_t r;
+ size_t alloc_len;
+ int fd, speed, r;
+ ssize_t nb;
dev->bus_number = busnum;
dev->device_address = devaddr;
@@ -981,10 +901,9 @@ static int initialize_device(struct libusb_device *dev, uint8_t busnum,
if (!priv->sysfs_dir)
return LIBUSB_ERROR_NO_MEM;
- /* Note speed can contain 1.5, in this case __read_sysfs_attr
+ /* Note speed can contain 1.5, in this case read_sysfs_attr()
will stop parsing at the '.' and return 1 */
- speed = __read_sysfs_attr(DEVICE_CTX(dev), sysfs_dir, "speed");
- if (speed >= 0) {
+ if (read_sysfs_attr(ctx, sysfs_dir, "speed", INT_MAX, &speed) == 0) {
switch (speed) {
case 1: dev->speed = LIBUSB_SPEED_LOW; break;
case 12: dev->speed = LIBUSB_SPEED_FULL; break;
@@ -992,68 +911,78 @@ static int initialize_device(struct libusb_device *dev, uint8_t busnum,
case 5000: dev->speed = LIBUSB_SPEED_SUPER; break;
case 10000: dev->speed = LIBUSB_SPEED_SUPER_PLUS; break;
default:
- usbi_warn(DEVICE_CTX(dev), "Unknown device speed: %d Mbps", speed);
+ usbi_warn(ctx, "unknown device speed: %d Mbps", speed);
}
}
+ } else if (wrapped_fd >= 0) {
+ dev->speed = usbfs_get_speed(ctx, wrapped_fd);
}
/* cache descriptors in memory */
- if (sysfs_dir && sysfs_has_descriptors) {
- fd = _open_sysfs_attr(dev, "descriptors");
+ if (sysfs_dir) {
+ fd = open_sysfs_attr(ctx, sysfs_dir, "descriptors");
} else if (wrapped_fd < 0) {
- fd = _get_usbfs_fd(dev, O_RDONLY, 0);
+ fd = get_usbfs_fd(dev, O_RDONLY, 0);
} else {
fd = wrapped_fd;
r = lseek(fd, 0, SEEK_SET);
if (r < 0) {
- usbi_err(ctx, "seek failed ret=%zd errno=%d", r, errno);
+ usbi_err(ctx, "lseek failed, errno=%d", errno);
return LIBUSB_ERROR_IO;
}
}
if (fd < 0)
return fd;
+ alloc_len = 0;
do {
- descriptors_size *= 2;
- priv->descriptors = usbi_reallocf(priv->descriptors,
- descriptors_size);
+ const size_t desc_read_length = 256;
+ uint8_t *read_ptr;
+
+ alloc_len += desc_read_length;
+ priv->descriptors = usbi_reallocf(priv->descriptors, alloc_len);
if (!priv->descriptors) {
if (fd != wrapped_fd)
close(fd);
return LIBUSB_ERROR_NO_MEM;
}
+ read_ptr = (uint8_t *)priv->descriptors + priv->descriptors_len;
/* usbfs has holes in the file */
- if (!(sysfs_dir && sysfs_has_descriptors)) {
- memset(priv->descriptors + priv->descriptors_len,
- 0, descriptors_size - priv->descriptors_len);
- }
- r = read(fd, priv->descriptors + priv->descriptors_len,
- descriptors_size - priv->descriptors_len);
- if (r < 0) {
- usbi_err(ctx, "read descriptor failed ret=%d errno=%d",
- fd, errno);
+ if (!sysfs_dir)
+ memset(read_ptr, 0, desc_read_length);
+ nb = read(fd, read_ptr, desc_read_length);
+ if (nb < 0) {
+ usbi_err(ctx, "read descriptor failed, errno=%d", errno);
if (fd != wrapped_fd)
close(fd);
return LIBUSB_ERROR_IO;
}
- priv->descriptors_len += r;
- } while (priv->descriptors_len == descriptors_size);
+ priv->descriptors_len += (size_t)nb;
+ } while (priv->descriptors_len == alloc_len);
if (fd != wrapped_fd)
close(fd);
- if (priv->descriptors_len < DEVICE_DESC_LENGTH) {
- usbi_err(ctx, "short descriptor read (%d)",
- priv->descriptors_len);
+ if (priv->descriptors_len < LIBUSB_DT_DEVICE_SIZE) {
+ usbi_err(ctx, "short descriptor read (%zu)", priv->descriptors_len);
return LIBUSB_ERROR_IO;
}
- if (sysfs_dir && sysfs_can_relate_devices)
+ r = parse_config_descriptors(dev);
+ if (r < 0)
+ return r;
+
+ memcpy(&dev->device_descriptor, priv->descriptors, LIBUSB_DT_DEVICE_SIZE);
+
+ if (sysfs_dir) {
+ /* sysfs descriptors are in bus-endian format */
+ usbi_localize_device_descriptor(&dev->device_descriptor);
return LIBUSB_SUCCESS;
+ }
/* cache active config */
if (wrapped_fd < 0)
- fd = _get_usbfs_fd(dev, O_RDWR, 1);
+ fd = get_usbfs_fd(dev, O_RDWR, 1);
else
fd = wrapped_fd;
if (fd < 0) {
@@ -1061,21 +990,16 @@ static int initialize_device(struct libusb_device *dev, uint8_t busnum,
* config. just assume the first one is active. */
usbi_warn(ctx, "Missing rw usbfs access; cannot determine "
"active configuration descriptor");
- if (priv->descriptors_len >=
- (DEVICE_DESC_LENGTH + LIBUSB_DT_CONFIG_SIZE)) {
- struct libusb_config_descriptor config;
- usbi_parse_descriptor(
- priv->descriptors + DEVICE_DESC_LENGTH,
- "bbwbbbbb", &config, 0);
- priv->active_config = config.bConfigurationValue;
- } else
- priv->active_config = -1; /* No config dt */
+ if (priv->config_descriptors)
+ priv->active_config = priv->config_descriptors[0].desc->bConfigurationValue;
+ else
+ priv->active_config = 0; /* No config dt */
return LIBUSB_SUCCESS;
}
r = usbfs_get_active_config(dev, fd);
- if (wrapped_fd < 0)
+ if (fd != wrapped_fd)
close(fd);
return r;
@@ -1089,43 +1013,43 @@ static int linux_get_parent_info(struct libusb_device *dev, const char *sysfs_di
int ret, add_parent = 1;
/* XXX -- can we figure out the topology when using usbfs? */
- if (NULL == sysfs_dir || 0 == strncmp(sysfs_dir, "usb", 3)) {
+ if (!sysfs_dir || !strncmp(sysfs_dir, "usb", 3)) {
/* either using usbfs or finding the parent of a root hub */
return LIBUSB_SUCCESS;
}
parent_sysfs_dir = strdup(sysfs_dir);
- if (NULL == parent_sysfs_dir) {
+ if (!parent_sysfs_dir)
return LIBUSB_ERROR_NO_MEM;
- }
- if (NULL != (tmp = strrchr(parent_sysfs_dir, '.')) ||
- NULL != (tmp = strrchr(parent_sysfs_dir, '-'))) {
+
+ if ((tmp = strrchr(parent_sysfs_dir, '.')) ||
+ (tmp = strrchr(parent_sysfs_dir, '-'))) {
dev->port_number = atoi(tmp + 1);
*tmp = '\0';
} else {
usbi_warn(ctx, "Can not parse sysfs_dir: %s, no parent info",
parent_sysfs_dir);
- free (parent_sysfs_dir);
+ free(parent_sysfs_dir);
return LIBUSB_SUCCESS;
}
/* is the parent a root hub? */
- if (NULL == strchr(parent_sysfs_dir, '-')) {
+ if (!strchr(parent_sysfs_dir, '-')) {
tmp = parent_sysfs_dir;
- ret = asprintf (&parent_sysfs_dir, "usb%s", tmp);
- free (tmp);
- if (0 > ret) {
+ ret = asprintf(&parent_sysfs_dir, "usb%s", tmp);
+ free(tmp);
+ if (ret < 0)
return LIBUSB_ERROR_NO_MEM;
- }
}
retry:
/* find the parent in the context */
usbi_mutex_lock(&ctx->usb_devs_lock);
- list_for_each_entry(it, &ctx->usb_devs, list, struct libusb_device) {
- struct linux_device_priv *priv = _device_priv(it);
+ for_each_device(ctx, it) {
+ struct linux_device_priv *priv = usbi_get_device_priv(it);
+
if (priv->sysfs_dir) {
- if (0 == strcmp (priv->sysfs_dir, parent_sysfs_dir)) {
+ if (!strcmp(priv->sysfs_dir, parent_sysfs_dir)) {
dev->parent_dev = libusb_ref_device(it);
break;
}
@@ -1141,10 +1065,10 @@ retry:
goto retry;
}
- usbi_dbg("Dev %p (%s) has parent %p (%s) port %d", dev, sysfs_dir,
+ usbi_dbg("dev %p (%s) has parent %p (%s) port %u", dev, sysfs_dir,
dev->parent_dev, parent_sysfs_dir, dev->port_number);
- free (parent_sysfs_dir);
+ free(parent_sysfs_dir);
return LIBUSB_SUCCESS;
}
@@ -1154,24 +1078,23 @@ int linux_enumerate_device(struct libusb_context *ctx,
{
unsigned long session_id;
struct libusb_device *dev;
- int r = 0;
+ int r;
/* FIXME: session ID is not guaranteed unique as addresses can wrap and
* will be reused. instead we should add a simple sysfs attribute with
* a session ID. */
session_id = busnum << 8 | devaddr;
- usbi_dbg("busnum %d devaddr %d session_id %ld", busnum, devaddr,
- session_id);
+ usbi_dbg("busnum %u devaddr %u session_id %lu", busnum, devaddr, session_id);
dev = usbi_get_device_by_session_id(ctx, session_id);
if (dev) {
/* device already exists in the context */
- usbi_dbg("session_id %ld already exists", session_id);
+ usbi_dbg("session_id %lu already exists", session_id);
libusb_unref_device(dev);
return LIBUSB_SUCCESS;
}
- usbi_dbg("allocating new device for %d/%d (session %ld)",
+ usbi_dbg("allocating new device for %u/%u (session %lu)",
busnum, devaddr, session_id);
dev = usbi_alloc_device(ctx, session_id);
if (!dev)
@@ -1201,7 +1124,7 @@ void linux_hotplug_enumerate(uint8_t busnum, uint8_t devaddr, const char *sys_na
struct libusb_context *ctx;
usbi_mutex_static_lock(&active_contexts_lock);
- list_for_each_entry(ctx, &active_contexts_list, list, struct libusb_context) {
+ for_each_context(ctx) {
linux_enumerate_device(ctx, busnum, devaddr, sys_name);
}
usbi_mutex_static_unlock(&active_contexts_lock);
@@ -1214,10 +1137,10 @@ void linux_device_disconnected(uint8_t busnum, uint8_t devaddr)
unsigned long session_id = busnum << 8 | devaddr;
usbi_mutex_static_lock(&active_contexts_lock);
- list_for_each_entry(ctx, &active_contexts_list, list, struct libusb_context) {
- dev = usbi_get_device_by_session_id (ctx, session_id);
- if (NULL != dev) {
- usbi_disconnect_device (dev);
+ for_each_context(ctx) {
+ dev = usbi_get_device_by_session_id(ctx, session_id);
+ if (dev) {
+ usbi_disconnect_device(dev);
libusb_unref_device(dev);
} else {
usbi_dbg("device not found for session %lx", session_id);
@@ -1226,16 +1149,32 @@ void linux_device_disconnected(uint8_t busnum, uint8_t devaddr)
usbi_mutex_static_unlock(&active_contexts_lock);
}
-#if !defined(USE_UDEV)
+#if !defined(HAVE_LIBUDEV)
+static int parse_u8(const char *str, uint8_t *val_p)
+{
+ char *endptr;
+ long num;
+
+ errno = 0;
+ num = strtol(str, &endptr, 10);
+ if (num < 0 || num > UINT8_MAX || errno)
+ return 0;
+ if (endptr == str || *endptr != '\0')
+ return 0;
+
+ *val_p = (uint8_t)num;
+ return 1;
+}
+
/* open a bus directory and adds all discovered devices to the context */
static int usbfs_scan_busdir(struct libusb_context *ctx, uint8_t busnum)
{
DIR *dir;
- char dirpath[PATH_MAX];
+ char dirpath[20];
struct dirent *entry;
int r = LIBUSB_ERROR_IO;
- snprintf(dirpath, PATH_MAX, "%s/%03d", usbfs_path, busnum);
+ sprintf(dirpath, USB_DEVTMPFS_PATH "/%03u", busnum);
usbi_dbg("%s", dirpath);
dir = opendir(dirpath);
if (!dir) {
@@ -1246,18 +1185,17 @@ static int usbfs_scan_busdir(struct libusb_context *ctx, uint8_t busnum)
}
while ((entry = readdir(dir))) {
- int devaddr;
+ uint8_t devaddr;
if (entry->d_name[0] == '.')
continue;
- devaddr = atoi(entry->d_name);
- if (devaddr == 0) {
+ if (!parse_u8(entry->d_name, &devaddr)) {
usbi_dbg("unknown dir entry %s", entry->d_name);
continue;
}
- if (linux_enumerate_device(ctx, busnum, (uint8_t) devaddr, NULL)) {
+ if (linux_enumerate_device(ctx, busnum, devaddr, NULL)) {
usbi_dbg("failed to enumerate dir entry %s", entry->d_name);
continue;
}
@@ -1272,33 +1210,35 @@ static int usbfs_scan_busdir(struct libusb_context *ctx, uint8_t busnum)
static int usbfs_get_device_list(struct libusb_context *ctx)
{
struct dirent *entry;
- DIR *buses = opendir(usbfs_path);
+ DIR *buses;
+ uint8_t busnum, devaddr;
int r = 0;
+ if (usbdev_names)
+ buses = opendir(USBDEV_PATH);
+ else
+ buses = opendir(USB_DEVTMPFS_PATH);
+
if (!buses) {
- usbi_err(ctx, "opendir buses failed errno=%d", errno);
+ usbi_err(ctx, "opendir buses failed, errno=%d", errno);
return LIBUSB_ERROR_IO;
}
while ((entry = readdir(buses))) {
- int busnum;
-
if (entry->d_name[0] == '.')
continue;
if (usbdev_names) {
- int devaddr;
- if (!_is_usbdev_entry(entry, &busnum, &devaddr))
+ if (!is_usbdev_entry(entry->d_name, &busnum, &devaddr))
continue;
- r = linux_enumerate_device(ctx, busnum, (uint8_t) devaddr, NULL);
+ r = linux_enumerate_device(ctx, busnum, devaddr, NULL);
if (r < 0) {
usbi_dbg("failed to enumerate dir entry %s", entry->d_name);
continue;
}
} else {
- busnum = atoi(entry->d_name);
- if (busnum == 0) {
+ if (!parse_u8(entry->d_name, &busnum)) {
usbi_dbg("unknown dir entry %s", entry->d_name);
continue;
}
@@ -1313,23 +1253,7 @@ static int usbfs_get_device_list(struct libusb_context *ctx)
return r;
}
-#endif
-static int sysfs_scan_device(struct libusb_context *ctx, const char *devname)
-{
- uint8_t busnum, devaddr;
- int ret;
-
- ret = linux_get_device_address (ctx, 0, &busnum, &devaddr, NULL, devname, -1);
- if (LIBUSB_SUCCESS != ret) {
- return ret;
- }
-
- return linux_enumerate_device(ctx, busnum & 0xff, devaddr & 0xff,
- devname);
-}
-
-#if !defined(USE_UDEV)
static int sysfs_get_device_list(struct libusb_context *ctx)
{
DIR *devices = opendir(SYSFS_DEVICE_PATH);
@@ -1338,13 +1262,13 @@ static int sysfs_get_device_list(struct libusb_context *ctx)
int num_enumerated = 0;
if (!devices) {
- usbi_err(ctx, "opendir devices failed errno=%d", errno);
+ usbi_err(ctx, "opendir devices failed, errno=%d", errno);
return LIBUSB_ERROR_IO;
}
while ((entry = readdir(devices))) {
if ((!isdigit(entry->d_name[0]) && strncmp(entry->d_name, "usb", 3))
- || strchr(entry->d_name, ':'))
+ || strchr(entry->d_name, ':'))
continue;
num_devices++;
@@ -1366,19 +1290,14 @@ static int sysfs_get_device_list(struct libusb_context *ctx)
return LIBUSB_ERROR_IO;
}
-static int linux_default_scan_devices (struct libusb_context *ctx)
+static int linux_default_scan_devices(struct libusb_context *ctx)
{
/* we can retrieve device list and descriptors from sysfs or usbfs.
* sysfs is preferable, because if we use usbfs we end up resuming
* any autosuspended USB devices. however, sysfs is not available
* everywhere, so we need a usbfs fallback too.
- *
- * as described in the "sysfs vs usbfs" comment at the top of this
- * file, sometimes we have sysfs but not enough information to
- * relate sysfs devices to usbfs nodes. op_init() determines the
- * adequacy of sysfs and sets sysfs_can_relate_devices.
*/
- if (sysfs_can_relate_devices != 0)
+ if (sysfs_available)
return sysfs_get_device_list(ctx);
else
return usbfs_get_device_list(ctx);
@@ -1387,7 +1306,7 @@ static int linux_default_scan_devices (struct libusb_context *ctx)
static int initialize_handle(struct libusb_device_handle *handle, int fd)
{
- struct linux_device_handle_priv *hpriv = _device_handle_priv(handle);
+ struct linux_device_handle_priv *hpriv = usbi_get_device_handle_priv(handle);
int r;
hpriv->fd = fd;
@@ -1397,21 +1316,17 @@ static int initialize_handle(struct libusb_device_handle *handle, int fd)
if (errno == ENOTTY)
usbi_dbg("getcap not available");
else
- usbi_err(HANDLE_CTX(handle), "getcap failed (%d)", errno);
- hpriv->caps = 0;
- if (supports_flag_zero_packet)
- hpriv->caps |= USBFS_CAP_ZERO_PACKET;
- if (supports_flag_bulk_continuation)
- hpriv->caps |= USBFS_CAP_BULK_CONTINUATION;
+ usbi_err(HANDLE_CTX(handle), "getcap failed, errno=%d", errno);
+ hpriv->caps = USBFS_CAP_BULK_CONTINUATION;
}
- return usbi_add_pollfd(HANDLE_CTX(handle), hpriv->fd, POLLOUT);
+ return usbi_add_event_source(HANDLE_CTX(handle), hpriv->fd, POLLOUT);
}
static int op_wrap_sys_device(struct libusb_context *ctx,
struct libusb_device_handle *handle, intptr_t sys_dev)
{
- struct linux_device_handle_priv *hpriv = _device_handle_priv(handle);
+ struct linux_device_handle_priv *hpriv = usbi_get_device_handle_priv(handle);
int fd = (int)sys_dev;
uint8_t busnum, devaddr;
struct usbfs_connectinfo ci;
@@ -1422,7 +1337,7 @@ static int op_wrap_sys_device(struct libusb_context *ctx,
if (r < 0) {
r = ioctl(fd, IOCTL_USBFS_CONNECTINFO, &ci);
if (r < 0) {
- usbi_err(ctx, "connectinfo failed (%d)", errno);
+ usbi_err(ctx, "connectinfo failed, errno=%d", errno);
return LIBUSB_ERROR_IO;
}
/* There is no ioctl to get the bus number. We choose 0 here
@@ -1462,7 +1377,7 @@ static int op_open(struct libusb_device_handle *handle)
{
int fd, r;
- fd = _get_usbfs_fd(handle->dev, O_RDWR, 0);
+ fd = get_usbfs_fd(handle->dev, O_RDWR, 0);
if (fd < 0) {
if (fd == LIBUSB_ERROR_NO_DEVICE) {
/* device will still be marked as attached if hotplug monitor thread
@@ -1471,7 +1386,7 @@ static int op_open(struct libusb_device_handle *handle)
if (handle->dev->attached) {
usbi_dbg("open failed with no device, but device still attached");
linux_device_disconnected(handle->dev->bus_number,
- handle->dev->device_address);
+ handle->dev->device_address);
}
usbi_mutex_static_unlock(&linux_hotplug_lock);
}
@@ -1487,45 +1402,47 @@ static int op_open(struct libusb_device_handle *handle)
static void op_close(struct libusb_device_handle *dev_handle)
{
- struct linux_device_handle_priv *hpriv = _device_handle_priv(dev_handle);
+ struct linux_device_handle_priv *hpriv = usbi_get_device_handle_priv(dev_handle);
+
/* fd may have already been removed by POLLERR condition in op_handle_events() */
if (!hpriv->fd_removed)
- usbi_remove_pollfd(HANDLE_CTX(dev_handle), hpriv->fd);
+ usbi_remove_event_source(HANDLE_CTX(dev_handle), hpriv->fd);
if (!hpriv->fd_keep)
close(hpriv->fd);
}
static int op_get_configuration(struct libusb_device_handle *handle,
- int *config)
+ uint8_t *config)
{
- struct linux_device_priv *priv = _device_priv(handle->dev);
+ struct linux_device_priv *priv = usbi_get_device_priv(handle->dev);
int r;
- if (priv->sysfs_dir && sysfs_can_relate_devices) {
+ if (priv->sysfs_dir) {
r = sysfs_get_active_config(handle->dev, config);
} else {
- r = usbfs_get_active_config(handle->dev,
- _device_handle_priv(handle)->fd);
+ struct linux_device_handle_priv *hpriv = usbi_get_device_handle_priv(handle);
+
+ r = usbfs_get_active_config(handle->dev, hpriv->fd);
if (r == LIBUSB_SUCCESS)
*config = priv->active_config;
}
if (r < 0)
return r;
- if (*config == -1) {
+ if (*config == 0)
usbi_err(HANDLE_CTX(handle), "device unconfigured");
- *config = 0;
- }
return 0;
}
static int op_set_configuration(struct libusb_device_handle *handle, int config)
{
- struct linux_device_priv *priv = _device_priv(handle->dev);
- int fd = _device_handle_priv(handle)->fd;
- int r = ioctl(fd, IOCTL_USBFS_SETCONFIG, &config);
- if (r) {
+ struct linux_device_priv *priv = usbi_get_device_priv(handle->dev);
+ struct linux_device_handle_priv *hpriv = usbi_get_device_handle_priv(handle);
+ int fd = hpriv->fd;
+ int r = ioctl(fd, IOCTL_USBFS_SETCONFIGURATION, &config);
+
+ if (r < 0) {
if (errno == EINVAL)
return LIBUSB_ERROR_NOT_FOUND;
else if (errno == EBUSY)
@@ -1533,21 +1450,26 @@ static int op_set_configuration(struct libusb_device_handle *handle, int config)
else if (errno == ENODEV)
return LIBUSB_ERROR_NO_DEVICE;
- usbi_err(HANDLE_CTX(handle), "failed, error %d errno %d", r, errno);
+ usbi_err(HANDLE_CTX(handle), "set configuration failed, errno=%d", errno);
return LIBUSB_ERROR_OTHER;
}
+ if (config == -1)
+ config = 0;
+
/* update our cached active config descriptor */
- priv->active_config = config;
+ priv->active_config = (uint8_t)config;
return LIBUSB_SUCCESS;
}
-static int claim_interface(struct libusb_device_handle *handle, int iface)
+static int claim_interface(struct libusb_device_handle *handle, unsigned int iface)
{
- int fd = _device_handle_priv(handle)->fd;
- int r = ioctl(fd, IOCTL_USBFS_CLAIMINTF, &iface);
- if (r) {
+ struct linux_device_handle_priv *hpriv = usbi_get_device_handle_priv(handle);
+ int fd = hpriv->fd;
+ int r = ioctl(fd, IOCTL_USBFS_CLAIMINTERFACE, &iface);
+
+ if (r < 0) {
if (errno == ENOENT)
return LIBUSB_ERROR_NOT_FOUND;
else if (errno == EBUSY)
@@ -1555,46 +1477,46 @@ static int claim_interface(struct libusb_device_handle *handle, int iface)
else if (errno == ENODEV)
return LIBUSB_ERROR_NO_DEVICE;
- usbi_err(HANDLE_CTX(handle),
- "claim interface failed, error %d errno %d", r, errno);
+ usbi_err(HANDLE_CTX(handle), "claim interface failed, errno=%d", errno);
return LIBUSB_ERROR_OTHER;
}
return 0;
}
-static int release_interface(struct libusb_device_handle *handle, int iface)
+static int release_interface(struct libusb_device_handle *handle, unsigned int iface)
{
- int fd = _device_handle_priv(handle)->fd;
- int r = ioctl(fd, IOCTL_USBFS_RELEASEINTF, &iface);
- if (r) {
+ struct linux_device_handle_priv *hpriv = usbi_get_device_handle_priv(handle);
+ int fd = hpriv->fd;
+ int r = ioctl(fd, IOCTL_USBFS_RELEASEINTERFACE, &iface);
+
+ if (r < 0) {
if (errno == ENODEV)
return LIBUSB_ERROR_NO_DEVICE;
- usbi_err(HANDLE_CTX(handle),
- "release interface failed, error %d errno %d", r, errno);
+ usbi_err(HANDLE_CTX(handle), "release interface failed, errno=%d", errno);
return LIBUSB_ERROR_OTHER;
}
return 0;
}
-static int op_set_interface(struct libusb_device_handle *handle, int iface,
- int altsetting)
+static int op_set_interface(struct libusb_device_handle *handle, uint8_t interface,
+ uint8_t altsetting)
{
- int fd = _device_handle_priv(handle)->fd;
+ struct linux_device_handle_priv *hpriv = usbi_get_device_handle_priv(handle);
+ int fd = hpriv->fd;
struct usbfs_setinterface setintf;
int r;
- setintf.interface = iface;
+ setintf.interface = interface;
setintf.altsetting = altsetting;
- r = ioctl(fd, IOCTL_USBFS_SETINTF, &setintf);
- if (r) {
+ r = ioctl(fd, IOCTL_USBFS_SETINTERFACE, &setintf);
+ if (r < 0) {
if (errno == EINVAL)
return LIBUSB_ERROR_NOT_FOUND;
else if (errno == ENODEV)
return LIBUSB_ERROR_NO_DEVICE;
- usbi_err(HANDLE_CTX(handle),
- "setintf failed error %d errno %d", r, errno);
+ usbi_err(HANDLE_CTX(handle), "set interface failed, errno=%d", errno);
return LIBUSB_ERROR_OTHER;
}
@@ -1604,17 +1526,18 @@ static int op_set_interface(struct libusb_device_handle *handle, int iface,
static int op_clear_halt(struct libusb_device_handle *handle,
unsigned char endpoint)
{
- int fd = _device_handle_priv(handle)->fd;
+ struct linux_device_handle_priv *hpriv = usbi_get_device_handle_priv(handle);
+ int fd = hpriv->fd;
unsigned int _endpoint = endpoint;
int r = ioctl(fd, IOCTL_USBFS_CLEAR_HALT, &_endpoint);
- if (r) {
+
+ if (r < 0) {
if (errno == ENOENT)
return LIBUSB_ERROR_NOT_FOUND;
else if (errno == ENODEV)
return LIBUSB_ERROR_NO_DEVICE;
- usbi_err(HANDLE_CTX(handle),
- "clear_halt failed error %d errno %d", r, errno);
+ usbi_err(HANDLE_CTX(handle), "clear halt failed, errno=%d", errno);
return LIBUSB_ERROR_OTHER;
}
@@ -1623,50 +1546,49 @@ static int op_clear_halt(struct libusb_device_handle *handle,
static int op_reset_device(struct libusb_device_handle *handle)
{
- int fd = _device_handle_priv(handle)->fd;
- int i, r, ret = 0;
+ struct linux_device_handle_priv *hpriv = usbi_get_device_handle_priv(handle);
+ int fd = hpriv->fd;
+ int r, ret = 0;
+ uint8_t i;
/* Doing a device reset will cause the usbfs driver to get unbound
- from any interfaces it is bound to. By voluntarily unbinding
- the usbfs driver ourself, we stop the kernel from rebinding
- the interface after reset (which would end up with the interface
- getting bound to the in kernel driver if any). */
+ * from any interfaces it is bound to. By voluntarily unbinding
+ * the usbfs driver ourself, we stop the kernel from rebinding
+ * the interface after reset (which would end up with the interface
+ * getting bound to the in kernel driver if any). */
for (i = 0; i < USB_MAXINTERFACES; i++) {
- if (handle->claimed_interfaces & (1L << i)) {
+ if (handle->claimed_interfaces & (1UL << i))
release_interface(handle, i);
- }
}
usbi_mutex_lock(&handle->lock);
r = ioctl(fd, IOCTL_USBFS_RESET, NULL);
- if (r) {
+ if (r < 0) {
if (errno == ENODEV) {
ret = LIBUSB_ERROR_NOT_FOUND;
goto out;
}
- usbi_err(HANDLE_CTX(handle),
- "reset failed error %d errno %d", r, errno);
+ usbi_err(HANDLE_CTX(handle), "reset failed, errno=%d", errno);
ret = LIBUSB_ERROR_OTHER;
goto out;
}
/* And re-claim any interfaces which were claimed before the reset */
for (i = 0; i < USB_MAXINTERFACES; i++) {
- if (handle->claimed_interfaces & (1L << i)) {
- /*
- * A driver may have completed modprobing during
- * IOCTL_USBFS_RESET, and bound itself as soon as
- * IOCTL_USBFS_RESET released the device lock
- */
- r = detach_kernel_driver_and_claim(handle, i);
- if (r) {
- usbi_warn(HANDLE_CTX(handle),
- "failed to re-claim interface %d after reset: %s",
- i, libusb_error_name(r));
- handle->claimed_interfaces &= ~(1L << i);
- ret = LIBUSB_ERROR_NOT_FOUND;
- }
+ if (!(handle->claimed_interfaces & (1UL << i)))
+ continue;
+ /*
+ * A driver may have completed modprobing during
+ * IOCTL_USBFS_RESET, and bound itself as soon as
+ * IOCTL_USBFS_RESET released the device lock
+ */
+ r = detach_kernel_driver_and_claim(handle, i);
+ if (r) {
+ usbi_warn(HANDLE_CTX(handle), "failed to re-claim interface %u after reset: %s",
+ i, libusb_error_name(r));
+ handle->claimed_interfaces &= ~(1UL << i);
+ ret = LIBUSB_ERROR_NOT_FOUND;
}
}
out:
@@ -1677,13 +1599,14 @@ out:
static int do_streams_ioctl(struct libusb_device_handle *handle, long req,
uint32_t num_streams, unsigned char *endpoints, int num_endpoints)
{
- int r, fd = _device_handle_priv(handle)->fd;
+ struct linux_device_handle_priv *hpriv = usbi_get_device_handle_priv(handle);
+ int r, fd = hpriv->fd;
struct usbfs_streams *streams;
if (num_endpoints > 30) /* Max 15 in + 15 out eps */
return LIBUSB_ERROR_INVALID_PARAM;
- streams = malloc(sizeof(struct usbfs_streams) + num_endpoints);
+ streams = malloc(sizeof(*streams) + num_endpoints);
if (!streams)
return LIBUSB_ERROR_NO_MEM;
@@ -1703,8 +1626,7 @@ static int do_streams_ioctl(struct libusb_device_handle *handle, long req,
else if (errno == ENODEV)
return LIBUSB_ERROR_NO_DEVICE;
- usbi_err(HANDLE_CTX(handle),
- "streams-ioctl failed error %d errno %d", r, errno);
+ usbi_err(HANDLE_CTX(handle), "streams-ioctl failed, errno=%d", errno);
return LIBUSB_ERROR_OTHER;
}
return r;
@@ -1724,26 +1646,24 @@ static int op_free_streams(struct libusb_device_handle *handle,
endpoints, num_endpoints);
}
-static unsigned char *op_dev_mem_alloc(struct libusb_device_handle *handle,
- size_t len)
+static void *op_dev_mem_alloc(struct libusb_device_handle *handle, size_t len)
{
- struct linux_device_handle_priv *hpriv = _device_handle_priv(handle);
- unsigned char *buffer = (unsigned char *)mmap(NULL, len,
- PROT_READ | PROT_WRITE, MAP_SHARED, hpriv->fd, 0);
+ struct linux_device_handle_priv *hpriv = usbi_get_device_handle_priv(handle);
+ void *buffer;
+
+ buffer = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, hpriv->fd, 0);
if (buffer == MAP_FAILED) {
- usbi_err(HANDLE_CTX(handle), "alloc dev mem failed errno %d",
- errno);
+ usbi_err(HANDLE_CTX(handle), "alloc dev mem failed, errno=%d", errno);
return NULL;
}
return buffer;
}
-static int op_dev_mem_free(struct libusb_device_handle *handle,
- unsigned char *buffer, size_t len)
+static int op_dev_mem_free(struct libusb_device_handle *handle, void *buffer,
+ size_t len)
{
if (munmap(buffer, len) != 0) {
- usbi_err(HANDLE_CTX(handle), "free dev mem failed errno %d",
- errno);
+ usbi_err(HANDLE_CTX(handle), "free dev mem failed, errno=%d", errno);
return LIBUSB_ERROR_OTHER;
} else {
return LIBUSB_SUCCESS;
@@ -1751,32 +1671,33 @@ static int op_dev_mem_free(struct libusb_device_handle *handle,
}
static int op_kernel_driver_active(struct libusb_device_handle *handle,
- int interface)
+ uint8_t interface)
{
- int fd = _device_handle_priv(handle)->fd;
+ struct linux_device_handle_priv *hpriv = usbi_get_device_handle_priv(handle);
+ int fd = hpriv->fd;
struct usbfs_getdriver getdrv;
int r;
getdrv.interface = interface;
r = ioctl(fd, IOCTL_USBFS_GETDRIVER, &getdrv);
- if (r) {
+ if (r < 0) {
if (errno == ENODATA)
return 0;
else if (errno == ENODEV)
return LIBUSB_ERROR_NO_DEVICE;
- usbi_err(HANDLE_CTX(handle),
- "get driver failed error %d errno %d", r, errno);
+ usbi_err(HANDLE_CTX(handle), "get driver failed, errno=%d", errno);
return LIBUSB_ERROR_OTHER;
}
- return (strcmp(getdrv.driver, "usbfs") == 0) ? 0 : 1;
+ return strcmp(getdrv.driver, "usbfs") != 0;
}
static int op_detach_kernel_driver(struct libusb_device_handle *handle,
- int interface)
+ uint8_t interface)
{
- int fd = _device_handle_priv(handle)->fd;
+ struct linux_device_handle_priv *hpriv = usbi_get_device_handle_priv(handle);
+ int fd = hpriv->fd;
struct usbfs_ioctl command;
struct usbfs_getdriver getdrv;
int r;
@@ -1787,11 +1708,11 @@ static int op_detach_kernel_driver(struct libusb_device_handle *handle,
getdrv.interface = interface;
r = ioctl(fd, IOCTL_USBFS_GETDRIVER, &getdrv);
- if (r == 0 && strcmp(getdrv.driver, "usbfs") == 0)
+ if (r == 0 && !strcmp(getdrv.driver, "usbfs"))
return LIBUSB_ERROR_NOT_FOUND;
r = ioctl(fd, IOCTL_USBFS_IOCTL, &command);
- if (r) {
+ if (r < 0) {
if (errno == ENODATA)
return LIBUSB_ERROR_NOT_FOUND;
else if (errno == EINVAL)
@@ -1799,8 +1720,7 @@ static int op_detach_kernel_driver(struct libusb_device_handle *handle,
else if (errno == ENODEV)
return LIBUSB_ERROR_NO_DEVICE;
- usbi_err(HANDLE_CTX(handle),
- "detach failed error %d errno %d", r, errno);
+ usbi_err(HANDLE_CTX(handle), "detach failed, errno=%d", errno);
return LIBUSB_ERROR_OTHER;
}
@@ -1808,9 +1728,10 @@ static int op_detach_kernel_driver(struct libusb_device_handle *handle,
}
static int op_attach_kernel_driver(struct libusb_device_handle *handle,
- int interface)
+ uint8_t interface)
{
- int fd = _device_handle_priv(handle)->fd;
+ struct linux_device_handle_priv *hpriv = usbi_get_device_handle_priv(handle);
+ int fd = hpriv->fd;
struct usbfs_ioctl command;
int r;
@@ -1829,8 +1750,7 @@ static int op_attach_kernel_driver(struct libusb_device_handle *handle,
else if (errno == EBUSY)
return LIBUSB_ERROR_BUSY;
- usbi_err(HANDLE_CTX(handle),
- "attach failed error %d errno %d", r, errno);
+ usbi_err(HANDLE_CTX(handle), "attach failed, errno=%d", errno);
return LIBUSB_ERROR_OTHER;
} else if (r == 0) {
return LIBUSB_ERROR_NOT_FOUND;
@@ -1840,29 +1760,31 @@ static int op_attach_kernel_driver(struct libusb_device_handle *handle,
}
static int detach_kernel_driver_and_claim(struct libusb_device_handle *handle,
- int interface)
+ uint8_t interface)
{
+ struct linux_device_handle_priv *hpriv = usbi_get_device_handle_priv(handle);
struct usbfs_disconnect_claim dc;
- int r, fd = _device_handle_priv(handle)->fd;
+ int r, fd = hpriv->fd;
dc.interface = interface;
strcpy(dc.driver, "usbfs");
dc.flags = USBFS_DISCONNECT_CLAIM_EXCEPT_DRIVER;
r = ioctl(fd, IOCTL_USBFS_DISCONNECT_CLAIM, &dc);
- if (r != 0 && errno != ENOTTY) {
- switch (errno) {
- case EBUSY:
- return LIBUSB_ERROR_BUSY;
- case EINVAL:
- return LIBUSB_ERROR_INVALID_PARAM;
- case ENODEV:
- return LIBUSB_ERROR_NO_DEVICE;
- }
- usbi_err(HANDLE_CTX(handle),
- "disconnect-and-claim failed errno %d", errno);
- return LIBUSB_ERROR_OTHER;
- } else if (r == 0)
+ if (r == 0)
return 0;
+ switch (errno) {
+ case ENOTTY:
+ break;
+ case EBUSY:
+ return LIBUSB_ERROR_BUSY;
+ case EINVAL:
+ return LIBUSB_ERROR_INVALID_PARAM;
+ case ENODEV:
+ return LIBUSB_ERROR_NO_DEVICE;
+ default:
+ usbi_err(HANDLE_CTX(handle), "disconnect-and-claim failed, errno=%d", errno);
+ return LIBUSB_ERROR_OTHER;
+ }
/* Fallback code for kernels which don't support the
disconnect-and-claim ioctl */
@@ -1873,35 +1795,35 @@ static int detach_kernel_driver_and_claim(struct libusb_device_handle *handle,
return claim_interface(handle, interface);
}
-static int op_claim_interface(struct libusb_device_handle *handle, int iface)
+static int op_claim_interface(struct libusb_device_handle *handle, uint8_t interface)
{
if (handle->auto_detach_kernel_driver)
- return detach_kernel_driver_and_claim(handle, iface);
+ return detach_kernel_driver_and_claim(handle, interface);
else
- return claim_interface(handle, iface);
+ return claim_interface(handle, interface);
}
-static int op_release_interface(struct libusb_device_handle *handle, int iface)
+static int op_release_interface(struct libusb_device_handle *handle, uint8_t interface)
{
int r;
- r = release_interface(handle, iface);
+ r = release_interface(handle, interface);
if (r)
return r;
if (handle->auto_detach_kernel_driver)
- op_attach_kernel_driver(handle, iface);
+ op_attach_kernel_driver(handle, interface);
return 0;
}
static void op_destroy_device(struct libusb_device *dev)
{
- struct linux_device_priv *priv = _device_priv(dev);
- if (priv->descriptors)
- free(priv->descriptors);
- if (priv->sysfs_dir)
- free(priv->sysfs_dir);
+ struct linux_device_priv *priv = usbi_get_device_priv(dev);
+
+ free(priv->config_descriptors);
+ free(priv->descriptors);
+ free(priv->sysfs_dir);
}
/* URBs are discarded in reverse order of submission to avoid races. */
@@ -1909,32 +1831,30 @@ static int discard_urbs(struct usbi_transfer *itransfer, int first, int last_plu
{
struct libusb_transfer *transfer =
USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct linux_transfer_priv *tpriv =
- usbi_transfer_get_os_priv(itransfer);
- struct linux_device_handle_priv *dpriv =
- _device_handle_priv(transfer->dev_handle);
+ struct linux_transfer_priv *tpriv = usbi_get_transfer_priv(itransfer);
+ struct linux_device_handle_priv *hpriv =
+ usbi_get_device_handle_priv(transfer->dev_handle);
int i, ret = 0;
struct usbfs_urb *urb;
for (i = last_plus_one - 1; i >= first; i--) {
- if (LIBUSB_TRANSFER_TYPE_ISOCHRONOUS == transfer->type)
+ if (transfer->type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS)
urb = tpriv->iso_urbs[i];
else
urb = &tpriv->urbs[i];
- if (0 == ioctl(dpriv->fd, IOCTL_USBFS_DISCARDURB, urb))
+ if (ioctl(hpriv->fd, IOCTL_USBFS_DISCARDURB, urb) == 0)
continue;
- if (EINVAL == errno) {
+ if (errno == EINVAL) {
usbi_dbg("URB not found --> assuming ready to be reaped");
if (i == (last_plus_one - 1))
ret = LIBUSB_ERROR_NOT_FOUND;
- } else if (ENODEV == errno) {
+ } else if (errno == ENODEV) {
usbi_dbg("Device not found for URB --> assuming ready to be reaped");
ret = LIBUSB_ERROR_NO_DEVICE;
} else {
- usbi_warn(TRANSFER_CTX(transfer),
- "unrecognised discard errno %d", errno);
+ usbi_warn(TRANSFER_CTX(transfer), "unrecognised discard errno %d", errno);
ret = LIBUSB_ERROR_OTHER;
}
}
@@ -1944,8 +1864,10 @@ static int discard_urbs(struct usbi_transfer *itransfer, int first, int last_plu
static void free_iso_urbs(struct linux_transfer_priv *tpriv)
{
int i;
+
for (i = 0; i < tpriv->num_urbs; i++) {
struct usbfs_urb *urb = tpriv->iso_urbs[i];
+
if (!urb)
break;
free(urb);
@@ -1959,20 +1881,17 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer =
USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct linux_transfer_priv *tpriv = usbi_transfer_get_os_priv(itransfer);
- struct linux_device_handle_priv *dpriv =
- _device_handle_priv(transfer->dev_handle);
+ struct linux_transfer_priv *tpriv = usbi_get_transfer_priv(itransfer);
+ struct linux_device_handle_priv *hpriv =
+ usbi_get_device_handle_priv(transfer->dev_handle);
struct usbfs_urb *urbs;
- int is_out = (transfer->endpoint & LIBUSB_ENDPOINT_DIR_MASK)
- == LIBUSB_ENDPOINT_OUT;
+ int is_out = IS_XFEROUT(transfer);
int bulk_buffer_len, use_bulk_continuation;
+ int num_urbs;
+ int last_urb_partial = 0;
int r;
int i;
- if (is_out && (transfer->flags & LIBUSB_TRANSFER_ADD_ZERO_PACKET) &&
- !(dpriv->caps & USBFS_CAP_ZERO_PACKET))
- return LIBUSB_ERROR_NOT_SUPPORTED;
-
/*
* Older versions of usbfs place a 16kb limit on bulk URBs. We work
* around this by splitting large transfers into 16k blocks, and then
@@ -1980,7 +1899,7 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer)
* a time, but there is a big performance gain doing it this way.
*
* Newer versions lift the 16k limit (USBFS_CAP_NO_PACKET_SIZE_LIM),
- * using arbritary large transfers can still be a bad idea though, as
+ * using arbitrary large transfers can still be a bad idea though, as
* the kernel needs to allocate physical contiguous memory for this,
* which may fail for large buffers.
*
@@ -1992,16 +1911,16 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer)
* short split-transfers to work reliable USBFS_CAP_BULK_CONTINUATION
* is needed, but this is not always available.
*/
- if (dpriv->caps & USBFS_CAP_BULK_SCATTER_GATHER) {
+ if (hpriv->caps & USBFS_CAP_BULK_SCATTER_GATHER) {
/* Good! Just submit everything in one go */
bulk_buffer_len = transfer->length ? transfer->length : 1;
use_bulk_continuation = 0;
- } else if (dpriv->caps & USBFS_CAP_BULK_CONTINUATION) {
+ } else if (hpriv->caps & USBFS_CAP_BULK_CONTINUATION) {
/* Split the transfers and use bulk-continuation to
avoid issues with short-transfers */
bulk_buffer_len = MAX_BULK_BUFFER_LENGTH;
use_bulk_continuation = 1;
- } else if (dpriv->caps & USBFS_CAP_NO_PACKET_SIZE_LIM) {
+ } else if (hpriv->caps & USBFS_CAP_NO_PACKET_SIZE_LIM) {
/* Don't split, assume the kernel can alloc the buffer
(otherwise the submit will fail with -ENOMEM) */
bulk_buffer_len = transfer->length ? transfer->length : 1;
@@ -2015,8 +1934,7 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer)
use_bulk_continuation = 0;
}
- int num_urbs = transfer->length / bulk_buffer_len;
- int last_urb_partial = 0;
+ num_urbs = transfer->length / bulk_buffer_len;
if (transfer->length == 0) {
num_urbs = 1;
@@ -2024,9 +1942,8 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer)
last_urb_partial = 1;
num_urbs++;
}
- usbi_dbg("need %d urbs for new transfer with length %d", num_urbs,
- transfer->length);
- urbs = calloc(num_urbs, sizeof(struct usbfs_urb));
+ usbi_dbg("need %d urbs for new transfer with length %d", num_urbs, transfer->length);
+ urbs = calloc(num_urbs, sizeof(*urbs));
if (!urbs)
return LIBUSB_ERROR_NO_MEM;
tpriv->urbs = urbs;
@@ -2037,6 +1954,7 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer)
for (i = 0; i < num_urbs; i++) {
struct usbfs_urb *urb = &urbs[i];
+
urb->usercontext = itransfer;
switch (transfer->type) {
case LIBUSB_TRANSFER_TYPE_BULK:
@@ -2053,9 +1971,11 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer)
}
urb->endpoint = transfer->endpoint;
urb->buffer = transfer->buffer + (i * bulk_buffer_len);
+
/* don't set the short not ok flag for the last URB */
if (use_bulk_continuation && !is_out && (i < num_urbs - 1))
urb->flags = USBFS_URB_SHORT_NOT_OK;
+
if (i == num_urbs - 1 && last_urb_partial)
urb->buffer_length = transfer->length % bulk_buffer_len;
else if (transfer->length == 0)
@@ -2068,60 +1988,62 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer)
/* we have already checked that the flag is supported */
if (is_out && i == num_urbs - 1 &&
- transfer->flags & LIBUSB_TRANSFER_ADD_ZERO_PACKET)
+ (transfer->flags & LIBUSB_TRANSFER_ADD_ZERO_PACKET))
urb->flags |= USBFS_URB_ZERO_PACKET;
- r = ioctl(dpriv->fd, IOCTL_USBFS_SUBMITURB, urb);
- if (r < 0) {
- if (errno == ENODEV) {
- r = LIBUSB_ERROR_NO_DEVICE;
- } else {
- usbi_err(TRANSFER_CTX(transfer),
- "submiturb failed error %d errno=%d", r, errno);
- r = LIBUSB_ERROR_IO;
- }
-
- /* if the first URB submission fails, we can simply free up and
- * return failure immediately. */
- if (i == 0) {
- usbi_dbg("first URB failed, easy peasy");
- free(urbs);
- tpriv->urbs = NULL;
- return r;
- }
+ r = ioctl(hpriv->fd, IOCTL_USBFS_SUBMITURB, urb);
+ if (r == 0)
+ continue;
- /* if it's not the first URB that failed, the situation is a bit
- * tricky. we may need to discard all previous URBs. there are
- * complications:
- * - discarding is asynchronous - discarded urbs will be reaped
- * later. the user must not have freed the transfer when the
- * discarded URBs are reaped, otherwise libusb will be using
- * freed memory.
- * - the earlier URBs may have completed successfully and we do
- * not want to throw away any data.
- * - this URB failing may be no error; EREMOTEIO means that
- * this transfer simply didn't need all the URBs we submitted
- * so, we report that the transfer was submitted successfully and
- * in case of error we discard all previous URBs. later when
- * the final reap completes we can report error to the user,
- * or success if an earlier URB was completed successfully.
- */
- tpriv->reap_action = EREMOTEIO == errno ? COMPLETED_EARLY : SUBMIT_FAILED;
+ if (errno == ENODEV) {
+ r = LIBUSB_ERROR_NO_DEVICE;
+ } else if (errno == ENOMEM) {
+ r = LIBUSB_ERROR_NO_MEM;
+ } else {
+ usbi_err(TRANSFER_CTX(transfer), "submiturb failed, errno=%d", errno);
+ r = LIBUSB_ERROR_IO;
+ }
- /* The URBs we haven't submitted yet we count as already
- * retired. */
- tpriv->num_retired += num_urbs - i;
+ /* if the first URB submission fails, we can simply free up and
+ * return failure immediately. */
+ if (i == 0) {
+ usbi_dbg("first URB failed, easy peasy");
+ free(urbs);
+ tpriv->urbs = NULL;
+ return r;
+ }
- /* If we completed short then don't try to discard. */
- if (COMPLETED_EARLY == tpriv->reap_action)
- return 0;
+ /* if it's not the first URB that failed, the situation is a bit
+ * tricky. we may need to discard all previous URBs. there are
+ * complications:
+ * - discarding is asynchronous - discarded urbs will be reaped
+ * later. the user must not have freed the transfer when the
+ * discarded URBs are reaped, otherwise libusb will be using
+ * freed memory.
+ * - the earlier URBs may have completed successfully and we do
+ * not want to throw away any data.
+ * - this URB failing may be no error; EREMOTEIO means that
+ * this transfer simply didn't need all the URBs we submitted
+ * so, we report that the transfer was submitted successfully and
+ * in case of error we discard all previous URBs. later when
+ * the final reap completes we can report error to the user,
+ * or success if an earlier URB was completed successfully.
+ */
+ tpriv->reap_action = errno == EREMOTEIO ? COMPLETED_EARLY : SUBMIT_FAILED;
- discard_urbs(itransfer, 0, i);
+ /* The URBs we haven't submitted yet we count as already
+ * retired. */
+ tpriv->num_retired += num_urbs - i;
- usbi_dbg("reporting successful submission but waiting for %d "
- "discards before reporting error", i);
+ /* If we completed short then don't try to discard. */
+ if (tpriv->reap_action == COMPLETED_EARLY)
return 0;
- }
+
+ discard_urbs(itransfer, 0, i);
+
+ usbi_dbg("reporting successful submission but waiting for %d "
+ "discards before reporting error", i);
+ return 0;
}
return 0;
@@ -2131,9 +2053,9 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer =
USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct linux_transfer_priv *tpriv = usbi_transfer_get_os_priv(itransfer);
- struct linux_device_handle_priv *dpriv =
- _device_handle_priv(transfer->dev_handle);
+ struct linux_transfer_priv *tpriv = usbi_get_transfer_priv(itransfer);
+ struct linux_device_handle_priv *hpriv =
+ usbi_get_device_handle_priv(transfer->dev_handle);
struct usbfs_urb **urbs;
int num_packets = transfer->num_iso_packets;
int num_packets_remaining;
@@ -2156,8 +2078,8 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer)
if (packet_len > max_iso_packet_len) {
usbi_warn(TRANSFER_CTX(transfer),
- "iso packet length of %u bytes exceeds maximum of %u bytes",
- packet_len, max_iso_packet_len);
+ "iso packet length of %u bytes exceeds maximum of %u bytes",
+ packet_len, max_iso_packet_len);
return LIBUSB_ERROR_INVALID_PARAM;
}
@@ -2170,8 +2092,7 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer)
/* usbfs limits the number of iso packets per URB */
num_urbs = (num_packets + (MAX_ISO_PACKETS_PER_URB - 1)) / MAX_ISO_PACKETS_PER_URB;
- usbi_dbg("need %d urbs for new transfer with length %d", num_urbs,
- transfer->length);
+ usbi_dbg("need %d urbs for new transfer with length %d", num_urbs, transfer->length);
urbs = calloc(num_urbs, sizeof(*urbs));
if (!urbs)
@@ -2221,56 +2142,55 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer)
/* submit URBs */
for (i = 0; i < num_urbs; i++) {
- int r = ioctl(dpriv->fd, IOCTL_USBFS_SUBMITURB, urbs[i]);
- if (r < 0) {
- if (errno == ENODEV) {
- r = LIBUSB_ERROR_NO_DEVICE;
- } else if (errno == EINVAL) {
- usbi_warn(TRANSFER_CTX(transfer),
- "submiturb failed, transfer too large");
- r = LIBUSB_ERROR_INVALID_PARAM;
- } else if (errno == EMSGSIZE) {
- usbi_warn(TRANSFER_CTX(transfer),
- "submiturb failed, iso packet length too large");
- r = LIBUSB_ERROR_INVALID_PARAM;
- } else {
- usbi_err(TRANSFER_CTX(transfer),
- "submiturb failed error %d errno=%d", r, errno);
- r = LIBUSB_ERROR_IO;
- }
-
- /* if the first URB submission fails, we can simply free up and
- * return failure immediately. */
- if (i == 0) {
- usbi_dbg("first URB failed, easy peasy");
- free_iso_urbs(tpriv);
- return r;
- }
+ int r = ioctl(hpriv->fd, IOCTL_USBFS_SUBMITURB, urbs[i]);
- /* if it's not the first URB that failed, the situation is a bit
- * tricky. we must discard all previous URBs. there are
- * complications:
- * - discarding is asynchronous - discarded urbs will be reaped
- * later. the user must not have freed the transfer when the
- * discarded URBs are reaped, otherwise libusb will be using
- * freed memory.
- * - the earlier URBs may have completed successfully and we do
- * not want to throw away any data.
- * so, in this case we discard all the previous URBs BUT we report
- * that the transfer was submitted successfully. then later when
- * the final discard completes we can report error to the user.
- */
- tpriv->reap_action = SUBMIT_FAILED;
+ if (r == 0)
+ continue;
- /* The URBs we haven't submitted yet we count as already
- * retired. */
- tpriv->num_retired = num_urbs - i;
- discard_urbs(itransfer, 0, i);
+ if (errno == ENODEV) {
+ r = LIBUSB_ERROR_NO_DEVICE;
+ } else if (errno == EINVAL) {
+ usbi_warn(TRANSFER_CTX(transfer), "submiturb failed, transfer too large");
+ r = LIBUSB_ERROR_INVALID_PARAM;
+ } else if (errno == EMSGSIZE) {
+ usbi_warn(TRANSFER_CTX(transfer), "submiturb failed, iso packet length too large");
+ r = LIBUSB_ERROR_INVALID_PARAM;
+ } else {
+ usbi_err(TRANSFER_CTX(transfer), "submiturb failed, errno=%d", errno);
+ r = LIBUSB_ERROR_IO;
+ }
- usbi_dbg("reporting successful submission but waiting for %d "
- "discards before reporting error", i);
- return 0;
+ /* if the first URB submission fails, we can simply free up and
+ * return failure immediately. */
+ if (i == 0) {
+ usbi_dbg("first URB failed, easy peasy");
+ free_iso_urbs(tpriv);
+ return r;
}
+
+ /* if it's not the first URB that failed, the situation is a bit
+ * tricky. we must discard all previous URBs. there are
+ * complications:
+ * - discarding is asynchronous - discarded urbs will be reaped
+ * later. the user must not have freed the transfer when the
+ * discarded URBs are reaped, otherwise libusb will be using
+ * freed memory.
+ * - the earlier URBs may have completed successfully and we do
+ * not want to throw away any data.
+ * so, in this case we discard all the previous URBs BUT we report
+ * that the transfer was submitted successfully. then later when
+ * the final discard completes we can report error to the user.
+ */
+ tpriv->reap_action = SUBMIT_FAILED;
+
+ /* The URBs we haven't submitted yet we count as already
+ * retired. */
+ tpriv->num_retired = num_urbs - i;
+ discard_urbs(itransfer, 0, i);
+
+ usbi_dbg("reporting successful submission but waiting for %d "
+ "discards before reporting error", i);
+ return 0;
}
return 0;
@@ -2278,18 +2198,18 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer)
static int submit_control_transfer(struct usbi_transfer *itransfer)
{
- struct linux_transfer_priv *tpriv = usbi_transfer_get_os_priv(itransfer);
+ struct linux_transfer_priv *tpriv = usbi_get_transfer_priv(itransfer);
struct libusb_transfer *transfer =
USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct linux_device_handle_priv *dpriv =
- _device_handle_priv(transfer->dev_handle);
+ struct linux_device_handle_priv *hpriv =
+ usbi_get_device_handle_priv(transfer->dev_handle);
struct usbfs_urb *urb;
int r;
if (transfer->length - LIBUSB_CONTROL_SETUP_SIZE > MAX_CTRL_BUFFER_LENGTH)
return LIBUSB_ERROR_INVALID_PARAM;
- urb = calloc(1, sizeof(struct usbfs_urb));
+ urb = calloc(1, sizeof(*urb));
if (!urb)
return LIBUSB_ERROR_NO_MEM;
tpriv->urbs = urb;
@@ -2302,15 +2222,14 @@ static int submit_control_transfer(struct usbi_transfer *itransfer)
urb->buffer = transfer->buffer;
urb->buffer_length = transfer->length;
- r = ioctl(dpriv->fd, IOCTL_USBFS_SUBMITURB, urb);
+ r = ioctl(hpriv->fd, IOCTL_USBFS_SUBMITURB, urb);
if (r < 0) {
free(urb);
tpriv->urbs = NULL;
if (errno == ENODEV)
return LIBUSB_ERROR_NO_DEVICE;
- usbi_err(TRANSFER_CTX(transfer),
- "submiturb failed error %d errno=%d", r, errno);
+ usbi_err(TRANSFER_CTX(transfer), "submiturb failed, errno=%d", errno);
return LIBUSB_ERROR_IO;
}
return 0;
@@ -2332,15 +2251,14 @@ static int op_submit_transfer(struct usbi_transfer *itransfer)
case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
return submit_iso_transfer(itransfer);
default:
- usbi_err(TRANSFER_CTX(transfer),
- "unknown endpoint type %d", transfer->type);
+ usbi_err(TRANSFER_CTX(transfer), "unknown transfer type %u", transfer->type);
return LIBUSB_ERROR_INVALID_PARAM;
}
}
static int op_cancel_transfer(struct usbi_transfer *itransfer)
{
- struct linux_transfer_priv *tpriv = usbi_transfer_get_os_priv(itransfer);
+ struct linux_transfer_priv *tpriv = usbi_get_transfer_priv(itransfer);
struct libusb_transfer *transfer =
USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
int r;
@@ -2369,7 +2287,7 @@ static void op_clear_transfer_priv(struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer =
USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct linux_transfer_priv *tpriv = usbi_transfer_get_os_priv(itransfer);
+ struct linux_transfer_priv *tpriv = usbi_get_transfer_priv(itransfer);
switch (transfer->type) {
case LIBUSB_TRANSFER_TYPE_CONTROL:
@@ -2388,21 +2306,20 @@ static void op_clear_transfer_priv(struct usbi_transfer *itransfer)
}
break;
default:
- usbi_err(TRANSFER_CTX(transfer),
- "unknown endpoint type %d", transfer->type);
+ usbi_err(TRANSFER_CTX(transfer), "unknown transfer type %u", transfer->type);
}
}
static int handle_bulk_completion(struct usbi_transfer *itransfer,
struct usbfs_urb *urb)
{
- struct linux_transfer_priv *tpriv = usbi_transfer_get_os_priv(itransfer);
+ struct linux_transfer_priv *tpriv = usbi_get_transfer_priv(itransfer);
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
int urb_idx = urb - tpriv->urbs;
usbi_mutex_lock(&itransfer->lock);
usbi_dbg("handling completion status %d of bulk urb %d/%d", urb->status,
- urb_idx + 1, tpriv->num_urbs);
+ urb_idx + 1, tpriv->num_urbs);
tpriv->num_retired++;
@@ -2428,11 +2345,12 @@ static int handle_bulk_completion(struct usbi_transfer *itransfer,
*/
if (urb->actual_length > 0) {
unsigned char *target = transfer->buffer + itransfer->transferred;
+
usbi_dbg("received %d bytes of surplus data", urb->actual_length);
if (urb->buffer != target) {
- usbi_dbg("moving surplus data from offset %zd to offset %zd",
- (unsigned char *) urb->buffer - transfer->buffer,
- target - transfer->buffer);
+ usbi_dbg("moving surplus data from offset %zu to offset %zu",
+ (unsigned char *)urb->buffer - transfer->buffer,
+ target - transfer->buffer);
memmove(target, urb->buffer, urb->actual_length);
}
itransfer->transferred += urb->actual_length;
@@ -2482,31 +2400,31 @@ static int handle_bulk_completion(struct usbi_transfer *itransfer,
case -EILSEQ:
case -ECOMM:
case -ENOSR:
- usbi_dbg("low level error %d", urb->status);
+ usbi_dbg("low-level bus error %d", urb->status);
tpriv->reap_action = ERROR;
goto cancel_remaining;
default:
- usbi_warn(ITRANSFER_CTX(itransfer),
- "unrecognised urb status %d", urb->status);
+ usbi_warn(ITRANSFER_CTX(itransfer), "unrecognised urb status %d", urb->status);
tpriv->reap_action = ERROR;
goto cancel_remaining;
}
- /* if we're the last urb or we got less data than requested then we're
+ /* if we've reaped all urbs or we got less data than requested then we're
* done */
- if (urb_idx == tpriv->num_urbs - 1) {
- usbi_dbg("last URB in transfer --> complete!");
+ if (tpriv->num_retired == tpriv->num_urbs) {
+ usbi_dbg("all URBs in transfer reaped --> complete!");
goto completed;
} else if (urb->actual_length < urb->buffer_length) {
usbi_dbg("short transfer %d/%d --> complete!",
- urb->actual_length, urb->buffer_length);
+ urb->actual_length, urb->buffer_length);
if (tpriv->reap_action == NORMAL)
tpriv->reap_action = COMPLETED_EARLY;
- } else
+ } else {
goto out_unlock;
+ }
cancel_remaining:
- if (ERROR == tpriv->reap_action && LIBUSB_TRANSFER_COMPLETED == tpriv->reap_status)
+ if (tpriv->reap_action == ERROR && tpriv->reap_status == LIBUSB_TRANSFER_COMPLETED)
tpriv->reap_status = LIBUSB_TRANSFER_ERROR;
if (tpriv->num_retired == tpriv->num_urbs) /* nothing to cancel */
@@ -2524,7 +2442,7 @@ completed:
free(tpriv->urbs);
tpriv->urbs = NULL;
usbi_mutex_unlock(&itransfer->lock);
- return CANCELLED == tpriv->reap_action ?
+ return tpriv->reap_action == CANCELLED ?
usbi_handle_transfer_cancellation(itransfer) :
usbi_handle_transfer_completion(itransfer, tpriv->reap_status);
}
@@ -2534,7 +2452,7 @@ static int handle_iso_completion(struct usbi_transfer *itransfer,
{
struct libusb_transfer *transfer =
USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct linux_transfer_priv *tpriv = usbi_transfer_get_os_priv(itransfer);
+ struct linux_transfer_priv *tpriv = usbi_get_transfer_priv(itransfer);
int num_urbs = tpriv->num_urbs;
int urb_idx = 0;
int i;
@@ -2554,7 +2472,7 @@ static int handle_iso_completion(struct usbi_transfer *itransfer,
}
usbi_dbg("handling completion status %d of iso urb %d/%d", urb->status,
- urb_idx, num_urbs);
+ urb_idx, num_urbs);
/* copy isochronous results back in */
@@ -2562,6 +2480,7 @@ static int handle_iso_completion(struct usbi_transfer *itransfer,
struct usbfs_iso_packet_desc *urb_desc = &urb->iso_frame_desc[i];
struct libusb_iso_packet_descriptor *lib_desc =
&transfer->iso_packet_desc[tpriv->iso_packet_offset++];
+
lib_desc->status = LIBUSB_TRANSFER_COMPLETED;
switch (urb_desc->status) {
case 0:
@@ -2571,15 +2490,15 @@ static int handle_iso_completion(struct usbi_transfer *itransfer,
break;
case -ENODEV:
case -ESHUTDOWN:
- usbi_dbg("device removed");
+ usbi_dbg("packet %d - device removed", i);
lib_desc->status = LIBUSB_TRANSFER_NO_DEVICE;
break;
case -EPIPE:
- usbi_dbg("detected endpoint stall");
+ usbi_dbg("packet %d - detected endpoint stall", i);
lib_desc->status = LIBUSB_TRANSFER_STALL;
break;
case -EOVERFLOW:
- usbi_dbg("overflow error");
+ usbi_dbg("packet %d - overflow error", i);
lib_desc->status = LIBUSB_TRANSFER_OVERFLOW;
break;
case -ETIME:
@@ -2588,12 +2507,12 @@ static int handle_iso_completion(struct usbi_transfer *itransfer,
case -ECOMM:
case -ENOSR:
case -EXDEV:
- usbi_dbg("low-level USB error %d", urb_desc->status);
+ usbi_dbg("packet %d - low-level USB error %d", i, urb_desc->status);
lib_desc->status = LIBUSB_TRANSFER_ERROR;
break;
default:
- usbi_warn(TRANSFER_CTX(transfer),
- "unrecognised urb status %d", urb_desc->status);
+ usbi_warn(TRANSFER_CTX(transfer), "packet %d - unrecognised urb status %d",
+ i, urb_desc->status);
lib_desc->status = LIBUSB_TRANSFER_ERROR;
break;
}
@@ -2613,8 +2532,7 @@ static int handle_iso_completion(struct usbi_transfer *itransfer,
return usbi_handle_transfer_cancellation(itransfer);
} else {
usbi_mutex_unlock(&itransfer->lock);
- return usbi_handle_transfer_completion(itransfer,
- LIBUSB_TRANSFER_ERROR);
+ return usbi_handle_transfer_completion(itransfer, LIBUSB_TRANSFER_ERROR);
}
}
goto out;
@@ -2631,15 +2549,14 @@ static int handle_iso_completion(struct usbi_transfer *itransfer,
status = LIBUSB_TRANSFER_NO_DEVICE;
break;
default:
- usbi_warn(TRANSFER_CTX(transfer),
- "unrecognised urb status %d", urb->status);
+ usbi_warn(TRANSFER_CTX(transfer), "unrecognised urb status %d", urb->status);
status = LIBUSB_TRANSFER_ERROR;
break;
}
- /* if we're the last urb then we're done */
- if (urb_idx == num_urbs) {
- usbi_dbg("last URB in transfer --> complete!");
+ /* if we've reaped all urbs then we're done */
+ if (tpriv->num_retired == num_urbs) {
+ usbi_dbg("all URBs in transfer reaped --> complete!");
free_iso_urbs(tpriv);
usbi_mutex_unlock(&itransfer->lock);
return usbi_handle_transfer_completion(itransfer, status);
@@ -2653,7 +2570,7 @@ out:
static int handle_control_completion(struct usbi_transfer *itransfer,
struct usbfs_urb *urb)
{
- struct linux_transfer_priv *tpriv = usbi_transfer_get_os_priv(itransfer);
+ struct linux_transfer_priv *tpriv = usbi_get_transfer_priv(itransfer);
int status;
usbi_mutex_lock(&itransfer->lock);
@@ -2662,9 +2579,9 @@ static int handle_control_completion(struct usbi_transfer *itransfer,
itransfer->transferred += urb->actual_length;
if (tpriv->reap_action == CANCELLED) {
- if (urb->status != 0 && urb->status != -ENOENT)
- usbi_warn(ITRANSFER_CTX(itransfer),
- "cancel: unrecognised urb status %d", urb->status);
+ if (urb->status && urb->status != -ENOENT)
+ usbi_warn(ITRANSFER_CTX(itransfer), "cancel: unrecognised urb status %d",
+ urb->status);
free(tpriv->urbs);
tpriv->urbs = NULL;
usbi_mutex_unlock(&itransfer->lock);
@@ -2688,7 +2605,7 @@ static int handle_control_completion(struct usbi_transfer *itransfer,
status = LIBUSB_TRANSFER_STALL;
break;
case -EOVERFLOW:
- usbi_dbg("control overflow error");
+ usbi_dbg("overflow, actual_length=%d", urb->actual_length);
status = LIBUSB_TRANSFER_OVERFLOW;
break;
case -ETIME:
@@ -2696,12 +2613,11 @@ static int handle_control_completion(struct usbi_transfer *itransfer,
case -EILSEQ:
case -ECOMM:
case -ENOSR:
- usbi_dbg("low-level bus error occurred");
+ usbi_dbg("low-level bus error %d", urb->status);
status = LIBUSB_TRANSFER_ERROR;
break;
default:
- usbi_warn(ITRANSFER_CTX(itransfer),
- "unrecognised urb status %d", urb->status);
+ usbi_warn(ITRANSFER_CTX(itransfer), "unrecognised urb status %d", urb->status);
status = LIBUSB_TRANSFER_ERROR;
break;
}
@@ -2714,29 +2630,27 @@ static int handle_control_completion(struct usbi_transfer *itransfer,
static int reap_for_handle(struct libusb_device_handle *handle)
{
- struct linux_device_handle_priv *hpriv = _device_handle_priv(handle);
+ struct linux_device_handle_priv *hpriv = usbi_get_device_handle_priv(handle);
int r;
struct usbfs_urb *urb = NULL;
struct usbi_transfer *itransfer;
struct libusb_transfer *transfer;
r = ioctl(hpriv->fd, IOCTL_USBFS_REAPURBNDELAY, &urb);
- if (r == -1 && errno == EAGAIN)
- return 1;
if (r < 0) {
+ if (errno == EAGAIN)
+ return 1;
if (errno == ENODEV)
return LIBUSB_ERROR_NO_DEVICE;
- usbi_err(HANDLE_CTX(handle), "reap failed error %d errno=%d",
- r, errno);
+ usbi_err(HANDLE_CTX(handle), "reap failed, errno=%d", errno);
return LIBUSB_ERROR_IO;
}
itransfer = urb->usercontext;
transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- usbi_dbg("urb type=%d status=%d transferred=%d", urb->type, urb->status,
- urb->actual_length);
+ usbi_dbg("urb type=%u status=%d transferred=%d", urb->type, urb->status, urb->actual_length);
switch (transfer->type) {
case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
@@ -2748,30 +2662,31 @@ static int reap_for_handle(struct libusb_device_handle *handle)
case LIBUSB_TRANSFER_TYPE_CONTROL:
return handle_control_completion(itransfer, urb);
default:
- usbi_err(HANDLE_CTX(handle), "unrecognised endpoint type %x",
- transfer->type);
+ usbi_err(HANDLE_CTX(handle), "unrecognised transfer type %u", transfer->type);
return LIBUSB_ERROR_OTHER;
}
}
static int op_handle_events(struct libusb_context *ctx,
- struct pollfd *fds, POLL_NFDS_TYPE nfds, int num_ready)
+ void *event_data, unsigned int count, unsigned int num_ready)
{
+ struct pollfd *fds = event_data;
+ unsigned int n;
int r;
- unsigned int i = 0;
usbi_mutex_lock(&ctx->open_devs_lock);
- for (i = 0; i < nfds && num_ready > 0; i++) {
- struct pollfd *pollfd = &fds[i];
+ for (n = 0; n < count && num_ready > 0; n++) {
+ struct pollfd *pollfd = &fds[n];
struct libusb_device_handle *handle;
struct linux_device_handle_priv *hpriv = NULL;
+ int reap_count;
if (!pollfd->revents)
continue;
num_ready--;
- list_for_each_entry(handle, &ctx->open_devs, list, struct libusb_device_handle) {
- hpriv = _device_handle_priv(handle);
+ for_each_open_device(ctx, handle) {
+ hpriv = usbi_get_device_handle_priv(handle);
if (hpriv->fd == pollfd->fd)
break;
}
@@ -2786,7 +2701,7 @@ static int op_handle_events(struct libusb_context *ctx,
/* remove the fd from the pollfd set so that it doesn't continuously
* trigger an event, and flag that it has been removed so op_close()
* doesn't try to remove it a second time */
- usbi_remove_pollfd(HANDLE_CTX(handle), hpriv->fd);
+ usbi_remove_event_source(HANDLE_CTX(handle), hpriv->fd);
hpriv->fd_removed = 1;
/* device will still be marked as attached if hotplug monitor thread
@@ -2794,7 +2709,7 @@ static int op_handle_events(struct libusb_context *ctx,
usbi_mutex_static_lock(&linux_hotplug_lock);
if (handle->dev->attached)
linux_device_disconnected(handle->dev->bus_number,
- handle->dev->device_address);
+ handle->dev->device_address);
usbi_mutex_static_unlock(&linux_hotplug_lock);
if (hpriv->caps & USBFS_CAP_REAP_AFTER_DISCONNECT) {
@@ -2807,9 +2722,11 @@ static int op_handle_events(struct libusb_context *ctx,
continue;
}
+ reap_count = 0;
do {
r = reap_for_handle(handle);
- } while (r == 0);
+ } while (r == 0 && ++reap_count <= 25);
+
if (r == 1 || r == LIBUSB_ERROR_NO_DEVICE)
continue;
else if (r < 0)
@@ -2822,34 +2739,13 @@ out:
return r;
}
-static int op_clock_gettime(int clk_id, struct timespec *tp)
-{
- switch (clk_id) {
- case USBI_CLOCK_MONOTONIC:
- return clock_gettime(monotonic_clkid, tp);
- case USBI_CLOCK_REALTIME:
- return clock_gettime(CLOCK_REALTIME, tp);
- default:
- return LIBUSB_ERROR_INVALID_PARAM;
- }
-}
-
-#ifdef USBI_TIMERFD_AVAILABLE
-static clockid_t op_get_timerfd_clockid(void)
-{
- return monotonic_clkid;
-
-}
-#endif
-
const struct usbi_os_backend usbi_backend = {
.name = "Linux usbfs",
.caps = USBI_CAP_HAS_HID_ACCESS|USBI_CAP_SUPPORTS_DETACH_KERNEL_DRIVER,
.init = op_init,
.exit = op_exit,
- .get_device_list = NULL,
+ .set_option = op_set_option,
.hotplug_poll = op_hotplug_poll,
- .get_device_descriptor = op_get_device_descriptor,
.get_active_config_descriptor = op_get_active_config_descriptor,
.get_config_descriptor = op_get_config_descriptor,
.get_config_descriptor_by_value = op_get_config_descriptor_by_value,
@@ -2884,12 +2780,6 @@ const struct usbi_os_backend usbi_backend = {
.handle_events = op_handle_events,
- .clock_gettime = op_clock_gettime,
-
-#ifdef USBI_TIMERFD_AVAILABLE
- .get_timerfd_clockid = op_get_timerfd_clockid,
-#endif
-
.device_priv_size = sizeof(struct linux_device_priv),
.device_handle_priv_size = sizeof(struct linux_device_handle_priv),
.transfer_priv_size = sizeof(struct linux_transfer_priv),
diff --git a/libusb/os/linux_usbfs.h b/libusb/os/linux_usbfs.h
index a57eb41..1238ffa 100644
--- a/libusb/os/linux_usbfs.h
+++ b/libusb/os/linux_usbfs.h
@@ -21,29 +21,20 @@
#ifndef LIBUSB_USBFS_H
#define LIBUSB_USBFS_H
+#include <linux/magic.h>
#include <linux/types.h>
-#define SYSFS_DEVICE_PATH "/sys/bus/usb/devices"
+#define SYSFS_MOUNT_PATH "/sys"
+#define SYSFS_DEVICE_PATH SYSFS_MOUNT_PATH "/bus/usb/devices"
struct usbfs_ctrltransfer {
/* keep in sync with usbdevice_fs.h:usbdevfs_ctrltransfer */
- uint8_t bmRequestType;
- uint8_t bRequest;
- uint16_t wValue;
- uint16_t wIndex;
- uint16_t wLength;
-
- uint32_t timeout; /* in milliseconds */
-
- /* pointer to data */
- void *data;
-};
-
-struct usbfs_bulktransfer {
- /* keep in sync with usbdevice_fs.h:usbdevfs_bulktransfer */
- unsigned int ep;
- unsigned int len;
- unsigned int timeout; /* in milliseconds */
+ __u8 bmRequestType;
+ __u8 bRequest;
+ __u16 wValue;
+ __u16 wIndex;
+ __u16 wLength;
+ __u32 timeout; /* in milliseconds */
/* pointer to data */
void *data;
@@ -55,7 +46,7 @@ struct usbfs_setinterface {
unsigned int altsetting;
};
-#define USBFS_MAXDRIVERNAME 255
+#define USBFS_MAXDRIVERNAME 255
struct usbfs_getdriver {
unsigned int interface;
@@ -63,17 +54,15 @@ struct usbfs_getdriver {
};
#define USBFS_URB_SHORT_NOT_OK 0x01
-#define USBFS_URB_ISO_ASAP 0x02
+#define USBFS_URB_ISO_ASAP 0x02
#define USBFS_URB_BULK_CONTINUATION 0x04
#define USBFS_URB_QUEUE_BULK 0x10
#define USBFS_URB_ZERO_PACKET 0x40
-enum usbfs_urb_type {
- USBFS_URB_TYPE_ISO = 0,
- USBFS_URB_TYPE_INTERRUPT = 1,
- USBFS_URB_TYPE_CONTROL = 2,
- USBFS_URB_TYPE_BULK = 3,
-};
+#define USBFS_URB_TYPE_ISO 0
+#define USBFS_URB_TYPE_INTERRUPT 1
+#define USBFS_URB_TYPE_CONTROL 2
+#define USBFS_URB_TYPE_BULK 3
struct usbfs_iso_packet_desc {
unsigned int length;
@@ -117,16 +106,11 @@ struct usbfs_ioctl {
void *data; /* param buffer (in, or out) */
};
-struct usbfs_hub_portinfo {
- unsigned char numports;
- unsigned char port[127]; /* port to device num mapping */
-};
-
-#define USBFS_CAP_ZERO_PACKET 0x01
-#define USBFS_CAP_BULK_CONTINUATION 0x02
-#define USBFS_CAP_NO_PACKET_SIZE_LIM 0x04
-#define USBFS_CAP_BULK_SCATTER_GATHER 0x08
-#define USBFS_CAP_REAP_AFTER_DISCONNECT 0x10
+#define USBFS_CAP_ZERO_PACKET 0x01
+#define USBFS_CAP_BULK_CONTINUATION 0x02
+#define USBFS_CAP_NO_PACKET_SIZE_LIM 0x04
+#define USBFS_CAP_BULK_SCATTER_GATHER 0x08
+#define USBFS_CAP_REAP_AFTER_DISCONNECT 0x10
#define USBFS_DISCONNECT_CLAIM_IF_DRIVER 0x01
#define USBFS_DISCONNECT_CLAIM_EXCEPT_DRIVER 0x02
@@ -143,35 +127,39 @@ struct usbfs_streams {
unsigned char eps[0];
};
-#define IOCTL_USBFS_CONTROL _IOWR('U', 0, struct usbfs_ctrltransfer)
-#define IOCTL_USBFS_BULK _IOWR('U', 2, struct usbfs_bulktransfer)
-#define IOCTL_USBFS_RESETEP _IOR('U', 3, unsigned int)
-#define IOCTL_USBFS_SETINTF _IOR('U', 4, struct usbfs_setinterface)
-#define IOCTL_USBFS_SETCONFIG _IOR('U', 5, unsigned int)
-#define IOCTL_USBFS_GETDRIVER _IOW('U', 8, struct usbfs_getdriver)
-#define IOCTL_USBFS_SUBMITURB _IOR('U', 10, struct usbfs_urb)
-#define IOCTL_USBFS_DISCARDURB _IO('U', 11)
-#define IOCTL_USBFS_REAPURB _IOW('U', 12, void *)
+#define USBFS_SPEED_UNKNOWN 0
+#define USBFS_SPEED_LOW 1
+#define USBFS_SPEED_FULL 2
+#define USBFS_SPEED_HIGH 3
+#define USBFS_SPEED_WIRELESS 4
+#define USBFS_SPEED_SUPER 5
+#define USBFS_SPEED_SUPER_PLUS 6
+
+#define IOCTL_USBFS_CONTROL _IOWR('U', 0, struct usbfs_ctrltransfer)
+#define IOCTL_USBFS_SETINTERFACE _IOR('U', 4, struct usbfs_setinterface)
+#define IOCTL_USBFS_SETCONFIGURATION _IOR('U', 5, unsigned int)
+#define IOCTL_USBFS_GETDRIVER _IOW('U', 8, struct usbfs_getdriver)
+#define IOCTL_USBFS_SUBMITURB _IOR('U', 10, struct usbfs_urb)
+#define IOCTL_USBFS_DISCARDURB _IO('U', 11)
#define IOCTL_USBFS_REAPURBNDELAY _IOW('U', 13, void *)
-#define IOCTL_USBFS_CLAIMINTF _IOR('U', 15, unsigned int)
-#define IOCTL_USBFS_RELEASEINTF _IOR('U', 16, unsigned int)
-#define IOCTL_USBFS_CONNECTINFO _IOW('U', 17, struct usbfs_connectinfo)
-#define IOCTL_USBFS_IOCTL _IOWR('U', 18, struct usbfs_ioctl)
-#define IOCTL_USBFS_HUB_PORTINFO _IOR('U', 19, struct usbfs_hub_portinfo)
+#define IOCTL_USBFS_CLAIMINTERFACE _IOR('U', 15, unsigned int)
+#define IOCTL_USBFS_RELEASEINTERFACE _IOR('U', 16, unsigned int)
+#define IOCTL_USBFS_CONNECTINFO _IOW('U', 17, struct usbfs_connectinfo)
+#define IOCTL_USBFS_IOCTL _IOWR('U', 18, struct usbfs_ioctl)
#define IOCTL_USBFS_RESET _IO('U', 20)
-#define IOCTL_USBFS_CLEAR_HALT _IOR('U', 21, unsigned int)
-#define IOCTL_USBFS_DISCONNECT _IO('U', 22)
-#define IOCTL_USBFS_CONNECT _IO('U', 23)
-#define IOCTL_USBFS_CLAIM_PORT _IOR('U', 24, unsigned int)
-#define IOCTL_USBFS_RELEASE_PORT _IOR('U', 25, unsigned int)
+#define IOCTL_USBFS_CLEAR_HALT _IOR('U', 21, unsigned int)
+#define IOCTL_USBFS_DISCONNECT _IO('U', 22)
+#define IOCTL_USBFS_CONNECT _IO('U', 23)
#define IOCTL_USBFS_GET_CAPABILITIES _IOR('U', 26, __u32)
#define IOCTL_USBFS_DISCONNECT_CLAIM _IOR('U', 27, struct usbfs_disconnect_claim)
#define IOCTL_USBFS_ALLOC_STREAMS _IOR('U', 28, struct usbfs_streams)
#define IOCTL_USBFS_FREE_STREAMS _IOR('U', 29, struct usbfs_streams)
+#define IOCTL_USBFS_DROP_PRIVILEGES _IOW('U', 30, __u32)
+#define IOCTL_USBFS_GET_SPEED _IO('U', 31)
extern usbi_mutex_static_t linux_hotplug_lock;
-#if defined(HAVE_LIBUDEV)
+#ifdef HAVE_LIBUDEV
int linux_udev_start_event_monitor(void);
int linux_udev_stop_event_monitor(void);
int linux_udev_scan_devices(struct libusb_context *ctx);
@@ -182,10 +170,39 @@ int linux_netlink_stop_event_monitor(void);
void linux_netlink_hotplug_poll(void);
#endif
+static inline int linux_start_event_monitor(void)
+{
+#if defined(HAVE_LIBUDEV)
+ return linux_udev_start_event_monitor();
+#elif !defined(__ANDROID__)
+ return linux_netlink_start_event_monitor();
+#else
+ return LIBUSB_SUCCESS;
+#endif
+}
+
+static inline void linux_stop_event_monitor(void)
+{
+#if defined(HAVE_LIBUDEV)
+ linux_udev_stop_event_monitor();
+#elif !defined(__ANDROID__)
+ linux_netlink_stop_event_monitor();
+#endif
+}
+
+static inline void linux_hotplug_poll(void)
+{
+#if defined(HAVE_LIBUDEV)
+ linux_udev_hotplug_poll();
+#elif !defined(__ANDROID__)
+ linux_netlink_hotplug_poll();
+#endif
+}
+
void linux_hotplug_enumerate(uint8_t busnum, uint8_t devaddr, const char *sys_name);
void linux_device_disconnected(uint8_t busnum, uint8_t devaddr);
-int linux_get_device_address (struct libusb_context *ctx, int detached,
+int linux_get_device_address(struct libusb_context *ctx, int detached,
uint8_t *busnum, uint8_t *devaddr, const char *dev_node,
const char *sys_name, int fd);
int linux_enumerate_device(struct libusb_context *ctx,
diff --git a/libusb/os/netbsd_usb.c b/libusb/os/netbsd_usb.c
index 79aeca9..7a36209 100644
--- a/libusb/os/netbsd_usb.c
+++ b/libusb/os/netbsd_usb.c
@@ -36,8 +36,7 @@ struct device_priv {
char devnode[16];
int fd;
- unsigned char *cdesc; /* active config descriptor */
- usb_device_descriptor_t ddesc; /* usb device descriptor */
+ usb_config_descriptor_t *cdesc; /* active config descriptor */
};
struct handle_priv {
@@ -52,30 +51,25 @@ static int netbsd_get_device_list(struct libusb_context *,
static int netbsd_open(struct libusb_device_handle *);
static void netbsd_close(struct libusb_device_handle *);
-static int netbsd_get_device_descriptor(struct libusb_device *, unsigned char *,
- int *);
static int netbsd_get_active_config_descriptor(struct libusb_device *,
- unsigned char *, size_t, int *);
+ void *, size_t);
static int netbsd_get_config_descriptor(struct libusb_device *, uint8_t,
- unsigned char *, size_t, int *);
+ void *, size_t);
-static int netbsd_get_configuration(struct libusb_device_handle *, int *);
+static int netbsd_get_configuration(struct libusb_device_handle *, uint8_t *);
static int netbsd_set_configuration(struct libusb_device_handle *, int);
-static int netbsd_claim_interface(struct libusb_device_handle *, int);
-static int netbsd_release_interface(struct libusb_device_handle *, int);
+static int netbsd_claim_interface(struct libusb_device_handle *, uint8_t);
+static int netbsd_release_interface(struct libusb_device_handle *, uint8_t);
-static int netbsd_set_interface_altsetting(struct libusb_device_handle *, int,
- int);
+static int netbsd_set_interface_altsetting(struct libusb_device_handle *,
+ uint8_t, uint8_t);
static int netbsd_clear_halt(struct libusb_device_handle *, unsigned char);
-static int netbsd_reset_device(struct libusb_device_handle *);
static void netbsd_destroy_device(struct libusb_device *);
static int netbsd_submit_transfer(struct usbi_transfer *);
static int netbsd_cancel_transfer(struct usbi_transfer *);
-static void netbsd_clear_transfer_priv(struct usbi_transfer *);
static int netbsd_handle_transfer_completion(struct usbi_transfer *);
-static int netbsd_clock_gettime(int, struct timespec *);
/*
* Private functions
@@ -87,55 +81,33 @@ static int _sync_gen_transfer(struct usbi_transfer *);
static int _access_endpoint(struct libusb_transfer *);
const struct usbi_os_backend usbi_backend = {
- "Synchronous NetBSD backend",
- 0,
- NULL, /* init() */
- NULL, /* exit() */
- NULL, /* set_option() */
- netbsd_get_device_list,
- NULL, /* hotplug_poll */
- netbsd_open,
- netbsd_close,
-
- netbsd_get_device_descriptor,
- netbsd_get_active_config_descriptor,
- netbsd_get_config_descriptor,
- NULL, /* get_config_descriptor_by_value() */
-
- netbsd_get_configuration,
- netbsd_set_configuration,
-
- netbsd_claim_interface,
- netbsd_release_interface,
-
- netbsd_set_interface_altsetting,
- netbsd_clear_halt,
- netbsd_reset_device,
-
- NULL, /* alloc_streams */
- NULL, /* free_streams */
-
- NULL, /* dev_mem_alloc() */
- NULL, /* dev_mem_free() */
-
- NULL, /* kernel_driver_active() */
- NULL, /* detach_kernel_driver() */
- NULL, /* attach_kernel_driver() */
-
- netbsd_destroy_device,
-
- netbsd_submit_transfer,
- netbsd_cancel_transfer,
- netbsd_clear_transfer_priv,
-
- NULL, /* handle_events() */
- netbsd_handle_transfer_completion,
-
- netbsd_clock_gettime,
- 0, /* context_priv_size */
- sizeof(struct device_priv),
- sizeof(struct handle_priv),
- 0, /* transfer_priv_size */
+ .name = "Synchronous NetBSD backend",
+ .caps = 0,
+ .get_device_list = netbsd_get_device_list,
+ .open = netbsd_open,
+ .close = netbsd_close,
+
+ .get_active_config_descriptor = netbsd_get_active_config_descriptor,
+ .get_config_descriptor = netbsd_get_config_descriptor,
+
+ .get_configuration = netbsd_get_configuration,
+ .set_configuration = netbsd_set_configuration,
+
+ .claim_interface = netbsd_claim_interface,
+ .release_interface = netbsd_release_interface,
+
+ .set_interface_altsetting = netbsd_set_interface_altsetting,
+ .clear_halt = netbsd_clear_halt,
+
+ .destroy_device = netbsd_destroy_device,
+
+ .submit_transfer = netbsd_submit_transfer,
+ .cancel_transfer = netbsd_cancel_transfer,
+
+ .handle_transfer_completion = netbsd_handle_transfer_completion,
+
+ .device_priv_size = sizeof(struct device_priv),
+ .device_handle_priv_size = sizeof(struct handle_priv),
};
int
@@ -145,11 +117,12 @@ netbsd_get_device_list(struct libusb_context * ctx,
struct libusb_device *dev;
struct device_priv *dpriv;
struct usb_device_info di;
+ usb_device_descriptor_t ddesc;
unsigned long session_id;
char devnode[16];
int fd, err, i;
- usbi_dbg("");
+ usbi_dbg(" ");
/* Only ugen(4) is supported */
for (i = 0; i < USB_MAX_DEVICES; i++) {
@@ -177,16 +150,20 @@ netbsd_get_device_list(struct libusb_context * ctx,
dev->device_address = di.udi_addr;
dev->speed = di.udi_speed;
- dpriv = (struct device_priv *)dev->os_priv;
+ dpriv = usbi_get_device_priv(dev);
strlcpy(dpriv->devnode, devnode, sizeof(devnode));
dpriv->fd = -1;
- if (ioctl(fd, USB_GET_DEVICE_DESC, &dpriv->ddesc) < 0) {
+ if (ioctl(fd, USB_GET_DEVICE_DESC, &ddesc) < 0) {
err = errno;
goto error;
}
- dpriv->cdesc = NULL;
+ static_assert(sizeof(dev->device_descriptor) == sizeof(ddesc),
+ "mismatch between libusb and OS device descriptor sizes");
+ memcpy(&dev->device_descriptor, &ddesc, LIBUSB_DT_DEVICE_SIZE);
+ usbi_localize_device_descriptor(&dev->device_descriptor);
+
if (_cache_active_config_descriptor(dev, fd)) {
err = errno;
goto error;
@@ -214,8 +191,8 @@ error:
int
netbsd_open(struct libusb_device_handle *handle)
{
- struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
- struct handle_priv *hpriv = (struct handle_priv *)handle->os_priv;
+ struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
+ struct handle_priv *hpriv = usbi_get_device_handle_priv(handle);
int i;
dpriv->fd = open(dpriv->devnode, O_RDWR);
@@ -236,7 +213,7 @@ netbsd_open(struct libusb_device_handle *handle)
void
netbsd_close(struct libusb_device_handle *handle)
{
- struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
+ struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
usbi_dbg("close: fd %d", dpriv->fd);
@@ -245,48 +222,29 @@ netbsd_close(struct libusb_device_handle *handle)
}
int
-netbsd_get_device_descriptor(struct libusb_device *dev, unsigned char *buf,
- int *host_endian)
-{
- struct device_priv *dpriv = (struct device_priv *)dev->os_priv;
-
- usbi_dbg("");
-
- memcpy(buf, &dpriv->ddesc, DEVICE_DESC_LENGTH);
-
- *host_endian = 0;
-
- return (LIBUSB_SUCCESS);
-}
-
-int
netbsd_get_active_config_descriptor(struct libusb_device *dev,
- unsigned char *buf, size_t len, int *host_endian)
+ void *buf, size_t len)
{
- struct device_priv *dpriv = (struct device_priv *)dev->os_priv;
- usb_config_descriptor_t *ucd;
+ struct device_priv *dpriv = usbi_get_device_priv(dev);
- ucd = (usb_config_descriptor_t *) dpriv->cdesc;
- len = MIN(len, UGETW(ucd->wTotalLength));
+ len = MIN(len, (size_t)UGETW(dpriv->cdesc->wTotalLength));
- usbi_dbg("len %d", len);
+ usbi_dbg("len %zu", len);
memcpy(buf, dpriv->cdesc, len);
- *host_endian = 0;
-
- return len;
+ return (int)len;
}
int
netbsd_get_config_descriptor(struct libusb_device *dev, uint8_t idx,
- unsigned char *buf, size_t len, int *host_endian)
+ void *buf, size_t len)
{
- struct device_priv *dpriv = (struct device_priv *)dev->os_priv;
+ struct device_priv *dpriv = usbi_get_device_priv(dev);
struct usb_full_desc ufd;
int fd, err;
- usbi_dbg("index %d, len %d", idx, len);
+ usbi_dbg("index %u, len %zu", idx, len);
/* A config descriptor may be requested before opening the device */
if (dpriv->fd >= 0) {
@@ -311,22 +269,22 @@ netbsd_get_config_descriptor(struct libusb_device *dev, uint8_t idx,
if (dpriv->fd < 0)
close(fd);
- *host_endian = 0;
-
- return len;
+ return (int)len;
}
int
-netbsd_get_configuration(struct libusb_device_handle *handle, int *config)
+netbsd_get_configuration(struct libusb_device_handle *handle, uint8_t *config)
{
- struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
+ struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
+ int tmp;
- usbi_dbg("");
+ usbi_dbg(" ");
- if (ioctl(dpriv->fd, USB_GET_CONFIG, config) < 0)
+ if (ioctl(dpriv->fd, USB_GET_CONFIG, &tmp) < 0)
return _errno_to_libusb(errno);
- usbi_dbg("configuration %d", *config);
+ usbi_dbg("configuration %d", tmp);
+ *config = (uint8_t)tmp;
return (LIBUSB_SUCCESS);
}
@@ -334,7 +292,7 @@ netbsd_get_configuration(struct libusb_device_handle *handle, int *config)
int
netbsd_set_configuration(struct libusb_device_handle *handle, int config)
{
- struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
+ struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
usbi_dbg("configuration %d", config);
@@ -345,11 +303,13 @@ netbsd_set_configuration(struct libusb_device_handle *handle, int config)
}
int
-netbsd_claim_interface(struct libusb_device_handle *handle, int iface)
+netbsd_claim_interface(struct libusb_device_handle *handle, uint8_t iface)
{
- struct handle_priv *hpriv = (struct handle_priv *)handle->os_priv;
+ struct handle_priv *hpriv = usbi_get_device_handle_priv(handle);
int i;
+ UNUSED(iface);
+
for (i = 0; i < USB_MAX_ENDPOINTS; i++)
hpriv->endpoints[i] = -1;
@@ -357,11 +317,13 @@ netbsd_claim_interface(struct libusb_device_handle *handle, int iface)
}
int
-netbsd_release_interface(struct libusb_device_handle *handle, int iface)
+netbsd_release_interface(struct libusb_device_handle *handle, uint8_t iface)
{
- struct handle_priv *hpriv = (struct handle_priv *)handle->os_priv;
+ struct handle_priv *hpriv = usbi_get_device_handle_priv(handle);
int i;
+ UNUSED(iface);
+
for (i = 0; i < USB_MAX_ENDPOINTS; i++)
if (hpriv->endpoints[i] >= 0)
close(hpriv->endpoints[i]);
@@ -370,13 +332,13 @@ netbsd_release_interface(struct libusb_device_handle *handle, int iface)
}
int
-netbsd_set_interface_altsetting(struct libusb_device_handle *handle, int iface,
- int altsetting)
+netbsd_set_interface_altsetting(struct libusb_device_handle *handle, uint8_t iface,
+ uint8_t altsetting)
{
- struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
+ struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
struct usb_alt_interface intf;
- usbi_dbg("iface %d, setting %d", iface, altsetting);
+ usbi_dbg("iface %u, setting %u", iface, altsetting);
memset(&intf, 0, sizeof(intf));
@@ -392,10 +354,10 @@ netbsd_set_interface_altsetting(struct libusb_device_handle *handle, int iface,
int
netbsd_clear_halt(struct libusb_device_handle *handle, unsigned char endpoint)
{
- struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
+ struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
struct usb_ctl_request req;
- usbi_dbg("");
+ usbi_dbg(" ");
req.ucr_request.bmRequestType = UT_WRITE_ENDPOINT;
req.ucr_request.bRequest = UR_CLEAR_FEATURE;
@@ -409,20 +371,12 @@ netbsd_clear_halt(struct libusb_device_handle *handle, unsigned char endpoint)
return (LIBUSB_SUCCESS);
}
-int
-netbsd_reset_device(struct libusb_device_handle *handle)
-{
- usbi_dbg("");
-
- return (LIBUSB_ERROR_NOT_SUPPORTED);
-}
-
void
netbsd_destroy_device(struct libusb_device *dev)
{
- struct device_priv *dpriv = (struct device_priv *)dev->os_priv;
+ struct device_priv *dpriv = usbi_get_device_priv(dev);
- usbi_dbg("");
+ usbi_dbg(" ");
free(dpriv->cdesc);
}
@@ -431,13 +385,11 @@ int
netbsd_submit_transfer(struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer;
- struct handle_priv *hpriv;
int err = 0;
- usbi_dbg("");
+ usbi_dbg(" ");
transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- hpriv = (struct handle_priv *)transfer->dev_handle->os_priv;
switch (transfer->type) {
case LIBUSB_TRANSFER_TYPE_CONTROL:
@@ -476,17 +428,11 @@ netbsd_submit_transfer(struct usbi_transfer *itransfer)
int
netbsd_cancel_transfer(struct usbi_transfer *itransfer)
{
- usbi_dbg("");
+ UNUSED(itransfer);
- return (LIBUSB_ERROR_NOT_SUPPORTED);
-}
+ usbi_dbg(" ");
-void
-netbsd_clear_transfer_priv(struct usbi_transfer *itransfer)
-{
- usbi_dbg("");
-
- /* Nothing to do */
+ return (LIBUSB_ERROR_NOT_SUPPORTED);
}
int
@@ -496,20 +442,6 @@ netbsd_handle_transfer_completion(struct usbi_transfer *itransfer)
}
int
-netbsd_clock_gettime(int clkid, struct timespec *tp)
-{
- usbi_dbg("clock %d", clkid);
-
- if (clkid == USBI_CLOCK_REALTIME)
- return clock_gettime(CLOCK_REALTIME, tp);
-
- if (clkid == USBI_CLOCK_MONOTONIC)
- return clock_gettime(CLOCK_MONOTONIC, tp);
-
- return (LIBUSB_ERROR_INVALID_PARAM);
-}
-
-int
_errno_to_libusb(int err)
{
switch (err) {
@@ -521,6 +453,9 @@ _errno_to_libusb(int err)
return (LIBUSB_ERROR_NO_DEVICE);
case ENOMEM:
return (LIBUSB_ERROR_NO_MEM);
+ case EWOULDBLOCK:
+ case ETIMEDOUT:
+ return (LIBUSB_ERROR_TIMEOUT);
}
usbi_dbg("error: %s", strerror(err));
@@ -531,10 +466,10 @@ _errno_to_libusb(int err)
int
_cache_active_config_descriptor(struct libusb_device *dev, int fd)
{
- struct device_priv *dpriv = (struct device_priv *)dev->os_priv;
+ struct device_priv *dpriv = usbi_get_device_priv(dev);
struct usb_config_desc ucd;
struct usb_full_desc ufd;
- unsigned char* buf;
+ void *buf;
int len;
usbi_dbg("fd %d", fd);
@@ -547,7 +482,7 @@ _cache_active_config_descriptor(struct libusb_device *dev, int fd)
usbi_dbg("active bLength %d", ucd.ucd_desc.bLength);
len = UGETW(ucd.ucd_desc.wTotalLength);
- buf = malloc(len);
+ buf = malloc((size_t)len);
if (buf == NULL)
return (LIBUSB_ERROR_NO_MEM);
@@ -578,7 +513,7 @@ _sync_control_transfer(struct usbi_transfer *itransfer)
struct usb_ctl_request req;
transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- dpriv = (struct device_priv *)transfer->dev_handle->dev->os_priv;
+ dpriv = usbi_get_device_priv(transfer->dev_handle->dev);
setup = (struct libusb_control_setup *)transfer->buffer;
usbi_dbg("type %d request %d value %d index %d length %d timeout %d",
@@ -620,8 +555,8 @@ _access_endpoint(struct libusb_transfer *transfer)
int fd, endpt;
mode_t mode;
- hpriv = (struct handle_priv *)transfer->dev_handle->os_priv;
- dpriv = (struct device_priv *)transfer->dev_handle->dev->os_priv;
+ hpriv = usbi_get_device_handle_priv(transfer->dev_handle);
+ dpriv = usbi_get_device_priv(transfer->dev_handle->dev);
endpt = UE_GET_ADDR(transfer->endpoint);
mode = IS_XFERIN(transfer) ? O_RDONLY : O_WRONLY;
diff --git a/libusb/os/null_usb.c b/libusb/os/null_usb.c
new file mode 100644
index 0000000..0cd531d
--- /dev/null
+++ b/libusb/os/null_usb.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright © 2019 Pino Toscano <toscano.pino@tiscali.it>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libusbi.h"
+
+static int
+null_get_device_list(struct libusb_context * ctx,
+ struct discovered_devs **discdevs)
+{
+ return LIBUSB_SUCCESS;
+}
+
+static int
+null_open(struct libusb_device_handle *handle)
+{
+ return LIBUSB_ERROR_NOT_SUPPORTED;
+}
+
+static void
+null_close(struct libusb_device_handle *handle)
+{
+}
+
+static int
+null_get_active_config_descriptor(struct libusb_device *dev,
+ void *buf, size_t len)
+{
+ return LIBUSB_ERROR_NOT_SUPPORTED;
+}
+
+static int
+null_get_config_descriptor(struct libusb_device *dev, uint8_t idx,
+ void *buf, size_t len)
+{
+ return LIBUSB_ERROR_NOT_SUPPORTED;
+}
+
+static int
+null_set_configuration(struct libusb_device_handle *handle, int config)
+{
+ return LIBUSB_ERROR_NOT_SUPPORTED;
+}
+
+static int
+null_claim_interface(struct libusb_device_handle *handle, uint8_t iface)
+{
+ return LIBUSB_ERROR_NOT_SUPPORTED;
+}
+
+static int
+null_release_interface(struct libusb_device_handle *handle, uint8_t iface)
+{
+ return LIBUSB_ERROR_NOT_SUPPORTED;
+}
+
+static int
+null_set_interface_altsetting(struct libusb_device_handle *handle, uint8_t iface,
+ uint8_t altsetting)
+{
+ return LIBUSB_ERROR_NOT_SUPPORTED;
+}
+
+static int
+null_clear_halt(struct libusb_device_handle *handle, unsigned char endpoint)
+{
+ return LIBUSB_ERROR_NOT_SUPPORTED;
+}
+
+static int
+null_submit_transfer(struct usbi_transfer *itransfer)
+{
+ return LIBUSB_ERROR_NOT_SUPPORTED;
+}
+
+static int
+null_cancel_transfer(struct usbi_transfer *itransfer)
+{
+ return LIBUSB_ERROR_NOT_SUPPORTED;
+}
+
+const struct usbi_os_backend usbi_backend = {
+ .name = "Null backend",
+ .caps = 0,
+ .get_device_list = null_get_device_list,
+ .open = null_open,
+ .close = null_close,
+ .get_active_config_descriptor = null_get_active_config_descriptor,
+ .get_config_descriptor = null_get_config_descriptor,
+ .set_configuration = null_set_configuration,
+ .claim_interface = null_claim_interface,
+ .release_interface = null_release_interface,
+ .set_interface_altsetting = null_set_interface_altsetting,
+ .clear_halt = null_clear_halt,
+ .submit_transfer = null_submit_transfer,
+ .cancel_transfer = null_cancel_transfer,
+};
diff --git a/libusb/os/openbsd_usb.c b/libusb/os/openbsd_usb.c
index 74d2c0f..e05610e 100644
--- a/libusb/os/openbsd_usb.c
+++ b/libusb/os/openbsd_usb.c
@@ -36,8 +36,7 @@ struct device_priv {
char *devname; /* name of the ugen(4) node */
int fd; /* device file descriptor */
- unsigned char *cdesc; /* active config descriptor */
- usb_device_descriptor_t ddesc; /* usb device descriptor */
+ usb_config_descriptor_t *cdesc; /* active config descriptor */
};
struct handle_priv {
@@ -52,30 +51,25 @@ static int obsd_get_device_list(struct libusb_context *,
static int obsd_open(struct libusb_device_handle *);
static void obsd_close(struct libusb_device_handle *);
-static int obsd_get_device_descriptor(struct libusb_device *, unsigned char *,
- int *);
static int obsd_get_active_config_descriptor(struct libusb_device *,
- unsigned char *, size_t, int *);
+ void *, size_t);
static int obsd_get_config_descriptor(struct libusb_device *, uint8_t,
- unsigned char *, size_t, int *);
+ void *, size_t);
-static int obsd_get_configuration(struct libusb_device_handle *, int *);
+static int obsd_get_configuration(struct libusb_device_handle *, uint8_t *);
static int obsd_set_configuration(struct libusb_device_handle *, int);
-static int obsd_claim_interface(struct libusb_device_handle *, int);
-static int obsd_release_interface(struct libusb_device_handle *, int);
+static int obsd_claim_interface(struct libusb_device_handle *, uint8_t);
+static int obsd_release_interface(struct libusb_device_handle *, uint8_t);
-static int obsd_set_interface_altsetting(struct libusb_device_handle *, int,
- int);
+static int obsd_set_interface_altsetting(struct libusb_device_handle *, uint8_t,
+ uint8_t);
static int obsd_clear_halt(struct libusb_device_handle *, unsigned char);
-static int obsd_reset_device(struct libusb_device_handle *);
static void obsd_destroy_device(struct libusb_device *);
static int obsd_submit_transfer(struct usbi_transfer *);
static int obsd_cancel_transfer(struct usbi_transfer *);
-static void obsd_clear_transfer_priv(struct usbi_transfer *);
static int obsd_handle_transfer_completion(struct usbi_transfer *);
-static int obsd_clock_gettime(int, struct timespec *);
/*
* Private functions
@@ -95,7 +89,6 @@ const struct usbi_os_backend usbi_backend = {
.open = obsd_open,
.close = obsd_close,
- .get_device_descriptor = obsd_get_device_descriptor,
.get_active_config_descriptor = obsd_get_active_config_descriptor,
.get_config_descriptor = obsd_get_config_descriptor,
@@ -107,16 +100,13 @@ const struct usbi_os_backend usbi_backend = {
.set_interface_altsetting = obsd_set_interface_altsetting,
.clear_halt = obsd_clear_halt,
- .reset_device = obsd_reset_device,
.destroy_device = obsd_destroy_device,
.submit_transfer = obsd_submit_transfer,
.cancel_transfer = obsd_cancel_transfer,
- .clear_transfer_priv = obsd_clear_transfer_priv,
.handle_transfer_completion = obsd_handle_transfer_completion,
- .clock_gettime = obsd_clock_gettime,
.device_priv_size = sizeof(struct device_priv),
.device_handle_priv_size = sizeof(struct handle_priv),
};
@@ -139,7 +129,7 @@ obsd_get_device_list(struct libusb_context * ctx,
char *udevname;
int fd, addr, i, j;
- usbi_dbg("");
+ usbi_dbg(" ");
for (i = 0; i < 8; i++) {
snprintf(busnode, sizeof(busnode), USBDEV "%d", i);
@@ -183,10 +173,10 @@ obsd_get_device_list(struct libusb_context * ctx,
dev->bus_number = di.udi_bus;
dev->device_address = di.udi_addr;
dev->speed = di.udi_speed;
+ dev->port_number = di.udi_port;
- dpriv = (struct device_priv *)dev->os_priv;
+ dpriv = usbi_get_device_priv(dev);
dpriv->fd = -1;
- dpriv->cdesc = NULL;
dpriv->devname = udevname;
dd.udd_bus = di.udi_bus;
@@ -195,7 +185,11 @@ obsd_get_device_list(struct libusb_context * ctx,
libusb_unref_device(dev);
continue;
}
- dpriv->ddesc = dd.udd_desc;
+
+ static_assert(sizeof(dev->device_descriptor) == sizeof(dd.udd_desc),
+ "mismatch between libusb and OS device descriptor sizes");
+ memcpy(&dev->device_descriptor, &dd.udd_desc, LIBUSB_DT_DEVICE_SIZE);
+ usbi_localize_device_descriptor(&dev->device_descriptor);
if (_cache_active_config_descriptor(dev)) {
libusb_unref_device(dev);
@@ -228,19 +222,21 @@ obsd_get_device_list(struct libusb_context * ctx,
int
obsd_open(struct libusb_device_handle *handle)
{
- struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
+ struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
char devnode[16];
if (dpriv->devname) {
+ int fd;
/*
* Only open ugen(4) attached devices read-write, all
* read-only operations are done through the bus node.
*/
snprintf(devnode, sizeof(devnode), DEVPATH "%s.00",
dpriv->devname);
- dpriv->fd = open(devnode, O_RDWR);
- if (dpriv->fd < 0)
+ fd = open(devnode, O_RDWR);
+ if (fd < 0)
return _errno_to_libusb(errno);
+ dpriv->fd = fd;
usbi_dbg("open %s: fd %d", devnode, dpriv->fd);
}
@@ -251,7 +247,7 @@ obsd_open(struct libusb_device_handle *handle)
void
obsd_close(struct libusb_device_handle *handle)
{
- struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
+ struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
if (dpriv->devname) {
usbi_dbg("close: fd %d", dpriv->fd);
@@ -262,41 +258,23 @@ obsd_close(struct libusb_device_handle *handle)
}
int
-obsd_get_device_descriptor(struct libusb_device *dev, unsigned char *buf,
- int *host_endian)
-{
- struct device_priv *dpriv = (struct device_priv *)dev->os_priv;
-
- usbi_dbg("");
-
- memcpy(buf, &dpriv->ddesc, DEVICE_DESC_LENGTH);
-
- *host_endian = 0;
-
- return (LIBUSB_SUCCESS);
-}
-
-int
obsd_get_active_config_descriptor(struct libusb_device *dev,
- unsigned char *buf, size_t len, int *host_endian)
+ void *buf, size_t len)
{
- struct device_priv *dpriv = (struct device_priv *)dev->os_priv;
- usb_config_descriptor_t *ucd = (usb_config_descriptor_t *)dpriv->cdesc;
+ struct device_priv *dpriv = usbi_get_device_priv(dev);
- len = MIN(len, UGETW(ucd->wTotalLength));
+ len = MIN(len, (size_t)UGETW(dpriv->cdesc->wTotalLength));
usbi_dbg("len %zu", len);
memcpy(buf, dpriv->cdesc, len);
- *host_endian = 0;
-
- return (len);
+ return ((int)len);
}
int
obsd_get_config_descriptor(struct libusb_device *dev, uint8_t idx,
- unsigned char *buf, size_t len, int *host_endian)
+ void *buf, size_t len)
{
struct usb_device_fdesc udf;
int fd, err;
@@ -319,20 +297,17 @@ obsd_get_config_descriptor(struct libusb_device *dev, uint8_t idx,
}
close(fd);
- *host_endian = 0;
-
- return (len);
+ return ((int)len);
}
int
-obsd_get_configuration(struct libusb_device_handle *handle, int *config)
+obsd_get_configuration(struct libusb_device_handle *handle, uint8_t *config)
{
- struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
- usb_config_descriptor_t *ucd = (usb_config_descriptor_t *)dpriv->cdesc;
+ struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
- *config = ucd->bConfigurationValue;
+ *config = dpriv->cdesc->bConfigurationValue;
- usbi_dbg("bConfigurationValue %d", *config);
+ usbi_dbg("bConfigurationValue %u", *config);
return (LIBUSB_SUCCESS);
}
@@ -340,7 +315,7 @@ obsd_get_configuration(struct libusb_device_handle *handle, int *config)
int
obsd_set_configuration(struct libusb_device_handle *handle, int config)
{
- struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
+ struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
if (dpriv->devname == NULL)
return (LIBUSB_ERROR_NOT_SUPPORTED);
@@ -354,11 +329,13 @@ obsd_set_configuration(struct libusb_device_handle *handle, int config)
}
int
-obsd_claim_interface(struct libusb_device_handle *handle, int iface)
+obsd_claim_interface(struct libusb_device_handle *handle, uint8_t iface)
{
- struct handle_priv *hpriv = (struct handle_priv *)handle->os_priv;
+ struct handle_priv *hpriv = usbi_get_device_handle_priv(handle);
int i;
+ UNUSED(iface);
+
for (i = 0; i < USB_MAX_ENDPOINTS; i++)
hpriv->endpoints[i] = -1;
@@ -366,11 +343,13 @@ obsd_claim_interface(struct libusb_device_handle *handle, int iface)
}
int
-obsd_release_interface(struct libusb_device_handle *handle, int iface)
+obsd_release_interface(struct libusb_device_handle *handle, uint8_t iface)
{
- struct handle_priv *hpriv = (struct handle_priv *)handle->os_priv;
+ struct handle_priv *hpriv = usbi_get_device_handle_priv(handle);
int i;
+ UNUSED(iface);
+
for (i = 0; i < USB_MAX_ENDPOINTS; i++)
if (hpriv->endpoints[i] >= 0)
close(hpriv->endpoints[i]);
@@ -379,16 +358,16 @@ obsd_release_interface(struct libusb_device_handle *handle, int iface)
}
int
-obsd_set_interface_altsetting(struct libusb_device_handle *handle, int iface,
- int altsetting)
+obsd_set_interface_altsetting(struct libusb_device_handle *handle, uint8_t iface,
+ uint8_t altsetting)
{
- struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv;
+ struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
struct usb_alt_interface intf;
if (dpriv->devname == NULL)
return (LIBUSB_ERROR_NOT_SUPPORTED);
- usbi_dbg("iface %d, setting %d", iface, altsetting);
+ usbi_dbg("iface %u, setting %u", iface, altsetting);
memset(&intf, 0, sizeof(intf));
@@ -410,7 +389,7 @@ obsd_clear_halt(struct libusb_device_handle *handle, unsigned char endpoint)
if ((fd = _bus_open(handle->dev->bus_number)) < 0)
return _errno_to_libusb(errno);
- usbi_dbg("");
+ usbi_dbg(" ");
req.ucr_addr = handle->dev->device_address;
req.ucr_request.bmRequestType = UT_WRITE_ENDPOINT;
@@ -429,20 +408,12 @@ obsd_clear_halt(struct libusb_device_handle *handle, unsigned char endpoint)
return (LIBUSB_SUCCESS);
}
-int
-obsd_reset_device(struct libusb_device_handle *handle)
-{
- usbi_dbg("");
-
- return (LIBUSB_ERROR_NOT_SUPPORTED);
-}
-
void
obsd_destroy_device(struct libusb_device *dev)
{
- struct device_priv *dpriv = (struct device_priv *)dev->os_priv;
+ struct device_priv *dpriv = usbi_get_device_priv(dev);
- usbi_dbg("");
+ usbi_dbg(" ");
free(dpriv->cdesc);
free(dpriv->devname);
@@ -452,13 +423,11 @@ int
obsd_submit_transfer(struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer;
- struct handle_priv *hpriv;
int err = 0;
- usbi_dbg("");
+ usbi_dbg(" ");
transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- hpriv = (struct handle_priv *)transfer->dev_handle->os_priv;
switch (transfer->type) {
case LIBUSB_TRANSFER_TYPE_CONTROL:
@@ -497,17 +466,11 @@ obsd_submit_transfer(struct usbi_transfer *itransfer)
int
obsd_cancel_transfer(struct usbi_transfer *itransfer)
{
- usbi_dbg("");
+ UNUSED(itransfer);
- return (LIBUSB_ERROR_NOT_SUPPORTED);
-}
-
-void
-obsd_clear_transfer_priv(struct usbi_transfer *itransfer)
-{
- usbi_dbg("");
+ usbi_dbg(" ");
- /* Nothing to do */
+ return (LIBUSB_ERROR_NOT_SUPPORTED);
}
int
@@ -517,18 +480,6 @@ obsd_handle_transfer_completion(struct usbi_transfer *itransfer)
}
int
-obsd_clock_gettime(int clkid, struct timespec *tp)
-{
- if (clkid == USBI_CLOCK_REALTIME)
- return clock_gettime(CLOCK_REALTIME, tp);
-
- if (clkid == USBI_CLOCK_MONOTONIC)
- return clock_gettime(CLOCK_MONOTONIC, tp);
-
- return (LIBUSB_ERROR_INVALID_PARAM);
-}
-
-int
_errno_to_libusb(int err)
{
usbi_dbg("error: %s (%d)", strerror(err), err);
@@ -552,10 +503,10 @@ _errno_to_libusb(int err)
int
_cache_active_config_descriptor(struct libusb_device *dev)
{
- struct device_priv *dpriv = (struct device_priv *)dev->os_priv;
+ struct device_priv *dpriv = usbi_get_device_priv(dev);
struct usb_device_cdesc udc;
struct usb_device_fdesc udf;
- unsigned char* buf;
+ void *buf;
int fd, len, err;
if ((fd = _bus_open(dev->bus_number)) < 0)
@@ -575,7 +526,7 @@ _cache_active_config_descriptor(struct libusb_device *dev)
usbi_dbg("active bLength %d", udc.udc_desc.bLength);
len = UGETW(udc.udc_desc.wTotalLength);
- buf = malloc(len);
+ buf = malloc((size_t)len);
if (buf == NULL)
return (LIBUSB_ERROR_NO_MEM);
@@ -611,7 +562,7 @@ _sync_control_transfer(struct usbi_transfer *itransfer)
struct usb_ctl_request req;
transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- dpriv = (struct device_priv *)transfer->dev_handle->dev->os_priv;
+ dpriv = usbi_get_device_priv(transfer->dev_handle->dev);
setup = (struct libusb_control_setup *)transfer->buffer;
usbi_dbg("type %x request %x value %x index %d length %d timeout %d",
@@ -673,8 +624,8 @@ _access_endpoint(struct libusb_transfer *transfer)
int fd, endpt;
mode_t mode;
- hpriv = (struct handle_priv *)transfer->dev_handle->os_priv;
- dpriv = (struct device_priv *)transfer->dev_handle->dev->os_priv;
+ hpriv = usbi_get_device_handle_priv(transfer->dev_handle);
+ dpriv = usbi_get_device_priv(transfer->dev_handle->dev);
endpt = UE_GET_ADDR(transfer->endpoint);
mode = IS_XFERIN(transfer) ? O_RDONLY : O_WRONLY;
@@ -705,7 +656,7 @@ _sync_gen_transfer(struct usbi_transfer *itransfer)
int fd, nr = 1;
transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- dpriv = (struct device_priv *)transfer->dev_handle->dev->os_priv;
+ dpriv = usbi_get_device_priv(transfer->dev_handle->dev);
if (dpriv->devname == NULL)
return (LIBUSB_ERROR_NOT_SUPPORTED);
diff --git a/libusb/os/poll_posix.c b/libusb/os/poll_posix.c
deleted file mode 100644
index 337714a..0000000
--- a/libusb/os/poll_posix.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * poll_posix: poll compatibility wrapper for POSIX systems
- * Copyright © 2013 RealVNC Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <config.h>
-
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <stdlib.h>
-
-#include "libusbi.h"
-
-int usbi_pipe(int pipefd[2])
-{
-#if defined(HAVE_PIPE2)
- int ret = pipe2(pipefd, O_CLOEXEC);
-#else
- int ret = pipe(pipefd);
-#endif
-
- if (ret != 0) {
- usbi_err(NULL, "failed to create pipe (%d)", errno);
- return ret;
- }
-
-#if !defined(HAVE_PIPE2) && defined(FD_CLOEXEC)
- ret = fcntl(pipefd[0], F_GETFD);
- if (ret == -1) {
- usbi_err(NULL, "failed to get pipe fd flags (%d)", errno);
- goto err_close_pipe;
- }
- ret = fcntl(pipefd[0], F_SETFD, ret | FD_CLOEXEC);
- if (ret == -1) {
- usbi_err(NULL, "failed to set pipe fd flags (%d)", errno);
- goto err_close_pipe;
- }
-
- ret = fcntl(pipefd[1], F_GETFD);
- if (ret == -1) {
- usbi_err(NULL, "failed to get pipe fd flags (%d)", errno);
- goto err_close_pipe;
- }
- ret = fcntl(pipefd[1], F_SETFD, ret | FD_CLOEXEC);
- if (ret == -1) {
- usbi_err(NULL, "failed to set pipe fd flags (%d)", errno);
- goto err_close_pipe;
- }
-#endif
-
- ret = fcntl(pipefd[1], F_GETFL);
- if (ret == -1) {
- usbi_err(NULL, "failed to get pipe fd status flags (%d)", errno);
- goto err_close_pipe;
- }
- ret = fcntl(pipefd[1], F_SETFL, ret | O_NONBLOCK);
- if (ret == -1) {
- usbi_err(NULL, "failed to set pipe fd status flags (%d)", errno);
- goto err_close_pipe;
- }
-
- return 0;
-
-err_close_pipe:
- close(pipefd[0]);
- close(pipefd[1]);
- return ret;
-}
diff --git a/libusb/os/poll_posix.h b/libusb/os/poll_posix.h
deleted file mode 100644
index bc0239c..0000000
--- a/libusb/os/poll_posix.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef LIBUSB_POLL_POSIX_H
-#define LIBUSB_POLL_POSIX_H
-
-#define usbi_write write
-#define usbi_read read
-#define usbi_close close
-#define usbi_poll poll
-
-int usbi_pipe(int pipefd[2]);
-
-#define usbi_inc_fds_ref(x, y)
-#define usbi_dec_fds_ref(x, y)
-
-#endif /* LIBUSB_POLL_POSIX_H */
diff --git a/libusb/os/poll_windows.c b/libusb/os/poll_windows.c
deleted file mode 100644
index 243495b..0000000
--- a/libusb/os/poll_windows.c
+++ /dev/null
@@ -1,447 +0,0 @@
-/*
- * poll_windows: poll compatibility wrapper for Windows
- * Copyright © 2017 Chris Dickens <christopher.a.dickens@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-/*
- * poll() and pipe() Windows compatibility layer for libusb 1.0
- *
- * The way this layer works is by using OVERLAPPED with async I/O transfers, as
- * OVERLAPPED have an associated event which is flagged for I/O completion.
- *
- * For USB pollable async I/O, you would typically:
- * - obtain a Windows HANDLE to a file or device that has been opened in
- * OVERLAPPED mode
- * - call usbi_create_fd with this handle to obtain a custom fd.
- * - leave the core functions call the poll routine and flag POLLIN/POLLOUT
- *
- * The pipe pollable synchronous I/O works using the overlapped event associated
- * with a fake pipe. The read/write functions are only meant to be used in that
- * context.
- */
-#include <config.h>
-
-#include <assert.h>
-#include <errno.h>
-#include <stdlib.h>
-
-#include "libusbi.h"
-#include "windows_common.h"
-
-// public fd data
-const struct winfd INVALID_WINFD = { -1, NULL };
-
-// private data
-struct file_descriptor {
- enum fd_type { FD_TYPE_PIPE, FD_TYPE_TRANSFER } type;
- OVERLAPPED overlapped;
- int refcount;
-};
-
-static usbi_mutex_static_t fd_table_lock = USBI_MUTEX_INITIALIZER;
-
-static struct file_descriptor **fd_table;
-static size_t fd_count;
-static size_t fd_size;
-#define INC_FDS_EACH 256
-
-static void usbi_dec_fd_table()
-{
- fd_count--;
- if (fd_count == 0) {
- free(fd_table);
- fd_size = 0;
- fd_table = NULL;
- }
-}
-
-static void smart_realloc_fd_table_space(int inc)
-{
- if (fd_table == NULL || fd_count + inc > fd_size) {
- struct file_descriptor **p = (struct file_descriptor **)realloc(fd_table, (fd_size + INC_FDS_EACH) * sizeof(struct file_descriptor *));
- if (p != NULL) {
- memset(p + fd_size, 0, INC_FDS_EACH * sizeof(struct file_descriptor *));
- fd_size += INC_FDS_EACH;
- fd_table = p;
- }
- }
-}
-
-static struct file_descriptor *create_fd(enum fd_type type)
-{
- struct file_descriptor *fd = calloc(1, sizeof(*fd));
- if (fd == NULL)
- return NULL;
- fd->overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
- if (fd->overlapped.hEvent == NULL) {
- free(fd);
- return NULL;
- }
- fd->type = type;
- fd->refcount = 1;
- return fd;
-}
-
-static void free_fd(struct file_descriptor *fd)
-{
- CloseHandle(fd->overlapped.hEvent);
- free(fd);
-}
-
-/*
- * Create both an fd and an OVERLAPPED, so that it can be used with our
- * polling function
- * The handle MUST support overlapped transfers (usually requires CreateFile
- * with FILE_FLAG_OVERLAPPED)
- * Return a pollable file descriptor struct, or INVALID_WINFD on error
- *
- * Note that the fd returned by this function is a per-transfer fd, rather
- * than a per-session fd and cannot be used for anything else but our
- * custom functions.
- * if you plan to do R/W on the same handle, you MUST create 2 fds: one for
- * read and one for write. Using a single R/W fd is unsupported and will
- * produce unexpected results
- */
-struct winfd usbi_create_fd(void)
-{
- struct file_descriptor *fd;
- struct winfd wfd;
-
- fd = create_fd(FD_TYPE_TRANSFER);
- if (fd == NULL)
- return INVALID_WINFD;
-
- usbi_mutex_static_lock(&fd_table_lock);
-
- smart_realloc_fd_table_space(1);
-
- for (wfd.fd = 0; wfd.fd < fd_size; wfd.fd++) {
- if (fd_table[wfd.fd] != NULL)
- continue;
- fd_table[wfd.fd] = fd;
- fd_count++;
- break;
- }
- usbi_mutex_static_unlock(&fd_table_lock);
-
- if (wfd.fd == fd_size) {
- free_fd(fd);
- return INVALID_WINFD;
- }
-
- wfd.overlapped = &fd->overlapped;
-
- return wfd;
-}
-
-void usbi_inc_fds_ref(struct pollfd *fds, unsigned int nfds)
-{
- int n;
- usbi_mutex_static_lock(&fd_table_lock);
- for (n = 0; n < nfds; ++n) {
- fd_table[fds[n].fd]->refcount++;
- }
- usbi_mutex_static_unlock(&fd_table_lock);
-}
-
-void usbi_dec_fds_ref(struct pollfd *fds, unsigned int nfds)
-{
- int n;
- struct file_descriptor *fd;
-
- usbi_mutex_static_lock(&fd_table_lock);
- for (n = 0; n < nfds; ++n) {
- fd = fd_table[fds[n].fd];
- fd->refcount--;
- //FD_TYPE_PIPE map fd to two _fd
- if (fd->refcount == 0 || (fd->refcount == 1 && fd->type == FD_TYPE_PIPE))
- {
- if (fd->type == FD_TYPE_PIPE) {
- // InternalHigh is our reference count
- fd->overlapped.InternalHigh--;
- if (fd->overlapped.InternalHigh == 0)
- free_fd(fd);
- }
- else {
- free_fd(fd);
- }
- fd_table[fds[n].fd] = NULL;
- usbi_dec_fd_table();
- }
- }
- usbi_mutex_static_unlock(&fd_table_lock);
-}
-
-
-static int check_pollfds(struct pollfd *fds, unsigned int nfds,
- HANDLE *wait_handles, DWORD *nb_wait_handles)
-{
- struct file_descriptor *fd;
- unsigned int n;
- int nready = 0;
-
- usbi_mutex_static_lock(&fd_table_lock);
-
- for (n = 0; n < nfds; ++n) {
- fds[n].revents = 0;
-
- // Keep it simple - only allow either POLLIN *or* POLLOUT
- assert((fds[n].events == POLLIN) || (fds[n].events == POLLOUT));
- if ((fds[n].events != POLLIN) && (fds[n].events != POLLOUT)) {
- fds[n].revents = POLLNVAL;
- nready++;
- continue;
- }
-
- if ((fds[n].fd >= 0) && (fds[n].fd < fd_size))
- fd = fd_table[fds[n].fd];
- else
- fd = NULL;
-
- assert(fd != NULL);
- if (fd == NULL) {
- fds[n].revents = POLLNVAL;
- nready++;
- continue;
- }
-
- if (HasOverlappedIoCompleted(&fd->overlapped)
- && (WaitForSingleObject(fd->overlapped.hEvent, 0) == WAIT_OBJECT_0)) {
- fds[n].revents = fds[n].events;
- nready++;
- } else if (wait_handles != NULL) {
- if (*nb_wait_handles == MAXIMUM_WAIT_OBJECTS) {
- usbi_warn(NULL, "too many HANDLEs to wait on");
- continue;
- }
- wait_handles[*nb_wait_handles] = fd->overlapped.hEvent;
- (*nb_wait_handles)++;
- }
- }
-
- usbi_mutex_static_unlock(&fd_table_lock);
-
- return nready;
-}
-/*
- * POSIX poll equivalent, using Windows OVERLAPPED
- * Currently, this function only accepts one of POLLIN or POLLOUT per fd
- * (but you can create multiple fds from the same handle for read and write)
- */
-int usbi_poll(struct pollfd *fds, unsigned int nfds, int timeout)
-{
- HANDLE wait_handles[MAXIMUM_WAIT_OBJECTS];
- DWORD nb_wait_handles = 0;
- DWORD ret;
- int nready;
-
- nready = check_pollfds(fds, nfds, wait_handles, &nb_wait_handles);
-
- // If nothing was triggered, wait on all fds that require it
- if ((nready == 0) && (nb_wait_handles != 0) && (timeout != 0)) {
- ret = WaitForMultipleObjects(nb_wait_handles, wait_handles,
- FALSE, (timeout < 0) ? INFINITE : (DWORD)timeout);
- if (ret < (WAIT_OBJECT_0 + nb_wait_handles)) {
- nready = check_pollfds(fds, nfds, NULL, NULL);
- } else if (ret != WAIT_TIMEOUT) {
- if (ret == WAIT_FAILED)
- usbi_err(NULL, "WaitForMultipleObjects failed: %u", (unsigned int)GetLastError());
- nready = -1;
- }
- }
-
- return nready;
-}
-
-/*
- * close a fake file descriptor
- */
-int usbi_close(int _fd)
-{
- struct file_descriptor *fd;
-
- if (_fd < 0 || _fd >= fd_size)
- goto err_badfd;
-
- usbi_mutex_static_lock(&fd_table_lock);
- fd = fd_table[_fd];
- fd->refcount--;
- //FD_TYPE_PIPE map fd to two _fd
- if(fd->refcount==0 || (fd->refcount == 1 && fd->type == FD_TYPE_PIPE))
- { fd_table[_fd] = NULL;
- usbi_dec_fd_table();
-
- if (fd->type == FD_TYPE_PIPE) {
- // InternalHigh is our reference count
- fd->overlapped.InternalHigh--;
- if (fd->overlapped.InternalHigh == 0)
- free_fd(fd);
- }
- else {
- free_fd(fd);
- }
- }
- usbi_mutex_static_unlock(&fd_table_lock);
-
- if (fd == NULL)
- goto err_badfd;
-
- return 0;
-
-err_badfd:
- errno = EBADF;
- return -1;
-}
-
-/*
-* Create a fake pipe.
-* As libusb only uses pipes for signaling, all we need from a pipe is an
-* event. To that extent, we create a single wfd and overlapped as a means
-* to access that event.
-*/
-int usbi_pipe(int filedes[2])
-{
- struct file_descriptor *fd;
- int r_fd = -1, w_fd = -1;
- int i;
-
- fd = create_fd(FD_TYPE_PIPE);
- if (fd == NULL) {
- errno = ENOMEM;
- return -1;
- }
-
- // Use InternalHigh as a reference count
- fd->overlapped.Internal = STATUS_PENDING;
- fd->overlapped.InternalHigh = 2;
-
- usbi_mutex_static_lock(&fd_table_lock);
- do {
- smart_realloc_fd_table_space(2);
-
- for (i = 0; i < fd_size; i++) {
- if (fd_table[i] != NULL)
- continue;
- if (r_fd == -1) {
- r_fd = i;
- } else if (w_fd == -1) {
- w_fd = i;
- break;
- }
- }
-
- if (i == fd_size)
- break;
-
- fd_table[r_fd] = fd;
- fd_table[w_fd] = fd;
-
- fd->refcount++; //this fd reference twice for r and w.
-
- fd_count += 2;
-
- } while (0);
- usbi_mutex_static_unlock(&fd_table_lock);
-
- if (i == fd_size) {
- free_fd(fd);
- errno = EMFILE;
- return -1;
- }
-
- filedes[0] = r_fd;
- filedes[1] = w_fd;
-
- return 0;
-}
-
-/*
- * synchronous write for fake "pipe" signaling
- */
-ssize_t usbi_write(int fd, const void *buf, size_t count)
-{
- int error = EBADF;
-
- UNUSED(buf);
-
- if (fd < 0 || fd >= fd_size)
- goto err_out;
-
- if (count != sizeof(unsigned char)) {
- usbi_err(NULL, "this function should only used for signaling");
- error = EINVAL;
- goto err_out;
- }
-
- usbi_mutex_static_lock(&fd_table_lock);
- if ((fd_table[fd] != NULL) && (fd_table[fd]->type == FD_TYPE_PIPE)) {
- assert(fd_table[fd]->overlapped.Internal == STATUS_PENDING);
- assert(fd_table[fd]->overlapped.InternalHigh == 2);
- fd_table[fd]->overlapped.Internal = STATUS_WAIT_0;
- SetEvent(fd_table[fd]->overlapped.hEvent);
- error = 0;
- }
- usbi_mutex_static_unlock(&fd_table_lock);
-
- if (error)
- goto err_out;
-
- return sizeof(unsigned char);
-
-err_out:
- errno = error;
- return -1;
-}
-
-/*
- * synchronous read for fake "pipe" signaling
- */
-ssize_t usbi_read(int fd, void *buf, size_t count)
-{
- int error = EBADF;
-
- UNUSED(buf);
-
- if (fd < 0 || fd >= fd_size)
- goto err_out;
-
- if (count != sizeof(unsigned char)) {
- usbi_err(NULL, "this function should only used for signaling");
- error = EINVAL;
- goto err_out;
- }
-
- usbi_mutex_static_lock(&fd_table_lock);
- if ((fd_table[fd] != NULL) && (fd_table[fd]->type == FD_TYPE_PIPE)) {
- assert(fd_table[fd]->overlapped.Internal == STATUS_WAIT_0);
- assert(fd_table[fd]->overlapped.InternalHigh == 2);
- fd_table[fd]->overlapped.Internal = STATUS_PENDING;
- ResetEvent(fd_table[fd]->overlapped.hEvent);
- error = 0;
- }
- usbi_mutex_static_unlock(&fd_table_lock);
-
- if (error)
- goto err_out;
-
- return sizeof(unsigned char);
-
-err_out:
- errno = error;
- return -1;
-}
diff --git a/libusb/os/poll_windows.h b/libusb/os/poll_windows.h
deleted file mode 100644
index 314853e..0000000
--- a/libusb/os/poll_windows.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Windows compat: POSIX compatibility wrapper
- * Copyright © 2012-2013 RealVNC Ltd.
- * Copyright © 2009-2010 Pete Batard <pete@akeo.ie>
- * Copyright © 2016-2018 Chris Dickens <christopher.a.dickens@gmail.com>
- * With contributions from Michael Plante, Orin Eman et al.
- * Parts of poll implementation from libusb-win32, by Stephan Meyer et al.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-#pragma once
-
-#if defined(_MSC_VER)
-// disable /W4 MSVC warnings that are benign
-#pragma warning(disable:4127) // conditional expression is constant
-#endif
-
-// Handle synchronous completion through the overlapped structure
-#if !defined(STATUS_REPARSE) // reuse the REPARSE status code
-#define STATUS_REPARSE ((LONG)0x00000104L)
-#endif
-#define STATUS_COMPLETED_SYNCHRONOUSLY STATUS_REPARSE
-#if defined(_WIN32_WCE)
-// WinCE doesn't have a HasOverlappedIoCompleted() macro, so attempt to emulate it
-#define HasOverlappedIoCompleted(lpOverlapped) (((DWORD)(lpOverlapped)->Internal) != STATUS_PENDING)
-#endif
-#define HasOverlappedIoCompletedSync(lpOverlapped) (((DWORD)(lpOverlapped)->Internal) == STATUS_COMPLETED_SYNCHRONOUSLY)
-
-#define DUMMY_HANDLE ((HANDLE)(LONG_PTR)-2)
-
-#define POLLIN 0x0001 /* There is data to read */
-#define POLLPRI 0x0002 /* There is urgent data to read */
-#define POLLOUT 0x0004 /* Writing now will not block */
-#define POLLERR 0x0008 /* Error condition */
-#define POLLHUP 0x0010 /* Hung up */
-#define POLLNVAL 0x0020 /* Invalid request: fd not open */
-
-struct pollfd {
- int fd; /* file descriptor */
- short events; /* requested events */
- short revents; /* returned events */
-};
-
-struct winfd {
- int fd; // what's exposed to libusb core
- OVERLAPPED *overlapped; // what will report our I/O status
-};
-
-extern const struct winfd INVALID_WINFD;
-
-struct winfd usbi_create_fd(void);
-
-int usbi_pipe(int pipefd[2]);
-int usbi_poll(struct pollfd *fds, unsigned int nfds, int timeout);
-ssize_t usbi_write(int fd, const void *buf, size_t count);
-ssize_t usbi_read(int fd, void *buf, size_t count);
-int usbi_close(int fd);
-
-void usbi_inc_fds_ref(struct pollfd *fds, unsigned int nfds);
-void usbi_dec_fds_ref(struct pollfd *fds, unsigned int nfds);
-
-/*
- * Timeval operations
- */
-#if defined(DDKBUILD)
-#include <winsock.h> // defines timeval functions on DDK
-#endif
-
-#if !defined(TIMESPEC_TO_TIMEVAL)
-#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
- (tv)->tv_sec = (long)(ts)->tv_sec; \
- (tv)->tv_usec = (long)(ts)->tv_nsec / 1000; \
-}
-#endif
-#if !defined(timersub)
-#define timersub(a, b, result) \
-do { \
- (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
- (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
- if ((result)->tv_usec < 0) { \
- --(result)->tv_sec; \
- (result)->tv_usec += 1000000; \
- } \
-} while (0)
-#endif
diff --git a/libusb/os/sunos_usb.c b/libusb/os/sunos_usb.c
index 6a3f633..46866fb 100644
--- a/libusb/os/sunos_usb.c
+++ b/libusb/os/sunos_usb.c
@@ -21,7 +21,6 @@
#include <sys/time.h>
#include <sys/types.h>
-#include <sys/list.h>
#include <sys/stat.h>
#include <strings.h>
#include <errno.h>
@@ -36,7 +35,6 @@
#include <sys/nvpair.h>
#include <sys/devctl.h>
#include <sys/usb/clients/ugen/usb_ugen.h>
-#include <errno.h>
#include <sys/usb/usba.h>
#include <sys/pci.h>
@@ -46,48 +44,42 @@
#define UPDATEDRV_PATH "/usr/sbin/update_drv"
#define UPDATEDRV "update_drv"
-typedef list_t string_list_t;
-typedef struct string_node {
- char *string;
- list_node_t link;
-} string_node_t;
+#define DEFAULT_LISTSIZE 6
+
+typedef struct {
+ int nargs;
+ int listsize;
+ char **string;
+} string_list_t;
/*
* Backend functions
*/
-static int sunos_init(struct libusb_context *);
-static void sunos_exit(struct libusb_context *);
static int sunos_get_device_list(struct libusb_context *,
struct discovered_devs **);
static int sunos_open(struct libusb_device_handle *);
static void sunos_close(struct libusb_device_handle *);
-static int sunos_get_device_descriptor(struct libusb_device *,
- uint8_t*, int *);
static int sunos_get_active_config_descriptor(struct libusb_device *,
- uint8_t*, size_t, int *);
+ void *, size_t);
static int sunos_get_config_descriptor(struct libusb_device *, uint8_t,
- uint8_t*, size_t, int *);
-static int sunos_get_configuration(struct libusb_device_handle *, int *);
+ void *, size_t);
+static int sunos_get_configuration(struct libusb_device_handle *, uint8_t *);
static int sunos_set_configuration(struct libusb_device_handle *, int);
-static int sunos_claim_interface(struct libusb_device_handle *, int);
-static int sunos_release_interface(struct libusb_device_handle *, int);
+static int sunos_claim_interface(struct libusb_device_handle *, uint8_t);
+static int sunos_release_interface(struct libusb_device_handle *, uint8_t);
static int sunos_set_interface_altsetting(struct libusb_device_handle *,
- int, int);
-static int sunos_clear_halt(struct libusb_device_handle *, uint8_t);
-static int sunos_reset_device(struct libusb_device_handle *);
+ uint8_t, uint8_t);
+static int sunos_clear_halt(struct libusb_device_handle *, unsigned char);
static void sunos_destroy_device(struct libusb_device *);
static int sunos_submit_transfer(struct usbi_transfer *);
static int sunos_cancel_transfer(struct usbi_transfer *);
-static void sunos_clear_transfer_priv(struct usbi_transfer *);
static int sunos_handle_transfer_completion(struct usbi_transfer *);
-static int sunos_clock_gettime(int, struct timespec *);
-static int sunos_kernel_driver_active(struct libusb_device_handle *, int interface);
-static int sunos_detach_kernel_driver (struct libusb_device_handle *dev, int interface_number);
-static int sunos_attach_kernel_driver (struct libusb_device_handle *dev, int interface_number);
+static int sunos_kernel_driver_active(struct libusb_device_handle *, uint8_t);
+static int sunos_detach_kernel_driver(struct libusb_device_handle *, uint8_t);
+static int sunos_attach_kernel_driver(struct libusb_device_handle *, uint8_t);
static int sunos_usb_open_ep0(sunos_dev_handle_priv_t *hpriv, sunos_dev_priv_t *dpriv);
static int sunos_usb_ioctl(struct libusb_device *dev, int cmd);
-static struct devctl_iocdata iocdata;
static int sunos_get_link(di_devlink_t devlink, void *arg)
{
walk_link_t *larg = (walk_link_t *)arg;
@@ -157,8 +149,9 @@ sunos_usb_ioctl(struct libusb_device *dev, int cmd)
char path_arg[PATH_MAX];
sunos_dev_priv_t *dpriv;
devctl_ap_state_t devctl_ap_state;
+ struct devctl_iocdata iocdata;
- dpriv = (sunos_dev_priv_t *)dev->os_priv;
+ dpriv = usbi_get_device_priv(dev);
phypath = dpriv->phypath;
end = strrchr(phypath, '/');
@@ -184,7 +177,7 @@ sunos_usb_ioctl(struct libusb_device *dev, int cmd)
fd = open(path_arg, O_RDONLY);
if (fd < 0) {
- usbi_err(DEVICE_CTX(dev), "open failed: %d (%s)", errno, strerror(errno));
+ usbi_err(DEVICE_CTX(dev), "open failed: errno %d (%s)", errno, strerror(errno));
nvlist_free(nvlist);
free(hubpath);
return (-1);
@@ -197,10 +190,10 @@ sunos_usb_ioctl(struct libusb_device *dev, int cmd)
iocdata.cmd = DEVCTL_AP_GETSTATE;
iocdata.flags = 0;
- iocdata.c_nodename = "hub";
+ iocdata.c_nodename = (char *)"hub";
iocdata.c_unitaddr = end;
iocdata.cpyout_buf = &devctl_ap_state;
- usbi_dbg("%p, %d", iocdata.nvl_user, iocdata.nvl_usersz);
+ usbi_dbg("%p, %" PRIuPTR, iocdata.nvl_user, iocdata.nvl_usersz);
errno = 0;
if (ioctl(fd, DEVCTL_AP_GETSTATE, &iocdata) == -1) {
@@ -228,10 +221,11 @@ sunos_usb_ioctl(struct libusb_device *dev, int cmd)
}
static int
-sunos_kernel_driver_active(struct libusb_device_handle *dev, int interface)
+sunos_kernel_driver_active(struct libusb_device_handle *dev_handle, uint8_t interface)
{
- sunos_dev_priv_t *dpriv;
- dpriv = (sunos_dev_priv_t *)dev->dev->os_priv;
+ sunos_dev_priv_t *dpriv = usbi_get_device_priv(dev_handle->dev);
+
+ UNUSED(interface);
usbi_dbg("%s", dpriv->ugenpath);
@@ -244,25 +238,21 @@ sunos_kernel_driver_active(struct libusb_device_handle *dev, int interface)
static int _errno_to_libusb(int);
static int sunos_usb_get_status(int fd);
-static int sunos_init(struct libusb_context *ctx)
-{
- return (LIBUSB_SUCCESS);
-}
-
-static void sunos_exit(struct libusb_context *ctx)
-{
- usbi_dbg("");
-}
-
static string_list_t *
sunos_new_string_list(void)
{
string_list_t *list;
- list = calloc(1, sizeof(*list));
- if (list != NULL)
- list_create(list, sizeof(string_node_t),
- offsetof(string_node_t, link));
+ list = calloc(1, sizeof(string_list_t));
+ if (list == NULL)
+ return (NULL);
+ list->string = calloc(DEFAULT_LISTSIZE, sizeof(char *));
+ if (list->string == NULL) {
+ free(list);
+ return (NULL);
+ }
+ list->nargs = 0;
+ list->listsize = DEFAULT_LISTSIZE;
return (list);
}
@@ -270,19 +260,22 @@ sunos_new_string_list(void)
static int
sunos_append_to_string_list(string_list_t *list, const char *arg)
{
- string_node_t *np;
+ char *str = strdup(arg);
- np = calloc(1, sizeof(*np));
- if (!np)
+ if (str == NULL)
return (-1);
- np->string = strdup(arg);
- if (!np->string) {
- free(np);
- return (-1);
+ if ((list->nargs + 1) == list->listsize) { /* +1 is for NULL */
+ char **tmp = realloc(list->string,
+ sizeof(char *) * (list->listsize + 1));
+ if (tmp == NULL) {
+ free(str);
+ return (-1);
+ }
+ list->string = tmp;
+ list->string[list->listsize++] = NULL;
}
-
- list_insert_tail(list, np);
+ list->string[list->nargs++] = str;
return (0);
}
@@ -290,36 +283,20 @@ sunos_append_to_string_list(string_list_t *list, const char *arg)
static void
sunos_free_string_list(string_list_t *list)
{
- string_node_t *np;
+ int i;
- while ((np = list_remove_head(list)) != NULL) {
- free(np->string);
- free(np);
+ for (i = 0; i < list->nargs; i++) {
+ free(list->string[i]);
}
+ free(list->string);
free(list);
}
static char **
sunos_build_argv_list(string_list_t *list)
{
- char **argv_list;
- string_node_t *np;
- int n;
-
- n = 1; /* Start at 1 for NULL terminator */
- for (np = list_head(list); np != NULL; np = list_next(list, np))
- n++;
-
- argv_list = calloc(n, sizeof(char *));
- if (argv_list == NULL)
- return NULL;
-
- n = 0;
- for (np = list_head(list); np != NULL; np = list_next(list, np))
- argv_list[n++] = np->string;
-
- return (argv_list);
+ return (list->string);
}
@@ -364,14 +341,12 @@ sunos_exec_command(struct libusb_context *ctx, const char *path,
exit_status = -1;
}
- free(argv_list);
-
return (exit_status);
}
static int
sunos_detach_kernel_driver(struct libusb_device_handle *dev_handle,
- int interface_number)
+ uint8_t interface_number)
{
struct libusb_context *ctx = HANDLE_CTX(dev_handle);
string_list_t *list;
@@ -379,7 +354,9 @@ sunos_detach_kernel_driver(struct libusb_device_handle *dev_handle,
sunos_dev_priv_t *dpriv;
int r;
- dpriv = (sunos_dev_priv_t *)dev_handle->dev->os_priv;
+ UNUSED(interface_number);
+
+ dpriv = usbi_get_device_priv(dev_handle->dev);
snprintf(path_arg, sizeof(path_arg), "\'\"%s\"\'", dpriv->phypath);
usbi_dbg("%s", path_arg);
@@ -411,8 +388,9 @@ sunos_detach_kernel_driver(struct libusb_device_handle *dev_handle,
if (r)
usbi_warn(HANDLE_CTX(dev_handle), "one or more ioctls failed");
- snprintf(path_arg, sizeof(path_arg), "^usb/%x.%x", dpriv->dev_descr.idVendor,
- dpriv->dev_descr.idProduct);
+ snprintf(path_arg, sizeof(path_arg), "^usb/%x.%x",
+ dev_handle->dev->device_descriptor.idVendor,
+ dev_handle->dev->device_descriptor.idProduct);
sunos_physpath_to_devlink(dpriv->phypath, path_arg, &dpriv->ugenpath);
if (access(dpriv->ugenpath, F_OK) == -1) {
@@ -420,12 +398,12 @@ sunos_detach_kernel_driver(struct libusb_device_handle *dev_handle,
return (LIBUSB_ERROR_IO);
}
- return sunos_usb_open_ep0((sunos_dev_handle_priv_t *)dev_handle->os_priv, dpriv);
+ return sunos_usb_open_ep0(usbi_get_device_handle_priv(dev_handle), dpriv);
}
static int
sunos_attach_kernel_driver(struct libusb_device_handle *dev_handle,
- int interface_number)
+ uint8_t interface_number)
{
struct libusb_context *ctx = HANDLE_CTX(dev_handle);
string_list_t *list;
@@ -433,10 +411,12 @@ sunos_attach_kernel_driver(struct libusb_device_handle *dev_handle,
sunos_dev_priv_t *dpriv;
int r;
+ UNUSED(interface_number);
+
/* we open the dev in detach driver, so we need close it first. */
sunos_close(dev_handle);
- dpriv = (sunos_dev_priv_t *)dev_handle->dev->os_priv;
+ dpriv = usbi_get_device_priv(dev_handle->dev);
snprintf(path_arg, sizeof(path_arg), "\'\"%s\"\'", dpriv->phypath);
usbi_dbg("%s", path_arg);
@@ -479,24 +459,16 @@ sunos_fill_in_dev_info(di_node_t node, struct libusb_device *dev)
int *i, n, *addr, *port_prop;
char *phypath;
uint8_t *rdata;
- struct libusb_device_descriptor *descr;
- sunos_dev_priv_t *dpriv = (sunos_dev_priv_t *)dev->os_priv;
+ sunos_dev_priv_t *dpriv = usbi_get_device_priv(dev);
char match_str[PATH_MAX];
/* Device descriptors */
proplen = di_prop_lookup_bytes(DDI_DEV_T_ANY, node,
"usb-dev-descriptor", &rdata);
if (proplen <= 0) {
-
return (LIBUSB_ERROR_IO);
}
-
- descr = (struct libusb_device_descriptor *)rdata;
- bcopy(descr, &dpriv->dev_descr, LIBUSB_DT_DEVICE_SIZE);
- dpriv->dev_descr.bcdUSB = libusb_cpu_to_le16(descr->bcdUSB);
- dpriv->dev_descr.idVendor = libusb_cpu_to_le16(descr->idVendor);
- dpriv->dev_descr.idProduct = libusb_cpu_to_le16(descr->idProduct);
- dpriv->dev_descr.bcdDevice = libusb_cpu_to_le16(descr->bcdDevice);
+ bcopy(rdata, &dev->device_descriptor, LIBUSB_DT_DEVICE_SIZE);
/* Raw configuration descriptors */
proplen = di_prop_lookup_bytes(DDI_DEV_T_ANY, node,
@@ -526,7 +498,9 @@ sunos_fill_in_dev_info(di_node_t node, struct libusb_device *dev)
phypath = di_devfs_path(node);
if (phypath) {
dpriv->phypath = strdup(phypath);
- snprintf(match_str, sizeof(match_str), "^usb/%x.%x", dpriv->dev_descr.idVendor, dpriv->dev_descr.idProduct);
+ snprintf(match_str, sizeof(match_str), "^usb/%x.%x",
+ dev->device_descriptor.idVendor,
+ dev->device_descriptor.idProduct);
usbi_dbg("match is %s", match_str);
sunos_physpath_to_devlink(dpriv->phypath, match_str, &dpriv->ugenpath);
di_devfs_path_free(phypath);
@@ -556,8 +530,8 @@ sunos_fill_in_dev_info(di_node_t node, struct libusb_device *dev)
dev->speed = LIBUSB_SPEED_SUPER;
}
- usbi_dbg("vid=%x pid=%x, path=%s, bus_nmber=0x%x, port_number=%d, "
- "speed=%d", dpriv->dev_descr.idVendor, dpriv->dev_descr.idProduct,
+ usbi_dbg("vid=%x pid=%x, path=%s, bus_nmber=0x%x, port_number=%d, speed=%d",
+ dev->device_descriptor.idVendor, dev->device_descriptor.idProduct,
dpriv->phypath, dev->bus_number, dev->port_number, dev->speed);
return (LIBUSB_SUCCESS);
@@ -578,9 +552,11 @@ sunos_add_devices(di_devlink_t link, void *arg)
int i = 0;
int *addr_prop;
uint8_t bus_number = 0;
- uint32_t * regbuf = NULL;
+ uint32_t * regbuf = NULL;
uint32_t reg;
+ UNUSED(link);
+
nargs = (struct node_args *)largs->nargs;
myself = largs->myself;
@@ -612,7 +588,7 @@ sunos_add_devices(di_devlink_t link, void *arg)
usbi_dbg("device bus address=%s:%x, name:%s",
di_bus_addr(myself), bus_number, di_node_name(dn));
- usbi_dbg("session id org:%lx", session_id);
+ usbi_dbg("session id org:%" PRIx64, session_id);
/* dn is the usb device */
for (dn = di_child_node(myself); dn != DI_NODE_NIL; dn = di_sibling_node(dn)) {
@@ -629,7 +605,7 @@ sunos_add_devices(di_devlink_t link, void *arg)
}
sid = (session_id << 8) | (addr_prop[0] & 0xff) ;
- usbi_dbg("session id %lx", sid);
+ usbi_dbg("session id %" PRIX64, sid);
dev = usbi_get_device_by_session_id(nargs->ctx, sid);
if (dev == NULL) {
@@ -638,12 +614,12 @@ sunos_add_devices(di_devlink_t link, void *arg)
usbi_dbg("can't alloc device");
continue;
}
- devpriv = (sunos_dev_priv_t *)dev->os_priv;
+ devpriv = usbi_get_device_priv(dev);
dev->bus_number = bus_number;
if (sunos_fill_in_dev_info(dn, dev) != LIBUSB_SUCCESS) {
libusb_unref_device(dev);
- usbi_dbg("get infomation fail");
+ usbi_dbg("get information fail");
continue;
}
if (usbi_sanitize_device(dev) < 0) {
@@ -652,7 +628,7 @@ sunos_add_devices(di_devlink_t link, void *arg)
return (DI_WALK_TERMINATE);
}
} else {
- devpriv = (sunos_dev_priv_t *)dev->os_priv;
+ devpriv = usbi_get_device_priv(dev);
usbi_dbg("Dev %s exists", devpriv->ugenpath);
}
@@ -666,7 +642,8 @@ sunos_add_devices(di_devlink_t link, void *arg)
*/
libusb_unref_device(dev);
- usbi_dbg("Device %s %s id=0x%llx, devcount:%d, bdf=%x",
+ usbi_dbg("Device %s %s id=0x%" PRIx64 ", devcount:%" PRIuPTR
+ ", bdf=%" PRIx64,
devpriv->ugenpath, di_devfs_path(dn), (uint64_t)sid,
(*nargs->discdevs)->len, bdf);
}
@@ -713,13 +690,13 @@ sunos_get_device_list(struct libusb_context * ctx,
args.discdevs = discdevs;
args.last_ugenpath = NULL;
if ((root_node = di_init("/", DINFOCPYALL)) == DI_NODE_NIL) {
- usbi_dbg("di_int() failed: %s", strerror(errno));
+ usbi_dbg("di_int() failed: errno %d (%s)", errno, strerror(errno));
return (LIBUSB_ERROR_IO);
}
if ((devlink_hdl = di_devlink_init(NULL, 0)) == NULL) {
di_fini(root_node);
- usbi_dbg("di_devlink_init() failed: %s", strerror(errno));
+ usbi_dbg("di_devlink_init() failed: errno %d (%s)", errno, strerror(errno));
return (LIBUSB_ERROR_IO);
}
@@ -728,7 +705,7 @@ sunos_get_device_list(struct libusb_context * ctx,
/* walk each node to find USB devices */
if (di_walk_node(root_node, DI_WALK_SIBFIRST, &args,
sunos_walk_minor_node_link) == -1) {
- usbi_dbg("di_walk_node() failed: %s", strerror(errno));
+ usbi_dbg("di_walk_node() failed: errno %d (%s)", errno, strerror(errno));
di_fini(root_node);
return (LIBUSB_ERROR_IO);
@@ -737,7 +714,7 @@ sunos_get_device_list(struct libusb_context * ctx,
di_fini(root_node);
di_devlink_fini(&devlink_hdl);
- usbi_dbg("%d devices", (*discdevs)->len);
+ usbi_dbg("%zu devices", (*discdevs)->len);
return ((*discdevs)->len);
}
@@ -748,7 +725,6 @@ sunos_usb_open_ep0(sunos_dev_handle_priv_t *hpriv, sunos_dev_priv_t *dpriv)
char filename[PATH_MAX + 1];
if (hpriv->eps[0].datafd > 0) {
-
return (LIBUSB_SUCCESS);
}
snprintf(filename, PATH_MAX, "%s/cntrl0", dpriv->ugenpath);
@@ -790,7 +766,7 @@ sunos_usb_close_all_eps(sunos_dev_handle_priv_t *hdev)
}
static void
-sunos_usb_close_ep0(sunos_dev_handle_priv_t *hdev, sunos_dev_priv_t *dpriv)
+sunos_usb_close_ep0(sunos_dev_handle_priv_t *hdev)
{
if (hdev->eps[0].datafd >= 0) {
close(hdev->eps[0].datafd);
@@ -861,7 +837,7 @@ sunos_check_device_and_status_open(struct libusb_device_handle *hdl,
sunos_dev_handle_priv_t *hpriv;
usbi_dbg("open ep 0x%02x", ep_addr);
- hpriv = (sunos_dev_handle_priv_t *)hdl->os_priv;
+ hpriv = usbi_get_device_handle_priv(hdl);
ep_index = sunos_usb_ep_index(ep_addr);
/* ep already opened */
if ((hpriv->eps[ep_index].datafd > 0) &&
@@ -881,17 +857,17 @@ sunos_check_device_and_status_open(struct libusb_device_handle *hdl,
/* create filename */
if (hpriv->config_index > 0) {
- (void) snprintf(cfg_num, sizeof (cfg_num), "cfg%d",
+ (void) snprintf(cfg_num, sizeof(cfg_num), "cfg%d",
hpriv->config_index + 1);
} else {
- bzero(cfg_num, sizeof (cfg_num));
+ bzero(cfg_num, sizeof(cfg_num));
}
if (hpriv->altsetting[ifc] > 0) {
- (void) snprintf(alt_num, sizeof (alt_num), ".%d",
+ (void) snprintf(alt_num, sizeof(alt_num), ".%d",
hpriv->altsetting[ifc]);
} else {
- bzero(alt_num, sizeof (alt_num));
+ bzero(alt_num, sizeof(alt_num));
}
(void) snprintf(filename, PATH_MAX, "%s/%sif%d%s%s%d",
@@ -901,59 +877,75 @@ sunos_check_device_and_status_open(struct libusb_device_handle *hdl,
(void) snprintf(statfilename, PATH_MAX, "%sstat", filename);
/*
- * for interrupt IN endpoints, we need to enable one xfer
- * mode before opening the endpoint
+ * In case configuration has been switched, the xfer endpoint needs
+ * to be opened before the status endpoint, due to a ugen issue.
+ * However, to enable the one transfer mode for an Interrupt-In pipe,
+ * the status endpoint needs to be opened before the xfer endpoint.
+ * So, open the xfer mode first and close it immediately
+ * as a workaround. This will handle the configuration switch.
+ * Then, open the status endpoint. If for an Interrupt-in pipe,
+ * write the USB_EP_INTR_ONE_XFER control to the status endpoint
+ * to enable the one transfer mode. Then, re-open the xfer mode.
+ */
+ if (ep_type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS) {
+ mode = O_RDWR;
+ } else if (ep_addr & LIBUSB_ENDPOINT_IN) {
+ mode = O_RDONLY;
+ } else {
+ mode = O_WRONLY;
+ }
+ /* Open the xfer endpoint first */
+ if ((fd = open(filename, mode)) == -1) {
+ usbi_dbg("can't open %s: errno %d (%s)", filename, errno,
+ strerror(errno));
+
+ return (errno);
+ }
+ /* And immediately close the xfer endpoint */
+ (void) close(fd);
+
+ /*
+ * Open the status endpoint.
+ * If for an Interrupt-IN pipe, need to enable the one transfer mode
+ * by writing USB_EP_INTR_ONE_XFER control to the status endpoint
+ * before opening the xfer endpoint
*/
if ((ep_type == LIBUSB_TRANSFER_TYPE_INTERRUPT) &&
(ep_addr & LIBUSB_ENDPOINT_IN)) {
char control = USB_EP_INTR_ONE_XFER;
- int count;
+ ssize_t count;
- /* open the status device node for the ep first RDWR */
+ /* Open the status endpoint with RDWR */
if ((fdstat = open(statfilename, O_RDWR)) == -1) {
- usbi_dbg("can't open %s RDWR: %d",
- statfilename, errno);
+ usbi_dbg("can't open %s RDWR: errno %d (%s)",
+ statfilename, errno, strerror(errno));
+
+ return (errno);
} else {
- count = write(fdstat, &control, sizeof (control));
+ count = write(fdstat, &control, sizeof(control));
if (count != 1) {
/* this should have worked */
- usbi_dbg("can't write to %s: %d",
- statfilename, errno);
+ usbi_dbg("can't write to %s: errno %d (%s)",
+ statfilename, errno, strerror(errno));
(void) close(fdstat);
return (errno);
}
- /* close status node and open xfer node first */
- close (fdstat);
}
- }
-
- /* open the xfer node first in case alt needs to be changed */
- if (ep_type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS) {
- mode = O_RDWR;
- } else if (ep_addr & LIBUSB_ENDPOINT_IN) {
- mode = O_RDONLY;
} else {
- mode = O_WRONLY;
- }
+ if ((fdstat = open(statfilename, O_RDONLY)) == -1) {
+ usbi_dbg("can't open %s: errno %d (%s)", statfilename, errno,
+ strerror(errno));
- /*
- * IMPORTANT: must open data xfer node first and then open stat node
- * Otherwise, it will fail on multi-config or multi-altsetting devices
- * with "Device Busy" error. See ugen_epxs_switch_cfg_alt() and
- * ugen_epxs_check_alt_switch() in ugen driver source code.
- */
- if ((fd = open(filename, mode)) == -1) {
- usbi_dbg("can't open %s: %d(%s)", filename, errno,
- strerror(errno));
-
- return (errno);
+ return (errno);
+ }
}
- /* open the status node */
- if ((fdstat = open(statfilename, O_RDONLY)) == -1) {
- usbi_dbg("can't open %s: %d", statfilename, errno);
- (void) close(fd);
+ /* Re-open the xfer endpoint */
+ if ((fd = open(filename, mode)) == -1) {
+ usbi_dbg("can't open %s: errno %d (%s)", filename, errno,
+ strerror(errno));
+ (void) close(fdstat);
return (errno);
}
@@ -973,8 +965,8 @@ sunos_open(struct libusb_device_handle *handle)
int i;
int ret;
- hpriv = (sunos_dev_handle_priv_t *)handle->os_priv;
- dpriv = (sunos_dev_priv_t *)handle->dev->os_priv;
+ hpriv = usbi_get_device_handle_priv(handle);
+ dpriv = usbi_get_device_priv(handle->dev);
hpriv->dpriv = dpriv;
/* set all file descriptors to "closed" */
@@ -1000,43 +992,20 @@ void
sunos_close(struct libusb_device_handle *handle)
{
sunos_dev_handle_priv_t *hpriv;
- sunos_dev_priv_t *dpriv;
- usbi_dbg("");
- if (!handle) {
- return;
- }
+ usbi_dbg(" ");
- hpriv = (sunos_dev_handle_priv_t *)handle->os_priv;
- if (!hpriv) {
- return;
- }
- dpriv = (sunos_dev_priv_t *)handle->dev->os_priv;
- if (!dpriv) {
- return;
- }
+ hpriv = usbi_get_device_handle_priv(handle);
sunos_usb_close_all_eps(hpriv);
- sunos_usb_close_ep0(hpriv, dpriv);
-}
-
-int
-sunos_get_device_descriptor(struct libusb_device *dev, uint8_t *buf,
- int *host_endian)
-{
- sunos_dev_priv_t *dpriv = (sunos_dev_priv_t *)dev->os_priv;
-
- memcpy(buf, &dpriv->dev_descr, LIBUSB_DT_DEVICE_SIZE);
- *host_endian = 0;
-
- return (LIBUSB_SUCCESS);
+ sunos_usb_close_ep0(hpriv);
}
int
sunos_get_active_config_descriptor(struct libusb_device *dev,
- uint8_t *buf, size_t len, int *host_endian)
+ void *buf, size_t len)
{
- sunos_dev_priv_t *dpriv = (sunos_dev_priv_t *)dev->os_priv;
+ sunos_dev_priv_t *dpriv = usbi_get_device_priv(dev);
struct libusb_config_descriptor *cfg;
int proplen;
di_node_t node;
@@ -1047,7 +1016,8 @@ sunos_get_active_config_descriptor(struct libusb_device *dev,
* has ever been changed through setCfg.
*/
if ((node = di_init(dpriv->phypath, DINFOCPYALL)) == DI_NODE_NIL) {
- usbi_dbg("di_int() failed: %s", strerror(errno));
+ usbi_dbg("di_int() failed: errno %d (%s)", errno,
+ strerror(errno));
return (LIBUSB_ERROR_IO);
}
proplen = di_prop_lookup_bytes(DDI_DEV_T_ANY, node,
@@ -1070,28 +1040,28 @@ sunos_get_active_config_descriptor(struct libusb_device *dev,
cfg = (struct libusb_config_descriptor *)dpriv->raw_cfgdescr;
len = MIN(len, libusb_le16_to_cpu(cfg->wTotalLength));
memcpy(buf, dpriv->raw_cfgdescr, len);
- *host_endian = 0;
- usbi_dbg("path:%s len %d", dpriv->phypath, len);
+ usbi_dbg("path:%s len %zu", dpriv->phypath, len);
return (len);
}
int
sunos_get_config_descriptor(struct libusb_device *dev, uint8_t idx,
- uint8_t *buf, size_t len, int *host_endian)
+ void *buf, size_t len)
{
+ UNUSED(idx);
/* XXX */
- return(sunos_get_active_config_descriptor(dev, buf, len, host_endian));
+ return(sunos_get_active_config_descriptor(dev, buf, len));
}
int
-sunos_get_configuration(struct libusb_device_handle *handle, int *config)
+sunos_get_configuration(struct libusb_device_handle *handle, uint8_t *config)
{
- sunos_dev_priv_t *dpriv = (sunos_dev_priv_t *)handle->dev->os_priv;
+ sunos_dev_priv_t *dpriv = usbi_get_device_priv(handle->dev);
*config = dpriv->cfgvalue;
- usbi_dbg("bConfigurationValue %d", *config);
+ usbi_dbg("bConfigurationValue %u", *config);
return (LIBUSB_SUCCESS);
}
@@ -1099,17 +1069,17 @@ sunos_get_configuration(struct libusb_device_handle *handle, int *config)
int
sunos_set_configuration(struct libusb_device_handle *handle, int config)
{
- sunos_dev_priv_t *dpriv = (sunos_dev_priv_t *)handle->dev->os_priv;
+ sunos_dev_priv_t *dpriv = usbi_get_device_priv(handle->dev);
sunos_dev_handle_priv_t *hpriv;
usbi_dbg("bConfigurationValue %d", config);
- hpriv = (sunos_dev_handle_priv_t *)handle->os_priv;
+ hpriv = usbi_get_device_handle_priv(handle);
if (dpriv->ugenpath == NULL)
return (LIBUSB_ERROR_NOT_SUPPORTED);
- if (config < 1 || config > dpriv->dev_descr.bNumConfigurations)
- return (LIBUSB_ERROR_INVALID_PARAM);
+ if (config < 1)
+ return (LIBUSB_ERROR_NOT_SUPPORTED);
dpriv->cfgvalue = config;
hpriv->config_index = config - 1;
@@ -1118,26 +1088,21 @@ sunos_set_configuration(struct libusb_device_handle *handle, int config)
}
int
-sunos_claim_interface(struct libusb_device_handle *handle, int iface)
+sunos_claim_interface(struct libusb_device_handle *handle, uint8_t iface)
{
- usbi_dbg("iface %d", iface);
- if (iface < 0) {
- return (LIBUSB_ERROR_INVALID_PARAM);
- }
+ UNUSED(handle);
+
+ usbi_dbg("iface %u", iface);
return (LIBUSB_SUCCESS);
}
int
-sunos_release_interface(struct libusb_device_handle *handle, int iface)
+sunos_release_interface(struct libusb_device_handle *handle, uint8_t iface)
{
- sunos_dev_handle_priv_t *hpriv =
- (sunos_dev_handle_priv_t *)handle->os_priv;
+ sunos_dev_handle_priv_t *hpriv = usbi_get_device_handle_priv(handle);
- usbi_dbg("iface %d", iface);
- if (iface < 0) {
- return (LIBUSB_ERROR_INVALID_PARAM);
- }
+ usbi_dbg("iface %u", iface);
/* XXX: can we release it? */
hpriv->altsetting[iface] = 0;
@@ -1146,18 +1111,14 @@ sunos_release_interface(struct libusb_device_handle *handle, int iface)
}
int
-sunos_set_interface_altsetting(struct libusb_device_handle *handle, int iface,
- int altsetting)
+sunos_set_interface_altsetting(struct libusb_device_handle *handle, uint8_t iface,
+ uint8_t altsetting)
{
- sunos_dev_priv_t *dpriv = (sunos_dev_priv_t *)handle->dev->os_priv;
- sunos_dev_handle_priv_t *hpriv =
- (sunos_dev_handle_priv_t *)handle->os_priv;
+ sunos_dev_priv_t *dpriv = usbi_get_device_priv(handle->dev);
+ sunos_dev_handle_priv_t *hpriv = usbi_get_device_handle_priv(handle);
- usbi_dbg("iface %d, setting %d", iface, altsetting);
+ usbi_dbg("iface %u, setting %u", iface, altsetting);
- if (iface < 0 || altsetting < 0) {
- return (LIBUSB_ERROR_INVALID_PARAM);
- }
if (dpriv->ugenpath == NULL)
return (LIBUSB_ERROR_NOT_FOUND);
@@ -1168,9 +1129,10 @@ sunos_set_interface_altsetting(struct libusb_device_handle *handle, int iface,
}
static void
-usb_dump_data(unsigned char *data, size_t size)
+usb_dump_data(const void *data, size_t size)
{
- int i;
+ const uint8_t *p = data;
+ size_t i;
if (getenv("LIBUSB_DEBUG") == NULL) {
return;
@@ -1179,9 +1141,9 @@ usb_dump_data(unsigned char *data, size_t size)
(void) fprintf(stderr, "data dump:");
for (i = 0; i < size; i++) {
if (i % 16 == 0) {
- (void) fprintf(stderr, "\n%08x ", i);
+ (void) fprintf(stderr, "\n%08zx ", i);
}
- (void) fprintf(stderr, "%02x ", (uchar_t)data[i]);
+ (void) fprintf(stderr, "%02x ", p[i]);
}
(void) fprintf(stderr, "\n");
}
@@ -1202,7 +1164,7 @@ sunos_async_callback(union sigval arg)
/* libusb can forcibly interrupt transfer in do_close() */
if (dev_handle != NULL) {
- hpriv = (sunos_dev_handle_priv_t *)dev_handle->os_priv;
+ hpriv = usbi_get_device_handle_priv(dev_handle);
ep = sunos_usb_ep_index(xfer->endpoint);
ret = aio_error(aiocb);
@@ -1233,15 +1195,15 @@ sunos_do_async_io(struct libusb_transfer *transfer)
uint8_t ep;
struct sunos_transfer_priv *tpriv;
- usbi_dbg("");
+ usbi_dbg(" ");
- tpriv = usbi_transfer_get_os_priv(LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer));
- hpriv = (sunos_dev_handle_priv_t *)transfer->dev_handle->os_priv;
+ tpriv = usbi_get_transfer_priv(LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer));
+ hpriv = usbi_get_device_handle_priv(transfer->dev_handle);
ep = sunos_usb_ep_index(transfer->endpoint);
tpriv->transfer = transfer;
aiocb = &tpriv->aiocb;
- bzero(aiocb, sizeof (*aiocb));
+ bzero(aiocb, sizeof(*aiocb));
aiocb->aio_fildes = hpriv->eps[ep].datafd;
aiocb->aio_buf = transfer->buffer;
aiocb->aio_nbytes = transfer->length;
@@ -1262,13 +1224,13 @@ sunos_do_async_io(struct libusb_transfer *transfer)
}
/* return the number of bytes read/written */
-static int
-usb_do_io(int fd, int stat_fd, char *data, size_t size, int flag, int *status)
+static ssize_t
+usb_do_io(int fd, int stat_fd, void *data, size_t size, int flag, int *status)
{
int error;
- int ret = -1;
+ ssize_t ret = -1;
- usbi_dbg("usb_do_io(): datafd=%d statfd=%d size=0x%x flag=%s",
+ usbi_dbg("usb_do_io(): datafd=%d statfd=%d size=0x%zx flag=%s",
fd, stat_fd, size, flag? "WRITE":"READ");
switch (flag) {
@@ -1284,17 +1246,17 @@ usb_do_io(int fd, int stat_fd, char *data, size_t size, int flag, int *status)
break;
}
- usbi_dbg("usb_do_io(): amount=%d", ret);
+ usbi_dbg("usb_do_io(): amount=%zd", ret);
if (ret < 0) {
int save_errno = errno;
- usbi_dbg("TID=%x io %s errno=%d(%s) ret=%d", pthread_self(),
- flag?"WRITE":"READ", errno, strerror(errno), ret);
+ usbi_dbg("TID=%x io %s errno %d (%s)", pthread_self(),
+ flag?"WRITE":"READ", errno, strerror(errno));
/* sunos_usb_get_status will do a read and overwrite errno */
error = sunos_usb_get_status(stat_fd);
- usbi_dbg("io status=%d errno=%d(%s)", error,
+ usbi_dbg("io status=%d errno %d (%s)", error,
save_errno, strerror(save_errno));
if (status) {
@@ -1313,14 +1275,14 @@ usb_do_io(int fd, int stat_fd, char *data, size_t size, int flag, int *status)
static int
solaris_submit_ctrl_on_default(struct libusb_transfer *transfer)
{
- int ret = -1, setup_ret;
+ ssize_t ret = -1, setup_ret;
int status;
sunos_dev_handle_priv_t *hpriv;
struct libusb_device_handle *hdl = transfer->dev_handle;
uint16_t wLength;
uint8_t *data = transfer->buffer;
- hpriv = (sunos_dev_handle_priv_t *)hdl->os_priv;
+ hpriv = usbi_get_device_handle_priv(hdl);
wLength = transfer->length - LIBUSB_CONTROL_SETUP_SIZE;
if (hpriv->eps[0].datafd == -1) {
@@ -1332,8 +1294,8 @@ solaris_submit_ctrl_on_default(struct libusb_transfer *transfer)
if ((data[0] & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_IN) {
usbi_dbg("IN request");
ret = usb_do_io(hpriv->eps[0].datafd,
- hpriv->eps[0].statfd, (char *)data, LIBUSB_CONTROL_SETUP_SIZE,
- WRITE, (int *)&status);
+ hpriv->eps[0].statfd, data, LIBUSB_CONTROL_SETUP_SIZE,
+ WRITE, &status);
} else {
usbi_dbg("OUT request");
ret = usb_do_io(hpriv->eps[0].datafd, hpriv->eps[0].statfd,
@@ -1342,8 +1304,8 @@ solaris_submit_ctrl_on_default(struct libusb_transfer *transfer)
}
setup_ret = ret;
- if (ret < LIBUSB_CONTROL_SETUP_SIZE) {
- usbi_dbg("error sending control msg: %d", ret);
+ if (ret < (ssize_t)LIBUSB_CONTROL_SETUP_SIZE) {
+ usbi_dbg("error sending control msg: %zd", ret);
return (LIBUSB_ERROR_IO);
}
@@ -1353,18 +1315,17 @@ solaris_submit_ctrl_on_default(struct libusb_transfer *transfer)
/* Read the remaining bytes for IN request */
if ((wLength) && ((data[0] & LIBUSB_ENDPOINT_DIR_MASK) ==
LIBUSB_ENDPOINT_IN)) {
- usbi_dbg("DATA: %d", transfer->length - setup_ret);
+ usbi_dbg("DATA: %d", transfer->length - (int)setup_ret);
ret = usb_do_io(hpriv->eps[0].datafd,
hpriv->eps[0].statfd,
- (char *)transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE,
+ transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE,
wLength, READ, (int *)&transfer->status);
}
if (ret >= 0) {
- transfer->actual_length = ret;
LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer)->transferred = ret;
}
- usbi_dbg("Done: ctrl data bytes %d", ret);
+ usbi_dbg("Done: ctrl data bytes %zd", ret);
/**
* Sync transfer handling.
@@ -1380,7 +1341,7 @@ solaris_submit_ctrl_on_default(struct libusb_transfer *transfer)
}
int
-sunos_clear_halt(struct libusb_device_handle *handle, uint8_t endpoint)
+sunos_clear_halt(struct libusb_device_handle *handle, unsigned char endpoint)
{
int ret;
@@ -1395,19 +1356,12 @@ sunos_clear_halt(struct libusb_device_handle *handle, uint8_t endpoint)
return (ret);
}
-int
-sunos_reset_device(struct libusb_device_handle *handle)
-{
- usbi_dbg("");
-
- return (LIBUSB_ERROR_NOT_SUPPORTED);
-}
-
void
sunos_destroy_device(struct libusb_device *dev)
{
- sunos_dev_priv_t *dpriv = (sunos_dev_priv_t *)dev->os_priv;
- usbi_dbg("destroy everyting");
+ sunos_dev_priv_t *dpriv = usbi_get_device_priv(dev);
+
+ usbi_dbg("destroy everything");
free(dpriv->raw_cfgdescr);
free(dpriv->ugenpath);
free(dpriv->phypath);
@@ -1473,10 +1427,10 @@ sunos_cancel_transfer(struct usbi_transfer *itransfer)
uint8_t ep;
int ret;
- tpriv = usbi_transfer_get_os_priv(itransfer);
+ tpriv = usbi_get_transfer_priv(itransfer);
aiocb = &tpriv->aiocb;
transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- hpriv = (sunos_dev_handle_priv_t *)transfer->dev_handle->os_priv;
+ hpriv = usbi_get_device_handle_priv(transfer->dev_handle);
ep = sunos_usb_ep_index(transfer->endpoint);
ret = aio_cancel(hpriv->eps[ep].datafd, aiocb);
@@ -1498,14 +1452,6 @@ sunos_cancel_transfer(struct usbi_transfer *itransfer)
return (ret);
}
-void
-sunos_clear_transfer_priv(struct usbi_transfer *itransfer)
-{
- usbi_dbg("");
-
- /* Nothing to do */
-}
-
int
sunos_handle_transfer_completion(struct usbi_transfer *itransfer)
{
@@ -1513,18 +1459,6 @@ sunos_handle_transfer_completion(struct usbi_transfer *itransfer)
}
int
-sunos_clock_gettime(int clkid, struct timespec *tp)
-{
- if (clkid == USBI_CLOCK_REALTIME)
- return clock_gettime(CLOCK_REALTIME, tp);
-
- if (clkid == USBI_CLOCK_MONOTONIC)
- return clock_gettime(CLOCK_MONOTONIC, tp);
-
- return (LIBUSB_ERROR_INVALID_PARAM);
-}
-
-int
_errno_to_libusb(int err)
{
usbi_dbg("error: %s (%d)", strerror(err), err);
@@ -1554,12 +1488,13 @@ _errno_to_libusb(int err)
static int
sunos_usb_get_status(int fd)
{
- int status, ret;
+ int status;
+ ssize_t ret;
usbi_dbg("sunos_usb_get_status(): fd=%d", fd);
- ret = read(fd, &status, sizeof (status));
- if (ret == sizeof (status)) {
+ ret = read(fd, &status, sizeof(status));
+ if (ret == sizeof(status)) {
switch (status) {
case USB_LC_STAT_NOERROR:
usbi_dbg("No Error");
@@ -1647,48 +1582,27 @@ sunos_usb_get_status(int fd)
return (status);
}
-#ifdef USBI_TIMERFD_AVAILABLE
-static clockid_t op_get_timerfd_clockid(void)
-{
- return CLOCK_MONOTONIC;
-}
-#endif
-
const struct usbi_os_backend usbi_backend = {
.name = "Solaris",
.caps = 0,
- .init = sunos_init,
- .exit = sunos_exit,
.get_device_list = sunos_get_device_list,
- .get_device_descriptor = sunos_get_device_descriptor,
.get_active_config_descriptor = sunos_get_active_config_descriptor,
.get_config_descriptor = sunos_get_config_descriptor,
- .hotplug_poll = NULL,
.open = sunos_open,
.close = sunos_close,
.get_configuration = sunos_get_configuration,
.set_configuration = sunos_set_configuration,
-
.claim_interface = sunos_claim_interface,
.release_interface = sunos_release_interface,
.set_interface_altsetting = sunos_set_interface_altsetting,
.clear_halt = sunos_clear_halt,
- .reset_device = sunos_reset_device, /* TODO */
- .alloc_streams = NULL,
- .free_streams = NULL,
.kernel_driver_active = sunos_kernel_driver_active,
.detach_kernel_driver = sunos_detach_kernel_driver,
.attach_kernel_driver = sunos_attach_kernel_driver,
.destroy_device = sunos_destroy_device,
.submit_transfer = sunos_submit_transfer,
.cancel_transfer = sunos_cancel_transfer,
- .handle_events = NULL,
- .clear_transfer_priv = sunos_clear_transfer_priv,
.handle_transfer_completion = sunos_handle_transfer_completion,
- .clock_gettime = sunos_clock_gettime,
-#ifdef USBI_TIMERFD_AVAILABLE
- .get_timerfd_clockid = op_get_timerfd_clockid,
-#endif
.device_priv_size = sizeof(sunos_dev_priv_t),
.device_handle_priv_size = sizeof(sunos_dev_handle_priv_t),
.transfer_priv_size = sizeof(sunos_xfer_priv_t),
diff --git a/libusb/os/sunos_usb.h b/libusb/os/sunos_usb.h
index 52bb3d3..2988398 100644
--- a/libusb/os/sunos_usb.h
+++ b/libusb/os/sunos_usb.h
@@ -30,7 +30,6 @@
typedef struct sunos_device_priv {
uint8_t cfgvalue; /* active config value */
uint8_t *raw_cfgdescr; /* active config descriptor */
- struct libusb_device_descriptor dev_descr; /* usb device descriptor */
char *ugenpath; /* name of the ugen(4) node */
char *phypath; /* physical path */
} sunos_dev_priv_t;
diff --git a/libusb/os/threads_posix.c b/libusb/os/threads_posix.c
index 16a7578..0e0e221 100644
--- a/libusb/os/threads_posix.c
+++ b/libusb/os/threads_posix.c
@@ -19,23 +19,39 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <config.h>
+#include "libusbi.h"
-#include <time.h>
-#if defined(__linux__) || defined(__OpenBSD__)
-# if defined(__OpenBSD__)
-# define _BSD_SOURCE
-# endif
+#include <errno.h>
+#if defined(__ANDROID__)
# include <unistd.h>
+#elif defined(__HAIKU__)
+# include <os/kernel/OS.h>
+#elif defined(__linux__)
# include <sys/syscall.h>
-#elif defined(__APPLE__)
-# include <pthread.h>
-#elif defined(__CYGWIN__)
-# include <windows.h>
+# include <unistd.h>
+#elif defined(__NetBSD__)
+# include <lwp.h>
+#elif defined(__OpenBSD__)
+# define _BSD_SOURCE
+# include <sys/syscall.h>
+# include <unistd.h>
+#elif defined(__sun__)
+# include <sys/lwp.h>
#endif
-#include "threads_posix.h"
-#include "libusbi.h"
+void usbi_cond_init(pthread_cond_t *cond)
+{
+#ifdef HAVE_PTHREAD_CONDATTR_SETCLOCK
+ pthread_condattr_t condattr;
+
+ PTHREAD_CHECK(pthread_condattr_init(&condattr));
+ PTHREAD_CHECK(pthread_condattr_setclock(&condattr, CLOCK_MONOTONIC));
+ PTHREAD_CHECK(pthread_cond_init(cond, &condattr));
+ PTHREAD_CHECK(pthread_condattr_destroy(&condattr));
+#else
+ PTHREAD_CHECK(pthread_cond_init(cond, NULL));
+#endif
+}
int usbi_cond_timedwait(pthread_cond_t *cond,
pthread_mutex_t *mutex, const struct timeval *tv)
@@ -43,38 +59,71 @@ int usbi_cond_timedwait(pthread_cond_t *cond,
struct timespec timeout;
int r;
- r = usbi_backend.clock_gettime(USBI_CLOCK_REALTIME, &timeout);
- if (r < 0)
- return r;
+#ifdef HAVE_PTHREAD_CONDATTR_SETCLOCK
+ usbi_get_monotonic_time(&timeout);
+#else
+ usbi_get_real_time(&timeout);
+#endif
timeout.tv_sec += tv->tv_sec;
- timeout.tv_nsec += tv->tv_usec * 1000;
- while (timeout.tv_nsec >= 1000000000L) {
- timeout.tv_nsec -= 1000000000L;
+ timeout.tv_nsec += tv->tv_usec * 1000L;
+ if (timeout.tv_nsec >= NSEC_PER_SEC) {
+ timeout.tv_nsec -= NSEC_PER_SEC;
timeout.tv_sec++;
}
- return pthread_cond_timedwait(cond, mutex, &timeout);
+ r = pthread_cond_timedwait(cond, mutex, &timeout);
+ if (r == 0)
+ return 0;
+ else if (r == ETIMEDOUT)
+ return LIBUSB_ERROR_TIMEOUT;
+ else
+ return LIBUSB_ERROR_OTHER;
}
-int usbi_get_tid(void)
+unsigned int usbi_get_tid(void)
{
- int ret;
+ static _Thread_local unsigned int tl_tid;
+ int tid;
+
+ if (tl_tid)
+ return tl_tid;
+
#if defined(__ANDROID__)
- ret = gettid();
+ tid = gettid();
+#elif defined(__APPLE__)
+#ifdef HAVE_PTHREAD_THREADID_NP
+ uint64_t thread_id;
+
+ if (pthread_threadid_np(NULL, &thread_id) == 0)
+ tid = (int)thread_id;
+ else
+ tid = -1;
+#else
+ tid = (int)pthread_mach_thread_np(pthread_self());
+#endif
+#elif defined(__HAIKU__)
+ tid = get_pthread_thread_id(pthread_self());
#elif defined(__linux__)
- ret = syscall(SYS_gettid);
+ tid = (int)syscall(SYS_gettid);
+#elif defined(__NetBSD__)
+ tid = _lwp_self();
#elif defined(__OpenBSD__)
/* The following only works with OpenBSD > 5.1 as it requires
- real thread support. For 5.1 and earlier, -1 is returned. */
- ret = syscall(SYS_getthrid);
-#elif defined(__APPLE__)
- ret = (int)pthread_mach_thread_np(pthread_self());
-#elif defined(__CYGWIN__)
- ret = GetCurrentThreadId();
+ * real thread support. For 5.1 and earlier, -1 is returned. */
+ tid = syscall(SYS_getthrid);
+#elif defined(__sun__)
+ tid = _lwp_self();
#else
- ret = -1;
+ tid = -1;
#endif
-/* TODO: NetBSD thread ID support */
- return ret;
+
+ if (tid == -1) {
+ /* If we don't have a thread ID, at least return a unique
+ * value that can be used to distinguish individual
+ * threads. */
+ tid = (int)(intptr_t)pthread_self();
+ }
+
+ return tl_tid = (unsigned int)tid;
}
diff --git a/libusb/os/threads_posix.h b/libusb/os/threads_posix.h
index 9f1ef94..9322834 100644
--- a/libusb/os/threads_posix.h
+++ b/libusb/os/threads_posix.h
@@ -22,67 +22,63 @@
#define LIBUSB_THREADS_POSIX_H
#include <pthread.h>
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
+
+#define PTHREAD_CHECK(expression) ASSERT_EQ(expression, 0)
#define USBI_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
typedef pthread_mutex_t usbi_mutex_static_t;
static inline void usbi_mutex_static_lock(usbi_mutex_static_t *mutex)
{
- (void)pthread_mutex_lock(mutex);
+ PTHREAD_CHECK(pthread_mutex_lock(mutex));
}
static inline void usbi_mutex_static_unlock(usbi_mutex_static_t *mutex)
{
- (void)pthread_mutex_unlock(mutex);
+ PTHREAD_CHECK(pthread_mutex_unlock(mutex));
}
typedef pthread_mutex_t usbi_mutex_t;
-static inline int usbi_mutex_init(usbi_mutex_t *mutex)
+static inline void usbi_mutex_init(usbi_mutex_t *mutex)
{
- return pthread_mutex_init(mutex, NULL);
+ PTHREAD_CHECK(pthread_mutex_init(mutex, NULL));
}
static inline void usbi_mutex_lock(usbi_mutex_t *mutex)
{
- (void)pthread_mutex_lock(mutex);
+ PTHREAD_CHECK(pthread_mutex_lock(mutex));
}
static inline void usbi_mutex_unlock(usbi_mutex_t *mutex)
{
- (void)pthread_mutex_unlock(mutex);
+ PTHREAD_CHECK(pthread_mutex_unlock(mutex));
}
static inline int usbi_mutex_trylock(usbi_mutex_t *mutex)
{
- return pthread_mutex_trylock(mutex);
+ return pthread_mutex_trylock(mutex) == 0;
}
static inline void usbi_mutex_destroy(usbi_mutex_t *mutex)
{
- (void)pthread_mutex_destroy(mutex);
+ PTHREAD_CHECK(pthread_mutex_destroy(mutex));
}
typedef pthread_cond_t usbi_cond_t;
-static inline void usbi_cond_init(pthread_cond_t *cond)
-{
- (void)pthread_cond_init(cond, NULL);
-}
-static inline int usbi_cond_wait(usbi_cond_t *cond, usbi_mutex_t *mutex)
+void usbi_cond_init(pthread_cond_t *cond);
+static inline void usbi_cond_wait(usbi_cond_t *cond, usbi_mutex_t *mutex)
{
- return pthread_cond_wait(cond, mutex);
+ PTHREAD_CHECK(pthread_cond_wait(cond, mutex));
}
int usbi_cond_timedwait(usbi_cond_t *cond,
usbi_mutex_t *mutex, const struct timeval *tv);
static inline void usbi_cond_broadcast(usbi_cond_t *cond)
{
- (void)pthread_cond_broadcast(cond);
+ PTHREAD_CHECK(pthread_cond_broadcast(cond));
}
static inline void usbi_cond_destroy(usbi_cond_t *cond)
{
- (void)pthread_cond_destroy(cond);
+ PTHREAD_CHECK(pthread_cond_destroy(cond));
}
typedef pthread_key_t usbi_tls_key_t;
static inline void usbi_tls_key_create(usbi_tls_key_t *key)
{
- (void)pthread_key_create(key, NULL);
+ PTHREAD_CHECK(pthread_key_create(key, NULL));
}
static inline void *usbi_tls_key_get(usbi_tls_key_t key)
{
@@ -90,13 +86,13 @@ static inline void *usbi_tls_key_get(usbi_tls_key_t key)
}
static inline void usbi_tls_key_set(usbi_tls_key_t key, void *ptr)
{
- (void)pthread_setspecific(key, ptr);
+ PTHREAD_CHECK(pthread_setspecific(key, ptr));
}
static inline void usbi_tls_key_delete(usbi_tls_key_t key)
{
- (void)pthread_key_delete(key);
+ PTHREAD_CHECK(pthread_key_delete(key));
}
-int usbi_get_tid(void);
+unsigned int usbi_get_tid(void);
#endif /* LIBUSB_THREADS_POSIX_H */
diff --git a/libusb/os/threads_windows.c b/libusb/os/threads_windows.c
index 409c490..4a57f42 100644
--- a/libusb/os/threads_windows.c
+++ b/libusb/os/threads_windows.c
@@ -2,6 +2,7 @@
* libusb synchronization on Microsoft Windows
*
* Copyright © 2010 Michael Plante <michael.plante@gmail.com>
+ * Copyright © 2020 Chris Dickens <christopher.a.dickens@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -18,109 +19,22 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <config.h>
-
-#include <errno.h>
-
#include "libusbi.h"
-struct usbi_cond_perthread {
- struct list_head list;
- HANDLE event;
-};
-
-void usbi_mutex_static_lock(usbi_mutex_static_t *mutex)
-{
- while (InterlockedExchange(mutex, 1L) == 1L)
- SleepEx(0, TRUE);
-}
-
-void usbi_cond_init(usbi_cond_t *cond)
-{
- list_init(&cond->waiters);
- list_init(&cond->not_waiting);
-}
-
-static int usbi_cond_intwait(usbi_cond_t *cond,
- usbi_mutex_t *mutex, DWORD timeout_ms)
-{
- struct usbi_cond_perthread *pos;
- DWORD r;
-
- // Same assumption as usbi_cond_broadcast() holds
- if (list_empty(&cond->not_waiting)) {
- pos = malloc(sizeof(*pos));
- if (pos == NULL)
- return ENOMEM; // This errno is not POSIX-allowed.
- pos->event = CreateEvent(NULL, FALSE, FALSE, NULL); // auto-reset.
- if (pos->event == NULL) {
- free(pos);
- return ENOMEM;
- }
- } else {
- pos = list_first_entry(&cond->not_waiting, struct usbi_cond_perthread, list);
- list_del(&pos->list); // remove from not_waiting list.
- // Ensure the event is clear before waiting
- WaitForSingleObject(pos->event, 0);
- }
-
- list_add(&pos->list, &cond->waiters);
-
- LeaveCriticalSection(mutex);
- r = WaitForSingleObject(pos->event, timeout_ms);
- EnterCriticalSection(mutex);
-
- list_del(&pos->list);
- list_add(&pos->list, &cond->not_waiting);
-
- if (r == WAIT_OBJECT_0)
- return 0;
- else if (r == WAIT_TIMEOUT)
- return ETIMEDOUT;
- else
- return EINVAL;
-}
-
-// N.B.: usbi_cond_*wait() can also return ENOMEM, even though pthread_cond_*wait cannot!
-int usbi_cond_wait(usbi_cond_t *cond, usbi_mutex_t *mutex)
-{
- return usbi_cond_intwait(cond, mutex, INFINITE);
-}
-
int usbi_cond_timedwait(usbi_cond_t *cond,
usbi_mutex_t *mutex, const struct timeval *tv)
{
DWORD millis;
- millis = (DWORD)(tv->tv_sec * 1000) + (tv->tv_usec / 1000);
+ millis = (DWORD)(tv->tv_sec * 1000L) + (tv->tv_usec / 1000L);
/* round up to next millisecond */
- if (tv->tv_usec % 1000)
+ if (tv->tv_usec % 1000L)
millis++;
- return usbi_cond_intwait(cond, mutex, millis);
-}
-void usbi_cond_broadcast(usbi_cond_t *cond)
-{
- // Assumes mutex is locked; this is not in keeping with POSIX spec, but
- // libusb does this anyway, so we simplify by not adding more sync
- // primitives to the CV definition!
- struct usbi_cond_perthread *pos;
-
- list_for_each_entry(pos, &cond->waiters, list, struct usbi_cond_perthread)
- SetEvent(pos->event);
- // The wait function will remove its respective item from the list.
-}
-
-void usbi_cond_destroy(usbi_cond_t *cond)
-{
- // This assumes no one is using this anymore. The check MAY NOT BE safe.
- struct usbi_cond_perthread *pos, *next;
-
- if (!list_empty(&cond->waiters))
- return; // (!see above!)
- list_for_each_entry_safe(pos, next, &cond->not_waiting, list, struct usbi_cond_perthread) {
- CloseHandle(pos->event);
- list_del(&pos->list);
- free(pos);
- }
+ if (SleepConditionVariableCS(cond, mutex, millis))
+ return 0;
+ else if (GetLastError() == ERROR_TIMEOUT)
+ return LIBUSB_ERROR_TIMEOUT;
+ else
+ return LIBUSB_ERROR_OTHER;
}
diff --git a/libusb/os/threads_windows.h b/libusb/os/threads_windows.h
index 409de2d..dfef158 100644
--- a/libusb/os/threads_windows.h
+++ b/libusb/os/threads_windows.h
@@ -21,23 +21,24 @@
#ifndef LIBUSB_THREADS_WINDOWS_H
#define LIBUSB_THREADS_WINDOWS_H
+#define WINAPI_CHECK(expression) ASSERT_NE(expression, 0)
+
#define USBI_MUTEX_INITIALIZER 0L
-#ifdef _WIN32_WCE
typedef LONG usbi_mutex_static_t;
-#else
-typedef volatile LONG usbi_mutex_static_t;
-#endif
-void usbi_mutex_static_lock(usbi_mutex_static_t *mutex);
+static inline void usbi_mutex_static_lock(usbi_mutex_static_t *mutex)
+{
+ while (InterlockedExchange(mutex, 1L) == 1L)
+ SleepEx(0, TRUE);
+}
static inline void usbi_mutex_static_unlock(usbi_mutex_static_t *mutex)
{
InterlockedExchange(mutex, 0L);
}
typedef CRITICAL_SECTION usbi_mutex_t;
-static inline int usbi_mutex_init(usbi_mutex_t *mutex)
+static inline void usbi_mutex_init(usbi_mutex_t *mutex)
{
InitializeCriticalSection(mutex);
- return 0;
}
static inline void usbi_mutex_lock(usbi_mutex_t *mutex)
{
@@ -49,46 +50,47 @@ static inline void usbi_mutex_unlock(usbi_mutex_t *mutex)
}
static inline int usbi_mutex_trylock(usbi_mutex_t *mutex)
{
- return !TryEnterCriticalSection(mutex);
+ return TryEnterCriticalSection(mutex) != 0;
}
static inline void usbi_mutex_destroy(usbi_mutex_t *mutex)
{
DeleteCriticalSection(mutex);
}
-// We *were* getting timespec from pthread.h:
-#if (!defined(HAVE_STRUCT_TIMESPEC) && !defined(_TIMESPEC_DEFINED))
+#if !defined(HAVE_STRUCT_TIMESPEC) && !defined(_TIMESPEC_DEFINED)
#define HAVE_STRUCT_TIMESPEC 1
#define _TIMESPEC_DEFINED 1
struct timespec {
long tv_sec;
long tv_nsec;
};
-#endif /* HAVE_STRUCT_TIMESPEC | _TIMESPEC_DEFINED */
-
-// We *were* getting ETIMEDOUT from pthread.h:
-#ifndef ETIMEDOUT
-#define ETIMEDOUT 10060 /* This is the value in winsock.h. */
-#endif
+#endif /* HAVE_STRUCT_TIMESPEC || _TIMESPEC_DEFINED */
-typedef struct usbi_cond {
- // Every time a thread touches the CV, it winds up in one of these lists.
- // It stays there until the CV is destroyed, even if the thread terminates.
- struct list_head waiters;
- struct list_head not_waiting;
-} usbi_cond_t;
-
-void usbi_cond_init(usbi_cond_t *cond);
-int usbi_cond_wait(usbi_cond_t *cond, usbi_mutex_t *mutex);
+typedef CONDITION_VARIABLE usbi_cond_t;
+static inline void usbi_cond_init(usbi_cond_t *cond)
+{
+ InitializeConditionVariable(cond);
+}
+static inline void usbi_cond_wait(usbi_cond_t *cond, usbi_mutex_t *mutex)
+{
+ WINAPI_CHECK(SleepConditionVariableCS(cond, mutex, INFINITE));
+}
int usbi_cond_timedwait(usbi_cond_t *cond,
usbi_mutex_t *mutex, const struct timeval *tv);
-void usbi_cond_broadcast(usbi_cond_t *cond);
-void usbi_cond_destroy(usbi_cond_t *cond);
+static inline void usbi_cond_broadcast(usbi_cond_t *cond)
+{
+ WakeAllConditionVariable(cond);
+}
+static inline void usbi_cond_destroy(usbi_cond_t *cond)
+{
+ UNUSED(cond);
+}
typedef DWORD usbi_tls_key_t;
static inline void usbi_tls_key_create(usbi_tls_key_t *key)
{
*key = TlsAlloc();
+ assert(*key != TLS_OUT_OF_INDEXES);
}
static inline void *usbi_tls_key_get(usbi_tls_key_t key)
{
@@ -96,16 +98,16 @@ static inline void *usbi_tls_key_get(usbi_tls_key_t key)
}
static inline void usbi_tls_key_set(usbi_tls_key_t key, void *ptr)
{
- (void)TlsSetValue(key, ptr);
+ WINAPI_CHECK(TlsSetValue(key, ptr));
}
static inline void usbi_tls_key_delete(usbi_tls_key_t key)
{
- (void)TlsFree(key);
+ WINAPI_CHECK(TlsFree(key));
}
-static inline int usbi_get_tid(void)
+static inline unsigned int usbi_get_tid(void)
{
- return (int)GetCurrentThreadId();
+ return (unsigned int)GetCurrentThreadId();
}
#endif /* LIBUSB_THREADS_WINDOWS_H */
diff --git a/libusb/os/wince_usb.c b/libusb/os/wince_usb.c
deleted file mode 100644
index a0f35e9..0000000
--- a/libusb/os/wince_usb.c
+++ /dev/null
@@ -1,888 +0,0 @@
-/*
- * Windows CE backend for libusb 1.0
- * Copyright © 2011-2013 RealVNC Ltd.
- * Large portions taken from Windows backend, which is
- * Copyright © 2009-2010 Pete Batard <pbatard@gmail.com>
- * With contributions from Michael Plante, Orin Eman et al.
- * Parts of this code adapted from libusb-win32-v1 by Stephan Meyer
- * Major code testing contribution by Xiaofan Chen
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <config.h>
-
-#include <stdint.h>
-#include <inttypes.h>
-
-#include "libusbi.h"
-#include "wince_usb.h"
-
-// Global variables
-int errno = 0;
-static uint64_t hires_frequency, hires_ticks_to_ps;
-static HANDLE driver_handle = INVALID_HANDLE_VALUE;
-static int concurrent_usage = -1;
-
-/*
- * Converts a windows error to human readable string
- * uses retval as errorcode, or, if 0, use GetLastError()
- */
-#if defined(ENABLE_LOGGING)
-static const char *windows_error_str(DWORD error_code)
-{
- static TCHAR wErr_string[ERR_BUFFER_SIZE];
- static char err_string[ERR_BUFFER_SIZE];
-
- DWORD size;
- int len;
-
- if (error_code == 0)
- error_code = GetLastError();
-
- len = sprintf(err_string, "[%u] ", (unsigned int)error_code);
-
- size = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- wErr_string, ERR_BUFFER_SIZE, NULL);
- if (size == 0) {
- DWORD format_error = GetLastError();
- if (format_error)
- snprintf(err_string, ERR_BUFFER_SIZE,
- "Windows error code %u (FormatMessage error code %u)",
- (unsigned int)error_code, (unsigned int)format_error);
- else
- snprintf(err_string, ERR_BUFFER_SIZE, "Unknown error code %u", (unsigned int)error_code);
- } else {
- // Remove CR/LF terminators, if present
- size_t pos = size - 2;
- if (wErr_string[pos] == 0x0D)
- wErr_string[pos] = 0;
-
- if (!WideCharToMultiByte(CP_ACP, 0, wErr_string, -1, &err_string[len], ERR_BUFFER_SIZE - len, NULL, NULL))
- strcpy(err_string, "Unable to convert error string");
- }
-
- return err_string;
-}
-#endif
-
-static struct wince_device_priv *_device_priv(struct libusb_device *dev)
-{
- return (struct wince_device_priv *)dev->os_priv;
-}
-
-// ceusbkwrapper to libusb error code mapping
-static int translate_driver_error(DWORD error)
-{
- switch (error) {
- case ERROR_INVALID_PARAMETER:
- return LIBUSB_ERROR_INVALID_PARAM;
- case ERROR_CALL_NOT_IMPLEMENTED:
- case ERROR_NOT_SUPPORTED:
- return LIBUSB_ERROR_NOT_SUPPORTED;
- case ERROR_NOT_ENOUGH_MEMORY:
- return LIBUSB_ERROR_NO_MEM;
- case ERROR_INVALID_HANDLE:
- return LIBUSB_ERROR_NO_DEVICE;
- case ERROR_BUSY:
- return LIBUSB_ERROR_BUSY;
-
- // Error codes that are either unexpected, or have
- // no suitable LIBUSB_ERROR equivalent.
- case ERROR_CANCELLED:
- case ERROR_INTERNAL_ERROR:
- default:
- return LIBUSB_ERROR_OTHER;
- }
-}
-
-static BOOL init_dllimports(void)
-{
- DLL_GET_HANDLE(ceusbkwrapper);
- DLL_LOAD_FUNC(ceusbkwrapper, UkwOpenDriver, TRUE);
- DLL_LOAD_FUNC(ceusbkwrapper, UkwGetDeviceList, TRUE);
- DLL_LOAD_FUNC(ceusbkwrapper, UkwReleaseDeviceList, TRUE);
- DLL_LOAD_FUNC(ceusbkwrapper, UkwGetDeviceAddress, TRUE);
- DLL_LOAD_FUNC(ceusbkwrapper, UkwGetDeviceDescriptor, TRUE);
- DLL_LOAD_FUNC(ceusbkwrapper, UkwGetConfigDescriptor, TRUE);
- DLL_LOAD_FUNC(ceusbkwrapper, UkwCloseDriver, TRUE);
- DLL_LOAD_FUNC(ceusbkwrapper, UkwCancelTransfer, TRUE);
- DLL_LOAD_FUNC(ceusbkwrapper, UkwIssueControlTransfer, TRUE);
- DLL_LOAD_FUNC(ceusbkwrapper, UkwClaimInterface, TRUE);
- DLL_LOAD_FUNC(ceusbkwrapper, UkwReleaseInterface, TRUE);
- DLL_LOAD_FUNC(ceusbkwrapper, UkwSetInterfaceAlternateSetting, TRUE);
- DLL_LOAD_FUNC(ceusbkwrapper, UkwClearHaltHost, TRUE);
- DLL_LOAD_FUNC(ceusbkwrapper, UkwClearHaltDevice, TRUE);
- DLL_LOAD_FUNC(ceusbkwrapper, UkwGetConfig, TRUE);
- DLL_LOAD_FUNC(ceusbkwrapper, UkwSetConfig, TRUE);
- DLL_LOAD_FUNC(ceusbkwrapper, UkwResetDevice, TRUE);
- DLL_LOAD_FUNC(ceusbkwrapper, UkwKernelDriverActive, TRUE);
- DLL_LOAD_FUNC(ceusbkwrapper, UkwAttachKernelDriver, TRUE);
- DLL_LOAD_FUNC(ceusbkwrapper, UkwDetachKernelDriver, TRUE);
- DLL_LOAD_FUNC(ceusbkwrapper, UkwIssueBulkTransfer, TRUE);
- DLL_LOAD_FUNC(ceusbkwrapper, UkwIsPipeHalted, TRUE);
-
- return TRUE;
-}
-
-static void exit_dllimports(void)
-{
- DLL_FREE_HANDLE(ceusbkwrapper);
-}
-
-static int init_device(
- struct libusb_device *dev, UKW_DEVICE drv_dev,
- unsigned char bus_addr, unsigned char dev_addr)
-{
- struct wince_device_priv *priv = _device_priv(dev);
- int r = LIBUSB_SUCCESS;
-
- dev->bus_number = bus_addr;
- dev->device_address = dev_addr;
- priv->dev = drv_dev;
-
- if (!UkwGetDeviceDescriptor(priv->dev, &(priv->desc)))
- r = translate_driver_error(GetLastError());
-
- return r;
-}
-
-// Internal API functions
-static int wince_init(struct libusb_context *ctx)
-{
- int r = LIBUSB_ERROR_OTHER;
- HANDLE semaphore;
- LARGE_INTEGER li_frequency;
- TCHAR sem_name[11 + 8 + 1]; // strlen("libusb_init") + (32-bit hex PID) + '\0'
-
- _stprintf(sem_name, _T("libusb_init%08X"), (unsigned int)(GetCurrentProcessId() & 0xFFFFFFFF));
- semaphore = CreateSemaphore(NULL, 1, 1, sem_name);
- if (semaphore == NULL) {
- usbi_err(ctx, "could not create semaphore: %s", windows_error_str(0));
- return LIBUSB_ERROR_NO_MEM;
- }
-
- // A successful wait brings our semaphore count to 0 (unsignaled)
- // => any concurent wait stalls until the semaphore's release
- if (WaitForSingleObject(semaphore, INFINITE) != WAIT_OBJECT_0) {
- usbi_err(ctx, "failure to access semaphore: %s", windows_error_str(0));
- CloseHandle(semaphore);
- return LIBUSB_ERROR_NO_MEM;
- }
-
- // NB: concurrent usage supposes that init calls are equally balanced with
- // exit calls. If init is called more than exit, we will not exit properly
- if ( ++concurrent_usage == 0 ) { // First init?
- // Load DLL imports
- if (!init_dllimports()) {
- usbi_err(ctx, "could not resolve DLL functions");
- r = LIBUSB_ERROR_NOT_SUPPORTED;
- goto init_exit;
- }
-
- // try to open a handle to the driver
- driver_handle = UkwOpenDriver();
- if (driver_handle == INVALID_HANDLE_VALUE) {
- usbi_err(ctx, "could not connect to driver");
- r = LIBUSB_ERROR_NOT_SUPPORTED;
- goto init_exit;
- }
-
- // find out if we have access to a monotonic (hires) timer
- if (QueryPerformanceFrequency(&li_frequency)) {
- hires_frequency = li_frequency.QuadPart;
- // The hires frequency can go as high as 4 GHz, so we'll use a conversion
- // to picoseconds to compute the tv_nsecs part in clock_gettime
- hires_ticks_to_ps = UINT64_C(1000000000000) / hires_frequency;
- usbi_dbg("hires timer available (Frequency: %"PRIu64" Hz)", hires_frequency);
- } else {
- usbi_dbg("no hires timer available on this platform");
- hires_frequency = 0;
- hires_ticks_to_ps = UINT64_C(0);
- }
- }
- // At this stage, either we went through full init successfully, or didn't need to
- r = LIBUSB_SUCCESS;
-
-init_exit: // Holds semaphore here.
- if (!concurrent_usage && r != LIBUSB_SUCCESS) { // First init failed?
- exit_dllimports();
-
- if (driver_handle != INVALID_HANDLE_VALUE) {
- UkwCloseDriver(driver_handle);
- driver_handle = INVALID_HANDLE_VALUE;
- }
- }
-
- if (r != LIBUSB_SUCCESS)
- --concurrent_usage; // Not expected to call libusb_exit if we failed.
-
- ReleaseSemaphore(semaphore, 1, NULL); // increase count back to 1
- CloseHandle(semaphore);
- return r;
-}
-
-static void wince_exit(struct libusb_context *ctx)
-{
- HANDLE semaphore;
- TCHAR sem_name[11 + 8 + 1]; // strlen("libusb_init") + (32-bit hex PID) + '\0'
- UNUSED(ctx);
-
- _stprintf(sem_name, _T("libusb_init%08X"), (unsigned int)(GetCurrentProcessId() & 0xFFFFFFFF));
- semaphore = CreateSemaphore(NULL, 1, 1, sem_name);
- if (semaphore == NULL)
- return;
-
- // A successful wait brings our semaphore count to 0 (unsignaled)
- // => any concurent wait stalls until the semaphore release
- if (WaitForSingleObject(semaphore, INFINITE) != WAIT_OBJECT_0) {
- CloseHandle(semaphore);
- return;
- }
-
- // Only works if exits and inits are balanced exactly
- if (--concurrent_usage < 0) { // Last exit
- exit_dllimports();
-
- if (driver_handle != INVALID_HANDLE_VALUE) {
- UkwCloseDriver(driver_handle);
- driver_handle = INVALID_HANDLE_VALUE;
- }
- }
-
- ReleaseSemaphore(semaphore, 1, NULL); // increase count back to 1
- CloseHandle(semaphore);
-}
-
-static int wince_get_device_list(
- struct libusb_context *ctx,
- struct discovered_devs **discdevs)
-{
- UKW_DEVICE devices[MAX_DEVICE_COUNT];
- struct discovered_devs *new_devices = *discdevs;
- DWORD count = 0, i;
- struct libusb_device *dev = NULL;
- unsigned char bus_addr, dev_addr;
- unsigned long session_id;
- BOOL success;
- DWORD release_list_offset = 0;
- int r = LIBUSB_SUCCESS;
-
- success = UkwGetDeviceList(driver_handle, devices, MAX_DEVICE_COUNT, &count);
- if (!success) {
- int libusbErr = translate_driver_error(GetLastError());
- usbi_err(ctx, "could not get devices: %s", windows_error_str(0));
- return libusbErr;
- }
-
- for (i = 0; i < count; ++i) {
- release_list_offset = i;
- success = UkwGetDeviceAddress(devices[i], &bus_addr, &dev_addr, &session_id);
- if (!success) {
- r = translate_driver_error(GetLastError());
- usbi_err(ctx, "could not get device address for %u: %s", (unsigned int)i, windows_error_str(0));
- goto err_out;
- }
-
- dev = usbi_get_device_by_session_id(ctx, session_id);
- if (dev) {
- usbi_dbg("using existing device for %u/%u (session %lu)",
- bus_addr, dev_addr, session_id);
- // Release just this element in the device list (as we already hold a
- // reference to it).
- UkwReleaseDeviceList(driver_handle, &devices[i], 1);
- release_list_offset++;
- } else {
- usbi_dbg("allocating new device for %u/%u (session %lu)",
- bus_addr, dev_addr, session_id);
- dev = usbi_alloc_device(ctx, session_id);
- if (!dev) {
- r = LIBUSB_ERROR_NO_MEM;
- goto err_out;
- }
-
- r = init_device(dev, devices[i], bus_addr, dev_addr);
- if (r < 0)
- goto err_out;
-
- r = usbi_sanitize_device(dev);
- if (r < 0)
- goto err_out;
- }
-
- new_devices = discovered_devs_append(new_devices, dev);
- if (!new_devices) {
- r = LIBUSB_ERROR_NO_MEM;
- goto err_out;
- }
-
- libusb_unref_device(dev);
- }
-
- *discdevs = new_devices;
- return r;
-err_out:
- *discdevs = new_devices;
- libusb_unref_device(dev);
- // Release the remainder of the unprocessed device list.
- // The devices added to new_devices already will still be passed up to libusb,
- // which can dispose of them at its leisure.
- UkwReleaseDeviceList(driver_handle, &devices[release_list_offset], count - release_list_offset);
- return r;
-}
-
-static int wince_open(struct libusb_device_handle *handle)
-{
- // Nothing to do to open devices as a handle to it has
- // been retrieved by wince_get_device_list
- return LIBUSB_SUCCESS;
-}
-
-static void wince_close(struct libusb_device_handle *handle)
-{
- // Nothing to do as wince_open does nothing.
-}
-
-static int wince_get_device_descriptor(
- struct libusb_device *device,
- unsigned char *buffer, int *host_endian)
-{
- struct wince_device_priv *priv = _device_priv(device);
-
- *host_endian = 1;
- memcpy(buffer, &priv->desc, DEVICE_DESC_LENGTH);
- return LIBUSB_SUCCESS;
-}
-
-static int wince_get_active_config_descriptor(
- struct libusb_device *device,
- unsigned char *buffer, size_t len, int *host_endian)
-{
- struct wince_device_priv *priv = _device_priv(device);
- DWORD actualSize = len;
-
- *host_endian = 0;
- if (!UkwGetConfigDescriptor(priv->dev, UKW_ACTIVE_CONFIGURATION, buffer, len, &actualSize))
- return translate_driver_error(GetLastError());
-
- return actualSize;
-}
-
-static int wince_get_config_descriptor(
- struct libusb_device *device,
- uint8_t config_index,
- unsigned char *buffer, size_t len, int *host_endian)
-{
- struct wince_device_priv *priv = _device_priv(device);
- DWORD actualSize = len;
-
- *host_endian = 0;
- if (!UkwGetConfigDescriptor(priv->dev, config_index, buffer, len, &actualSize))
- return translate_driver_error(GetLastError());
-
- return actualSize;
-}
-
-static int wince_get_configuration(
- struct libusb_device_handle *handle,
- int *config)
-{
- struct wince_device_priv *priv = _device_priv(handle->dev);
- UCHAR cv = 0;
-
- if (!UkwGetConfig(priv->dev, &cv))
- return translate_driver_error(GetLastError());
-
- (*config) = cv;
- return LIBUSB_SUCCESS;
-}
-
-static int wince_set_configuration(
- struct libusb_device_handle *handle,
- int config)
-{
- struct wince_device_priv *priv = _device_priv(handle->dev);
- // Setting configuration 0 places the device in Address state.
- // This should correspond to the "unconfigured state" required by
- // libusb when the specified configuration is -1.
- UCHAR cv = (config < 0) ? 0 : config;
- if (!UkwSetConfig(priv->dev, cv))
- return translate_driver_error(GetLastError());
-
- return LIBUSB_SUCCESS;
-}
-
-static int wince_claim_interface(
- struct libusb_device_handle *handle,
- int interface_number)
-{
- struct wince_device_priv *priv = _device_priv(handle->dev);
-
- if (!UkwClaimInterface(priv->dev, interface_number))
- return translate_driver_error(GetLastError());
-
- return LIBUSB_SUCCESS;
-}
-
-static int wince_release_interface(
- struct libusb_device_handle *handle,
- int interface_number)
-{
- struct wince_device_priv *priv = _device_priv(handle->dev);
-
- if (!UkwSetInterfaceAlternateSetting(priv->dev, interface_number, 0))
- return translate_driver_error(GetLastError());
-
- if (!UkwReleaseInterface(priv->dev, interface_number))
- return translate_driver_error(GetLastError());
-
- return LIBUSB_SUCCESS;
-}
-
-static int wince_set_interface_altsetting(
- struct libusb_device_handle *handle,
- int interface_number, int altsetting)
-{
- struct wince_device_priv *priv = _device_priv(handle->dev);
-
- if (!UkwSetInterfaceAlternateSetting(priv->dev, interface_number, altsetting))
- return translate_driver_error(GetLastError());
-
- return LIBUSB_SUCCESS;
-}
-
-static int wince_clear_halt(
- struct libusb_device_handle *handle,
- unsigned char endpoint)
-{
- struct wince_device_priv *priv = _device_priv(handle->dev);
-
- if (!UkwClearHaltHost(priv->dev, endpoint))
- return translate_driver_error(GetLastError());
-
- if (!UkwClearHaltDevice(priv->dev, endpoint))
- return translate_driver_error(GetLastError());
-
- return LIBUSB_SUCCESS;
-}
-
-static int wince_reset_device(
- struct libusb_device_handle *handle)
-{
- struct wince_device_priv *priv = _device_priv(handle->dev);
-
- if (!UkwResetDevice(priv->dev))
- return translate_driver_error(GetLastError());
-
- return LIBUSB_SUCCESS;
-}
-
-static int wince_kernel_driver_active(
- struct libusb_device_handle *handle,
- int interface_number)
-{
- struct wince_device_priv *priv = _device_priv(handle->dev);
- BOOL result = FALSE;
-
- if (!UkwKernelDriverActive(priv->dev, interface_number, &result))
- return translate_driver_error(GetLastError());
-
- return result ? 1 : 0;
-}
-
-static int wince_detach_kernel_driver(
- struct libusb_device_handle *handle,
- int interface_number)
-{
- struct wince_device_priv *priv = _device_priv(handle->dev);
-
- if (!UkwDetachKernelDriver(priv->dev, interface_number))
- return translate_driver_error(GetLastError());
-
- return LIBUSB_SUCCESS;
-}
-
-static int wince_attach_kernel_driver(
- struct libusb_device_handle *handle,
- int interface_number)
-{
- struct wince_device_priv *priv = _device_priv(handle->dev);
-
- if (!UkwAttachKernelDriver(priv->dev, interface_number))
- return translate_driver_error(GetLastError());
-
- return LIBUSB_SUCCESS;
-}
-
-static void wince_destroy_device(struct libusb_device *dev)
-{
- struct wince_device_priv *priv = _device_priv(dev);
-
- UkwReleaseDeviceList(driver_handle, &priv->dev, 1);
-}
-
-static void wince_clear_transfer_priv(struct usbi_transfer *itransfer)
-{
- struct wince_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer);
-
- usbi_close(transfer_priv->pollable_fd.fd);
- transfer_priv->pollable_fd = INVALID_WINFD;
-}
-
-static int wince_cancel_transfer(struct usbi_transfer *itransfer)
-{
- struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct wince_device_priv *priv = _device_priv(transfer->dev_handle->dev);
- struct wince_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer);
-
- if (!UkwCancelTransfer(priv->dev, transfer_priv->pollable_fd.overlapped, UKW_TF_NO_WAIT))
- return translate_driver_error(GetLastError());
-
- return LIBUSB_SUCCESS;
-}
-
-static int wince_submit_control_or_bulk_transfer(struct usbi_transfer *itransfer)
-{
- struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct libusb_context *ctx = DEVICE_CTX(transfer->dev_handle->dev);
- struct wince_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer);
- struct wince_device_priv *priv = _device_priv(transfer->dev_handle->dev);
- BOOL direction_in, ret;
- struct winfd wfd;
- DWORD flags;
- PUKW_CONTROL_HEADER setup = NULL;
- const BOOL control_transfer = transfer->type == LIBUSB_TRANSFER_TYPE_CONTROL;
- int r;
-
- if (control_transfer) {
- setup = (PUKW_CONTROL_HEADER) transfer->buffer;
- direction_in = setup->bmRequestType & LIBUSB_ENDPOINT_IN;
- } else {
- direction_in = transfer->endpoint & LIBUSB_ENDPOINT_IN;
- }
- flags = direction_in ? UKW_TF_IN_TRANSFER : UKW_TF_OUT_TRANSFER;
- flags |= UKW_TF_SHORT_TRANSFER_OK;
-
- wfd = usbi_create_fd();
- if (wfd.fd < 0)
- return LIBUSB_ERROR_NO_MEM;
-
- r = usbi_add_pollfd(ctx, wfd.fd, direction_in ? POLLIN : POLLOUT);
- if (r) {
- usbi_close(wfd.fd);
- return r;
- }
-
- transfer_priv->pollable_fd = wfd;
-
- if (control_transfer) {
- // Split out control setup header and data buffer
- DWORD bufLen = transfer->length - sizeof(UKW_CONTROL_HEADER);
- PVOID buf = (PVOID) &transfer->buffer[sizeof(UKW_CONTROL_HEADER)];
-
- ret = UkwIssueControlTransfer(priv->dev, flags, setup, buf, bufLen, &transfer->actual_length, wfd.overlapped);
- } else {
- ret = UkwIssueBulkTransfer(priv->dev, flags, transfer->endpoint, transfer->buffer,
- transfer->length, &transfer->actual_length, wfd.overlapped);
- }
-
- if (!ret) {
- int libusbErr = translate_driver_error(GetLastError());
- usbi_err(ctx, "UkwIssue%sTransfer failed: error %u",
- control_transfer ? "Control" : "Bulk", (unsigned int)GetLastError());
- usbi_remove_pollfd(ctx, wfd.fd);
- usbi_close(wfd.fd);
- transfer_priv->pollable_fd = INVALID_WINFD;
- return libusbErr;
- }
-
-
- return LIBUSB_SUCCESS;
-}
-
-static int wince_submit_transfer(struct usbi_transfer *itransfer)
-{
- struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
-
- switch (transfer->type) {
- case LIBUSB_TRANSFER_TYPE_CONTROL:
- case LIBUSB_TRANSFER_TYPE_BULK:
- case LIBUSB_TRANSFER_TYPE_INTERRUPT:
- return wince_submit_control_or_bulk_transfer(itransfer);
- case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
- case LIBUSB_TRANSFER_TYPE_BULK_STREAM:
- return LIBUSB_ERROR_NOT_SUPPORTED;
- default:
- usbi_err(TRANSFER_CTX(transfer), "unknown endpoint type %d", transfer->type);
- return LIBUSB_ERROR_INVALID_PARAM;
- }
-}
-
-static void wince_transfer_callback(
- struct usbi_transfer *itransfer,
- uint32_t io_result, uint32_t io_size)
-{
- struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct wince_transfer_priv *transfer_priv = (struct wince_transfer_priv*)usbi_transfer_get_os_priv(itransfer);
- struct wince_device_priv *priv = _device_priv(transfer->dev_handle->dev);
- int status;
-
- usbi_dbg("handling I/O completion with errcode %u", io_result);
-
- if (io_result == ERROR_NOT_SUPPORTED &&
- transfer->type != LIBUSB_TRANSFER_TYPE_CONTROL) {
- /* For functional stalls, the WinCE USB layer (and therefore the USB Kernel Wrapper
- * Driver) will report USB_ERROR_STALL/ERROR_NOT_SUPPORTED in situations where the
- * endpoint isn't actually stalled.
- *
- * One example of this is that some devices will occasionally fail to reply to an IN
- * token. The WinCE USB layer carries on with the transaction until it is completed
- * (or cancelled) but then completes it with USB_ERROR_STALL.
- *
- * This code therefore needs to confirm that there really is a stall error, by both
- * checking the pipe status and requesting the endpoint status from the device.
- */
- BOOL halted = FALSE;
- usbi_dbg("checking I/O completion with errcode ERROR_NOT_SUPPORTED is really a stall");
- if (UkwIsPipeHalted(priv->dev, transfer->endpoint, &halted)) {
- /* Pipe status retrieved, so now request endpoint status by sending a GET_STATUS
- * control request to the device. This is done synchronously, which is a bit
- * naughty, but this is a special corner case.
- */
- WORD wStatus = 0;
- DWORD written = 0;
- UKW_CONTROL_HEADER ctrlHeader;
- ctrlHeader.bmRequestType = LIBUSB_REQUEST_TYPE_STANDARD |
- LIBUSB_ENDPOINT_IN | LIBUSB_RECIPIENT_ENDPOINT;
- ctrlHeader.bRequest = LIBUSB_REQUEST_GET_STATUS;
- ctrlHeader.wValue = 0;
- ctrlHeader.wIndex = transfer->endpoint;
- ctrlHeader.wLength = sizeof(wStatus);
- if (UkwIssueControlTransfer(priv->dev,
- UKW_TF_IN_TRANSFER | UKW_TF_SEND_TO_ENDPOINT,
- &ctrlHeader, &wStatus, sizeof(wStatus), &written, NULL)) {
- if (written == sizeof(wStatus) &&
- (wStatus & STATUS_HALT_FLAG) == 0) {
- if (!halted || UkwClearHaltHost(priv->dev, transfer->endpoint)) {
- usbi_dbg("Endpoint doesn't appear to be stalled, overriding error with success");
- io_result = ERROR_SUCCESS;
- } else {
- usbi_dbg("Endpoint doesn't appear to be stalled, but the host is halted, changing error");
- io_result = ERROR_IO_DEVICE;
- }
- }
- }
- }
- }
-
- switch(io_result) {
- case ERROR_SUCCESS:
- itransfer->transferred += io_size;
- status = LIBUSB_TRANSFER_COMPLETED;
- break;
- case ERROR_CANCELLED:
- usbi_dbg("detected transfer cancel");
- status = LIBUSB_TRANSFER_CANCELLED;
- break;
- case ERROR_NOT_SUPPORTED:
- case ERROR_GEN_FAILURE:
- usbi_dbg("detected endpoint stall");
- status = LIBUSB_TRANSFER_STALL;
- break;
- case ERROR_SEM_TIMEOUT:
- usbi_dbg("detected semaphore timeout");
- status = LIBUSB_TRANSFER_TIMED_OUT;
- break;
- case ERROR_OPERATION_ABORTED:
- usbi_dbg("detected operation aborted");
- status = LIBUSB_TRANSFER_CANCELLED;
- break;
- default:
- usbi_err(ITRANSFER_CTX(itransfer), "detected I/O error: %s", windows_error_str(io_result));
- status = LIBUSB_TRANSFER_ERROR;
- break;
- }
-
- wince_clear_transfer_priv(itransfer);
- if (status == LIBUSB_TRANSFER_CANCELLED)
- usbi_handle_transfer_cancellation(itransfer);
- else
- usbi_handle_transfer_completion(itransfer, (enum libusb_transfer_status)status);
-}
-
-static void wince_handle_callback(
- struct usbi_transfer *itransfer,
- uint32_t io_result, uint32_t io_size)
-{
- struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
-
- switch (transfer->type) {
- case LIBUSB_TRANSFER_TYPE_CONTROL:
- case LIBUSB_TRANSFER_TYPE_BULK:
- case LIBUSB_TRANSFER_TYPE_INTERRUPT:
- case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
- wince_transfer_callback (itransfer, io_result, io_size);
- break;
- case LIBUSB_TRANSFER_TYPE_BULK_STREAM:
- break;
- default:
- usbi_err(ITRANSFER_CTX(itransfer), "unknown endpoint type %d", transfer->type);
- }
-}
-
-static int wince_handle_events(
- struct libusb_context *ctx,
- struct pollfd *fds, POLL_NFDS_TYPE nfds, int num_ready)
-{
- struct wince_transfer_priv* transfer_priv = NULL;
- POLL_NFDS_TYPE i = 0;
- BOOL found = FALSE;
- struct usbi_transfer *itransfer;
- DWORD io_size, io_result;
- int r = LIBUSB_SUCCESS;
-
- usbi_mutex_lock(&ctx->open_devs_lock);
- for (i = 0; i < nfds && num_ready > 0; i++) {
-
- usbi_dbg("checking fd %d with revents = %04x", fds[i].fd, fds[i].revents);
-
- if (!fds[i].revents)
- continue;
-
- num_ready--;
-
- // Because a Windows OVERLAPPED is used for poll emulation,
- // a pollable fd is created and stored with each transfer
- usbi_mutex_lock(&ctx->flying_transfers_lock);
- list_for_each_entry(itransfer, &ctx->flying_transfers, list, struct usbi_transfer) {
- transfer_priv = usbi_transfer_get_os_priv(itransfer);
- if (transfer_priv->pollable_fd.fd == fds[i].fd) {
- found = TRUE;
- break;
- }
- }
- usbi_mutex_unlock(&ctx->flying_transfers_lock);
-
- if (found && HasOverlappedIoCompleted(transfer_priv->pollable_fd.overlapped)) {
- io_result = (DWORD)transfer_priv->pollable_fd.overlapped->Internal;
- io_size = (DWORD)transfer_priv->pollable_fd.overlapped->InternalHigh;
- usbi_remove_pollfd(ctx, transfer_priv->pollable_fd.fd);
- // let handle_callback free the event using the transfer wfd
- // If you don't use the transfer wfd, you run a risk of trying to free a
- // newly allocated wfd that took the place of the one from the transfer.
- wince_handle_callback(itransfer, io_result, io_size);
- } else if (found) {
- usbi_err(ctx, "matching transfer for fd %d has not completed", fds[i]);
- r = LIBUSB_ERROR_OTHER;
- break;
- } else {
- usbi_err(ctx, "could not find a matching transfer for fd %d", fds[i]);
- r = LIBUSB_ERROR_NOT_FOUND;
- break;
- }
- }
- usbi_mutex_unlock(&ctx->open_devs_lock);
-
- return r;
-}
-
-/*
- * Monotonic and real time functions
- */
-static int wince_clock_gettime(int clk_id, struct timespec *tp)
-{
- LARGE_INTEGER hires_counter;
- ULARGE_INTEGER rtime;
- FILETIME filetime;
- SYSTEMTIME st;
-
- switch(clk_id) {
- case USBI_CLOCK_MONOTONIC:
- if (hires_frequency != 0 && QueryPerformanceCounter(&hires_counter)) {
- tp->tv_sec = (long)(hires_counter.QuadPart / hires_frequency);
- tp->tv_nsec = (long)(((hires_counter.QuadPart % hires_frequency) / 1000) * hires_ticks_to_ps);
- return LIBUSB_SUCCESS;
- }
- // Fall through and return real-time if monotonic read failed or was not detected @ init
- case USBI_CLOCK_REALTIME:
- // We follow http://msdn.microsoft.com/en-us/library/ms724928%28VS.85%29.aspx
- // with a predef epoch time to have an epoch that starts at 1970.01.01 00:00
- // Note however that our resolution is bounded by the Windows system time
- // functions and is at best of the order of 1 ms (or, usually, worse)
- GetSystemTime(&st);
- SystemTimeToFileTime(&st, &filetime);
- rtime.LowPart = filetime.dwLowDateTime;
- rtime.HighPart = filetime.dwHighDateTime;
- rtime.QuadPart -= EPOCH_TIME;
- tp->tv_sec = (long)(rtime.QuadPart / 10000000);
- tp->tv_nsec = (long)((rtime.QuadPart % 10000000)*100);
- return LIBUSB_SUCCESS;
- default:
- return LIBUSB_ERROR_INVALID_PARAM;
- }
-}
-
-const struct usbi_os_backend usbi_backend = {
- "Windows CE",
- 0,
- wince_init,
- wince_exit,
- NULL, /* set_option() */
-
- wince_get_device_list,
- NULL, /* hotplug_poll */
- wince_open,
- wince_close,
-
- wince_get_device_descriptor,
- wince_get_active_config_descriptor,
- wince_get_config_descriptor,
- NULL, /* get_config_descriptor_by_value() */
-
- wince_get_configuration,
- wince_set_configuration,
- wince_claim_interface,
- wince_release_interface,
-
- wince_set_interface_altsetting,
- wince_clear_halt,
- wince_reset_device,
-
- NULL, /* alloc_streams */
- NULL, /* free_streams */
-
- NULL, /* dev_mem_alloc() */
- NULL, /* dev_mem_free() */
-
- wince_kernel_driver_active,
- wince_detach_kernel_driver,
- wince_attach_kernel_driver,
-
- wince_destroy_device,
-
- wince_submit_transfer,
- wince_cancel_transfer,
- wince_clear_transfer_priv,
-
- wince_handle_events,
- NULL, /* handle_transfer_completion() */
-
- wince_clock_gettime,
- 0,
- sizeof(struct wince_device_priv),
- 0,
- sizeof(struct wince_transfer_priv),
-};
diff --git a/libusb/os/wince_usb.h b/libusb/os/wince_usb.h
deleted file mode 100644
index edcb9fc..0000000
--- a/libusb/os/wince_usb.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Windows CE backend for libusb 1.0
- * Copyright © 2011-2013 RealVNC Ltd.
- * Portions taken from Windows backend, which is
- * Copyright © 2009-2010 Pete Batard <pbatard@gmail.com>
- * With contributions from Michael Plante, Orin Eman et al.
- * Parts of this code adapted from libusb-win32-v1 by Stephan Meyer
- * Major code testing contribution by Xiaofan Chen
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-#pragma once
-
-#include "windows_common.h"
-
-#include <windows.h>
-#include "poll_windows.h"
-
-#define MAX_DEVICE_COUNT 256
-
-// This is a modified dump of the types in the ceusbkwrapper.h library header
-// with functions transformed into extern pointers.
-//
-// This backend dynamically loads ceusbkwrapper.dll and doesn't include
-// ceusbkwrapper.h directly to simplify the build process. The kernel
-// side wrapper driver is built using the platform image build tools,
-// which makes it difficult to reference directly from the libusb build
-// system.
-struct UKW_DEVICE_PRIV;
-typedef struct UKW_DEVICE_PRIV *UKW_DEVICE;
-typedef UKW_DEVICE *PUKW_DEVICE, *LPUKW_DEVICE;
-
-typedef struct {
- UINT8 bLength;
- UINT8 bDescriptorType;
- UINT16 bcdUSB;
- UINT8 bDeviceClass;
- UINT8 bDeviceSubClass;
- UINT8 bDeviceProtocol;
- UINT8 bMaxPacketSize0;
- UINT16 idVendor;
- UINT16 idProduct;
- UINT16 bcdDevice;
- UINT8 iManufacturer;
- UINT8 iProduct;
- UINT8 iSerialNumber;
- UINT8 bNumConfigurations;
-} UKW_DEVICE_DESCRIPTOR, *PUKW_DEVICE_DESCRIPTOR, *LPUKW_DEVICE_DESCRIPTOR;
-
-typedef struct {
- UINT8 bmRequestType;
- UINT8 bRequest;
- UINT16 wValue;
- UINT16 wIndex;
- UINT16 wLength;
-} UKW_CONTROL_HEADER, *PUKW_CONTROL_HEADER, *LPUKW_CONTROL_HEADER;
-
-// Collection of flags which can be used when issuing transfer requests
-/* Indicates that the transfer direction is 'in' */
-#define UKW_TF_IN_TRANSFER 0x00000001
-/* Indicates that the transfer direction is 'out' */
-#define UKW_TF_OUT_TRANSFER 0x00000000
-/* Specifies that the transfer should complete as soon as possible,
- * even if no OVERLAPPED structure has been provided. */
-#define UKW_TF_NO_WAIT 0x00000100
-/* Indicates that transfers shorter than the buffer are ok */
-#define UKW_TF_SHORT_TRANSFER_OK 0x00000200
-#define UKW_TF_SEND_TO_DEVICE 0x00010000
-#define UKW_TF_SEND_TO_INTERFACE 0x00020000
-#define UKW_TF_SEND_TO_ENDPOINT 0x00040000
-/* Don't block when waiting for memory allocations */
-#define UKW_TF_DONT_BLOCK_FOR_MEM 0x00080000
-
-/* Value to use when dealing with configuration values, such as UkwGetConfigDescriptor,
- * to specify the currently active configuration for the device. */
-#define UKW_ACTIVE_CONFIGURATION -1
-
-DLL_DECLARE_HANDLE(ceusbkwrapper);
-DLL_DECLARE_FUNC(WINAPI, HANDLE, UkwOpenDriver, ());
-DLL_DECLARE_FUNC(WINAPI, BOOL, UkwGetDeviceList, (HANDLE, LPUKW_DEVICE, DWORD, LPDWORD));
-DLL_DECLARE_FUNC(WINAPI, void, UkwReleaseDeviceList, (HANDLE, LPUKW_DEVICE, DWORD));
-DLL_DECLARE_FUNC(WINAPI, BOOL, UkwGetDeviceAddress, (UKW_DEVICE, unsigned char*, unsigned char*, unsigned long*));
-DLL_DECLARE_FUNC(WINAPI, BOOL, UkwGetDeviceDescriptor, (UKW_DEVICE, LPUKW_DEVICE_DESCRIPTOR));
-DLL_DECLARE_FUNC(WINAPI, BOOL, UkwGetConfigDescriptor, (UKW_DEVICE, DWORD, LPVOID, DWORD, LPDWORD));
-DLL_DECLARE_FUNC(WINAPI, void, UkwCloseDriver, (HANDLE));
-DLL_DECLARE_FUNC(WINAPI, BOOL, UkwCancelTransfer, (UKW_DEVICE, LPOVERLAPPED, DWORD));
-DLL_DECLARE_FUNC(WINAPI, BOOL, UkwIssueControlTransfer, (UKW_DEVICE, DWORD, LPUKW_CONTROL_HEADER, LPVOID, DWORD, LPDWORD, LPOVERLAPPED));
-DLL_DECLARE_FUNC(WINAPI, BOOL, UkwClaimInterface, (UKW_DEVICE, DWORD));
-DLL_DECLARE_FUNC(WINAPI, BOOL, UkwReleaseInterface, (UKW_DEVICE, DWORD));
-DLL_DECLARE_FUNC(WINAPI, BOOL, UkwSetInterfaceAlternateSetting, (UKW_DEVICE, DWORD, DWORD));
-DLL_DECLARE_FUNC(WINAPI, BOOL, UkwClearHaltHost, (UKW_DEVICE, UCHAR));
-DLL_DECLARE_FUNC(WINAPI, BOOL, UkwClearHaltDevice, (UKW_DEVICE, UCHAR));
-DLL_DECLARE_FUNC(WINAPI, BOOL, UkwGetConfig, (UKW_DEVICE, PUCHAR));
-DLL_DECLARE_FUNC(WINAPI, BOOL, UkwSetConfig, (UKW_DEVICE, UCHAR));
-DLL_DECLARE_FUNC(WINAPI, BOOL, UkwResetDevice, (UKW_DEVICE));
-DLL_DECLARE_FUNC(WINAPI, BOOL, UkwKernelDriverActive, (UKW_DEVICE, DWORD, PBOOL));
-DLL_DECLARE_FUNC(WINAPI, BOOL, UkwAttachKernelDriver, (UKW_DEVICE, DWORD));
-DLL_DECLARE_FUNC(WINAPI, BOOL, UkwDetachKernelDriver, (UKW_DEVICE, DWORD));
-DLL_DECLARE_FUNC(WINAPI, BOOL, UkwIssueBulkTransfer, (UKW_DEVICE, DWORD, UCHAR, LPVOID, DWORD, LPDWORD, LPOVERLAPPED));
-DLL_DECLARE_FUNC(WINAPI, BOOL, UkwIsPipeHalted, (UKW_DEVICE, UCHAR, LPBOOL));
-
-// Used to determine if an endpoint status really is halted on a failed transfer.
-#define STATUS_HALT_FLAG 0x1
-
-struct wince_device_priv {
- UKW_DEVICE dev;
- UKW_DEVICE_DESCRIPTOR desc;
-};
-
-struct wince_transfer_priv {
- struct winfd pollable_fd;
- uint8_t interface_number;
-};
-
diff --git a/libusb/os/windows_common.c b/libusb/os/windows_common.c
new file mode 100644
index 0000000..119ed49
--- /dev/null
+++ b/libusb/os/windows_common.c
@@ -0,0 +1,886 @@
+/*
+ * windows backend for libusb 1.0
+ * Copyright © 2009-2012 Pete Batard <pete@akeo.ie>
+ * With contributions from Michael Plante, Orin Eman et al.
+ * Parts of this code adapted from libusb-win32-v1 by Stephan Meyer
+ * HID Reports IOCTLs inspired from HIDAPI by Alan Ott, Signal 11 Software
+ * Hash table functions adapted from glibc, by Ulrich Drepper et al.
+ * Major code testing contribution by Xiaofan Chen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <config.h>
+
+#include <process.h>
+#include <stdio.h>
+
+#include "libusbi.h"
+#include "windows_common.h"
+
+#define EPOCH_TIME UINT64_C(116444736000000000) // 1970.01.01 00:00:000 in MS Filetime
+
+#define STATUS_SUCCESS ((ULONG_PTR)0UL)
+
+// Public
+enum windows_version windows_version = WINDOWS_UNDEFINED;
+
+// Global variables for init/exit
+static unsigned int init_count;
+static bool usbdk_available;
+
+/*
+* Converts a windows error to human readable string
+* uses retval as errorcode, or, if 0, use GetLastError()
+*/
+#if defined(ENABLE_LOGGING)
+const char *windows_error_str(DWORD error_code)
+{
+ static char err_string[256];
+
+ DWORD size;
+ int len;
+
+ if (error_code == 0)
+ error_code = GetLastError();
+
+ len = sprintf(err_string, "[%lu] ", ULONG_CAST(error_code));
+
+ // Translate codes returned by SetupAPI. The ones we are dealing with are either
+ // in 0x0000xxxx or 0xE000xxxx and can be distinguished from standard error codes.
+ // See http://msdn.microsoft.com/en-us/library/windows/hardware/ff545011.aspx
+ switch (error_code & 0xE0000000) {
+ case 0:
+ error_code = HRESULT_FROM_WIN32(error_code); // Still leaves ERROR_SUCCESS unmodified
+ break;
+ case 0xE0000000:
+ error_code = 0x80000000 | (FACILITY_SETUPAPI << 16) | (error_code & 0x0000FFFF);
+ break;
+ default:
+ break;
+ }
+
+ size = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ &err_string[len], sizeof(err_string) - len, NULL);
+ if (size == 0) {
+ DWORD format_error = GetLastError();
+ if (format_error)
+ snprintf(err_string, sizeof(err_string),
+ "Windows error code %lu (FormatMessage error code %lu)",
+ ULONG_CAST(error_code), ULONG_CAST(format_error));
+ else
+ snprintf(err_string, sizeof(err_string), "Unknown error code %lu",
+ ULONG_CAST(error_code));
+ } else {
+ // Remove CRLF from end of message, if present
+ size_t pos = len + size - 2;
+ if (err_string[pos] == '\r')
+ err_string[pos] = '\0';
+ }
+
+ return err_string;
+}
+#endif
+
+/*
+ * Dynamically loads a DLL from the Windows system directory. Unlike the
+ * LoadLibraryA() function, this function will not search through any
+ * directories to try and find the library.
+ */
+HMODULE load_system_library(struct libusb_context *ctx, const char *name)
+{
+ char library_path[MAX_PATH];
+ char *filename_start;
+ UINT length;
+
+ length = GetSystemDirectoryA(library_path, sizeof(library_path));
+ if ((length == 0) || (length >= (UINT)sizeof(library_path))) {
+ usbi_err(ctx, "program assertion failed - could not get system directory");
+ return NULL;
+ }
+
+ filename_start = library_path + length;
+ // Append '\' + name + ".dll" + NUL
+ length += 1 + (UINT)strlen(name) + 4 + 1;
+ if (length >= (UINT)sizeof(library_path)) {
+ usbi_err(ctx, "program assertion failed - library path buffer overflow");
+ return NULL;
+ }
+
+ sprintf(filename_start, "\\%s.dll", name);
+ return LoadLibraryA(library_path);
+}
+
+/* Hash table functions - modified From glibc 2.3.2:
+ [Aho,Sethi,Ullman] Compilers: Principles, Techniques and Tools, 1986
+ [Knuth] The Art of Computer Programming, part 3 (6.4) */
+
+#define HTAB_SIZE 1021UL // *MUST* be a prime number!!
+
+typedef struct htab_entry {
+ unsigned long used;
+ char *str;
+} htab_entry;
+
+static htab_entry *htab_table;
+static usbi_mutex_t htab_mutex;
+static unsigned long htab_filled;
+
+/* Before using the hash table we must allocate memory for it.
+ We allocate one element more as the found prime number says.
+ This is done for more effective indexing as explained in the
+ comment for the hash function. */
+static bool htab_create(struct libusb_context *ctx)
+{
+ if (htab_table != NULL) {
+ usbi_err(ctx, "program assertion failed - hash table already allocated");
+ return true;
+ }
+
+ // Create a mutex
+ usbi_mutex_init(&htab_mutex);
+
+ usbi_dbg("using %lu entries hash table", HTAB_SIZE);
+ htab_filled = 0;
+
+ // allocate memory and zero out.
+ htab_table = calloc(HTAB_SIZE + 1, sizeof(htab_entry));
+ if (htab_table == NULL) {
+ usbi_err(ctx, "could not allocate space for hash table");
+ return false;
+ }
+
+ return true;
+}
+
+/* After using the hash table it has to be destroyed. */
+static void htab_destroy(void)
+{
+ unsigned long i;
+
+ if (htab_table == NULL)
+ return;
+
+ for (i = 0; i < HTAB_SIZE; i++)
+ free(htab_table[i].str);
+
+ safe_free(htab_table);
+
+ usbi_mutex_destroy(&htab_mutex);
+}
+
+/* This is the search function. It uses double hashing with open addressing.
+ We use a trick to speed up the lookup. The table is created with one
+ more element available. This enables us to use the index zero special.
+ This index will never be used because we store the first hash index in
+ the field used where zero means not used. Every other value means used.
+ The used field can be used as a first fast comparison for equality of
+ the stored and the parameter value. This helps to prevent unnecessary
+ expensive calls of strcmp. */
+unsigned long htab_hash(const char *str)
+{
+ unsigned long hval, hval2;
+ unsigned long idx;
+ unsigned long r = 5381UL;
+ int c;
+ const char *sz = str;
+
+ if (str == NULL)
+ return 0;
+
+ // Compute main hash value (algorithm suggested by Nokia)
+ while ((c = *sz++) != 0)
+ r = ((r << 5) + r) + c;
+ if (r == 0)
+ ++r;
+
+ // compute table hash: simply take the modulus
+ hval = r % HTAB_SIZE;
+ if (hval == 0)
+ ++hval;
+
+ // Try the first index
+ idx = hval;
+
+ // Mutually exclusive access (R/W lock would be better)
+ usbi_mutex_lock(&htab_mutex);
+
+ if (htab_table[idx].used) {
+ if ((htab_table[idx].used == hval) && (strcmp(str, htab_table[idx].str) == 0))
+ goto out_unlock; // existing hash
+
+ usbi_dbg("hash collision ('%s' vs '%s')", str, htab_table[idx].str);
+
+ // Second hash function, as suggested in [Knuth]
+ hval2 = 1UL + hval % (HTAB_SIZE - 2);
+
+ do {
+ // Because size is prime this guarantees to step through all available indexes
+ if (idx <= hval2)
+ idx = HTAB_SIZE + idx - hval2;
+ else
+ idx -= hval2;
+
+ // If we visited all entries leave the loop unsuccessfully
+ if (idx == hval)
+ break;
+
+ // If entry is found use it.
+ if ((htab_table[idx].used == hval) && (strcmp(str, htab_table[idx].str) == 0))
+ goto out_unlock;
+ } while (htab_table[idx].used);
+ }
+
+ // Not found => New entry
+
+ // If the table is full return an error
+ if (htab_filled >= HTAB_SIZE) {
+ usbi_err(NULL, "hash table is full (%lu entries)", HTAB_SIZE);
+ idx = 0UL;
+ goto out_unlock;
+ }
+
+ htab_table[idx].str = _strdup(str);
+ if (htab_table[idx].str == NULL) {
+ usbi_err(NULL, "could not duplicate string for hash table");
+ idx = 0UL;
+ goto out_unlock;
+ }
+
+ htab_table[idx].used = hval;
+ ++htab_filled;
+
+out_unlock:
+ usbi_mutex_unlock(&htab_mutex);
+
+ return idx;
+}
+
+enum libusb_transfer_status usbd_status_to_libusb_transfer_status(USBD_STATUS status)
+{
+ if (USBD_SUCCESS(status))
+ return LIBUSB_TRANSFER_COMPLETED;
+
+ switch (status) {
+ case USBD_STATUS_TIMEOUT:
+ return LIBUSB_TRANSFER_TIMED_OUT;
+ case USBD_STATUS_CANCELED:
+ return LIBUSB_TRANSFER_CANCELLED;
+ case USBD_STATUS_ENDPOINT_HALTED:
+ return LIBUSB_TRANSFER_STALL;
+ case USBD_STATUS_DEVICE_GONE:
+ return LIBUSB_TRANSFER_NO_DEVICE;
+ default:
+ usbi_dbg("USBD_STATUS 0x%08lx translated to LIBUSB_TRANSFER_ERROR", ULONG_CAST(status));
+ return LIBUSB_TRANSFER_ERROR;
+ }
+}
+
+/*
+ * Make a transfer complete synchronously
+ */
+void windows_force_sync_completion(struct usbi_transfer *itransfer, ULONG size)
+{
+ struct windows_transfer_priv *transfer_priv = usbi_get_transfer_priv(itransfer);
+ OVERLAPPED *overlapped = &transfer_priv->overlapped;
+
+ usbi_dbg("transfer %p, length %lu", USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer), ULONG_CAST(size));
+
+ overlapped->Internal = (ULONG_PTR)STATUS_SUCCESS;
+ overlapped->InternalHigh = (ULONG_PTR)size;
+
+ usbi_signal_transfer_completion(itransfer);
+}
+
+/* Windows version detection */
+static BOOL is_x64(void)
+{
+ BOOL ret = FALSE;
+
+ // Detect if we're running a 32 or 64 bit system
+ if (sizeof(uintptr_t) < 8) {
+ IsWow64Process(GetCurrentProcess(), &ret);
+ } else {
+ ret = TRUE;
+ }
+
+ return ret;
+}
+
+static enum windows_version get_windows_version(void)
+{
+ enum windows_version winver;
+ OSVERSIONINFOEXA vi, vi2;
+ unsigned major, minor, version;
+ ULONGLONG major_equal, minor_equal;
+ const char *w, *arch;
+ bool ws;
+
+ memset(&vi, 0, sizeof(vi));
+ vi.dwOSVersionInfoSize = sizeof(vi);
+ if (!GetVersionExA((OSVERSIONINFOA *)&vi)) {
+ memset(&vi, 0, sizeof(vi));
+ vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
+ if (!GetVersionExA((OSVERSIONINFOA *)&vi))
+ return WINDOWS_UNDEFINED;
+ }
+
+ if (vi.dwPlatformId != VER_PLATFORM_WIN32_NT)
+ return WINDOWS_UNDEFINED;
+
+ if ((vi.dwMajorVersion > 6) || ((vi.dwMajorVersion == 6) && (vi.dwMinorVersion >= 2))) {
+ // Starting with Windows 8.1 Preview, GetVersionEx() does no longer report the actual OS version
+ // See: http://msdn.microsoft.com/en-us/library/windows/desktop/dn302074.aspx
+
+ major_equal = VerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL);
+ for (major = vi.dwMajorVersion; major <= 9; major++) {
+ memset(&vi2, 0, sizeof(vi2));
+ vi2.dwOSVersionInfoSize = sizeof(vi2);
+ vi2.dwMajorVersion = major;
+ if (!VerifyVersionInfoA(&vi2, VER_MAJORVERSION, major_equal))
+ continue;
+
+ if (vi.dwMajorVersion < major) {
+ vi.dwMajorVersion = major;
+ vi.dwMinorVersion = 0;
+ }
+
+ minor_equal = VerSetConditionMask(0, VER_MINORVERSION, VER_EQUAL);
+ for (minor = vi.dwMinorVersion; minor <= 9; minor++) {
+ memset(&vi2, 0, sizeof(vi2));
+ vi2.dwOSVersionInfoSize = sizeof(vi2);
+ vi2.dwMinorVersion = minor;
+ if (!VerifyVersionInfoA(&vi2, VER_MINORVERSION, minor_equal))
+ continue;
+
+ vi.dwMinorVersion = minor;
+ break;
+ }
+
+ break;
+ }
+ }
+
+ if ((vi.dwMajorVersion > 0xf) || (vi.dwMinorVersion > 0xf))
+ return WINDOWS_UNDEFINED;
+
+ ws = (vi.wProductType <= VER_NT_WORKSTATION);
+ version = vi.dwMajorVersion << 4 | vi.dwMinorVersion;
+ switch (version) {
+ case 0x50: winver = WINDOWS_2000; w = "2000"; break;
+ case 0x51: winver = WINDOWS_XP; w = "XP"; break;
+ case 0x52: winver = WINDOWS_2003; w = "2003"; break;
+ case 0x60: winver = WINDOWS_VISTA; w = (ws ? "Vista" : "2008"); break;
+ case 0x61: winver = WINDOWS_7; w = (ws ? "7" : "2008_R2"); break;
+ case 0x62: winver = WINDOWS_8; w = (ws ? "8" : "2012"); break;
+ case 0x63: winver = WINDOWS_8_1; w = (ws ? "8.1" : "2012_R2"); break;
+ case 0x64: // Early Windows 10 Insider Previews and Windows Server 2017 Technical Preview 1 used version 6.4
+ case 0xA0: winver = WINDOWS_10; w = (ws ? "10" : "2016"); break;
+ default:
+ if (version < 0x50)
+ return WINDOWS_UNDEFINED;
+ winver = WINDOWS_11_OR_LATER;
+ w = "11 or later";
+ }
+
+ arch = is_x64() ? "64-bit" : "32-bit";
+
+ if (vi.wServicePackMinor)
+ usbi_dbg("Windows %s SP%u.%u %s", w, vi.wServicePackMajor, vi.wServicePackMinor, arch);
+ else if (vi.wServicePackMajor)
+ usbi_dbg("Windows %s SP%u %s", w, vi.wServicePackMajor, arch);
+ else
+ usbi_dbg("Windows %s %s", w, arch);
+
+ return winver;
+}
+
+static unsigned __stdcall windows_iocp_thread(void *arg)
+{
+ struct libusb_context *ctx = arg;
+ struct windows_context_priv *priv = usbi_get_context_priv(ctx);
+ HANDLE iocp = priv->completion_port;
+ DWORD num_bytes;
+ ULONG_PTR completion_key;
+ OVERLAPPED *overlapped;
+ struct windows_transfer_priv *transfer_priv;
+ struct usbi_transfer *itransfer;
+
+ usbi_dbg("I/O completion thread started");
+
+ while (true) {
+ overlapped = NULL;
+ if (!GetQueuedCompletionStatus(iocp, &num_bytes, &completion_key, &overlapped, INFINITE) && (overlapped == NULL)) {
+ usbi_err(ctx, "GetQueuedCompletionStatus failed: %s", windows_error_str(0));
+ break;
+ }
+
+ if (overlapped == NULL) {
+ // Signal to quit
+ if (completion_key != (ULONG_PTR)ctx)
+ usbi_err(ctx, "program assertion failed - overlapped is NULL");
+ break;
+ }
+
+ transfer_priv = container_of(overlapped, struct windows_transfer_priv, overlapped);
+ itransfer = (struct usbi_transfer *)((unsigned char *)transfer_priv + PTR_ALIGN(sizeof(*transfer_priv)));
+ usbi_dbg("transfer %p completed, length %lu",
+ USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer), ULONG_CAST(num_bytes));
+ usbi_signal_transfer_completion(itransfer);
+ }
+
+ usbi_dbg("I/O completion thread exiting");
+
+ return 0;
+}
+
+static int windows_init(struct libusb_context *ctx)
+{
+ struct windows_context_priv *priv = usbi_get_context_priv(ctx);
+ char mutex_name[11 + 8 + 1]; // strlen("libusb_init") + (32-bit hex PID) + '\0'
+ HANDLE mutex;
+ bool winusb_backend_init = false;
+ int r;
+
+ sprintf(mutex_name, "libusb_init%08lX", ULONG_CAST(GetCurrentProcessId() & 0xFFFFFFFFU));
+ mutex = CreateMutexA(NULL, FALSE, mutex_name);
+ if (mutex == NULL) {
+ usbi_err(ctx, "could not create mutex: %s", windows_error_str(0));
+ return LIBUSB_ERROR_NO_MEM;
+ }
+
+ // A successful wait gives this thread ownership of the mutex
+ // => any concurrent wait stalls until the mutex is released
+ if (WaitForSingleObject(mutex, INFINITE) != WAIT_OBJECT_0) {
+ usbi_err(ctx, "failure to access mutex: %s", windows_error_str(0));
+ CloseHandle(mutex);
+ return LIBUSB_ERROR_NO_MEM;
+ }
+
+ // NB: concurrent usage supposes that init calls are equally balanced with
+ // exit calls. If init is called more than exit, we will not exit properly
+ if (++init_count == 1) { // First init?
+ windows_version = get_windows_version();
+ if (windows_version == WINDOWS_UNDEFINED) {
+ usbi_err(ctx, "failed to detect Windows version");
+ r = LIBUSB_ERROR_NOT_SUPPORTED;
+ goto init_exit;
+ } else if (windows_version < WINDOWS_VISTA) {
+ usbi_err(ctx, "Windows version is too old");
+ r = LIBUSB_ERROR_NOT_SUPPORTED;
+ goto init_exit;
+ }
+
+ if (!htab_create(ctx)) {
+ r = LIBUSB_ERROR_NO_MEM;
+ goto init_exit;
+ }
+
+ r = winusb_backend.init(ctx);
+ if (r != LIBUSB_SUCCESS)
+ goto init_exit;
+ winusb_backend_init = true;
+
+ r = usbdk_backend.init(ctx);
+ if (r == LIBUSB_SUCCESS) {
+ usbi_dbg("UsbDk backend is available");
+ usbdk_available = true;
+ } else {
+ usbi_info(ctx, "UsbDk backend is not available");
+ // Do not report this as an error
+ }
+ }
+
+ // By default, new contexts will use the WinUSB backend
+ priv->backend = &winusb_backend;
+
+ r = LIBUSB_ERROR_NO_MEM;
+
+ // Use an I/O completion port to manage all transfers for this context
+ priv->completion_port = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 1);
+ if (priv->completion_port == NULL) {
+ usbi_err(ctx, "failed to create I/O completion port: %s", windows_error_str(0));
+ goto init_exit;
+ }
+
+ // And a dedicated thread to wait for I/O completions
+ priv->completion_port_thread = (HANDLE)_beginthreadex(NULL, 0, windows_iocp_thread, ctx, 0, NULL);
+ if (priv->completion_port_thread == NULL) {
+ usbi_err(ctx, "failed to create I/O completion port thread");
+ CloseHandle(priv->completion_port);
+ goto init_exit;
+ }
+
+ r = LIBUSB_SUCCESS;
+
+init_exit: // Holds semaphore here
+ if ((init_count == 1) && (r != LIBUSB_SUCCESS)) { // First init failed?
+ if (usbdk_available) {
+ usbdk_backend.exit(ctx);
+ usbdk_available = false;
+ }
+ if (winusb_backend_init)
+ winusb_backend.exit(ctx);
+ htab_destroy();
+ --init_count;
+ }
+
+ ReleaseMutex(mutex);
+ CloseHandle(mutex);
+ return r;
+}
+
+static void windows_exit(struct libusb_context *ctx)
+{
+ struct windows_context_priv *priv = usbi_get_context_priv(ctx);
+ char mutex_name[11 + 8 + 1]; // strlen("libusb_init") + (32-bit hex PID) + '\0'
+ HANDLE mutex;
+
+ sprintf(mutex_name, "libusb_init%08lX", ULONG_CAST(GetCurrentProcessId() & 0xFFFFFFFFU));
+ mutex = CreateMutexA(NULL, FALSE, mutex_name);
+ if (mutex == NULL)
+ return;
+
+ // A successful wait gives this thread ownership of the mutex
+ // => any concurrent wait stalls until the mutex is released
+ if (WaitForSingleObject(mutex, INFINITE) != WAIT_OBJECT_0) {
+ usbi_err(ctx, "failed to access mutex: %s", windows_error_str(0));
+ CloseHandle(mutex);
+ return;
+ }
+
+ // A NULL completion status will indicate to the thread that it is time to exit
+ if (!PostQueuedCompletionStatus(priv->completion_port, 0, (ULONG_PTR)ctx, NULL))
+ usbi_err(ctx, "failed to post I/O completion: %s", windows_error_str(0));
+
+ if (WaitForSingleObject(priv->completion_port_thread, INFINITE) == WAIT_FAILED)
+ usbi_err(ctx, "failed to wait for I/O completion port thread: %s", windows_error_str(0));
+
+ CloseHandle(priv->completion_port_thread);
+ CloseHandle(priv->completion_port);
+
+ // Only works if exits and inits are balanced exactly
+ if (--init_count == 0) { // Last exit
+ if (usbdk_available) {
+ usbdk_backend.exit(ctx);
+ usbdk_available = false;
+ }
+ winusb_backend.exit(ctx);
+ htab_destroy();
+ }
+
+ ReleaseMutex(mutex);
+ CloseHandle(mutex);
+}
+
+static int windows_set_option(struct libusb_context *ctx, enum libusb_option option, va_list ap)
+{
+ struct windows_context_priv *priv = usbi_get_context_priv(ctx);
+
+ UNUSED(ap);
+
+ if (option == LIBUSB_OPTION_USE_USBDK) {
+ if (!usbdk_available) {
+ usbi_err(ctx, "UsbDk backend not available");
+ return LIBUSB_ERROR_NOT_FOUND;
+ }
+ usbi_dbg("switching context %p to use UsbDk backend", ctx);
+ priv->backend = &usbdk_backend;
+ return LIBUSB_SUCCESS;
+ }
+
+ return LIBUSB_ERROR_NOT_SUPPORTED;
+}
+
+static int windows_get_device_list(struct libusb_context *ctx, struct discovered_devs **discdevs)
+{
+ struct windows_context_priv *priv = usbi_get_context_priv(ctx);
+ return priv->backend->get_device_list(ctx, discdevs);
+}
+
+static int windows_open(struct libusb_device_handle *dev_handle)
+{
+ struct windows_context_priv *priv = usbi_get_context_priv(HANDLE_CTX(dev_handle));
+ return priv->backend->open(dev_handle);
+}
+
+static void windows_close(struct libusb_device_handle *dev_handle)
+{
+ struct windows_context_priv *priv = usbi_get_context_priv(HANDLE_CTX(dev_handle));
+ priv->backend->close(dev_handle);
+}
+
+static int windows_get_active_config_descriptor(struct libusb_device *dev,
+ void *buffer, size_t len)
+{
+ struct windows_context_priv *priv = usbi_get_context_priv(DEVICE_CTX(dev));
+ return priv->backend->get_active_config_descriptor(dev, buffer, len);
+}
+
+static int windows_get_config_descriptor(struct libusb_device *dev,
+ uint8_t config_index, void *buffer, size_t len)
+{
+ struct windows_context_priv *priv = usbi_get_context_priv(DEVICE_CTX(dev));
+ return priv->backend->get_config_descriptor(dev, config_index, buffer, len);
+}
+
+static int windows_get_config_descriptor_by_value(struct libusb_device *dev,
+ uint8_t bConfigurationValue, void **buffer)
+{
+ struct windows_context_priv *priv = usbi_get_context_priv(DEVICE_CTX(dev));
+ return priv->backend->get_config_descriptor_by_value(dev, bConfigurationValue, buffer);
+}
+
+static int windows_get_configuration(struct libusb_device_handle *dev_handle, uint8_t *config)
+{
+ struct windows_context_priv *priv = usbi_get_context_priv(HANDLE_CTX(dev_handle));
+ return priv->backend->get_configuration(dev_handle, config);
+}
+
+static int windows_set_configuration(struct libusb_device_handle *dev_handle, int config)
+{
+ struct windows_context_priv *priv = usbi_get_context_priv(HANDLE_CTX(dev_handle));
+ if (config == -1)
+ config = 0;
+ return priv->backend->set_configuration(dev_handle, (uint8_t)config);
+}
+
+static int windows_claim_interface(struct libusb_device_handle *dev_handle, uint8_t interface_number)
+{
+ struct windows_context_priv *priv = usbi_get_context_priv(HANDLE_CTX(dev_handle));
+ return priv->backend->claim_interface(dev_handle, interface_number);
+}
+
+static int windows_release_interface(struct libusb_device_handle *dev_handle, uint8_t interface_number)
+{
+ struct windows_context_priv *priv = usbi_get_context_priv(HANDLE_CTX(dev_handle));
+ return priv->backend->release_interface(dev_handle, interface_number);
+}
+
+static int windows_set_interface_altsetting(struct libusb_device_handle *dev_handle,
+ uint8_t interface_number, uint8_t altsetting)
+{
+ struct windows_context_priv *priv = usbi_get_context_priv(HANDLE_CTX(dev_handle));
+ return priv->backend->set_interface_altsetting(dev_handle, interface_number, altsetting);
+}
+
+static int windows_clear_halt(struct libusb_device_handle *dev_handle, unsigned char endpoint)
+{
+ struct windows_context_priv *priv = usbi_get_context_priv(HANDLE_CTX(dev_handle));
+ return priv->backend->clear_halt(dev_handle, endpoint);
+}
+
+static int windows_reset_device(struct libusb_device_handle *dev_handle)
+{
+ struct windows_context_priv *priv = usbi_get_context_priv(HANDLE_CTX(dev_handle));
+ return priv->backend->reset_device(dev_handle);
+}
+
+static void windows_destroy_device(struct libusb_device *dev)
+{
+ struct windows_context_priv *priv = usbi_get_context_priv(DEVICE_CTX(dev));
+ priv->backend->destroy_device(dev);
+}
+
+static int windows_submit_transfer(struct usbi_transfer *itransfer)
+{
+ struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
+ struct libusb_context *ctx = TRANSFER_CTX(transfer);
+ struct windows_context_priv *priv = usbi_get_context_priv(ctx);
+ struct windows_transfer_priv *transfer_priv = usbi_get_transfer_priv(itransfer);
+ int r;
+
+ switch (transfer->type) {
+ case LIBUSB_TRANSFER_TYPE_CONTROL:
+ case LIBUSB_TRANSFER_TYPE_BULK:
+ case LIBUSB_TRANSFER_TYPE_INTERRUPT:
+ case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
+ break;
+ case LIBUSB_TRANSFER_TYPE_BULK_STREAM:
+ usbi_warn(ctx, "bulk stream transfers are not yet supported on this platform");
+ return LIBUSB_ERROR_NOT_SUPPORTED;
+ default:
+ usbi_err(ctx, "unknown endpoint type %d", transfer->type);
+ return LIBUSB_ERROR_INVALID_PARAM;
+ }
+
+ if (transfer_priv->handle != NULL) {
+ usbi_err(ctx, "program assertion failed - transfer HANDLE is not NULL");
+ transfer_priv->handle = NULL;
+ }
+
+ r = priv->backend->submit_transfer(itransfer);
+ if (r != LIBUSB_SUCCESS) {
+ // Always call the backend's clear_transfer_priv() function on failure
+ priv->backend->clear_transfer_priv(itransfer);
+ transfer_priv->handle = NULL;
+ return r;
+ }
+
+ // The backend should set the HANDLE used for each submitted transfer
+ // by calling set_transfer_priv_handle()
+ if (transfer_priv->handle == NULL)
+ usbi_err(ctx, "program assertion failed - transfer HANDLE is NULL after transfer was submitted");
+
+ return r;
+}
+
+static int windows_cancel_transfer(struct usbi_transfer *itransfer)
+{
+ struct windows_context_priv *priv = usbi_get_context_priv(ITRANSFER_CTX(itransfer));
+ struct windows_transfer_priv *transfer_priv = usbi_get_transfer_priv(itransfer);
+
+ // Try CancelIoEx() on the transfer
+ // If that fails, fall back to the backend's cancel_transfer()
+ // function if it is available
+ if (CancelIoEx(transfer_priv->handle, &transfer_priv->overlapped))
+ return LIBUSB_SUCCESS;
+ else if (GetLastError() == ERROR_NOT_FOUND)
+ return LIBUSB_ERROR_NOT_FOUND;
+
+ if (priv->backend->cancel_transfer)
+ return priv->backend->cancel_transfer(itransfer);
+
+ usbi_warn(ITRANSFER_CTX(itransfer), "cancellation not supported for this transfer's driver");
+ return LIBUSB_ERROR_NOT_SUPPORTED;
+}
+
+static int windows_handle_transfer_completion(struct usbi_transfer *itransfer)
+{
+ struct libusb_context *ctx = ITRANSFER_CTX(itransfer);
+ struct windows_context_priv *priv = usbi_get_context_priv(ctx);
+ const struct windows_backend *backend = priv->backend;
+ struct windows_transfer_priv *transfer_priv = usbi_get_transfer_priv(itransfer);
+ enum libusb_transfer_status status, istatus;
+ DWORD result, bytes_transferred;
+
+ if (GetOverlappedResult(transfer_priv->handle, &transfer_priv->overlapped, &bytes_transferred, FALSE))
+ result = NO_ERROR;
+ else
+ result = GetLastError();
+
+ usbi_dbg("handling transfer %p completion with errcode %lu, length %lu",
+ USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer), ULONG_CAST(result), ULONG_CAST(bytes_transferred));
+
+ switch (result) {
+ case NO_ERROR:
+ status = backend->copy_transfer_data(itransfer, bytes_transferred);
+ break;
+ case ERROR_GEN_FAILURE:
+ usbi_dbg("detected endpoint stall");
+ status = LIBUSB_TRANSFER_STALL;
+ break;
+ case ERROR_SEM_TIMEOUT:
+ usbi_dbg("detected semaphore timeout");
+ status = LIBUSB_TRANSFER_TIMED_OUT;
+ break;
+ case ERROR_OPERATION_ABORTED:
+ istatus = backend->copy_transfer_data(itransfer, bytes_transferred);
+ if (istatus != LIBUSB_TRANSFER_COMPLETED)
+ usbi_dbg("failed to copy partial data in aborted operation: %d", (int)istatus);
+
+ usbi_dbg("detected operation aborted");
+ status = LIBUSB_TRANSFER_CANCELLED;
+ break;
+ case ERROR_FILE_NOT_FOUND:
+ case ERROR_DEVICE_NOT_CONNECTED:
+ case ERROR_NO_SUCH_DEVICE:
+ usbi_dbg("detected device removed");
+ status = LIBUSB_TRANSFER_NO_DEVICE;
+ break;
+ default:
+ usbi_err(ctx, "detected I/O error %lu: %s",
+ ULONG_CAST(result), windows_error_str(result));
+ status = LIBUSB_TRANSFER_ERROR;
+ break;
+ }
+
+ transfer_priv->handle = NULL;
+
+ // Backend-specific cleanup
+ backend->clear_transfer_priv(itransfer);
+
+ if (status == LIBUSB_TRANSFER_CANCELLED)
+ return usbi_handle_transfer_cancellation(itransfer);
+ else
+ return usbi_handle_transfer_completion(itransfer, status);
+}
+
+void usbi_get_monotonic_time(struct timespec *tp)
+{
+ static LONG hires_counter_init;
+ static uint64_t hires_ticks_to_ps;
+ static uint64_t hires_frequency;
+ LARGE_INTEGER hires_counter;
+
+ if (InterlockedExchange(&hires_counter_init, 1L) == 0L) {
+ LARGE_INTEGER li_frequency;
+
+ // Microsoft says that the QueryPerformanceFrequency() and
+ // QueryPerformanceCounter() functions always succeed on XP and later
+ QueryPerformanceFrequency(&li_frequency);
+
+ // The hires frequency can go as high as 4 GHz, so we'll use a conversion
+ // to picoseconds to compute the tv_nsecs part
+ hires_frequency = li_frequency.QuadPart;
+ hires_ticks_to_ps = UINT64_C(1000000000000) / hires_frequency;
+ }
+
+ QueryPerformanceCounter(&hires_counter);
+ tp->tv_sec = (long)(hires_counter.QuadPart / hires_frequency);
+ tp->tv_nsec = (long)(((hires_counter.QuadPart % hires_frequency) * hires_ticks_to_ps) / UINT64_C(1000));
+}
+
+// NB: MSVC6 does not support named initializers.
+const struct usbi_os_backend usbi_backend = {
+ "Windows",
+ USBI_CAP_HAS_HID_ACCESS,
+ windows_init,
+ windows_exit,
+ windows_set_option,
+ windows_get_device_list,
+ NULL, /* hotplug_poll */
+ NULL, /* wrap_sys_device */
+ windows_open,
+ windows_close,
+ windows_get_active_config_descriptor,
+ windows_get_config_descriptor,
+ windows_get_config_descriptor_by_value,
+ windows_get_configuration,
+ windows_set_configuration,
+ windows_claim_interface,
+ windows_release_interface,
+ windows_set_interface_altsetting,
+ windows_clear_halt,
+ windows_reset_device,
+ NULL, /* alloc_streams */
+ NULL, /* free_streams */
+ NULL, /* dev_mem_alloc */
+ NULL, /* dev_mem_free */
+ NULL, /* kernel_driver_active */
+ NULL, /* detach_kernel_driver */
+ NULL, /* attach_kernel_driver */
+ windows_destroy_device,
+ windows_submit_transfer,
+ windows_cancel_transfer,
+ NULL, /* clear_transfer_priv */
+ NULL, /* handle_events */
+ windows_handle_transfer_completion,
+ sizeof(struct windows_context_priv),
+ sizeof(union windows_device_priv),
+ sizeof(union windows_device_handle_priv),
+ sizeof(struct windows_transfer_priv),
+};
diff --git a/libusb/os/windows_common.h b/libusb/os/windows_common.h
index b1725c2..0c4b94c 100644
--- a/libusb/os/windows_common.h
+++ b/libusb/os/windows_common.h
@@ -2,9 +2,10 @@
* Windows backend common header for libusb 1.0
*
* This file brings together header code common between
- * the desktop Windows and Windows CE backends.
+ * the desktop Windows backends.
* Copyright © 2012-2013 RealVNC Ltd.
* Copyright © 2009-2012 Pete Batard <pete@akeo.ie>
+ * Copyright © 2014-2020 Chris Dickens <christopher.a.dickens@gmail.com>
* With contributions from Michael Plante, Orin Eman et al.
* Parts of this code adapted from libusb-win32-v1 by Stephan Meyer
* Major code testing contribution by Xiaofan Chen
@@ -24,22 +25,29 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#pragma once
+#ifndef LIBUSB_WINDOWS_COMMON_H
+#define LIBUSB_WINDOWS_COMMON_H
-// Windows API default is uppercase - ugh!
-#if !defined(bool)
-#define bool BOOL
-#endif
-#if !defined(true)
-#define true TRUE
-#endif
-#if !defined(false)
-#define false FALSE
-#endif
+#include <stdbool.h>
-#define EPOCH_TIME UINT64_C(116444736000000000) // 1970.01.01 00:00:000 in MS Filetime
+/*
+ * Workaround for the mess that exists with the DWORD and ULONG types.
+ * Visual Studio unconditionally defines these types as 'unsigned long'
+ * and a long is always 32-bits, even on 64-bit builds. GCC on the other
+ * hand varies the width of a long, matching it to the build. To make
+ * matters worse, the platform headers for these GCC builds define a
+ * DWORD/ULONG to be 'unsigned long' on 32-bit builds and 'unsigned int'
+ * on 64-bit builds. This creates a great deal of warnings for compilers
+ * that support printf format checking since it will never actually be
+ * an unsigned long.
+ */
+#if defined(_MSC_VER)
+#define ULONG_CAST(x) (x)
+#else
+#define ULONG_CAST(x) ((unsigned long)(x))
+#endif
-#if defined(__CYGWIN__ )
+#if defined(__CYGWIN__)
#define _stricmp strcasecmp
#define _strdup strdup
// _beginthreadex is MSVCRT => unavailable for cygwin. Fallback to using CreateThread
@@ -48,47 +56,35 @@
#define safe_free(p) do {if (p != NULL) {free((void *)p); p = NULL;}} while (0)
-#ifndef ARRAYSIZE
-#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
-#endif
-
-#define ERR_BUFFER_SIZE 256
-
/*
* API macros - leveraged from libusb-win32 1.x
*/
-#ifndef _WIN32_WCE
#define DLL_STRINGIFY(s) #s
-#define DLL_LOAD_LIBRARY(name) LoadLibraryA(DLL_STRINGIFY(name))
-#else
-#define DLL_STRINGIFY(s) L#s
-#define DLL_LOAD_LIBRARY(name) LoadLibrary(DLL_STRINGIFY(name))
-#endif
/*
* Macros for handling DLL themselves
*/
#define DLL_HANDLE_NAME(name) __dll_##name##_handle
-#define DLL_DECLARE_HANDLE(name) \
- static HMODULE DLL_HANDLE_NAME(name) = NULL
+#define DLL_DECLARE_HANDLE(name) \
+ static HMODULE DLL_HANDLE_NAME(name)
-#define DLL_GET_HANDLE(name) \
- do { \
- DLL_HANDLE_NAME(name) = DLL_LOAD_LIBRARY(name); \
- if (!DLL_HANDLE_NAME(name)) \
- return FALSE; \
+#define DLL_GET_HANDLE(ctx, name) \
+ do { \
+ DLL_HANDLE_NAME(name) = load_system_library(ctx, \
+ DLL_STRINGIFY(name)); \
+ if (!DLL_HANDLE_NAME(name)) \
+ return false; \
} while (0)
-#define DLL_FREE_HANDLE(name) \
- do { \
- if (DLL_HANDLE_NAME(name)) { \
- FreeLibrary(DLL_HANDLE_NAME(name)); \
- DLL_HANDLE_NAME(name) = NULL; \
- } \
+#define DLL_FREE_HANDLE(name) \
+ do { \
+ if (DLL_HANDLE_NAME(name)) { \
+ FreeLibrary(DLL_HANDLE_NAME(name)); \
+ DLL_HANDLE_NAME(name) = NULL; \
+ } \
} while (0)
-
/*
* Macros for handling functions within a DLL
*/
@@ -96,7 +92,7 @@
#define DLL_DECLARE_FUNC_PREFIXNAME(api, ret, prefixname, name, args) \
typedef ret (api * DLL_FUNC_NAME(name))args; \
- static DLL_FUNC_NAME(name) prefixname = NULL
+ static DLL_FUNC_NAME(name) prefixname
#define DLL_DECLARE_FUNC(api, ret, name, args) \
DLL_DECLARE_FUNC_PREFIXNAME(api, ret, name, name, args)
@@ -119,10 +115,275 @@
if (prefixname) \
break; \
if (ret_on_failure) \
- return FALSE; \
+ return false; \
} while (0)
#define DLL_LOAD_FUNC(dll, name, ret_on_failure) \
DLL_LOAD_FUNC_PREFIXNAME(dll, name, name, ret_on_failure)
#define DLL_LOAD_FUNC_PREFIXED(dll, prefix, name, ret_on_failure) \
DLL_LOAD_FUNC_PREFIXNAME(dll, prefix##name, name, ret_on_failure)
+
+// https://msdn.microsoft.com/en-us/library/windows/hardware/ff539136(v=vs.85).aspx
+#if !defined(USBD_SUCCESS)
+typedef LONG USBD_STATUS;
+
+#define USBD_SUCCESS(Status) ((USBD_STATUS)(Status) >= 0)
+
+#define USBD_STATUS_ENDPOINT_HALTED ((USBD_STATUS)0xC0000030L)
+#define USBD_STATUS_TIMEOUT ((USBD_STATUS)0xC0006000L)
+#define USBD_STATUS_DEVICE_GONE ((USBD_STATUS)0xC0007000L)
+#define USBD_STATUS_CANCELED ((USBD_STATUS)0xC0010000L)
+#endif
+
+// error code added with Windows SDK 10.0.18362
+#ifndef ERROR_NO_SUCH_DEVICE
+#define ERROR_NO_SUCH_DEVICE 433L
+#endif
+
+/* Windows versions */
+enum windows_version {
+ WINDOWS_UNDEFINED,
+ WINDOWS_2000,
+ WINDOWS_XP,
+ WINDOWS_2003, // Also XP x64
+ WINDOWS_VISTA,
+ WINDOWS_7,
+ WINDOWS_8,
+ WINDOWS_8_1,
+ WINDOWS_10,
+ WINDOWS_11_OR_LATER
+};
+
+extern enum windows_version windows_version;
+
+#include <pshpack1.h>
+
+typedef struct USB_DEVICE_DESCRIPTOR {
+ UCHAR bLength;
+ UCHAR bDescriptorType;
+ USHORT bcdUSB;
+ UCHAR bDeviceClass;
+ UCHAR bDeviceSubClass;
+ UCHAR bDeviceProtocol;
+ UCHAR bMaxPacketSize0;
+ USHORT idVendor;
+ USHORT idProduct;
+ USHORT bcdDevice;
+ UCHAR iManufacturer;
+ UCHAR iProduct;
+ UCHAR iSerialNumber;
+ UCHAR bNumConfigurations;
+} USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
+
+typedef struct USB_CONFIGURATION_DESCRIPTOR {
+ UCHAR bLength;
+ UCHAR bDescriptorType;
+ USHORT wTotalLength;
+ UCHAR bNumInterfaces;
+ UCHAR bConfigurationValue;
+ UCHAR iConfiguration;
+ UCHAR bmAttributes;
+ UCHAR MaxPower;
+} USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR;
+
+#include <poppack.h>
+
+#define MAX_DEVICE_ID_LEN 200
+
+typedef struct USB_DK_DEVICE_ID {
+ WCHAR DeviceID[MAX_DEVICE_ID_LEN];
+ WCHAR InstanceID[MAX_DEVICE_ID_LEN];
+} USB_DK_DEVICE_ID, *PUSB_DK_DEVICE_ID;
+
+typedef struct USB_DK_DEVICE_INFO {
+ USB_DK_DEVICE_ID ID;
+ ULONG64 FilterID;
+ ULONG64 Port;
+ ULONG64 Speed;
+ USB_DEVICE_DESCRIPTOR DeviceDescriptor;
+} USB_DK_DEVICE_INFO, *PUSB_DK_DEVICE_INFO;
+
+typedef struct USB_DK_ISO_TRANSFER_RESULT {
+ ULONG64 ActualLength;
+ ULONG64 TransferResult;
+} USB_DK_ISO_TRANSFER_RESULT, *PUSB_DK_ISO_TRANSFER_RESULT;
+
+typedef struct USB_DK_GEN_TRANSFER_RESULT {
+ ULONG64 BytesTransferred;
+ ULONG64 UsbdStatus; // USBD_STATUS code
+} USB_DK_GEN_TRANSFER_RESULT, *PUSB_DK_GEN_TRANSFER_RESULT;
+
+typedef struct USB_DK_TRANSFER_RESULT {
+ USB_DK_GEN_TRANSFER_RESULT GenResult;
+ PVOID64 IsochronousResultsArray; // array of USB_DK_ISO_TRANSFER_RESULT
+} USB_DK_TRANSFER_RESULT, *PUSB_DK_TRANSFER_RESULT;
+
+typedef struct USB_DK_TRANSFER_REQUEST {
+ ULONG64 EndpointAddress;
+ PVOID64 Buffer;
+ ULONG64 BufferLength;
+ ULONG64 TransferType;
+ ULONG64 IsochronousPacketsArraySize;
+ PVOID64 IsochronousPacketsArray;
+ USB_DK_TRANSFER_RESULT Result;
+} USB_DK_TRANSFER_REQUEST, *PUSB_DK_TRANSFER_REQUEST;
+
+struct usbdk_device_priv {
+ USB_DK_DEVICE_ID ID;
+ PUSB_CONFIGURATION_DESCRIPTOR *config_descriptors;
+ HANDLE redirector_handle;
+ HANDLE system_handle;
+ uint8_t active_configuration;
+};
+
+struct winusb_device_priv {
+ bool initialized;
+ bool root_hub;
+ uint8_t active_config;
+ uint8_t depth; // distance to HCD
+ const struct windows_usb_api_backend *apib;
+ char *dev_id;
+ char *path; // device interface path
+ int sub_api; // for WinUSB-like APIs
+ struct {
+ char *path; // each interface needs a device interface path,
+ const struct windows_usb_api_backend *apib; // an API backend (multiple drivers support),
+ int sub_api;
+ int8_t nb_endpoints; // and a set of endpoint addresses (USB_MAXENDPOINTS)
+ uint8_t *endpoint;
+ int current_altsetting;
+ bool restricted_functionality; // indicates if the interface functionality is restricted
+ // by Windows (eg. HID keyboards or mice cannot do R/W)
+ } usb_interface[USB_MAXINTERFACES];
+ struct hid_device_priv *hid;
+ PUSB_CONFIGURATION_DESCRIPTOR *config_descriptor; // list of pointers to the cached config descriptors
+};
+
+struct usbdk_device_handle_priv {
+ // Not currently used
+ char dummy;
+};
+
+struct winusb_device_handle_priv {
+ int active_interface;
+ struct {
+ HANDLE dev_handle; // WinUSB needs an extra handle for the file
+ HANDLE api_handle; // used by the API to communicate with the device
+ } interface_handle[USB_MAXINTERFACES];
+ int autoclaim_count[USB_MAXINTERFACES]; // For auto-release
+};
+
+struct usbdk_transfer_priv {
+ USB_DK_TRANSFER_REQUEST request;
+ PULONG64 IsochronousPacketsArray;
+ PUSB_DK_ISO_TRANSFER_RESULT IsochronousResultsArray;
+};
+
+struct winusb_transfer_priv {
+ uint8_t interface_number;
+
+ uint8_t *hid_buffer; // 1 byte extended data buffer, required for HID
+ uint8_t *hid_dest; // transfer buffer destination, required for HID
+ size_t hid_expected_size;
+
+ // For isochronous transfers with LibUSBk driver:
+ void *iso_context;
+
+ // For isochronous transfers with Microsoft WinUSB driver:
+ void *isoch_buffer_handle; // The isoch_buffer_handle to free at the end of the transfer
+ BOOL iso_break_stream; // Whether the isoch. stream was to be continued in the last call of libusb_submit_transfer.
+ // As we this structure is zeroed out upon initialization, we need to use inverse logic here.
+ libusb_transfer_cb_fn iso_user_callback; // Original transfer callback of the user. Might be used for isochronous transfers.
+};
+
+struct windows_backend {
+ int (*init)(struct libusb_context *ctx);
+ void (*exit)(struct libusb_context *ctx);
+ int (*get_device_list)(struct libusb_context *ctx,
+ struct discovered_devs **discdevs);
+ int (*open)(struct libusb_device_handle *dev_handle);
+ void (*close)(struct libusb_device_handle *dev_handle);
+ int (*get_active_config_descriptor)(struct libusb_device *device,
+ void *buffer, size_t len);
+ int (*get_config_descriptor)(struct libusb_device *device,
+ uint8_t config_index, void *buffer, size_t len);
+ int (*get_config_descriptor_by_value)(struct libusb_device *device,
+ uint8_t bConfigurationValue, void **buffer);
+ int (*get_configuration)(struct libusb_device_handle *dev_handle, uint8_t *config);
+ int (*set_configuration)(struct libusb_device_handle *dev_handle, uint8_t config);
+ int (*claim_interface)(struct libusb_device_handle *dev_handle, uint8_t interface_number);
+ int (*release_interface)(struct libusb_device_handle *dev_handle, uint8_t interface_number);
+ int (*set_interface_altsetting)(struct libusb_device_handle *dev_handle,
+ uint8_t interface_number, uint8_t altsetting);
+ int (*clear_halt)(struct libusb_device_handle *dev_handle,
+ unsigned char endpoint);
+ int (*reset_device)(struct libusb_device_handle *dev_handle);
+ void (*destroy_device)(struct libusb_device *dev);
+ int (*submit_transfer)(struct usbi_transfer *itransfer);
+ int (*cancel_transfer)(struct usbi_transfer *itransfer);
+ void (*clear_transfer_priv)(struct usbi_transfer *itransfer);
+ enum libusb_transfer_status (*copy_transfer_data)(struct usbi_transfer *itransfer, DWORD length);
+};
+
+struct windows_context_priv {
+ const struct windows_backend *backend;
+ HANDLE completion_port;
+ HANDLE completion_port_thread;
+};
+
+union windows_device_priv {
+ struct usbdk_device_priv usbdk_priv;
+ struct winusb_device_priv winusb_priv;
+};
+
+union windows_device_handle_priv {
+ struct usbdk_device_handle_priv usbdk_priv;
+ struct winusb_device_handle_priv winusb_priv;
+};
+
+struct windows_transfer_priv {
+ OVERLAPPED overlapped;
+ HANDLE handle;
+ union {
+ struct usbdk_transfer_priv usbdk_priv;
+ struct winusb_transfer_priv winusb_priv;
+ };
+};
+
+static inline OVERLAPPED *get_transfer_priv_overlapped(struct usbi_transfer *itransfer)
+{
+ struct windows_transfer_priv *transfer_priv = usbi_get_transfer_priv(itransfer);
+ return &transfer_priv->overlapped;
+}
+
+static inline void set_transfer_priv_handle(struct usbi_transfer *itransfer, HANDLE handle)
+{
+ struct windows_transfer_priv *transfer_priv = usbi_get_transfer_priv(itransfer);
+ transfer_priv->handle = handle;
+}
+
+static inline struct usbdk_transfer_priv *get_usbdk_transfer_priv(struct usbi_transfer *itransfer)
+{
+ struct windows_transfer_priv *transfer_priv = usbi_get_transfer_priv(itransfer);
+ return &transfer_priv->usbdk_priv;
+}
+
+static inline struct winusb_transfer_priv *get_winusb_transfer_priv(struct usbi_transfer *itransfer)
+{
+ struct windows_transfer_priv *transfer_priv = usbi_get_transfer_priv(itransfer);
+ return &transfer_priv->winusb_priv;
+}
+
+extern const struct windows_backend usbdk_backend;
+extern const struct windows_backend winusb_backend;
+
+HMODULE load_system_library(struct libusb_context *ctx, const char *name);
+unsigned long htab_hash(const char *str);
+enum libusb_transfer_status usbd_status_to_libusb_transfer_status(USBD_STATUS status);
+void windows_force_sync_completion(struct usbi_transfer *itransfer, ULONG size);
+
+#if defined(ENABLE_LOGGING)
+const char *windows_error_str(DWORD error_code);
+#endif
+
+#endif
diff --git a/libusb/os/windows_nt_common.c b/libusb/os/windows_nt_common.c
deleted file mode 100644
index 54338a7..0000000
--- a/libusb/os/windows_nt_common.c
+++ /dev/null
@@ -1,1010 +0,0 @@
-/*
- * windows backend for libusb 1.0
- * Copyright © 2009-2012 Pete Batard <pete@akeo.ie>
- * With contributions from Michael Plante, Orin Eman et al.
- * Parts of this code adapted from libusb-win32-v1 by Stephan Meyer
- * HID Reports IOCTLs inspired from HIDAPI by Alan Ott, Signal 11 Software
- * Hash table functions adapted from glibc, by Ulrich Drepper et al.
- * Major code testing contribution by Xiaofan Chen
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <config.h>
-
-#include <inttypes.h>
-#include <process.h>
-#include <stdio.h>
-
-#include "libusbi.h"
-#include "windows_common.h"
-#include "windows_nt_common.h"
-
-// Public
-BOOL (WINAPI *pCancelIoEx)(HANDLE, LPOVERLAPPED);
-enum windows_version windows_version = WINDOWS_UNDEFINED;
-
- // Global variables for init/exit
-static unsigned int init_count = 0;
-static bool usbdk_available = false;
-
-// Global variables for clock_gettime mechanism
-static uint64_t hires_ticks_to_ps;
-static uint64_t hires_frequency;
-
-#define TIMER_REQUEST_RETRY_MS 100
-#define WM_TIMER_REQUEST (WM_USER + 1)
-#define WM_TIMER_EXIT (WM_USER + 2)
-
-// used for monotonic clock_gettime()
-struct timer_request {
- struct timespec *tp;
- HANDLE event;
-};
-
-// Timer thread
-static HANDLE timer_thread = NULL;
-static DWORD timer_thread_id = 0;
-
-/* Kernel32 dependencies */
-DLL_DECLARE_HANDLE(Kernel32);
-/* This call is only available from XP SP2 */
-DLL_DECLARE_FUNC_PREFIXED(WINAPI, BOOL, p, IsWow64Process, (HANDLE, PBOOL));
-
-/* User32 dependencies */
-DLL_DECLARE_HANDLE(User32);
-DLL_DECLARE_FUNC_PREFIXED(WINAPI, BOOL, p, GetMessageA, (LPMSG, HWND, UINT, UINT));
-DLL_DECLARE_FUNC_PREFIXED(WINAPI, BOOL, p, PeekMessageA, (LPMSG, HWND, UINT, UINT, UINT));
-DLL_DECLARE_FUNC_PREFIXED(WINAPI, BOOL, p, PostThreadMessageA, (DWORD, UINT, WPARAM, LPARAM));
-
-static unsigned __stdcall windows_clock_gettime_threaded(void *param);
-
-/*
-* Converts a windows error to human readable string
-* uses retval as errorcode, or, if 0, use GetLastError()
-*/
-#if defined(ENABLE_LOGGING)
-const char *windows_error_str(DWORD error_code)
-{
- static char err_string[ERR_BUFFER_SIZE];
-
- DWORD size;
- int len;
-
- if (error_code == 0)
- error_code = GetLastError();
-
- len = sprintf(err_string, "[%u] ", (unsigned int)error_code);
-
- // Translate codes returned by SetupAPI. The ones we are dealing with are either
- // in 0x0000xxxx or 0xE000xxxx and can be distinguished from standard error codes.
- // See http://msdn.microsoft.com/en-us/library/windows/hardware/ff545011.aspx
- switch (error_code & 0xE0000000) {
- case 0:
- error_code = HRESULT_FROM_WIN32(error_code); // Still leaves ERROR_SUCCESS unmodified
- break;
- case 0xE0000000:
- error_code = 0x80000000 | (FACILITY_SETUPAPI << 16) | (error_code & 0x0000FFFF);
- break;
- default:
- break;
- }
-
- size = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- &err_string[len], ERR_BUFFER_SIZE - len, NULL);
- if (size == 0) {
- DWORD format_error = GetLastError();
- if (format_error)
- snprintf(err_string, ERR_BUFFER_SIZE,
- "Windows error code %u (FormatMessage error code %u)",
- (unsigned int)error_code, (unsigned int)format_error);
- else
- snprintf(err_string, ERR_BUFFER_SIZE, "Unknown error code %u", (unsigned int)error_code);
- } else {
- // Remove CRLF from end of message, if present
- size_t pos = len + size - 2;
- if (err_string[pos] == '\r')
- err_string[pos] = '\0';
- }
-
- return err_string;
-}
-#endif
-
-static inline struct windows_context_priv *_context_priv(struct libusb_context *ctx)
-{
- return (struct windows_context_priv *)ctx->os_priv;
-}
-
-/* Hash table functions - modified From glibc 2.3.2:
- [Aho,Sethi,Ullman] Compilers: Principles, Techniques and Tools, 1986
- [Knuth] The Art of Computer Programming, part 3 (6.4) */
-
-#define HTAB_SIZE 1021UL // *MUST* be a prime number!!
-
-typedef struct htab_entry {
- unsigned long used;
- char *str;
-} htab_entry;
-
-static htab_entry *htab_table = NULL;
-static usbi_mutex_t htab_mutex;
-static unsigned long htab_filled;
-
-/* Before using the hash table we must allocate memory for it.
- We allocate one element more as the found prime number says.
- This is done for more effective indexing as explained in the
- comment for the hash function. */
-static bool htab_create(struct libusb_context *ctx)
-{
- if (htab_table != NULL) {
- usbi_err(ctx, "hash table already allocated");
- return true;
- }
-
- // Create a mutex
- usbi_mutex_init(&htab_mutex);
-
- usbi_dbg("using %lu entries hash table", HTAB_SIZE);
- htab_filled = 0;
-
- // allocate memory and zero out.
- htab_table = calloc(HTAB_SIZE + 1, sizeof(htab_entry));
- if (htab_table == NULL) {
- usbi_err(ctx, "could not allocate space for hash table");
- return false;
- }
-
- return true;
-}
-
-/* After using the hash table it has to be destroyed. */
-static void htab_destroy(void)
-{
- unsigned long i;
-
- if (htab_table == NULL)
- return;
-
- for (i = 0; i < HTAB_SIZE; i++)
- free(htab_table[i].str);
-
- safe_free(htab_table);
-
- usbi_mutex_destroy(&htab_mutex);
-}
-
-/* This is the search function. It uses double hashing with open addressing.
- We use a trick to speed up the lookup. The table is created with one
- more element available. This enables us to use the index zero special.
- This index will never be used because we store the first hash index in
- the field used where zero means not used. Every other value means used.
- The used field can be used as a first fast comparison for equality of
- the stored and the parameter value. This helps to prevent unnecessary
- expensive calls of strcmp. */
-unsigned long htab_hash(const char *str)
-{
- unsigned long hval, hval2;
- unsigned long idx;
- unsigned long r = 5381;
- int c;
- const char *sz = str;
-
- if (str == NULL)
- return 0;
-
- // Compute main hash value (algorithm suggested by Nokia)
- while ((c = *sz++) != 0)
- r = ((r << 5) + r) + c;
- if (r == 0)
- ++r;
-
- // compute table hash: simply take the modulus
- hval = r % HTAB_SIZE;
- if (hval == 0)
- ++hval;
-
- // Try the first index
- idx = hval;
-
- // Mutually exclusive access (R/W lock would be better)
- usbi_mutex_lock(&htab_mutex);
-
- if (htab_table[idx].used) {
- if ((htab_table[idx].used == hval) && (strcmp(str, htab_table[idx].str) == 0))
- goto out_unlock; // existing hash
-
- usbi_dbg("hash collision ('%s' vs '%s')", str, htab_table[idx].str);
-
- // Second hash function, as suggested in [Knuth]
- hval2 = 1 + hval % (HTAB_SIZE - 2);
-
- do {
- // Because size is prime this guarantees to step through all available indexes
- if (idx <= hval2)
- idx = HTAB_SIZE + idx - hval2;
- else
- idx -= hval2;
-
- // If we visited all entries leave the loop unsuccessfully
- if (idx == hval)
- break;
-
- // If entry is found use it.
- if ((htab_table[idx].used == hval) && (strcmp(str, htab_table[idx].str) == 0))
- goto out_unlock;
- } while (htab_table[idx].used);
- }
-
- // Not found => New entry
-
- // If the table is full return an error
- if (htab_filled >= HTAB_SIZE) {
- usbi_err(NULL, "hash table is full (%lu entries)", HTAB_SIZE);
- idx = 0;
- goto out_unlock;
- }
-
- htab_table[idx].str = _strdup(str);
- if (htab_table[idx].str == NULL) {
- usbi_err(NULL, "could not duplicate string for hash table");
- idx = 0;
- goto out_unlock;
- }
-
- htab_table[idx].used = hval;
- ++htab_filled;
-
-out_unlock:
- usbi_mutex_unlock(&htab_mutex);
-
- return idx;
-}
-
-/*
-* Make a transfer complete synchronously
-*/
-void windows_force_sync_completion(OVERLAPPED *overlapped, ULONG size)
-{
- overlapped->Internal = STATUS_COMPLETED_SYNCHRONOUSLY;
- overlapped->InternalHigh = size;
- SetEvent(overlapped->hEvent);
-}
-
-static BOOL windows_init_dlls(void)
-{
- DLL_GET_HANDLE(Kernel32);
- DLL_LOAD_FUNC_PREFIXED(Kernel32, p, IsWow64Process, FALSE);
- pCancelIoEx = (BOOL (WINAPI *)(HANDLE, LPOVERLAPPED))
- GetProcAddress(DLL_HANDLE_NAME(Kernel32), "CancelIoEx");
- usbi_dbg("Will use CancelIo%s for I/O cancellation", pCancelIoEx ? "Ex" : "");
-
- DLL_GET_HANDLE(User32);
- DLL_LOAD_FUNC_PREFIXED(User32, p, GetMessageA, TRUE);
- DLL_LOAD_FUNC_PREFIXED(User32, p, PeekMessageA, TRUE);
- DLL_LOAD_FUNC_PREFIXED(User32, p, PostThreadMessageA, TRUE);
-
- return TRUE;
-}
-
-static void windows_exit_dlls(void)
-{
- DLL_FREE_HANDLE(Kernel32);
- DLL_FREE_HANDLE(User32);
-}
-
-static bool windows_init_clock(struct libusb_context *ctx)
-{
- DWORD_PTR affinity, dummy;
- HANDLE event;
- LARGE_INTEGER li_frequency;
- int i;
-
- if (QueryPerformanceFrequency(&li_frequency)) {
- // The hires frequency can go as high as 4 GHz, so we'll use a conversion
- // to picoseconds to compute the tv_nsecs part in clock_gettime
- hires_frequency = li_frequency.QuadPart;
- hires_ticks_to_ps = UINT64_C(1000000000000) / hires_frequency;
- usbi_dbg("hires timer available (Frequency: %"PRIu64" Hz)", hires_frequency);
-
- // Because QueryPerformanceCounter might report different values when
- // running on different cores, we create a separate thread for the timer
- // calls, which we glue to the first available core always to prevent timing discrepancies.
- if (!GetProcessAffinityMask(GetCurrentProcess(), &affinity, &dummy) || (affinity == 0)) {
- usbi_err(ctx, "could not get process affinity: %s", windows_error_str(0));
- return false;
- }
-
- // The process affinity mask is a bitmask where each set bit represents a core on
- // which this process is allowed to run, so we find the first set bit
- for (i = 0; !(affinity & (DWORD_PTR)(1 << i)); i++);
- affinity = (DWORD_PTR)(1 << i);
-
- usbi_dbg("timer thread will run on core #%d", i);
-
- event = CreateEvent(NULL, FALSE, FALSE, NULL);
- if (event == NULL) {
- usbi_err(ctx, "could not create event: %s", windows_error_str(0));
- return false;
- }
-
- timer_thread = (HANDLE)_beginthreadex(NULL, 0, windows_clock_gettime_threaded, (void *)event,
- 0, (unsigned int *)&timer_thread_id);
- if (timer_thread == NULL) {
- usbi_err(ctx, "unable to create timer thread - aborting");
- CloseHandle(event);
- return false;
- }
-
- if (!SetThreadAffinityMask(timer_thread, affinity))
- usbi_warn(ctx, "unable to set timer thread affinity, timer discrepancies may arise");
-
- // Wait for timer thread to init before continuing.
- if (WaitForSingleObject(event, INFINITE) != WAIT_OBJECT_0) {
- usbi_err(ctx, "failed to wait for timer thread to become ready - aborting");
- CloseHandle(event);
- return false;
- }
-
- CloseHandle(event);
- } else {
- usbi_dbg("no hires timer available on this platform");
- hires_frequency = 0;
- hires_ticks_to_ps = UINT64_C(0);
- }
-
- return true;
-}
-
-static void windows_destroy_clock(void)
-{
- if (timer_thread) {
- // actually the signal to quit the thread.
- if (!pPostThreadMessageA(timer_thread_id, WM_TIMER_EXIT, 0, 0)
- || (WaitForSingleObject(timer_thread, INFINITE) != WAIT_OBJECT_0)) {
- usbi_dbg("could not wait for timer thread to quit");
- TerminateThread(timer_thread, 1);
- // shouldn't happen, but we're destroying
- // all objects it might have held anyway.
- }
- CloseHandle(timer_thread);
- timer_thread = NULL;
- timer_thread_id = 0;
- }
-}
-
-/* Windows version detection */
-static BOOL is_x64(void)
-{
- BOOL ret = FALSE;
-
- // Detect if we're running a 32 or 64 bit system
- if (sizeof(uintptr_t) < 8) {
- if (pIsWow64Process != NULL)
- pIsWow64Process(GetCurrentProcess(), &ret);
- } else {
- ret = TRUE;
- }
-
- return ret;
-}
-
-static void get_windows_version(void)
-{
- OSVERSIONINFOEXA vi, vi2;
- const char *arch, *w = NULL;
- unsigned major, minor, version;
- ULONGLONG major_equal, minor_equal;
- BOOL ws;
-
- windows_version = WINDOWS_UNDEFINED;
-
- memset(&vi, 0, sizeof(vi));
- vi.dwOSVersionInfoSize = sizeof(vi);
- if (!GetVersionExA((OSVERSIONINFOA *)&vi)) {
- memset(&vi, 0, sizeof(vi));
- vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
- if (!GetVersionExA((OSVERSIONINFOA *)&vi))
- return;
- }
-
- if (vi.dwPlatformId != VER_PLATFORM_WIN32_NT)
- return;
-
- if ((vi.dwMajorVersion > 6) || ((vi.dwMajorVersion == 6) && (vi.dwMinorVersion >= 2))) {
- // Starting with Windows 8.1 Preview, GetVersionEx() does no longer report the actual OS version
- // See: http://msdn.microsoft.com/en-us/library/windows/desktop/dn302074.aspx
-
- major_equal = VerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL);
- for (major = vi.dwMajorVersion; major <= 9; major++) {
- memset(&vi2, 0, sizeof(vi2));
- vi2.dwOSVersionInfoSize = sizeof(vi2);
- vi2.dwMajorVersion = major;
- if (!VerifyVersionInfoA(&vi2, VER_MAJORVERSION, major_equal))
- continue;
-
- if (vi.dwMajorVersion < major) {
- vi.dwMajorVersion = major;
- vi.dwMinorVersion = 0;
- }
-
- minor_equal = VerSetConditionMask(0, VER_MINORVERSION, VER_EQUAL);
- for (minor = vi.dwMinorVersion; minor <= 9; minor++) {
- memset(&vi2, 0, sizeof(vi2));
- vi2.dwOSVersionInfoSize = sizeof(vi2);
- vi2.dwMinorVersion = minor;
- if (!VerifyVersionInfoA(&vi2, VER_MINORVERSION, minor_equal))
- continue;
-
- vi.dwMinorVersion = minor;
- break;
- }
-
- break;
- }
- }
-
- if ((vi.dwMajorVersion > 0xf) || (vi.dwMinorVersion > 0xf))
- return;
-
- ws = (vi.wProductType <= VER_NT_WORKSTATION);
- version = vi.dwMajorVersion << 4 | vi.dwMinorVersion;
- switch (version) {
- case 0x50: windows_version = WINDOWS_2000; w = "2000"; break;
- case 0x51: windows_version = WINDOWS_XP; w = "XP"; break;
- case 0x52: windows_version = WINDOWS_2003; w = "2003"; break;
- case 0x60: windows_version = WINDOWS_VISTA; w = (ws ? "Vista" : "2008"); break;
- case 0x61: windows_version = WINDOWS_7; w = (ws ? "7" : "2008_R2"); break;
- case 0x62: windows_version = WINDOWS_8; w = (ws ? "8" : "2012"); break;
- case 0x63: windows_version = WINDOWS_8_1; w = (ws ? "8.1" : "2012_R2"); break;
- case 0x64: // Early Windows 10 Insider Previews and Windows Server 2017 Technical Preview 1 used version 6.4
- case 0xA0: windows_version = WINDOWS_10; w = (ws ? "10" : "2016"); break;
- default:
- if (version < 0x50) {
- return;
- } else {
- windows_version = WINDOWS_11_OR_LATER;
- w = "11 or later";
- }
- }
-
- arch = is_x64() ? "64-bit" : "32-bit";
-
- if (vi.wServicePackMinor)
- usbi_dbg("Windows %s SP%u.%u %s", w, vi.wServicePackMajor, vi.wServicePackMinor, arch);
- else if (vi.wServicePackMajor)
- usbi_dbg("Windows %s SP%u %s", w, vi.wServicePackMajor, arch);
- else
- usbi_dbg("Windows %s %s", w, arch);
-}
-
-/*
-* Monotonic and real time functions
-*/
-static unsigned __stdcall windows_clock_gettime_threaded(void *param)
-{
- struct timer_request *request;
- LARGE_INTEGER hires_counter;
- MSG msg;
-
- // The following call will create this thread's message queue
- // See https://msdn.microsoft.com/en-us/library/windows/desktop/ms644946.aspx
- pPeekMessageA(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
-
- // Signal windows_init_clock() that we're ready to service requests
- if (!SetEvent((HANDLE)param))
- usbi_dbg("SetEvent failed for timer init event: %s", windows_error_str(0));
- param = NULL;
-
- // Main loop - wait for requests
- while (1) {
- if (pGetMessageA(&msg, NULL, WM_TIMER_REQUEST, WM_TIMER_EXIT) == -1) {
- usbi_err(NULL, "GetMessage failed for timer thread: %s", windows_error_str(0));
- return 1;
- }
-
- switch (msg.message) {
- case WM_TIMER_REQUEST:
- // Requests to this thread are for hires always
- // Microsoft says that this function always succeeds on XP and later
- // See https://msdn.microsoft.com/en-us/library/windows/desktop/ms644904.aspx
- request = (struct timer_request *)msg.lParam;
- QueryPerformanceCounter(&hires_counter);
- request->tp->tv_sec = (long)(hires_counter.QuadPart / hires_frequency);
- request->tp->tv_nsec = (long)(((hires_counter.QuadPart % hires_frequency) / 1000) * hires_ticks_to_ps);
- if (!SetEvent(request->event))
- usbi_err(NULL, "SetEvent failed for timer request: %s", windows_error_str(0));
- break;
- case WM_TIMER_EXIT:
- usbi_dbg("timer thread quitting");
- return 0;
- }
- }
-}
-
-static void windows_transfer_callback(const struct windows_backend *backend,
- struct usbi_transfer *itransfer, DWORD io_result, DWORD io_size)
-{
- int status, istatus;
-
- usbi_dbg("handling I/O completion with errcode %u, size %u", (unsigned int)io_result, (unsigned int)io_size);
-
- switch (io_result) {
- case NO_ERROR:
- status = backend->copy_transfer_data(itransfer, (uint32_t)io_size);
- break;
- case ERROR_GEN_FAILURE:
- usbi_dbg("detected endpoint stall");
- status = LIBUSB_TRANSFER_STALL;
- break;
- case ERROR_SEM_TIMEOUT:
- usbi_dbg("detected semaphore timeout");
- status = LIBUSB_TRANSFER_TIMED_OUT;
- break;
- case ERROR_OPERATION_ABORTED:
- istatus = backend->copy_transfer_data(itransfer, (uint32_t)io_size);
- if (istatus != LIBUSB_TRANSFER_COMPLETED)
- usbi_dbg("Failed to copy partial data in aborted operation: %d", istatus);
-
- usbi_dbg("detected operation aborted");
- status = LIBUSB_TRANSFER_CANCELLED;
- break;
- case ERROR_FILE_NOT_FOUND:
- usbi_dbg("detected device removed");
- status = LIBUSB_TRANSFER_NO_DEVICE;
- break;
- default:
- usbi_err(ITRANSFER_CTX(itransfer), "detected I/O error %u: %s", (unsigned int)io_result, windows_error_str(io_result));
- status = LIBUSB_TRANSFER_ERROR;
- break;
- }
- backend->clear_transfer_priv(itransfer); // Cancel polling
- if (status == LIBUSB_TRANSFER_CANCELLED)
- usbi_handle_transfer_cancellation(itransfer);
- else
- usbi_handle_transfer_completion(itransfer, (enum libusb_transfer_status)status);
-}
-
-static void windows_handle_callback(const struct windows_backend *backend,
- struct usbi_transfer *itransfer, DWORD io_result, DWORD io_size)
-{
- struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
-
- switch (transfer->type) {
- case LIBUSB_TRANSFER_TYPE_CONTROL:
- case LIBUSB_TRANSFER_TYPE_BULK:
- case LIBUSB_TRANSFER_TYPE_INTERRUPT:
- case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
- windows_transfer_callback(backend, itransfer, io_result, io_size);
- break;
- case LIBUSB_TRANSFER_TYPE_BULK_STREAM:
- usbi_warn(ITRANSFER_CTX(itransfer), "bulk stream transfers are not yet supported on this platform");
- break;
- default:
- usbi_err(ITRANSFER_CTX(itransfer), "unknown endpoint type %d", transfer->type);
- }
-}
-
-static int windows_init(struct libusb_context *ctx)
-{
- struct windows_context_priv *priv = _context_priv(ctx);
- HANDLE semaphore;
- char sem_name[11 + 8 + 1]; // strlen("libusb_init") + (32-bit hex PID) + '\0'
- int r = LIBUSB_ERROR_OTHER;
- bool winusb_backend_init = false;
-
- sprintf(sem_name, "libusb_init%08X", (unsigned int)(GetCurrentProcessId() & 0xFFFFFFFF));
- semaphore = CreateSemaphoreA(NULL, 1, 1, sem_name);
- if (semaphore == NULL) {
- usbi_err(ctx, "could not create semaphore: %s", windows_error_str(0));
- return LIBUSB_ERROR_NO_MEM;
- }
-
- // A successful wait brings our semaphore count to 0 (unsignaled)
- // => any concurent wait stalls until the semaphore's release
- if (WaitForSingleObject(semaphore, INFINITE) != WAIT_OBJECT_0) {
- usbi_err(ctx, "failure to access semaphore: %s", windows_error_str(0));
- CloseHandle(semaphore);
- return LIBUSB_ERROR_NO_MEM;
- }
-
- // NB: concurrent usage supposes that init calls are equally balanced with
- // exit calls. If init is called more than exit, we will not exit properly
- if (++init_count == 1) { // First init?
- // Load DLL imports
- if (!windows_init_dlls()) {
- usbi_err(ctx, "could not resolve DLL functions");
- goto init_exit;
- }
-
- get_windows_version();
-
- if (windows_version == WINDOWS_UNDEFINED) {
- usbi_err(ctx, "failed to detect Windows version");
- r = LIBUSB_ERROR_NOT_SUPPORTED;
- goto init_exit;
- }
-
- if (!windows_init_clock(ctx))
- goto init_exit;
-
- if (!htab_create(ctx))
- goto init_exit;
-
- r = winusb_backend.init(ctx);
- if (r != LIBUSB_SUCCESS)
- goto init_exit;
- winusb_backend_init = true;
-
- r = usbdk_backend.init(ctx);
- if (r == LIBUSB_SUCCESS) {
- usbi_dbg("UsbDk backend is available");
- usbdk_available = true;
- } else {
- usbi_info(ctx, "UsbDk backend is not available");
- // Do not report this as an error
- r = LIBUSB_SUCCESS;
- }
- }
-
- // By default, new contexts will use the WinUSB backend
- priv->backend = &winusb_backend;
-
- r = LIBUSB_SUCCESS;
-
-init_exit: // Holds semaphore here
- if ((init_count == 1) && (r != LIBUSB_SUCCESS)) { // First init failed?
- if (winusb_backend_init)
- winusb_backend.exit(ctx);
- htab_destroy();
- windows_destroy_clock();
- windows_exit_dlls();
- --init_count;
- }
-
- ReleaseSemaphore(semaphore, 1, NULL); // increase count back to 1
- CloseHandle(semaphore);
- return r;
-}
-
-static void windows_exit(struct libusb_context *ctx)
-{
- HANDLE semaphore;
- char sem_name[11 + 8 + 1]; // strlen("libusb_init") + (32-bit hex PID) + '\0'
- UNUSED(ctx);
-
- sprintf(sem_name, "libusb_init%08X", (unsigned int)(GetCurrentProcessId() & 0xFFFFFFFF));
- semaphore = CreateSemaphoreA(NULL, 1, 1, sem_name);
- if (semaphore == NULL)
- return;
-
- // A successful wait brings our semaphore count to 0 (unsignaled)
- // => any concurent wait stalls until the semaphore release
- if (WaitForSingleObject(semaphore, INFINITE) != WAIT_OBJECT_0) {
- CloseHandle(semaphore);
- return;
- }
-
- // Only works if exits and inits are balanced exactly
- if (--init_count == 0) { // Last exit
- if (usbdk_available) {
- usbdk_backend.exit(ctx);
- usbdk_available = false;
- }
- winusb_backend.exit(ctx);
- htab_destroy();
- windows_destroy_clock();
- windows_exit_dlls();
- }
-
- ReleaseSemaphore(semaphore, 1, NULL); // increase count back to 1
- CloseHandle(semaphore);
-}
-
-static int windows_set_option(struct libusb_context *ctx, enum libusb_option option, va_list ap)
-{
- struct windows_context_priv *priv = _context_priv(ctx);
-
- UNUSED(ap);
-
- switch (option) {
- case LIBUSB_OPTION_USE_USBDK:
- if (usbdk_available) {
- usbi_dbg("switching context %p to use UsbDk backend", ctx);
- priv->backend = &usbdk_backend;
- } else {
- usbi_err(ctx, "UsbDk backend not available");
- return LIBUSB_ERROR_NOT_FOUND;
- }
- return LIBUSB_SUCCESS;
- default:
- return LIBUSB_ERROR_NOT_SUPPORTED;
- }
-
-}
-
-static int windows_get_device_list(struct libusb_context *ctx, struct discovered_devs **discdevs)
-{
- struct windows_context_priv *priv = _context_priv(ctx);
- return priv->backend->get_device_list(ctx, discdevs);
-}
-
-static int windows_open(struct libusb_device_handle *dev_handle)
-{
- struct windows_context_priv *priv = _context_priv(HANDLE_CTX(dev_handle));
- return priv->backend->open(dev_handle);
-}
-
-static void windows_close(struct libusb_device_handle *dev_handle)
-{
- struct windows_context_priv *priv = _context_priv(HANDLE_CTX(dev_handle));
- priv->backend->close(dev_handle);
-}
-
-static int windows_get_device_descriptor(struct libusb_device *dev,
- unsigned char *buffer, int *host_endian)
-{
- struct windows_context_priv *priv = _context_priv(DEVICE_CTX(dev));
- *host_endian = 0;
- return priv->backend->get_device_descriptor(dev, buffer);
-}
-
-static int windows_get_active_config_descriptor(struct libusb_device *dev,
- unsigned char *buffer, size_t len, int *host_endian)
-{
- struct windows_context_priv *priv = _context_priv(DEVICE_CTX(dev));
- *host_endian = 0;
- return priv->backend->get_active_config_descriptor(dev, buffer, len);
-}
-
-static int windows_get_config_descriptor(struct libusb_device *dev,
- uint8_t config_index, unsigned char *buffer, size_t len, int *host_endian)
-{
- struct windows_context_priv *priv = _context_priv(DEVICE_CTX(dev));
- *host_endian = 0;
- return priv->backend->get_config_descriptor(dev, config_index, buffer, len);
-}
-
-static int windows_get_config_descriptor_by_value(struct libusb_device *dev,
- uint8_t bConfigurationValue, unsigned char **buffer, int *host_endian)
-{
- struct windows_context_priv *priv = _context_priv(DEVICE_CTX(dev));
- *host_endian = 0;
- return priv->backend->get_config_descriptor_by_value(dev, bConfigurationValue, buffer);
-}
-
-static int windows_get_configuration(struct libusb_device_handle *dev_handle, int *config)
-{
- struct windows_context_priv *priv = _context_priv(HANDLE_CTX(dev_handle));
- return priv->backend->get_configuration(dev_handle, config);
-}
-
-static int windows_set_configuration(struct libusb_device_handle *dev_handle, int config)
-{
- struct windows_context_priv *priv = _context_priv(HANDLE_CTX(dev_handle));
- return priv->backend->set_configuration(dev_handle, config);
-}
-
-static int windows_claim_interface(struct libusb_device_handle *dev_handle, int interface_number)
-{
- struct windows_context_priv *priv = _context_priv(HANDLE_CTX(dev_handle));
- return priv->backend->claim_interface(dev_handle, interface_number);
-}
-
-static int windows_release_interface(struct libusb_device_handle *dev_handle, int interface_number)
-{
- struct windows_context_priv *priv = _context_priv(HANDLE_CTX(dev_handle));
- return priv->backend->release_interface(dev_handle, interface_number);
-}
-
-static int windows_set_interface_altsetting(struct libusb_device_handle *dev_handle,
- int interface_number, int altsetting)
-{
- struct windows_context_priv *priv = _context_priv(HANDLE_CTX(dev_handle));
- return priv->backend->set_interface_altsetting(dev_handle, interface_number, altsetting);
-}
-
-static int windows_clear_halt(struct libusb_device_handle *dev_handle, unsigned char endpoint)
-{
- struct windows_context_priv *priv = _context_priv(HANDLE_CTX(dev_handle));
- return priv->backend->clear_halt(dev_handle, endpoint);
-}
-
-static int windows_reset_device(struct libusb_device_handle *dev_handle)
-{
- struct windows_context_priv *priv = _context_priv(HANDLE_CTX(dev_handle));
- return priv->backend->reset_device(dev_handle);
-}
-
-static void windows_destroy_device(struct libusb_device *dev)
-{
- struct windows_context_priv *priv = _context_priv(DEVICE_CTX(dev));
- priv->backend->destroy_device(dev);
-}
-
-static int windows_submit_transfer(struct usbi_transfer *itransfer)
-{
- struct windows_context_priv *priv = _context_priv(ITRANSFER_CTX(itransfer));
- return priv->backend->submit_transfer(itransfer);
-}
-
-static int windows_cancel_transfer(struct usbi_transfer *itransfer)
-{
- struct windows_context_priv *priv = _context_priv(ITRANSFER_CTX(itransfer));
- return priv->backend->cancel_transfer(itransfer);
-}
-
-static void windows_clear_transfer_priv(struct usbi_transfer *itransfer)
-{
- struct windows_context_priv *priv = _context_priv(ITRANSFER_CTX(itransfer));
- priv->backend->clear_transfer_priv(itransfer);
-}
-
-static int windows_handle_events(struct libusb_context *ctx, struct pollfd *fds, POLL_NFDS_TYPE nfds, int num_ready)
-{
- struct windows_context_priv *priv = _context_priv(ctx);
- struct usbi_transfer *itransfer;
- DWORD io_size, io_result;
- POLL_NFDS_TYPE i;
- bool found;
- int transfer_fd;
- int r = LIBUSB_SUCCESS;
-
- usbi_mutex_lock(&ctx->open_devs_lock);
- for (i = 0; i < nfds && num_ready > 0; i++) {
-
- usbi_dbg("checking fd %d with revents = %04x", fds[i].fd, fds[i].revents);
-
- if (!fds[i].revents)
- continue;
-
- num_ready--;
-
- // Because a Windows OVERLAPPED is used for poll emulation,
- // a pollable fd is created and stored with each transfer
- found = false;
- transfer_fd = -1;
- usbi_mutex_lock(&ctx->flying_transfers_lock);
- list_for_each_entry(itransfer, &ctx->flying_transfers, list, struct usbi_transfer) {
- transfer_fd = priv->backend->get_transfer_fd(itransfer);
- if (transfer_fd == fds[i].fd) {
- found = true;
- break;
- }
- }
- usbi_mutex_unlock(&ctx->flying_transfers_lock);
-
- if (found) {
- priv->backend->get_overlapped_result(itransfer, &io_result, &io_size);
-
- usbi_remove_pollfd(ctx, transfer_fd);
-
- // let handle_callback free the event using the transfer wfd
- // If you don't use the transfer wfd, you run a risk of trying to free a
- // newly allocated wfd that took the place of the one from the transfer.
- windows_handle_callback(priv->backend, itransfer, io_result, io_size);
- } else {
- usbi_err(ctx, "could not find a matching transfer for fd %d", fds[i].fd);
- r = LIBUSB_ERROR_NOT_FOUND;
- break;
- }
- }
- usbi_mutex_unlock(&ctx->open_devs_lock);
-
- return r;
-}
-
-static int windows_clock_gettime(int clk_id, struct timespec *tp)
-{
- struct timer_request request;
-#if !defined(_MSC_VER) || (_MSC_VER < 1900)
- FILETIME filetime;
- ULARGE_INTEGER rtime;
-#endif
- DWORD r;
-
- switch (clk_id) {
- case USBI_CLOCK_MONOTONIC:
- if (timer_thread) {
- request.tp = tp;
- request.event = CreateEvent(NULL, FALSE, FALSE, NULL);
- if (request.event == NULL)
- return LIBUSB_ERROR_NO_MEM;
-
- if (!pPostThreadMessageA(timer_thread_id, WM_TIMER_REQUEST, 0, (LPARAM)&request)) {
- usbi_err(NULL, "PostThreadMessage failed for timer thread: %s", windows_error_str(0));
- CloseHandle(request.event);
- return LIBUSB_ERROR_OTHER;
- }
-
- do {
- r = WaitForSingleObject(request.event, TIMER_REQUEST_RETRY_MS);
- if (r == WAIT_TIMEOUT)
- usbi_dbg("could not obtain a timer value within reasonable timeframe - too much load?");
- else if (r == WAIT_FAILED)
- usbi_err(NULL, "WaitForSingleObject failed: %s", windows_error_str(0));
- } while (r == WAIT_TIMEOUT);
- CloseHandle(request.event);
-
- if (r == WAIT_OBJECT_0)
- return LIBUSB_SUCCESS;
- else
- return LIBUSB_ERROR_OTHER;
- }
- // Fall through and return real-time if monotonic was not detected @ timer init
- case USBI_CLOCK_REALTIME:
-#if defined(_MSC_VER) && (_MSC_VER >= 1900)
- timespec_get(tp, TIME_UTC);
-#else
- // We follow http://msdn.microsoft.com/en-us/library/ms724928%28VS.85%29.aspx
- // with a predef epoch time to have an epoch that starts at 1970.01.01 00:00
- // Note however that our resolution is bounded by the Windows system time
- // functions and is at best of the order of 1 ms (or, usually, worse)
- GetSystemTimeAsFileTime(&filetime);
- rtime.LowPart = filetime.dwLowDateTime;
- rtime.HighPart = filetime.dwHighDateTime;
- rtime.QuadPart -= EPOCH_TIME;
- tp->tv_sec = (long)(rtime.QuadPart / 10000000);
- tp->tv_nsec = (long)((rtime.QuadPart % 10000000) * 100);
-#endif
- return LIBUSB_SUCCESS;
- default:
- return LIBUSB_ERROR_INVALID_PARAM;
- }
-}
-
-// NB: MSVC6 does not support named initializers.
-const struct usbi_os_backend usbi_backend = {
- "Windows",
- USBI_CAP_HAS_HID_ACCESS,
- windows_init,
- windows_exit,
- windows_set_option,
- windows_get_device_list,
- NULL, /* hotplug_poll */
- NULL, /* wrap_sys_device */
- windows_open,
- windows_close,
- windows_get_device_descriptor,
- windows_get_active_config_descriptor,
- windows_get_config_descriptor,
- windows_get_config_descriptor_by_value,
- windows_get_configuration,
- windows_set_configuration,
- windows_claim_interface,
- windows_release_interface,
- windows_set_interface_altsetting,
- windows_clear_halt,
- windows_reset_device,
- NULL, /* alloc_streams */
- NULL, /* free_streams */
- NULL, /* dev_mem_alloc */
- NULL, /* dev_mem_free */
- NULL, /* kernel_driver_active */
- NULL, /* detach_kernel_driver */
- NULL, /* attach_kernel_driver */
- windows_destroy_device,
- windows_submit_transfer,
- windows_cancel_transfer,
- windows_clear_transfer_priv,
- windows_handle_events,
- NULL, /* handle_transfer_completion */
- windows_clock_gettime,
- sizeof(struct windows_context_priv),
- sizeof(union windows_device_priv),
- sizeof(union windows_device_handle_priv),
- sizeof(union windows_transfer_priv),
-};
diff --git a/libusb/os/windows_nt_common.h b/libusb/os/windows_nt_common.h
deleted file mode 100644
index e155b5d..0000000
--- a/libusb/os/windows_nt_common.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Windows backend common header for libusb 1.0
- *
- * This file brings together header code common between
- * the desktop Windows backends.
- * Copyright © 2012-2013 RealVNC Ltd.
- * Copyright © 2009-2012 Pete Batard <pete@akeo.ie>
- * With contributions from Michael Plante, Orin Eman et al.
- * Parts of this code adapted from libusb-win32-v1 by Stephan Meyer
- * Major code testing contribution by Xiaofan Chen
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#pragma once
-
-#include "windows_nt_shared_types.h"
-
- /* Windows versions */
-enum windows_version {
- WINDOWS_UNDEFINED,
- WINDOWS_2000,
- WINDOWS_XP,
- WINDOWS_2003, // Also XP x64
- WINDOWS_VISTA,
- WINDOWS_7,
- WINDOWS_8,
- WINDOWS_8_1,
- WINDOWS_10,
- WINDOWS_11_OR_LATER
-};
-
-extern enum windows_version windows_version;
-
-/* This call is only available from Vista */
-extern BOOL (WINAPI *pCancelIoEx)(HANDLE, LPOVERLAPPED);
-
-struct windows_backend {
- int (*init)(struct libusb_context *ctx);
- void (*exit)(struct libusb_context *ctx);
- int (*get_device_list)(struct libusb_context *ctx,
- struct discovered_devs **discdevs);
- int (*open)(struct libusb_device_handle *dev_handle);
- void (*close)(struct libusb_device_handle *dev_handle);
- int (*get_device_descriptor)(struct libusb_device *device, unsigned char *buffer);
- int (*get_active_config_descriptor)(struct libusb_device *device,
- unsigned char *buffer, size_t len);
- int (*get_config_descriptor)(struct libusb_device *device,
- uint8_t config_index, unsigned char *buffer, size_t len);
- int (*get_config_descriptor_by_value)(struct libusb_device *device,
- uint8_t bConfigurationValue, unsigned char **buffer);
- int (*get_configuration)(struct libusb_device_handle *dev_handle, int *config);
- int (*set_configuration)(struct libusb_device_handle *dev_handle, int config);
- int (*claim_interface)(struct libusb_device_handle *dev_handle, int interface_number);
- int (*release_interface)(struct libusb_device_handle *dev_handle, int interface_number);
- int (*set_interface_altsetting)(struct libusb_device_handle *dev_handle,
- int interface_number, int altsetting);
- int (*clear_halt)(struct libusb_device_handle *dev_handle,
- unsigned char endpoint);
- int (*reset_device)(struct libusb_device_handle *dev_handle);
- void (*destroy_device)(struct libusb_device *dev);
- int (*submit_transfer)(struct usbi_transfer *itransfer);
- int (*cancel_transfer)(struct usbi_transfer *itransfer);
- void (*clear_transfer_priv)(struct usbi_transfer *itransfer);
- int (*copy_transfer_data)(struct usbi_transfer *itransfer, uint32_t io_size);
- int (*get_transfer_fd)(struct usbi_transfer *itransfer);
- void (*get_overlapped_result)(struct usbi_transfer *itransfer,
- DWORD *io_result, DWORD *io_size);
-};
-
-struct windows_context_priv {
- const struct windows_backend *backend;
-};
-
-union windows_device_priv {
- struct usbdk_device_priv usbdk_priv;
- struct winusb_device_priv winusb_priv;
-};
-
-union windows_device_handle_priv {
- struct usbdk_device_handle_priv usbdk_priv;
- struct winusb_device_handle_priv winusb_priv;
-};
-
-union windows_transfer_priv {
- struct usbdk_transfer_priv usbdk_priv;
- struct winusb_transfer_priv winusb_priv;
-};
-
-extern const struct windows_backend usbdk_backend;
-extern const struct windows_backend winusb_backend;
-
-unsigned long htab_hash(const char *str);
-void windows_force_sync_completion(OVERLAPPED *overlapped, ULONG size);
-
-#if defined(ENABLE_LOGGING)
-const char *windows_error_str(DWORD error_code);
-#endif
diff --git a/libusb/os/windows_nt_shared_types.h b/libusb/os/windows_nt_shared_types.h
deleted file mode 100644
index d809bfd..0000000
--- a/libusb/os/windows_nt_shared_types.h
+++ /dev/null
@@ -1,147 +0,0 @@
-#pragma once
-
-#include "windows_common.h"
-
-#include <pshpack1.h>
-
-typedef struct USB_DEVICE_DESCRIPTOR {
- UCHAR bLength;
- UCHAR bDescriptorType;
- USHORT bcdUSB;
- UCHAR bDeviceClass;
- UCHAR bDeviceSubClass;
- UCHAR bDeviceProtocol;
- UCHAR bMaxPacketSize0;
- USHORT idVendor;
- USHORT idProduct;
- USHORT bcdDevice;
- UCHAR iManufacturer;
- UCHAR iProduct;
- UCHAR iSerialNumber;
- UCHAR bNumConfigurations;
-} USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
-
-typedef struct USB_CONFIGURATION_DESCRIPTOR {
- UCHAR bLength;
- UCHAR bDescriptorType;
- USHORT wTotalLength;
- UCHAR bNumInterfaces;
- UCHAR bConfigurationValue;
- UCHAR iConfiguration;
- UCHAR bmAttributes;
- UCHAR MaxPower;
-} USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR;
-
-#include <poppack.h>
-
-#define MAX_DEVICE_ID_LEN 200
-
-typedef struct USB_DK_DEVICE_ID {
- WCHAR DeviceID[MAX_DEVICE_ID_LEN];
- WCHAR InstanceID[MAX_DEVICE_ID_LEN];
-} USB_DK_DEVICE_ID, *PUSB_DK_DEVICE_ID;
-
-typedef struct USB_DK_DEVICE_INFO {
- USB_DK_DEVICE_ID ID;
- ULONG64 FilterID;
- ULONG64 Port;
- ULONG64 Speed;
- USB_DEVICE_DESCRIPTOR DeviceDescriptor;
-} USB_DK_DEVICE_INFO, *PUSB_DK_DEVICE_INFO;
-
-typedef struct USB_DK_ISO_TRANSFER_RESULT {
- ULONG64 ActualLength;
- ULONG64 TransferResult;
-} USB_DK_ISO_TRANSFER_RESULT, *PUSB_DK_ISO_TRANSFER_RESULT;
-
-typedef struct USB_DK_GEN_TRANSFER_RESULT {
- ULONG64 BytesTransferred;
- ULONG64 UsbdStatus; // USBD_STATUS code
-} USB_DK_GEN_TRANSFER_RESULT, *PUSB_DK_GEN_TRANSFER_RESULT;
-
-typedef struct USB_DK_TRANSFER_RESULT {
- USB_DK_GEN_TRANSFER_RESULT GenResult;
- PVOID64 IsochronousResultsArray; // array of USB_DK_ISO_TRANSFER_RESULT
-} USB_DK_TRANSFER_RESULT, *PUSB_DK_TRANSFER_RESULT;
-
-typedef struct USB_DK_TRANSFER_REQUEST {
- ULONG64 EndpointAddress;
- PVOID64 Buffer;
- ULONG64 BufferLength;
- ULONG64 TransferType;
- ULONG64 IsochronousPacketsArraySize;
- PVOID64 IsochronousPacketsArray;
- USB_DK_TRANSFER_RESULT Result;
-} USB_DK_TRANSFER_REQUEST, *PUSB_DK_TRANSFER_REQUEST;
-
-struct usbdk_device_priv {
- USB_DK_DEVICE_INFO info;
- PUSB_CONFIGURATION_DESCRIPTOR *config_descriptors;
- HANDLE redirector_handle;
- HANDLE system_handle;
- uint8_t active_configuration;
-};
-
-struct winusb_device_priv {
- bool initialized;
- bool root_hub;
- uint8_t active_config;
- uint8_t depth; // distance to HCD
- const struct windows_usb_api_backend *apib;
- char *dev_id;
- char *path; // device interface path
- int sub_api; // for WinUSB-like APIs
- struct {
- char *path; // each interface needs a device interface path,
- const struct windows_usb_api_backend *apib; // an API backend (multiple drivers support),
- int sub_api;
- int8_t nb_endpoints; // and a set of endpoint addresses (USB_MAXENDPOINTS)
- uint8_t *endpoint;
- int current_altsetting;
- bool restricted_functionality; // indicates if the interface functionality is restricted
- // by Windows (eg. HID keyboards or mice cannot do R/W)
- } usb_interface[USB_MAXINTERFACES];
- struct hid_device_priv *hid;
- USB_DEVICE_DESCRIPTOR dev_descriptor;
- PUSB_CONFIGURATION_DESCRIPTOR *config_descriptor; // list of pointers to the cached config descriptors
-};
-
-struct usbdk_device_handle_priv {
- // Not currently used
- char dummy;
-};
-
-struct winusb_device_handle_priv {
- int active_interface;
- struct {
- HANDLE dev_handle; // WinUSB needs an extra handle for the file
- HANDLE api_handle; // used by the API to communicate with the device
- } interface_handle[USB_MAXINTERFACES];
- int autoclaim_count[USB_MAXINTERFACES]; // For auto-release
-};
-
-struct usbdk_transfer_priv {
- USB_DK_TRANSFER_REQUEST request;
- struct winfd pollable_fd;
- HANDLE system_handle;
- PULONG64 IsochronousPacketsArray;
- PUSB_DK_ISO_TRANSFER_RESULT IsochronousResultsArray;
-};
-
-struct winusb_transfer_priv {
- struct winfd pollable_fd;
- HANDLE handle;
- uint8_t interface_number;
- uint8_t *hid_buffer; // 1 byte extended data buffer, required for HID
- uint8_t *hid_dest; // transfer buffer destination, required for HID
- size_t hid_expected_size;
-
- // For isochronous transfers with LibUSBk driver:
- void *iso_context;
-
- // For isochronous transfers with Microsoft WinUSB driver:
- void *isoch_buffer_handle; // The isoch_buffer_handle to free at the end of the transfer
- BOOL iso_break_stream; // Whether the isoch. stream was to be continued in the last call of libusb_submit_transfer.
- // As we this structure is zeroed out upon initialization, we need to use inverse logic here.
- libusb_transfer_cb_fn iso_user_callback; // Original transfer callback of the user. Might be used for isochronous transfers.
-};
diff --git a/libusb/os/windows_usbdk.c b/libusb/os/windows_usbdk.c
index 2b4f7e0..c9ebfcf 100644
--- a/libusb/os/windows_usbdk.c
+++ b/libusb/os/windows_usbdk.c
@@ -28,7 +28,6 @@
#include "libusbi.h"
#include "windows_common.h"
-#include "windows_nt_common.h"
#include "windows_usbdk.h"
#if !defined(STATUS_SUCCESS)
@@ -44,28 +43,6 @@ typedef LONG NTSTATUS;
#define STATUS_REQUEST_CANCELED ((NTSTATUS)0xC0000703L)
#endif
-#if !defined(USBD_SUCCESS)
-typedef LONG USBD_STATUS;
-#define USBD_SUCCESS(Status) ((USBD_STATUS) (Status) >= 0)
-#define USBD_PENDING(Status) ((ULONG) (Status) >> 30 == 1)
-#define USBD_ERROR(Status) ((USBD_STATUS) (Status) < 0)
-#define USBD_STATUS_STALL_PID ((USBD_STATUS) 0xc0000004)
-#define USBD_STATUS_ENDPOINT_HALTED ((USBD_STATUS) 0xc0000030)
-#define USBD_STATUS_BAD_START_FRAME ((USBD_STATUS) 0xc0000a00)
-#define USBD_STATUS_TIMEOUT ((USBD_STATUS) 0xc0006000)
-#define USBD_STATUS_CANCELED ((USBD_STATUS) 0xc0010000)
-#endif
-
-static inline struct usbdk_device_priv *_usbdk_device_priv(struct libusb_device *dev)
-{
- return (struct usbdk_device_priv *)dev->os_priv;
-}
-
-static inline struct usbdk_transfer_priv *_usbdk_transfer_priv(struct usbi_transfer *itransfer)
-{
- return (struct usbdk_transfer_priv *)usbi_transfer_get_os_priv(itransfer);
-}
-
static struct {
HMODULE module;
@@ -104,7 +81,7 @@ static void unload_usbdk_helper_dll(void)
static int load_usbdk_helper_dll(struct libusb_context *ctx)
{
- usbdk_helper.module = LoadLibraryA("UsbDkHelper");
+ usbdk_helper.module = load_system_library(ctx, "UsbDkHelper");
if (usbdk_helper.module == NULL) {
usbi_err(ctx, "Failed to load UsbDkHelper.dll: %s", windows_error_str(0));
return LIBUSB_ERROR_NOT_FOUND;
@@ -170,29 +147,65 @@ error_unload:
return LIBUSB_ERROR_NOT_FOUND;
}
+typedef SC_HANDLE (WINAPI *POPENSCMANAGERA)(LPCSTR, LPCSTR, DWORD);
+typedef SC_HANDLE (WINAPI *POPENSERVICEA)(SC_HANDLE, LPCSTR, DWORD);
+typedef BOOL (WINAPI *PCLOSESERVICEHANDLE)(SC_HANDLE);
+
static int usbdk_init(struct libusb_context *ctx)
{
+ POPENSCMANAGERA pOpenSCManagerA;
+ POPENSERVICEA pOpenServiceA;
+ PCLOSESERVICEHANDLE pCloseServiceHandle;
SC_HANDLE managerHandle;
SC_HANDLE serviceHandle;
+ HMODULE h;
+
+ h = load_system_library(ctx, "Advapi32");
+ if (h == NULL) {
+ usbi_warn(ctx, "failed to open Advapi32\n");
+ return LIBUSB_ERROR_OTHER;
+ }
+
+ pOpenSCManagerA = (POPENSCMANAGERA)GetProcAddress(h, "OpenSCManagerA");
+ if (pOpenSCManagerA == NULL) {
+ usbi_warn(ctx, "failed to find %s in Advapi32\n", "OpenSCManagerA");
+ goto error_free_library;
+ }
+ pOpenServiceA = (POPENSERVICEA)GetProcAddress(h, "OpenServiceA");
+ if (pOpenServiceA == NULL) {
+ usbi_warn(ctx, "failed to find %s in Advapi32\n", "OpenServiceA");
+ goto error_free_library;
+ }
+ pCloseServiceHandle = (PCLOSESERVICEHANDLE)GetProcAddress(h, "CloseServiceHandle");
+ if (pCloseServiceHandle == NULL) {
+ usbi_warn(ctx, "failed to find %s in Advapi32\n", "CloseServiceHandle");
+ goto error_free_library;
+ }
- managerHandle = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
+ managerHandle = pOpenSCManagerA(NULL, NULL, SC_MANAGER_CONNECT);
if (managerHandle == NULL) {
usbi_warn(ctx, "failed to open service control manager: %s", windows_error_str(0));
- return LIBUSB_ERROR_OTHER;
+ goto error_free_library;
}
- serviceHandle = OpenServiceA(managerHandle, "UsbDk", GENERIC_READ);
- CloseServiceHandle(managerHandle);
+ serviceHandle = pOpenServiceA(managerHandle, "UsbDk", GENERIC_READ);
+ pCloseServiceHandle(managerHandle);
if (serviceHandle == NULL) {
if (GetLastError() != ERROR_SERVICE_DOES_NOT_EXIST)
usbi_warn(ctx, "failed to open UsbDk service: %s", windows_error_str(0));
+ FreeLibrary(h);
return LIBUSB_ERROR_NOT_FOUND;
}
- CloseServiceHandle(serviceHandle);
+ pCloseServiceHandle(serviceHandle);
+ FreeLibrary(h);
return load_usbdk_helper_dll(ctx);
+
+error_free_library:
+ FreeLibrary(h);
+ return LIBUSB_ERROR_OTHER;
}
static void usbdk_exit(struct libusb_context *ctx)
@@ -216,26 +229,26 @@ static int usbdk_get_session_id_for_device(struct libusb_context *ctx,
return LIBUSB_SUCCESS;
}
-static void usbdk_release_config_descriptors(struct usbdk_device_priv *p, uint8_t count)
+static void usbdk_release_config_descriptors(struct usbdk_device_priv *priv, uint8_t count)
{
uint8_t i;
for (i = 0; i < count; i++)
- usbdk_helper.ReleaseConfigurationDescriptor(p->config_descriptors[i]);
+ usbdk_helper.ReleaseConfigurationDescriptor(priv->config_descriptors[i]);
- free(p->config_descriptors);
- p->config_descriptors = NULL;
+ free(priv->config_descriptors);
+ priv->config_descriptors = NULL;
}
static int usbdk_cache_config_descriptors(struct libusb_context *ctx,
- struct usbdk_device_priv *p, PUSB_DK_DEVICE_INFO info)
+ struct usbdk_device_priv *priv, PUSB_DK_DEVICE_INFO info)
{
uint8_t i;
USB_DK_CONFIG_DESCRIPTOR_REQUEST Request;
Request.ID = info->ID;
- p->config_descriptors = calloc(info->DeviceDescriptor.bNumConfigurations, sizeof(PUSB_CONFIGURATION_DESCRIPTOR));
- if (p->config_descriptors == NULL) {
+ priv->config_descriptors = calloc(info->DeviceDescriptor.bNumConfigurations, sizeof(PUSB_CONFIGURATION_DESCRIPTOR));
+ if (priv->config_descriptors == NULL) {
usbi_err(ctx, "failed to allocate configuration descriptors holder");
return LIBUSB_ERROR_NO_MEM;
}
@@ -244,9 +257,9 @@ static int usbdk_cache_config_descriptors(struct libusb_context *ctx,
ULONG Length;
Request.Index = i;
- if (!usbdk_helper.GetConfigurationDescriptor(&Request, &p->config_descriptors[i], &Length)) {
+ if (!usbdk_helper.GetConfigurationDescriptor(&Request, &priv->config_descriptors[i], &Length)) {
usbi_err(ctx, "failed to retrieve configuration descriptors");
- usbdk_release_config_descriptors(p, i);
+ usbdk_release_config_descriptors(priv, i);
return LIBUSB_ERROR_OTHER;
}
}
@@ -256,15 +269,15 @@ static int usbdk_cache_config_descriptors(struct libusb_context *ctx,
static inline int usbdk_device_priv_init(struct libusb_context *ctx, struct libusb_device *dev, PUSB_DK_DEVICE_INFO info)
{
- struct usbdk_device_priv *p = _usbdk_device_priv(dev);
+ struct usbdk_device_priv *priv = usbi_get_device_priv(dev);
- p->info = *info;
- p->active_configuration = 0;
+ priv->ID = info->ID;
+ priv->active_configuration = 0;
- return usbdk_cache_config_descriptors(ctx, p, info);
+ return usbdk_cache_config_descriptors(ctx, priv, info);
}
-static void usbdk_device_init(libusb_device *dev, PUSB_DK_DEVICE_INFO info)
+static void usbdk_device_init(struct libusb_device *dev, PUSB_DK_DEVICE_INFO info)
{
dev->bus_number = (uint8_t)info->FilterID;
dev->port_number = (uint8_t)info->Port;
@@ -273,8 +286,10 @@ static void usbdk_device_init(libusb_device *dev, PUSB_DK_DEVICE_INFO info)
// Addresses in libusb are 1-based
dev->device_address = (uint8_t)(info->Port + 1);
- dev->num_configurations = info->DeviceDescriptor.bNumConfigurations;
+ static_assert(sizeof(dev->device_descriptor) == sizeof(info->DeviceDescriptor),
+ "mismatch between libusb and OS device descriptor sizes");
memcpy(&dev->device_descriptor, &info->DeviceDescriptor, LIBUSB_DT_DEVICE_SIZE);
+ usbi_localize_device_descriptor(&dev->device_descriptor);
switch (info->Speed) {
case LowSpeed:
@@ -345,24 +360,12 @@ func_exit:
return r;
}
-static int usbdk_get_device_descriptor(struct libusb_device *dev, unsigned char *buffer)
+static int usbdk_get_config_descriptor(struct libusb_device *dev, uint8_t config_index, void *buffer, size_t len)
{
- struct usbdk_device_priv *priv = _usbdk_device_priv(dev);
-
- memcpy(buffer, &priv->info.DeviceDescriptor, DEVICE_DESC_LENGTH);
-
- return LIBUSB_SUCCESS;
-}
-
-static int usbdk_get_config_descriptor(struct libusb_device *dev, uint8_t config_index, unsigned char *buffer, size_t len)
-{
- struct usbdk_device_priv *priv = _usbdk_device_priv(dev);
+ struct usbdk_device_priv *priv = usbi_get_device_priv(dev);
PUSB_CONFIGURATION_DESCRIPTOR config_header;
size_t size;
- if (config_index >= dev->num_configurations)
- return LIBUSB_ERROR_INVALID_PARAM;
-
config_header = (PUSB_CONFIGURATION_DESCRIPTOR)priv->config_descriptors[config_index];
size = min(config_header->wTotalLength, len);
@@ -371,16 +374,16 @@ static int usbdk_get_config_descriptor(struct libusb_device *dev, uint8_t config
}
static int usbdk_get_config_descriptor_by_value(struct libusb_device *dev, uint8_t bConfigurationValue,
- unsigned char **buffer)
+ void **buffer)
{
- struct usbdk_device_priv *priv = _usbdk_device_priv(dev);
+ struct usbdk_device_priv *priv = usbi_get_device_priv(dev);
PUSB_CONFIGURATION_DESCRIPTOR config_header;
uint8_t index;
- for (index = 0; index < dev->num_configurations; index++) {
+ for (index = 0; index < dev->device_descriptor.bNumConfigurations; index++) {
config_header = priv->config_descriptors[index];
if (config_header->bConfigurationValue == bConfigurationValue) {
- *buffer = (unsigned char *)priv->config_descriptors[index];
+ *buffer = priv->config_descriptors[index];
return (int)config_header->wTotalLength;
}
}
@@ -388,70 +391,87 @@ static int usbdk_get_config_descriptor_by_value(struct libusb_device *dev, uint8
return LIBUSB_ERROR_NOT_FOUND;
}
-static int usbdk_get_active_config_descriptor(struct libusb_device *dev, unsigned char *buffer, size_t len)
+static int usbdk_get_active_config_descriptor(struct libusb_device *dev, void *buffer, size_t len)
{
- return usbdk_get_config_descriptor(dev, _usbdk_device_priv(dev)->active_configuration,
- buffer, len);
+ struct usbdk_device_priv *priv = usbi_get_device_priv(dev);
+
+ return usbdk_get_config_descriptor(dev, priv->active_configuration, buffer, len);
}
static int usbdk_open(struct libusb_device_handle *dev_handle)
{
- struct usbdk_device_priv *priv = _usbdk_device_priv(dev_handle->dev);
+ struct libusb_device *dev = dev_handle->dev;
+ struct libusb_context *ctx = DEVICE_CTX(dev);
+ struct windows_context_priv *priv = usbi_get_context_priv(ctx);
+ struct usbdk_device_priv *device_priv = usbi_get_device_priv(dev);
- priv->redirector_handle = usbdk_helper.StartRedirect(&priv->info.ID);
- if (priv->redirector_handle == INVALID_HANDLE_VALUE) {
- usbi_err(DEVICE_CTX(dev_handle->dev), "Redirector startup failed");
+ device_priv->redirector_handle = usbdk_helper.StartRedirect(&device_priv->ID);
+ if (device_priv->redirector_handle == INVALID_HANDLE_VALUE) {
+ usbi_err(ctx, "Redirector startup failed");
+ device_priv->redirector_handle = NULL;
return LIBUSB_ERROR_OTHER;
}
- priv->system_handle = usbdk_helper.GetRedirectorSystemHandle(priv->redirector_handle);
+ device_priv->system_handle = usbdk_helper.GetRedirectorSystemHandle(device_priv->redirector_handle);
+
+ if (CreateIoCompletionPort(device_priv->system_handle, priv->completion_port, 0, 0) == NULL) {
+ usbi_err(ctx, "failed to associate handle to I/O completion port: %s", windows_error_str(0));
+ usbdk_helper.StopRedirect(device_priv->redirector_handle);
+ device_priv->system_handle = NULL;
+ device_priv->redirector_handle = NULL;
+ return LIBUSB_ERROR_OTHER;
+ }
return LIBUSB_SUCCESS;
}
static void usbdk_close(struct libusb_device_handle *dev_handle)
{
- struct usbdk_device_priv *priv = _usbdk_device_priv(dev_handle->dev);
+ struct usbdk_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
if (!usbdk_helper.StopRedirect(priv->redirector_handle))
usbi_err(HANDLE_CTX(dev_handle), "Redirector shutdown failed");
+
+ priv->system_handle = NULL;
+ priv->redirector_handle = NULL;
}
-static int usbdk_get_configuration(struct libusb_device_handle *dev_handle, int *config)
+static int usbdk_get_configuration(struct libusb_device_handle *dev_handle, uint8_t *config)
{
- *config = _usbdk_device_priv(dev_handle->dev)->active_configuration;
+ struct usbdk_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
+
+ *config = priv->active_configuration;
return LIBUSB_SUCCESS;
}
-static int usbdk_set_configuration(struct libusb_device_handle *dev_handle, int config)
+static int usbdk_set_configuration(struct libusb_device_handle *dev_handle, uint8_t config)
{
UNUSED(dev_handle);
UNUSED(config);
return LIBUSB_SUCCESS;
}
-static int usbdk_claim_interface(struct libusb_device_handle *dev_handle, int iface)
+static int usbdk_claim_interface(struct libusb_device_handle *dev_handle, uint8_t iface)
{
UNUSED(dev_handle);
UNUSED(iface);
return LIBUSB_SUCCESS;
}
-static int usbdk_set_interface_altsetting(struct libusb_device_handle *dev_handle, int iface, int altsetting)
+static int usbdk_set_interface_altsetting(struct libusb_device_handle *dev_handle, uint8_t iface, uint8_t altsetting)
{
- struct libusb_context *ctx = HANDLE_CTX(dev_handle);
- struct usbdk_device_priv *priv = _usbdk_device_priv(dev_handle->dev);
+ struct usbdk_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
if (!usbdk_helper.SetAltsetting(priv->redirector_handle, iface, altsetting)) {
- usbi_err(ctx, "SetAltsetting failed: %s", windows_error_str(0));
+ usbi_err(HANDLE_CTX(dev_handle), "SetAltsetting failed: %s", windows_error_str(0));
return LIBUSB_ERROR_NO_DEVICE;
}
return LIBUSB_SUCCESS;
}
-static int usbdk_release_interface(struct libusb_device_handle *dev_handle, int iface)
+static int usbdk_release_interface(struct libusb_device_handle *dev_handle, uint8_t iface)
{
UNUSED(dev_handle);
UNUSED(iface);
@@ -460,11 +480,10 @@ static int usbdk_release_interface(struct libusb_device_handle *dev_handle, int
static int usbdk_clear_halt(struct libusb_device_handle *dev_handle, unsigned char endpoint)
{
- struct libusb_context *ctx = HANDLE_CTX(dev_handle);
- struct usbdk_device_priv *priv = _usbdk_device_priv(dev_handle->dev);
+ struct usbdk_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
if (!usbdk_helper.ResetPipe(priv->redirector_handle, endpoint)) {
- usbi_err(ctx, "ResetPipe failed: %s", windows_error_str(0));
+ usbi_err(HANDLE_CTX(dev_handle), "ResetPipe failed: %s", windows_error_str(0));
return LIBUSB_ERROR_NO_DEVICE;
}
@@ -473,11 +492,10 @@ static int usbdk_clear_halt(struct libusb_device_handle *dev_handle, unsigned ch
static int usbdk_reset_device(struct libusb_device_handle *dev_handle)
{
- struct libusb_context *ctx = HANDLE_CTX(dev_handle);
- struct usbdk_device_priv *priv = _usbdk_device_priv(dev_handle->dev);
+ struct usbdk_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
if (!usbdk_helper.ResetDevice(priv->redirector_handle)) {
- usbi_err(ctx, "ResetDevice failed: %s", windows_error_str(0));
+ usbi_err(HANDLE_CTX(dev_handle), "ResetDevice failed: %s", windows_error_str(0));
return LIBUSB_ERROR_NO_DEVICE;
}
@@ -486,21 +504,17 @@ static int usbdk_reset_device(struct libusb_device_handle *dev_handle)
static void usbdk_destroy_device(struct libusb_device *dev)
{
- struct usbdk_device_priv* p = _usbdk_device_priv(dev);
+ struct usbdk_device_priv *priv = usbi_get_device_priv(dev);
- if (p->config_descriptors != NULL)
- usbdk_release_config_descriptors(p, p->info.DeviceDescriptor.bNumConfigurations);
+ if (priv->config_descriptors != NULL)
+ usbdk_release_config_descriptors(priv, dev->device_descriptor.bNumConfigurations);
}
static void usbdk_clear_transfer_priv(struct usbi_transfer *itransfer)
{
- struct usbdk_transfer_priv *transfer_priv = _usbdk_transfer_priv(itransfer);
+ struct usbdk_transfer_priv *transfer_priv = get_usbdk_transfer_priv(itransfer);
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- usbi_close(transfer_priv->pollable_fd.fd);
- transfer_priv->pollable_fd = INVALID_WINFD;
- transfer_priv->system_handle = NULL;
-
if (transfer->type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS) {
safe_free(transfer_priv->IsochronousPacketsArray);
safe_free(transfer_priv->IsochronousResultsArray);
@@ -510,16 +524,17 @@ static void usbdk_clear_transfer_priv(struct usbi_transfer *itransfer)
static int usbdk_do_control_transfer(struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct usbdk_device_priv *priv = _usbdk_device_priv(transfer->dev_handle->dev);
- struct usbdk_transfer_priv *transfer_priv = _usbdk_transfer_priv(itransfer);
- struct libusb_context *ctx = TRANSFER_CTX(transfer);
- OVERLAPPED *overlapped = transfer_priv->pollable_fd.overlapped;
+ struct usbdk_device_priv *priv = usbi_get_device_priv(transfer->dev_handle->dev);
+ struct usbdk_transfer_priv *transfer_priv = get_usbdk_transfer_priv(itransfer);
+ OVERLAPPED *overlapped = get_transfer_priv_overlapped(itransfer);
TransferResult transResult;
transfer_priv->request.Buffer = (PVOID64)transfer->buffer;
transfer_priv->request.BufferLength = transfer->length;
transfer_priv->request.TransferType = ControlTransferType;
+ set_transfer_priv_handle(itransfer, priv->system_handle);
+
if (transfer->buffer[0] & LIBUSB_ENDPOINT_IN)
transResult = usbdk_helper.ReadPipe(priv->redirector_handle, &transfer_priv->request, overlapped);
else
@@ -527,12 +542,12 @@ static int usbdk_do_control_transfer(struct usbi_transfer *itransfer)
switch (transResult) {
case TransferSuccess:
- windows_force_sync_completion(overlapped, (ULONG)transfer_priv->request.Result.GenResult.BytesTransferred);
+ windows_force_sync_completion(itransfer, (ULONG)transfer_priv->request.Result.GenResult.BytesTransferred);
break;
case TransferSuccessAsync:
break;
case TransferFailure:
- usbi_err(ctx, "ControlTransfer failed: %s", windows_error_str(0));
+ usbi_err(TRANSFER_CTX(transfer), "ControlTransfer failed: %s", windows_error_str(0));
return LIBUSB_ERROR_IO;
}
@@ -542,10 +557,9 @@ static int usbdk_do_control_transfer(struct usbi_transfer *itransfer)
static int usbdk_do_bulk_transfer(struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct usbdk_device_priv *priv = _usbdk_device_priv(transfer->dev_handle->dev);
- struct usbdk_transfer_priv *transfer_priv = _usbdk_transfer_priv(itransfer);
- struct libusb_context *ctx = TRANSFER_CTX(transfer);
- OVERLAPPED *overlapped = transfer_priv->pollable_fd.overlapped;
+ struct usbdk_device_priv *priv = usbi_get_device_priv(transfer->dev_handle->dev);
+ struct usbdk_transfer_priv *transfer_priv = get_usbdk_transfer_priv(itransfer);
+ OVERLAPPED *overlapped = get_transfer_priv_overlapped(itransfer);
TransferResult transferRes;
transfer_priv->request.Buffer = (PVOID64)transfer->buffer;
@@ -559,11 +573,10 @@ static int usbdk_do_bulk_transfer(struct usbi_transfer *itransfer)
case LIBUSB_TRANSFER_TYPE_INTERRUPT:
transfer_priv->request.TransferType = InterruptTransferType;
break;
- default:
- usbi_err(ctx, "Wrong transfer type (%d) in usbdk_do_bulk_transfer", transfer->type);
- return LIBUSB_ERROR_INVALID_PARAM;
}
+ set_transfer_priv_handle(itransfer, priv->system_handle);
+
if (IS_XFERIN(transfer))
transferRes = usbdk_helper.ReadPipe(priv->redirector_handle, &transfer_priv->request, overlapped);
else
@@ -571,12 +584,12 @@ static int usbdk_do_bulk_transfer(struct usbi_transfer *itransfer)
switch (transferRes) {
case TransferSuccess:
- windows_force_sync_completion(overlapped, (ULONG)transfer_priv->request.Result.GenResult.BytesTransferred);
+ windows_force_sync_completion(itransfer, (ULONG)transfer_priv->request.Result.GenResult.BytesTransferred);
break;
case TransferSuccessAsync:
break;
case TransferFailure:
- usbi_err(ctx, "ReadPipe/WritePipe failed: %s", windows_error_str(0));
+ usbi_err(TRANSFER_CTX(transfer), "ReadPipe/WritePipe failed: %s", windows_error_str(0));
return LIBUSB_ERROR_IO;
}
@@ -586,10 +599,9 @@ static int usbdk_do_bulk_transfer(struct usbi_transfer *itransfer)
static int usbdk_do_iso_transfer(struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct usbdk_device_priv *priv = _usbdk_device_priv(transfer->dev_handle->dev);
- struct usbdk_transfer_priv *transfer_priv = _usbdk_transfer_priv(itransfer);
- struct libusb_context *ctx = TRANSFER_CTX(transfer);
- OVERLAPPED *overlapped = transfer_priv->pollable_fd.overlapped;
+ struct usbdk_device_priv *priv = usbi_get_device_priv(transfer->dev_handle->dev);
+ struct usbdk_transfer_priv *transfer_priv = get_usbdk_transfer_priv(itransfer);
+ OVERLAPPED *overlapped = get_transfer_priv_overlapped(itransfer);
TransferResult transferRes;
int i;
@@ -601,20 +613,22 @@ static int usbdk_do_iso_transfer(struct usbi_transfer *itransfer)
transfer_priv->IsochronousPacketsArray = malloc(transfer->num_iso_packets * sizeof(ULONG64));
transfer_priv->request.IsochronousPacketsArray = (PVOID64)transfer_priv->IsochronousPacketsArray;
if (!transfer_priv->IsochronousPacketsArray) {
- usbi_err(ctx, "Allocation of IsochronousPacketsArray failed");
+ usbi_err(TRANSFER_CTX(transfer), "Allocation of IsochronousPacketsArray failed");
return LIBUSB_ERROR_NO_MEM;
}
transfer_priv->IsochronousResultsArray = malloc(transfer->num_iso_packets * sizeof(USB_DK_ISO_TRANSFER_RESULT));
transfer_priv->request.Result.IsochronousResultsArray = (PVOID64)transfer_priv->IsochronousResultsArray;
if (!transfer_priv->IsochronousResultsArray) {
- usbi_err(ctx, "Allocation of isochronousResultsArray failed");
+ usbi_err(TRANSFER_CTX(transfer), "Allocation of isochronousResultsArray failed");
return LIBUSB_ERROR_NO_MEM;
}
for (i = 0; i < transfer->num_iso_packets; i++)
transfer_priv->IsochronousPacketsArray[i] = transfer->iso_packet_desc[i].length;
+ set_transfer_priv_handle(itransfer, priv->system_handle);
+
if (IS_XFERIN(transfer))
transferRes = usbdk_helper.ReadPipe(priv->redirector_handle, &transfer_priv->request, overlapped);
else
@@ -622,7 +636,7 @@ static int usbdk_do_iso_transfer(struct usbi_transfer *itransfer)
switch (transferRes) {
case TransferSuccess:
- windows_force_sync_completion(overlapped, (ULONG)transfer_priv->request.Result.GenResult.BytesTransferred);
+ windows_force_sync_completion(itransfer, (ULONG)transfer_priv->request.Result.GenResult.BytesTransferred);
break;
case TransferSuccessAsync:
break;
@@ -633,174 +647,58 @@ static int usbdk_do_iso_transfer(struct usbi_transfer *itransfer)
return LIBUSB_SUCCESS;
}
-static int usbdk_do_submit_transfer(struct usbi_transfer *itransfer,
- short events, int (*transfer_fn)(struct usbi_transfer *))
-{
- struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct libusb_context *ctx = TRANSFER_CTX(transfer);
- struct usbdk_device_priv *priv = _usbdk_device_priv(transfer->dev_handle->dev);
- struct usbdk_transfer_priv *transfer_priv = _usbdk_transfer_priv(itransfer);
- struct winfd wfd;
- int r;
-
- wfd = usbi_create_fd();
- if (wfd.fd < 0)
- return LIBUSB_ERROR_NO_MEM;
-
- r = usbi_add_pollfd(ctx, wfd.fd, events);
- if (r) {
- usbi_close(wfd.fd);
- return r;
- }
-
- // Use transfer_priv to store data needed for async polling
- transfer_priv->pollable_fd = wfd;
- transfer_priv->system_handle = priv->system_handle;
-
- r = transfer_fn(itransfer);
- if (r != LIBUSB_SUCCESS) {
- usbi_remove_pollfd(ctx, wfd.fd);
- usbdk_clear_transfer_priv(itransfer);
- return r;
- }
-
- return LIBUSB_SUCCESS;
-}
-
static int usbdk_submit_transfer(struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- int (*transfer_fn)(struct usbi_transfer *);
- short events;
switch (transfer->type) {
case LIBUSB_TRANSFER_TYPE_CONTROL:
- events = (transfer->buffer[0] & LIBUSB_ENDPOINT_IN) ? POLLIN : POLLOUT;
- transfer_fn = usbdk_do_control_transfer;
- break;
+ return usbdk_do_control_transfer(itransfer);
case LIBUSB_TRANSFER_TYPE_BULK:
case LIBUSB_TRANSFER_TYPE_INTERRUPT:
if (IS_XFEROUT(transfer) && (transfer->flags & LIBUSB_TRANSFER_ADD_ZERO_PACKET))
return LIBUSB_ERROR_NOT_SUPPORTED; //TODO: Check whether we can support this in UsbDk
- events = IS_XFERIN(transfer) ? POLLIN : POLLOUT;
- transfer_fn = usbdk_do_bulk_transfer;
- break;
+ return usbdk_do_bulk_transfer(itransfer);
case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
- events = IS_XFERIN(transfer) ? POLLIN : POLLOUT;
- transfer_fn = usbdk_do_iso_transfer;
- break;
+ return usbdk_do_iso_transfer(itransfer);
default:
- usbi_err(TRANSFER_CTX(transfer), "unknown endpoint type %d", transfer->type);
- return LIBUSB_ERROR_INVALID_PARAM;
+ // Should not get here since windows_submit_transfer() validates
+ // the transfer->type field
+ usbi_err(TRANSFER_CTX(transfer), "unsupported endpoint type %d", transfer->type);
+ return LIBUSB_ERROR_NOT_SUPPORTED;
}
-
- return usbdk_do_submit_transfer(itransfer, events, transfer_fn);
}
-static int usbdk_abort_transfers(struct usbi_transfer *itransfer)
+static enum libusb_transfer_status usbdk_copy_transfer_data(struct usbi_transfer *itransfer, DWORD length)
{
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct libusb_context *ctx = TRANSFER_CTX(transfer);
- struct usbdk_device_priv *priv = _usbdk_device_priv(transfer->dev_handle->dev);
- struct usbdk_transfer_priv *transfer_priv = _usbdk_transfer_priv(itransfer);
- struct winfd *pollable_fd = &transfer_priv->pollable_fd;
-
- if (pCancelIoEx != NULL) {
- // Use CancelIoEx if available to cancel just a single transfer
- if (!pCancelIoEx(priv->system_handle, pollable_fd->overlapped)) {
- usbi_err(ctx, "CancelIoEx failed: %s", windows_error_str(0));
- return LIBUSB_ERROR_NO_DEVICE;
- }
- } else {
- if (!usbdk_helper.AbortPipe(priv->redirector_handle, transfer->endpoint)) {
- usbi_err(ctx, "AbortPipe failed: %s", windows_error_str(0));
- return LIBUSB_ERROR_NO_DEVICE;
- }
- }
+ struct usbdk_transfer_priv *transfer_priv = get_usbdk_transfer_priv(itransfer);
- return LIBUSB_SUCCESS;
-}
+ UNUSED(length);
-static int usbdk_cancel_transfer(struct usbi_transfer *itransfer)
-{
- struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
-
- switch (transfer->type) {
- case LIBUSB_TRANSFER_TYPE_CONTROL:
- // Control transfers cancelled by IoCancelXXX() API
- // No special treatment needed
- return LIBUSB_SUCCESS;
- case LIBUSB_TRANSFER_TYPE_BULK:
- case LIBUSB_TRANSFER_TYPE_INTERRUPT:
- case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
- return usbdk_abort_transfers(itransfer);
- default:
- usbi_err(ITRANSFER_CTX(itransfer), "unknown endpoint type %d", transfer->type);
- return LIBUSB_ERROR_INVALID_PARAM;
- }
-}
-
-static int usbdk_copy_transfer_data(struct usbi_transfer *itransfer, uint32_t io_size)
-{
- itransfer->transferred += io_size;
- return LIBUSB_TRANSFER_COMPLETED;
-}
-
-static int usbdk_get_transfer_fd(struct usbi_transfer *itransfer)
-{
- struct usbdk_transfer_priv *transfer_priv = _usbdk_transfer_priv(itransfer);
- return transfer_priv->pollable_fd.fd;
-}
-
-static DWORD usbdk_translate_usbd_status(USBD_STATUS UsbdStatus)
-{
- if (USBD_SUCCESS(UsbdStatus))
- return NO_ERROR;
-
- switch (UsbdStatus) {
- case USBD_STATUS_TIMEOUT:
- return ERROR_SEM_TIMEOUT;
- case USBD_STATUS_CANCELED:
- return ERROR_OPERATION_ABORTED;
- default:
- return ERROR_GEN_FAILURE;
- }
-}
-
-static void usbdk_get_overlapped_result(struct usbi_transfer *itransfer, DWORD *io_result, DWORD *io_size)
-{
- struct usbdk_transfer_priv *transfer_priv = _usbdk_transfer_priv(itransfer);
- struct winfd *pollable_fd = &transfer_priv->pollable_fd;
-
- if (HasOverlappedIoCompletedSync(pollable_fd->overlapped) // Handle async requests that completed synchronously first
- || GetOverlappedResult(transfer_priv->system_handle, pollable_fd->overlapped, io_size, FALSE)) { // Regular async overlapped
- struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
-
- if (transfer->type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS) {
- ULONG64 i;
- for (i = 0; i < transfer_priv->request.IsochronousPacketsArraySize; i++) {
- struct libusb_iso_packet_descriptor *lib_desc = &transfer->iso_packet_desc[i];
-
- switch (transfer_priv->IsochronousResultsArray[i].TransferResult) {
- case STATUS_SUCCESS:
- case STATUS_CANCELLED:
- case STATUS_REQUEST_CANCELED:
- lib_desc->status = LIBUSB_TRANSFER_COMPLETED; // == ERROR_SUCCESS
- break;
- default:
- lib_desc->status = LIBUSB_TRANSFER_ERROR; // ERROR_UNKNOWN_EXCEPTION;
- break;
- }
-
- lib_desc->actual_length = (unsigned int)transfer_priv->IsochronousResultsArray[i].ActualLength;
+ if (transfer->type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS) {
+ ULONG64 i;
+
+ for (i = 0; i < transfer_priv->request.IsochronousPacketsArraySize; i++) {
+ struct libusb_iso_packet_descriptor *lib_desc = &transfer->iso_packet_desc[i];
+
+ switch (transfer_priv->IsochronousResultsArray[i].TransferResult) {
+ case STATUS_SUCCESS:
+ case STATUS_CANCELLED:
+ case STATUS_REQUEST_CANCELED:
+ lib_desc->status = LIBUSB_TRANSFER_COMPLETED; // == ERROR_SUCCESS
+ break;
+ default:
+ lib_desc->status = LIBUSB_TRANSFER_ERROR; // ERROR_UNKNOWN_EXCEPTION;
+ break;
}
- }
- *io_size = (DWORD)transfer_priv->request.Result.GenResult.BytesTransferred;
- *io_result = usbdk_translate_usbd_status((USBD_STATUS)transfer_priv->request.Result.GenResult.UsbdStatus);
- } else {
- *io_result = GetLastError();
+ lib_desc->actual_length = (unsigned int)transfer_priv->IsochronousResultsArray[i].ActualLength;
+ }
}
+
+ itransfer->transferred += (int)transfer_priv->request.Result.GenResult.BytesTransferred;
+ return usbd_status_to_libusb_transfer_status((USBD_STATUS)transfer_priv->request.Result.GenResult.UsbdStatus);
}
const struct windows_backend usbdk_backend = {
@@ -809,7 +707,6 @@ const struct windows_backend usbdk_backend = {
usbdk_get_device_list,
usbdk_open,
usbdk_close,
- usbdk_get_device_descriptor,
usbdk_get_active_config_descriptor,
usbdk_get_config_descriptor,
usbdk_get_config_descriptor_by_value,
@@ -822,9 +719,7 @@ const struct windows_backend usbdk_backend = {
usbdk_reset_device,
usbdk_destroy_device,
usbdk_submit_transfer,
- usbdk_cancel_transfer,
+ NULL, /* cancel_transfer */
usbdk_clear_transfer_priv,
usbdk_copy_transfer_data,
- usbdk_get_transfer_fd,
- usbdk_get_overlapped_result,
};
diff --git a/libusb/os/windows_usbdk.h b/libusb/os/windows_usbdk.h
index 77660ae..0eb3779 100644
--- a/libusb/os/windows_usbdk.h
+++ b/libusb/os/windows_usbdk.h
@@ -21,9 +21,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#pragma once
+#ifndef LIBUSB_WINDOWS_USBDK_H
+#define LIBUSB_WINDOWS_USBDK_H
-#include "windows_nt_common.h"
+#include "windows_common.h"
typedef struct USB_DK_CONFIG_DESCRIPTOR_REQUEST {
USB_DK_DEVICE_ID ID;
@@ -101,3 +102,5 @@ typedef BOOL (__cdecl *USBDK_RESET_DEVICE)(
typedef HANDLE (__cdecl *USBDK_GET_REDIRECTOR_SYSTEM_HANDLE)(
HANDLE DeviceHandle
);
+
+#endif
diff --git a/libusb/os/windows_winusb.c b/libusb/os/windows_winusb.c
index 1b42d4e..f291b8e 100644
--- a/libusb/os/windows_winusb.c
+++ b/libusb/os/windows_winusb.c
@@ -28,28 +28,19 @@
#include <windows.h>
#include <setupapi.h>
#include <ctype.h>
-#include <errno.h>
#include <fcntl.h>
#include <process.h>
#include <stdio.h>
-#include <inttypes.h>
#include <objbase.h>
#include <winioctl.h>
#include "libusbi.h"
#include "windows_common.h"
-#include "windows_nt_common.h"
#include "windows_winusb.h"
#define HANDLE_VALID(h) (((h) != NULL) && ((h) != INVALID_HANDLE_VALUE))
-// The 2 macros below are used in conjunction with safe loops.
-#define LOOP_CHECK(fcall) \
- { \
- r = fcall; \
- if (r != LIBUSB_SUCCESS) \
- continue; \
- }
+// The below macro is used in conjunction with safe loops.
#define LOOP_BREAK(err) \
{ \
r = err; \
@@ -57,68 +48,63 @@
}
// WinUSB-like API prototypes
-static int winusbx_init(struct libusb_context *ctx);
+static bool winusbx_init(struct libusb_context *ctx);
static void winusbx_exit(void);
static int winusbx_open(int sub_api, struct libusb_device_handle *dev_handle);
static void winusbx_close(int sub_api, struct libusb_device_handle *dev_handle);
-static int winusbx_configure_endpoints(int sub_api, struct libusb_device_handle *dev_handle, int iface);
-static int winusbx_claim_interface(int sub_api, struct libusb_device_handle *dev_handle, int iface);
-static int winusbx_release_interface(int sub_api, struct libusb_device_handle *dev_handle, int iface);
+static int winusbx_configure_endpoints(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface);
+static int winusbx_claim_interface(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface);
+static int winusbx_release_interface(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface);
static int winusbx_submit_control_transfer(int sub_api, struct usbi_transfer *itransfer);
-static int winusbx_set_interface_altsetting(int sub_api, struct libusb_device_handle *dev_handle, int iface, int altsetting);
+static int winusbx_set_interface_altsetting(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface, uint8_t altsetting);
static int winusbx_submit_iso_transfer(int sub_api, struct usbi_transfer *itransfer);
static int winusbx_submit_bulk_transfer(int sub_api, struct usbi_transfer *itransfer);
static int winusbx_clear_halt(int sub_api, struct libusb_device_handle *dev_handle, unsigned char endpoint);
-static int winusbx_abort_transfers(int sub_api, struct usbi_transfer *itransfer);
-static int winusbx_abort_control(int sub_api, struct usbi_transfer *itransfer);
+static int winusbx_cancel_transfer(int sub_api, struct usbi_transfer *itransfer);
static int winusbx_reset_device(int sub_api, struct libusb_device_handle *dev_handle);
-static int winusbx_copy_transfer_data(int sub_api, struct usbi_transfer *itransfer, uint32_t io_size);
+static enum libusb_transfer_status winusbx_copy_transfer_data(int sub_api, struct usbi_transfer *itransfer, DWORD length);
// HID API prototypes
-static int hid_init(struct libusb_context *ctx);
+static bool hid_init(struct libusb_context *ctx);
static void hid_exit(void);
static int hid_open(int sub_api, struct libusb_device_handle *dev_handle);
static void hid_close(int sub_api, struct libusb_device_handle *dev_handle);
-static int hid_claim_interface(int sub_api, struct libusb_device_handle *dev_handle, int iface);
-static int hid_release_interface(int sub_api, struct libusb_device_handle *dev_handle, int iface);
-static int hid_set_interface_altsetting(int sub_api, struct libusb_device_handle *dev_handle, int iface, int altsetting);
+static int hid_claim_interface(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface);
+static int hid_release_interface(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface);
+static int hid_set_interface_altsetting(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface, uint8_t altsetting);
static int hid_submit_control_transfer(int sub_api, struct usbi_transfer *itransfer);
static int hid_submit_bulk_transfer(int sub_api, struct usbi_transfer *itransfer);
static int hid_clear_halt(int sub_api, struct libusb_device_handle *dev_handle, unsigned char endpoint);
-static int hid_abort_transfers(int sub_api, struct usbi_transfer *itransfer);
static int hid_reset_device(int sub_api, struct libusb_device_handle *dev_handle);
-static int hid_copy_transfer_data(int sub_api, struct usbi_transfer *itransfer, uint32_t io_size);
+static enum libusb_transfer_status hid_copy_transfer_data(int sub_api, struct usbi_transfer *itransfer, DWORD length);
// Composite API prototypes
static int composite_open(int sub_api, struct libusb_device_handle *dev_handle);
static void composite_close(int sub_api, struct libusb_device_handle *dev_handle);
-static int composite_claim_interface(int sub_api, struct libusb_device_handle *dev_handle, int iface);
-static int composite_set_interface_altsetting(int sub_api, struct libusb_device_handle *dev_handle, int iface, int altsetting);
-static int composite_release_interface(int sub_api, struct libusb_device_handle *dev_handle, int iface);
+static int composite_claim_interface(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface);
+static int composite_set_interface_altsetting(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface, uint8_t altsetting);
+static int composite_release_interface(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface);
static int composite_submit_control_transfer(int sub_api, struct usbi_transfer *itransfer);
static int composite_submit_bulk_transfer(int sub_api, struct usbi_transfer *itransfer);
static int composite_submit_iso_transfer(int sub_api, struct usbi_transfer *itransfer);
static int composite_clear_halt(int sub_api, struct libusb_device_handle *dev_handle, unsigned char endpoint);
-static int composite_abort_transfers(int sub_api, struct usbi_transfer *itransfer);
-static int composite_abort_control(int sub_api, struct usbi_transfer *itransfer);
+static int composite_cancel_transfer(int sub_api, struct usbi_transfer *itransfer);
static int composite_reset_device(int sub_api, struct libusb_device_handle *dev_handle);
-static int composite_copy_transfer_data(int sub_api, struct usbi_transfer *itransfer, uint32_t io_size);
+static enum libusb_transfer_status composite_copy_transfer_data(int sub_api, struct usbi_transfer *itransfer, DWORD length);
static usbi_mutex_t autoclaim_lock;
// API globals
-static HMODULE WinUSBX_handle = NULL;
static struct winusb_interface WinUSBX[SUB_API_MAX];
#define CHECK_WINUSBX_AVAILABLE(sub_api) \
do { \
if (sub_api == SUB_API_NOTSET) \
sub_api = priv->sub_api; \
- if (!WinUSBX[sub_api].initialized) \
+ if (WinUSBX[sub_api].hDll == NULL) \
return LIBUSB_ERROR_ACCESS; \
} while (0)
-static bool api_hid_available = false;
#define CHECK_HID_AVAILABLE \
do { \
- if (!api_hid_available) \
+ if (DLL_HANDLE_NAME(hid) == NULL) \
return LIBUSB_ERROR_ACCESS; \
} while (0)
@@ -140,43 +126,19 @@ static const char *guid_to_string(const GUID *guid)
#endif
/*
- * Sanitize Microsoft's paths: convert to uppercase, add prefix and fix backslashes.
- * Return an allocated sanitized string or NULL on error.
+ * Normalize Microsoft's paths: return a duplicate of the given path
+ * with all characters converted to uppercase
*/
-static char *sanitize_path(const char *path)
+static char *normalize_path(const char *path)
{
- const char root_prefix[] = {'\\', '\\', '.', '\\'};
- size_t j, size;
- char *ret_path;
- size_t add_root = 0;
-
- if (path == NULL)
- return NULL;
-
- size = strlen(path) + 1;
-
- // Microsoft indiscriminately uses '\\?\', '\\.\', '##?#" or "##.#" for root prefixes.
- if (!((size > 3) && (((path[0] == '\\') && (path[1] == '\\') && (path[3] == '\\'))
- || ((path[0] == '#') && (path[1] == '#') && (path[3] == '#'))))) {
- add_root = sizeof(root_prefix);
- size += add_root;
- }
+ char *ret_path = _strdup(path);
+ char *p;
- ret_path = malloc(size);
if (ret_path == NULL)
return NULL;
- strcpy(&ret_path[add_root], path);
-
- // Ensure consistency with root prefix
- memcpy(ret_path, root_prefix, sizeof(root_prefix));
-
- // Same goes for '\' and '#' after the root prefix. Ensure '#' is used
- for (j = sizeof(root_prefix); j < size; j++) {
- ret_path[j] = (char)toupper((int)ret_path[j]); // Fix case too
- if (ret_path[j] == '\\')
- ret_path[j] = '#';
- }
+ for (p = ret_path; *p != '\0'; p++)
+ *p = (char)toupper((unsigned char)*p);
return ret_path;
}
@@ -184,40 +146,40 @@ static char *sanitize_path(const char *path)
/*
* Cfgmgr32, AdvAPI32, OLE32 and SetupAPI DLL functions
*/
-static BOOL init_dlls(void)
+static bool init_dlls(struct libusb_context *ctx)
{
- DLL_GET_HANDLE(Cfgmgr32);
- DLL_LOAD_FUNC(Cfgmgr32, CM_Get_Parent, TRUE);
- DLL_LOAD_FUNC(Cfgmgr32, CM_Get_Child, TRUE);
+ DLL_GET_HANDLE(ctx, Cfgmgr32);
+ DLL_LOAD_FUNC(Cfgmgr32, CM_Get_Parent, true);
+ DLL_LOAD_FUNC(Cfgmgr32, CM_Get_Child, true);
// Prefixed to avoid conflict with header files
- DLL_GET_HANDLE(AdvAPI32);
- DLL_LOAD_FUNC_PREFIXED(AdvAPI32, p, RegQueryValueExW, TRUE);
- DLL_LOAD_FUNC_PREFIXED(AdvAPI32, p, RegCloseKey, TRUE);
-
- DLL_GET_HANDLE(OLE32);
- DLL_LOAD_FUNC_PREFIXED(OLE32, p, IIDFromString, TRUE);
-
- DLL_GET_HANDLE(SetupAPI);
- DLL_LOAD_FUNC_PREFIXED(SetupAPI, p, SetupDiGetClassDevsA, TRUE);
- DLL_LOAD_FUNC_PREFIXED(SetupAPI, p, SetupDiEnumDeviceInfo, TRUE);
- DLL_LOAD_FUNC_PREFIXED(SetupAPI, p, SetupDiEnumDeviceInterfaces, TRUE);
- DLL_LOAD_FUNC_PREFIXED(SetupAPI, p, SetupDiGetDeviceInstanceIdA, TRUE);
- DLL_LOAD_FUNC_PREFIXED(SetupAPI, p, SetupDiGetDeviceInterfaceDetailA, TRUE);
- DLL_LOAD_FUNC_PREFIXED(SetupAPI, p, SetupDiGetDeviceRegistryPropertyA, TRUE);
- DLL_LOAD_FUNC_PREFIXED(SetupAPI, p, SetupDiDestroyDeviceInfoList, TRUE);
- DLL_LOAD_FUNC_PREFIXED(SetupAPI, p, SetupDiOpenDevRegKey, TRUE);
- DLL_LOAD_FUNC_PREFIXED(SetupAPI, p, SetupDiOpenDeviceInterfaceRegKey, TRUE);
-
- return TRUE;
+ DLL_GET_HANDLE(ctx, AdvAPI32);
+ DLL_LOAD_FUNC_PREFIXED(AdvAPI32, p, RegQueryValueExW, true);
+ DLL_LOAD_FUNC_PREFIXED(AdvAPI32, p, RegCloseKey, true);
+
+ DLL_GET_HANDLE(ctx, OLE32);
+ DLL_LOAD_FUNC_PREFIXED(OLE32, p, IIDFromString, true);
+
+ DLL_GET_HANDLE(ctx, SetupAPI);
+ DLL_LOAD_FUNC_PREFIXED(SetupAPI, p, SetupDiGetClassDevsA, true);
+ DLL_LOAD_FUNC_PREFIXED(SetupAPI, p, SetupDiEnumDeviceInfo, true);
+ DLL_LOAD_FUNC_PREFIXED(SetupAPI, p, SetupDiEnumDeviceInterfaces, true);
+ DLL_LOAD_FUNC_PREFIXED(SetupAPI, p, SetupDiGetDeviceInstanceIdA, true);
+ DLL_LOAD_FUNC_PREFIXED(SetupAPI, p, SetupDiGetDeviceInterfaceDetailA, true);
+ DLL_LOAD_FUNC_PREFIXED(SetupAPI, p, SetupDiGetDeviceRegistryPropertyA, true);
+ DLL_LOAD_FUNC_PREFIXED(SetupAPI, p, SetupDiDestroyDeviceInfoList, true);
+ DLL_LOAD_FUNC_PREFIXED(SetupAPI, p, SetupDiOpenDevRegKey, true);
+ DLL_LOAD_FUNC_PREFIXED(SetupAPI, p, SetupDiOpenDeviceInterfaceRegKey, true);
+
+ return true;
}
static void exit_dlls(void)
{
- DLL_FREE_HANDLE(Cfgmgr32);
- DLL_FREE_HANDLE(AdvAPI32);
- DLL_FREE_HANDLE(OLE32);
DLL_FREE_HANDLE(SetupAPI);
+ DLL_FREE_HANDLE(OLE32);
+ DLL_FREE_HANDLE(AdvAPI32);
+ DLL_FREE_HANDLE(Cfgmgr32);
}
/*
@@ -284,7 +246,7 @@ static int get_interface_details(struct libusb_context *ctx, HDEVINFO dev_info,
if (!pSetupDiEnumDeviceInfo(dev_info, *_index, dev_info_data)) {
if (GetLastError() != ERROR_NO_MORE_ITEMS) {
usbi_err(ctx, "Could not obtain device info data for %s index %lu: %s",
- guid_to_string(guid), *_index, windows_error_str(0));
+ guid_to_string(guid), ULONG_CAST(*_index), windows_error_str(0));
return LIBUSB_ERROR_OTHER;
}
@@ -300,7 +262,7 @@ static int get_interface_details(struct libusb_context *ctx, HDEVINFO dev_info,
if (GetLastError() != ERROR_NO_MORE_ITEMS) {
usbi_err(ctx, "Could not obtain interface data for %s devInst %lX: %s",
- guid_to_string(guid), dev_info_data->DevInst, windows_error_str(0));
+ guid_to_string(guid), ULONG_CAST(dev_info_data->DevInst), windows_error_str(0));
return LIBUSB_ERROR_OTHER;
}
@@ -312,7 +274,7 @@ static int get_interface_details(struct libusb_context *ctx, HDEVINFO dev_info,
// The dummy call should fail with ERROR_INSUFFICIENT_BUFFER
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
usbi_err(ctx, "could not access interface data (dummy) for %s devInst %lX: %s",
- guid_to_string(guid), dev_info_data->DevInst, windows_error_str(0));
+ guid_to_string(guid), ULONG_CAST(dev_info_data->DevInst), windows_error_str(0));
return LIBUSB_ERROR_OTHER;
}
} else {
@@ -323,7 +285,7 @@ static int get_interface_details(struct libusb_context *ctx, HDEVINFO dev_info,
dev_interface_details = malloc(size);
if (dev_interface_details == NULL) {
usbi_err(ctx, "could not allocate interface data for %s devInst %lX",
- guid_to_string(guid), dev_info_data->DevInst);
+ guid_to_string(guid), ULONG_CAST(dev_info_data->DevInst));
return LIBUSB_ERROR_NO_MEM;
}
@@ -331,17 +293,17 @@ static int get_interface_details(struct libusb_context *ctx, HDEVINFO dev_info,
if (!pSetupDiGetDeviceInterfaceDetailA(dev_info, &dev_interface_data,
dev_interface_details, size, NULL, NULL)) {
usbi_err(ctx, "could not access interface data (actual) for %s devInst %lX: %s",
- guid_to_string(guid), dev_info_data->DevInst, windows_error_str(0));
+ guid_to_string(guid), ULONG_CAST(dev_info_data->DevInst), windows_error_str(0));
free(dev_interface_details);
return LIBUSB_ERROR_OTHER;
}
- *dev_interface_path = sanitize_path(dev_interface_details->DevicePath);
+ *dev_interface_path = normalize_path(dev_interface_details->DevicePath);
free(dev_interface_details);
if (*dev_interface_path == NULL) {
usbi_err(ctx, "could not allocate interface path for %s devInst %lX",
- guid_to_string(guid), dev_info_data->DevInst);
+ guid_to_string(guid), ULONG_CAST(dev_info_data->DevInst));
return LIBUSB_ERROR_NO_MEM;
}
@@ -349,95 +311,106 @@ static int get_interface_details(struct libusb_context *ctx, HDEVINFO dev_info,
}
/* For libusb0 filter */
-static SP_DEVICE_INTERFACE_DETAIL_DATA_A *get_interface_details_filter(struct libusb_context *ctx,
- HDEVINFO *dev_info, SP_DEVINFO_DATA *dev_info_data, const GUID *guid, unsigned _index, char *filter_path)
+static int get_interface_details_filter(struct libusb_context *ctx, HDEVINFO *dev_info,
+ DWORD _index, char *filter_path, char **dev_interface_path)
{
+ const GUID *libusb0_guid = &GUID_DEVINTERFACE_LIBUSB0_FILTER;
SP_DEVICE_INTERFACE_DATA dev_interface_data;
- SP_DEVICE_INTERFACE_DETAIL_DATA_A *dev_interface_details;
+ PSP_DEVICE_INTERFACE_DETAIL_DATA_A dev_interface_details;
+ HKEY hkey_dev_interface;
DWORD size;
+ int err = LIBUSB_ERROR_OTHER;
- if (_index == 0)
- *dev_info = pSetupDiGetClassDevsA(guid, NULL, NULL, DIGCF_PRESENT|DIGCF_DEVICEINTERFACE);
-
- if (dev_info_data != NULL) {
- dev_info_data->cbSize = sizeof(SP_DEVINFO_DATA);
- if (!pSetupDiEnumDeviceInfo(*dev_info, _index, dev_info_data)) {
- if (GetLastError() != ERROR_NO_MORE_ITEMS)
- usbi_err(ctx, "Could not obtain device info data for index %u: %s",
- _index, windows_error_str(0));
-
- pSetupDiDestroyDeviceInfoList(*dev_info);
- *dev_info = INVALID_HANDLE_VALUE;
- return NULL;
+ if (_index == 0) {
+ *dev_info = pSetupDiGetClassDevsA(libusb0_guid, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
+ if (*dev_info == INVALID_HANDLE_VALUE) {
+ usbi_err(ctx, "could not obtain device info set: %s", windows_error_str(0));
+ return LIBUSB_ERROR_OTHER;
}
}
dev_interface_data.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
- if (!pSetupDiEnumDeviceInterfaces(*dev_info, NULL, guid, _index, &dev_interface_data)) {
- if (GetLastError() != ERROR_NO_MORE_ITEMS)
- usbi_err(ctx, "Could not obtain interface data for index %u: %s",
- _index, windows_error_str(0));
+ if (!pSetupDiEnumDeviceInterfaces(*dev_info, NULL, libusb0_guid, _index, &dev_interface_data)) {
+ if (GetLastError() != ERROR_NO_MORE_ITEMS) {
+ usbi_err(ctx, "Could not obtain interface data for index %lu: %s",
+ ULONG_CAST(_index), windows_error_str(0));
+ goto err_exit;
+ }
pSetupDiDestroyDeviceInfoList(*dev_info);
*dev_info = INVALID_HANDLE_VALUE;
- return NULL;
+ return LIBUSB_SUCCESS;
}
// Read interface data (dummy + actual) to access the device path
if (!pSetupDiGetDeviceInterfaceDetailA(*dev_info, &dev_interface_data, NULL, 0, &size, NULL)) {
// The dummy call should fail with ERROR_INSUFFICIENT_BUFFER
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
- usbi_err(ctx, "could not access interface data (dummy) for index %u: %s",
- _index, windows_error_str(0));
+ usbi_err(ctx, "could not access interface data (dummy) for index %lu: %s",
+ ULONG_CAST(_index), windows_error_str(0));
goto err_exit;
}
} else {
- usbi_err(ctx, "program assertion failed - http://msdn.microsoft.com/en-us/library/ms792901.aspx is wrong.");
+ usbi_err(ctx, "program assertion failed - http://msdn.microsoft.com/en-us/library/ms792901.aspx is wrong");
goto err_exit;
}
- dev_interface_details = calloc(1, size);
+ dev_interface_details = malloc(size);
if (dev_interface_details == NULL) {
- usbi_err(ctx, "could not allocate interface data for index %u.", _index);
+ usbi_err(ctx, "could not allocate interface data for index %lu", ULONG_CAST(_index));
+ err = LIBUSB_ERROR_NO_MEM;
goto err_exit;
}
dev_interface_details->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A);
- if (!pSetupDiGetDeviceInterfaceDetailA(*dev_info, &dev_interface_data, dev_interface_details, size, &size, NULL))
- usbi_err(ctx, "could not access interface data (actual) for index %u: %s",
- _index, windows_error_str(0));
+ if (!pSetupDiGetDeviceInterfaceDetailA(*dev_info, &dev_interface_data, dev_interface_details, size, NULL, NULL)) {
+ usbi_err(ctx, "could not access interface data (actual) for index %lu: %s",
+ ULONG_CAST(_index), windows_error_str(0));
+ free(dev_interface_details);
+ goto err_exit;
+ }
+
+ *dev_interface_path = normalize_path(dev_interface_details->DevicePath);
+ free(dev_interface_details);
+
+ if (*dev_interface_path == NULL) {
+ usbi_err(ctx, "could not allocate interface path for index %lu", ULONG_CAST(_index));
+ err = LIBUSB_ERROR_NO_MEM;
+ goto err_exit;
+ }
// [trobinso] lookup the libusb0 symbolic index.
- if (dev_interface_details) {
- HKEY hkey_device_interface = pSetupDiOpenDeviceInterfaceRegKey(*dev_info, &dev_interface_data, 0, KEY_READ);
- if (hkey_device_interface != INVALID_HANDLE_VALUE) {
- DWORD libusb0_symboliclink_index = 0;
- DWORD value_length = sizeof(DWORD);
- DWORD value_type = 0;
- LONG status;
-
- status = pRegQueryValueExW(hkey_device_interface, L"LUsb0", NULL, &value_type,
- (LPBYTE)&libusb0_symboliclink_index, &value_length);
- if (status == ERROR_SUCCESS) {
- if (libusb0_symboliclink_index < 256) {
- // libusb0.sys is connected to this device instance.
- // If the the device interface guid is {F9F3FF14-AE21-48A0-8A25-8011A7A931D9} then it's a filter.
- sprintf(filter_path, "\\\\.\\libusb0-%04u", (unsigned int)libusb0_symboliclink_index);
- usbi_dbg("assigned libusb0 symbolic link %s", filter_path);
- } else {
- // libusb0.sys was connected to this device instance at one time; but not anymore.
- }
+ hkey_dev_interface = pSetupDiOpenDeviceInterfaceRegKey(*dev_info, &dev_interface_data, 0, KEY_READ);
+ if (hkey_dev_interface != INVALID_HANDLE_VALUE) {
+ DWORD libusb0_symboliclink_index = 0;
+ DWORD value_length = sizeof(DWORD);
+ LONG status;
+
+ status = pRegQueryValueExW(hkey_dev_interface, L"LUsb0", NULL, NULL,
+ (LPBYTE)&libusb0_symboliclink_index, &value_length);
+ if (status == ERROR_SUCCESS) {
+ if (libusb0_symboliclink_index < 256) {
+ // libusb0.sys is connected to this device instance.
+ // If the the device interface guid is {F9F3FF14-AE21-48A0-8A25-8011A7A931D9} then it's a filter.
+ sprintf(filter_path, "\\\\.\\libusb0-%04u", (unsigned int)libusb0_symboliclink_index);
+ usbi_dbg("assigned libusb0 symbolic link %s", filter_path);
+ } else {
+ // libusb0.sys was connected to this device instance at one time; but not anymore.
}
- pRegCloseKey(hkey_device_interface);
}
+ pRegCloseKey(hkey_dev_interface);
+ } else {
+ usbi_warn(ctx, "could not open device interface registry key for index %lu: %s",
+ ULONG_CAST(_index), windows_error_str(0));
+ // TODO: should this be an error?
}
- return dev_interface_details;
+ return LIBUSB_SUCCESS;
err_exit:
pSetupDiDestroyDeviceInfoList(*dev_info);
*dev_info = INVALID_HANDLE_VALUE;
- return NULL;
+ return err;
}
/*
@@ -469,7 +442,8 @@ static int get_interface_by_endpoint(struct libusb_config_descriptor *conf_desc,
{
const struct libusb_interface *intf;
const struct libusb_interface_descriptor *intf_desc;
- int i, j, k;
+ uint8_t i, k;
+ int j;
for (i = 0; i < conf_desc->bNumInterfaces; i++) {
intf = &conf_desc->interface[i];
@@ -489,19 +463,40 @@ static int get_interface_by_endpoint(struct libusb_config_descriptor *conf_desc,
}
/*
+ * Open a device and associate the HANDLE with the context's I/O completion port
+ */
+static HANDLE windows_open(struct libusb_device *dev, const char *path, DWORD access)
+{
+ struct libusb_context *ctx = DEVICE_CTX(dev);
+ struct windows_context_priv *priv = usbi_get_context_priv(ctx);
+ HANDLE handle;
+
+ handle = CreateFileA(path, access, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
+ if (handle == INVALID_HANDLE_VALUE)
+ return handle;
+
+ if (CreateIoCompletionPort(handle, priv->completion_port, 0, 0) == NULL) {
+ usbi_err(ctx, "failed to associate handle to I/O completion port: %s", windows_error_str(0));
+ CloseHandle(handle);
+ return INVALID_HANDLE_VALUE;
+ }
+
+ return handle;
+}
+
+/*
* Populate the endpoints addresses of the device_priv interface helper structs
*/
-static int windows_assign_endpoints(struct libusb_device_handle *dev_handle, int iface, int altsetting)
+static int windows_assign_endpoints(struct libusb_device_handle *dev_handle, uint8_t iface, uint8_t altsetting)
{
- int i, r;
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
struct libusb_config_descriptor *conf_desc;
const struct libusb_interface_descriptor *if_desc;
- struct libusb_context *ctx = DEVICE_CTX(dev_handle->dev);
+ int i, r;
r = libusb_get_active_config_descriptor(dev_handle->dev, &conf_desc);
if (r != LIBUSB_SUCCESS) {
- usbi_warn(ctx, "could not read config descriptor: error %d", r);
+ usbi_warn(HANDLE_CTX(dev_handle), "could not read config descriptor: error %d", r);
return r;
}
@@ -509,7 +504,7 @@ static int windows_assign_endpoints(struct libusb_device_handle *dev_handle, int
safe_free(priv->usb_interface[iface].endpoint);
if (if_desc->bNumEndpoints == 0) {
- usbi_dbg("no endpoints found for interface %d", iface);
+ usbi_dbg("no endpoints found for interface %u", iface);
libusb_free_config_descriptor(conf_desc);
priv->usb_interface[iface].current_altsetting = altsetting;
return LIBUSB_SUCCESS;
@@ -524,7 +519,7 @@ static int windows_assign_endpoints(struct libusb_device_handle *dev_handle, int
priv->usb_interface[iface].nb_endpoints = if_desc->bNumEndpoints;
for (i = 0; i < if_desc->bNumEndpoints; i++) {
priv->usb_interface[iface].endpoint[i] = if_desc->endpoint[i].bEndpointAddress;
- usbi_dbg("(re)assigned endpoint %02X to interface %d", priv->usb_interface[iface].endpoint[i], iface);
+ usbi_dbg("(re)assigned endpoint %02X to interface %u", priv->usb_interface[iface].endpoint[i], iface);
}
libusb_free_config_descriptor(conf_desc);
@@ -542,10 +537,10 @@ static int windows_assign_endpoints(struct libusb_device_handle *dev_handle, int
// return -1 if not found, driver match number otherwise
static int get_sub_api(char *driver, int api)
{
- int i;
const char sep_str[2] = {LIST_SEPARATOR, 0};
char *tok, *tmp_str;
size_t len = strlen(driver);
+ int i;
if (len == 0)
return SUB_API_NOTSET;
@@ -574,10 +569,9 @@ static int get_sub_api(char *driver, int api)
*/
static int auto_claim(struct libusb_transfer *transfer, int *interface_number, int api_type)
{
- struct libusb_context *ctx = DEVICE_CTX(transfer->dev_handle->dev);
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(
- transfer->dev_handle);
- struct winusb_device_priv *priv = _device_priv(transfer->dev_handle->dev);
+ struct winusb_device_handle_priv *handle_priv =
+ usbi_get_device_handle_priv(transfer->dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(transfer->dev_handle->dev);
int current_interface = *interface_number;
int r = LIBUSB_SUCCESS;
@@ -597,13 +591,13 @@ static int auto_claim(struct libusb_transfer *transfer, int *interface_number, i
&& (libusb_claim_interface(transfer->dev_handle, current_interface) == LIBUSB_SUCCESS)) {
usbi_dbg("auto-claimed interface %d for control request", current_interface);
if (handle_priv->autoclaim_count[current_interface] != 0)
- usbi_warn(ctx, "program assertion failed - autoclaim_count was nonzero");
+ usbi_err(TRANSFER_CTX(transfer), "program assertion failed - autoclaim_count was nonzero");
handle_priv->autoclaim_count[current_interface]++;
break;
}
}
if (current_interface == USB_MAXINTERFACES) {
- usbi_err(ctx, "could not auto-claim any interface");
+ usbi_err(TRANSFER_CTX(transfer), "could not auto-claim any interface");
r = LIBUSB_ERROR_NOT_FOUND;
}
} else {
@@ -620,10 +614,10 @@ static int auto_claim(struct libusb_transfer *transfer, int *interface_number, i
static void auto_release(struct usbi_transfer *itransfer)
{
- struct winusb_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer);
+ struct winusb_transfer_priv *transfer_priv = get_winusb_transfer_priv(itransfer);
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
libusb_device_handle *dev_handle = transfer->dev_handle;
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(dev_handle);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
int r;
usbi_mutex_lock(&autoclaim_lock);
@@ -648,22 +642,22 @@ static int winusb_init(struct libusb_context *ctx)
{
int i;
- // We need a lock for proper auto-release
- usbi_mutex_init(&autoclaim_lock);
-
// Load DLL imports
- if (!init_dlls()) {
+ if (!init_dlls(ctx)) {
usbi_err(ctx, "could not resolve DLL functions");
return LIBUSB_ERROR_OTHER;
}
// Initialize the low level APIs (we don't care about errors at this stage)
for (i = 0; i < USB_API_MAX; i++) {
- if (usb_api_backend[i].init && usb_api_backend[i].init(ctx))
+ if (usb_api_backend[i].init && !usb_api_backend[i].init(ctx))
usbi_warn(ctx, "error initializing %s backend",
usb_api_backend[i].designation);
}
+ // We need a lock for proper auto-release
+ usbi_mutex_init(&autoclaim_lock);
+
return LIBUSB_SUCCESS;
}
@@ -674,13 +668,16 @@ static void winusb_exit(struct libusb_context *ctx)
{
int i;
+ UNUSED(ctx);
+
+ usbi_mutex_destroy(&autoclaim_lock);
+
for (i = 0; i < USB_API_MAX; i++) {
if (usb_api_backend[i].exit)
usb_api_backend[i].exit();
}
exit_dlls();
- usbi_mutex_destroy(&autoclaim_lock);
}
/*
@@ -689,31 +686,34 @@ static void winusb_exit(struct libusb_context *ctx)
static void cache_config_descriptors(struct libusb_device *dev, HANDLE hub_handle)
{
struct libusb_context *ctx = DEVICE_CTX(dev);
- struct winusb_device_priv *priv = _device_priv(dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev);
DWORD size, ret_size;
- uint8_t i;
+ uint8_t i, num_configurations;
USB_CONFIGURATION_DESCRIPTOR_SHORT cd_buf_short; // dummy request
PUSB_DESCRIPTOR_REQUEST cd_buf_actual = NULL; // actual request
PUSB_CONFIGURATION_DESCRIPTOR cd_data;
- if (dev->num_configurations == 0)
+ num_configurations = dev->device_descriptor.bNumConfigurations;
+ if (num_configurations == 0)
return;
- priv->config_descriptor = calloc(dev->num_configurations, sizeof(PUSB_CONFIGURATION_DESCRIPTOR));
+ assert(sizeof(USB_DESCRIPTOR_REQUEST) == USB_DESCRIPTOR_REQUEST_SIZE);
+
+ priv->config_descriptor = calloc(num_configurations, sizeof(PUSB_CONFIGURATION_DESCRIPTOR));
if (priv->config_descriptor == NULL) {
usbi_err(ctx, "could not allocate configuration descriptor array for '%s'", priv->dev_id);
return;
}
- for (i = 0; i <= dev->num_configurations; i++) {
+ for (i = 0; i <= num_configurations; i++) {
safe_free(cd_buf_actual);
- if (i == dev->num_configurations)
+ if (i == num_configurations)
break;
size = sizeof(cd_buf_short);
- memset(&cd_buf_short, 0, size);
+ memset(&cd_buf_short.desc, 0, sizeof(cd_buf_short.desc));
cd_buf_short.req.ConnectionIndex = (ULONG)dev->port_number;
cd_buf_short.req.SetupPacket.bmRequest = LIBUSB_ENDPOINT_IN;
@@ -757,7 +757,7 @@ static void cache_config_descriptors(struct libusb_device *dev, HANDLE hub_handl
continue;
}
- cd_data = (PUSB_CONFIGURATION_DESCRIPTOR)((UCHAR *)cd_buf_actual + sizeof(USB_DESCRIPTOR_REQUEST));
+ cd_data = (PUSB_CONFIGURATION_DESCRIPTOR)((UCHAR *)cd_buf_actual + USB_DESCRIPTOR_REQUEST_SIZE);
if ((size != ret_size) || (cd_data->wTotalLength != cd_buf_short.desc.wTotalLength)) {
usbi_err(ctx, "unexpected configuration descriptor %u size (actual) for '%s'", i, priv->dev_id);
@@ -773,13 +773,246 @@ static void cache_config_descriptors(struct libusb_device *dev, HANDLE hub_handl
i, cd_data->bConfigurationValue, cd_data->wTotalLength);
// Cache the descriptor
- priv->config_descriptor[i] = malloc(cd_data->wTotalLength);
- if (priv->config_descriptor[i] != NULL) {
- memcpy(priv->config_descriptor[i], cd_data, cd_data->wTotalLength);
- } else {
- usbi_err(ctx, "could not allocate configuration descriptor %u buffer for '%s'", i, priv->dev_id);
+ priv->config_descriptor[i] = cd_data;
+ cd_buf_actual = NULL;
+ }
+}
+
+#define ROOT_HUB_FS_CONFIG_DESC_LENGTH 0x19
+#define ROOT_HUB_HS_CONFIG_DESC_LENGTH 0x19
+#define ROOT_HUB_SS_CONFIG_DESC_LENGTH 0x1f
+#define CONFIG_DESC_WTOTAL_LENGTH_OFFSET 0x02
+#define CONFIG_DESC_EP_MAX_PACKET_OFFSET 0x16
+#define CONFIG_DESC_EP_BINTERVAL_OFFSET 0x18
+
+static const uint8_t root_hub_config_descriptor_template[] = {
+ // Configuration Descriptor
+ LIBUSB_DT_CONFIG_SIZE, // bLength
+ LIBUSB_DT_CONFIG, // bDescriptorType
+ 0x00, 0x00, // wTotalLength (filled in)
+ 0x01, // bNumInterfaces
+ 0x01, // bConfigurationValue
+ 0x00, // iConfiguration
+ 0xc0, // bmAttributes (reserved + self-powered)
+ 0x00, // bMaxPower
+ // Interface Descriptor
+ LIBUSB_DT_INTERFACE_SIZE, // bLength
+ LIBUSB_DT_INTERFACE, // bDescriptorType
+ 0x00, // bInterfaceNumber
+ 0x00, // bAlternateSetting
+ 0x01, // bNumEndpoints
+ LIBUSB_CLASS_HUB, // bInterfaceClass
+ 0x00, // bInterfaceSubClass
+ 0x00, // bInterfaceProtocol
+ 0x00, // iInterface
+ // Endpoint Descriptor
+ LIBUSB_DT_ENDPOINT_SIZE, // bLength
+ LIBUSB_DT_ENDPOINT, // bDescriptorType
+ 0x81, // bEndpointAddress
+ 0x03, // bmAttributes (Interrupt)
+ 0x00, 0x00, // wMaxPacketSize (filled in)
+ 0x00, // bInterval (filled in)
+ // SuperSpeed Endpoint Companion Descriptor
+ LIBUSB_DT_SS_ENDPOINT_COMPANION_SIZE, // bLength
+ LIBUSB_DT_SS_ENDPOINT_COMPANION, // bDescriptorType
+ 0x00, // bMaxBurst
+ 0x00, // bmAttributes
+ 0x02, 0x00 // wBytesPerInterval
+};
+
+static int alloc_root_hub_config_desc(struct libusb_device *dev, ULONG num_ports,
+ uint8_t config_desc_length, uint8_t ep_interval)
+{
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev);
+ uint8_t *ptr;
+
+ priv->config_descriptor = malloc(sizeof(*priv->config_descriptor));
+ if (priv->config_descriptor == NULL)
+ return LIBUSB_ERROR_NO_MEM;
+
+ // Most config descriptors come from cache_config_descriptors() which obtains the
+ // descriptors from the hub using an allocated USB_DESCRIPTOR_REQUEST structure.
+ // To avoid an extra malloc + memcpy we just hold on to the USB_DESCRIPTOR_REQUEST
+ // structure we already have and back up the pointer in windows_device_priv_release()
+ // when freeing the descriptors. To keep a single execution path, we need to offset
+ // the pointer here by the same amount.
+ ptr = malloc(USB_DESCRIPTOR_REQUEST_SIZE + config_desc_length);
+ if (ptr == NULL)
+ return LIBUSB_ERROR_NO_MEM;
+
+ ptr += USB_DESCRIPTOR_REQUEST_SIZE;
+
+ memcpy(ptr, root_hub_config_descriptor_template, config_desc_length);
+ ptr[CONFIG_DESC_WTOTAL_LENGTH_OFFSET] = config_desc_length;
+ ptr[CONFIG_DESC_EP_MAX_PACKET_OFFSET] = (uint8_t)((num_ports + 7) / 8);
+ ptr[CONFIG_DESC_EP_BINTERVAL_OFFSET] = ep_interval;
+
+ priv->config_descriptor[0] = (PUSB_CONFIGURATION_DESCRIPTOR)ptr;
+ priv->active_config = 1;
+
+ return 0;
+}
+
+static int init_root_hub(struct libusb_device *dev)
+{
+ struct libusb_context *ctx = DEVICE_CTX(dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev);
+ USB_NODE_CONNECTION_INFORMATION_EX conn_info;
+ USB_NODE_CONNECTION_INFORMATION_EX_V2 conn_info_v2;
+ USB_NODE_INFORMATION hub_info;
+ enum libusb_speed speed = LIBUSB_SPEED_UNKNOWN;
+ uint8_t config_desc_length;
+ uint8_t ep_interval;
+ HANDLE handle;
+ ULONG port_number, num_ports;
+ DWORD size;
+ int r;
+
+ // Determining the speed of a root hub is painful. Microsoft does not directly report the speed
+ // capabilities of the root hub itself, only its ports and/or connected devices. Therefore we
+ // are forced to query each individual port of the root hub to try and infer the root hub's
+ // speed. Note that we have to query all ports because the presence of a device on that port
+ // changes if/how Windows returns any useful speed information.
+ handle = CreateFileA(priv->path, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
+ if (handle == INVALID_HANDLE_VALUE) {
+ usbi_err(ctx, "could not open root hub %s: %s", priv->path, windows_error_str(0));
+ return LIBUSB_ERROR_ACCESS;
+ }
+
+ if (!DeviceIoControl(handle, IOCTL_USB_GET_NODE_INFORMATION, NULL, 0, &hub_info, sizeof(hub_info), &size, NULL)) {
+ usbi_warn(ctx, "could not get root hub info for '%s': %s", priv->dev_id, windows_error_str(0));
+ CloseHandle(handle);
+ return LIBUSB_ERROR_ACCESS;
+ }
+
+ num_ports = hub_info.u.HubInformation.HubDescriptor.bNumberOfPorts;
+ usbi_dbg("root hub '%s' reports %lu ports", priv->dev_id, ULONG_CAST(num_ports));
+
+ if (windows_version >= WINDOWS_8) {
+ // Windows 8 and later is better at reporting the speed capabilities of the root hub,
+ // but it is not perfect. If no device is attached to the port being queried, the
+ // returned information will only indicate whether that port supports USB 3.0 signalling.
+ // That is not enough information to distinguish between SuperSpeed and SuperSpeed Plus.
+ for (port_number = 1; port_number <= num_ports; port_number++) {
+ conn_info_v2.ConnectionIndex = port_number;
+ conn_info_v2.Length = sizeof(conn_info_v2);
+ conn_info_v2.SupportedUsbProtocols.Usb300 = 1;
+ if (!DeviceIoControl(handle, IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX_V2,
+ &conn_info_v2, sizeof(conn_info_v2), &conn_info_v2, sizeof(conn_info_v2), &size, NULL)) {
+ usbi_warn(ctx, "could not get node connection information (V2) for root hub '%s' port %lu: %s",
+ priv->dev_id, ULONG_CAST(port_number), windows_error_str(0));
+ break;
+ }
+
+ if (conn_info_v2.Flags.DeviceIsSuperSpeedPlusCapableOrHigher)
+ speed = MAX(speed, LIBUSB_SPEED_SUPER_PLUS);
+ else if (conn_info_v2.Flags.DeviceIsSuperSpeedCapableOrHigher || conn_info_v2.SupportedUsbProtocols.Usb300)
+ speed = MAX(speed, LIBUSB_SPEED_SUPER);
+ else if (conn_info_v2.SupportedUsbProtocols.Usb200)
+ speed = MAX(speed, LIBUSB_SPEED_HIGH);
+ else
+ speed = MAX(speed, LIBUSB_SPEED_FULL);
+ }
+
+ if (speed != LIBUSB_SPEED_UNKNOWN)
+ goto make_descriptors;
+ }
+
+ // At this point the speed is still not known, most likely because we are executing on
+ // Windows 7 or earlier. The following hackery peeks into the root hub's Device ID and
+ // tries to extract speed information from it, based on observed naming conventions.
+ // If this does not work, we will query individual ports of the root hub.
+ if (strstr(priv->dev_id, "ROOT_HUB31") != NULL)
+ speed = LIBUSB_SPEED_SUPER_PLUS;
+ else if (strstr(priv->dev_id, "ROOT_HUB30") != NULL)
+ speed = LIBUSB_SPEED_SUPER;
+ else if (strstr(priv->dev_id, "ROOT_HUB20") != NULL)
+ speed = LIBUSB_SPEED_HIGH;
+
+ if (speed != LIBUSB_SPEED_UNKNOWN)
+ goto make_descriptors;
+
+ // Windows only reports speed information about a connected device. This means that a root
+ // hub with no connected devices or devices that are all operating at a speed less than the
+ // highest speed that the root hub supports will not give us the correct speed.
+ for (port_number = 1; port_number <= num_ports; port_number++) {
+ conn_info.ConnectionIndex = port_number;
+ if (!DeviceIoControl(handle, IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX, &conn_info, sizeof(conn_info),
+ &conn_info, sizeof(conn_info), &size, NULL)) {
+ usbi_warn(ctx, "could not get node connection information for root hub '%s' port %lu: %s",
+ priv->dev_id, ULONG_CAST(port_number), windows_error_str(0));
+ continue;
+ }
+
+ if (conn_info.ConnectionStatus != DeviceConnected)
+ continue;
+
+ if (conn_info.Speed == UsbHighSpeed) {
+ speed = LIBUSB_SPEED_HIGH;
+ break;
}
}
+
+make_descriptors:
+ CloseHandle(handle);
+
+ dev->device_descriptor.bLength = LIBUSB_DT_DEVICE_SIZE;
+ dev->device_descriptor.bDescriptorType = LIBUSB_DT_DEVICE;
+ dev->device_descriptor.bDeviceClass = LIBUSB_CLASS_HUB;
+ if ((dev->device_descriptor.idVendor == 0) && (dev->device_descriptor.idProduct == 0)) {
+ dev->device_descriptor.idVendor = 0x1d6b; // Linux Foundation
+ dev->device_descriptor.idProduct = (uint16_t)speed;
+ }
+ dev->device_descriptor.bcdDevice = 0x0100;
+ dev->device_descriptor.bNumConfigurations = 1;
+
+ switch (speed) {
+ case LIBUSB_SPEED_SUPER_PLUS:
+ dev->device_descriptor.bcdUSB = 0x0310;
+ config_desc_length = ROOT_HUB_SS_CONFIG_DESC_LENGTH;
+ ep_interval = 0x0c; // 256ms
+ break;
+ case LIBUSB_SPEED_SUPER:
+ dev->device_descriptor.bcdUSB = 0x0300;
+ config_desc_length = ROOT_HUB_SS_CONFIG_DESC_LENGTH;
+ ep_interval = 0x0c; // 256ms
+ break;
+ case LIBUSB_SPEED_HIGH:
+ dev->device_descriptor.bcdUSB = 0x0200;
+ config_desc_length = ROOT_HUB_HS_CONFIG_DESC_LENGTH;
+ ep_interval = 0x0c; // 256ms
+ break;
+ case LIBUSB_SPEED_LOW: // Not used, but keeps compiler happy
+ case LIBUSB_SPEED_UNKNOWN:
+ // This case means absolutely no information about this root hub was determined.
+ // There is not much choice than to be pessimistic and label this as a
+ // full-speed device.
+ speed = LIBUSB_SPEED_FULL;
+ // fallthrough
+ case LIBUSB_SPEED_FULL:
+ dev->device_descriptor.bcdUSB = 0x0110;
+ config_desc_length = ROOT_HUB_FS_CONFIG_DESC_LENGTH;
+ ep_interval = 0xff; // 255ms
+ break;
+ default: // Impossible, buts keeps compiler happy
+ usbi_err(ctx, "program assertion failed - unknown root hub speed");
+ return LIBUSB_ERROR_INVALID_PARAM;
+ }
+
+ if (speed >= LIBUSB_SPEED_SUPER) {
+ dev->device_descriptor.bDeviceProtocol = 0x03; // USB 3.0 Hub
+ dev->device_descriptor.bMaxPacketSize0 = 0x09; // 2^9 bytes
+ } else {
+ dev->device_descriptor.bMaxPacketSize0 = 0x40; // 64 bytes
+ }
+
+ dev->speed = speed;
+
+ r = alloc_root_hub_config_desc(dev, num_ports, config_desc_length, ep_interval);
+ if (r)
+ usbi_err(ctx, "could not allocate config descriptor for root hub '%s'", priv->dev_id);
+
+ return r;
}
/*
@@ -790,7 +1023,7 @@ static int init_device(struct libusb_device *dev, struct libusb_device *parent_d
{
struct libusb_context *ctx;
struct libusb_device *tmp_dev;
- struct winusb_device_priv *priv, *parent_priv;
+ struct winusb_device_priv *priv, *parent_priv, *tmp_priv;
USB_NODE_CONNECTION_INFORMATION_EX conn_info;
USB_NODE_CONNECTION_INFORMATION_EX_V2 conn_info_v2;
HANDLE hub_handle;
@@ -799,7 +1032,7 @@ static int init_device(struct libusb_device *dev, struct libusb_device *parent_d
int r;
int ginfotimeout;
- priv = _device_priv(dev);
+ priv = usbi_get_device_priv(dev);
// If the device is already initialized, we can stop here
if (priv->initialized)
@@ -807,7 +1040,7 @@ static int init_device(struct libusb_device *dev, struct libusb_device *parent_d
if (parent_dev != NULL) { // Not a HCD root hub
ctx = DEVICE_CTX(dev);
- parent_priv = _device_priv(parent_dev);
+ parent_priv = usbi_get_device_priv(parent_dev);
if (parent_priv->apib->id != USB_API_HUB) {
usbi_warn(ctx, "parent for device '%s' is not a hub", priv->dev_id);
return LIBUSB_ERROR_NOT_FOUND;
@@ -825,9 +1058,14 @@ static int init_device(struct libusb_device *dev, struct libusb_device *parent_d
for (depth = 1; bus_number == 0; depth++) {
tmp_dev = get_ancestor(ctx, devinst, &devinst);
+ if (tmp_dev == NULL) {
+ usbi_warn(ctx, "ancestor for device '%s' not found at depth %u", priv->dev_id, depth);
+ return LIBUSB_ERROR_NO_DEVICE;
+ }
if (tmp_dev->bus_number != 0) {
bus_number = tmp_dev->bus_number;
- depth += _device_priv(tmp_dev)->depth;
+ tmp_priv = usbi_get_device_priv(tmp_dev);
+ depth += tmp_priv->depth;
}
libusb_unref_device(tmp_dev);
}
@@ -845,14 +1083,12 @@ static int init_device(struct libusb_device *dev, struct libusb_device *parent_d
dev->parent_dev = parent_dev;
priv->depth = depth;
- hub_handle = CreateFileA(parent_priv->path, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
- 0, NULL);
+ hub_handle = CreateFileA(parent_priv->path, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (hub_handle == INVALID_HANDLE_VALUE) {
usbi_warn(ctx, "could not open hub %s: %s", parent_priv->path, windows_error_str(0));
return LIBUSB_ERROR_ACCESS;
}
- memset(&conn_info, 0, sizeof(conn_info));
conn_info.ConnectionIndex = (ULONG)port_number;
// coverity[tainted_data_argument]
ginfotimeout = 20;
@@ -871,32 +1107,45 @@ static int init_device(struct libusb_device *dev, struct libusb_device *parent_d
return LIBUSB_ERROR_NO_DEVICE;
}
- memcpy(&priv->dev_descriptor, &(conn_info.DeviceDescriptor), sizeof(USB_DEVICE_DESCRIPTOR));
- dev->num_configurations = priv->dev_descriptor.bNumConfigurations;
+ if ((conn_info.DeviceDescriptor.bLength != LIBUSB_DT_DEVICE_SIZE)
+ || (conn_info.DeviceDescriptor.bDescriptorType != LIBUSB_DT_DEVICE)) {
+ SleepEx(50, TRUE);
+ continue;
+ }
+
+ static_assert(sizeof(dev->device_descriptor) == sizeof(conn_info.DeviceDescriptor),
+ "mismatch between libusb and OS device descriptor sizes");
+ memcpy(&dev->device_descriptor, &conn_info.DeviceDescriptor, LIBUSB_DT_DEVICE_SIZE);
+ usbi_localize_device_descriptor(&dev->device_descriptor);
+
priv->active_config = conn_info.CurrentConfigurationValue;
if (priv->active_config == 0) {
- usbi_dbg("0x%x:0x%x found %u configurations (active conf: %u) \n",
- priv->dev_descriptor.idVendor,
- priv->dev_descriptor.idProduct,
- dev->num_configurations,
- priv->active_config);
+ usbi_dbg("0x%x:0x%x found %u configurations (not configured)",
+ dev->device_descriptor.idVendor,
+ dev->device_descriptor.idProduct,
+ dev->device_descriptor.bNumConfigurations);
+ SleepEx(50, TRUE);
}
- if (priv->active_config == 0)
- Sleep(50);
} while (priv->active_config == 0 && --ginfotimeout >= 0);
+ if ((conn_info.DeviceDescriptor.bLength != LIBUSB_DT_DEVICE_SIZE)
+ || (conn_info.DeviceDescriptor.bDescriptorType != LIBUSB_DT_DEVICE)) {
+ usbi_err(ctx, "device '%s' has invalid descriptor!", priv->dev_id);
+ CloseHandle(hub_handle);
+ return LIBUSB_ERROR_OTHER;
+ }
+
if (priv->active_config == 0) {
- usbi_dbg("after try 0x%x:0x%x found %u configurations (active conf: %u) \n",
- priv->dev_descriptor.idVendor,
- priv->dev_descriptor.idProduct,
- dev->num_configurations,
- priv->active_config);
- usbi_dbg("Force this device active config to 1 in libusb! \nNOTICE: Should not reach this place!!!!!! \n");
+ usbi_info(ctx, "0x%x:0x%x found %u configurations but device isn't configured, "
+ "forcing current configuration to 1",
+ dev->device_descriptor.idVendor,
+ dev->device_descriptor.idProduct,
+ dev->device_descriptor.bNumConfigurations);
priv->active_config = 1;
+ } else {
+ usbi_dbg("found %u configurations (current config: %u)", dev->device_descriptor.bNumConfigurations, priv->active_config);
}
- usbi_dbg("found %u configurations (active conf: %u)", dev->num_configurations, priv->active_config);
-
// Cache as many config descriptors as we can
cache_config_descriptors(dev, hub_handle);
@@ -908,11 +1157,11 @@ static int init_device(struct libusb_device *dev, struct libusb_device *parent_d
if (!DeviceIoControl(hub_handle, IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX_V2,
&conn_info_v2, sizeof(conn_info_v2), &conn_info_v2, sizeof(conn_info_v2), &size, NULL)) {
usbi_warn(ctx, "could not get node connection information (V2) for device '%s': %s",
- priv->dev_id, windows_error_str(0));
+ priv->dev_id, windows_error_str(0));
} else if (conn_info_v2.Flags.DeviceIsOperatingAtSuperSpeedPlusOrHigher) {
- conn_info.Speed = 4;
+ conn_info.Speed = UsbSuperSpeedPlus;
} else if (conn_info_v2.Flags.DeviceIsOperatingAtSuperSpeedOrHigher) {
- conn_info.Speed = 3;
+ conn_info.Speed = UsbSuperSpeed;
}
}
@@ -924,15 +1173,19 @@ static int init_device(struct libusb_device *dev, struct libusb_device *parent_d
dev->device_address = (uint8_t)conn_info.DeviceAddress;
switch (conn_info.Speed) {
- case 0: dev->speed = LIBUSB_SPEED_LOW; break;
- case 1: dev->speed = LIBUSB_SPEED_FULL; break;
- case 2: dev->speed = LIBUSB_SPEED_HIGH; break;
- case 3: dev->speed = LIBUSB_SPEED_SUPER; break;
- case 4: dev->speed = LIBUSB_SPEED_SUPER_PLUS; break;
+ case UsbLowSpeed: dev->speed = LIBUSB_SPEED_LOW; break;
+ case UsbFullSpeed: dev->speed = LIBUSB_SPEED_FULL; break;
+ case UsbHighSpeed: dev->speed = LIBUSB_SPEED_HIGH; break;
+ case UsbSuperSpeed: dev->speed = LIBUSB_SPEED_SUPER; break;
+ case UsbSuperSpeedPlus: dev->speed = LIBUSB_SPEED_SUPER_PLUS; break;
default:
usbi_warn(ctx, "unknown device speed %u", conn_info.Speed);
break;
}
+ } else {
+ r = init_root_hub(dev);
+ if (r)
+ return r;
}
r = usbi_sanitize_device(dev);
@@ -955,7 +1208,7 @@ static int enumerate_hcd_root_hub(struct libusb_context *ctx, const char *dev_id
unsigned long session_id;
DEVINST child_devinst;
- if ((CM_Get_Child(&child_devinst, devinst, 0)) != CR_SUCCESS) {
+ if (CM_Get_Child(&child_devinst, devinst, 0) != CR_SUCCESS) {
usbi_warn(ctx, "could not get child devinst for '%s'", dev_id);
return LIBUSB_SUCCESS;
}
@@ -964,26 +1217,19 @@ static int enumerate_hcd_root_hub(struct libusb_context *ctx, const char *dev_id
dev = usbi_get_device_by_session_id(ctx, session_id);
if (dev == NULL) {
usbi_err(ctx, "program assertion failed - HCD '%s' child not found", dev_id);
- return LIBUSB_ERROR_NO_DEVICE;
+ return LIBUSB_SUCCESS;
}
if (dev->bus_number == 0) {
// Only do this once
usbi_dbg("assigning HCD '%s' bus number %u", dev_id, bus_number);
- priv = _device_priv(dev);
dev->bus_number = bus_number;
- dev->num_configurations = 1;
- priv->dev_descriptor.bLength = LIBUSB_DT_DEVICE_SIZE;
- priv->dev_descriptor.bDescriptorType = LIBUSB_DT_DEVICE;
- priv->dev_descriptor.bDeviceClass = LIBUSB_CLASS_HUB;
- priv->dev_descriptor.bNumConfigurations = 1;
- priv->active_config = 1;
- priv->root_hub = true;
- if (sscanf(dev_id, "PCI\\VEN_%04hx&DEV_%04hx%*s", &priv->dev_descriptor.idVendor, &priv->dev_descriptor.idProduct) != 2) {
+
+ if (sscanf(dev_id, "PCI\\VEN_%04hx&DEV_%04hx%*s", &dev->device_descriptor.idVendor, &dev->device_descriptor.idProduct) != 2)
usbi_warn(ctx, "could not infer VID/PID of HCD root hub from '%s'", dev_id);
- priv->dev_descriptor.idVendor = 0x1d6b; // Linux Foundation root hub
- priv->dev_descriptor.idProduct = 1;
- }
+
+ priv = usbi_get_device_priv(dev);
+ priv->root_hub = true;
}
libusb_unref_device(dev);
@@ -991,8 +1237,8 @@ static int enumerate_hcd_root_hub(struct libusb_context *ctx, const char *dev_id
}
// Returns the api type, or 0 if not found/unsupported
-static void get_api_type(struct libusb_context *ctx, HDEVINFO *dev_info,
- SP_DEVINFO_DATA *dev_info_data, int *api, int *sub_api)
+static void get_api_type(HDEVINFO *dev_info, SP_DEVINFO_DATA *dev_info_data,
+ int *api, int *sub_api)
{
// Precedence for filter drivers vs driver is in the order of this array
struct driver_lookup lookup[3] = {
@@ -1015,7 +1261,7 @@ static void get_api_type(struct libusb_context *ctx, HDEVINFO *dev_info,
// MULTI_SZ is a pain to work with. Turn it into something much more manageable
// NB: none of the driver names we check against contain LIST_SEPARATOR,
- // (currently ';'), so even if an unsuported one does, it's not an issue
+ // (currently ';'), so even if an unsupported one does, it's not an issue
for (l = 0; (lookup[k].list[l] != 0) || (lookup[k].list[l + 1] != 0); l++) {
if (lookup[k].list[l] == 0)
lookup[k].list[l] = LIST_SEPARATOR;
@@ -1045,7 +1291,7 @@ static void get_api_type(struct libusb_context *ctx, HDEVINFO *dev_info,
static int set_composite_interface(struct libusb_context *ctx, struct libusb_device *dev,
char *dev_interface_path, char *device_id, int api, int sub_api)
{
- struct winusb_device_priv *priv = _device_priv(dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev);
int interface_number;
const char *mi_str;
@@ -1053,7 +1299,7 @@ static int set_composite_interface(struct libusb_context *ctx, struct libusb_dev
// devices will have only MI_00 & MI_03 for instance), we retrieve the actual
// interface number from the path's MI value
mi_str = strstr(device_id, "MI_");
- if ((mi_str != NULL) && isdigit(mi_str[3]) && isdigit(mi_str[4])) {
+ if ((mi_str != NULL) && isdigit((unsigned char)mi_str[3]) && isdigit((unsigned char)mi_str[4])) {
interface_number = ((mi_str[3] - '0') * 10) + (mi_str[4] - '0');
} else {
usbi_warn(ctx, "failure to read interface number for %s, using default value", device_id);
@@ -1092,20 +1338,20 @@ static int set_composite_interface(struct libusb_context *ctx, struct libusb_dev
static int set_hid_interface(struct libusb_context *ctx, struct libusb_device *dev,
char *dev_interface_path)
{
- int i;
- struct winusb_device_priv *priv = _device_priv(dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev);
+ uint8_t i;
if (priv->hid == NULL) {
- usbi_err(ctx, "program assertion failed: parent is not HID");
+ usbi_err(ctx, "program assertion failed - parent is not HID");
return LIBUSB_ERROR_NO_DEVICE;
} else if (priv->hid->nb_interfaces == USB_MAXINTERFACES) {
- usbi_err(ctx, "program assertion failed: max USB interfaces reached for HID device");
+ usbi_err(ctx, "program assertion failed - max USB interfaces reached for HID device");
return LIBUSB_ERROR_NO_DEVICE;
}
for (i = 0; i < priv->hid->nb_interfaces; i++) {
if ((priv->usb_interface[i].path != NULL) && strcmp(priv->usb_interface[i].path, dev_interface_path) == 0) {
- usbi_dbg("interface[%d] already set to %s", i, dev_interface_path);
+ usbi_dbg("interface[%u] already set to %s", i, dev_interface_path);
return LIBUSB_ERROR_ACCESS;
}
}
@@ -1153,7 +1399,7 @@ static int winusb_get_device_list(struct libusb_context *ctx, struct discovered_
unsigned int guid_size = GUID_SIZE_STEP;
unsigned int nb_guids;
// Keep a list of PnP enumerator strings that are found
- char *usb_enumerator[8] = { "USB" };
+ const char *usb_enumerator[8] = { "USB" };
unsigned int nb_usb_enumerators = 1;
unsigned int usb_enum_index = 0;
// Keep a list of newly allocated devs to unref
@@ -1181,7 +1427,7 @@ static int winusb_get_device_list(struct libusb_context *ctx, struct discovered_
guid_list[DEV_PASS] = &GUID_DEVINTERFACE_USB_DEVICE;
guid_list[HCD_PASS] = &GUID_DEVINTERFACE_USB_HOST_CONTROLLER;
guid_list[GEN_PASS] = NULL;
- if (api_hid_available) {
+ if (HidD_GetHidGuid != NULL) {
HidD_GetHidGuid(&hid_guid);
guid_list[HID_PASS] = &hid_guid;
} else {
@@ -1227,7 +1473,7 @@ static int winusb_get_device_list(struct libusb_context *ctx, struct discovered_
break;
if ((pass == HCD_PASS) && (i == UINT8_MAX)) {
- usbi_warn(ctx, "program assertion failed - found more than %u buses, skipping the rest.", UINT8_MAX);
+ usbi_warn(ctx, "program assertion failed - found more than %u buses, skipping the rest", UINT8_MAX);
break;
}
@@ -1255,7 +1501,7 @@ static int winusb_get_device_list(struct libusb_context *ctx, struct discovered_
// Read the Device ID path
if (!pSetupDiGetDeviceInstanceIdA(*dev_info, &dev_info_data, dev_id, sizeof(dev_id), NULL)) {
usbi_warn(ctx, "could not read the device instance ID for devInst %lX, skipping",
- dev_info_data.DevInst);
+ ULONG_CAST(dev_info_data.DevInst));
continue;
}
@@ -1364,11 +1610,11 @@ static int winusb_get_device_list(struct libusb_context *ctx, struct discovered_
usbi_warn(ctx, "could not detect installation state of driver for '%s': %s",
dev_id, windows_error_str(0));
} else if (install_state != 0) {
- usbi_warn(ctx, "driver for device '%s' is reporting an issue (code: %u) - skipping",
- dev_id, (unsigned int)install_state);
+ usbi_warn(ctx, "driver for device '%s' is reporting an issue (code: %lu) - skipping",
+ dev_id, ULONG_CAST(install_state));
continue;
}
- get_api_type(ctx, dev_info, &dev_info_data, &api, &sub_api);
+ get_api_type(dev_info, &dev_info_data, &api, &sub_api);
break;
}
@@ -1379,7 +1625,7 @@ static int winusb_get_device_list(struct libusb_context *ctx, struct discovered_
// Root hubs will not have a parent
dev = usbi_get_device_by_session_id(ctx, (unsigned long)dev_info_data.DevInst);
if (dev != NULL) {
- priv = _device_priv(dev);
+ priv = usbi_get_device_priv(dev);
if (priv->root_hub)
goto track_unref;
libusb_unref_device(dev);
@@ -1389,7 +1635,7 @@ static int winusb_get_device_list(struct libusb_context *ctx, struct discovered_
continue;
}
- parent_priv = _device_priv(parent_dev);
+ parent_priv = usbi_get_device_priv(parent_dev);
// virtual USB devices are also listed during GEN - don't process these yet
if ((pass == GEN_PASS) && (parent_priv->apib->id != USB_API_HUB)) {
libusb_unref_device(parent_dev);
@@ -1418,7 +1664,7 @@ static int winusb_get_device_list(struct libusb_context *ctx, struct discovered_
} else {
usbi_dbg("found existing device for session [%lX]", session_id);
- priv = _device_priv(dev);
+ priv = usbi_get_device_priv(dev);
if (strcmp(priv->dev_id, dev_id) != 0) {
usbi_dbg("device instance ID for session [%lX] changed", session_id);
usbi_disconnect_device(dev);
@@ -1491,9 +1737,10 @@ static int winusb_get_device_list(struct libusb_context *ctx, struct discovered_
LOOP_BREAK(LIBUSB_ERROR_NO_MEM);
*_discdevs = discdevs;
- } else if (r == LIBUSB_ERROR_NO_DEVICE) {
- // This can occur if the device was disconnected but Windows hasn't
- // refreshed its enumeration yet - in that case, we ignore the device
+ } else {
+ // Failed to initialize a single device doesn't stop us from enumerating all other devices,
+ // but we skip it (don't add to list of discovered devices)
+ usbi_warn(ctx, "failed to initialize device '%s'", priv->dev_id);
r = LIBUSB_SUCCESS;
}
break;
@@ -1534,7 +1781,7 @@ static int winusb_get_device_list(struct libusb_context *ctx, struct discovered_
// Free any PnP enumerator strings
for (i = 1; i < nb_usb_enumerators; i++)
- free(usb_enumerator[i]);
+ free((void *)usb_enumerator[i]);
// Unref newly allocated devs
for (i = 0; i < unref_cur; i++)
@@ -1544,50 +1791,37 @@ static int winusb_get_device_list(struct libusb_context *ctx, struct discovered_
return r;
}
-static int winusb_get_device_descriptor(struct libusb_device *dev, unsigned char *buffer)
-{
- struct winusb_device_priv *priv = _device_priv(dev);
-
- memcpy(buffer, &priv->dev_descriptor, DEVICE_DESC_LENGTH);
- return LIBUSB_SUCCESS;
-}
-
-static int winusb_get_config_descriptor(struct libusb_device *dev, uint8_t config_index, unsigned char *buffer, size_t len)
+static int winusb_get_config_descriptor(struct libusb_device *dev, uint8_t config_index, void *buffer, size_t len)
{
- struct winusb_device_priv *priv = _device_priv(dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev);
PUSB_CONFIGURATION_DESCRIPTOR config_header;
- size_t size;
-
- // config index is zero based
- if (config_index >= dev->num_configurations)
- return LIBUSB_ERROR_INVALID_PARAM;
if ((priv->config_descriptor == NULL) || (priv->config_descriptor[config_index] == NULL))
return LIBUSB_ERROR_NOT_FOUND;
config_header = priv->config_descriptor[config_index];
- size = MIN(config_header->wTotalLength, len);
- memcpy(buffer, priv->config_descriptor[config_index], size);
- return (int)size;
+ len = MIN(len, config_header->wTotalLength);
+ memcpy(buffer, config_header, len);
+ return (int)len;
}
static int winusb_get_config_descriptor_by_value(struct libusb_device *dev, uint8_t bConfigurationValue,
- unsigned char **buffer)
+ void **buffer)
{
- struct winusb_device_priv *priv = _device_priv(dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev);
PUSB_CONFIGURATION_DESCRIPTOR config_header;
uint8_t index;
if (priv->config_descriptor == NULL)
return LIBUSB_ERROR_NOT_FOUND;
- for (index = 0; index < dev->num_configurations; index++) {
+ for (index = 0; index < dev->device_descriptor.bNumConfigurations; index++) {
config_header = priv->config_descriptor[index];
if (config_header == NULL)
continue;
if (config_header->bConfigurationValue == bConfigurationValue) {
- *buffer = (unsigned char *)priv->config_descriptor[index];
+ *buffer = config_header;
return (int)config_header->wTotalLength;
}
}
@@ -1598,10 +1832,10 @@ static int winusb_get_config_descriptor_by_value(struct libusb_device *dev, uint
/*
* return the cached copy of the active config descriptor
*/
-static int winusb_get_active_config_descriptor(struct libusb_device *dev, unsigned char *buffer, size_t len)
+static int winusb_get_active_config_descriptor(struct libusb_device *dev, void *buffer, size_t len)
{
- struct winusb_device_priv *priv = _device_priv(dev);
- unsigned char *config_desc;
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev);
+ void *config_desc;
int r;
if (priv->active_config == 0)
@@ -1611,14 +1845,14 @@ static int winusb_get_active_config_descriptor(struct libusb_device *dev, unsign
if (r < 0)
return r;
- len = MIN((size_t)r, len);
+ len = MIN(len, (size_t)r);
memcpy(buffer, config_desc, len);
return (int)len;
}
static int winusb_open(struct libusb_device_handle *dev_handle)
{
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
CHECK_SUPPORTED_API(priv->apib, open);
@@ -1627,20 +1861,15 @@ static int winusb_open(struct libusb_device_handle *dev_handle)
static void winusb_close(struct libusb_device_handle *dev_handle)
{
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
if (priv->apib->close)
priv->apib->close(SUB_API_NOTSET, dev_handle);
}
-static int winusb_get_configuration(struct libusb_device_handle *dev_handle, int *config)
+static int winusb_get_configuration(struct libusb_device_handle *dev_handle, uint8_t *config)
{
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
-
- if (priv->active_config == 0) {
- *config = 0;
- return LIBUSB_ERROR_NOT_FOUND;
- }
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
*config = priv->active_config;
return LIBUSB_SUCCESS;
@@ -1651,28 +1880,25 @@ static int winusb_get_configuration(struct libusb_device_handle *dev_handle, int
* does not currently expose a service that allows higher-level drivers to set
* the configuration."
*/
-static int winusb_set_configuration(struct libusb_device_handle *dev_handle, int config)
+static int winusb_set_configuration(struct libusb_device_handle *dev_handle, uint8_t config)
{
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
int r = LIBUSB_SUCCESS;
- if (config >= USB_MAXCONFIG)
- return LIBUSB_ERROR_INVALID_PARAM;
-
r = libusb_control_transfer(dev_handle, LIBUSB_ENDPOINT_OUT |
LIBUSB_REQUEST_TYPE_STANDARD | LIBUSB_RECIPIENT_DEVICE,
- LIBUSB_REQUEST_SET_CONFIGURATION, (uint16_t)config,
+ LIBUSB_REQUEST_SET_CONFIGURATION, config,
0, NULL, 0, 1000);
if (r == LIBUSB_SUCCESS)
- priv->active_config = (uint8_t)config;
+ priv->active_config = config;
return r;
}
-static int winusb_claim_interface(struct libusb_device_handle *dev_handle, int iface)
+static int winusb_claim_interface(struct libusb_device_handle *dev_handle, uint8_t iface)
{
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
int r;
CHECK_SUPPORTED_API(priv->apib, claim_interface);
@@ -1688,9 +1914,9 @@ static int winusb_claim_interface(struct libusb_device_handle *dev_handle, int i
return r;
}
-static int winusb_set_interface_altsetting(struct libusb_device_handle *dev_handle, int iface, int altsetting)
+static int winusb_set_interface_altsetting(struct libusb_device_handle *dev_handle, uint8_t iface, uint8_t altsetting)
{
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
int r;
CHECK_SUPPORTED_API(priv->apib, set_interface_altsetting);
@@ -1706,9 +1932,9 @@ static int winusb_set_interface_altsetting(struct libusb_device_handle *dev_hand
return r;
}
-static int winusb_release_interface(struct libusb_device_handle *dev_handle, int iface)
+static int winusb_release_interface(struct libusb_device_handle *dev_handle, uint8_t iface)
{
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
CHECK_SUPPORTED_API(priv->apib, release_interface);
@@ -1717,7 +1943,7 @@ static int winusb_release_interface(struct libusb_device_handle *dev_handle, int
static int winusb_clear_halt(struct libusb_device_handle *dev_handle, unsigned char endpoint)
{
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
CHECK_SUPPORTED_API(priv->apib, clear_halt);
@@ -1726,7 +1952,7 @@ static int winusb_clear_halt(struct libusb_device_handle *dev_handle, unsigned c
static int winusb_reset_device(struct libusb_device_handle *dev_handle)
{
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
CHECK_SUPPORTED_API(priv->apib, reset_device);
@@ -1740,14 +1966,11 @@ static void winusb_destroy_device(struct libusb_device *dev)
static void winusb_clear_transfer_priv(struct usbi_transfer *itransfer)
{
- struct winusb_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer);
+ struct winusb_transfer_priv *transfer_priv = get_winusb_transfer_priv(itransfer);
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct winusb_device_priv *priv = _device_priv(transfer->dev_handle->dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(transfer->dev_handle->dev);
int sub_api = priv->sub_api;
- usbi_close(transfer_priv->pollable_fd.fd);
- transfer_priv->pollable_fd = INVALID_WINFD;
- transfer_priv->handle = NULL;
safe_free(transfer_priv->hid_buffer);
if (transfer->type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS && sub_api == SUB_API_WINUSB) {
@@ -1755,7 +1978,7 @@ static void winusb_clear_transfer_priv(struct usbi_transfer *itransfer)
if (WinUSBX[sub_api].UnregisterIsochBuffer(transfer_priv->isoch_buffer_handle)) {
transfer_priv->isoch_buffer_handle = NULL;
} else {
- usbi_dbg("Couldn't unregister isoch buffer!");
+ usbi_warn(TRANSFER_CTX(transfer), "failed to unregister WinUSB isoch buffer: %s", windows_error_str(0));
}
}
}
@@ -1766,64 +1989,28 @@ static void winusb_clear_transfer_priv(struct usbi_transfer *itransfer)
auto_release(itransfer);
}
-static int do_submit_transfer(struct usbi_transfer *itransfer, short events,
- int (*transfer_fn)(int, struct usbi_transfer *))
-{
- struct libusb_context *ctx = ITRANSFER_CTX(itransfer);
- struct winusb_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer);
- struct winfd wfd;
- int r;
-
- wfd = usbi_create_fd();
- if (wfd.fd < 0)
- return LIBUSB_ERROR_NO_MEM;
-
- r = usbi_add_pollfd(ctx, wfd.fd, events);
- if (r) {
- usbi_close(wfd.fd);
- return r;
- }
-
- // Use transfer_priv to store data needed for async polling
- transfer_priv->pollable_fd = wfd;
-
- r = transfer_fn(SUB_API_NOTSET, itransfer);
-
- if ((r != LIBUSB_SUCCESS) && (r != LIBUSB_ERROR_OVERFLOW)) {
- usbi_remove_pollfd(ctx, wfd.fd);
- usbi_close(wfd.fd);
- transfer_priv->pollable_fd = INVALID_WINFD;
- }
-
- return r;
-}
-
static int winusb_submit_transfer(struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct winusb_device_priv *priv = _device_priv(transfer->dev_handle->dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(transfer->dev_handle->dev);
int (*transfer_fn)(int, struct usbi_transfer *);
- short events;
switch (transfer->type) {
case LIBUSB_TRANSFER_TYPE_CONTROL:
- events = (transfer->buffer[0] & LIBUSB_ENDPOINT_IN) ? POLLIN : POLLOUT;
transfer_fn = priv->apib->submit_control_transfer;
break;
case LIBUSB_TRANSFER_TYPE_BULK:
case LIBUSB_TRANSFER_TYPE_INTERRUPT:
if (IS_XFEROUT(transfer) && (transfer->flags & LIBUSB_TRANSFER_ADD_ZERO_PACKET))
return LIBUSB_ERROR_NOT_SUPPORTED;
- events = IS_XFERIN(transfer) ? POLLIN : POLLOUT;
transfer_fn = priv->apib->submit_bulk_transfer;
break;
case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
- events = IS_XFERIN(transfer) ? POLLIN : POLLOUT;
transfer_fn = priv->apib->submit_iso_transfer;
break;
- case LIBUSB_TRANSFER_TYPE_BULK_STREAM:
- return LIBUSB_ERROR_NOT_SUPPORTED;
default:
+ // Should not get here since windows_submit_transfer() validates
+ // the transfer->type field
usbi_err(TRANSFER_CTX(transfer), "unknown endpoint type %d", transfer->type);
return LIBUSB_ERROR_INVALID_PARAM;
}
@@ -1835,76 +2022,30 @@ static int winusb_submit_transfer(struct usbi_transfer *itransfer)
return LIBUSB_ERROR_NOT_SUPPORTED;
}
- return do_submit_transfer(itransfer, events, transfer_fn);
+ return transfer_fn(SUB_API_NOTSET, itransfer);
}
-static int windows_abort_control(struct usbi_transfer *itransfer)
-{
- struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct winusb_device_priv *priv = _device_priv(transfer->dev_handle->dev);
-
- CHECK_SUPPORTED_API(priv->apib, abort_control);
-
- return priv->apib->abort_control(SUB_API_NOTSET, itransfer);
-}
-
-static int windows_abort_transfers(struct usbi_transfer *itransfer)
+static int winusb_cancel_transfer(struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct winusb_device_priv *priv = _device_priv(transfer->dev_handle->dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(transfer->dev_handle->dev);
- CHECK_SUPPORTED_API(priv->apib, abort_transfers);
+ CHECK_SUPPORTED_API(priv->apib, cancel_transfer);
- return priv->apib->abort_transfers(SUB_API_NOTSET, itransfer);
+ return priv->apib->cancel_transfer(SUB_API_NOTSET, itransfer);
}
-static int winusb_cancel_transfer(struct usbi_transfer *itransfer)
+static enum libusb_transfer_status winusb_copy_transfer_data(struct usbi_transfer *itransfer, DWORD length)
{
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
+ struct winusb_device_priv *priv = usbi_get_device_priv(transfer->dev_handle->dev);
- switch (transfer->type) {
- case LIBUSB_TRANSFER_TYPE_CONTROL:
- return windows_abort_control(itransfer);
- case LIBUSB_TRANSFER_TYPE_BULK:
- case LIBUSB_TRANSFER_TYPE_INTERRUPT:
- case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
- return windows_abort_transfers(itransfer);
- case LIBUSB_TRANSFER_TYPE_BULK_STREAM:
- return LIBUSB_ERROR_NOT_SUPPORTED;
- default:
- usbi_err(ITRANSFER_CTX(itransfer), "unknown endpoint type %d", transfer->type);
- return LIBUSB_ERROR_INVALID_PARAM;
+ if (priv->apib->copy_transfer_data == NULL) {
+ usbi_err(TRANSFER_CTX(transfer), "program assertion failed - no function to copy transfer data");
+ return LIBUSB_TRANSFER_ERROR;
}
-}
-static int winusb_copy_transfer_data(struct usbi_transfer *itransfer, uint32_t io_size)
-{
- struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct winusb_device_priv *priv = _device_priv(transfer->dev_handle->dev);
- return priv->apib->copy_transfer_data(SUB_API_NOTSET, itransfer, io_size);
-}
-
-static int winusb_get_transfer_fd(struct usbi_transfer *itransfer)
-{
- struct winusb_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer);
- return transfer_priv->pollable_fd.fd;
-}
-
-static void winusb_get_overlapped_result(struct usbi_transfer *itransfer,
- DWORD *io_result, DWORD *io_size)
-{
- struct winusb_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer);
- struct winfd *pollable_fd = &transfer_priv->pollable_fd;
-
- if (HasOverlappedIoCompletedSync(pollable_fd->overlapped)) {
- *io_result = NO_ERROR;
- *io_size = (DWORD)pollable_fd->overlapped->InternalHigh;
- } else if (GetOverlappedResult(transfer_priv->handle, pollable_fd->overlapped, io_size, FALSE)) {
- // Regular async overlapped
- *io_result = NO_ERROR;
- } else {
- *io_result = GetLastError();
- }
+ return priv->apib->copy_transfer_data(SUB_API_NOTSET, itransfer, length);
}
// NB: MSVC6 does not support named initializers.
@@ -1914,7 +2055,6 @@ const struct windows_backend winusb_backend = {
winusb_get_device_list,
winusb_open,
winusb_close,
- winusb_get_device_descriptor,
winusb_get_active_config_descriptor,
winusb_get_config_descriptor,
winusb_get_config_descriptor_by_value,
@@ -1930,8 +2070,6 @@ const struct windows_backend winusb_backend = {
winusb_cancel_transfer,
winusb_clear_transfer_priv,
winusb_copy_transfer_data,
- winusb_get_transfer_fd,
- winusb_get_overlapped_result,
};
/*
@@ -1945,12 +2083,44 @@ const struct windows_usb_api_backend usb_api_backend[USB_API_MAX] = {
{
USB_API_UNSUPPORTED,
"Unsupported API",
- // No supported operations
+ NULL, /* driver_name_list */
+ 0, /* nb_driver_names */
+ NULL, /* init */
+ NULL, /* exit */
+ NULL, /* open */
+ NULL, /* close */
+ NULL, /* configure_endpoints */
+ NULL, /* claim_interface */
+ NULL, /* set_interface_altsetting */
+ NULL, /* release_interface */
+ NULL, /* clear_halt */
+ NULL, /* reset_device */
+ NULL, /* submit_bulk_transfer */
+ NULL, /* submit_iso_transfer */
+ NULL, /* submit_control_transfer */
+ NULL, /* cancel_transfer */
+ NULL, /* copy_transfer_data */
},
{
USB_API_HUB,
"HUB API",
- // No supported operations
+ NULL, /* driver_name_list */
+ 0, /* nb_driver_names */
+ NULL, /* init */
+ NULL, /* exit */
+ NULL, /* open */
+ NULL, /* close */
+ NULL, /* configure_endpoints */
+ NULL, /* claim_interface */
+ NULL, /* set_interface_altsetting */
+ NULL, /* release_interface */
+ NULL, /* clear_halt */
+ NULL, /* reset_device */
+ NULL, /* submit_bulk_transfer */
+ NULL, /* submit_iso_transfer */
+ NULL, /* submit_control_transfer */
+ NULL, /* cancel_transfer */
+ NULL, /* copy_transfer_data */
},
{
USB_API_COMPOSITE,
@@ -1970,8 +2140,7 @@ const struct windows_usb_api_backend usb_api_backend[USB_API_MAX] = {
composite_submit_bulk_transfer,
composite_submit_iso_transfer,
composite_submit_control_transfer,
- composite_abort_control,
- composite_abort_transfers,
+ composite_cancel_transfer,
composite_copy_transfer_data,
},
{
@@ -1992,8 +2161,7 @@ const struct windows_usb_api_backend usb_api_backend[USB_API_MAX] = {
winusbx_submit_bulk_transfer,
winusbx_submit_iso_transfer,
winusbx_submit_control_transfer,
- winusbx_abort_control,
- winusbx_abort_transfers,
+ winusbx_cancel_transfer,
winusbx_copy_transfer_data,
},
{
@@ -2014,8 +2182,7 @@ const struct windows_usb_api_backend usb_api_backend[USB_API_MAX] = {
hid_submit_bulk_transfer,
NULL, /* submit_iso_transfer */
hid_submit_control_transfer,
- hid_abort_transfers,
- hid_abort_transfers,
+ NULL, /* cancel_transfer */
hid_copy_transfer_data,
},
};
@@ -2024,105 +2191,159 @@ const struct windows_usb_api_backend usb_api_backend[USB_API_MAX] = {
/*
* WinUSB-like (WinUSB, libusb0/libusbK through libusbk DLL) API functions
*/
-#define WinUSBX_Set(fn) \
+#define WinUSB_Set(h, fn, required) \
do { \
- if (native_winusb) \
- WinUSBX[i].fn = (WinUsb_##fn##_t)GetProcAddress(h, "WinUsb_" #fn); \
- else \
- pLibK_GetProcAddress((PVOID *)&WinUSBX[i].fn, i, KUSB_FNID_##fn); \
+ WinUSBX[SUB_API_WINUSB].fn = (WinUsb_##fn##_t)GetProcAddress(h, "WinUsb_" #fn); \
+ if (required && (WinUSBX[SUB_API_WINUSB].fn == NULL)) { \
+ usbi_err(ctx, "GetProcAddress() failed for WinUsb_%s", #fn); \
+ goto cleanup_winusb; \
+ } \
} while (0)
-#define NativeWinUSBOnly_Set(fn) \
+#define libusbK_Set(sub_api, fn, required) \
do { \
- if (native_winusb) \
- WinUSBX[i].fn = (WinUsb_##fn##_t)GetProcAddress(h, "WinUsb_" #fn); \
- else \
- WinUSBX[i].fn = NULL; \
+ pLibK_GetProcAddress((PVOID *)&WinUSBX[sub_api].fn, sub_api, KUSB_FNID_##fn); \
+ if (required && (WinUSBX[sub_api].fn == NULL)) { \
+ usbi_err(ctx, "LibK_GetProcAddress() failed for LibK_%s", #fn); \
+ goto cleanup_libusbk; \
+ } \
} while (0)
-static int winusbx_init(struct libusb_context *ctx)
+static bool winusbx_init(struct libusb_context *ctx)
{
- HMODULE h;
- bool native_winusb;
- int i;
- KLIB_VERSION LibK_Version;
- LibK_GetProcAddress_t pLibK_GetProcAddress = NULL;
- LibK_GetVersion_t pLibK_GetVersion;
+ HMODULE hWinUSB, hlibusbK;
+
+ hWinUSB = load_system_library(ctx, "WinUSB");
+ if (hWinUSB != NULL) {
+ WinUSB_Set(hWinUSB, AbortPipe, true);
+ WinUSB_Set(hWinUSB, ControlTransfer, true);
+ WinUSB_Set(hWinUSB, FlushPipe, true);
+ WinUSB_Set(hWinUSB, Free, true);
+ WinUSB_Set(hWinUSB, GetAssociatedInterface, true);
+ WinUSB_Set(hWinUSB, Initialize, true);
+ WinUSB_Set(hWinUSB, ReadPipe, true);
+ WinUSB_Set(hWinUSB, ResetPipe, true);
+ WinUSB_Set(hWinUSB, SetCurrentAlternateSetting, true);
+ WinUSB_Set(hWinUSB, SetPipePolicy, true);
+ WinUSB_Set(hWinUSB, WritePipe, true);
+
+ // Check for isochronous transfers support (available starting with Windows 8.1)
+ WinUSB_Set(hWinUSB, ReadIsochPipeAsap, false);
+ if (WinUSBX[SUB_API_WINUSB].ReadIsochPipeAsap != NULL) {
+ WinUSB_Set(hWinUSB, QueryPipeEx, true);
+ WinUSB_Set(hWinUSB, RegisterIsochBuffer, true);
+ WinUSB_Set(hWinUSB, UnregisterIsochBuffer, true);
+ WinUSB_Set(hWinUSB, WriteIsochPipeAsap, true);
+ }
- h = LoadLibraryA("libusbK");
+ WinUSBX[SUB_API_WINUSB].hDll = hWinUSB;
- if (h == NULL) {
- usbi_info(ctx, "libusbK DLL is not available, will use native WinUSB");
- h = LoadLibraryA("WinUSB");
+ usbi_info(ctx, "WinUSB DLL available (%s isoch support)",
+ (WinUSBX[SUB_API_WINUSB].ReadIsochPipeAsap != NULL) ? "with" : "without");
- if (h == NULL) {
- usbi_warn(ctx, "WinUSB DLL is not available either, "
- "you will not be able to access devices outside of enumeration");
- return LIBUSB_ERROR_NOT_FOUND;
+cleanup_winusb:
+ if (WinUSBX[SUB_API_WINUSB].hDll == NULL) {
+ usbi_err(ctx, "failed to initialize WinUSB");
+ memset(&WinUSBX[SUB_API_WINUSB], 0, sizeof(WinUSBX[SUB_API_WINUSB]));
+ FreeLibrary(hWinUSB);
+ hWinUSB = NULL;
}
} else {
- usbi_dbg("using libusbK DLL for universal access");
- pLibK_GetVersion = (LibK_GetVersion_t)GetProcAddress(h, "LibK_GetVersion");
+ usbi_info(ctx, "WinUSB DLL is not available");
+ }
+
+ hlibusbK = load_system_library(ctx, "libusbK");
+ if (hlibusbK != NULL) {
+ LibK_GetVersion_t pLibK_GetVersion;
+ LibK_GetProcAddress_t pLibK_GetProcAddress;
+ int sub_api = 0;
+
+ pLibK_GetVersion = (LibK_GetVersion_t)GetProcAddress(hlibusbK, "LibK_GetVersion");
if (pLibK_GetVersion != NULL) {
+ KLIB_VERSION LibK_Version;
+
pLibK_GetVersion(&LibK_Version);
- usbi_dbg("libusbK version: %d.%d.%d.%d", LibK_Version.Major, LibK_Version.Minor,
+ usbi_dbg("libusbK DLL found, version: %d.%d.%d.%d", LibK_Version.Major, LibK_Version.Minor,
LibK_Version.Micro, LibK_Version.Nano);
+ } else {
+ usbi_dbg("libusbK DLL found, version unknown");
}
- pLibK_GetProcAddress = (LibK_GetProcAddress_t)GetProcAddress(h, "LibK_GetProcAddress");
+
+ pLibK_GetProcAddress = (LibK_GetProcAddress_t)GetProcAddress(hlibusbK, "LibK_GetProcAddress");
if (pLibK_GetProcAddress == NULL) {
usbi_err(ctx, "LibK_GetProcAddress() not found in libusbK DLL");
- FreeLibrary(h);
- return LIBUSB_ERROR_NOT_FOUND;
+ goto cleanup_libusbk;
}
- }
- native_winusb = (pLibK_GetProcAddress == NULL);
- for (i = 0; i < SUB_API_MAX; i++) {
- WinUSBX_Set(AbortPipe);
- WinUSBX_Set(ControlTransfer);
- WinUSBX_Set(FlushPipe);
- WinUSBX_Set(Free);
- WinUSBX_Set(GetAssociatedInterface);
- WinUSBX_Set(Initialize);
- WinUSBX_Set(ReadPipe);
- if (!native_winusb)
- WinUSBX_Set(ResetDevice);
- WinUSBX_Set(ResetPipe);
- WinUSBX_Set(SetCurrentAlternateSetting);
- WinUSBX_Set(SetPipePolicy);
- WinUSBX_Set(WritePipe);
- WinUSBX_Set(IsoReadPipe);
- WinUSBX_Set(IsoWritePipe);
- NativeWinUSBOnly_Set(RegisterIsochBuffer);
- NativeWinUSBOnly_Set(UnregisterIsochBuffer);
- NativeWinUSBOnly_Set(WriteIsochPipeAsap);
- NativeWinUSBOnly_Set(ReadIsochPipeAsap);
- NativeWinUSBOnly_Set(QueryPipeEx);
-
- if (WinUSBX[i].Initialize != NULL) {
- WinUSBX[i].initialized = true;
- // Assume driver supports CancelIoEx() if it is available
- WinUSBX[i].CancelIoEx_supported = (pCancelIoEx != NULL);
- usbi_dbg("initalized sub API %s", winusbx_driver_names[i]);
- } else {
- usbi_warn(ctx, "Failed to initalize sub API %s", winusbx_driver_names[i]);
- WinUSBX[i].initialized = false;
+ // NB: The below for loop works because the sub_api value for WinUSB
+ // is a higher value than that of libusbK and libusb0
+ for (; sub_api < SUB_API_WINUSB; sub_api++) {
+ libusbK_Set(sub_api, AbortPipe, true);
+ libusbK_Set(sub_api, ControlTransfer, true);
+ libusbK_Set(sub_api, FlushPipe, true);
+ libusbK_Set(sub_api, Free, true);
+ libusbK_Set(sub_api, GetAssociatedInterface, true);
+ libusbK_Set(sub_api, Initialize, true);
+ libusbK_Set(sub_api, ReadPipe, true);
+ libusbK_Set(sub_api, ResetPipe, true);
+ libusbK_Set(sub_api, SetCurrentAlternateSetting, true);
+ libusbK_Set(sub_api, SetPipePolicy, true);
+ libusbK_Set(sub_api, WritePipe, true);
+
+ // Optional isochronous support
+ libusbK_Set(sub_api, IsoReadPipe, false);
+ if (WinUSBX[sub_api].IsoReadPipe != NULL)
+ libusbK_Set(sub_api, IsoWritePipe, true);
+
+ // Optional device reset support
+ libusbK_Set(sub_api, ResetDevice, false);
+
+ WinUSBX[sub_api].hDll = hlibusbK;
+ }
+
+cleanup_libusbk:
+ if (sub_api < SUB_API_WINUSB) {
+ usbi_err(ctx, "failed to initialize libusbK");
+ while (sub_api >= 0) {
+ memset(&WinUSBX[sub_api], 0, sizeof(WinUSBX[sub_api]));
+ sub_api--;
+ }
+ FreeLibrary(hlibusbK);
+ hlibusbK = NULL;
}
+ } else {
+ usbi_info(ctx, "libusbK DLL is not available");
}
- WinUSBX_handle = h;
- return LIBUSB_SUCCESS;
+ if ((hWinUSB == NULL) && (hlibusbK == NULL)) {
+ usbi_warn(ctx, "neither WinUSB nor libusbK DLLs were found, "
+ "you will not be able to access devices outside of enumeration");
+ return false;
+ }
+
+ return true;
}
static void winusbx_exit(void)
{
- if (WinUSBX_handle != NULL) {
- FreeLibrary(WinUSBX_handle);
- WinUSBX_handle = NULL;
+ bool loaded = false;
+ HMODULE hDll;
- /* Reset the WinUSBX API structures */
- memset(&WinUSBX, 0, sizeof(WinUSBX));
+ hDll = WinUSBX[SUB_API_LIBUSBK].hDll;
+ if (hDll != NULL) {
+ FreeLibrary(hDll);
+ loaded = true;
}
+
+ hDll = WinUSBX[SUB_API_WINUSB].hDll;
+ if (hDll != NULL) {
+ FreeLibrary(hDll);
+ loaded = true;
+ }
+
+ // Reset the WinUSBX API structures if something was loaded
+ if (loaded)
+ memset(&WinUSBX, 0, sizeof(WinUSBX));
}
// NB: open and close must ensure that they only handle interface of
@@ -2130,9 +2351,8 @@ static void winusbx_exit(void)
// composite_open(), with interfaces belonging to different APIs
static int winusbx_open(int sub_api, struct libusb_device_handle *dev_handle)
{
- struct libusb_context *ctx = DEVICE_CTX(dev_handle->dev);
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
HANDLE file_handle;
int i;
@@ -2142,10 +2362,9 @@ static int winusbx_open(int sub_api, struct libusb_device_handle *dev_handle)
for (i = 0; i < USB_MAXINTERFACES; i++) {
if ((priv->usb_interface[i].path != NULL)
&& (priv->usb_interface[i].apib->id == USB_API_WINUSBX)) {
- file_handle = CreateFileA(priv->usb_interface[i].path, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ,
- NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL);
+ file_handle = windows_open(dev_handle->dev, priv->usb_interface[i].path, GENERIC_READ | GENERIC_WRITE);
if (file_handle == INVALID_HANDLE_VALUE) {
- usbi_err(ctx, "could not open device %s (interface %d): %s", priv->usb_interface[i].path, i, windows_error_str(0));
+ usbi_err(HANDLE_CTX(dev_handle), "could not open device %s (interface %d): %s", priv->usb_interface[i].path, i, windows_error_str(0));
switch (GetLastError()) {
case ERROR_FILE_NOT_FOUND: // The device was disconnected
return LIBUSB_ERROR_NO_DEVICE;
@@ -2155,6 +2374,7 @@ static int winusbx_open(int sub_api, struct libusb_device_handle *dev_handle)
return LIBUSB_ERROR_IO;
}
}
+
handle_priv->interface_handle[i].dev_handle = file_handle;
}
}
@@ -2164,15 +2384,15 @@ static int winusbx_open(int sub_api, struct libusb_device_handle *dev_handle)
static void winusbx_close(int sub_api, struct libusb_device_handle *dev_handle)
{
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(dev_handle);
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
HANDLE handle;
int i;
if (sub_api == SUB_API_NOTSET)
sub_api = priv->sub_api;
- if (!WinUSBX[sub_api].initialized)
+ if (WinUSBX[sub_api].hDll == NULL)
return;
if (priv->apib->id == USB_API_COMPOSITE) {
@@ -2207,10 +2427,10 @@ static void winusbx_close(int sub_api, struct libusb_device_handle *dev_handle)
}
}
-static int winusbx_configure_endpoints(int sub_api, struct libusb_device_handle *dev_handle, int iface)
+static int winusbx_configure_endpoints(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface)
{
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(dev_handle);
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
HANDLE winusb_handle = handle_priv->interface_handle[iface].api_handle;
UCHAR policy;
ULONG timeout = 0;
@@ -2219,7 +2439,7 @@ static int winusbx_configure_endpoints(int sub_api, struct libusb_device_handle
CHECK_WINUSBX_AVAILABLE(sub_api);
- // With handle and enpoints set (in parent), we can setup the default pipe properties
+ // With handle and endpoints set (in parent), we can setup the default pipe properties
// see http://download.microsoft.com/download/D/1/D/D1DD7745-426B-4CC3-A269-ABBBE427C0EF/DVC-T705_DDC08.pptx
for (i = -1; i < priv->usb_interface[iface].nb_endpoints; i++) {
endpoint_address = (i == -1) ? 0 : priv->usb_interface[iface].endpoint[i];
@@ -2260,21 +2480,20 @@ static int winusbx_configure_endpoints(int sub_api, struct libusb_device_handle
return LIBUSB_SUCCESS;
}
-static int winusbx_claim_interface(int sub_api, struct libusb_device_handle *dev_handle, int iface)
+static int winusbx_claim_interface(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface)
{
- struct libusb_context *ctx = DEVICE_CTX(dev_handle->dev);
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(dev_handle);
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct libusb_context *ctx = HANDLE_CTX(dev_handle);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
bool is_using_usbccgp = (priv->apib->id == USB_API_COMPOSITE);
- SP_DEVICE_INTERFACE_DETAIL_DATA_A *dev_interface_details = NULL;
- HDEVINFO dev_info = INVALID_HANDLE_VALUE;
- SP_DEVINFO_DATA dev_info_data;
- char *dev_path_no_guid = NULL;
+ HDEVINFO dev_info;
+ char *dev_interface_path = NULL;
+ char *dev_interface_path_guid_start;
char filter_path[] = "\\\\.\\libusb0-0000";
bool found_filter = false;
HANDLE file_handle, winusb_handle;
- DWORD err;
- int i;
+ DWORD err, _index;
+ int r;
CHECK_WINUSBX_AVAILABLE(sub_api);
@@ -2292,27 +2511,30 @@ static int winusbx_claim_interface(int sub_api, struct libusb_device_handle *dev
switch (err) {
case ERROR_BAD_COMMAND:
// The device was disconnected
- usbi_err(ctx, "could not access interface %d: %s", iface, windows_error_str(0));
+ usbi_err(ctx, "could not access interface %u: %s", iface, windows_error_str(0));
return LIBUSB_ERROR_NO_DEVICE;
default:
// it may be that we're using the libusb0 filter driver.
// TODO: can we move this whole business into the K/0 DLL?
- for (i = 0; ; i++) {
- safe_free(dev_interface_details);
- safe_free(dev_path_no_guid);
+ r = LIBUSB_SUCCESS;
+ for (_index = 0; ; _index++) {
+ safe_free(dev_interface_path);
+
+ if (found_filter)
+ break;
- dev_interface_details = get_interface_details_filter(ctx, &dev_info, &dev_info_data, &GUID_DEVINTERFACE_LIBUSB0_FILTER, i, filter_path);
- if ((found_filter) || (dev_interface_details == NULL))
+ r = get_interface_details_filter(ctx, &dev_info, _index, filter_path, &dev_interface_path);
+ if ((r != LIBUSB_SUCCESS) || (dev_interface_path == NULL))
break;
// ignore GUID part
- dev_path_no_guid = sanitize_path(strtok(dev_interface_details->DevicePath, "{"));
- if (dev_path_no_guid == NULL)
+ dev_interface_path_guid_start = strchr(dev_interface_path, '{');
+ if (dev_interface_path_guid_start == NULL)
continue;
+ *dev_interface_path_guid_start = '\0';
- if (strncmp(dev_path_no_guid, priv->usb_interface[iface].path, strlen(dev_path_no_guid)) == 0) {
- file_handle = CreateFileA(filter_path, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ,
- NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL);
+ if (strncmp(dev_interface_path, priv->usb_interface[iface].path, strlen(dev_interface_path)) == 0) {
+ file_handle = windows_open(dev_handle->dev, filter_path, GENERIC_READ | GENERIC_WRITE);
if (file_handle != INVALID_HANDLE_VALUE) {
if (WinUSBX[sub_api].Initialize(file_handle, &winusb_handle)) {
// Replace the existing file handle with the working one
@@ -2328,9 +2550,10 @@ static int winusbx_claim_interface(int sub_api, struct libusb_device_handle *dev
}
}
}
- free(dev_interface_details);
+ if (r != LIBUSB_SUCCESS)
+ return r;
if (!found_filter) {
- usbi_err(ctx, "could not access interface %d: %s", iface, windows_error_str(err));
+ usbi_err(ctx, "could not access interface %u: %s", iface, windows_error_str(err));
return LIBUSB_ERROR_ACCESS;
}
}
@@ -2345,9 +2568,9 @@ static int winusbx_claim_interface(int sub_api, struct libusb_device_handle *dev
file_handle = handle_priv->interface_handle[0].dev_handle;
if (WinUSBX[sub_api].Initialize(file_handle, &winusb_handle)) {
handle_priv->interface_handle[0].api_handle = winusb_handle;
- usbi_warn(ctx, "auto-claimed interface 0 (required to claim %d with WinUSB)", iface);
+ usbi_warn(ctx, "auto-claimed interface 0 (required to claim %u with WinUSB)", iface);
} else {
- usbi_warn(ctx, "failed to auto-claim interface 0 (required to claim %d with WinUSB): %s", iface, windows_error_str(0));
+ usbi_warn(ctx, "failed to auto-claim interface 0 (required to claim %u with WinUSB): %s", iface, windows_error_str(0));
return LIBUSB_ERROR_ACCESS;
}
}
@@ -2362,22 +2585,22 @@ static int winusbx_claim_interface(int sub_api, struct libusb_device_handle *dev
case ERROR_ALREADY_EXISTS: // already claimed
return LIBUSB_ERROR_BUSY;
default:
- usbi_err(ctx, "could not claim interface %d: %s", iface, windows_error_str(0));
+ usbi_err(ctx, "could not claim interface %u: %s", iface, windows_error_str(0));
return LIBUSB_ERROR_ACCESS;
}
}
handle_priv->interface_handle[iface].dev_handle = handle_priv->interface_handle[0].dev_handle;
}
- usbi_dbg("claimed interface %d", iface);
+ usbi_dbg("claimed interface %u", iface);
handle_priv->active_interface = iface;
return LIBUSB_SUCCESS;
}
-static int winusbx_release_interface(int sub_api, struct libusb_device_handle *dev_handle, int iface)
+static int winusbx_release_interface(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface)
{
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(dev_handle);
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
HANDLE winusb_handle;
CHECK_WINUSBX_AVAILABLE(sub_api);
@@ -2397,8 +2620,8 @@ static int winusbx_release_interface(int sub_api, struct libusb_device_handle *d
*/
static int get_valid_interface(struct libusb_device_handle *dev_handle, int api_id)
{
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(dev_handle);
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
int i;
if ((api_id < USB_API_WINUSBX) || (api_id > USB_API_HID)) {
@@ -2421,8 +2644,8 @@ static int get_valid_interface(struct libusb_device_handle *dev_handle, int api_
*/
static int check_valid_interface(struct libusb_device_handle *dev_handle, unsigned short interface, int api_id)
{
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(dev_handle);
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
if (interface >= USB_MAXINTERFACES)
return -1;
@@ -2466,10 +2689,9 @@ static int interface_by_endpoint(struct winusb_device_priv *priv,
static int winusbx_submit_control_transfer(int sub_api, struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct libusb_context *ctx = DEVICE_CTX(transfer->dev_handle->dev);
- struct winusb_device_priv *priv = _device_priv(transfer->dev_handle->dev);
- struct winusb_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer);
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(transfer->dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(transfer->dev_handle->dev);
+ struct winusb_transfer_priv *transfer_priv = get_winusb_transfer_priv(itransfer);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(transfer->dev_handle);
PWINUSB_SETUP_PACKET setup = (PWINUSB_SETUP_PACKET)transfer->buffer;
ULONG size;
HANDLE winusb_handle;
@@ -2496,26 +2718,25 @@ static int winusbx_submit_control_transfer(int sub_api, struct usbi_transfer *it
usbi_dbg("will use interface %d", current_interface);
- transfer_priv->handle = winusb_handle = handle_priv->interface_handle[current_interface].api_handle;
- overlapped = transfer_priv->pollable_fd.overlapped;
+ winusb_handle = handle_priv->interface_handle[current_interface].api_handle;
+ set_transfer_priv_handle(itransfer, handle_priv->interface_handle[current_interface].dev_handle);
+ overlapped = get_transfer_priv_overlapped(itransfer);
// Sending of set configuration control requests from WinUSB creates issues, except when using libusb0.sys
if (sub_api != SUB_API_LIBUSB0
&& (LIBUSB_REQ_TYPE(setup->RequestType) == LIBUSB_REQUEST_TYPE_STANDARD)
&& (setup->Request == LIBUSB_REQUEST_SET_CONFIGURATION)) {
if (setup->Value != priv->active_config) {
- usbi_warn(ctx, "cannot set configuration other than the default one");
- return LIBUSB_ERROR_INVALID_PARAM;
+ usbi_warn(TRANSFER_CTX(transfer), "cannot set configuration other than the default one");
+ return LIBUSB_ERROR_NOT_SUPPORTED;
}
- windows_force_sync_completion(overlapped, 0);
+ windows_force_sync_completion(itransfer, 0);
} else {
if (!WinUSBX[sub_api].ControlTransfer(winusb_handle, *setup, transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE, size, NULL, overlapped)) {
if (GetLastError() != ERROR_IO_PENDING) {
- usbi_warn(ctx, "ControlTransfer failed: %s", windows_error_str(0));
+ usbi_warn(TRANSFER_CTX(transfer), "ControlTransfer failed: %s", windows_error_str(0));
return LIBUSB_ERROR_IO;
}
- } else {
- windows_force_sync_completion(overlapped, size);
}
}
@@ -2524,57 +2745,28 @@ static int winusbx_submit_control_transfer(int sub_api, struct usbi_transfer *it
return LIBUSB_SUCCESS;
}
-static int winusbx_set_interface_altsetting(int sub_api, struct libusb_device_handle *dev_handle, int iface, int altsetting)
+static int winusbx_set_interface_altsetting(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface, uint8_t altsetting)
{
- struct libusb_context *ctx = DEVICE_CTX(dev_handle->dev);
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(dev_handle);
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
HANDLE winusb_handle;
CHECK_WINUSBX_AVAILABLE(sub_api);
- if (altsetting > 255)
- return LIBUSB_ERROR_INVALID_PARAM;
-
winusb_handle = handle_priv->interface_handle[iface].api_handle;
if (!HANDLE_VALID(winusb_handle)) {
- usbi_err(ctx, "interface must be claimed first");
+ usbi_err(HANDLE_CTX(dev_handle), "interface must be claimed first");
return LIBUSB_ERROR_NOT_FOUND;
}
- if (!WinUSBX[sub_api].SetCurrentAlternateSetting(winusb_handle, (UCHAR)altsetting)) {
- usbi_err(ctx, "SetCurrentAlternateSetting failed: %s", windows_error_str(0));
+ if (!WinUSBX[sub_api].SetCurrentAlternateSetting(winusb_handle, altsetting)) {
+ usbi_err(HANDLE_CTX(dev_handle), "SetCurrentAlternateSetting failed: %s", windows_error_str(0));
return LIBUSB_ERROR_IO;
}
return LIBUSB_SUCCESS;
}
-static enum libusb_transfer_status usbd_status_to_libusb_transfer_status(USBD_STATUS status)
-{
- /* Based on https://msdn.microsoft.com/en-us/library/windows/hardware/ff539136(v=vs.85).aspx :
- * USBD_STATUS have the most significant 4 bits indicating overall status and the rest gives the details. */
- switch (status >> 28) {
- case 0x00: /* USBD_STATUS_SUCCESS */
- return LIBUSB_TRANSFER_COMPLETED;
- case 0x01: /* USBD_STATUS_PENDING */
- return LIBUSB_TRANSFER_COMPLETED;
- default: /* USBD_STATUS_ERROR */
- switch (status & 0x0fffffff) {
- case 0xC0006000: /* USBD_STATUS_TIMEOUT */
- return LIBUSB_TRANSFER_TIMED_OUT;
- case 0xC0010000: /* USBD_STATUS_CANCELED */
- return LIBUSB_TRANSFER_CANCELLED;
- case 0xC0000030: /* USBD_STATUS_ENDPOINT_HALTED */
- return LIBUSB_TRANSFER_STALL;
- case 0xC0007000: /* USBD_STATUS_DEVICE_GONE */
- return LIBUSB_TRANSFER_NO_DEVICE;
- default:
- usbi_dbg("USBD_STATUS 0x%08lx translated to LIBUSB_TRANSFER_ERROR", status);
- return LIBUSB_TRANSFER_ERROR;
- }
- }
-}
static void WINAPI winusbx_native_iso_transfer_continue_stream_callback(struct libusb_transfer *transfer)
{
@@ -2583,27 +2775,24 @@ static void WINAPI winusbx_native_iso_transfer_continue_stream_callback(struct l
// The role of this callback is to fallback to ContinueStream = FALSE if the transfer
// did not succeed.
- struct winusb_transfer_priv *transfer_priv = (struct winusb_transfer_priv *)
- usbi_transfer_get_os_priv(LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer));
- BOOL fallback = (transfer->status != LIBUSB_TRANSFER_COMPLETED);
+ struct winusb_transfer_priv *transfer_priv =
+ get_winusb_transfer_priv(LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer));
+ bool fallback = (transfer->status != LIBUSB_TRANSFER_COMPLETED);
int idx;
// Restore the user callback
transfer->callback = transfer_priv->iso_user_callback;
- for (idx = 0; idx < transfer->num_iso_packets && !fallback; ++idx) {
- if (transfer->iso_packet_desc[idx].status != LIBUSB_TRANSFER_COMPLETED) {
- fallback = TRUE;
- }
+ for (idx = 0; idx < transfer->num_iso_packets && !fallback; idx++) {
+ if (transfer->iso_packet_desc[idx].status != LIBUSB_TRANSFER_COMPLETED)
+ fallback = true;
}
if (!fallback) {
// If the transfer was successful, we restore the user callback and call it.
- if (transfer->callback) {
+ if (transfer->callback)
transfer->callback(transfer);
- }
- }
- else {
+ } else {
// If the transfer wasn't successful we reschedule the transfer while forcing it
// not to continue the stream. This might results in a 5-ms delay.
transfer_priv->iso_break_stream = TRUE;
@@ -2613,27 +2802,27 @@ static void WINAPI winusbx_native_iso_transfer_continue_stream_callback(struct l
static int winusbx_submit_iso_transfer(int sub_api, struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct libusb_context *ctx = DEVICE_CTX(transfer->dev_handle->dev);
- struct winusb_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer);
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(transfer->dev_handle);
- struct winusb_device_priv *priv = _device_priv(transfer->dev_handle->dev);
+ struct winusb_transfer_priv *transfer_priv = get_winusb_transfer_priv(itransfer);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(transfer->dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(transfer->dev_handle->dev);
HANDLE winusb_handle;
OVERLAPPED *overlapped;
- bool ret;
+ BOOL ret;
int current_interface;
CHECK_WINUSBX_AVAILABLE(sub_api);
current_interface = interface_by_endpoint(priv, handle_priv, transfer->endpoint);
if (current_interface < 0) {
- usbi_err(ctx, "unable to match endpoint to an open interface - cancelling transfer");
+ usbi_err(TRANSFER_CTX(transfer), "unable to match endpoint to an open interface - cancelling transfer");
return LIBUSB_ERROR_NOT_FOUND;
- } else {
- usbi_dbg("matched endpoint %02X with interface %d", transfer->endpoint, current_interface);
}
- transfer_priv->handle = winusb_handle = handle_priv->interface_handle[current_interface].api_handle;
- overlapped = transfer_priv->pollable_fd.overlapped;
+ usbi_dbg("matched endpoint %02X with interface %d", transfer->endpoint, current_interface);
+
+ winusb_handle = handle_priv->interface_handle[current_interface].api_handle;
+ set_transfer_priv_handle(itransfer, handle_priv->interface_handle[current_interface].dev_handle);
+ overlapped = get_transfer_priv_overlapped(itransfer);
if ((sub_api == SUB_API_LIBUSBK) || (sub_api == SUB_API_LIBUSB0)) {
int i;
@@ -2641,6 +2830,11 @@ static int winusbx_submit_iso_transfer(int sub_api, struct usbi_transfer *itrans
size_t iso_ctx_size;
PKISO_CONTEXT iso_context;
+ if (WinUSBX[sub_api].IsoReadPipe == NULL) {
+ usbi_warn(TRANSFER_CTX(transfer), "libusbK DLL does not support isoch transfers");
+ return LIBUSB_ERROR_NOT_SUPPORTED;
+ }
+
iso_ctx_size = sizeof(KISO_CONTEXT) + (transfer->num_iso_packets * sizeof(KISO_PACKET));
transfer_priv->iso_context = iso_context = calloc(1, iso_ctx_size);
if (transfer_priv->iso_context == NULL)
@@ -2665,42 +2859,29 @@ static int winusbx_submit_iso_transfer(int sub_api, struct usbi_transfer *itrans
ret = WinUSBX[sub_api].IsoWritePipe(winusb_handle, transfer->endpoint, transfer->buffer, transfer->length, overlapped, iso_context);
}
- if (!ret) {
- if (GetLastError() != ERROR_IO_PENDING) {
- usbi_err(ctx, "IsoReadPipe/IsoWritePipe failed: %s", windows_error_str(0));
- return LIBUSB_ERROR_IO;
- }
- } else {
- windows_force_sync_completion(overlapped, (ULONG)transfer->length);
+ if (!ret && GetLastError() != ERROR_IO_PENDING) {
+ usbi_err(TRANSFER_CTX(transfer), "IsoReadPipe/IsoWritePipe failed: %s", windows_error_str(0));
+ return LIBUSB_ERROR_IO;
}
transfer_priv->interface_number = (uint8_t)current_interface;
return LIBUSB_SUCCESS;
- }
- else if (sub_api == SUB_API_WINUSB) {
+ } else if (sub_api == SUB_API_WINUSB) {
WINUSB_PIPE_INFORMATION_EX pipe_info_ex = { 0 };
WINUSB_ISOCH_BUFFER_HANDLE buffer_handle;
ULONG iso_transfer_size_multiple;
int out_transfer_length = 0;
int idx;
-# define WINUSBX_CHECK_API_SUPPORTED(API) \
- if (WinUSBX[sub_api].API == NULL) \
- { \
- usbi_dbg(#API " isn't available"); \
- return LIBUSB_ERROR_NOT_SUPPORTED; \
- }
-
// Depending on the version of Microsoft WinUSB, isochronous transfers may not be supported.
- WINUSBX_CHECK_API_SUPPORTED(RegisterIsochBuffer);
- WINUSBX_CHECK_API_SUPPORTED(ReadIsochPipeAsap);
- WINUSBX_CHECK_API_SUPPORTED(WriteIsochPipeAsap);
- WINUSBX_CHECK_API_SUPPORTED(UnregisterIsochBuffer);
- WINUSBX_CHECK_API_SUPPORTED(QueryPipeEx);
+ if (WinUSBX[sub_api].ReadIsochPipeAsap == NULL) {
+ usbi_warn(TRANSFER_CTX(transfer), "WinUSB DLL does not support isoch transfers");
+ return LIBUSB_ERROR_NOT_SUPPORTED;
+ }
if (sizeof(struct libusb_iso_packet_descriptor) != sizeof(USBD_ISO_PACKET_DESCRIPTOR)) {
- usbi_dbg("The size of Microsoft WinUsb and libusb isochronous packet descriptor doesn't match.");
+ usbi_err(TRANSFER_CTX(transfer), "size of WinUsb and libusb isoch packet descriptors don't match");
return LIBUSB_ERROR_NOT_SUPPORTED;
}
@@ -2708,18 +2889,17 @@ static int winusbx_submit_iso_transfer(int sub_api, struct usbi_transfer *itrans
for (idx = 0; idx < priv->usb_interface[current_interface].nb_endpoints; ++idx) {
ret = WinUSBX[sub_api].QueryPipeEx(winusb_handle, (UINT8)priv->usb_interface[current_interface].current_altsetting, (UCHAR)idx, &pipe_info_ex);
if (!ret) {
- usbi_dbg("Couldn't query interface settings for USB pipe with index %d. Error: %s", idx, windows_error_str(0));
+ usbi_err(TRANSFER_CTX(transfer), "couldn't query interface settings for USB pipe with index %d. Error: %s", idx, windows_error_str(0));
return LIBUSB_ERROR_NOT_FOUND;
}
- if (pipe_info_ex.PipeId == transfer->endpoint && pipe_info_ex.PipeType == UsbdPipeTypeIsochronous) {
+ if (pipe_info_ex.PipeId == transfer->endpoint && pipe_info_ex.PipeType == UsbdPipeTypeIsochronous)
break;
- }
}
// Make sure we found the index.
- if (idx >= priv->usb_interface[current_interface].nb_endpoints) {
- usbi_dbg("Couldn't find the isochronous endpoint %02x.", transfer->endpoint);
+ if (idx == priv->usb_interface[current_interface].nb_endpoints) {
+ usbi_err(TRANSFER_CTX(transfer), "couldn't find isoch endpoint 0x%02x", transfer->endpoint);
return LIBUSB_ERROR_NOT_FOUND;
}
@@ -2727,27 +2907,25 @@ static int winusbx_submit_iso_transfer(int sub_api, struct usbi_transfer *itrans
int interval = pipe_info_ex.Interval;
// For high-speed and SuperSpeed device, the interval is 2**(bInterval-1).
- if (libusb_get_device_speed(libusb_get_device(transfer->dev_handle)) >= LIBUSB_SPEED_HIGH) {
+ if (transfer->dev_handle->dev->speed >= LIBUSB_SPEED_HIGH)
interval = (1 << (pipe_info_ex.Interval - 1));
- }
- // WinUSB only supports isochronous transfers spanning a full USB frames. Later, we might be smarter about this
+ // WinUSB only supports isoch transfers spanning a full USB frames. Later, we might be smarter about this
// and allocate a temporary buffer. However, this is harder than it seems as its destruction would depend on overlapped
// IO...
iso_transfer_size_multiple = (pipe_info_ex.MaximumBytesPerInterval * 8) / interval;
if (transfer->length % iso_transfer_size_multiple != 0) {
- usbi_dbg("The length of isochronous buffer must be a multiple of the MaximumBytesPerInterval * 8 / Interval");
+ usbi_err(TRANSFER_CTX(transfer), "length of isoch buffer must be a multiple of the MaximumBytesPerInterval * 8 / Interval");
return LIBUSB_ERROR_INVALID_PARAM;
}
- }
- else {
- // If this is an OUT transfer, we make sure the isochronous packets are contiguous as this isn't supported otherwise.
- BOOL size_should_be_zero = FALSE;
- out_transfer_length = 0;
+ } else {
+ // If this is an OUT transfer, we make sure the isoch packets are contiguous as this isn't supported otherwise.
+ bool size_should_be_zero = false;
+
for (idx = 0; idx < transfer->num_iso_packets; ++idx) {
if ((size_should_be_zero && transfer->iso_packet_desc[idx].length != 0) ||
(transfer->iso_packet_desc[idx].length != pipe_info_ex.MaximumBytesPerInterval && idx + 1 < transfer->num_iso_packets && transfer->iso_packet_desc[idx + 1].length > 0)) {
- usbi_dbg("Isochronous packets for OUT transfer with Microsoft WinUSB must be contiguous in memory.");
+ usbi_err(TRANSFER_CTX(transfer), "isoch packets for OUT transfer with WinUSB must be contiguous in memory");
return LIBUSB_ERROR_INVALID_PARAM;
}
@@ -2760,20 +2938,20 @@ static int winusbx_submit_iso_transfer(int sub_api, struct usbi_transfer *itrans
if (WinUSBX[sub_api].UnregisterIsochBuffer(transfer_priv->isoch_buffer_handle)) {
transfer_priv->isoch_buffer_handle = NULL;
} else {
- usbi_dbg("Couldn't unregister the Microsoft WinUSB isochronous buffer: %s", windows_error_str(0));
+ usbi_err(TRANSFER_CTX(transfer), "failed to unregister WinUSB isoch buffer: %s", windows_error_str(0));
return LIBUSB_ERROR_OTHER;
}
}
- // Register the isochronous buffer to the operating system.
+ // Register the isoch buffer to the operating system.
ret = WinUSBX[sub_api].RegisterIsochBuffer(winusb_handle, transfer->endpoint, transfer->buffer, transfer->length, &buffer_handle);
if (!ret) {
- usbi_dbg("Microsoft WinUSB refused to allocate an isochronous buffer.");
+ usbi_err(TRANSFER_CTX(transfer), "failed to register WinUSB isoch buffer: %s", windows_error_str(0));
return LIBUSB_ERROR_NO_MEM;
}
// Important note: the WinUSB_Read/WriteIsochPipeAsap API requires a ContinueStream parameter that tells whether the isochronous
- // stream must be continued or if the WinUSB driver can schedule the transfer at its conveniance. Profiling subsequent transfers
+ // stream must be continued or if the WinUSB driver can schedule the transfer at its convenience. Profiling subsequent transfers
// with ContinueStream = FALSE showed that 5 frames, i.e. about 5 milliseconds, were left empty between each transfer. This
// is critical as this greatly diminish the achievable isochronous bandwidth. We solved the problem using the following strategy:
// - Transfers are first scheduled with ContinueStream = TRUE and with winusbx_iso_transfer_continue_stream_callback as user callback.
@@ -2785,36 +2963,22 @@ static int winusbx_submit_iso_transfer(int sub_api, struct usbi_transfer *itrans
}
// Initiate the transfers.
- if (IS_XFERIN(transfer)) {
+ if (IS_XFERIN(transfer))
ret = WinUSBX[sub_api].ReadIsochPipeAsap(buffer_handle, 0, transfer->length, !transfer_priv->iso_break_stream, transfer->num_iso_packets, (PUSBD_ISO_PACKET_DESCRIPTOR)transfer->iso_packet_desc, overlapped);
- }
- else {
+ else
ret = WinUSBX[sub_api].WriteIsochPipeAsap(buffer_handle, 0, out_transfer_length, !transfer_priv->iso_break_stream, overlapped);
+
+ if (!ret && GetLastError() != ERROR_IO_PENDING) {
+ usbi_err(TRANSFER_CTX(transfer), "ReadIsochPipeAsap/WriteIsochPipeAsap failed: %s", windows_error_str(0));
+ if (!WinUSBX[sub_api].UnregisterIsochBuffer(buffer_handle))
+ usbi_warn(TRANSFER_CTX(transfer), "failed to unregister WinUSB isoch buffer: %s", windows_error_str(0));
+ return LIBUSB_ERROR_IO;
}
// Restore the ContinueStream parameter to TRUE.
transfer_priv->iso_break_stream = FALSE;
- if (!ret) {
- if (GetLastError() == ERROR_IO_PENDING) {
- transfer_priv->isoch_buffer_handle = buffer_handle;
- } else {
- usbi_err(ctx, "ReadIsochPipeAsap/WriteIsochPipeAsap failed: %s", windows_error_str(0));
- if (WinUSBX[sub_api].UnregisterIsochBuffer(buffer_handle)) {
- transfer_priv->isoch_buffer_handle = NULL;
- return LIBUSB_ERROR_IO;
- } else {
- usbi_dbg("Couldn't unregister the Microsoft WinUSB isochronous buffer: %s", windows_error_str(0));
- return LIBUSB_ERROR_OTHER;
- }
- }
- } else {
- windows_force_sync_completion(overlapped, (ULONG)transfer->length);
- if (!WinUSBX[sub_api].UnregisterIsochBuffer(buffer_handle)) {
- usbi_dbg("Couldn't unregister the Microsoft WinUSB isochronous buffer: %s", windows_error_str(0));
- return LIBUSB_ERROR_OTHER;
- }
- }
+ transfer_priv->isoch_buffer_handle = buffer_handle;
transfer_priv->interface_number = (uint8_t)current_interface;
@@ -2828,27 +2992,27 @@ static int winusbx_submit_iso_transfer(int sub_api, struct usbi_transfer *itrans
static int winusbx_submit_bulk_transfer(int sub_api, struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct libusb_context *ctx = DEVICE_CTX(transfer->dev_handle->dev);
- struct winusb_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer);
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(transfer->dev_handle);
- struct winusb_device_priv *priv = _device_priv(transfer->dev_handle->dev);
+ struct winusb_transfer_priv *transfer_priv = get_winusb_transfer_priv(itransfer);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(transfer->dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(transfer->dev_handle->dev);
HANDLE winusb_handle;
OVERLAPPED *overlapped;
- bool ret;
+ BOOL ret;
int current_interface;
CHECK_WINUSBX_AVAILABLE(sub_api);
current_interface = interface_by_endpoint(priv, handle_priv, transfer->endpoint);
if (current_interface < 0) {
- usbi_err(ctx, "unable to match endpoint to an open interface - cancelling transfer");
+ usbi_err(TRANSFER_CTX(transfer), "unable to match endpoint to an open interface - cancelling transfer");
return LIBUSB_ERROR_NOT_FOUND;
}
usbi_dbg("matched endpoint %02X with interface %d", transfer->endpoint, current_interface);
- transfer_priv->handle = winusb_handle = handle_priv->interface_handle[current_interface].api_handle;
- overlapped = transfer_priv->pollable_fd.overlapped;
+ winusb_handle = handle_priv->interface_handle[current_interface].api_handle;
+ set_transfer_priv_handle(itransfer, handle_priv->interface_handle[current_interface].dev_handle);
+ overlapped = get_transfer_priv_overlapped(itransfer);
if (IS_XFERIN(transfer)) {
usbi_dbg("reading %d bytes", transfer->length);
@@ -2858,13 +3022,9 @@ static int winusbx_submit_bulk_transfer(int sub_api, struct usbi_transfer *itran
ret = WinUSBX[sub_api].WritePipe(winusb_handle, transfer->endpoint, transfer->buffer, transfer->length, NULL, overlapped);
}
- if (!ret) {
- if (GetLastError() != ERROR_IO_PENDING) {
- usbi_err(ctx, "ReadPipe/WritePipe failed: %s", windows_error_str(0));
- return LIBUSB_ERROR_IO;
- }
- } else {
- windows_force_sync_completion(overlapped, (ULONG)transfer->length);
+ if (!ret && GetLastError() != ERROR_IO_PENDING) {
+ usbi_err(TRANSFER_CTX(transfer), "ReadPipe/WritePipe failed: %s", windows_error_str(0));
+ return LIBUSB_ERROR_IO;
}
transfer_priv->interface_number = (uint8_t)current_interface;
@@ -2874,9 +3034,8 @@ static int winusbx_submit_bulk_transfer(int sub_api, struct usbi_transfer *itran
static int winusbx_clear_halt(int sub_api, struct libusb_device_handle *dev_handle, unsigned char endpoint)
{
- struct libusb_context *ctx = DEVICE_CTX(dev_handle->dev);
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(dev_handle);
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
HANDLE winusb_handle;
int current_interface;
@@ -2884,7 +3043,7 @@ static int winusbx_clear_halt(int sub_api, struct libusb_device_handle *dev_hand
current_interface = interface_by_endpoint(priv, handle_priv, endpoint);
if (current_interface < 0) {
- usbi_err(ctx, "unable to match endpoint to an open interface - cannot clear");
+ usbi_err(HANDLE_CTX(dev_handle), "unable to match endpoint to an open interface - cannot clear");
return LIBUSB_ERROR_NOT_FOUND;
}
@@ -2892,60 +3051,29 @@ static int winusbx_clear_halt(int sub_api, struct libusb_device_handle *dev_hand
winusb_handle = handle_priv->interface_handle[current_interface].api_handle;
if (!WinUSBX[sub_api].ResetPipe(winusb_handle, endpoint)) {
- usbi_err(ctx, "ResetPipe failed: %s", windows_error_str(0));
+ usbi_err(HANDLE_CTX(dev_handle), "ResetPipe failed: %s", windows_error_str(0));
return LIBUSB_ERROR_NO_DEVICE;
}
return LIBUSB_SUCCESS;
}
-/*
- * from http://www.winvistatips.com/winusb-bugchecks-t335323.html (confirmed
- * through testing as well):
- * "You can not call WinUsb_AbortPipe on control pipe. You can possibly cancel
- * the control transfer using CancelIo"
- */
-static int winusbx_abort_control(int sub_api, struct usbi_transfer *itransfer)
-{
- // Cancelling of the I/O is done in the parent
- return LIBUSB_SUCCESS;
-}
-
-static int winusbx_abort_transfers(int sub_api, struct usbi_transfer *itransfer)
+static int winusbx_cancel_transfer(int sub_api, struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct libusb_context *ctx = DEVICE_CTX(transfer->dev_handle->dev);
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(transfer->dev_handle);
- struct winusb_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer);
- struct winusb_device_priv *priv = _device_priv(transfer->dev_handle->dev);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(transfer->dev_handle);
+ struct winusb_transfer_priv *transfer_priv = get_winusb_transfer_priv(itransfer);
+ struct winusb_device_priv *priv = usbi_get_device_priv(transfer->dev_handle->dev);
+ int current_interface = transfer_priv->interface_number;
HANDLE handle;
- int current_interface;
CHECK_WINUSBX_AVAILABLE(sub_api);
- current_interface = transfer_priv->interface_number;
- if ((current_interface < 0) || (current_interface >= USB_MAXINTERFACES)) {
- usbi_err(ctx, "program assertion failed: invalid interface_number");
- return LIBUSB_ERROR_NOT_FOUND;
- }
usbi_dbg("will use interface %d", current_interface);
- if (WinUSBX[sub_api].CancelIoEx_supported) {
- // Try to use CancelIoEx if available to cancel just a single transfer
- handle = handle_priv->interface_handle[current_interface].dev_handle;
- if (pCancelIoEx(handle, transfer_priv->pollable_fd.overlapped))
- return LIBUSB_SUCCESS;
- else if (GetLastError() == ERROR_NOT_FOUND)
- return LIBUSB_ERROR_NOT_FOUND;
-
- // Not every driver implements the necessary functionality for CancelIoEx
- usbi_warn(ctx, "CancelIoEx not supported for sub API %s", winusbx_driver_names[sub_api]);
- WinUSBX[sub_api].CancelIoEx_supported = false;
- }
-
handle = handle_priv->interface_handle[current_interface].api_handle;
if (!WinUSBX[sub_api].AbortPipe(handle, transfer->endpoint)) {
- usbi_err(ctx, "AbortPipe failed: %s", windows_error_str(0));
+ usbi_err(TRANSFER_CTX(transfer), "AbortPipe failed: %s", windows_error_str(0));
return LIBUSB_ERROR_NO_DEVICE;
}
@@ -2963,9 +3091,8 @@ static int winusbx_abort_transfers(int sub_api, struct usbi_transfer *itransfer)
// TODO: (post hotplug): see if we can force eject the device and redetect it (reuse hotplug?)
static int winusbx_reset_device(int sub_api, struct libusb_device_handle *dev_handle)
{
- struct libusb_context *ctx = DEVICE_CTX(dev_handle->dev);
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(dev_handle);
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
HANDLE winusb_handle;
int i, j;
@@ -2978,24 +3105,24 @@ static int winusbx_reset_device(int sub_api, struct libusb_device_handle *dev_ha
for (j = 0; j < priv->usb_interface[i].nb_endpoints; j++) {
usbi_dbg("resetting ep %02X", priv->usb_interface[i].endpoint[j]);
if (!WinUSBX[sub_api].AbortPipe(winusb_handle, priv->usb_interface[i].endpoint[j]))
- usbi_err(ctx, "AbortPipe (pipe address %02X) failed: %s",
+ usbi_err(HANDLE_CTX(dev_handle), "AbortPipe (pipe address %02X) failed: %s",
priv->usb_interface[i].endpoint[j], windows_error_str(0));
// FlushPipe seems to fail on OUT pipes
if (IS_EPIN(priv->usb_interface[i].endpoint[j])
&& (!WinUSBX[sub_api].FlushPipe(winusb_handle, priv->usb_interface[i].endpoint[j])))
- usbi_err(ctx, "FlushPipe (pipe address %02X) failed: %s",
+ usbi_err(HANDLE_CTX(dev_handle), "FlushPipe (pipe address %02X) failed: %s",
priv->usb_interface[i].endpoint[j], windows_error_str(0));
if (!WinUSBX[sub_api].ResetPipe(winusb_handle, priv->usb_interface[i].endpoint[j]))
- usbi_err(ctx, "ResetPipe (pipe address %02X) failed: %s",
+ usbi_err(HANDLE_CTX(dev_handle), "ResetPipe (pipe address %02X) failed: %s",
priv->usb_interface[i].endpoint[j], windows_error_str(0));
}
}
}
// libusbK & libusb0 have the ability to issue an actual device reset
- if (WinUSBX[sub_api].ResetDevice != NULL) {
+ if ((sub_api != SUB_API_WINUSB) && (WinUSBX[sub_api].ResetDevice != NULL)) {
winusb_handle = handle_priv->interface_handle[0].api_handle;
if (HANDLE_VALID(winusb_handle))
WinUSBX[sub_api].ResetDevice(winusb_handle);
@@ -3004,21 +3131,17 @@ static int winusbx_reset_device(int sub_api, struct libusb_device_handle *dev_ha
return LIBUSB_SUCCESS;
}
-static int winusbx_copy_transfer_data(int sub_api, struct usbi_transfer *itransfer, uint32_t io_size)
+static enum libusb_transfer_status winusbx_copy_transfer_data(int sub_api, struct usbi_transfer *itransfer, DWORD length)
{
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct winusb_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer);
- struct winusb_device_priv *priv = _device_priv(transfer->dev_handle->dev);
- PKISO_CONTEXT iso_context;
+ struct winusb_transfer_priv *transfer_priv = get_winusb_transfer_priv(itransfer);
int i;
if (transfer->type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS) {
- CHECK_WINUSBX_AVAILABLE(sub_api);
-
// for isochronous, need to copy the individual iso packet actual_lengths and statuses
if ((sub_api == SUB_API_LIBUSBK) || (sub_api == SUB_API_LIBUSB0)) {
// iso only supported on libusbk-based backends for now
- iso_context = transfer_priv->iso_context;
+ PKISO_CONTEXT iso_context = transfer_priv->iso_context;
for (i = 0; i < transfer->num_iso_packets; i++) {
transfer->iso_packet_desc[i].actual_length = iso_context->IsoPackets[i].actual_length;
// TODO translate USDB_STATUS codes http://msdn.microsoft.com/en-us/library/ff539136(VS.85).aspx to libusb_transfer_status
@@ -3029,31 +3152,28 @@ static int winusbx_copy_transfer_data(int sub_api, struct usbi_transfer *itransf
/* Convert isochronous packet descriptor between Windows and libusb representation.
* Both representation are guaranteed to have the same length in bytes.*/
PUSBD_ISO_PACKET_DESCRIPTOR usbd_iso_packet_desc = (PUSBD_ISO_PACKET_DESCRIPTOR)transfer->iso_packet_desc;
- for (i = 0; i < transfer->num_iso_packets; ++i)
- {
- int length = (i < transfer->num_iso_packets - 1) ? (usbd_iso_packet_desc[i + 1].Offset - usbd_iso_packet_desc[i].Offset) : usbd_iso_packet_desc[i].Length;
- int actual_length = usbd_iso_packet_desc[i].Length;
+ for (i = 0; i < transfer->num_iso_packets; i++) {
+ unsigned int packet_length = (i < transfer->num_iso_packets - 1) ? (usbd_iso_packet_desc[i + 1].Offset - usbd_iso_packet_desc[i].Offset) : usbd_iso_packet_desc[i].Length;
+ unsigned int actual_length = usbd_iso_packet_desc[i].Length;
USBD_STATUS status = usbd_iso_packet_desc[i].Status;
- transfer->iso_packet_desc[i].length = length;
+ transfer->iso_packet_desc[i].length = packet_length;
transfer->iso_packet_desc[i].actual_length = actual_length;
transfer->iso_packet_desc[i].status = usbd_status_to_libusb_transfer_status(status);
}
- }
- else {
- for (i = 0; i < transfer->num_iso_packets; ++i)
- {
+ } else {
+ for (i = 0; i < transfer->num_iso_packets; i++) {
transfer->iso_packet_desc[i].status = LIBUSB_TRANSFER_COMPLETED;
}
}
} else {
// This should only occur if backend is not set correctly or other backend isoc is partially implemented
PRINT_UNSUPPORTED_API(copy_transfer_data);
- return LIBUSB_ERROR_NOT_SUPPORTED;
+ return LIBUSB_TRANSFER_ERROR;
}
}
- itransfer->transferred += io_size;
+ itransfer->transferred += (int)length;
return LIBUSB_TRANSFER_COMPLETED;
}
@@ -3075,7 +3195,7 @@ static int _hid_wcslen(WCHAR *str)
return i;
}
-static int _hid_get_device_descriptor(struct hid_device_priv *dev, void *data, size_t *size)
+static int _hid_get_device_descriptor(struct hid_device_priv *hid_priv, void *data, size_t *size)
{
struct libusb_device_descriptor d;
@@ -3086,12 +3206,12 @@ static int _hid_get_device_descriptor(struct hid_device_priv *dev, void *data, s
d.bDeviceSubClass = 0;
d.bDeviceProtocol = 0;
d.bMaxPacketSize0 = 64; /* fix this! */
- d.idVendor = (uint16_t)dev->vid;
- d.idProduct = (uint16_t)dev->pid;
+ d.idVendor = (uint16_t)hid_priv->vid;
+ d.idProduct = (uint16_t)hid_priv->pid;
d.bcdDevice = 0x0100;
- d.iManufacturer = dev->string_index[0];
- d.iProduct = dev->string_index[1];
- d.iSerialNumber = dev->string_index[2];
+ d.iManufacturer = hid_priv->string_index[0];
+ d.iProduct = hid_priv->string_index[1];
+ d.iSerialNumber = hid_priv->string_index[2];
d.bNumConfigurations = 1;
if (*size > LIBUSB_DT_DEVICE_SIZE)
@@ -3101,7 +3221,7 @@ static int _hid_get_device_descriptor(struct hid_device_priv *dev, void *data, s
return LIBUSB_COMPLETED;
}
-static int _hid_get_config_descriptor(struct hid_device_priv *dev, void *data, size_t *size)
+static int _hid_get_config_descriptor(struct hid_device_priv *hid_priv, void *data, size_t *size)
{
char num_endpoints = 0;
size_t config_total_len = 0;
@@ -3112,9 +3232,9 @@ static int _hid_get_config_descriptor(struct hid_device_priv *dev, void *data, s
struct libusb_endpoint_descriptor *ed;
size_t tmp_size;
- if (dev->input_report_size)
+ if (hid_priv->input_report_size)
num_endpoints++;
- if (dev->output_report_size)
+ if (hid_priv->output_report_size)
num_endpoints++;
config_total_len = LIBUSB_DT_CONFIG_SIZE + LIBUSB_DT_INTERFACE_SIZE
@@ -3148,24 +3268,24 @@ static int _hid_get_config_descriptor(struct hid_device_priv *dev, void *data, s
id->iInterface = 0;
tmp_size = LIBUSB_DT_HID_SIZE;
- _hid_get_hid_descriptor(dev, hd, &tmp_size);
+ _hid_get_hid_descriptor(hid_priv, hd, &tmp_size);
- if (dev->input_report_size) {
+ if (hid_priv->input_report_size) {
ed->bLength = LIBUSB_DT_ENDPOINT_SIZE;
ed->bDescriptorType = LIBUSB_DT_ENDPOINT;
ed->bEndpointAddress = HID_IN_EP;
ed->bmAttributes = 3;
- ed->wMaxPacketSize = dev->input_report_size - 1;
+ ed->wMaxPacketSize = hid_priv->input_report_size - 1;
ed->bInterval = 10;
ed = (struct libusb_endpoint_descriptor *)((char *)ed + LIBUSB_DT_ENDPOINT_SIZE);
}
- if (dev->output_report_size) {
+ if (hid_priv->output_report_size) {
ed->bLength = LIBUSB_DT_ENDPOINT_SIZE;
ed->bDescriptorType = LIBUSB_DT_ENDPOINT;
ed->bEndpointAddress = HID_OUT_EP;
ed->bmAttributes = 3;
- ed->wMaxPacketSize = dev->output_report_size - 1;
+ ed->wMaxPacketSize = hid_priv->output_report_size - 1;
ed->bInterval = 10;
}
@@ -3176,7 +3296,7 @@ static int _hid_get_config_descriptor(struct hid_device_priv *dev, void *data, s
return LIBUSB_COMPLETED;
}
-static int _hid_get_string_descriptor(struct hid_device_priv *dev, int _index,
+static int _hid_get_string_descriptor(struct hid_device_priv *hid_priv, int _index,
void *data, size_t *size, HANDLE hid_handle)
{
void *tmp = NULL;
@@ -3187,17 +3307,14 @@ static int _hid_get_string_descriptor(struct hid_device_priv *dev, int _index,
/* language ID, EN-US */
char string_langid[] = {0x09, 0x04};
- if ((*size < 2) || (*size > 255))
- return LIBUSB_ERROR_OVERFLOW;
-
if (_index == 0) {
tmp = string_langid;
tmp_size = sizeof(string_langid) + 2;
} else {
for (i = 0; i < 3; i++) {
- if (_index == (dev->string_index[i])) {
- tmp = dev->string[i];
- tmp_size = (_hid_wcslen(dev->string[i]) + 1) * sizeof(WCHAR);
+ if (_index == (hid_priv->string_index[i])) {
+ tmp = hid_priv->string[i];
+ tmp_size = (_hid_wcslen(hid_priv->string[i]) + 1) * sizeof(WCHAR);
break;
}
}
@@ -3224,13 +3341,13 @@ static int _hid_get_string_descriptor(struct hid_device_priv *dev, int _index,
return LIBUSB_COMPLETED;
}
-static int _hid_get_hid_descriptor(struct hid_device_priv *dev, void *data, size_t *size)
+static int _hid_get_hid_descriptor(struct hid_device_priv *hid_priv, void *data, size_t *size)
{
struct libusb_hid_descriptor d;
uint8_t tmp[MAX_HID_DESCRIPTOR_SIZE];
size_t report_len = MAX_HID_DESCRIPTOR_SIZE;
- _hid_get_report_descriptor(dev, tmp, &report_len);
+ _hid_get_report_descriptor(hid_priv, tmp, &report_len);
d.bLength = LIBUSB_DT_HID_SIZE;
d.bDescriptorType = LIBUSB_DT_HID;
@@ -3247,19 +3364,19 @@ static int _hid_get_hid_descriptor(struct hid_device_priv *dev, void *data, size
return LIBUSB_COMPLETED;
}
-static int _hid_get_report_descriptor(struct hid_device_priv *dev, void *data, size_t *size)
+static int _hid_get_report_descriptor(struct hid_device_priv *hid_priv, void *data, size_t *size)
{
uint8_t d[MAX_HID_DESCRIPTOR_SIZE];
size_t i = 0;
/* usage page */
- d[i++] = 0x06; d[i++] = dev->usagePage & 0xFF; d[i++] = dev->usagePage >> 8;
+ d[i++] = 0x06; d[i++] = hid_priv->usagePage & 0xFF; d[i++] = hid_priv->usagePage >> 8;
/* usage */
- d[i++] = 0x09; d[i++] = (uint8_t)dev->usage;
+ d[i++] = 0x09; d[i++] = (uint8_t)hid_priv->usage;
/* start collection (application) */
d[i++] = 0xA1; d[i++] = 0x01;
/* input report */
- if (dev->input_report_size) {
+ if (hid_priv->input_report_size) {
/* usage (vendor defined) */
d[i++] = 0x09; d[i++] = 0x01;
/* logical minimum (0) */
@@ -3269,12 +3386,12 @@ static int _hid_get_report_descriptor(struct hid_device_priv *dev, void *data, s
/* report size (8 bits) */
d[i++] = 0x75; d[i++] = 0x08;
/* report count */
- d[i++] = 0x95; d[i++] = (uint8_t)dev->input_report_size - 1;
+ d[i++] = 0x95; d[i++] = (uint8_t)hid_priv->input_report_size - 1;
/* input (data, variable, absolute) */
d[i++] = 0x81; d[i++] = 0x00;
}
/* output report */
- if (dev->output_report_size) {
+ if (hid_priv->output_report_size) {
/* usage (vendor defined) */
d[i++] = 0x09; d[i++] = 0x02;
/* logical minimum (0) */
@@ -3284,12 +3401,12 @@ static int _hid_get_report_descriptor(struct hid_device_priv *dev, void *data, s
/* report size (8 bits) */
d[i++] = 0x75; d[i++] = 0x08;
/* report count */
- d[i++] = 0x95; d[i++] = (uint8_t)dev->output_report_size - 1;
+ d[i++] = 0x95; d[i++] = (uint8_t)hid_priv->output_report_size - 1;
/* output (data, variable, absolute) */
d[i++] = 0x91; d[i++] = 0x00;
}
/* feature report */
- if (dev->feature_report_size) {
+ if (hid_priv->feature_report_size) {
/* usage (vendor defined) */
d[i++] = 0x09; d[i++] = 0x03;
/* logical minimum (0) */
@@ -3299,7 +3416,7 @@ static int _hid_get_report_descriptor(struct hid_device_priv *dev, void *data, s
/* report size (8 bits) */
d[i++] = 0x75; d[i++] = 0x08;
/* report count */
- d[i++] = 0x95; d[i++] = (uint8_t)dev->feature_report_size - 1;
+ d[i++] = 0x95; d[i++] = (uint8_t)hid_priv->feature_report_size - 1;
/* feature (data, variable, absolute) */
d[i++] = 0xb2; d[i++] = 0x02; d[i++] = 0x01;
}
@@ -3314,30 +3431,33 @@ static int _hid_get_report_descriptor(struct hid_device_priv *dev, void *data, s
return LIBUSB_COMPLETED;
}
-static int _hid_get_descriptor(struct hid_device_priv *dev, HANDLE hid_handle, int recipient,
+static int _hid_get_descriptor(struct libusb_device *dev, HANDLE hid_handle, int recipient,
int type, int _index, void *data, size_t *size)
{
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev);
+ UNUSED(recipient);
+
switch (type) {
case LIBUSB_DT_DEVICE:
usbi_dbg("LIBUSB_DT_DEVICE");
- return _hid_get_device_descriptor(dev, data, size);
+ return _hid_get_device_descriptor(priv->hid, data, size);
case LIBUSB_DT_CONFIG:
usbi_dbg("LIBUSB_DT_CONFIG");
if (!_index)
- return _hid_get_config_descriptor(dev, data, size);
+ return _hid_get_config_descriptor(priv->hid, data, size);
return LIBUSB_ERROR_INVALID_PARAM;
case LIBUSB_DT_STRING:
usbi_dbg("LIBUSB_DT_STRING");
- return _hid_get_string_descriptor(dev, _index, data, size, hid_handle);
+ return _hid_get_string_descriptor(priv->hid, _index, data, size, hid_handle);
case LIBUSB_DT_HID:
usbi_dbg("LIBUSB_DT_HID");
if (!_index)
- return _hid_get_hid_descriptor(dev, data, size);
+ return _hid_get_hid_descriptor(priv->hid, data, size);
return LIBUSB_ERROR_INVALID_PARAM;
case LIBUSB_DT_REPORT:
usbi_dbg("LIBUSB_DT_REPORT");
if (!_index)
- return _hid_get_report_descriptor(dev, data, size);
+ return _hid_get_report_descriptor(priv->hid, data, size);
return LIBUSB_ERROR_INVALID_PARAM;
case LIBUSB_DT_PHYSICAL:
usbi_dbg("LIBUSB_DT_PHYSICAL");
@@ -3346,22 +3466,21 @@ static int _hid_get_descriptor(struct hid_device_priv *dev, HANDLE hid_handle, i
return LIBUSB_ERROR_OTHER;
}
- usbi_dbg("unsupported");
+ usbi_warn(DEVICE_CTX(dev), "unsupported");
return LIBUSB_ERROR_NOT_SUPPORTED;
}
-static int _hid_get_report(struct hid_device_priv *dev, HANDLE hid_handle, int id, void *data,
- struct winusb_transfer_priv *tp, size_t *size, OVERLAPPED *overlapped, int report_type)
+static int _hid_get_report(struct libusb_device *dev, HANDLE hid_handle, int id, void *data,
+ struct winusb_transfer_priv *tp, size_t size, OVERLAPPED *overlapped, int report_type)
{
+ DWORD ioctl_code, expected_size = (DWORD)size;
uint8_t *buf;
- DWORD ioctl_code, read_size, expected_size = (DWORD)*size;
- int r = LIBUSB_SUCCESS;
if (tp->hid_buffer != NULL)
- usbi_dbg("program assertion failed: hid_buffer is not NULL");
+ usbi_err(DEVICE_CTX(dev), "program assertion failed - hid_buffer is not NULL");
- if ((*size == 0) || (*size > MAX_HID_REPORT_SIZE)) {
- usbi_dbg("invalid size (%zu)", *size);
+ if ((size == 0) || (size > MAX_HID_REPORT_SIZE)) {
+ usbi_warn(DEVICE_CTX(dev), "invalid size (%"PRIuPTR")", (uintptr_t)size);
return LIBUSB_ERROR_INVALID_PARAM;
}
@@ -3373,7 +3492,7 @@ static int _hid_get_report(struct hid_device_priv *dev, HANDLE hid_handle, int i
ioctl_code = IOCTL_HID_GET_FEATURE;
break;
default:
- usbi_dbg("unknown HID report type %d", report_type);
+ usbi_warn(DEVICE_CTX(dev), "unknown HID report type %d", report_type);
return LIBUSB_ERROR_INVALID_PARAM;
}
@@ -3385,62 +3504,37 @@ static int _hid_get_report(struct hid_device_priv *dev, HANDLE hid_handle, int i
buf[0] = (uint8_t)id; // Must be set always
usbi_dbg("report ID: 0x%02X", buf[0]);
- tp->hid_expected_size = expected_size;
- read_size = expected_size;
-
// NB: The size returned by DeviceIoControl doesn't include report IDs when not in use (0)
if (!DeviceIoControl(hid_handle, ioctl_code, buf, expected_size + 1,
- buf, expected_size + 1, &read_size, overlapped)) {
+ buf, expected_size + 1, NULL, overlapped)) {
if (GetLastError() != ERROR_IO_PENDING) {
- usbi_dbg("Failed to Read HID Report: %s", windows_error_str(0));
+ usbi_err(DEVICE_CTX(dev), "failed to read HID Report: %s", windows_error_str(0));
free(buf);
return LIBUSB_ERROR_IO;
}
- // Asynchronous wait
- tp->hid_buffer = buf;
- tp->hid_dest = data; // copy dest, as not necessarily the start of the transfer buffer
- return LIBUSB_SUCCESS;
}
- // Transfer completed synchronously => copy and discard extra buffer
- if (read_size == 0) {
- usbi_warn(NULL, "program assertion failed - read completed synchronously, but no data was read");
- *size = 0;
- } else {
- if (buf[0] != id)
- usbi_warn(NULL, "mismatched report ID (data is %02X, parameter is %02X)", buf[0], id);
-
- if ((size_t)read_size > expected_size) {
- r = LIBUSB_ERROR_OVERFLOW;
- usbi_dbg("OVERFLOW!");
- } else {
- r = LIBUSB_COMPLETED;
- }
-
- *size = MIN((size_t)read_size, *size);
- if (id == 0)
- memcpy(data, buf + 1, *size); // Discard report ID
- else
- memcpy(data, buf, *size);
- }
+ // Asynchronous wait
+ tp->hid_buffer = buf;
+ tp->hid_dest = data; // copy dest, as not necessarily the start of the transfer buffer
+ tp->hid_expected_size = expected_size;
- free(buf);
- return r;
+ return LIBUSB_SUCCESS;
}
-static int _hid_set_report(struct hid_device_priv *dev, HANDLE hid_handle, int id, void *data,
- struct winusb_transfer_priv *tp, size_t *size, OVERLAPPED *overlapped, int report_type)
+static int _hid_set_report(struct libusb_device *dev, HANDLE hid_handle, int id, void *data,
+ struct winusb_transfer_priv *tp, size_t size, OVERLAPPED *overlapped, int report_type)
{
- uint8_t *buf = NULL;
- DWORD ioctl_code, write_size = (DWORD)*size;
+ DWORD ioctl_code, write_size = (DWORD)size;
// If an id is reported, we must allow MAX_HID_REPORT_SIZE + 1
size_t max_report_size = MAX_HID_REPORT_SIZE + (id ? 1 : 0);
+ uint8_t *buf;
if (tp->hid_buffer != NULL)
- usbi_dbg("program assertion failed: hid_buffer is not NULL");
+ usbi_err(DEVICE_CTX(dev), "program assertion failed - hid_buffer is not NULL");
- if ((*size == 0) || (*size > max_report_size)) {
- usbi_dbg("invalid size (%zu)", *size);
+ if ((size == 0) || (size > max_report_size)) {
+ usbi_warn(DEVICE_CTX(dev), "invalid size (%"PRIuPTR")", (uintptr_t)size);
return LIBUSB_ERROR_INVALID_PARAM;
}
@@ -3452,7 +3546,7 @@ static int _hid_set_report(struct hid_device_priv *dev, HANDLE hid_handle, int i
ioctl_code = IOCTL_HID_SET_FEATURE;
break;
default:
- usbi_dbg("unknown HID report type %d", report_type);
+ usbi_warn(DEVICE_CTX(dev), "unknown HID report type %d", report_type);
return LIBUSB_ERROR_INVALID_PARAM;
}
@@ -3468,44 +3562,39 @@ static int _hid_set_report(struct hid_device_priv *dev, HANDLE hid_handle, int i
if (id == 0) {
buf[0] = 0;
- memcpy(buf + 1, data, *size);
+ memcpy(buf + 1, data, size);
} else {
// This seems like a waste, but if we don't duplicate the
// data, we'll get issues when freeing hid_buffer
- memcpy(buf, data, *size);
+ memcpy(buf, data, size);
if (buf[0] != id)
- usbi_warn(NULL, "mismatched report ID (data is %02X, parameter is %02X)", buf[0], id);
+ usbi_warn(DEVICE_CTX(dev), "mismatched report ID (data is %02X, parameter is %02X)", buf[0], id);
}
// NB: The size returned by DeviceIoControl doesn't include report IDs when not in use (0)
if (!DeviceIoControl(hid_handle, ioctl_code, buf, write_size,
- buf, write_size, &write_size, overlapped)) {
+ buf, write_size, NULL, overlapped)) {
if (GetLastError() != ERROR_IO_PENDING) {
- usbi_dbg("Failed to Write HID Output Report: %s", windows_error_str(0));
+ usbi_err(DEVICE_CTX(dev), "failed to write HID Output Report: %s", windows_error_str(0));
free(buf);
return LIBUSB_ERROR_IO;
}
- tp->hid_buffer = buf;
- tp->hid_dest = NULL;
- return LIBUSB_SUCCESS;
}
- // Transfer completed synchronously
- *size = write_size;
- if (write_size == 0)
- usbi_dbg("program assertion failed - write completed synchronously, but no data was written");
-
- free(buf);
- return LIBUSB_COMPLETED;
+ tp->hid_buffer = buf;
+ tp->hid_dest = NULL;
+ return LIBUSB_SUCCESS;
}
-static int _hid_class_request(struct hid_device_priv *dev, HANDLE hid_handle, int request_type,
+static int _hid_class_request(struct libusb_device *dev, HANDLE hid_handle, int request_type,
int request, int value, int _index, void *data, struct winusb_transfer_priv *tp,
- size_t *size, OVERLAPPED *overlapped)
+ size_t size, OVERLAPPED *overlapped)
{
int report_type = (value >> 8) & 0xFF;
int report_id = value & 0xFF;
+ UNUSED(_index);
+
if ((LIBUSB_REQ_RECIPIENT(request_type) != LIBUSB_RECIPIENT_INTERFACE)
&& (LIBUSB_REQ_RECIPIENT(request_type) != LIBUSB_RECIPIENT_DEVICE))
return LIBUSB_ERROR_INVALID_PARAM;
@@ -3519,30 +3608,28 @@ static int _hid_class_request(struct hid_device_priv *dev, HANDLE hid_handle, in
return LIBUSB_ERROR_INVALID_PARAM;
}
-
/*
* HID API functions
*/
-static int hid_init(struct libusb_context *ctx)
+static bool hid_init(struct libusb_context *ctx)
{
- DLL_GET_HANDLE(hid);
-
- DLL_LOAD_FUNC(hid, HidD_GetAttributes, TRUE);
- DLL_LOAD_FUNC(hid, HidD_GetHidGuid, TRUE);
- DLL_LOAD_FUNC(hid, HidD_GetPreparsedData, TRUE);
- DLL_LOAD_FUNC(hid, HidD_FreePreparsedData, TRUE);
- DLL_LOAD_FUNC(hid, HidD_GetManufacturerString, TRUE);
- DLL_LOAD_FUNC(hid, HidD_GetProductString, TRUE);
- DLL_LOAD_FUNC(hid, HidD_GetSerialNumberString, TRUE);
- DLL_LOAD_FUNC(hid, HidD_GetIndexedString, TRUE);
- DLL_LOAD_FUNC(hid, HidP_GetCaps, TRUE);
- DLL_LOAD_FUNC(hid, HidD_SetNumInputBuffers, TRUE);
- DLL_LOAD_FUNC(hid, HidD_GetPhysicalDescriptor, TRUE);
- DLL_LOAD_FUNC(hid, HidD_FlushQueue, TRUE);
- DLL_LOAD_FUNC(hid, HidP_GetValueCaps, TRUE);
-
- api_hid_available = true;
- return LIBUSB_SUCCESS;
+ DLL_GET_HANDLE(ctx, hid);
+
+ DLL_LOAD_FUNC(hid, HidD_GetAttributes, true);
+ DLL_LOAD_FUNC(hid, HidD_GetHidGuid, true);
+ DLL_LOAD_FUNC(hid, HidD_GetPreparsedData, true);
+ DLL_LOAD_FUNC(hid, HidD_FreePreparsedData, true);
+ DLL_LOAD_FUNC(hid, HidD_GetManufacturerString, true);
+ DLL_LOAD_FUNC(hid, HidD_GetProductString, true);
+ DLL_LOAD_FUNC(hid, HidD_GetSerialNumberString, true);
+ DLL_LOAD_FUNC(hid, HidD_GetIndexedString, true);
+ DLL_LOAD_FUNC(hid, HidP_GetCaps, true);
+ DLL_LOAD_FUNC(hid, HidD_SetNumInputBuffers, true);
+ DLL_LOAD_FUNC(hid, HidD_GetPhysicalDescriptor, true);
+ DLL_LOAD_FUNC(hid, HidD_FlushQueue, true);
+ DLL_LOAD_FUNC(hid, HidP_GetValueCaps, true);
+
+ return true;
}
static void hid_exit(void)
@@ -3555,9 +3642,9 @@ static void hid_exit(void)
// composite_open(), with interfaces belonging to different APIs
static int hid_open(int sub_api, struct libusb_device_handle *dev_handle)
{
- struct libusb_context *ctx = DEVICE_CTX(dev_handle->dev);
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(dev_handle);
+ struct libusb_device *dev = dev_handle->dev;
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
HIDD_ATTRIBUTES hid_attributes;
PHIDP_PREPARSED_DATA preparsed_data = NULL;
HIDP_CAPS capabilities;
@@ -3571,18 +3658,18 @@ static int hid_open(int sub_api, struct libusb_device_handle *dev_handle)
const char * const type[3] = {"input", "output", "feature"};
#endif
+ UNUSED(sub_api);
CHECK_HID_AVAILABLE;
if (priv->hid == NULL) {
- usbi_err(ctx, "program assertion failed - private HID structure is unitialized");
+ usbi_err(HANDLE_CTX(dev_handle), "program assertion failed - private HID structure is uninitialized");
return LIBUSB_ERROR_NOT_FOUND;
}
for (i = 0; i < USB_MAXINTERFACES; i++) {
if ((priv->usb_interface[i].path != NULL)
&& (priv->usb_interface[i].apib->id == USB_API_HID)) {
- hid_handle = CreateFileA(priv->usb_interface[i].path, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ,
- NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL);
+ hid_handle = windows_open(dev, priv->usb_interface[i].path, GENERIC_READ | GENERIC_WRITE);
/*
* http://www.lvr.com/hidfaq.htm: Why do I receive "Access denied" when attempting to access my HID?
* "Windows 2000 and later have exclusive read/write access to HIDs that are configured as a system
@@ -3591,11 +3678,10 @@ static int hid_open(int sub_api, struct libusb_device_handle *dev_handle)
* HidD_GetFeature (if the device supports Feature reports)."
*/
if (hid_handle == INVALID_HANDLE_VALUE) {
- usbi_warn(ctx, "could not open HID device in R/W mode (keyboard or mouse?) - trying without");
- hid_handle = CreateFileA(priv->usb_interface[i].path, 0, FILE_SHARE_WRITE | FILE_SHARE_READ,
- NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL);
+ usbi_warn(HANDLE_CTX(dev_handle), "could not open HID device in R/W mode (keyboard or mouse?) - trying without");
+ hid_handle = windows_open(dev, priv->usb_interface[i].path, 0);
if (hid_handle == INVALID_HANDLE_VALUE) {
- usbi_err(ctx, "could not open device %s (interface %d): %s", priv->path, i, windows_error_str(0));
+ usbi_err(HANDLE_CTX(dev_handle), "could not open device %s (interface %d): %s", priv->path, i, windows_error_str(0));
switch (GetLastError()) {
case ERROR_FILE_NOT_FOUND: // The device was disconnected
return LIBUSB_ERROR_NO_DEVICE;
@@ -3614,7 +3700,7 @@ static int hid_open(int sub_api, struct libusb_device_handle *dev_handle)
hid_attributes.Size = sizeof(hid_attributes);
do {
if (!HidD_GetAttributes(hid_handle, &hid_attributes)) {
- usbi_err(ctx, "could not gain access to HID top collection (HidD_GetAttributes)");
+ usbi_err(HANDLE_CTX(dev_handle), "could not gain access to HID top collection (HidD_GetAttributes)");
break;
}
@@ -3627,11 +3713,11 @@ static int hid_open(int sub_api, struct libusb_device_handle *dev_handle)
// Get the maximum input and output report size
if (!HidD_GetPreparsedData(hid_handle, &preparsed_data) || !preparsed_data) {
- usbi_err(ctx, "could not read HID preparsed data (HidD_GetPreparsedData)");
+ usbi_err(HANDLE_CTX(dev_handle), "could not read HID preparsed data (HidD_GetPreparsedData)");
break;
}
if (HidP_GetCaps(preparsed_data, &capabilities) != HIDP_STATUS_SUCCESS) {
- usbi_err(ctx, "could not parse HID capabilities (HidP_GetCaps)");
+ usbi_err(HANDLE_CTX(dev_handle), "could not parse HID capabilities (HidP_GetCaps)");
break;
}
@@ -3640,7 +3726,7 @@ static int hid_open(int sub_api, struct libusb_device_handle *dev_handle)
size[1] = capabilities.NumberOutputValueCaps;
size[2] = capabilities.NumberFeatureValueCaps;
for (j = HidP_Input; j <= HidP_Feature; j++) {
- usbi_dbg("%u HID %s report value(s) found", (unsigned int)size[j], type[j]);
+ usbi_dbg("%lu HID %s report value(s) found", ULONG_CAST(size[j]), type[j]);
priv->hid->uses_report_ids[j] = false;
if (size[j] > 0) {
value_caps = calloc(size[j], sizeof(HIDP_VALUE_CAPS));
@@ -3658,12 +3744,12 @@ static int hid_open(int sub_api, struct libusb_device_handle *dev_handle)
}
if (nb_ids[1] != 0) {
if (nb_ids[0] != 0)
- usbi_warn(ctx, "program assertion failed: zero and nonzero report IDs used for %s",
+ usbi_warn(HANDLE_CTX(dev_handle), "program assertion failed - zero and nonzero report IDs used for %s",
type[j]);
priv->hid->uses_report_ids[j] = true;
}
} else {
- usbi_warn(ctx, " could not process %s report IDs", type[j]);
+ usbi_warn(HANDLE_CTX(dev_handle), " could not process %s report IDs", type[j]);
}
free(value_caps);
}
@@ -3679,19 +3765,19 @@ static int hid_open(int sub_api, struct libusb_device_handle *dev_handle)
priv->hid->usagePage = capabilities.UsagePage;
// Fetch string descriptors
- priv->hid->string_index[0] = priv->dev_descriptor.iManufacturer;
+ priv->hid->string_index[0] = dev->device_descriptor.iManufacturer;
if (priv->hid->string_index[0] != 0)
HidD_GetManufacturerString(hid_handle, priv->hid->string[0], sizeof(priv->hid->string[0]));
else
priv->hid->string[0][0] = 0;
- priv->hid->string_index[1] = priv->dev_descriptor.iProduct;
+ priv->hid->string_index[1] = dev->device_descriptor.iProduct;
if (priv->hid->string_index[1] != 0)
HidD_GetProductString(hid_handle, priv->hid->string[1], sizeof(priv->hid->string[1]));
else
priv->hid->string[1][0] = 0;
- priv->hid->string_index[2] = priv->dev_descriptor.iSerialNumber;
+ priv->hid->string_index[2] = dev->device_descriptor.iSerialNumber;
if (priv->hid->string_index[2] != 0)
HidD_GetSerialNumberString(hid_handle, priv->hid->string[2], sizeof(priv->hid->string[2]));
else
@@ -3706,12 +3792,14 @@ static int hid_open(int sub_api, struct libusb_device_handle *dev_handle)
static void hid_close(int sub_api, struct libusb_device_handle *dev_handle)
{
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
HANDLE file_handle;
int i;
- if (!api_hid_available)
+ UNUSED(sub_api);
+
+ if (DLL_HANDLE_NAME(hid) == NULL)
return;
for (i = 0; i < USB_MAXINTERFACES; i++) {
@@ -3723,11 +3811,12 @@ static void hid_close(int sub_api, struct libusb_device_handle *dev_handle)
}
}
-static int hid_claim_interface(int sub_api, struct libusb_device_handle *dev_handle, int iface)
+static int hid_claim_interface(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface)
{
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(dev_handle);
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
+ UNUSED(sub_api);
CHECK_HID_AVAILABLE;
// NB: Disconnection detection is not possible in this function
@@ -3740,17 +3829,18 @@ static int hid_claim_interface(int sub_api, struct libusb_device_handle *dev_han
handle_priv->interface_handle[iface].dev_handle = INTERFACE_CLAIMED;
- usbi_dbg("claimed interface %d", iface);
+ usbi_dbg("claimed interface %u", iface);
handle_priv->active_interface = iface;
return LIBUSB_SUCCESS;
}
-static int hid_release_interface(int sub_api, struct libusb_device_handle *dev_handle, int iface)
+static int hid_release_interface(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface)
{
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(dev_handle);
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
+ UNUSED(sub_api);
CHECK_HID_AVAILABLE;
if (priv->usb_interface[iface].path == NULL)
@@ -3764,17 +3854,15 @@ static int hid_release_interface(int sub_api, struct libusb_device_handle *dev_h
return LIBUSB_SUCCESS;
}
-static int hid_set_interface_altsetting(int sub_api, struct libusb_device_handle *dev_handle, int iface, int altsetting)
+static int hid_set_interface_altsetting(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface, uint8_t altsetting)
{
- struct libusb_context *ctx = DEVICE_CTX(dev_handle->dev);
+ UNUSED(sub_api);
+ UNUSED(iface);
CHECK_HID_AVAILABLE;
- if (altsetting > 255)
- return LIBUSB_ERROR_INVALID_PARAM;
-
if (altsetting != 0) {
- usbi_err(ctx, "set interface altsetting not supported for altsetting >0");
+ usbi_err(HANDLE_CTX(dev_handle), "set interface altsetting not supported for altsetting >0");
return LIBUSB_ERROR_NOT_SUPPORTED;
}
@@ -3784,17 +3872,19 @@ static int hid_set_interface_altsetting(int sub_api, struct libusb_device_handle
static int hid_submit_control_transfer(int sub_api, struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct winusb_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer);
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(transfer->dev_handle);
- struct winusb_device_priv *priv = _device_priv(transfer->dev_handle->dev);
- struct libusb_context *ctx = DEVICE_CTX(transfer->dev_handle->dev);
+ struct winusb_transfer_priv *transfer_priv = get_winusb_transfer_priv(itransfer);
+ struct libusb_device_handle *dev_handle = transfer->dev_handle;
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(transfer->dev_handle->dev);
WINUSB_SETUP_PACKET *setup = (WINUSB_SETUP_PACKET *)transfer->buffer;
HANDLE hid_handle;
OVERLAPPED *overlapped;
- int current_interface, config;
+ int current_interface;
+ uint8_t config;
size_t size;
- int r = LIBUSB_ERROR_INVALID_PARAM;
+ int r;
+ UNUSED(sub_api);
CHECK_HID_AVAILABLE;
safe_free(transfer_priv->hid_buffer);
@@ -3804,7 +3894,7 @@ static int hid_submit_control_transfer(int sub_api, struct usbi_transfer *itrans
if (size > MAX_CTRL_BUFFER_LENGTH)
return LIBUSB_ERROR_INVALID_PARAM;
- current_interface = get_valid_interface(transfer->dev_handle, USB_API_HID);
+ current_interface = get_valid_interface(dev_handle, USB_API_HID);
if (current_interface < 0) {
if (auto_claim(transfer, &current_interface, USB_API_HID) != LIBUSB_SUCCESS)
return LIBUSB_ERROR_NOT_FOUND;
@@ -3813,20 +3903,21 @@ static int hid_submit_control_transfer(int sub_api, struct usbi_transfer *itrans
usbi_dbg("will use interface %d", current_interface);
hid_handle = handle_priv->interface_handle[current_interface].api_handle;
- overlapped = transfer_priv->pollable_fd.overlapped;
+ set_transfer_priv_handle(itransfer, hid_handle);
+ overlapped = get_transfer_priv_overlapped(itransfer);
switch (LIBUSB_REQ_TYPE(setup->RequestType)) {
case LIBUSB_REQUEST_TYPE_STANDARD:
switch (setup->Request) {
case LIBUSB_REQUEST_GET_DESCRIPTOR:
- r = _hid_get_descriptor(priv->hid, hid_handle, LIBUSB_REQ_RECIPIENT(setup->RequestType),
+ r = _hid_get_descriptor(dev_handle->dev, hid_handle, LIBUSB_REQ_RECIPIENT(setup->RequestType),
(setup->Value >> 8) & 0xFF, setup->Value & 0xFF, transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE, &size);
break;
case LIBUSB_REQUEST_GET_CONFIGURATION:
- r = winusb_get_configuration(transfer->dev_handle, &config);
+ r = winusb_get_configuration(dev_handle, &config);
if (r == LIBUSB_SUCCESS) {
size = 1;
- ((uint8_t *)transfer->buffer)[LIBUSB_CONTROL_SETUP_SIZE] = (uint8_t)config;
+ ((uint8_t *)transfer->buffer)[LIBUSB_CONTROL_SETUP_SIZE] = config;
r = LIBUSB_COMPLETED;
}
break;
@@ -3834,7 +3925,7 @@ static int hid_submit_control_transfer(int sub_api, struct usbi_transfer *itrans
if (setup->Value == priv->active_config) {
r = LIBUSB_COMPLETED;
} else {
- usbi_warn(ctx, "cannot set configuration other than the default one");
+ usbi_warn(TRANSFER_CTX(transfer), "cannot set configuration other than the default one");
r = LIBUSB_ERROR_NOT_SUPPORTED;
}
break;
@@ -3844,22 +3935,22 @@ static int hid_submit_control_transfer(int sub_api, struct usbi_transfer *itrans
r = LIBUSB_COMPLETED;
break;
case LIBUSB_REQUEST_SET_INTERFACE:
- r = hid_set_interface_altsetting(0, transfer->dev_handle, setup->Index, setup->Value);
+ r = hid_set_interface_altsetting(0, dev_handle, (uint8_t)setup->Index, (uint8_t)setup->Value);
if (r == LIBUSB_SUCCESS)
r = LIBUSB_COMPLETED;
break;
default:
- usbi_warn(ctx, "unsupported HID control request");
+ usbi_warn(TRANSFER_CTX(transfer), "unsupported HID control request");
return LIBUSB_ERROR_NOT_SUPPORTED;
}
break;
case LIBUSB_REQUEST_TYPE_CLASS:
- r = _hid_class_request(priv->hid, hid_handle, setup->RequestType, setup->Request, setup->Value,
+ r = _hid_class_request(dev_handle->dev, hid_handle, setup->RequestType, setup->Request, setup->Value,
setup->Index, transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE, transfer_priv,
- &size, overlapped);
+ size, overlapped);
break;
default:
- usbi_warn(ctx, "unsupported HID control request");
+ usbi_warn(TRANSFER_CTX(transfer), "unsupported HID control request");
return LIBUSB_ERROR_NOT_SUPPORTED;
}
@@ -3868,7 +3959,7 @@ static int hid_submit_control_transfer(int sub_api, struct usbi_transfer *itrans
if (r == LIBUSB_COMPLETED) {
// Force request to be completed synchronously. Transferred size has been set by previous call
- windows_force_sync_completion(overlapped, (ULONG)size);
+ windows_force_sync_completion(itransfer, (ULONG)size);
r = LIBUSB_SUCCESS;
}
@@ -3880,17 +3971,16 @@ static int hid_submit_control_transfer(int sub_api, struct usbi_transfer *itrans
static int hid_submit_bulk_transfer(int sub_api, struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct winusb_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer);
- struct libusb_context *ctx = DEVICE_CTX(transfer->dev_handle->dev);
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(transfer->dev_handle);
- struct winusb_device_priv *priv = _device_priv(transfer->dev_handle->dev);
+ struct winusb_transfer_priv *transfer_priv = get_winusb_transfer_priv(itransfer);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(transfer->dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(transfer->dev_handle->dev);
HANDLE hid_handle;
OVERLAPPED *overlapped;
- bool direction_in, ret;
+ bool direction_in;
+ BOOL ret;
int current_interface, length;
- DWORD size;
- int r = LIBUSB_SUCCESS;
+ UNUSED(sub_api);
CHECK_HID_AVAILABLE;
transfer_priv->hid_dest = NULL;
@@ -3898,14 +3988,15 @@ static int hid_submit_bulk_transfer(int sub_api, struct usbi_transfer *itransfer
current_interface = interface_by_endpoint(priv, handle_priv, transfer->endpoint);
if (current_interface < 0) {
- usbi_err(ctx, "unable to match endpoint to an open interface - cancelling transfer");
+ usbi_err(TRANSFER_CTX(transfer), "unable to match endpoint to an open interface - cancelling transfer");
return LIBUSB_ERROR_NOT_FOUND;
}
usbi_dbg("matched endpoint %02X with interface %d", transfer->endpoint, current_interface);
- transfer_priv->handle = hid_handle = handle_priv->interface_handle[current_interface].api_handle;
- overlapped = transfer_priv->pollable_fd.overlapped;
+ hid_handle = handle_priv->interface_handle[current_interface].api_handle;
+ set_transfer_priv_handle(itransfer, hid_handle);
+ overlapped = get_transfer_priv_overlapped(itransfer);
direction_in = IS_XFERIN(transfer);
// If report IDs are not in use, an extra prefix byte must be added
@@ -3925,7 +4016,7 @@ static int hid_submit_bulk_transfer(int sub_api, struct usbi_transfer *itransfer
if (direction_in) {
transfer_priv->hid_dest = transfer->buffer;
usbi_dbg("reading %d bytes (report ID: 0x00)", length);
- ret = ReadFile(hid_handle, transfer_priv->hid_buffer, length + 1, &size, overlapped);
+ ret = ReadFile(hid_handle, transfer_priv->hid_buffer, length + 1, NULL, overlapped);
} else {
if (!priv->hid->uses_report_ids[1])
memcpy(transfer_priv->hid_buffer + 1, transfer->buffer, transfer->length);
@@ -3934,76 +4025,27 @@ static int hid_submit_bulk_transfer(int sub_api, struct usbi_transfer *itransfer
memcpy(transfer_priv->hid_buffer, transfer->buffer, transfer->length);
usbi_dbg("writing %d bytes (report ID: 0x%02X)", length, transfer_priv->hid_buffer[0]);
- ret = WriteFile(hid_handle, transfer_priv->hid_buffer, length, &size, overlapped);
+ ret = WriteFile(hid_handle, transfer_priv->hid_buffer, length, NULL, overlapped);
}
- if (!ret) {
- if (GetLastError() != ERROR_IO_PENDING) {
- usbi_err(ctx, "HID transfer failed: %s", windows_error_str(0));
- safe_free(transfer_priv->hid_buffer);
- return LIBUSB_ERROR_IO;
- }
- } else {
- // Only write operations that completed synchronously need to free up
- // hid_buffer. For reads, copy_transfer_data() handles that process.
- if (!direction_in)
- safe_free(transfer_priv->hid_buffer);
-
- if (size == 0) {
- usbi_err(ctx, "program assertion failed - no data was transferred");
- size = 1;
- }
- if (size > (size_t)length) {
- usbi_err(ctx, "OVERFLOW!");
- r = LIBUSB_ERROR_OVERFLOW;
- }
- windows_force_sync_completion(overlapped, (ULONG)size);
+ if (!ret && GetLastError() != ERROR_IO_PENDING) {
+ usbi_err(TRANSFER_CTX(transfer), "HID transfer failed: %s", windows_error_str(0));
+ safe_free(transfer_priv->hid_buffer);
+ return LIBUSB_ERROR_IO;
}
transfer_priv->interface_number = (uint8_t)current_interface;
- return r;
-}
-
-static int hid_abort_transfers(int sub_api, struct usbi_transfer *itransfer)
-{
- struct libusb_context *ctx = ITRANSFER_CTX(itransfer);
- struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct winusb_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer);
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(transfer->dev_handle);
- HANDLE hid_handle;
- int current_interface;
-
- CHECK_HID_AVAILABLE;
-
- current_interface = transfer_priv->interface_number;
- if ((current_interface < 0) || (current_interface >= USB_MAXINTERFACES)) {
- usbi_err(ctx, "program assertion failed: invalid interface_number");
- return LIBUSB_ERROR_NOT_FOUND;
- }
- usbi_dbg("will use interface %d", current_interface);
-
- hid_handle = handle_priv->interface_handle[current_interface].api_handle;
-
- if (pCancelIoEx != NULL) {
- // Use CancelIoEx if available to cancel just a single transfer
- if (pCancelIoEx(hid_handle, transfer_priv->pollable_fd.overlapped))
- return LIBUSB_SUCCESS;
- } else {
- if (CancelIo(hid_handle))
- return LIBUSB_SUCCESS;
- }
-
- usbi_warn(ctx, "cancel failed: %s", windows_error_str(0));
- return LIBUSB_ERROR_NOT_FOUND;
+ return LIBUSB_SUCCESS;
}
static int hid_reset_device(int sub_api, struct libusb_device_handle *dev_handle)
{
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(dev_handle);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
HANDLE hid_handle;
int current_interface;
+ UNUSED(sub_api);
CHECK_HID_AVAILABLE;
// Flushing the queues on all interfaces is the best we can achieve
@@ -4018,17 +4060,17 @@ static int hid_reset_device(int sub_api, struct libusb_device_handle *dev_handle
static int hid_clear_halt(int sub_api, struct libusb_device_handle *dev_handle, unsigned char endpoint)
{
- struct libusb_context *ctx = DEVICE_CTX(dev_handle->dev);
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(dev_handle);
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
HANDLE hid_handle;
int current_interface;
+ UNUSED(sub_api);
CHECK_HID_AVAILABLE;
current_interface = interface_by_endpoint(priv, handle_priv, endpoint);
if (current_interface < 0) {
- usbi_err(ctx, "unable to match endpoint to an open interface - cannot clear");
+ usbi_err(HANDLE_CTX(dev_handle), "unable to match endpoint to an open interface - cannot clear");
return LIBUSB_ERROR_NOT_FOUND;
}
@@ -4038,7 +4080,7 @@ static int hid_clear_halt(int sub_api, struct libusb_device_handle *dev_handle,
// No endpoint selection with Microsoft's implementation, so we try to flush the
// whole interface. Should be OK for most case scenarios
if (!HidD_FlushQueue(hid_handle)) {
- usbi_err(ctx, "Flushing of HID queue failed: %s", windows_error_str(0));
+ usbi_err(HANDLE_CTX(dev_handle), "Flushing of HID queue failed: %s", windows_error_str(0));
// Device was probably disconnected
return LIBUSB_ERROR_NO_DEVICE;
}
@@ -4047,31 +4089,31 @@ static int hid_clear_halt(int sub_api, struct libusb_device_handle *dev_handle,
}
// This extra function is only needed for HID
-static int hid_copy_transfer_data(int sub_api, struct usbi_transfer *itransfer, uint32_t io_size)
+static enum libusb_transfer_status hid_copy_transfer_data(int sub_api, struct usbi_transfer *itransfer, DWORD length)
{
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct libusb_context *ctx = DEVICE_CTX(transfer->dev_handle->dev);
- struct winusb_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer);
- int r = LIBUSB_TRANSFER_COMPLETED;
- uint32_t corrected_size = io_size;
+ struct winusb_transfer_priv *transfer_priv = get_winusb_transfer_priv(itransfer);
+ enum libusb_transfer_status r = LIBUSB_TRANSFER_COMPLETED;
+
+ UNUSED(sub_api);
if (transfer_priv->hid_buffer != NULL) {
// If we have a valid hid_buffer, it means the transfer was async
if (transfer_priv->hid_dest != NULL) { // Data readout
- if (corrected_size > 0) {
+ if (length > 0) {
// First, check for overflow
- if (corrected_size > transfer_priv->hid_expected_size) {
- usbi_err(ctx, "OVERFLOW!");
- corrected_size = (uint32_t)transfer_priv->hid_expected_size;
+ if ((size_t)length > transfer_priv->hid_expected_size) {
+ usbi_err(TRANSFER_CTX(transfer), "OVERFLOW!");
+ length = (DWORD)transfer_priv->hid_expected_size;
r = LIBUSB_TRANSFER_OVERFLOW;
}
if (transfer_priv->hid_buffer[0] == 0) {
// Discard the 1 byte report ID prefix
- corrected_size--;
- memcpy(transfer_priv->hid_dest, transfer_priv->hid_buffer + 1, corrected_size);
+ length--;
+ memcpy(transfer_priv->hid_dest, transfer_priv->hid_buffer + 1, length);
} else {
- memcpy(transfer_priv->hid_dest, transfer_priv->hid_buffer, corrected_size);
+ memcpy(transfer_priv->hid_dest, transfer_priv->hid_buffer, length);
}
}
transfer_priv->hid_dest = NULL;
@@ -4080,7 +4122,7 @@ static int hid_copy_transfer_data(int sub_api, struct usbi_transfer *itransfer,
safe_free(transfer_priv->hid_buffer);
}
- itransfer->transferred += corrected_size;
+ itransfer->transferred += (int)length;
return r;
}
@@ -4090,11 +4132,15 @@ static int hid_copy_transfer_data(int sub_api, struct usbi_transfer *itransfer,
*/
static int composite_open(int sub_api, struct libusb_device_handle *dev_handle)
{
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
- int r = LIBUSB_ERROR_NOT_FOUND;
- uint8_t i;
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
+ int i, r = LIBUSB_ERROR_NOT_FOUND;
// SUB_API_MAX + 1 as the SUB_API_MAX pos is used to indicate availability of HID
- bool available[SUB_API_MAX + 1] = { 0 };
+ bool available[SUB_API_MAX + 1];
+
+ UNUSED(sub_api);
+
+ for (i = 0; i < SUB_API_MAX + 1; i++)
+ available[i] = false;
for (i = 0; i < USB_MAXINTERFACES; i++) {
switch (priv->usb_interface[i].apib->id) {
@@ -4135,10 +4181,15 @@ static int composite_open(int sub_api, struct libusb_device_handle *dev_handle)
static void composite_close(int sub_api, struct libusb_device_handle *dev_handle)
{
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
- uint8_t i;
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
+ int i;
// SUB_API_MAX + 1 as the SUB_API_MAX pos is used to indicate availability of HID
- bool available[SUB_API_MAX + 1] = { 0 };
+ bool available[SUB_API_MAX + 1];
+
+ UNUSED(sub_api);
+
+ for (i = 0; i < SUB_API_MAX + 1; i++)
+ available[i] = false;
for (i = 0; i < USB_MAXINTERFACES; i++) {
switch (priv->usb_interface[i].apib->id) {
@@ -4163,30 +4214,33 @@ static void composite_close(int sub_api, struct libusb_device_handle *dev_handle
hid_close(SUB_API_NOTSET, dev_handle);
}
-static int composite_claim_interface(int sub_api, struct libusb_device_handle *dev_handle, int iface)
+static int composite_claim_interface(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface)
{
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
+ UNUSED(sub_api);
CHECK_SUPPORTED_API(priv->usb_interface[iface].apib, claim_interface);
return priv->usb_interface[iface].apib->
claim_interface(priv->usb_interface[iface].sub_api, dev_handle, iface);
}
-static int composite_set_interface_altsetting(int sub_api, struct libusb_device_handle *dev_handle, int iface, int altsetting)
+static int composite_set_interface_altsetting(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface, uint8_t altsetting)
{
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
+ UNUSED(sub_api);
CHECK_SUPPORTED_API(priv->usb_interface[iface].apib, set_interface_altsetting);
return priv->usb_interface[iface].apib->
set_interface_altsetting(priv->usb_interface[iface].sub_api, dev_handle, iface, altsetting);
}
-static int composite_release_interface(int sub_api, struct libusb_device_handle *dev_handle, int iface)
+static int composite_release_interface(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface)
{
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
+ UNUSED(sub_api);
CHECK_SUPPORTED_API(priv->usb_interface[iface].apib, release_interface);
return priv->usb_interface[iface].apib->
@@ -4196,12 +4250,13 @@ static int composite_release_interface(int sub_api, struct libusb_device_handle
static int composite_submit_control_transfer(int sub_api, struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct libusb_context *ctx = DEVICE_CTX(transfer->dev_handle->dev);
- struct winusb_device_priv *priv = _device_priv(transfer->dev_handle->dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(transfer->dev_handle->dev);
struct libusb_config_descriptor *conf_desc;
WINUSB_SETUP_PACKET *setup = (WINUSB_SETUP_PACKET *)transfer->buffer;
int iface, pass, r;
+ UNUSED(sub_api);
+
// Interface shouldn't matter for control, but it does in practice, with Windows'
// restrictions with regards to accessing HID keyboards and mice. Try to target
// a specific interface first, if possible.
@@ -4216,7 +4271,8 @@ static int composite_submit_control_transfer(int sub_api, struct usbi_transfer *
libusb_free_config_descriptor(conf_desc);
break;
}
- // Fall through if not able to determine interface
+ // No break if not able to determine interface
+ // Fall through
default:
iface = -1;
break;
@@ -4253,20 +4309,22 @@ static int composite_submit_control_transfer(int sub_api, struct usbi_transfer *
}
}
- usbi_err(ctx, "no libusb supported interfaces to complete request");
+ usbi_err(TRANSFER_CTX(transfer), "no libusb supported interfaces to complete request");
return LIBUSB_ERROR_NOT_FOUND;
}
-static int composite_submit_bulk_transfer(int sub_api, struct usbi_transfer *itransfer) {
+static int composite_submit_bulk_transfer(int sub_api, struct usbi_transfer *itransfer)
+{
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct libusb_context *ctx = DEVICE_CTX(transfer->dev_handle->dev);
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(transfer->dev_handle);
- struct winusb_device_priv *priv = _device_priv(transfer->dev_handle->dev);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(transfer->dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(transfer->dev_handle->dev);
int current_interface;
+ UNUSED(sub_api);
+
current_interface = interface_by_endpoint(priv, handle_priv, transfer->endpoint);
if (current_interface < 0) {
- usbi_err(ctx, "unable to match endpoint to an open interface - cancelling transfer");
+ usbi_err(TRANSFER_CTX(transfer), "unable to match endpoint to an open interface - cancelling transfer");
return LIBUSB_ERROR_NOT_FOUND;
}
@@ -4276,16 +4334,18 @@ static int composite_submit_bulk_transfer(int sub_api, struct usbi_transfer *itr
submit_bulk_transfer(priv->usb_interface[current_interface].sub_api, itransfer);
}
-static int composite_submit_iso_transfer(int sub_api, struct usbi_transfer *itransfer) {
+static int composite_submit_iso_transfer(int sub_api, struct usbi_transfer *itransfer)
+{
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct libusb_context *ctx = DEVICE_CTX(transfer->dev_handle->dev);
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(transfer->dev_handle);
- struct winusb_device_priv *priv = _device_priv(transfer->dev_handle->dev);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(transfer->dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(transfer->dev_handle->dev);
int current_interface;
+ UNUSED(sub_api);
+
current_interface = interface_by_endpoint(priv, handle_priv, transfer->endpoint);
if (current_interface < 0) {
- usbi_err(ctx, "unable to match endpoint to an open interface - cancelling transfer");
+ usbi_err(TRANSFER_CTX(transfer), "unable to match endpoint to an open interface - cancelling transfer");
return LIBUSB_ERROR_NOT_FOUND;
}
@@ -4297,14 +4357,15 @@ static int composite_submit_iso_transfer(int sub_api, struct usbi_transfer *itra
static int composite_clear_halt(int sub_api, struct libusb_device_handle *dev_handle, unsigned char endpoint)
{
- struct libusb_context *ctx = DEVICE_CTX(dev_handle->dev);
- struct winusb_device_handle_priv *handle_priv = _device_handle_priv(dev_handle);
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
+ struct winusb_device_handle_priv *handle_priv = usbi_get_device_handle_priv(dev_handle);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
int current_interface;
+ UNUSED(sub_api);
+
current_interface = interface_by_endpoint(priv, handle_priv, endpoint);
if (current_interface < 0) {
- usbi_err(ctx, "unable to match endpoint to an open interface - cannot clear");
+ usbi_err(HANDLE_CTX(dev_handle), "unable to match endpoint to an open interface - cannot clear");
return LIBUSB_ERROR_NOT_FOUND;
}
@@ -4314,49 +4375,34 @@ static int composite_clear_halt(int sub_api, struct libusb_device_handle *dev_ha
clear_halt(priv->usb_interface[current_interface].sub_api, dev_handle, endpoint);
}
-static int composite_abort_control(int sub_api, struct usbi_transfer *itransfer)
+static int composite_cancel_transfer(int sub_api, struct usbi_transfer *itransfer)
{
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct winusb_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer);
- struct winusb_device_priv *priv = _device_priv(transfer->dev_handle->dev);
+ struct winusb_transfer_priv *transfer_priv = get_winusb_transfer_priv(itransfer);
+ struct winusb_device_priv *priv = usbi_get_device_priv(transfer->dev_handle->dev);
int current_interface = transfer_priv->interface_number;
- if ((current_interface < 0) || (current_interface >= USB_MAXINTERFACES)) {
- usbi_err(TRANSFER_CTX(transfer), "program assertion failed: invalid interface_number");
- return LIBUSB_ERROR_NOT_FOUND;
- }
-
- CHECK_SUPPORTED_API(priv->usb_interface[current_interface].apib, abort_control);
-
- return priv->usb_interface[current_interface].apib->
- abort_control(priv->usb_interface[current_interface].sub_api, itransfer);
-}
-
-static int composite_abort_transfers(int sub_api, struct usbi_transfer *itransfer)
-{
- struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct winusb_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer);
- struct winusb_device_priv *priv = _device_priv(transfer->dev_handle->dev);
- int current_interface = transfer_priv->interface_number;
+ UNUSED(sub_api);
if ((current_interface < 0) || (current_interface >= USB_MAXINTERFACES)) {
- usbi_err(TRANSFER_CTX(transfer), "program assertion failed: invalid interface_number");
+ usbi_err(TRANSFER_CTX(transfer), "program assertion failed - invalid interface_number");
return LIBUSB_ERROR_NOT_FOUND;
}
- CHECK_SUPPORTED_API(priv->usb_interface[current_interface].apib, abort_transfers);
+ CHECK_SUPPORTED_API(priv->usb_interface[current_interface].apib, cancel_transfer);
return priv->usb_interface[current_interface].apib->
- abort_transfers(priv->usb_interface[current_interface].sub_api, itransfer);
+ cancel_transfer(priv->usb_interface[current_interface].sub_api, itransfer);
}
static int composite_reset_device(int sub_api, struct libusb_device_handle *dev_handle)
{
- struct winusb_device_priv *priv = _device_priv(dev_handle->dev);
- int r;
- uint8_t i;
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev_handle->dev);
+ int i, r;
bool available[SUB_API_MAX];
+ UNUSED(sub_api);
+
for (i = 0; i < SUB_API_MAX; i++)
available[i] = false;
@@ -4377,15 +4423,19 @@ static int composite_reset_device(int sub_api, struct libusb_device_handle *dev_
return LIBUSB_SUCCESS;
}
-static int composite_copy_transfer_data(int sub_api, struct usbi_transfer *itransfer, uint32_t io_size)
+static enum libusb_transfer_status composite_copy_transfer_data(int sub_api, struct usbi_transfer *itransfer, DWORD length)
{
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
- struct winusb_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer);
- struct winusb_device_priv *priv = _device_priv(transfer->dev_handle->dev);
+ struct winusb_transfer_priv *transfer_priv = get_winusb_transfer_priv(itransfer);
+ struct winusb_device_priv *priv = usbi_get_device_priv(transfer->dev_handle->dev);
int current_interface = transfer_priv->interface_number;
- CHECK_SUPPORTED_API(priv->usb_interface[current_interface].apib, copy_transfer_data);
+ UNUSED(sub_api);
+ if (priv->usb_interface[current_interface].apib->copy_transfer_data == NULL) {
+ usbi_err(TRANSFER_CTX(transfer), "program assertion failed - no function to copy transfer data");
+ return LIBUSB_TRANSFER_ERROR;
+ }
return priv->usb_interface[current_interface].apib->
- copy_transfer_data(priv->usb_interface[current_interface].sub_api, itransfer, io_size);
+ copy_transfer_data(priv->usb_interface[current_interface].sub_api, itransfer, length);
}
diff --git a/libusb/os/windows_winusb.h b/libusb/os/windows_winusb.h
index dd8fde5..49355d4 100644
--- a/libusb/os/windows_winusb.h
+++ b/libusb/os/windows_winusb.h
@@ -20,19 +20,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#pragma once
+#ifndef LIBUSB_WINDOWS_WINUSB_H
+#define LIBUSB_WINDOWS_WINUSB_H
#include "windows_common.h"
-#include "windows_nt_common.h"
#if defined(_MSC_VER)
// disable /W4 MSVC warnings that are benign
-#pragma warning(disable:4100) // unreferenced formal parameter
-#pragma warning(disable:4127) // conditional expression is constant
-#pragma warning(disable:4201) // nameless struct/union
#pragma warning(disable:4214) // bit field types other than int
-#pragma warning(disable:4996) // deprecated API calls
-#pragma warning(disable:28159) // more deprecated API calls
#endif
// Missing from MSVC6 setupapi.h
@@ -48,7 +43,7 @@
#define MAX_HID_REPORT_SIZE 1024
#define MAX_HID_DESCRIPTOR_SIZE 256
#define MAX_GUID_STRING_LENGTH 40
-#define MAX_PATH_LENGTH 128
+#define MAX_PATH_LENGTH 256
#define MAX_KEY_LENGTH 256
#define LIST_SEPARATOR ';'
@@ -73,6 +68,8 @@ const GUID GUID_DEVINTERFACE_USB_HUB = {0xF18A0E88, 0xC30C, 0x11D0, {0x88, 0x15,
const GUID GUID_DEVINTERFACE_LIBUSB0_FILTER = {0xF9F3FF14, 0xAE21, 0x48A0, {0x8A, 0x25, 0x80, 0x11, 0xA7, 0xA9, 0x31, 0xD9}};
#endif
+// The following define MUST be == sizeof(USB_DESCRIPTOR_REQUEST)
+#define USB_DESCRIPTOR_REQUEST_SIZE 12U
/*
* Multiple USB API backend support
@@ -97,22 +94,21 @@ struct windows_usb_api_backend {
const char * const designation;
const char * const * const driver_name_list; // Driver name, without .sys, e.g. "usbccgp"
const uint8_t nb_driver_names;
- int (*init)(struct libusb_context *ctx);
+ bool (*init)(struct libusb_context *ctx);
void (*exit)(void);
int (*open)(int sub_api, struct libusb_device_handle *dev_handle);
void (*close)(int sub_api, struct libusb_device_handle *dev_handle);
- int (*configure_endpoints)(int sub_api, struct libusb_device_handle *dev_handle, int iface);
- int (*claim_interface)(int sub_api, struct libusb_device_handle *dev_handle, int iface);
- int (*set_interface_altsetting)(int sub_api, struct libusb_device_handle *dev_handle, int iface, int altsetting);
- int (*release_interface)(int sub_api, struct libusb_device_handle *dev_handle, int iface);
+ int (*configure_endpoints)(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface);
+ int (*claim_interface)(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface);
+ int (*set_interface_altsetting)(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface, uint8_t altsetting);
+ int (*release_interface)(int sub_api, struct libusb_device_handle *dev_handle, uint8_t iface);
int (*clear_halt)(int sub_api, struct libusb_device_handle *dev_handle, unsigned char endpoint);
int (*reset_device)(int sub_api, struct libusb_device_handle *dev_handle);
int (*submit_bulk_transfer)(int sub_api, struct usbi_transfer *itransfer);
int (*submit_iso_transfer)(int sub_api, struct usbi_transfer *itransfer);
int (*submit_control_transfer)(int sub_api, struct usbi_transfer *itransfer);
- int (*abort_control)(int sub_api, struct usbi_transfer *itransfer);
- int (*abort_transfers)(int sub_api, struct usbi_transfer *itransfer);
- int (*copy_transfer_data)(int sub_api, struct usbi_transfer *itransfer, uint32_t io_size);
+ int (*cancel_transfer)(int sub_api, struct usbi_transfer *itransfer);
+ enum libusb_transfer_status (*copy_transfer_data)(int sub_api, struct usbi_transfer *itransfer, DWORD length);
};
extern const struct windows_usb_api_backend usb_api_backend[USB_API_MAX];
@@ -202,56 +198,48 @@ struct hid_device_priv {
uint8_t string_index[3]; // man, prod, ser
};
-static inline struct winusb_device_priv *_device_priv(struct libusb_device *dev)
-{
- return (struct winusb_device_priv *)dev->os_priv;
-}
-
static inline struct winusb_device_priv *winusb_device_priv_init(struct libusb_device *dev)
{
- struct winusb_device_priv *p = _device_priv(dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev);
int i;
- p->apib = &usb_api_backend[USB_API_UNSUPPORTED];
- p->sub_api = SUB_API_NOTSET;
+ priv->apib = &usb_api_backend[USB_API_UNSUPPORTED];
+ priv->sub_api = SUB_API_NOTSET;
for (i = 0; i < USB_MAXINTERFACES; i++) {
- p->usb_interface[i].apib = &usb_api_backend[USB_API_UNSUPPORTED];
- p->usb_interface[i].sub_api = SUB_API_NOTSET;
+ priv->usb_interface[i].apib = &usb_api_backend[USB_API_UNSUPPORTED];
+ priv->usb_interface[i].sub_api = SUB_API_NOTSET;
}
- return p;
+ return priv;
}
static inline void winusb_device_priv_release(struct libusb_device *dev)
{
- struct winusb_device_priv *p = _device_priv(dev);
+ struct winusb_device_priv *priv = usbi_get_device_priv(dev);
int i;
- free(p->dev_id);
- free(p->path);
- if ((dev->num_configurations > 0) && (p->config_descriptor != NULL)) {
- for (i = 0; i < dev->num_configurations; i++)
- free(p->config_descriptor[i]);
+ free(priv->dev_id);
+ free(priv->path);
+ if ((dev->device_descriptor.bNumConfigurations > 0) && (priv->config_descriptor != NULL)) {
+ for (i = 0; i < dev->device_descriptor.bNumConfigurations; i++) {
+ if (priv->config_descriptor[i] == NULL)
+ continue;
+ free((UCHAR *)priv->config_descriptor[i] - USB_DESCRIPTOR_REQUEST_SIZE);
+ }
}
- free(p->config_descriptor);
- free(p->hid);
+ free(priv->config_descriptor);
+ free(priv->hid);
for (i = 0; i < USB_MAXINTERFACES; i++) {
- free(p->usb_interface[i].path);
- free(p->usb_interface[i].endpoint);
+ free(priv->usb_interface[i].path);
+ free(priv->usb_interface[i].endpoint);
}
}
-static inline struct winusb_device_handle_priv *_device_handle_priv(
- struct libusb_device_handle *handle)
-{
- return (struct winusb_device_handle_priv *)handle->os_priv;
-}
-
// used to match a device driver (including filter drivers) against a supported API
struct driver_lookup {
char list[MAX_KEY_LENGTH + 1]; // REG_MULTI_SZ list of services (driver) names
const DWORD reg_prop; // SPDRP registry key to use to retrieve list
- const char* designation; // internal designation (for debug output)
+ const char *designation; // internal designation (for debug output)
};
/*
@@ -295,6 +283,9 @@ DLL_DECLARE_FUNC_PREFIXED(WINAPI, HKEY, p, SetupDiOpenDevRegKey, (HDEVINFO, PSP_
DLL_DECLARE_FUNC_PREFIXED(WINAPI, HKEY, p, SetupDiOpenDeviceInterfaceRegKey, (HDEVINFO, PSP_DEVICE_INTERFACE_DATA, DWORD, DWORD));
+#ifndef USB_GET_NODE_INFORMATION
+#define USB_GET_NODE_INFORMATION 258
+#endif
#ifndef USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION
#define USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION 260
#endif
@@ -312,6 +303,9 @@ DLL_DECLARE_FUNC_PREFIXED(WINAPI, HKEY, p, SetupDiOpenDeviceInterfaceRegKey, (HD
#define USB_CTL_CODE(id) \
CTL_CODE(FILE_DEVICE_USB, (id), METHOD_BUFFERED, FILE_ANY_ACCESS)
+#define IOCTL_USB_GET_NODE_INFORMATION \
+ USB_CTL_CODE(USB_GET_NODE_INFORMATION)
+
#define IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION \
USB_CTL_CODE(USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION)
@@ -321,7 +315,7 @@ DLL_DECLARE_FUNC_PREFIXED(WINAPI, HKEY, p, SetupDiOpenDeviceInterfaceRegKey, (HD
#define IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX_V2 \
USB_CTL_CODE(USB_GET_NODE_CONNECTION_INFORMATION_EX_V2)
-typedef enum USB_CONNECTION_STATUS {
+typedef enum _USB_CONNECTION_STATUS {
NoDeviceConnected,
DeviceConnected,
DeviceFailedEnumeration,
@@ -330,10 +324,20 @@ typedef enum USB_CONNECTION_STATUS {
DeviceNotEnoughPower,
DeviceNotEnoughBandwidth,
DeviceHubNestedTooDeeply,
- DeviceInLegacyHub
-} USB_CONNECTION_STATUS, *PUSB_CONNECTION_STATUS;
-
-typedef enum USB_HUB_NODE {
+ DeviceInLegacyHub,
+ DeviceEnumerating,
+ DeviceReset
+} USB_CONNECTION_STATUS;
+
+typedef enum _USB_DEVICE_SPEED {
+ UsbLowSpeed = 0,
+ UsbFullSpeed,
+ UsbHighSpeed,
+ UsbSuperSpeed,
+ UsbSuperSpeedPlus // Not in Microsoft headers
+} USB_DEVICE_SPEED;
+
+typedef enum _USB_HUB_NODE {
UsbHub,
UsbMIParent
} USB_HUB_NODE;
@@ -341,6 +345,29 @@ typedef enum USB_HUB_NODE {
// Most of the structures below need to be packed
#include <pshpack1.h>
+typedef struct _USB_HUB_DESCRIPTOR {
+ UCHAR bDescriptorLength;
+ UCHAR bDescriptorType;
+ UCHAR bNumberOfPorts;
+ USHORT wHubCharacteristics;
+ UCHAR bPowerOnToPowerGood;
+ UCHAR bHubControlCurrent;
+ UCHAR bRemoveAndPowerMask[64];
+} USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR;
+
+typedef struct _USB_HUB_INFORMATION {
+ USB_HUB_DESCRIPTOR HubDescriptor;
+ BOOLEAN HubIsBusPowered;
+} USB_HUB_INFORMATION, *PUSB_HUB_INFORMATION;
+
+typedef struct _USB_NODE_INFORMATION {
+ USB_HUB_NODE NodeType;
+ union {
+ USB_HUB_INFORMATION HubInformation;
+// USB_MI_PARENT_INFORMATION MiParentInformation;
+ } u;
+} USB_NODE_INFORMATION, *PUSB_NODE_INFORMATION;
+
typedef struct _USB_DESCRIPTOR_REQUEST {
ULONG ConnectionIndex;
struct {
@@ -426,6 +453,12 @@ typedef struct _USB_NODE_CONNECTION_INFORMATION_EX_V2 {
/* libusbK */
#define ISO_ALWAYS_START_ASAP 0x21
+typedef struct _USBD_ISO_PACKET_DESCRIPTOR {
+ ULONG Offset;
+ ULONG Length;
+ USBD_STATUS Status;
+} USBD_ISO_PACKET_DESCRIPTOR, *PUSBD_ISO_PACKET_DESCRIPTOR;
+
typedef enum _USBD_PIPE_TYPE {
UsbdPipeTypeControl,
UsbdPipeTypeIsochronous,
@@ -433,6 +466,14 @@ typedef enum _USBD_PIPE_TYPE {
UsbdPipeTypeInterrupt
} USBD_PIPE_TYPE;
+typedef struct {
+ USBD_PIPE_TYPE PipeType;
+ UCHAR PipeId;
+ USHORT MaximumPacketSize;
+ UCHAR Interval;
+ ULONG MaximumBytesPerInterval;
+} WINUSB_PIPE_INFORMATION_EX, *PWINUSB_PIPE_INFORMATION_EX;
+
#include <pshpack1.h>
typedef struct _WINUSB_SETUP_PACKET {
@@ -445,7 +486,8 @@ typedef struct _WINUSB_SETUP_PACKET {
#include <poppack.h>
-typedef void *WINUSB_INTERFACE_HANDLE, *PWINUSB_INTERFACE_HANDLE;
+typedef PVOID WINUSB_INTERFACE_HANDLE, *PWINUSB_INTERFACE_HANDLE;
+typedef PVOID WINUSB_ISOCH_BUFFER_HANDLE, *PWINUSB_ISOCH_BUFFER_HANDLE;
typedef BOOL (WINAPI *WinUsb_AbortPipe_t)(
WINUSB_INTERFACE_HANDLE InterfaceHandle,
@@ -475,6 +517,21 @@ typedef BOOL (WINAPI *WinUsb_Initialize_t)(
HANDLE DeviceHandle,
PWINUSB_INTERFACE_HANDLE InterfaceHandle
);
+typedef BOOL (WINAPI *WinUsb_QueryPipeEx_t)(
+ WINUSB_INTERFACE_HANDLE InterfaceHandle,
+ UCHAR AlternateInterfaceHandle,
+ UCHAR PipeIndex,
+ PWINUSB_PIPE_INFORMATION_EX PipeInformationEx
+);
+typedef BOOL (WINAPI *WinUsb_ReadIsochPipeAsap_t)(
+ PWINUSB_ISOCH_BUFFER_HANDLE BufferHandle,
+ ULONG Offset,
+ ULONG Length,
+ BOOL ContinueStream,
+ ULONG NumberOfPackets,
+ PUSBD_ISO_PACKET_DESCRIPTOR IsoPacketDescriptors,
+ LPOVERLAPPED Overlapped
+);
typedef BOOL (WINAPI *WinUsb_ReadPipe_t)(
WINUSB_INTERFACE_HANDLE InterfaceHandle,
UCHAR PipeID,
@@ -483,8 +540,12 @@ typedef BOOL (WINAPI *WinUsb_ReadPipe_t)(
PULONG LengthTransferred,
LPOVERLAPPED Overlapped
);
-typedef BOOL (WINAPI *WinUsb_ResetDevice_t)(
- WINUSB_INTERFACE_HANDLE InterfaceHandle
+typedef BOOL (WINAPI *WinUsb_RegisterIsochBuffer_t)(
+ WINUSB_INTERFACE_HANDLE InterfaceHandle,
+ UCHAR PipeID,
+ PVOID Buffer,
+ ULONG BufferLength,
+ PWINUSB_ISOCH_BUFFER_HANDLE BufferHandle
);
typedef BOOL (WINAPI *WinUsb_ResetPipe_t)(
WINUSB_INTERFACE_HANDLE InterfaceHandle,
@@ -501,29 +562,9 @@ typedef BOOL (WINAPI *WinUsb_SetPipePolicy_t)(
ULONG ValueLength,
PVOID Value
);
-typedef BOOL (WINAPI *WinUsb_WritePipe_t)(
- WINUSB_INTERFACE_HANDLE InterfaceHandle,
- UCHAR PipeID,
- PUCHAR Buffer,
- ULONG BufferLength,
- PULONG LengthTransferred,
- LPOVERLAPPED Overlapped
-);
-
-typedef PVOID WINUSB_ISOCH_BUFFER_HANDLE, *PWINUSB_ISOCH_BUFFER_HANDLE;
-
-typedef BOOL (WINAPI *WinUsb_RegisterIsochBuffer_t)(
- WINUSB_INTERFACE_HANDLE InterfaceHandle,
- UCHAR PipeID,
- PVOID Buffer,
- ULONG BufferLength,
- PWINUSB_ISOCH_BUFFER_HANDLE BufferHandle
-);
-
typedef BOOL (WINAPI *WinUsb_UnregisterIsochBuffer_t)(
WINUSB_ISOCH_BUFFER_HANDLE BufferHandle
);
-
typedef BOOL (WINAPI *WinUsb_WriteIsochPipeAsap_t)(
WINUSB_ISOCH_BUFFER_HANDLE BufferHandle,
ULONG Offset,
@@ -531,37 +572,13 @@ typedef BOOL (WINAPI *WinUsb_WriteIsochPipeAsap_t)(
BOOL ContinueStream,
LPOVERLAPPED Overlapped
);
-
-typedef LONG USBD_STATUS;
-typedef struct {
- ULONG Offset;
- ULONG Length;
- USBD_STATUS Status;
-} USBD_ISO_PACKET_DESCRIPTOR, *PUSBD_ISO_PACKET_DESCRIPTOR;
-
-typedef BOOL (WINAPI *WinUsb_ReadIsochPipeAsap_t)(
- PWINUSB_ISOCH_BUFFER_HANDLE BufferHandle,
- ULONG Offset,
- ULONG Length,
- BOOL ContinueStream,
- ULONG NumberOfPackets,
- PUSBD_ISO_PACKET_DESCRIPTOR IsoPacketDescriptors,
- LPOVERLAPPED Overlapped
-);
-
-typedef struct {
- USBD_PIPE_TYPE PipeType;
- UCHAR PipeId;
- USHORT MaximumPacketSize;
- UCHAR Interval;
- ULONG MaximumBytesPerInterval;
-} WINUSB_PIPE_INFORMATION_EX, *PWINUSB_PIPE_INFORMATION_EX;
-
-typedef BOOL (WINAPI *WinUsb_QueryPipeEx_t)(
+typedef BOOL (WINAPI *WinUsb_WritePipe_t)(
WINUSB_INTERFACE_HANDLE InterfaceHandle,
- UCHAR AlternateInterfaceHandle,
- UCHAR PipeIndex,
- PWINUSB_PIPE_INFORMATION_EX PipeInformationEx
+ UCHAR PipeID,
+ PUCHAR Buffer,
+ ULONG BufferLength,
+ PULONG LengthTransferred,
+ LPOVERLAPPED Overlapped
);
/* /!\ These must match the ones from the official libusbk.h */
@@ -611,15 +628,19 @@ typedef struct _KLIB_VERSION {
} KLIB_VERSION, *PKLIB_VERSION;
typedef BOOL (WINAPI *LibK_GetProcAddress_t)(
- PVOID *ProcAddress,
- ULONG DriverID,
- ULONG FunctionID
+ PVOID ProcAddress,
+ INT DriverID,
+ INT FunctionID
);
typedef VOID (WINAPI *LibK_GetVersion_t)(
PKLIB_VERSION Version
);
+typedef BOOL (WINAPI *LibK_ResetDevice_t)(
+ WINUSB_INTERFACE_HANDLE InterfaceHandle
+);
+
//KISO_PACKET is equivalent of libusb_iso_packet_descriptor except uses absolute "offset" field instead of sequential Lengths
typedef struct _KISO_PACKET {
UINT offset;
@@ -642,7 +663,7 @@ typedef struct _KISO_CONTEXT {
KISO_PACKET IsoPackets[0];
} KISO_CONTEXT, *PKISO_CONTEXT;
-typedef BOOL(WINAPI *WinUsb_IsoReadPipe_t)(
+typedef BOOL(WINAPI *LibK_IsoReadPipe_t)(
WINUSB_INTERFACE_HANDLE InterfaceHandle,
UCHAR PipeID,
PUCHAR Buffer,
@@ -651,7 +672,7 @@ typedef BOOL(WINAPI *WinUsb_IsoReadPipe_t)(
PKISO_CONTEXT IsoContext
);
-typedef BOOL(WINAPI *WinUsb_IsoWritePipe_t)(
+typedef BOOL(WINAPI *LibK_IsoWritePipe_t)(
WINUSB_INTERFACE_HANDLE InterfaceHandle,
UCHAR PipeID,
PUCHAR Buffer,
@@ -661,8 +682,7 @@ typedef BOOL(WINAPI *WinUsb_IsoWritePipe_t)(
);
struct winusb_interface {
- bool initialized;
- bool CancelIoEx_supported;
+ HMODULE hDll;
WinUsb_AbortPipe_t AbortPipe;
WinUsb_ControlTransfer_t ControlTransfer;
WinUsb_FlushPipe_t FlushPipe;
@@ -670,22 +690,27 @@ struct winusb_interface {
WinUsb_GetAssociatedInterface_t GetAssociatedInterface;
WinUsb_Initialize_t Initialize;
WinUsb_ReadPipe_t ReadPipe;
- WinUsb_ResetDevice_t ResetDevice;
WinUsb_ResetPipe_t ResetPipe;
WinUsb_SetCurrentAlternateSetting_t SetCurrentAlternateSetting;
WinUsb_SetPipePolicy_t SetPipePolicy;
WinUsb_WritePipe_t WritePipe;
-
- // Isochoronous functions for LibUSBk sub api:
- WinUsb_IsoReadPipe_t IsoReadPipe;
- WinUsb_IsoWritePipe_t IsoWritePipe;
-
- // Isochronous functions for Microsoft WinUSB sub api (native WinUSB):
- WinUsb_RegisterIsochBuffer_t RegisterIsochBuffer;
- WinUsb_UnregisterIsochBuffer_t UnregisterIsochBuffer;
- WinUsb_WriteIsochPipeAsap_t WriteIsochPipeAsap;
- WinUsb_ReadIsochPipeAsap_t ReadIsochPipeAsap;
- WinUsb_QueryPipeEx_t QueryPipeEx;
+ union {
+ struct {
+ // Isochoronous functions for libusbK sub api:
+ LibK_IsoReadPipe_t IsoReadPipe;
+ LibK_IsoWritePipe_t IsoWritePipe;
+ // Reset device function for libusbK sub api:
+ LibK_ResetDevice_t ResetDevice;
+ };
+ struct {
+ // Isochronous functions for WinUSB sub api:
+ WinUsb_QueryPipeEx_t QueryPipeEx;
+ WinUsb_ReadIsochPipeAsap_t ReadIsochPipeAsap;
+ WinUsb_RegisterIsochBuffer_t RegisterIsochBuffer;
+ WinUsb_UnregisterIsochBuffer_t UnregisterIsochBuffer;
+ WinUsb_WriteIsochPipeAsap_t WriteIsochPipeAsap;
+ };
+ };
};
/* hid.dll interface */
@@ -781,3 +806,5 @@ DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_SetNumInputBuffers, (HANDLE, ULONG));
DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_GetPhysicalDescriptor, (HANDLE, PVOID, ULONG));
DLL_DECLARE_FUNC(WINAPI, BOOL, HidD_FlushQueue, (HANDLE));
DLL_DECLARE_FUNC(WINAPI, BOOL, HidP_GetValueCaps, (HIDP_REPORT_TYPE, PHIDP_VALUE_CAPS, PULONG, PHIDP_PREPARSED_DATA));
+
+#endif
diff --git a/libusb/strerror.c b/libusb/strerror.c
index a1b474e..9445fa9 100644
--- a/libusb/strerror.c
+++ b/libusb/strerror.c
@@ -17,22 +17,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <config.h>
-
-#include <locale.h>
-#include <stdlib.h>
-#include <string.h>
-#if defined(HAVE_STRINGS_H)
-#include <strings.h>
-#endif
-
#include "libusbi.h"
-#if defined(_MSC_VER)
-#define strncasecmp _strnicmp
-#endif
-
-static size_t usbi_locale = 0;
+#include <ctype.h>
+#include <string.h>
/** \ingroup libusb_misc
* How to add a new \ref libusb_strerror() translation:
@@ -53,15 +41,15 @@ static size_t usbi_locale = 0;
* "Success",
* ...
* "Other error",
- * }
+ * },
* };\endcode </li>
* <li> Translate each of the English messages from the section you copied into your language </li>
* <li> Save the file (in UTF-8 format) and send it to \c libusb-devel\@lists.sourceforge.net </li>
* </ol>
*/
-static const char* usbi_locale_supported[] = { "en", "nl", "fr", "ru", "de", "hu" };
-static const char* usbi_localized_errors[ARRAYSIZE(usbi_locale_supported)][LIBUSB_ERROR_COUNT] = {
+static const char * const usbi_locale_supported[] = { "en", "nl", "fr", "ru", "de", "hu" };
+static const char * const usbi_localized_errors[ARRAYSIZE(usbi_locale_supported)][LIBUSB_ERROR_COUNT] = {
{ /* English (en) */
"Success",
"Input/Output Error",
@@ -122,7 +110,6 @@ static const char* usbi_localized_errors[ARRAYSIZE(usbi_locale_supported)][LIBUS
"Память исчерпана",
"Операция не поддерживается данной платформой",
"Неизвестная ошибка"
-
}, { /* German (de) */
"Erfolgreich",
"Eingabe-/Ausgabefehler",
@@ -153,9 +140,11 @@ static const char* usbi_localized_errors[ARRAYSIZE(usbi_locale_supported)][LIBUS
"Nincs elég memória",
"A művelet nem támogatott ezen a rendszeren",
"Általános hiba",
- }
+ },
};
+static const char * const (*usbi_error_strings)[LIBUSB_ERROR_COUNT] = &usbi_localized_errors[0];
+
/** \ingroup libusb_misc
* Set the language, and only the language, not the encoding! used for
* translatable libusb messages.
@@ -165,7 +154,7 @@ static const char* usbi_localized_errors[ARRAYSIZE(usbi_locale_supported)][LIBUS
* used, and only 2 letter ISO 639-1 codes are accepted for it, such as "de".
* The optional region, country_region or codeset parts are ignored. This
* means that functions which return translatable strings will NOT honor the
- * specified encoding.
+ * specified encoding.
* All strings returned are encoded as UTF-8 strings.
*
* If libusb_setlocale() is not called, all messages will be in English.
@@ -190,19 +179,20 @@ int API_EXPORTED libusb_setlocale(const char *locale)
{
size_t i;
- if ( (locale == NULL) || (strlen(locale) < 2)
- || ((strlen(locale) > 2) && (locale[2] != '-') && (locale[2] != '_') && (locale[2] != '.')) )
+ if (!locale || strlen(locale) < 2
+ || (locale[2] != '\0' && locale[2] != '-' && locale[2] != '_' && locale[2] != '.'))
return LIBUSB_ERROR_INVALID_PARAM;
- for (i=0; i<ARRAYSIZE(usbi_locale_supported); i++) {
- if (strncasecmp(usbi_locale_supported[i], locale, 2) == 0)
+ for (i = 0; i < ARRAYSIZE(usbi_locale_supported); i++) {
+ if (usbi_locale_supported[i][0] == tolower((unsigned char)locale[0])
+ && usbi_locale_supported[i][1] == tolower((unsigned char)locale[1]))
break;
}
- if (i >= ARRAYSIZE(usbi_locale_supported)) {
+
+ if (i == ARRAYSIZE(usbi_locale_supported))
return LIBUSB_ERROR_NOT_FOUND;
- }
- usbi_locale = i;
+ usbi_error_strings = &usbi_localized_errors[i];
return LIBUSB_SUCCESS;
}
@@ -220,14 +210,14 @@ int API_EXPORTED libusb_setlocale(const char *locale)
* \param errcode the error code whose description is desired
* \returns a short description of the error code in UTF-8 encoding
*/
-DEFAULT_VISIBILITY const char* LIBUSB_CALL libusb_strerror(enum libusb_error errcode)
+DEFAULT_VISIBILITY const char * LIBUSB_CALL libusb_strerror(int errcode)
{
int errcode_index = -errcode;
- if ((errcode_index < 0) || (errcode_index >= LIBUSB_ERROR_COUNT)) {
+ if (errcode_index < 0 || errcode_index >= LIBUSB_ERROR_COUNT) {
/* "Other Error", which should always be our last message, is returned */
errcode_index = LIBUSB_ERROR_COUNT - 1;
}
- return usbi_localized_errors[usbi_locale][errcode_index];
+ return (*usbi_error_strings)[errcode_index];
}
diff --git a/libusb/sync.c b/libusb/sync.c
index 70942ac..adc95b4 100644
--- a/libusb/sync.c
+++ b/libusb/sync.c
@@ -20,15 +20,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <config.h>
+#include "libusbi.h"
-#include <errno.h>
-#include <stdint.h>
-#include <stdlib.h>
#include <string.h>
-#include "libusbi.h"
-
/**
* @defgroup libusb_syncio Synchronous device I/O
*
@@ -62,7 +57,7 @@ static void sync_transfer_wait_for_completion(struct libusb_transfer *transfer)
}
if (NULL == transfer->dev_handle) {
/* transfer completion after libusb_close() */
- transfer->status = LIBUSB_ERROR_NO_DEVICE;
+ transfer->status = LIBUSB_TRANSFER_NO_DEVICE;
*completed = 1;
}
}
@@ -86,7 +81,7 @@ static void sync_transfer_wait_for_completion(struct libusb_transfer *transfer)
* (depending on direction bits within bmRequestType)
* \param wLength the length field for the setup packet. The data buffer should
* be at least this size.
- * \param timeout timeout (in millseconds) that this function should wait
+ * \param timeout timeout (in milliseconds) that this function should wait
* before giving up due to no response being received. For an unlimited
* timeout, use value 0.
* \returns on success, the number of bytes actually transferred
@@ -96,7 +91,7 @@ static void sync_transfer_wait_for_completion(struct libusb_transfer *transfer)
* \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
* \returns LIBUSB_ERROR_BUSY if called from event handling context
* \returns LIBUSB_ERROR_INVALID_PARAM if the transfer size is larger than
- * the operating system and/or hardware can support
+ * the operating system and/or hardware can support (see \ref asynclimits)
* \returns another LIBUSB_ERROR code on other failures
*/
int API_EXPORTED libusb_control_transfer(libusb_device_handle *dev_handle,
@@ -115,7 +110,7 @@ int API_EXPORTED libusb_control_transfer(libusb_device_handle *dev_handle,
if (!transfer)
return LIBUSB_ERROR_NO_MEM;
- buffer = (unsigned char*) malloc(LIBUSB_CONTROL_SETUP_SIZE + wLength);
+ buffer = malloc(LIBUSB_CONTROL_SETUP_SIZE + wLength);
if (!buffer) {
libusb_free_transfer(transfer);
return LIBUSB_ERROR_NO_MEM;
@@ -248,7 +243,7 @@ static int do_sync_bulk_transfer(struct libusb_device_handle *dev_handle,
* underlying O/S requirements, meaning that the timeout may expire after
* the first few chunks have completed. libusb is careful not to lose any data
* that may have been transferred; do not assume that timeout conditions
- * indicate a complete lack of I/O.
+ * indicate a complete lack of I/O. See \ref asynctimeout for more details.
*
* \param dev_handle a handle for the device to communicate with
* \param endpoint the address of a valid endpoint to communicate with
@@ -260,7 +255,7 @@ static int do_sync_bulk_transfer(struct libusb_device_handle *dev_handle,
* transferred. Since version 1.0.21 (\ref LIBUSB_API_VERSION >= 0x01000105),
* it is legal to pass a NULL pointer if you do not wish to receive this
* information.
- * \param timeout timeout (in millseconds) that this function should wait
+ * \param timeout timeout (in milliseconds) that this function should wait
* before giving up due to no response being received. For an unlimited
* timeout, use value 0.
*
@@ -272,11 +267,13 @@ static int do_sync_bulk_transfer(struct libusb_device_handle *dev_handle,
* \ref libusb_packetoverflow
* \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
* \returns LIBUSB_ERROR_BUSY if called from event handling context
+ * \returns LIBUSB_ERROR_INVALID_PARAM if the transfer size is larger than
+ * the operating system and/or hardware can support (see \ref asynclimits)
* \returns another LIBUSB_ERROR code on other failures
*/
-int API_EXPORTED libusb_bulk_transfer(struct libusb_device_handle *dev_handle,
- unsigned char endpoint, unsigned char *data, int length, int *transferred,
- unsigned int timeout)
+int API_EXPORTED libusb_bulk_transfer(libusb_device_handle *dev_handle,
+ unsigned char endpoint, unsigned char *data, int length,
+ int *transferred, unsigned int timeout)
{
return do_sync_bulk_transfer(dev_handle, endpoint, data, length,
transferred, timeout, LIBUSB_TRANSFER_TYPE_BULK);
@@ -299,7 +296,7 @@ int API_EXPORTED libusb_bulk_transfer(struct libusb_device_handle *dev_handle,
* underlying O/S requirements, meaning that the timeout may expire after
* the first few chunks have completed. libusb is careful not to lose any data
* that may have been transferred; do not assume that timeout conditions
- * indicate a complete lack of I/O.
+ * indicate a complete lack of I/O. See \ref asynctimeout for more details.
*
* The default endpoint bInterval value is used as the polling interval.
*
@@ -313,7 +310,7 @@ int API_EXPORTED libusb_bulk_transfer(struct libusb_device_handle *dev_handle,
* transferred. Since version 1.0.21 (\ref LIBUSB_API_VERSION >= 0x01000105),
* it is legal to pass a NULL pointer if you do not wish to receive this
* information.
- * \param timeout timeout (in millseconds) that this function should wait
+ * \param timeout timeout (in milliseconds) that this function should wait
* before giving up due to no response being received. For an unlimited
* timeout, use value 0.
*
@@ -324,11 +321,13 @@ int API_EXPORTED libusb_bulk_transfer(struct libusb_device_handle *dev_handle,
* \ref libusb_packetoverflow
* \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
* \returns LIBUSB_ERROR_BUSY if called from event handling context
+ * \returns LIBUSB_ERROR_INVALID_PARAM if the transfer size is larger than
+ * the operating system and/or hardware can support (see \ref asynclimits)
* \returns another LIBUSB_ERROR code on other error
*/
-int API_EXPORTED libusb_interrupt_transfer(
- struct libusb_device_handle *dev_handle, unsigned char endpoint,
- unsigned char *data, int length, int *transferred, unsigned int timeout)
+int API_EXPORTED libusb_interrupt_transfer(libusb_device_handle *dev_handle,
+ unsigned char endpoint, unsigned char *data, int length,
+ int *transferred, unsigned int timeout)
{
return do_sync_bulk_transfer(dev_handle, endpoint, data, length,
transferred, timeout, LIBUSB_TRANSFER_TYPE_INTERRUPT);
diff --git a/libusb/version.h b/libusb/version.h
index 8fccd35..d8ebde4 100644
--- a/libusb/version.h
+++ b/libusb/version.h
@@ -7,7 +7,7 @@
#define LIBUSB_MINOR 0
#endif
#ifndef LIBUSB_MICRO
-#define LIBUSB_MICRO 23
+#define LIBUSB_MICRO 24
#endif
#ifndef LIBUSB_NANO
#define LIBUSB_NANO 0
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 02179a4..0f100a8 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11397
+#define LIBUSB_NANO 11584
diff --git a/linux/config.h b/linux/config.h
index f50f5ab..e4860a6 100644
--- a/linux/config.h
+++ b/linux/config.h
@@ -11,13 +11,32 @@
#define ENABLE_LOGGING 1
/* Define to 1 if you have the <asm/types.h> header file. */
-#define HAVE_ASM_TYPES_H 1
+/* #undef HAVE_ASM_TYPES_H */
+
+/* Define to 1 if you have the `clock_gettime' function. */
+#define HAVE_CLOCK_GETTIME 1
+
+/* Define to 1 if you have the declaration of `EFD_CLOEXEC', and to 0 if you
+ * don't. */
+#define HAVE_DECL_EFD_CLOEXEC 1
+
+/* Define to 1 if you have the declaration of `EFD_NONBLOCK', and to 0 if you
+ * don't. */
+#define HAVE_DECL_EFD_NONBLOCK 1
+
+/* Define to 1 if you have the declaration of `TFD_CLOEXEC', and to 0 if you
+ * don't. */
+#define HAVE_DECL_TFD_CLOEXEC 1
+
+/* Define to 1 if you have the declaration of `TFD_NONBLOCK', and to 0 if you
+ * don't. */
+#define HAVE_DECL_TFD_NONBLOCK 1
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
-/* Define to 1 if you have the `gettimeofday' function. */
-#define HAVE_GETTIMEOFDAY 1
+/* Define to 1 if the system has eventfd functionality. */
+#define HAVE_EVENTFD 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
@@ -25,20 +44,23 @@
/* Define to 1 if you have the `udev' library (-ludev). */
/* #undef HAVE_LIBUDEV */
-/* Define to 1 if you have the <libudev.h> header file. */
-/* #undef HAVE_LIBUDEV_H */
-
-/* Define to 1 if you have the <linux/netlink.h> header file. */
-#define HAVE_LINUX_NETLINK_H 1
-
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
-/* Define to 1 if you have the <poll.h> header file. */
-#define HAVE_POLL_H 1
+/* Define to 1 if the system has the type `nfds_t'. */
+#define HAVE_NFDS_T 1
-/* Define to 1 if you have the <signal.h> header file. */
-#define HAVE_SIGNAL_H 1
+/* Define to 1 if you have the `pipe2' function. */
+#define HAVE_PIPE2 1
+
+/* Define to 1 if you have the `pthread_condattr_setclock' function. */
+#define HAVE_PTHREAD_CONDATTR_SETCLOCK 1
+
+/* Define to 1 if you have the `pthread_setname_np' function. */
+#define HAVE_PTHREAD_SETNAME_NP 1
+
+/* Define to 1 if you have the `pthread_threadid_np' function. */
+/* #undef HAVE_PTHREAD_THREADID_NP */
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
@@ -53,16 +75,10 @@
#define HAVE_STRING_H 1
/* Define to 1 if the system has the type `struct timespec'. */
-#define HAVE_STRUCT_TIMESPEC 1
-
-/* syslog() function available */
-#define HAVE_SYSLOG_FUNC 1
+/* #undef HAVE_STRUCT_TIMESPEC */
-/* Define to 1 if you have the <syslog.h> header file. */
-#define HAVE_SYSLOG_H 1
-
-/* Define to 1 if you have the <sys/socket.h> header file. */
-#define HAVE_SYS_SOCKET_H 1
+/* Define to 1 if you have the `syslog' function. */
+/* #undef HAVE_SYSLOG */
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
@@ -73,87 +89,63 @@
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
+/* Define to 1 if the system has timerfd functionality. */
+#define HAVE_TIMERFD 1
+
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
- */
+/* Define to the sub-directory in which libtool stores uninstalled libraries. */
#define LT_OBJDIR ".libs/"
-/* Darwin backend */
-/* #undef OS_DARWIN */
-
-/* Haiku backend */
-/* #undef OS_HAIKU */
-
-/* Linux backend */
-#define OS_LINUX 1
-
-/* NetBSD backend */
-/* #undef OS_NETBSD */
-
-/* OpenBSD backend */
-/* #undef OS_OPENBSD */
-
-/* SunOS backend */
-/* #undef OS_SUNOS */
-
-/* Windows backend */
-/* #undef OS_WINDOWS */
-
/* Name of package */
-#define PACKAGE "libusb"
+#define PACKAGE "libusb-1.0"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "libusb-devel@lists.sourceforge.net"
/* Define to the full name of this package. */
-#define PACKAGE_NAME "libusb"
+#define PACKAGE_NAME "libusb-1.0"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "libusb 1.0.21-rc5"
+#define PACKAGE_STRING "libusb-1.0 1.0.24"
/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "libusb"
+#define PACKAGE_TARNAME "libusb-1.0"
/* Define to the home page for this package. */
#define PACKAGE_URL "http://libusb.info"
/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.0.21-rc5"
+#define PACKAGE_VERSION "1.0.24"
-/* type of second poll() argument */
-#define POLL_NFDS_TYPE nfds_t
+/* Define to 1 if compiling for a POSIX platform. */
+#define PLATFORM_POSIX 1
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
+/* Define to 1 if compiling for a Windows platform. */
+/* #undef PLATFORM_WINDOWS */
-/* Use POSIX Threads */
-#define THREADS_POSIX 1
+/* Define to the attribute for enabling parameter checks on printf-like
+ * functions. */
+#define PRINTF_FORMAT(a, b) __attribute__ ((__format__ (__printf__, a, b)))
-/* timerfd headers available */
-#define USBI_TIMERFD_AVAILABLE 1
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
-/* Enable output to system log */
+/* Define to 1 to output logging messages to the systemwide log. */
/* #undef USE_SYSTEM_LOGGING_FACILITY */
-/* Use udev for device enumeration/hotplug */
-/* #undef USE_UDEV */
-
-/* Use UsbDk Windows backend */
-/* #undef USE_USBDK */
-
/* Version number of package */
-#define VERSION "1.0.21-rc5"
-
-/* Oldest Windows version supported */
-/* #undef WINVER */
+#define VERSION "1.0.24"
-/* Use GNU extensions */
+/* Enable GNU extensions. */
#define _GNU_SOURCE 1
+/* Define to the oldest supported Windows version. */
+/* #undef _WIN32_WINNT */
+
/* Define to `__inline__' or `__inline' if that's what the C compiler
- calls it, or to nothing if 'inline' is not supported under any name. */
+ * calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
/* #undef inline */
#endif
diff --git a/msvc/.gitattributes b/msvc/.gitattributes
new file mode 100644
index 0000000..c42ba10
--- /dev/null
+++ b/msvc/.gitattributes
@@ -0,0 +1,3 @@
+*.sln eol=crlf
+*.vcxproj eol=crlf
+*.vcxproj.filters eol=crlf
diff --git a/msvc/appveyor.bat b/msvc/appveyor.bat
deleted file mode 100644
index b703435..0000000
--- a/msvc/appveyor.bat
+++ /dev/null
@@ -1,27 +0,0 @@
-echo on
-SetLocal EnableDelayedExpansion
-
-if [%Configuration%] NEQ [Debug] goto releasex64
-if [%Configuration%] NEQ [Release] goto debugx64
-
-:debugx64
-if [%Platform%] NEQ [x64] goto debugWin32
-if [%Configuration%] NEQ [Debug] exit 0
-call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /Debug /x64 || exit /B
-msbuild %libusb_2010% /p:Configuration=Debug,Platform=x64 /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" || exit /B
-
-:releasex64
-if [%Platform%] NEQ [x64] goto releaseWin32
-if [%Configuration%] NEQ [Release] exit 0
-call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /Release /x64 || exit /B
-msbuild %libusb_2010% /p:Configuration=Release,Platform=x64 /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" || exit /B
-
-:debugWin32
-if [%Platform%] NEQ [Win32] exit 0
-if [%Configuration%] NEQ [Debug] exit 0
-msbuild %libusb_2010% /p:Configuration=Debug,Platform=Win32 /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" || exit /B
-
-:releaseWin32
-if [%Platform%] NEQ [Win32] exit 0
-if [%Configuration%] NEQ [Release] exit 0
-msbuild %libusb_2010% /p:Configuration=Release,Platform=Win32 /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" || exit /B
diff --git a/msvc/config.h b/msvc/config.h
index b20d99b..8aafd9d 100644
--- a/msvc/config.h
+++ b/msvc/config.h
@@ -5,18 +5,30 @@
#error "Please make sure the msvc/ directory is removed from your build path."
#endif
+/* Visual Studio 2013 or later is required */
+#if (_MSC_VER < 1800)
+#error "Visual Studio 2013 or later is required."
+#endif
+
+/* Visual Studio 2013 does not support __func__ */
+#if (_MSC_VER < 1900)
+#define __func__ __FUNCTION__
+#endif
+
/* Visual Studio 2015 and later defines timespec */
#if (_MSC_VER >= 1900)
#define _TIMESPEC_DEFINED 1
#endif
+/* Disable: warning C4127: conditional expression is constant */
+#pragma warning(disable:4127)
/* Disable: warning C4200: nonstandard extension used : zero-sized array in struct/union */
#pragma warning(disable:4200)
+/* Disable: warning C4201: nonstandard extension used : nameless struct/union */
+#pragma warning(disable:4201)
/* Disable: warning C4324: structure was padded due to __declspec(align()) */
#pragma warning(disable:4324)
-/* Disable: warning C6258: Using TerminateThread does not allow proper thread clean up */
-#pragma warning(disable:6258)
-/* Disable: warning C4996: 'GetVersionA': was declared deprecated */
+/* Disable: warning C4996: 'GetVersionExA': was declared deprecated */
#pragma warning(disable:4996)
#if defined(_PREFAST_)
@@ -26,26 +38,21 @@
#pragma warning(disable:28125)
#endif
-/* Default visibility */
+/* Define to the attribute for default visibility. */
#define DEFAULT_VISIBILITY /**/
-/* Enable global message logging */
-#define ENABLE_LOGGING 1
+/* Define to 1 to start with debug message logging enabled. */
+/* #undef ENABLE_DEBUG_LOGGING */
-/* Uncomment to start with debug message logging enabled */
-// #define ENABLE_DEBUG_LOGGING 1
+/* Define to 1 to enable message logging. */
+#define ENABLE_LOGGING 1
-/* Uncomment to enabling logging to system log */
-// #define USE_SYSTEM_LOGGING_FACILITY
+/* Define to 1 if compiling for a Windows platform. */
+#define PLATFORM_WINDOWS 1
-/* type of second poll() argument */
-#define POLL_NFDS_TYPE unsigned int
+/* Define to the attribute for enabling parameter checks on printf-like
+ functions. */
+#define PRINTF_FORMAT(a, b) /**/
-/* Windows/WinCE backend */
-#if defined(_WIN32_WCE)
-#define OS_WINCE 1
-#define HAVE_MISSING_H
-#else
-#define OS_WINDOWS 1
-#define HAVE_SYS_TYPES_H 1
-#endif
+/* Define to 1 to output logging messages to the systemwide log. */
+/* #undef USE_SYSTEM_LOGGING_FACILITY */
diff --git a/msvc/ddk_build.cmd b/msvc/ddk_build.cmd
deleted file mode 100644
index bb071e1..0000000
--- a/msvc/ddk_build.cmd
+++ /dev/null
@@ -1,219 +0,0 @@
-@echo off
-::# default builds static library.
-::# you can pass the following arguments (case insensitive):
-::# - "DLL" to build a DLL instead of a static library
-::# - "/MT" to build a static library compatible with MSVC's /MT option (LIBCMT vs MSVCRT)
-
-if Test%BUILD_ALT_DIR%==Test goto usage
-
-::# process commandline parameters
-set TARGET=LIBRARY
-set STATIC_LIBC=
-set version=1.0
-set PWD=%~dp0
-set BUILD_CMD=build /bcwgZ /M2
-
-if "%1" == "" goto no_more_args
-::# /I for case insensitive
-if /I Test%1==TestDLL set TARGET=DYNLINK
-if /I Test%1==Test/MT set STATIC_LIBC=1
-
-:no_more_args
-
-cd ..\libusb\os
-echo TARGETTYPE=%TARGET% > target
-copy target+..\..\msvc\libusb_sources sources >NUL 2>&1
-del target
-@echo on
-%BUILD_CMD%
-@echo off
-if errorlevel 1 goto builderror
-cd ..\..
-
-set cpudir=i386
-set destType=Win32
-if %_BUILDARCH%==x86 goto isI386
-set cpudir=amd64
-set destType=x64
-:isI386
-
-set srcPath=libusb\os\obj%BUILD_ALT_DIR%\%cpudir%
-
-set dstPath=%destType%\Debug
-if %DDKBUILDENV%==chk goto isDebug
-set dstPath=%destType%\Release
-:isDebug
-
-if exist %destType% goto md2
-md %destType%
-:md2
-if exist %dstPath% goto md3
-md %dstPath%
-:md3
-if exist %dstPath%\dll goto md4
-md %dstPath%\dll
-:md4
-if exist %dstPath%\lib goto md5
-md %dstPath%\lib
-:md5
-if exist %dstPath%\examples goto md6
-md %dstPath%\examples
-:md6
-if exist %dstPath%\tests goto md7
-md %dstPath%\tests
-:md7
-@echo on
-
-if %TARGET%==LIBRARY goto copylib
-copy %srcPath%\libusb-%version%.dll %dstPath%\dll
-copy %srcPath%\libusb-%version%.pdb %dstPath%\dll
-:copylib
-copy %srcPath%\libusb-%version%.lib %dstPath%\lib
-
-@echo off
-
-if exist examples\getopt\getopt_ddkbuild goto md8
-md examples\getopt\getopt_ddkbuild
-:md8
-
-cd examples\getopt\getopt_ddkbuild
-copy ..\..\..\msvc\getopt_sources sources >NUL 2>&1
-@echo on
-%BUILD_CMD%
-@echo off
-if errorlevel 1 goto builderror
-cd ..\..\..
-
-if exist examples\fxload_ddkbuild goto md9
-md examples\fxload_ddkbuild
-:md9
-
-cd examples\fxload_ddkbuild
-copy ..\..\msvc\fxload_sources sources >NUL 2>&1
-@echo on
-%BUILD_CMD%
-@echo off
-if errorlevel 1 goto builderror
-cd ..\..
-
-set srcPath=examples\fxload_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir%
-@echo on
-
-copy %srcPath%\fxload.exe %dstPath%\examples
-copy %srcPath%\fxload.pdb %dstPath%\examples
-
-@echo off
-
-if exist examples\hotplugtest_ddkbuild goto md10
-md examples\hotplugtest_ddkbuild
-:md10
-
-cd examples\hotplugtest_ddkbuild
-copy ..\..\msvc\hotplugtest_sources sources >NUL 2>&1
-@echo on
-%BUILD_CMD%
-@echo off
-if errorlevel 1 goto builderror
-cd ..\..
-
-set srcPath=examples\hotplugtest_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir%
-@echo on
-
-copy %srcPath%\hotplugtest.exe %dstPath%\examples
-copy %srcPath%\hotplugtest.pdb %dstPath%\examples
-
-@echo off
-
-if exist examples\listdevs_ddkbuild goto md11
-md examples\listdevs_ddkbuild
-:md11
-
-cd examples\listdevs_ddkbuild
-copy ..\..\msvc\listdevs_sources sources >NUL 2>&1
-@echo on
-%BUILD_CMD%
-@echo off
-if errorlevel 1 goto builderror
-cd ..\..
-
-set srcPath=examples\listdevs_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir%
-@echo on
-
-copy %srcPath%\listdevs.exe %dstPath%\examples
-copy %srcPath%\listdevs.pdb %dstPath%\examples
-
-@echo off
-
-if exist examples\testlibusb_ddkbuild goto md12
-md examples\testlibusb_ddkbuild
-:md12
-
-cd examples\testlibusb_ddkbuild
-copy ..\..\msvc\testlibusb_sources sources >NUL 2>&1
-@echo on
-%BUILD_CMD%
-@echo off
-if errorlevel 1 goto builderror
-cd ..\..
-
-set srcPath=examples\testlibusb_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir%
-@echo on
-
-copy %srcPath%\testlibusb.exe %dstPath%\examples
-copy %srcPath%\testlibusb.pdb %dstPath%\examples
-
-@echo off
-
-if exist examples\xusb_ddkbuild goto md13
-md examples\xusb_ddkbuild
-:md13
-
-cd examples\xusb_ddkbuild
-copy ..\..\msvc\xusb_sources sources >NUL 2>&1
-@echo on
-%BUILD_CMD%
-@echo off
-if errorlevel 1 goto builderror
-cd ..\..
-
-set srcPath=examples\xusb_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir%
-@echo on
-
-copy %srcPath%\xusb.exe %dstPath%\examples
-copy %srcPath%\xusb.pdb %dstPath%\examples
-
-@echo off
-
-if exist tests\stress_ddkbuild goto md14
-md tests\stress_ddkbuild
-:md14
-
-cd tests\stress_ddkbuild
-copy ..\..\msvc\stress_sources sources >NUL 2>&1
-@echo on
-%BUILD_CMD%
-@echo off
-if errorlevel 1 goto builderror
-cd ..\..
-
-set srcPath=tests\stress_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir%
-@echo on
-
-copy %srcPath%\stress.exe %dstPath%\tests
-copy %srcPath%\stress.pdb %dstPath%\tests
-
-@echo off
-
-cd msvc
-goto done
-
-:usage
-echo ddk_build must be run in a WDK build environment
-pause
-goto done
-
-:builderror
-echo Build failed
-
-:done
-cd %PWD%
diff --git a/msvc/hotplugtest_2012.vcxproj b/msvc/dpfp_2013.vcxproj
index 2fe92b8..d9753e7 100644
--- a/msvc/hotplugtest_2012.vcxproj
+++ b/msvc/dpfp_2013.vcxproj
@@ -1,5 +1,5 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@@ -19,8 +19,8 @@
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
- <ProjectName>hotplugtest</ProjectName>
- <ProjectGuid>{99D2AC64-DC66-4422-91CE-6715C403C9E5}</ProjectGuid>
+ <ProjectName>dpfp</ProjectName>
+ <ProjectGuid>{8c7814a1-fd6e-4185-9ea0-8208119756d4}</ProjectGuid>
<RootNamespace>examples</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
@@ -28,7 +28,7 @@
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -45,8 +45,7 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
- <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
@@ -63,16 +62,21 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="..\examples\hotplugtest.c" />
+ <ClCompile Include="..\examples\dpfp.c" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include=".\libusb_static_2012.vcxproj">
+ <ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include=".\libusb_static_2013.vcxproj">
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
@@ -80,4 +84,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/dpfp_2013.vcxproj.filters b/msvc/dpfp_2013.vcxproj.filters
new file mode 100644
index 0000000..6af88cf
--- /dev/null
+++ b/msvc/dpfp_2013.vcxproj.filters
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4fc737f1-c7a5-4376-a066-2a32d752a2ff}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89bd-4b04-88eb-625fbe52ebfb}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\dpfp.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/listdevs_2010.vcxproj b/msvc/dpfp_2015.vcxproj
index 3568b40..0db1a55 100644
--- a/msvc/listdevs_2010.vcxproj
+++ b/msvc/dpfp_2015.vcxproj
@@ -1,5 +1,5 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@@ -19,8 +19,8 @@
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
- <ProjectName>listdevs</ProjectName>
- <ProjectGuid>{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}</ProjectGuid>
+ <ProjectName>dpfp</ProjectName>
+ <ProjectGuid>{8c7814a1-fd6e-4185-9ea0-8208119756d4}</ProjectGuid>
<RootNamespace>examples</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
@@ -28,6 +28,7 @@
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -45,13 +46,12 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <MinimalRebuild>true</MinimalRebuild>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
@@ -62,16 +62,21 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="..\examples\listdevs.c" />
+ <ClCompile Include="..\examples\dpfp.c" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include=".\libusb_static_2010.vcxproj">
+ <ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include=".\libusb_static_2015.vcxproj">
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
@@ -79,4 +84,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/dpfp_2015.vcxproj.filters b/msvc/dpfp_2015.vcxproj.filters
new file mode 100644
index 0000000..6af88cf
--- /dev/null
+++ b/msvc/dpfp_2015.vcxproj.filters
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4fc737f1-c7a5-4376-a066-2a32d752a2ff}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89bd-4b04-88eb-625fbe52ebfb}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\dpfp.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/dpfp_2017.vcxproj b/msvc/dpfp_2017.vcxproj
new file mode 100644
index 0000000..308cd55
--- /dev/null
+++ b/msvc/dpfp_2017.vcxproj
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|ARM64">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM64">
+ <Configuration>Release</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>dpfp</ProjectName>
+ <ProjectGuid>{8c7814a1-fd6e-4185-9ea0-8208119756d4}</ProjectGuid>
+ <RootNamespace>examples</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ <WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
+ <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion Condition="'$(Platform)'=='ARM' Or '$(Platform)'=='ARM64'">10.0.17763.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ <WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <IntDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\$(ProjectName)\</IntDir>
+ <OutDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\</OutDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <WarningLevel>Level3</WarningLevel>
+ </ClCompile>
+ <ClCompile Condition="'$(Configuration)'=='Debug'">
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <Optimization>Disabled</Optimization>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <ClCompile Condition="'$(Configuration)'=='Release'">
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <Link Condition="'$(Configuration)'=='Debug'">
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\dpfp.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include=".\libusb_static_2017.vcxproj">
+ <Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/dpfp_2017.vcxproj.filters b/msvc/dpfp_2017.vcxproj.filters
new file mode 100644
index 0000000..6af88cf
--- /dev/null
+++ b/msvc/dpfp_2017.vcxproj.filters
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4fc737f1-c7a5-4376-a066-2a32d752a2ff}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89bd-4b04-88eb-625fbe52ebfb}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\dpfp.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/dpfp_2019.vcxproj b/msvc/dpfp_2019.vcxproj
new file mode 100644
index 0000000..0fea8bb
--- /dev/null
+++ b/msvc/dpfp_2019.vcxproj
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|ARM64">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM64">
+ <Configuration>Release</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>dpfp</ProjectName>
+ <ProjectGuid>{8c7814a1-fd6e-4185-9ea0-8208119756d4}</ProjectGuid>
+ <RootNamespace>examples</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ <WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
+ <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v142</PlatformToolset>
+ <WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <IntDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\$(ProjectName)\</IntDir>
+ <OutDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\</OutDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <WarningLevel>Level3</WarningLevel>
+ </ClCompile>
+ <ClCompile Condition="'$(Configuration)'=='Debug'">
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <Optimization>Disabled</Optimization>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <ClCompile Condition="'$(Configuration)'=='Release'">
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <Link Condition="'$(Configuration)'=='Debug'">
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\dpfp.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include=".\libusb_static_2019.vcxproj">
+ <Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/dpfp_2019.vcxproj.filters b/msvc/dpfp_2019.vcxproj.filters
new file mode 100644
index 0000000..6af88cf
--- /dev/null
+++ b/msvc/dpfp_2019.vcxproj.filters
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4fc737f1-c7a5-4376-a066-2a32d752a2ff}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89bd-4b04-88eb-625fbe52ebfb}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\dpfp.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/dpfp_threaded_2013.vcxproj b/msvc/dpfp_threaded_2013.vcxproj
new file mode 100644
index 0000000..dfdfc52
--- /dev/null
+++ b/msvc/dpfp_threaded_2013.vcxproj
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>dpfp_threaded</ProjectName>
+ <ProjectGuid>{8c7814a2-fd6e-4185-9ea0-8208119756d4}</ProjectGuid>
+ <RootNamespace>examples</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ <WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <IntDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\$(ProjectName)\</IntDir>
+ <OutDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\</OutDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>DPFP_THREADED;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <WarningLevel>Level3</WarningLevel>
+ </ClCompile>
+ <ClCompile Condition="'$(Configuration)'=='Debug'">
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MinimalRebuild>true</MinimalRebuild>
+ <Optimization>Disabled</Optimization>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <ClCompile Condition="'$(Configuration)'=='Release'">
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <Link Condition="'$(Configuration)'=='Debug'">
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\dpfp.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include=".\libusb_static_2013.vcxproj">
+ <Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/dpfp_threaded_2013.vcxproj.filters b/msvc/dpfp_threaded_2013.vcxproj.filters
new file mode 100644
index 0000000..b97fc29
--- /dev/null
+++ b/msvc/dpfp_threaded_2013.vcxproj.filters
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4fc737f2-c7a5-4376-a066-2a32d752a2ff}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995381-89bd-4b04-88eb-625fbe52ebfb}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\dpfp.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/dpfp_threaded_2015.vcxproj b/msvc/dpfp_threaded_2015.vcxproj
new file mode 100644
index 0000000..84516b4
--- /dev/null
+++ b/msvc/dpfp_threaded_2015.vcxproj
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>dpfp_threaded</ProjectName>
+ <ProjectGuid>{8c7814a2-fd6e-4185-9ea0-8208119756d4}</ProjectGuid>
+ <RootNamespace>examples</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
+ <WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <IntDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\$(ProjectName)\</IntDir>
+ <OutDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\</OutDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>DPFP_THREADED;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <WarningLevel>Level3</WarningLevel>
+ </ClCompile>
+ <ClCompile Condition="'$(Configuration)'=='Debug'">
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <Optimization>Disabled</Optimization>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <ClCompile Condition="'$(Configuration)'=='Release'">
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <Link Condition="'$(Configuration)'=='Debug'">
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\dpfp.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include=".\libusb_static_2015.vcxproj">
+ <Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/dpfp_threaded_2015.vcxproj.filters b/msvc/dpfp_threaded_2015.vcxproj.filters
new file mode 100644
index 0000000..b97fc29
--- /dev/null
+++ b/msvc/dpfp_threaded_2015.vcxproj.filters
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4fc737f2-c7a5-4376-a066-2a32d752a2ff}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995381-89bd-4b04-88eb-625fbe52ebfb}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\dpfp.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/dpfp_threaded_2017.vcxproj b/msvc/dpfp_threaded_2017.vcxproj
new file mode 100644
index 0000000..04f4734
--- /dev/null
+++ b/msvc/dpfp_threaded_2017.vcxproj
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|ARM64">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM64">
+ <Configuration>Release</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>dpfp_threaded</ProjectName>
+ <ProjectGuid>{8c7814a2-fd6e-4185-9ea0-8208119756d4}</ProjectGuid>
+ <RootNamespace>examples</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ <WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
+ <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion Condition="'$(Platform)'=='ARM' Or '$(Platform)'=='ARM64'">10.0.17763.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ <WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <IntDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\$(ProjectName)\</IntDir>
+ <OutDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\</OutDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>DPFP_THREADED;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <WarningLevel>Level3</WarningLevel>
+ </ClCompile>
+ <ClCompile Condition="'$(Configuration)'=='Debug'">
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <Optimization>Disabled</Optimization>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <ClCompile Condition="'$(Configuration)'=='Release'">
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <Link Condition="'$(Configuration)'=='Debug'">
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\dpfp.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include=".\libusb_static_2017.vcxproj">
+ <Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/dpfp_threaded_2017.vcxproj.filters b/msvc/dpfp_threaded_2017.vcxproj.filters
new file mode 100644
index 0000000..b97fc29
--- /dev/null
+++ b/msvc/dpfp_threaded_2017.vcxproj.filters
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4fc737f2-c7a5-4376-a066-2a32d752a2ff}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995381-89bd-4b04-88eb-625fbe52ebfb}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\dpfp.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/fxload_2012.vcxproj b/msvc/dpfp_threaded_2019.vcxproj
index ea83011..27f961a 100644
--- a/msvc/fxload_2012.vcxproj
+++ b/msvc/dpfp_threaded_2019.vcxproj
@@ -1,6 +1,14 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|ARM64">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
@@ -9,6 +17,14 @@
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM64">
+ <Configuration>Release</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
@@ -19,16 +35,19 @@
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
- <ProjectName>fxload</ProjectName>
- <ProjectGuid>{9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}</ProjectGuid>
+ <ProjectName>dpfp_threaded</ProjectName>
+ <ProjectGuid>{8c7814a2-fd6e-4185-9ea0-8208119756d4}</ProjectGuid>
<RootNamespace>examples</RootNamespace>
<Keyword>Win32Proj</Keyword>
+ <WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
+ <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -46,13 +65,12 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>.;..\examples\getopt;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>__GNU_LIBRARY__;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>DPFP_THREADED;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <MinimalRebuild>true</MinimalRebuild>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
@@ -63,24 +81,21 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="..\examples\ezusb.c" />
- <ClCompile Include="..\examples\fxload.c" />
+ <ClCompile Include="..\examples\dpfp.c" />
</ItemGroup>
<ItemGroup>
- <ClInclude Include="..\examples\ezusb.h" />
+ <ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\libusb.h" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include=".\getopt_2012.vcxproj">
- <Project>{ae83e1b4-ce06-47ee-b7a3-c3a1d7c2d71e}</Project>
- <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
- </ProjectReference>
- <ProjectReference Include=".\libusb_static_2012.vcxproj">
+ <ProjectReference Include=".\libusb_static_2019.vcxproj">
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
@@ -88,4 +103,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/dpfp_threaded_2019.vcxproj.filters b/msvc/dpfp_threaded_2019.vcxproj.filters
new file mode 100644
index 0000000..b97fc29
--- /dev/null
+++ b/msvc/dpfp_threaded_2019.vcxproj.filters
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4fc737f2-c7a5-4376-a066-2a32d752a2ff}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995381-89bd-4b04-88eb-625fbe52ebfb}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\dpfp.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/errno.h b/msvc/errno.h
deleted file mode 100644
index 07d15e3..0000000
--- a/msvc/errno.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * errno.h
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is a part of the mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within the package.
- *
- * Error numbers and access to error reporting.
- *
- */
-
-#ifndef _ERRNO_H_
-#define _ERRNO_H_
-
-#include <crtdefs.h>
-
-/*
- * Error numbers.
- * TODO: Can't be sure of some of these assignments, I guessed from the
- * names given by strerror and the defines in the Cygnus errno.h. A lot
- * of the names from the Cygnus errno.h are not represented, and a few
- * of the descriptions returned by strerror do not obviously match
- * their error naming.
- */
-#define EPERM 1 /* Operation not permitted */
-#define ENOFILE 2 /* No such file or directory */
-#define ENOENT 2
-#define ESRCH 3 /* No such process */
-#define EINTR 4 /* Interrupted function call */
-#define EIO 5 /* Input/output error */
-#define ENXIO 6 /* No such device or address */
-#define E2BIG 7 /* Arg list too long */
-#define ENOEXEC 8 /* Exec format error */
-#define EBADF 9 /* Bad file descriptor */
-#define ECHILD 10 /* No child processes */
-#define EAGAIN 11 /* Resource temporarily unavailable */
-#define ENOMEM 12 /* Not enough space */
-#define EACCES 13 /* Permission denied */
-#define EFAULT 14 /* Bad address */
-/* 15 - Unknown Error */
-#define EBUSY 16 /* strerror reports "Resource device" */
-#define EEXIST 17 /* File exists */
-#define EXDEV 18 /* Improper link (cross-device link?) */
-#define ENODEV 19 /* No such device */
-#define ENOTDIR 20 /* Not a directory */
-#define EISDIR 21 /* Is a directory */
-#define EINVAL 22 /* Invalid argument */
-#define ENFILE 23 /* Too many open files in system */
-#define EMFILE 24 /* Too many open files */
-#define ENOTTY 25 /* Inappropriate I/O control operation */
-/* 26 - Unknown Error */
-#define EFBIG 27 /* File too large */
-#define ENOSPC 28 /* No space left on device */
-#define ESPIPE 29 /* Invalid seek (seek on a pipe?) */
-#define EROFS 30 /* Read-only file system */
-#define EMLINK 31 /* Too many links */
-#define EPIPE 32 /* Broken pipe */
-#define EDOM 33 /* Domain error (math functions) */
-#define ERANGE 34 /* Result too large (possibly too small) */
-/* 35 - Unknown Error */
-#define EDEADLOCK 36 /* Resource deadlock avoided (non-Cyg) */
-#define EDEADLK 36
-#if 0
-/* 37 - Unknown Error */
-#define ENAMETOOLONG 38 /* Filename too long (91 in Cyg?) */
-#define ENOLCK 39 /* No locks available (46 in Cyg?) */
-#define ENOSYS 40 /* Function not implemented (88 in Cyg?) */
-#define ENOTEMPTY 41 /* Directory not empty (90 in Cyg?) */
-#define EILSEQ 42 /* Illegal byte sequence */
-#endif
-
-/*
- * NOTE: ENAMETOOLONG and ENOTEMPTY conflict with definitions in the
- * sockets.h header provided with windows32api-0.1.2.
- * You should go and put an #if 0 ... #endif around the whole block
- * of errors (look at the comment above them).
- */
-
-#ifndef RC_INVOKED
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Definitions of errno. For _doserrno, sys_nerr and * sys_errlist, see
- * stdlib.h.
- */
-#if defined(_UWIN) || defined(_WIN32_WCE)
-#undef errno
-extern int errno;
-#else
-_CRTIMP int* __cdecl _errno(void);
-#define errno (*_errno())
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* Not RC_INVOKED */
-
-#endif /* Not _ERRNO_H_ */ \ No newline at end of file
diff --git a/msvc/fxload_2013.vcxproj b/msvc/fxload_2013.vcxproj
index e056546..6b7cebd 100644
--- a/msvc/fxload_2013.vcxproj
+++ b/msvc/fxload_2013.vcxproj
@@ -45,8 +45,7 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
- <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>.;..\examples\getopt;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>.;.\getopt;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>__GNU_LIBRARY__;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
@@ -63,6 +62,7 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -73,7 +73,10 @@
<ClCompile Include="..\examples\fxload.c" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include=".\config.h" />
+ <ClInclude Include=".\getopt\getopt.h" />
<ClInclude Include="..\examples\ezusb.h" />
+ <ClInclude Include="..\libusb\libusb.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include=".\getopt_2013.vcxproj">
@@ -88,4 +91,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/fxload_2013.vcxproj.filters b/msvc/fxload_2013.vcxproj.filters
new file mode 100644
index 0000000..2129604
--- /dev/null
+++ b/msvc/fxload_2013.vcxproj.filters
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{777c7051-d00a-4cb4-9bd0-1c8f843183db}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{1cfdb0a6-840c-4444-a5c3-e3cd508bf25b}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include=".\getopt\getopt.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\examples\ezusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\ezusb.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\examples\fxload.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project>
diff --git a/msvc/fxload_2015.vcxproj b/msvc/fxload_2015.vcxproj
index a6589b5..01c12b3 100644
--- a/msvc/fxload_2015.vcxproj
+++ b/msvc/fxload_2015.vcxproj
@@ -46,13 +46,12 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>.;..\examples\getopt;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>.;.\getopt;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>__GNU_LIBRARY__;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <MinimalRebuild>true</MinimalRebuild>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
@@ -63,6 +62,7 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -73,7 +73,10 @@
<ClCompile Include="..\examples\fxload.c" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include=".\config.h" />
+ <ClInclude Include=".\getopt\getopt.h" />
<ClInclude Include="..\examples\ezusb.h" />
+ <ClInclude Include="..\libusb\libusb.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include=".\getopt_2015.vcxproj">
@@ -88,4 +91,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/fxload_2015.vcxproj.filters b/msvc/fxload_2015.vcxproj.filters
new file mode 100644
index 0000000..2129604
--- /dev/null
+++ b/msvc/fxload_2015.vcxproj.filters
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{777c7051-d00a-4cb4-9bd0-1c8f843183db}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{1cfdb0a6-840c-4444-a5c3-e3cd508bf25b}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include=".\getopt\getopt.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\examples\ezusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\ezusb.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\examples\fxload.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project>
diff --git a/msvc/fxload_2017.vcxproj b/msvc/fxload_2017.vcxproj
index e4e74ab..c8186ef 100644
--- a/msvc/fxload_2017.vcxproj
+++ b/msvc/fxload_2017.vcxproj
@@ -39,9 +39,9 @@
<ProjectGuid>{9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}</ProjectGuid>
<RootNamespace>examples</RootNamespace>
<Keyword>Win32Proj</Keyword>
- <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion Condition="'$(Platform)'=='ARM' Or '$(Platform)'=='ARM64'">10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
@@ -65,13 +65,12 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>.;..\examples\getopt;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>.;.\getopt;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>__GNU_LIBRARY__;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <MinimalRebuild>true</MinimalRebuild>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
@@ -82,13 +81,10 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
@@ -96,7 +92,10 @@
<ClCompile Include="..\examples\fxload.c" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include=".\config.h" />
+ <ClInclude Include=".\getopt\getopt.h" />
<ClInclude Include="..\examples\ezusb.h" />
+ <ClInclude Include="..\libusb\libusb.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include=".\getopt_2017.vcxproj">
diff --git a/msvc/fxload_2017.vcxproj.filters b/msvc/fxload_2017.vcxproj.filters
new file mode 100644
index 0000000..2129604
--- /dev/null
+++ b/msvc/fxload_2017.vcxproj.filters
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{777c7051-d00a-4cb4-9bd0-1c8f843183db}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{1cfdb0a6-840c-4444-a5c3-e3cd508bf25b}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include=".\getopt\getopt.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\examples\ezusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\ezusb.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\examples\fxload.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project>
diff --git a/msvc/fxload_2010.vcxproj b/msvc/fxload_2019.vcxproj
index 7446976..9e32da6 100644
--- a/msvc/fxload_2010.vcxproj
+++ b/msvc/fxload_2019.vcxproj
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|ARM64">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
@@ -9,6 +17,14 @@
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM64">
+ <Configuration>Release</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
@@ -23,11 +39,15 @@
<ProjectGuid>{9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}</ProjectGuid>
<RootNamespace>examples</RootNamespace>
<Keyword>Win32Proj</Keyword>
+ <WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
+ <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -45,13 +65,12 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>.;..\examples\getopt;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>.;.\getopt;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>__GNU_LIBRARY__;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <MinimalRebuild>true</MinimalRebuild>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
@@ -62,6 +81,7 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -72,14 +92,17 @@
<ClCompile Include="..\examples\fxload.c" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include=".\config.h" />
+ <ClInclude Include=".\getopt\getopt.h" />
<ClInclude Include="..\examples\ezusb.h" />
+ <ClInclude Include="..\libusb\libusb.h" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include=".\getopt_2010.vcxproj">
+ <ProjectReference Include=".\getopt_2019.vcxproj">
<Project>{ae83e1b4-ce06-47ee-b7a3-c3a1d7c2d71e}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
- <ProjectReference Include=".\libusb_static_2010.vcxproj">
+ <ProjectReference Include=".\libusb_static_2019.vcxproj">
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
@@ -87,4 +110,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/fxload_2019.vcxproj.filters b/msvc/fxload_2019.vcxproj.filters
new file mode 100644
index 0000000..2129604
--- /dev/null
+++ b/msvc/fxload_2019.vcxproj.filters
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{777c7051-d00a-4cb4-9bd0-1c8f843183db}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{1cfdb0a6-840c-4444-a5c3-e3cd508bf25b}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include=".\getopt\getopt.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\examples\ezusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\ezusb.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\examples\fxload.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project>
diff --git a/msvc/fxload_sources b/msvc/fxload_sources
deleted file mode 100644
index 9f5dbd9..0000000
--- a/msvc/fxload_sources
+++ /dev/null
@@ -1,23 +0,0 @@
-TARGETNAME=fxload
-TARGETTYPE=PROGRAM
-386_STDCALL=0
-
-_NT_TARGET_VERSION=$(_NT_TARGET_VERSION_WINXP)
-
-!IFNDEF MSC_WARNING_LEVEL
-MSC_WARNING_LEVEL=/W3
-!ENDIF
-
-!IFDEF STATIC_LIBC
-USE_LIBCMT=1
-!ELSE
-USE_MSVCRT=1
-!ENDIF
-
-UMTYPE=console
-INCLUDES=..\..\msvc;..\..\libusb;..\getopt;$(DDK_INC_PATH)
-C_DEFINES=$(C_DEFINES) /D__GNU_LIBRARY__
-UMLIBS=..\..\libusb\os\obj$(BUILD_ALT_DIR)\*\libusb-1.0.lib \
- ..\getopt\getopt_ddkbuild\obj$(BUILD_ALT_DIR)\*\getopt.lib
-SOURCES=..\ezusb.c \
- ..\fxload.c
diff --git a/examples/getopt/getopt.c b/msvc/getopt/getopt.c
index b7f26eb..b7f26eb 100644
--- a/examples/getopt/getopt.c
+++ b/msvc/getopt/getopt.c
diff --git a/examples/getopt/getopt.h b/msvc/getopt/getopt.h
index a1b8dd6..a1b8dd6 100644
--- a/examples/getopt/getopt.h
+++ b/msvc/getopt/getopt.h
diff --git a/examples/getopt/getopt1.c b/msvc/getopt/getopt1.c
index 22a7efb..22a7efb 100644
--- a/examples/getopt/getopt1.c
+++ b/msvc/getopt/getopt1.c
diff --git a/msvc/getopt_2005.vcproj b/msvc/getopt_2005.vcproj
deleted file mode 100644
index 0efcb0b..0000000
--- a/msvc/getopt_2005.vcproj
+++ /dev/null
@@ -1,288 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="getopt"
- ProjectGUID="{AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}"
- RootNamespace="getopt"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\lib"
- IntermediateDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\lib\getopt"
- ConfigurationType="4"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions="HAVE_STRING_H;_CRT_SECURE_NO_WARNINGS"
- MinimalRebuild="true"
- RuntimeLibrary="1"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- IgnoreAllDefaultLibraries="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\lib"
- IntermediateDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\lib\getopt"
- ConfigurationType="4"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions="HAVE_STRING_H;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="1"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- IgnoreAllDefaultLibraries="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\lib"
- IntermediateDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\lib\getopt"
- ConfigurationType="4"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- PreprocessorDefinitions="HAVE_STRING_H;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="0"
- WarningLevel="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- IgnoreAllDefaultLibraries="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\lib"
- IntermediateDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\lib\getopt"
- ConfigurationType="4"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- PreprocessorDefinitions="HAVE_STRING_H;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="0"
- WarningLevel="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- IgnoreAllDefaultLibraries="true"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\examples\getopt\getopt.c"
- >
- </File>
- <File
- RelativePath="..\examples\getopt\getopt1.c"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- <File
- RelativePath="..\examples\getopt\getopt.h"
- >
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/msvc/getopt_2010.vcxproj b/msvc/getopt_2010.vcxproj
deleted file mode 100644
index dcea23d..0000000
--- a/msvc/getopt_2010.vcxproj
+++ /dev/null
@@ -1,72 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectName>getopt</ProjectName>
- <ProjectGuid>{AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}</ProjectGuid>
- <RootNamespace>getopt</RootNamespace>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
- <WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <IntDir>$(ProjectDir)..\$(Platform)\$(Configuration)\lib\$(ProjectName)\</IntDir>
- <OutDir>$(ProjectDir)..\$(Platform)\$(Configuration)\lib\</OutDir>
- </PropertyGroup>
- <ItemDefinitionGroup>
- <ClCompile>
- <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>HAVE_STRING_H;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <WarningLevel>Level3</WarningLevel>
- </ClCompile>
- <ClCompile Condition="'$(Configuration)'=='Debug'">
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <Optimization>Disabled</Optimization>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- </ClCompile>
- <ClCompile Condition="'$(Configuration)'=='Release'">
- <Optimization>MaxSpeed</Optimization>
- <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\examples\getopt\getopt.c" />
- <ClCompile Include="..\examples\getopt\getopt1.c" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="..\examples\getopt\getopt.h" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project>
diff --git a/msvc/getopt_2013.vcxproj b/msvc/getopt_2013.vcxproj
index 4024140..daf2d86 100644
--- a/msvc/getopt_2013.vcxproj
+++ b/msvc/getopt_2013.vcxproj
@@ -44,7 +44,6 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
- <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>HAVE_STRING_H;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
@@ -61,13 +60,13 @@
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="..\examples\getopt\getopt.c" />
- <ClCompile Include="..\examples\getopt\getopt1.c" />
+ <ClCompile Include=".\getopt\getopt.c" />
+ <ClCompile Include=".\getopt\getopt1.c" />
</ItemGroup>
<ItemGroup>
- <ClInclude Include="..\examples\getopt\getopt.h" />
+ <ClInclude Include=".\getopt\getopt.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/getopt_2013.vcxproj.filters b/msvc/getopt_2013.vcxproj.filters
new file mode 100644
index 0000000..54416cc
--- /dev/null
+++ b/msvc/getopt_2013.vcxproj.filters
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{ace8a4fb-b016-42e1-ad13-5e813dc2161a}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{fb949e29-22d4-48ec-a6ca-acc76a3caa62}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\getopt\getopt.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include=".\getopt\getopt.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include=".\getopt\getopt1.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/getopt_2015.vcxproj b/msvc/getopt_2015.vcxproj
index 1413ef6..94526b3 100644
--- a/msvc/getopt_2015.vcxproj
+++ b/msvc/getopt_2015.vcxproj
@@ -61,13 +61,13 @@
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="..\examples\getopt\getopt.c" />
- <ClCompile Include="..\examples\getopt\getopt1.c" />
+ <ClCompile Include=".\getopt\getopt.c" />
+ <ClCompile Include=".\getopt\getopt1.c" />
</ItemGroup>
<ItemGroup>
- <ClInclude Include="..\examples\getopt\getopt.h" />
+ <ClInclude Include=".\getopt\getopt.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/getopt_2015.vcxproj.filters b/msvc/getopt_2015.vcxproj.filters
new file mode 100644
index 0000000..54416cc
--- /dev/null
+++ b/msvc/getopt_2015.vcxproj.filters
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{ace8a4fb-b016-42e1-ad13-5e813dc2161a}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{fb949e29-22d4-48ec-a6ca-acc76a3caa62}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\getopt\getopt.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include=".\getopt\getopt.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include=".\getopt\getopt1.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/getopt_2017.vcxproj b/msvc/getopt_2017.vcxproj
index 3d62696..07d9890 100644
--- a/msvc/getopt_2017.vcxproj
+++ b/msvc/getopt_2017.vcxproj
@@ -38,9 +38,9 @@
<ProjectName>getopt</ProjectName>
<ProjectGuid>{AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}</ProjectGuid>
<RootNamespace>getopt</RootNamespace>
- <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion Condition="'$(Platform)'=='ARM' Or '$(Platform)'=='ARM64'">10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
@@ -78,19 +78,13 @@
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
- <Lib>
- <TargetMachine Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MachineX86</TargetMachine>
- </Lib>
- <Lib>
- <TargetMachine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MachineX86</TargetMachine>
- </Lib>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="..\examples\getopt\getopt.c" />
- <ClCompile Include="..\examples\getopt\getopt1.c" />
+ <ClCompile Include=".\getopt\getopt.c" />
+ <ClCompile Include=".\getopt\getopt1.c" />
</ItemGroup>
<ItemGroup>
- <ClInclude Include="..\examples\getopt\getopt.h" />
+ <ClInclude Include=".\getopt\getopt.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/msvc/getopt_2017.vcxproj.filters b/msvc/getopt_2017.vcxproj.filters
new file mode 100644
index 0000000..54416cc
--- /dev/null
+++ b/msvc/getopt_2017.vcxproj.filters
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{ace8a4fb-b016-42e1-ad13-5e813dc2161a}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{fb949e29-22d4-48ec-a6ca-acc76a3caa62}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\getopt\getopt.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include=".\getopt\getopt.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include=".\getopt\getopt1.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/getopt_2012.vcxproj b/msvc/getopt_2019.vcxproj
index d9b2b9d..ff08461 100644
--- a/msvc/getopt_2012.vcxproj
+++ b/msvc/getopt_2019.vcxproj
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|ARM64">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
@@ -9,6 +17,14 @@
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM64">
+ <Configuration>Release</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
@@ -22,12 +38,15 @@
<ProjectName>getopt</ProjectName>
<ProjectGuid>{AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}</ProjectGuid>
<RootNamespace>getopt</RootNamespace>
+ <WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
+ <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -61,13 +80,13 @@
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="..\examples\getopt\getopt.c" />
- <ClCompile Include="..\examples\getopt\getopt1.c" />
+ <ClCompile Include=".\getopt\getopt.c" />
+ <ClCompile Include=".\getopt\getopt1.c" />
</ItemGroup>
<ItemGroup>
- <ClInclude Include="..\examples\getopt\getopt.h" />
+ <ClInclude Include=".\getopt\getopt.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/getopt_2019.vcxproj.filters b/msvc/getopt_2019.vcxproj.filters
new file mode 100644
index 0000000..54416cc
--- /dev/null
+++ b/msvc/getopt_2019.vcxproj.filters
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{ace8a4fb-b016-42e1-ad13-5e813dc2161a}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{fb949e29-22d4-48ec-a6ca-acc76a3caa62}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\getopt\getopt.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include=".\getopt\getopt.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include=".\getopt\getopt1.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/getopt_sources b/msvc/getopt_sources
deleted file mode 100644
index 3f96899..0000000
--- a/msvc/getopt_sources
+++ /dev/null
@@ -1,24 +0,0 @@
-TARGETTYPE=LIBRARY
-TARGETNAME=getopt
-386_STDCALL=0
-
-_NT_TARGET_VERSION=$(_NT_TARGET_VERSION_WINXP)
-
-!IFNDEF MSC_WARNING_LEVEL
-MSC_WARNING_LEVEL=/W3
-!ENDIF
-
-!IFDEF STATIC_LIBC
-USE_LIBCMT=1
-!ELSE
-USE_MSVCRT=1
-!ENDIF
-
-INCLUDES=$(DDK_INC_PATH)
-C_DEFINES=$(C_DEFINES) /DDDKBUILD /DHAVE_STRING_H
-
-TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib \
- $(SDK_LIB_PATH)\user32.lib
-
-SOURCES=..\getopt1.c \
- ..\getopt.c
diff --git a/msvc/hotplugtest_2013.vcxproj b/msvc/hotplugtest_2013.vcxproj
index efbd353..2fad4a7 100644
--- a/msvc/hotplugtest_2013.vcxproj
+++ b/msvc/hotplugtest_2013.vcxproj
@@ -45,8 +45,7 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
- <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
@@ -63,6 +62,7 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -72,6 +72,9 @@
<ClCompile Include="..\examples\hotplugtest.c" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
<ProjectReference Include=".\libusb_static_2013.vcxproj">
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
@@ -80,4 +83,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/hotplugtest_2013.vcxproj.filters b/msvc/hotplugtest_2013.vcxproj.filters
new file mode 100644
index 0000000..6228bd3
--- /dev/null
+++ b/msvc/hotplugtest_2013.vcxproj.filters
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{2499509b-af28-4409-aed1-a0c3cc458288}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{6fa5acdf-d7e4-48e3-a554-9000deb594d1}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\hotplugtest.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/hotplugtest_2015.vcxproj b/msvc/hotplugtest_2015.vcxproj
index ec9773d..9a56aee 100644
--- a/msvc/hotplugtest_2015.vcxproj
+++ b/msvc/hotplugtest_2015.vcxproj
@@ -46,13 +46,12 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <MinimalRebuild>true</MinimalRebuild>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
@@ -63,6 +62,7 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -72,6 +72,9 @@
<ClCompile Include="..\examples\hotplugtest.c" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
<ProjectReference Include=".\libusb_static_2015.vcxproj">
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
@@ -80,4 +83,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/hotplugtest_2015.vcxproj.filters b/msvc/hotplugtest_2015.vcxproj.filters
new file mode 100644
index 0000000..6228bd3
--- /dev/null
+++ b/msvc/hotplugtest_2015.vcxproj.filters
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{2499509b-af28-4409-aed1-a0c3cc458288}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{6fa5acdf-d7e4-48e3-a554-9000deb594d1}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\hotplugtest.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/hotplugtest_2017.vcxproj b/msvc/hotplugtest_2017.vcxproj
index 93061db..ca383d3 100644
--- a/msvc/hotplugtest_2017.vcxproj
+++ b/msvc/hotplugtest_2017.vcxproj
@@ -39,9 +39,9 @@
<ProjectGuid>{99D2AC64-DC66-4422-91CE-6715C403C9E5}</ProjectGuid>
<RootNamespace>examples</RootNamespace>
<Keyword>Win32Proj</Keyword>
- <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion Condition="'$(Platform)'=='ARM' Or '$(Platform)'=='ARM64'">10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
@@ -65,13 +65,12 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <MinimalRebuild>true</MinimalRebuild>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
@@ -82,19 +81,19 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\examples\hotplugtest.c" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
<ProjectReference Include=".\libusb_static_2017.vcxproj">
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
diff --git a/msvc/hotplugtest_2017.vcxproj.filters b/msvc/hotplugtest_2017.vcxproj.filters
new file mode 100644
index 0000000..6228bd3
--- /dev/null
+++ b/msvc/hotplugtest_2017.vcxproj.filters
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{2499509b-af28-4409-aed1-a0c3cc458288}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{6fa5acdf-d7e4-48e3-a554-9000deb594d1}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\hotplugtest.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/hotplugtest_2019.vcxproj b/msvc/hotplugtest_2019.vcxproj
new file mode 100644
index 0000000..d65bb6f
--- /dev/null
+++ b/msvc/hotplugtest_2019.vcxproj
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|ARM64">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM64">
+ <Configuration>Release</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>hotplugtest</ProjectName>
+ <ProjectGuid>{99D2AC64-DC66-4422-91CE-6715C403C9E5}</ProjectGuid>
+ <RootNamespace>examples</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ <WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
+ <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v142</PlatformToolset>
+ <WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <IntDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\$(ProjectName)\</IntDir>
+ <OutDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\</OutDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <WarningLevel>Level3</WarningLevel>
+ </ClCompile>
+ <ClCompile Condition="'$(Configuration)'=='Debug'">
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <Optimization>Disabled</Optimization>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <ClCompile Condition="'$(Configuration)'=='Release'">
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <Link Condition="'$(Configuration)'=='Debug'">
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\hotplugtest.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include=".\libusb_static_2019.vcxproj">
+ <Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/hotplugtest_2019.vcxproj.filters b/msvc/hotplugtest_2019.vcxproj.filters
new file mode 100644
index 0000000..6228bd3
--- /dev/null
+++ b/msvc/hotplugtest_2019.vcxproj.filters
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{2499509b-af28-4409-aed1-a0c3cc458288}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{6fa5acdf-d7e4-48e3-a554-9000deb594d1}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\hotplugtest.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/hotplugtest_sources b/msvc/hotplugtest_sources
deleted file mode 100644
index 0282d95..0000000
--- a/msvc/hotplugtest_sources
+++ /dev/null
@@ -1,20 +0,0 @@
-TARGETNAME=hotplugtest
-TARGETTYPE=PROGRAM
-386_STDCALL=0
-
-_NT_TARGET_VERSION=$(_NT_TARGET_VERSION_WINXP)
-
-!IFNDEF MSC_WARNING_LEVEL
-MSC_WARNING_LEVEL=/W3
-!ENDIF
-
-!IFDEF STATIC_LIBC
-USE_LIBCMT=1
-!ELSE
-USE_MSVCRT=1
-!ENDIF
-
-UMTYPE=console
-INCLUDES=..\..\msvc;..\..\libusb;$(DDK_INC_PATH)
-UMLIBS=..\..\libusb\os\obj$(BUILD_ALT_DIR)\*\libusb-1.0.lib
-SOURCES=..\hotplugtest.c
diff --git a/msvc/inttypes.h b/msvc/inttypes.h
deleted file mode 100644
index 289bb50..0000000
--- a/msvc/inttypes.h
+++ /dev/null
@@ -1,295 +0,0 @@
-/**
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file was original part of the w64 mingw-runtime package.
- */
-
-/*
- * THIS SOFTWARE IS NOT COPYRIGHTED
- *
- * Modified for libusb/MSVC: Pete Batard <pbatard@gmail.com>
- *
- * This source code is offered for use in the public domain. You may
- * use, modify or distribute it freely.
- *
- * This code is distributed in the hope that it will be useful but
- * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
- * DISCLAIMED. This includes but is not limited to warranties of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Date: 2010-04-02
- */
-
-#ifndef _MSC_VER
-#error This header should only be used with Microsoft compilers
-#endif
-
-/* 7.8 Format conversion of integer types <inttypes.h> */
-
-#ifndef _INTTYPES_H_
-#define _INTTYPES_H_
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct {
- intmax_t quot;
- intmax_t rem;
- } imaxdiv_t;
-
-
-/* 7.8.1 Macros for format specifiers
- *
- * MS runtime does not yet understand C9x standard "ll"
- * length specifier. It appears to treat "ll" as "l".
- * The non-standard I64 length specifier causes warning in GCC,
- * but understood by MS runtime functions.
- */
-
-/* fprintf macros for signed types */
-#define PRId8 "d"
-#define PRId16 "d"
-#define PRId32 "d"
-#define PRId64 "I64d"
-
-#define PRIdLEAST8 "d"
-#define PRIdLEAST16 "d"
-#define PRIdLEAST32 "d"
-#define PRIdLEAST64 "I64d"
-
-#define PRIdFAST8 "d"
-#define PRIdFAST16 "d"
-#define PRIdFAST32 "d"
-#define PRIdFAST64 "I64d"
-
-#define PRIdMAX "I64d"
-
-#define PRIi8 "i"
-#define PRIi16 "i"
-#define PRIi32 "i"
-#define PRIi64 "I64i"
-
-#define PRIiLEAST8 "i"
-#define PRIiLEAST16 "i"
-#define PRIiLEAST32 "i"
-#define PRIiLEAST64 "I64i"
-
-#define PRIiFAST8 "i"
-#define PRIiFAST16 "i"
-#define PRIiFAST32 "i"
-#define PRIiFAST64 "I64i"
-
-#define PRIiMAX "I64i"
-
-#define PRIo8 "o"
-#define PRIo16 "o"
-#define PRIo32 "o"
-#define PRIo64 "I64o"
-
-#define PRIoLEAST8 "o"
-#define PRIoLEAST16 "o"
-#define PRIoLEAST32 "o"
-#define PRIoLEAST64 "I64o"
-
-#define PRIoFAST8 "o"
-#define PRIoFAST16 "o"
-#define PRIoFAST32 "o"
-#define PRIoFAST64 "I64o"
-
-#define PRIoMAX "I64o"
-
-/* fprintf macros for unsigned types */
-#define PRIu8 "u"
-#define PRIu16 "u"
-#define PRIu32 "u"
-#define PRIu64 "I64u"
-
-
-#define PRIuLEAST8 "u"
-#define PRIuLEAST16 "u"
-#define PRIuLEAST32 "u"
-#define PRIuLEAST64 "I64u"
-
-#define PRIuFAST8 "u"
-#define PRIuFAST16 "u"
-#define PRIuFAST32 "u"
-#define PRIuFAST64 "I64u"
-
-#define PRIuMAX "I64u"
-
-#define PRIx8 "x"
-#define PRIx16 "x"
-#define PRIx32 "x"
-#define PRIx64 "I64x"
-
-#define PRIxLEAST8 "x"
-#define PRIxLEAST16 "x"
-#define PRIxLEAST32 "x"
-#define PRIxLEAST64 "I64x"
-
-#define PRIxFAST8 "x"
-#define PRIxFAST16 "x"
-#define PRIxFAST32 "x"
-#define PRIxFAST64 "I64x"
-
-#define PRIxMAX "I64x"
-
-#define PRIX8 "X"
-#define PRIX16 "X"
-#define PRIX32 "X"
-#define PRIX64 "I64X"
-
-#define PRIXLEAST8 "X"
-#define PRIXLEAST16 "X"
-#define PRIXLEAST32 "X"
-#define PRIXLEAST64 "I64X"
-
-#define PRIXFAST8 "X"
-#define PRIXFAST16 "X"
-#define PRIXFAST32 "X"
-#define PRIXFAST64 "I64X"
-
-#define PRIXMAX "I64X"
-
-/*
- * fscanf macros for signed int types
- * NOTE: if 32-bit int is used for int_fast8_t and int_fast16_t
- * (see stdint.h, 7.18.1.3), FAST8 and FAST16 should have
- * no length identifiers
- */
-
-#define SCNd16 "hd"
-#define SCNd32 "d"
-#define SCNd64 "I64d"
-
-#define SCNdLEAST16 "hd"
-#define SCNdLEAST32 "d"
-#define SCNdLEAST64 "I64d"
-
-#define SCNdFAST16 "hd"
-#define SCNdFAST32 "d"
-#define SCNdFAST64 "I64d"
-
-#define SCNdMAX "I64d"
-
-#define SCNi16 "hi"
-#define SCNi32 "i"
-#define SCNi64 "I64i"
-
-#define SCNiLEAST16 "hi"
-#define SCNiLEAST32 "i"
-#define SCNiLEAST64 "I64i"
-
-#define SCNiFAST16 "hi"
-#define SCNiFAST32 "i"
-#define SCNiFAST64 "I64i"
-
-#define SCNiMAX "I64i"
-
-#define SCNo16 "ho"
-#define SCNo32 "o"
-#define SCNo64 "I64o"
-
-#define SCNoLEAST16 "ho"
-#define SCNoLEAST32 "o"
-#define SCNoLEAST64 "I64o"
-
-#define SCNoFAST16 "ho"
-#define SCNoFAST32 "o"
-#define SCNoFAST64 "I64o"
-
-#define SCNoMAX "I64o"
-
-#define SCNx16 "hx"
-#define SCNx32 "x"
-#define SCNx64 "I64x"
-
-#define SCNxLEAST16 "hx"
-#define SCNxLEAST32 "x"
-#define SCNxLEAST64 "I64x"
-
-#define SCNxFAST16 "hx"
-#define SCNxFAST32 "x"
-#define SCNxFAST64 "I64x"
-
-#define SCNxMAX "I64x"
-
-/* fscanf macros for unsigned int types */
-
-#define SCNu16 "hu"
-#define SCNu32 "u"
-#define SCNu64 "I64u"
-
-#define SCNuLEAST16 "hu"
-#define SCNuLEAST32 "u"
-#define SCNuLEAST64 "I64u"
-
-#define SCNuFAST16 "hu"
-#define SCNuFAST32 "u"
-#define SCNuFAST64 "I64u"
-
-#define SCNuMAX "I64u"
-
-#ifdef _WIN64
-#define PRIdPTR "I64d"
-#define PRIiPTR "I64i"
-#define PRIoPTR "I64o"
-#define PRIuPTR "I64u"
-#define PRIxPTR "I64x"
-#define PRIXPTR "I64X"
-#define SCNdPTR "I64d"
-#define SCNiPTR "I64i"
-#define SCNoPTR "I64o"
-#define SCNxPTR "I64x"
-#define SCNuPTR "I64u"
-#else
-#define PRIdPTR "d"
-#define PRIiPTR "i"
-#define PRIoPTR "o"
-#define PRIuPTR "u"
-#define PRIxPTR "x"
-#define PRIXPTR "X"
-#define SCNdPTR "d"
-#define SCNiPTR "i"
-#define SCNoPTR "o"
-#define SCNxPTR "x"
- #define SCNuPTR "u"
-#endif
-
-#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-/*
- * no length modifier for char types prior to C9x
- * MS runtime scanf appears to treat "hh" as "h"
- */
-
-/* signed char */
-#define SCNd8 "hhd"
-#define SCNdLEAST8 "hhd"
-#define SCNdFAST8 "hhd"
-
-#define SCNi8 "hhi"
-#define SCNiLEAST8 "hhi"
-#define SCNiFAST8 "hhi"
-
-#define SCNo8 "hho"
-#define SCNoLEAST8 "hho"
-#define SCNoFAST8 "hho"
-
-#define SCNx8 "hhx"
-#define SCNxLEAST8 "hhx"
-#define SCNxFAST8 "hhx"
-
-/* unsigned char */
-#define SCNu8 "hhu"
-#define SCNuLEAST8 "hhu"
-#define SCNuFAST8 "hhu"
-#endif /* __STDC_VERSION__ >= 199901 */
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ndef _INTTYPES_H */
diff --git a/msvc/libusb.dsw b/msvc/libusb.dsw
deleted file mode 100644
index 14569a6..0000000
--- a/msvc/libusb.dsw
+++ /dev/null
@@ -1,71 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "libusb_dll"=".\libusb_dll.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Project: "libusb_static"=".\libusb_static.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Project: "listdevs"=".\listdevs.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
- Begin Project Dependency
- Project_Dep_Name libusb_static
- End Project Dependency
-}}}
-
-###############################################################################
-
-Project: "xusb"=".\xusb.dsp" - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
- Begin Project Dependency
- Project_Dep_Name libusb_static
- End Project Dependency
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/msvc/libusb_2005.sln b/msvc/libusb_2005.sln
deleted file mode 100644
index 135f0b9..0000000
--- a/msvc/libusb_2005.sln
+++ /dev/null
@@ -1,95 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (dll)", "libusb_dll_2005.vcproj", "{8224C054-5968-4238-832C-167155E7ECC3}"
- ProjectSection(WebsiteProperties) = preProject
- Debug.AspNetCompiler.Debug = "True"
- Release.AspNetCompiler.Debug = "False"
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (static)", "libusb_static_2005.vcproj", "{5AB6B770-1925-48D5-ABC2-930F3259C020}"
- ProjectSection(WebsiteProperties) = preProject
- Debug.AspNetCompiler.Debug = "True"
- Release.AspNetCompiler.Debug = "False"
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "listdevs", "listdevs_2005.vcproj", "{98CFD8FA-EE20-40D5-AF13-F8C4856D6CA5}"
- ProjectSection(WebsiteProperties) = preProject
- Debug.AspNetCompiler.Debug = "True"
- Release.AspNetCompiler.Debug = "False"
- EndProjectSection
- ProjectSection(ProjectDependencies) = postProject
- {5AB6B770-1925-48D5-ABC2-930F3259C020} = {5AB6B770-1925-48D5-ABC2-930F3259C020}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stress", "stress_2005.vcproj", "{53942EFF-C810-458D-B3CB-EE5CE9F1E781}"
- ProjectSection(WebsiteProperties) = preProject
- Debug.AspNetCompiler.Debug = "True"
- Release.AspNetCompiler.Debug = "False"
- EndProjectSection
- ProjectSection(ProjectDependencies) = postProject
- {5AB6B770-1925-48D5-ABC2-930F3259C020} = {5AB6B770-1925-48D5-ABC2-930F3259C020}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xusb", "xusb_2005.vcproj", "{08A6FA39-21B7-4A05-9252-2F9864A5E5A4}"
- ProjectSection(WebsiteProperties) = preProject
- Debug.AspNetCompiler.Debug = "True"
- Release.AspNetCompiler.Debug = "False"
- EndProjectSection
- ProjectSection(ProjectDependencies) = postProject
- {5AB6B770-1925-48D5-ABC2-930F3259C020} = {5AB6B770-1925-48D5-ABC2-930F3259C020}
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Debug|x64 = Debug|x64
- Release|Win32 = Release|Win32
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {8224C054-5968-4238-832C-167155E7ECC3}.Debug|Win32.ActiveCfg = Debug|Win32
- {8224C054-5968-4238-832C-167155E7ECC3}.Debug|Win32.Build.0 = Debug|Win32
- {8224C054-5968-4238-832C-167155E7ECC3}.Debug|x64.ActiveCfg = Debug|x64
- {8224C054-5968-4238-832C-167155E7ECC3}.Debug|x64.Build.0 = Debug|x64
- {8224C054-5968-4238-832C-167155E7ECC3}.Release|Win32.ActiveCfg = Release|Win32
- {8224C054-5968-4238-832C-167155E7ECC3}.Release|Win32.Build.0 = Release|Win32
- {8224C054-5968-4238-832C-167155E7ECC3}.Release|x64.ActiveCfg = Release|x64
- {8224C054-5968-4238-832C-167155E7ECC3}.Release|x64.Build.0 = Release|x64
- {5AB6B770-1925-48D5-ABC2-930F3259C020}.Debug|Win32.ActiveCfg = Debug|Win32
- {5AB6B770-1925-48D5-ABC2-930F3259C020}.Debug|Win32.Build.0 = Debug|Win32
- {5AB6B770-1925-48D5-ABC2-930F3259C020}.Debug|x64.ActiveCfg = Debug|x64
- {5AB6B770-1925-48D5-ABC2-930F3259C020}.Debug|x64.Build.0 = Debug|x64
- {5AB6B770-1925-48D5-ABC2-930F3259C020}.Release|Win32.ActiveCfg = Release|Win32
- {5AB6B770-1925-48D5-ABC2-930F3259C020}.Release|Win32.Build.0 = Release|Win32
- {5AB6B770-1925-48D5-ABC2-930F3259C020}.Release|x64.ActiveCfg = Release|x64
- {5AB6B770-1925-48D5-ABC2-930F3259C020}.Release|x64.Build.0 = Release|x64
- {98CFD8FA-EE20-40D5-AF13-F8C4856D6CA5}.Debug|Win32.ActiveCfg = Debug|Win32
- {98CFD8FA-EE20-40D5-AF13-F8C4856D6CA5}.Debug|Win32.Build.0 = Debug|Win32
- {98CFD8FA-EE20-40D5-AF13-F8C4856D6CA5}.Debug|x64.ActiveCfg = Debug|x64
- {98CFD8FA-EE20-40D5-AF13-F8C4856D6CA5}.Debug|x64.Build.0 = Debug|x64
- {98CFD8FA-EE20-40D5-AF13-F8C4856D6CA5}.Release|Win32.ActiveCfg = Release|Win32
- {98CFD8FA-EE20-40D5-AF13-F8C4856D6CA5}.Release|Win32.Build.0 = Release|Win32
- {98CFD8FA-EE20-40D5-AF13-F8C4856D6CA5}.Release|x64.ActiveCfg = Release|x64
- {98CFD8FA-EE20-40D5-AF13-F8C4856D6CA5}.Release|x64.Build.0 = Release|x64
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|Win32.ActiveCfg = Debug|Win32
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|Win32.Build.0 = Debug|Win32
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|x64.ActiveCfg = Debug|x64
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|x64.Build.0 = Debug|x64
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|Win32.ActiveCfg = Release|Win32
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|Win32.Build.0 = Release|Win32
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|x64.ActiveCfg = Release|x64
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|x64.Build.0 = Release|x64
- {08A6FA39-21B7-4A05-9252-2F9864A5E5A4}.Debug|Win32.ActiveCfg = Debug|Win32
- {08A6FA39-21B7-4A05-9252-2F9864A5E5A4}.Debug|Win32.Build.0 = Debug|Win32
- {08A6FA39-21B7-4A05-9252-2F9864A5E5A4}.Debug|x64.ActiveCfg = Debug|x64
- {08A6FA39-21B7-4A05-9252-2F9864A5E5A4}.Debug|x64.Build.0 = Debug|x64
- {08A6FA39-21B7-4A05-9252-2F9864A5E5A4}.Release|Win32.ActiveCfg = Release|Win32
- {08A6FA39-21B7-4A05-9252-2F9864A5E5A4}.Release|Win32.Build.0 = Release|Win32
- {08A6FA39-21B7-4A05-9252-2F9864A5E5A4}.Release|x64.ActiveCfg = Release|x64
- {08A6FA39-21B7-4A05-9252-2F9864A5E5A4}.Release|x64.Build.0 = Release|x64
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/msvc/libusb_2010.sln b/msvc/libusb_2010.sln
deleted file mode 100644
index 8cdcb6a..0000000
--- a/msvc/libusb_2010.sln
+++ /dev/null
@@ -1,105 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fxload", "fxload_2010.vcxproj", "{9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "getopt", "getopt_2010.vcxproj", "{AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hotplugtest", "hotplugtest_2010.vcxproj", "{99D2AC64-DC66-4422-91CE-6715C403C9E5}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (dll)", "libusb_dll_2010.vcxproj", "{349EE8FA-7D25-4909-AAF5-FF3FADE72187}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (static)", "libusb_static_2010.vcxproj", "{349EE8F9-7D25-4909-AAF5-FF3FADE72187}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "listdevs", "listdevs_2010.vcxproj", "{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stress", "stress_2010.vcxproj", "{53942EFF-C810-458D-B3CB-EE5CE9F1E781}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testlibusb", "testlibusb_2010.vcxproj", "{70828935-325B-4749-B381-0E55EF31AEE8}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xusb", "xusb_2010.vcxproj", "{3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Debug|x64 = Debug|x64
- Release|Win32 = Release|Win32
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|Win32.ActiveCfg = Debug|Win32
- {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|Win32.Build.0 = Debug|Win32
- {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|x64.ActiveCfg = Debug|x64
- {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|x64.Build.0 = Debug|x64
- {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|Win32.ActiveCfg = Release|Win32
- {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|Win32.Build.0 = Release|Win32
- {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|x64.ActiveCfg = Release|x64
- {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|x64.Build.0 = Release|x64
- {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|Win32.ActiveCfg = Debug|Win32
- {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|Win32.Build.0 = Debug|Win32
- {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|x64.ActiveCfg = Debug|x64
- {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|x64.Build.0 = Debug|x64
- {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|Win32.ActiveCfg = Release|Win32
- {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|Win32.Build.0 = Release|Win32
- {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|x64.ActiveCfg = Release|x64
- {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|x64.Build.0 = Release|x64
- {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Debug|Win32.ActiveCfg = Debug|Win32
- {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Debug|Win32.Build.0 = Debug|Win32
- {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Debug|x64.ActiveCfg = Debug|x64
- {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Debug|x64.Build.0 = Debug|x64
- {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|Win32.ActiveCfg = Release|Win32
- {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|Win32.Build.0 = Release|Win32
- {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|x64.ActiveCfg = Release|x64
- {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|x64.Build.0 = Release|x64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|Win32.ActiveCfg = Debug|Win32
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|Win32.Build.0 = Debug|Win32
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|x64.ActiveCfg = Debug|x64
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|x64.Build.0 = Debug|x64
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|Win32.ActiveCfg = Release|Win32
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|Win32.Build.0 = Release|Win32
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|x64.ActiveCfg = Release|x64
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|x64.Build.0 = Release|x64
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|Win32.ActiveCfg = Debug|Win32
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|Win32.Build.0 = Debug|Win32
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|x64.ActiveCfg = Debug|x64
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|x64.Build.0 = Debug|x64
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|Win32.ActiveCfg = Release|Win32
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|Win32.Build.0 = Release|Win32
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|x64.ActiveCfg = Release|x64
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|x64.Build.0 = Release|x64
- {70828935-325B-4749-B381-0E55EF31AEE8}.Debug|Win32.ActiveCfg = Debug|Win32
- {70828935-325B-4749-B381-0E55EF31AEE8}.Debug|Win32.Build.0 = Debug|Win32
- {70828935-325B-4749-B381-0E55EF31AEE8}.Debug|x64.ActiveCfg = Debug|x64
- {70828935-325B-4749-B381-0E55EF31AEE8}.Debug|x64.Build.0 = Debug|x64
- {70828935-325B-4749-B381-0E55EF31AEE8}.Release|Win32.ActiveCfg = Release|Win32
- {70828935-325B-4749-B381-0E55EF31AEE8}.Release|Win32.Build.0 = Release|Win32
- {70828935-325B-4749-B381-0E55EF31AEE8}.Release|x64.ActiveCfg = Release|x64
- {70828935-325B-4749-B381-0E55EF31AEE8}.Release|x64.Build.0 = Release|x64
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|Win32.ActiveCfg = Debug|Win32
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|Win32.Build.0 = Debug|Win32
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|x64.ActiveCfg = Debug|x64
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|x64.Build.0 = Debug|x64
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|Win32.ActiveCfg = Release|Win32
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|Win32.Build.0 = Release|Win32
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|x64.ActiveCfg = Release|x64
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|x64.Build.0 = Release|x64
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/msvc/libusb_2012.sln b/msvc/libusb_2012.sln
deleted file mode 100644
index 518d371..0000000
--- a/msvc/libusb_2012.sln
+++ /dev/null
@@ -1,105 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2012
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fxload", "fxload_2012.vcxproj", "{9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "getopt", "getopt_2012.vcxproj", "{AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hotplugtest", "hotplugtest_2012.vcxproj", "{99D2AC64-DC66-4422-91CE-6715C403C9E5}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (dll)", "libusb_dll_2012.vcxproj", "{349EE8FA-7D25-4909-AAF5-FF3FADE72187}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (static)", "libusb_static_2012.vcxproj", "{349EE8F9-7D25-4909-AAF5-FF3FADE72187}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "listdevs", "listdevs_2012.vcxproj", "{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stress", "stress_2012.vcxproj", "{53942EFF-C810-458D-B3CB-EE5CE9F1E781}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testlibusb", "testlibusb_2012.vcxproj", "{70828935-325B-4749-B381-0E55EF31AEE8}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xusb", "xusb_2012.vcxproj", "{3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Debug|x64 = Debug|x64
- Release|Win32 = Release|Win32
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|Win32.ActiveCfg = Debug|Win32
- {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|Win32.Build.0 = Debug|Win32
- {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|x64.ActiveCfg = Debug|x64
- {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|x64.Build.0 = Debug|x64
- {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|Win32.ActiveCfg = Release|Win32
- {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|Win32.Build.0 = Release|Win32
- {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|x64.ActiveCfg = Release|x64
- {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|x64.Build.0 = Release|x64
- {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|Win32.ActiveCfg = Debug|Win32
- {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|Win32.Build.0 = Debug|Win32
- {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|x64.ActiveCfg = Debug|x64
- {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|x64.Build.0 = Debug|x64
- {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|Win32.ActiveCfg = Release|Win32
- {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|Win32.Build.0 = Release|Win32
- {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|x64.ActiveCfg = Release|x64
- {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|x64.Build.0 = Release|x64
- {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Debug|Win32.ActiveCfg = Debug|Win32
- {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Debug|Win32.Build.0 = Debug|Win32
- {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Debug|x64.ActiveCfg = Debug|x64
- {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Debug|x64.Build.0 = Debug|x64
- {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|Win32.ActiveCfg = Release|Win32
- {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|Win32.Build.0 = Release|Win32
- {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|x64.ActiveCfg = Release|x64
- {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|x64.Build.0 = Release|x64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|Win32.ActiveCfg = Debug|Win32
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|Win32.Build.0 = Debug|Win32
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|x64.ActiveCfg = Debug|x64
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|x64.Build.0 = Debug|x64
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|Win32.ActiveCfg = Release|Win32
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|Win32.Build.0 = Release|Win32
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|x64.ActiveCfg = Release|x64
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|x64.Build.0 = Release|x64
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|Win32.ActiveCfg = Debug|Win32
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|Win32.Build.0 = Debug|Win32
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|x64.ActiveCfg = Debug|x64
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|x64.Build.0 = Debug|x64
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|Win32.ActiveCfg = Release|Win32
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|Win32.Build.0 = Release|Win32
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|x64.ActiveCfg = Release|x64
- {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|x64.Build.0 = Release|x64
- {70828935-325B-4749-B381-0E55EF31AEE8}.Debug|Win32.ActiveCfg = Debug|Win32
- {70828935-325B-4749-B381-0E55EF31AEE8}.Debug|Win32.Build.0 = Debug|Win32
- {70828935-325B-4749-B381-0E55EF31AEE8}.Debug|x64.ActiveCfg = Debug|x64
- {70828935-325B-4749-B381-0E55EF31AEE8}.Debug|x64.Build.0 = Debug|x64
- {70828935-325B-4749-B381-0E55EF31AEE8}.Release|Win32.ActiveCfg = Release|Win32
- {70828935-325B-4749-B381-0E55EF31AEE8}.Release|Win32.Build.0 = Release|Win32
- {70828935-325B-4749-B381-0E55EF31AEE8}.Release|x64.ActiveCfg = Release|x64
- {70828935-325B-4749-B381-0E55EF31AEE8}.Release|x64.Build.0 = Release|x64
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|Win32.ActiveCfg = Debug|Win32
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|Win32.Build.0 = Debug|Win32
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|x64.ActiveCfg = Debug|x64
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|x64.Build.0 = Debug|x64
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|Win32.ActiveCfg = Release|Win32
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|Win32.Build.0 = Release|Win32
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|x64.ActiveCfg = Release|x64
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|x64.Build.0 = Release|x64
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/msvc/libusb_2013.sln b/msvc/libusb_2013.sln
index 0b4e9f1..44fca6d 100644
--- a/msvc/libusb_2013.sln
+++ b/msvc/libusb_2013.sln
@@ -2,18 +2,24 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (static)", "libusb_static_2013.vcxproj", "{349EE8F9-7D25-4909-AAF5-FF3FADE72187}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (dll)", "libusb_dll_2013.vcxproj", "{349EE8FA-7D25-4909-AAF5-FF3FADE72187}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dpfp", "dpfp_2013.vcxproj", "{8C7814A1-FD6E-4185-9EA0-8208119756D4}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dpfp_threaded", "dpfp_threaded_2013.vcxproj", "{8C7814A2-FD6E-4185-9EA0-8208119756D4}"
+EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fxload", "fxload_2013.vcxproj", "{9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "getopt", "getopt_2013.vcxproj", "{AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hotplugtest", "hotplugtest_2013.vcxproj", "{99D2AC64-DC66-4422-91CE-6715C403C9E5}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (dll)", "libusb_dll_2013.vcxproj", "{349EE8FA-7D25-4909-AAF5-FF3FADE72187}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (static)", "libusb_static_2013.vcxproj", "{349EE8F9-7D25-4909-AAF5-FF3FADE72187}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "listdevs", "listdevs_2013.vcxproj", "{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sam3u_benchmark", "sam3u_benchmark_2013.vcxproj", "{861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}"
+EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stress", "stress_2013.vcxproj", "{53942EFF-C810-458D-B3CB-EE5CE9F1E781}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testlibusb", "testlibusb_2013.vcxproj", "{70828935-325B-4749-B381-0E55EF31AEE8}"
@@ -28,6 +34,38 @@ Global
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|Win32.Build.0 = Debug|Win32
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|x64.ActiveCfg = Debug|x64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|x64.Build.0 = Debug|x64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|Win32.ActiveCfg = Release|Win32
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|Win32.Build.0 = Release|Win32
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|x64.ActiveCfg = Release|x64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|x64.Build.0 = Release|x64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|Win32.Build.0 = Debug|Win32
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|x64.ActiveCfg = Debug|x64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|x64.Build.0 = Debug|x64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|Win32.ActiveCfg = Release|Win32
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|Win32.Build.0 = Release|Win32
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|x64.ActiveCfg = Release|x64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|x64.Build.0 = Release|x64
{9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|Win32.ActiveCfg = Debug|Win32
{9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|Win32.Build.0 = Debug|Win32
{9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|x64.ActiveCfg = Debug|x64
@@ -52,22 +90,6 @@ Global
{99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|Win32.Build.0 = Release|Win32
{99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|x64.ActiveCfg = Release|x64
{99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|x64.Build.0 = Release|x64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64
{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|Win32.ActiveCfg = Debug|Win32
{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|Win32.Build.0 = Debug|Win32
{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|x64.ActiveCfg = Debug|x64
@@ -76,6 +98,14 @@ Global
{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|Win32.Build.0 = Release|Win32
{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|x64.ActiveCfg = Release|x64
{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|x64.Build.0 = Release|x64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|Win32.ActiveCfg = Debug|Win32
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|Win32.Build.0 = Debug|Win32
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|x64.ActiveCfg = Debug|x64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|x64.Build.0 = Debug|x64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|Win32.ActiveCfg = Release|Win32
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|Win32.Build.0 = Release|Win32
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|x64.ActiveCfg = Release|x64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|x64.Build.0 = Release|x64
{53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|Win32.ActiveCfg = Debug|Win32
{53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|Win32.Build.0 = Debug|Win32
{53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|x64.ActiveCfg = Debug|x64
diff --git a/msvc/libusb_2015.sln b/msvc/libusb_2015.sln
index 3e333ba..8c86639 100644
--- a/msvc/libusb_2015.sln
+++ b/msvc/libusb_2015.sln
@@ -1,19 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
-VisualStudioVersion = 14.0.24720.0
+VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (static)", "libusb_static_2015.vcxproj", "{349EE8F9-7D25-4909-AAF5-FF3FADE72187}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (dll)", "libusb_dll_2015.vcxproj", "{349EE8FA-7D25-4909-AAF5-FF3FADE72187}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dpfp", "dpfp_2015.vcxproj", "{8C7814A1-FD6E-4185-9EA0-8208119756D4}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dpfp_threaded", "dpfp_threaded_2015.vcxproj", "{8C7814A2-FD6E-4185-9EA0-8208119756D4}"
+EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fxload", "fxload_2015.vcxproj", "{9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "getopt", "getopt_2015.vcxproj", "{AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hotplugtest", "hotplugtest_2015.vcxproj", "{99D2AC64-DC66-4422-91CE-6715C403C9E5}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (dll)", "libusb_dll_2015.vcxproj", "{349EE8FA-7D25-4909-AAF5-FF3FADE72187}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (static)", "libusb_static_2015.vcxproj", "{349EE8F9-7D25-4909-AAF5-FF3FADE72187}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "listdevs", "listdevs_2015.vcxproj", "{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sam3u_benchmark", "sam3u_benchmark_2015.vcxproj", "{861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}"
+EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stress", "stress_2015.vcxproj", "{53942EFF-C810-458D-B3CB-EE5CE9F1E781}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testlibusb", "testlibusb_2015.vcxproj", "{70828935-325B-4749-B381-0E55EF31AEE8}"
@@ -28,6 +34,38 @@ Global
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|Win32.Build.0 = Debug|Win32
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|x64.ActiveCfg = Debug|x64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|x64.Build.0 = Debug|x64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|Win32.ActiveCfg = Release|Win32
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|Win32.Build.0 = Release|Win32
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|x64.ActiveCfg = Release|x64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|x64.Build.0 = Release|x64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|Win32.Build.0 = Debug|Win32
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|x64.ActiveCfg = Debug|x64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|x64.Build.0 = Debug|x64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|Win32.ActiveCfg = Release|Win32
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|Win32.Build.0 = Release|Win32
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|x64.ActiveCfg = Release|x64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|x64.Build.0 = Release|x64
{9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|Win32.ActiveCfg = Debug|Win32
{9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|Win32.Build.0 = Debug|Win32
{9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|x64.ActiveCfg = Debug|x64
@@ -52,22 +90,6 @@ Global
{99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|Win32.Build.0 = Release|Win32
{99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|x64.ActiveCfg = Release|x64
{99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|x64.Build.0 = Release|x64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64
{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|Win32.ActiveCfg = Debug|Win32
{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|Win32.Build.0 = Debug|Win32
{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|x64.ActiveCfg = Debug|x64
@@ -76,6 +98,14 @@ Global
{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|Win32.Build.0 = Release|Win32
{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|x64.ActiveCfg = Release|x64
{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|x64.Build.0 = Release|x64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|Win32.ActiveCfg = Debug|Win32
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|Win32.Build.0 = Debug|Win32
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|x64.ActiveCfg = Debug|x64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|x64.Build.0 = Debug|x64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|Win32.ActiveCfg = Release|Win32
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|Win32.Build.0 = Release|Win32
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|x64.ActiveCfg = Release|x64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|x64.Build.0 = Release|x64
{53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|Win32.ActiveCfg = Debug|Win32
{53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|Win32.Build.0 = Debug|Win32
{53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|x64.ActiveCfg = Debug|x64
diff --git a/msvc/libusb_2017.sln b/msvc/libusb_2017.sln
index 63d91d5..3535138 100644
--- a/msvc/libusb_2017.sln
+++ b/msvc/libusb_2017.sln
@@ -2,18 +2,24 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26020.0
MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (static)", "libusb_static_2017.vcxproj", "{349EE8F9-7D25-4909-AAF5-FF3FADE72187}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (dll)", "libusb_dll_2017.vcxproj", "{349EE8FA-7D25-4909-AAF5-FF3FADE72187}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dpfp", "dpfp_2017.vcxproj", "{8C7814A1-FD6E-4185-9EA0-8208119756D4}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dpfp_threaded", "dpfp_threaded_2017.vcxproj", "{8C7814A2-FD6E-4185-9EA0-8208119756D4}"
+EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fxload", "fxload_2017.vcxproj", "{9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "getopt", "getopt_2017.vcxproj", "{AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hotplugtest", "hotplugtest_2017.vcxproj", "{99D2AC64-DC66-4422-91CE-6715C403C9E5}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (dll)", "libusb_dll_2017.vcxproj", "{349EE8FA-7D25-4909-AAF5-FF3FADE72187}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (static)", "libusb_static_2017.vcxproj", "{349EE8F9-7D25-4909-AAF5-FF3FADE72187}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "listdevs", "listdevs_2017.vcxproj", "{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sam3u_benchmark", "sam3u_benchmark_2017.vcxproj", "{861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}"
+EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stress", "stress_2017.vcxproj", "{53942EFF-C810-458D-B3CB-EE5CE9F1E781}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testlibusb", "testlibusb_2017.vcxproj", "{70828935-325B-4749-B381-0E55EF31AEE8}"
@@ -32,6 +38,70 @@ Global
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM.ActiveCfg = Debug|ARM
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM.Build.0 = Debug|ARM
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM64.Build.0 = Debug|ARM64
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|ARM.ActiveCfg = Release|ARM
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|ARM.Build.0 = Release|ARM
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|ARM64.ActiveCfg = Release|ARM64
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|ARM64.Build.0 = Release|ARM64
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM.ActiveCfg = Debug|ARM
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM.Build.0 = Debug|ARM
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM64.Build.0 = Debug|ARM64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|ARM.ActiveCfg = Release|ARM
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|ARM.Build.0 = Release|ARM
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|ARM64.ActiveCfg = Release|ARM64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|ARM64.Build.0 = Release|ARM64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|ARM.ActiveCfg = Debug|ARM
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|ARM.Build.0 = Debug|ARM
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|ARM64.Build.0 = Debug|ARM64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|Win32.Build.0 = Debug|Win32
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|x64.ActiveCfg = Debug|x64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|x64.Build.0 = Debug|x64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|ARM.ActiveCfg = Release|ARM
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|ARM.Build.0 = Release|ARM
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|ARM64.ActiveCfg = Release|ARM64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|ARM64.Build.0 = Release|ARM64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|Win32.ActiveCfg = Release|Win32
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|Win32.Build.0 = Release|Win32
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|x64.ActiveCfg = Release|x64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|x64.Build.0 = Release|x64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|ARM.ActiveCfg = Debug|ARM
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|ARM.Build.0 = Debug|ARM
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|ARM64.Build.0 = Debug|ARM64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|Win32.Build.0 = Debug|Win32
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|x64.ActiveCfg = Debug|x64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|x64.Build.0 = Debug|x64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|ARM.ActiveCfg = Release|ARM
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|ARM.Build.0 = Release|ARM
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|ARM64.ActiveCfg = Release|ARM64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|ARM64.Build.0 = Release|ARM64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|Win32.ActiveCfg = Release|Win32
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|Win32.Build.0 = Release|Win32
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|x64.ActiveCfg = Release|x64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|x64.Build.0 = Release|x64
{9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|ARM.ActiveCfg = Debug|ARM
{9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|ARM.Build.0 = Debug|ARM
{9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|ARM64.ActiveCfg = Debug|ARM64
@@ -80,38 +150,6 @@ Global
{99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|Win32.Build.0 = Release|Win32
{99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|x64.ActiveCfg = Release|x64
{99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|x64.Build.0 = Release|x64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM.ActiveCfg = Debug|ARM
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM.Build.0 = Debug|ARM
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM64.ActiveCfg = Debug|ARM64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM64.Build.0 = Debug|ARM64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|ARM.ActiveCfg = Release|ARM
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|ARM.Build.0 = Release|ARM
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|ARM64.ActiveCfg = Release|ARM64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|ARM64.Build.0 = Release|ARM64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM.ActiveCfg = Debug|ARM
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM.Build.0 = Debug|ARM
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM64.ActiveCfg = Debug|ARM64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM64.Build.0 = Debug|ARM64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|ARM.ActiveCfg = Release|ARM
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|ARM.Build.0 = Release|ARM
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|ARM64.ActiveCfg = Release|ARM64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|ARM64.Build.0 = Release|ARM64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64
{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|ARM.ActiveCfg = Debug|ARM
{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|ARM.Build.0 = Debug|ARM
{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|ARM64.ActiveCfg = Debug|ARM64
@@ -128,6 +166,22 @@ Global
{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|Win32.Build.0 = Release|Win32
{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|x64.ActiveCfg = Release|x64
{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|x64.Build.0 = Release|x64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|ARM.ActiveCfg = Debug|ARM
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|ARM.Build.0 = Debug|ARM
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|ARM64.Build.0 = Debug|ARM64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|Win32.ActiveCfg = Debug|Win32
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|Win32.Build.0 = Debug|Win32
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|x64.ActiveCfg = Debug|x64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|x64.Build.0 = Debug|x64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|ARM.ActiveCfg = Release|ARM
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|ARM.Build.0 = Release|ARM
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|ARM64.ActiveCfg = Release|ARM64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|ARM64.Build.0 = Release|ARM64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|Win32.ActiveCfg = Release|Win32
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|Win32.Build.0 = Release|Win32
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|x64.ActiveCfg = Release|x64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|x64.Build.0 = Release|x64
{53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|ARM.ActiveCfg = Debug|ARM
{53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|ARM.Build.0 = Debug|ARM
{53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|ARM64.ActiveCfg = Debug|ARM64
diff --git a/msvc/libusb_2019.sln b/msvc/libusb_2019.sln
new file mode 100644
index 0000000..0a6a1c4
--- /dev/null
+++ b/msvc/libusb_2019.sln
@@ -0,0 +1,240 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.29709.97
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (static)", "libusb_static_2019.vcxproj", "{349EE8F9-7D25-4909-AAF5-FF3FADE72187}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (dll)", "libusb_dll_2019.vcxproj", "{349EE8FA-7D25-4909-AAF5-FF3FADE72187}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dpfp", "dpfp_2019.vcxproj", "{8C7814A1-FD6E-4185-9EA0-8208119756D4}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dpfp_threaded", "dpfp_threaded_2019.vcxproj", "{8C7814A2-FD6E-4185-9EA0-8208119756D4}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fxload", "fxload_2019.vcxproj", "{9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "getopt", "getopt_2019.vcxproj", "{AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hotplugtest", "hotplugtest_2019.vcxproj", "{99D2AC64-DC66-4422-91CE-6715C403C9E5}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "listdevs", "listdevs_2019.vcxproj", "{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sam3u_benchmark", "sam3u_benchmark_2019.vcxproj", "{861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stress", "stress_2019.vcxproj", "{53942EFF-C810-458D-B3CB-EE5CE9F1E781}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testlibusb", "testlibusb_2019.vcxproj", "{70828935-325B-4749-B381-0E55EF31AEE8}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xusb", "xusb_2019.vcxproj", "{3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|ARM = Debug|ARM
+ Debug|ARM64 = Debug|ARM64
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|ARM = Release|ARM
+ Release|ARM64 = Release|ARM64
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM.ActiveCfg = Debug|ARM
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM.Build.0 = Debug|ARM
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM64.Build.0 = Debug|ARM64
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|ARM.ActiveCfg = Release|ARM
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|ARM.Build.0 = Release|ARM
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|ARM64.ActiveCfg = Release|ARM64
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|ARM64.Build.0 = Release|ARM64
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64
+ {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM.ActiveCfg = Debug|ARM
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM.Build.0 = Debug|ARM
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|ARM64.Build.0 = Debug|ARM64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|ARM.ActiveCfg = Release|ARM
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|ARM.Build.0 = Release|ARM
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|ARM64.ActiveCfg = Release|ARM64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|ARM64.Build.0 = Release|ARM64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64
+ {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|ARM.ActiveCfg = Debug|ARM
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|ARM.Build.0 = Debug|ARM
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|ARM64.Build.0 = Debug|ARM64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|Win32.Build.0 = Debug|Win32
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|x64.ActiveCfg = Debug|x64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Debug|x64.Build.0 = Debug|x64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|ARM.ActiveCfg = Release|ARM
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|ARM.Build.0 = Release|ARM
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|ARM64.ActiveCfg = Release|ARM64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|ARM64.Build.0 = Release|ARM64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|Win32.ActiveCfg = Release|Win32
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|Win32.Build.0 = Release|Win32
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|x64.ActiveCfg = Release|x64
+ {8C7814A1-FD6E-4185-9EA0-8208119756D4}.Release|x64.Build.0 = Release|x64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|ARM.ActiveCfg = Debug|ARM
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|ARM.Build.0 = Debug|ARM
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|ARM64.Build.0 = Debug|ARM64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|Win32.Build.0 = Debug|Win32
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|x64.ActiveCfg = Debug|x64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Debug|x64.Build.0 = Debug|x64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|ARM.ActiveCfg = Release|ARM
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|ARM.Build.0 = Release|ARM
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|ARM64.ActiveCfg = Release|ARM64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|ARM64.Build.0 = Release|ARM64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|Win32.ActiveCfg = Release|Win32
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|Win32.Build.0 = Release|Win32
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|x64.ActiveCfg = Release|x64
+ {8C7814A2-FD6E-4185-9EA0-8208119756D4}.Release|x64.Build.0 = Release|x64
+ {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|ARM.ActiveCfg = Debug|ARM
+ {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|ARM.Build.0 = Debug|ARM
+ {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|ARM64.Build.0 = Debug|ARM64
+ {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|Win32.ActiveCfg = Debug|Win32
+ {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|Win32.Build.0 = Debug|Win32
+ {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|x64.ActiveCfg = Debug|x64
+ {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Debug|x64.Build.0 = Debug|x64
+ {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|ARM.ActiveCfg = Release|ARM
+ {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|ARM.Build.0 = Release|ARM
+ {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|ARM64.ActiveCfg = Release|ARM64
+ {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|ARM64.Build.0 = Release|ARM64
+ {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|Win32.ActiveCfg = Release|Win32
+ {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|Win32.Build.0 = Release|Win32
+ {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|x64.ActiveCfg = Release|x64
+ {9E166F7A-A793-9FB6-0A67-F0AED8AE8C88}.Release|x64.Build.0 = Release|x64
+ {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|ARM.ActiveCfg = Debug|ARM
+ {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|ARM.Build.0 = Debug|ARM
+ {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|ARM64.Build.0 = Debug|ARM64
+ {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|Win32.ActiveCfg = Debug|Win32
+ {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|Win32.Build.0 = Debug|Win32
+ {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|x64.ActiveCfg = Debug|x64
+ {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|x64.Build.0 = Debug|x64
+ {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|ARM.ActiveCfg = Release|ARM
+ {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|ARM.Build.0 = Release|ARM
+ {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|ARM64.ActiveCfg = Release|ARM64
+ {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|ARM64.Build.0 = Release|ARM64
+ {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|Win32.ActiveCfg = Release|Win32
+ {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|Win32.Build.0 = Release|Win32
+ {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|x64.ActiveCfg = Release|x64
+ {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|x64.Build.0 = Release|x64
+ {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Debug|ARM.ActiveCfg = Debug|ARM
+ {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Debug|ARM.Build.0 = Debug|ARM
+ {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Debug|ARM64.Build.0 = Debug|ARM64
+ {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Debug|Win32.ActiveCfg = Debug|Win32
+ {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Debug|Win32.Build.0 = Debug|Win32
+ {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Debug|x64.ActiveCfg = Debug|x64
+ {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Debug|x64.Build.0 = Debug|x64
+ {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|ARM.ActiveCfg = Release|ARM
+ {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|ARM.Build.0 = Release|ARM
+ {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|ARM64.ActiveCfg = Release|ARM64
+ {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|ARM64.Build.0 = Release|ARM64
+ {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|Win32.ActiveCfg = Release|Win32
+ {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|Win32.Build.0 = Release|Win32
+ {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|x64.ActiveCfg = Release|x64
+ {99D2AC64-DC66-4422-91CE-6715C403C9E5}.Release|x64.Build.0 = Release|x64
+ {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|ARM.ActiveCfg = Debug|ARM
+ {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|ARM.Build.0 = Debug|ARM
+ {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|ARM64.Build.0 = Debug|ARM64
+ {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|Win32.ActiveCfg = Debug|Win32
+ {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|Win32.Build.0 = Debug|Win32
+ {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|x64.ActiveCfg = Debug|x64
+ {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|x64.Build.0 = Debug|x64
+ {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|ARM.ActiveCfg = Release|ARM
+ {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|ARM.Build.0 = Release|ARM
+ {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|ARM64.ActiveCfg = Release|ARM64
+ {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|ARM64.Build.0 = Release|ARM64
+ {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|Win32.ActiveCfg = Release|Win32
+ {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|Win32.Build.0 = Release|Win32
+ {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|x64.ActiveCfg = Release|x64
+ {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|x64.Build.0 = Release|x64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|ARM.ActiveCfg = Debug|ARM
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|ARM.Build.0 = Debug|ARM
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|ARM64.Build.0 = Debug|ARM64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|Win32.ActiveCfg = Debug|Win32
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|Win32.Build.0 = Debug|Win32
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|x64.ActiveCfg = Debug|x64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Debug|x64.Build.0 = Debug|x64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|ARM.ActiveCfg = Release|ARM
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|ARM.Build.0 = Release|ARM
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|ARM64.ActiveCfg = Release|ARM64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|ARM64.Build.0 = Release|ARM64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|Win32.ActiveCfg = Release|Win32
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|Win32.Build.0 = Release|Win32
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|x64.ActiveCfg = Release|x64
+ {861CDD5F-59A2-4F34-957E-5C1AF98BE0A4}.Release|x64.Build.0 = Release|x64
+ {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|ARM.ActiveCfg = Debug|ARM
+ {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|ARM.Build.0 = Debug|ARM
+ {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|ARM64.Build.0 = Debug|ARM64
+ {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|Win32.ActiveCfg = Debug|Win32
+ {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|Win32.Build.0 = Debug|Win32
+ {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|x64.ActiveCfg = Debug|x64
+ {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Debug|x64.Build.0 = Debug|x64
+ {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|ARM.ActiveCfg = Release|ARM
+ {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|ARM.Build.0 = Release|ARM
+ {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|ARM64.ActiveCfg = Release|ARM64
+ {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|ARM64.Build.0 = Release|ARM64
+ {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|Win32.ActiveCfg = Release|Win32
+ {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|Win32.Build.0 = Release|Win32
+ {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|x64.ActiveCfg = Release|x64
+ {53942EFF-C810-458D-B3CB-EE5CE9F1E781}.Release|x64.Build.0 = Release|x64
+ {70828935-325B-4749-B381-0E55EF31AEE8}.Debug|ARM.ActiveCfg = Debug|ARM
+ {70828935-325B-4749-B381-0E55EF31AEE8}.Debug|ARM.Build.0 = Debug|ARM
+ {70828935-325B-4749-B381-0E55EF31AEE8}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {70828935-325B-4749-B381-0E55EF31AEE8}.Debug|ARM64.Build.0 = Debug|ARM64
+ {70828935-325B-4749-B381-0E55EF31AEE8}.Debug|Win32.ActiveCfg = Debug|Win32
+ {70828935-325B-4749-B381-0E55EF31AEE8}.Debug|Win32.Build.0 = Debug|Win32
+ {70828935-325B-4749-B381-0E55EF31AEE8}.Debug|x64.ActiveCfg = Debug|x64
+ {70828935-325B-4749-B381-0E55EF31AEE8}.Debug|x64.Build.0 = Debug|x64
+ {70828935-325B-4749-B381-0E55EF31AEE8}.Release|ARM.ActiveCfg = Release|ARM
+ {70828935-325B-4749-B381-0E55EF31AEE8}.Release|ARM.Build.0 = Release|ARM
+ {70828935-325B-4749-B381-0E55EF31AEE8}.Release|ARM64.ActiveCfg = Release|ARM64
+ {70828935-325B-4749-B381-0E55EF31AEE8}.Release|ARM64.Build.0 = Release|ARM64
+ {70828935-325B-4749-B381-0E55EF31AEE8}.Release|Win32.ActiveCfg = Release|Win32
+ {70828935-325B-4749-B381-0E55EF31AEE8}.Release|Win32.Build.0 = Release|Win32
+ {70828935-325B-4749-B381-0E55EF31AEE8}.Release|x64.ActiveCfg = Release|x64
+ {70828935-325B-4749-B381-0E55EF31AEE8}.Release|x64.Build.0 = Release|x64
+ {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|ARM.ActiveCfg = Debug|ARM
+ {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|ARM.Build.0 = Debug|ARM
+ {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|ARM64.Build.0 = Debug|ARM64
+ {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|Win32.ActiveCfg = Debug|Win32
+ {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|Win32.Build.0 = Debug|Win32
+ {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|x64.ActiveCfg = Debug|x64
+ {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|x64.Build.0 = Debug|x64
+ {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|ARM.ActiveCfg = Release|ARM
+ {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|ARM.Build.0 = Release|ARM
+ {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|ARM64.ActiveCfg = Release|ARM64
+ {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|ARM64.Build.0 = Release|ARM64
+ {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|Win32.ActiveCfg = Release|Win32
+ {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|Win32.Build.0 = Release|Win32
+ {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|x64.ActiveCfg = Release|x64
+ {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {AD8203A3-88DD-4212-A273-100DFAD69F6B}
+ EndGlobalSection
+EndGlobal
diff --git a/msvc/libusb_dll.dsp b/msvc/libusb_dll.dsp
deleted file mode 100644
index 4e3d4cb..0000000
--- a/msvc/libusb_dll.dsp
+++ /dev/null
@@ -1,194 +0,0 @@
-# Microsoft Developer Studio Project File - Name="libusb_dll" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=libusb_dll - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "libusb_dll.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "libusb_dll.mak" CFG="libusb_dll - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "libusb_dll - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "libusb_dll - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "libusb_dll - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "../Win32/Release/dll"
-# PROP Intermediate_Dir "../Win32/Release/dll"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "LIBUSB_DLL_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I "../libusb" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /U "_MBCS" /D "_USRDLL" /FR /FD /EHsc /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"Win32/Release/dll/libusb-1.0.dll"
-
-!ELSEIF "$(CFG)" == "libusb_dll - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "../Win32/Debug/dll"
-# PROP Intermediate_Dir "../Win32/Debug/dll"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "LIBUSB_DLL_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /I "../libusb" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /U "_MBCS" /D "_USRDLL" /FR /FD /EHsc /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo /n
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"Win32/Debug/dll/libusb-1.0.dll"
-# SUBTRACT LINK32 /pdb:none /incremental:no
-
-!ENDIF
-
-# Begin Target
-
-# Name "libusb_dll - Win32 Release"
-# Name "libusb_dll - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\libusb\core.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\darwin_usb.c
-# PROP Exclude_From_Build 1
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\descriptor.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\io.c
-# End Source File
-# Begin Source File
-
-SOURCE="..\libusb\libusb-1.0.rc"
-# End Source File
-# Begin Source File
-
-SOURCE="..\libusb\libusb-1.0.def"
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\linux_usbfs.c
-# PROP Exclude_From_Build 1
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\poll_windows.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\sync.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\threads_windows.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\windows_winusb.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\config.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\darwin_usb.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\libusb.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\libusbi.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\linux_usbfs.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\poll_posix.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\poll_windows.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\threads_posix.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\threads_windows.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\windows_winusb.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\windows_common.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/msvc/libusb_dll_2005.vcproj b/msvc/libusb_dll_2005.vcproj
deleted file mode 100644
index 325a4d7..0000000
--- a/msvc/libusb_dll_2005.vcproj
+++ /dev/null
@@ -1,464 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="8.00"
- Name="libusb-1.0 (dll)"
- ProjectGUID="{8224C054-5968-4238-832C-167155E7ECC3}"
- RootNamespace="libusbdll"
- Keyword="Win32Proj"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="..\$(PlatformName)\$(ConfigurationName)\dll"
- IntermediateDirectory="..\$(PlatformName)\$(ConfigurationName)\dll\libusb-1.0"
- ConfigurationType="2"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)\libusb-1.0.dll"
- LinkIncremental="2"
- ModuleDefinitionFile="..\libusb\libusb-1.0.def"
- GenerateDebugInformation="true"
- SubSystem="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="..\$(PlatformName)\$(ConfigurationName)\dll"
- IntermediateDirectory="..\$(PlatformName)\$(ConfigurationName)\dll\libusb-1.0"
- ConfigurationType="2"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)\libusb-1.0.dll"
- LinkIncremental="2"
- ModuleDefinitionFile="..\libusb\libusb-1.0.def"
- GenerateDebugInformation="true"
- SubSystem="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="..\$(PlatformName)\$(ConfigurationName)\dll"
- IntermediateDirectory="..\$(PlatformName)\$(ConfigurationName)\dll\libusb-1.0"
- ConfigurationType="2"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="2"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)\libusb-1.0.dll"
- LinkIncremental="1"
- ModuleDefinitionFile="..\libusb\libusb-1.0.def"
- GenerateDebugInformation="true"
- SubSystem="2"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="..\$(PlatformName)\$(ConfigurationName)\dll"
- IntermediateDirectory="..\$(PlatformName)\$(ConfigurationName)\dll\libusb-1.0"
- ConfigurationType="2"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="2"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)\libusb-1.0.dll"
- LinkIncremental="1"
- ModuleDefinitionFile="..\libusb\libusb-1.0.def"
- GenerateDebugInformation="true"
- SubSystem="2"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\libusb\core.c"
- >
- </File>
- <File
- RelativePath="..\libusb\descriptor.c"
- >
- </File>
- <File
- RelativePath="..\libusb\hotplug.c"
- >
- </File>
- <File
- RelativePath="..\libusb\io.c"
- >
- </File>
- <File
- RelativePath="..\libusb\os\poll_windows.c"
- >
- </File>
- <File
- RelativePath="..\libusb\strerror.c"
- >
- </File>
- <File
- RelativePath="..\libusb\sync.c"
- >
- </File>
- <File
- RelativePath="..\libusb\os\threads_windows.c"
- >
- </File>
- <File
- RelativePath="..\libusb\os\windows_nt_common.c"
- >
- </File>
- <File
- RelativePath="..\libusb\os\windows_usbdk.c"
- >
- </File>
- <File
- RelativePath="..\libusb\os\windows_winusb.c"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- <File
- RelativePath=".\config.h"
- >
- </File>
- <File
- RelativePath="..\libusb\hotplug.h"
- >
- </File>
- <File
- RelativePath="..\libusb\libusb.h"
- >
- </File>
- <File
- RelativePath="..\libusb\libusbi.h"
- >
- </File>
- <File
- RelativePath="..\libusb\os\poll_windows.h"
- >
- </File>
- <File
- RelativePath="..\libusb\os\threads_windows.h"
- >
- </File>
- <File
- RelativePath="..\libusb\version.h"
- >
- </File>
- <File
- RelativePath="..\libusb\version_nano.h"
- >
- </File>
- <File
- RelativePath="..\libusb\os\windows_common.h"
- >
- </File>
- <File
- RelativePath="..\libusb\os\windows_nt_common.h"
- >
- </File>
- <File
- RelativePath="..\libusb\os\windows_nt_shared_types.h"
- >
- </File>
- <File
- RelativePath="..\libusb\os\windows_usbdk.h"
- >
- </File>
- <File
- RelativePath="..\libusb\os\windows_winusb.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
- >
- <File
- RelativePath="..\libusb\libusb-1.0.def"
- >
- </File>
- <File
- RelativePath="..\libusb\libusb-1.0.rc"
- >
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/msvc/libusb_dll_2012.vcxproj b/msvc/libusb_dll_2012.vcxproj
deleted file mode 100644
index 4643c55..0000000
--- a/msvc/libusb_dll_2012.vcxproj
+++ /dev/null
@@ -1,107 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectName>libusb-1.0 (dll)</ProjectName>
- <ProjectGuid>{349EE8FA-7D25-4909-AAF5-FF3FADE72187}</ProjectGuid>
- <RootNamespace>libusbdll</RootNamespace>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v110</PlatformToolset>
- <WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <IntDir>$(ProjectDir)..\$(Platform)\$(Configuration)\dll\$(TargetName)\</IntDir>
- <OutDir>$(ProjectDir)..\$(Platform)\$(Configuration)\dll\</OutDir>
- <TargetName>libusb-1.0</TargetName>
- </PropertyGroup>
- <ItemDefinitionGroup>
- <ClCompile>
- <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WINVER=0x0501;_WIN32_WINNT=0x0501;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <WarningLevel>Level4</WarningLevel>
- </ClCompile>
- <ClCompile Condition="'$(Configuration)'=='Debug'">
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <Optimization>Disabled</Optimization>
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- </ClCompile>
- <ClCompile Condition="'$(Configuration)'=='Release'">
- <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
- </ClCompile>
- <Link>
- <EmbedManagedResourceFile>libusb-1.0.rc;%(EmbedManagedResourceFile)</EmbedManagedResourceFile>
- <ModuleDefinitionFile>..\libusb\libusb-1.0.def</ModuleDefinitionFile>
- </Link>
- <Link Condition="'$(Configuration)'=='Debug'">
- <GenerateDebugInformation>true</GenerateDebugInformation>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\libusb\core.c" />
- <ClCompile Include="..\libusb\descriptor.c" />
- <ClCompile Include="..\libusb\hotplug.c" />
- <ClCompile Include="..\libusb\io.c" />
- <ClCompile Include="..\libusb\os\poll_windows.c" />
- <ClCompile Include="..\libusb\strerror.c" />
- <ClCompile Include="..\libusb\sync.c" />
- <ClCompile Include="..\libusb\os\threads_windows.c" />
- <ClCompile Include="..\libusb\os\windows_nt_common.c" />
- <ClCompile Include="..\libusb\os\windows_usbdk.c" />
- <ClCompile Include="..\libusb\os\windows_winusb.c" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include=".\config.h" />
- <ClInclude Include="..\libusb\hotplug.h" />
- <ClInclude Include="..\libusb\libusb.h" />
- <ClInclude Include="..\libusb\libusbi.h" />
- <ClInclude Include="..\libusb\os\poll_windows.h" />
- <ClInclude Include="..\libusb\os\threads_windows.h" />
- <ClInclude Include="..\libusb\version.h" />
- <ClInclude Include="..\libusb\version_nano.h" />
- <ClInclude Include="..\libusb\os\windows_common.h" />
- <ClInclude Include="..\libusb\os\windows_nt_common.h" />
- <ClInclude Include="..\libusb\os\windows_nt_shared_types.h" />
- <ClInclude Include="..\libusb\os\windows_usbdk.h" />
- <ClInclude Include="..\libusb\os\windows_winusb.h" />
- </ItemGroup>
- <ItemGroup>
- <None Include="..\libusb\libusb-1.0.def" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="..\libusb\libusb-1.0.rc" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project>
diff --git a/msvc/libusb_dll_2013.vcxproj b/msvc/libusb_dll_2013.vcxproj
index d37b486..56ffd75 100644
--- a/msvc/libusb_dll_2013.vcxproj
+++ b/msvc/libusb_dll_2013.vcxproj
@@ -45,9 +45,8 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
- <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WINVER=0x0501;_WIN32_WINNT=0x0501;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>_WIN32_WINNT=_WIN32_WINNT_VISTA;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level4</WarningLevel>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
@@ -62,6 +61,7 @@
<Link>
<EmbedManagedResourceFile>libusb-1.0.rc;%(EmbedManagedResourceFile)</EmbedManagedResourceFile>
<ModuleDefinitionFile>..\libusb\libusb-1.0.def</ModuleDefinitionFile>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -70,28 +70,26 @@
<ItemGroup>
<ClCompile Include="..\libusb\core.c" />
<ClCompile Include="..\libusb\descriptor.c" />
+ <ClCompile Include="..\libusb\os\events_windows.c" />
<ClCompile Include="..\libusb\hotplug.c" />
<ClCompile Include="..\libusb\io.c" />
- <ClCompile Include="..\libusb\os\poll_windows.c" />
<ClCompile Include="..\libusb\strerror.c" />
<ClCompile Include="..\libusb\sync.c" />
<ClCompile Include="..\libusb\os\threads_windows.c" />
- <ClCompile Include="..\libusb\os\windows_nt_common.c" />
+ <ClCompile Include="..\libusb\os\windows_common.c" />
<ClCompile Include="..\libusb\os\windows_usbdk.c" />
<ClCompile Include="..\libusb\os\windows_winusb.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\os\events_windows.h" />
<ClInclude Include="..\libusb\hotplug.h" />
<ClInclude Include="..\libusb\libusb.h" />
<ClInclude Include="..\libusb\libusbi.h" />
- <ClInclude Include="..\libusb\os\poll_windows.h" />
<ClInclude Include="..\libusb\os\threads_windows.h" />
<ClInclude Include="..\libusb\version.h" />
<ClInclude Include="..\libusb\version_nano.h" />
<ClInclude Include="..\libusb\os\windows_common.h" />
- <ClInclude Include="..\libusb\os\windows_nt_common.h" />
- <ClInclude Include="..\libusb\os\windows_nt_shared_types.h" />
<ClInclude Include="..\libusb\os\windows_usbdk.h" />
<ClInclude Include="..\libusb\os\windows_winusb.h" />
</ItemGroup>
@@ -104,4 +102,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/libusb_dll_2013.vcxproj.filters b/msvc/libusb_dll_2013.vcxproj.filters
new file mode 100644
index 0000000..8da28e3
--- /dev/null
+++ b/msvc/libusb_dll_2013.vcxproj.filters
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{b331c0a5-4768-422a-9194-b30409d686f1}</UniqueIdentifier>
+ <Extensions>c;def</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{2a88dc3a-a289-444d-8a31-5fc2f7b1a9ad}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{56507e4d-3872-49b5-b9b1-e49829611792}</UniqueIdentifier>
+ <Extensions>rc</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\events_windows.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\hotplug.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusbi.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\threads_windows.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\version_nano.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_common.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_usbdk.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_winusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="..\libusb\libusb-1.0.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\libusb\core.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\descriptor.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\events_windows.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\hotplug.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\io.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\strerror.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\sync.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\threads_windows.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_common.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_usbdk.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_winusb.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="..\libusb\libusb-1.0.def">
+ <Filter>Source Files</Filter>
+ </None>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/libusb_dll_2015.vcxproj b/msvc/libusb_dll_2015.vcxproj
index 3e6bb8a..d2c850d 100644
--- a/msvc/libusb_dll_2015.vcxproj
+++ b/msvc/libusb_dll_2015.vcxproj
@@ -47,7 +47,7 @@
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WINVER=0x0501;_WIN32_WINNT=0x0501;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>_WIN32_WINNT=_WIN32_WINNT_VISTA;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level4</WarningLevel>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
@@ -62,6 +62,7 @@
<Link>
<EmbedManagedResourceFile>libusb-1.0.rc;%(EmbedManagedResourceFile)</EmbedManagedResourceFile>
<ModuleDefinitionFile>..\libusb\libusb-1.0.def</ModuleDefinitionFile>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -70,28 +71,26 @@
<ItemGroup>
<ClCompile Include="..\libusb\core.c" />
<ClCompile Include="..\libusb\descriptor.c" />
+ <ClCompile Include="..\libusb\os\events_windows.c" />
<ClCompile Include="..\libusb\hotplug.c" />
<ClCompile Include="..\libusb\io.c" />
- <ClCompile Include="..\libusb\os\poll_windows.c" />
<ClCompile Include="..\libusb\strerror.c" />
<ClCompile Include="..\libusb\sync.c" />
<ClCompile Include="..\libusb\os\threads_windows.c" />
- <ClCompile Include="..\libusb\os\windows_nt_common.c" />
+ <ClCompile Include="..\libusb\os\windows_common.c" />
<ClCompile Include="..\libusb\os\windows_usbdk.c" />
<ClCompile Include="..\libusb\os\windows_winusb.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\os\events_windows.h" />
<ClInclude Include="..\libusb\hotplug.h" />
<ClInclude Include="..\libusb\libusb.h" />
<ClInclude Include="..\libusb\libusbi.h" />
- <ClInclude Include="..\libusb\os\poll_windows.h" />
<ClInclude Include="..\libusb\os\threads_windows.h" />
<ClInclude Include="..\libusb\version.h" />
<ClInclude Include="..\libusb\version_nano.h" />
<ClInclude Include="..\libusb\os\windows_common.h" />
- <ClInclude Include="..\libusb\os\windows_nt_common.h" />
- <ClInclude Include="..\libusb\os\windows_nt_shared_types.h" />
<ClInclude Include="..\libusb\os\windows_usbdk.h" />
<ClInclude Include="..\libusb\os\windows_winusb.h" />
</ItemGroup>
@@ -104,4 +103,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/libusb_dll_2015.vcxproj.filters b/msvc/libusb_dll_2015.vcxproj.filters
new file mode 100644
index 0000000..8da28e3
--- /dev/null
+++ b/msvc/libusb_dll_2015.vcxproj.filters
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{b331c0a5-4768-422a-9194-b30409d686f1}</UniqueIdentifier>
+ <Extensions>c;def</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{2a88dc3a-a289-444d-8a31-5fc2f7b1a9ad}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{56507e4d-3872-49b5-b9b1-e49829611792}</UniqueIdentifier>
+ <Extensions>rc</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\events_windows.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\hotplug.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusbi.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\threads_windows.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\version_nano.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_common.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_usbdk.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_winusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="..\libusb\libusb-1.0.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\libusb\core.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\descriptor.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\events_windows.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\hotplug.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\io.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\strerror.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\sync.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\threads_windows.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_common.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_usbdk.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_winusb.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="..\libusb\libusb-1.0.def">
+ <Filter>Source Files</Filter>
+ </None>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/libusb_dll_2017.vcxproj b/msvc/libusb_dll_2017.vcxproj
index 33c7aa7..598159d 100644
--- a/msvc/libusb_dll_2017.vcxproj
+++ b/msvc/libusb_dll_2017.vcxproj
@@ -38,9 +38,9 @@
<ProjectName>libusb-1.0 (dll)</ProjectName>
<ProjectGuid>{349EE8FA-7D25-4909-AAF5-FF3FADE72187}</ProjectGuid>
<RootNamespace>libusbdll</RootNamespace>
- <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion Condition="'$(Platform)'=='ARM' Or '$(Platform)'=='ARM64'">10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
@@ -66,7 +66,7 @@
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WINVER=0x0501;_WIN32_WINNT=0x0501;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>_WIN32_WINNT=_WIN32_WINNT_VISTA;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level4</WarningLevel>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
@@ -81,44 +81,35 @@
<Link>
<EmbedManagedResourceFile>libusb-1.0.rc;%(EmbedManagedResourceFile)</EmbedManagedResourceFile>
<ModuleDefinitionFile>..\libusb\libusb-1.0.def</ModuleDefinitionFile>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">kernel32.lib;user32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">kernel32.lib;user32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">kernel32.lib;user32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|x64'">kernel32.lib;user32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">kernel32.lib;user32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">kernel32.lib;user32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">kernel32.lib;user32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">kernel32.lib;user32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\libusb\core.c" />
<ClCompile Include="..\libusb\descriptor.c" />
+ <ClCompile Include="..\libusb\os\events_windows.c" />
<ClCompile Include="..\libusb\hotplug.c" />
<ClCompile Include="..\libusb\io.c" />
- <ClCompile Include="..\libusb\os\poll_windows.c" />
<ClCompile Include="..\libusb\strerror.c" />
<ClCompile Include="..\libusb\sync.c" />
<ClCompile Include="..\libusb\os\threads_windows.c" />
- <ClCompile Include="..\libusb\os\windows_nt_common.c" />
+ <ClCompile Include="..\libusb\os\windows_common.c" />
<ClCompile Include="..\libusb\os\windows_usbdk.c" />
<ClCompile Include="..\libusb\os\windows_winusb.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\os\events_windows.h" />
<ClInclude Include="..\libusb\hotplug.h" />
<ClInclude Include="..\libusb\libusb.h" />
<ClInclude Include="..\libusb\libusbi.h" />
- <ClInclude Include="..\libusb\os\poll_windows.h" />
<ClInclude Include="..\libusb\os\threads_windows.h" />
<ClInclude Include="..\libusb\version.h" />
<ClInclude Include="..\libusb\version_nano.h" />
<ClInclude Include="..\libusb\os\windows_common.h" />
- <ClInclude Include="..\libusb\os\windows_nt_common.h" />
- <ClInclude Include="..\libusb\os\windows_nt_shared_types.h" />
<ClInclude Include="..\libusb\os\windows_usbdk.h" />
<ClInclude Include="..\libusb\os\windows_winusb.h" />
</ItemGroup>
diff --git a/msvc/libusb_dll_2017.vcxproj.filters b/msvc/libusb_dll_2017.vcxproj.filters
new file mode 100644
index 0000000..8da28e3
--- /dev/null
+++ b/msvc/libusb_dll_2017.vcxproj.filters
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{b331c0a5-4768-422a-9194-b30409d686f1}</UniqueIdentifier>
+ <Extensions>c;def</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{2a88dc3a-a289-444d-8a31-5fc2f7b1a9ad}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{56507e4d-3872-49b5-b9b1-e49829611792}</UniqueIdentifier>
+ <Extensions>rc</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\events_windows.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\hotplug.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusbi.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\threads_windows.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\version_nano.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_common.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_usbdk.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_winusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="..\libusb\libusb-1.0.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\libusb\core.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\descriptor.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\events_windows.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\hotplug.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\io.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\strerror.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\sync.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\threads_windows.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_common.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_usbdk.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_winusb.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="..\libusb\libusb-1.0.def">
+ <Filter>Source Files</Filter>
+ </None>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/libusb_dll_2010.vcxproj b/msvc/libusb_dll_2019.vcxproj
index 79768e5..dbd8717 100644
--- a/msvc/libusb_dll_2010.vcxproj
+++ b/msvc/libusb_dll_2019.vcxproj
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|ARM64">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
@@ -9,6 +17,14 @@
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM64">
+ <Configuration>Release</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
@@ -22,11 +38,15 @@
<ProjectName>libusb-1.0 (dll)</ProjectName>
<ProjectGuid>{349EE8FA-7D25-4909-AAF5-FF3FADE72187}</ProjectGuid>
<RootNamespace>libusbdll</RootNamespace>
+ <WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
+ <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -46,7 +66,7 @@
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WINVER=0x0501;_WIN32_WINNT=0x0501;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>_WIN32_WINNT=_WIN32_WINNT_VISTA;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level4</WarningLevel>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
@@ -61,6 +81,7 @@
<Link>
<EmbedManagedResourceFile>libusb-1.0.rc;%(EmbedManagedResourceFile)</EmbedManagedResourceFile>
<ModuleDefinitionFile>..\libusb\libusb-1.0.def</ModuleDefinitionFile>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -69,28 +90,26 @@
<ItemGroup>
<ClCompile Include="..\libusb\core.c" />
<ClCompile Include="..\libusb\descriptor.c" />
+ <ClCompile Include="..\libusb\os\events_windows.c" />
<ClCompile Include="..\libusb\hotplug.c" />
<ClCompile Include="..\libusb\io.c" />
- <ClCompile Include="..\libusb\os\poll_windows.c" />
<ClCompile Include="..\libusb\strerror.c" />
<ClCompile Include="..\libusb\sync.c" />
<ClCompile Include="..\libusb\os\threads_windows.c" />
- <ClCompile Include="..\libusb\os\windows_nt_common.c" />
+ <ClCompile Include="..\libusb\os\windows_common.c" />
<ClCompile Include="..\libusb\os\windows_usbdk.c" />
<ClCompile Include="..\libusb\os\windows_winusb.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\os\events_windows.h" />
<ClInclude Include="..\libusb\hotplug.h" />
<ClInclude Include="..\libusb\libusb.h" />
<ClInclude Include="..\libusb\libusbi.h" />
- <ClInclude Include="..\libusb\os\poll_windows.h" />
<ClInclude Include="..\libusb\os\threads_windows.h" />
<ClInclude Include="..\libusb\version.h" />
<ClInclude Include="..\libusb\version_nano.h" />
<ClInclude Include="..\libusb\os\windows_common.h" />
- <ClInclude Include="..\libusb\os\windows_nt_common.h" />
- <ClInclude Include="..\libusb\os\windows_nt_shared_types.h" />
<ClInclude Include="..\libusb\os\windows_usbdk.h" />
<ClInclude Include="..\libusb\os\windows_winusb.h" />
</ItemGroup>
@@ -103,4 +122,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/libusb_dll_2019.vcxproj.filters b/msvc/libusb_dll_2019.vcxproj.filters
new file mode 100644
index 0000000..8da28e3
--- /dev/null
+++ b/msvc/libusb_dll_2019.vcxproj.filters
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{b331c0a5-4768-422a-9194-b30409d686f1}</UniqueIdentifier>
+ <Extensions>c;def</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{2a88dc3a-a289-444d-8a31-5fc2f7b1a9ad}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{56507e4d-3872-49b5-b9b1-e49829611792}</UniqueIdentifier>
+ <Extensions>rc</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\events_windows.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\hotplug.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusbi.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\threads_windows.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\version_nano.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_common.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_usbdk.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_winusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="..\libusb\libusb-1.0.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\libusb\core.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\descriptor.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\events_windows.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\hotplug.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\io.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\strerror.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\sync.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\threads_windows.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_common.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_usbdk.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_winusb.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="..\libusb\libusb-1.0.def">
+ <Filter>Source Files</Filter>
+ </None>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/libusb_dll_wince.vcproj b/msvc/libusb_dll_wince.vcproj
deleted file mode 100644
index f365ba3..0000000
--- a/msvc/libusb_dll_wince.vcproj
+++ /dev/null
@@ -1,1251 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="8.00"
- Name="libusb-1.0 (dll)"
- ProjectGUID="{6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}"
- RootNamespace="libusb"
- >
- <Platforms>
- <Platform
- Name="STANDARDSDK_500 (ARMV4I)"
- />
- <Platform
- Name="STANDARDSDK_500 (MIPSII)"
- />
- <Platform
- Name="STANDARDSDK_500 (MIPSII_FP)"
- />
- <Platform
- Name="STANDARDSDK_500 (MIPSIV)"
- />
- <Platform
- Name="STANDARDSDK_500 (MIPSIV_FP)"
- />
- <Platform
- Name="STANDARDSDK_500 (SH4)"
- />
- <Platform
- Name="STANDARDSDK_500 (x86)"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|STANDARDSDK_500 (ARMV4I)"
- OutputDirectory="$(SolutionDir)..\ARMV4I\$(ConfigurationName)\dll"
- IntermediateDirectory="$(SolutionDir)..\ARMV4I\$(ConfigurationName)\dll\libusb-1.0"
- ConfigurationType="2"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_USRDLL;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- ForcedIncludeFiles=""
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)\libusb-1.0.dll"
- ModuleDefinitionFile="../libusb/libusb-1.0.def"
- GenerateDebugInformation="true"
- SubSystem="9"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory="%CSIDL_PROGRAM_FILES%\lsusb"
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (MIPSII)"
- OutputDirectory="$(SolutionDir)..\MIPSII\$(ConfigurationName)\dll"
- IntermediateDirectory="$(SolutionDir)..\MIPSII\$(ConfigurationName)\dll\libusb-1.0"
- ConfigurationType="2"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_USRDLL;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)\libusb-1.0.dll"
- ModuleDefinitionFile="../libusb/libusb-1.0.def"
- GenerateDebugInformation="true"
- SubSystem="9"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (MIPSII_FP)"
- OutputDirectory="$(SolutionDir)..\MIPSII_FP\$(ConfigurationName)\dll"
- IntermediateDirectory="$(SolutionDir)..\MIPSII_FP\$(ConfigurationName)\dll\libusb-1.0"
- ConfigurationType="2"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_USRDLL;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)\libusb-1.0.dll"
- ModuleDefinitionFile="../libusb/libusb-1.0.def"
- GenerateDebugInformation="true"
- SubSystem="9"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (MIPSIV)"
- OutputDirectory="$(SolutionDir)..\MIPSIV\$(ConfigurationName)\dll"
- IntermediateDirectory="$(SolutionDir)..\MIPSIV\$(ConfigurationName)\dll\libusb-1.0"
- ConfigurationType="2"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_USRDLL;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)\libusb-1.0.dll"
- ModuleDefinitionFile="../libusb/libusb-1.0.def"
- GenerateDebugInformation="true"
- SubSystem="9"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (MIPSIV_FP)"
- OutputDirectory="$(SolutionDir)..\MIPSIV_FP\$(ConfigurationName)\dll"
- IntermediateDirectory="$(SolutionDir)..\MIPSIV_FP\$(ConfigurationName)\dll\libusb-1.0"
- ConfigurationType="2"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_USRDLL;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)\libusb-1.0.dll"
- ModuleDefinitionFile="../libusb/libusb-1.0.def"
- GenerateDebugInformation="true"
- SubSystem="9"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (SH4)"
- OutputDirectory="$(SolutionDir)..\SH4\$(ConfigurationName)\dll"
- IntermediateDirectory="$(SolutionDir)..\SH4\$(ConfigurationName)\dll\libusb-1.0"
- ConfigurationType="2"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_USRDLL;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)\libusb-1.0.dll"
- ModuleDefinitionFile="../libusb/libusb-1.0.def"
- GenerateDebugInformation="true"
- SubSystem="9"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (x86)"
- OutputDirectory="$(SolutionDir)..\x86\$(ConfigurationName)\dll"
- IntermediateDirectory="$(SolutionDir)..\x86\$(ConfigurationName)\dll\libusb-1.0"
- ConfigurationType="2"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_USRDLL;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)\libusb-1.0.dll"
- IgnoreDefaultLibraryNames="oldnames.lib,libc.lib"
- ModuleDefinitionFile="../libusb/libusb-1.0.def"
- GenerateDebugInformation="true"
- SubSystem="9"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (ARMV4I)"
- OutputDirectory="$(SolutionDir)..\ARMV4I\$(ConfigurationName)\dll"
- IntermediateDirectory="$(SolutionDir)..\ARMV4I\$(ConfigurationName)\dll\libusb-1.0"
- ConfigurationType="2"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_USRDLL;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)\libusb-1.0.dll"
- ModuleDefinitionFile="../libusb/libusb-1.0.def"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (MIPSII)"
- OutputDirectory="$(SolutionDir)..\MIPSII\$(ConfigurationName)\dll"
- IntermediateDirectory="$(SolutionDir)..\MIPSII\$(ConfigurationName)\dll\libusb-1.0"
- ConfigurationType="2"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_USRDLL;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)\libusb-1.0.dll"
- ModuleDefinitionFile="../libusb/libusb-1.0.def"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (MIPSII_FP)"
- OutputDirectory="$(SolutionDir)..\MIPSII_FP\$(ConfigurationName)\dll"
- IntermediateDirectory="$(SolutionDir)..\MIPSII_FP\$(ConfigurationName)\dll\libusb-1.0"
- ConfigurationType="2"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_USRDLL;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)\libusb-1.0.dll"
- ModuleDefinitionFile="../libusb/libusb-1.0.def"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (MIPSIV)"
- OutputDirectory="$(SolutionDir)..\MIPSIV\$(ConfigurationName)\dll"
- IntermediateDirectory="$(SolutionDir)..\MIPSIV\$(ConfigurationName)\dll\libusb-1.0"
- ConfigurationType="2"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_USRDLL;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)\libusb-1.0.dll"
- ModuleDefinitionFile="../libusb/libusb-1.0.def"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (MIPSIV_FP)"
- OutputDirectory="$(SolutionDir)..\MIPSIV_FP\$(ConfigurationName)\dll"
- IntermediateDirectory="$(SolutionDir)..\MIPSIV_FP\$(ConfigurationName)\dll\libusb-1.0"
- ConfigurationType="2"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_USRDLL;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)\libusb-1.0.dll"
- ModuleDefinitionFile="../libusb/libusb-1.0.def"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (SH4)"
- OutputDirectory="$(SolutionDir)..\SH4\$(ConfigurationName)\dll"
- IntermediateDirectory="$(SolutionDir)..\SH4\$(ConfigurationName)\dll\libusb-1.0"
- ConfigurationType="2"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_USRDLL;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)\libusb-1.0.dll"
- ModuleDefinitionFile="../libusb/libusb-1.0.def"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (x86)"
- OutputDirectory="$(SolutionDir)..\x86\$(ConfigurationName)\dll"
- IntermediateDirectory="$(SolutionDir)..\x86\$(ConfigurationName)\dll\libusb-1.0"
- ConfigurationType="2"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_USRDLL;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- OutputFile="$(OutDir)\libusb-1.0.dll"
- IgnoreDefaultLibraryNames="oldnames.lib,libc.lib"
- ModuleDefinitionFile="../libusb/libusb-1.0.def"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\libusb\core.c"
- >
- </File>
- <File
- RelativePath="..\libusb\descriptor.c"
- >
- </File>
- <File
- RelativePath="..\libusb\hotplug.c"
- >
- </File>
- <File
- RelativePath="..\libusb\io.c"
- >
- </File>
- <File
- RelativePath="missing.c"
- >
- </File>
- <File
- RelativePath="..\libusb\os\poll_windows.c"
- >
- </File>
- <File
- RelativePath="..\libusb\strerror.c"
- >
- </File>
- <File
- RelativePath="..\libusb\sync.c"
- >
- </File>
- <File
- RelativePath="..\libusb\os\threads_windows.c"
- >
- </File>
- <File
- RelativePath="..\libusb\os\wince_usb.c"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- <File
- RelativePath="config.h"
- >
- </File>
- <File
- RelativePath="errno.h"
- >
- </File>
- <File
- RelativePath="..\libusb\hotplug.h"
- >
- </File>
- <File
- RelativePath="..\libusb\libusb.h"
- >
- </File>
- <File
- RelativePath="..\libusb\libusbi.h"
- >
- </File>
- <File
- RelativePath="missing.h"
- >
- </File>
- <File
- RelativePath="..\libusb\os\poll_windows.h"
- >
- </File>
- <File
- RelativePath="..\libusb\os\threads_windows.h"
- >
- </File>
- <File
- RelativePath="..\libusb\version.h"
- >
- </File>
- <File
- RelativePath="..\libusb\version_nano.h"
- >
- </File>
- <File
- RelativePath="..\libusb\os\windows_common.h"
- >
- </File>
- <File
- RelativePath="..\libusb\os\wince_usb.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
- >
- <File
- RelativePath="..\libusb\libusb-1.0.def"
- >
- </File>
- <File
- RelativePath="..\libusb\libusb-1.0.rc"
- >
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/msvc/libusb_sources b/msvc/libusb_sources
deleted file mode 100644
index fcb1f77..0000000
--- a/msvc/libusb_sources
+++ /dev/null
@@ -1,43 +0,0 @@
-#TARGETTYPE is not defined, to allow selection between static lib or DLL with ddk_build
-TARGETNAME=libusb-1.0
-DLLDEF=..\libusb-1.0.def
-
-_NT_TARGET_VERSION=$(_NT_TARGET_VERSION_WINXP)
-
-!IFNDEF MSC_WARNING_LEVEL
-MSC_WARNING_LEVEL=/W3
-!ENDIF
-
-!IFDEF STATIC_LIBC
-USE_LIBCMT=1
-!ELSE
-USE_MSVCRT=1
-!ENDIF
-
-INCLUDES=..;..\..\msvc;$(DDK_INC_PATH)
-C_DEFINES=$(C_DEFINES) $(LIBUSB_DEFINES) /DDDKBUILD
-
-# http://jpassing.com/2009/10/21/ltcg-issues-with-the-win7amd64-environment-of-wdk-7600/
-# prevents the following error when using the 64 bit static lib with Visual Studio 2010:
-# "fatal error C1001: An internal error has occurred in the compiler.
-# (compiler file 'f:\dd\vctools\compiler\utc\src\p2\p2symtab.c', line 1823)"
-# and the following with Visual Studio 2010:
-# "fatal error C1047: The object or library file 'libusb-1.0.lib' was created with
-# an older compiler than other objects; rebuild old objects and libraries"
-USER_C_FLAGS=/GL-
-
-TARGETLIBS=$(SDK_LIB_PATH)\advapi32.lib \
- $(SDK_LIB_PATH)\kernel32.lib
-
-SOURCES=..\core.c \
- ..\descriptor.c \
- ..\hotplug.c \
- ..\io.c \
- poll_windows.c \
- ..\strerror.c \
- ..\sync.c \
- threads_windows.c \
- windows_nt_common.c \
- windows_usbdk.c \
- windows_winusb.c \
- ..\libusb-1.0.rc
diff --git a/msvc/libusb_static.dsp b/msvc/libusb_static.dsp
deleted file mode 100644
index 7eddf79..0000000
--- a/msvc/libusb_static.dsp
+++ /dev/null
@@ -1,174 +0,0 @@
-# Microsoft Developer Studio Project File - Name="libusb_static" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=libusb_static - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "libusb_static.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "libusb_static.mak" CFG="libusb_static - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "libusb_static - Win32 Release" (based on "Win32 (x86) Static Library")
-!MESSAGE "libusb_static - Win32 Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "libusb_static - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "../Win32/Release/lib"
-# PROP Intermediate_Dir "../Win32/Release/lib"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I "../libusb" /D "WIN32" /D "NDEBUG" /D "_UNICODE" /D "UNICODE" /U "_MBCS" /D "_LIB" /FR /FD /EHsc /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"../Win32/Release/lib/libusb-1.0.lib"
-
-!ELSEIF "$(CFG)" == "libusb_static - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "../Win32/Debug/lib"
-# PROP Intermediate_Dir "../Win32/Debug/lib"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /I "../libusb" /D "WIN32" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /U "_MBCS" /D "_LIB" /FR /FD /GZ /EHsc /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo /n
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"../Win32/Debug/lib/libusb-1.0.lib"
-
-!ENDIF
-
-# Begin Target
-
-# Name "libusb_static - Win32 Release"
-# Name "libusb_static - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\libusb\core.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\darwin_usb.c
-# PROP Exclude_From_Build 1
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\descriptor.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\io.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\linux_usbfs.c
-# PROP Exclude_From_Build 1
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\poll_windows.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\sync.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\threads_windows.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\windows_winusb.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\config.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\darwin_usb.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\libusb.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\libusbi.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\linux_usbfs.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\poll_posix.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\poll_windows.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\threads_posix.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\threads_windows.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\windows_winusb.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\libusb\os\windows_common.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/msvc/libusb_static_2005.vcproj b/msvc/libusb_static_2005.vcproj
deleted file mode 100644
index 901c499..0000000
--- a/msvc/libusb_static_2005.vcproj
+++ /dev/null
@@ -1,390 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="8.00"
- Name="libusb-1.0 (static)"
- ProjectGUID="{5AB6B770-1925-48D5-ABC2-930F3259C020}"
- RootNamespace="libusb"
- Keyword="Win32Proj"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="..\$(PlatformName)\$(ConfigurationName)\lib"
- IntermediateDirectory="..\$(PlatformName)\$(ConfigurationName)\lib\libusb-1.0"
- ConfigurationType="4"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)\libusb-1.0.lib"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="..\$(PlatformName)\$(ConfigurationName)\lib"
- IntermediateDirectory="..\$(PlatformName)\$(ConfigurationName)\lib\libusb-1.0"
- ConfigurationType="4"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="2"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)\libusb-1.0.lib"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="..\$(PlatformName)\$(ConfigurationName)\lib"
- IntermediateDirectory="..\$(PlatformName)\$(ConfigurationName)\lib\libusb-1.0"
- ConfigurationType="4"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)\libusb-1.0.lib"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="..\$(PlatformName)\$(ConfigurationName)\lib"
- IntermediateDirectory="..\$(PlatformName)\$(ConfigurationName)\lib\libusb-1.0"
- ConfigurationType="4"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="2"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)\libusb-1.0.lib"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\libusb\core.c"
- >
- </File>
- <File
- RelativePath="..\libusb\descriptor.c"
- >
- </File>
- <File
- RelativePath="..\libusb\hotplug.c"
- >
- </File>
- <File
- RelativePath="..\libusb\io.c"
- >
- </File>
- <File
- RelativePath="..\libusb\os\poll_windows.c"
- >
- </File>
- <File
- RelativePath="..\libusb\strerror.c"
- >
- </File>
- <File
- RelativePath="..\libusb\sync.c"
- >
- </File>
- <File
- RelativePath="..\libusb\os\threads_windows.c"
- >
- </File>
- <File
- RelativePath="..\libusb\os\windows_nt_common.c"
- >
- </File>
- <File
- RelativePath="..\libusb\os\windows_usbdk.c"
- >
- </File>
- <File
- RelativePath="..\libusb\os\windows_winusb.c"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- <File
- RelativePath=".\config.h"
- >
- </File>
- <File
- RelativePath="..\libusb\hotplug.h"
- >
- </File>
- <File
- RelativePath="..\libusb\libusb.h"
- >
- </File>
- <File
- RelativePath="..\libusb\libusbi.h"
- >
- </File>
- <File
- RelativePath="..\libusb\os\poll_windows.h"
- >
- </File>
- <File
- RelativePath="..\libusb\os\threads_windows.h"
- >
- </File>
- <File
- RelativePath="..\libusb\version.h"
- >
- </File>
- <File
- RelativePath="..\libusb\version_nano.h"
- >
- </File>
- <File
- RelativePath="..\libusb\os\windows_common.h"
- >
- </File>
- <File
- RelativePath="..\libusb\os\windows_nt_common.h"
- >
- </File>
- <File
- RelativePath="..\libusb\os\windows_nt_shared_types.h"
- >
- </File>
- <File
- RelativePath="..\libusb\os\windows_usbdk.h"
- >
- </File>
- <File
- RelativePath="..\libusb\os\windows_winusb.h"
- >
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/msvc/libusb_static_2012.vcxproj b/msvc/libusb_static_2012.vcxproj
deleted file mode 100644
index 567ca47..0000000
--- a/msvc/libusb_static_2012.vcxproj
+++ /dev/null
@@ -1,98 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectName>libusb-1.0 (static)</ProjectName>
- <ProjectGuid>{349EE8F9-7D25-4909-AAF5-FF3FADE72187}</ProjectGuid>
- <RootNamespace>libusb</RootNamespace>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v110</PlatformToolset>
- <WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <IntDir>$(ProjectDir)..\$(Platform)\$(Configuration)\lib\$(TargetName)\</IntDir>
- <OutDir>$(ProjectDir)..\$(Platform)\$(Configuration)\lib\</OutDir>
- <TargetName>libusb-1.0</TargetName>
- </PropertyGroup>
- <ItemDefinitionGroup>
- <ClCompile>
- <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WINVER=0x0501;_WIN32_WINNT=0x0501;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
- <WarningLevel>Level4</WarningLevel>
- </ClCompile>
- <ClCompile Condition="'$(Configuration)'=='Debug'">
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <Optimization>Disabled</Optimization>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- </ClCompile>
- <ClCompile Condition="'$(Configuration)'=='Release'">
- <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- </ClCompile>
- <Lib>
- <OutputFile>$(OutDir)libusb-1.0.lib</OutputFile>
- </Lib>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\libusb\core.c" />
- <ClCompile Include="..\libusb\descriptor.c" />
- <ClCompile Include="..\libusb\hotplug.c" />
- <ClCompile Include="..\libusb\io.c" />
- <ClCompile Include="..\libusb\os\poll_windows.c" />
- <ClCompile Include="..\libusb\strerror.c" />
- <ClCompile Include="..\libusb\sync.c" />
- <ClCompile Include="..\libusb\os\threads_windows.c" />
- <ClCompile Include="..\libusb\os\windows_nt_common.c" />
- <ClCompile Include="..\libusb\os\windows_usbdk.c" />
- <ClCompile Include="..\libusb\os\windows_winusb.c" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include=".\config.h" />
- <ClInclude Include="..\libusb\hotplug.h" />
- <ClInclude Include="..\libusb\libusb.h" />
- <ClInclude Include="..\libusb\libusbi.h" />
- <ClInclude Include="..\libusb\os\poll_windows.h" />
- <ClInclude Include="..\libusb\os\threads_windows.h" />
- <ClInclude Include="..\libusb\version.h" />
- <ClInclude Include="..\libusb\version_nano.h" />
- <ClInclude Include="..\libusb\os\windows_common.h" />
- <ClInclude Include="..\libusb\os\windows_nt_common.h" />
- <ClInclude Include="..\libusb\os\windows_nt_shared_types.h" />
- <ClInclude Include="..\libusb\os\windows_usbdk.h" />
- <ClInclude Include="..\libusb\os\windows_winusb.h" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project>
diff --git a/msvc/libusb_static_2013.vcxproj b/msvc/libusb_static_2013.vcxproj
index 486723e..1b287e5 100644
--- a/msvc/libusb_static_2013.vcxproj
+++ b/msvc/libusb_static_2013.vcxproj
@@ -45,9 +45,8 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
- <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WINVER=0x0501;_WIN32_WINNT=0x0501;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>_WIN32_WINNT=_WIN32_WINNT_VISTA;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<WarningLevel>Level4</WarningLevel>
</ClCompile>
@@ -67,32 +66,30 @@
<ItemGroup>
<ClCompile Include="..\libusb\core.c" />
<ClCompile Include="..\libusb\descriptor.c" />
+ <ClCompile Include="..\libusb\os\events_windows.c" />
<ClCompile Include="..\libusb\hotplug.c" />
<ClCompile Include="..\libusb\io.c" />
- <ClCompile Include="..\libusb\os\poll_windows.c" />
<ClCompile Include="..\libusb\strerror.c" />
<ClCompile Include="..\libusb\sync.c" />
<ClCompile Include="..\libusb\os\threads_windows.c" />
- <ClCompile Include="..\libusb\os\windows_nt_common.c" />
+ <ClCompile Include="..\libusb\os\windows_common.c" />
<ClCompile Include="..\libusb\os\windows_usbdk.c" />
<ClCompile Include="..\libusb\os\windows_winusb.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\os\events_windows.h" />
<ClInclude Include="..\libusb\hotplug.h" />
<ClInclude Include="..\libusb\libusb.h" />
<ClInclude Include="..\libusb\libusbi.h" />
- <ClInclude Include="..\libusb\os\poll_windows.h" />
<ClInclude Include="..\libusb\os\threads_windows.h" />
<ClInclude Include="..\libusb\version.h" />
<ClInclude Include="..\libusb\version_nano.h" />
<ClInclude Include="..\libusb\os\windows_common.h" />
- <ClInclude Include="..\libusb\os\windows_nt_common.h" />
- <ClInclude Include="..\libusb\os\windows_nt_shared_types.h" />
<ClInclude Include="..\libusb\os\windows_usbdk.h" />
<ClInclude Include="..\libusb\os\windows_winusb.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/libusb_static_2013.vcxproj.filters b/msvc/libusb_static_2013.vcxproj.filters
new file mode 100644
index 0000000..2994ca1
--- /dev/null
+++ b/msvc/libusb_static_2013.vcxproj.filters
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{e01d2270-44db-420b-af4e-2ccf8b5e2758}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{d86f23bc-6e95-4704-b2ff-dccb4133d5f9}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\events_windows.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\hotplug.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusbi.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\threads_windows.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_common.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_usbdk.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_winusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\version_nano.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\libusb\core.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\descriptor.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\events_windows.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\hotplug.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\io.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\strerror.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\sync.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\threads_windows.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_common.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_usbdk.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_winusb.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/libusb_static_2015.vcxproj b/msvc/libusb_static_2015.vcxproj
index 7910967..9fa30da 100644
--- a/msvc/libusb_static_2015.vcxproj
+++ b/msvc/libusb_static_2015.vcxproj
@@ -47,7 +47,7 @@
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WINVER=0x0501;_WIN32_WINNT=0x0501;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>_WIN32_WINNT=_WIN32_WINNT_VISTA;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<WarningLevel>Level4</WarningLevel>
</ClCompile>
@@ -67,32 +67,30 @@
<ItemGroup>
<ClCompile Include="..\libusb\core.c" />
<ClCompile Include="..\libusb\descriptor.c" />
+ <ClCompile Include="..\libusb\os\events_windows.c" />
<ClCompile Include="..\libusb\hotplug.c" />
<ClCompile Include="..\libusb\io.c" />
- <ClCompile Include="..\libusb\os\poll_windows.c" />
<ClCompile Include="..\libusb\strerror.c" />
<ClCompile Include="..\libusb\sync.c" />
<ClCompile Include="..\libusb\os\threads_windows.c" />
- <ClCompile Include="..\libusb\os\windows_nt_common.c" />
+ <ClCompile Include="..\libusb\os\windows_common.c" />
<ClCompile Include="..\libusb\os\windows_usbdk.c" />
<ClCompile Include="..\libusb\os\windows_winusb.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\os\events_windows.h" />
<ClInclude Include="..\libusb\hotplug.h" />
<ClInclude Include="..\libusb\libusb.h" />
<ClInclude Include="..\libusb\libusbi.h" />
- <ClInclude Include="..\libusb\os\poll_windows.h" />
<ClInclude Include="..\libusb\os\threads_windows.h" />
<ClInclude Include="..\libusb\version.h" />
<ClInclude Include="..\libusb\version_nano.h" />
<ClInclude Include="..\libusb\os\windows_common.h" />
- <ClInclude Include="..\libusb\os\windows_nt_common.h" />
- <ClInclude Include="..\libusb\os\windows_nt_shared_types.h" />
<ClInclude Include="..\libusb\os\windows_usbdk.h" />
<ClInclude Include="..\libusb\os\windows_winusb.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/libusb_static_2015.vcxproj.filters b/msvc/libusb_static_2015.vcxproj.filters
new file mode 100644
index 0000000..2994ca1
--- /dev/null
+++ b/msvc/libusb_static_2015.vcxproj.filters
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{e01d2270-44db-420b-af4e-2ccf8b5e2758}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{d86f23bc-6e95-4704-b2ff-dccb4133d5f9}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\events_windows.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\hotplug.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusbi.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\threads_windows.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_common.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_usbdk.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_winusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\version_nano.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\libusb\core.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\descriptor.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\events_windows.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\hotplug.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\io.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\strerror.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\sync.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\threads_windows.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_common.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_usbdk.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_winusb.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/libusb_static_2017.vcxproj b/msvc/libusb_static_2017.vcxproj
index ec1b1be..62076e0 100644
--- a/msvc/libusb_static_2017.vcxproj
+++ b/msvc/libusb_static_2017.vcxproj
@@ -38,9 +38,9 @@
<ProjectName>libusb-1.0 (static)</ProjectName>
<ProjectGuid>{349EE8F9-7D25-4909-AAF5-FF3FADE72187}</ProjectGuid>
<RootNamespace>libusb</RootNamespace>
- <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion Condition="'$(Platform)'=='ARM' Or '$(Platform)'=='ARM64'">10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
@@ -66,7 +66,7 @@
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WINVER=0x0501;_WIN32_WINNT=0x0501;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>_WIN32_WINNT=_WIN32_WINNT_VISTA;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<WarningLevel>Level4</WarningLevel>
</ClCompile>
@@ -86,28 +86,26 @@
<ItemGroup>
<ClCompile Include="..\libusb\core.c" />
<ClCompile Include="..\libusb\descriptor.c" />
+ <ClCompile Include="..\libusb\os\events_windows.c" />
<ClCompile Include="..\libusb\hotplug.c" />
<ClCompile Include="..\libusb\io.c" />
- <ClCompile Include="..\libusb\os\poll_windows.c" />
<ClCompile Include="..\libusb\strerror.c" />
<ClCompile Include="..\libusb\sync.c" />
<ClCompile Include="..\libusb\os\threads_windows.c" />
- <ClCompile Include="..\libusb\os\windows_nt_common.c" />
+ <ClCompile Include="..\libusb\os\windows_common.c" />
<ClCompile Include="..\libusb\os\windows_usbdk.c" />
<ClCompile Include="..\libusb\os\windows_winusb.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\os\events_windows.h" />
<ClInclude Include="..\libusb\hotplug.h" />
<ClInclude Include="..\libusb\libusb.h" />
<ClInclude Include="..\libusb\libusbi.h" />
- <ClInclude Include="..\libusb\os\poll_windows.h" />
<ClInclude Include="..\libusb\os\threads_windows.h" />
<ClInclude Include="..\libusb\version.h" />
<ClInclude Include="..\libusb\version_nano.h" />
<ClInclude Include="..\libusb\os\windows_common.h" />
- <ClInclude Include="..\libusb\os\windows_nt_common.h" />
- <ClInclude Include="..\libusb\os\windows_nt_shared_types.h" />
<ClInclude Include="..\libusb\os\windows_usbdk.h" />
<ClInclude Include="..\libusb\os\windows_winusb.h" />
</ItemGroup>
diff --git a/msvc/libusb_static_2017.vcxproj.filters b/msvc/libusb_static_2017.vcxproj.filters
new file mode 100644
index 0000000..2994ca1
--- /dev/null
+++ b/msvc/libusb_static_2017.vcxproj.filters
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{e01d2270-44db-420b-af4e-2ccf8b5e2758}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{d86f23bc-6e95-4704-b2ff-dccb4133d5f9}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\events_windows.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\hotplug.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusbi.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\threads_windows.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_common.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_usbdk.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_winusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\version_nano.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\libusb\core.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\descriptor.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\events_windows.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\hotplug.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\io.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\strerror.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\sync.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\threads_windows.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_common.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_usbdk.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_winusb.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/libusb_static_2010.vcxproj b/msvc/libusb_static_2019.vcxproj
index 8c18f08..60ad642 100644
--- a/msvc/libusb_static_2010.vcxproj
+++ b/msvc/libusb_static_2019.vcxproj
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|ARM64">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
@@ -9,6 +17,14 @@
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM64">
+ <Configuration>Release</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
@@ -22,11 +38,15 @@
<ProjectName>libusb-1.0 (static)</ProjectName>
<ProjectGuid>{349EE8F9-7D25-4909-AAF5-FF3FADE72187}</ProjectGuid>
<RootNamespace>libusb</RootNamespace>
+ <WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
+ <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -46,7 +66,7 @@
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WINVER=0x0501;_WIN32_WINNT=0x0501;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>_WIN32_WINNT=_WIN32_WINNT_VISTA;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<WarningLevel>Level4</WarningLevel>
</ClCompile>
@@ -66,32 +86,30 @@
<ItemGroup>
<ClCompile Include="..\libusb\core.c" />
<ClCompile Include="..\libusb\descriptor.c" />
+ <ClCompile Include="..\libusb\os\events_windows.c" />
<ClCompile Include="..\libusb\hotplug.c" />
<ClCompile Include="..\libusb\io.c" />
- <ClCompile Include="..\libusb\os\poll_windows.c" />
<ClCompile Include="..\libusb\strerror.c" />
<ClCompile Include="..\libusb\sync.c" />
<ClCompile Include="..\libusb\os\threads_windows.c" />
- <ClCompile Include="..\libusb\os\windows_nt_common.c" />
+ <ClCompile Include="..\libusb\os\windows_common.c" />
<ClCompile Include="..\libusb\os\windows_usbdk.c" />
<ClCompile Include="..\libusb\os\windows_winusb.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\os\events_windows.h" />
<ClInclude Include="..\libusb\hotplug.h" />
<ClInclude Include="..\libusb\libusb.h" />
<ClInclude Include="..\libusb\libusbi.h" />
- <ClInclude Include="..\libusb\os\poll_windows.h" />
<ClInclude Include="..\libusb\os\threads_windows.h" />
<ClInclude Include="..\libusb\version.h" />
<ClInclude Include="..\libusb\version_nano.h" />
<ClInclude Include="..\libusb\os\windows_common.h" />
- <ClInclude Include="..\libusb\os\windows_nt_common.h" />
- <ClInclude Include="..\libusb\os\windows_nt_shared_types.h" />
<ClInclude Include="..\libusb\os\windows_usbdk.h" />
<ClInclude Include="..\libusb\os\windows_winusb.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/libusb_static_2019.vcxproj.filters b/msvc/libusb_static_2019.vcxproj.filters
new file mode 100644
index 0000000..2994ca1
--- /dev/null
+++ b/msvc/libusb_static_2019.vcxproj.filters
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{e01d2270-44db-420b-af4e-2ccf8b5e2758}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{d86f23bc-6e95-4704-b2ff-dccb4133d5f9}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\events_windows.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\hotplug.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusbi.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\threads_windows.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_common.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_usbdk.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\os\windows_winusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\version_nano.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\libusb\core.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\descriptor.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\events_windows.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\hotplug.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\io.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\strerror.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\sync.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\threads_windows.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_common.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_usbdk.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\libusb\os\windows_winusb.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/libusb_static_wince.vcproj b/msvc/libusb_static_wince.vcproj
deleted file mode 100644
index 48e08cb..0000000
--- a/msvc/libusb_static_wince.vcproj
+++ /dev/null
@@ -1,1179 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="8.00"
- Name="libusb-1.0 (static)"
- ProjectGUID="{CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}"
- RootNamespace="libusb"
- >
- <Platforms>
- <Platform
- Name="STANDARDSDK_500 (ARMV4I)"
- />
- <Platform
- Name="STANDARDSDK_500 (MIPSII)"
- />
- <Platform
- Name="STANDARDSDK_500 (MIPSII_FP)"
- />
- <Platform
- Name="STANDARDSDK_500 (MIPSIV)"
- />
- <Platform
- Name="STANDARDSDK_500 (MIPSIV_FP)"
- />
- <Platform
- Name="STANDARDSDK_500 (SH4)"
- />
- <Platform
- Name="STANDARDSDK_500 (x86)"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|STANDARDSDK_500 (ARMV4I)"
- OutputDirectory="$(SolutionDir)..\ARMV4I\$(ConfigurationName)\lib"
- IntermediateDirectory="$(SolutionDir)..\ARMV4I\$(ConfigurationName)\lib\libusb-1.0"
- ConfigurationType="4"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- ForcedIncludeFiles=""
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)\libusb-1.0.lib"
- AdditionalOptions="/subsystem:$(CESubsystem)"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory="%CSIDL_PROGRAM_FILES%\lsusb"
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (MIPSII)"
- OutputDirectory="$(SolutionDir)..\MIPSII\$(ConfigurationName)\lib"
- IntermediateDirectory="$(SolutionDir)..\MIPSII\$(ConfigurationName)\lib\libusb-1.0"
- ConfigurationType="4"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)\libusb-1.0.lib"
- AdditionalOptions="/subsystem:$(CESubsystem)"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (MIPSII_FP)"
- OutputDirectory="$(SolutionDir)..\MIPSII_FP\$(ConfigurationName)\lib"
- IntermediateDirectory="$(SolutionDir)..\MIPSII_FP\$(ConfigurationName)\lib\libusb-1.0"
- ConfigurationType="4"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)\libusb-1.0.lib"
- AdditionalOptions="/subsystem:$(CESubsystem)"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (MIPSIV)"
- OutputDirectory="$(SolutionDir)..\MIPSIV\$(ConfigurationName)\lib"
- IntermediateDirectory="$(SolutionDir)..\MIPSIV\$(ConfigurationName)\lib\libusb-1.0"
- ConfigurationType="4"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)\libusb-1.0.lib"
- AdditionalOptions="/subsystem:$(CESubsystem)"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (MIPSIV_FP)"
- OutputDirectory="$(SolutionDir)..\MIPSIV_FP\$(ConfigurationName)\lib"
- IntermediateDirectory="$(SolutionDir)..\MIPSIV_FP\$(ConfigurationName)\lib\libusb-1.0"
- ConfigurationType="4"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)\libusb-1.0.lib"
- AdditionalOptions="/subsystem:$(CESubsystem)"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (SH4)"
- OutputDirectory="$(SolutionDir)..\SH4\$(ConfigurationName)\lib"
- IntermediateDirectory="$(SolutionDir)..\SH4\$(ConfigurationName)\lib\libusb-1.0"
- ConfigurationType="4"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)\libusb-1.0.lib"
- AdditionalOptions="/subsystem:$(CESubsystem)"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (x86)"
- OutputDirectory="$(SolutionDir)..\x86\$(ConfigurationName)\lib"
- IntermediateDirectory="$(SolutionDir)..\x86\$(ConfigurationName)\lib\libusb-1.0"
- ConfigurationType="4"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)\libusb-1.0.lib"
- AdditionalOptions="/subsystem:$(CESubsystem)"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (ARMV4I)"
- OutputDirectory="$(SolutionDir)..\ARMV4I\$(ConfigurationName)\lib"
- IntermediateDirectory="$(SolutionDir)..\ARMV4I\$(ConfigurationName)\lib\libusb-1.0"
- ConfigurationType="4"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)\libusb-1.0.lib"
- AdditionalOptions="/subsystem:$(CESubsystem)"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (MIPSII)"
- OutputDirectory="$(SolutionDir)..\MIPSII\$(ConfigurationName)\lib"
- IntermediateDirectory="$(SolutionDir)..\MIPSII\$(ConfigurationName)\lib\libusb-1.0"
- ConfigurationType="4"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)\libusb-1.0.lib"
- AdditionalOptions="/subsystem:$(CESubsystem)"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (MIPSII_FP)"
- OutputDirectory="$(SolutionDir)..\MIPSII_FP\$(ConfigurationName)\lib"
- IntermediateDirectory="$(SolutionDir)..\MIPSII_FP\$(ConfigurationName)\lib\libusb-1.0"
- ConfigurationType="4"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)\libusb-1.0.lib"
- AdditionalOptions="/subsystem:$(CESubsystem)"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (MIPSIV)"
- OutputDirectory="$(SolutionDir)..\MIPSIV\$(ConfigurationName)\lib"
- IntermediateDirectory="$(SolutionDir)..\MIPSIV\$(ConfigurationName)\lib\libusb-1.0"
- ConfigurationType="4"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)\libusb-1.0.lib"
- AdditionalOptions="/subsystem:$(CESubsystem)"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (MIPSIV_FP)"
- OutputDirectory="$(SolutionDir)..\MIPSIV_FP\$(ConfigurationName)\lib"
- IntermediateDirectory="$(SolutionDir)..\MIPSIV_FP\$(ConfigurationName)\lib\libusb-1.0"
- ConfigurationType="4"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)\libusb-1.0.lib"
- AdditionalOptions="/subsystem:$(CESubsystem)"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (SH4)"
- OutputDirectory="$(SolutionDir)..\SH4\$(ConfigurationName)\lib"
- IntermediateDirectory="$(SolutionDir)..\SH4\$(ConfigurationName)\lib\libusb-1.0"
- ConfigurationType="4"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)\libusb-1.0.lib"
- AdditionalOptions="/subsystem:$(CESubsystem)"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (x86)"
- OutputDirectory="$(SolutionDir)..\x86\$(ConfigurationName)\lib"
- IntermediateDirectory="$(SolutionDir)..\x86\$(ConfigurationName)\lib\libusb-1.0"
- ConfigurationType="4"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- PreprocessorDefinitions="WINCE;_WIN32_WCE"
- AdditionalIncludeDirectories="."
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLibrarianTool"
- OutputFile="$(OutDir)\libusb-1.0.lib"
- AdditionalOptions="/subsystem:$(CESubsystem)"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\libusb\core.c"
- >
- </File>
- <File
- RelativePath="..\libusb\descriptor.c"
- >
- </File>
- <File
- RelativePath="..\libusb\hotplug.c"
- >
- </File>
- <File
- RelativePath="..\libusb\io.c"
- >
- </File>
- <File
- RelativePath="missing.c"
- >
- </File>
- <File
- RelativePath="..\libusb\os\poll_windows.c"
- >
- </File>
- <File
- RelativePath="..\libusb\strerror.c"
- >
- </File>
- <File
- RelativePath="..\libusb\sync.c"
- >
- </File>
- <File
- RelativePath="..\libusb\os\threads_windows.c"
- >
- </File>
- <File
- RelativePath="..\libusb\os\wince_usb.c"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- <File
- RelativePath="config.h"
- >
- </File>
- <File
- RelativePath="errno.h"
- >
- </File>
- <File
- RelativePath="..\libusb\hotplug.h"
- >
- </File>
- <File
- RelativePath="..\libusb\libusb.h"
- >
- </File>
- <File
- RelativePath="..\libusb\libusbi.h"
- >
- </File>
- <File
- RelativePath="missing.h"
- >
- </File>
- <File
- RelativePath="..\libusb\os\poll_windows.h"
- >
- </File>
- <File
- RelativePath="..\libusb\os\threads_windows.h"
- >
- </File>
- <File
- RelativePath="..\libusb\version.h"
- >
- </File>
- <File
- RelativePath="..\libusb\version_nano.h"
- >
- </File>
- <File
- RelativePath="..\libusb\os\windows_common.h"
- >
- </File>
- <File
- RelativePath="..\libusb\os\wince_usb.h"
- >
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/msvc/libusb_wince.sln b/msvc/libusb_wince.sln
deleted file mode 100644
index d75ed7f..0000000
--- a/msvc/libusb_wince.sln
+++ /dev/null
@@ -1,246 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (dll)", "libusb_dll_wince.vcproj", "{6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (static)", "libusb_static_wince.vcproj", "{CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "listdevs", "listdevs_wince.vcproj", "{960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stress", "stress_wince.vcproj", "{61476624-3354-48C8-9334-85AC0D624640}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xusb", "xusb_wince.vcproj", "{93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|STANDARDSDK_500 (ARMV4I) = Debug|STANDARDSDK_500 (ARMV4I)
- Debug|STANDARDSDK_500 (MIPSII) = Debug|STANDARDSDK_500 (MIPSII)
- Debug|STANDARDSDK_500 (MIPSII_FP) = Debug|STANDARDSDK_500 (MIPSII_FP)
- Debug|STANDARDSDK_500 (MIPSIV) = Debug|STANDARDSDK_500 (MIPSIV)
- Debug|STANDARDSDK_500 (MIPSIV_FP) = Debug|STANDARDSDK_500 (MIPSIV_FP)
- Debug|STANDARDSDK_500 (SH4) = Debug|STANDARDSDK_500 (SH4)
- Debug|STANDARDSDK_500 (x86) = Debug|STANDARDSDK_500 (x86)
- Release|STANDARDSDK_500 (ARMV4I) = Release|STANDARDSDK_500 (ARMV4I)
- Release|STANDARDSDK_500 (MIPSII) = Release|STANDARDSDK_500 (MIPSII)
- Release|STANDARDSDK_500 (MIPSII_FP) = Release|STANDARDSDK_500 (MIPSII_FP)
- Release|STANDARDSDK_500 (MIPSIV) = Release|STANDARDSDK_500 (MIPSIV)
- Release|STANDARDSDK_500 (MIPSIV_FP) = Release|STANDARDSDK_500 (MIPSIV_FP)
- Release|STANDARDSDK_500 (SH4) = Release|STANDARDSDK_500 (SH4)
- Release|STANDARDSDK_500 (x86) = Release|STANDARDSDK_500 (x86)
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Debug|STANDARDSDK_500 (ARMV4I).ActiveCfg = Debug|STANDARDSDK_500 (ARMV4I)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Debug|STANDARDSDK_500 (ARMV4I).Build.0 = Debug|STANDARDSDK_500 (ARMV4I)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Debug|STANDARDSDK_500 (ARMV4I).Deploy.0 = Debug|STANDARDSDK_500 (ARMV4I)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Debug|STANDARDSDK_500 (MIPSII).ActiveCfg = Debug|STANDARDSDK_500 (MIPSII)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Debug|STANDARDSDK_500 (MIPSII).Build.0 = Debug|STANDARDSDK_500 (MIPSII)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Debug|STANDARDSDK_500 (MIPSII).Deploy.0 = Debug|STANDARDSDK_500 (MIPSII)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Debug|STANDARDSDK_500 (MIPSII_FP).ActiveCfg = Debug|STANDARDSDK_500 (MIPSII_FP)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Debug|STANDARDSDK_500 (MIPSII_FP).Build.0 = Debug|STANDARDSDK_500 (MIPSII_FP)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Debug|STANDARDSDK_500 (MIPSII_FP).Deploy.0 = Debug|STANDARDSDK_500 (MIPSII_FP)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Debug|STANDARDSDK_500 (MIPSIV).ActiveCfg = Debug|STANDARDSDK_500 (MIPSIV)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Debug|STANDARDSDK_500 (MIPSIV).Build.0 = Debug|STANDARDSDK_500 (MIPSIV)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Debug|STANDARDSDK_500 (MIPSIV).Deploy.0 = Debug|STANDARDSDK_500 (MIPSIV)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Debug|STANDARDSDK_500 (MIPSIV_FP).ActiveCfg = Debug|STANDARDSDK_500 (MIPSIV_FP)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Debug|STANDARDSDK_500 (MIPSIV_FP).Build.0 = Debug|STANDARDSDK_500 (MIPSIV_FP)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Debug|STANDARDSDK_500 (MIPSIV_FP).Deploy.0 = Debug|STANDARDSDK_500 (MIPSIV_FP)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Debug|STANDARDSDK_500 (SH4).ActiveCfg = Debug|STANDARDSDK_500 (SH4)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Debug|STANDARDSDK_500 (SH4).Build.0 = Debug|STANDARDSDK_500 (SH4)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Debug|STANDARDSDK_500 (SH4).Deploy.0 = Debug|STANDARDSDK_500 (SH4)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Debug|STANDARDSDK_500 (x86).ActiveCfg = Debug|STANDARDSDK_500 (x86)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Debug|STANDARDSDK_500 (x86).Build.0 = Debug|STANDARDSDK_500 (x86)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Debug|STANDARDSDK_500 (x86).Deploy.0 = Debug|STANDARDSDK_500 (x86)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Release|STANDARDSDK_500 (ARMV4I).ActiveCfg = Release|STANDARDSDK_500 (ARMV4I)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Release|STANDARDSDK_500 (ARMV4I).Build.0 = Release|STANDARDSDK_500 (ARMV4I)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Release|STANDARDSDK_500 (ARMV4I).Deploy.0 = Release|STANDARDSDK_500 (ARMV4I)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Release|STANDARDSDK_500 (MIPSII).ActiveCfg = Release|STANDARDSDK_500 (MIPSII)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Release|STANDARDSDK_500 (MIPSII).Build.0 = Release|STANDARDSDK_500 (MIPSII)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Release|STANDARDSDK_500 (MIPSII).Deploy.0 = Release|STANDARDSDK_500 (MIPSII)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Release|STANDARDSDK_500 (MIPSII_FP).ActiveCfg = Release|STANDARDSDK_500 (MIPSII_FP)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Release|STANDARDSDK_500 (MIPSII_FP).Build.0 = Release|STANDARDSDK_500 (MIPSII_FP)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Release|STANDARDSDK_500 (MIPSII_FP).Deploy.0 = Release|STANDARDSDK_500 (MIPSII_FP)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Release|STANDARDSDK_500 (MIPSIV).ActiveCfg = Release|STANDARDSDK_500 (MIPSIV)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Release|STANDARDSDK_500 (MIPSIV).Build.0 = Release|STANDARDSDK_500 (MIPSIV)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Release|STANDARDSDK_500 (MIPSIV).Deploy.0 = Release|STANDARDSDK_500 (MIPSIV)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Release|STANDARDSDK_500 (MIPSIV_FP).ActiveCfg = Release|STANDARDSDK_500 (MIPSIV_FP)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Release|STANDARDSDK_500 (MIPSIV_FP).Build.0 = Release|STANDARDSDK_500 (MIPSIV_FP)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Release|STANDARDSDK_500 (MIPSIV_FP).Deploy.0 = Release|STANDARDSDK_500 (MIPSIV_FP)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Release|STANDARDSDK_500 (SH4).ActiveCfg = Release|STANDARDSDK_500 (SH4)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Release|STANDARDSDK_500 (SH4).Build.0 = Release|STANDARDSDK_500 (SH4)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Release|STANDARDSDK_500 (SH4).Deploy.0 = Release|STANDARDSDK_500 (SH4)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Release|STANDARDSDK_500 (x86).ActiveCfg = Release|STANDARDSDK_500 (x86)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Release|STANDARDSDK_500 (x86).Build.0 = Release|STANDARDSDK_500 (x86)
- {6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}.Release|STANDARDSDK_500 (x86).Deploy.0 = Release|STANDARDSDK_500 (x86)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Debug|STANDARDSDK_500 (ARMV4I).ActiveCfg = Debug|STANDARDSDK_500 (ARMV4I)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Debug|STANDARDSDK_500 (ARMV4I).Build.0 = Debug|STANDARDSDK_500 (ARMV4I)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Debug|STANDARDSDK_500 (ARMV4I).Deploy.0 = Debug|STANDARDSDK_500 (ARMV4I)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Debug|STANDARDSDK_500 (MIPSII).ActiveCfg = Debug|STANDARDSDK_500 (MIPSII)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Debug|STANDARDSDK_500 (MIPSII).Build.0 = Debug|STANDARDSDK_500 (MIPSII)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Debug|STANDARDSDK_500 (MIPSII).Deploy.0 = Debug|STANDARDSDK_500 (MIPSII)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Debug|STANDARDSDK_500 (MIPSII_FP).ActiveCfg = Debug|STANDARDSDK_500 (MIPSII_FP)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Debug|STANDARDSDK_500 (MIPSII_FP).Build.0 = Debug|STANDARDSDK_500 (MIPSII_FP)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Debug|STANDARDSDK_500 (MIPSII_FP).Deploy.0 = Debug|STANDARDSDK_500 (MIPSII_FP)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Debug|STANDARDSDK_500 (MIPSIV).ActiveCfg = Debug|STANDARDSDK_500 (MIPSIV)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Debug|STANDARDSDK_500 (MIPSIV).Build.0 = Debug|STANDARDSDK_500 (MIPSIV)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Debug|STANDARDSDK_500 (MIPSIV).Deploy.0 = Debug|STANDARDSDK_500 (MIPSIV)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Debug|STANDARDSDK_500 (MIPSIV_FP).ActiveCfg = Debug|STANDARDSDK_500 (MIPSIV_FP)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Debug|STANDARDSDK_500 (MIPSIV_FP).Build.0 = Debug|STANDARDSDK_500 (MIPSIV_FP)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Debug|STANDARDSDK_500 (MIPSIV_FP).Deploy.0 = Debug|STANDARDSDK_500 (MIPSIV_FP)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Debug|STANDARDSDK_500 (SH4).ActiveCfg = Debug|STANDARDSDK_500 (SH4)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Debug|STANDARDSDK_500 (SH4).Build.0 = Debug|STANDARDSDK_500 (SH4)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Debug|STANDARDSDK_500 (SH4).Deploy.0 = Debug|STANDARDSDK_500 (SH4)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Debug|STANDARDSDK_500 (x86).ActiveCfg = Debug|STANDARDSDK_500 (x86)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Debug|STANDARDSDK_500 (x86).Build.0 = Debug|STANDARDSDK_500 (x86)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Debug|STANDARDSDK_500 (x86).Deploy.0 = Debug|STANDARDSDK_500 (x86)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Release|STANDARDSDK_500 (ARMV4I).ActiveCfg = Release|STANDARDSDK_500 (ARMV4I)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Release|STANDARDSDK_500 (ARMV4I).Build.0 = Release|STANDARDSDK_500 (ARMV4I)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Release|STANDARDSDK_500 (ARMV4I).Deploy.0 = Release|STANDARDSDK_500 (ARMV4I)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Release|STANDARDSDK_500 (MIPSII).ActiveCfg = Release|STANDARDSDK_500 (MIPSII)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Release|STANDARDSDK_500 (MIPSII).Build.0 = Release|STANDARDSDK_500 (MIPSII)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Release|STANDARDSDK_500 (MIPSII).Deploy.0 = Release|STANDARDSDK_500 (MIPSII)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Release|STANDARDSDK_500 (MIPSII_FP).ActiveCfg = Release|STANDARDSDK_500 (MIPSII_FP)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Release|STANDARDSDK_500 (MIPSII_FP).Build.0 = Release|STANDARDSDK_500 (MIPSII_FP)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Release|STANDARDSDK_500 (MIPSII_FP).Deploy.0 = Release|STANDARDSDK_500 (MIPSII_FP)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Release|STANDARDSDK_500 (MIPSIV).ActiveCfg = Release|STANDARDSDK_500 (MIPSIV)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Release|STANDARDSDK_500 (MIPSIV).Build.0 = Release|STANDARDSDK_500 (MIPSIV)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Release|STANDARDSDK_500 (MIPSIV).Deploy.0 = Release|STANDARDSDK_500 (MIPSIV)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Release|STANDARDSDK_500 (MIPSIV_FP).ActiveCfg = Release|STANDARDSDK_500 (MIPSIV_FP)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Release|STANDARDSDK_500 (MIPSIV_FP).Build.0 = Release|STANDARDSDK_500 (MIPSIV_FP)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Release|STANDARDSDK_500 (MIPSIV_FP).Deploy.0 = Release|STANDARDSDK_500 (MIPSIV_FP)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Release|STANDARDSDK_500 (SH4).ActiveCfg = Release|STANDARDSDK_500 (SH4)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Release|STANDARDSDK_500 (SH4).Build.0 = Release|STANDARDSDK_500 (SH4)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Release|STANDARDSDK_500 (SH4).Deploy.0 = Release|STANDARDSDK_500 (SH4)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Release|STANDARDSDK_500 (x86).ActiveCfg = Release|STANDARDSDK_500 (x86)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Release|STANDARDSDK_500 (x86).Build.0 = Release|STANDARDSDK_500 (x86)
- {CE67BEFB-37EA-4F5C-A60E-F2D0CC91B6AA}.Release|STANDARDSDK_500 (x86).Deploy.0 = Release|STANDARDSDK_500 (x86)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Debug|STANDARDSDK_500 (ARMV4I).ActiveCfg = Debug|STANDARDSDK_500 (ARMV4I)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Debug|STANDARDSDK_500 (ARMV4I).Build.0 = Debug|STANDARDSDK_500 (ARMV4I)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Debug|STANDARDSDK_500 (ARMV4I).Deploy.0 = Debug|STANDARDSDK_500 (ARMV4I)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Debug|STANDARDSDK_500 (MIPSII).ActiveCfg = Debug|STANDARDSDK_500 (MIPSII)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Debug|STANDARDSDK_500 (MIPSII).Build.0 = Debug|STANDARDSDK_500 (MIPSII)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Debug|STANDARDSDK_500 (MIPSII).Deploy.0 = Debug|STANDARDSDK_500 (MIPSII)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Debug|STANDARDSDK_500 (MIPSII_FP).ActiveCfg = Debug|STANDARDSDK_500 (MIPSII_FP)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Debug|STANDARDSDK_500 (MIPSII_FP).Build.0 = Debug|STANDARDSDK_500 (MIPSII_FP)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Debug|STANDARDSDK_500 (MIPSII_FP).Deploy.0 = Debug|STANDARDSDK_500 (MIPSII_FP)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Debug|STANDARDSDK_500 (MIPSIV).ActiveCfg = Debug|STANDARDSDK_500 (MIPSIV)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Debug|STANDARDSDK_500 (MIPSIV).Build.0 = Debug|STANDARDSDK_500 (MIPSIV)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Debug|STANDARDSDK_500 (MIPSIV).Deploy.0 = Debug|STANDARDSDK_500 (MIPSIV)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Debug|STANDARDSDK_500 (MIPSIV_FP).ActiveCfg = Debug|STANDARDSDK_500 (MIPSIV_FP)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Debug|STANDARDSDK_500 (MIPSIV_FP).Build.0 = Debug|STANDARDSDK_500 (MIPSIV_FP)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Debug|STANDARDSDK_500 (MIPSIV_FP).Deploy.0 = Debug|STANDARDSDK_500 (MIPSIV_FP)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Debug|STANDARDSDK_500 (SH4).ActiveCfg = Debug|STANDARDSDK_500 (SH4)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Debug|STANDARDSDK_500 (SH4).Build.0 = Debug|STANDARDSDK_500 (SH4)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Debug|STANDARDSDK_500 (SH4).Deploy.0 = Debug|STANDARDSDK_500 (SH4)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Debug|STANDARDSDK_500 (x86).ActiveCfg = Debug|STANDARDSDK_500 (x86)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Debug|STANDARDSDK_500 (x86).Build.0 = Debug|STANDARDSDK_500 (x86)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Debug|STANDARDSDK_500 (x86).Deploy.0 = Debug|STANDARDSDK_500 (x86)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Release|STANDARDSDK_500 (ARMV4I).ActiveCfg = Release|STANDARDSDK_500 (ARMV4I)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Release|STANDARDSDK_500 (ARMV4I).Build.0 = Release|STANDARDSDK_500 (ARMV4I)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Release|STANDARDSDK_500 (ARMV4I).Deploy.0 = Release|STANDARDSDK_500 (ARMV4I)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Release|STANDARDSDK_500 (MIPSII).ActiveCfg = Release|STANDARDSDK_500 (MIPSII)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Release|STANDARDSDK_500 (MIPSII).Build.0 = Release|STANDARDSDK_500 (MIPSII)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Release|STANDARDSDK_500 (MIPSII).Deploy.0 = Release|STANDARDSDK_500 (MIPSII)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Release|STANDARDSDK_500 (MIPSII_FP).ActiveCfg = Release|STANDARDSDK_500 (MIPSII_FP)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Release|STANDARDSDK_500 (MIPSII_FP).Build.0 = Release|STANDARDSDK_500 (MIPSII_FP)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Release|STANDARDSDK_500 (MIPSII_FP).Deploy.0 = Release|STANDARDSDK_500 (MIPSII_FP)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Release|STANDARDSDK_500 (MIPSIV).ActiveCfg = Release|STANDARDSDK_500 (MIPSIV)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Release|STANDARDSDK_500 (MIPSIV).Build.0 = Release|STANDARDSDK_500 (MIPSIV)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Release|STANDARDSDK_500 (MIPSIV).Deploy.0 = Release|STANDARDSDK_500 (MIPSIV)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Release|STANDARDSDK_500 (MIPSIV_FP).ActiveCfg = Release|STANDARDSDK_500 (MIPSIV_FP)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Release|STANDARDSDK_500 (MIPSIV_FP).Build.0 = Release|STANDARDSDK_500 (MIPSIV_FP)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Release|STANDARDSDK_500 (MIPSIV_FP).Deploy.0 = Release|STANDARDSDK_500 (MIPSIV_FP)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Release|STANDARDSDK_500 (SH4).ActiveCfg = Release|STANDARDSDK_500 (SH4)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Release|STANDARDSDK_500 (SH4).Build.0 = Release|STANDARDSDK_500 (SH4)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Release|STANDARDSDK_500 (SH4).Deploy.0 = Release|STANDARDSDK_500 (SH4)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Release|STANDARDSDK_500 (x86).ActiveCfg = Release|STANDARDSDK_500 (x86)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Release|STANDARDSDK_500 (x86).Build.0 = Release|STANDARDSDK_500 (x86)
- {960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}.Release|STANDARDSDK_500 (x86).Deploy.0 = Release|STANDARDSDK_500 (x86)
- {61476624-3354-48C8-9334-85AC0D624640}.Debug|STANDARDSDK_500 (ARMV4I).ActiveCfg = Debug|STANDARDSDK_500 (ARMV4I)
- {61476624-3354-48C8-9334-85AC0D624640}.Debug|STANDARDSDK_500 (ARMV4I).Build.0 = Debug|STANDARDSDK_500 (ARMV4I)
- {61476624-3354-48C8-9334-85AC0D624640}.Debug|STANDARDSDK_500 (ARMV4I).Deploy.0 = Debug|STANDARDSDK_500 (ARMV4I)
- {61476624-3354-48C8-9334-85AC0D624640}.Debug|STANDARDSDK_500 (MIPSII).ActiveCfg = Debug|STANDARDSDK_500 (MIPSII)
- {61476624-3354-48C8-9334-85AC0D624640}.Debug|STANDARDSDK_500 (MIPSII).Build.0 = Debug|STANDARDSDK_500 (MIPSII)
- {61476624-3354-48C8-9334-85AC0D624640}.Debug|STANDARDSDK_500 (MIPSII).Deploy.0 = Debug|STANDARDSDK_500 (MIPSII)
- {61476624-3354-48C8-9334-85AC0D624640}.Debug|STANDARDSDK_500 (MIPSII_FP).ActiveCfg = Debug|STANDARDSDK_500 (MIPSII_FP)
- {61476624-3354-48C8-9334-85AC0D624640}.Debug|STANDARDSDK_500 (MIPSII_FP).Build.0 = Debug|STANDARDSDK_500 (MIPSII_FP)
- {61476624-3354-48C8-9334-85AC0D624640}.Debug|STANDARDSDK_500 (MIPSII_FP).Deploy.0 = Debug|STANDARDSDK_500 (MIPSII_FP)
- {61476624-3354-48C8-9334-85AC0D624640}.Debug|STANDARDSDK_500 (MIPSIV).ActiveCfg = Debug|STANDARDSDK_500 (MIPSIV)
- {61476624-3354-48C8-9334-85AC0D624640}.Debug|STANDARDSDK_500 (MIPSIV).Build.0 = Debug|STANDARDSDK_500 (MIPSIV)
- {61476624-3354-48C8-9334-85AC0D624640}.Debug|STANDARDSDK_500 (MIPSIV).Deploy.0 = Debug|STANDARDSDK_500 (MIPSIV)
- {61476624-3354-48C8-9334-85AC0D624640}.Debug|STANDARDSDK_500 (MIPSIV_FP).ActiveCfg = Debug|STANDARDSDK_500 (MIPSIV_FP)
- {61476624-3354-48C8-9334-85AC0D624640}.Debug|STANDARDSDK_500 (MIPSIV_FP).Build.0 = Debug|STANDARDSDK_500 (MIPSIV_FP)
- {61476624-3354-48C8-9334-85AC0D624640}.Debug|STANDARDSDK_500 (MIPSIV_FP).Deploy.0 = Debug|STANDARDSDK_500 (MIPSIV_FP)
- {61476624-3354-48C8-9334-85AC0D624640}.Debug|STANDARDSDK_500 (SH4).ActiveCfg = Debug|STANDARDSDK_500 (SH4)
- {61476624-3354-48C8-9334-85AC0D624640}.Debug|STANDARDSDK_500 (SH4).Build.0 = Debug|STANDARDSDK_500 (SH4)
- {61476624-3354-48C8-9334-85AC0D624640}.Debug|STANDARDSDK_500 (SH4).Deploy.0 = Debug|STANDARDSDK_500 (SH4)
- {61476624-3354-48C8-9334-85AC0D624640}.Debug|STANDARDSDK_500 (x86).ActiveCfg = Debug|STANDARDSDK_500 (x86)
- {61476624-3354-48C8-9334-85AC0D624640}.Debug|STANDARDSDK_500 (x86).Build.0 = Debug|STANDARDSDK_500 (x86)
- {61476624-3354-48C8-9334-85AC0D624640}.Debug|STANDARDSDK_500 (x86).Deploy.0 = Debug|STANDARDSDK_500 (x86)
- {61476624-3354-48C8-9334-85AC0D624640}.Release|STANDARDSDK_500 (ARMV4I).ActiveCfg = Release|STANDARDSDK_500 (ARMV4I)
- {61476624-3354-48C8-9334-85AC0D624640}.Release|STANDARDSDK_500 (ARMV4I).Build.0 = Release|STANDARDSDK_500 (ARMV4I)
- {61476624-3354-48C8-9334-85AC0D624640}.Release|STANDARDSDK_500 (ARMV4I).Deploy.0 = Release|STANDARDSDK_500 (ARMV4I)
- {61476624-3354-48C8-9334-85AC0D624640}.Release|STANDARDSDK_500 (MIPSII).ActiveCfg = Release|STANDARDSDK_500 (MIPSII)
- {61476624-3354-48C8-9334-85AC0D624640}.Release|STANDARDSDK_500 (MIPSII).Build.0 = Release|STANDARDSDK_500 (MIPSII)
- {61476624-3354-48C8-9334-85AC0D624640}.Release|STANDARDSDK_500 (MIPSII).Deploy.0 = Release|STANDARDSDK_500 (MIPSII)
- {61476624-3354-48C8-9334-85AC0D624640}.Release|STANDARDSDK_500 (MIPSII_FP).ActiveCfg = Release|STANDARDSDK_500 (MIPSII_FP)
- {61476624-3354-48C8-9334-85AC0D624640}.Release|STANDARDSDK_500 (MIPSII_FP).Build.0 = Release|STANDARDSDK_500 (MIPSII_FP)
- {61476624-3354-48C8-9334-85AC0D624640}.Release|STANDARDSDK_500 (MIPSII_FP).Deploy.0 = Release|STANDARDSDK_500 (MIPSII_FP)
- {61476624-3354-48C8-9334-85AC0D624640}.Release|STANDARDSDK_500 (MIPSIV).ActiveCfg = Release|STANDARDSDK_500 (MIPSIV)
- {61476624-3354-48C8-9334-85AC0D624640}.Release|STANDARDSDK_500 (MIPSIV).Build.0 = Release|STANDARDSDK_500 (MIPSIV)
- {61476624-3354-48C8-9334-85AC0D624640}.Release|STANDARDSDK_500 (MIPSIV).Deploy.0 = Release|STANDARDSDK_500 (MIPSIV)
- {61476624-3354-48C8-9334-85AC0D624640}.Release|STANDARDSDK_500 (MIPSIV_FP).ActiveCfg = Release|STANDARDSDK_500 (MIPSIV_FP)
- {61476624-3354-48C8-9334-85AC0D624640}.Release|STANDARDSDK_500 (MIPSIV_FP).Build.0 = Release|STANDARDSDK_500 (MIPSIV_FP)
- {61476624-3354-48C8-9334-85AC0D624640}.Release|STANDARDSDK_500 (MIPSIV_FP).Deploy.0 = Release|STANDARDSDK_500 (MIPSIV_FP)
- {61476624-3354-48C8-9334-85AC0D624640}.Release|STANDARDSDK_500 (SH4).ActiveCfg = Release|STANDARDSDK_500 (SH4)
- {61476624-3354-48C8-9334-85AC0D624640}.Release|STANDARDSDK_500 (SH4).Build.0 = Release|STANDARDSDK_500 (SH4)
- {61476624-3354-48C8-9334-85AC0D624640}.Release|STANDARDSDK_500 (SH4).Deploy.0 = Release|STANDARDSDK_500 (SH4)
- {61476624-3354-48C8-9334-85AC0D624640}.Release|STANDARDSDK_500 (x86).ActiveCfg = Release|STANDARDSDK_500 (x86)
- {61476624-3354-48C8-9334-85AC0D624640}.Release|STANDARDSDK_500 (x86).Build.0 = Release|STANDARDSDK_500 (x86)
- {61476624-3354-48C8-9334-85AC0D624640}.Release|STANDARDSDK_500 (x86).Deploy.0 = Release|STANDARDSDK_500 (x86)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Debug|STANDARDSDK_500 (ARMV4I).ActiveCfg = Debug|STANDARDSDK_500 (ARMV4I)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Debug|STANDARDSDK_500 (ARMV4I).Build.0 = Debug|STANDARDSDK_500 (ARMV4I)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Debug|STANDARDSDK_500 (ARMV4I).Deploy.0 = Debug|STANDARDSDK_500 (ARMV4I)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Debug|STANDARDSDK_500 (MIPSII).ActiveCfg = Debug|STANDARDSDK_500 (MIPSII)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Debug|STANDARDSDK_500 (MIPSII).Build.0 = Debug|STANDARDSDK_500 (MIPSII)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Debug|STANDARDSDK_500 (MIPSII).Deploy.0 = Debug|STANDARDSDK_500 (MIPSII)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Debug|STANDARDSDK_500 (MIPSII_FP).ActiveCfg = Debug|STANDARDSDK_500 (MIPSII_FP)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Debug|STANDARDSDK_500 (MIPSII_FP).Build.0 = Debug|STANDARDSDK_500 (MIPSII_FP)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Debug|STANDARDSDK_500 (MIPSII_FP).Deploy.0 = Debug|STANDARDSDK_500 (MIPSII_FP)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Debug|STANDARDSDK_500 (MIPSIV).ActiveCfg = Debug|STANDARDSDK_500 (MIPSIV)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Debug|STANDARDSDK_500 (MIPSIV).Build.0 = Debug|STANDARDSDK_500 (MIPSIV)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Debug|STANDARDSDK_500 (MIPSIV).Deploy.0 = Debug|STANDARDSDK_500 (MIPSIV)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Debug|STANDARDSDK_500 (MIPSIV_FP).ActiveCfg = Debug|STANDARDSDK_500 (MIPSIV_FP)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Debug|STANDARDSDK_500 (MIPSIV_FP).Build.0 = Debug|STANDARDSDK_500 (MIPSIV_FP)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Debug|STANDARDSDK_500 (MIPSIV_FP).Deploy.0 = Debug|STANDARDSDK_500 (MIPSIV_FP)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Debug|STANDARDSDK_500 (SH4).ActiveCfg = Debug|STANDARDSDK_500 (SH4)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Debug|STANDARDSDK_500 (SH4).Build.0 = Debug|STANDARDSDK_500 (SH4)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Debug|STANDARDSDK_500 (SH4).Deploy.0 = Debug|STANDARDSDK_500 (SH4)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Debug|STANDARDSDK_500 (x86).ActiveCfg = Debug|STANDARDSDK_500 (x86)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Debug|STANDARDSDK_500 (x86).Build.0 = Debug|STANDARDSDK_500 (x86)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Debug|STANDARDSDK_500 (x86).Deploy.0 = Debug|STANDARDSDK_500 (x86)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Release|STANDARDSDK_500 (ARMV4I).ActiveCfg = Release|STANDARDSDK_500 (ARMV4I)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Release|STANDARDSDK_500 (ARMV4I).Build.0 = Release|STANDARDSDK_500 (ARMV4I)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Release|STANDARDSDK_500 (ARMV4I).Deploy.0 = Release|STANDARDSDK_500 (ARMV4I)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Release|STANDARDSDK_500 (MIPSII).ActiveCfg = Release|STANDARDSDK_500 (MIPSII)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Release|STANDARDSDK_500 (MIPSII).Build.0 = Release|STANDARDSDK_500 (MIPSII)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Release|STANDARDSDK_500 (MIPSII).Deploy.0 = Release|STANDARDSDK_500 (MIPSII)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Release|STANDARDSDK_500 (MIPSII_FP).ActiveCfg = Release|STANDARDSDK_500 (MIPSII_FP)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Release|STANDARDSDK_500 (MIPSII_FP).Build.0 = Release|STANDARDSDK_500 (MIPSII_FP)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Release|STANDARDSDK_500 (MIPSII_FP).Deploy.0 = Release|STANDARDSDK_500 (MIPSII_FP)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Release|STANDARDSDK_500 (MIPSIV).ActiveCfg = Release|STANDARDSDK_500 (MIPSIV)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Release|STANDARDSDK_500 (MIPSIV).Build.0 = Release|STANDARDSDK_500 (MIPSIV)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Release|STANDARDSDK_500 (MIPSIV).Deploy.0 = Release|STANDARDSDK_500 (MIPSIV)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Release|STANDARDSDK_500 (MIPSIV_FP).ActiveCfg = Release|STANDARDSDK_500 (MIPSIV_FP)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Release|STANDARDSDK_500 (MIPSIV_FP).Build.0 = Release|STANDARDSDK_500 (MIPSIV_FP)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Release|STANDARDSDK_500 (MIPSIV_FP).Deploy.0 = Release|STANDARDSDK_500 (MIPSIV_FP)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Release|STANDARDSDK_500 (SH4).ActiveCfg = Release|STANDARDSDK_500 (SH4)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Release|STANDARDSDK_500 (SH4).Build.0 = Release|STANDARDSDK_500 (SH4)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Release|STANDARDSDK_500 (SH4).Deploy.0 = Release|STANDARDSDK_500 (SH4)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Release|STANDARDSDK_500 (x86).ActiveCfg = Release|STANDARDSDK_500 (x86)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Release|STANDARDSDK_500 (x86).Build.0 = Release|STANDARDSDK_500 (x86)
- {93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}.Release|STANDARDSDK_500 (x86).Deploy.0 = Release|STANDARDSDK_500 (x86)
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/msvc/listdevs.dsp b/msvc/listdevs.dsp
deleted file mode 100644
index 93a93e4..0000000
--- a/msvc/listdevs.dsp
+++ /dev/null
@@ -1,103 +0,0 @@
-# Microsoft Developer Studio Project File - Name="listdevs" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=listdevs - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "listdevs.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "listdevs.mak" CFG="listdevs - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "listdevs - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "listdevs - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "listdevs - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "../Win32/Release/examples"
-# PROP Intermediate_Dir "../Win32/Release/examples/listdevs"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "../libusb" /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /U "_MBCS" /FR /FD /EHsc /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-
-!ELSEIF "$(CFG)" == "listdevs - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "../Win32/Debug/examples"
-# PROP Intermediate_Dir "../Win32/Debug/examples/listdevs"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../libusb" /I "." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /U "_MBCS" /FR /FD /GZ /EHsc /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo /n "../Win32/Debug/dll/core.sbr" "../Win32/Debug/dll/descriptor.sbr" "../Win32/Debug/dll/io.sbr" "../Win32/Debug/dll/sync.sbr" "../Win32/Debug/dll/poll_windows.sbr" "../Win32/Debug/dll/threads_windows.sbr" "../Win32/Debug/dll/windows_usb.sbr"
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
-# SUBTRACT LINK32 /pdb:none
-
-!ENDIF
-
-# Begin Target
-
-# Name "listdevs - Win32 Release"
-# Name "listdevs - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\examples\listdevs.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/msvc/listdevs_2005.vcproj b/msvc/listdevs_2005.vcproj
deleted file mode 100644
index 88cef7f..0000000
--- a/msvc/listdevs_2005.vcproj
+++ /dev/null
@@ -1,360 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="8.00"
- Name="listdevs"
- ProjectGUID="{98CFD8FA-EE20-40D5-AF13-F8C4856D6CA5}"
- RootNamespace="examples"
- Keyword="Win32Proj"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="..\$(PlatformName)\$(ConfigurationName)\examples"
- IntermediateDirectory="..\$(PlatformName)\$(ConfigurationName)\examples\$(ProjectName)"
- ConfigurationType="1"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="..\$(PlatformName)\$(ConfigurationName)\examples"
- IntermediateDirectory="..\$(PlatformName)\$(ConfigurationName)\examples\$(ProjectName)"
- ConfigurationType="1"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\libusb"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
- RuntimeLibrary="2"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="..\$(PlatformName)\$(ConfigurationName)\examples"
- IntermediateDirectory="..\$(PlatformName)\$(ConfigurationName)\examples\$(ProjectName)"
- ConfigurationType="1"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="..\$(PlatformName)\$(ConfigurationName)\examples"
- IntermediateDirectory="..\$(PlatformName)\$(ConfigurationName)\examples\$(ProjectName)"
- ConfigurationType="1"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\libusb"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
- RuntimeLibrary="2"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\examples\listdevs.c"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Detect64BitPortabilityProblems="false"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Detect64BitPortabilityProblems="false"
- />
- </FileConfiguration>
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/msvc/listdevs_2013.vcxproj b/msvc/listdevs_2013.vcxproj
index ba054d5..08c0a3f 100644
--- a/msvc/listdevs_2013.vcxproj
+++ b/msvc/listdevs_2013.vcxproj
@@ -45,8 +45,7 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
- <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
@@ -63,6 +62,7 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -72,6 +72,9 @@
<ClCompile Include="..\examples\listdevs.c" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
<ProjectReference Include=".\libusb_static_2013.vcxproj">
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
@@ -80,4 +83,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/listdevs_2013.vcxproj.filters b/msvc/listdevs_2013.vcxproj.filters
new file mode 100644
index 0000000..895e2bc
--- /dev/null
+++ b/msvc/listdevs_2013.vcxproj.filters
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{2ceecece-c641-4d87-8e75-ea3622a2a50c}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{6162aa6f-aa3a-43b0-92b2-f40207a0b581}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\listdevs.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/listdevs_2015.vcxproj b/msvc/listdevs_2015.vcxproj
index 64368e2..7791894 100644
--- a/msvc/listdevs_2015.vcxproj
+++ b/msvc/listdevs_2015.vcxproj
@@ -46,13 +46,12 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <MinimalRebuild>true</MinimalRebuild>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
@@ -63,6 +62,7 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -72,6 +72,9 @@
<ClCompile Include="..\examples\listdevs.c" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
<ProjectReference Include=".\libusb_static_2015.vcxproj">
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
@@ -80,4 +83,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/listdevs_2015.vcxproj.filters b/msvc/listdevs_2015.vcxproj.filters
new file mode 100644
index 0000000..895e2bc
--- /dev/null
+++ b/msvc/listdevs_2015.vcxproj.filters
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{2ceecece-c641-4d87-8e75-ea3622a2a50c}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{6162aa6f-aa3a-43b0-92b2-f40207a0b581}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\listdevs.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/listdevs_2017.vcxproj b/msvc/listdevs_2017.vcxproj
index ecc51de..f7ae424 100644
--- a/msvc/listdevs_2017.vcxproj
+++ b/msvc/listdevs_2017.vcxproj
@@ -39,9 +39,9 @@
<ProjectGuid>{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}</ProjectGuid>
<RootNamespace>examples</RootNamespace>
<Keyword>Win32Proj</Keyword>
- <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion Condition="'$(Platform)'=='ARM' Or '$(Platform)'=='ARM64'">10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
@@ -65,13 +65,12 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <MinimalRebuild>true</MinimalRebuild>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
@@ -82,19 +81,19 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\examples\listdevs.c" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
<ProjectReference Include=".\libusb_static_2017.vcxproj">
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
diff --git a/msvc/listdevs_2017.vcxproj.filters b/msvc/listdevs_2017.vcxproj.filters
new file mode 100644
index 0000000..895e2bc
--- /dev/null
+++ b/msvc/listdevs_2017.vcxproj.filters
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{2ceecece-c641-4d87-8e75-ea3622a2a50c}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{6162aa6f-aa3a-43b0-92b2-f40207a0b581}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\listdevs.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/listdevs_2019.vcxproj b/msvc/listdevs_2019.vcxproj
new file mode 100644
index 0000000..cbb97cf
--- /dev/null
+++ b/msvc/listdevs_2019.vcxproj
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|ARM64">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM64">
+ <Configuration>Release</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>listdevs</ProjectName>
+ <ProjectGuid>{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}</ProjectGuid>
+ <RootNamespace>examples</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ <WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
+ <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v142</PlatformToolset>
+ <WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <IntDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\$(ProjectName)\</IntDir>
+ <OutDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\</OutDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <WarningLevel>Level3</WarningLevel>
+ </ClCompile>
+ <ClCompile Condition="'$(Configuration)'=='Debug'">
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <Optimization>Disabled</Optimization>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <ClCompile Condition="'$(Configuration)'=='Release'">
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <Link Condition="'$(Configuration)'=='Debug'">
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\listdevs.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include=".\libusb_static_2019.vcxproj">
+ <Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/listdevs_2019.vcxproj.filters b/msvc/listdevs_2019.vcxproj.filters
new file mode 100644
index 0000000..895e2bc
--- /dev/null
+++ b/msvc/listdevs_2019.vcxproj.filters
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{2ceecece-c641-4d87-8e75-ea3622a2a50c}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{6162aa6f-aa3a-43b0-92b2-f40207a0b581}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\listdevs.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/listdevs_sources b/msvc/listdevs_sources
deleted file mode 100644
index 2b110ee..0000000
--- a/msvc/listdevs_sources
+++ /dev/null
@@ -1,20 +0,0 @@
-TARGETNAME=listdevs
-TARGETTYPE=PROGRAM
-386_STDCALL=0
-
-_NT_TARGET_VERSION=$(_NT_TARGET_VERSION_WINXP)
-
-!IFNDEF MSC_WARNING_LEVEL
-MSC_WARNING_LEVEL=/W3
-!ENDIF
-
-!IFDEF STATIC_LIBC
-USE_LIBCMT=1
-!ELSE
-USE_MSVCRT=1
-!ENDIF
-
-UMTYPE=console
-INCLUDES=..\..\libusb;$(DDK_INC_PATH)
-UMLIBS=..\..\libusb\os\obj$(BUILD_ALT_DIR)\*\libusb-1.0.lib
-SOURCES=..\listdevs.c
diff --git a/msvc/listdevs_wince.vcproj b/msvc/listdevs_wince.vcproj
deleted file mode 100644
index a31424b..0000000
--- a/msvc/listdevs_wince.vcproj
+++ /dev/null
@@ -1,1120 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="8.00"
- Name="listdevs"
- ProjectGUID="{960C3BC3-26D6-49C7-ACE4-0AE65CC049E6}"
- RootNamespace="listdevs"
- >
- <Platforms>
- <Platform
- Name="STANDARDSDK_500 (ARMV4I)"
- />
- <Platform
- Name="STANDARDSDK_500 (MIPSII)"
- />
- <Platform
- Name="STANDARDSDK_500 (MIPSII_FP)"
- />
- <Platform
- Name="STANDARDSDK_500 (MIPSIV)"
- />
- <Platform
- Name="STANDARDSDK_500 (MIPSIV_FP)"
- />
- <Platform
- Name="STANDARDSDK_500 (SH4)"
- />
- <Platform
- Name="STANDARDSDK_500 (x86)"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|STANDARDSDK_500 (ARMV4I)"
- OutputDirectory="$(SolutionDir)..\ARMV4I\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\ARMV4I\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;DEBUG;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory="%CSIDL_PROGRAM_FILES%\listdevs"
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (MIPSII)"
- OutputDirectory="$(SolutionDir)..\MIPSII\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\MIPSII\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;DEBUG;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (MIPSII_FP)"
- OutputDirectory="$(SolutionDir)..\MIPSII_FP\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\MIPSII_FP\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;DEBUG;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (MIPSIV)"
- OutputDirectory="$(SolutionDir)..\MIPSIV\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\MIPSIV\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;DEBUG;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (MIPSIV_FP)"
- OutputDirectory="$(SolutionDir)..\MIPSIV_FP\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\MIPSIV_FP\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;DEBUG;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (SH4)"
- OutputDirectory="$(SolutionDir)..\SH4\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\SH4\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;DEBUG;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (x86)"
- OutputDirectory="$(SolutionDir)..\x86\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\x86\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;DEBUG;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- IgnoreDefaultLibraryNames="oldnames.lib,libc.lib"
- SubSystem="9"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (ARMV4I)"
- OutputDirectory="$(SolutionDir)..\ARMV4I\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\ARMV4I\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (MIPSII)"
- OutputDirectory="$(SolutionDir)..\MIPSII\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\MIPSII\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (MIPSII_FP)"
- OutputDirectory="$(SolutionDir)..\MIPSII_FP\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\MIPSII_FP\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (MIPSIV)"
- OutputDirectory="$(SolutionDir)..\MIPSIV\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\MIPSIV\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (MIPSIV_FP)"
- OutputDirectory="$(SolutionDir)..\MIPSIV_FP\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\MIPSIV_FP\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (SH4)"
- OutputDirectory="$(SolutionDir)..\SH4\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\SH4\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (x86)"
- OutputDirectory="$(SolutionDir)..\x86\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\x86\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- IgnoreDefaultLibraryNames="oldnames.lib,libc.lib"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- </Configurations>
- <References>
- <ProjectReference
- ReferencedProjectIdentifier="{6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}"
- RelativePathToProject=".\libusb-1.0.vcproj"
- />
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\examples\listdevs.c"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
- >
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/msvc/missing.c b/msvc/missing.c
deleted file mode 100644
index 85d9d6f..0000000
--- a/msvc/missing.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Source file for missing WinCE functionality
- * Copyright © 2012 RealVNC Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "missing.h"
-
-#include <config.h>
-#include <libusbi.h>
-
-#include <windows.h>
-
-// The registry path to store environment variables
-#define ENVIRONMENT_REG_PATH _T("Software\\libusb\\environment")
-
-/* Workaround getenv not being available on WinCE.
- * Instead look in HKLM\Software\libusb\environment */
-char *getenv(const char *name)
-{
- static char value[MAX_PATH];
- TCHAR wValue[MAX_PATH];
- WCHAR wName[MAX_PATH];
- DWORD dwType, dwData;
- HKEY hkey;
- LONG rc;
-
- if (!name)
- return NULL;
-
- if (MultiByteToWideChar(CP_UTF8, 0, name, -1, wName, MAX_PATH) <= 0) {
- usbi_dbg("Failed to convert environment variable name to wide string");
- return NULL;
- }
- wName[MAX_PATH - 1] = 0; // Be sure it's NUL terminated
-
- rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, ENVIRONMENT_REG_PATH, 0, KEY_QUERY_VALUE, &hkey);
- if (rc != ERROR_SUCCESS) {
- usbi_dbg("Failed to open registry key for getenv with error %d", rc);
- return NULL;
- }
-
- // Attempt to read the key
- dwData = sizeof(wValue);
- rc = RegQueryValueEx(hkey, wName, NULL, &dwType,
- (LPBYTE)&wValue, &dwData);
- RegCloseKey(hkey);
- if (rc != ERROR_SUCCESS) {
- usbi_dbg("Failed to read registry key value for getenv with error %d", rc);
- return NULL;
- }
- if (dwType != REG_SZ) {
- usbi_dbg("Registry value was of type %d instead of REG_SZ", dwType);
- return NULL;
- }
-
- // Success in reading the key, convert from WCHAR to char
- if (WideCharToMultiByte(CP_UTF8, 0,
- wValue, dwData / sizeof(*wValue),
- value, MAX_PATH,
- NULL, NULL) <= 0) {
- usbi_dbg("Failed to convert environment variable value to narrow string");
- return NULL;
- }
- value[MAX_PATH - 1] = 0; // Be sure it's NUL terminated
- return value;
-}
diff --git a/msvc/listdevs_2012.vcxproj b/msvc/sam3u_benchmark_2013.vcxproj
index 1c13339..42a1cb1 100644
--- a/msvc/listdevs_2012.vcxproj
+++ b/msvc/sam3u_benchmark_2013.vcxproj
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@@ -19,8 +19,8 @@
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
- <ProjectName>listdevs</ProjectName>
- <ProjectGuid>{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}</ProjectGuid>
+ <ProjectName>sam3u_benchmark</ProjectName>
+ <ProjectGuid>{861cdd5f-59a2-4f34-957e-5c1af98be0a4}</ProjectGuid>
<RootNamespace>examples</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
@@ -28,7 +28,7 @@
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v110</PlatformToolset>
+ <PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -45,8 +45,7 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
- <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
@@ -63,16 +62,21 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="..\examples\listdevs.c" />
+ <ClCompile Include="..\examples\sam3u_benchmark.c" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include=".\libusb_static_2012.vcxproj">
+ <ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include=".\libusb_static_2013.vcxproj">
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
@@ -80,4 +84,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/sam3u_benchmark_2013.vcxproj.filters b/msvc/sam3u_benchmark_2013.vcxproj.filters
new file mode 100644
index 0000000..e0f6bd0
--- /dev/null
+++ b/msvc/sam3u_benchmark_2013.vcxproj.filters
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{a19ef59c-c0d8-48a6-8d62-c158c7bac2fe}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{5a6ad543-f221-4cb6-addd-c9020acd752e}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\sam3u_benchmark.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/hotplugtest_2010.vcxproj b/msvc/sam3u_benchmark_2015.vcxproj
index d518b71..7d2d2e6 100644
--- a/msvc/hotplugtest_2010.vcxproj
+++ b/msvc/sam3u_benchmark_2015.vcxproj
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@@ -19,8 +19,8 @@
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
- <ProjectName>hotplugtest</ProjectName>
- <ProjectGuid>{99D2AC64-DC66-4422-91CE-6715C403C9E5}</ProjectGuid>
+ <ProjectName>sam3u_benchmark</ProjectName>
+ <ProjectGuid>{861cdd5f-59a2-4f34-957e-5c1af98be0a4}</ProjectGuid>
<RootNamespace>examples</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
@@ -28,6 +28,7 @@
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -45,13 +46,12 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <MinimalRebuild>true</MinimalRebuild>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
@@ -62,16 +62,21 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="..\examples\hotplugtest.c" />
+ <ClCompile Include="..\examples\sam3u_benchmark.c" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include=".\libusb_static_2010.vcxproj">
+ <ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include=".\libusb_static_2015.vcxproj">
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
@@ -79,4 +84,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/sam3u_benchmark_2015.vcxproj.filters b/msvc/sam3u_benchmark_2015.vcxproj.filters
new file mode 100644
index 0000000..e0f6bd0
--- /dev/null
+++ b/msvc/sam3u_benchmark_2015.vcxproj.filters
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{a19ef59c-c0d8-48a6-8d62-c158c7bac2fe}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{5a6ad543-f221-4cb6-addd-c9020acd752e}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\sam3u_benchmark.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/sam3u_benchmark_2017.vcxproj b/msvc/sam3u_benchmark_2017.vcxproj
new file mode 100644
index 0000000..ca29706
--- /dev/null
+++ b/msvc/sam3u_benchmark_2017.vcxproj
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|ARM64">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM64">
+ <Configuration>Release</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>sam3u_benchmark</ProjectName>
+ <ProjectGuid>{861cdd5f-59a2-4f34-957e-5c1af98be0a4}</ProjectGuid>
+ <RootNamespace>examples</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ <WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
+ <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion Condition="'$(Platform)'=='ARM' Or '$(Platform)'=='ARM64'">10.0.17763.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v141</PlatformToolset>
+ <WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <IntDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\$(ProjectName)\</IntDir>
+ <OutDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\</OutDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <WarningLevel>Level3</WarningLevel>
+ </ClCompile>
+ <ClCompile Condition="'$(Configuration)'=='Debug'">
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <Optimization>Disabled</Optimization>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <ClCompile Condition="'$(Configuration)'=='Release'">
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <Link Condition="'$(Configuration)'=='Debug'">
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\sam3u_benchmark.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include=".\libusb_static_2017.vcxproj">
+ <Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/sam3u_benchmark_2017.vcxproj.filters b/msvc/sam3u_benchmark_2017.vcxproj.filters
new file mode 100644
index 0000000..e0f6bd0
--- /dev/null
+++ b/msvc/sam3u_benchmark_2017.vcxproj.filters
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{a19ef59c-c0d8-48a6-8d62-c158c7bac2fe}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{5a6ad543-f221-4cb6-addd-c9020acd752e}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\sam3u_benchmark.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/sam3u_benchmark_2019.vcxproj b/msvc/sam3u_benchmark_2019.vcxproj
new file mode 100644
index 0000000..fd5317a
--- /dev/null
+++ b/msvc/sam3u_benchmark_2019.vcxproj
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|ARM64">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM64">
+ <Configuration>Release</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>sam3u_benchmark</ProjectName>
+ <ProjectGuid>{861cdd5f-59a2-4f34-957e-5c1af98be0a4}</ProjectGuid>
+ <RootNamespace>examples</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ <WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
+ <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v142</PlatformToolset>
+ <WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <IntDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\$(ProjectName)\</IntDir>
+ <OutDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\</OutDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <WarningLevel>Level3</WarningLevel>
+ </ClCompile>
+ <ClCompile Condition="'$(Configuration)'=='Debug'">
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <Optimization>Disabled</Optimization>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <ClCompile Condition="'$(Configuration)'=='Release'">
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
+ <SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <Link Condition="'$(Configuration)'=='Debug'">
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\sam3u_benchmark.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include=".\libusb_static_2019.vcxproj">
+ <Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/sam3u_benchmark_2019.vcxproj.filters b/msvc/sam3u_benchmark_2019.vcxproj.filters
new file mode 100644
index 0000000..e0f6bd0
--- /dev/null
+++ b/msvc/sam3u_benchmark_2019.vcxproj.filters
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{a19ef59c-c0d8-48a6-8d62-c158c7bac2fe}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{5a6ad543-f221-4cb6-addd-c9020acd752e}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\sam3u_benchmark.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/stdint.h b/msvc/stdint.h
deleted file mode 100644
index 00988d9..0000000
--- a/msvc/stdint.h
+++ /dev/null
@@ -1,256 +0,0 @@
-/**
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file was originally part of the w64 mingw-runtime package.
- */
-
-/* ISO C9x 7.18 Integer types <stdint.h>
- * Based on ISO/IEC SC22/WG14 9899 Committee draft (SC22 N2794)
- *
- * THIS SOFTWARE IS NOT COPYRIGHTED
- *
- * Contributor: Danny Smith <danny_r_smith_2001@yahoo.co.nz>
- * Modified for libusb/MSVC: Pete Batard <pbatard@gmail.com>
- *
- * This source code is offered for use in the public domain. You may
- * use, modify or distribute it freely.
- *
- * This code is distributed in the hope that it will be useful but
- * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
- * DISCLAIMED. This includes but is not limited to warranties of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Date: 2010-04-02
- */
-
-#ifndef _MSC_VER
-#error This header should only be used with Microsoft compilers
-#endif
-
-#ifndef _STDINT_H
-#define _STDINT_H
-
-#ifndef _INTPTR_T_DEFINED
-#define _INTPTR_T_DEFINED
-#ifndef __intptr_t_defined
-#define __intptr_t_defined
-#undef intptr_t
-#ifdef _WIN64
- typedef __int64 intptr_t;
-#else
- typedef int intptr_t;
-#endif /* _WIN64 */
-#endif /* __intptr_t_defined */
-#endif /* _INTPTR_T_DEFINED */
-
-#ifndef _UINTPTR_T_DEFINED
-#define _UINTPTR_T_DEFINED
-#ifndef __uintptr_t_defined
-#define __uintptr_t_defined
-#undef uintptr_t
-#ifdef _WIN64
- typedef unsigned __int64 uintptr_t;
-#else
- typedef unsigned int uintptr_t;
-#endif /* _WIN64 */
-#endif /* __uintptr_t_defined */
-#endif /* _UINTPTR_T_DEFINED */
-
-#ifndef _PTRDIFF_T_DEFINED
-#define _PTRDIFF_T_DEFINED
-#ifndef _PTRDIFF_T_
-#define _PTRDIFF_T_
-#undef ptrdiff_t
-#ifdef _WIN64
- typedef __int64 ptrdiff_t;
-#else
- typedef int ptrdiff_t;
-#endif /* _WIN64 */
-#endif /* _PTRDIFF_T_ */
-#endif /* _PTRDIFF_T_DEFINED */
-
-#ifndef _WCHAR_T_DEFINED
-#define _WCHAR_T_DEFINED
-#ifndef __cplusplus
- typedef unsigned short wchar_t;
-#endif /* C++ */
-#endif /* _WCHAR_T_DEFINED */
-
-#ifndef _WCTYPE_T_DEFINED
-#define _WCTYPE_T_DEFINED
-#ifndef _WINT_T
-#define _WINT_T
- typedef unsigned short wint_t;
- typedef unsigned short wctype_t;
-#endif /* _WINT_T */
-#endif /* _WCTYPE_T_DEFINED */
-
-/* 7.18.1.1 Exact-width integer types */
-typedef __int8 int8_t;
-typedef unsigned __int8 uint8_t;
-typedef __int16 int16_t;
-typedef unsigned __int16 uint16_t;
-typedef __int32 int32_t;
-typedef unsigned __int32 uint32_t;
-typedef __int64 int64_t;
-typedef unsigned __int64 uint64_t;
-
-/* 7.18.1.2 Minimum-width integer types */
-typedef signed char int_least8_t;
-typedef unsigned char uint_least8_t;
-typedef short int_least16_t;
-typedef unsigned short uint_least16_t;
-typedef int int_least32_t;
-typedef unsigned uint_least32_t;
-typedef __int64 int_least64_t;
-typedef unsigned __int64 uint_least64_t;
-
-/* 7.18.1.3 Fastest minimum-width integer types
- * Not actually guaranteed to be fastest for all purposes
- * Here we use the exact-width types for 8 and 16-bit ints.
- */
-typedef __int8 int_fast8_t;
-typedef unsigned __int8 uint_fast8_t;
-typedef __int16 int_fast16_t;
-typedef unsigned __int16 uint_fast16_t;
-typedef __int32 int_fast32_t;
-typedef unsigned __int32 uint_fast32_t;
-typedef __int64 int_fast64_t;
-typedef unsigned __int64 uint_fast64_t;
-
-/* 7.18.1.5 Greatest-width integer types */
-typedef __int64 intmax_t;
-typedef unsigned __int64 uintmax_t;
-
-/* 7.18.2 Limits of specified-width integer types */
-
-/* 7.18.2.1 Limits of exact-width integer types */
-#define INT8_MIN (-128)
-#define INT16_MIN (-32768)
-#define INT32_MIN (-2147483647 - 1)
-#define INT64_MIN (-9223372036854775807LL - 1)
-
-#define INT8_MAX 127
-#define INT16_MAX 32767
-#define INT32_MAX 2147483647
-#define INT64_MAX 9223372036854775807LL
-
-#define UINT8_MAX 255
-#define UINT16_MAX 65535
-#define UINT32_MAX 0xffffffffU /* 4294967295U */
-#define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */
-
-/* 7.18.2.2 Limits of minimum-width integer types */
-#define INT_LEAST8_MIN INT8_MIN
-#define INT_LEAST16_MIN INT16_MIN
-#define INT_LEAST32_MIN INT32_MIN
-#define INT_LEAST64_MIN INT64_MIN
-
-#define INT_LEAST8_MAX INT8_MAX
-#define INT_LEAST16_MAX INT16_MAX
-#define INT_LEAST32_MAX INT32_MAX
-#define INT_LEAST64_MAX INT64_MAX
-
-#define UINT_LEAST8_MAX UINT8_MAX
-#define UINT_LEAST16_MAX UINT16_MAX
-#define UINT_LEAST32_MAX UINT32_MAX
-#define UINT_LEAST64_MAX UINT64_MAX
-
-/* 7.18.2.3 Limits of fastest minimum-width integer types */
-#define INT_FAST8_MIN INT8_MIN
-#define INT_FAST16_MIN INT16_MIN
-#define INT_FAST32_MIN INT32_MIN
-#define INT_FAST64_MIN INT64_MIN
-
-#define INT_FAST8_MAX INT8_MAX
-#define INT_FAST16_MAX INT16_MAX
-#define INT_FAST32_MAX INT32_MAX
-#define INT_FAST64_MAX INT64_MAX
-
-#define UINT_FAST8_MAX UINT8_MAX
-#define UINT_FAST16_MAX UINT16_MAX
-#define UINT_FAST32_MAX UINT32_MAX
-#define UINT_FAST64_MAX UINT64_MAX
-
-/* 7.18.2.4 Limits of integer types capable of holding
- object pointers */
-#ifdef _WIN64
-#define INTPTR_MIN INT64_MIN
-#define INTPTR_MAX INT64_MAX
-#define UINTPTR_MAX UINT64_MAX
-#else
-#define INTPTR_MIN INT32_MIN
-#define INTPTR_MAX INT32_MAX
-#define UINTPTR_MAX UINT32_MAX
-#endif
-
-/* 7.18.2.5 Limits of greatest-width integer types */
-#define INTMAX_MIN INT64_MIN
-#define INTMAX_MAX INT64_MAX
-#define UINTMAX_MAX UINT64_MAX
-
-/* 7.18.3 Limits of other integer types */
-#ifdef _WIN64
-#define PTRDIFF_MIN INT64_MIN
-#define PTRDIFF_MAX INT64_MAX
-#else
-#define PTRDIFF_MIN INT32_MIN
-#define PTRDIFF_MAX INT32_MAX
-#endif
-
-#define SIG_ATOMIC_MIN INT32_MIN
-#define SIG_ATOMIC_MAX INT32_MAX
-
-#ifndef SIZE_MAX
-#ifdef _WIN64
-#define SIZE_MAX UINT64_MAX
-#else
-#define SIZE_MAX UINT32_MAX
-#endif
-#endif
-
-#ifndef WCHAR_MIN /* also in wchar.h */
-#define WCHAR_MIN 0U
-#define WCHAR_MAX 0xffffU
-#endif
-
-/*
- * wint_t is unsigned short for compatibility with MS runtime
- */
-#define WINT_MIN 0U
-#define WINT_MAX 0xffffU
-
-
-/* 7.18.4 Macros for integer constants */
-
-/* 7.18.4.1 Macros for minimum-width integer constants
-
- Accoding to Douglas Gwyn <gwyn@arl.mil>:
- "This spec was changed in ISO/IEC 9899:1999 TC1; in ISO/IEC
- 9899:1999 as initially published, the expansion was required
- to be an integer constant of precisely matching type, which
- is impossible to accomplish for the shorter types on most
- platforms, because C99 provides no standard way to designate
- an integer constant with width less than that of type int.
- TC1 changed this to require just an integer constant
- *expression* with *promoted* type."
-
- The trick used here is from Clive D W Feather.
-*/
-
-#define INT8_C(val) (INT_LEAST8_MAX-INT_LEAST8_MAX+(val))
-#define INT16_C(val) (INT_LEAST16_MAX-INT_LEAST16_MAX+(val))
-#define INT32_C(val) (INT_LEAST32_MAX-INT_LEAST32_MAX+(val))
-/* The 'trick' doesn't work in C89 for long long because, without
- suffix, (val) will be evaluated as int, not intmax_t */
-#define INT64_C(val) val##i64
-
-#define UINT8_C(val) (val)
-#define UINT16_C(val) (val)
-#define UINT32_C(val) (val##i32)
-#define UINT64_C(val) val##ui64
-
-/* 7.18.4.2 Macros for greatest-width integer constants */
-#define INTMAX_C(val) val##i64
-#define UINTMAX_C(val) val##ui64
-
-#endif
diff --git a/msvc/stress_2005.vcproj b/msvc/stress_2005.vcproj
deleted file mode 100644
index ebb5491..0000000
--- a/msvc/stress_2005.vcproj
+++ /dev/null
@@ -1,390 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="8.00"
- Name="stress"
- ProjectGUID="{53942EFF-C810-458D-B3CB-EE5CE9F1E781}"
- RootNamespace="tests"
- Keyword="Win32Proj"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="..\$(PlatformName)\$(ConfigurationName)\tests"
- IntermediateDirectory="..\$(PlatformName)\$(ConfigurationName)\tests\$(ProjectName)"
- ConfigurationType="1"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="..\$(PlatformName)\$(ConfigurationName)\tests"
- IntermediateDirectory="..\$(PlatformName)\$(ConfigurationName)\tests\$(ProjectName)"
- ConfigurationType="1"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="..\$(PlatformName)\$(ConfigurationName)\tests"
- IntermediateDirectory="..\$(PlatformName)\$(ConfigurationName)\tests\$(ProjectName)"
- ConfigurationType="1"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\libusb"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
- RuntimeLibrary="2"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="..\$(PlatformName)\$(ConfigurationName)\tests"
- IntermediateDirectory="..\$(PlatformName)\$(ConfigurationName)\tests\$(ProjectName)"
- ConfigurationType="1"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\libusb"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
- RuntimeLibrary="2"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\tests\testlib.c"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Detect64BitPortabilityProblems="false"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Detect64BitPortabilityProblems="false"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\tests\stress.c"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- Detect64BitPortabilityProblems="false"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|x64"
- >
- <Tool
- Name="VCCLCompilerTool"
- Detect64BitPortabilityProblems="false"
- />
- </FileConfiguration>
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- <File
- RelativePath="..\tests\libusb_testlib.h"
- >
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/msvc/stress_2012.vcxproj b/msvc/stress_2012.vcxproj
deleted file mode 100644
index 79bbb6f..0000000
--- a/msvc/stress_2012.vcxproj
+++ /dev/null
@@ -1,87 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectName>stress</ProjectName>
- <ProjectGuid>{53942EFF-C810-458D-B3CB-EE5CE9F1E781}</ProjectGuid>
- <RootNamespace>tests</RootNamespace>
- <Keyword>Win32Proj</Keyword>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v110</PlatformToolset>
- <WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <IntDir>$(ProjectDir)..\$(Platform)\$(Configuration)\tests\$(ProjectName)\</IntDir>
- <OutDir>$(ProjectDir)..\$(Platform)\$(Configuration)\tests\</OutDir>
- </PropertyGroup>
- <ItemDefinitionGroup>
- <ClCompile>
- <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <WarningLevel>Level3</WarningLevel>
- </ClCompile>
- <ClCompile Condition="'$(Configuration)'=='Debug'">
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <MinimalRebuild>true</MinimalRebuild>
- <Optimization>Disabled</Optimization>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- </ClCompile>
- <ClCompile Condition="'$(Configuration)'=='Release'">
- <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- </ClCompile>
- <Link>
- <ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
- <SubSystem>Console</SubSystem>
- </Link>
- <Link Condition="'$(Configuration)'=='Debug'">
- <GenerateDebugInformation>true</GenerateDebugInformation>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\tests\stress.c" />
- <ClCompile Include="..\tests\testlib.c" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="..\tests\libusb_testlib.h" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include=".\libusb_static_2012.vcxproj">
- <Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
- <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project>
diff --git a/msvc/stress_2013.vcxproj b/msvc/stress_2013.vcxproj
index 3200900..2d5a3c1 100644
--- a/msvc/stress_2013.vcxproj
+++ b/msvc/stress_2013.vcxproj
@@ -45,7 +45,6 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
- <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
@@ -63,6 +62,7 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -73,6 +73,8 @@
<ClCompile Include="..\tests\testlib.c" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\libusb.h" />
<ClInclude Include="..\tests\libusb_testlib.h" />
</ItemGroup>
<ItemGroup>
@@ -84,4 +86,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/stress_2013.vcxproj.filters b/msvc/stress_2013.vcxproj.filters
new file mode 100644
index 0000000..9c867ea
--- /dev/null
+++ b/msvc/stress_2013.vcxproj.filters
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{9c3f4e23-69bf-41de-adfd-324d8a986054}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{0c2492ba-a6ee-4a3d-94c3-3e1ec440c8dd}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\tests\libusb_testlib.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\tests\stress.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\tests\testlib.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/stress_2015.vcxproj b/msvc/stress_2015.vcxproj
index 7dc3d47..dc1d1d2 100644
--- a/msvc/stress_2015.vcxproj
+++ b/msvc/stress_2015.vcxproj
@@ -52,7 +52,6 @@
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <MinimalRebuild>true</MinimalRebuild>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
@@ -63,6 +62,7 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -73,6 +73,8 @@
<ClCompile Include="..\tests\testlib.c" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\libusb.h" />
<ClInclude Include="..\tests\libusb_testlib.h" />
</ItemGroup>
<ItemGroup>
@@ -84,4 +86,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/stress_2015.vcxproj.filters b/msvc/stress_2015.vcxproj.filters
new file mode 100644
index 0000000..9c867ea
--- /dev/null
+++ b/msvc/stress_2015.vcxproj.filters
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{9c3f4e23-69bf-41de-adfd-324d8a986054}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{0c2492ba-a6ee-4a3d-94c3-3e1ec440c8dd}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\tests\libusb_testlib.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\tests\stress.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\tests\testlib.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/stress_2017.vcxproj b/msvc/stress_2017.vcxproj
index 7df6147..9d412db 100644
--- a/msvc/stress_2017.vcxproj
+++ b/msvc/stress_2017.vcxproj
@@ -39,9 +39,9 @@
<ProjectGuid>{53942EFF-C810-458D-B3CB-EE5CE9F1E781}</ProjectGuid>
<RootNamespace>tests</RootNamespace>
<Keyword>Win32Proj</Keyword>
- <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion Condition="'$(Platform)'=='ARM' Or '$(Platform)'=='ARM64'">10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
@@ -71,7 +71,6 @@
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <MinimalRebuild>true</MinimalRebuild>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
@@ -82,13 +81,10 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
@@ -96,6 +92,8 @@
<ClCompile Include="..\tests\testlib.c" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\libusb.h" />
<ClInclude Include="..\tests\libusb_testlib.h" />
</ItemGroup>
<ItemGroup>
diff --git a/msvc/stress_2017.vcxproj.filters b/msvc/stress_2017.vcxproj.filters
new file mode 100644
index 0000000..9c867ea
--- /dev/null
+++ b/msvc/stress_2017.vcxproj.filters
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{9c3f4e23-69bf-41de-adfd-324d8a986054}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{0c2492ba-a6ee-4a3d-94c3-3e1ec440c8dd}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\tests\libusb_testlib.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\tests\stress.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\tests\testlib.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/stress_2010.vcxproj b/msvc/stress_2019.vcxproj
index ce0acd6..d9ca666 100644
--- a/msvc/stress_2010.vcxproj
+++ b/msvc/stress_2019.vcxproj
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|ARM64">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
@@ -9,6 +17,14 @@
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM64">
+ <Configuration>Release</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
@@ -23,11 +39,15 @@
<ProjectGuid>{53942EFF-C810-458D-B3CB-EE5CE9F1E781}</ProjectGuid>
<RootNamespace>tests</RootNamespace>
<Keyword>Win32Proj</Keyword>
+ <WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
+ <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -51,7 +71,6 @@
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <MinimalRebuild>true</MinimalRebuild>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
@@ -62,6 +81,7 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -72,10 +92,12 @@
<ClCompile Include="..\tests\testlib.c" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include=".\config.h" />
+ <ClInclude Include="..\libusb\libusb.h" />
<ClInclude Include="..\tests\libusb_testlib.h" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include=".\libusb_static_2010.vcxproj">
+ <ProjectReference Include=".\libusb_static_2019.vcxproj">
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
@@ -83,4 +105,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/stress_2019.vcxproj.filters b/msvc/stress_2019.vcxproj.filters
new file mode 100644
index 0000000..9c867ea
--- /dev/null
+++ b/msvc/stress_2019.vcxproj.filters
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{9c3f4e23-69bf-41de-adfd-324d8a986054}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{0c2492ba-a6ee-4a3d-94c3-3e1ec440c8dd}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include=".\config.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\tests\libusb_testlib.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\tests\stress.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\tests\testlib.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/stress_sources b/msvc/stress_sources
deleted file mode 100644
index 5bdd2e8..0000000
--- a/msvc/stress_sources
+++ /dev/null
@@ -1,21 +0,0 @@
-TARGETNAME=stress
-TARGETTYPE=PROGRAM
-386_STDCALL=0
-
-_NT_TARGET_VERSION=$(_NT_TARGET_VERSION_WINXP)
-
-!IFNDEF MSC_WARNING_LEVEL
-MSC_WARNING_LEVEL=/W3
-!ENDIF
-
-!IFDEF STATIC_LIBC
-USE_LIBCMT=1
-!ELSE
-USE_MSVCRT=1
-!ENDIF
-
-UMTYPE=console
-INCLUDES=..\..\msvc;..\..\libusb;$(DDK_INC_PATH)
-UMLIBS=..\..\libusb\os\obj$(BUILD_ALT_DIR)\*\libusb-1.0.lib
-SOURCES=..\stress.c \
- ..\testlib.c
diff --git a/msvc/stress_wince.vcproj b/msvc/stress_wince.vcproj
deleted file mode 100644
index 86b0388..0000000
--- a/msvc/stress_wince.vcproj
+++ /dev/null
@@ -1,1128 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="8.00"
- Name="stress"
- ProjectGUID="{61476624-3354-48C8-9334-85AC0D624640}"
- RootNamespace="stress"
- >
- <Platforms>
- <Platform
- Name="STANDARDSDK_500 (ARMV4I)"
- />
- <Platform
- Name="STANDARDSDK_500 (MIPSII)"
- />
- <Platform
- Name="STANDARDSDK_500 (MIPSII_FP)"
- />
- <Platform
- Name="STANDARDSDK_500 (MIPSIV)"
- />
- <Platform
- Name="STANDARDSDK_500 (MIPSIV_FP)"
- />
- <Platform
- Name="STANDARDSDK_500 (SH4)"
- />
- <Platform
- Name="STANDARDSDK_500 (x86)"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|STANDARDSDK_500 (ARMV4I)"
- OutputDirectory="$(SolutionDir)..\ARMV4I\$(ConfigurationName)\tests"
- IntermediateDirectory="$(SolutionDir)..\ARMV4I\$(ConfigurationName)\tests\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;DEBUG;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory="%CSIDL_PROGRAM_FILES%\stress"
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (MIPSII)"
- OutputDirectory="$(SolutionDir)..\MIPSII\$(ConfigurationName)\tests"
- IntermediateDirectory="$(SolutionDir)..\MIPSII\$(ConfigurationName)\tests\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;DEBUG;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (MIPSII_FP)"
- OutputDirectory="$(SolutionDir)..\MIPSII_FP\$(ConfigurationName)\tests"
- IntermediateDirectory="$(SolutionDir)..\MIPSII_FP\$(ConfigurationName)\tests\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;DEBUG;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (MIPSIV)"
- OutputDirectory="$(SolutionDir)..\MIPSIV\$(ConfigurationName)\tests"
- IntermediateDirectory="$(SolutionDir)..\MIPSIV\$(ConfigurationName)\tests\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;DEBUG;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (MIPSIV_FP)"
- OutputDirectory="$(SolutionDir)..\MIPSIV_FP\$(ConfigurationName)\tests"
- IntermediateDirectory="$(SolutionDir)..\MIPSIV_FP\$(ConfigurationName)\tests\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;DEBUG;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (SH4)"
- OutputDirectory="$(SolutionDir)..\SH4\$(ConfigurationName)\tests"
- IntermediateDirectory="$(SolutionDir)..\SH4\$(ConfigurationName)\tests\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;DEBUG;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (x86)"
- OutputDirectory="$(SolutionDir)..\x86\$(ConfigurationName)\tests"
- IntermediateDirectory="$(SolutionDir)..\x86\$(ConfigurationName)\tests\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;DEBUG;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- IgnoreDefaultLibraryNames="oldnames.lib,libc.lib"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (ARMV4I)"
- OutputDirectory="$(SolutionDir)..\ARMV4I\$(ConfigurationName)\tests"
- IntermediateDirectory="$(SolutionDir)..\ARMV4I\$(ConfigurationName)\tests\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (MIPSII)"
- OutputDirectory="$(SolutionDir)..\MIPSII\$(ConfigurationName)\tests"
- IntermediateDirectory="$(SolutionDir)..\MIPSII\$(ConfigurationName)\tests\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (MIPSII_FP)"
- OutputDirectory="$(SolutionDir)..\MIPSII_FP\$(ConfigurationName)\tests"
- IntermediateDirectory="$(SolutionDir)..\MIPSII_FP\$(ConfigurationName)\tests\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (MIPSIV)"
- OutputDirectory="$(SolutionDir)..\MIPSIV\$(ConfigurationName)\tests"
- IntermediateDirectory="$(SolutionDir)..\MIPSIV\$(ConfigurationName)\tests\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (MIPSIV_FP)"
- OutputDirectory="$(SolutionDir)..\MIPSIV_FP\$(ConfigurationName)\tests"
- IntermediateDirectory="$(SolutionDir)..\MIPSIV_FP\$(ConfigurationName)\tests\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (SH4)"
- OutputDirectory="$(SolutionDir)..\SH4\$(ConfigurationName)\tests"
- IntermediateDirectory="$(SolutionDir)..\SH4\$(ConfigurationName)\tests\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (x86)"
- OutputDirectory="$(SolutionDir)..\x86\$(ConfigurationName)\tests"
- IntermediateDirectory="$(SolutionDir)..\x86\$(ConfigurationName)\tests\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- IgnoreDefaultLibraryNames="oldnames.lib,libc.lib"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- </Configurations>
- <References>
- <ProjectReference
- ReferencedProjectIdentifier="{6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}"
- RelativePathToProject=".\libusb_dll.vcproj"
- />
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\tests\stress.c"
- >
- </File>
- <File
- RelativePath="..\tests\testlib.c"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- <File
- RelativePath="..\tests\libusb_testlib.h"
- >
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
- >
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/msvc/testlibusb_2012.vcxproj b/msvc/testlibusb_2012.vcxproj
deleted file mode 100644
index 2ab1cad..0000000
--- a/msvc/testlibusb_2012.vcxproj
+++ /dev/null
@@ -1,83 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectName>testlibusb</ProjectName>
- <ProjectGuid>{70828935-325B-4749-B381-0E55EF31AEE8}</ProjectGuid>
- <RootNamespace>examples</RootNamespace>
- <Keyword>Win32Proj</Keyword>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v110</PlatformToolset>
- <WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <IntDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\$(ProjectName)\</IntDir>
- <OutDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\</OutDir>
- </PropertyGroup>
- <ItemDefinitionGroup>
- <ClCompile>
- <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <WarningLevel>Level3</WarningLevel>
- </ClCompile>
- <ClCompile Condition="'$(Configuration)'=='Debug'">
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <MinimalRebuild>true</MinimalRebuild>
- <Optimization>Disabled</Optimization>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- </ClCompile>
- <ClCompile Condition="'$(Configuration)'=='Release'">
- <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- </ClCompile>
- <Link>
- <ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
- <SubSystem>Console</SubSystem>
- </Link>
- <Link Condition="'$(Configuration)'=='Debug'">
- <GenerateDebugInformation>true</GenerateDebugInformation>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\examples\testlibusb.c" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include=".\libusb_static_2012.vcxproj">
- <Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
- <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project>
diff --git a/msvc/testlibusb_2013.vcxproj b/msvc/testlibusb_2013.vcxproj
index 96c75de..dd7f1b6 100644
--- a/msvc/testlibusb_2013.vcxproj
+++ b/msvc/testlibusb_2013.vcxproj
@@ -45,8 +45,7 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
- <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
@@ -63,6 +62,7 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -72,6 +72,9 @@
<ClCompile Include="..\examples\testlibusb.c" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
<ProjectReference Include=".\libusb_static_2013.vcxproj">
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
@@ -80,4 +83,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/testlibusb_2013.vcxproj.filters b/msvc/testlibusb_2013.vcxproj.filters
new file mode 100644
index 0000000..d655f83
--- /dev/null
+++ b/msvc/testlibusb_2013.vcxproj.filters
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4a89b408-009b-41e4-bb05-78f07a7c7f82}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{9dc8bfc2-c1d0-41d9-9fd2-858137d5d7c7}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\testlibusb.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/testlibusb_2015.vcxproj b/msvc/testlibusb_2015.vcxproj
index 2eb59dc..c2f356b 100644
--- a/msvc/testlibusb_2015.vcxproj
+++ b/msvc/testlibusb_2015.vcxproj
@@ -46,13 +46,12 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <MinimalRebuild>true</MinimalRebuild>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
@@ -63,6 +62,7 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -72,6 +72,9 @@
<ClCompile Include="..\examples\testlibusb.c" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
<ProjectReference Include=".\libusb_static_2015.vcxproj">
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
@@ -80,4 +83,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/testlibusb_2015.vcxproj.filters b/msvc/testlibusb_2015.vcxproj.filters
new file mode 100644
index 0000000..d655f83
--- /dev/null
+++ b/msvc/testlibusb_2015.vcxproj.filters
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4a89b408-009b-41e4-bb05-78f07a7c7f82}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{9dc8bfc2-c1d0-41d9-9fd2-858137d5d7c7}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\testlibusb.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/testlibusb_2017.vcxproj b/msvc/testlibusb_2017.vcxproj
index be240d4..c7cbc84 100644
--- a/msvc/testlibusb_2017.vcxproj
+++ b/msvc/testlibusb_2017.vcxproj
@@ -39,9 +39,9 @@
<ProjectGuid>{70828935-325B-4749-B381-0E55EF31AEE8}</ProjectGuid>
<RootNamespace>examples</RootNamespace>
<Keyword>Win32Proj</Keyword>
- <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion Condition="'$(Platform)'=='ARM' Or '$(Platform)'=='ARM64'">10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
@@ -65,13 +65,12 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <MinimalRebuild>true</MinimalRebuild>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
@@ -82,19 +81,19 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\examples\testlibusb.c" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
<ProjectReference Include=".\libusb_static_2017.vcxproj">
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
diff --git a/msvc/testlibusb_2017.vcxproj.filters b/msvc/testlibusb_2017.vcxproj.filters
new file mode 100644
index 0000000..d655f83
--- /dev/null
+++ b/msvc/testlibusb_2017.vcxproj.filters
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4a89b408-009b-41e4-bb05-78f07a7c7f82}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{9dc8bfc2-c1d0-41d9-9fd2-858137d5d7c7}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\testlibusb.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/testlibusb_2010.vcxproj b/msvc/testlibusb_2019.vcxproj
index 349adee..896d4fb 100644
--- a/msvc/testlibusb_2010.vcxproj
+++ b/msvc/testlibusb_2019.vcxproj
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|ARM64">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
@@ -9,6 +17,14 @@
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM64">
+ <Configuration>Release</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
@@ -23,11 +39,15 @@
<ProjectGuid>{70828935-325B-4749-B381-0E55EF31AEE8}</ProjectGuid>
<RootNamespace>examples</RootNamespace>
<Keyword>Win32Proj</Keyword>
+ <WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
+ <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -45,13 +65,12 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <MinimalRebuild>true</MinimalRebuild>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
@@ -62,6 +81,7 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -71,7 +91,10 @@
<ClCompile Include="..\examples\testlibusb.c" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include=".\libusb_static_2010.vcxproj">
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include=".\libusb_static_2019.vcxproj">
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
@@ -79,4 +102,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/testlibusb_2019.vcxproj.filters b/msvc/testlibusb_2019.vcxproj.filters
new file mode 100644
index 0000000..d655f83
--- /dev/null
+++ b/msvc/testlibusb_2019.vcxproj.filters
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4a89b408-009b-41e4-bb05-78f07a7c7f82}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{9dc8bfc2-c1d0-41d9-9fd2-858137d5d7c7}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\testlibusb.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/testlibusb_sources b/msvc/testlibusb_sources
deleted file mode 100644
index 9b96ebe..0000000
--- a/msvc/testlibusb_sources
+++ /dev/null
@@ -1,20 +0,0 @@
-TARGETNAME=testlibusb
-TARGETTYPE=PROGRAM
-386_STDCALL=0
-
-_NT_TARGET_VERSION=$(_NT_TARGET_VERSION_WINXP)
-
-!IFNDEF MSC_WARNING_LEVEL
-MSC_WARNING_LEVEL=/W3
-!ENDIF
-
-!IFDEF STATIC_LIBC
-USE_LIBCMT=1
-!ELSE
-USE_MSVCRT=1
-!ENDIF
-
-UMTYPE=console
-INCLUDES=..\..\msvc;..\..\libusb;$(DDK_INC_PATH)
-UMLIBS=..\..\libusb\os\obj$(BUILD_ALT_DIR)\*\libusb-1.0.lib
-SOURCES=..\testlibusb.c
diff --git a/msvc/xusb.dsp b/msvc/xusb.dsp
deleted file mode 100644
index 0e5c13b..0000000
--- a/msvc/xusb.dsp
+++ /dev/null
@@ -1,102 +0,0 @@
-# Microsoft Developer Studio Project File - Name="xusb" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=xusb - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "xusb.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "xusb.mak" CFG="xusb - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "xusb - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "xusb - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "xusb - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "../Win32/Release/examples"
-# PROP Intermediate_Dir "../Win32/Release/examples/xusb"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I "../libusb" /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /U "_MBCS" /FR /FD /EHsc /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-
-!ELSEIF "$(CFG)" == "xusb - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "xusb___Win32_Debug"
-# PROP BASE Intermediate_Dir "xusb___Win32_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "../Win32/Debug/examples"
-# PROP Intermediate_Dir "../Win32/Debug/examples/xusb"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /I "../libusb" /I "." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /U "_MBCS" /FR /FD /GZ /EHsc /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo /n "../Win32/Debug/dll/core.sbr" "../Win32/Debug/dll/descriptor.sbr" "../Win32/Debug/dll/io.sbr" "../Win32/Debug/dll/sync.sbr" "../Win32/Debug/dll/poll_windows.sbr" "../Win32/Debug/dll/threads_windows.sbr" "../Win32/Debug/dll/windows_usb.sbr"
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
-
-!ENDIF
-
-# Begin Target
-
-# Name "xusb - Win32 Release"
-# Name "xusb - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\examples\xusb.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/msvc/xusb_2005.vcproj b/msvc/xusb_2005.vcproj
deleted file mode 100644
index 6ad9b7c..0000000
--- a/msvc/xusb_2005.vcproj
+++ /dev/null
@@ -1,344 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="8.00"
- Name="xusb"
- ProjectGUID="{08A6FA39-21B7-4A05-9252-2F9864A5E5A4}"
- RootNamespace="examples"
- Keyword="Win32Proj"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="..\$(PlatformName)\$(ConfigurationName)\examples"
- IntermediateDirectory="..\$(PlatformName)\$(ConfigurationName)\examples\$(ProjectName)"
- ConfigurationType="1"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="..\$(PlatformName)\$(ConfigurationName)\examples"
- IntermediateDirectory="..\$(PlatformName)\$(ConfigurationName)\examples\$(ProjectName)"
- ConfigurationType="1"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="2"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="..\$(PlatformName)\$(ConfigurationName)\examples"
- IntermediateDirectory="..\$(PlatformName)\$(ConfigurationName)\examples\$(ProjectName)"
- ConfigurationType="1"
- CharacterSet="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- LinkIncremental="2"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="..\$(PlatformName)\$(ConfigurationName)\examples"
- IntermediateDirectory="..\$(PlatformName)\$(ConfigurationName)\examples\$(ProjectName)"
- ConfigurationType="1"
- CharacterSet="1"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=".;..\libusb"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="2"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="false"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\examples\xusb.c"
- >
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/msvc/xusb_2012.vcxproj b/msvc/xusb_2012.vcxproj
deleted file mode 100644
index c08dc2b..0000000
--- a/msvc/xusb_2012.vcxproj
+++ /dev/null
@@ -1,83 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectName>xusb</ProjectName>
- <ProjectGuid>{3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}</ProjectGuid>
- <RootNamespace>examples</RootNamespace>
- <Keyword>Win32Proj</Keyword>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v110</PlatformToolset>
- <WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <IntDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\$(ProjectName)\</IntDir>
- <OutDir>$(ProjectDir)..\$(Platform)\$(Configuration)\examples\</OutDir>
- </PropertyGroup>
- <ItemDefinitionGroup>
- <ClCompile>
- <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <WarningLevel>Level3</WarningLevel>
- </ClCompile>
- <ClCompile Condition="'$(Configuration)'=='Debug'">
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <Optimization>Disabled</Optimization>
- <MinimalRebuild>true</MinimalRebuild>
- <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
- </ClCompile>
- <ClCompile Condition="'$(Configuration)'=='Release'">
- <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- </ClCompile>
- <Link>
- <ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
- <SubSystem>Console</SubSystem>
- </Link>
- <Link Condition="'$(Configuration)'=='Debug'">
- <GenerateDebugInformation>true</GenerateDebugInformation>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\examples\xusb.c" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include=".\libusb_static_2012.vcxproj">
- <Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
- <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project>
diff --git a/msvc/xusb_2013.vcxproj b/msvc/xusb_2013.vcxproj
index df7ed14..ba9cd72 100644
--- a/msvc/xusb_2013.vcxproj
+++ b/msvc/xusb_2013.vcxproj
@@ -45,8 +45,7 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
- <AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
@@ -63,6 +62,7 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -72,6 +72,9 @@
<ClCompile Include="..\examples\xusb.c" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
<ProjectReference Include=".\libusb_static_2013.vcxproj">
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
@@ -80,4 +83,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/xusb_2013.vcxproj.filters b/msvc/xusb_2013.vcxproj.filters
new file mode 100644
index 0000000..30dca26
--- /dev/null
+++ b/msvc/xusb_2013.vcxproj.filters
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4bdcefa9-8c79-431b-965b-15b234737380}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{f81e24cd-e12b-4324-ada3-accbab00ef08}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\xusb.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/xusb_2015.vcxproj b/msvc/xusb_2015.vcxproj
index 4582e3b..1b5d944 100644
--- a/msvc/xusb_2015.vcxproj
+++ b/msvc/xusb_2015.vcxproj
@@ -46,14 +46,13 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
- <MinimalRebuild>true</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Release'">
@@ -63,6 +62,7 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -72,6 +72,9 @@
<ClCompile Include="..\examples\xusb.c" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
<ProjectReference Include=".\libusb_static_2015.vcxproj">
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
@@ -80,4 +83,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/xusb_2015.vcxproj.filters b/msvc/xusb_2015.vcxproj.filters
new file mode 100644
index 0000000..30dca26
--- /dev/null
+++ b/msvc/xusb_2015.vcxproj.filters
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4bdcefa9-8c79-431b-965b-15b234737380}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{f81e24cd-e12b-4324-ada3-accbab00ef08}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\xusb.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/xusb_2017.vcxproj b/msvc/xusb_2017.vcxproj
index f03ae6b..4526d94 100644
--- a/msvc/xusb_2017.vcxproj
+++ b/msvc/xusb_2017.vcxproj
@@ -39,9 +39,9 @@
<ProjectGuid>{3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}</ProjectGuid>
<RootNamespace>examples</RootNamespace>
<Keyword>Win32Proj</Keyword>
- <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion Condition="'$(Platform)'=='ARM' Or '$(Platform)'=='ARM64'">10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
@@ -65,14 +65,13 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
- <MinimalRebuild>true</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Release'">
@@ -82,19 +81,19 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\examples\xusb.c" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
<ProjectReference Include=".\libusb_static_2017.vcxproj">
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
diff --git a/msvc/xusb_2017.vcxproj.filters b/msvc/xusb_2017.vcxproj.filters
new file mode 100644
index 0000000..30dca26
--- /dev/null
+++ b/msvc/xusb_2017.vcxproj.filters
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4bdcefa9-8c79-431b-965b-15b234737380}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{f81e24cd-e12b-4324-ada3-accbab00ef08}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\xusb.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/xusb_2010.vcxproj b/msvc/xusb_2019.vcxproj
index 165e144..d61b0cb 100644
--- a/msvc/xusb_2010.vcxproj
+++ b/msvc/xusb_2019.vcxproj
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|ARM">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|ARM64">
+ <Configuration>Debug</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
@@ -9,6 +17,14 @@
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM">
+ <Configuration>Release</Configuration>
+ <Platform>ARM</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|ARM64">
+ <Configuration>Release</Configuration>
+ <Platform>ARM64</Platform>
+ </ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
@@ -23,11 +39,15 @@
<ProjectGuid>{3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}</ProjectGuid>
<RootNamespace>examples</RootNamespace>
<Keyword>Win32Proj</Keyword>
+ <WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
+ <WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization Condition="'$(Configuration)'=='Release'">true</WholeProgramOptimization>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -45,14 +65,13 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
- <AdditionalIncludeDirectories>..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>.;..\libusb;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Debug'">
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
- <MinimalRebuild>true</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<ClCompile Condition="'$(Configuration)'=='Release'">
@@ -62,6 +81,7 @@
<Link>
<ProgramDatabaseFile>$(TargetDir)$(ProjectName).pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
+ <AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Link Condition="'$(Configuration)'=='Debug'">
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -71,7 +91,10 @@
<ClCompile Include="..\examples\xusb.c" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include=".\libusb_static_2010.vcxproj">
+ <ClInclude Include="..\libusb\libusb.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include=".\libusb_static_2019.vcxproj">
<Project>{349ee8f9-7d25-4909-aaf5-ff3fade72187}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
@@ -79,4 +102,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/msvc/xusb_2019.vcxproj.filters b/msvc/xusb_2019.vcxproj.filters
new file mode 100644
index 0000000..30dca26
--- /dev/null
+++ b/msvc/xusb_2019.vcxproj.filters
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4bdcefa9-8c79-431b-965b-15b234737380}</UniqueIdentifier>
+ <Extensions>c</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{f81e24cd-e12b-4324-ada3-accbab00ef08}</UniqueIdentifier>
+ <Extensions>h</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\libusb\libusb.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\examples\xusb.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/msvc/xusb_sources b/msvc/xusb_sources
deleted file mode 100644
index 8b87492..0000000
--- a/msvc/xusb_sources
+++ /dev/null
@@ -1,20 +0,0 @@
-TARGETNAME=xusb
-TARGETTYPE=PROGRAM
-386_STDCALL=0
-
-_NT_TARGET_VERSION=$(_NT_TARGET_VERSION_WINXP)
-
-!IFNDEF MSC_WARNING_LEVEL
-MSC_WARNING_LEVEL=/W3
-!ENDIF
-
-!IFDEF STATIC_LIBC
-USE_LIBCMT=1
-!ELSE
-USE_MSVCRT=1
-!ENDIF
-
-UMTYPE=console
-INCLUDES=..\..\msvc;..\..\libusb;$(DDK_INC_PATH)
-UMLIBS=..\..\libusb\os\obj$(BUILD_ALT_DIR)\*\libusb-1.0.lib
-SOURCES=..\xusb.c
diff --git a/msvc/xusb_wince.vcproj b/msvc/xusb_wince.vcproj
deleted file mode 100644
index 17f1e85..0000000
--- a/msvc/xusb_wince.vcproj
+++ /dev/null
@@ -1,1120 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="8.00"
- Name="xusb"
- ProjectGUID="{93F53A7E-6DEF-469A-ABD4-A5AD02A0A511}"
- RootNamespace="xusb"
- >
- <Platforms>
- <Platform
- Name="STANDARDSDK_500 (ARMV4I)"
- />
- <Platform
- Name="STANDARDSDK_500 (MIPSII)"
- />
- <Platform
- Name="STANDARDSDK_500 (MIPSII_FP)"
- />
- <Platform
- Name="STANDARDSDK_500 (MIPSIV)"
- />
- <Platform
- Name="STANDARDSDK_500 (MIPSIV_FP)"
- />
- <Platform
- Name="STANDARDSDK_500 (SH4)"
- />
- <Platform
- Name="STANDARDSDK_500 (x86)"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|STANDARDSDK_500 (ARMV4I)"
- OutputDirectory="$(SolutionDir)..\ARMV4I\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\ARMV4I\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;DEBUG;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory="%CSIDL_PROGRAM_FILES%\xusb"
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (MIPSII)"
- OutputDirectory="$(SolutionDir)..\MIPSII\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\MIPSII\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;DEBUG;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (MIPSII_FP)"
- OutputDirectory="$(SolutionDir)..\MIPSII_FP\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\MIPSII_FP\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;DEBUG;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (MIPSIV)"
- OutputDirectory="$(SolutionDir)..\MIPSIV\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\MIPSIV\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;DEBUG;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (MIPSIV_FP)"
- OutputDirectory="$(SolutionDir)..\MIPSIV_FP\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\MIPSIV_FP\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;DEBUG;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (SH4)"
- OutputDirectory="$(SolutionDir)..\SH4\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\SH4\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;DEBUG;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Debug|STANDARDSDK_500 (x86)"
- OutputDirectory="$(SolutionDir)..\x86\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\x86\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;DEBUG;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="3"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- IgnoreDefaultLibraryNames="oldnames.lib,libc.lib"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (ARMV4I)"
- OutputDirectory="$(SolutionDir)..\ARMV4I\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\ARMV4I\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (MIPSII)"
- OutputDirectory="$(SolutionDir)..\MIPSII\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\MIPSII\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (MIPSII_FP)"
- OutputDirectory="$(SolutionDir)..\MIPSII_FP\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\MIPSII_FP\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (MIPSIV)"
- OutputDirectory="$(SolutionDir)..\MIPSIV\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\MIPSIV\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (MIPSIV_FP)"
- OutputDirectory="$(SolutionDir)..\MIPSIV_FP\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\MIPSIV_FP\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (SH4)"
- OutputDirectory="$(SolutionDir)..\SH4\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\SH4\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- <Configuration
- Name="Release|STANDARDSDK_500 (x86)"
- OutputDirectory="$(SolutionDir)..\x86\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)..\x86\$(ConfigurationName)\examples\$(TargetName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="1"
- />
- <Tool
- Name="VCCLCompilerTool"
- ExecutionBucket="7"
- AdditionalIncludeDirectories="..\libusb;."
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;WINCE;_CONSOLE;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
- MinimalRebuild="true"
- RuntimeLibrary="2"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- GenerateDebugInformation="true"
- SubSystem="9"
- IgnoreDefaultLibraryNames="oldnames.lib,libc.lib"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- EntryPointSymbol="mainACRTStartup"
- TargetMachine="0"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCCodeSignTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
- </Configuration>
- </Configurations>
- <References>
- <ProjectReference
- ReferencedProjectIdentifier="{6A49B75F-FB1C-45C0-B7C3-A7698255E7E9}"
- RelativePathToProject=".\libusb-1.0.vcproj"
- />
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\examples\xusb.c"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
- >
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/test b/test
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 12c5105..cb8fad9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,5 +1,6 @@
AM_CPPFLAGS = -I$(top_srcdir)/libusb
LDADD = ../libusb/libusb-1.0.la
+LIBS =
noinst_PROGRAMS = stress
diff --git a/tests/libusb_testlib.h b/tests/libusb_testlib.h
index 6c987d3..145f4e6 100644
--- a/tests/libusb_testlib.h
+++ b/tests/libusb_testlib.h
@@ -20,17 +20,7 @@
#ifndef LIBUSB_TESTLIB_H
#define LIBUSB_TESTLIB_H
-#include <stdio.h>
-
-#if !defined(bool)
-#define bool int
-#endif
-#if !defined(true)
-#define true (1 == 1)
-#endif
-#if !defined(false)
-#define false (!true)
-#endif
+#include <config.h>
/** Values returned from a test function to indicate test result */
typedef enum {
@@ -41,53 +31,33 @@ typedef enum {
/** Indicates that an unexpected error occurred. */
TEST_STATUS_ERROR,
/** Indicates that the test can't be run. For example this may be
- * due to no suitable device being connected to perform the tests.*/
+ * due to no suitable device being connected to perform the tests. */
TEST_STATUS_SKIP
} libusb_testlib_result;
/**
- * Context for test library functions
- */
-typedef struct {
- char ** test_names;
- int test_count;
- bool list_tests;
- bool verbose;
- int old_stdout;
- int old_stderr;
- FILE* output_file;
- int null_fd;
-} libusb_testlib_ctx;
-
-/**
* Logs some test information or state
*/
-void libusb_testlib_logf(libusb_testlib_ctx * ctx,
- const char* fmt, ...);
-
-/**
- * Function pointer for a libusb test function.
- *
- * Should return TEST_STATUS_SUCCESS on success or another TEST_STATUS value.
- */
-typedef libusb_testlib_result
-(*libusb_testlib_test_function)(libusb_testlib_ctx * ctx);
+void libusb_testlib_logf(const char *fmt, ...) PRINTF_FORMAT(1, 2);
/**
* Structure holding a test description.
*/
typedef struct {
/** Human readable name of the test. */
- const char * name;
- /** The test library will call this function to run the test. */
- libusb_testlib_test_function function;
+ const char *name;
+ /** The test library will call this function to run the test.
+ *
+ * Should return TEST_STATUS_SUCCESS on success or another TEST_STATUS value.
+ */
+ libusb_testlib_result (*function)(void);
} libusb_testlib_test;
/**
* Value to use at the end of a test array to indicate the last
* element.
*/
-#define LIBUSB_NULL_TEST {NULL, NULL}
+#define LIBUSB_NULL_TEST { NULL, NULL }
/**
* Runs the tests provided.
@@ -100,8 +70,7 @@ typedef struct {
* \param tests A NULL_TEST terminated array of tests
* \return 0 on success, non-zero on failure
*/
-int libusb_testlib_run_tests(int argc,
- char ** argv,
- const libusb_testlib_test * tests);
+int libusb_testlib_run_tests(int argc, char *argv[],
+ const libusb_testlib_test *tests);
#endif //LIBUSB_TESTLIB_H
diff --git a/tests/stress.c b/tests/stress.c
index 0e2dbe5..6dcb8f3 100644
--- a/tests/stress.c
+++ b/tests/stress.c
@@ -17,111 +17,116 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <stdio.h>
+#include <config.h>
+
#include <string.h>
-#include <memory.h>
#include "libusb.h"
#include "libusb_testlib.h"
/** Test that creates and destroys a single concurrent context
* 10000 times. */
-static libusb_testlib_result test_init_and_exit(libusb_testlib_ctx * tctx)
+static libusb_testlib_result test_init_and_exit(void)
{
- libusb_context * ctx = NULL;
- int i;
- for (i = 0; i < 10000; ++i) {
- int r = libusb_init(&ctx);
+ for (int i = 0; i < 10000; ++i) {
+ libusb_context *ctx = NULL;
+ int r;
+
+ r = libusb_init(&ctx);
if (r != LIBUSB_SUCCESS) {
- libusb_testlib_logf(tctx,
+ libusb_testlib_logf(
"Failed to init libusb on iteration %d: %d",
i, r);
return TEST_STATUS_FAILURE;
}
libusb_exit(ctx);
- ctx = NULL;
}
return TEST_STATUS_SUCCESS;
}
/** Tests that devices can be listed 1000 times. */
-static libusb_testlib_result test_get_device_list(libusb_testlib_ctx * tctx)
+static libusb_testlib_result test_get_device_list(void)
{
- libusb_context * ctx = NULL;
- int r, i;
+ libusb_context *ctx;
+ int r;
+
r = libusb_init(&ctx);
if (r != LIBUSB_SUCCESS) {
- libusb_testlib_logf(tctx, "Failed to init libusb: %d", r);
+ libusb_testlib_logf("Failed to init libusb: %d", r);
return TEST_STATUS_FAILURE;
}
- for (i = 0; i < 1000; ++i) {
- libusb_device ** device_list;
+
+ for (int i = 0; i < 1000; ++i) {
+ libusb_device **device_list = NULL;
ssize_t list_size = libusb_get_device_list(ctx, &device_list);
- if (list_size < 0 || device_list == NULL) {
- libusb_testlib_logf(tctx,
- "Failed to get device list on iteration %d: %d (%p)",
- i, -list_size, device_list);
+ if (list_size < 0 || !device_list) {
+ libusb_testlib_logf(
+ "Failed to get device list on iteration %d: %ld (%p)",
+ i, (long)-list_size, device_list);
+ libusb_exit(ctx);
return TEST_STATUS_FAILURE;
}
libusb_free_device_list(device_list, 1);
}
+
libusb_exit(ctx);
return TEST_STATUS_SUCCESS;
}
/** Tests that 100 concurrent device lists can be open at a time. */
-static libusb_testlib_result test_many_device_lists(libusb_testlib_ctx * tctx)
+static libusb_testlib_result test_many_device_lists(void)
{
#define LIST_COUNT 100
- libusb_context * ctx = NULL;
- libusb_device ** device_lists[LIST_COUNT];
- int r, i;
- memset(device_lists, 0, sizeof(device_lists));
+ libusb_testlib_result result = TEST_STATUS_SUCCESS;
+ libusb_context *ctx = NULL;
+ libusb_device **device_lists[LIST_COUNT];
+ int r;
r = libusb_init(&ctx);
if (r != LIBUSB_SUCCESS) {
- libusb_testlib_logf(tctx, "Failed to init libusb: %d", r);
+ libusb_testlib_logf("Failed to init libusb: %d", r);
return TEST_STATUS_FAILURE;
}
+ memset(device_lists, 0, sizeof(device_lists));
+
/* Create the 100 device lists. */
- for (i = 0; i < LIST_COUNT; ++i) {
- ssize_t list_size = libusb_get_device_list(ctx, &(device_lists[i]));
- if (list_size < 0 || device_lists[i] == NULL) {
- libusb_testlib_logf(tctx,
- "Failed to get device list on iteration %d: %d (%p)",
- i, -list_size, device_lists[i]);
- return TEST_STATUS_FAILURE;
+ for (int i = 0; i < LIST_COUNT; ++i) {
+ ssize_t list_size = libusb_get_device_list(ctx, &device_lists[i]);
+ if (list_size < 0 || !device_lists[i]) {
+ libusb_testlib_logf(
+ "Failed to get device list on iteration %d: %ld (%p)",
+ i, (long)-list_size, device_lists[i]);
+ result = TEST_STATUS_FAILURE;
+ break;
}
}
/* Destroy the 100 device lists. */
- for (i = 0; i < LIST_COUNT; ++i) {
- if (device_lists[i]) {
+ for (int i = 0; i < LIST_COUNT; ++i) {
+ if (device_lists[i])
libusb_free_device_list(device_lists[i], 1);
- device_lists[i] = NULL;
- }
}
libusb_exit(ctx);
- return TEST_STATUS_SUCCESS;
+ return result;
#undef LIST_COUNT
}
/** Tests that the default context (used for various things including
* logging) works correctly when the first context created in a
* process is destroyed. */
-static libusb_testlib_result test_default_context_change(libusb_testlib_ctx * tctx)
+static libusb_testlib_result test_default_context_change(void)
{
- libusb_context * ctx = NULL;
- int r, i;
+ for (int i = 0; i < 100; ++i) {
+ libusb_context *ctx = NULL;
+ int r;
- for (i = 0; i < 100; ++i) {
/* First create a new context */
r = libusb_init(&ctx);
if (r != LIBUSB_SUCCESS) {
- libusb_testlib_logf(tctx, "Failed to init libusb: %d", r);
+ libusb_testlib_logf("Failed to init libusb: %d", r);
return TEST_STATUS_FAILURE;
}
@@ -132,7 +137,8 @@ static libusb_testlib_result test_default_context_change(libusb_testlib_ctx * tc
/* Now create a reference to the default context */
r = libusb_init(NULL);
if (r != LIBUSB_SUCCESS) {
- libusb_testlib_logf(tctx, "Failed to init libusb: %d", r);
+ libusb_testlib_logf("Failed to init libusb: %d", r);
+ libusb_exit(ctx);
return TEST_STATUS_FAILURE;
}
@@ -147,14 +153,14 @@ static libusb_testlib_result test_default_context_change(libusb_testlib_ctx * tc
/* Fill in the list of tests. */
static const libusb_testlib_test tests[] = {
- {"init_and_exit", &test_init_and_exit},
- {"get_device_list", &test_get_device_list},
- {"many_device_lists", &test_many_device_lists},
- {"default_context_change", &test_default_context_change},
+ { "init_and_exit", &test_init_and_exit },
+ { "get_device_list", &test_get_device_list },
+ { "many_device_lists", &test_many_device_lists },
+ { "default_context_change", &test_default_context_change },
LIBUSB_NULL_TEST
};
-int main (int argc, char ** argv)
+int main(int argc, char *argv[])
{
return libusb_testlib_run_tests(argc, argv, tests);
}
diff --git a/tests/testlib.c b/tests/testlib.c
index aa38cf1..3825341 100644
--- a/tests/testlib.c
+++ b/tests/testlib.c
@@ -17,43 +17,26 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "libusb_testlib.h"
+#include <config.h>
-#include <stdio.h>
+#include <errno.h>
#include <stdarg.h>
+#include <stdbool.h>
+#include <stdio.h>
#include <string.h>
-#include <errno.h>
-#if !defined(_WIN32_WCE)
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#endif
-#if defined(_WIN32_WCE)
-// No support for selective redirection of STDOUT on WinCE.
-#define DISABLE_STDOUT_REDIRECTION
-#define STDOUT_FILENO 1
-#elif defined(_WIN32)
-#include <io.h>
-#define dup _dup
-#define dup2 _dup2
-#define open _open
-#define close _close
-#define fdopen _fdopen
-#define NULL_PATH "nul"
-#define STDOUT_FILENO 1
-#define STDERR_FILENO 2
-#else
-#include <unistd.h>
+#include "libusb_testlib.h"
+
+#if defined(PLATFORM_POSIX)
#define NULL_PATH "/dev/null"
+#elif defined(PLATFORM_WINDOWS)
+#define NULL_PATH "nul"
#endif
-#define INVALID_FD -1
-#define IGNORE_RETVAL(expr) do { (void)(expr); } while(0)
/**
* Converts a test result code into a human readable string.
*/
-static const char* test_result_to_str(libusb_testlib_result result)
+static const char *test_result_to_str(libusb_testlib_result result)
{
switch (result) {
case TEST_STATUS_SUCCESS:
@@ -69,100 +52,27 @@ static const char* test_result_to_str(libusb_testlib_result result)
}
}
-static void print_usage(int argc, char ** argv)
+static void print_usage(const char *progname)
{
- printf("Usage: %s [-l] [-v] [<test_name> ...]\n",
- argc > 0 ? argv[0] : "test_*");
+ printf("Usage: %s [-l] [-v] [<test_name> ...]\n", progname);
printf(" -l List available tests\n");
- printf(" -v Don't redirect STDERR/STDOUT during tests\n");
+ printf(" -v Don't redirect STDERR before running tests\n");
+ printf(" -h Display this help and exit\n");
}
-static void cleanup_test_output(libusb_testlib_ctx * ctx)
-{
-#ifndef DISABLE_STDOUT_REDIRECTION
- if (!ctx->verbose) {
- if (ctx->old_stdout != INVALID_FD) {
- IGNORE_RETVAL(dup2(ctx->old_stdout, STDOUT_FILENO));
- ctx->old_stdout = INVALID_FD;
- }
- if (ctx->old_stderr != INVALID_FD) {
- IGNORE_RETVAL(dup2(ctx->old_stderr, STDERR_FILENO));
- ctx->old_stderr = INVALID_FD;
- }
- if (ctx->null_fd != INVALID_FD) {
- close(ctx->null_fd);
- ctx->null_fd = INVALID_FD;
- }
- if (ctx->output_file != stdout) {
- fclose(ctx->output_file);
- ctx->output_file = stdout;
- }
- }
-#endif
-}
-
-/**
- * Setup test output handles
- * \return zero on success, non-zero on failure
- */
-static int setup_test_output(libusb_testlib_ctx * ctx)
-{
-#ifndef DISABLE_STDOUT_REDIRECTION
- /* Stop output to stdout and stderr from being displayed if using non-verbose output */
- if (!ctx->verbose) {
- /* Keep a copy of STDOUT and STDERR */
- ctx->old_stdout = dup(STDOUT_FILENO);
- if (ctx->old_stdout < 0) {
- ctx->old_stdout = INVALID_FD;
- printf("Failed to duplicate stdout handle: %d\n", errno);
- return 1;
- }
- ctx->old_stderr = dup(STDERR_FILENO);
- if (ctx->old_stderr < 0) {
- ctx->old_stderr = INVALID_FD;
- cleanup_test_output(ctx);
- printf("Failed to duplicate stderr handle: %d\n", errno);
- return 1;
- }
- /* Redirect STDOUT_FILENO and STDERR_FILENO to /dev/null or "nul"*/
- ctx->null_fd = open(NULL_PATH, O_WRONLY);
- if (ctx->null_fd < 0) {
- ctx->null_fd = INVALID_FD;
- cleanup_test_output(ctx);
- printf("Failed to open null handle: %d\n", errno);
- return 1;
- }
- if ((dup2(ctx->null_fd, STDOUT_FILENO) < 0) ||
- (dup2(ctx->null_fd, STDERR_FILENO) < 0)) {
- cleanup_test_output(ctx);
- return 1;
- }
- ctx->output_file = fdopen(ctx->old_stdout, "w");
- if (!ctx->output_file) {
- ctx->output_file = stdout;
- cleanup_test_output(ctx);
- printf("Failed to open FILE for output handle: %d\n", errno);
- return 1;
- }
- }
-#endif
- return 0;
-}
-
-void libusb_testlib_logf(libusb_testlib_ctx * ctx,
- const char* fmt, ...)
+void libusb_testlib_logf(const char *fmt, ...)
{
va_list va;
+
va_start(va, fmt);
- vfprintf(ctx->output_file, fmt, va);
+ vfprintf(stdout, fmt, va);
va_end(va);
- fprintf(ctx->output_file, "\n");
- fflush(ctx->output_file);
+ fputc('\n', stdout);
+ fflush(stdout);
}
-int libusb_testlib_run_tests(int argc,
- char ** argv,
- const libusb_testlib_test * tests)
+int libusb_testlib_run_tests(int argc, char *argv[],
+ const libusb_testlib_test *tests)
{
int run_count = 0;
int idx = 0;
@@ -170,108 +80,105 @@ int libusb_testlib_run_tests(int argc,
int fail_count = 0;
int error_count = 0;
int skip_count = 0;
- int r, j;
- size_t arglen;
- libusb_testlib_result test_result;
- libusb_testlib_ctx ctx;
/* Setup default mode of operation */
- ctx.test_names = NULL;
- ctx.test_count = 0;
- ctx.list_tests = false;
- ctx.verbose = false;
- ctx.old_stdout = INVALID_FD;
- ctx.old_stderr = INVALID_FD;
- ctx.output_file = stdout;
- ctx.null_fd = INVALID_FD;
+ char **test_names = NULL;
+ int test_count = 0;
+ bool list_tests = false;
+ bool verbose = false;
/* Parse command line options */
if (argc >= 2) {
- for (j = 1; j < argc; j++) {
- arglen = strlen(argv[j]);
- if ( ((argv[j][0] == '-') || (argv[j][0] == '/')) &&
- arglen >=2 ) {
- switch (argv[j][1]) {
+ for (int j = 1; j < argc; j++) {
+ const char *argstr = argv[j];
+ size_t arglen = strlen(argstr);
+
+ if (argstr[0] == '-' || argstr[0] == '/') {
+ if (arglen == 2) {
+ switch (argstr[1]) {
case 'l':
- ctx.list_tests = true;
- break;
+ list_tests = true;
+ continue;
case 'v':
- ctx.verbose = true;
- break;
- default:
- printf("Unknown option: '%s'\n", argv[j]);
- print_usage(argc, argv);
- return 1;
+ verbose = true;
+ continue;
+ case 'h':
+ print_usage(argv[0]);
+ return 0;
}
+ }
+
+ fprintf(stderr, "Unknown option: '%s'\n", argstr);
+ print_usage(argv[0]);
+ return 1;
} else {
/* End of command line options, remaining must be list of tests to run */
- ctx.test_names = argv + j;
- ctx.test_count = argc - j;
+ test_names = argv + j;
+ test_count = argc - j;
break;
}
}
}
/* Validate command line options */
- if (ctx.test_names && ctx.list_tests) {
- printf("List of tests requested but test list provided\n");
- print_usage(argc, argv);
+ if (test_names && list_tests) {
+ fprintf(stderr, "List of tests requested but test list provided\n");
+ print_usage(argv[0]);
return 1;
}
/* Setup test log output */
- r = setup_test_output(&ctx);
- if (r != 0)
- return r;
+ if (!verbose) {
+ if (!freopen(NULL_PATH, "w", stderr)) {
+ printf("Failed to open null handle: %d\n", errno);
+ return 1;
+ }
+ }
/* Act on any options not related to running tests */
- if (ctx.list_tests) {
- while (tests[idx].function != NULL) {
- libusb_testlib_logf(&ctx, tests[idx].name);
- ++idx;
- }
- cleanup_test_output(&ctx);
+ if (list_tests) {
+ while (tests[idx].function)
+ libusb_testlib_logf("%s", tests[idx++].name);
return 0;
}
/* Run any requested tests */
- while (tests[idx].function != NULL) {
- const libusb_testlib_test * test = &tests[idx];
- ++idx;
- if (ctx.test_count > 0) {
+ while (tests[idx].function) {
+ const libusb_testlib_test *test = &tests[idx++];
+ libusb_testlib_result test_result;
+
+ if (test_count > 0) {
/* Filtering tests to run, check if this is one of them */
int i;
- for (i = 0; i < ctx.test_count; ++i) {
- if (strcmp(ctx.test_names[i], test->name) == 0)
+
+ for (i = 0; i < test_count; i++) {
+ if (!strcmp(test_names[i], test->name))
/* Matches a requested test name */
break;
}
- if (i >= ctx.test_count) {
+ if (i == test_count) {
/* Failed to find a test match, so do the next loop iteration */
continue;
}
}
- libusb_testlib_logf(&ctx,
- "Starting test run: %s...", test->name);
- test_result = test->function(&ctx);
- libusb_testlib_logf(&ctx,
- "%s (%d)",
- test_result_to_str(test_result), test_result);
+ libusb_testlib_logf("Starting test run: %s...", test->name);
+ test_result = test->function();
+ libusb_testlib_logf("%s (%d)", test_result_to_str(test_result), test_result);
switch (test_result) {
case TEST_STATUS_SUCCESS: pass_count++; break;
case TEST_STATUS_FAILURE: fail_count++; break;
case TEST_STATUS_ERROR: error_count++; break;
case TEST_STATUS_SKIP: skip_count++; break;
}
- ++run_count;
+ run_count++;
}
- libusb_testlib_logf(&ctx, "---");
- libusb_testlib_logf(&ctx, "Ran %d tests", run_count);
- libusb_testlib_logf(&ctx, "Passed %d tests", pass_count);
- libusb_testlib_logf(&ctx, "Failed %d tests", fail_count);
- libusb_testlib_logf(&ctx, "Error in %d tests", error_count);
- libusb_testlib_logf(&ctx, "Skipped %d tests", skip_count);
- cleanup_test_output(&ctx);
+ libusb_testlib_logf("---");
+ libusb_testlib_logf("Ran %d tests", run_count);
+ libusb_testlib_logf("Passed %d tests", pass_count);
+ libusb_testlib_logf("Failed %d tests", fail_count);
+ libusb_testlib_logf("Error in %d tests", error_count);
+ libusb_testlib_logf("Skipped %d tests", skip_count);
+
return pass_count != run_count;
}
diff --git a/travis-autogen.sh b/travis-autogen.sh
deleted file mode 100755
index cdd8781..0000000
--- a/travis-autogen.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/bash
-
-# Warnings enabled
-CFLAGS="-Wall -Wextra"
-
-CFLAGS+=" -Wbad-function-cast"
-#CFLAGS+=" -Wcast-align"
-CFLAGS+=" -Wchar-subscripts"
-CFLAGS+=" -Wempty-body"
-CFLAGS+=" -Wformat"
-CFLAGS+=" -Wformat-security"
-CFLAGS+=" -Winit-self"
-CFLAGS+=" -Winline"
-CFLAGS+=" -Wmissing-declarations"
-CFLAGS+=" -Wmissing-include-dirs"
-CFLAGS+=" -Wmissing-prototypes"
-CFLAGS+=" -Wnested-externs"
-CFLAGS+=" -Wold-style-definition"
-CFLAGS+=" -Wpointer-arith"
-CFLAGS+=" -Wredundant-decls"
-CFLAGS+=" -Wshadow"
-CFLAGS+=" -Wstrict-prototypes"
-CFLAGS+=" -Wswitch-enum"
-CFLAGS+=" -Wundef"
-CFLAGS+=" -Wuninitialized"
-CFLAGS+=" -Wunused"
-CFLAGS+=" -Wwrite-strings"
-
-# warnings disabled on purpose
-CFLAGS+=" -Wno-unused-parameter"
-CFLAGS+=" -Wno-unused-function"
-CFLAGS+=" -Wno-deprecated-declarations"
-
-# should be removed and the code fixed
-CFLAGS+=" -Wno-incompatible-pointer-types-discards-qualifiers"
-
-export CFLAGS
-
-./autogen.sh "$@"
diff --git a/windows/config.h b/windows/config.h
index 835160d..f14d406 100644
--- a/windows/config.h
+++ b/windows/config.h
@@ -13,11 +13,30 @@
/* Define to 1 if you have the <asm/types.h> header file. */
/* #undef HAVE_ASM_TYPES_H */
+/* Define to 1 if you have the `clock_gettime' function. */
+/* #undef HAVE_CLOCK_GETTIME */
+
+/* Define to 1 if you have the declaration of `EFD_CLOEXEC', and to 0 if you
+ * don't. */
+#define HAVE_DECL_EFD_CLOEXEC 1
+
+/* Define to 1 if you have the declaration of `EFD_NONBLOCK', and to 0 if you
+ * don't. */
+#define HAVE_DECL_EFD_NONBLOCK 1
+
+/* Define to 1 if you have the declaration of `TFD_CLOEXEC', and to 0 if you
+ * don't. */
+#define HAVE_DECL_TFD_CLOEXEC 1
+
+/* Define to 1 if you have the declaration of `TFD_NONBLOCK', and to 0 if you
+ * don't. */
+#define HAVE_DECL_TFD_NONBLOCK 1
+
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
-/* Define to 1 if you have the `gettimeofday' function. */
-#define HAVE_GETTIMEOFDAY 1
+/* Define to 1 if the system has eventfd functionality. */
+#define HAVE_EVENTFD 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
@@ -25,20 +44,23 @@
/* Define to 1 if you have the `udev' library (-ludev). */
/* #undef HAVE_LIBUDEV */
-/* Define to 1 if you have the <libudev.h> header file. */
-/* #define HAVE_LIBUDEV_H */
-
-/* Define to 1 if you have the <linux/netlink.h> header file. */
-/* #undef HAVE_LINUX_NETLINK_H */
-
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
-/* Define to 1 if you have the <poll.h> header file. */
-/* #undef HAVE_POLL_H */
+/* Define to 1 if the system has the type `nfds_t'. */
+#define HAVE_NFDS_T 1
-/* Define to 1 if you have the <signal.h> header file. */
-#define HAVE_SIGNAL_H 1
+/* Define to 1 if you have the `pipe2' function. */
+#define HAVE_PIPE2 1
+
+/* Define to 1 if you have the `pthread_condattr_setclock' function. */
+#define HAVE_PTHREAD_CONDATTR_SETCLOCK 1
+
+/* Define to 1 if you have the `pthread_setname_np' function. */
+#define HAVE_PTHREAD_SETNAME_NP 1
+
+/* Define to 1 if you have the `pthread_threadid_np' function. */
+/* #undef HAVE_PTHREAD_THREADID_NP */
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
@@ -53,16 +75,10 @@
#define HAVE_STRING_H 1
/* Define to 1 if the system has the type `struct timespec'. */
-#define HAVE_STRUCT_TIMESPEC 1
+/* #undef HAVE_STRUCT_TIMESPEC */
-/* syslog() function available */
-/* #undef HAVE_SYSLOG_FUNC */
-
-/* Define to 1 if you have the <syslog.h> header file. */
-/* #undef HAVE_SYSLOG_H */
-
-/* Define to 1 if you have the <sys/socket.h> header file. */
-/* #undef HAVE_SYS_SOCKET_H */
+/* Define to 1 if you have the `syslog' function. */
+/* #undef HAVE_SYSLOG */
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
@@ -73,87 +89,63 @@
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
+/* Define to 1 if the system has timerfd functionality. */
+#define HAVE_TIMERFD 1
+
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
- */
+/* Define to the sub-directory in which libtool stores uninstalled libraries. */
#define LT_OBJDIR ".libs/"
-/* Darwin backend */
-/* #undef OS_DARWIN */
-
-/* Haiku backend */
-/* #undef OS_HAIKU */
-
-/* Linux backend */
-/* #define OS_LINUX 1 */
-
-/* NetBSD backend */
-/* #undef OS_NETBSD */
-
-/* OpenBSD backend */
-/* #undef OS_OPENBSD */
-
-/* SunOS backend */
-/* #undef OS_SUNOS */
-
-/* Windows backend */
-#define OS_WINDOWS 1
-
/* Name of package */
-#define PACKAGE "libusb"
+#define PACKAGE "libusb-1.0"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "libusb-devel@lists.sourceforge.net"
/* Define to the full name of this package. */
-#define PACKAGE_NAME "libusb"
+#define PACKAGE_NAME "libusb-1.0"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "libusb 1.0.21-rc5"
+#define PACKAGE_STRING "libusb-1.0 1.0.24"
/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "libusb"
+#define PACKAGE_TARNAME "libusb-1.0"
/* Define to the home page for this package. */
#define PACKAGE_URL "http://libusb.info"
/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.0.21-rc5"
+#define PACKAGE_VERSION "1.0.24"
-/* type of second poll() argument */
-#define POLL_NFDS_TYPE unsigned int
+/* Define to 1 if compiling for a POSIX platform. */
+/* #undef PLATFORM_POSIX */
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
+/* Define to 1 if compiling for a Windows platform. */
+#define PLATFORM_WINDOWS 1
-/* Use POSIX Threads */
-/* #undef THREADS_POSIX */
+/* Define to the attribute for enabling parameter checks on printf-like
+ * functions. */
+#define PRINTF_FORMAT(a, b) __attribute__ ((__format__ (__printf__, a, b)))
-/* timerfd headers available */
-/* #undef USBI_TIMERFD_AVAILABLE */
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
-/* Enable output to system log */
+/* Define to 1 to output logging messages to the systemwide log. */
/* #undef USE_SYSTEM_LOGGING_FACILITY */
-/* Use udev for device enumeration/hotplug */
-/* #undef USE_UDEV */
-
-/* Use UsbDk Windows backend */
-/* #undef USE_USBDK */
-
/* Version number of package */
-#define VERSION "1.0.21-rc5"
+#define VERSION "1.0.24"
-/* Oldest Windows version supported */
-/* #undef WINVER */
+/* Enable GNU extensions. */
+#define _GNU_SOURCE 1
-/* Use GNU extensions */
-/* #undef _GNU_SOURCE */
+/* Define to the oldest supported Windows version. */
+/* #undef _WIN32_WINNT */
/* Define to `__inline__' or `__inline' if that's what the C compiler
- calls it, or to nothing if 'inline' is not supported under any name. */
+ * calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
/* #undef inline */
#endif