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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [testsuite/] [gcc.dg/] [torture/] [builtin-rounding-1.c] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
/* Copyright (C) 2004 Free Software Foundation.
2
 
3
   Check that constant folding of the rounding math functions doesn't
4
   break anything and produces the expected results.
5
 
6
   Written by Kaveh Ghazi, 2004-04-29.  */
7
 
8
/* { dg-do link } */
9
 
10
#define PROTOTYPE(FN) \
11
  PROTOTYPE_LINK_ERROR(FN) \
12
  extern double FN (double); \
13
  extern float FN##f (float); \
14
  extern long double FN##l (long double);
15
 
16
#define PROTOTYPE_RET(FN, RET) \
17
  PROTOTYPE_LINK_ERROR(FN) \
18
  extern RET FN (double); \
19
  extern RET FN##f (float); \
20
  extern RET FN##l (long double);
21
 
22
#define PROTOTYPE_LINK_ERROR(FN) \
23
  extern void link_error_##FN(void); \
24
  extern void link_error_##FN##f(void); \
25
  extern void link_error_##FN##l(void);
26
 
27
#define TEST(FN, VALUE, RESULT) \
28
  if (FN (VALUE) != RESULT) link_error_##FN(); \
29
  if (FN##f (VALUE) != RESULT) link_error_##FN##f(); \
30
  if (FN##l (VALUE) != RESULT) link_error_##FN##l(); \
31
 
32
PROTOTYPE (trunc);
33
PROTOTYPE (floor);
34
PROTOTYPE (ceil);
35
PROTOTYPE (round);
36
PROTOTYPE_RET (lround, long);
37
PROTOTYPE_RET (llround, long long);
38
 
39
int
40
main (void)
41
{
42
  TEST(trunc,   0, 0);
43
  TEST(floor,   0, 0);
44
  TEST(ceil,    0, 0);
45
  TEST(round,   0, 0);
46
  TEST(lround,  0, 0);
47
  TEST(llround, 0, 0);
48
 
49
  TEST(trunc,   6, 6);
50
  TEST(floor,   6, 6);
51
  TEST(ceil,    6, 6);
52
  TEST(round,   6, 6);
53
  TEST(lround,  6, 6);
54
  TEST(llround, 6, 6);
55
 
56
  TEST(trunc,   -8, -8);
57
  TEST(floor,   -8, -8);
58
  TEST(ceil,    -8, -8);
59
  TEST(round,   -8, -8);
60
  TEST(lround,  -8, -8);
61
  TEST(llround, -8, -8);
62
 
63
  TEST(trunc,   3.2, 3);
64
  TEST(floor,   3.2, 3);
65
  TEST(ceil,    3.2, 4);
66
  TEST(round,   3.2, 3);
67
  TEST(lround,  3.2, 3);
68
  TEST(llround, 3.2, 3);
69
 
70
  TEST(trunc,   -2.8, -2);
71
  TEST(floor,   -2.8, -3);
72
  TEST(ceil,    -2.8, -2);
73
  TEST(round,   -2.8, -3);
74
  TEST(lround,  -2.8, -3);
75
  TEST(llround, -2.8, -3);
76
 
77
  TEST(trunc,   0.01, 0);
78
  TEST(floor,   0.01, 0);
79
  TEST(ceil,    0.01, 1);
80
  TEST(round,   0.01, 0);
81
  TEST(lround,  0.01, 0);
82
  TEST(llround, 0.01, 0);
83
 
84
  TEST(trunc,   -0.7, 0);
85
  TEST(floor,   -0.7, -1);
86
  TEST(ceil,    -0.7, 0);
87
  TEST(round,   -0.7, -1);
88
  TEST(lround,  -0.7, -1);
89
  TEST(llround, -0.7, -1);
90
 
91
  TEST(trunc,   2.5, 2);
92
  TEST(floor,   2.5, 2);
93
  TEST(ceil,    2.5, 3);
94
  TEST(round,   2.5, 3);
95
  TEST(lround,  2.5, 3);
96
  TEST(llround, 2.5, 3);
97
 
98
  TEST(trunc,   -1.5, -1);
99
  TEST(floor,   -1.5, -2);
100
  TEST(ceil,    -1.5, -1);
101
  TEST(round,   -1.5, -2);
102
  TEST(lround,  -1.5, -2);
103
  TEST(llround, -1.5, -2);
104
 
105
  return 0;
106
}

powered by: WebSVN 2.1.0

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