OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [torture/] [tls/] [tls-test.c] - Blame information for rev 774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* { dg-do run }  */
2
/* { dg-require-effective-target tls  }  */
3
/* { dg-require-effective-target pthread } */
4
/* { dg-options "-pthread" } */
5
 
6
#include <pthread.h>
7
extern int printf (char *,...);
8
__thread int a = 5;
9
int *volatile a_in_other_thread = (int *) 12345;
10
 
11
static void *
12
thread_func (void *arg)
13
{
14
  a_in_other_thread = &a;
15
  a+=5;
16
  *((int *) arg) = a;
17
  return (void *)0;
18
}
19
 
20
int
21
main ()
22
{
23
  pthread_t thread;
24
  void *thread_retval;
25
  int *volatile a_in_main_thread;
26
  int *volatile again ;
27
  int thr_a;
28
 
29
  a_in_main_thread = &a;
30
 
31
  if (pthread_create (&thread, (pthread_attr_t *)0, thread_func, &thr_a))
32
    return 0;
33
 
34
  if (pthread_join (thread, &thread_retval))
35
    return 0;
36
 
37
  again = &a;
38
  if (again != a_in_main_thread)
39
    {
40
      printf ("FAIL: main thread addy changed from 0x%0x to 0x%0x\n",
41
                a_in_other_thread, again);
42
      return 1;
43
    }
44
 
45
  if (a != 5 || thr_a != 10 || (a_in_other_thread == a_in_main_thread))
46
    {
47
      printf ("FAIL: a= %d, thr_a = %d Addr = 0x%0x\n",
48
                a, thr_a, a_in_other_thread);
49
      return 1;
50
    }
51
  return 0;
52
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.