diff options
author | Keith Packard via Newlib <newlib@sourceware.org> | 2020-08-05 01:22:24 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2020-08-05 23:23:02 +0300 |
commit | c3ce8405c185ee192ed802f9c79f2f5a797062ea (patch) | |
tree | 4729e2dc868bf14c878b9c7d0d59665bc407c8eb | |
parent | e108d04432bb0c0c223c447fcead5f7605342cba (diff) |
libm: Control errno support with _IEEE_LIBM configuration parameter
This removes the run-time configuration of errno support present in
portions of the math library and unifies all of the compile-time errno
configuration under a single parameter so that the whole library
is consistent.
The run-time support provided by _LIB_VERSION is no longer present in
the public API, although it is still used internally to disable errno
setting in some functions. Now that it is a constant, the compiler should
remove that code when errno is not supported.
This removes s_lib_ver.c as _LIB_VERSION is no longer variable.
Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r-- | newlib/libc/include/math.h | 16 | ||||
-rw-r--r-- | newlib/libm/common/Makefile.am | 2 | ||||
-rw-r--r-- | newlib/libm/common/Makefile.in | 36 | ||||
-rw-r--r-- | newlib/libm/common/fdlibm.h | 1 | ||||
-rw-r--r-- | newlib/libm/common/math_config.h | 5 | ||||
-rw-r--r-- | newlib/libm/common/s_lib_ver.c | 35 |
6 files changed, 22 insertions, 73 deletions
diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h index 9fd82d9fa..5e6155cc4 100644 --- a/newlib/libc/include/math.h +++ b/newlib/libc/include/math.h @@ -612,22 +612,6 @@ extern int *__signgam (void); #define M_LOG2_E _M_LN2 #define M_INVLN2 1.4426950408889633870E0 /* 1 / log(2) */ -/* Global control over fdlibm error handling. */ - -enum __fdlibm_version -{ - __fdlibm_ieee = -1, - __fdlibm_posix -}; - -#define _LIB_VERSION_TYPE enum __fdlibm_version -#define _LIB_VERSION __fdlib_version - -extern __IMPORT _LIB_VERSION_TYPE _LIB_VERSION; - -#define _IEEE_ __fdlibm_ieee -#define _POSIX_ __fdlibm_posix - #endif /* __BSD_VISIBLE */ _END_STD_C diff --git a/newlib/libm/common/Makefile.am b/newlib/libm/common/Makefile.am index 1eef0236a..1d178da4d 100644 --- a/newlib/libm/common/Makefile.am +++ b/newlib/libm/common/Makefile.am @@ -8,7 +8,7 @@ src = s_finite.c s_copysign.c s_modf.c s_scalbn.c \ s_cbrt.c s_exp10.c s_expm1.c s_ilogb.c \ s_infinity.c s_isinf.c s_isinfd.c s_isnan.c s_isnand.c \ s_log1p.c s_nan.c s_nextafter.c s_pow10.c \ - s_rint.c s_logb.c s_log2.c s_lib_ver.c \ + s_rint.c s_logb.c s_log2.c \ s_fdim.c s_fma.c s_fmax.c s_fmin.c s_fpclassify.c \ s_lrint.c s_llrint.c \ s_lround.c s_llround.c s_nearbyint.c s_remquo.c s_round.c s_scalbln.c \ diff --git a/newlib/libm/common/Makefile.in b/newlib/libm/common/Makefile.in index 2caf7dd6c..896843833 100644 --- a/newlib/libm/common/Makefile.in +++ b/newlib/libm/common/Makefile.in @@ -85,19 +85,19 @@ am__objects_1 = lib_a-s_finite.$(OBJEXT) lib_a-s_copysign.$(OBJEXT) \ lib_a-s_nan.$(OBJEXT) lib_a-s_nextafter.$(OBJEXT) \ lib_a-s_pow10.$(OBJEXT) lib_a-s_rint.$(OBJEXT) \ lib_a-s_logb.$(OBJEXT) lib_a-s_log2.$(OBJEXT) \ - lib_a-s_lib_ver.$(OBJEXT) lib_a-s_fdim.$(OBJEXT) \ - lib_a-s_fma.$(OBJEXT) lib_a-s_fmax.$(OBJEXT) \ - lib_a-s_fmin.$(OBJEXT) lib_a-s_fpclassify.$(OBJEXT) \ - lib_a-s_lrint.$(OBJEXT) lib_a-s_llrint.$(OBJEXT) \ - lib_a-s_lround.$(OBJEXT) lib_a-s_llround.$(OBJEXT) \ - lib_a-s_nearbyint.$(OBJEXT) lib_a-s_remquo.$(OBJEXT) \ - lib_a-s_round.$(OBJEXT) lib_a-s_scalbln.$(OBJEXT) \ - lib_a-s_signbit.$(OBJEXT) lib_a-s_trunc.$(OBJEXT) \ - lib_a-exp.$(OBJEXT) lib_a-exp2.$(OBJEXT) \ - lib_a-exp_data.$(OBJEXT) lib_a-math_err.$(OBJEXT) \ - lib_a-log.$(OBJEXT) lib_a-log_data.$(OBJEXT) \ - lib_a-log2.$(OBJEXT) lib_a-log2_data.$(OBJEXT) \ - lib_a-pow.$(OBJEXT) lib_a-pow_log_data.$(OBJEXT) + lib_a-s_fdim.$(OBJEXT) lib_a-s_fma.$(OBJEXT) \ + lib_a-s_fmax.$(OBJEXT) lib_a-s_fmin.$(OBJEXT) \ + lib_a-s_fpclassify.$(OBJEXT) lib_a-s_lrint.$(OBJEXT) \ + lib_a-s_llrint.$(OBJEXT) lib_a-s_lround.$(OBJEXT) \ + lib_a-s_llround.$(OBJEXT) lib_a-s_nearbyint.$(OBJEXT) \ + lib_a-s_remquo.$(OBJEXT) lib_a-s_round.$(OBJEXT) \ + lib_a-s_scalbln.$(OBJEXT) lib_a-s_signbit.$(OBJEXT) \ + lib_a-s_trunc.$(OBJEXT) lib_a-exp.$(OBJEXT) \ + lib_a-exp2.$(OBJEXT) lib_a-exp_data.$(OBJEXT) \ + lib_a-math_err.$(OBJEXT) lib_a-log.$(OBJEXT) \ + lib_a-log_data.$(OBJEXT) lib_a-log2.$(OBJEXT) \ + lib_a-log2_data.$(OBJEXT) lib_a-pow.$(OBJEXT) \ + lib_a-pow_log_data.$(OBJEXT) am__objects_2 = lib_a-sf_finite.$(OBJEXT) lib_a-sf_copysign.$(OBJEXT) \ lib_a-sf_modf.$(OBJEXT) lib_a-sf_scalbn.$(OBJEXT) \ lib_a-sf_cbrt.$(OBJEXT) lib_a-sf_exp10.$(OBJEXT) \ @@ -163,7 +163,7 @@ am__objects_5 = s_finite.lo s_copysign.lo s_modf.lo s_scalbn.lo \ s_cbrt.lo s_exp10.lo s_expm1.lo s_ilogb.lo s_infinity.lo \ s_isinf.lo s_isinfd.lo s_isnan.lo s_isnand.lo s_log1p.lo \ s_nan.lo s_nextafter.lo s_pow10.lo s_rint.lo s_logb.lo \ - s_log2.lo s_lib_ver.lo s_fdim.lo s_fma.lo s_fmax.lo s_fmin.lo \ + s_log2.lo s_fdim.lo s_fma.lo s_fmax.lo s_fmin.lo \ s_fpclassify.lo s_lrint.lo s_llrint.lo s_lround.lo \ s_llround.lo s_nearbyint.lo s_remquo.lo s_round.lo \ s_scalbln.lo s_signbit.lo s_trunc.lo exp.lo exp2.lo \ @@ -354,7 +354,7 @@ src = s_finite.c s_copysign.c s_modf.c s_scalbn.c \ s_cbrt.c s_exp10.c s_expm1.c s_ilogb.c \ s_infinity.c s_isinf.c s_isinfd.c s_isnan.c s_isnand.c \ s_log1p.c s_nan.c s_nextafter.c s_pow10.c \ - s_rint.c s_logb.c s_log2.c s_lib_ver.c \ + s_rint.c s_logb.c s_log2.c \ s_fdim.c s_fma.c s_fmax.c s_fmin.c s_fpclassify.c \ s_lrint.c s_llrint.c \ s_lround.c s_llround.c s_nearbyint.c s_remquo.c s_round.c s_scalbln.c \ @@ -602,12 +602,6 @@ lib_a-s_log2.o: s_log2.c lib_a-s_log2.obj: s_log2.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-s_log2.obj `if test -f 's_log2.c'; then $(CYGPATH_W) 's_log2.c'; else $(CYGPATH_W) '$(srcdir)/s_log2.c'; fi` -lib_a-s_lib_ver.o: s_lib_ver.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-s_lib_ver.o `test -f 's_lib_ver.c' || echo '$(srcdir)/'`s_lib_ver.c - -lib_a-s_lib_ver.obj: s_lib_ver.c - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-s_lib_ver.obj `if test -f 's_lib_ver.c'; then $(CYGPATH_W) 's_lib_ver.c'; else $(CYGPATH_W) '$(srcdir)/s_lib_ver.c'; fi` - lib_a-s_fdim.o: s_fdim.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-s_fdim.o `test -f 's_fdim.c' || echo '$(srcdir)/'`s_fdim.c diff --git a/newlib/libm/common/fdlibm.h b/newlib/libm/common/fdlibm.h index 8dfff243d..8dffc832d 100644 --- a/newlib/libm/common/fdlibm.h +++ b/newlib/libm/common/fdlibm.h @@ -15,6 +15,7 @@ #include <math.h> #include <sys/types.h> #include <machine/ieeefp.h> +#include "math_config.h" /* Most routines need to check whether a float is finite, infinite, or not a number, and many need to know whether the result of an operation will diff --git a/newlib/libm/common/math_config.h b/newlib/libm/common/math_config.h index 3be7e6320..1089b0ec6 100644 --- a/newlib/libm/common/math_config.h +++ b/newlib/libm/common/math_config.h @@ -38,15 +38,20 @@ #endif #ifdef _IEEE_LIBM # define WANT_ERRNO 0 +# define _LIB_VERSION _IEEE_ #else /* Set errno according to ISO C with (math_errhandling & MATH_ERRNO) != 0. */ # define WANT_ERRNO 1 +# define _LIB_VERSION _POSIX_ #endif #ifndef WANT_ERRNO_UFLOW /* Set errno to ERANGE if result underflows to 0 (in all rounding modes). */ # define WANT_ERRNO_UFLOW (WANT_ROUNDING && WANT_ERRNO) #endif +#define _IEEE_ -1 +#define _POSIX_ 0 + /* Compiler can inline round as a single instruction. */ #ifndef HAVE_FAST_ROUND # if __aarch64__ diff --git a/newlib/libm/common/s_lib_ver.c b/newlib/libm/common/s_lib_ver.c deleted file mode 100644 index 8da03b79a..000000000 --- a/newlib/libm/common/s_lib_ver.c +++ /dev/null @@ -1,35 +0,0 @@ - -/* @(#)s_lib_ver.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* - * MACRO for standards - */ - -#include "fdlibm.h" - -/* - * define and initialize _LIB_VERSION - */ -#ifdef _POSIX_MODE -_LIB_VERSION_TYPE _LIB_VERSION = _POSIX_; -#else -#ifdef _XOPEN_MODE -#error _XOPEN_MODE is unsupported -#else -#ifdef _SVID3_MODE -#error _SVID3_MODE is unsupported -#else /* default _IEEE_MODE */ -_LIB_VERSION_TYPE _LIB_VERSION = _IEEE_; -#endif -#endif -#endif |