0001-Use-C99-standard-fixed-width-integer-types-in-usb.h.patch 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. From 87adda6abc3467ede45a6d2a87df2b9efdf5bb33 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] Use C99 standard fixed width integer types in usb.h
  5. This patch modifies the integer types in usb.h of the form u_int* to the
  6. C99 standard uint* types.
  7. Based on patch from Gwenhael Goavec-Merou.
  8. Backported from upstream commit
  9. https://github.com/libusb/libusb-compat-0.1/commit/2e9b6bbebb7cf1ef0095516ec6d5203deb3822e8.
  10. Signed-off-by: Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
  11. Signed-off-by: Nathan Hjelm <hjelmn@me.com>
  12. Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
  13. ---
  14. libusb/usb.h | 130 ++++++++++++++++++++++++++++++++---------------------------
  15. 1 file changed, 70 insertions(+), 60 deletions(-)
  16. diff --git a/libusb/usb.h b/libusb/usb.h
  17. index 84e730f..d2c30aa 100644
  18. --- a/libusb/usb.h
  19. +++ b/libusb/usb.h
  20. @@ -2,6 +2,7 @@
  21. * Prototypes, structure definitions and macros.
  22. *
  23. * Copyright (c) 2000-2003 Johannes Erdfelt <johannes@erdfelt.com>
  24. + * Copyright (c) 2015 Nathan Hjelm <hjelmn@cs.unm.edu>
  25. *
  26. * This library is free software; you can redistribute it and/or
  27. * modify it under the terms of the GNU Lesser General Public
  28. @@ -22,8 +23,8 @@
  29. * distribution for details.
  30. */
  31. -#ifndef __USB_H__
  32. -#define __USB_H__
  33. +#ifndef USB_H
  34. +#define USB_H
  35. #include <unistd.h>
  36. #include <stdlib.h>
  37. @@ -31,6 +32,15 @@
  38. #include <dirent.h>
  39. +/* stdint.h is not available on older MSVC */
  40. +#if defined(_MSC_VER) && (_MSC_VER < 1600) && (!defined(_STDINT)) && (!defined(_STDINT_H))
  41. +typedef unsigned __int8 uint8_t;
  42. +typedef unsigned __int16 uint16_t;
  43. +typedef unsigned __int32 uint32_t;
  44. +#else
  45. +#include <stdint.h>
  46. +#endif
  47. +
  48. /*
  49. * USB spec information
  50. *
  51. @@ -78,40 +88,40 @@
  52. /* All standard descriptors have these 2 fields in common */
  53. struct usb_descriptor_header {
  54. - u_int8_t bLength;
  55. - u_int8_t bDescriptorType;
  56. + uint8_t bLength;
  57. + uint8_t bDescriptorType;
  58. };
  59. /* String descriptor */
  60. struct usb_string_descriptor {
  61. - u_int8_t bLength;
  62. - u_int8_t bDescriptorType;
  63. - u_int16_t wData[1];
  64. + uint8_t bLength;
  65. + uint8_t bDescriptorType;
  66. + uint16_t wData[1];
  67. };
  68. /* HID descriptor */
  69. struct usb_hid_descriptor {
  70. - u_int8_t bLength;
  71. - u_int8_t bDescriptorType;
  72. - u_int16_t bcdHID;
  73. - u_int8_t bCountryCode;
  74. - u_int8_t bNumDescriptors;
  75. - /* u_int8_t bReportDescriptorType; */
  76. - /* u_int16_t wDescriptorLength; */
  77. + uint8_t bLength;
  78. + uint8_t bDescriptorType;
  79. + uint16_t bcdHID;
  80. + uint8_t bCountryCode;
  81. + uint8_t bNumDescriptors;
  82. + /* uint8_t bReportDescriptorType; */
  83. + /* uint16_t wDescriptorLength; */
  84. /* ... */
  85. };
  86. /* Endpoint descriptor */
  87. #define USB_MAXENDPOINTS 32
  88. struct usb_endpoint_descriptor {
  89. - u_int8_t bLength;
  90. - u_int8_t bDescriptorType;
  91. - u_int8_t bEndpointAddress;
  92. - u_int8_t bmAttributes;
  93. - u_int16_t wMaxPacketSize;
  94. - u_int8_t bInterval;
  95. - u_int8_t bRefresh;
  96. - u_int8_t bSynchAddress;
  97. + uint8_t bLength;
  98. + uint8_t bDescriptorType;
  99. + uint8_t bEndpointAddress;
  100. + uint8_t bmAttributes;
  101. + uint16_t wMaxPacketSize;
  102. + uint8_t bInterval;
  103. + uint8_t bRefresh;
  104. + uint8_t bSynchAddress;
  105. unsigned char *extra; /* Extra descriptors */
  106. int extralen;
  107. @@ -129,15 +139,15 @@ struct usb_endpoint_descriptor {
  108. /* Interface descriptor */
  109. #define USB_MAXINTERFACES 32
  110. struct usb_interface_descriptor {
  111. - u_int8_t bLength;
  112. - u_int8_t bDescriptorType;
  113. - u_int8_t bInterfaceNumber;
  114. - u_int8_t bAlternateSetting;
  115. - u_int8_t bNumEndpoints;
  116. - u_int8_t bInterfaceClass;
  117. - u_int8_t bInterfaceSubClass;
  118. - u_int8_t bInterfaceProtocol;
  119. - u_int8_t iInterface;
  120. + uint8_t bLength;
  121. + uint8_t bDescriptorType;
  122. + uint8_t bInterfaceNumber;
  123. + uint8_t bAlternateSetting;
  124. + uint8_t bNumEndpoints;
  125. + uint8_t bInterfaceClass;
  126. + uint8_t bInterfaceSubClass;
  127. + uint8_t bInterfaceProtocol;
  128. + uint8_t iInterface;
  129. struct usb_endpoint_descriptor *endpoint;
  130. @@ -155,14 +165,14 @@ struct usb_interface {
  131. /* Configuration descriptor information.. */
  132. #define USB_MAXCONFIG 8
  133. struct usb_config_descriptor {
  134. - u_int8_t bLength;
  135. - u_int8_t bDescriptorType;
  136. - u_int16_t wTotalLength;
  137. - u_int8_t bNumInterfaces;
  138. - u_int8_t bConfigurationValue;
  139. - u_int8_t iConfiguration;
  140. - u_int8_t bmAttributes;
  141. - u_int8_t MaxPower;
  142. + uint8_t bLength;
  143. + uint8_t bDescriptorType;
  144. + uint16_t wTotalLength;
  145. + uint8_t bNumInterfaces;
  146. + uint8_t bConfigurationValue;
  147. + uint8_t iConfiguration;
  148. + uint8_t bmAttributes;
  149. + uint8_t MaxPower;
  150. struct usb_interface *interface;
  151. @@ -172,28 +182,28 @@ struct usb_config_descriptor {
  152. /* Device descriptor */
  153. struct usb_device_descriptor {
  154. - u_int8_t bLength;
  155. - u_int8_t bDescriptorType;
  156. - u_int16_t bcdUSB;
  157. - u_int8_t bDeviceClass;
  158. - u_int8_t bDeviceSubClass;
  159. - u_int8_t bDeviceProtocol;
  160. - u_int8_t bMaxPacketSize0;
  161. - u_int16_t idVendor;
  162. - u_int16_t idProduct;
  163. - u_int16_t bcdDevice;
  164. - u_int8_t iManufacturer;
  165. - u_int8_t iProduct;
  166. - u_int8_t iSerialNumber;
  167. - u_int8_t bNumConfigurations;
  168. + uint8_t bLength;
  169. + uint8_t bDescriptorType;
  170. + uint16_t bcdUSB;
  171. + uint8_t bDeviceClass;
  172. + uint8_t bDeviceSubClass;
  173. + uint8_t bDeviceProtocol;
  174. + uint8_t bMaxPacketSize0;
  175. + uint16_t idVendor;
  176. + uint16_t idProduct;
  177. + uint16_t bcdDevice;
  178. + uint8_t iManufacturer;
  179. + uint8_t iProduct;
  180. + uint8_t iSerialNumber;
  181. + uint8_t bNumConfigurations;
  182. };
  183. struct usb_ctrl_setup {
  184. - u_int8_t bRequestType;
  185. - u_int8_t bRequest;
  186. - u_int16_t wValue;
  187. - u_int16_t wIndex;
  188. - u_int16_t wLength;
  189. + uint8_t bRequestType;
  190. + uint8_t bRequest;
  191. + uint16_t wValue;
  192. + uint16_t wIndex;
  193. + uint16_t wLength;
  194. };
  195. /*
  196. @@ -254,7 +264,7 @@ struct usb_device {
  197. void *dev; /* Darwin support */
  198. - u_int8_t devnum;
  199. + uint8_t devnum;
  200. unsigned char num_children;
  201. struct usb_device **children;
  202. @@ -266,7 +276,7 @@ struct usb_bus {
  203. char dirname[PATH_MAX + 1];
  204. struct usb_device *devices;
  205. - u_int32_t location;
  206. + uint32_t location;
  207. struct usb_device *root_dev;
  208. };
  209. --
  210. 2.9.3