From eb5da24bed4710f5c1fa9be221d22ddbeb44f583 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Wed, 24 Jul 2002 15:20:34 -0700 Subject: [PATCH] * gcc.c-torture/execute/loop-2e.c: Rewrite for 64 bit and no mmap. From-SVN: r55724 --- gcc/testsuite/ChangeLog | 4 + gcc/testsuite/gcc.c-torture/execute/loop-2e.c | 73 +++++++------------ 2 files changed, 30 insertions(+), 47 deletions(-) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 554b416869a..2ee83e8006a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2002-07-24 Richard Henderson + + * gcc.c-torture/execute/loop-2e.c: Rewrite for 64 bit and no mmap. + 2002-07-24 Gabriel Dos Reis * g++.dg/ext/alignof1.C (main): Return 0 for success. diff --git a/gcc/testsuite/gcc.c-torture/execute/loop-2e.c b/gcc/testsuite/gcc.c-torture/execute/loop-2e.c index b6ee6501501..71c7a4d1d87 100644 --- a/gcc/testsuite/gcc.c-torture/execute/loop-2e.c +++ b/gcc/testsuite/gcc.c-torture/execute/loop-2e.c @@ -1,31 +1,4 @@ -#include - -#ifdef __unix__ /* ??? Is that good enough? */ -#include -#include -#include -#include -#ifndef MAP_ANON -#ifdef MAP_ANONYMOUS -#define MAP_ANON MAP_ANONYMOUS -#else -#define MAP_ANON MAP_FILE -#endif -#endif -#ifndef MAP_FILE -#define MAP_FILE 0 -#endif -#ifndef MAP_FIXED -#define MAP_FIXED 0 -#endif -#endif - -#define MAP_START (void *)0x7fff8000 -#define MAP_LEN 0x10000 - -#define OFFSET (MAP_LEN/2 - 2 * sizeof (int)); - -f (int *p, int **q) +void f (int *p, int **q) { int i; for (i = 0; i < 40; i++) @@ -34,27 +7,33 @@ f (int *p, int **q) } } -main () +int main () { -#ifdef MAP_ANON void *p; int *q[40]; - int dev_zero; + __SIZE_TYPE__ start; - dev_zero = open ("/dev/zero", O_RDONLY); - /* -1 is OK when we have MAP_ANON; else mmap will flag an error. */ - if (INT_MAX != 0x7fffffffL || sizeof (char *) != sizeof (int)) - exit (0); - p = mmap (MAP_START, MAP_LEN, PROT_READ|PROT_WRITE, - MAP_ANON|MAP_FIXED|MAP_PRIVATE, dev_zero, 0); - if (p != (void *)-1) - { - p = (char *)p + OFFSET; - q[39] = 0; - f (p, q); - if (q[39] != (int *)p + 39) - abort (); - } -#endif - exit (0); + /* Find the signed middle of the address space. */ + if (sizeof(start) == sizeof(int)) + start = (__SIZE_TYPE__) __INT_MAX__; + else if (sizeof(start) == sizeof(long)) + start = (__SIZE_TYPE__) __LONG_MAX__; + else if (sizeof(start) == sizeof(long long)) + start = (__SIZE_TYPE__) __LONG_LONG_MAX__; + else + return 0; + + /* Arbitrarily align the pointer. */ + start &= -32; + + /* Pretend that's good enough to start address arithmetic. */ + p = (void *)start; + + /* Verify that GIV replacement computes the correct results. */ + q[39] = 0; + f (p, q); + if (q[39] != (int *)p + 39) + abort (); + + return 0; }