Remove socket.S implementation
[glibc.git] / elf / tst-audit2.c
blobacad1b05cf7d1b250dd0d0c6148abfb150a850ab
1 /* Test case for early TLS initialization in dynamic linker. */
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
7 #define MAGIC1 0xabcdef72
8 #define MAGIC2 0xd8675309
9 static __thread unsigned int magic[] = { MAGIC1, MAGIC2 };
11 #undef calloc
13 /* This calloc definition will be called by the dynamic linker itself.
14 We test that it has initialized our TLS block by the time it does so. */
16 void *
17 calloc (size_t n, size_t m)
19 if (magic[0] != MAGIC1 || magic[1] != MAGIC2)
21 printf ("{%x, %x} != {%x, %x}\n", magic[0], magic[1], MAGIC1, MAGIC2);
22 abort ();
24 magic[0] = MAGIC2;
25 magic[1] = MAGIC1;
27 n *= m;
28 void *ptr = malloc (n);
29 if (ptr != NULL)
30 memset (ptr, '\0', n);
31 return ptr;
34 static int
35 do_test (void)
37 if (magic[1] != MAGIC1 || magic[0] != MAGIC2)
39 printf ("{%x, %x} != {%x, %x}\n", magic[0], magic[1], MAGIC2, MAGIC1);
40 return 1;
43 return 0;
46 #define TEST_FUNCTION do_test ()
47 #include "../test-skeleton.c"