[cfe-commits] r63984 - /cfe/trunk/lib/Headers/stdint.h

Chris Lattner sabre at nondot.org
Fri Feb 6 16:23:21 PST 2009


Author: lattner
Date: Fri Feb  6 18:23:17 2009
New Revision: 63984

URL: http://llvm.org/viewvc/llvm-project?rev=63984&view=rev
Log:
Apparently it is important to define intptr_t and uintptr_t to 
long instead of int.  This is because system heaers like to redefine
typedefs and that is an error if they don't exactly match.  Use long
for intptr_t on all systems where long is the right size.

Modified:
    cfe/trunk/lib/Headers/stdint.h

Modified: cfe/trunk/lib/Headers/stdint.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/stdint.h?rev=63984&r1=63983&r2=63984&view=diff

==============================================================================
--- cfe/trunk/lib/Headers/stdint.h (original)
+++ cfe/trunk/lib/Headers/stdint.h Fri Feb  6 18:23:17 2009
@@ -70,7 +70,14 @@
 
 /* C99 7.18.1.4 Integer types capable of holding object pointers.
  */
-#if __POINTER_WIDTH__ == 64
+#if (1LL << (__POINTER_WIDTH__-1))-1 == __LONG_MAX__
+/* If the pointer size is equal to long, use long.  This is for compatibility
+ * with many systems which just use long and expect it to work in 32-bit and
+ * 64-bit mode.  If long is not suitable, we use a fixed size type below.
+ */
+typedef long          intptr_t;
+typedef unsigned long uintptr_t;
+#elif __POINTER_WIDTH__ == 64
 typedef int64_t  intptr_t;
 typedef uint64_t uintptr_t;
 #elif __POINTER_WIDTH__ == 32





More information about the cfe-commits mailing list