[llvm-commits] [test-suite] r107945 - in /test-suite/trunk/SingleSource/Regression/C: casts.c casts.reference_output

Bob Wilson bob.wilson at apple.com
Thu Jul 8 17:48:46 PDT 2010


Author: bwilson
Date: Thu Jul  8 19:48:46 2010
New Revision: 107945

URL: http://llvm.org/viewvc/llvm-project?rev=107945&view=rev
Log:
Change SingleSource/Regression/C/casts to explicitly use int64_t values
instead of longs.  Otherwise the output differs between 32-bit and 64-bit
targets.

Modified:
    test-suite/trunk/SingleSource/Regression/C/casts.c
    test-suite/trunk/SingleSource/Regression/C/casts.reference_output

Modified: test-suite/trunk/SingleSource/Regression/C/casts.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/casts.c?rev=107945&r1=107944&r2=107945&view=diff
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/casts.c (original)
+++ test-suite/trunk/SingleSource/Regression/C/casts.c Thu Jul  8 19:48:46 2010
@@ -5,7 +5,11 @@
 #define __STDC_LIMIT_MACROS 1
 #endif
 #include <inttypes.h>
-
+#ifndef PRId64
+#define PRId64 "lld"
+#define PRIu64 "llu"
+#define PRIx64 "llx"
+#endif
 
 static int64_t lls[] = {
   123ULL, -1LL, -14LL, 14, 1ULL << 63, 0
@@ -23,8 +27,8 @@
   int           i1, i;
   unsigned      ui1;
 
-  long          L, l1;
-  unsigned long ul1;
+  int64_t       L, l1;
+  uint64_t      ul1;
 
   float         F;
   double        D;
@@ -32,46 +36,46 @@
   /* input values */
   C = (char)  (argc >= 2)? atoi(argv[1]) : 0x64;           /* 100 = 'd' */
   S = (short) (argc >= 3)? atoi(argv[2]) : -769;           /* 0xfcff = -769 */
-  L = (long)  (argc >= 4)? atoi(argv[3]) : 0xa3a3a3a3a3a3; /*179923220407203*/
+  L = (int64_t) (argc >= 4)? atoi(argv[3]) : 0xa3a3a3a3a3a3LL; /*179923220407203*/
   
   /* Test integer to integer conversions */
   uc1 = (uint8_t) C;                       /* 100 = 'd' */
   us1 = (unsigned short) C;                /* 100 = 'd' */
   ui1 = (unsigned int) C;                  /* 100 = 'd' */
-  ul1 = (unsigned long) C;                 /* 100 = 'd' */
+  ul1 = (uint64_t) C;                      /* 100 = 'd' */
 
   s1  = (short) C;                         /* 100 = 'd' */
   i1  = (int) C;                           /* 100 = 'd' */
-  l1  = (long) C;                          /* 100 = 'd' */
+  l1  = (int64_t) C;                       /* 100 = 'd' */
   
   printf("\nCHAR             C = '%c' (%d)\t\t(0x%x)\n", C, C, C);
   printf("char to short   s1 = %d\t\t(0x%x)\n", s1, s1);
   printf("char to int     i1 = %d\t\t(0x%x)\n", i1, i1);
-  printf("char to long    l1 = %ld\t\t(0x%lx)\n", l1, l1);
+  printf("char to int64_t l1 = %"PRId64"\t\t(0x%"PRIx64")\n", l1, l1);
 
   printf("\nchar to ubyte  uc1 = %u\t\t(0x%x)\n", uc1, uc1);
   printf("char to ushort us1 = %u\t\t(0x%x)\n", us1, us1);
   printf("char to uint   ui1 = %u\t\t(0x%x)\n", ui1, ui1);
-  printf("char to ulong  ul1 = %lu\t\t(0x%lx)\n", ul1, ul1);
+  printf("char to uint64_t ul1 = %"PRIu64"\t\t(0x%"PRIx64")\n", ul1, ul1);
 
   uc1 = (uint8_t) S;                            /* 0xff = 255 */
   us1 = (unsigned short) S;                     /* 0xfcff = 64767 */
   ui1 = (unsigned int) S;                       /* 0xfffffcff = 4294966527 */
-  ul1 = (unsigned long) S;                      /* */
+  ul1 = (uint64_t) S;                           /* */
 
   c1  = (int8_t) S;                             /* 0xff = -1 */
   i1  = (int) S;                                /* 0xfffffcff = -769 */
-  l1  = (long) S;                               /* */
+  l1  = (int64_t) S;                            /* */
 
   printf("\n\nSHORT            S = %d\t\t(0x%x)\n", S, S);
   printf("short to byte    c1 = %d\t\t(0x%x)\n", c1, c1);
   printf("short to int     i1 = %d\t\t(0x%x)\n", i1, i1);
-  printf("short to long    l1 = %ld\t\t(0x%lx)\n", l1, l1);
+  printf("short to int64_t l1 = %"PRId64"\t\t(0x%"PRIx64")\n", l1, l1);
 
   printf("\nshort to ubyte  uc1 = %u\t\t(0x%x)\n", uc1, uc1);
   printf("short to ushort us1 = %u\t\t(0x%x)\n", us1, us1);
   printf("short to uint   ui1 = %u\t\t(0x%x)\n", ui1, ui1);
-  printf("short to ulong  ul1 = %lu\t\t(0x%lx)\n", ul1, ul1);
+  printf("short to uint64_t ul1 = %"PRIu64"\t\t(0x%"PRIx64")\n", ul1, ul1);
 
   uc1 = (unsigned char) L;                      /* */
   c1  = (int8_t) L;                             /* */
@@ -79,9 +83,9 @@
   us1 = (unsigned short) L;                     /* */
   i1  = (int) L;                                /* */
   ui1 = (unsigned int) L;                       /* */
-  ul1 = (unsigned long) L;                       /* */
+  ul1 = (uint64_t) L;                           /* */
 
-  printf("\n\nLONG            L = %ld\t\t(0x%lx)\n", L, L);
+  printf("\n\nLONG            L = %"PRId64"\t\t(0x%"PRIx64")\n", L, L);
   printf("long to byte    c1 = %d\t\t(0x%x)\n", c1, c1);
   printf("long to short   s1 = %d\t\t(0x%x)\n", s1, s1);
   printf("long to int     i1 = %d\t\t(0x%x)\n", i1, i1);
@@ -89,7 +93,7 @@
   printf("\nlong to ubyte  uc1 = %u\t\t(0x%x)\n", uc1, uc1);
   printf("long to ushort us1 = %u\t\t(0x%x)\n", us1, us1);
   printf("long to uint   ui1 = %u\t\t(0x%x)\n", ui1, ui1);
-  printf("long to ulong  ul1 = %lu\t\t(0x%lx)\n", ul1, ul1);
+  printf("long to uint64_t ul1 = %"PRIu64"\t\t(0x%"PRIx64")\n", ul1, ul1);
 
   /* Test floating-point to integer conversions */
   F = (float)  (argc >= 4)? atof(argv[3]) : 1.0;
@@ -97,11 +101,11 @@
   
   us1 = (unsigned short) F;
   ui1 = (unsigned int) F;
-  ul1 = (unsigned long) F;
+  ul1 = (uint64_t) F;
 
   s1  = (short) F;
   i1  = (int) F;
-  l1  = (long) F;
+  l1  = (int64_t) F;
 
   printf("\n\nFLOAT            F = %f\n", F);
   printf("float to short   s1 = %d\t\t(0x%x)\n", s1, s1);
@@ -109,29 +113,29 @@
 
   printf("float to ushort us1 = %u\t\t(0x%x)\n", us1, us1);
   printf("float to uint   ui1 = %u\t\t(0x%x)\n", ui1, ui1);
-  printf("float to ulong  ul1 = %lu\t\t(0x%lx)\n", ul1, ul1);
+  printf("float to uint64_t ul1 = %"PRIu64"\t\t(0x%"PRIx64")\n", ul1, ul1);
 
   us1 = (unsigned short) D;
   ui1 = (unsigned int) D;
-  ul1 = (unsigned long) D;
+  ul1 = (uint64_t) D;
   
   s1  = (short) D;
   i1  = (int) D;
-  l1  = (long) D;
+  l1  = (int64_t) D;
 
   printf("\n\nDOUBLE            D = %f\n", D);
   printf("double to short   s1 = %d\t\t(0x%x)\n", s1, s1);
   printf("double to int     i1 = %d\t\t(0x%x)\n", i1, i1);
-  printf("double to long    l1 = %ld\t\t(0x%lx)\n", l1, l1);
+  printf("double to int64_t l1 = %"PRId64"\t\t(0x%"PRIx64")\n", l1, l1);
 
   printf("double to ushort us1 = %u\t\t(0x%x)\n", us1, us1);
   printf("double to uint   ui1 = %u\t\t(0x%x)\n", ui1, ui1);
-  printf("double to ulong  ul1 = %lu\t\t(0x%lx)\n", ul1, ul1);
+  printf("double to uint64_t ul1 = %"PRIu64"\t\t(0x%"PRIx64")\n", ul1, ul1);
 
   for (i = 0; lls[i]; ++i) {
-    printf("double <- long long %lld = %f\n", lls[i], (double)lls[i]);
-    printf("double <- unsigned long long %llu = %f\n",
-           (unsigned long long)lls[i], (double)(unsigned long long)lls[i]);
+    printf("double <- int64_t %"PRId64" = %f\n", lls[i], (double)lls[i]);
+    printf("double <- uint64_t %"PRIu64" = %f\n",
+           (uint64_t)lls[i], (double)(uint64_t)lls[i]);
   }
 
   return 0;

Modified: test-suite/trunk/SingleSource/Regression/C/casts.reference_output
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/casts.reference_output?rev=107945&r1=107944&r2=107945&view=diff
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/casts.reference_output (original)
+++ test-suite/trunk/SingleSource/Regression/C/casts.reference_output Thu Jul  8 19:48:46 2010
@@ -2,23 +2,23 @@
 CHAR             C = 'd' (100)		(0x64)
 char to short   s1 = 100		(0x64)
 char to int     i1 = 100		(0x64)
-char to long    l1 = 100		(0x64)
+char to int64_t l1 = 100		(0x64)
 
 char to ubyte  uc1 = 100		(0x64)
 char to ushort us1 = 100		(0x64)
 char to uint   ui1 = 100		(0x64)
-char to ulong  ul1 = 100		(0x64)
+char to uint64_t ul1 = 100		(0x64)
 
 
 SHORT            S = -769		(0xfffffcff)
 short to byte    c1 = -1		(0xffffffff)
 short to int     i1 = -769		(0xfffffcff)
-short to long    l1 = -769		(0xfffffffffffffcff)
+short to int64_t l1 = -769		(0xfffffffffffffcff)
 
 short to ubyte  uc1 = 255		(0xff)
 short to ushort us1 = 64767		(0xfcff)
 short to uint   ui1 = 4294966527		(0xfffffcff)
-short to ulong  ul1 = 18446744073709550847		(0xfffffffffffffcff)
+short to uint64_t ul1 = 18446744073709550847		(0xfffffffffffffcff)
 
 
 LONG            L = 179923220407203		(0xa3a3a3a3a3a3)
@@ -29,7 +29,7 @@
 long to ubyte  uc1 = 163		(0xa3)
 long to ushort us1 = 41891		(0xa3a3)
 long to uint   ui1 = 2745410467		(0xa3a3a3a3)
-long to ulong  ul1 = 179923220407203		(0xa3a3a3a3a3a3)
+long to uint64_t ul1 = 179923220407203		(0xa3a3a3a3a3a3)
 
 
 FLOAT            F = 1.000000
@@ -37,24 +37,23 @@
 float to int     i1 = 1		(0x1)
 float to ushort us1 = 1		(0x1)
 float to uint   ui1 = 1		(0x1)
-float to ulong  ul1 = 1		(0x1)
+float to uint64_t ul1 = 1		(0x1)
 
 
 DOUBLE            D = 2.000000
 double to short   s1 = 2		(0x2)
 double to int     i1 = 2		(0x2)
-double to long    l1 = 2		(0x2)
+double to int64_t l1 = 2		(0x2)
 double to ushort us1 = 2		(0x2)
 double to uint   ui1 = 2		(0x2)
-double to ulong  ul1 = 2		(0x2)
-double <- long long 123 = 123.000000
-double <- unsigned long long 123 = 123.000000
-double <- long long -1 = -1.000000
-double <- unsigned long long 18446744073709551615 = 18446744073709551616.000000
-double <- long long -14 = -14.000000
-double <- unsigned long long 18446744073709551602 = 18446744073709551616.000000
-double <- long long 14 = 14.000000
-double <- unsigned long long 14 = 14.000000
-double <- long long -9223372036854775808 = -9223372036854775808.000000
-double <- unsigned long long 9223372036854775808 = 9223372036854775808.000000
-exit 0
+double to uint64_t ul1 = 2		(0x2)
+double <- int64_t 123 = 123.000000
+double <- uint64_t 123 = 123.000000
+double <- int64_t -1 = -1.000000
+double <- uint64_t 18446744073709551615 = 18446744073709551616.000000
+double <- int64_t -14 = -14.000000
+double <- uint64_t 18446744073709551602 = 18446744073709551616.000000
+double <- int64_t 14 = 14.000000
+double <- uint64_t 14 = 14.000000
+double <- int64_t -9223372036854775808 = -9223372036854775808.000000
+double <- uint64_t 9223372036854775808 = 9223372036854775808.000000





More information about the llvm-commits mailing list