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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [pr45034.c] - Blame information for rev 801

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

Line No. Rev Author Line
1 688 jeremybenn
extern void abort (void);
2
static void fixnum_neg(signed char x, signed char *py, int *pv)
3
{
4
  unsigned char ux, uy;
5
 
6
  ux = (unsigned char)x;
7
  uy = -ux;
8
  *py = (uy <= 127) ? (signed char)uy : (-(signed char)(255 - uy) - 1);
9
  *pv = (x == -128) ? 1 : 0;
10
}
11
 
12
void __attribute__((noinline)) foo(int x, int y, int v)
13
{
14
  if (y < -128 || y > 127)
15
    abort();
16
}
17
 
18
int test_neg(void)
19
{
20
  signed char x, y;
21
  int v, err;
22
 
23
  err = 0;
24
  x = -128;
25
  for (;;) {
26
      fixnum_neg(x, &y, &v);
27
      foo((int)x, (int)y, v);
28
      if ((v && x != -128) || (!v && x == -128))
29
        ++err;
30
      if (x == 127)
31
        break;
32
      ++x;
33
  }
34
  return err;
35
}
36
 
37
int main(void)
38
{
39
  if (sizeof (char) != 1)
40
    return 0;
41
  if (test_neg() != 0)
42
    abort();
43
  return 0;
44
}
45
 

powered by: WebSVN 2.1.0

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