diff options
author | Joseph Myers <joseph@codesourcery.com> | 2017-11-30 22:39:07 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2017-11-30 22:39:07 +0000 |
commit | e53df1dee841a206bf376373eb4250ce4f277e4b (patch) | |
tree | 474412d9424304fd87148f53ebbd300e7e2184d8 /sysdeps/m68k | |
parent | c0535adfeb5aad46f622f040925889602a482f29 (diff) | |
download | glibc-e53df1dee841a206bf376373eb4250ce4f277e4b.tar.gz glibc-e53df1dee841a206bf376373eb4250ce4f277e4b.tar.xz glibc-e53df1dee841a206bf376373eb4250ce4f277e4b.zip |
Rework m68k libm functions to use declare_mgen_alias.
Many m68k libm functions use their own system to share code between different types and functions, involving defining macros before including code for another function (for example, s_atan.c also acts as a template that can define other functions). Thes files serving as templates generate function aliases directly with e.g. "weak_alias (__CONCATX(__,FUNC), FUNC)" in s_atan.c. To be prepared to generate _Float32, _Float64 and _Float32x function aliases, this needs changing so that the libm_alias_* macros get used instead. As the macro to use varies depending on the type, that would mean additional macros to define in several different places to get the appropriate alias-generation macro used in each case. Rather than adding to the m68k-specific mechanisms, this patch converts the functions in question to use something closer to the math/ type-generic template mechanism. After this patch, these functions have m68k-specific templates such as s_atan_template.c, but those templates use all the same macros as in the math/ templates, such as FLOAT, M_DECL_FUNC, M_SUF and declare_mgen_alias. There is no automatic generation of the files such as s_atan.c that include the appropriate math-type-macros-*.h header and the template file (the existing automatic generation logic is only applicable for the fixed set of templates listed in math/ - and sysdeps sources always override files generated that way), so those files are still checked in, but they are all the obvious two-line files (with one additional definition in the case of the expm1 implementations), rather than making e.g. s_atan.c special. Functions are only converted where they should have aliases for _FloatN / _FloatNx types. Those m68k functions that do not generate public names (those that only generate __ieee754_*, with wrappers generating the public names, and classification functions that only exist once per format not once per type so don't get aliases) are unchanged. However, log1p (public names generated by wrapper) and significand (not provided for new types so no new aliases needed) needed changing because they previously included the atan implementations. Now, s_significand.c is the main implementation for functions with that prototype and using the old implementation approach, while log1p includes it in place of atan. Any further cleanups in this area (which preserve the proper set of functions getting aliases defined by libm_alias_float and libm_alias_double) are of course welcome, just not needed for the goals of this patch. Tested with build-many-glibcs.py that installed stripped shared libraries are unchanged by the patch. * sysdeps/m68k/m680x0/fpu/s_atan_template.c: New file. * sysdeps/m68k/m680x0/fpu/s_ceil_template.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_cos_template.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_expm1_template.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_fabs_template.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_floor_template.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_frexp_template.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_lrint_template.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_modf_template.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_nearbyint_template.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_remquo_template.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_rint_template.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_sin_template.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_sincos_template.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_tan_template.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_tanh_template.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_trunc_template.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_atan.c: Reimplement to use s_atan_template.c. * sysdeps/m68k/m680x0/fpu/s_atanf.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_atanl.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_ceil.c: Reimplement to use s_ceil_template.c. * sysdeps/m68k/m680x0/fpu/s_ceilf.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_ceill.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_cos.c: Reimplement to use s_cos_template.c. * sysdeps/m68k/m680x0/fpu/s_cosf.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_cosl.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_expm1.c: Reimplement to use s_expm1_template.c. * sysdeps/m68k/m680x0/fpu/s_expm1f.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_expm1l.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_fabs.c: Reimplement to use s_fabs_template.c. * sysdeps/m68k/m680x0/fpu/s_fabsf.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_fabsl.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_floor.c: Reimplement to use s_floor_template.c. * sysdeps/m68k/m680x0/fpu/s_floorf.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_floorl.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_frexp.c: Reimplement to use s_frexp_template.c. * sysdeps/m68k/m680x0/fpu/s_frexpf.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_lrint.c: Reimplement to use s_lrint_template.c. * sysdeps/m68k/m680x0/fpu/s_lrintf.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_lrintl.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_modf.c: Reimplement to use s_modf_template.c. * sysdeps/m68k/m680x0/fpu/s_modff.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_modfl.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_nearbyint.c: Reimplement to use s_nearbyint_template.c. * sysdeps/m68k/m680x0/fpu/s_nearbyintf.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_nearbyintl.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_remquo.c: Reimplement to use s_remquo_template.c. * sysdeps/m68k/m680x0/fpu/s_remquof.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_remquol.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_rint.c: Reimplement to use s_rint_template.c. * sysdeps/m68k/m680x0/fpu/s_rintf.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_rintl.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_sin.c: Reimplement to use s_sin_template.c. * sysdeps/m68k/m680x0/fpu/s_sinf.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_sinl.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_sincos.c: Reimplement to use s_sincos_template.c. * sysdeps/m68k/m680x0/fpu/s_sincosf.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_sincosl.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_tan.c: Reimplement to use s_tan_template.c. * sysdeps/m68k/m680x0/fpu/s_tanf.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_tanl.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_tanh.c: Reimplement to use s_tanh_template.c. * sysdeps/m68k/m680x0/fpu/s_tanhf.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_tanhl.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_trunc.c: Reimplement to use s_trunc_template.c. * sysdeps/m68k/m680x0/fpu/s_truncf.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_truncl.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_significand.c: Reimplement based on s_atan.c instead of including s_atan.c. * sysdeps/m68k/m680x0/fpu/s_significandf.c: Reimplement based on s_atanf.c instead of including s_atanf.c. * sysdeps/m68k/m680x0/fpu/s_significandl.c: Reimplement based on s_atanl.c instead of including s_atanl.c. * sysdeps/m68k/m680x0/fpu/s_log1p.c: Include s_significand.c instead of s_atan.c. * sysdeps/m68k/m680x0/fpu/s_log1pf.c: Include s_significandf.c instead of s_atanf.c. * sysdeps/m68k/m680x0/fpu/s_log1pl.c: Include s_significandl.c instead of s_atanl.c.
Diffstat (limited to 'sysdeps/m68k')
73 files changed, 654 insertions, 434 deletions
diff --git a/sysdeps/m68k/m680x0/fpu/s_atan.c b/sysdeps/m68k/m680x0/fpu/s_atan.c index 55e26312fc..a6f90d3298 100644 --- a/sysdeps/m68k/m680x0/fpu/s_atan.c +++ b/sysdeps/m68k/m680x0/fpu/s_atan.c @@ -1,34 +1,2 @@ -/* Copyright (C) 1996-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <http://www.gnu.org/licenses/>. */ - -#include <math.h> - -#ifndef FUNC -#define FUNC atan -#endif -#ifndef float_type -#define float_type double -#endif - -#define __CONCATX(a,b) __CONCAT(a,b) - -float_type -__CONCATX(__,FUNC) (float_type x) -{ - return __m81_u(__CONCATX(__,FUNC))(x); -} -weak_alias (__CONCATX(__,FUNC), FUNC) +#include <math-type-macros-double.h> +#include <s_atan_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_atan_template.c b/sysdeps/m68k/m680x0/fpu/s_atan_template.c new file mode 100644 index 0000000000..03da769565 --- /dev/null +++ b/sysdeps/m68k/m680x0/fpu/s_atan_template.c @@ -0,0 +1,26 @@ +/* Implement atan for m68k. + Copyright (C) 1996-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> + +FLOAT +M_DECL_FUNC (__atan) (FLOAT x) +{ + return __m81_u(M_SUF (__atan)) (x); +} +declare_mgen_alias (__atan, atan) diff --git a/sysdeps/m68k/m680x0/fpu/s_atanf.c b/sysdeps/m68k/m680x0/fpu/s_atanf.c index c98559a8ba..bc24155c41 100644 --- a/sysdeps/m68k/m680x0/fpu/s_atanf.c +++ b/sysdeps/m68k/m680x0/fpu/s_atanf.c @@ -1,5 +1,2 @@ -#ifndef FUNC -#define FUNC atanf -#endif -#define float_type float -#include <s_atan.c> +#include <math-type-macros-float.h> +#include <s_atan_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_atanl.c b/sysdeps/m68k/m680x0/fpu/s_atanl.c index b7e608addd..28eea11999 100644 --- a/sysdeps/m68k/m680x0/fpu/s_atanl.c +++ b/sysdeps/m68k/m680x0/fpu/s_atanl.c @@ -1,5 +1,2 @@ -#ifndef FUNC -#define FUNC atanl -#endif -#define float_type long double -#include <s_atan.c> +#include <math-type-macros-ldouble.h> +#include <s_atan_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_ceil.c b/sysdeps/m68k/m680x0/fpu/s_ceil.c index 93d5ad72e5..70aeb739f1 100644 --- a/sysdeps/m68k/m680x0/fpu/s_ceil.c +++ b/sysdeps/m68k/m680x0/fpu/s_ceil.c @@ -1,2 +1,2 @@ -#define FUNC ceil -#include <s_atan.c> +#include <math-type-macros-double.h> +#include <s_ceil_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_ceil_template.c b/sysdeps/m68k/m680x0/fpu/s_ceil_template.c new file mode 100644 index 0000000000..945f7c18ae --- /dev/null +++ b/sysdeps/m68k/m680x0/fpu/s_ceil_template.c @@ -0,0 +1,26 @@ +/* Implement ceil for m68k. + Copyright (C) 1996-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> + +FLOAT +M_DECL_FUNC (__ceil) (FLOAT x) +{ + return __m81_u(M_SUF (__ceil)) (x); +} +declare_mgen_alias (__ceil, ceil) diff --git a/sysdeps/m68k/m680x0/fpu/s_ceilf.c b/sysdeps/m68k/m680x0/fpu/s_ceilf.c index b3ba6a5700..74e027e40c 100644 --- a/sysdeps/m68k/m680x0/fpu/s_ceilf.c +++ b/sysdeps/m68k/m680x0/fpu/s_ceilf.c @@ -1,2 +1,2 @@ -#define FUNC ceilf -#include <s_atanf.c> +#include <math-type-macros-float.h> +#include <s_ceil_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_ceill.c b/sysdeps/m68k/m680x0/fpu/s_ceill.c index 2bf95b00c6..5188c2471d 100644 --- a/sysdeps/m68k/m680x0/fpu/s_ceill.c +++ b/sysdeps/m68k/m680x0/fpu/s_ceill.c @@ -1,2 +1,2 @@ -#define FUNC ceill -#include <s_atanl.c> +#include <math-type-macros-ldouble.h> +#include <s_ceil_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_cos.c b/sysdeps/m68k/m680x0/fpu/s_cos.c index 2f1adf77f5..24e508e5c3 100644 --- a/sysdeps/m68k/m680x0/fpu/s_cos.c +++ b/sysdeps/m68k/m680x0/fpu/s_cos.c @@ -1,2 +1,2 @@ -#define FUNC cos -#include <s_sin.c> +#include <math-type-macros-double.h> +#include <s_cos_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_cos_template.c b/sysdeps/m68k/m680x0/fpu/s_cos_template.c new file mode 100644 index 0000000000..56a5a75bb2 --- /dev/null +++ b/sysdeps/m68k/m680x0/fpu/s_cos_template.c @@ -0,0 +1,30 @@ +/* Implement cos for m68k. + Copyright (C) 2012-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> +#include <errno.h> +#include "mathimpl.h" + +FLOAT +M_DECL_FUNC (__cos) (FLOAT x) +{ + if (__m81_test (x) & __M81_COND_INF) + __set_errno (EDOM); + return __m81_u(M_SUF (__cos)) (x); +} +declare_mgen_alias (__cos, cos) diff --git a/sysdeps/m68k/m680x0/fpu/s_cosf.c b/sysdeps/m68k/m680x0/fpu/s_cosf.c index b6d6accb4a..fcfc844dfe 100644 --- a/sysdeps/m68k/m680x0/fpu/s_cosf.c +++ b/sysdeps/m68k/m680x0/fpu/s_cosf.c @@ -1,2 +1,2 @@ -#define FUNC cosf -#include <s_sinf.c> +#include <math-type-macros-float.h> +#include <s_cos_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_cosl.c b/sysdeps/m68k/m680x0/fpu/s_cosl.c index eb61521fdd..de8767cfe3 100644 --- a/sysdeps/m68k/m680x0/fpu/s_cosl.c +++ b/sysdeps/m68k/m680x0/fpu/s_cosl.c @@ -1,2 +1,2 @@ -#define FUNC cosl -#include <s_sinl.c> +#include <math-type-macros-ldouble.h> +#include <s_cos_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_expm1.c b/sysdeps/m68k/m680x0/fpu/s_expm1.c index c969a7f029..e3abfbdfa5 100644 --- a/sysdeps/m68k/m680x0/fpu/s_expm1.c +++ b/sysdeps/m68k/m680x0/fpu/s_expm1.c @@ -15,27 +15,6 @@ License along with the GNU C Library. If not, see <http://www.gnu.org/licenses/>. */ -#include <math.h> -#include <errno.h> -#include "mathimpl.h" - -#ifndef FUNC -# define FUNC expm1 -#endif -#ifndef float_type -# define float_type double -#endif -#ifndef o_threshold -# define o_threshold 7.09782712893383973096e+02 -#endif - -#define CONCATX(a,b) __CONCAT(a,b) - -float_type -CONCATX(__,FUNC) (float_type x) -{ - if ((__m81_test (x) & __M81_COND_INF) == 0 && isgreater (x, o_threshold)) - __set_errno (ERANGE); - return __m81_u(CONCATX(__, FUNC)) (x); -} -weak_alias (CONCATX(__, FUNC), FUNC) +#include <math-type-macros-double.h> +#define o_threshold 7.09782712893383973096e+02 +#include <s_expm1_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_expm1_template.c b/sysdeps/m68k/m680x0/fpu/s_expm1_template.c new file mode 100644 index 0000000000..492cc87619 --- /dev/null +++ b/sysdeps/m68k/m680x0/fpu/s_expm1_template.c @@ -0,0 +1,30 @@ +/* Implement expm1 for m68k. + Copyright (C) 2012-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> +#include <errno.h> +#include "mathimpl.h" + +FLOAT +M_DECL_FUNC (__expm1) (FLOAT x) +{ + if ((__m81_test (x) & __M81_COND_INF) == 0 && isgreater (x, o_threshold)) + __set_errno (ERANGE); + return __m81_u(M_SUF (__expm1)) (x); +} +declare_mgen_alias (__expm1, expm1) diff --git a/sysdeps/m68k/m680x0/fpu/s_expm1f.c b/sysdeps/m68k/m680x0/fpu/s_expm1f.c index 2cd8ffcfeb..a36080030e 100644 --- a/sysdeps/m68k/m680x0/fpu/s_expm1f.c +++ b/sysdeps/m68k/m680x0/fpu/s_expm1f.c @@ -1,4 +1,3 @@ -#define FUNC expm1f -#define float_type float +#include <math-type-macros-float.h> #define o_threshold 8.8722831726e+01F -#include <s_expm1.c> +#include <s_expm1_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_expm1l.c b/sysdeps/m68k/m680x0/fpu/s_expm1l.c index a2c80860ba..cfbab2843b 100644 --- a/sysdeps/m68k/m680x0/fpu/s_expm1l.c +++ b/sysdeps/m68k/m680x0/fpu/s_expm1l.c @@ -1,6 +1,5 @@ -#define FUNC expm1l -#define float_type long double +#include <math-type-macros-ldouble.h> /* 400c0000b17217f7d1cf79ab */ #define o_threshold 1.13565234062941439487914863093465101e+04L -#include <s_expm1.c> +#include <s_expm1_template.c> libm_hidden_def (__expm1l) diff --git a/sysdeps/m68k/m680x0/fpu/s_fabs.c b/sysdeps/m68k/m680x0/fpu/s_fabs.c index 1f0631e2ff..179a94add2 100644 --- a/sysdeps/m68k/m680x0/fpu/s_fabs.c +++ b/sysdeps/m68k/m680x0/fpu/s_fabs.c @@ -1,2 +1,2 @@ -#define FUNC fabs -#include <s_atan.c> +#include <math-type-macros-double.h> +#include <s_fabs_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_fabs_template.c b/sysdeps/m68k/m680x0/fpu/s_fabs_template.c new file mode 100644 index 0000000000..5b74e4b564 --- /dev/null +++ b/sysdeps/m68k/m680x0/fpu/s_fabs_template.c @@ -0,0 +1,26 @@ +/* Implement fabs for m68k. + Copyright (C) 1996-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> + +FLOAT +M_DECL_FUNC (__fabs) (FLOAT x) +{ + return __m81_u(M_SUF (__fabs)) (x); +} +declare_mgen_alias (__fabs, fabs) diff --git a/sysdeps/m68k/m680x0/fpu/s_fabsf.c b/sysdeps/m68k/m680x0/fpu/s_fabsf.c index 8f9421998a..9072d2a76a 100644 --- a/sysdeps/m68k/m680x0/fpu/s_fabsf.c +++ b/sysdeps/m68k/m680x0/fpu/s_fabsf.c @@ -1,2 +1,2 @@ -#define FUNC fabsf -#include <s_atanf.c> +#include <math-type-macros-float.h> +#include <s_fabs_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_fabsl.c b/sysdeps/m68k/m680x0/fpu/s_fabsl.c index 8ac14d5b8c..fa48f8ae4e 100644 --- a/sysdeps/m68k/m680x0/fpu/s_fabsl.c +++ b/sysdeps/m68k/m680x0/fpu/s_fabsl.c @@ -1,2 +1,2 @@ -#define FUNC fabsl -#include <s_atanl.c> +#include <math-type-macros-ldouble.h> +#include <s_fabs_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_floor.c b/sysdeps/m68k/m680x0/fpu/s_floor.c index e1219c602a..339ae2cce4 100644 --- a/sysdeps/m68k/m680x0/fpu/s_floor.c +++ b/sysdeps/m68k/m680x0/fpu/s_floor.c @@ -1,2 +1,2 @@ -#define FUNC floor -#include <s_atan.c> +#include <math-type-macros-double.h> +#include <s_floor_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_floor_template.c b/sysdeps/m68k/m680x0/fpu/s_floor_template.c new file mode 100644 index 0000000000..542d8b85c9 --- /dev/null +++ b/sysdeps/m68k/m680x0/fpu/s_floor_template.c @@ -0,0 +1,26 @@ +/* Implement floor for m68k. + Copyright (C) 1996-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> + +FLOAT +M_DECL_FUNC (__floor) (FLOAT x) +{ + return __m81_u(M_SUF (__floor)) (x); +} +declare_mgen_alias (__floor, floor) diff --git a/sysdeps/m68k/m680x0/fpu/s_floorf.c b/sysdeps/m68k/m680x0/fpu/s_floorf.c index f4f9b9a1d8..5d998e0217 100644 --- a/sysdeps/m68k/m680x0/fpu/s_floorf.c +++ b/sysdeps/m68k/m680x0/fpu/s_floorf.c @@ -1,2 +1,2 @@ -#define FUNC floorf -#include <s_atanf.c> +#include <math-type-macros-float.h> +#include <s_floor_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_floorl.c b/sysdeps/m68k/m680x0/fpu/s_floorl.c index 2c1ffd7d2c..2295f99845 100644 --- a/sysdeps/m68k/m680x0/fpu/s_floorl.c +++ b/sysdeps/m68k/m680x0/fpu/s_floorl.c @@ -1,2 +1,2 @@ -#define FUNC floorl -#include <s_atanl.c> +#include <math-type-macros-ldouble.h> +#include <s_floor_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_frexp.c b/sysdeps/m68k/m680x0/fpu/s_frexp.c index 009b1e3223..be8db3875a 100644 --- a/sysdeps/m68k/m680x0/fpu/s_frexp.c +++ b/sysdeps/m68k/m680x0/fpu/s_frexp.c @@ -1,53 +1,2 @@ -/* Copyright (C) 1996-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <http://www.gnu.org/licenses/>. */ - -#include <math.h> - -#ifndef FUNC -#define FUNC frexp -#endif -#ifndef float_type -#define float_type double -#endif - -#define __CONCATX(a,b) __CONCAT(a,b) - -float_type -__CONCATX(__,FUNC) (float_type value, int *expptr) -{ - float_type mantissa, exponent; - int iexponent; - unsigned long fpsr; - - __asm ("ftst%.x %1\n" - "fmove%.l %/fpsr, %0" - : "=dm" (fpsr) : "f" (value)); - if (fpsr & (7 << 24)) - { - /* Not finite or zero. */ - *expptr = 0; - return value; - } - __asm ("fgetexp%.x %1, %0" : "=f" (exponent) : "f" (value)); - iexponent = (int) exponent + 1; - *expptr = iexponent; - __asm ("fscale%.l %2, %0" - : "=f" (mantissa) - : "0" (value), "dmi" (-iexponent)); - return mantissa; -} -weak_alias (__CONCATX(__,FUNC), FUNC) +#include <math-type-macros-double.h> +#include <s_frexp_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_frexp_template.c b/sysdeps/m68k/m680x0/fpu/s_frexp_template.c new file mode 100644 index 0000000000..7f50887373 --- /dev/null +++ b/sysdeps/m68k/m680x0/fpu/s_frexp_template.c @@ -0,0 +1,45 @@ +/* Implement frexp for m68k. + Copyright (C) 1996-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> + +FLOAT +M_DECL_FUNC (__frexp) (FLOAT value, int *expptr) +{ + FLOAT mantissa, exponent; + int iexponent; + unsigned long fpsr; + + __asm ("ftst%.x %1\n" + "fmove%.l %/fpsr, %0" + : "=dm" (fpsr) : "f" (value)); + if (fpsr & (7 << 24)) + { + /* Not finite or zero. */ + *expptr = 0; + return value; + } + __asm ("fgetexp%.x %1, %0" : "=f" (exponent) : "f" (value)); + iexponent = (int) exponent + 1; + *expptr = iexponent; + __asm ("fscale%.l %2, %0" + : "=f" (mantissa) + : "0" (value), "dmi" (-iexponent)); + return mantissa; +} +declare_mgen_alias (__frexp, frexp) diff --git a/sysdeps/m68k/m680x0/fpu/s_frexpf.c b/sysdeps/m68k/m680x0/fpu/s_frexpf.c index 893b6ad3cf..6cf7ceb294 100644 --- a/sysdeps/m68k/m680x0/fpu/s_frexpf.c +++ b/sysdeps/m68k/m680x0/fpu/s_frexpf.c @@ -1,3 +1,2 @@ -#define FUNC frexpf -#define float_type float -#include <s_frexp.c> +#include <math-type-macros-float.h> +#include <s_frexp_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_log1p.c b/sysdeps/m68k/m680x0/fpu/s_log1p.c index 082618df18..7eb2529547 100644 --- a/sysdeps/m68k/m680x0/fpu/s_log1p.c +++ b/sysdeps/m68k/m680x0/fpu/s_log1p.c @@ -1,4 +1,4 @@ #define FUNC log1p #undef weak_alias #define weak_alias(a,b) -#include <s_atan.c> +#include <s_significand.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_log1pf.c b/sysdeps/m68k/m680x0/fpu/s_log1pf.c index 480c39519f..40f332ff36 100644 --- a/sysdeps/m68k/m680x0/fpu/s_log1pf.c +++ b/sysdeps/m68k/m680x0/fpu/s_log1pf.c @@ -1,4 +1,4 @@ #define FUNC log1pf #undef weak_alias #define weak_alias(a,b) -#include <s_atanf.c> +#include <s_significandf.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_log1pl.c b/sysdeps/m68k/m680x0/fpu/s_log1pl.c index a4f34a4f86..e580bafbc5 100644 --- a/sysdeps/m68k/m680x0/fpu/s_log1pl.c +++ b/sysdeps/m68k/m680x0/fpu/s_log1pl.c @@ -1,4 +1,4 @@ #define FUNC log1pl #undef weak_alias #define weak_alias(a,b) -#include <s_atanl.c> +#include <s_significandl.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_lrint.c b/sysdeps/m68k/m680x0/fpu/s_lrint.c index d25a548dcd..31440cfdbc 100644 --- a/sysdeps/m68k/m680x0/fpu/s_lrint.c +++ b/sysdeps/m68k/m680x0/fpu/s_lrint.c @@ -1,37 +1,2 @@ -/* Round argument to nearest integral value according to current rounding - direction. - Copyright (C) 1997-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <http://www.gnu.org/licenses/>. */ - -#include <math.h> - -#ifndef suffix -#define suffix /*empty*/ -#endif -#ifndef float_type -#define float_type double -#endif - -#define CONCATX(a,b) __CONCAT(a,b) - -long int -CONCATX(__lrint,suffix) (float_type x) -{ - return __m81_u(CONCATX(__lrint,suffix)) (x); -} -weak_alias (CONCATX(__lrint,suffix), CONCATX(lrint,suffix)) +#include <math-type-macros-double.h> +#include <s_lrint_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_lrint_template.c b/sysdeps/m68k/m680x0/fpu/s_lrint_template.c new file mode 100644 index 0000000000..efa00f12b9 --- /dev/null +++ b/sysdeps/m68k/m680x0/fpu/s_lrint_template.c @@ -0,0 +1,28 @@ +/* Round argument to nearest integral value according to current rounding + direction. + Copyright (C) 1997-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> + +long int +M_DECL_FUNC (__lrint) (FLOAT x) +{ + return __m81_u(M_SUF (__lrint)) (x); +} +declare_mgen_alias (__lrint, lrint) diff --git a/sysdeps/m68k/m680x0/fpu/s_lrintf.c b/sysdeps/m68k/m680x0/fpu/s_lrintf.c index 44924cb82f..77e753baa7 100644 --- a/sysdeps/m68k/m680x0/fpu/s_lrintf.c +++ b/sysdeps/m68k/m680x0/fpu/s_lrintf.c @@ -1,3 +1,2 @@ -#define suffix f -#define float_type float -#include <s_lrint.c> +#include <math-type-macros-float.h> +#include <s_lrint_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_lrintl.c b/sysdeps/m68k/m680x0/fpu/s_lrintl.c index cd0bd23b8a..a4670b83c6 100644 --- a/sysdeps/m68k/m680x0/fpu/s_lrintl.c +++ b/sysdeps/m68k/m680x0/fpu/s_lrintl.c @@ -1,3 +1,2 @@ -#define suffix l -#define float_type long double -#include <s_lrint.c> +#include <math-type-macros-ldouble.h> +#include <s_lrint_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_modf.c b/sysdeps/m68k/m680x0/fpu/s_modf.c index 3c1a5a2749..1d1c0ea7f2 100644 --- a/sysdeps/m68k/m680x0/fpu/s_modf.c +++ b/sysdeps/m68k/m680x0/fpu/s_modf.c @@ -1,53 +1,2 @@ -/* Copyright (C) 1996-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <http://www.gnu.org/licenses/>. */ - -#include <math.h> -#include "mathimpl.h" - -#ifndef SUFF -#define SUFF -#endif -#ifndef float_type -#define float_type double -#endif - -#define CONCATX(a,b) __CONCAT(a,b) -#define s(name) CONCATX(name,SUFF) -#define m81(func) __m81_u(s(func)) - -float_type -s(__modf) (float_type x, float_type *iptr) -{ - float_type x_int, result; - unsigned long x_cond; - - __asm ("fintrz%.x %1, %0" : "=f" (x_int) : "f" (x)); - *iptr = x_int; - x_cond = __m81_test (x); - if (x_cond & __M81_COND_INF) - { - result = 0; - if (x_cond & __M81_COND_NEG) - result = -result; - } - else if (x_cond & __M81_COND_ZERO) - result = x; - else - result = x - x_int; - return result; -} -weak_alias (s(__modf), s(modf)) +#include <math-type-macros-double.h> +#include <s_modf_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_modf_template.c b/sysdeps/m68k/m680x0/fpu/s_modf_template.c new file mode 100644 index 0000000000..b354e738a5 --- /dev/null +++ b/sysdeps/m68k/m680x0/fpu/s_modf_template.c @@ -0,0 +1,43 @@ +/* Implement modf for m68k. + Copyright (C) 1996-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> +#include "mathimpl.h" + +FLOAT +M_DECL_FUNC (__modf) (FLOAT x, FLOAT *iptr) +{ + FLOAT x_int, result; + unsigned long x_cond; + + __asm ("fintrz%.x %1, %0" : "=f" (x_int) : "f" (x)); + *iptr = x_int; + x_cond = __m81_test (x); + if (x_cond & __M81_COND_INF) + { + result = 0; + if (x_cond & __M81_COND_NEG) + result = -result; + } + else if (x_cond & __M81_COND_ZERO) + result = x; + else + result = x - x_int; + return result; +} +declare_mgen_alias (__modf, modf) diff --git a/sysdeps/m68k/m680x0/fpu/s_modff.c b/sysdeps/m68k/m680x0/fpu/s_modff.c index 0c44d7c0ab..3d28880398 100644 --- a/sysdeps/m68k/m680x0/fpu/s_modff.c +++ b/sysdeps/m68k/m680x0/fpu/s_modff.c @@ -1,3 +1,2 @@ -#define SUFF f -#define float_type float -#include <s_modf.c> +#include <math-type-macros-float.h> +#include <s_modf_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_modfl.c b/sysdeps/m68k/m680x0/fpu/s_modfl.c index c7075b3ba9..9057645249 100644 --- a/sysdeps/m68k/m680x0/fpu/s_modfl.c +++ b/sysdeps/m68k/m680x0/fpu/s_modfl.c @@ -1,3 +1,2 @@ -#define SUFF l -#define float_type long double -#include <s_modf.c> +#include <math-type-macros-ldouble.h> +#include <s_modf_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_nearbyint.c b/sysdeps/m68k/m680x0/fpu/s_nearbyint.c index b87f5e2160..6af0d9b1a9 100644 --- a/sysdeps/m68k/m680x0/fpu/s_nearbyint.c +++ b/sysdeps/m68k/m680x0/fpu/s_nearbyint.c @@ -1,2 +1,2 @@ -#define FUNC nearbyint -#include <s_atan.c> +#include <math-type-macros-double.h> +#include <s_nearbyint_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_nearbyint_template.c b/sysdeps/m68k/m680x0/fpu/s_nearbyint_template.c new file mode 100644 index 0000000000..45463788c4 --- /dev/null +++ b/sysdeps/m68k/m680x0/fpu/s_nearbyint_template.c @@ -0,0 +1,26 @@ +/* Implement nearbyint for m68k. + Copyright (C) 1996-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> + +FLOAT +M_DECL_FUNC (__nearbyint) (FLOAT x) +{ + return __m81_u(M_SUF (__nearbyint)) (x); +} +declare_mgen_alias (__nearbyint, nearbyint) diff --git a/sysdeps/m68k/m680x0/fpu/s_nearbyintf.c b/sysdeps/m68k/m680x0/fpu/s_nearbyintf.c index 70d08ab44c..aefd7fc7c5 100644 --- a/sysdeps/m68k/m680x0/fpu/s_nearbyintf.c +++ b/sysdeps/m68k/m680x0/fpu/s_nearbyintf.c @@ -1,2 +1,2 @@ -#define FUNC nearbyintf -#include <s_atanf.c> +#include <math-type-macros-float.h> +#include <s_nearbyint_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_nearbyintl.c b/sysdeps/m68k/m680x0/fpu/s_nearbyintl.c index 230cd7784c..8516caf947 100644 --- a/sysdeps/m68k/m680x0/fpu/s_nearbyintl.c +++ b/sysdeps/m68k/m680x0/fpu/s_nearbyintl.c @@ -1,2 +1,2 @@ -#define FUNC nearbyintl -#include <s_atanl.c> +#include <math-type-macros-ldouble.h> +#include <s_nearbyint_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_remquo.c b/sysdeps/m68k/m680x0/fpu/s_remquo.c index 554751ca87..b1d8f3a972 100644 --- a/sysdeps/m68k/m680x0/fpu/s_remquo.c +++ b/sysdeps/m68k/m680x0/fpu/s_remquo.c @@ -1,46 +1,2 @@ -/* Compute remainder and a congruent to the quotient. m68k fpu version - Copyright (C) 1997-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <http://www.gnu.org/licenses/>. */ - -#include <math.h> - -#ifndef SUFF -#define SUFF -#endif -#ifndef float_type -#define float_type double -#endif - -#define CONCATX(a,b) __CONCAT(a,b) -#define s(name) CONCATX(name,SUFF) - -float_type -s(__remquo) (float_type x, float_type y, int *quo) -{ - float_type result; - int cquo, fpsr; - - __asm ("frem%.x %2,%0\n\tfmove%.l %/fpsr,%1" - : "=f" (result), "=dm" (fpsr) : "f" (y), "0" (x)); - cquo = (fpsr >> 16) & 0x7f; - if (fpsr & (1 << 23)) - cquo = -cquo; - *quo = cquo; - return result; -} -weak_alias (s(__remquo), s(remquo)) +#include <math-type-macros-double.h> +#include <s_remquo_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_remquo_template.c b/sysdeps/m68k/m680x0/fpu/s_remquo_template.c new file mode 100644 index 0000000000..fb5a096054 --- /dev/null +++ b/sysdeps/m68k/m680x0/fpu/s_remquo_template.c @@ -0,0 +1,36 @@ +/* Compute remainder and a congruent to the quotient. m68k fpu version + Copyright (C) 1997-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> + +FLOAT +M_DECL_FUNC (__remquo) (FLOAT x, FLOAT y, int *quo) +{ + FLOAT result; + int cquo, fpsr; + + __asm ("frem%.x %2,%0\n\tfmove%.l %/fpsr,%1" + : "=f" (result), "=dm" (fpsr) : "f" (y), "0" (x)); + cquo = (fpsr >> 16) & 0x7f; + if (fpsr & (1 << 23)) + cquo = -cquo; + *quo = cquo; + return result; +} +declare_mgen_alias (__remquo, remquo) diff --git a/sysdeps/m68k/m680x0/fpu/s_remquof.c b/sysdeps/m68k/m680x0/fpu/s_remquof.c index 8a292fc26c..f2b86628d2 100644 --- a/sysdeps/m68k/m680x0/fpu/s_remquof.c +++ b/sysdeps/m68k/m680x0/fpu/s_remquof.c @@ -1,3 +1,2 @@ -#define SUFF f -#define float_type float -#include <s_remquo.c> +#include <math-type-macros-float.h> +#include <s_remquo_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_remquol.c b/sysdeps/m68k/m680x0/fpu/s_remquol.c index d236cfd1f9..cb18d9e520 100644 --- a/sysdeps/m68k/m680x0/fpu/s_remquol.c +++ b/sysdeps/m68k/m680x0/fpu/s_remquol.c @@ -1,3 +1,2 @@ -#define SUFF l -#define float_type long double -#include <s_remquo.c> +#include <math-type-macros-ldouble.h> +#include <s_remquo_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_rint.c b/sysdeps/m68k/m680x0/fpu/s_rint.c index f0f18c7346..fa092c07eb 100644 --- a/sysdeps/m68k/m680x0/fpu/s_rint.c +++ b/sysdeps/m68k/m680x0/fpu/s_rint.c @@ -1,2 +1,2 @@ -#define FUNC rint -#include <s_atan.c> +#include <math-type-macros-double.h> +#include <s_rint_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_rint_template.c b/sysdeps/m68k/m680x0/fpu/s_rint_template.c new file mode 100644 index 0000000000..2589f9d332 --- /dev/null +++ b/sysdeps/m68k/m680x0/fpu/s_rint_template.c @@ -0,0 +1,26 @@ +/* Implement rint for m68k. + Copyright (C) 1996-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> + +FLOAT +M_DECL_FUNC (__rint) (FLOAT x) +{ + return __m81_u(M_SUF (__rint)) (x); +} +declare_mgen_alias (__rint, rint) diff --git a/sysdeps/m68k/m680x0/fpu/s_rintf.c b/sysdeps/m68k/m680x0/fpu/s_rintf.c index 4e00cab0fb..5cda19c690 100644 --- a/sysdeps/m68k/m680x0/fpu/s_rintf.c +++ b/sysdeps/m68k/m680x0/fpu/s_rintf.c @@ -1,2 +1,2 @@ -#define FUNC rintf -#include <s_atanf.c> +#include <math-type-macros-float.h> +#include <s_rint_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_rintl.c b/sysdeps/m68k/m680x0/fpu/s_rintl.c index 305667b3a1..df393ee895 100644 --- a/sysdeps/m68k/m680x0/fpu/s_rintl.c +++ b/sysdeps/m68k/m680x0/fpu/s_rintl.c @@ -1,2 +1,2 @@ -#define FUNC rintl -#include <s_atanl.c> +#include <math-type-macros-ldouble.h> +#include <s_rint_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_significand.c b/sysdeps/m68k/m680x0/fpu/s_significand.c index 34d4ea3d14..d43de6ed91 100644 --- a/sysdeps/m68k/m680x0/fpu/s_significand.c +++ b/sysdeps/m68k/m680x0/fpu/s_significand.c @@ -1,2 +1,35 @@ -#define FUNC significand -#include <s_atan.c> +/* Implement significand for m68k. + Copyright (C) 1996-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> + +#ifndef FUNC +#define FUNC significand +#endif +#ifndef float_type +#define float_type double +#endif + +#define __CONCATX(a,b) __CONCAT(a,b) + +float_type +__CONCATX(__,FUNC) (float_type x) +{ + return __m81_u(__CONCATX(__,FUNC))(x); +} +weak_alias (__CONCATX(__,FUNC), FUNC) diff --git a/sysdeps/m68k/m680x0/fpu/s_significandf.c b/sysdeps/m68k/m680x0/fpu/s_significandf.c index 4e769ca317..bbaa64bb13 100644 --- a/sysdeps/m68k/m680x0/fpu/s_significandf.c +++ b/sysdeps/m68k/m680x0/fpu/s_significandf.c @@ -1,2 +1,5 @@ -#define FUNC significandf -#include <s_atanf.c> +#ifndef FUNC +#define FUNC significandf +#endif +#define float_type float +#include <s_significand.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_significandl.c b/sysdeps/m68k/m680x0/fpu/s_significandl.c index 8c6fc7e610..f3496ee862 100644 --- a/sysdeps/m68k/m680x0/fpu/s_significandl.c +++ b/sysdeps/m68k/m680x0/fpu/s_significandl.c @@ -1,2 +1,5 @@ +#ifndef FUNC #define FUNC significandl -#include <s_atanl.c> +#endif +#define float_type long double +#include <s_significand.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_sin.c b/sysdeps/m68k/m680x0/fpu/s_sin.c index 953fb445cf..b52e804ab9 100644 --- a/sysdeps/m68k/m680x0/fpu/s_sin.c +++ b/sysdeps/m68k/m680x0/fpu/s_sin.c @@ -1,38 +1,2 @@ -/* Copyright (C) 2012-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <http://www.gnu.org/licenses/>. */ - -#include <math.h> -#include <errno.h> -#include "mathimpl.h" - -#ifndef FUNC -# define FUNC sin -#endif -#ifndef float_type -# define float_type double -#endif - -#define CONCATX(a,b) __CONCAT(a,b) - -float_type -CONCATX(__,FUNC) (float_type x) -{ - if (__m81_test (x) & __M81_COND_INF) - __set_errno (EDOM); - return __m81_u(CONCATX(__, FUNC)) (x); -} -weak_alias (CONCATX(__, FUNC), FUNC) +#include <math-type-macros-double.h> +#include <s_sin_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_sin_template.c b/sysdeps/m68k/m680x0/fpu/s_sin_template.c new file mode 100644 index 0000000000..c44d414c5b --- /dev/null +++ b/sysdeps/m68k/m680x0/fpu/s_sin_template.c @@ -0,0 +1,30 @@ +/* Implement sin for m68k. + Copyright (C) 2012-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> +#include <errno.h> +#include "mathimpl.h" + +FLOAT +M_DECL_FUNC (__sin) (FLOAT x) +{ + if (__m81_test (x) & __M81_COND_INF) + __set_errno (EDOM); + return __m81_u(M_SUF (__sin)) (x); +} +declare_mgen_alias (__sin, sin) diff --git a/sysdeps/m68k/m680x0/fpu/s_sincos.c b/sysdeps/m68k/m680x0/fpu/s_sincos.c index ca93d93333..9226798fd7 100644 --- a/sysdeps/m68k/m680x0/fpu/s_sincos.c +++ b/sysdeps/m68k/m680x0/fpu/s_sincos.c @@ -1,34 +1,2 @@ -/* Copyright (C) 1997-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - <http://www.gnu.org/licenses/>. */ - -#include <math.h> - -#ifndef FUNC -#define FUNC sincos -#endif -#ifndef float_type -#define float_type double -#endif - -#define CONCATX(a,b) __CONCAT(a,b) - -void -CONCATX(__,FUNC) (float_type x, float_type *sinx, float_type *cosx) -{ - __m81_u(CONCATX(__,FUNC))(x, sinx, cosx); -} -weak_alias (CONCATX(__,FUNC), FUNC) +#include <math-type-macros-double.h> +#include <s_sincos_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_sincos_template.c b/sysdeps/m68k/m680x0/fpu/s_sincos_template.c new file mode 100644 index 0000000000..017f01198a --- /dev/null +++ b/sysdeps/m68k/m680x0/fpu/s_sincos_template.c @@ -0,0 +1,26 @@ +/* Implement sincos for m68k. + Copyright (C) 1997-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> + +void +M_DECL_FUNC (__sincos) (FLOAT x, FLOAT *sinx, FLOAT *cosx) +{ + __m81_u(M_SUF (__sincos)) (x, sinx, cosx); +} +declare_mgen_alias (__sincos, sincos) diff --git a/sysdeps/m68k/m680x0/fpu/s_sincosf.c b/sysdeps/m68k/m680x0/fpu/s_sincosf.c index 7ee2ec6600..581388bdc6 100644 --- a/sysdeps/m68k/m680x0/fpu/s_sincosf.c +++ b/sysdeps/m68k/m680x0/fpu/s_sincosf.c @@ -1,3 +1,2 @@ -#define FUNC sincosf -#define float_type float -#include <s_sincos.c> +#include <math-type-macros-float.h> +#include <s_sincos_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_sincosl.c b/sysdeps/m68k/m680x0/fpu/s_sincosl.c index f998cc0977..6a88d3e88a 100644 --- a/sysdeps/m68k/m680x0/fpu/s_sincosl.c +++ b/sysdeps/m68k/m680x0/fpu/s_sincosl.c @@ -1,3 +1,2 @@ -#define FUNC sincosl -#define float_type long double -#include <s_sincos.c> +#include <math-type-macros-ldouble.h> +#include <s_sincos_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_sinf.c b/sysdeps/m68k/m680x0/fpu/s_sinf.c index 304f4f76f6..7868705d27 100644 --- a/sysdeps/m68k/m680x0/fpu/s_sinf.c +++ b/sysdeps/m68k/m680x0/fpu/s_sinf.c @@ -1,5 +1,2 @@ -#ifndef FUNC -# define FUNC sinf -#endif -#define float_type float -#include <s_sin.c> +#include <math-type-macros-float.h> +#include <s_sin_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_sinl.c b/sysdeps/m68k/m680x0/fpu/s_sinl.c index 31dac0bee7..f542d1b096 100644 --- a/sysdeps/m68k/m680x0/fpu/s_sinl.c +++ b/sysdeps/m68k/m680x0/fpu/s_sinl.c @@ -1,5 +1,2 @@ -#ifndef FUNC -# define FUNC sinl -#endif -#define float_type long double -#include <s_sin.c> +#include <math-type-macros-ldouble.h> +#include <s_sin_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_tan.c b/sysdeps/m68k/m680x0/fpu/s_tan.c index dfbbbb2270..c680a6b041 100644 --- a/sysdeps/m68k/m680x0/fpu/s_tan.c +++ b/sysdeps/m68k/m680x0/fpu/s_tan.c @@ -1,2 +1,2 @@ -#define FUNC tan -#include <s_sin.c> +#include <math-type-macros-double.h> +#include <s_tan_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_tan_template.c b/sysdeps/m68k/m680x0/fpu/s_tan_template.c new file mode 100644 index 0000000000..6291096111 --- /dev/null +++ b/sysdeps/m68k/m680x0/fpu/s_tan_template.c @@ -0,0 +1,30 @@ +/* Implement tan for m68k. + Copyright (C) 2012-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> +#include <errno.h> +#include "mathimpl.h" + +FLOAT +M_DECL_FUNC (__tan) (FLOAT x) +{ + if (__m81_test (x) & __M81_COND_INF) + __set_errno (EDOM); + return __m81_u(M_SUF (__tan)) (x); +} +declare_mgen_alias (__tan, tan) diff --git a/sysdeps/m68k/m680x0/fpu/s_tanf.c b/sysdeps/m68k/m680x0/fpu/s_tanf.c index 9ae66ddbf3..a95d4d757c 100644 --- a/sysdeps/m68k/m680x0/fpu/s_tanf.c +++ b/sysdeps/m68k/m680x0/fpu/s_tanf.c @@ -1,2 +1,2 @@ -#define FUNC tanf -#include <s_sinf.c> +#include <math-type-macros-float.h> +#include <s_tan_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_tanh.c b/sysdeps/m68k/m680x0/fpu/s_tanh.c index ac2e7dbb79..11d4bc4f71 100644 --- a/sysdeps/m68k/m680x0/fpu/s_tanh.c +++ b/sysdeps/m68k/m680x0/fpu/s_tanh.c @@ -1,2 +1,2 @@ -#define FUNC tanh -#include <s_atan.c> +#include <math-type-macros-double.h> +#include <s_tanh_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_tanh_template.c b/sysdeps/m68k/m680x0/fpu/s_tanh_template.c new file mode 100644 index 0000000000..6b591f1b37 --- /dev/null +++ b/sysdeps/m68k/m680x0/fpu/s_tanh_template.c @@ -0,0 +1,26 @@ +/* Implement tanh for m68k. + Copyright (C) 1996-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> + +FLOAT +M_DECL_FUNC (__tanh) (FLOAT x) +{ + return __m81_u(M_SUF (__tanh)) (x); +} +declare_mgen_alias (__tanh, tanh) diff --git a/sysdeps/m68k/m680x0/fpu/s_tanhf.c b/sysdeps/m68k/m680x0/fpu/s_tanhf.c index 1addaae4ff..40f45a2fd7 100644 --- a/sysdeps/m68k/m680x0/fpu/s_tanhf.c +++ b/sysdeps/m68k/m680x0/fpu/s_tanhf.c @@ -1,2 +1,2 @@ -#define FUNC tanhf -#include <s_atanf.c> +#include <math-type-macros-float.h> +#include <s_tanh_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_tanhl.c b/sysdeps/m68k/m680x0/fpu/s_tanhl.c index 6e997911f2..72f4d8f1bc 100644 --- a/sysdeps/m68k/m680x0/fpu/s_tanhl.c +++ b/sysdeps/m68k/m680x0/fpu/s_tanhl.c @@ -1,2 +1,2 @@ -#define FUNC tanhl -#include <s_atanl.c> +#include <math-type-macros-ldouble.h> +#include <s_tanh_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_tanl.c b/sysdeps/m68k/m680x0/fpu/s_tanl.c index 27daf8f29b..099dbfde7d 100644 --- a/sysdeps/m68k/m680x0/fpu/s_tanl.c +++ b/sysdeps/m68k/m680x0/fpu/s_tanl.c @@ -1,2 +1,2 @@ -#define FUNC tanl -#include <s_sinl.c> +#include <math-type-macros-ldouble.h> +#include <s_tan_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_trunc.c b/sysdeps/m68k/m680x0/fpu/s_trunc.c index 96f29a776c..a9f0c4b9db 100644 --- a/sysdeps/m68k/m680x0/fpu/s_trunc.c +++ b/sysdeps/m68k/m680x0/fpu/s_trunc.c @@ -1,2 +1,2 @@ -#define FUNC trunc -#include <s_atan.c> +#include <math-type-macros-double.h> +#include <s_trunc_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_trunc_template.c b/sysdeps/m68k/m680x0/fpu/s_trunc_template.c new file mode 100644 index 0000000000..9ed1e3d8e4 --- /dev/null +++ b/sysdeps/m68k/m680x0/fpu/s_trunc_template.c @@ -0,0 +1,26 @@ +/* Implement trunc for m68k. + Copyright (C) 1996-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> + +FLOAT +M_DECL_FUNC (__trunc) (FLOAT x) +{ + return __m81_u(M_SUF (__trunc)) (x); +} +declare_mgen_alias (__trunc, trunc) diff --git a/sysdeps/m68k/m680x0/fpu/s_truncf.c b/sysdeps/m68k/m680x0/fpu/s_truncf.c index 44dca748ca..65474c779b 100644 --- a/sysdeps/m68k/m680x0/fpu/s_truncf.c +++ b/sysdeps/m68k/m680x0/fpu/s_truncf.c @@ -1,2 +1,2 @@ -#define FUNC truncf -#include <s_atanf.c> +#include <math-type-macros-float.h> +#include <s_trunc_template.c> diff --git a/sysdeps/m68k/m680x0/fpu/s_truncl.c b/sysdeps/m68k/m680x0/fpu/s_truncl.c index 8d35777aed..cbb87540cf 100644 --- a/sysdeps/m68k/m680x0/fpu/s_truncl.c +++ b/sysdeps/m68k/m680x0/fpu/s_truncl.c @@ -1,2 +1,2 @@ -#define FUNC truncl -#include <s_atanl.c> +#include <math-type-macros-ldouble.h> +#include <s_trunc_template.c> |