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

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