This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 5/5][testsuite] Use stdint.h when needing int of exact size
- From: Rask Ingemann Lambertsen <rask at sygehus dot dk>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 24 Jul 2007 19:24:54 +0200
- Subject: [PATCH 5/5][testsuite] Use stdint.h when needing int of exact size
- References: <20070724160434.GB4125@sygehus.dk>
These testcases all rely on very specific integer sizes to pass. The
vector tests assume the vectors have exactly four elements and simd-4.c
additionally needs integers of exactly 32 bits and 64 bits. pr27743.c relies
on sign extension of bit 31, so a signed 32-bit integer is required. This
patch uses types from stdint.h to make sure that these requirements are
met, also on targets where int gives you only 16 bits.
Ok for trunk?
:ADDPATCH testsuite:
2007-07-24 Rask Ingemann Lambertsen <rask@sygehus.dk>
* gcc.dg/torture/pr27743.c (bar): Use an integer of exactly 32 bits
where required.
* gcc.c-torture/execute/simd-1.c: Likewise.
* gcc.c-torture/execute/pr23135.c: Likewise.
* gcc.c-torture/execute/simd-4.c (__ev_convert_s64)(main): Likewise.
Use an integer of exactly 64 bits where required.
Index: gcc.c-torture/execute/simd-1.c
===================================================================
--- gcc.c-torture/execute/simd-1.c (revision 126653)
+++ gcc.c-torture/execute/simd-1.c (working copy)
@@ -3,9 +3,10 @@
Purpose: Test generic SIMD support. This test should work
regardless of if the target has SIMD instructions.
*/
+#include <stdint.h>
-typedef int __attribute__((vector_size (16))) vecint;
-typedef int __attribute__((mode(SI))) siint;
+typedef int32_t __attribute__((vector_size (16))) vecint;
+typedef int32_t siint;
vecint i = { 150, 100, 150, 200 };
vecint j = { 10, 13, 20, 30 };
Index: gcc.c-torture/execute/simd-4.c
===================================================================
--- gcc.c-torture/execute/simd-4.c (revision 126653)
+++ gcc.c-torture/execute/simd-4.c (working copy)
@@ -1,17 +1,18 @@
-typedef int __attribute__((vector_size(8))) v2si;
-long long s64;
+#include <stdint.h>
+typedef int32_t __attribute__((vector_size(8))) v2si;
+int64_t s64;
-static inline long long
+static inline int64_t
__ev_convert_s64 (v2si a)
{
- return (long long) a;
+ return (int64_t) a;
}
int main()
{
- union { long long ll; int i[2]; } endianness_test;
+ union { int64_t ll; int32_t i[2]; } endianness_test;
endianness_test.ll = 1;
- int little_endian = endianness_test.i[0];
+ int32_t little_endian = endianness_test.i[0];
s64 = __ev_convert_s64 ((v2si){1,0xffffffff});
if (s64 != (little_endian ? 0xffffffff00000001LL : 0x1ffffffffLL))
abort ();
Index: gcc.c-torture/execute/pr23135.c
===================================================================
--- gcc.c-torture/execute/pr23135.c (revision 126653)
+++ gcc.c-torture/execute/pr23135.c (working copy)
@@ -1,14 +1,15 @@
/* Based on execute/simd-1.c, modified by joern.rennecke@st.com to
trigger a reload bug. Verified for gcc mainline from 20050722 13:00 UTC
for sh-elf -m4 -O2. */
+#include <stdint.h>
#ifndef STACK_SIZE
#define STACK_SIZE (256*1024)
#endif
typedef struct { char c[STACK_SIZE/2]; } big_t;
-typedef int __attribute__((vector_size (8))) vecint;
-typedef int __attribute__((mode(SI))) siint;
+typedef int32_t __attribute__((vector_size (8))) vecint;
+typedef int32_t siint;
vecint i = { 150, 100 };
vecint j = { 10, 13 };
Index: gcc.dg/torture/pr27743.c
===================================================================
--- gcc.dg/torture/pr27743.c (revision 126653)
+++ gcc.dg/torture/pr27743.c (working copy)
@@ -1,10 +1,11 @@
-/* { dg-do run } */
+/* { dg-do run { target { stdint_types } } } */
+#include <stdint.h>
extern void abort(void);
-int bar(int a)
+int32_t bar (int32_t a)
{
- return ((unsigned) ((a) >> 2)) >> 15;
+ return ((uint32_t) ((a) >> 2)) >> 15;
}
int main()
--
Rask Ingemann Lambertsen