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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [tm/] [pr45940-3.C] - Blame information for rev 749

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

Line No. Rev Author Line
1 693 jeremybenn
// { dg-do compile }
2
// { dg-options "-fgnu-tm -O0" }
3
 
4
__attribute__((transaction_safe))
5
void* operator new (__SIZE_TYPE__);
6
 
7
__attribute__((transaction_pure))
8
inline int atomic_exchange_and_add( int * pw, int dv )
9
{
10
    int r;
11
    __asm__ ("" : "=r"(r));
12
    return r;
13
}
14
 
15
class sp_counted_base
16
{
17
protected:
18
    int use_count_;        // #shared
19
public:
20
    __attribute__((transaction_safe))
21
    virtual void dispose() = 0; // nothrow
22
 
23
    __attribute__((transaction_safe))
24
    void release() // nothrow
25
    {
26
        if( atomic_exchange_and_add( &use_count_, -1 ) == 1 )
27
        {
28
            dispose();
29
        }
30
    }
31
};
32
 
33
class sp_counted_base_x86 : public sp_counted_base
34
{
35
public:
36
  void dispose()
37
  {
38
    release();
39
  }
40
};
41
 
42
class shared_count
43
{
44
private:
45
    sp_counted_base * pi_;
46
public:
47
    int j;
48
    __attribute__((transaction_safe))
49
    shared_count(): pi_(new sp_counted_base_x86()), j(0)
50
    {
51
    }
52
    __attribute__((transaction_safe))
53
    ~shared_count() // nothrow
54
    {
55
        if( pi_ != 0 ) pi_->release();
56
    }
57
};
58
 
59
volatile int i = 1;
60
shared_count * c;
61
int main()
62
{
63
  if ( i == 0) {
64
    __transaction_atomic {
65
     shared_count sc;
66
    }
67
  }
68
  return 0;
69
}

powered by: WebSVN 2.1.0

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