~mingw-w64/mingw-w64/experimental

« back to all changes in this revision

Viewing changes to ros-privexp/mingw-w64-crt/testcases/t_tls1.c

  • Committer: NightStrike
  • Date: 2010-08-11 22:20:57 UTC
  • Revision ID: svn-v4:4407c894-4637-0410-b4f5-ada5f102cad1:experimental:3266
Branch for adding option for supporting ros

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 need gcc-4.3.4 (gcc-4_3-branch r149015)
 
3
   or gcc-4.4.1 (gcc-4_4-branch r149016)
 
4
   or gcc-4.5.x (trunk r149593) or newer
 
5
 which have a properly fixed gcc/emutls.c,
 
6
 along with mingw-w64-headers r960 and
 
7
 mingw-w64-crt r973.
 
8
*/
 
9
 
 
10
#include <sys/types.h>
 
11
#include <stdio.h>
 
12
#include <stdlib.h>
 
13
#include <windows.h>
 
14
 
 
15
#if defined(_MSC_VER) /* MS Visual Studio */
 
16
#define __threadlocal__ __declspec(thread)
 
17
#elif defined(__GNUC__) && ((__GNUC__ > 4) \
 
18
  || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
 
19
/* gcc >= 4.3, also needs binutils >= 2.19 */
 
20
#define __threadlocal__ __thread
 
21
#else
 
22
#error No keyword for TLS vars is defined.
 
23
#endif
 
24
 
 
25
__threadlocal__ int tvar = 0;
 
26
 
 
27
int main (int argc, char **argv)
 
28
{
 
29
  (void)argv;
 
30
  if (argc != 1)
 
31
    {
 
32
      printf("not referencing tvar\n");
 
33
    }
 
34
  else
 
35
    {
 
36
      printf("incrementing tvar..\n");
 
37
      ++tvar;
 
38
      printf("   .. done (%i)\n", tvar);
 
39
    }
 
40
  printf("exiting....\n");
 
41
  exit (0);
 
42
}
 
43