Switched to standard int pointer type for windows 64-bit compat
authorPete Batard <pbatard@gmail.com>
Mon, 1 Feb 2010 19:26:13 +0000 (19:26 +0000)
committerDaniel Drake <dan@reactivated.net>
Fri, 4 Jun 2010 00:28:52 +0000 (19:28 -0500)
On 64-bit Windows a pointer is 64 bit, but long is still 32 bit for
backwards compatibility.
uintptr_t nicely hides this difference and also works on Linux.

[dsd: add appropriate include]

libusb/descriptor.c
libusb/libusbi.h

index 4384e3a..041c39d 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <errno.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -51,7 +52,7 @@ int usbi_parse_descriptor(unsigned char *source, char *descriptor, void *dest,
                                *dp++ = *sp++;
                                break;
                        case 'w':       /* 16-bit word, convert from little endian to CPU */
-                               dp += ((unsigned long)dp & 1);  /* Align to word boundary */
+                               dp += ((uintptr_t)dp & 1);      /* Align to word boundary */
 
                                if (host_endian) {
                                        memcpy(dp, sp, 2);
index 1a7731f..14996cf 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <poll.h>
 #include <stddef.h>
+#include <stdint.h>
 #include <time.h>
 
 #include <libusb.h>
@@ -45,7 +46,7 @@ struct list_head {
  *     member - the list_head element in "type"
  */
 #define list_entry(ptr, type, member) \
-       ((type *)((char *)(ptr) - (unsigned long)(&((type *)0L)->member)))
+       ((type *)((uintptr_t)(ptr) - (uintptr_t)(&((type *)0L)->member)))
 
 /* Get each entry from a list
  *     pos - A structure pointer has a "member" element