Back to index

glibc  2.9
tst-tlsmod2.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 
00003 #include <tls.h>
00004 
00005 #include "tls-macros.h"
00006 
00007 
00008 COMMON_INT_DEF(foo);
00009 
00010 
00011 int
00012 in_dso (int n, int *caller_foop)
00013 {
00014   int *foop;
00015   int result = 0;
00016 
00017   puts ("foo");                    /* Make sure PLT is used before macros.  */
00018   asm ("" ::: "memory");
00019 
00020   foop = TLS_GD (foo);
00021 
00022   if (caller_foop != NULL && foop != caller_foop)
00023     {
00024       printf ("callers address of foo differs: %p vs %p\n", caller_foop, foop);
00025       result = 1;
00026     }
00027   else if (*foop != n)
00028     {
00029       printf ("foo != %d\n", n);
00030       result = 1;
00031     }
00032 
00033   *foop = 16;
00034 
00035   return result;
00036 }