xref: /third_party/musl/libc-test/src/functional/tls_init_dlopen.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/musl/libc-test/src/functional/
1570af302Sopenharmony_ci#include <string.h>
2570af302Sopenharmony_ci#include <dlfcn.h>
3570af302Sopenharmony_ci#include "test.h"
4570af302Sopenharmony_ci
5570af302Sopenharmony_ciint main(int argc, char *argv[])
6570af302Sopenharmony_ci{
7570af302Sopenharmony_ci	void *h;
8570af302Sopenharmony_ci	char *(*f)(void);
9570af302Sopenharmony_ci	char *s;
10570af302Sopenharmony_ci	char buf[512];
11570af302Sopenharmony_ci
12570af302Sopenharmony_ci	t_pathrel(buf, sizeof buf, argv[0], "libtls_init_dso.so");
13570af302Sopenharmony_ci	h = dlopen(buf, RTLD_NOW|RTLD_GLOBAL);
14570af302Sopenharmony_ci	if (!h)
15570af302Sopenharmony_ci		t_error("dlopen failed: %s\n", dlerror());
16570af302Sopenharmony_ci	f = dlsym(h, "gettls");
17570af302Sopenharmony_ci	if (!f)
18570af302Sopenharmony_ci		t_error("dlsym failed: %s\n", dlerror());
19570af302Sopenharmony_ci	s = f();
20570af302Sopenharmony_ci	if (!s)
21570af302Sopenharmony_ci		t_error("tls was not initialized at dlopen\n");
22570af302Sopenharmony_ci	if (strcmp(s, "foobar")!=0)
23570af302Sopenharmony_ci		t_error("tls was not initialized correctly at dlopen (got \"%s\", want \"foobar\"\n", s);
24570af302Sopenharmony_ci
25570af302Sopenharmony_ci	return t_status;
26570af302Sopenharmony_ci}
27

Indexes created Thu Nov 07 10:32:03 CST 2024