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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [simulate-thread/] [atomics-1.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 "-std=c++0x" } */
3
/* { dg-final { simulate-thread } } */
4
 
5
/* Test that atomic int and atomic char work properly.  */
6
 
7
using namespace std;
8
 
9
#include 
10
#include 
11
#include 
12
#include "simulate-thread.h"
13
 
14
atomic atomi;
15
atomic atomc;
16
 
17
/* No need for parallel threads to do anything */
18
void simulate_thread_other_threads()
19
{
20
}
21
 
22
/* Verify after every instruction is executed, that the atmoic int and
23
   char have one of the 2 legitimate values. */
24
int simulate_thread_step_verify()
25
{
26
  if (atomi != 0 && atomi != INT_MAX)
27
    {
28
      printf ("FAIL: invalid intermediate result for atomi (%d).\n",
29
              (int)atomi);
30
      return 1;
31
    }
32
  if (atomc != 0 && atomc != CHAR_MAX)
33
    {
34
      printf ("FAIL: invalid intermediate result for atomc (%d).\n",
35
              (int)atomc);
36
      return 1;
37
    }
38
  return 0;
39
}
40
 
41
 
42
/* Verify that both atmoics have the corerct value.  */
43
int simulate_thread_final_verify()
44
{
45
  if (atomi != INT_MAX)
46
    {
47
      printf ("FAIL: invalid final result for atomi (%d).\n",
48
              (int)atomi);
49
      return 1;
50
    }
51
  if (atomc != CHAR_MAX)
52
    {
53
      printf ("FAIL: invalid final result for atomc (%d).\n",
54
              (int)atomc);
55
      return 1;
56
    }
57
  return 0;
58
}
59
 
60
/* Test a store to an atomic int and an atomic char. */
61
__attribute__((noinline))
62
void simulate_thread_main()
63
{
64
  atomi = INT_MAX;
65
  atomc = CHAR_MAX;
66
}
67
 
68
int main ()
69
{
70
  simulate_thread_main();
71
  simulate_thread_done();
72
  return 0;
73
}

powered by: WebSVN 2.1.0

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