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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [torture/] [builtin-complex-1.c] - Blame information for rev 754

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

Line No. Rev Author Line
1 689 jeremybenn
/* Test __builtin_complex semantics.  */
2
/* { dg-do run } */
3
/* { dg-options "-std=c1x -pedantic-errors" } */
4
/* { dg-add-options ieee } */
5
 
6
extern void exit (int);
7
extern void abort (void);
8
 
9
#define COMPARE_BODY(A, B, TYPE, COPYSIGN)                              \
10
  do {                                                                  \
11
    TYPE s1 = COPYSIGN ((TYPE) 1.0, A);                                 \
12
    TYPE s2 = COPYSIGN ((TYPE) 1.0, B);                                 \
13
    if (s1 != s2)                                                       \
14
      abort ();                                                         \
15
    if ((__builtin_isnan (A) != 0) != (__builtin_isnan (B) != 0)) \
16
      abort ();                                                         \
17
    if ((A != B) != (__builtin_isnan (A) != 0))                          \
18
      abort ();                                                         \
19
  } while (0)
20
 
21
#ifndef __SPU__
22
void
23
comparef (float a, float b)
24
{
25
  COMPARE_BODY (a, b, float, __builtin_copysignf);
26
}
27
#endif
28
 
29
void
30
compare (double a, double b)
31
{
32
  COMPARE_BODY (a, b, double, __builtin_copysign);
33
}
34
 
35
void
36
comparel (long double a, long double b)
37
{
38
  COMPARE_BODY (a, b, long double, __builtin_copysignl);
39
}
40
 
41
#ifndef __SPU__
42
void
43
comparecf (_Complex float a, float r, float i)
44
{
45
  comparef (__real__ a, r);
46
  comparef (__imag__ a, i);
47
}
48
#endif
49
 
50
void
51
comparec (_Complex double a, double r, double i)
52
{
53
  compare (__real__ a, r);
54
  compare (__imag__ a, i);
55
}
56
 
57
void
58
comparecl (_Complex long double a, long double r, long double i)
59
{
60
  comparel (__real__ a, r);
61
  comparel (__imag__ a, i);
62
}
63
 
64
#define VERIFY(A, B, TYPE, COMPARE)                     \
65
  do {                                                  \
66
    TYPE a = A;                                         \
67
    TYPE b = B;                                         \
68
    _Complex TYPE cr = __builtin_complex (a, b);        \
69
    static _Complex TYPE cs = __builtin_complex (A, B); \
70
    COMPARE (cr, A, B);                                 \
71
    COMPARE (cs, A, B);                                 \
72
  } while (0)
73
 
74
#define ALL_CHECKS(PZ, NZ, NAN, INF, TYPE, COMPARE)     \
75
  do {                                                  \
76
    VERIFY (PZ, PZ, TYPE, COMPARE);                     \
77
    VERIFY (PZ, NZ, TYPE, COMPARE);                     \
78
    VERIFY (PZ, NAN, TYPE, COMPARE);                    \
79
    VERIFY (PZ, INF, TYPE, COMPARE);                    \
80
    VERIFY (NZ, PZ, TYPE, COMPARE);                     \
81
    VERIFY (NZ, NZ, TYPE, COMPARE);                     \
82
    VERIFY (NZ, NAN, TYPE, COMPARE);                    \
83
    VERIFY (NZ, INF, TYPE, COMPARE);                    \
84
    VERIFY (NAN, PZ, TYPE, COMPARE);                    \
85
    VERIFY (NAN, NZ, TYPE, COMPARE);                    \
86
    VERIFY (NAN, NAN, TYPE, COMPARE);                   \
87
    VERIFY (NAN, INF, TYPE, COMPARE);                   \
88
    VERIFY (INF, PZ, TYPE, COMPARE);                    \
89
    VERIFY (INF, NZ, TYPE, COMPARE);                    \
90
    VERIFY (INF, NAN, TYPE, COMPARE);                   \
91
    VERIFY (INF, INF, TYPE, COMPARE);                   \
92
  } while (0)
93
 
94
void
95
check_float (void)
96
{
97
#ifndef __SPU__
98
  ALL_CHECKS (0.0f, -0.0f, __builtin_nanf(""), __builtin_inff(),
99
              float, comparecf);
100
#endif
101
}
102
 
103
void
104
check_double (void)
105
{
106
  ALL_CHECKS (0.0, -0.0, __builtin_nan(""), __builtin_inf(),
107
              double, comparec);
108
}
109
 
110
void
111
check_long_double (void)
112
{
113
  ALL_CHECKS (0.0l, -0.0l, __builtin_nanl(""), __builtin_infl(),
114
              long double, comparecl);
115
}
116
 
117
int
118
main (void)
119
{
120
  check_float ();
121
  check_double ();
122
  check_long_double ();
123
  exit (0);
124
}

powered by: WebSVN 2.1.0

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