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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// PR target/38287
2
// { dg-do run }
3
// { dg-options "-O2 -mcpu=v8 -fPIC" { target { { sparc*-*-* } && { ilp32 && fpic } } } }
4
 
5
#include 
6
 
7
class QTime
8
{
9
public:
10
    explicit QTime(int ms = 0) : ds(ms) {}
11
    static QTime currentTime() { return QTime(); }
12
    QTime addMSecs(int ms) const;
13
    int msecs() const { return ds; }
14
private:
15
    unsigned ds;
16
};
17
 
18
static const unsigned MSECS_PER_DAY = 86400000;
19
 
20
QTime QTime::addMSecs(int ms) const
21
{
22
    QTime t;
23
    if ( ms < 0 ) {
24
        // % not well-defined for -ve, but / is.
25
        int negdays = (MSECS_PER_DAY-ms) / MSECS_PER_DAY;
26
        t.ds = ((int)ds + ms + negdays*MSECS_PER_DAY)
27
                % MSECS_PER_DAY;
28
    } else {
29
        t.ds = ((int)ds + ms) % MSECS_PER_DAY;
30
    }
31
    return t;
32
}
33
 
34
int main()
35
{
36
  if (QTime(1).addMSecs(1).msecs() != 2)
37
    abort ();
38
  return 0;
39
}

powered by: WebSVN 2.1.0

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