@@ -43,6 +43,18 @@ libm-support = s_lib_version s_matherr s_signgam \
fesetenv feupdateenv t_exp fedisblxcpt feenablxcpt \
fegetexcept
+# These functions are generated from a common source with a select macros
+# for each type they built for. There is an explicit underscore between
+# the function name and the type suffix to simplify matching to the
+# rule used to build it. These all build from a common b_func.c file.
+#
+# Similarly, a platform can override any of these generated functions
+# (after type suffix substitution occurs) by adding a fragment which
+# defines libm-gen-calls-override and lists each function which should
+# not use the default version. If declared, it is assumed the target
+# will match the name s_<func><type suffix>
+gen-libm-calls = g_carg_F g_conj_F g_cimag_F g_creal_F g_cabs_F
+
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 +71,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 = w_lgamma_compatf w_lgamma_compat w_lgamma_compatl \
k_standardf k_standard k_standardl
@@ -104,7 +116,9 @@ type-float-routines :=
type-foreach = $(foreach t,$(types),$(subst F,$(type-$(t)-suffix),$(1)))
libm-routines = $(strip $(libm-support) $(libm-compat-calls) \
- $(call type-foreach, $(libm-calls)) \
+ $(filter-out $(libm-gen-calls-override), \
+ $(call type-foreach, $(libm-calls))) \
+ $(libm-gen-replacement-calls) \
$(foreach t, $(types), $(type-$(t)-routines))) \
# These functions are in libc instead of libm because __printf_fp
@@ -117,6 +131,9 @@ calls = s_isinfF s_isnanF s_finiteF s_copysignF s_modfF s_scalbnF s_frexpF \
generated += $(foreach s,.c .S,$(call type-foreach, $(calls:s_%=m_%$(s))))
routines = $(call type-foreach, $(calls))
+# Wrappers and what not are generated per type to keep the noise down.
+generated += $(foreach s,.c .S,$(call type-foreach,$(gen-libm-calls:%=%$(s))))
+
ifeq ($(build-mathvec),yes)
# We need to install libm.so as linker script
# for more comfortable use of vector math library.
@@ -302,6 +319,33 @@ endef
object-suffixes-left := $(all-object-suffixes)
include $(o-iterator)
+# Generated per-type files.
+#
+# Suffixes for each generated file. This hackery makes it possible
+# to correctly identify name of the templated file.
+gen-suffixes := $(foreach s,$(all-object-suffixes), \
+ $(foreach t,$(types),_$(type-$(t)-suffix)$s))
+
+# Declare the type for each build of the type-generic files.
+CPPFLAGS-mtype_l = -DM_TYPE=M_LDOUBLE
+CPPFLAGS-mtype_ = -DM_TYPE=M_DOUBLE
+CPPFLAGS-mtype_f = -DM_TYPE=M_FLOAT
+
+# One rule to build to them all.
+define o-iterator-doit
+$(objpfx)g_%$o: b_%.c $(before-compile); $$(compile-command.c)
+endef
+object-suffixes-left := $(gen-suffixes)
+include $(o-iterator)
+
+# And anther one to pass in the extra cpp flags to build them
+# correctly.
+define o-iterator-doit
+$(objpfx)g_%$o: CPPFLAGS += -include math-type-macros.h \
+ $(CPPFLAGS-mtype$(basename $o))
+endef
+object-suffixes-left := $(gen-suffixes)
+include $(o-iterator)
# This file defines the default _LIB_VERSION variable that controls
# the error return conventions for the math functions.
new file mode 100644
@@ -0,0 +1,33 @@
+/* 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.
+
+ 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
+M_SUF (__cabs) (CFLOAT z)
+{
+ return M_SUF (__hypot) (__real__ z, __imag__ z);
+}
+
+declare_mgen_alias (__cabs, cabs)
+
+#if M_LIBM_NEED_COMPAT (cabs)
+ declare_mgen_libm_compat (__cabs, cabs)
+#endif
new file mode 100644
@@ -0,0 +1,33 @@
+/* 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.
+
+ 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
+M_SUF (__carg) (CFLOAT x)
+{
+ return M_SUF (__atan2) (__imag__ x, __real__ x);
+}
+
+declare_mgen_alias (__carg, carg)
+
+#if M_LIBM_NEED_COMPAT (carg)
+ declare_mgen_libm_compat (__carg, carg)
+#endif
new file mode 100644
@@ -0,0 +1,32 @@
+/* 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.
+
+ 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
+M_SUF (__cimag) (CFLOAT z)
+{
+ return __imag__ z;
+}
+
+declare_mgen_alias (__cimag, cimag)
+
+#if M_LIBM_NEED_COMPAT (cimag)
+ declare_mgen_libm_compat (__cimag, cimag)
+#endif
new file mode 100644
@@ -0,0 +1,32 @@
+/* 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.
+
+ 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>
+
+CFLOAT
+M_SUF (__conj) (CFLOAT z)
+{
+ return ~z;
+}
+
+declare_mgen_alias (__conj, conj)
+
+#if M_LIBM_NEED_COMPAT (conj)
+ declare_mgen_libm_compat (__conj, conj)
+#endif
new file mode 100644
@@ -0,0 +1,32 @@
+/* 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.
+
+ 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
+M_SUF (__creal) (CFLOAT z)
+{
+ return __real__ z;
+}
+
+declare_mgen_alias (__creal, creal)
+
+#if M_LIBM_NEED_COMPAT (creal)
+ declare_mgen_libm_compat (__creal, creal)
+#endif
deleted file mode 100644
@@ -1,32 +0,0 @@
-/* Return the complex absolute value of 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>
-
-double
-__cabs (double _Complex z)
-{
- return __hypot (__real__ z, __imag__ z);
-}
-weak_alias (__cabs, cabs)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cabs, __cabsl)
-weak_alias (__cabs, cabsl)
-#endif
deleted file mode 100644
@@ -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)
deleted file mode 100644
@@ -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)
deleted file mode 100644
@@ -1,32 +0,0 @@
-/* Compute argument of complex 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>
-
-double
-__carg (__complex__ double x)
-{
- return __atan2 (__imag__ x, __real__ x);
-}
-weak_alias (__carg, carg)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__carg, __cargl)
-weak_alias (__carg, cargl)
-#endif
deleted file mode 100644
@@ -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)
deleted file mode 100644
@@ -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)
deleted file mode 100644
@@ -1,31 +0,0 @@
-/* Return imaginary part of complex 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>
-
-double
-__cimag (double _Complex z)
-{
- return __imag__ z;
-}
-weak_alias (__cimag, cimag)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__cimag, __cimagl)
-weak_alias (__cimag, cimagl)
-#endif
deleted file mode 100644
@@ -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)
deleted file mode 100644
@@ -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)
deleted file mode 100644
@@ -1,31 +0,0 @@
-/* Return complex conjugate of complex 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>
-
-double _Complex
-__conj (double _Complex z)
-{
- return ~z;
-}
-weak_alias (__conj, conj)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__conj, __conjl)
-weak_alias (__conj, conjl)
-#endif
deleted file mode 100644
@@ -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)
deleted file mode 100644
@@ -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)
deleted file mode 100644
@@ -1,31 +0,0 @@
-/* Return real part of complex 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>
-
-double
-__creal (double _Complex z)
-{
- return __real__ z;
-}
-weak_alias (__creal, creal)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__creal, __creall)
-weak_alias (__creal, creall)
-#endif
deleted file mode 100644
@@ -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)
deleted file mode 100644
@@ -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)
new file mode 100644
@@ -0,0 +1,4 @@
+# Inhibit generation of these math files as they are supplied via
+# the respectic s_*.c versions here.
+libm-gen-calls-override = g_cabs_f g_carg_f g_cimag_f g_creal_f g_conj_f
+libm-gen-replacement-calls = cabsf cargf cimagf crealf conjf
new file mode 100644
@@ -0,0 +1,108 @@
+/* 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
+
+#define M_FLOAT 1
+#define M_DOUBLE 2
+#define M_LDOUBLE 3
+
+#if M_TYPE == M_FLOAT
+# define M_PFX FLT
+# define M_LIT f
+# define M_SUF(c) c ## f
+# define FLOAT float
+# define CFLOAT __complex__ float
+#elif M_TYPE == M_DOUBLE
+# define M_PFX DBL
+# define M_LIT
+# define M_SUF(c) c
+# define FLOAT double
+# define CFLOAT __complex__ double
+#elif M_TYPE == M_LDOUBLE
+# define M_PFX LDBL
+# define M_LIT L
+# define M_SUF(c) c ## l
+# define FLOAT long double
+# define CFLOAT __complex__ long double
+#else
+# error Error: M_TYPE is not a known floating point type
+#endif
+
+/* Rules for aliasing the currently generated math files. */
+
+/* Aliasing rules for float are straight forward. */
+#if M_TYPE == M_FLOAT
+# define declare_mgen_alias(from, to) weak_alias (M_SUF (from), M_SUF (to))
+#endif
+
+/* Aliasing rules for double are sightly more
+ complicated.
+ 1. long double == double.
+ 2. long double used to be double.
+ 3. double has always been unique. */
+#if M_TYPE == M_DOUBLE
+# if defined NO_LONG_DOUBLE
+# define declare_mgen_alias(from, to) \
+ weak_alias (from, to) \
+ strong_alias (from, to ## l) \
+ weak_alias (from, to ## l)
+# else
+# define declare_mgen_alias(from, to) \
+ weak_alias (M_SUF (from), M_SUF (to))
+# endif
+#endif
+
+/* Slightly simpler for long double.
+ 1. long double used to be double.
+ 2. long double has always been unique. */
+#if M_TYPE == M_LDOUBLE
+# if defined LONG_DOUBLE_COMPAT_VERSION
+# define declare_mgen_alias(from, to) \
+ long_double_symbol (libm, from ## l, to ## l);
+# else
+# define declare_mgen_alias(from, to) \
+ weak_alias (M_SUF (from), M_SUF (to))
+# endif
+#endif
+
+#if ! defined declare_mgen_alias
+# error Alias rules not defined for M_TYPE
+#endif
+
+/* From case 2 for double, we may need to declare compat
+ aliases for double symbols mapping to long double.
+
+ This suffices for the majority of the complex functions.
+ More interesting cases need to be handled on a case by
+ case basis. */
+#if M_TYPE == M_DOUBLE && defined LONG_DOUBLE_COMPAT_VERSION
+# 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);
+#else
+# define M_LIBM_NEED_COMPAT(func) 0
+# define declare_mgen_libm_compat(from, to)
+#endif
+
+#endif /* _MATH_TYPE_MACROS */
deleted file mode 100644
@@ -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
deleted file mode 100644
@@ -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);
deleted file mode 100644
@@ -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
deleted file mode 100644
@@ -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);
deleted file mode 100644
@@ -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
deleted file mode 100644
@@ -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);
deleted file mode 100644
@@ -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
deleted file mode 100644
@@ -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);
deleted file mode 100644
@@ -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
deleted file mode 100644
@@ -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);
new file mode 100644
@@ -0,0 +1,11 @@
+/* Include the long double compatability support for generated math files. */
+#include <math_ldbl_opt.h>
+
+/* Declare compat versions for generated functions. */
+#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
+
+#include_next <math-type-macros.h>