(parse_grp_str): PIDLIST is supposed to have NGRPS elements.
[glibc/history.git] / elf / tst-audit2.c
blobfd089b6f6479b22b37038fa49dd1892a3b4e067c
1 /* Test case for early TLS initialization in dynamic linker. */
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
7 #if HAVE___THREAD
8 # define MAGIC1 0xabcdef72
9 # define MAGIC2 0xd8675309
10 static __thread unsigned int magic[] = { MAGIC1, MAGIC2 };
11 #endif
13 #undef calloc
15 /* This calloc definition will be called by the dynamic linker itself.
16 We test that it has initialized our TLS block by the time it does so. */
18 void *
19 calloc (size_t n, size_t m)
21 #if HAVE___THREAD
22 if (magic[0] != MAGIC1 || magic[1] != MAGIC2)
24 printf ("{%x, %x} != {%x, %x}\n", magic[0], magic[1], MAGIC1, MAGIC2);
25 abort ();
27 magic[0] = MAGIC2;
28 magic[1] = MAGIC1;
29 #endif
31 n *= m;
32 void *ptr = malloc (n);
33 if (ptr != NULL)
34 memset (ptr, '\0', n);
35 return ptr;
38 int
39 main (void)
41 #if HAVE___THREAD
42 if (magic[1] != MAGIC1 || magic[0] != MAGIC2)
44 printf ("{%x, %x} != {%x, %x}\n", magic[0], magic[1], MAGIC2, MAGIC1);
45 return 1;
47 #endif
49 return 0;