diff options
author | Roland McGrath <roland@gnu.org> | 1996-06-05 01:07:21 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1996-06-05 01:07:21 +0000 |
commit | ee188d555b8c32ad9704a7440cab400af967292f (patch) | |
tree | 037a4821d35c11f2bbf89e7e71dc43dada67b166 /sysdeps | |
parent | f68b86cc7bdcee246296d49f3a3318c1b97693f0 (diff) | |
download | glibc-ee188d555b8c32ad9704a7440cab400af967292f.zip glibc-ee188d555b8c32ad9704a7440cab400af967292f.tar.gz glibc-ee188d555b8c32ad9704a7440cab400af967292f.tar.bz2 |
Tue Jun 4 21:01:20 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* sysdeps/mach/hurd/getlogin_r.c: New file.
Wed Jun 5 02:11:30 1996 Ulrich Drepper <drepper@cygnus.com>
* io/Makefile (routines): Add ttyname_r.
* resolv/res_debug.c, resolv/resolv.h: Update from bind-4.3.4-T4A.
* sysdeps/libm-i387/e_asinl.S, sysdeps/libm-i387/e_atan2l.S,
sysdeps/libm-i387/e_expl.S, sysdeps/libm-i387/e_fmodl.S,
sysdeps/libm-i387/e_log10l.S, sysdeps/libm-i387/e_logl.S,
sysdeps/libm-i387/e_remainderl.S, sysdeps/libm-i387/e_scalbl.S,
sysdeps/libm-i387/e_sqrtl.S, sysdeps/libm-i387/s_atanl.S,
sysdeps/libm-i387/s_cosl.S, sysdeps/libm-i387/s_ilogbl.S,
sysdeps/libm-i387/s_log1pl.S, sysdeps/libm-i387/s_logbl.S,
sysdeps/libm-i387/s_scalbnl.S, sysdeps/libm-i387/s_sinl.S,
sysdeps/libm-i387/s_tanl.S: New files. i387 assembler versions
of `long double' math functions.
* sysdeps/libm-ieee754/k_standard.c: Add handling for errors
in long double functions.
* sysdeps/libm-ieee754/s_ilogbl.c, sysdeps/libm-ieee754/s_logbl.c,
sysdeps/libm-ieee754/s_modfl.c: New files. Generic versions
of `long double' math functions.
* sysdeps/libm-ieee754/s_isinf.c [NO_LONG_DOUBLE]: Add string
alias for __isinfl.
* sysdeps/libm-ieee754/w_acoshl.c, sysdeps/libm-ieee754/w_acosl.c,
sysdeps/libm-ieee754/w_asinl.c, sysdeps/libm-ieee754/w_atan2l.c,
sysdeps/libm-ieee754/w_atanhl.c, sysdeps/libm-ieee754/w_cabsl.c,
sysdeps/libm-ieee754/w_coshl.c, sysdeps/libm-ieee754/w_dreml.c,
sysdeps/libm-ieee754/w_expl.c, sysdeps/libm-ieee754/w_fmodl.c,
sysdeps/libm-ieee754/w_gammal.c, sysdeps/libm-ieee754/w_gammal_r.c,
sysdeps/libm-ieee754/w_hypotl.c, sysdeps/libm-ieee754/w_j0l.c,
sysdeps/libm-ieee754/w_j1l.c, sysdeps/libm-ieee754/w_jnl.c,
sysdeps/libm-ieee754/w_lgammal.c, sysdeps/libm-ieee754/w_lgammal_r.c,
sysdeps/libm-ieee754/w_log10l.c, sysdeps/libm-ieee754/w_logl.c,
sysdeps/libm-ieee754/w_powl.c, sysdeps/libm-ieee754/w_remainderl.c,
sysdeps/libm-ieee754/w_scalbl.c, sysdeps/libm-ieee754/w_sinhl.c,
sysdeps/libm-ieee754/w_sqrtl.c: New files. Wrapper functions
around long double function implementations.
* sysdeps/posix/ttyname_r.c (ttyname_r): Use _D_EXACT_NAMLEN
to determine length of directory entry name.
* posix/Makefile (routines): Add getlogin_r.
* posix/unistd.h: Add prototype for getlogin_r.
* sysdeps/stub/getlogin_r.c: New file. Reentrant version of
getlogin function, specified in P1003.1c/D6. Stub version.
* sysdeps/unix/getlogin.c (getlogin): Use ttyname_r instead of
ttyname. This avoids saving and restoring the old content.
Also use setutent_r, getutline_r and endutent_r instead of
accing UTMP file directly.
* sysdeps/unix/getlogin_r.c: New file. Reentrant version of
getlogin function, specified in P1003.1c/D6.
Tue Jun 4 20:10:09 1996 J.T. Conklin <jtc@cygnus.com>
* sysdeps/libm-i387/s_finitef.S: Fix mask for exponent.
* elf/dl-lookup.c (_dl_lookup_symbol): Grok magical undefined symbols
_GNU_libc_dl_{open,close,symbol} and resolve them to dl functions.
* elf/rtld.c (rtld_map): Renamed to _dl_rtld_map, made global.
* elf/link.h: Declare _dl_rtld_map.
* elf/dl-lookup.c (_dl_symbol_value): New function.
* elf/link.h: Declare it.
stdio-common/vfscanf.c: Prepare for reentrant libio.
Used in reentrant libio.
Diffstat (limited to 'sysdeps')
53 files changed, 2177 insertions, 101 deletions
diff --git a/sysdeps/libm-i387/e_asinl.S b/sysdeps/libm-i387/e_asinl.S new file mode 100644 index 0000000..7a90c3e --- /dev/null +++ b/sysdeps/libm-i387/e_asinl.S @@ -0,0 +1,21 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Public domain. + * + * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>. + */ + +#include <machine/asm.h> + +RCSID("$NetBSD: $") + +/* asinl = atanl (x / sqrtl(1 - x^2)) */ +ENTRY(__ieee754_asinl) + fldt 4(%esp) /* x */ + fst %st(1) + fmul %st(0) /* x^2 */ + fld1 + fsubp /* 1 - x^2 */ + fsqrt /* sqrt (1 - x^2) */ + fpatan + ret diff --git a/sysdeps/libm-i387/e_atan2l.S b/sysdeps/libm-i387/e_atan2l.S new file mode 100644 index 0000000..748571e --- /dev/null +++ b/sysdeps/libm-i387/e_atan2l.S @@ -0,0 +1,16 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Public domain. + * + * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>. + */ + +#include <machine/asm.h> + +RCSID("$NetBSD: $") + +ENTRY(__ieee754_atan2l) + fldt 4(%esp) + fldt 16(%esp) + fpatan + ret diff --git a/sysdeps/libm-i387/e_expl.S b/sysdeps/libm-i387/e_expl.S new file mode 100644 index 0000000..d140898 --- /dev/null +++ b/sysdeps/libm-i387/e_expl.S @@ -0,0 +1,40 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Public domain. + * + * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>. + */ + +#include <machine/asm.h> + +RCSID("$NetBSD: $") + +/* e^x = 2^(x * log2l(e)) */ +ENTRY(__ieee754_expl) + fldt 4(%esp) +/* I added the following ugly construct because expl(+-Inf) resulted + in NaN. The ugliness results from the bright minds at Intel. + -- drepper@cygnus.com. */ + fxam /* Is NaN or +-Inf? */ + fstsw %ax + sahf + jnc .LnoInfNaN /* No, jump. */ + jp .LisInf /* Is +-Inf, jump. */ +.LnoInfNaN: + fldl2e + fmulp /* x * log2(e) */ + fstl %st(1) + frndint /* int(x * log2(e)) */ + fstl %st(2) + fsubrp /* fract(x * log2(e)) */ + f2xm1 /* 2^(fract(x * log2(e))) - 1 */ + fld1 + faddp /* 2^(fract(x * log2(e))) */ + fscale /* e^x */ + ret + +.LisInf: + andb $2, %ah /* Test sign. */ + jz .LpInf /* If positive, jump. */ + fldz /* Set result to 0. */ +.LpInf: ret diff --git a/sysdeps/libm-i387/e_fmodl.S b/sysdeps/libm-i387/e_fmodl.S new file mode 100644 index 0000000..75ed17b --- /dev/null +++ b/sysdeps/libm-i387/e_fmodl.S @@ -0,0 +1,20 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Public domain. + * + * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>. + */ + +#include <machine/asm.h> + +RCSID("$NetBSD: $") + +ENTRY(__ieee754_fmodl) + fldt 16(%esp) + fldt 4(%esp) +1: fprem + fstsw %ax + sahf + jp 1b + fstpl %st(1) + ret diff --git a/sysdeps/libm-i387/e_log10l.S b/sysdeps/libm-i387/e_log10l.S new file mode 100644 index 0000000..0a19256 --- /dev/null +++ b/sysdeps/libm-i387/e_log10l.S @@ -0,0 +1,16 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Public domain. + * + * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>. + */ + +#include <machine/asm.h> + +RCSID("$NetBSD: $") + +ENTRY(__ieee754_log10l) + fldlg2 + fldt 4(%esp) + fyl2x + ret diff --git a/sysdeps/libm-i387/e_logl.S b/sysdeps/libm-i387/e_logl.S new file mode 100644 index 0000000..2575d6c --- /dev/null +++ b/sysdeps/libm-i387/e_logl.S @@ -0,0 +1,16 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Public domain. + * + * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>. + */ + +#include <machine/asm.h> + +RCSID("$NetBSD: $") + +ENTRY(__ieee754_logl) + fldln2 + fldt 4(%esp) + fyl2x + ret diff --git a/sysdeps/libm-i387/e_remainderl.S b/sysdeps/libm-i387/e_remainderl.S new file mode 100644 index 0000000..ce98515 --- /dev/null +++ b/sysdeps/libm-i387/e_remainderl.S @@ -0,0 +1,19 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Public domain. + * + * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>. + */ + +#include <machine/asm.h> + +RCSID("$NetBSD: $") + +ENTRY(__ieee754_remainderl) + fldt 16(%esp) + fldt 4(%esp) +1: fprem1 + fstsw %ax + sahf + jp 1b + ret diff --git a/sysdeps/libm-i387/e_scalbl.S b/sysdeps/libm-i387/e_scalbl.S new file mode 100644 index 0000000..8d5cd3b --- /dev/null +++ b/sysdeps/libm-i387/e_scalbl.S @@ -0,0 +1,16 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Public domain. + * + * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>. + */ + +#include <machine/asm.h> + +RCSID("$NetBSD: $") + +ENTRY(__ieee754_scalbl) + fldt 16(%esp) + fldt 4(%esp) + fscale + ret diff --git a/sysdeps/libm-i387/e_sqrtl.S b/sysdeps/libm-i387/e_sqrtl.S new file mode 100644 index 0000000..88e5f82 --- /dev/null +++ b/sysdeps/libm-i387/e_sqrtl.S @@ -0,0 +1,15 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Public domain. + * + * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>. + */ + +#include <machine/asm.h> + +RCSID("$NetBSD: $") + +ENTRY(__ieee754_sqrtl) + fldt 4(%esp) + fsqrt + ret diff --git a/sysdeps/libm-i387/s_atanl.S b/sysdeps/libm-i387/s_atanl.S new file mode 100644 index 0000000..867e60b --- /dev/null +++ b/sysdeps/libm-i387/s_atanl.S @@ -0,0 +1,17 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Public domain. + * + * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>. + */ + +#include <machine/asm.h> + +RCSID("$NetBSD: $") + +ENTRY(__atanl) + fldt 4(%esp) + fld1 + fpatan + ret +weak_alias (__atanl, atanl) diff --git a/sysdeps/libm-i387/s_cosl.S b/sysdeps/libm-i387/s_cosl.S new file mode 100644 index 0000000..e2c2242 --- /dev/null +++ b/sysdeps/libm-i387/s_cosl.S @@ -0,0 +1,29 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Public domain. + * + * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>. + */ + +#include <machine/asm.h> + +RCSID("$NetBSD: $") + +ENTRY(__cosl) + fldt 4(%esp) + fcos + fnstsw %ax + andw $0x400,%ax + jnz 1f + ret +1: fldpi + fadd %st(0) + fxch %st(1) +2: fprem1 + fnstsw %ax + andw $0x400,%ax + jnz 2b + fstp %st(1) + fcos + ret +weak_alias (__cosl, cosl) diff --git a/sysdeps/libm-i387/s_finitef.S b/sysdeps/libm-i387/s_finitef.S index f842d46..28a0a40 100644 --- a/sysdeps/libm-i387/s_finitef.S +++ b/sysdeps/libm-i387/s_finitef.S @@ -9,9 +9,9 @@ RCSID("$NetBSD: s_finitef.S,v 1.3 1995/05/09 00:00:02 jtc Exp $") ENTRY(__finitef) movl 4(%esp),%eax - andl $0x7ff00000, %eax - cmpl $0x7ff00000, %eax - setnel %al + andl $0x7f800000, %eax + cmpl $0x7f800000, %eax + setne %al andl $0x000000ff, %eax ret weak_alias (__finitef, finitef) diff --git a/sysdeps/libm-i387/s_ilogbl.S b/sysdeps/libm-i387/s_ilogbl.S new file mode 100644 index 0000000..11c8101 --- /dev/null +++ b/sysdeps/libm-i387/s_ilogbl.S @@ -0,0 +1,24 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Changes for long double by Ulrich Drepper <drepper@cygnus.com> + * Public domain. + */ + +#include <machine/asm.h> + +RCSID("$NetBSD: $") + +ENTRY(__ilogbl) + pushl %ebp + movl %esp,%ebp + subl $4,%esp + + fldt 8(%ebp) + fxtract + + fistpl -4(%ebp) + movl -4(%ebp),%eax + + leave + ret +weak_alias (__ilogbl, ilogbl) diff --git a/sysdeps/libm-i387/s_log1pl.S b/sysdeps/libm-i387/s_log1pl.S new file mode 100644 index 0000000..4a9faf7 --- /dev/null +++ b/sysdeps/libm-i387/s_log1pl.S @@ -0,0 +1,25 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Public domain. + * + * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>. + */ + +#include <machine/asm.h> + +RCSID("$NetBSD: $") + +/* + * Since the fyl2xp1 instruction has such a limited range: + * -(1 - (sqrt(2) / 2)) <= x <= sqrt(2) - 1 + * it's not worth trying to use it. + */ + +ENTRY(__log1pl) + fldln2 + fldt 4(%esp) + fld1 + faddp + fyl2x + ret +weak_alias (__log1pl, log1pl) diff --git a/sysdeps/libm-i387/s_logbl.S b/sysdeps/libm-i387/s_logbl.S new file mode 100644 index 0000000..e72b1fb --- /dev/null +++ b/sysdeps/libm-i387/s_logbl.S @@ -0,0 +1,15 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Changes for long double by Ulrich Drepper <drepper@cygnus.com> + * Public domain. + */ + +#include <machine/asm.h> + +RCSID("$NetBSD: $") + +ENTRY(__logbl) + fldt 4(%esp) + fxtract + ret +weak_alias (__logbl, logbl) diff --git a/sysdeps/libm-i387/s_scalbnl.S b/sysdeps/libm-i387/s_scalbnl.S new file mode 100644 index 0000000..b5fdf82 --- /dev/null +++ b/sysdeps/libm-i387/s_scalbnl.S @@ -0,0 +1,16 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Changes for long double by Ulrich Drepper <drepper@cygnus.com> + * Public domain. + */ + +#include <machine/asm.h> + +RCSID("$NetBSD: $") + +ENTRY(__scalbnl) + fildl 16(%esp) + fldt 4(%esp) + fscale + ret +weak_alias (__scalbnl, scalbnl) diff --git a/sysdeps/libm-i387/s_sinl.S b/sysdeps/libm-i387/s_sinl.S new file mode 100644 index 0000000..03c9c87 --- /dev/null +++ b/sysdeps/libm-i387/s_sinl.S @@ -0,0 +1,29 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Public domain. + * + * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>. + */ + +#include <machine/asm.h> + +RCSID("$NetBSD: $") + +ENTRY(__sinl) + fldt 4(%esp) + fsin + fnstsw %ax + andw $0x400,%ax + jnz 1f + ret +1: fldpi + fadd %st(0) + fxch %st(1) +2: fprem1 + fnstsw %ax + andw $0x400,%ax + jnz 2b + fstp %st(1) + fsin + ret +weak_alias (__sinl, sinl) diff --git a/sysdeps/libm-i387/s_tanl.S b/sysdeps/libm-i387/s_tanl.S new file mode 100644 index 0000000..6b1532a --- /dev/null +++ b/sysdeps/libm-i387/s_tanl.S @@ -0,0 +1,31 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Public domain. + * + * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>. + */ + +#include <machine/asm.h> + +RCSID("$NetBSD: $") + +ENTRY(__tanl) + fldt 4(%esp) + fptan + fnstsw %ax + andw $0x400,%ax + jnz 1f + fstp %st(0) + ret +1: fldpi + fadd %st(0) + fxch %st(1) +2: fprem1 + fstsw %ax + andw $0x400,%ax + jnz 2b + fstp %st(1) + fptan + fstp %st(0) + ret +weak_alias (__tanl, tanl) diff --git a/sysdeps/libm-ieee754/k_standard.c b/sysdeps/libm-ieee754/k_standard.c index d46afb5..ea070bc 100644 --- a/sysdeps/libm-ieee754/k_standard.c +++ b/sysdeps/libm-ieee754/k_standard.c @@ -5,7 +5,7 @@ * * Developed at SunPro, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice + * software is freely granted, provided that this notice * is preserved. * ==================================================== */ @@ -33,7 +33,7 @@ static const double zero = 0.0; /* used as const */ static double zero = 0.0; /* used as const */ #endif -/* +/* * Standard conformance (non-IEEE) on exception cases. * Mapping: * 1 -- acos(|x|>1) @@ -58,7 +58,7 @@ static double zero = 0.0; /* used as const */ * 20-- pow(0.0,0.0) * 21-- pow(x,y) overflow * 22-- pow(x,y) underflow - * 23-- pow(0,negative) + * 23-- pow(0,negative) * 24-- pow(neg,non-integral) * 25-- sinh(finite) overflow * 26-- sqrt(negative) @@ -82,14 +82,14 @@ static double zero = 0.0; /* used as const */ #ifdef __STDC__ - double __kernel_standard(double x, double y, int type) + double __kernel_standard(double x, double y, int type) #else - double __kernel_standard(x,y,type) + double __kernel_standard(x,y,type) double x,y; int type; #endif { struct exception exc; -#ifndef HUGE_VAL /* this is the only routine that uses HUGE_VAL */ +#ifndef HUGE_VAL /* this is the only routine that uses HUGE_VAL */ #define HUGE_VAL inf double inf = 0.0; @@ -104,9 +104,11 @@ static double zero = 0.0; /* used as const */ switch(type) { case 1: case 101: + case 201: /* acos(|x|>1) */ exc.type = DOMAIN; - exc.name = type < 100 ? "acos" : "acosf"; + exc.name = type < 100 ? "acos" : (type < 200 + ? "acosf" : "acosl");; exc.retval = zero; if (_LIB_VERSION == _POSIX_) errno = EDOM; @@ -119,9 +121,11 @@ static double zero = 0.0; /* used as const */ break; case 2: case 102: + case 202: /* asin(|x|>1) */ exc.type = DOMAIN; - exc.name = type < 100 ? "asin" : "asinf"; + exc.name = type < 100 ? "asin" : (type < 200 + ? "asinf" : "asinl"); exc.retval = zero; if(_LIB_VERSION == _POSIX_) errno = EDOM; @@ -134,11 +138,13 @@ static double zero = 0.0; /* used as const */ break; case 3: case 103: + case 203: /* atan2(+-0,+-0) */ exc.arg1 = y; exc.arg2 = x; exc.type = DOMAIN; - exc.name = type < 100 ? "atan2" : "atan2f"; + exc.name = type < 100 ? "atan2" : (type < 200 + ? "atan2f" : "atan2l"); exc.retval = zero; if(_LIB_VERSION == _POSIX_) errno = EDOM; @@ -151,9 +157,11 @@ static double zero = 0.0; /* used as const */ break; case 4: case 104: + case 204: /* hypot(finite,finite) overflow */ exc.type = OVERFLOW; - exc.name = type < 100 ? "hypot" : "hypotf"; + exc.name = type < 100 ? "hypot" : (type < 200 + ? "hypotf" : "hypotl"); if (_LIB_VERSION == _SVID_) exc.retval = HUGE; else @@ -166,9 +174,11 @@ static double zero = 0.0; /* used as const */ break; case 5: case 105: + case 205: /* cosh(finite) overflow */ exc.type = OVERFLOW; - exc.name = type < 100 ? "cosh" : "coshf"; + exc.name = type < 100 ? "cosh" : (type < 200 + ? "coshf" : "coshl"); if (_LIB_VERSION == _SVID_) exc.retval = HUGE; else @@ -181,9 +191,11 @@ static double zero = 0.0; /* used as const */ break; case 6: case 106: + case 206: /* exp(finite) overflow */ exc.type = OVERFLOW; - exc.name = type < 100 ? "exp" : "expf"; + exc.name = type < 100 ? "exp" : (type < 200 + ? "expf" : "expl"); if (_LIB_VERSION == _SVID_) exc.retval = HUGE; else @@ -196,9 +208,11 @@ static double zero = 0.0; /* used as const */ break; case 7: case 107: + case 207: /* exp(finite) underflow */ exc.type = UNDERFLOW; - exc.name = type < 100 ? "exp" : "expf"; + exc.name = type < 100 ? "exp" : (type < 200 + ? "expf" : "expl"); exc.retval = zero; if (_LIB_VERSION == _POSIX_) errno = ERANGE; @@ -208,9 +222,10 @@ static double zero = 0.0; /* used as const */ break; case 8: case 108: + case 208: /* y0(0) = -inf */ exc.type = DOMAIN; /* should be SING for IEEE */ - exc.name = type < 100 ? "y0" : "y0f"; + exc.name = type < 100 ? "y0" : (type < 200 ? "y0f" : "y0l"); if (_LIB_VERSION == _SVID_) exc.retval = -HUGE; else @@ -226,9 +241,10 @@ static double zero = 0.0; /* used as const */ break; case 9: case 109: + case 209: /* y0(x<0) = NaN */ exc.type = DOMAIN; - exc.name = type < 100 ? "y0" : "y0f"; + exc.name = type < 100 ? "y0" : (type < 200 ? "y0f" : "y0l"); if (_LIB_VERSION == _SVID_) exc.retval = -HUGE; else @@ -244,9 +260,10 @@ static double zero = 0.0; /* used as const */ break; case 10: case 110: + case 210: /* y1(0) = -inf */ exc.type = DOMAIN; /* should be SING for IEEE */ - exc.name = type < 100 ? "y1" : "y1f"; + exc.name = type < 100 ? "y1" : (type < 200 ? "y1f" : "y1l"); if (_LIB_VERSION == _SVID_) exc.retval = -HUGE; else @@ -262,9 +279,10 @@ static double zero = 0.0; /* used as const */ break; case 11: case 111: + case 211: /* y1(x<0) = NaN */ exc.type = DOMAIN; - exc.name = type < 100 ? "y1" : "y1f"; + exc.name = type < 100 ? "y1" : (type < 200 ? "y1f" : "y1l"); if (_LIB_VERSION == _SVID_) exc.retval = -HUGE; else @@ -280,9 +298,10 @@ static double zero = 0.0; /* used as const */ break; case 12: case 112: + case 212: /* yn(n,0) = -inf */ exc.type = DOMAIN; /* should be SING for IEEE */ - exc.name = type < 100 ? "yn" : "ynf"; + exc.name = type < 100 ? "yn" : (type < 200 ? "ynf" : "ynl"); if (_LIB_VERSION == _SVID_) exc.retval = -HUGE; else @@ -298,9 +317,10 @@ static double zero = 0.0; /* used as const */ break; case 13: case 113: + case 213: /* yn(x<0) = NaN */ exc.type = DOMAIN; - exc.name = type < 100 ? "yn" : "ynf"; + exc.name = type < 100 ? "yn" : (type < 200 ? "ynf" : "ynl"); if (_LIB_VERSION == _SVID_) exc.retval = -HUGE; else @@ -316,9 +336,11 @@ static double zero = 0.0; /* used as const */ break; case 14: case 114: + case 214: /* lgamma(finite) overflow */ exc.type = OVERFLOW; - exc.name = type < 100 ? "lgamma" : "lgammaf"; + exc.name = type < 100 ? "lgamma" : (type < 200 + ? "lgammaf" : "lgammal"); if (_LIB_VERSION == _SVID_) exc.retval = HUGE; else @@ -331,9 +353,11 @@ static double zero = 0.0; /* used as const */ break; case 15: case 115: + case 215: /* lgamma(-integer) or lgamma(0) */ exc.type = SING; - exc.name = type < 100 ? "lgamma" : "lgammaf"; + exc.name = type < 100 ? "lgamma" : (type < 200 + ? "lgammaf" : "lgammal"); if (_LIB_VERSION == _SVID_) exc.retval = HUGE; else @@ -349,9 +373,10 @@ static double zero = 0.0; /* used as const */ break; case 16: case 116: + case 216: /* log(0) */ exc.type = SING; - exc.name = type < 100 ? "log" : "logf"; + exc.name = type < 100 ? "log" : (type < 200 ? "logf" : "logl"); if (_LIB_VERSION == _SVID_) exc.retval = -HUGE; else @@ -367,9 +392,10 @@ static double zero = 0.0; /* used as const */ break; case 17: case 117: + case 217: /* log(x<0) */ exc.type = DOMAIN; - exc.name = type < 100 ? "log" : "logf"; + exc.name = type < 100 ? "log" : (type < 200 ? "logf" : "logl"); if (_LIB_VERSION == _SVID_) exc.retval = -HUGE; else @@ -385,9 +411,11 @@ static double zero = 0.0; /* used as const */ break; case 18: case 118: + case 218: /* log10(0) */ exc.type = SING; - exc.name = type < 100 ? "log10" : "log10f"; + exc.name = type < 100 ? "log10" : (type < 200 + ? "log10f" : "log10l"); if (_LIB_VERSION == _SVID_) exc.retval = -HUGE; else @@ -403,9 +431,11 @@ static double zero = 0.0; /* used as const */ break; case 19: case 119: + case 219: /* log10(x<0) */ exc.type = DOMAIN; - exc.name = type < 100 ? "log10" : "log10f"; + exc.name = type < 100 ? "log10" : (type < 200 + ? "log10f" : "log10l"); if (_LIB_VERSION == _SVID_) exc.retval = -HUGE; else @@ -421,10 +451,11 @@ static double zero = 0.0; /* used as const */ break; case 20: case 120: + case 220: /* pow(0.0,0.0) */ /* error only if _LIB_VERSION == _SVID_ */ exc.type = DOMAIN; - exc.name = type < 100 ? "pow" : "powf"; + exc.name = type < 100 ? "pow" : (type < 200 ? "powf" : "powl"); exc.retval = zero; if (_LIB_VERSION != _SVID_) exc.retval = 1.0; else if (!matherr(&exc)) { @@ -434,9 +465,10 @@ static double zero = 0.0; /* used as const */ break; case 21: case 121: + case 221: /* pow(x,y) overflow */ exc.type = OVERFLOW; - exc.name = type < 100 ? "pow" : "powf"; + exc.name = type < 100 ? "pow" : (type < 200 ? "powf" : "powl"); if (_LIB_VERSION == _SVID_) { exc.retval = HUGE; y *= 0.5; @@ -454,9 +486,10 @@ static double zero = 0.0; /* used as const */ break; case 22: case 122: + case 222: /* pow(x,y) underflow */ exc.type = UNDERFLOW; - exc.name = type < 100 ? "pow" : "powf"; + exc.name = type < 100 ? "pow" : (type < 200 ? "powf" : "powl"); exc.retval = zero; if (_LIB_VERSION == _POSIX_) errno = ERANGE; @@ -466,10 +499,11 @@ static double zero = 0.0; /* used as const */ break; case 23: case 123: + case 223: /* 0**neg */ exc.type = DOMAIN; - exc.name = type < 100 ? "pow" : "powf"; - if (_LIB_VERSION == _SVID_) + exc.name = type < 100 ? "pow" : (type < 200 ? "powf" : "powl"); + if (_LIB_VERSION == _SVID_) exc.retval = zero; else exc.retval = -HUGE_VAL; @@ -484,14 +518,15 @@ static double zero = 0.0; /* used as const */ break; case 24: case 124: + case 224: /* neg**non-integral */ exc.type = DOMAIN; - exc.name = type < 100 ? "pow" : "powf"; - if (_LIB_VERSION == _SVID_) + exc.name = type < 100 ? "pow" : (type < 200 ? "powf" : "powl"); + if (_LIB_VERSION == _SVID_) exc.retval = zero; - else + else exc.retval = zero/zero; /* X/Open allow NaN */ - if (_LIB_VERSION == _POSIX_) + if (_LIB_VERSION == _POSIX_) errno = EDOM; else if (!matherr(&exc)) { if (_LIB_VERSION == _SVID_) { @@ -502,9 +537,11 @@ static double zero = 0.0; /* used as const */ break; case 25: case 125: + case 225: /* sinh(finite) overflow */ exc.type = OVERFLOW; - exc.name = type < 100 ? "sinh" : "sinhf"; + exc.name = type < 100 ? "sinh" : (type < 200 + ? "sinhf" : "sinhl"); if (_LIB_VERSION == _SVID_) exc.retval = ( (x>zero) ? HUGE : -HUGE); else @@ -517,9 +554,11 @@ static double zero = 0.0; /* used as const */ break; case 26: case 126: + case 226: /* sqrt(x<0) */ exc.type = DOMAIN; - exc.name = type < 100 ? "sqrt" : "sqrtf"; + exc.name = type < 100 ? "sqrt" : (type < 200 + ? "sqrtf" : "sqrtl"); if (_LIB_VERSION == _SVID_) exc.retval = zero; else @@ -535,9 +574,11 @@ static double zero = 0.0; /* used as const */ break; case 27: case 127: + case 227: /* fmod(x,0) */ exc.type = DOMAIN; - exc.name = type < 100 ? "fmod" : "fmodf"; + exc.name = type < 100 ? "fmod" : (type < 200 + ? "fmodf" : "fmodl"); if (_LIB_VERSION == _SVID_) exc.retval = x; else @@ -553,9 +594,12 @@ static double zero = 0.0; /* used as const */ break; case 28: case 128: + case 228: /* remainder(x,0) */ exc.type = DOMAIN; - exc.name = type < 100 ? "remainder" : "remainderf"; + exc.name = type < 100 ? "remainder" : (type < 200 + ? "remainderf" + : "remainderl"); exc.retval = zero/zero; if (_LIB_VERSION == _POSIX_) errno = EDOM; @@ -568,9 +612,11 @@ static double zero = 0.0; /* used as const */ break; case 29: case 129: + case 229: /* acosh(x<1) */ exc.type = DOMAIN; - exc.name = type < 100 ? "acosh" : "acoshf"; + exc.name = type < 100 ? "acosh" : (type < 200 + ? "acoshf" : "acoshl"); exc.retval = zero/zero; if (_LIB_VERSION == _POSIX_) errno = EDOM; @@ -583,9 +629,11 @@ static double zero = 0.0; /* used as const */ break; case 30: case 130: + case 230: /* atanh(|x|>1) */ exc.type = DOMAIN; - exc.name = type < 100 ? "atanh" : "atanhf"; + exc.name = type < 100 ? "atanh" : (type < 200 + ? "atanhf" : "atanhl"); exc.retval = zero/zero; if (_LIB_VERSION == _POSIX_) errno = EDOM; @@ -598,9 +646,11 @@ static double zero = 0.0; /* used as const */ break; case 31: case 131: + case 231: /* atanh(|x|=1) */ exc.type = SING; - exc.name = type < 100 ? "atanh" : "atanhf"; + exc.name = type < 100 ? "atanh" : (type < 200 + ? "atanhf" : "atanhl"); exc.retval = x/zero; /* sign(x)*inf */ if (_LIB_VERSION == _POSIX_) errno = EDOM; @@ -613,9 +663,11 @@ static double zero = 0.0; /* used as const */ break; case 32: case 132: + case 232: /* scalb overflow; SVID also returns +-HUGE_VAL */ exc.type = OVERFLOW; - exc.name = type < 100 ? "scalb" : "scalbf"; + exc.name = type < 100 ? "scalb" : (type < 200 + ? "scalbf" : "scalbl"); exc.retval = x > zero ? HUGE_VAL : -HUGE_VAL; if (_LIB_VERSION == _POSIX_) errno = ERANGE; @@ -625,9 +677,11 @@ static double zero = 0.0; /* used as const */ break; case 33: case 133: + case 233: /* scalb underflow */ exc.type = UNDERFLOW; - exc.name = type < 100 ? "scalb" : "scalbf"; + exc.name = type < 100 ? "scalb" : (type < 200 + ? "scalbf" : "scalbl"); exc.retval = __copysign(zero,x); if (_LIB_VERSION == _POSIX_) errno = ERANGE; @@ -637,9 +691,10 @@ static double zero = 0.0; /* used as const */ break; case 34: case 134: + case 234: /* j0(|x|>X_TLOSS) */ exc.type = TLOSS; - exc.name = type < 100 ? "j0" : "j0f"; + exc.name = type < 100 ? "j0" : (type < 200 ? "j0f" : "j0l"); exc.retval = zero; if (_LIB_VERSION == _POSIX_) errno = ERANGE; @@ -649,13 +704,14 @@ static double zero = 0.0; /* used as const */ (void) WRITE2(": TLOSS error\n", 14); } errno = ERANGE; - } + } break; case 35: case 135: + case 235: /* y0(x>X_TLOSS) */ exc.type = TLOSS; - exc.name = type < 100 ? "y0" : "y0f"; + exc.name = type < 100 ? "y0" : (type < 200 ? "y0f" : "y0l"); exc.retval = zero; if (_LIB_VERSION == _POSIX_) errno = ERANGE; @@ -665,13 +721,14 @@ static double zero = 0.0; /* used as const */ (void) WRITE2(": TLOSS error\n", 14); } errno = ERANGE; - } + } break; case 36: case 136: + case 236: /* j1(|x|>X_TLOSS) */ exc.type = TLOSS; - exc.name = type < 100 ? "j1" : "j1f"; + exc.name = type < 100 ? "j1" : (type < 200 ? "j1f" : "j1l"); exc.retval = zero; if (_LIB_VERSION == _POSIX_) errno = ERANGE; @@ -681,13 +738,14 @@ static double zero = 0.0; /* used as const */ (void) WRITE2(": TLOSS error\n", 14); } errno = ERANGE; - } + } break; case 37: case 137: + case 237: /* y1(x>X_TLOSS) */ exc.type = TLOSS; - exc.name = type < 100 ? "y1" : "y1f"; + exc.name = type < 100 ? "y1" : (type < 200 ? "y1f" : "y1l"); exc.retval = zero; if (_LIB_VERSION == _POSIX_) errno = ERANGE; @@ -697,13 +755,14 @@ static double zero = 0.0; /* used as const */ (void) WRITE2(": TLOSS error\n", 14); } errno = ERANGE; - } + } break; case 38: case 138: + case 238: /* jn(|x|>X_TLOSS) */ exc.type = TLOSS; - exc.name = type < 100 ? "jn" : "jnf"; + exc.name = type < 100 ? "jn" : (type < 200 ? "jnf" : "jnl"); exc.retval = zero; if (_LIB_VERSION == _POSIX_) errno = ERANGE; @@ -713,13 +772,14 @@ static double zero = 0.0; /* used as const */ (void) WRITE2(": TLOSS error\n", 14); } errno = ERANGE; - } + } break; case 39: case 139: + case 239: /* yn(x>X_TLOSS) */ exc.type = TLOSS; - exc.name = type < 100 ? "yn" : "ynf"; + exc.name = type < 100 ? "yn" : (type < 200 ? "ynf" : "ynl"); exc.retval = zero; if (_LIB_VERSION == _POSIX_) errno = ERANGE; @@ -729,13 +789,15 @@ static double zero = 0.0; /* used as const */ (void) WRITE2(": TLOSS error\n", 14); } errno = ERANGE; - } + } break; case 40: case 140: + case 240: /* gamma(finite) overflow */ exc.type = OVERFLOW; - exc.name = type < 100 ? "gamma" : "gammaf"; + exc.name = type < 100 ? "gamma" : (type < 200 + ? "gammaf" : "gammal"); if (_LIB_VERSION == _SVID_) exc.retval = HUGE; else @@ -748,9 +810,11 @@ static double zero = 0.0; /* used as const */ break; case 41: case 141: + case 241: /* gamma(-integer) or gamma(0) */ exc.type = SING; - exc.name = type < 100 ? "gamma" : "gammaf"; + exc.name = type < 100 ? "gamma" : (type < 200 + ? "gammaf" : "gammal"); if (_LIB_VERSION == _SVID_) exc.retval = HUGE; else @@ -766,10 +830,11 @@ static double zero = 0.0; /* used as const */ break; case 42: case 142: + case 242: /* pow(NaN,0.0) */ /* error only if _LIB_VERSION == _SVID_ & _XOPEN_ */ exc.type = DOMAIN; - exc.name = type < 100 ? "pow" : "powf"; + exc.name = type < 100 ? "pow" : (type < 200 ? "powf" : "powl"); exc.retval = x; if (_LIB_VERSION == _IEEE_ || _LIB_VERSION == _POSIX_) exc.retval = 1.0; @@ -778,5 +843,5 @@ static double zero = 0.0; /* used as const */ } break; } - return exc.retval; + return exc.retval; } diff --git a/sysdeps/libm-ieee754/s_ilogbl.c b/sysdeps/libm-ieee754/s_ilogbl.c new file mode 100644 index 0000000..11372e0 --- /dev/null +++ b/sysdeps/libm-ieee754/s_ilogbl.c @@ -0,0 +1,56 @@ +/* s_ilogbl.c -- long double version of s_ilogb.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* ilogbl(long double x) + * return the binary exponent of non-zero x + * ilogbl(0) = 0x80000001 + * ilogbl(inf/NaN) = 0x7fffffff (no signal is raised) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + int __ilogbl(long double x) +#else + int __ilogbl(x) + long double x; +#endif +{ + int32_t es,hx,lx,ix; + + GET_LDOUBLE_EXP(es,x); + es &= 0x7fff; + if(es==0) { + GET_LDOUBLE_WORDS(es,hx,lx,x); + if((hx|lx)==0) + return 0x80000001; /* ilogbl(0) = 0x80000001 */ + else /* subnormal x */ + if(hx==0) { + for (ix = -16415; lx>0; lx<<=1) ix -=1; + } else { + for (ix = -16383; hx>0; hx<<=1) ix -=1; + } + return ix; + } + else if (es<0x7fff) return es-0x3fff; + else return 0x7fffffff; +} +weak_alias (__ilogbl, ilogbl) diff --git a/sysdeps/libm-ieee754/s_isinf.c b/sysdeps/libm-ieee754/s_isinf.c index 6d435f0..b35fc1c 100644 --- a/sysdeps/libm-ieee754/s_isinf.c +++ b/sysdeps/libm-ieee754/s_isinf.c @@ -31,5 +31,6 @@ static char rcsid[] = "$NetBSD: s_isinf.c,v 1.3 1995/05/11 23:20:14 jtc Exp $"; } weak_alias (__isinf, isinf) #ifdef NO_LONG_DOUBLE +strong_alias (__isinf, __isinfl) weak_alias (__isinf, isinfl) #endif diff --git a/sysdeps/libm-ieee754/s_logbl.c b/sysdeps/libm-ieee754/s_logbl.c new file mode 100644 index 0000000..2cd9d10 --- /dev/null +++ b/sysdeps/libm-ieee754/s_logbl.c @@ -0,0 +1,47 @@ +/* s_logbl.c -- long double version of s_logb.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * long double logbl(x) + * IEEE 754 logb. Included to pass IEEE test suite. Not recommend. + * Use ilogb instead. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + long double __logbl(long double x) +#else + long double __logbl(x) + long double x; +#endif +{ + int32_t es,lx,ix; + GET_LDOUBLE_WORDS(es,ix,lx,x); + es &= 0x7fff; /* exponent */ + if((es|ix|lx)==0) return -1.0/fabs(x); + if(es==0x7fff) return x*x; + if(es==0) /* IEEE 754 logb */ + return -16382.0; + else + return (long double) (es-0x3fff); +} +weak_alias (__logbl, logbl) diff --git a/sysdeps/libm-ieee754/s_modfl.c b/sysdeps/libm-ieee754/s_modfl.c new file mode 100644 index 0000000..433c936 --- /dev/null +++ b/sysdeps/libm-ieee754/s_modfl.c @@ -0,0 +1,88 @@ +/* s_modfl.c -- long double version of s_modf.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * modfl(long double x, long double *iptr) + * return fraction part of x, and return x's integral part in *iptr. + * Method: + * Bit twiddling. + * + * Exception: + * No exception. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const long double one = 1.0; +#else +static long double one = 1.0; +#endif + +#ifdef __STDC__ + long double __modfl(long double x, long double *iptr) +#else + long double __modfl(x, iptr) + long double x,*iptr; +#endif +{ + int32_t i0,i1,j0; + u_int32_t i,se; + GET_LDOUBLE_WORDS(se,i0,i1,x); + j0 = (se&0x7fff)-0x3fff; /* exponent of x */ + if(j0<32) { /* integer part in high x */ + if(j0<0) { /* |x|<1 */ + SET_LDOUBLE_WORDS(*iptr,se&0x8000,0,0); /* *iptr = +-0 */ + return x; + } else { + i = (0xffffffff)>>j0; + if(((i0&i)|i1)==0) { /* x is integral */ + u_int32_t high; + *iptr = x; + GET_HIGH_WORD(high,x); + INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */ + return x; + } else { + INSERT_WORDS(*iptr,i0&(~i),0); + return x - *iptr; + } + } + } else if (j0>63) { /* no fraction part */ + u_int32_t high; + *iptr = x*one; + GET_HIGH_WORD(high,x); + INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */ + return x; + } else { /* fraction part in low x */ + i = ((u_int32_t)(0xffffffff))>>(j0-20); + if((i1&i)==0) { /* x is integral */ + u_int32_t high; + *iptr = x; + GET_HIGH_WORD(high,x); + INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */ + return x; + } else { + INSERT_WORDS(*iptr,i0,i1&(~i)); + return x - *iptr; + } + } +} +weak_alias (__modfl, modfl) diff --git a/sysdeps/libm-ieee754/w_acoshl.c b/sysdeps/libm-ieee754/w_acoshl.c new file mode 100644 index 0000000..a37d4c1 --- /dev/null +++ b/sysdeps/libm-ieee754/w_acoshl.c @@ -0,0 +1,47 @@ +/* w_acoshl.c -- long double version of w_acosh.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * wrapper acoshl(x) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + long double __acoshl(long double x) /* wrapper acosh */ +#else + long double __acoshl(x) /* wrapper acosh */ + long double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_acoshl(x); +#else + long double z; + z = __ieee754_acoshl(x); + if(_LIB_VERSION == _IEEE_ || __isnanl(x)) return z; + if(x<1.0) { + return __kernel_standard(x,x,229); /* acoshl(x<1) */ + } else + return z; +#endif +} +weak_alias (__acoshl, acoshl) diff --git a/sysdeps/libm-ieee754/w_acosl.c b/sysdeps/libm-ieee754/w_acosl.c new file mode 100644 index 0000000..cd9cecf --- /dev/null +++ b/sysdeps/libm-ieee754/w_acosl.c @@ -0,0 +1,48 @@ +/* w_acosl.c -- long double version of w_acos.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * wrap_acosl(x) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + long double __acosl(long double x) /* wrapper acos */ +#else + long double __acosl(x) /* wrapper acos */ + long double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_acosl(x); +#else + long double z; + z = __ieee754_acosl(x); + if(_LIB_VERSION == _IEEE_ || __isnanl(x)) return z; + if(fabsl(x)>1.0) { + return __kernel_standard(x,x,201); /* acosl(|x|>1) */ + } else + return z; +#endif +} +weak_alias (__acosl, acosl) diff --git a/sysdeps/libm-ieee754/w_asinl.c b/sysdeps/libm-ieee754/w_asinl.c new file mode 100644 index 0000000..0ac3038 --- /dev/null +++ b/sysdeps/libm-ieee754/w_asinl.c @@ -0,0 +1,49 @@ +/* w_asinl.c -- long double version of w_asin.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * wrapper asinl(x) + */ + + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + long double __asinl(long double x) /* wrapper asinl */ +#else + long double __asinl(x) /* wrapper asinl */ + long double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_asinl(x); +#else + long double z; + z = __ieee754_asinl(x); + if(_LIB_VERSION == _IEEE_ || __isnanl(x)) return z; + if(fabsl(x)>1.0) { + return __kernel_standard(x,x,202); /* asinl(|x|>1) */ + } else + return z; +#endif +} +weak_alias (__asinl, asinl) diff --git a/sysdeps/libm-ieee754/w_atan2l.c b/sysdeps/libm-ieee754/w_atan2l.c new file mode 100644 index 0000000..9e6e56b --- /dev/null +++ b/sysdeps/libm-ieee754/w_atan2l.c @@ -0,0 +1,48 @@ +/* w_atan2l.c -- long double version of w_atan2.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * wrapper atan2l(y,x) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + long double __atan2l(long double y, long double x) /* wrapper atan2l */ +#else + long double __atan2l(y,x) /* wrapper atan2l */ + long double y,x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_atan2l(y,x); +#else + long double z; + z = __ieee754_atan2l(y,x); + if(_LIB_VERSION == _IEEE_||__isnanl(x)||__isnanl(y)) return z; + if(x==0.0&&y==0.0) { + return __kernel_standard(y,x,203); /* atan2l(+-0,+-0) */ + } else + return z; +#endif +} +weak_alias (__atan2l, atan2l) diff --git a/sysdeps/libm-ieee754/w_atanhl.c b/sysdeps/libm-ieee754/w_atanhl.c new file mode 100644 index 0000000..d675fc6 --- /dev/null +++ b/sysdeps/libm-ieee754/w_atanhl.c @@ -0,0 +1,52 @@ +/* w_atanhl.c -- long double version of w_atanh.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * wrapper atanhl(x) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + long double __atanhl(long double x) /* wrapper atanhl */ +#else + long double __atanhl(x) /* wrapper atanhl */ + long double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_atanhl(x); +#else + long double z,y; + z = __ieee754_atanhl(x); + if(_LIB_VERSION == _IEEE_ || __isnanl(x)) return z; + y = fabsl(x); + if(y>=1.0) { + if(y>1.0) + return __kernel_standard(x,x,230); /* atanhl(|x|>1) */ + else + return __kernel_standard(x,x,231); /* atanhl(|x|==1) */ + } else + return z; +#endif +} +weak_alias (__atanhl, atanhl) diff --git a/sysdeps/libm-ieee754/w_cabsl.c b/sysdeps/libm-ieee754/w_cabsl.c new file mode 100644 index 0000000..e82130d --- /dev/null +++ b/sysdeps/libm-ieee754/w_cabsl.c @@ -0,0 +1,18 @@ +/* + * cabsl() wrapper for hypotl(). + * + * Written by J.T. Conklin, <jtc@wimsey.com> + * Conversion to long double by Ulrich Drepper, + * Cygnus Support, drepper@cygnus.com. + * Placed into the Public Domain, 1994. + */ + +#include <math.h> + +long double +__cabsl(z) + struct __cabsl_complex z; +{ + return __hypotl(z.x, z.y); +} +weak_alias (__cabsl, cabsl) diff --git a/sysdeps/libm-ieee754/w_coshl.c b/sysdeps/libm-ieee754/w_coshl.c new file mode 100644 index 0000000..343d572 --- /dev/null +++ b/sysdeps/libm-ieee754/w_coshl.c @@ -0,0 +1,47 @@ +/* w_acoshl.c -- long double version of w_acosh.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * wrapper coshl(x) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + long double __coshl(long double x) /* wrapper coshl */ +#else + long double __coshl(x) /* wrapper coshl */ + long double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_coshl(x); +#else + long double z; + z = __ieee754_coshl(x); + if(_LIB_VERSION == _IEEE_ || __isnanl(x)) return z; + if(fabsl(x)>7.10475860073943863426e+02) { + return __kernel_standard(x,x,205); /* cosh overflow */ + } else + return z; +#endif +} +weak_alias (__coshl, coshl) diff --git a/sysdeps/libm-ieee754/w_dreml.c b/sysdeps/libm-ieee754/w_dreml.c new file mode 100644 index 0000000..aa73eed --- /dev/null +++ b/sysdeps/libm-ieee754/w_dreml.c @@ -0,0 +1,18 @@ +/* + * dreml() wrapper for remainderl(). + * + * Written by J.T. Conklin, <jtc@wimsey.com> + * Conversion to long double by Ulrich Drepper, + * Cygnus Support, drepper@cygnus.com. + * Placed into the Public Domain, 1994. + */ + +#include <math.h> + +long double +__dreml(x, y) + long double x, y; +{ + return __remainderl(x, y); +} +weak_alias (__dreml, dreml) diff --git a/sysdeps/libm-ieee754/w_expl.c b/sysdeps/libm-ieee754/w_expl.c new file mode 100644 index 0000000..b8152ce --- /dev/null +++ b/sysdeps/libm-ieee754/w_expl.c @@ -0,0 +1,60 @@ +/* w_expl.c -- long double version of w_exp.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * wrapper expl(x) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const long double +#else +static long double +#endif +o_threshold= 1.135652340629414394949193107797076489134e4, + /* 0x400C, 0xB17217F7, 0xD1CF79AC */ +u_threshold= -1.140019167866942050398521670162263001513e4; + /* 0x400C, 0xB220C447, 0x69C201E8 */ + +#ifdef __STDC__ + long double __expl(long double x) /* wrapper exp */ +#else + long double __expl(x) /* wrapper exp */ + long double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_expl(x); +#else + long double z; + z = __ieee754_expl(x); + if(_LIB_VERSION == _IEEE_) return z; + if(__finitel(x)) { + if(x>o_threshold) + return __kernel_standard(x,x,206); /* exp overflow */ + else if(x<u_threshold) + return __kernel_standard(x,x,207); /* exp underflow */ + } + return z; +#endif +} +weak_alias (__expl, expl) diff --git a/sysdeps/libm-ieee754/w_fmodl.c b/sysdeps/libm-ieee754/w_fmodl.c new file mode 100644 index 0000000..71ed4a9 --- /dev/null +++ b/sysdeps/libm-ieee754/w_fmodl.c @@ -0,0 +1,48 @@ +/* w_fmodl.c -- long double version of w_fmod.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * wrapper fmodl(x,y) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + long double __fmodl(long double x, long double y)/* wrapper fmodl */ +#else + long double __fmodl(x,y) /* wrapper fmodl */ + long double x,y; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_fmodl(x,y); +#else + long double z; + z = __ieee754_fmodl(x,y); + if(_LIB_VERSION == _IEEE_ ||__isnanl(y)||__isnanl(x)) return z; + if(y==0.0) { + return __kernel_standard(x,y,227); /* fmod(x,0) */ + } else + return z; +#endif +} +weak_alias (__fmodl, fmodl) diff --git a/sysdeps/libm-ieee754/w_gammal.c b/sysdeps/libm-ieee754/w_gammal.c new file mode 100644 index 0000000..f72e2e7 --- /dev/null +++ b/sysdeps/libm-ieee754/w_gammal.c @@ -0,0 +1,54 @@ +/* w_gammal.c -- long double version of w_gamma.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* long double gammal(double x) + * Return the logarithm of the Gamma function of x. + * + * Method: call gammal_r + */ + +#include "math.h" +#include "math_private.h" + +extern int signgam; + +#ifdef __STDC__ + long double __gammal(long double x) +#else + long double __gammal(x) + long double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_lgammal_r(x,&signgam); +#else + long double y; + y = __ieee754_lgammal_r(x,&signgam); + if(_LIB_VERSION == _IEEE_) return y; + if(!__finitel(y)&&__finitel(x)) { + if(__floorl(x)==x&&x<=0.0) + return __kernel_standard(x,x,241); /* gamma pole */ + else + return __kernel_standard(x,x,240); /* gamma overflow */ + } else + return y; +#endif +} +weak_alias (__gammal, gammal) diff --git a/sysdeps/libm-ieee754/w_gammal_r.c b/sysdeps/libm-ieee754/w_gammal_r.c new file mode 100644 index 0000000..ad6a43a --- /dev/null +++ b/sysdeps/libm-ieee754/w_gammal_r.c @@ -0,0 +1,52 @@ +/* w_gammal_r.c -- long double version of w_gamma_r.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * wrapper long double gammal_r(long double x, int *signgamp) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + long double __gammal_r(long double x, int *signgamp) + /* wrapper lgammal_r */ +#else + long double __gammal_r(x,signgamp) /* wrapper lgamma_r */ + long double x; int *signgamp; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_lgammal_r(x,signgamp); +#else + long double y; + y = __ieee754_lgammal_r(x,signgamp); + if(_LIB_VERSION == _IEEE_) return y; + if(!__finitel(y)&&__finitel(x)) { + if(__floorl(x)==x&&x<=0.0) + return __kernel_standard(x,x,241); /* gamma pole */ + else + return __kernel_standard(x,x,240); /* gamma overflow */ + } else + return y; +#endif +} +weak_alias (__gammal_r, gammal_r) diff --git a/sysdeps/libm-ieee754/w_hypotl.c b/sysdeps/libm-ieee754/w_hypotl.c new file mode 100644 index 0000000..9f92e95 --- /dev/null +++ b/sysdeps/libm-ieee754/w_hypotl.c @@ -0,0 +1,48 @@ +/* w_hypotl.c -- long double version of w_hypot.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * wrapper hypotl(x,y) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + long double __hypotl(longdouble x, long double y)/* wrapper hypotl */ +#else + long double __hypotl(x,y) /* wrapper hypotl */ + long double x,y; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_hypotl(x,y); +#else + long double z; + z = __ieee754_hypotl(x,y); + if(_LIB_VERSION == _IEEE_) return z; + if((!__finitel(z))&&__finitel(x)&&__finitel(y)) + return __kernel_standard(x,y,204); /* hypot overflow */ + else + return z; +#endif +} +weak_alias (__hypotl, hypotl) diff --git a/sysdeps/libm-ieee754/w_j0l.c b/sysdeps/libm-ieee754/w_j0l.c new file mode 100644 index 0000000..7b4144c --- /dev/null +++ b/sysdeps/libm-ieee754/w_j0l.c @@ -0,0 +1,75 @@ +/* w_j0l.c -- long double version of w_j0.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * wrapper j0l(long double x), y0l(long double x) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + long double __j0l(long double x) /* wrapper j0l */ +#else + long double __j0l(x) /* wrapper j0 */ + long double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_j0l(x); +#else + long double z = __ieee754_j0l(x); + if(_LIB_VERSION == _IEEE_ || __isnanl(x)) return z; + if(fabsl(x)>X_TLOSS) { + return __kernel_standard(x,x,234); /* j0(|x|>X_TLOSS) */ + } else + return z; +#endif +} +weak_alias (__j0l, j0l) + +#ifdef __STDC__ + long double __y0l(long double x) /* wrapper y0l */ +#else + long double __y0l(x) /* wrapper y0 */ + long double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_y0l(x); +#else + long double z; + z = __ieee754_y0l(x); + if(_LIB_VERSION == _IEEE_ || __isnanl(x) ) return z; + if(x <= 0.0){ + if(x==0.0) + /* d= -one/(x-x); */ + return __kernel_standard(x,x,208); + else + /* d = zero/(x-x); */ + return __kernel_standard(x,x,209); + } + if(x>X_TLOSS) { + return __kernel_standard(x,x,235); /* y0(x>X_TLOSS) */ + } else + return z; +#endif +} +weak_alias (__y0l, y0l) diff --git a/sysdeps/libm-ieee754/w_j1l.c b/sysdeps/libm-ieee754/w_j1l.c new file mode 100644 index 0000000..223ab79 --- /dev/null +++ b/sysdeps/libm-ieee754/w_j1l.c @@ -0,0 +1,76 @@ +/* w_j1l.c -- long double version of w_j1.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * wrapper of j1l,y1l + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + long double __j1l(long double x) /* wrapper j1l */ +#else + long double __j1l(x) /* wrapper j1l */ + long double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_j1l(x); +#else + long double z; + z = __ieee754_j1l(x); + if(_LIB_VERSION == _IEEE_ || __isnanl(x) ) return z; + if(fabsl(x)>X_TLOSS) { + return __kernel_standard(x,x,236); /* j1(|x|>X_TLOSS) */ + } else + return z; +#endif +} +weak_alias (__j1l, j1l) + +#ifdef __STDC__ + long double __y1l(long double x) /* wrapper y1l */ +#else + long double __y1l(x) /* wrapper y1l */ + long double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_y1l(x); +#else + long double z; + z = __ieee754_y1l(x); + if(_LIB_VERSION == _IEEE_ || __isnanl(x) ) return z; + if(x <= 0.0){ + if(x==0.0) + /* d= -one/(x-x); */ + return __kernel_standard(x,x,210); + else + /* d = zero/(x-x); */ + return __kernel_standard(x,x,211); + } + if(x>X_TLOSS) { + return __kernel_standard(x,x,237); /* y1(x>X_TLOSS) */ + } else + return z; +#endif +} +weak_alias (__y1l, y1l) diff --git a/sysdeps/libm-ieee754/w_jnl.c b/sysdeps/libm-ieee754/w_jnl.c new file mode 100644 index 0000000..0a243db --- /dev/null +++ b/sysdeps/libm-ieee754/w_jnl.c @@ -0,0 +1,98 @@ +/* w_jnl.c -- long double version of w_jn.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * wrapper jn(int n, double x), yn(int n, double x) + * floating point Bessel's function of the 1st and 2nd kind + * of order n + * + * Special cases: + * y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal; + * y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal. + * Note 2. About jn(n,x), yn(n,x) + * For n=0, j0(x) is called, + * for n=1, j1(x) is called, + * for n<x, forward recursion us used starting + * from values of j0(x) and j1(x). + * for n>x, a continued fraction approximation to + * j(n,x)/j(n-1,x) is evaluated and then backward + * recursion is used starting from a supposed value + * for j(n,x). The resulting value of j(0,x) is + * compared with the actual value to correct the + * supposed value of j(n,x). + * + * yn(n,x) is similar in all respects, except + * that forward recursion is used for all + * values of n>1. + * + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + long double __jnl(int n, long double x) /* wrapper jnl */ +#else + long double __jnl(n,x) /* wrapper jnl */ + long double x; int n; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_jnl(n,x); +#else + long double z; + z = __ieee754_jnl(n,x); + if(_LIB_VERSION == _IEEE_ || __isnanl(x) ) return z; + if(fabsl(x)>X_TLOSS) { + return __kernel_standard((double)n,x,238); /* jn(|x|>X_TLOSS,n) */ + } else + return z; +#endif +} +weak_alias (__jnl, jnl) + +#ifdef __STDC__ + long double __ynl(int n, long double x) /* wrapper ynl */ +#else + long double __ynl(n,x) /* wrapper ynl */ + long double x; int n; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_ynl(n,x); +#else + long double z; + z = __ieee754_ynl(n,x); + if(_LIB_VERSION == _IEEE_ || __isnanl(x) ) return z; + if(x <= 0.0){ + if(x==0.0) + /* d= -one/(x-x); */ + return __kernel_standard((double)n,x,212); + else + /* d = zero/(x-x); */ + return __kernel_standard((double)n,x,213); + } + if(x>X_TLOSS) { + return __kernel_standard((double)n,x,239); /* yn(x>X_TLOSS,n) */ + } else + return z; +#endif +} +weak_alias (__ynl, ynl) diff --git a/sysdeps/libm-ieee754/w_lgammal.c b/sysdeps/libm-ieee754/w_lgammal.c new file mode 100644 index 0000000..3d2cdbb --- /dev/null +++ b/sysdeps/libm-ieee754/w_lgammal.c @@ -0,0 +1,54 @@ +/* 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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* 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" + +extern int signgam; + +#ifdef __STDC__ + long double __lgammal(long double x) +#else + long double __lgammal(x) + long double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_lgammal_r(x,&signgam); +#else + long double y; + y = __ieee754_lgammal_r(x,&signgam); + if(_LIB_VERSION == _IEEE_) return y; + if(!__finitel(y)&&__finitel(x)) { + if(__floorl(x)==x&&x<=0.0) + return __kernel_standard(x,x,215); /* lgamma pole */ + else + return __kernel_standard(x,x,214); /* lgamma overflow */ + } else + return y; +#endif +} +weak_alias (__lgammal, lgammal) diff --git a/sysdeps/libm-ieee754/w_lgammal_r.c b/sysdeps/libm-ieee754/w_lgammal_r.c new file mode 100644 index 0000000..71f5c00 --- /dev/null +++ b/sysdeps/libm-ieee754/w_lgammal_r.c @@ -0,0 +1,52 @@ +/* w_lgammal_r.c -- long double version of w_lgamma_r.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * wrapper long double lgammal_r(long double x, int *signgamp) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + long double __lgammal_r(long double x, int *signgamp) + /* wrapper lgamma_r */ +#else + long double __lgammal_r(x,signgamp) /* wrapper lgamma_r */ + long double x; int *signgamp; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_lgammal_r(x,signgamp); +#else + long double y; + y = __ieee754_lgammal_r(x,signgamp); + if(_LIB_VERSION == _IEEE_) return y; + if(!__finitel(y)&&__finitel(x)) { + if(__floorl(x)==x&&x<=0.0) + return __kernel_standard(x,x,215); /* lgamma pole */ + else + return __kernel_standard(x,x,214); /* lgamma overflow */ + } else + return y; +#endif +} +weak_alias (__lgammal_r, lgammal_r) diff --git a/sysdeps/libm-ieee754/w_log10l.c b/sysdeps/libm-ieee754/w_log10l.c new file mode 100644 index 0000000..0d08616 --- /dev/null +++ b/sysdeps/libm-ieee754/w_log10l.c @@ -0,0 +1,51 @@ +/* w_log10l.c -- long double version of w_log10.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * wrapper log10l(X) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + long double __log10l(long double x) /* wrapper log10l */ +#else + long double __log10l(x) /* wrapper log10l */ + long double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_log10l(x); +#else + long double z; + z = __ieee754_log10l(x); + if(_LIB_VERSION == _IEEE_ || __isnanl(x)) return z; + if(x<=0.0) { + if(x==0.0) + return __kernel_standard(x,x,218); /* log10(0) */ + else + return __kernel_standard(x,x,219); /* log10(x<0) */ + } else + return z; +#endif +} +weak_alias (__log10l, log10l) diff --git a/sysdeps/libm-ieee754/w_logl.c b/sysdeps/libm-ieee754/w_logl.c new file mode 100644 index 0000000..bb979c2 --- /dev/null +++ b/sysdeps/libm-ieee754/w_logl.c @@ -0,0 +1,48 @@ +/* w_logl.c -- long double version of w_log.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * wrapper logl(x) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + long double __logl(long double x) /* wrapper logl */ +#else + long double __logl(x) /* wrapper logl */ + long double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_logl(x); +#else + long double z; + z = __ieee754_logl(x); + if(_LIB_VERSION == _IEEE_ || __isnanl(x) || x > 0.0) return z; + if(x==0.0) + return __kernel_standard(x,x,216); /* log(0) */ + else + return __kernel_standard(x,x,217); /* log(x<0) */ +#endif +} +weak_alias (__logl, logl) diff --git a/sysdeps/libm-ieee754/w_powl.c b/sysdeps/libm-ieee754/w_powl.c new file mode 100644 index 0000000..019664e --- /dev/null +++ b/sysdeps/libm-ieee754/w_powl.c @@ -0,0 +1,64 @@ +/* w_powl.c -- long double version of w_pow.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. + * ==================================================== + */ + +/* + * wrapper powl(x,y) return x**y + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + long double __powl(long double x, long double y)/* wrapper powl */ +#else + long double __powl(x,y) /* wrapper powl */ + long double x,y; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_powl(x,y); +#else + long double z; + z=__ieee754_powl(x,y); + if(_LIB_VERSION == _IEEE_|| __isnanl(y)) return z; + if(__isnanl(x)) { + if(y==0.0) + return __kernel_standard(x,y,242); /* pow(NaN,0.0) */ + else + return z; + } + if(x==0.0){ + if(y==0.0) + return __kernel_standard(x,y,220); /* pow(0.0,0.0) */ + if(__finite(y)&&y<0.0) + return __kernel_standard(x,y,223); /* pow(0.0,negative) */ + return z; + } + if(!__finitel(z)) { + if(__finitel(x)&&__finitel(y)) { + if(__isnanl(z)) + return __kernel_standard(x,y,224); /* pow neg**non-int */ + else + return __kernel_standard(x,y,221); /* pow overflow */ + } + } + if(z==0.0&&__finitel(x)&&__finitel(y)) + return __kernel_standard(x,y,222); /* pow underflow */ + return z; +#endif +} +weak_alias (__powl, powl) diff --git a/sysdeps/libm-ieee754/w_remainderl.c b/sysdeps/libm-ieee754/w_remainderl.c new file mode 100644 index 0000000..2841401 --- /dev/null +++ b/sysdeps/libm-ieee754/w_remainderl.c @@ -0,0 +1,48 @@ +/* w_remainderl.c -- long double version of w_remainder.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * wrapper remainderl(x,p) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + long double __remainderl(long double x, long double y) + /* wrapper remainderl */ +#else + long double __remainderl(x,y) /* wrapper remainder */ + long double x,y; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_remainderl(x,y); +#else + long double z; + z = __ieee754_remainderl(x,y); + if(_LIB_VERSION == _IEEE_ || __isnanl(y)) return z; + if(y==0.0) + return __kernel_standard(x,y,228); /* remainder(x,0) */ + else + return z; +#endif +} +weak_alias (__remainderl, remainderl) diff --git a/sysdeps/libm-ieee754/w_scalbl.c b/sysdeps/libm-ieee754/w_scalbl.c new file mode 100644 index 0000000..ff5117d --- /dev/null +++ b/sysdeps/libm-ieee754/w_scalbl.c @@ -0,0 +1,65 @@ +/* w_scalbl.c -- long double version of w_scalb.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * wrapper scalbl(long double x, long double fn) is provide for + * passing various standard test suite. One + * should use scalbnl() instead. + */ + +#include "math.h" +#include "math_private.h" + +#include <errno.h> + +#ifdef __STDC__ +#ifdef _SCALB_INT + long double __scalbl(long double x, int fn) /* wrapper scalbl */ +#else + long double __scalbl(long double x, long double fn)/* wrapper scalbl */ +#endif +#else + long double __scalbl(x,fn) /* wrapper scalbl */ +#ifdef _SCALB_INT + long double x; int fn; +#else + long double x,fn; +#endif +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_scalbl(x,fn); +#else + long double z; + z = __ieee754_scalbl(x,fn); + if(_LIB_VERSION == _IEEE_) return z; + if(!(__finitel(z)||__isnanl(z))&&__finitel(x)) { + return __kernel_standard(x,(double)fn,232); /* scalb overflow */ + } + if(z==0.0&&z!=x) { + return __kernel_standard(x,(double)fn,233); /* scalb underflow */ + } +#ifndef _SCALB_INT + if(!__finitel(fn)) errno = ERANGE; +#endif + return z; +#endif +} +weak_alias (__scalbl, scalbl) diff --git a/sysdeps/libm-ieee754/w_sinhl.c b/sysdeps/libm-ieee754/w_sinhl.c new file mode 100644 index 0000000..3e93cc5 --- /dev/null +++ b/sysdeps/libm-ieee754/w_sinhl.c @@ -0,0 +1,47 @@ +/* w_sinhl.c -- long double version of w_sinh.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * wrapper sinhl(x) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + long double __sinhl(long double x) /* wrapper sinhl */ +#else + long double __sinhl(x) /* wrapper sinhl */ + long double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_sinhl(x); +#else + long double z; + z = __ieee754_sinhl(x); + if(_LIB_VERSION == _IEEE_) return z; + if(!__finitel(z)&&__finitel(x)) { + return __kernel_standard(x,x,225); /* sinh overflow */ + } else + return z; +#endif +} +weak_alias (__sinhl, sinhl) diff --git a/sysdeps/libm-ieee754/w_sqrtl.c b/sysdeps/libm-ieee754/w_sqrtl.c new file mode 100644 index 0000000..5873ce9 --- /dev/null +++ b/sysdeps/libm-ieee754/w_sqrtl.c @@ -0,0 +1,47 @@ +/* w_sqrtl.c -- long double version of w_sqrt.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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * wrapper sqrtl(x) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + long double __sqrtl(long double x) /* wrapper sqrtl */ +#else + long double __sqrtl(x) /* wrapper sqrtl */ + long double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_sqrtl(x); +#else + long double z; + z = __ieee754_sqrtl(x); + if(_LIB_VERSION == _IEEE_ || __isnanl(x)) return z; + if(x<0.0) { + return __kernel_standard(x,x,226); /* sqrt(negative) */ + } else + return z; +#endif +} +weak_alias (__sqrtl, sqrtl) diff --git a/sysdeps/mach/hurd/getlogin_r.c b/sysdeps/mach/hurd/getlogin_r.c new file mode 100644 index 0000000..16eca67 --- /dev/null +++ b/sysdeps/mach/hurd/getlogin_r.c @@ -0,0 +1,41 @@ +/* Reentrant function to return the current login name. Hurd version. +Copyright (C) 1996 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 Library General Public License as +published by the Free Software Foundation; either version 2 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 +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <unistd.h> +#include <hurd.h> +#include <string.h> + +/* Return at most NAME_LEN characters of the login name of the user in NAME. + If it cannot be determined or some other error occured, return the error + code. Otherwise return 0. */ +int +getlogin_r (name, name_len) + char *name; + size_t name_len; +{ + static char login[1024]; /* XXX */ + error_t err; + + if (err = __USEPORT (PROC, __proc_getlogin (port, login))) + return errno = err; + + strncpy (name, login, name_len); + return 0; +} diff --git a/sysdeps/posix/ttyname_r.c b/sysdeps/posix/ttyname_r.c index e225da2..30f0583 100644 --- a/sysdeps/posix/ttyname_r.c +++ b/sysdeps/posix/ttyname_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993, 1995 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 93, 95, 96 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 @@ -48,7 +48,7 @@ ttyname_r (fd, buf, buflen) /* Test for the absolute minimal size. This makes life easier inside the loop. */ - if (buflen < sizeof (dev) + 2) + if (buflen < (int) (sizeof (dev) + 2)) { errno = EINVAL; return -1; @@ -73,8 +73,8 @@ ttyname_r (fd, buf, buflen) { char *cp; - cp = stpncpy (&buf[sizeof (dev) + 1], d->d_name, - MIN (d->d_namlen + 1, buflen)); + cp = __stpncpy (&buf[sizeof (dev) + 1], d->d_name, + MIN ((int) (_D_EXACT_NAMLEN (d) + 1), buflen)); cp[0] = '\0'; if (stat (buf, &st) == 0 && st.st_dev == mydev) diff --git a/sysdeps/stub/getlogin_r.c b/sysdeps/stub/getlogin_r.c new file mode 100644 index 0000000..bf29c7c --- /dev/null +++ b/sysdeps/stub/getlogin_r.c @@ -0,0 +1,35 @@ +/* Reentrant function to return the current login name. Stub version. +Copyright (C) 1996 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 Library General Public License as +published by the Free Software Foundation; either version 2 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 +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <unistd.h> + +/* Return at most NAME_LEN characters of the login name of the user in NAME. + If it cannot be determined or some other error occured, return the error + code. Otherwise return 0. */ +int +getlogin_r (name, name_len) + char *name; + size_t name_len; +{ + errno = ENOSYS; + return errno; +} + +stub_warning (getlogin_r) diff --git a/sysdeps/unix/getlogin.c b/sysdeps/unix/getlogin.c index 504a7aa..00baf68 100644 --- a/sysdeps/unix/getlogin.c +++ b/sysdeps/unix/getlogin.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1996 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 @@ -17,7 +17,6 @@ not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <ansidecl.h> -#include <stddef.h> #include <errno.h> #include <unistd.h> #include <string.h> @@ -27,38 +26,29 @@ Cambridge, MA 02139, USA. */ #include <utmp.h> -/* Defined in ttyname.c. */ -extern char *__ttyname; - /* Return the login name of the user, or NULL if it can't be determined. The returned pointer, if not NULL, is good only until the next call. */ char * DEFUN_VOID(getlogin) { - char save_tty_pathname[2 + 2 * NAME_MAX]; - char *save_ttyname; - char *real_tty_path; + char tty_pathname[2 + 2 * NAME_MAX]; + char *real_tty_path = tty_pathname; char *result = NULL; - FILE *f; - static struct utmp ut; - - if (__ttyname == NULL) - save_ttyname = NULL; - else - save_ttyname = strcpy (save_tty_pathname, __ttyname); + static struct utmp_data utmp_data; + struct utmp *ut; { - int err; + int err = 0; int d = __open ("/dev/tty", 0); if (d < 0) return NULL; - real_tty_path = ttyname (d); - err = errno; + if (ttyname_r (d, real_tty_path, sizeof (tty_pathname)) < 0) + err = errno; (void) close (d); - if (real_tty_path == NULL) + if (errno != 0) { errno = err; return NULL; @@ -67,24 +57,18 @@ DEFUN_VOID(getlogin) real_tty_path += 5; /* Remove "/dev/". */ - f = fopen ("/etc/utmp", "r"); - if (f != NULL) + setutent_r (&utmp_data); + if (getutline_r (real_tty_path, &ut, &utmp_data) < 0) { - while (fread ((PTR) &ut, sizeof(ut), 1, f) == 1) - if (!strncmp (ut.ut_line, real_tty_path, sizeof (ut.ut_line))) - { - result = ut.ut_name; - /* The name is not null-terminated if - it is as long as sizeof (ut.ut_name). */ - result[sizeof (ut.ut_name)] = '\0'; - break; - } - (void) fclose (f); + if (errno == ESRCH) + /* The caller expects ENOENT if nothing is found. */ + errno = ENOENT; + result = NULL; } + else + result = ut->ut_line; + + endutent_r (&utmp_data); - if (save_ttyname != NULL) - strcpy (__ttyname, save_ttyname); - if (result == NULL) - errno = ENOENT; return result; } diff --git a/sysdeps/unix/getlogin_r.c b/sysdeps/unix/getlogin_r.c new file mode 100644 index 0000000..15afdee --- /dev/null +++ b/sysdeps/unix/getlogin_r.c @@ -0,0 +1,80 @@ +/* Reentrant function to return the current login name. Unix version. +Copyright (C) 1991, 1992, 1996 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 Library General Public License as +published by the Free Software Foundation; either version 2 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 +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include <errno.h> +#include <unistd.h> +#include <string.h> +#include <stdio.h> +#include <limits.h> +#include <fcntl.h> + +#include <utmp.h> + +/* Return at most NAME_LEN characters of the login name of the user in NAME. + If it cannot be determined or some other error occured, return the error + code. Otherwise return 0. */ + +int +getlogin_r (name, name_len) + char *name; + size_t name_len; +{ + char tty_pathname[2 + 2 * NAME_MAX]; + char *real_tty_path = tty_pathname; + int result = 0; + struct utmp_data utmp_data; + struct utmp *ut; + + { + int err; + int d = __open ("/dev/tty", 0); + if (d < 0) + return errno; + + result = ttyname_r (d, real_tty_path, sizeof (tty_pathname)); + err = errno; + (void) close (d); + + if (result < 0) + { + errno = err; + return err; + } + } + + real_tty_path += 5; /* Remove "/dev/". */ + + setutent_r (&utmp_data); + if (getutline_r (real_tty_path, &ut, &utmp_data) < 0) + { + if (errno == ESRCH) + /* The caller expects ENOENT if nothing is found. */ + result = ENOENT; + else + result = errno; + } + else + { + strncpy (name, ut->ut_line, name_len); + result = 0; + } + endutent_r (&utmp_data); + + return result; +} |