Blame src/functional/tls_init_dlopen.c
|
Szabolcs Nagy |
164c1f |
#include <string.h>
|
|
Szabolcs Nagy |
164c1f |
#include <dlfcn.h>
|
|
Szabolcs Nagy |
164c1f |
#include "test.h"
|
|
Szabolcs Nagy |
164c1f |
|
|
Szabolcs Nagy |
164c1f |
int main()
|
|
Szabolcs Nagy |
164c1f |
{
|
|
Szabolcs Nagy |
164c1f |
void *h;
|
|
Szabolcs Nagy |
164c1f |
char *(*f)(void);
|
|
Szabolcs Nagy |
164c1f |
char *s;
|
|
Szabolcs Nagy |
164c1f |
|
|
Szabolcs Nagy |
164c1f |
h = dlopen("src/functional/tls_init_dso.so", RTLD_NOW|RTLD_GLOBAL);
|
|
Szabolcs Nagy |
164c1f |
if (!h)
|
|
Szabolcs Nagy |
164c1f |
t_error("dlopen failed: %s\n", dlerror());
|
|
Szabolcs Nagy |
164c1f |
f = dlsym(h, "gettls");
|
|
Szabolcs Nagy |
164c1f |
if (!f)
|
|
Szabolcs Nagy |
164c1f |
t_error("dlsym failed: %s\n", dlerror());
|
|
Szabolcs Nagy |
164c1f |
s = f();
|
|
Szabolcs Nagy |
164c1f |
if (!s)
|
|
Szabolcs Nagy |
164c1f |
t_error("tls was not initialized at dlopen\n");
|
|
Szabolcs Nagy |
164c1f |
if (strcmp(s, "foobar")!=0)
|
|
Szabolcs Nagy |
164c1f |
t_error("tls was not initialized correctly at dlopen (got \"%s\", want \"foobar\"\n", s);
|
|
Szabolcs Nagy |
164c1f |
|
|
Szabolcs Nagy |
164c1f |
return t_status;
|
|
Szabolcs Nagy |
164c1f |
}
|