source: vendor/glibc-tests/2005-06-14/elf/tst-tls14.c

Last change on this file was 2036, checked in by bird, 20 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.0 KB
Line 
1/* Check alignment of TLS variable. */
2#include <dlfcn.h>
3#include <stdint.h>
4#include <stdio.h>
5#include <stdlib.h>
6
7#include <tls.h>
8
9#if USE_TLS && HAVE___THREAD
10
11#define AL 4096
12struct foo
13{
14 int i;
15} __attribute ((aligned (AL)));
16
17static __thread struct foo f;
18static struct foo g;
19
20
21extern int in_dso1 (void);
22
23
24static int
25do_test (void)
26{
27 int result = 0;
28
29 int fail = (((uintptr_t) &f) & (AL - 1)) != 0;
30 printf ("&f = %p %s\n", &f, fail ? "FAIL" : "OK");
31 result |= fail;
32
33 fail = (((uintptr_t) &g) & (AL - 1)) != 0;
34 printf ("&g = %p %s\n", &g, fail ? "FAIL" : "OK");
35 result |= fail;
36
37 result |= in_dso1 ();
38
39 void *h = dlopen ("tst-tlsmod14b.so", RTLD_LAZY);
40 if (h == NULL)
41 {
42 printf ("cannot open tst-tlsmod14b.so: %m\n");
43 exit (1);
44 }
45
46 int (*fp) (void) = (int (*) (void)) dlsym (h, "in_dso2");
47 if (fp == NULL)
48 {
49 puts ("cannot find in_dso2");
50 exit (1);
51 }
52
53 result |= fp ();
54
55 return result;
56}
57
58#define TEST_FUNCTION do_test ()
59
60#else
61
62#define TEST_FUNCTION 0
63
64#endif
65
66#include "../test-skeleton.c"
Note: See TracBrowser for help on using the repository browser.