[oe-commits] neomilium : libusb: packed struct and ansi types.
git version control
git at git.openembedded.org
Wed Jun 10 12:13:19 UTC 2009
Module: openembedded.git
Branch: shr/import
Commit: b4df8cc2e9f6aca4d433e73c275a8fdad103223e
URL: http://gitweb.openembedded.net/?p=openembedded.git&a=commit;h=b4df8cc2e9f6aca4d433e73c275a8fdad103223e
Author: neomilium <neomilium at gmail.com>
Date: Wed Jun 10 11:20:22 2009 +0200
libusb: packed struct and ansi types.
- packed structs can reduce memory footprint
- ANSI types allow applications/libraries to be compile against libusb using C99 (-std=c99 or -std=gnu99 flag)
Signed-off-by: Julien 'Ainulindale' Cassignol <ainulindale at gmail.com>
---
recipes/libusb/files/libusb-ansi-types.patch | 194 +++++++++++++++++++++++
recipes/libusb/files/libusb-packed-struct.patch | 52 ++++++
recipes/libusb/libusb_0.1.12.bb | 5 +-
3 files changed, 250 insertions(+), 1 deletions(-)
diff --git a/recipes/libusb/files/libusb-ansi-types.patch b/recipes/libusb/files/libusb-ansi-types.patch
new file mode 100644
index 0000000..629ad9a
--- /dev/null
+++ b/recipes/libusb/files/libusb-ansi-types.patch
@@ -0,0 +1,194 @@
+
+---
+ usb.h.in | 118 ++++++++++++++++++++++++++++++++-------------------------------
+ 1 file changed, 60 insertions(+), 58 deletions(-)
+
+--- a/usb.h.in
++++ b/usb.h.in
+@@ -13,8 +13,10 @@
+
+ #include <unistd.h>
+ #include <stdlib.h>
++#include <stdint.h>
+ #include <limits.h>
+
++#include <sys/param.h>
+ #include <dirent.h>
+
+ /*
+@@ -64,40 +66,40 @@
+
+ /* All standard descriptors have these 2 fields in common */
+ struct usb_descriptor_header {
+- u_int8_t bLength;
+- u_int8_t bDescriptorType;
++ uint8_t bLength;
++ uint8_t bDescriptorType;
+ } __attribute__ ((packed));
+
+ /* String descriptor */
+ struct usb_string_descriptor {
+- u_int8_t bLength;
+- u_int8_t bDescriptorType;
+- u_int16_t wData[1];
++ uint8_t bLength;
++ uint8_t bDescriptorType;
++ uint16_t wData[1];
+ } __attribute__ ((packed));
+
+ /* HID descriptor */
+ struct usb_hid_descriptor {
+- u_int8_t bLength;
+- u_int8_t bDescriptorType;
+- u_int16_t bcdHID;
+- u_int8_t bCountryCode;
+- u_int8_t bNumDescriptors;
+- /* u_int8_t bReportDescriptorType; */
+- /* u_int16_t wDescriptorLength; */
++ uint8_t bLength;
++ uint8_t bDescriptorType;
++ uint16_t bcdHID;
++ uint8_t bCountryCode;
++ uint8_t bNumDescriptors;
++ /* uint8_t bReportDescriptorType; */
++ /* uint16_t wDescriptorLength; */
+ /* ... */
+ } __attribute__ ((packed));
+
+ /* Endpoint descriptor */
+ #define USB_MAXENDPOINTS 32
+ struct usb_endpoint_descriptor {
+- u_int8_t bLength;
+- u_int8_t bDescriptorType;
+- u_int8_t bEndpointAddress;
+- u_int8_t bmAttributes;
+- u_int16_t wMaxPacketSize;
+- u_int8_t bInterval;
+- u_int8_t bRefresh;
+- u_int8_t bSynchAddress;
++ uint8_t bLength;
++ uint8_t bDescriptorType;
++ uint8_t bEndpointAddress;
++ uint8_t bmAttributes;
++ uint16_t wMaxPacketSize;
++ uint8_t bInterval;
++ uint8_t bRefresh;
++ uint8_t bSynchAddress;
+
+ unsigned char *extra; /* Extra descriptors */
+ int extralen;
+@@ -115,15 +117,15 @@
+ /* Interface descriptor */
+ #define USB_MAXINTERFACES 32
+ struct usb_interface_descriptor {
+- u_int8_t bLength;
+- u_int8_t bDescriptorType;
+- u_int8_t bInterfaceNumber;
+- u_int8_t bAlternateSetting;
+- u_int8_t bNumEndpoints;
+- u_int8_t bInterfaceClass;
+- u_int8_t bInterfaceSubClass;
+- u_int8_t bInterfaceProtocol;
+- u_int8_t iInterface;
++ 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;
+
+ struct usb_endpoint_descriptor *endpoint;
+
+@@ -141,14 +143,14 @@
+ /* Configuration descriptor information.. */
+ #define USB_MAXCONFIG 8
+ struct usb_config_descriptor {
+- u_int8_t bLength;
+- u_int8_t bDescriptorType;
+- u_int16_t wTotalLength;
+- u_int8_t bNumInterfaces;
+- u_int8_t bConfigurationValue;
+- u_int8_t iConfiguration;
+- u_int8_t bmAttributes;
+- u_int8_t MaxPower;
++ uint8_t bLength;
++ uint8_t bDescriptorType;
++ uint16_t wTotalLength;
++ uint8_t bNumInterfaces;
++ uint8_t bConfigurationValue;
++ uint8_t iConfiguration;
++ uint8_t bmAttributes;
++ uint8_t MaxPower;
+
+ struct usb_interface *interface;
+
+@@ -158,28 +160,28 @@
+
+ /* Device descriptor */
+ struct usb_device_descriptor {
+- u_int8_t bLength;
+- u_int8_t bDescriptorType;
+- u_int16_t bcdUSB;
+- u_int8_t bDeviceClass;
+- u_int8_t bDeviceSubClass;
+- u_int8_t bDeviceProtocol;
+- u_int8_t bMaxPacketSize0;
+- u_int16_t idVendor;
+- u_int16_t idProduct;
+- u_int16_t bcdDevice;
+- u_int8_t iManufacturer;
+- u_int8_t iProduct;
+- u_int8_t iSerialNumber;
+- u_int8_t bNumConfigurations;
++ 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;
+ } __attribute__ ((packed));
+
+ struct usb_ctrl_setup {
+- u_int8_t bRequestType;
+- u_int8_t bRequest;
+- u_int16_t wValue;
+- u_int16_t wIndex;
+- u_int16_t wLength;
++ uint8_t bRequestType;
++ uint8_t bRequest;
++ uint16_t wValue;
++ uint16_t wIndex;
++ uint16_t wLength;
+ } __attribute__ ((packed));
+
+ /*
+@@ -250,7 +252,7 @@
+
+ void *dev; /* Darwin support */
+
+- u_int8_t devnum;
++ uint8_t devnum;
+
+ unsigned char num_children;
+ struct usb_device **children;
+@@ -262,7 +264,7 @@
+ char dirname[PATH_MAX + 1];
+
+ struct usb_device *devices;
+- u_int32_t location;
++ uint32_t location;
+
+ struct usb_device *root_dev;
+ };
+
diff --git a/recipes/libusb/files/libusb-packed-struct.patch b/recipes/libusb/files/libusb-packed-struct.patch
new file mode 100644
index 0000000..169de31
--- /dev/null
+++ b/recipes/libusb/files/libusb-packed-struct.patch
@@ -0,0 +1,52 @@
+
+---
+ usb.h.in | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+--- a/usb.h.in
++++ b/usb.h.in
+@@ -66,14 +66,14 @@
+ struct usb_descriptor_header {
+ u_int8_t bLength;
+ u_int8_t bDescriptorType;
+-};
++} __attribute__ ((packed));
+
+ /* String descriptor */
+ struct usb_string_descriptor {
+ u_int8_t bLength;
+ u_int8_t bDescriptorType;
+ u_int16_t wData[1];
+-};
++} __attribute__ ((packed));
+
+ /* HID descriptor */
+ struct usb_hid_descriptor {
+@@ -85,7 +85,7 @@
+ /* u_int8_t bReportDescriptorType; */
+ /* u_int16_t wDescriptorLength; */
+ /* ... */
+-};
++} __attribute__ ((packed));
+
+ /* Endpoint descriptor */
+ #define USB_MAXENDPOINTS 32
+@@ -172,7 +172,7 @@
+ u_int8_t iProduct;
+ u_int8_t iSerialNumber;
+ u_int8_t bNumConfigurations;
+-};
++} __attribute__ ((packed));
+
+ struct usb_ctrl_setup {
+ u_int8_t bRequestType;
+@@ -180,7 +180,7 @@
+ u_int16_t wValue;
+ u_int16_t wIndex;
+ u_int16_t wLength;
+-};
++} __attribute__ ((packed));
+
+ /*
+ * Standard requests
+
diff --git a/recipes/libusb/libusb_0.1.12.bb b/recipes/libusb/libusb_0.1.12.bb
index 3d6a213..42bc3d2 100644
--- a/recipes/libusb/libusb_0.1.12.bb
+++ b/recipes/libusb/libusb_0.1.12.bb
@@ -3,10 +3,13 @@ access to USB devices."
HOMEPAGE = "http://libusb.sf.net"
SECTION = "libs"
LICENSE = "LGPL"
-PR = "r3"
+PR = "r4"
SRC_URI = "${SOURCEFORGE_MIRROR}/libusb/libusb-${PV}.tar.gz \
file://configure_fix.patch;patch=1"
+SRC_URI_append_shr = "\
+ file://libusb-packed-struct.patch;patch=1 \
+ file://libusb-ansi-types.patch;patch=1"
S = "${WORKDIR}/libusb-${PV}"
More information about the Openembedded-commits
mailing list