Support for type-generic libm function implementations libm

This defines a new classes of libm objects.  The
<func>_template.c file which is used in conjunction
with the new makefile hooks to derive variants for
each type supported by the target machine.

The headers math-type-macros-TYPE.h are used to supply
macros to a common implementation of a function in
a file named FUNC_template.c and glued togethor via
a generated file matching existing naming in the
build directory.

This has the properties of preserving the existing
override mechanism and not requiring any arcane
build system twiddling.  Likewise, it enables machines
to override these files without any additional work.

I have verified the built objects for ppc64, x86_64,
alpha, arm, and m68k do not change in any meaningful
way with these changes using the Fedora cross toolchains.
I have verified the x86_64 and ppc64 changes still run.
This commit is contained in:
Paul E. Murphy 2016-06-14 11:44:14 -05:00
parent 1f645571d2
commit ce6698ea0a
33 changed files with 441 additions and 373 deletions

View File

@ -1,3 +1,53 @@
2016-08-17 Paul E. Murphy <murphyp@linux.vnet.ibm.com>
* math/Makefile: (gen-libm-templates.stmp): New rule.
(libm-calls): Move carg conj cimag and cabs into ...
(gen-libm-calls): New variable.
(generated): Inform Make objects from gen-libm-calls
may be generated.
* sysdeps/generic/math-type-macros.h: New file.
* sysdeps/generic/math-type-macros-float.h: Likewise.
* sysdeps/generic/math-type-macros-double.h: Likewise.
* sysdeps/generic/math-type-macros-ldouble.h: Likewise.
* sysdeps/ieee754/ldbl-opt/math-type-macros-double.h: Likewise.
* sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h: Likewise.
* math/cabs.c: Refactor into
* math/cabs_template.c: new file.
* math/cabsf.c: Removed.
* math/cabsl.c: Removed.
* sysdeps/ieee754/ldbl-opt/cabsf.c: Removed.
* sysdeps/ieee754/ldbl-opt/cabsl.c: Removed.
* math/carg.c: Refactor into
* math/carg_template.c: new file.
* math/cargf.c: Removed.
* math/cargl.c: Removed.
* sysdeps/ieee754/ldbl-opt/cargf.c: Removed.
* sysdeps/ieee754/ldbl-opt/cargl.c: Removed.
* math/conj.c: Refactor into
* math/conj_template.c: new file.
* math/conjf.c: Removed.
* math/conjl.c: Removed.
* sysdeps/ieee754/ldbl-opt/conjf.c: Removed.
* sysdeps/ieee754/ldbl-opt/conjl.c: Removed.
* math/cimag.c: Refactor into
* math/cimag_template.c: new file.
* math/cimagf.c: Removed.
* math/cimagl.c: Removed.
* sysdeps/ieee754/ldbl-opt/cimagf.c: Removed.
* sysdeps/ieee754/ldbl-opt/cimagl.c: Removed.
* math/cimag.c: Refactor into
* math/cimag_template.c: new file.
* math/cimagf.c: Removed.
* math/cimagl.c: Removed.
* sysdeps/ieee754/ldbl-opt/cimagf.c: Removed.
* sysdeps/ieee754/ldbl-opt/cimagl.c: Removed.
2016-08-17 Florian Weimer <fweimer@redhat.com>
Reduce time to expected nptl/tst-once5 failure.

View File

@ -43,6 +43,10 @@ libm-support = s_lib_version s_matherr s_signgam \
fesetenv feupdateenv t_exp fedisblxcpt feenablxcpt \
fegetexcept fesetexcept
# Wrappers for these functions generated per type using a file named
# <func>_template.c and the appropriate math-type-macros-<TYPE>.h.
gen-libm-calls = cargF conjF cimagF crealF cabsF
libm-calls = \
e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
e_hypotF e_j0F e_j1F e_jnF e_lgammaF_r e_logF e_log10F e_powF \
@ -59,13 +63,13 @@ libm-calls = \
w_ilogbF \
s_fpclassifyF s_fmaxF s_fminF s_fdimF s_nanF s_truncF \
s_remquoF e_log2F e_exp2F s_roundF s_nearbyintF s_sincosF \
conjF cimagF crealF cabsF cargF s_cexpF s_csinhF s_ccoshF s_clogF \
s_cexpF s_csinhF s_ccoshF s_clogF \
s_catanF s_casinF s_ccosF s_csinF s_ctanF s_ctanhF s_cacosF \
s_casinhF s_cacoshF s_catanhF s_csqrtF s_cpowF s_cprojF s_clog10F \
s_fmaF s_lrintF s_llrintF s_lroundF s_llroundF e_exp10F w_log2F \
s_issignalingF $(calls:s_%=m_%) x2y2m1F k_casinhF \
gamma_productF lgamma_negF lgamma_productF \
s_nextupF s_nextdownF
s_nextupF s_nextdownF $(gen-libm-calls)
libm-compat-calls-ldouble-yes = w_lgamma_compatl k_standardl
libm-compat-calls = w_lgamma_compatf w_lgamma_compat k_standard k_standardf \
@ -265,6 +269,29 @@ extra-objs += libieee.a ieee-math.o
include ../Rules
generated += $(addsuffix .c,$(call type-foreach,$(gen-libm-calls))) \
gen-libm-templates.stmp
# Create wrappers in the math build directory.
$(objpfx)gen-libm-templates.stmp:
for gcall in $(gen-libm-calls); do \
func=$${gcall%F*}$${gcall#*F}; \
for type in $(foreach t,$(types),$(t)__$(type-$(t)-suffix)); do \
suff=$${type#*__}; \
type=$${type%__*}; \
file=$(objpfx)$${gcall%F*}$${suff}$${gcall#*F}.c; \
( \
echo "#include <math-type-macros-$${type}.h>"; \
echo "#include <$${func}_template.c>"; \
) > $${file}; \
done; \
done; \
echo > $(@)
# Add dependency to ensure the generator runs prior.
$(foreach t, $(call type-foreach, $(gen-libm-calls)), \
$(objpfx)$(t).c): $(objpfx)gen-libm-templates.stmp
ifneq (no,$(PERL))
# This must come after the inclusion of sysdeps Makefiles via Rules.
$(addprefix $(objpfx), $(libm-tests.o)): $(objpfx)libm-test.stmp

View File

@ -1,4 +1,4 @@
/* Return the complex absolute value of double complex value.
/* Return the complex absolute value of complex float type.
Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@ -20,13 +20,14 @@
#include <complex.h>
#include <math.h>
double
__cabs (double _Complex z)
FLOAT
M_DECL_FUNC (__cabs) (CFLOAT z)
{
return __hypot (__real__ z, __imag__ z);
return M_SUF (__hypot) (__real__ z, __imag__ z);
}
weak_alias (__cabs, cabs)
#ifdef NO_LONG_DOUBLE
strong_alias (__cabs, __cabsl)
weak_alias (__cabs, cabsl)
declare_mgen_alias (__cabs, cabs)
#if M_LIBM_NEED_COMPAT (cabs)
declare_mgen_libm_compat (__cabs, cabs)
#endif

View File

@ -1,28 +0,0 @@
/* Return the complex absolute value of float complex value.
Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <complex.h>
#include <math.h>
float
__cabsf (float _Complex z)
{
return __hypotf (__real__ z, __imag__ z);
}
weak_alias (__cabsf, cabsf)

View File

@ -1,28 +0,0 @@
/* Return the complex absolute value of long double complex value.
Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <complex.h>
#include <math.h>
long double
__cabsl (long double _Complex z)
{
return __hypotl (__real__ z, __imag__ z);
}
weak_alias (__cabsl, cabsl)

View File

@ -1,4 +1,4 @@
/* Compute argument of complex double value.
/* Compute argument of complex float type.
Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@ -20,13 +20,14 @@
#include <complex.h>
#include <math.h>
double
__carg (__complex__ double x)
FLOAT
M_DECL_FUNC (__carg) (CFLOAT x)
{
return __atan2 (__imag__ x, __real__ x);
return M_SUF (__atan2) (__imag__ x, __real__ x);
}
weak_alias (__carg, carg)
#ifdef NO_LONG_DOUBLE
strong_alias (__carg, __cargl)
weak_alias (__carg, cargl)
declare_mgen_alias (__carg, carg)
#if M_LIBM_NEED_COMPAT (carg)
declare_mgen_libm_compat (__carg, carg)
#endif

View File

@ -1,28 +0,0 @@
/* Compute argument of complex float value.
Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <complex.h>
#include <math.h>
float
__cargf (__complex__ float x)
{
return __atan2f (__imag__ x, __real__ x);
}
weak_alias (__cargf, cargf)

View File

@ -1,28 +0,0 @@
/* Compute argument of complex long double value.
Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <complex.h>
#include <math.h>
long double
__cargl (__complex__ long double x)
{
return __atan2l (__imag__ x, __real__ x);
}
weak_alias (__cargl, cargl)

View File

@ -1,4 +1,4 @@
/* Return imaginary part of complex double value.
/* Return imaginary part of complex float type.
Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@ -19,13 +19,14 @@
#include <complex.h>
double
__cimag (double _Complex z)
FLOAT
M_DECL_FUNC (__cimag) (CFLOAT z)
{
return __imag__ z;
}
weak_alias (__cimag, cimag)
#ifdef NO_LONG_DOUBLE
strong_alias (__cimag, __cimagl)
weak_alias (__cimag, cimagl)
declare_mgen_alias (__cimag, cimag)
#if M_LIBM_NEED_COMPAT (cimag)
declare_mgen_libm_compat (__cimag, cimag)
#endif

View File

@ -1,27 +0,0 @@
/* Return imaginary part of complex float value.
Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <complex.h>
float
__cimagf (float _Complex z)
{
return __imag__ z;
}
weak_alias (__cimagf, cimagf)

View File

@ -1,27 +0,0 @@
/* Return imaginary part of complex long double value.
Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <complex.h>
long double
__cimagl (long double _Complex z)
{
return __imag__ z;
}
weak_alias (__cimagl, cimagl)

View File

@ -1,4 +1,4 @@
/* Return complex conjugate of complex double value.
/* Return complex conjugate of complex float type.
Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@ -19,13 +19,14 @@
#include <complex.h>
double _Complex
__conj (double _Complex z)
CFLOAT
M_DECL_FUNC (__conj) (CFLOAT z)
{
return ~z;
}
weak_alias (__conj, conj)
#ifdef NO_LONG_DOUBLE
strong_alias (__conj, __conjl)
weak_alias (__conj, conjl)
declare_mgen_alias (__conj, conj)
#if M_LIBM_NEED_COMPAT (conj)
declare_mgen_libm_compat (__conj, conj)
#endif

View File

@ -1,27 +0,0 @@
/* Return complex conjugate of complex float value.
Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <complex.h>
float _Complex
__conjf (float _Complex z)
{
return ~z;
}
weak_alias (__conjf, conjf)

View File

@ -1,27 +0,0 @@
/* Return complex conjugate of complex long double value.
Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <complex.h>
long double _Complex
__conjl (long double _Complex z)
{
return ~z;
}
weak_alias (__conjl, conjl)

View File

@ -1,4 +1,4 @@
/* Return real part of complex double value.
/* Return real part of complex float type.
Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@ -19,13 +19,14 @@
#include <complex.h>
double
__creal (double _Complex z)
FLOAT
M_DECL_FUNC (__creal) (CFLOAT z)
{
return __real__ z;
}
weak_alias (__creal, creal)
#ifdef NO_LONG_DOUBLE
strong_alias (__creal, __creall)
weak_alias (__creal, creall)
declare_mgen_alias (__creal, creal)
#if M_LIBM_NEED_COMPAT (creal)
declare_mgen_libm_compat (__creal, creal)
#endif

View File

@ -1,27 +0,0 @@
/* Return real part of complex float value.
Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <complex.h>
float
__crealf (float _Complex z)
{
return __real__ z;
}
weak_alias (__crealf, crealf)

View File

@ -1,27 +0,0 @@
/* Return real part of complex long double value.
Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
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 <complex.h>
long double
__creall (long double _Complex z)
{
return __real__ z;
}
weak_alias (__creall, creall)

View File

@ -0,0 +1,45 @@
/* Helper macros for double variants of type generic functions of libm.
Copyright (C) 2016 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/>. */
#ifndef _MATH_TYPE_MACROS_DOUBLE
#define _MATH_TYPE_MACROS_DOUBLE
#define M_LIT(c) c
#define M_MLIT(c) c
#define M_PFX DBL
#define M_SUF(c) c
#define FLOAT double
#define CFLOAT _Complex double
/* Machines without a distinct long double type
alias long double functions to their double
equivalent. */
#if defined NO_LONG_DOUBLE
# define declare_mgen_alias(from, to) \
weak_alias (from, to) \
strong_alias (from, from ## l) \
weak_alias (from, to ## l)
#else
# define declare_mgen_alias(from, to) \
weak_alias (M_SUF (from), M_SUF (to))
#endif
/* Supply the generic macros. */
#include <math-type-macros.h>
#endif

View File

@ -0,0 +1,35 @@
/* Helper macros for float variants of type generic functions of libm.
Copyright (C) 2016 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/>. */
#ifndef _MATH_TYPE_MACROS_FLOAT
#define _MATH_TYPE_MACROS_FLOAT
#define M_LIT(c) c ## f
#define M_PFX FLT
#define M_SUF(c) c ## f
#define FLOAT float
#define CFLOAT _Complex float
/* Standard/GNU macro literals do not exist for the float type. Use
the double macro constants. */
#define M_MLIT(c) c
/* Supply the generic macros. */
#include <math-type-macros.h>
#endif

View File

@ -0,0 +1,32 @@
/* Helper macros for long double variants of type generic functions of libm.
Copyright (C) 2016 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/>. */
#ifndef _MATH_TYPE_MACROS_LDOUBLE
#define _MATH_TYPE_MACROS_LDOUBLE
#define M_LIT(c) c ## L
#define M_MLIT(c) c ## l
#define M_PFX LDBL
#define M_SUF(c) c ## l
#define FLOAT long double
#define CFLOAT _Complex long double
/* Supply the generic macros. */
#include <math-type-macros.h>
#endif

View File

@ -0,0 +1,121 @@
/* Helper macros for type generic function implementations within libm.
Copyright (C) 2016 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/>. */
#ifndef _MATH_TYPE_MACROS
#define _MATH_TYPE_MACROS
/* Each type imports a header which is expected to
define:
M_LIT(x) - Paste the type specific suffix onto the constant x.
M_MLIT(x) - Paste the type specific suffix used by the macro
constants in math.h, i.e M_PI or M_PIl.
M_PFX - The prefixed used by float.h macros like FLT_MANT_DIG.
M_SUF(x) - Paste the the type specific suffix used by functions
i.e expf expl exp.
FLOAT - Resolves to the C typename of M_TYPE.
CFLOAT - Resolves to the complex typename of M_TYPE.
Optionally, these headers may inject a non-standard
definition for the following:
declare_mgen_alias(from,to)
This exposes the appropriate symbol(s) for a
function f of type FLOAT.
M_LIBM_NEED_COMPAT(func)
This is utilized in macro context to indicate
whether func should declare compat symbols.
declare_mgen_libm_compat(from,to)
This is used in conjunction with the above macro
outside of macro context to paste whatever is
required to generate a compat symbol. */
#ifndef M_PFX
# error "M_PFX must be defined."
#endif
#ifndef M_LIT
# error "M_LIT must be defined."
#endif
#ifndef M_MLIT
# error "M_MLIT must be defined."
#endif
#ifndef M_SUF
# error "M_SUF must be defined."
#endif
#ifndef FLOAT
# error "FLOAT must be defined."
#endif
#ifndef CFLOAT
# error "CFLOAT must be defined."
#endif
#define __M_CONCAT(a,b) a ## b
#define __M_CONCATX(a,b) __M_CONCAT(a,b)
#define M_NAN M_SUF (__nan) ("")
#define M_MAX_EXP __M_CONCATX (M_PFX, _MAX_EXP)
#define M_MIN __M_CONCATX (M_PFX, _MIN)
#define M_MAX __M_CONCATX (M_PFX, _MAX)
#define M_MANT_DIG __M_CONCATX (M_PFX, _MANT_DIG)
#define M_HUGE_VAL (M_SUF (__builtin_huge_val) ())
/* Helper macros for commonly used functions. */
#define M_COPYSIGN M_SUF (__copysign)
#define M_FABS M_SUF (fabs)
#define M_SINCOS M_SUF (__sincos)
#define M_SCALBN M_SUF (__scalbn)
#define M_LOG1P M_SUF (__log1p)
#define M_ATAN2 M_SUF (__ieee754_atan2)
#define M_COSH M_SUF (__ieee754_cosh)
#define M_EXP M_SUF (__ieee754_exp)
#define M_HYPOT M_SUF (__ieee754_hypot)
#define M_LOG M_SUF (__ieee754_log)
#define M_SINH M_SUF (__ieee754_sinh)
#define M_SQRT M_SUF (__ieee754_sqrt)
/* Needed to evaluate M_MANT_DIG below. */
#include <float.h>
/* Use a special epsilon value for IBM long double
to avoid spurious overflows/underflows. */
#if M_MANT_DIG != 106
# define M_EPSILON __M_CONCATX (M_PFX, _EPSILON)
#else
# define M_EPSILON M_LIT (0x1p-106)
#endif
/* Enable overloading of function name to assist reuse. */
#ifndef M_DECL_FUNC
# define M_DECL_FUNC(f) M_SUF (f)
#endif
/* If the type does not declare special aliasing, use the default. */
#ifndef declare_mgen_alias
# define declare_mgen_alias(from, to) weak_alias (M_SUF (from), M_SUF (to))
#endif
/* Do not generate anything for compat symbols by default. */
#ifndef M_LIBM_NEED_COMPAT
# define M_LIBM_NEED_COMPAT(func) 0
# define declare_mgen_libm_compat(from, to)
#endif
#endif /* _MATH_TYPE_MACROS */

View File

@ -1,6 +0,0 @@
#include <complex.h>
#include <math_ldbl_opt.h>
#include <math/cabs.c>
#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
compat_symbol (libm, __cabs, cabsl, GLIBC_2_1);
#endif

View File

@ -1,6 +0,0 @@
#include <complex.h>
#include <math_ldbl_opt.h>
#undef weak_alias
#define weak_alias(n,a)
#include <math/cabsl.c>
long_double_symbol (libm, __cabsl, cabsl);

View File

@ -1,6 +0,0 @@
#include <complex.h>
#include <math_ldbl_opt.h>
#include <math/carg.c>
#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
compat_symbol (libm, __carg, cargl, GLIBC_2_1);
#endif

View File

@ -1,6 +0,0 @@
#include <complex.h>
#include <math_ldbl_opt.h>
#undef weak_alias
#define weak_alias(n,a)
#include <math/cargl.c>
long_double_symbol (libm, __cargl, cargl);

View File

@ -1,6 +0,0 @@
#include <complex.h>
#include <math_ldbl_opt.h>
#include <math/cimag.c>
#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
compat_symbol (libm, __cimag, cimagl, GLIBC_2_1);
#endif

View File

@ -1,6 +0,0 @@
#include <complex.h>
#include <math_ldbl_opt.h>
#undef weak_alias
#define weak_alias(n,a)
#include <math/cimagl.c>
long_double_symbol (libm, __cimagl, cimagl);

View File

@ -1,6 +0,0 @@
#include <complex.h>
#include <math_ldbl_opt.h>
#include <math/conj.c>
#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
compat_symbol (libm, __conj, conjl, GLIBC_2_1);
#endif

View File

@ -1,6 +0,0 @@
#include <complex.h>
#include <math_ldbl_opt.h>
#undef weak_alias
#define weak_alias(n,a)
#include <math/conjl.c>
long_double_symbol (libm, __conjl, conjl);

View File

@ -1,6 +0,0 @@
#include <complex.h>
#include <math_ldbl_opt.h>
#include <math/creal.c>
#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
compat_symbol (libm, __creal, creall, GLIBC_2_1);
#endif

View File

@ -1,6 +0,0 @@
#include <complex.h>
#include <math_ldbl_opt.h>
#undef weak_alias
#define weak_alias(n,a)
#include <math/creall.c>
long_double_symbol (libm, __creall, creall);

View File

@ -0,0 +1,58 @@
/* Overrides for ldbl-opt versioning for double types.
Copyright (C) 2016 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/>. */
#ifndef _MATH_TYPE_MACROS_DOUBLE
#include <math_ldbl_opt.h>
#define LDOUBLE_cabsl_libm_version GLIBC_2_1
#define LDOUBLE_cargl_libm_version GLIBC_2_1
#define LDOUBLE_cimagl_libm_version GLIBC_2_1
#define LDOUBLE_conjl_libm_version GLIBC_2_1
#define LDOUBLE_creall_libm_version GLIBC_2_1
#define LDOUBLE_cacosl_libm_version GLIBC_2_1
#define LDOUBLE_cacoshl_libm_version GLIBC_2_1
#define LDOUBLE_ccosl_libm_version GLIBC_2_1
#define LDOUBLE_ccoshl_libm_version GLIBC_2_1
#define LDOUBLE_casinl_libm_version GLIBC_2_1
#define LDOUBLE_csinl_libm_version GLIBC_2_1
#define LDOUBLE_casinhl_libm_version GLIBC_2_1
#define LDOUBLE_csinhl_libm_version GLIBC_2_1
#define LDOUBLE_catanl_libm_version GLIBC_2_1
#define LDOUBLE_catanhl_libm_version GLIBC_2_1
#define LDOUBLE_ctanl_libm_version GLIBC_2_1
#define LDOUBLE_ctanhl_libm_version GLIBC_2_1
#define LDOUBLE_cexpl_libm_version GLIBC_2_1
#define LDOUBLE_clogl_libm_version GLIBC_2_1
#define LDOUBLE_cprojl_libm_version GLIBC_2_1
#define LDOUBLE_csqrtl_libm_version GLIBC_2_1
#define LDOUBLE_cpowl_libm_version GLIBC_2_1
#define LDOUBLE_clog10l_libm_version GLIBC_2_1
#define LDOUBLE___clog10l_libm_version GLIBC_2_1
/* Define compat symbols for long double on platforms
where it was not always a distinct type. */
#define M_LIBM_NEED_COMPAT(f) \
LONG_DOUBLE_COMPAT (libm, LDOUBLE_ ## f ## l_libm_version)
#define declare_mgen_libm_compat(from, to) \
compat_symbol (libm, from, to ## l, \
LDOUBLE_ ## to ## l_libm_version);
#include_next <math-type-macros-double.h>
#endif

View File

@ -0,0 +1,29 @@
/* Overrides for ldbl-opt versioning for long double types.
Copyright (C) 2016 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/>. */
#ifndef _MATH_TYPE_MACROS_LDOUBLE
#include <math_ldbl_opt.h>
/* Use properly versioned symbols for long double on platforms where
it was not always a distinct type. */
#define declare_mgen_alias(from, to) \
long_double_symbol (libm, from ## l, to ## l);
#include_next <math-type-macros-ldouble.h>
#endif