diff --git a/liba/Makefile b/liba/Makefile index 36778c01b..074eff25e 100644 --- a/liba/Makefile +++ b/liba/Makefile @@ -99,7 +99,7 @@ objs += $(addprefix liba/src/external/openbsd/, \ w_lgamma.o \ ) -liba/src/external/openbsd/%.o: CFLAGS += -Iliba/src/external/openbsd/include +liba/src/external/openbsd/%.o: SFLAGS := -Iliba/src/external/openbsd/include $(SFLAGS) liba/src/external/openbsd/e_lgammaf_r.o: CFLAGS += -w liba/src/external/openbsd/s_log1pf.o: CFLAGS += -w liba/src/external/openbsd/s_scalbnf.o: CFLAGS += -w diff --git a/liba/include/math.h b/liba/include/math.h index 95cd641fa..6d20e74e6 100644 --- a/liba/include/math.h +++ b/liba/include/math.h @@ -73,6 +73,39 @@ float sqrtf(float x); float tanf(float x); float tanhf(float x); +double acos(double x); +double acosh(double x); +double asin(double x); +double asinh(double x); +double atan(double x); +double atanh(double x); +double ceil(double x); +double copysign(double x, double y); +double cos(double x); +double cosh(double x); +double exp(double x); +double expm1(double x); +double fabs(double x); +double floor(double x); +double lgamma(double x); +double lgamma_r(double x, int *signgamp); +double log1p(double x); +double log10(double x); +double log(double x); +double pow(double x, double y); +double round(double x); +double scalbn(double x, int n); +double sin(double x); +double sinh(double x); +double sqrt(double x); +double tan(double x); +double tanh(double x); + +/* The C99 standard says that any libc function can be re-declared as a macro. + * (See N1124 paragraph 7.1.4). This means that C files willing to actually + * implement said functions should either re-define the prototype or #undef the + * macro. */ + #define acosf(x) __builtin_acosf(x) #define acoshf(x) __builtin_acoshf(x) #define asinf(x) __builtin_asinf(x) @@ -105,34 +138,6 @@ float tanhf(float x); #define tanf(x) __builtin_tanf(x) #define tanhf(x) __builtin_tanhf(x) -double acos(double x); -double acosh(double x); -double asin(double x); -double asinh(double x); -double atan(double x); -double atanh(double x); -double ceil(double x); -double copysign(double x, double y); -double cos(double x); -double cosh(double x); -double exp(double x); -double expm1(double x); -double fabs(double x); -double floor(double x); -double lgamma(double x); -double lgamma_r(double x, int *signgamp); -double log1p(double x); -double log10(double x); -double log(double x); -double pow(double x, double y); -double round(double x); -double scalbn(double x, int n); -double sin(double x); -double sinh(double x); -double sqrt(double x); -double tan(double x); -double tanh(double x); - #define acos(x) __builtin_acos(x) #define acosh(x) __builtin_acosh(x) #define asin(x) __builtin_asin(x) diff --git a/liba/src/external/openbsd/include/math.h b/liba/src/external/openbsd/include/math.h new file mode 100644 index 000000000..f3457a210 --- /dev/null +++ b/liba/src/external/openbsd/include/math.h @@ -0,0 +1,66 @@ +#include_next + +/* In accordance with the C99 standard, we've defined libm function as macros to + * leverage compiler optimizations. When comes the time to actually implement + * those functions, we don't want the macro to be active. OpenBSD doesn't use + * macros so it doesn't bother #undef-ing libm functions. Let's do it here. */ + +#undef acosf +#undef acoshf +#undef asinf +#undef asinhf +#undef atanf +#undef atan2f +#undef atanhf +#undef ceilf +#undef copysignf +#undef cosf +#undef coshf +#undef expf +#undef expm1f +#undef fabsf +#undef floorf +#undef fmodf +#undef lgammaf +#undef lgammaf_r +#undef log1pf +#undef log10f +#undef logf +#undef nanf +#undef nearbyintf +#undef powf +#undef roundf +#undef scalbnf +#undef sinf +#undef sinhf +#undef sqrtf +#undef tanf +#undef tanhf + +#undef acos +#undef acosh +#undef asin +#undef asinh +#undef atan +#undef atanh +#undef ceil +#undef copysign +#undef cos +#undef cosh +#undef exp +#undef expm1 +#undef fabs +#undef floor +#undef lgamma +#undef lgamma_r +#undef log1p +#undef log10 +#undef log +#undef pow +#undef round +#undef scalbn +#undef sin +#undef sinh +#undef sqrt +#undef tan +#undef tanh diff --git a/liba/src/nearbyintf.c b/liba/src/nearbyintf.c index ca0e261e6..f62e02fb8 100644 --- a/liba/src/nearbyintf.c +++ b/liba/src/nearbyintf.c @@ -1,5 +1,7 @@ #include +#undef nearbyintf + /* nearbyintf is not supposed to be the same as roundf according to openBSD * documentation. Indeed: * - they round halfway cases to the nearest integer instead of away from zero