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 | |
parent | c0535adfeb5aad46f622f040925889602a482f29 (diff) | |
download | glibc-e53df1dee841a206bf376373eb4250ce4f277e4b.zip glibc-e53df1dee841a206bf376373eb4250ce4f277e4b.tar.gz glibc-e53df1dee841a206bf376373eb4250ce4f277e4b.tar.bz2 |
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')
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 55e2631..a6f90d3 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 0000000..03da769 --- /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 c98559a..bc24155 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 b7e608a..28eea11 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 93d5ad7..70aeb73 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 0000000..945f7c1 --- /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 b3ba6a5..74e027e 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 2bf95b0..5188c24 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 2f1adf7..24e508e 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 0000000..56a5a75 --- /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 b6d6acc..fcfc844 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 eb61521..de8767c 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 c969a7f..e3abfbd 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 0000000..492cc87 --- /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 2cd8ffc..a360800 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 a2c8086..cfbab28 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 1f0631e..179a94a 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 0000000..5b74e4b --- /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 8f94219..9072d2a 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 8ac14d5..fa48f8a 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 e1219c6..339ae2c 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 0000000..542d8b8 --- /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 f4f9b9a..5d998e0 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 2c1ffd7..2295f99 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 009b1e3..be8db38 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 0000000..7f50887 --- /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 893b6ad..6cf7ceb 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 082618d..7eb2529 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 480c395..40f332f 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 a4f34a4..e580baf 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 d25a548..31440cf 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 0000000..efa00f1 --- /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 44924cb..77e753b 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 cd0bd23..a4670b8 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 3c1a5a2..1d1c0ea 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 0000000..b354e73 --- /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 0c44d7c..3d28880 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 c7075b3..9057645 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 b87f5e2..6af0d9b 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 0000000..4546378 --- /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 70d08ab..aefd7fc 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 230cd77..8516caf 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 554751c..b1d8f3a 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 0000000..fb5a096 --- /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 8a292fc..f2b8662 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 d236cfd..cb18d9e 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 f0f18c7..fa092c0 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 0000000..2589f9d --- /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 4e00cab..5cda19c 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 305667b..df393ee 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 34d4ea3..d43de6e 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 4e769ca..bbaa64b 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 8c6fc7e..f3496ee 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 953fb44..b52e804 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 0000000..c44d414 --- /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 ca93d93..9226798 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 0000000..017f011 --- /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 7ee2ec6..581388b 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 f998cc0..6a88d3e 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 304f4f7..7868705 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 31dac0b..f542d1b 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 dfbbbb2..c680a6b 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 0000000..6291096 --- /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 9ae66dd..a95d4d7 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 ac2e7db..11d4bc4 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 0000000..6b591f1 --- /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 1addaae..40f45a2 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 6e99791..72f4d8f 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 27daf8f..099dbfd 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 96f29a7..a9f0c4b 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 0000000..9ed1e3d --- /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 44dca74..65474c7 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 8d35777..cbb8754 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> |