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 (format: "dlopen failed: %s\n", dlerror ());
15 exit (status: 1);
16 }
17 if (dlsym (handle: h, name: "sin") == NULL)
18 {
19 printf (format: "dlsym failed: %s\n", dlerror ());
20 exit (status: 1);
21 }
22 if (dlclose (handle: h) != 0)
23 {
24 printf (format: "dlclose failed: %s\n", dlerror ());
25 exit (status: 1);
26 }
27 return NULL;
28}
29
30
31static int
32do_test (void)
33{
34#define N 10
35 pthread_t th[N];
36 for (int i = 0; i < N; ++i)
37 {
38 int e = pthread_create (newthread: &th[i], NULL, start_routine: tf, NULL);
39 if (e != 0)
40 {
41 printf (format: "pthread_create failed with %d (%s)\n", e, strerror (errnum: e));
42 return 1;
43 }
44 }
45 for (int i = 0; i < N; ++i)
46 {
47 void *res;
48 int e = pthread_join (th: th[i], thread_return: &res);
49 if (e != 0 || res != NULL)
50 {
51 puts (s: "thread failed");
52 return 1;
53 }
54 }
55 return 0;
56}
57
58#include <support/test-driver.c>
59

source code of glibc/elf/tst-thrlock.c