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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [builtins/] [abs-2.c] - Blame information for rev 297

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 297 jeremybenn
/* Test for builtin abs, labs, llabs, imaxabs.  */
2
/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
3
 
4
#include <limits.h>
5
typedef __INTMAX_TYPE__ intmax_t;
6
#define INTMAX_MAX __INTMAX_MAX__
7
 
8
extern int abs (int);
9
extern long labs (long);
10
extern long long llabs (long long);
11
extern intmax_t imaxabs (intmax_t);
12
extern void abort (void);
13
extern void link_error (void);
14
 
15
void
16
main_test (void)
17
{
18
  /* For each type, test both runtime and compile time (constant folding)
19
     optimization.  */
20
  volatile int i0 = 0, i1 = 1, im1 = -1, imin = -INT_MAX, imax = INT_MAX;
21
  volatile long l0 = 0L, l1 = 1L, lm1 = -1L, lmin = -LONG_MAX, lmax = LONG_MAX;
22
  volatile long long ll0 = 0LL, ll1 = 1LL, llm1 = -1LL;
23
  volatile long long llmin = -__LONG_LONG_MAX__, llmax = __LONG_LONG_MAX__;
24
  volatile intmax_t imax0 = 0, imax1 = 1, imaxm1 = -1;
25
  volatile intmax_t imaxmin = -INTMAX_MAX, imaxmax = INTMAX_MAX;
26
  if (abs (i0) != 0)
27
    abort ();
28
  if (abs (0) != 0)
29
    link_error ();
30
  if (abs (i1) != 1)
31
    abort ();
32
  if (abs (1) != 1)
33
    link_error ();
34
  if (abs (im1) != 1)
35
    abort ();
36
  if (abs (-1) != 1)
37
    link_error ();
38
  if (abs (imin) != INT_MAX)
39
    abort ();
40
  if (abs (-INT_MAX) != INT_MAX)
41
    link_error ();
42
  if (abs (imax) != INT_MAX)
43
    abort ();
44
  if (abs (INT_MAX) != INT_MAX)
45
    link_error ();
46
  if (labs (l0) != 0L)
47
    abort ();
48
  if (labs (0L) != 0L)
49
    link_error ();
50
  if (labs (l1) != 1L)
51
    abort ();
52
  if (labs (1L) != 1L)
53
    link_error ();
54
  if (labs (lm1) != 1L)
55
    abort ();
56
  if (labs (-1L) != 1L)
57
    link_error ();
58
  if (labs (lmin) != LONG_MAX)
59
    abort ();
60
  if (labs (-LONG_MAX) != LONG_MAX)
61
    link_error ();
62
  if (labs (lmax) != LONG_MAX)
63
    abort ();
64
  if (labs (LONG_MAX) != LONG_MAX)
65
    link_error ();
66
  if (llabs (ll0) != 0LL)
67
    abort ();
68
  if (llabs (0LL) != 0LL)
69
    link_error ();
70
  if (llabs (ll1) != 1LL)
71
    abort ();
72
  if (llabs (1LL) != 1LL)
73
    link_error ();
74
  if (llabs (llm1) != 1LL)
75
    abort ();
76
  if (llabs (-1LL) != 1LL)
77
    link_error ();
78
  if (llabs (llmin) != __LONG_LONG_MAX__)
79
    abort ();
80
  if (llabs (-__LONG_LONG_MAX__) != __LONG_LONG_MAX__)
81
    link_error ();
82
  if (llabs (llmax) != __LONG_LONG_MAX__)
83
    abort ();
84
  if (llabs (__LONG_LONG_MAX__) != __LONG_LONG_MAX__)
85
    link_error ();
86
  if (imaxabs (imax0) != 0)
87
    abort ();
88
  if (imaxabs (0) != 0)
89
    link_error ();
90
  if (imaxabs (imax1) != 1)
91
    abort ();
92
  if (imaxabs (1) != 1)
93
    link_error ();
94
  if (imaxabs (imaxm1) != 1)
95
    abort ();
96
  if (imaxabs (-1) != 1)
97
    link_error ();
98
  if (imaxabs (imaxmin) != INTMAX_MAX)
99
    abort ();
100
  if (imaxabs (-INTMAX_MAX) != INTMAX_MAX)
101
    link_error ();
102
  if (imaxabs (imaxmax) != INTMAX_MAX)
103
    abort ();
104
  if (imaxabs (INTMAX_MAX) != INTMAX_MAX)
105
    link_error ();
106
}

powered by: WebSVN 2.1.0

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