1 From 2e9b6bbebb7cf1ef0095516ec6d5203deb3822e8 Mon Sep 17 00:00:00 2001
2 From: Nathan Hjelm <hjelmn@me.com>
3 Date: Fri, 9 Oct 2015 15:03:10 -0600
4 Subject: [PATCH 1/1] Use C99 standard fixed width integer types in usb.h
6 This patch modifies the integer types in usb.h of the form u_int* to the
7 C99 standard uint* types.
9 Based on patch from Gwenhael Goavec-Merou.
11 Backported from upstream commit
12 https://github.com/libusb/libusb-compat-0.1/commit/2e9b6bbebb7cf1ef0095516ec6d5203deb3822e8.
14 Signed-off-by: Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
15 Signed-off-by: Nathan Hjelm <hjelmn@me.com>
17 libusb/usb.h | 130 ++++++++++++++++++++++++++++++++---------------------------
18 1 file changed, 70 insertions(+), 60 deletions(-)
20 diff --git a/libusb/usb.h b/libusb/usb.h
21 index 84e730f..d2c30aa 100644
25 * Prototypes, structure definitions and macros.
27 * Copyright (c) 2000-2003 Johannes Erdfelt <johannes@erdfelt.com>
28 + * Copyright (c) 2015 Nathan Hjelm <hjelmn@cs.unm.edu>
30 * This library is free software; you can redistribute it and/or
31 * modify it under the terms of the GNU Lesser General Public
33 * distribution for details.
47 +/* stdint.h is not available on older MSVC */
48 +#if defined(_MSC_VER) && (_MSC_VER < 1600) && (!defined(_STDINT)) && (!defined(_STDINT_H))
49 +typedef unsigned __int8 uint8_t;
50 +typedef unsigned __int16 uint16_t;
51 +typedef unsigned __int32 uint32_t;
57 * USB spec information
61 /* All standard descriptors have these 2 fields in common */
62 struct usb_descriptor_header {
64 - u_int8_t bDescriptorType;
66 + uint8_t bDescriptorType;
69 /* String descriptor */
70 struct usb_string_descriptor {
72 - u_int8_t bDescriptorType;
75 + uint8_t bDescriptorType;
80 struct usb_hid_descriptor {
82 - u_int8_t bDescriptorType;
84 - u_int8_t bCountryCode;
85 - u_int8_t bNumDescriptors;
86 - /* u_int8_t bReportDescriptorType; */
87 - /* u_int16_t wDescriptorLength; */
89 + uint8_t bDescriptorType;
91 + uint8_t bCountryCode;
92 + uint8_t bNumDescriptors;
93 + /* uint8_t bReportDescriptorType; */
94 + /* uint16_t wDescriptorLength; */
98 /* Endpoint descriptor */
99 #define USB_MAXENDPOINTS 32
100 struct usb_endpoint_descriptor {
102 - u_int8_t bDescriptorType;
103 - u_int8_t bEndpointAddress;
104 - u_int8_t bmAttributes;
105 - u_int16_t wMaxPacketSize;
106 - u_int8_t bInterval;
108 - u_int8_t bSynchAddress;
110 + uint8_t bDescriptorType;
111 + uint8_t bEndpointAddress;
112 + uint8_t bmAttributes;
113 + uint16_t wMaxPacketSize;
116 + uint8_t bSynchAddress;
118 unsigned char *extra; /* Extra descriptors */
120 @@ -129,15 +139,15 @@ struct usb_endpoint_descriptor {
121 /* Interface descriptor */
122 #define USB_MAXINTERFACES 32
123 struct usb_interface_descriptor {
125 - u_int8_t bDescriptorType;
126 - u_int8_t bInterfaceNumber;
127 - u_int8_t bAlternateSetting;
128 - u_int8_t bNumEndpoints;
129 - u_int8_t bInterfaceClass;
130 - u_int8_t bInterfaceSubClass;
131 - u_int8_t bInterfaceProtocol;
132 - u_int8_t iInterface;
134 + uint8_t bDescriptorType;
135 + uint8_t bInterfaceNumber;
136 + uint8_t bAlternateSetting;
137 + uint8_t bNumEndpoints;
138 + uint8_t bInterfaceClass;
139 + uint8_t bInterfaceSubClass;
140 + uint8_t bInterfaceProtocol;
141 + uint8_t iInterface;
143 struct usb_endpoint_descriptor *endpoint;
145 @@ -155,14 +165,14 @@ struct usb_interface {
146 /* Configuration descriptor information.. */
147 #define USB_MAXCONFIG 8
148 struct usb_config_descriptor {
150 - u_int8_t bDescriptorType;
151 - u_int16_t wTotalLength;
152 - u_int8_t bNumInterfaces;
153 - u_int8_t bConfigurationValue;
154 - u_int8_t iConfiguration;
155 - u_int8_t bmAttributes;
158 + uint8_t bDescriptorType;
159 + uint16_t wTotalLength;
160 + uint8_t bNumInterfaces;
161 + uint8_t bConfigurationValue;
162 + uint8_t iConfiguration;
163 + uint8_t bmAttributes;
166 struct usb_interface *interface;
168 @@ -172,28 +182,28 @@ struct usb_config_descriptor {
170 /* Device descriptor */
171 struct usb_device_descriptor {
173 - u_int8_t bDescriptorType;
175 - u_int8_t bDeviceClass;
176 - u_int8_t bDeviceSubClass;
177 - u_int8_t bDeviceProtocol;
178 - u_int8_t bMaxPacketSize0;
179 - u_int16_t idVendor;
180 - u_int16_t idProduct;
181 - u_int16_t bcdDevice;
182 - u_int8_t iManufacturer;
184 - u_int8_t iSerialNumber;
185 - u_int8_t bNumConfigurations;
187 + uint8_t bDescriptorType;
189 + uint8_t bDeviceClass;
190 + uint8_t bDeviceSubClass;
191 + uint8_t bDeviceProtocol;
192 + uint8_t bMaxPacketSize0;
194 + uint16_t idProduct;
195 + uint16_t bcdDevice;
196 + uint8_t iManufacturer;
198 + uint8_t iSerialNumber;
199 + uint8_t bNumConfigurations;
202 struct usb_ctrl_setup {
203 - u_int8_t bRequestType;
208 + uint8_t bRequestType;
216 @@ -254,7 +264,7 @@ struct usb_device {
218 void *dev; /* Darwin support */
223 unsigned char num_children;
224 struct usb_device **children;
225 @@ -266,7 +276,7 @@ struct usb_bus {
226 char dirname[PATH_MAX + 1];
228 struct usb_device *devices;
229 - u_int32_t location;
232 struct usb_device *root_dev;