Skip to content

Commit 7d0514c

Browse files
committed
DEBUG DO NOT USE| test if __builtin_* crashes anything
1 parent b86395a commit 7d0514c

File tree

2 files changed

+276
-9
lines changed

2 files changed

+276
-9
lines changed

src/libc/include/__math_def.h

Lines changed: 274 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ bool _signbitf(float) __NOEXCEPT_CONST;
6969
bool _signbitl(long double) __NOEXCEPT_CONST;
7070
#endif
7171

72+
#ifdef DEBUG_FOOBAR
73+
7274
double acos(double);
7375
float acosf(float);
7476
long double acosl(long double);
@@ -172,9 +174,9 @@ double fmod(double, double);
172174
float fmodf(float, float);
173175
long double fmodl(long double, long double);
174176

175-
double frexp(double, int *) __attribute__((nonnull(2)));
176-
float frexpf(float, int *) __attribute__((nonnull(2)));
177-
long double frexpl(long double, int *) __attribute__((nonnull(2)));
177+
double frexp(double, int *) ;
178+
float frexpf(float, int *) ;
179+
long double frexpl(long double, int *) ;
178180

179181
double hypot(double, double);
180182
float hypotf(float, float);
@@ -232,9 +234,9 @@ long lround(double);
232234
long lroundf(float);
233235
long lroundl(long double);
234236

235-
double modf(double, double *) __attribute__((nonnull(2)));
236-
float modff(float, float *) __attribute__((nonnull(2)));
237-
long double modfl(long double, long double *) __attribute__((nonnull(2)));
237+
double modf(double, double *) ;
238+
float modff(float, float *) ;
239+
long double modfl(long double, long double *) ;
238240

239241
double nan(const char *);
240242
float nanf(const char *);
@@ -268,9 +270,9 @@ double remainder(double, double);
268270
float remainderf(float, float);
269271
long double remainderl(long double, long double);
270272

271-
double remquo(double, double, int *) __attribute__((nonnull(3)));
272-
float remquof(float, float, int *) __attribute__((nonnull(3)));
273-
long double remquol(long double, long double, int *) __attribute__((nonnull(3)));
273+
double remquo(double, double, int *) ;
274+
float remquof(float, float, int *) ;
275+
long double remquol(long double, long double, int *) ;
274276

275277
double rint(double);
276278
float rintf(float);
@@ -328,6 +330,269 @@ double trunc(double);
328330
float truncf(float);
329331
long double truncl(long double);
330332

333+
#else
334+
335+
static inline double acos(double x) { return __builtin_acos(x); }
336+
static inline float acosf(float x) { return __builtin_acosf(x); }
337+
static inline long double acosl(long double x) { return __builtin_acosl(x); }
338+
339+
static inline double acosh(double x) { return __builtin_acosh(x); }
340+
static inline float acoshf(float x) { return __builtin_acoshf(x); }
341+
static inline long double acoshl(long double x) { return __builtin_acoshl(x); }
342+
343+
static inline double asin(double x) { return __builtin_asin(x); }
344+
static inline float asinf(float x) { return __builtin_asinf(x); }
345+
static inline long double asinl(long double x) { return __builtin_asinl(x); }
346+
347+
static inline double asinh(double x) { return __builtin_asinh(x); }
348+
static inline float asinhf(float x) { return __builtin_asinhf(x); }
349+
static inline long double asinhl(long double x) { return __builtin_asinhl(x); }
350+
351+
static inline double atan(double x) { return __builtin_atan(x); }
352+
static inline float atanf(float x) { return __builtin_atanf(x); }
353+
static inline long double atanl(long double x) { return __builtin_atanl(x); }
354+
355+
static inline double atan2(double y, double x) { return __builtin_atan2(y, x); }
356+
static inline float atan2f(float y, float x) { return __builtin_atan2f(y, x); }
357+
static inline long double atan2l(long double y, long double x) { return __builtin_atan2l(y, x); }
358+
359+
static inline double atanh(double x) { return __builtin_atanh(x); }
360+
static inline float atanhf(float x) { return __builtin_atanhf(x); }
361+
static inline long double atanhl(long double x) { return __builtin_atanhl(x); }
362+
363+
static inline double cbrt(double x) { return __builtin_cbrt(x); }
364+
static inline float cbrtf(float x) { return __builtin_cbrtf(x); }
365+
static inline long double cbrtl(long double x) { return __builtin_cbrtl(x); }
366+
367+
static inline double ceil(double x) { return __builtin_ceil(x); }
368+
static inline float ceilf(float x) { return __builtin_ceilf(x); }
369+
static inline long double ceill(long double x) { return __builtin_ceill(x); }
370+
371+
static inline double copysign(double x, double y) { return __builtin_copysign(x, y); }
372+
static inline float copysignf(float x, float y) { return __builtin_copysignf(x, y); }
373+
static inline long double copysignl(long double x, long double y) { return __builtin_copysignl(x, y); }
374+
375+
static inline double cos(double x) { return __builtin_cos(x); }
376+
static inline float cosf(float x) { return __builtin_cosf(x); }
377+
static inline long double cosl(long double x) { return __builtin_cosl(x); }
378+
379+
double cospi(double);
380+
float cospif(float);
381+
long double cospil(long double);
382+
383+
static inline double cosh(double x) { return __builtin_cosh(x); }
384+
static inline float coshf(float x) { return __builtin_coshf(x); }
385+
static inline long double coshl(long double x) { return __builtin_coshl(x); }
386+
387+
static inline double erf(double x) { return __builtin_erf(x); }
388+
static inline float erff(float x) { return __builtin_erff(x); }
389+
static inline long double erfl(long double x) { return __builtin_erfl(x); }
390+
391+
static inline double erfc(double x) { return __builtin_erfc(x); }
392+
static inline float erfcf(float x) { return __builtin_erfcf(x); }
393+
static inline long double erfcl(long double x) { return __builtin_erfcl(x); }
394+
395+
static inline double exp(double x) { return __builtin_exp(x); }
396+
static inline float expf(float x) { return __builtin_expf(x); }
397+
static inline long double expl(long double x) { return __builtin_expl(x); }
398+
399+
static inline double exp2(double x) { return __builtin_exp2(x); }
400+
static inline float exp2f(float x) { return __builtin_exp2f(x); }
401+
static inline long double exp2l(long double x) { return __builtin_exp2l(x); }
402+
403+
static inline double expm1(double x) { return __builtin_expm1(x); }
404+
static inline float expm1f(float x) { return __builtin_expm1f(x); }
405+
static inline long double expm1l(long double x) { return __builtin_expm1l(x); }
406+
407+
#ifndef _ABS_FLOAT_DEFINED
408+
#define _ABS_FLOAT_DEFINED
409+
double fabs(double x);
410+
float fabsf(float x);
411+
long double fabsl(long double x);
412+
#endif /* _ABS_FLOAT_DEFINED */
413+
414+
static inline double fdim(double x, double y) { return __builtin_fdim(x, y); }
415+
static inline float fdimf(float x, float y) { return __builtin_fdimf(x, y); }
416+
static inline long double fdiml(long double x, long double y) { return __builtin_fdiml(x, y); }
417+
418+
static inline double floor(double x) { return __builtin_floor(x); }
419+
static inline float floorf(float x) { return __builtin_floorf(x); }
420+
static inline long double floorl(long double x) { return __builtin_floorl(x); }
421+
422+
static inline double fma(double x, double y, double z) { return __builtin_fma(x, y, z); }
423+
static inline float fmaf(float x, float y, float z) { return __builtin_fmaf(x, y, z); }
424+
static inline long double fmal(long double x, long double y, long double z) { return __builtin_fmal(x, y, z); }
425+
426+
static inline double fmax(double x, double y) { return __builtin_fmax(x, y); }
427+
static inline float fmaxf(float x, float y) { return __builtin_fmaxf(x, y); }
428+
static inline long double fmaxl(long double x, long double y) { return __builtin_fmaxl(x, y); }
429+
430+
static inline double fmin(double x, double y) { return __builtin_fmin(x, y); }
431+
static inline float fminf(float x, float y) { return __builtin_fminf(x, y); }
432+
static inline long double fminl(long double x, long double y) { return __builtin_fminl(x, y); }
433+
434+
static inline double fmod(double x, double y) { return __builtin_fmod(x, y); }
435+
static inline float fmodf(float x, float y) { return __builtin_fmodf(x, y); }
436+
static inline long double fmodl(long double x, long double y) { return __builtin_fmodl(x, y); }
437+
438+
static inline double frexp(double x, int *e) { return __builtin_frexp(x, e); }
439+
static inline float frexpf(float x, int *e) { return __builtin_frexpf(x, e); }
440+
static inline long double frexpl(long double x, int *e) { return __builtin_frexpl(x, e); }
441+
442+
static inline double hypot(double x, double y) { return __builtin_hypot(x, y); }
443+
static inline float hypotf(float x, float y) { return __builtin_hypotf(x, y); }
444+
static inline long double hypotl(long double x, long double y) { return __builtin_hypotl(x, y); }
445+
446+
double __hypot3(double, double, double);
447+
float __hypot3f(float, float, float);
448+
long double __hypot3l(long double, long double, long double);
449+
450+
static inline int ilogb(double x) { return __builtin_ilogb(x); }
451+
static inline int ilogbf(float x) { return __builtin_ilogbf(x); }
452+
static inline int ilogbl(long double x) { return __builtin_ilogbl(x); }
453+
454+
static inline double ldexp(double x, int e) { return __builtin_ldexp(x, e); }
455+
static inline float ldexpf(float x, int e) { return __builtin_ldexpf(x, e); }
456+
static inline long double ldexpl(long double x, int e) { return __builtin_ldexpl(x, e); }
457+
458+
static inline double lgamma(double x) { return __builtin_lgamma(x); }
459+
static inline float lgammaf(float x) { return __builtin_lgammaf(x); }
460+
static inline long double lgammal(long double x) { return __builtin_lgammal(x); }
461+
462+
static inline long long llrint(double x) { return __builtin_llrint(x); }
463+
static inline long long llrintf(float x) { return __builtin_llrintf(x); }
464+
static inline long long llrintl(long double x) { return __builtin_llrintl(x); }
465+
466+
static inline long long llround(double x) { return __builtin_llround(x); }
467+
static inline long long llroundf(float x) { return __builtin_llroundf(x); }
468+
static inline long long llroundl(long double x) { return __builtin_llroundl(x); }
469+
470+
static inline double log(double x) { return __builtin_log(x); }
471+
static inline float logf(float x) { return __builtin_logf(x); }
472+
static inline long double logl(long double x) { return __builtin_logl(x); }
473+
474+
static inline double log10(double x) { return __builtin_log10(x); }
475+
static inline float log10f(float x) { return __builtin_log10f(x); }
476+
static inline long double log10l(long double x) { return __builtin_log10l(x); }
477+
478+
static inline double log1p(double x) { return __builtin_log1p(x); }
479+
static inline float log1pf(float x) { return __builtin_log1pf(x); }
480+
static inline long double log1pl(long double x) { return __builtin_log1pl(x); }
481+
482+
static inline double log2(double x) { return __builtin_log2(x); }
483+
static inline float log2f(float x) { return __builtin_log2f(x); }
484+
static inline long double log2l(long double x) { return __builtin_log2l(x); }
485+
486+
static inline double logb(double x) { return __builtin_logb(x); }
487+
static inline float logbf(float x) { return __builtin_logbf(x); }
488+
static inline long double logbl(long double x) { return __builtin_logbl(x); }
489+
490+
static inline long lrint(double x) { return __builtin_lrint(x); }
491+
static inline long lrintf(float x) { return __builtin_lrintf(x); }
492+
static inline long lrintl(long double x) { return __builtin_lrintl(x); }
493+
494+
static inline long lround(double x) { return __builtin_lround(x); }
495+
static inline long lroundf(float x) { return __builtin_lroundf(x); }
496+
static inline long lroundl(long double x) { return __builtin_lroundl(x); }
497+
498+
static inline double modf(double x, double *ip) { return __builtin_modf(x, ip); }
499+
static inline float modff(float x, float *ip) { return __builtin_modff(x, ip); }
500+
static inline long double modfl(long double x, long double *ip) { return __builtin_modfl(x, ip); }
501+
502+
static inline double nan(const char *s) { return __builtin_nan(s); }
503+
static inline float nanf(const char *s) { return __builtin_nanf(s); }
504+
static inline long double nanl(const char *s) { return __builtin_nanl(s); }
505+
506+
static inline double nearbyint(double x) { return __builtin_nearbyint(x); }
507+
static inline float nearbyintf(float x) { return __builtin_nearbyintf(x); }
508+
static inline long double nearbyintl(long double x) { return __builtin_nearbyintl(x); }
509+
510+
static inline double nextafter(double x, double y) { return __builtin_nextafter(x, y); }
511+
static inline float nextafterf(float x, float y) { return __builtin_nextafterf(x, y); }
512+
static inline long double nextafterl(long double x, long double y) { return __builtin_nextafterl(x, y); }
513+
514+
double nextdown(double);
515+
float nextdownf(float);
516+
long double nextdownl(long double);
517+
518+
static inline double nexttoward(double x, long double y) { return __builtin_nexttoward(x, y); }
519+
static inline float nexttowardf(float x, long double y) { return __builtin_nexttowardf(x, y); }
520+
static inline long double nexttowardl(long double x, long double y) { return __builtin_nexttowardl(x, y); }
521+
522+
double nextup(double);
523+
float nextupf(float);
524+
long double nextupl(long double);
525+
526+
static inline double pow(double x, double y) { return __builtin_pow(x, y); }
527+
static inline float powf(float x, float y) { return __builtin_powf(x, y); }
528+
static inline long double powl(long double x, long double y) { return __builtin_powl(x, y); }
529+
530+
static inline double remainder(double x, double y) { return __builtin_remainder(x, y); }
531+
static inline float remainderf(float x, float y) { return __builtin_remainderf(x, y); }
532+
static inline long double remainderl(long double x, long double y) { return __builtin_remainderl(x, y); }
533+
534+
static inline double remquo(double x, double y, int *q) { return __builtin_remquo(x, y, q); }
535+
static inline float remquof(float x, float y, int *q) { return __builtin_remquof(x, y, q); }
536+
static inline long double remquol(long double x, long double y, int *q) { return __builtin_remquol(x, y, q); }
537+
538+
static inline double rint(double x) { return __builtin_rint(x); }
539+
static inline float rintf(float x) { return __builtin_rintf(x); }
540+
static inline long double rintl(long double x) { return __builtin_rintl(x); }
541+
542+
static inline double round(double x) { return __builtin_round(x); }
543+
static inline float roundf(float x) { return __builtin_roundf(x); }
544+
static inline long double roundl(long double x) { return __builtin_roundl(x); }
545+
546+
double roundeven(double);
547+
float roundevenf(float);
548+
long double roundevenl(long double);
549+
550+
static inline double scalbln(double x, long n) { return __builtin_scalbln(x, n); }
551+
static inline float scalblnf(float x, long n) { return __builtin_scalblnf(x, n); }
552+
static inline long double scalblnl(long double x, long n) { return __builtin_scalblnl(x, n); }
553+
554+
static inline double scalbn(double x, int n) { return __builtin_scalbn(x, n); }
555+
static inline float scalbnf(float x, int n) { return __builtin_scalbnf(x, n); }
556+
static inline long double scalbnl(long double x, int n) { return __builtin_scalbnl(x, n); }
557+
558+
static inline double sin(double x) { return __builtin_sin(x); }
559+
static inline float sinf(float x) { return __builtin_sinf(x); }
560+
static inline long double sinl(long double x) { return __builtin_sinl(x); }
561+
562+
double sinpi(double);
563+
float sinpif(float);
564+
long double sinpil(long double);
565+
566+
static inline double sinh(double x) { return __builtin_sinh(x); }
567+
static inline float sinhf(float x) { return __builtin_sinhf(x); }
568+
static inline long double sinhl(long double x) { return __builtin_sinhl(x); }
569+
570+
static inline double sqrt(double x) { return __builtin_sqrt(x); }
571+
static inline float sqrtf(float x) { return __builtin_sqrtf(x); }
572+
static inline long double sqrtl(long double x) { return __builtin_sqrtl(x); }
573+
574+
static inline double tan(double x) { return __builtin_tan(x); }
575+
static inline float tanf(float x) { return __builtin_tanf(x); }
576+
static inline long double tanl(long double x) { return __builtin_tanl(x); }
577+
578+
double tanpi(double);
579+
float tanpif(float);
580+
long double tanpil(long double);
581+
582+
static inline double tanh(double x) { return __builtin_tanh(x); }
583+
static inline float tanhf(float x) { return __builtin_tanhf(x); }
584+
static inline long double tanhl(long double x) { return __builtin_tanhl(x); }
585+
586+
static inline double tgamma(double x) { return __builtin_tgamma(x); }
587+
static inline float tgammaf(float x) { return __builtin_tgammaf(x); }
588+
static inline long double tgammal(long double x) { return __builtin_tgammal(x); }
589+
590+
static inline double trunc(double x) { return __builtin_trunc(x); }
591+
static inline float truncf(float x) { return __builtin_truncf(x); }
592+
static inline long double truncl(long double x) { return __builtin_truncl(x); }
593+
594+
#endif
595+
331596
#ifdef __cplusplus
332597
}
333598
#endif

src/libc/makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
include $(CURDIR)/../common.mk
1818

19+
EZCFLAGS += -DDEBUG_FOOBAR
20+
1921
OBJECTS =
2022
OBJECTS += $(patsubst %.c,build/%.c.o,$(wildcard *.c))
2123
OBJECTS += $(patsubst %.cpp,build/%.cpp.o,$(wildcard *.cpp))

0 commit comments

Comments
 (0)