testsuite: Skip analyzer tests on AIX.
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / pr104029.c
blob04b9ef872a3aaa23a20c710471449455d3352c80
1 typedef __SIZE_TYPE__ size_t;
2 typedef const void *t_comptype;
3 typedef int (*t_compfunc)(t_comptype, t_comptype);
5 extern int *__errno_location(void)
6 __attribute__((__nothrow__, __leaf__,__const__));
7 extern void free(void *__ptr)
8 __attribute__((__nothrow__, __leaf__));
9 extern void *my_malloc1(const char *file, int line, size_t size);
11 int heapsort(void *vbase, size_t nmemb, size_t size, t_compfunc compar) {
12 char tmp, *tmp1, *tmp2, *abase, *k, *p, *t;
13 size_t cnt, i, j, l;
15 if (nmemb <= 1)
16 return (0);
18 if (!size) {
19 (*__errno_location()) = 22;
20 return (-1);
23 k = (char *) my_malloc1(__FILE__, __LINE__, size);
25 abase = (char *)vbase - size;
27 for (l = nmemb / 2 + 1; --l;) {
28 for (i = l; (j = i * 2) <= nmemb; i = j) {
29 p = abase + j * size;
30 if (j < nmemb && compar(p, p + size) < 0) {
31 p += size;
32 ++j;
34 t = abase + i * size;
35 if (compar(p, t) <= 0)
36 break;
38 cnt = size;
39 do {
40 tmp = *t;
41 *t++ = *p;
42 *p++ = tmp;
43 } while (--cnt);
48 while (nmemb > 1) {
50 cnt = size;
51 tmp1 = k;
52 tmp2 = abase + nmemb * size;
53 do {
54 *tmp1++ = *tmp2++;
55 } while (--cnt);
58 cnt = size;
59 tmp1 = abase + nmemb * size;
60 tmp2 = abase + size;
61 do {
62 *tmp1++ = *tmp2++;
63 } while (--cnt);
65 --nmemb;
67 for (i = 1; (j = i * 2) <= nmemb; i = j) {
68 p = abase + j * size;
69 if (j < nmemb && compar(p, p + size) < 0) {
70 p += size;
71 ++j;
73 t = abase + i * size;
75 cnt = size;
76 tmp1 = t;
77 tmp2 = p;
78 do {
79 *tmp1++ = *tmp2++;
80 } while (--cnt);
83 for (;;) {
84 j = i;
85 i = j / 2;
86 p = abase + j * size;
87 t = abase + i * size;
88 if (j == 1 || compar(k, t) < 0) {
90 cnt = size;
91 tmp1 = p;
92 tmp2 = k;
93 do {
94 *tmp1++ = *tmp2++;
95 } while (--cnt);
97 break;
100 cnt = size;
101 tmp1 = p;
102 tmp2 = t;
103 do {
104 *tmp1++ = *tmp2++;
105 } while (--cnt);
110 free(k);
111 return (0);