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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [simulate-thread/] [bitfields.C] - Blame information for rev 693

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
/* { dg-do link } */
2
/* { dg-options "--param allow-load-data-races=0 --param allow-store-data-races=0" } */
3
/* { dg-final { simulate-thread } } */
4
 
5
/* Test that setting  does not touch either  or .
6
   In the C++ memory model, non contiguous bitfields ("a" and "c"
7
   here) should be considered as distinct memory locations, so we
8
   can't use bit twiddling to set either one.  */
9
 
10
#include 
11
#include "simulate-thread.h"
12
 
13
#define CONSTA 12
14
 
15
static int global;
16
struct S
17
{
18
  /* On x86-64, the volatile causes us to access  with a 32-bit
19
     access, and thus trigger this test.  */
20
  volatile unsigned int a : 4;
21
 
22
  unsigned char b;
23
  unsigned int c : 6;
24
} var;
25
 
26
__attribute__((noinline))
27
void set_a()
28
{
29
  var.a = CONSTA;
30
}
31
 
32
void simulate_thread_other_threads()
33
{
34
  ++global;
35
  var.b = global;
36
  var.c = global;
37
}
38
 
39
int simulate_thread_step_verify()
40
{
41
  int ret = 0;
42
  if (var.b != global)
43
    {
44
      printf ("FAIL: Unexpected value: var.b is %d, should be %d\n",
45
              var.b, global);
46
      ret = 1;
47
    }
48
  if (var.c != global)
49
    {
50
      printf ("FAIL: Unexpected value: var.c is %d, should be %d\n",
51
              var.c, global);
52
      ret = 1;
53
    }
54
  return ret;
55
}
56
 
57
int simulate_thread_final_verify()
58
{
59
  int ret = simulate_thread_step_verify();
60
  if (var.a != CONSTA)
61
    {
62
      printf ("FAIL: Unexpected value: var.a is %d, should be %d\n",
63
              var.a, CONSTA);
64
      ret = 1;
65
    }
66
  return ret;
67
}
68
 
69
__attribute__((noinline))
70
void simulate_thread_main()
71
{
72
  set_a();
73
}
74
 
75
int main ()
76
{
77
  simulate_thread_main();
78
  simulate_thread_done();
79
  return 0;
80
}

powered by: WebSVN 2.1.0

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