diff options
Diffstat (limited to 'math')
-rw-r--r-- | math/Makefile | 24 | ||||
-rw-r--r-- | math/Versions | 7 | ||||
-rw-r--r-- | math/lgamma-compat.h | 73 | ||||
-rw-r--r-- | math/test-signgam-main.c | 71 | ||||
-rw-r--r-- | math/test-signgam-uchar-init-static.c | 1 | ||||
-rw-r--r-- | math/test-signgam-uchar-init.c | 3 | ||||
-rw-r--r-- | math/test-signgam-uchar-static.c | 1 | ||||
-rw-r--r-- | math/test-signgam-uchar.c | 3 | ||||
-rw-r--r-- | math/test-signgam-uint-init-static.c | 1 | ||||
-rw-r--r-- | math/test-signgam-uint-init.c | 3 | ||||
-rw-r--r-- | math/test-signgam-uint-static.c | 1 | ||||
-rw-r--r-- | math/test-signgam-uint.c | 3 | ||||
-rw-r--r-- | math/test-signgam-ullong-init-static.c | 1 | ||||
-rw-r--r-- | math/test-signgam-ullong-init.c | 3 | ||||
-rw-r--r-- | math/test-signgam-ullong-static.c | 1 | ||||
-rw-r--r-- | math/test-signgam-ullong.c | 3 | ||||
-rw-r--r-- | math/w_lgamma.c | 51 | ||||
-rw-r--r-- | math/w_lgamma_compat.c | 2 | ||||
-rw-r--r-- | math/w_lgamma_compatf.c | 2 | ||||
-rw-r--r-- | math/w_lgamma_compatl.c | 2 | ||||
-rw-r--r-- | math/w_lgamma_main.c | 59 | ||||
-rw-r--r-- | math/w_lgammaf.c | 42 | ||||
-rw-r--r-- | math/w_lgammaf_main.c | 44 | ||||
-rw-r--r-- | math/w_lgammal.c | 49 | ||||
-rw-r--r-- | math/w_lgammal_main.c | 51 |
25 files changed, 362 insertions, 139 deletions
diff --git a/math/Makefile b/math/Makefile index 06412f3980..0ff3baa19e 100644 --- a/math/Makefile +++ b/math/Makefile @@ -62,7 +62,8 @@ libm-calls = e_acos e_acosh e_asin e_atan2 e_atanh e_cosh e_exp e_fmod \ s_casinh s_cacosh s_catanh s_csqrt s_cpow s_cproj s_clog10 \ s_fma s_lrint s_llrint s_lround s_llround e_exp10 w_log2 \ s_issignaling $(calls:s_%=m_%) x2y2m1 k_casinh \ - gamma_product k_standard lgamma_neg lgamma_product + gamma_product k_standard lgamma_neg lgamma_product \ + w_lgamma_compat dbl-only-routines := branred doasin dosincos halfulp mpa mpatan2 \ mpatan mpexp mplog mpsqrt mptan sincos32 slowexp \ @@ -110,8 +111,13 @@ tests = test-matherr test-fenv atest-exp atest-sincos atest-exp2 basic-test \ test-fenv-tls test-fenv-preserve test-fenv-return test-fenvinline \ test-nearbyint-except test-fenv-clear test-signgam-finite \ test-signgam-finite-c99 test-signgam-finite-c11 \ - test-nearbyint-except-2 $(tests-static) -tests-static = test-fpucw-static test-fpucw-ieee-static + test-nearbyint-except-2 test-signgam-uchar test-signgam-uchar-init \ + test-signgam-uint test-signgam-uint-init test-signgam-ullong \ + test-signgam-ullong-init $(tests-static) +tests-static = test-fpucw-static test-fpucw-ieee-static \ + test-signgam-uchar-static test-signgam-uchar-init-static \ + test-signgam-uint-static test-signgam-uint-init-static \ + test-signgam-ullong-static test-signgam-ullong-init-static # We do the `long double' tests only if this data type is available and # distinct from `double'. test-longdouble-yes = test-ldouble test-ildoubl test-ldouble-finite @@ -200,6 +206,18 @@ CPPFLAGS-test-ildoubl.c = -U__LIBC_INTERNAL_MATH_INLINES \ CFLAGS-test-signgam-finite.c = -ffinite-math-only CFLAGS-test-signgam-finite-c99.c = -ffinite-math-only -std=c99 CFLAGS-test-signgam-finite-c11.c = -ffinite-math-only -std=c11 +CFLAGS-test-signgam-uchar.c = -std=c99 +CFLAGS-test-signgam-uchar-init.c = -std=c99 +CFLAGS-test-signgam-uchar-static.c = -std=c99 +CFLAGS-test-signgam-uchar-init-static.c = -std=c99 +CFLAGS-test-signgam-uint.c = -std=c99 +CFLAGS-test-signgam-uint-init.c = -std=c99 +CFLAGS-test-signgam-uint-static.c = -std=c99 +CFLAGS-test-signgam-uint-init-static.c = -std=c99 +CFLAGS-test-signgam-ullong.c = -std=c99 +CFLAGS-test-signgam-ullong-init.c = -std=c99 +CFLAGS-test-signgam-ullong-static.c = -std=c99 +CFLAGS-test-signgam-ullong-init-static.c = -std=c99 # The -lieee module sets the _LIB_VERSION_ switch to IEEE mode # for error handling in the -lm functions. diff --git a/math/Versions b/math/Versions index 551abec020..e6a597cf23 100644 --- a/math/Versions +++ b/math/Versions @@ -203,4 +203,11 @@ libm { GLIBC_2.18 { __issignaling; __issignalingf; __issignalingl; } + GLIBC_2.23 { + # The __signgam name must be exported for the signgam weak alias + # to work. New symbol versions of lgamma* that set __signgam are + # needed to preserve compatibility with old binaries that have a + # dynamic symbol for signgam but not __signgam. + lgamma; lgammaf; lgammal; __signgam; + } } diff --git a/math/lgamma-compat.h b/math/lgamma-compat.h new file mode 100644 index 0000000000..1393f0e1f5 --- /dev/null +++ b/math/lgamma-compat.h @@ -0,0 +1,73 @@ +/* ABI compatibility for lgamma functions. + Copyright (C) 2015 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 LGAMMA_COMPAT_H +#define LGAMMA_COMPAT_H 1 + +#include <shlib-compat.h> + +/* XSI POSIX requires lgamma to set signgam, but ISO C does not permit + this. Namespace issues can be avoided if the functions set + __signgam and signgam is a weak alias, but this only works if both + signgam and __signgam were exported from the glibc version the + program was linked against. Before glibc 2.23, lgamma functions + set signgam which was not a weak alias for __signgam, so old + binaries have dynamic symbols for signgam only and the versions of + lgamma used for old binaries must set both signgam and __signgam. + Those versions also do a check of _LIB_VERSION != _ISOC_ to match + old glibc. + + Users of this file define USE_AS_COMPAT to 0 when building the main + version of lgamma, 1 when building the compatibility version. */ + +#define LGAMMA_OLD_VER GLIBC_2_0 +#define LGAMMA_NEW_VER GLIBC_2_23 +#define HAVE_LGAMMA_COMPAT SHLIB_COMPAT (libm, LGAMMA_OLD_VER, LGAMMA_NEW_VER) + +/* Whether to build this version at all. */ +#define BUILD_LGAMMA (HAVE_LGAMMA_COMPAT || !USE_AS_COMPAT) + +/* The name to use for this version. */ +#if USE_AS_COMPAT +# define LGFUNC(FUNC) FUNC ## _compat +#else +# define LGFUNC(FUNC) FUNC +#endif + +/* If there is a compatibility version, gamma (not an ISO C function, + so never a problem for it to set signgam) points directly to it + rather than having separate versions. */ +#define GAMMA_ALIAS (USE_AS_COMPAT ? HAVE_LGAMMA_COMPAT : !HAVE_LGAMMA_COMPAT) + +/* How to call the underlying lgamma_r function. */ +#define CALL_LGAMMA(TYPE, FUNC, ARG) \ + ({ \ + TYPE lgamma_tmp; \ + int local_signgam; \ + if (USE_AS_COMPAT) \ + { \ + lgamma_tmp = FUNC ((ARG), &local_signgam); \ + if (_LIB_VERSION != _ISOC_) \ + signgam = __signgam = local_signgam; \ + } \ + else \ + lgamma_tmp = FUNC ((ARG), &__signgam); \ + lgamma_tmp; \ + }) + +#endif /* lgamma-compat.h. */ diff --git a/math/test-signgam-main.c b/math/test-signgam-main.c new file mode 100644 index 0000000000..6aed7f4f01 --- /dev/null +++ b/math/test-signgam-main.c @@ -0,0 +1,71 @@ +/* Test lgamma functions do not set signgam for ISO C. + Copyright (C) 2015 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/>. */ + +#undef _LIBC +#undef _GNU_SOURCE +#define _ISOMAC + +#include <math.h> +#include <stdio.h> + +#define INITVAL ((TYPE) -1 / 3) + +#if DO_INIT +TYPE signgam = INITVAL; +#else +TYPE signgam; +#endif + +#define RUN_TESTS(FUNC, TYPE) \ + do \ + { \ + volatile TYPE a, b, c __attribute__ ((unused)); \ + a = 0.5; \ + b = -0.5; \ + signgam = INITVAL; \ + c = FUNC (a); \ + if (signgam == INITVAL) \ + puts ("PASS: " #FUNC " (0.5) setting signgam"); \ + else \ + { \ + puts ("FAIL: " #FUNC " (0.5) setting signgam"); \ + result = 1; \ + } \ + signgam = INITVAL; \ + c = FUNC (b); \ + if (signgam == INITVAL) \ + puts ("PASS: " #FUNC " (-0.5) setting signgam"); \ + else \ + { \ + puts ("FAIL: " #FUNC " (-0.5) setting signgam"); \ + result = 1; \ + } \ + } \ + while (0) + +int +main (void) +{ + int result = 0; + RUN_TESTS (lgammaf, float); + RUN_TESTS (lgamma, double); +#ifndef NO_LONG_DOUBLE + RUN_TESTS (lgammal, long double); +#endif + return result; +} diff --git a/math/test-signgam-uchar-init-static.c b/math/test-signgam-uchar-init-static.c new file mode 100644 index 0000000000..43ac5026b6 --- /dev/null +++ b/math/test-signgam-uchar-init-static.c @@ -0,0 +1 @@ +#include "test-signgam-uchar-init.c" diff --git a/math/test-signgam-uchar-init.c b/math/test-signgam-uchar-init.c new file mode 100644 index 0000000000..4eea51e5ae --- /dev/null +++ b/math/test-signgam-uchar-init.c @@ -0,0 +1,3 @@ +#define TYPE unsigned char +#define DO_INIT 1 +#include "test-signgam-main.c" diff --git a/math/test-signgam-uchar-static.c b/math/test-signgam-uchar-static.c new file mode 100644 index 0000000000..a1e655dfb7 --- /dev/null +++ b/math/test-signgam-uchar-static.c @@ -0,0 +1 @@ +#include "test-signgam-uchar.c" diff --git a/math/test-signgam-uchar.c b/math/test-signgam-uchar.c new file mode 100644 index 0000000000..b613fd2ea1 --- /dev/null +++ b/math/test-signgam-uchar.c @@ -0,0 +1,3 @@ +#define TYPE unsigned char +#define DO_INIT 0 +#include "test-signgam-main.c" diff --git a/math/test-signgam-uint-init-static.c b/math/test-signgam-uint-init-static.c new file mode 100644 index 0000000000..1afb205ed2 --- /dev/null +++ b/math/test-signgam-uint-init-static.c @@ -0,0 +1 @@ +#include "test-signgam-uint-init.c" diff --git a/math/test-signgam-uint-init.c b/math/test-signgam-uint-init.c new file mode 100644 index 0000000000..e3d064fbb8 --- /dev/null +++ b/math/test-signgam-uint-init.c @@ -0,0 +1,3 @@ +#define TYPE unsigned int +#define DO_INIT 1 +#include "test-signgam-main.c" diff --git a/math/test-signgam-uint-static.c b/math/test-signgam-uint-static.c new file mode 100644 index 0000000000..0aa0c24a75 --- /dev/null +++ b/math/test-signgam-uint-static.c @@ -0,0 +1 @@ +#include "test-signgam-uint.c" diff --git a/math/test-signgam-uint.c b/math/test-signgam-uint.c new file mode 100644 index 0000000000..4ab783f111 --- /dev/null +++ b/math/test-signgam-uint.c @@ -0,0 +1,3 @@ +#define TYPE unsigned int +#define DO_INIT 0 +#include "test-signgam-main.c" diff --git a/math/test-signgam-ullong-init-static.c b/math/test-signgam-ullong-init-static.c new file mode 100644 index 0000000000..84e0a195fb --- /dev/null +++ b/math/test-signgam-ullong-init-static.c @@ -0,0 +1 @@ +#include "test-signgam-ullong-init.c" diff --git a/math/test-signgam-ullong-init.c b/math/test-signgam-ullong-init.c new file mode 100644 index 0000000000..f32957f879 --- /dev/null +++ b/math/test-signgam-ullong-init.c @@ -0,0 +1,3 @@ +#define TYPE unsigned long long int +#define DO_INIT 1 +#include "test-signgam-main.c" diff --git a/math/test-signgam-ullong-static.c b/math/test-signgam-ullong-static.c new file mode 100644 index 0000000000..13e43854be --- /dev/null +++ b/math/test-signgam-ullong-static.c @@ -0,0 +1 @@ +#include "test-signgam-ullong.c" diff --git a/math/test-signgam-ullong.c b/math/test-signgam-ullong.c new file mode 100644 index 0000000000..5d4f27e8a3 --- /dev/null +++ b/math/test-signgam-ullong.c @@ -0,0 +1,3 @@ +#define TYPE unsigned long long int +#define DO_INIT 0 +#include "test-signgam-main.c" diff --git a/math/w_lgamma.c b/math/w_lgamma.c index a82b5e397c..8bb33e0472 100644 --- a/math/w_lgamma.c +++ b/math/w_lgamma.c @@ -1,49 +1,2 @@ -/* @(#)w_lgamma.c 5.1 93/09/24 */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* double lgamma(double x) - * Return the logarithm of the Gamma function of x. - * - * Method: call __ieee754_lgamma_r - */ - -#include <math.h> -#include <math_private.h> - -double -__lgamma(double x) -{ - int local_signgam = 0; - double y = __ieee754_lgamma_r(x, - _LIB_VERSION != _ISOC_ - /* ISO C99 does not define the - global variable. */ - ? &signgam - : &local_signgam); - if(__builtin_expect(!isfinite(y), 0) - && isfinite(x) && _LIB_VERSION != _IEEE_) - return __kernel_standard(x, x, - __floor(x)==x&&x<=0.0 - ? 15 /* lgamma pole */ - : 14); /* lgamma overflow */ - - return y; -} -weak_alias (__lgamma, lgamma) -strong_alias (__lgamma, __gamma) -weak_alias (__gamma, gamma) -#ifdef NO_LONG_DOUBLE -strong_alias (__lgamma, __lgammal) -weak_alias (__lgamma, lgammal) -strong_alias (__gamma, __gammal) -weak_alias (__gamma, gammal) -#endif +#define USE_AS_COMPAT 0 +#include <w_lgamma_main.c> diff --git a/math/w_lgamma_compat.c b/math/w_lgamma_compat.c new file mode 100644 index 0000000000..30510a5eee --- /dev/null +++ b/math/w_lgamma_compat.c @@ -0,0 +1,2 @@ +#define USE_AS_COMPAT 1 +#include <w_lgamma_main.c> diff --git a/math/w_lgamma_compatf.c b/math/w_lgamma_compatf.c new file mode 100644 index 0000000000..e59586fe8a --- /dev/null +++ b/math/w_lgamma_compatf.c @@ -0,0 +1,2 @@ +#define USE_AS_COMPAT 1 +#include <w_lgammaf_main.c> diff --git a/math/w_lgamma_compatl.c b/math/w_lgamma_compatl.c new file mode 100644 index 0000000000..55ca3640b3 --- /dev/null +++ b/math/w_lgamma_compatl.c @@ -0,0 +1,2 @@ +#define USE_AS_COMPAT 1 +#include <w_lgammal_main.c> diff --git a/math/w_lgamma_main.c b/math/w_lgamma_main.c new file mode 100644 index 0000000000..cdea331f1a --- /dev/null +++ b/math/w_lgamma_main.c @@ -0,0 +1,59 @@ +/* @(#)w_lgamma.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* double lgamma(double x) + * Return the logarithm of the Gamma function of x. + * + * Method: call __ieee754_lgamma_r + */ + +#include <math.h> +#include <math_private.h> + +#include <lgamma-compat.h> + +#if BUILD_LGAMMA +double +LGFUNC (__lgamma) (double x) +{ + double y = CALL_LGAMMA (double, __ieee754_lgamma_r, x); + if(__builtin_expect(!isfinite(y), 0) + && isfinite(x) && _LIB_VERSION != _IEEE_) + return __kernel_standard(x, x, + __floor(x)==x&&x<=0.0 + ? 15 /* lgamma pole */ + : 14); /* lgamma overflow */ + + return y; +} +# if USE_AS_COMPAT +compat_symbol (libm, __lgamma_compat, lgamma, LGAMMA_OLD_VER); +# ifdef NO_LONG_DOUBLE +strong_alias (__lgamma_compat, __lgammal_compat) +compat_symbol (libm, __lgammal_compat, lgammal, LGAMMA_OLD_VER); +# endif +# else +versioned_symbol (libm, __lgamma, lgamma, LGAMMA_NEW_VER); +# ifdef NO_LONG_DOUBLE +strong_alias (__lgamma, __lgammal) +versioned_symbol (libm, __lgammal, lgammal, LGAMMA_NEW_VER); +# endif +# endif +# if GAMMA_ALIAS +strong_alias (LGFUNC (__lgamma), __gamma) +weak_alias (__gamma, gamma) +# ifdef NO_LONG_DOUBLE +strong_alias (__gamma, __gammal) +weak_alias (__gamma, gammal) +# endif +# endif +#endif diff --git a/math/w_lgammaf.c b/math/w_lgammaf.c index dac69dd32a..5fc402260c 100644 --- a/math/w_lgammaf.c +++ b/math/w_lgammaf.c @@ -1,40 +1,2 @@ -/* w_lgammaf.c -- float version of w_lgamma.c. - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include <math.h> -#include <math_private.h> - -float -__lgammaf(float x) -{ - int local_signgam = 0; - float y = __ieee754_lgammaf_r(x, - _LIB_VERSION != _ISOC_ - /* ISO C99 does not define the - global variable. */ - ? &signgam - : &local_signgam); - if(__builtin_expect(!isfinite(y), 0) - && isfinite(x) && _LIB_VERSION != _IEEE_) - return __kernel_standard_f(x, x, - __floorf(x)==x&&x<=0.0f - ? 115 /* lgamma pole */ - : 114); /* lgamma overflow */ - - return y; -} -weak_alias (__lgammaf, lgammaf) -strong_alias (__lgammaf, __gammaf) -weak_alias (__gammaf, gammaf) +#define USE_AS_COMPAT 0 +#include <w_lgammaf_main.c> diff --git a/math/w_lgammaf_main.c b/math/w_lgammaf_main.c new file mode 100644 index 0000000000..ba7ff0e573 --- /dev/null +++ b/math/w_lgammaf_main.c @@ -0,0 +1,44 @@ +/* w_lgammaf.c -- float version of w_lgamma.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include <math.h> +#include <math_private.h> + +#include <lgamma-compat.h> + +#if BUILD_LGAMMA +float +LGFUNC (__lgammaf) (float x) +{ + float y = CALL_LGAMMA (float, __ieee754_lgammaf_r, x); + if(__builtin_expect(!isfinite(y), 0) + && isfinite(x) && _LIB_VERSION != _IEEE_) + return __kernel_standard_f(x, x, + __floorf(x)==x&&x<=0.0f + ? 115 /* lgamma pole */ + : 114); /* lgamma overflow */ + + return y; +} +# if USE_AS_COMPAT +compat_symbol (libm, __lgammaf_compat, lgammaf, LGAMMA_OLD_VER); +# else +versioned_symbol (libm, __lgammaf, lgammaf, LGAMMA_NEW_VER); +# endif +# if GAMMA_ALIAS +strong_alias (LGFUNC (__lgammaf), __gammaf) +weak_alias (__gammaf, gammaf) +# endif +#endif diff --git a/math/w_lgammal.c b/math/w_lgammal.c index 8abe6a018f..78dd9c5808 100644 --- a/math/w_lgammal.c +++ b/math/w_lgammal.c @@ -1,47 +1,2 @@ -/* w_lgammal.c -- long double version of w_lgamma.c. - * Conversion to long double by Ulrich Drepper, - * Cygnus Support, drepper@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* long double lgammal(long double x) - * Return the logarithm of the Gamma function of x. - * - * Method: call __ieee754_lgammal_r - */ - -#include <math.h> -#include <math_private.h> - -long double -__lgammal(long double x) -{ - int local_signgam = 0; - long double y = __ieee754_lgammal_r(x, - _LIB_VERSION != _ISOC_ - /* ISO C99 does not define the - global variable. */ - ? &signgam - : &local_signgam); - if(__builtin_expect(!isfinite(y), 0) - && isfinite(x) && _LIB_VERSION != _IEEE_) - return __kernel_standard_l(x, x, - __floorl(x)==x&&x<=0.0L - ? 215 /* lgamma pole */ - : 214); /* lgamma overflow */ - - return y; -} -weak_alias (__lgammal, lgammal) -strong_alias (__lgammal, __gammal) -weak_alias (__gammal, gammal) +#define USE_AS_COMPAT 0 +#include <w_lgammal_main.c> diff --git a/math/w_lgammal_main.c b/math/w_lgammal_main.c new file mode 100644 index 0000000000..c3c41f6fff --- /dev/null +++ b/math/w_lgammal_main.c @@ -0,0 +1,51 @@ +/* w_lgammal.c -- long double version of w_lgamma.c. + * Conversion to long double by Ulrich Drepper, + * Cygnus Support, drepper@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* long double lgammal(long double x) + * Return the logarithm of the Gamma function of x. + * + * Method: call __ieee754_lgammal_r + */ + +#include <math.h> +#include <math_private.h> + +#include <lgamma-compat.h> + +#if BUILD_LGAMMA +long double +LGFUNC (__lgammal) (long double x) +{ + long double y = CALL_LGAMMA (long double, __ieee754_lgammal_r, x); + if(__builtin_expect(!isfinite(y), 0) + && isfinite(x) && _LIB_VERSION != _IEEE_) + return __kernel_standard_l(x, x, + __floorl(x)==x&&x<=0.0L + ? 215 /* lgamma pole */ + : 214); /* lgamma overflow */ + + return y; +} +# if USE_AS_COMPAT +compat_symbol (libm, __lgammal_compat, lgammal, LGAMMA_OLD_VER); +# else +versioned_symbol (libm, __lgammal, lgammal, LGAMMA_NEW_VER); +# endif +# if GAMMA_ALIAS +strong_alias (LGFUNC (__lgammal), __gammal) +weak_alias (__gammal, gammal) +# endif +#endif |