X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=blobdiff_plain;f=gcc%2Ftestsuite%2Fgcc.c-torture%2Fexecute%2Fmulti-ix.c;h=377f08c115cb918db47988ee9687e5196e8261bb;hp=c9f28b0ac8deccdc0e444e631fe136c97567d41e;hb=37bc930d0411dc1436654cb32f3333eac55e5e5d;hpb=dd691fd82a095f40bf1ae57b0bf481e4084bf58b diff --git a/gcc/testsuite/gcc.c-torture/execute/multi-ix.c b/gcc/testsuite/gcc.c-torture/execute/multi-ix.c index c9f28b0ac8d..377f08c115c 100644 --- a/gcc/testsuite/gcc.c-torture/execute/multi-ix.c +++ b/gcc/testsuite/gcc.c-torture/execute/multi-ix.c @@ -21,8 +21,15 @@ Subtract the last two off STACK_SIZE and figure out what the maximum chunk size can be. We make the last bit conservative to account for - register saves and other processor-dependent saving. */ -#define CHUNK ((STACK_SIZE-40*sizeof(int)-256*sizeof(void *))/40/sizeof(int)) + register saves and other processor-dependent saving. Limit the + chunk size to some sane values. */ + +#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) +#define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) + +#define CHUNK \ + MIN (500, (MAX (1, (signed)(STACK_SIZE-40*sizeof(int)-256*sizeof(void *)) \ + / (signed)(40*sizeof(int))))) #else #define CHUNK 500 #endif @@ -146,6 +153,11 @@ f (int n) int main () { + /* CHUNK needs to be at least 40 to avoid stack corruption, + since index variable i0 in "a[i0] = i0" equals 39. */ + if (CHUNK < 40) + exit (0); + f (1); exit (0); }