Correct DT_LOOS and DT_HIOS values.
[glibc.git] / stdlib / tst-qsort.c
blobf39667b17ccbd0e3fc996dc6707262d88eae13a6
1 /* Test case by Paul Eggert <eggert@twinsun.com> */
2 #include <stdio.h>
3 #include <stdlib.h>
5 struct big { char c[4 * 1024]; };
7 struct big *array;
8 struct big *array_end;
10 int
11 compare (void const *a1, void const *b1)
13 struct big const *a = a1;
14 struct big const *b = b1;
15 if (! (array <= a && a < array_end
16 && array <= b && b < array_end))
18 exit (EXIT_FAILURE);
20 return b->c[0] - a->c[0];
23 int
24 main (int argc, char **argv)
26 size_t i;
27 size_t array_members = argv[1] ? atoi (argv[1]) : 50;
28 array = (struct big *) malloc (array_members * sizeof *array);
29 if (array == NULL)
31 puts ("no memory");
32 exit (EXIT_FAILURE);
35 array_end = array + array_members;
36 for (i = 0; i < array_members; i++)
37 array[i].c[0] = i % 128;
39 qsort (array, array_members, sizeof *array, compare);
41 return 0;