1 /* Test case by Paul Eggert <eggert@twinsun.com> */
4 #include <tst-stack-align.h>
6 struct big
{ char c
[4 * 1024]; };
11 static int align_check
;
14 compare (void const *a1
, void const *b1
)
16 struct big
const *a
= a1
;
17 struct big
const *b
= b1
;
20 align_check
= TEST_STACK_ALIGN () ? -1 : 1;
22 if (! (array
<= a
&& a
< array_end
23 && array
<= b
&& b
< array_end
))
27 return b
->c
[0] - a
->c
[0];
31 main (int argc
, char **argv
)
34 size_t array_members
= argv
[1] ? atoi (argv
[1]) : 50;
35 array
= (struct big
*) malloc (array_members
* sizeof *array
);
42 array_end
= array
+ array_members
;
43 for (i
= 0; i
< array_members
; i
++)
44 array
[i
].c
[0] = i
% 128;
46 qsort (array
, array_members
, sizeof *array
, compare
);
48 if (align_check
== -1)
50 puts ("stack not sufficiently aligned");