about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/math-type-macros-double.h45
-rw-r--r--sysdeps/generic/math-type-macros-float.h35
-rw-r--r--sysdeps/generic/math-type-macros-ldouble.h32
-rw-r--r--sysdeps/generic/math-type-macros.h121
-rw-r--r--sysdeps/ieee754/ldbl-opt/cabs.c6
-rw-r--r--sysdeps/ieee754/ldbl-opt/cabsl.c6
-rw-r--r--sysdeps/ieee754/ldbl-opt/carg.c6
-rw-r--r--sysdeps/ieee754/ldbl-opt/cargl.c6
-rw-r--r--sysdeps/ieee754/ldbl-opt/cimag.c6
-rw-r--r--sysdeps/ieee754/ldbl-opt/cimagl.c6
-rw-r--r--sysdeps/ieee754/ldbl-opt/conj.c6
-rw-r--r--sysdeps/ieee754/ldbl-opt/conjl.c6
-rw-r--r--sysdeps/ieee754/ldbl-opt/creal.c6
-rw-r--r--sysdeps/ieee754/ldbl-opt/creall.c6
-rw-r--r--sysdeps/ieee754/ldbl-opt/math-type-macros-double.h58
-rw-r--r--sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h29
16 files changed, 320 insertions, 60 deletions
diff --git a/sysdeps/generic/math-type-macros-double.h b/sysdeps/generic/math-type-macros-double.h
new file mode 100644
index 0000000000..4149b39a9b
--- /dev/null
+++ b/sysdeps/generic/math-type-macros-double.h
@@ -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
diff --git a/sysdeps/generic/math-type-macros-float.h b/sysdeps/generic/math-type-macros-float.h
new file mode 100644
index 0000000000..aab88fdfa5
--- /dev/null
+++ b/sysdeps/generic/math-type-macros-float.h
@@ -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
diff --git a/sysdeps/generic/math-type-macros-ldouble.h b/sysdeps/generic/math-type-macros-ldouble.h
new file mode 100644
index 0000000000..90773fa578
--- /dev/null
+++ b/sysdeps/generic/math-type-macros-ldouble.h
@@ -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
diff --git a/sysdeps/generic/math-type-macros.h b/sysdeps/generic/math-type-macros.h
new file mode 100644
index 0000000000..259cb9421f
--- /dev/null
+++ b/sysdeps/generic/math-type-macros.h
@@ -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 */
diff --git a/sysdeps/ieee754/ldbl-opt/cabs.c b/sysdeps/ieee754/ldbl-opt/cabs.c
deleted file mode 100644
index a181de2fa8..0000000000
--- a/sysdeps/ieee754/ldbl-opt/cabs.c
+++ /dev/null
@@ -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
diff --git a/sysdeps/ieee754/ldbl-opt/cabsl.c b/sysdeps/ieee754/ldbl-opt/cabsl.c
deleted file mode 100644
index b861633544..0000000000
--- a/sysdeps/ieee754/ldbl-opt/cabsl.c
+++ /dev/null
@@ -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);
diff --git a/sysdeps/ieee754/ldbl-opt/carg.c b/sysdeps/ieee754/ldbl-opt/carg.c
deleted file mode 100644
index 2ed358113c..0000000000
--- a/sysdeps/ieee754/ldbl-opt/carg.c
+++ /dev/null
@@ -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
diff --git a/sysdeps/ieee754/ldbl-opt/cargl.c b/sysdeps/ieee754/ldbl-opt/cargl.c
deleted file mode 100644
index 952dc60664..0000000000
--- a/sysdeps/ieee754/ldbl-opt/cargl.c
+++ /dev/null
@@ -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);
diff --git a/sysdeps/ieee754/ldbl-opt/cimag.c b/sysdeps/ieee754/ldbl-opt/cimag.c
deleted file mode 100644
index f8052581b3..0000000000
--- a/sysdeps/ieee754/ldbl-opt/cimag.c
+++ /dev/null
@@ -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
diff --git a/sysdeps/ieee754/ldbl-opt/cimagl.c b/sysdeps/ieee754/ldbl-opt/cimagl.c
deleted file mode 100644
index 112365e3ae..0000000000
--- a/sysdeps/ieee754/ldbl-opt/cimagl.c
+++ /dev/null
@@ -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);
diff --git a/sysdeps/ieee754/ldbl-opt/conj.c b/sysdeps/ieee754/ldbl-opt/conj.c
deleted file mode 100644
index e4edade05e..0000000000
--- a/sysdeps/ieee754/ldbl-opt/conj.c
+++ /dev/null
@@ -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
diff --git a/sysdeps/ieee754/ldbl-opt/conjl.c b/sysdeps/ieee754/ldbl-opt/conjl.c
deleted file mode 100644
index c98e0ed1c3..0000000000
--- a/sysdeps/ieee754/ldbl-opt/conjl.c
+++ /dev/null
@@ -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);
diff --git a/sysdeps/ieee754/ldbl-opt/creal.c b/sysdeps/ieee754/ldbl-opt/creal.c
deleted file mode 100644
index 0d1c93e640..0000000000
--- a/sysdeps/ieee754/ldbl-opt/creal.c
+++ /dev/null
@@ -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
diff --git a/sysdeps/ieee754/ldbl-opt/creall.c b/sysdeps/ieee754/ldbl-opt/creall.c
deleted file mode 100644
index 68fedd4ccd..0000000000
--- a/sysdeps/ieee754/ldbl-opt/creall.c
+++ /dev/null
@@ -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);
diff --git a/sysdeps/ieee754/ldbl-opt/math-type-macros-double.h b/sysdeps/ieee754/ldbl-opt/math-type-macros-double.h
new file mode 100644
index 0000000000..8cb569454e
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/math-type-macros-double.h
@@ -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
diff --git a/sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h b/sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h
new file mode 100644
index 0000000000..d2af4bbcc0
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/math-type-macros-ldouble.h
@@ -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