Skip to content

Commit d93d724

Browse files
ZERICO2005adriweb
authored andcommitted
added <tgmath.h> to the toolchain
1 parent 9d82626 commit d93d724

File tree

2 files changed

+383
-0
lines changed

2 files changed

+383
-0
lines changed

src/libc/include/tgmath.h

Lines changed: 374 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,374 @@
1+
#ifndef _TGMATH_H
2+
#define _TGMATH_H
3+
4+
#ifdef __cplusplus
5+
6+
#include <cmath>
7+
8+
#else /* __cplusplus */
9+
10+
#include <math.h>
11+
12+
#define __tgmath_promote(x) _Generic((x), \
13+
float: ((float)0.f), \
14+
default: ((double)0.), \
15+
long double: ((long double)0.L) \
16+
)
17+
18+
/* single argument */
19+
20+
#define acos(x) _Generic(__tgmath_promote(x), \
21+
long double: acosl, \
22+
default: acos, \
23+
float: acosf \
24+
)(x)
25+
26+
#define acosh(x) _Generic(__tgmath_promote(x), \
27+
long double: acoshl, \
28+
default: acosh, \
29+
float: acoshf \
30+
)(x)
31+
32+
#define asin(x) _Generic(__tgmath_promote(x), \
33+
long double: asinl, \
34+
default: asin, \
35+
float: asinf \
36+
)(x)
37+
38+
#define asinh(x) _Generic(__tgmath_promote(x), \
39+
long double: asinhl, \
40+
default: asinh, \
41+
float: asinhf \
42+
)(x)
43+
44+
#define atan(x) _Generic(__tgmath_promote(x), \
45+
long double: atanl, \
46+
default: atan, \
47+
float: atanf \
48+
)(x)
49+
50+
#define atanh(x) _Generic(__tgmath_promote(x), \
51+
long double: atanhl, \
52+
default: atanh, \
53+
float: atanhf \
54+
)(x)
55+
56+
#define cbrt(x) _Generic(__tgmath_promote(x), \
57+
long double: cbrtl, \
58+
default: cbrt, \
59+
float: cbrtf \
60+
)(x)
61+
62+
#define ceil(x) _Generic(__tgmath_promote(x), \
63+
long double: ceill, \
64+
default: ceil, \
65+
float: ceilf \
66+
)(x)
67+
68+
#define cos(x) _Generic(__tgmath_promote(x), \
69+
long double: cosl, \
70+
default: cos, \
71+
float: cosf \
72+
)(x)
73+
74+
#define cosh(x) _Generic(__tgmath_promote(x), \
75+
long double: coshl, \
76+
default: cosh, \
77+
float: coshf \
78+
)(x)
79+
80+
#define erf(x) _Generic(__tgmath_promote(x), \
81+
long double: erfl, \
82+
default: erf, \
83+
float: erff \
84+
)(x)
85+
86+
#define erfc(x) _Generic(__tgmath_promote(x), \
87+
long double: erfcl, \
88+
default: erfc, \
89+
float: erfcf \
90+
)(x)
91+
92+
#define exp(x) _Generic(__tgmath_promote(x), \
93+
long double: expl, \
94+
default: exp, \
95+
float: expf \
96+
)(x)
97+
98+
#define exp2(x) _Generic(__tgmath_promote(x), \
99+
long double: exp2l, \
100+
default: exp2, \
101+
float: exp2f \
102+
)(x)
103+
104+
#define expm1(x) _Generic(__tgmath_promote(x), \
105+
long double: expm1l, \
106+
default: expm1, \
107+
float: expm1f \
108+
)(x)
109+
110+
#define fabs(x) _Generic(__tgmath_promote(x), \
111+
long double: fabsl, \
112+
default: fabs, \
113+
float: fabsf \
114+
)(x)
115+
116+
#define floor(x) _Generic(__tgmath_promote(x), \
117+
long double: floorl, \
118+
default: floor, \
119+
float: floorf \
120+
)(x)
121+
122+
#define ilogb(x) _Generic(__tgmath_promote(x), \
123+
long double: ilogbl, \
124+
default: ilogb, \
125+
float: ilogbf \
126+
)(x)
127+
128+
#define lgamma(x) _Generic(__tgmath_promote(x), \
129+
long double: lgammal, \
130+
default: lgamma, \
131+
float: lgammaf \
132+
)(x)
133+
134+
#define llrint(x) _Generic(__tgmath_promote(x), \
135+
long double: llrintl, \
136+
default: llrint, \
137+
float: llrintf \
138+
)(x)
139+
140+
#define llround(x) _Generic(__tgmath_promote(x), \
141+
long double: llroundl, \
142+
default: llround, \
143+
float: llroundf \
144+
)(x)
145+
146+
#define log(x) _Generic(__tgmath_promote(x), \
147+
long double: logl, \
148+
default: log, \
149+
float: logf \
150+
)(x)
151+
152+
#define log10(x) _Generic(__tgmath_promote(x), \
153+
long double: log10l, \
154+
default: log10, \
155+
float: log10f \
156+
)(x)
157+
158+
#define log1p(x) _Generic(__tgmath_promote(x), \
159+
long double: log1pl, \
160+
default: log1p, \
161+
float: log1pf \
162+
)(x)
163+
164+
#define log2(x) _Generic(__tgmath_promote(x), \
165+
long double: log2l, \
166+
default: log2, \
167+
float: log2f \
168+
)(x)
169+
170+
#define logb(x) _Generic(__tgmath_promote(x), \
171+
long double: logbl, \
172+
default: logb, \
173+
float: logbf \
174+
)(x)
175+
176+
#define lrint(x) _Generic(__tgmath_promote(x), \
177+
long double: lrintl, \
178+
default: lrint, \
179+
float: lrintf \
180+
)(x)
181+
182+
#define lround(x) _Generic(__tgmath_promote(x), \
183+
long double: lroundl, \
184+
default: lround, \
185+
float: lroundf \
186+
)(x)
187+
188+
#define nearbyint(x) _Generic(__tgmath_promote(x), \
189+
long double: nearbyintl, \
190+
default: nearbyint, \
191+
float: nearbyintf \
192+
)(x)
193+
194+
#define nextdown(x) _Generic(__tgmath_promote(x), \
195+
long double: nextdownl, \
196+
default: nextdown, \
197+
float: nextdownf \
198+
)(x)
199+
200+
#define nextup(x) _Generic(__tgmath_promote(x), \
201+
long double: nextupl, \
202+
default: nextup, \
203+
float: nextupf \
204+
)(x)
205+
206+
#define rint(x) _Generic(__tgmath_promote(x), \
207+
long double: rintl, \
208+
default: rint, \
209+
float: rintf \
210+
)(x)
211+
212+
#define round(x) _Generic(__tgmath_promote(x), \
213+
long double: roundl, \
214+
default: round, \
215+
float: roundf \
216+
)(x)
217+
218+
#define roundeven(x) _Generic(__tgmath_promote(x), \
219+
long double: roundevenl, \
220+
default: roundeven, \
221+
float: roundevenf \
222+
)(x)
223+
224+
#define sin(x) _Generic(__tgmath_promote(x), \
225+
long double: sinl, \
226+
default: sin, \
227+
float: sinf \
228+
)(x)
229+
230+
#define sinh(x) _Generic(__tgmath_promote(x), \
231+
long double: sinhl, \
232+
default: sinh, \
233+
float: sinhf \
234+
)(x)
235+
236+
#define sqrt(x) _Generic(__tgmath_promote(x), \
237+
long double: sqrtl, \
238+
default: sqrt, \
239+
float: sqrtf \
240+
)(x)
241+
242+
#define tan(x) _Generic(__tgmath_promote(x), \
243+
long double: tanl, \
244+
default: tan, \
245+
float: tanf \
246+
)(x)
247+
248+
#define tanh(x) _Generic(__tgmath_promote(x), \
249+
long double: tanhl, \
250+
default: tanh, \
251+
float: tanhf \
252+
)(x)
253+
254+
#define tgamma(x) _Generic(__tgmath_promote(x), \
255+
long double: tgammal, \
256+
default: tgamma, \
257+
float: tgammaf \
258+
)(x)
259+
260+
#define trunc(x) _Generic(__tgmath_promote(x), \
261+
long double: truncl, \
262+
default: trunc, \
263+
float: truncf \
264+
)(x)
265+
266+
/* two identical arguments */
267+
268+
#define atan2(x, y) _Generic(__tgmath_promote(x) + __tgmath_promote(y), \
269+
long double: atan2l, \
270+
default: atan2, \
271+
float: atan2f \
272+
)((x), (y))
273+
274+
#define copysign(x, y) _Generic(__tgmath_promote(x) + __tgmath_promote(y), \
275+
long double: copysignl, \
276+
default: copysign, \
277+
float: copysignf \
278+
)((x), (y))
279+
280+
#define fdim(x, y) _Generic(__tgmath_promote(x) + __tgmath_promote(y), \
281+
long double: fdiml, \
282+
default: fdim, \
283+
float: fdimf \
284+
)((x), (y))
285+
286+
#define fmax(x, y) _Generic(__tgmath_promote(x) + __tgmath_promote(y), \
287+
long double: fmaxl, \
288+
default: fmax, \
289+
float: fmaxf \
290+
)((x), (y))
291+
292+
#define fmin(x, y) _Generic(__tgmath_promote(x) + __tgmath_promote(y), \
293+
long double: fminl, \
294+
default: fmin, \
295+
float: fminf \
296+
)((x), (y))
297+
298+
#define fmod(x, y) _Generic(__tgmath_promote(x) + __tgmath_promote(y), \
299+
long double: fmodl, \
300+
default: fmod, \
301+
float: fmodf \
302+
)((x), (y))
303+
304+
#define hypot(x, y) _Generic(__tgmath_promote(x) + __tgmath_promote(y), \
305+
long double: hypotl, \
306+
default: hypot, \
307+
float: hypotf \
308+
)((x), (y))
309+
310+
#define nextafter(x, y) _Generic(__tgmath_promote(x) + __tgmath_promote(y), \
311+
long double: nextafterl, \
312+
default: nextafter, \
313+
float: nextafterf \
314+
)((x), (y))
315+
316+
#define pow(x, y) _Generic(__tgmath_promote(x) + __tgmath_promote(y), \
317+
long double: powl, \
318+
default: pow, \
319+
float: powf \
320+
)((x), (y))
321+
322+
#define remainder(x, y) _Generic(__tgmath_promote(x) + __tgmath_promote(y), \
323+
long double: remainderl, \
324+
default: remainder, \
325+
float: remainderf \
326+
)((x), (y))
327+
328+
/* multiple arguments */
329+
330+
#define fma(x, y, z) _Generic(__tgmath_promote(x) + __tgmath_promote(y) + __tgmath_promote(z), \
331+
long double: fmal, \
332+
default: fma, \
333+
float: fmaf \
334+
)((x), (y), (z))
335+
336+
#define frexp(x, y) _Generic(__tgmath_promote(x), \
337+
long double: frexpl, \
338+
default: frexp, \
339+
float: frexpf \
340+
)((x), (y))
341+
342+
#define ldexp(x, y) _Generic(__tgmath_promote(x), \
343+
long double: ldexpl, \
344+
default: ldexp, \
345+
float: ldexpf \
346+
)((x), (y))
347+
348+
#define nexttoward(x, y) _Generic(__tgmath_promote(x), \
349+
long double: nexttowardl, \
350+
default: nexttoward, \
351+
float: nexttowardf \
352+
)((x), (y))
353+
354+
#define remquo(x, y, z) _Generic(__tgmath_promote(x) + __tgmath_promote(y), \
355+
long double: remquol, \
356+
default: remquo, \
357+
float: remquof \
358+
)((x), (y), (z))
359+
360+
#define scalbln(x, y) _Generic(__tgmath_promote(x), \
361+
long double: scalblnl, \
362+
default: scalbln, \
363+
float: scalblnf \
364+
)((x), (y))
365+
366+
#define scalbn(x, y) _Generic(__tgmath_promote(x), \
367+
long double: scalbnl, \
368+
default: scalbn, \
369+
float: scalbnf \
370+
)((x), (y))
371+
372+
#endif /* __cplusplus */
373+
374+
#endif /* _TGMATH_H */

src/libcxx/include/ctgmath

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// -*- C++ -*-
2+
#ifndef _EZCXX_CTGMATH
3+
#define _EZCXX_CTGMATH
4+
5+
#include <tgmath.h>
6+
7+
#pragma clang system_header
8+
9+
#endif // _EZCXX_CTGMATH

0 commit comments

Comments
 (0)