1 | /* Test C99 math functions are available in C++11 without _GNU_SOURCE. |
---|---|
2 | Copyright (C) 2017-2022 Free Software Foundation, Inc. |
3 | This file is part of the GNU C Library. |
4 | |
5 | The GNU C Library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2.1 of the License, or (at your option) any later version. |
9 | |
10 | The GNU C Library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Lesser General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Lesser General Public |
16 | License along with the GNU C Library; if not, see |
17 | <https://www.gnu.org/licenses/>. */ |
18 | |
19 | #undef _GNU_SOURCE |
20 | #undef _DEFAULT_SOURCE |
21 | #undef _XOPEN_SOURCE |
22 | #undef _POSIX_SOURCE |
23 | #undef _POSIX_C_SOURCE |
24 | // __STRICT_ANSI__ gets defined by -std=c++11 in CFLAGS |
25 | #include <math.h> |
26 | #include <stdio.h> |
27 | |
28 | static int |
29 | do_test (void) |
30 | { |
31 | #ifdef _GNU_SOURCE |
32 | printf ("FAIL: _GNU_SOURCE is defined.\n"); |
33 | return 1; |
34 | #endif |
35 | |
36 | #if __cplusplus >= 201103L |
37 | /* Verify that C11 math functions and types are defined for C++11, |
38 | without _GNU_SOURCE being defined. [BZ #21326] */ |
39 | (void) FP_INFINITE; |
40 | (void) FP_NAN; |
41 | (void) FP_NORMAL; |
42 | (void) FP_SUBNORMAL; |
43 | (void) FP_ZERO; |
44 | double_t d = 1.0; |
45 | (void) d; |
46 | float_t f = 1.0f; |
47 | (void) f; |
48 | (void) acosh; |
49 | (void) acoshf; |
50 | (void) acoshl; |
51 | (void) asinh; |
52 | (void) asinhf; |
53 | (void) asinhl; |
54 | (void) atanh; |
55 | (void) atanhf; |
56 | (void) atanhl; |
57 | (void) cbrt; |
58 | (void) cbrtf; |
59 | (void) cbrtl; |
60 | (void) copysign; |
61 | (void) copysignf; |
62 | (void) copysignl; |
63 | (void) erf; |
64 | (void) erff; |
65 | (void) erfl; |
66 | (void) erfc; |
67 | (void) erfcf; |
68 | (void) erfcl; |
69 | (void) exp2; |
70 | (void) exp2f; |
71 | (void) exp2l; |
72 | (void) expm1; |
73 | (void) expm1f; |
74 | (void) expm1l; |
75 | (void) fdim; |
76 | (void) fdimf; |
77 | (void) fdiml; |
78 | (void) fma; |
79 | (void) fmaf; |
80 | (void) fmal; |
81 | (void) fmax; |
82 | (void) fmaxf; |
83 | (void) fmaxl; |
84 | (void) fmin; |
85 | (void) fminf; |
86 | (void) fminl; |
87 | (void) hypot; |
88 | (void) hypotf; |
89 | (void) hypotl; |
90 | (void) ilogb; |
91 | (void) ilogbf; |
92 | (void) ilogbl; |
93 | (void) lgamma; |
94 | (void) lgammaf; |
95 | (void) lgammal; |
96 | (void) llrint; |
97 | (void) llrintf; |
98 | (void) llrintl; |
99 | (void) llround; |
100 | (void) llroundf; |
101 | (void) llroundl; |
102 | (void) log1p; |
103 | (void) log1pf; |
104 | (void) log1pl; |
105 | (void) log2; |
106 | (void) log2f; |
107 | (void) log2l; |
108 | (void) logb; |
109 | (void) logbf; |
110 | (void) logbl; |
111 | (void) lrint; |
112 | (void) lrintf; |
113 | (void) lrintl; |
114 | (void) lround; |
115 | (void) lroundf; |
116 | (void) lroundl; |
117 | (void) nan; |
118 | (void) nanf; |
119 | (void) nanl; |
120 | (void) nearbyint; |
121 | (void) nearbyintf; |
122 | (void) nearbyintl; |
123 | (void) nextafter; |
124 | (void) nextafterf; |
125 | (void) nextafterl; |
126 | (void) nexttoward; |
127 | (void) nexttowardf; |
128 | (void) nexttowardl; |
129 | (void) remainder; |
130 | (void) remainderf; |
131 | (void) remainderl; |
132 | (void) remquo; |
133 | (void) remquof; |
134 | (void) remquol; |
135 | (void) rint; |
136 | (void) rintf; |
137 | (void) rintl; |
138 | (void) round; |
139 | (void) roundf; |
140 | (void) roundl; |
141 | (void) scalbln; |
142 | (void) scalblnf; |
143 | (void) scalblnl; |
144 | (void) scalbn; |
145 | (void) scalbnf; |
146 | (void) scalbnl; |
147 | (void) tgamma; |
148 | (void) tgammaf; |
149 | (void) tgammal; |
150 | (void) trunc; |
151 | (void) truncf; |
152 | (void) truncl; |
153 | printf (format: "PASS: C11 math functions present in C++11 without _GNU_SOURCE.\n"); |
154 | #else |
155 | printf ("UNSUPPORTED: C++11 not enabled.\n"); |
156 | #endif |
157 | return 0; |
158 | } |
159 | |
160 | #include <support/test-driver.c> |
161 |