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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [c-c++-common/] [simulate-thread/] [bitfields-4.c] - Blame information for rev 686

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 686 jeremybenn
/* { dg-do link } */
2
/* { dg-options "--param allow-store-data-races=0" } */
3
/* { dg-final { simulate-thread } } */
4
 
5
#include <stdio.h>
6
#include <stdlib.h>
7
#include "../../gcc.dg/simulate-thread/simulate-thread.h"
8
 
9
struct bits
10
{
11
  char a;
12
  int b:7;
13
  int c:9;
14
  unsigned char d;
15
} *p;
16
 
17
static int global = 0;
18
 
19
void simulate_thread_other_threads()
20
{
21
  global++;
22
  p->d = global % 256;
23
}
24
 
25
int simulate_thread_step_verify()
26
{
27
  if (p->d != global % 256)
28
    {
29
      printf("FAIL: invalid intermediate result\n");
30
      return 1;
31
    }
32
  return 0;
33
}
34
 
35
int simulate_thread_final_verify()
36
{
37
  if (p->c != 55)
38
    {
39
      printf("FAIL: invalid final result\n");
40
      return 1;
41
    }
42
  return 0;
43
}
44
 
45
/* Store into <c> should not clobber <d>.  */
46
/* We should not use a 32-bit move to store into p->, but a smaller move.  */
47
__attribute__((noinline))
48
void simulate_thread_main()
49
{
50
  p -> c = 55;
51
}
52
 
53
 
54
int main()
55
{
56
  p = (struct bits *) calloc (1, sizeof (struct bits));
57
  simulate_thread_main();
58
  simulate_thread_done();
59
  return 0;
60
}

powered by: WebSVN 2.1.0

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