]> git.ipfire.org Git - thirdparty/glibc.git/blame - elf/tst-thrlock.c
tunables: Avoid getenv calls and disable glibc.malloc.check by default
[thirdparty/glibc.git] / elf / tst-thrlock.c
CommitLineData
ffd0e1b7
UD
1#include <dlfcn.h>
2#include <pthread.h>
3#include <stdio.h>
4#include <stdlib.h>
5#include <string.h>
6#include <gnu/lib-names.h>
7
8static void *
9tf (void *arg)
10{
11 void *h = dlopen (LIBM_SO, RTLD_LAZY);
12 if (h == NULL)
13 {
14 printf ("dlopen failed: %s\n", dlerror ());
15 exit (1);
16 }
17 if (dlsym (h, "sin") == NULL)
18 {
19 printf ("dlsym failed: %s\n", dlerror ());
20 exit (1);
21 }
22 if (dlclose (h) != 0)
23 {
24 printf ("dlclose failed: %s\n", dlerror ());
25 exit (1);
26 }
27 return NULL;
28}
29
11bf311e
UD
30
31static int
32do_test (void)
ffd0e1b7
UD
33{
34#define N 10
35 pthread_t th[N];
36 for (int i = 0; i < N; ++i)
37 {
38 int e = pthread_create (&th[i], NULL, tf, NULL);
39 if (e != 0)
40 {
41 printf ("pthread_create failed with %d (%s)\n", e, strerror (e));
42 return 1;
43 }
44 }
45 for (int i = 0; i < N; ++i)
46 {
47 void *res;
48 int e = pthread_join (th[i], &res);
49 if (e != 0 || res != NULL)
50 {
51 puts ("thread failed");
52 return 1;
53 }
54 }
55 return 0;
56}
11bf311e
UD
57
58#define TEST_FUNCTION do_test ()
59#include "../test-skeleton.c"