From jakub@redhat.com Sat Jun 2 12:07:00 2001 From: jakub@redhat.com (Jakub Jelinek) Date: Sat, 02 Jun 2001 12:07:00 -0000 Subject: [PATCH] Fix i386 frexpl Message-ID: <20010602210913.B1253@sunsite.ms.mff.cuni.cz> Hi! i386 assembly frexpl.S has a bug in test for denormals (where C code tests if (ix==0x0000) { /* subnormal */ x *= two65; GET_LDOUBLE_EXP(se,x); ix = se&0x7fff; *eptr = -65; } assembly has cmpl $0, %eax je 2f special denormal handling 2: (%eax holds ix)), so frexpl was needlessly slow for most normalized numbers and was broken for denormals and values with large exponents (the former because the needed special care was not given to it, the latter because it overflowed). In December last year frexpl got a workaround for the large exponent case, but denormals are still broken. The following patch backs out 2000-12-03 changes (leaves fwait in) and fixes the branch, plus adds testcase for this which passed glibc make check. 2001-06-02 Jakub Jelinek * sysdeps/i386/fpu/s_frexpl.S (__frexpl): Mostly revert 2000-12-03 changes, do the special handling for denormal numbers, not for normalized numbers (patch by ). * math/test-misc.c (main): Test frexpl with denormal arguments. --- libc/math/test-misc.c.jj Wed Jan 31 16:35:03 2001 +++ libc/math/test-misc.c Sat Jun 2 20:36:01 2001 @@ -79,6 +79,28 @@ main (void) } puts ("ok"); } + + for (i = LDBL_MIN_EXP, x = LDBL_MIN; i >= LDBL_MIN_EXP - LDBL_MANT_DIG + 1; + --i, x /= 2.0L) + { + printf ("2^%d: ", i); + + r = frexpl (x, &e); + if (r != 0.5L) + { + printf ("mantissa incorrect: %.20La\n", r); + result = 1; + continue; + } + if (e != i) + { + printf ("exponent wrong %d (%.20Lg)\n", e, x); + result = 1; + continue; + } + puts ("ok"); + } + } # endif --- libc/sysdeps/i386/fpu/s_frexpl.S.jj Mon Dec 4 15:07:46 2000 +++ libc/sysdeps/i386/fpu/s_frexpl.S Sat Jun 2 19:56:15 2001 @@ -1,5 +1,5 @@ /* ix87 specific frexp implementation for long double. - Copyright (C) 1997, 2000 Free Software Foundation, Inc. + Copyright (C) 1997, 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997. @@ -32,12 +32,6 @@ ASM_TYPE_DIRECTIVE(two64,@object) two64: .byte 0, 0, 0, 0, 0, 0, 0xf0, 0x43 ASM_SIZE_DIRECTIVE(two64) - /* The following is LDBL_MAX / ldexp (1.0, 64), the largest - number we can handle the normal way. */ - ASM_TYPE_DIRECTIVE(largest,@object) -largest: - .byte 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbe, 0x7f, 0, 0 - ASM_SIZE_DIRECTIVE(largest) #ifdef PIC #define MO(op) op##@GOTOFF(%edx) @@ -67,10 +61,7 @@ ENTRY (BP_SYM (__frexpl)) je 1f cmpl $0, %eax - je 2f - - cmpl $0x7fbe, %eax - ja 4f + jne 2f fldt VAL0(%esp) #ifdef PIC @@ -102,15 +93,5 @@ ENTRY (BP_SYM (__frexpl)) LEAVE ret - -4: movl VAL2(%esp), %ecx - movl %ecx, %edx - andl $0x7fff, %ecx - - andl $0x8000, %edx - subl $16382, %ecx - orl $0x3ffe, %edx - movl %edx, VAL2(%esp) - jmp 1b END (BP_SYM (__frexpl)) weak_alias (BP_SYM (__frexpl), BP_SYM (frexpl)) Jakub From jakub@redhat.com Mon Jun 4 06:01:00 2001 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 04 Jun 2001 06:01:00 -0000 Subject: [PATCH] Fix llroundl Message-ID: <20010604150417.C1253@sunsite.ms.mff.cuni.cz> Hi! ldbl-96 llroundl(4294967295.5) returns 0, although it should return 4294967296LL. The problem is that on this input i0 == 0xffffffff, i1 == 0x80000000, j0 == 31, so llroundl rounds up (by doing ++i0, which overflows and is suddenly 0). Fixed with a patch below, where the rounding is already done on long long variable. 2001-06-04 Jakub Jelinek * math/libm-test.inc (llround_test): Add two new llround tests. * sysdeps/ieee754/ldbl-96/s_llroundl.c (__llroundl): Don't allow overflow when rounding away from zero. --- libc/math/libm-test.inc.jj Wed May 23 09:21:45 2001 +++ libc/math/libm-test.inc Mon Jun 4 10:01:59 2001 @@ -3302,6 +3302,13 @@ llround_test (void) /* 0x100000000000000 */ TEST_f_L (llround, 72057594037927936.0, 72057594037927936LL); +#ifndef TEST_FLOAT + /* 0x100000000 */ + TEST_f_L (llround, 4294967295.5, 4294967296LL); + /* 0x200000000 */ + TEST_f_L (llround, 8589934591.5, 8589934592LL); +#endif + END (llround); } --- libc/sysdeps/ieee754/ldbl-96/s_llroundl.c.jj Wed Jul 14 02:14:08 1999 +++ libc/sysdeps/ieee754/ldbl-96/s_llroundl.c Mon Jun 4 09:50:49 2001 @@ -1,5 +1,5 @@ /* Round long double value to long long int. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997. @@ -59,13 +59,13 @@ __llroundl (long double x) else { u_int32_t j = i1 + (0x80000000 >> (j0 - 31)); + + result = (long long int) i0; if (j < i1) - ++i0; + ++result; - if (j0 == 31) - result = (long long int) i0; - else - result = ((long long int) i0 << (j0 - 31)) | (j >> (63 - j0)); + if (j0 > 31) + result = (result << (j0 - 31)) | (j >> (63 - j0)); } } else Jakub From jakub@redhat.com Mon Jun 4 06:03:00 2001 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 04 Jun 2001 06:03:00 -0000 Subject: [PATCH] Fix log2* error handling Message-ID: <20010604150630.D1253@sunsite.ms.mff.cuni.cz> Hi! According to ISO C99, log2 has to return domain range error if argument is negative and error may be signalled if argument is 0 (similarly to log or log10). So I guess we need a log2 wrapper, implemented below: 2001-06-04 Jakub Jelinek * math/Makefile (libm-calls): Add e_log2, w_log2, remove s_log2. * math/math_private.h (__ieee754_log2, __ieee754_log2f, __ieee754_log2l): New prototypes. * sysdeps/generic/w_log2.c: New file. * sysdeps/generic/w_log2f.c: New file. * sysdeps/generic/w_log2l.c: New file. * sysdeps/generic/s_log2l.c: Move... * sysdeps/generic/e_log2l.c: ...to here. Rename to __ieee754_log2l. * sysdeps/ieee754/k_standard.c (__kernel_standard): Handle log2(0) and log2(x < 0). * sysdeps/i386/fpu/s_log2.S: Move... * sysdeps/i386/fpu/e_log2.S: ...to here. Rename to __ieee754_log2. * sysdeps/i386/fpu/s_log2f.S: Move... * sysdeps/i386/fpu/e_log2f.S: ...to here. Rename to __ieee754_log2f. * sysdeps/i386/fpu/s_log2l.S: Move... * sysdeps/i386/fpu/e_log2l.S: ...to here. Rename to __ieee754_log2l. * sysdeps/m68k/fpu/s_log2.S: Move... * sysdeps/m68k/fpu/e_log2.S: ...to here. Rename to __ieee754_log2. * sysdeps/m68k/fpu/s_log2f.S: Move... * sysdeps/m68k/fpu/e_log2f.S: ...to here. Rename to __ieee754_log2f. * sysdeps/m68k/fpu/s_log2l.S: Move... * sysdeps/m68k/fpu/e_log2l.S: ...to here. Rename to __ieee754_log2l. * sysdeps/ieee754/dbl-64/s_log2.c: Move... * sysdeps/ieee754/dbl-64/e_log2.c: ...to here. Rename to __ieee754_log2. * sysdeps/ieee754/flt-32/s_log2f.c: Move... * sysdeps/ieee754/flt-32/e_log2f.c: ...to here. Rename to __ieee754_log2f. --- libc/math/Makefile.jj Tue Mar 20 13:45:34 2001 +++ libc/math/Makefile Mon Jun 4 10:43:00 2001 @@ -53,11 +53,11 @@ libm-calls = e_acos e_acosh e_asin e_ata w_tgamma w_hypot w_j0 w_j1 w_jn w_lgamma w_lgamma_r \ w_log w_log10 w_pow w_remainder w_scalb w_sinh w_sqrt \ s_signbit s_fpclassify s_fmax s_fmin s_fdim s_nan s_trunc \ - s_remquo s_log2 e_exp2 s_round s_nearbyint s_sincos \ + s_remquo e_log2 e_exp2 s_round s_nearbyint s_sincos \ conj cimag creal cabs carg s_cexp s_csinh s_ccosh s_clog \ s_catan s_casin s_ccos s_csin s_ctan s_ctanh s_cacos \ 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 + s_fma s_lrint s_llrint s_lround s_llround e_exp10 w_log2 dbl-only-routines := branred doasin dosincos halfulp mpa mpatan2 \ mpatan mpexp mplog mpsqrt mptan sincos32 slowexp \ slowpow --- libc/math/math_private.h.jj Wed May 23 09:21:45 2001 +++ libc/math/math_private.h Mon Jun 4 10:52:07 2001 @@ -169,6 +169,7 @@ extern double __ieee754_gamma_r (double, extern double __ieee754_lgamma (double); extern double __ieee754_gamma (double); extern double __ieee754_log10 (double); +extern double __ieee754_log2 (double); extern double __ieee754_sinh (double); extern double __ieee754_hypot (double,double); extern double __ieee754_j0 (double); @@ -211,6 +212,7 @@ extern float __ieee754_gammaf_r (float,i extern float __ieee754_lgammaf (float); extern float __ieee754_gammaf (float); extern float __ieee754_log10f (float); +extern float __ieee754_log2f (float); extern float __ieee754_sinhf (float); extern float __ieee754_hypotf (float,float); extern float __ieee754_j0f (float); @@ -250,6 +252,7 @@ extern long double __ieee754_gammal_r (l extern long double __ieee754_lgammal (long double); extern long double __ieee754_gammal (long double); extern long double __ieee754_log10l (long double); +extern long double __ieee754_log2l (long double); extern long double __ieee754_sinhl (long double); extern long double __ieee754_hypotl (long double,long double); extern long double __ieee754_j0l (long double); --- libc/sysdeps/generic/w_log2.c.jj Mon Jun 4 10:17:22 2001 +++ libc/sysdeps/generic/w_log2.c Mon Jun 4 11:47:28 2001 @@ -0,0 +1,32 @@ +/* + * wrapper log2(X) + */ + +#include "math.h" +#include "math_private.h" + +double +__log2 (double x) /* wrapper log2 */ +{ +#ifdef _IEEE_LIBM + return __ieee754_log2 (x); +#else + double z; + z = __ieee754_log2 (x); + if (_LIB_VERSION == _IEEE_ || __isnan (x)) return z; + if (x <= 0.0) + { + if (x == 0.0) + return __kernel_standard (x, x, 48); /* log2 (0) */ + else + return __kernel_standard (x, x, 49); /* log2 (x < 0) */ + } + else + return z; +#endif +} +weak_alias (__log2, log2) +#ifdef NO_LONG_DOUBLE +strong_alias (__log2, __log2l) +weak_alias (__log2, log2l) +#endif --- libc/sysdeps/generic/w_log2f.c.jj Mon Jun 4 10:17:22 2001 +++ libc/sysdeps/generic/w_log2f.c Mon Jun 4 11:47:21 2001 @@ -0,0 +1,30 @@ +/* + * wrapper log2(X) + */ + +#include "math.h" +#include "math_private.h" + +float +__log2f (float x) /* wrapper log2f */ +{ +#ifdef _IEEE_LIBM + return __ieee754_log2f (x); +#else + float z; + z = __ieee754_log2f (x); + if (_LIB_VERSION == _IEEE_ || __isnanf (x)) return z; + if (x <= 0.0f) + { + if (x == 0.0f) + /* log2f (0) */ + return __kernel_standard ((double) x, (double) x, 148); + else + /* log2f (x < 0) */ + return __kernel_standard ((double) x, (double) x, 149); + } + else + return z; +#endif +} +weak_alias (__log2f, log2f) --- libc/sysdeps/generic/w_log2l.c.jj Mon Jun 4 10:17:22 2001 +++ libc/sysdeps/generic/w_log2l.c Mon Jun 4 11:47:40 2001 @@ -0,0 +1,28 @@ +/* + * wrapper log2l(X) + */ + +#include "math.h" +#include "math_private.h" + +long double +__log2l (long double x) /* wrapper log2l */ +{ +#ifdef _IEEE_LIBM + return __ieee754_log2l (x); +#else + long double z; + z = __ieee754_log2l (x); + if (_LIB_VERSION == _IEEE_ || __isnanl (x)) return z; + if (x <= 0.0) + { + if (x == 0.0) + return __kernel_standard (x, x, 248); /* log2l (0) */ + else + return __kernel_standard (x, x, 249); /* log2l (x < 0) */ + } + else + return z; +#endif +} +weak_alias (__log2l, log2l) --- libc/sysdeps/generic/s_log2l.c.jj Mon Oct 13 05:52:31 1997 +++ libc/sysdeps/generic/s_log2l.c Mon Jun 4 10:41:10 2001 @@ -1,15 +0,0 @@ -#include -#include -#include - -long double -__log2l (long double x) -{ - fputs ("__log2l not implemented\n", stderr); - __set_errno (ENOSYS); - return 0.0; -} -weak_alias (__log2l, log2l) - -stub_warning (log2l) -#include --- libc/sysdeps/generic/e_log2l.c.jj Mon Jun 4 10:41:18 2001 +++ libc/sysdeps/generic/e_log2l.c Mon Jun 4 10:41:42 2001 @@ -0,0 +1,14 @@ +#include +#include +#include + +long double +__ieee754_log2l (long double x) +{ + fputs ("__ieee754_log2l not implemented\n", stderr); + __set_errno (ENOSYS); + return 0.0; +} + +stub_warning (log2l) +#include --- libc/sysdeps/i386/fpu/s_log2.S.jj Fri Nov 12 16:30:30 1999 +++ libc/sysdeps/i386/fpu/s_log2.S Mon Jun 4 10:34:33 2001 @@ -1,68 +0,0 @@ -/* - * Written by J.T. Conklin . - * Adapted for use as log2 by Ulrich Drepper . - * Public domain. - * - * Changed to use fyl2xp1 for values near 1, . - */ - -#include - -#ifdef __ELF__ - .section .rodata -#else - .text -#endif - .align ALIGNARG(4) - ASM_TYPE_DIRECTIVE(one,@object) -one: .double 1.0 - ASM_SIZE_DIRECTIVE(one) - /* It is not important that this constant is precise. It is only - a value which is known to be on the safe side for using the - fyl2xp1 instruction. */ - ASM_TYPE_DIRECTIVE(limit,@object) -limit: .double 0.29 - ASM_SIZE_DIRECTIVE(limit) - - -#ifdef PIC -#define MO(op) op##@GOTOFF(%edx) -#else -#define MO(op) op -#endif - - .text -ENTRY(__log2) -#ifdef PIC - call 1f -1: popl %edx - addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %edx -#endif - fldl MO(one) - fldl 4(%esp) // x : 1 - fxam - fnstsw - fld %st // x : x : 1 - sahf - jc 3f // in case x is NaN or ????Inf -4: fsub %st(2), %st // x-1 : x : 1 - fld %st // x-1 : x-1 : x : 1 - fabs // |x-1| : x-1 : x : 1 - fcompl MO(limit) // x-1 : x : 1 - fnstsw // x-1 : x : 1 - andb $0x45, %ah - jz 2f - fstp %st(1) // x-1 : 1 - fyl2xp1 // log(x) - ret - -2: fstp %st(0) // x : 1 - fyl2x // log(x) - ret - -3: jp 4b // in case x is ????Inf - fstp %st(1) - fstp %st(1) - ret -END (__log2) -weak_alias (__log2, log2) --- libc/sysdeps/i386/fpu/s_log2f.S.jj Fri Nov 12 16:30:30 1999 +++ libc/sysdeps/i386/fpu/s_log2f.S Mon Jun 4 10:34:33 2001 @@ -1,68 +0,0 @@ -/* - * Written by J.T. Conklin . - * Adapted for use as log2 by Ulrich Drepper . - * Public domain. - * - * Changed to use fyl2xp1 for values near 1, . - */ - -#include - -#ifdef __ELF__ - .section .rodata -#else - .text -#endif - .align ALIGNARG(4) - ASM_TYPE_DIRECTIVE(one,@object) -one: .double 1.0 - ASM_SIZE_DIRECTIVE(one) - /* It is not important that this constant is precise. It is only - a value which is known to be on the safe side for using the - fyl2xp1 instruction. */ - ASM_TYPE_DIRECTIVE(limit,@object) -limit: .double 0.29 - ASM_SIZE_DIRECTIVE(limit) - - -#ifdef PIC -#define MO(op) op##@GOTOFF(%edx) -#else -#define MO(op) op -#endif - - .text -ENTRY(__log2f) -#ifdef PIC - call 1f -1: popl %edx - addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %edx -#endif - fldl MO(one) - flds 4(%esp) // x : 1 - fxam - fnstsw - fld %st // x : x : 1 - sahf - jc 3f // in case x is NaN or ????Inf -4: fsub %st(2), %st // x-1 : x : 1 - fld %st // x-1 : x-1 : x : 1 - fabs // |x-1| : x-1 : x : 1 - fcompl MO(limit) // x-1 : x : 1 - fnstsw // x-1 : x : 1 - andb $0x45, %ah - jz 2f - fstp %st(1) // x-1 : 1 - fyl2xp1 // log(x) - ret - -2: fstp %st(0) // x : 1 - fyl2x // log(x) - ret - -3: jp 4b // in case x is ????Inf - fstp %st(1) - fstp %st(1) - ret -END (__log2f) -weak_alias (__log2f, log2f) --- libc/sysdeps/i386/fpu/s_log2l.S.jj Fri Nov 12 16:30:30 1999 +++ libc/sysdeps/i386/fpu/s_log2l.S Mon Jun 4 10:34:33 2001 @@ -1,68 +0,0 @@ -/* - * Written by J.T. Conklin . - * Adapted for use as log2 by Ulrich Drepper . - * Public domain. - * - * Changed to use fyl2xp1 for values near 1, . - */ - -#include - -#ifdef __ELF__ - .section .rodata -#else - .text -#endif - .align ALIGNARG(4) - ASM_TYPE_DIRECTIVE(one,@object) -one: .double 1.0 - ASM_SIZE_DIRECTIVE(one) - /* It is not important that this constant is precise. It is only - a value which is known to be on the safe side for using the - fyl2xp1 instruction. */ - ASM_TYPE_DIRECTIVE(limit,@object) -limit: .double 0.29 - ASM_SIZE_DIRECTIVE(limit) - - -#ifdef PIC -#define MO(op) op##@GOTOFF(%edx) -#else -#define MO(op) op -#endif - - .text -ENTRY(__log2l) -#ifdef PIC - call 1f -1: popl %edx - addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %edx -#endif - fldl MO(one) - fldt 4(%esp) // x : 1 - fxam - fnstsw - fld %st // x : x : 1 - sahf - jc 3f // in case x is NaN or ????Inf -4: fsub %st(2), %st // x-1 : x : 1 - fld %st // x-1 : x-1 : x : 1 - fabs // |x-1| : x-1 : x : 1 - fcompl MO(limit) // x-1 : x : 1 - fnstsw // x-1 : x : 1 - andb $0x45, %ah - jz 2f - fstp %st(1) // x-1 : 1 - fyl2xp1 // log(x) - ret - -2: fstp %st(0) // x : 1 - fyl2x // log(x) - ret - -3: jp 4b // in case x is ????Inf - fstp %st(1) - fstp %st(1) - ret -END (__log2l) -weak_alias (__log2l, log2l) --- libc/sysdeps/i386/fpu/e_log2f.S.jj Mon Jun 4 10:34:55 2001 +++ libc/sysdeps/i386/fpu/e_log2f.S Mon Jun 4 10:35:10 2001 @@ -0,0 +1,67 @@ +/* + * Written by J.T. Conklin . + * Adapted for use as log2 by Ulrich Drepper . + * Public domain. + * + * Changed to use fyl2xp1 for values near 1, . + */ + +#include + +#ifdef __ELF__ + .section .rodata +#else + .text +#endif + .align ALIGNARG(4) + ASM_TYPE_DIRECTIVE(one,@object) +one: .double 1.0 + ASM_SIZE_DIRECTIVE(one) + /* It is not important that this constant is precise. It is only + a value which is known to be on the safe side for using the + fyl2xp1 instruction. */ + ASM_TYPE_DIRECTIVE(limit,@object) +limit: .double 0.29 + ASM_SIZE_DIRECTIVE(limit) + + +#ifdef PIC +#define MO(op) op##@GOTOFF(%edx) +#else +#define MO(op) op +#endif + + .text +ENTRY(__ieee754_log2f) +#ifdef PIC + call 1f +1: popl %edx + addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %edx +#endif + fldl MO(one) + flds 4(%esp) // x : 1 + fxam + fnstsw + fld %st // x : x : 1 + sahf + jc 3f // in case x is NaN or ????Inf +4: fsub %st(2), %st // x-1 : x : 1 + fld %st // x-1 : x-1 : x : 1 + fabs // |x-1| : x-1 : x : 1 + fcompl MO(limit) // x-1 : x : 1 + fnstsw // x-1 : x : 1 + andb $0x45, %ah + jz 2f + fstp %st(1) // x-1 : 1 + fyl2xp1 // log(x) + ret + +2: fstp %st(0) // x : 1 + fyl2x // log(x) + ret + +3: jp 4b // in case x is ????Inf + fstp %st(1) + fstp %st(1) + ret +END (__ieee754_log2f) --- libc/sysdeps/i386/fpu/e_log2l.S.jj Mon Jun 4 10:34:55 2001 +++ libc/sysdeps/i386/fpu/e_log2l.S Mon Jun 4 10:35:24 2001 @@ -0,0 +1,67 @@ +/* + * Written by J.T. Conklin . + * Adapted for use as log2 by Ulrich Drepper . + * Public domain. + * + * Changed to use fyl2xp1 for values near 1, . + */ + +#include + +#ifdef __ELF__ + .section .rodata +#else + .text +#endif + .align ALIGNARG(4) + ASM_TYPE_DIRECTIVE(one,@object) +one: .double 1.0 + ASM_SIZE_DIRECTIVE(one) + /* It is not important that this constant is precise. It is only + a value which is known to be on the safe side for using the + fyl2xp1 instruction. */ + ASM_TYPE_DIRECTIVE(limit,@object) +limit: .double 0.29 + ASM_SIZE_DIRECTIVE(limit) + + +#ifdef PIC +#define MO(op) op##@GOTOFF(%edx) +#else +#define MO(op) op +#endif + + .text +ENTRY(__ieee754_log2l) +#ifdef PIC + call 1f +1: popl %edx + addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %edx +#endif + fldl MO(one) + fldt 4(%esp) // x : 1 + fxam + fnstsw + fld %st // x : x : 1 + sahf + jc 3f // in case x is NaN or ????Inf +4: fsub %st(2), %st // x-1 : x : 1 + fld %st // x-1 : x-1 : x : 1 + fabs // |x-1| : x-1 : x : 1 + fcompl MO(limit) // x-1 : x : 1 + fnstsw // x-1 : x : 1 + andb $0x45, %ah + jz 2f + fstp %st(1) // x-1 : 1 + fyl2xp1 // log(x) + ret + +2: fstp %st(0) // x : 1 + fyl2x // log(x) + ret + +3: jp 4b // in case x is ????Inf + fstp %st(1) + fstp %st(1) + ret +END (__ieee754_log2l) --- libc/sysdeps/i386/fpu/e_log2.S.jj Mon Jun 4 10:34:55 2001 +++ libc/sysdeps/i386/fpu/e_log2.S Mon Jun 4 10:35:38 2001 @@ -0,0 +1,67 @@ +/* + * Written by J.T. Conklin . + * Adapted for use as log2 by Ulrich Drepper . + * Public domain. + * + * Changed to use fyl2xp1 for values near 1, . + */ + +#include + +#ifdef __ELF__ + .section .rodata +#else + .text +#endif + .align ALIGNARG(4) + ASM_TYPE_DIRECTIVE(one,@object) +one: .double 1.0 + ASM_SIZE_DIRECTIVE(one) + /* It is not important that this constant is precise. It is only + a value which is known to be on the safe side for using the + fyl2xp1 instruction. */ + ASM_TYPE_DIRECTIVE(limit,@object) +limit: .double 0.29 + ASM_SIZE_DIRECTIVE(limit) + + +#ifdef PIC +#define MO(op) op##@GOTOFF(%edx) +#else +#define MO(op) op +#endif + + .text +ENTRY(__ieee754_log2) +#ifdef PIC + call 1f +1: popl %edx + addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %edx +#endif + fldl MO(one) + fldl 4(%esp) // x : 1 + fxam + fnstsw + fld %st // x : x : 1 + sahf + jc 3f // in case x is NaN or ????Inf +4: fsub %st(2), %st // x-1 : x : 1 + fld %st // x-1 : x-1 : x : 1 + fabs // |x-1| : x-1 : x : 1 + fcompl MO(limit) // x-1 : x : 1 + fnstsw // x-1 : x : 1 + andb $0x45, %ah + jz 2f + fstp %st(1) // x-1 : 1 + fyl2xp1 // log(x) + ret + +2: fstp %st(0) // x : 1 + fyl2x // log(x) + ret + +3: jp 4b // in case x is ????Inf + fstp %st(1) + fstp %st(1) + ret +END (__ieee754_log2) --- libc/sysdeps/ieee754/dbl-64/s_log2.c.jj Wed Jul 14 01:52:42 1999 +++ libc/sysdeps/ieee754/dbl-64/s_log2.c Mon Jun 4 10:30:38 2001 @@ -1,136 +0,0 @@ -/* Adapted for log2 by Ulrich Drepper . */ -/* - * ==================================================== - * 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. - * ==================================================== - */ - -/* __log2(x) - * Return the logarithm to base 2 of x - * - * Method : - * 1. Argument Reduction: find k and f such that - * x = 2^k * (1+f), - * where sqrt(2)/2 < 1+f < sqrt(2) . - * - * 2. Approximation of log(1+f). - * Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s) - * = 2s + 2/3 s**3 + 2/5 s**5 + ....., - * = 2s + s*R - * We use a special Reme algorithm on [0,0.1716] to generate - * a polynomial of degree 14 to approximate R The maximum error - * of this polynomial approximation is bounded by 2**-58.45. In - * other words, - * 2 4 6 8 10 12 14 - * R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s +Lg6*s +Lg7*s - * (the values of Lg1 to Lg7 are listed in the program) - * and - * | 2 14 | -58.45 - * | Lg1*s +...+Lg7*s - R(z) | <= 2 - * | | - * Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2. - * In order to guarantee error in log below 1ulp, we compute log - * by - * log(1+f) = f - s*(f - R) (if f is not too large) - * log(1+f) = f - (hfsq - s*(hfsq+R)). (better accuracy) - * - * 3. Finally, log(x) = k + log(1+f). - * = k+(f-(hfsq-(s*(hfsq+R)))) - * - * Special cases: - * log2(x) is NaN with signal if x < 0 (including -INF) ; - * log2(+INF) is +INF; log(0) is -INF with signal; - * log2(NaN) is that NaN with no signal. - * - * Constants: - * The hexadecimal values are the intended ones for the following - * constants. The decimal values may be used, provided that the - * compiler will convert from decimal to binary accurately enough - * to produce the hexadecimal values shown. - */ - -#include "math.h" -#include "math_private.h" - -#ifdef __STDC__ -static const double -#else -static double -#endif -ln2 = 0.69314718055994530942, -two54 = 1.80143985094819840000e+16, /* 43500000 00000000 */ -Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */ -Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */ -Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */ -Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */ -Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */ -Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */ -Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */ - -#ifdef __STDC__ -static const double zero = 0.0; -#else -static double zero = 0.0; -#endif - -#ifdef __STDC__ - double __log2(double x) -#else - double __log2(x) - double x; -#endif -{ - double hfsq,f,s,z,R,w,t1,t2,dk; - int32_t k,hx,i,j; - u_int32_t lx; - - EXTRACT_WORDS(hx,lx,x); - - k=0; - if (hx < 0x00100000) { /* x < 2**-1022 */ - if (((hx&0x7fffffff)|lx)==0) - return -two54/(x-x); /* log(+-0)=-inf */ - if (hx<0) return (x-x)/(x-x); /* log(-#) = NaN */ - k -= 54; x *= two54; /* subnormal number, scale up x */ - GET_HIGH_WORD(hx,x); - } - if (hx >= 0x7ff00000) return x+x; - k += (hx>>20)-1023; - hx &= 0x000fffff; - i = (hx+0x95f64)&0x100000; - SET_HIGH_WORD(x,hx|(i^0x3ff00000)); /* normalize x or x/2 */ - k += (i>>20); - dk = (double) k; - f = x-1.0; - if((0x000fffff&(2+hx))<3) { /* |f| < 2**-20 */ - if(f==zero) return dk; - R = f*f*(0.5-0.33333333333333333*f); - return dk-(R-f)/ln2; - } - s = f/(2.0+f); - z = s*s; - i = hx-0x6147a; - w = z*z; - j = 0x6b851-hx; - t1= w*(Lg2+w*(Lg4+w*Lg6)); - t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7))); - i |= j; - R = t2+t1; - if(i>0) { - hfsq=0.5*f*f; - return dk-((hfsq-(s*(hfsq+R)))-f)/ln2; - } else { - return dk-((s*(f-R))-f)/ln2; - } -} - -weak_alias (__log2, log2) -#ifdef NO_LONG_DOUBLE -strong_alias (__log2, __log2l) -weak_alias (__log2, log2l) -#endif --- libc/sysdeps/ieee754/dbl-64/e_log2.c.jj Mon Jun 4 10:30:46 2001 +++ libc/sysdeps/ieee754/dbl-64/e_log2.c Mon Jun 4 10:31:08 2001 @@ -0,0 +1,130 @@ +/* Adapted for log2 by Ulrich Drepper . */ +/* + * ==================================================== + * 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. + * ==================================================== + */ + +/* __ieee754_log2(x) + * Return the logarithm to base 2 of x + * + * Method : + * 1. Argument Reduction: find k and f such that + * x = 2^k * (1+f), + * where sqrt(2)/2 < 1+f < sqrt(2) . + * + * 2. Approximation of log(1+f). + * Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s) + * = 2s + 2/3 s**3 + 2/5 s**5 + ....., + * = 2s + s*R + * We use a special Reme algorithm on [0,0.1716] to generate + * a polynomial of degree 14 to approximate R The maximum error + * of this polynomial approximation is bounded by 2**-58.45. In + * other words, + * 2 4 6 8 10 12 14 + * R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s +Lg6*s +Lg7*s + * (the values of Lg1 to Lg7 are listed in the program) + * and + * | 2 14 | -58.45 + * | Lg1*s +...+Lg7*s - R(z) | <= 2 + * | | + * Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2. + * In order to guarantee error in log below 1ulp, we compute log + * by + * log(1+f) = f - s*(f - R) (if f is not too large) + * log(1+f) = f - (hfsq - s*(hfsq+R)). (better accuracy) + * + * 3. Finally, log(x) = k + log(1+f). + * = k+(f-(hfsq-(s*(hfsq+R)))) + * + * Special cases: + * log2(x) is NaN with signal if x < 0 (including -INF) ; + * log2(+INF) is +INF; log(0) is -INF with signal; + * log2(NaN) is that NaN with no signal. + * + * Constants: + * The hexadecimal values are the intended ones for the following + * constants. The decimal values may be used, provided that the + * compiler will convert from decimal to binary accurately enough + * to produce the hexadecimal values shown. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const double +#else +static double +#endif +ln2 = 0.69314718055994530942, +two54 = 1.80143985094819840000e+16, /* 43500000 00000000 */ +Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */ +Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */ +Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */ +Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */ +Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */ +Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */ +Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */ + +#ifdef __STDC__ +static const double zero = 0.0; +#else +static double zero = 0.0; +#endif + +#ifdef __STDC__ + double __ieee754_log2(double x) +#else + double __ieee754_log2(x) + double x; +#endif +{ + double hfsq,f,s,z,R,w,t1,t2,dk; + int32_t k,hx,i,j; + u_int32_t lx; + + EXTRACT_WORDS(hx,lx,x); + + k=0; + if (hx < 0x00100000) { /* x < 2**-1022 */ + if (((hx&0x7fffffff)|lx)==0) + return -two54/(x-x); /* log(+-0)=-inf */ + if (hx<0) return (x-x)/(x-x); /* log(-#) = NaN */ + k -= 54; x *= two54; /* subnormal number, scale up x */ + GET_HIGH_WORD(hx,x); + } + if (hx >= 0x7ff00000) return x+x; + k += (hx>>20)-1023; + hx &= 0x000fffff; + i = (hx+0x95f64)&0x100000; + SET_HIGH_WORD(x,hx|(i^0x3ff00000)); /* normalize x or x/2 */ + k += (i>>20); + dk = (double) k; + f = x-1.0; + if((0x000fffff&(2+hx))<3) { /* |f| < 2**-20 */ + if(f==zero) return dk; + R = f*f*(0.5-0.33333333333333333*f); + return dk-(R-f)/ln2; + } + s = f/(2.0+f); + z = s*s; + i = hx-0x6147a; + w = z*z; + j = 0x6b851-hx; + t1= w*(Lg2+w*(Lg4+w*Lg6)); + t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7))); + i |= j; + R = t2+t1; + if(i>0) { + hfsq=0.5*f*f; + return dk-((hfsq-(s*(hfsq+R)))-f)/ln2; + } else { + return dk-((s*(f-R))-f)/ln2; + } +} --- libc/sysdeps/ieee754/flt-32/s_log2f.c.jj Wed Jul 14 02:01:54 1999 +++ libc/sysdeps/ieee754/flt-32/s_log2f.c Mon Jun 4 10:32:15 2001 @@ -1,91 +0,0 @@ -/* e_logf.c -- float version of e_log.c. - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - * adapted for log2 by Ulrich Drepper - */ - -/* - * ==================================================== - * 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" - -#ifdef __STDC__ -static const float -#else -static float -#endif -ln2 = 0.69314718055994530942, -two25 = 3.355443200e+07, /* 0x4c000000 */ -Lg1 = 6.6666668653e-01, /* 3F2AAAAB */ -Lg2 = 4.0000000596e-01, /* 3ECCCCCD */ -Lg3 = 2.8571429849e-01, /* 3E924925 */ -Lg4 = 2.2222198546e-01, /* 3E638E29 */ -Lg5 = 1.8183572590e-01, /* 3E3A3325 */ -Lg6 = 1.5313838422e-01, /* 3E1CD04F */ -Lg7 = 1.4798198640e-01; /* 3E178897 */ - -#ifdef __STDC__ -static const float zero = 0.0; -#else -static float zero = 0.0; -#endif - -#ifdef __STDC__ - float __log2f(float x) -#else - float __log2f(x) - float x; -#endif -{ - float hfsq,f,s,z,R,w,t1,t2,dk; - int32_t k,ix,i,j; - - GET_FLOAT_WORD(ix,x); - - k=0; - if (ix < 0x00800000) { /* x < 2**-126 */ - if ((ix&0x7fffffff)==0) - return -two25/(x-x); /* log(+-0)=-inf */ - if (ix<0) return (x-x)/(x-x); /* log(-#) = NaN */ - k -= 25; x *= two25; /* subnormal number, scale up x */ - GET_FLOAT_WORD(ix,x); - } - if (ix >= 0x7f800000) return x+x; - k += (ix>>23)-127; - ix &= 0x007fffff; - i = (ix+(0x95f64<<3))&0x800000; - SET_FLOAT_WORD(x,ix|(i^0x3f800000)); /* normalize x or x/2 */ - k += (i>>23); - dk = (float)k; - f = x-(float)1.0; - if((0x007fffff&(15+ix))<16) { /* |f| < 2**-20 */ - if(f==zero) return dk; - R = f*f*((float)0.5-(float)0.33333333333333333*f); - return dk-(R-f)/ln2; - } - s = f/((float)2.0+f); - z = s*s; - i = ix-(0x6147a<<3); - w = z*z; - j = (0x6b851<<3)-ix; - t1= w*(Lg2+w*(Lg4+w*Lg6)); - t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7))); - i |= j; - R = t2+t1; - if(i>0) { - hfsq=(float)0.5*f*f; - return dk-((hfsq-(s*(hfsq+R)))-f)/ln2; - } else { - return dk-((s*(f-R))-f)/ln2; - } -} -weak_alias (__log2f, log2f) --- libc/sysdeps/ieee754/flt-32/e_log2f.c.jj Mon Jun 4 10:32:21 2001 +++ libc/sysdeps/ieee754/flt-32/e_log2f.c Mon Jun 4 10:32:43 2001 @@ -0,0 +1,90 @@ +/* e_logf.c -- float version of e_log.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + * adapted for log2 by Ulrich Drepper + */ + +/* + * ==================================================== + * 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" + +#ifdef __STDC__ +static const float +#else +static float +#endif +ln2 = 0.69314718055994530942, +two25 = 3.355443200e+07, /* 0x4c000000 */ +Lg1 = 6.6666668653e-01, /* 3F2AAAAB */ +Lg2 = 4.0000000596e-01, /* 3ECCCCCD */ +Lg3 = 2.8571429849e-01, /* 3E924925 */ +Lg4 = 2.2222198546e-01, /* 3E638E29 */ +Lg5 = 1.8183572590e-01, /* 3E3A3325 */ +Lg6 = 1.5313838422e-01, /* 3E1CD04F */ +Lg7 = 1.4798198640e-01; /* 3E178897 */ + +#ifdef __STDC__ +static const float zero = 0.0; +#else +static float zero = 0.0; +#endif + +#ifdef __STDC__ + float __ieee754_log2f(float x) +#else + float __ieee754_log2f(x) + float x; +#endif +{ + float hfsq,f,s,z,R,w,t1,t2,dk; + int32_t k,ix,i,j; + + GET_FLOAT_WORD(ix,x); + + k=0; + if (ix < 0x00800000) { /* x < 2**-126 */ + if ((ix&0x7fffffff)==0) + return -two25/(x-x); /* log(+-0)=-inf */ + if (ix<0) return (x-x)/(x-x); /* log(-#) = NaN */ + k -= 25; x *= two25; /* subnormal number, scale up x */ + GET_FLOAT_WORD(ix,x); + } + if (ix >= 0x7f800000) return x+x; + k += (ix>>23)-127; + ix &= 0x007fffff; + i = (ix+(0x95f64<<3))&0x800000; + SET_FLOAT_WORD(x,ix|(i^0x3f800000)); /* normalize x or x/2 */ + k += (i>>23); + dk = (float)k; + f = x-(float)1.0; + if((0x007fffff&(15+ix))<16) { /* |f| < 2**-20 */ + if(f==zero) return dk; + R = f*f*((float)0.5-(float)0.33333333333333333*f); + return dk-(R-f)/ln2; + } + s = f/((float)2.0+f); + z = s*s; + i = ix-(0x6147a<<3); + w = z*z; + j = (0x6b851<<3)-ix; + t1= w*(Lg2+w*(Lg4+w*Lg6)); + t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7))); + i |= j; + R = t2+t1; + if(i>0) { + hfsq=(float)0.5*f*f; + return dk-((hfsq-(s*(hfsq+R)))-f)/ln2; + } else { + return dk-((s*(f-R))-f)/ln2; + } +} --- libc/sysdeps/ieee754/k_standard.c.jj Wed Jul 14 01:44:31 1999 +++ libc/sysdeps/ieee754/k_standard.c Mon Jun 4 10:15:50 2001 @@ -88,6 +88,8 @@ static double zero = 0.0; /* used as con * 45-- exp2 underflow * 46-- exp10 overflow * 47-- exp10 underflow + * 48-- log2(0) + * 49-- log2(x<0) */ @@ -937,7 +939,42 @@ static double zero = 0.0; /* used as con __set_errno (ERANGE); } break; - /* #### Last used is 47/147/247 ### */ + case 48: + case 148: + case 248: + /* log2(0) */ + exc.type = SING; + exc.name = type < 100 ? "log2" : (type < 200 + ? "log2f" : "log2l"); + if (_LIB_VERSION == _SVID_) + exc.retval = -HUGE; + else + exc.retval = -HUGE_VAL; + if (_LIB_VERSION == _POSIX_) + __set_errno (ERANGE); + else if (!matherr(&exc)) { + __set_errno (EDOM); + } + break; + case 49: + case 149: + case 249: + /* log2(x<0) */ + exc.type = DOMAIN; + exc.name = type < 100 ? "log2" : (type < 200 + ? "log2f" : "log2l"); + if (_LIB_VERSION == _SVID_) + exc.retval = -HUGE; + else + exc.retval = NAN; + if (_LIB_VERSION == _POSIX_) + __set_errno (EDOM); + else if (!matherr(&exc)) { + __set_errno (EDOM); + } + break; + + /* #### Last used is 49/149/249 ### */ } return exc.retval; } --- libc/sysdeps/m68k/fpu/s_log2.c.jj Tue Mar 25 02:33:29 1997 +++ libc/sysdeps/m68k/fpu/s_log2.c Mon Jun 4 10:39:50 2001 @@ -1,2 +0,0 @@ -#define FUNC log2 -#include --- libc/sysdeps/m68k/fpu/s_log2f.c.jj Tue Mar 25 02:33:29 1997 +++ libc/sysdeps/m68k/fpu/s_log2f.c Mon Jun 4 10:39:50 2001 @@ -1,2 +0,0 @@ -#define FUNC log2f -#include --- libc/sysdeps/m68k/fpu/s_log2l.c.jj Tue Mar 25 02:33:30 1997 +++ libc/sysdeps/m68k/fpu/s_log2l.c Mon Jun 4 10:39:50 2001 @@ -1,2 +0,0 @@ -#define FUNC log2l -#include --- libc/sysdeps/m68k/fpu/e_log2.c.jj Mon Jun 4 10:40:09 2001 +++ libc/sysdeps/m68k/fpu/e_log2.c Mon Jun 4 10:40:22 2001 @@ -0,0 +1,2 @@ +#define FUNC __ieee754_log2 +#include --- libc/sysdeps/m68k/fpu/e_log2f.c.jj Mon Jun 4 10:40:09 2001 +++ libc/sysdeps/m68k/fpu/e_log2f.c Mon Jun 4 10:40:35 2001 @@ -0,0 +1,2 @@ +#define FUNC __ieee754_log10f +#include --- libc/sysdeps/m68k/fpu/e_log2l.c.jj Mon Jun 4 10:40:09 2001 +++ libc/sysdeps/m68k/fpu/e_log2l.c Mon Jun 4 10:40:50 2001 @@ -0,0 +1,2 @@ +#define FUNC __ieee754_log10l +#include Jakub From jakub@redhat.com Mon Jun 4 06:09:00 2001 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 04 Jun 2001 06:09:00 -0000 Subject: [PATCH] Fix exp2* on very small values Message-ID: <20010604151159.E1253@sunsite.ms.mff.cuni.cz> Hi! The exp2* wrappers would signal underflow too early (they should do so when real underflow happens, not when the returned value would be denormal), on the other side __ieee754_exp* had the low threshold too small (arguments <= 2^(*_MIN_EXP - *_MANT_DIG - 1) underflow, while the code was testing arguments < 2^(*_MIN_EXP - *_MANT_DIG - 2)). 2001-06-04 Jakub Jelinek * sysdeps/generic/w_exp2.c (u_threshold): Lower threshold so that even arguments which result in denormalized exp2 are accepted. (__exp2): Arguments equal to u_threshold already result into underflow. * sysdeps/generic/w_exp2f.c (u_threshold, __exp2f): Likewise. * sysdeps/generic/w_exp2l.c (u_threshold, __exp2l): Likewise. * sysdeps/ieee754/dbl-64/e_exp2.c (__ieee754_exp2): Lomark was too low, with corrected lowmark use greaterequal, not greater. * sysdeps/ieee754/flt-32/e_exp2f.c (__ieee754_exp2f): Likewise. --- libc/sysdeps/generic/w_exp2.c.jj Sat Feb 17 02:42:18 2001 +++ libc/sysdeps/generic/w_exp2.c Mon Jun 4 11:45:24 2001 @@ -7,7 +7,7 @@ #include "math_private.h" static const double o_threshold= (double) DBL_MAX_EXP; -static const double u_threshold= (double) DBL_MIN_EXP; +static const double u_threshold= (double) (DBL_MIN_EXP - DBL_MANT_DIG - 1); double __exp2 (double x) /* wrapper exp2 */ @@ -22,7 +22,7 @@ __exp2 (double x) /* wrapper exp2 */ if (x > o_threshold) /* exp2 overflow */ return __kernel_standard (x, x, 44); - else if (x < u_threshold) + else if (x <= u_threshold) /* exp2 underflow */ return __kernel_standard (x, x, 45); } --- libc/sysdeps/generic/w_exp2f.c.jj Sat Feb 17 02:42:22 2001 +++ libc/sysdeps/generic/w_exp2f.c Mon Jun 4 11:48:44 2001 @@ -7,7 +7,7 @@ #include "math_private.h" static const float o_threshold= (float) FLT_MAX_EXP; -static const float u_threshold= (float) FLT_MIN_EXP; +static const float u_threshold= (float) (FLT_MIN_EXP - FLT_MANT_DIG - 1); float __exp2f (float x) /* wrapper exp2f */ @@ -22,7 +22,7 @@ __exp2f (float x) /* wrapper exp2f */ if (x > o_threshold) /* exp2 overflow */ return (float) __kernel_standard ((double) x, (double) x, 144); - else if (x < u_threshold) + else if (x <= u_threshold) /* exp2 underflow */ return (float) __kernel_standard ((double) x, (double) x, 145); } --- libc/sysdeps/generic/w_exp2l.c.jj Sat Feb 17 02:42:26 2001 +++ libc/sysdeps/generic/w_exp2l.c Mon Jun 4 11:48:26 2001 @@ -7,7 +7,8 @@ #include "math_private.h" static const long double o_threshold = (long double) LDBL_MAX_EXP; -static const long double u_threshold = (long double) LDBL_MIN_EXP; +static const long double u_threshold + = (long double) (LDBL_MIN_EXP - LDBL_MANT_DIG - 1); long double __exp2l (long double x) /* wrapper exp2l */ @@ -21,7 +22,7 @@ __exp2l (long double x) /* wrapper exp { if (x > o_threshold) return __kernel_standard (x, x, 244); /* exp2l overflow */ - else if (x < u_threshold) + else if (x <= u_threshold) return __kernel_standard (x, x, 245); /* exp2l underflow */ } return z; --- libc/sysdeps/ieee754/dbl-64/e_exp2.c.jj Sat Feb 17 17:48:54 2001 +++ libc/sysdeps/ieee754/dbl-64/e_exp2.c Mon Jun 4 11:34:32 2001 @@ -1,5 +1,5 @@ /* Double-precision floating point 2^x. - Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Geoffrey Keating @@ -44,10 +44,10 @@ double __ieee754_exp2 (double x) { static const double himark = (double) DBL_MAX_EXP; - static const double lomark = (double) (DBL_MIN_EXP - DBL_MANT_DIG - 1) - 1.0; + static const double lomark = (double) (DBL_MIN_EXP - DBL_MANT_DIG - 1); /* Check for usual case. */ - if (isless (x, himark) && isgreater (x, lomark)) + if (isless (x, himark) && isgreaterequal (x, lomark)) { static const double THREEp42 = 13194139533312.0; int tval, unsafe; --- libc/sysdeps/ieee754/flt-32/e_exp2f.c.jj Sat Feb 17 17:48:20 2001 +++ libc/sysdeps/ieee754/flt-32/e_exp2f.c Mon Jun 4 11:44:12 2001 @@ -1,5 +1,5 @@ /* Single-precision floating point 2^x. - Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Geoffrey Keating @@ -45,10 +45,10 @@ float __ieee754_exp2f (float x) { static const float himark = (float) FLT_MAX_EXP; - static const float lomark = (float) (FLT_MIN_EXP - FLT_MANT_DIG - 1) - 1.0; + static const float lomark = (float) (FLT_MIN_EXP - FLT_MANT_DIG - 1); /* Check for usual case. */ - if (isless (x, himark) && isgreater (x, lomark)) + if (isless (x, himark) && isgreaterequal (x, lomark)) { static const float THREEp14 = 49152.0; int tval, unsafe; Jakub From jakub@redhat.com Mon Jun 4 06:17:00 2001 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 04 Jun 2001 06:17:00 -0000 Subject: [PATCH] Make ilogb C99 compliant Message-ID: <20010604152037.F1253@sunsite.ms.mff.cuni.cz> Hi! ISO C99 explicitely requires that: ilogb(0) returns FP_ILOGB0 where FP_ILOGB0 is either INT_MIN, or -INT_MAX. ilogb(NaN) returns FP_ILOGBNAN where FP_ILOGBNAN is either INT_MIN or INT_MAX. ilogb(+-Inf) returns INT_MAX. so we return wrong results on i386 for infinity where FP_ILOGBNAN is INT_MIN. The following patch makes sure ilogb(+-Inf) returns INT_MAX (the non-assembly changes are actually not required, but are there for completeness and are optimized out). 2001-06-04 Jakub Jelinek * math/libm-test.inc (ilogb_test): Test that ilogb(+-Inf) == INT_MAX. * sysdeps/i386/fpu/s_ilogb.S (__ilogb): Return INT_MAX for +-Inf. * sysdeps/i386/fpu/s_ilogbf.S (__ilogbf): Likewise. * sysdeps/i386/fpu/s_ilogbl.S (__ilogbl): Likewise. * sysdeps/ieee754/dbl-64/s_ilogb.c (__ilogb): Likewise. * sysdeps/ieee754/flt-32/s_ilogbf.c (__ilogbf): Likewise. * sysdeps/ieee754/ldbl-128/s_ilogbl.c (__ilogbl): Likewise. * sysdeps/ieee754/ldbl-96/s_ilogbl.c (__ilogbl): Likewise. --- libc/math/libm-test.inc.jj Mon Jun 4 10:01:59 2001 +++ libc/math/libm-test.inc Mon Jun 4 12:54:26 2001 @@ -120,6 +120,7 @@ #include #include #include +#include #include #include @@ -2800,6 +2801,8 @@ ilogb_test (void) TEST_f_i (ilogb, 0.0, FP_ILOGB0, EXCEPTIONS_OK); TEST_f_i (ilogb, nan_value, FP_ILOGBNAN, EXCEPTIONS_OK); + TEST_f_i (ilogb, plus_infty, INT_MAX, EXCEPTIONS_OK); + TEST_f_i (ilogb, minus_infty, INT_MAX, EXCEPTIONS_OK); END (ilogb); } --- libc/sysdeps/i386/fpu/s_ilogb.S.jj Wed Jul 14 01:34:41 1999 +++ libc/sysdeps/i386/fpu/s_ilogb.S Mon Jun 4 12:48:24 2001 @@ -9,6 +9,16 @@ RCSID("$NetBSD: s_ilogb.S,v 1.5 1995/10/ ENTRY(__ilogb) fldl 4(%esp) +/* I added the following ugly construct because ilogb(+-Inf) is + required to return INT_MAX in ISO C99. + -- jakub@redhat.com. */ + fxam /* Is NaN or +-Inf? */ + fstsw %ax + movb $0x45, %dh + andb %ah, %dh + cmpb $0x05, %dh + je 1f /* Is +-Inf, jump. */ + fxtract pushl %eax fstp %st @@ -17,6 +27,10 @@ ENTRY(__ilogb) fwait popl %eax + ret + +1: fstp %st + movl $0x7fffffff, %eax ret END (__ilogb) weak_alias (__ilogb, ilogb) --- libc/sysdeps/i386/fpu/s_ilogbl.S.jj Wed Jul 14 01:34:48 1999 +++ libc/sysdeps/i386/fpu/s_ilogbl.S Mon Jun 4 12:50:35 2001 @@ -10,6 +10,16 @@ RCSID("$NetBSD: $") ENTRY(__ilogbl) fldt 4(%esp) +/* I added the following ugly construct because ilogb(+-Inf) is + required to return INT_MAX in ISO C99. + -- jakub@redhat.com. */ + fxam /* Is NaN or +-Inf? */ + fstsw %ax + movb $0x45, %dh + andb %ah, %dh + cmpb $0x05, %dh + je 1f /* Is +-Inf, jump. */ + fxtract pushl %eax fstp %st @@ -18,6 +28,10 @@ ENTRY(__ilogbl) fwait popl %eax + ret + +1: fstp %st + movl $0x7fffffff, %eax ret END (__ilogbl) weak_alias (__ilogbl, ilogbl) --- libc/sysdeps/i386/fpu/s_ilogbf.S.jj Wed Jul 14 01:34:45 1999 +++ libc/sysdeps/i386/fpu/s_ilogbf.S Mon Jun 4 12:50:27 2001 @@ -9,6 +9,16 @@ RCSID("$NetBSD: s_ilogbf.S,v 1.4 1995/10 ENTRY(__ilogbf) flds 4(%esp) +/* I added the following ugly construct because ilogb(+-Inf) is + required to return INT_MAX in ISO C99. + -- jakub@redhat.com. */ + fxam /* Is NaN or +-Inf? */ + fstsw %ax + movb $0x45, %dh + andb %ah, %dh + cmpb $0x05, %dh + je 1f /* Is +-Inf, jump. */ + fxtract pushl %eax fstp %st @@ -17,6 +27,10 @@ ENTRY(__ilogbf) fwait popl %eax + ret + +1: fstp %st + movl $0x7fffffff, %eax ret END (__ilogbf) weak_alias (__ilogbf, ilogbf) --- libc/sysdeps/ieee754/dbl-64/s_ilogb.c.jj Wed Jul 14 01:52:14 1999 +++ libc/sysdeps/ieee754/dbl-64/s_ilogb.c Mon Jun 4 12:26:17 2001 @@ -16,10 +16,12 @@ static char rcsid[] = "$NetBSD: s_ilogb. /* ilogb(double x) * return the binary exponent of non-zero x - * ilogb(0) = 0x80000001 - * ilogb(inf/NaN) = 0x7fffffff (no signal is raised) + * ilogb(0) = FP_ILOGB0 + * ilogb(NaN) = FP_ILOGBNAN (no signal is raised) + * ilogb(+-Inf) = INT_MAX (no signal is raised) */ +#include #include "math.h" #include "math_private.h" @@ -47,7 +49,13 @@ static char rcsid[] = "$NetBSD: s_ilogb. return ix; } else if (hx<0x7ff00000) return (hx>>20)-1023; - else return FP_ILOGBNAN; + else if (FP_ILOGBNAN != INT_MAX) { + /* ISO C99 requires ilogb(+-Inf) == INT_MAX. */ + GET_LOW_WORD(lx,x); + if(((hx^0x7ff00000)|lx) == 0) + return INT_MAX; + } + return FP_ILOGBNAN; } weak_alias (__ilogb, ilogb) #ifdef NO_LONG_DOUBLE --- libc/sysdeps/ieee754/flt-32/s_ilogbf.c.jj Wed Jul 14 02:01:28 1999 +++ libc/sysdeps/ieee754/flt-32/s_ilogbf.c Mon Jun 4 12:32:43 2001 @@ -17,6 +17,7 @@ static char rcsid[] = "$NetBSD: s_ilogbf.c,v 1.4 1995/05/10 20:47:31 jtc Exp $"; #endif +#include #include "math.h" #include "math_private.h" @@ -39,6 +40,11 @@ static char rcsid[] = "$NetBSD: s_ilogbf return ix; } else if (hx<0x7f800000) return (hx>>23)-127; - else return FP_ILOGBNAN; + else if (FP_ILOGBNAN != INT_MAX) { + /* ISO C99 requires ilogbf(+-Inf) == INT_MAX. */ + if (hx==0x7f800000) + return INT_MAX; + } + return FP_ILOGBNAN; } weak_alias (__ilogbf, ilogbf) --- libc/sysdeps/ieee754/ldbl-128/s_ilogbl.c.jj Wed Jul 14 02:08:52 1999 +++ libc/sysdeps/ieee754/ldbl-128/s_ilogbl.c Mon Jun 4 12:38:18 2001 @@ -19,8 +19,9 @@ static char rcsid[] = "$NetBSD: $"; /* ilogbl(long double x) * return the binary exponent of non-zero x - * ilogbl(0) = 0x80000001 - * ilogbl(inf/NaN) = 0x7fffffff (no signal is raised) + * ilogbl(0) = FP_ILOGB0 + * ilogbl(NaN) = FP_ILOGBNAN (no signal is raised) + * ilogbl(+-Inf) = INT_MAX (no signal is raised) */ #include "math.h" @@ -50,6 +51,11 @@ static char rcsid[] = "$NetBSD: $"; return ix; } else if (hx<0x7fff000000000000LL) return (hx>>48)-0x3fff; - else return FP_ILOGBNAN; + else if (FP_ILOGBNAN != INT_MAX) { + /* ISO C99 requires ilogbl(+-Inf) == INT_MAX. */ + if (((hx^0x7fff000000000000LL)|lx) == 0) + return INT_MAX; + } + return FP_ILOGBNAN; } weak_alias (__ilogbl, ilogbl) --- libc/sysdeps/ieee754/ldbl-96/s_ilogbl.c.jj Wed Jul 14 02:13:51 1999 +++ libc/sysdeps/ieee754/ldbl-96/s_ilogbl.c Mon Jun 4 12:35:43 2001 @@ -20,10 +20,12 @@ static char rcsid[] = "$NetBSD: $"; /* ilogbl(long double x) * return the binary exponent of non-zero x - * ilogbl(0) = 0x80000001 - * ilogbl(inf/NaN) = 0x7fffffff (no signal is raised) + * ilogbl(0) = FP_ILOGB0 + * ilogbl(NaN) = FP_ILOGBNAN (no signal is raised) + * ilogbl(+-Inf) = INT_MAX (no signal is raised) */ +#include #include "math.h" #include "math_private.h" @@ -51,6 +53,9 @@ static char rcsid[] = "$NetBSD: $"; return ix; } else if (es<0x7fff) return es-0x3fff; - else return FP_ILOGBNAN; + else if (FP_ILOGBNAN != INT_MAX && (hx|lx) == 0) + /* ISO C99 requires ilogbl(+-Inf) == INT_MAX. */ + return INT_MAX; + return FP_ILOGBNAN; } weak_alias (__ilogbl, ilogbl) Jakub From jakub@redhat.com Mon Jun 4 06:27:00 2001 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 04 Jun 2001 06:27:00 -0000 Subject: [PATCH] Fix exp10 and coshl Message-ID: <20010604153034.G1253@sunsite.ms.mff.cuni.cz> Hi! IMHO sysdeps/generic/ should have no knowledge about IEEE single/double/extended double/quad formats. Routines which need constant which depend on the exact number format should be only in ieee754/*/ or in architecture dependent directories. Using magic constants in coshl below e.g. caused coshl to issue an error even for arguments which should be handled (the constant computed in generic w_coshl was log(DBL_MAX)+M_LN2, not logl(LDBL_MAX)+M_LN2l) and errors with ldbl-128 in both coshl and exp10l. Either we should move these wrappers into appropriate sysdeps/ieee754/ directories and compute correct constants, or we can check overflows/underflows without any cooked up constants which is what the patch below does (then we can have just a single wrapper for each of these functions). 2001-06-04 Jakub Jelinek * sysdeps/generic/w_coshl.c (__coshl): Test if finite argument gave non-finite result instead of using constant in generic version. * sysdeps/generic/w_coshf.c (__coshf): Likewise. * sysdeps/generic/w_cosh.c (__cosh): Likewise. * sysdeps/generic/w_exp10.c (o_threshold, u_threshold): Remove. (__exp10): Test if finite argument gave non-finite result. * sysdeps/generic/w_exp10f.c (o_threshold, u_threshold, __exp10f): Likewise. * sysdeps/generic/w_exp10l.c (o_threshold, u_threshold, __exp10l): Likewise. --- libc/sysdeps/generic/w_coshl.c.jj Sat Feb 17 02:41:50 2001 +++ libc/sysdeps/generic/w_coshl.c Mon Jun 4 13:52:06 2001 @@ -38,7 +38,7 @@ static char rcsid[] = "$NetBSD: $"; long double z; z = __ieee754_coshl(x); if(_LIB_VERSION == _IEEE_ || __isnanl(x)) return z; - if(fabsl(x)>7.10475860073943863426e+02) { + if(!__finite(z) && __finite(x)) { return __kernel_standard(x,x,205); /* cosh overflow */ } else return z; --- libc/sysdeps/generic/w_coshf.c.jj Sat Feb 17 02:41:46 2001 +++ libc/sysdeps/generic/w_coshf.c Mon Jun 4 13:52:32 2001 @@ -37,7 +37,7 @@ static char rcsid[] = "$NetBSD: w_coshf. float z; z = __ieee754_coshf(x); if(_LIB_VERSION == _IEEE_ || __isnanf(x)) return z; - if(fabsf(x)>(float)8.9415985107e+01) { + if(!__finite(z) && __finite(x)) { /* cosh overflow */ return (float)__kernel_standard((double)x,(double)x,105); } else --- libc/sysdeps/generic/w_cosh.c.jj Sat Feb 17 02:41:41 2001 +++ libc/sysdeps/generic/w_cosh.c Mon Jun 4 13:52:55 2001 @@ -34,7 +34,7 @@ static char rcsid[] = "$NetBSD: w_cosh.c double z; z = __ieee754_cosh(x); if(_LIB_VERSION == _IEEE_ || __isnan(x)) return z; - if(fabs(x)>7.10475860073943863426e+02) { + if(!__finite(z) && __finite(x)) { return __kernel_standard(x,x,5); /* cosh overflow */ } else return z; --- libc/sysdeps/generic/w_exp10.c.jj Sat Feb 17 02:42:06 2001 +++ libc/sysdeps/generic/w_exp10.c Mon Jun 4 13:57:14 2001 @@ -21,14 +21,6 @@ #include "math_private.h" #ifdef __STDC__ -static const double -#else -static double -#endif -o_threshold= 3.0825471555991674389672e+02, -u_threshold= -3.2360724533877978485251e+02; - -#ifdef __STDC__ double __exp10(double x) /* wrapper exp10 */ #else double __exp10(x) /* wrapper exp10 */ @@ -41,11 +33,9 @@ u_threshold= -3.2360724533877978485251e+ double z; z = __ieee754_exp10(x); if(_LIB_VERSION == _IEEE_) return z; - if(__finite(x)) { - if(x>o_threshold) - return __kernel_standard(x,x,46); /* exp10 overflow */ - else if(x 0, underflow (47) if x < 0. */ + return __kernel_standard(x,x,46+!!__signbit(x)); } return z; #endif --- libc/sysdeps/generic/w_exp10f.c.jj Sat Feb 17 02:42:10 2001 +++ libc/sysdeps/generic/w_exp10f.c Mon Jun 4 13:59:10 2001 @@ -21,14 +21,6 @@ #include "math_private.h" #ifdef __STDC__ -static const float -#else -static float -#endif -o_threshold= 3.853183944498959298709e+01, -u_threshold= -4.515449934959717928174e+01; - -#ifdef __STDC__ float __exp10f(float x) /* wrapper exp10f */ #else float __exp10f(x) /* wrapper exp10f */ @@ -41,13 +33,10 @@ u_threshold= -4.515449934959717928174e+0 float z; z = __ieee754_exp10f(x); if(_LIB_VERSION == _IEEE_) return z; - if(__finitef(x)) { - if(x>o_threshold) - /* exp overflow */ - return (float)__kernel_standard((double)x,(double)x,146); - else if(x 0, underflow (147) if x < 0. */ + return (float)__kernel_standard((double) x, (double) x, + 146+!!__signbitf(x)); } return z; #endif --- libc/sysdeps/generic/w_exp10l.c.jj Sat Feb 17 02:42:14 2001 +++ libc/sysdeps/generic/w_exp10l.c Mon Jun 4 14:00:17 2001 @@ -22,14 +22,6 @@ #include "math_private.h" #ifdef __STDC__ -static const long double -#else -static long double -#endif -o_threshold= 4.93207544895866790234755e+03, -u_threshold= -4.95104033868549871764588e+03; - -#ifdef __STDC__ long double __exp10l(long double x) /* wrapper exp10 */ #else long double __exp10l(x) /* wrapper exp10 */ @@ -42,11 +34,9 @@ u_threshold= -4.95104033868549871764588e long double z; z = __ieee754_exp10l(x); if(_LIB_VERSION == _IEEE_) return z; - if(__finitel(x)) { - if(x>o_threshold) - return __kernel_standard(x,x,246); /* exp10 overflow */ - else if(x 0, underflow (247) if x < 0. */ + return __kernel_standard(x,x,246+__signbitl(x)); } return z; #endif Jakub From jakub@redhat.com Mon Jun 4 06:33:00 2001 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 04 Jun 2001 06:33:00 -0000 Subject: [PATCH] Fix ldbl-96 coshl Message-ID: <20010604153551.H1253@sunsite.ms.mff.cuni.cz> Hi! No idea how the overflowthresold below was computed, it looks close to 2*log(LDBL_MAX), but coshl overflows already at log(LDBL_MAX)+M_LN2l (0xb.174ddc031aec0eap+10 does not overflow and 0xb.174ddc031aec0ebp+10 already does). 2001-06-04 Jakub Jelinek * sysdeps/ieee754/ldbl-96/e_coshl.c (__ieee754_coshl): Fix overflow threshold constant (log(LDBL_MAX)+M_LN2l). --- libc/sysdeps/ieee754/ldbl-96/e_coshl.c.jj Wed Jul 14 02:11:28 1999 +++ libc/sysdeps/ieee754/ldbl-96/e_coshl.c Mon Jun 4 14:20:26 2001 @@ -79,16 +79,15 @@ static long double one = 1.0, half=0.5, if (ex < 0x400c || (ex == 0x400c && mx < 0xb1700000u)) return half*__ieee754_expl(fabsl(x)); - /* |x| in [log(maxdouble), overflowthresold] */ - if (ex < 0x400d - || (ex == 0x400d && (mx < 0xb170b513u - || (mx == 0xb170b513u && lx < 0xa1dfd60cu)))) + /* |x| in [log(maxdouble), log(2*maxdouble)) */ + if (ex == 0x400c && (mx < 0xb174ddc0u + || (mx == 0xb174ddc0u && lx < 0x31aec0ebu))) { w = __ieee754_expl(half*fabsl(x)); t = half*w; return t*w; } - /* |x| > overflowthresold, cosh(x) overflow */ + /* |x| >= log(2*maxdouble), cosh(x) overflow */ return huge*huge; } Jakub From drepper@redhat.com Wed Jun 6 06:11:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 06 Jun 2001 06:11:00 -0000 Subject: [PATCH] Fix exp2* on very small values References: <20010604151159.E1253@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > The exp2* wrappers would signal underflow too early (they should do so when > real underflow happens, not when the returned value would be denormal), on > the other side __ieee754_exp* had the low threshold too small (arguments > <= 2^(*_MIN_EXP - *_MANT_DIG - 1) underflow, while the code was testing > arguments < 2^(*_MIN_EXP - *_MANT_DIG - 2)). Seems OK. Thanks, -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Wed Jun 6 06:11:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 06 Jun 2001 06:11:00 -0000 Subject: [PATCH] Fix llroundl References: <20010604150417.C1253@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > ldbl-96 llroundl(4294967295.5) returns 0, although it should return > 4294967296LL. OK. Thanks, -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Wed Jun 6 06:11:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 06 Jun 2001 06:11:00 -0000 Subject: [PATCH] Make ilogb C99 compliant References: <20010604152037.F1253@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > so we return wrong results on i386 for infinity where FP_ILOGBNAN is > INT_MIN. OK. -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Wed Jun 6 06:11:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 06 Jun 2001 06:11:00 -0000 Subject: [PATCH] Fix ldbl-96 coshl References: <20010604153551.H1253@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > No idea how the overflowthresold below was computed, it looks close to > 2*log(LDBL_MAX), but coshl overflows already at log(LDBL_MAX)+M_LN2l > (0xb.174ddc031aec0eap+10 does not overflow and 0xb.174ddc031aec0ebp+10 > already does). OK. -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Wed Jun 6 06:11:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 06 Jun 2001 06:11:00 -0000 Subject: [PATCH] Fix i386 frexpl References: <20010602210913.B1253@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > i386 assembly frexpl.S has a bug in test for denormals (where C code tests > [...] OK. Thanks, -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Wed Jun 6 06:11:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 06 Jun 2001 06:11:00 -0000 Subject: [PATCH] Fix log2* error handling References: <20010604150630.D1253@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > According to ISO C99, log2 has to return domain range error if argument is > negative and error may be signalled if argument is 0 (similarly to log or > log10). So I guess we need a log2 wrapper, implemented below: Seems OK. Thanks, -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Wed Jun 6 06:11:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 06 Jun 2001 06:11:00 -0000 Subject: [PATCH] Fix exp10 and coshl References: <20010604153034.G1253@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > IMHO sysdeps/generic/ should have no knowledge about IEEE > single/double/extended double/quad formats. Makes sense. Thanks, -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From kettenis@wins.uva.nl Thu Jun 7 12:50:00 2001 From: kettenis@wins.uva.nl (Mark Kettenis) Date: Thu, 07 Jun 2001 12:50:00 -0000 Subject: getgrouplist implementation Message-ID: <200106071950.f57Jo9E00392@delius.kettenis.local> Here is a patch that implements getgrouplist() from 4.4 BSD. We really need this to handle supplementary group ID's in the Hurd and implementing it outside glibc would be pretty hard. I added the prototype to since that is where initgroups() and setgroups() live. On *BSD all these functions live in , so perhaps we should also add these prototypes there. Mark Index: ChangeLog from Mark Kettenis * grp/initgroups.c (initgroups): Factor out re-usable code into... (internal_getgrouplist): ... new function. (getgrouplist): New function. * grp/grp.h (getgrouplist): New prototype. * grp/Versions [2.2.4]: Add getgrouplist. Index: grp/initgroups.c =================================================================== RCS file: /cvs/glibc/libc/grp/initgroups.c,v retrieving revision 1.24 diff -u -p -r1.24 initgroups.c --- grp/initgroups.c 2001/04/17 03:34:06 1.24 +++ grp/initgroups.c 2001/06/07 19:42:10 @@ -136,51 +136,19 @@ compat_call (service_user *nip, const ch return NSS_STATUS_SUCCESS; } -/* Initialize the group set for the current user - by reading the group database and using all groups - of which USER is a member. Also include GROUP. */ -int -initgroups (user, group) - const char *user; - gid_t group; +static int +internal_getgrouplist (const char *user, gid_t group, long int *size, + gid_t **groupsp, long int limit) { -#if defined NGROUPS_MAX && NGROUPS_MAX == 0 - - /* No extra groups allowed. */ - return 0; - -#else - service_user *nip = NULL; initgroups_dyn_function fct; enum nss_status status = NSS_STATUS_UNAVAIL; int no_more; /* Start is one, because we have the first group as parameter. */ long int start = 1; - long int size; - gid_t *groups; - int result; - /* We always use sysconf even if NGROUPS_MAX is defined. That way, the - limit can be raised in the kernel configuration without having to - recompile libc. */ - long int limit = __sysconf (_SC_NGROUPS_MAX); + *groupsp[0] = group; - if (limit > 0) - size = limit; - else - { - /* No fixed limit on groups. Pick a starting buffer size. */ - size = 16; - } - - groups = (gid_t *) malloc (size * sizeof (gid_t)); - if (__builtin_expect (groups == NULL, 0)) - /* No more memory. */ - return -1; - - groups[0] = group; - if (__nss_group_database != NULL) { no_more = 0; @@ -196,14 +164,14 @@ initgroups (user, group) if (fct == NULL) { - status = compat_call (nip, user, group, &start, &size, &groups, + status = compat_call (nip, user, group, &start, size, groupsp, limit, &errno); if (nss_next_action (nip, NSS_STATUS_UNAVAIL) != NSS_ACTION_CONTINUE) break; } else - status = DL_CALL_FCT (fct, (user, group, &start, &size, &groups, + status = DL_CALL_FCT (fct, (user, group, &start, size, groupsp, limit, &errno)); /* This is really only for debugging. */ @@ -220,10 +188,81 @@ initgroups (user, group) nip = nip->next; } + return start; +} + +/* Store at most *NGROUPS members of the group set for USER into + *GROUPS. Also include GROUP. The actual number of groups found is + returned in *NGROUPS. Return -1 if the if *NGROUPS is too small. */ +int +getgrouplist (const char *user, gid_t group, gid_t *groups, int *ngroups) +{ + gid_t *newgroups; + long int size = *ngroups; + int result; + + newgroups = (gid_t *) malloc (size * sizeof (gid_t)); + if (__builtin_expect (newgroups == NULL, 0)) + /* No more memory. */ + return -1; + + result = internal_getgrouplist (user, group, &size, &newgroups, -1); + if (result > *ngroups) + { + *ngroups = result; + result = -1; + } + else + *ngroups = result; + + memcpy (groups, newgroups, *ngroups * sizeof (gid_t)); + + free (newgroups); + return result; +} + +/* Initialize the group set for the current user + by reading the group database and using all groups + of which USER is a member. Also include GROUP. */ +int +initgroups (const char *user, gid_t group) +{ +#if defined NGROUPS_MAX && NGROUPS_MAX == 0 + + /* No extra groups allowed. */ + return 0; + +#else + + long int size; + gid_t *groups; + int ngroups; + int result; + + /* We always use sysconf even if NGROUPS_MAX is defined. That way, the + limit can be raised in the kernel configuration without having to + recompile libc. */ + long int limit = __sysconf (_SC_NGROUPS_MAX); + + if (limit > 0) + size = limit; + else + { + /* No fixed limit on groups. Pick a starting buffer size. */ + size = 16; + } + + groups = (gid_t *) malloc (size * sizeof (gid_t)); + if (__builtin_expect (groups == NULL, 0)) + /* No more memory. */ + return -1; + + ngroups = internal_getgrouplist (user, group, &size, &groups, limit); + /* Try to set the maximum number of groups the kernel can handle. */ do - result = setgroups (start, groups); - while (result == -1 && errno == EINVAL && --start > 0); + result = setgroups (ngroups, groups); + while (result == -1 && errno == EINVAL && --ngroups > 0); free (groups); Index: grp/grp.h =================================================================== RCS file: /cvs/glibc/libc/grp/grp.h,v retrieving revision 1.28 diff -u -p -r1.28 grp.h --- grp/grp.h 2000/02/28 04:24:18 1.28 +++ grp/grp.h 2001/06/07 19:42:10 @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,92,95,96,97,98,99,2000 Free Software Foundation, Inc. +/* Copyright (C) 1991,92,95,96,97,98,99,2000,01 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 @@ -135,6 +135,12 @@ extern int fgetgrent_r (FILE *__restrict /* Set the group set for the current user to GROUPS (N of them). */ extern int setgroups (size_t __n, __const __gid_t *__groups) __THROW; + +/* Store at most *NGROUPS members of the group set for USER into + *GROUPS. Also include GROUP. The actual number of groups found is + returned in *NGROUPS. Return -1 if the if *NGROUPS is too small. */ +extern int getgrouplist (__const char *__user, __gid_t __group, + __gid_t *__groups, int *__ngroups) __THROW; /* Initialize the group set for the current user by reading the group database and using all groups Index: grp/Versions =================================================================== RCS file: /cvs/glibc/libc/grp/Versions,v retrieving revision 1.3 diff -u -p -r1.3 Versions --- grp/Versions 1999/07/09 20:47:25 1.3 +++ grp/Versions 2001/06/07 19:42:10 @@ -24,4 +24,8 @@ libc { # g* getgrent_r; getgrgid_r; getgrnam_r; } + GLIBC_2.2.4 { + # g* + getgrouplist; + } } From schwab@suse.de Fri Jun 8 07:10:00 2001 From: schwab@suse.de (Andreas Schwab) Date: Fri, 08 Jun 2001 07:10:00 -0000 Subject: regex crash Message-ID: This fixes a crash when calling regexec with the empty string and the pattern '\<'. 2001-06-08 Andreas Schwab * posix/regex.c (re_match_2_internal) [case wordbeg, wordend]: Don't dereference at end of string. --- posix/regex.c.~1.97.~ Tue May 15 13:30:03 2001 +++ posix/regex.c Fri Jun 8 16:03:51 2001 @@ -7094,14 +7094,15 @@ case wordbeg: DEBUG_PRINT1 ("EXECUTING wordbeg.\n"); - if (WORDCHAR_P (d) && (AT_STRINGS_BEG (d) || !WORDCHAR_P (d - 1))) + if (!AT_STRINGS_END (d) && WORDCHAR_P (d) + && (AT_STRINGS_BEG (d) || !WORDCHAR_P (d - 1))) break; goto fail; case wordend: DEBUG_PRINT1 ("EXECUTING wordend.\n"); if (!AT_STRINGS_BEG (d) && WORDCHAR_P (d - 1) - && (!WORDCHAR_P (d) || AT_STRINGS_END (d))) + && (AT_STRINGS_END (d) || !WORDCHAR_P (d))) break; goto fail; -- Andreas Schwab "And now for something SuSE Labs completely different." Andreas.Schwab@suse.de SuSE GmbH, Schanz????ckerstr. 10, D-90443 N????rnberg Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 From drepper@redhat.com Sat Jun 9 23:44:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Sat, 09 Jun 2001 23:44:00 -0000 Subject: regex crash References: Message-ID: Andreas Schwab writes: > This fixes a crash when calling regexec with the empty string and the > pattern '\<'. OK, I've applied it. Thanks, -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Sat Jun 9 23:45:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Sat, 09 Jun 2001 23:45:00 -0000 Subject: getgrouplist implementation References: <200106071950.f57Jo9E00392@delius.kettenis.local> Message-ID: Mark Kettenis writes: > Here is a patch that implements getgrouplist() from 4.4 BSD. We > really need this to handle supplementary group ID's in the Hurd and > implementing it outside glibc would be pretty hard. Give me some more details, please. I've never come across a situation where it is used and don't want to add cruft for all platforms just because BSD did it. -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From kettenis@wins.uva.nl Sun Jun 10 01:19:00 2001 From: kettenis@wins.uva.nl (Mark Kettenis) Date: Sun, 10 Jun 2001 01:19:00 -0000 Subject: getgrouplist implementation References: <200106071950.f57Jo9E00392@delius.kettenis.local> Message-ID: <200106100819.f5A8JHH00344@delius.kettenis.local> From: Ulrich Drepper Date: 09 Jun 2001 23:43:43 -0700 Mark Kettenis writes: > Here is a patch that implements getgrouplist() from 4.4 BSD. We > really need this to handle supplementary group ID's in the Hurd and > implementing it outside glibc would be pretty hard. Give me some more details, please. I've never come across a situation where it is used and don't want to add cruft for all platforms just because BSD did it. Basically you would use it in a situation where you're interested in a user's suplementary group IDs, but where you do not want to set them (or at least not yet). You could roll your own getgrouplist() using getgrent(), but that wouldn't be terribly efficient and probably even miss out groups if you use NSS backends like NIS+ or Hesiod. OpenSSH uses getgrouplist() to implement some access control based on suplementary group IDs. In the Hurd we have a lot more flexibility with respect to user and group IDs than on traditional UNIX. That's why we need to fetch a complete list of supplementary group ID's and fiddle with those instead of calling initgroups(). Mark From aj@suse.de Mon Jun 11 05:33:00 2001 From: aj@suse.de (Andreas Jaeger) Date: Mon, 11 Jun 2001 05:33:00 -0000 Subject: patch for aclocal.m4 Message-ID: I've committed the appended patch to fix a bug in our aclocal.m4. Andreas * aclocal.m4: Quote AC_FD_MSG and AC_FD_CC. ============================================================ Index: aclocal.m4 --- aclocal.m4 1999/05/29 22:54:11 1.16 +++ aclocal.m4 2001/06/11 12:29:56 @@ -3,8 +3,8 @@ dnl Each sysdep configure.in does GLIBC_PROVIDES first, to avoid any dnl AC_REQUIREs or AC_BEFOREs duplicating their code. dnl -define(AC_FD_MSG,6)dnl Autoconf lossage. -define(AC_FD_CC,5)dnl Autoconf lossage. +define([AC_FD_MSG],6)dnl Autoconf lossage. +define([AC_FD_CC],5)dnl Autoconf lossage. AC_DEFUN([GLIBC_PROVIDES], [dnl AC_PROVIDE([AC_PROG_INSTALL])dnl AC_PROVIDE([AC_PROG_RANLIB])dnl -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de http://www.suse.de/~aj From jakub@redhat.com Tue Jun 12 08:59:00 2001 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 12 Jun 2001 08:59:00 -0000 Subject: GCC 3.0 and GLIBC don't work together References: Message-ID: <20010612180120.A662@sunsite.ms.mff.cuni.cz> On Tue, Jun 12, 2001 at 04:38:31PM +0200, Andreas Jaeger wrote: Speaking of GLIBC and GCC 3.0, we should I think finally decide what to do, because even if GCC 3.0 compiler GLIBC passed all tests, it will still be binary incompatible (e.g. __frame_state_for symbol will be missing) and it would be bad if someone started shipping GCC 3.0 compiler GLIBC without these issues sorted out. Richard has included _Unwind_Find_FDE API in libgcc_s, so __frame_state_for can be built on top of that. Doing so requires glibc to have a copy of gcc old-style dwarf2 unwinder updated so that it copes with newly generated unwind directives. Then, I think we have the following options: - glibc will be linked without special options and appart from __frame_state_for no other unwinding symbols will be exported from glibc. Like this, glibc will have DT_NEEDED libgcc_s.so.1 which will provide the whole interface and just glibc's __frame_state_for will use _Unwind_Find_FDE to locate FDEs. The advantages of this are that libgcc_s can be simply upgraded, __frame_state_for code will have to be checked only if glibc is recompiled with newer gcc. The disadvantages include bigger memory footprint of every application and bigger startup times due to one more shared library included in each program. - like the above, but libgcc_s.so.1 is DT_FILTER of glibc (requires the current GLIBC semantics of DT_FILTER, not the one Solaris uses) - libgcc_s has to be found in this case - glibc will be linked with -static-libgcc and will export the usual __register_frame_info@@GLIBC_2.0 etc., and __register_frame_info_bases@@GCC_3.0 __deregister_frame_info_bases@@GCC_3.0 __register_frame_info_table_bases@@GCC_3.0 _Unwind_Find_FDE@@GCC_3.0 Like this, glibc does not have to be linked to libgcc_s at all, but if any library is linked against libgcc_s, it will find its FDEs just fine - like the above, but libgcc_s.so.1 is DT_AUXILIARY (in the GLIBC semantics of DT_AUXILIARY) of glibc. Jakub From hjl@lucon.org Tue Jun 12 15:47:00 2001 From: hjl@lucon.org (H . J . Lu) Date: Tue, 12 Jun 2001 15:47:00 -0000 Subject: GCC 3.0 and GLIBC don't work together References: <20010612180120.A662@sunsite.ms.mff.cuni.cz> Message-ID: <20010612154700.A26830@lucon.org> On Tue, Jun 12, 2001 at 06:01:20PM +0200, Jakub Jelinek wrote: > On Tue, Jun 12, 2001 at 04:38:31PM +0200, Andreas Jaeger wrote: > > Speaking of GLIBC and GCC 3.0, we should I think finally decide what to do, > because even if GCC 3.0 compiler GLIBC passed all tests, it will still be > binary incompatible (e.g. __frame_state_for symbol will be missing) and it > would be bad if someone started shipping GCC 3.0 compiler GLIBC without > these issues sorted out. > > Richard has included _Unwind_Find_FDE API in libgcc_s, so __frame_state_for > can be built on top of that. Doing so requires glibc to have a copy of gcc > old-style dwarf2 unwinder updated so that it copes with newly generated > unwind directives. > > Then, I think we have the following options: > > - glibc will be linked without special options and appart from > __frame_state_for no other unwinding symbols will be exported from glibc. > Like this, glibc will have DT_NEEDED libgcc_s.so.1 which will provide the > whole interface and just glibc's __frame_state_for will use > _Unwind_Find_FDE to locate FDEs. > The advantages of this are that libgcc_s can be simply upgraded, > __frame_state_for code will have to be checked only if glibc is recompiled > with newer gcc. > The disadvantages include bigger memory footprint of every application > and bigger startup times due to one more shared library included in each > program. I have once concern. If glibc has libgcc_s.so.1 in DT_NEEDED, that means the glibc binary will depend on something outside of glibc, which can be changed without the knowledge of glibc. > - like the above, but libgcc_s.so.1 is DT_FILTER of glibc (requires the > current GLIBC semantics of DT_FILTER, not the one Solaris uses) - libgcc_s > has to be found in this case > - glibc will be linked with -static-libgcc and will export > the usual __register_frame_info@@GLIBC_2.0 etc., and > __register_frame_info_bases@@GCC_3.0 > __deregister_frame_info_bases@@GCC_3.0 > __register_frame_info_table_bases@@GCC_3.0 > _Unwind_Find_FDE@@GCC_3.0 > Like this, glibc does not have to be linked to libgcc_s at all, but > if any library is linked against libgcc_s, it will find its FDEs just fine > - like the above, but libgcc_s.so.1 is DT_AUXILIARY (in the GLIBC semantics > of DT_AUXILIARY) of glibc. If we have to choose between DT_FILTER and DT_AUXILIARY, I prefer DT_AUXILIARY since libgcc_s.so.1 doesn't have to exist. What I'd like to see as an option is 1. gcc 3.0 can be configured not to build its own libgcc_s, but use the system one if it exists. 2. glibc builds/uses/installs libgcc_s out of libgcc.a in gcc 3.0. In this way, libgcc_s becomes the part of glibc. H.J. From schwab@suse.de Wed Jun 13 11:23:00 2001 From: schwab@suse.de (Andreas Schwab) Date: Wed, 13 Jun 2001 11:23:00 -0000 Subject: ldconfig bug Message-ID: This makes ldconfig working again. Andreas. 2001-06-13 Andreas Schwab * elf/ldconfig.c (search_dir): Fix check for regular file. --- elf/ldconfig.c.~1.21.~ Fri May 18 11:12:20 2001 +++ elf/ldconfig.c Wed Jun 13 20:17:25 2001 @@ -720,7 +720,7 @@ add_single_dir (new_entry, 0); continue; } - else if (!S_ISREG (stat_buf.st_mode) && !is_link) + else if (!S_ISREG (lstat_buf.st_mode) && !is_link) continue; if (opt_chroot && is_link) -- Andreas Schwab "And now for something SuSE Labs completely different." Andreas.Schwab@suse.de SuSE GmbH, Schanz????ckerstr. 10, D-90443 N????rnberg Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 From aj@suse.de Wed Jun 13 15:32:00 2001 From: aj@suse.de (Andreas Jaeger) Date: Wed, 13 Jun 2001 15:32:00 -0000 Subject: ldconfig bug References: Message-ID: Andreas Schwab writes: > This makes ldconfig working again. > > Andreas. > > 2001-06-13 Andreas Schwab > > * elf/ldconfig.c (search_dir): Fix check for regular file. > > --- elf/ldconfig.c.~1.21.~ Fri May 18 11:12:20 2001 >+++ elf/ldconfig.c Wed Jun 13 20:17:25 2001 > @@ -720,7 +720,7 @@ > add_single_dir (new_entry, 0); > continue; > } > - else if (!S_ISREG (stat_buf.st_mode) && !is_link) >+ else if (!S_ISREG (lstat_buf.st_mode) && !is_link) I prefer to switch the conditions: else if (!is_link && !S_ISREG (stat_buf.st_mode)) Please commit this, Andreas > continue; > > if (opt_chroot && is_link) -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de http://www.suse.de/~aj From roland@frob.com Wed Jun 13 23:09:00 2001 From: roland@frob.com (Roland McGrath) Date: Wed, 13 Jun 2001 23:09:00 -0000 Subject: shm_open in librt Message-ID: <20010614060934.1AD9799862@perdition.linnaean.org> What is the rationale for shm_open/shm_unlink being in librt? The _POSIX_SHARED_MEMORY_OBJECTS option is independent of any other option or anything having to do with real-time. From drepper@redhat.com Thu Jun 14 00:08:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Thu, 14 Jun 2001 00:08:00 -0000 Subject: shm_open in librt References: <20010614060934.1AD9799862@perdition.linnaean.org> Message-ID: Roland McGrath writes: > What is the rationale for shm_open/shm_unlink being in librt? The > _POSIX_SHARED_MEMORY_OBJECTS option is independent of any other option > or anything having to do with real-time. The position of the POSIX committee is that all features added in .1b belongs in librt. -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From schwab@suse.de Thu Jun 14 07:41:00 2001 From: schwab@suse.de (Andreas Schwab) Date: Thu, 14 Jun 2001 07:41:00 -0000 Subject: ldconfig bug References: Message-ID: Andreas Jaeger writes: |> Andreas Schwab writes: |> |> > This makes ldconfig working again. |> > |> > Andreas. |> > |> > 2001-06-13 Andreas Schwab |> > |> > * elf/ldconfig.c (search_dir): Fix check for regular file. |> > |> > --- elf/ldconfig.c.~1.21.~ Fri May 18 11:12:20 2001 |> >+++ elf/ldconfig.c Wed Jun 13 20:17:25 2001 |> > @@ -720,7 +720,7 @@ |> > add_single_dir (new_entry, 0); |> > continue; |> > } |> > - else if (!S_ISREG (stat_buf.st_mode) && !is_link) |> >+ else if (!S_ISREG (lstat_buf.st_mode) && !is_link) |> |> I prefer to switch the conditions: |> else if (!is_link && !S_ISREG (stat_buf.st_mode)) |> |> Please commit this, stat_buf is only defined if is_link is non-zero. I'm now committing my version. Andreas. -- Andreas Schwab "And now for something SuSE Labs completely different." Andreas.Schwab@suse.de SuSE GmbH, Schanz????ckerstr. 10, D-90443 N????rnberg Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 From roland@frob.com Thu Jun 14 13:25:00 2001 From: roland@frob.com (Roland McGrath) Date: Thu, 14 Jun 2001 13:25:00 -0000 Subject: move aio code to sysdeps/pthread Message-ID: <20010614202507.C1CD099863@perdition.linnaean.org> I'd like to commit the following change to configure.in, which has to effect of making the linuxthreads add-on bring sysdeps/pthread from the main source directory into the list of sysdeps dirs searched. A simpler feature like just add-on/Implies would suffice for this case, but it seems generally useful to have sysdeps in the main source directory that is used only in some configurations and let the set of add-ons constitute another axis multiplied by the configuration tuple to choose the final set. For example, there could be a sysdeps subdir in the main source that contains code that's optimal if you have the foo facility and won't work if you don't have the foo facility. A particular add-on might provide the foo facility only on certain configurations (i.e. machine/OS combinations), and so would express with the file add-on/sysdeps/someos/somecpu/Implies containing "foo". It then becomes a degenerate case of this for any add-on to supply an add-on/sysdeps/generic/Implies file for the add-on-wide Implies. I then want to move most of the aio_*.c code from rt/ to sysdeps/pthread/ and add sysdeps/generic/ stub files. By convention, aio.h would also be split into bits/aio.h, but I'm not doing that since in fact I would like to keep the aio.h part of the ABI the same across configurations. For that reason, I'm not moving aio_error and aio_return.c, which are just structure accessors. The reason I'm doing this is because the aio routines have natural implementations not using threads on some systems (like the Hurd). POSIX.1 makes it meaningful to support _POSIX_ASYNCHRONOUS_IO (i.e. aio.h) without supporting _POSIX_THREADS (you just can't use SIGEV_THREAD) or _POSIX_REALTIME_SIGNALS (you just get plain signals for SIGEV_SIGNAL). That's what I plan to do for the Hurd in the near term. At any rate, even once we have pthreads for the Hurd, the Hurd-specific implementation will be preferable to one based on pthreads, so the aio code should be sysdeps. I see no reason not to build librt in the absence of libpthread, even if it is just built full of stubs, so I plan to make that change. (The only reason it fails to build if you try it now is because there are no aio_* stubs, only code that requires pthread.h to compile. There are stub sources for all the other routines in librt. In fact, several routines from shm_* and clock_* already have implementations that don't require pthreads.) Is all this OK? Note that this does permute slightly the sysdeps list you wind up with. I have not checked meticulously to be sure that it has not changed which sources get compiled in practice, but I don't think it has. 2001-06-14 Roland McGrath * configure.in: Let sysdeps Implies files in add-ons bring in sysdeps directories from the main source and other add-ons too. Index: configure.in =================================================================== RCS file: /cvs/glibc/libc/configure.in,v retrieving revision 1.317 diff -u -b -p -r1.317 configure.in --- configure.in 2001/06/13 08:05:26 1.317 +++ configure.in 2001/06/14 19:59:07 @@ -495,9 +495,25 @@ while test $# -gt 0; do implied_candidate="`sed 's/#.*$//' < $xsrcdir$name/Implies`" implied= for x in $implied_candidate; do + found=no if test -d $xsrcdir$name_base/$x; then implied="$implied $name_base/$x"; - else + found=yes + fi + for d in $add_ons_pfx ''; do + try="${d}sysdeps/$x" + case $d in + /*) try_srcdir= ;; + *) try_srcdir=$srcdir/ ;; + esac + test -n "$enable_debug_configure" && + echo "[DEBUG]: $name implied $x try($d) {$try_srcdir}$try" >&2 + if test $try != $xsrcdir$name_base/$x && test -d $try_srcdir$try; then + implied="$implied $try" + found=yes + fi + done + if test $found = no; then AC_MSG_WARN($name/Implies specifies nonexistent $x) fi done From roland@frob.com Thu Jun 14 14:08:00 2001 From: roland@frob.com (Roland McGrath) Date: Thu, 14 Jun 2001 14:08:00 -0000 Subject: --whole-archive libc_nonshared.a in shared objects Message-ID: <20010614210759.C717999862@perdition.linnaean.org> Why is all of libc_nonshared.a included with --whole-archive into every .so linked? Shouldn't it come after --no-whole-archive and link in only the modules needed by that .so? It seems pretty wrong that e.g. libm.so has a local definition of __mknod and an undefined dynamic symbol reference for __xmknod. From drepper@redhat.com Thu Jun 14 14:41:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Thu, 14 Jun 2001 14:41:00 -0000 Subject: --whole-archive libc_nonshared.a in shared objects References: <20010614210759.C717999862@perdition.linnaean.org> Message-ID: Roland McGrath writes: > Why is all of libc_nonshared.a included with --whole-archive into every .so > linked? Shouldn't it come after --no-whole-archive and link in only the > modules needed by that .so? Yes, this should be changed. Note that it's not causing any harm since the symbols are not exported. Nevertheless... -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From roland@frob.com Thu Jun 14 14:44:00 2001 From: roland@frob.com (Roland McGrath) Date: Thu, 14 Jun 2001 14:44:00 -0000 Subject: --whole-archive libc_nonshared.a in shared objects References: Message-ID: <20010614214434.C1E0A99862@perdition.linnaean.org> > Roland McGrath writes: > > > Why is all of libc_nonshared.a included with --whole-archive into every .so > > linked? Shouldn't it come after --no-whole-archive and link in only the > > modules needed by that .so? > > Yes, this should be changed. Note that it's not causing any harm > since the symbols are not exported. Nevertheless... But the undefined symbols are there, and possibly creating more version set dependencies than there need to be. From drepper@redhat.com Thu Jun 14 15:24:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Thu, 14 Jun 2001 15:24:00 -0000 Subject: --whole-archive libc_nonshared.a in shared objects References: <20010614214434.C1E0A99862@perdition.linnaean.org> Message-ID: Roland McGrath writes: > But the undefined symbols are there, and possibly creating more version set > dependencies than there need to be. That part is OK. All references to symbols in libc_nonshared must be resolved locally. So, linking in libc_nonshared.a as an archive is necessary. -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From roland@frob.com Thu Jun 14 15:40:00 2001 From: roland@frob.com (Roland McGrath) Date: Thu, 14 Jun 2001 15:40:00 -0000 Subject: --whole-archive libc_nonshared.a in shared objects References: Message-ID: <20010614224023.DA46799862@perdition.linnaean.org> > Roland McGrath writes: > > > But the undefined symbols are there, and possibly creating more version set > > dependencies than there need to be. > > That part is OK. All references to symbols in libc_nonshared must be > resolved locally. So, linking in libc_nonshared.a as an archive is > necessary. I don't understand. I thought you just said we should not the whole archive. From drepper@redhat.com Thu Jun 14 15:52:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Thu, 14 Jun 2001 15:52:00 -0000 Subject: --whole-archive libc_nonshared.a in shared objects References: <20010614224023.DA46799862@perdition.linnaean.org> Message-ID: Roland McGrath writes: > > That part is OK. All references to symbols in libc_nonshared must be > > resolved locally. So, linking in libc_nonshared.a as an archive is > > necessary. > > I don't understand. I thought you just said we should not the whole archive. Not the whole archive but all the functions definitions from the archive which are referenced. -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From roland@frob.com Thu Jun 14 15:59:00 2001 From: roland@frob.com (Roland McGrath) Date: Thu, 14 Jun 2001 15:59:00 -0000 Subject: --whole-archive libc_nonshared.a in shared objects References: Message-ID: <20010614225856.DB33699862@perdition.linnaean.org> > Not the whole archive but all the functions definitions from the > archive which are referenced. Well, sure. But e.g. libm doesn't reference anything but still winds up with the references to __xmknod, __xstat, etc. That's what I was saying. So we are agreed that libc_nonshared.a should move after --no-whole-archive. From drepper@redhat.com Thu Jun 14 16:05:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Thu, 14 Jun 2001 16:05:00 -0000 Subject: --whole-archive libc_nonshared.a in shared objects References: <20010614225856.DB33699862@perdition.linnaean.org> Message-ID: Roland McGrath writes: > So we are agreed that libc_nonshared.a should move after --no-whole-archive. Yes. Wanna come up with a patch? -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From roland@frob.com Thu Jun 14 16:38:00 2001 From: roland@frob.com (Roland McGrath) Date: Thu, 14 Jun 2001 16:38:00 -0000 Subject: --whole-archive libc_nonshared.a in shared objects References: Message-ID: <20010614233803.CE28E99862@perdition.linnaean.org> > Roland McGrath writes: > > > So we are agreed that libc_nonshared.a should move after --no-whole-archive. > > Yes. Wanna come up with a patch? Who, me? I thought I was on the complaining-only track. ;-) I will figure something out. From jakub@redhat.com Fri Jun 15 05:10:00 2001 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 15 Jun 2001 05:10:00 -0000 Subject: [PATCH] Fix nexttoward* and nextafter* Message-ID: <20010615141233.A508@sunsite.ms.mff.cuni.cz> Hi! Some of nextafter* and nexttoward* are buggy. Namely, i386 style INFINITY is 0x7fff, 0x80000000, 0x0 but the code would do very complicated check (((hx|lx)|-(hx|lx))&hx)!=0 which is non-zero for INFINITY as well, also ldbl-96/s_nextafterl had wrong sign e.g. for nextafterl(-0.0, INFINITY) or nextafterl(0.0, -INFINITY). 2001-06-15 Jakub Jelinek * math/test-misc.c (main): Add tests for nextafter and nexttoward with +-Inf as second argument. * sysdeps/generic/s_nexttowardf.c (__nexttowardf): Only check for NaN, not Inf. * sysdeps/i386/fpu/s_nextafterl.c (__nextafterl): Fix check for NaN. * sysdeps/i386/fpu/s_nexttoward.c: New. * sysdeps/i386/fpu/s_nexttowardf.c: New. * sysdeps/ieee754/ldbl-96/s_nexttoward.c (__nexttoward): Simplify check for NaN, optimize x==+-0 handling. * sysdeps/ieee754/ldbl-96/s_nexttowardf.c (__nexttowardf): Likewise. * sysdeps/ieee754/ldbl-96/s_nextafterl.c (__nextafterl): Simplify check for NaN, fix sign in x==+-0 case. * sysdeps/ia64/fpu/s_nexttoward.c: New. * sysdeps/ia64/fpu/s_nexttowardf.c: New. --- libc/math/test-misc.c.jj Sat Jun 2 20:36:01 2001 +++ libc/math/test-misc.c Fri Jun 15 13:44:11 2001 @@ -384,6 +384,24 @@ main (void) v2.ieee.negative); result = 1; } + + if (nextafterf (0.0f, INFINITY) != nextafterf (0.0f, 1.0f) + || nextafterf (-0.0f, INFINITY) != nextafterf (-0.0f, 1.0f) + || nextafterf (0.0f, -INFINITY) != nextafterf (0.0f, -1.0f) + || nextafterf (-0.0f, -INFINITY) != nextafterf (-0.0f, -1.0f)) + { + printf ("nextafterf (+-0, +-Inf) != nextafterf (+-0, +-1)\n"); + result = 1; + } + + if (nexttowardf (0.0f, INFINITY) != nexttowardf (0.0f, 1.0f) + || nexttowardf (-0.0f, INFINITY) != nexttowardf (-0.0f, 1.0f) + || nexttowardf (0.0f, -INFINITY) != nexttowardf (0.0f, -1.0f) + || nexttowardf (-0.0f, -INFINITY) != nexttowardf (-0.0f, -1.0f)) + { + printf ("nexttowardf (+-0, +-Inf) != nexttowardf (+-0, +-1)\n"); + result = 1; + } } { @@ -680,6 +698,24 @@ main (void) v2.ieee.negative); result = 1; } + + if (nextafter (0.0, INFINITY) != nextafter (0.0, 1.0) + || nextafter (-0.0, INFINITY) != nextafter (-0.0, 1.0) + || nextafter (0.0, -INFINITY) != nextafter (0.0, -1.0) + || nextafter (-0.0, -INFINITY) != nextafter (-0.0, -1.0)) + { + printf ("nextafter (+-0, +-Inf) != nextafter (+-0, +-1)\n"); + result = 1; + } + + if (nexttoward (0.0, INFINITY) != nexttoward (0.0, 1.0) + || nexttoward (-0.0, INFINITY) != nexttoward (-0.0, 1.0) + || nexttoward (0.0, -INFINITY) != nexttoward (0.0, -1.0) + || nexttoward (-0.0, -INFINITY) != nexttoward (-0.0, -1.0)) + { + printf ("nexttoward (+-0, +-Inf) != nexttoward (+-0, +-1)\n"); + result = 1; + } } #ifndef NO_LONG_DOUBLE @@ -978,6 +1014,24 @@ main (void) { printf ("0.0L down: negative differs: 1 vs %d\n", v2.ieee.negative); + result = 1; + } + + if (nextafterl (0.0, INFINITY) != nextafterl (0.0, 1.0) + || nextafterl (-0.0, INFINITY) != nextafterl (-0.0, 1.0) + || nextafterl (0.0, -INFINITY) != nextafterl (0.0, -1.0) + || nextafterl (-0.0, -INFINITY) != nextafterl (-0.0, -1.0)) + { + printf ("nextafterl (+-0, +-Inf) != nextafterl (+-0, +-1)\n"); + result = 1; + } + + if (nexttowardl (0.0L, INFINITY) != nexttowardl (0.0L, 1.0L) + || nexttowardl (-0.0L, INFINITY) != nexttowardl (-0.0L, 1.0L) + || nexttowardl (0.0L, -INFINITY) != nexttowardl (0.0L, -1.0L) + || nexttowardl (-0.0L, -INFINITY) != nexttowardl (-0.0L, -1.0L)) + { + printf ("nexttowardl (+-0, +-Inf) != nexttowardl (+-0, +-1)\n"); result = 1; } } --- libc/sysdeps/generic/s_nexttowardf.c.jj Tue Oct 12 17:39:31 1999 +++ libc/sysdeps/generic/s_nexttowardf.c Fri Jun 15 13:04:26 2001 @@ -39,7 +39,7 @@ ix = hx&0x7fffffff; /* |x| */ iy = hy&0x7fffffff; /* |y| */ - if((ix>=0x7f800000) || /* x is nan */ + if((ix>0x7f800000) || /* x is nan */ ((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0)) /* y is nan */ return x+y; if((long double) x==y) return y; /* x=y, return y */ --- libc/sysdeps/i386/fpu/s_nextafterl.c.jj Tue Jan 2 14:18:03 2001 +++ libc/sysdeps/i386/fpu/s_nextafterl.c Fri Jun 15 13:17:43 2001 @@ -45,10 +45,10 @@ static char rcsid[] = "$NetBSD: $"; ix = esx&0x7fff; /* |x| */ iy = esy&0x7fff; /* |y| */ - /* The additional &hx/&hy is required because Intel's extended format - has the normally implicit 1 explicit present. Sigh! */ - if(((ix==0x7fff)&&(((hx|lx)|-(hx|lx))&hx)>>31!=0) || /* x is nan */ - ((iy==0x7fff)&&(((hy|ly)|-(hy|ly))&hy)>>31!=0)) /* y is nan */ + /* Intel's extended format has the normally implicit 1 explicit + present. Sigh! */ + if(((ix==0x7fff)&&((hx&0x7fffffff|lx)!=0)) || /* x is nan */ + ((iy==0x7fff)&&((hy&0x7fffffff|ly)!=0))) /* y is nan */ return x+y; if(x==y) return y; /* x=y, return y */ if((ix|hx|lx)==0) { /* x == 0 */ --- libc/sysdeps/i386/fpu/s_nexttoward.c.jj Fri Jun 15 13:22:20 2001 +++ libc/sysdeps/i386/fpu/s_nexttoward.c Fri Jun 15 13:23:14 2001 @@ -0,0 +1,101 @@ +/* s_nexttoward.c + * Special i387 version + * Conversion from s_nextafter.c 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 + +/* IEEE functions + * nexttoward(x,y) + * return the next machine floating-point number of x in the + * direction toward y. + * Special cases: + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + double __nexttoward(double x, long double y) +#else + double __nexttoward(x,y) + double x; + long double y; +#endif +{ + int32_t hx,ix,iy; + u_int32_t lx,hy,ly,esy; + + EXTRACT_WORDS(hx,lx,x); + GET_LDOUBLE_WORDS(esy,hy,ly,y); + ix = hx&0x7fffffff; /* |x| */ + iy = esy&0x7fff; /* |y| */ + + /* Intel's extended format has the normally implicit 1 explicit + present. Sigh! */ + if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) || /* x is nan */ + ((iy>=0x7fff)&&((hy&0x7fffffff)|ly)!=0)) /* y is nan */ + return x+y; + if((long double) x==y) return y; /* x=y, return y */ + if((ix|lx)==0) { /* x == 0 */ + double x2; + INSERT_WORDS(x,(esy&0x8000)<<16,1); /* return +-minsub */ + x2 = x*x; + if(x2==x) return x2; else return x; /* raise underflow flag */ + } + if(hx>=0) { /* x > 0 */ + if (esy>=0x8000||((ix>>20)&0x7ff)>iy-0x3c00 + || (((ix>>20)&0x7ff)==iy-0x3c00 + && (((hx<<11)|(lx>>21))>(hy&0x7fffffff) + || (((hx<<11)|(lx>>21))==(hy&0x7fffffff) + && (lx<<11)>ly)))) { /* x > y, x -= ulp */ + if(lx==0) hx -= 1; + lx -= 1; + } else { /* x < y, x += ulp */ + lx += 1; + if(lx==0) hx += 1; + } + } else { /* x < 0 */ + if (esy<0x8000||((ix>>20)&0x7ff)>iy-0x3c00 + || (((ix>>20)&0x7ff)==iy-0x3c00 + && (((hx<<11)|(lx>>21))>(hy&0x7fffffff) + || (((hx<<11)|(lx>>21))==(hy&0x7fffffff) + && (lx<<11)>ly)))) {/* x < y, x -= ulp */ + if(lx==0) hx -= 1; + lx -= 1; + } else { /* x > y, x += ulp */ + lx += 1; + if(lx==0) hx += 1; + } + } + hy = hx&0x7ff00000; + if(hy>=0x7ff00000) return x+x; /* overflow */ + if(hy<0x00100000) { /* underflow */ + double x2 = x*x; + if(x2!=x) { /* raise underflow flag */ + INSERT_WORDS(x2,hx,lx); + return x2; + } + } + INSERT_WORDS(x,hx,lx); + return x; +} +weak_alias (__nexttoward, nexttoward) +#ifdef NO_LONG_DOUBLE +strong_alias (__nexttoward, __nexttowardl) +weak_alias (__nexttoward, nexttowardl) +#endif --- libc/sysdeps/i386/fpu/s_nexttowardf.c.jj Fri Jun 15 13:25:44 2001 +++ libc/sysdeps/i386/fpu/s_nexttowardf.c Fri Jun 15 13:27:31 2001 @@ -0,0 +1,81 @@ +/* s_nexttowardf.c -- float version of s_nextafter.c. + * Special i387 version. + * 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. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + float __nexttowardf(float x, long double y) +#else + float __nexttowardf(x,y) + float x; + long double y; +#endif +{ + int32_t hx,ix,iy; + u_int32_t hy,ly,esy; + + GET_FLOAT_WORD(hx,x); + GET_LDOUBLE_WORDS(esy,hy,ly,y); + ix = hx&0x7fffffff; /* |x| */ + iy = esy&0x7fff; /* |y| */ + + /* Intel's extended format has the normally implicit 1 explicit + present. Sigh! */ + if((ix>0x7f800000) || /* x is nan */ + (iy>=0x7fff&&(((hy&0x7fffffff)|ly)!=0))) /* y is nan */ + return x+y; + if((long double) x==y) return y; /* x=y, return y */ + if(ix==0) { /* x == 0 */ + float x2; + SET_FLOAT_WORD(x,((esy&0x8000)<<16)|1);/* return +-minsub*/ + x2 = x*x; + if(x2==x) return x2; else return x; /* raise underflow flag */ + } + if(hx>=0) { /* x > 0 */ + if(esy>=0x8000||((ix>>23)&0xff)>iy-0x3f80 + || (((ix>>23)&0xff)==iy-0x3f80 + && ((ix&0x7fffff)<<8)>(hy&0x7fffffff))) {/* x > y, x -= ulp */ + hx -= 1; + } else { /* x < y, x += ulp */ + hx += 1; + } + } else { /* x < 0 */ + if(esy<0x8000||((ix>>23)&0xff)>iy-0x3f80 + || (((ix>>23)&0xff)==iy-0x3f80 + && ((ix&0x7fffff)<<8)>(hy&0x7fffffff))) {/* x < y, x -= ulp */ + hx -= 1; + } else { /* x > y, x += ulp */ + hx += 1; + } + } + hy = hx&0x7f800000; + if(hy>=0x7f800000) return x+x; /* overflow */ + if(hy<0x00800000) { /* underflow */ + float x2 = x*x; + if(x2!=x) { /* raise underflow flag */ + SET_FLOAT_WORD(x2,hx); + return x2; + } + } + SET_FLOAT_WORD(x,hx); + return x; +} +weak_alias (__nexttowardf, nexttowardf) --- libc/sysdeps/ieee754/ldbl-96/s_nexttoward.c.jj Thu Nov 2 08:52:19 2000 +++ libc/sysdeps/ieee754/ldbl-96/s_nexttoward.c Fri Jun 15 13:28:40 2001 @@ -45,12 +45,12 @@ static char rcsid[] = "$NetBSD: $"; iy = esy&0x7fff; /* |y| */ if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) || /* x is nan */ - ((iy>=0x7fff)&&((hy|ly)|-(hy|ly))!=0)) /* y is nan */ + ((iy>=0x7fff)&&(hy|ly)!=0)) /* y is nan */ return x+y; if((long double) x==y) return y; /* x=y, return y */ if((ix|lx)==0) { /* x == 0 */ double x2; - INSERT_WORDS(x,esy&0x8000?0x80000000:0,1);/* return +-minsub */ + INSERT_WORDS(x,(esy&0x8000)<<16,1); /* return +-minsub */ x2 = x*x; if(x2==x) return x2; else return x; /* raise underflow flag */ } --- libc/sysdeps/ieee754/ldbl-96/s_nextafterl.c.jj Wed Jul 14 02:14:34 1999 +++ libc/sysdeps/ieee754/ldbl-96/s_nextafterl.c Fri Jun 15 13:07:08 2001 @@ -43,12 +43,12 @@ static char rcsid[] = "$NetBSD: $"; ix = esx&0x7fff; /* |x| */ iy = esy&0x7fff; /* |y| */ - if(((ix==0x7fff)&&((hx|lx)|-(hx|lx))!=0) || /* x is nan */ - ((iy==0x7fff)&&((hy|ly)|-(hy|ly))!=0)) /* y is nan */ + if(((ix==0x7fff)&&((hx|lx)!=0) || /* x is nan */ + ((iy==0x7fff)&&((hy|ly)!=0)) /* y is nan */ return x+y; if(x==y) return y; /* x=y, return y */ if((ix|hx|lx)==0) { /* x == 0 */ - SET_LDOUBLE_WORDS(x,esx&0x8000,0,1);/* return +-minsubnormal */ + SET_LDOUBLE_WORDS(x,esy&0x8000,0,1);/* return +-minsubnormal */ y = x*x; if(y==x) return y; else return x; /* raise underflow flag */ } --- libc/sysdeps/ieee754/ldbl-96/s_nexttowardf.c.jj Wed Jul 14 02:14:43 1999 +++ libc/sysdeps/ieee754/ldbl-96/s_nexttowardf.c Fri Jun 15 13:10:52 2001 @@ -36,13 +36,13 @@ static char rcsid[] = "$NetBSD: $"; ix = hx&0x7fffffff; /* |x| */ iy = esy&0x7fff; /* |y| */ - if((ix>0x7f800000) || /* x is nan */ - (iy>=0x7fff&&((hy|ly)|-(hy|ly))!=0)) /* y is nan */ + if((ix>0x7f800000) || /* x is nan */ + (iy>=0x7fff&&((hy|ly)!=0))) /* y is nan */ return x+y; if((long double) x==y) return y; /* x=y, return y */ if(ix==0) { /* x == 0 */ float x2; - SET_FLOAT_WORD(x,(esy&0x8000?0x80000000:0)|1);/* return +-minsub*/ + SET_FLOAT_WORD(x,((esy&0x8000)<<16)|1);/* return +-minsub*/ x2 = x*x; if(x2==x) return x2; else return x; /* raise underflow flag */ } --- libc/sysdeps/ia64/fpu/s_nexttoward.c.jj Fri Jun 15 13:24:52 2001 +++ libc/sysdeps/ia64/fpu/s_nexttoward.c Fri Jun 15 13:24:48 2001 @@ -0,0 +1 @@ +#include --- libc/sysdeps/ia64/fpu/s_nexttowardf.c.jj Fri Jun 15 13:24:52 2001 +++ libc/sysdeps/ia64/fpu/s_nexttowardf.c Fri Jun 15 13:25:23 2001 @@ -0,0 +1 @@ +#include Jakub From drepper@redhat.com Fri Jun 15 20:37:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 15 Jun 2001 20:37:00 -0000 Subject: [PATCH] Fix nexttoward* and nextafter* References: <20010615141233.A508@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > Some of nextafter* and nexttoward* are buggy. Thanks, I've applied the patch. -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Fri Jun 15 21:32:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 15 Jun 2001 21:32:00 -0000 Subject: move aio code to sysdeps/pthread References: <20010614202507.C1CD099863@perdition.linnaean.org> Message-ID: Roland McGrath writes: > I'd like to commit the following change to configure.in, which has > to effect of making the linuxthreads add-on bring sysdeps/pthread > from the main source directory into the list of sysdeps dirs searched. Seems OK, I've applied the patch. -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From roland@frob.com Fri Jun 15 21:48:00 2001 From: roland@frob.com (Roland McGrath) Date: Fri, 15 Jun 2001 21:48:00 -0000 Subject: move aio code to sysdeps/pthread References: Message-ID: <20010616044823.53F0499862@perdition.linnaean.org> Ok. I have checked in the move of the aio functions to sysdeps/pthread and the addition of sysdeps/generic versions. From drepper@redhat.com Sat Jun 16 12:07:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Sat, 16 Jun 2001 12:07:00 -0000 Subject: getgrouplist implementation References: <200106071950.f57Jo9E00392@delius.kettenis.local> Message-ID: Mark Kettenis writes: > Here is a patch that implements getgrouplist() from 4.4 BSD. We > really need this to handle supplementary group ID's in the Hurd and > implementing it outside glibc would be pretty hard. I still don't see that his function is necessary. The concept of the auxiliary groups and security don't really match very well, it's and antique concept overrun by time. Anyhow, since I cannot disprove it the function is in now. It's up to you now to provide documentation and an example. -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From aj@suse.de Tue Jun 19 04:35:00 2001 From: aj@suse.de (Andreas Jaeger) Date: Tue, 19 Jun 2001 04:35:00 -0000 Subject: patch: profiling on powerpc broken Message-ID: With profiling on PowerPC I get: cantaloupe:~/tmp:[0]$ gcc -profile -O2 -Wall -o t t.c /usr/lib/libc_p.a(dl-runtime.op): In function `_dl_prof_resolve': dl-runtime.op(.text+0x274): undefined reference to `profile_fixup' collect2: ld returned 1 exit status The problem is the usage of profile_fixup if PROF defined. I'm appending a small, tested patch. Ok to commit? Andreas 2001-06-19 Andreas Jaeger * sysdeps/powerpc/dl-machine.h (ELF_MACHINE_RUNTIME_TRAMPOLINE): Handle profiling. ============================================================ Index: sysdeps/powerpc/dl-machine.h --- sysdeps/powerpc/dl-machine.h 2001/04/04 13:45:44 1.30 +++ sysdeps/powerpc/dl-machine.h 2001/06/19 07:57:14 @@ -102,6 +102,7 @@ /* This code is used in dl-runtime.c to call the `fixup' function and then redirect to the address it returns. It is called from code built in the PLT by elf_machine_runtime_setup. */ +#if !defined PROF #define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\n\ .section \".text\" \n\ .align 2 \n\ @@ -198,6 +199,59 @@ # Undo '.section text'.\n\ .previous \n\ "); +#else +# define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\n\ + .section \".text\" \n\ + .align 2 \n\ + .globl _dl_runtime_resolve \n\ + .globl _dl_prof_resolve \n\ + .type _dl_runtime_resolve,@function \n\ + .type _dl_prof_resolve,@function \n\ +_dl_runtime_resolve: \n\ +_dl_prof_resolve: \n\ + # We need to save the registers used to pass parameters, and register 0,\n\ + # which is used by _mcount; the registers are saved in a stack frame.\n\ + stwu 1,-64(1) \n\ + stw 0,12(1) \n\ + stw 3,16(1) \n\ + stw 4,20(1) \n\ + # The code that calls this has put parameters for `fixup' in r12 and r11.\n\ + mr 3,12 \n\ + stw 5,24(1) \n\ + mr 4,11 \n\ + stw 6,28(1) \n\ + mflr 0 \n\ + # We also need to save some of the condition register fields.\n\ + stw 7,32(1) \n\ + stw 0,48(1) \n\ + stw 8,36(1) \n\ + mfcr 0 \n\ + stw 9,40(1) \n\ + stw 10,44(1) \n\ + stw 0,8(1) \n\ + bl fixup@local \n\ + # 'fixup' returns the address we want to branch to.\n\ + mtctr 3 \n\ + # Put the registers back...\n\ + lwz 0,48(1) \n\ + lwz 10,44(1) \n\ + lwz 9,40(1) \n\ + mtlr 0 \n\ + lwz 8,36(1) \n\ + lwz 0,8(1) \n\ + lwz 7,32(1) \n\ + lwz 6,28(1) \n\ + mtcrf 0xFF,0 \n\ + lwz 5,24(1) \n\ + lwz 4,20(1) \n\ + lwz 3,16(1) \n\ + lwz 0,12(1) \n\ + # ...unwind the stack frame, and jump to the PLT entry we updated.\n\ + addi 1,1,64 \n\ + bctr \n\ + .size _dl_runtime_resolve,.-_dl_runtime_resolve \n\ +"); +#endif /* The actual _start code is in dl-start.S. Use a really ugly bit of assembler to let dl-start.o see _dl_start. */ -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de http://www.suse.de/~aj From schwidefsky@de.ibm.com Tue Jun 19 07:02:00 2001 From: schwidefsky@de.ibm.com (schwidefsky@de.ibm.com) Date: Tue, 19 Jun 2001 07:02:00 -0000 Subject: dl-cache.h for s390x. Message-ID: Hi, I found another bug with 64 bit S/390. The dynamic linker didn't care about the information in /etc/ld.so.cache. After some debugging I found that the generic _dl_cache_check_flags always returned 0. Wouldn't it make sense to mask the flags with FLAG_TYPE_MASK before comparing it with the _DL_CACHE_DEFAULT_ID ? Anyway here is a patch and the ChangeLog for a s390x version of dl-cache.h: 2001-06-19 Martin Schwidefsky * sysdeps/unix/sysv/linux/s390/s390-64/dl-cache.h: New file. (See attached file: dl-cache.diff) blue skies, Martin Linux/390 Design & Development, IBM Deutschland Entwicklung GmbH Sch????naicherstr. 220, D-71032 B????blingen, Telefon: 49 - (0)7031 - 16-2247 E-Mail: schwidefsky@de.ibm.com -------------- next part -------------- A non-text attachment was scrubbed... Name: dl-cache.diff Type: text/x-diff Size: 1427 bytes Desc: not available URL: From drepper@redhat.com Wed Jun 20 00:16:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 20 Jun 2001 00:16:00 -0000 Subject: dl-cache.h for s390x. References: Message-ID: schwidefsky@de.ibm.com writes: > 2001-06-19 Martin Schwidefsky > > * sysdeps/unix/sysv/linux/s390/s390-64/dl-cache.h: New file. I've applied the patch. Thanks, -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From wmglo@dent.med.uni-muenchen.de Fri Jun 22 04:27:00 2001 From: wmglo@dent.med.uni-muenchen.de (Wolfram Gloger) Date: Fri, 22 Jun 2001 04:27:00 -0000 Subject: malloc patch for atfork Message-ID: <20010622112754.23575.qmail@md.dent.med.uni-muenchen.de> Hi, I suggest that the following small patch is applied for 2.2.4, even though I can't yet provide a testcase which is fixed by this change. Several people are currently examining the problem and a test case will emerge when the problem is analyzed more completely. The code that is still hanging with an SMP Linux system can be found at: http://www.malloc.de/tests/fork-malloc.c I have tested the patch for several weeks now on UP and dual-SMP. Regards, Wolfram. 2001-06-01 Wolfram Gloger * malloc/malloc.c (malloc_atfork, free_atfork): Use a unique value ATFORK_ARENA_PTR, not 0, for the thread-specific arena pointer when malloc_atfork is in use. --- malloc/malloc.c 2001/02/14 22:27:17 1.1.1.22 +++ malloc/malloc.c 2001/06/01 15:38:53 @@ -1590,6 +1590,11 @@ #ifndef NO_THREADS +/* Magic value for the thread-specific arena pointer when + malloc_atfork() is in use. */ + +#define ATFORK_ARENA_PTR ((Void_t*)-1) + /* The following two functions are registered via thread_atfork() to make sure that the mutexes remain in a consistent state in the fork()ed version of a thread. Also adapt the malloc and free hooks @@ -1620,7 +1625,7 @@ __free_hook = free_atfork; /* Only the current thread may perform malloc/free calls now. */ tsd_getspecific(arena_key, save_arena); - tsd_setspecific(arena_key, (Void_t*)0); + tsd_setspecific(arena_key, ATFORK_ARENA_PTR); #endif } @@ -4140,6 +4145,8 @@ #ifndef NO_THREADS tsd_getspecific(arena_key, vptr); + if(vptr == ATFORK_ARENA_PTR) + vptr = (Void_t*)&main_arena; #endif malloc_update_mallinfo((vptr ? (arena*)vptr : &main_arena), &mi); return mi; @@ -4687,7 +4694,8 @@ mchunkptr victim; tsd_getspecific(arena_key, vptr); - if(!vptr) { + if(vptr == ATFORK_ARENA_PTR) { + /* We are the only thread that may allocate at all. */ if(save_malloc_hook != malloc_check) { if(request2size(sz, nb)) return 0; @@ -4735,10 +4743,10 @@ ar_ptr = arena_for_ptr(p); tsd_getspecific(arena_key, vptr); - if(vptr) + if(vptr != ATFORK_ARENA_PTR) (void)mutex_lock(&ar_ptr->mutex); chunk_free(ar_ptr, p); - if(vptr) + if(vptr != ATFORK_ARENA_PTR) (void)mutex_unlock(&ar_ptr->mutex); } From jakub@redhat.com Mon Jun 25 02:52:00 2001 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 25 Jun 2001 02:52:00 -0000 Subject: [PATCH] Fix ro_RO locale Message-ID: <20010625115503.D2811@sunsite.ms.mff.cuni.cz> Hi! Although I don't know Romanian at all, I think it is impossible that the language would use LATIN SMALL LETTER T WITH COMMA BELOW when it is normally using ISO-8859-2 encoding which has LATIN SMALL LETTER T WITH CEDILLA but not LATIN SMALL LETTER T WITH COMMA BELOW. Also, I've checked pre-2001-05-26 ro_RO and at that point the day was written in uppercase and was using U0162 (LATIN CAPITAL LETTER T WITH CEDILLA), so I think this patch is right. 2001-06-25 Jakub Jelinek * locales/ro_RO (day): Use U0163 instead of U021B. --- localedata/locales/ro_RO.jj Mon Jun 25 10:34:35 2001 +++ localedata/locales/ro_RO Mon Jun 25 11:54:13 2001 @@ -2150,7 +2150,7 @@ abday "";" "";"";"" day "";/ "";/ - "";/ + "";/ "";/ "";/ "";/ Jakub From jakub@redhat.com Mon Jun 25 02:57:00 2001 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 25 Jun 2001 02:57:00 -0000 Subject: [PATCH] Fix regex typos in comments Message-ID: <20010625120024.E2811@sunsite.ms.mff.cuni.cz> Hi! While looking at new regex I went over these. 2001-06-22 Jakub Jelinek * posix/regex.c (regex_compile, re_match_2_internal): Fix comment typos. --- posix/regex.c.jj Sun Jun 24 18:56:34 2001 +++ posix/regex.c Mon Jun 25 10:13:06 2001 @@ -2339,7 +2339,7 @@ PREFIX(regex_compile) (ARG_PREFIX(patter /* A temporary space to keep wchar_t pattern and compiled pattern. */ CHAR_T *pattern, *COMPILED_BUFFER_VAR; size_t size; - /* offset buffer for optimizatoin. See convert_mbs_to_wc. */ + /* offset buffer for optimization. See convert_mbs_to_wc. */ int *mbs_offset = NULL; /* It hold whether each wchar_t is binary data or not. */ char *is_binary = NULL; @@ -5468,7 +5468,7 @@ PREFIX(re_match_2_internal) (bufp, ARG_P CHAR_T *string1 = NULL, *string2 = NULL; /* We need the size of wchar_t buffers correspond to csize1, csize2. */ int size1 = 0, size2 = 0; - /* offset buffer for optimizatoin. See convert_mbs_to_wc. */ + /* offset buffer for optimization. See convert_mbs_to_wc. */ int *mbs_offset1 = NULL, *mbs_offset2 = NULL; /* They hold whether each wchar_t is binary data or not. */ char *is_binary = NULL; Jakub From jakub@redhat.com Mon Jun 25 03:37:00 2001 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 25 Jun 2001 03:37:00 -0000 Subject: FE_* constants and ISO C99 Message-ID: <20010625124041.F2811@sunsite.ms.mff.cuni.cz> Hi! ISO C99 states in 7.1.4.1: All object-like macros listed as expanding to integer constant expressions shall additionally be suitable for use in #if preprocessing directives. I'm not entirely sure if this allows them to be defined as they sometimes are in glibc headers, ie. enum { FE_INEXACT = 0x?? #define FE_INEXACT FE_INEXACT }; , see http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=44520 because they can then be only used in #if preprocessing directives when testing if they are defined, not to check their value (and I don't see why ISO C99 would explicitely state it when all macros are suitable for use in #ifdef resp #if defined() preprocessing directives). Ideas? Jakub From jakub@redhat.com Mon Jun 25 10:37:00 2001 From: jakub@redhat.com (Jakub Jelinek) Date: Mon, 25 Jun 2001 10:37:00 -0000 Subject: [PATCH] Fix localedata/SUPPORTED Message-ID: <20010625194034.G2811@sunsite.ms.mff.cuni.cz> Hi! Looks like not all occurrences of BIG5HKSCS have been changed... 2001-06-25 Jakub Jelinek * SUPPORTED (zh_HK): Update character map name to BIG5-HKSCS. --- localedata/SUPPORTED.jj Fri Feb 16 11:46:01 2001 +++ localedata/SUPPORTED Mon Jun 25 19:24:40 2001 @@ -144,6 +144,6 @@ vi_VN UTF-8 zh_CN GB2312 zh_CN.GB18030 GB18030 zh_CN.GBK GBK -zh_HK BIG5HKSCS +zh_HK BIG5-HKSCS zh_TW BIG5 zh_TW.EUC-TW EUC-TW Jakub From drepper@redhat.com Mon Jun 25 19:58:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 25 Jun 2001 19:58:00 -0000 Subject: malloc patch for atfork References: <20010622112754.23575.qmail@md.dent.med.uni-muenchen.de> Message-ID: Wolfram Gloger writes: > I suggest that the following small patch is applied for 2.2.4, even > though I can't yet provide a testcase which is fixed by this change. > Several people are currently examining the problem and a test case > will emerge when the problem is analyzed more completely. I've applied the patch. Thanks, -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Mon Jun 25 20:01:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 25 Jun 2001 20:01:00 -0000 Subject: FE_* constants and ISO C99 References: <20010625124041.F2811@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > I'm not entirely sure if this allows them to be defined as they sometimes > are in glibc headers, ie. I see no problem. If somebody has a problem with it have them file an interpretation request for the ISO C committee. -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Mon Jun 25 20:06:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 25 Jun 2001 20:06:00 -0000 Subject: [PATCH] Fix localedata/SUPPORTED References: <20010625194034.G2811@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > Looks like not all occurrences of BIG5HKSCS have been changed... Thanks, I've applied the patch. -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Mon Jun 25 20:07:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Mon, 25 Jun 2001 20:07:00 -0000 Subject: [PATCH] Fix regex typos in comments References: <20010625120024.E2811@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > While looking at new regex I went over these. Applied these changes. Thanks, -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From kettenis@wins.uva.nl Tue Jun 26 03:54:00 2001 From: kettenis@wins.uva.nl (Mark Kettenis) Date: Tue, 26 Jun 2001 03:54:00 -0000 Subject: initgroups() doesn't match documented behaviour Message-ID: <200106261054.f5QAsHq01081@delius.kettenis.local> While working on the documentation for the new getgrouplist() function, I noticed that the documentation for initgroups() doesn't match its actual behaviour. The documentation says that when: GID is not -1, it includes that group also. But the actual code doesn't treat -1 specially; it always includes the group. Since this matches FreeBSD behaviour, I think we should fix the manual. OK, if I include that with the getgrouplist documentation patch? From drepper@redhat.com Tue Jun 26 09:10:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 26 Jun 2001 09:10:00 -0000 Subject: initgroups() doesn't match documented behaviour References: <200106261054.f5QAsHq01081@delius.kettenis.local> Message-ID: Mark Kettenis writes: > Since this matches FreeBSD behaviour, I think we should fix the > manual. OK, if I include that with the getgrouplist documentation > patch? Yes. -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From kettenis@wins.uva.nl Thu Jun 28 15:08:00 2001 From: kettenis@wins.uva.nl (Mark Kettenis) Date: Thu, 28 Jun 2001 15:08:00 -0000 Subject: initgroups() doesn't match documented behaviour References: <200106261054.f5QAsHq01081@delius.kettenis.local> Message-ID: <200106282208.f5SM8gr02145@delius.kettenis.local> From: Ulrich Drepper Date: 26 Jun 2001 09:08:10 -0700 Mark Kettenis writes: > Since this matches FreeBSD behaviour, I think we should fix the > manual. OK, if I include that with the getgrouplist documentation > patch? Yes. OK, here it is. Index: ChangeLog from Mark Kettenis * manual/users.texi (Setting Groups): Correct initgroups documentation. Add documentation for getgrouplist. Index: manual/users.texi =================================================================== RCS file: /cvs/glibc/libc/manual/users.texi,v retrieving revision 1.32 diff -u -p -r1.32 users.texi --- manual/users.texi 2000/04/18 06:23:17 1.32 +++ manual/users.texi 2001/06/28 22:07:40 @@ -454,10 +454,10 @@ The calling process is not privileged. @comment grp.h @comment BSD -@deftypefun int initgroups (const char *@var{user}, gid_t @var{gid}) +@deftypefun int initgroups (const char *@var{user}, gid_t @var{group}) The @code{initgroups} function sets the process's supplementary group -IDs to be the normal default for the user name @var{user}. If @var{gid} -is not -1, it includes that group also. +IDs to be the normal default for the user name @var{user}. The group +@var{group} is automatically included. This function works by scanning the group database for all the groups @var{user} belongs to. It then calls @code{setgroups} with the list it @@ -465,6 +465,52 @@ has constructed. The return values and error conditions are the same as for @code{setgroups}. +@end deftypefun + +If you are interested in the groups a particular user belongs to, but do +not want to change the process's supplementary group IDs, you can use +@code{getgrouplist}. To use @code{getgrouplist}, your programs should +include the header file @file{grp.h}. +@pindex grp.h + +@comment grp.h +@comment BSD +@deftypefun int getgrouplist (const char *@var{user}, gid_t @var{group}, gid_t *@var{groups}, int *@var{ngroups}) +The @code{getgrouplist} function scans the group database for all the +groups @var{user} belongs to. Up to *@var{ngroups} group IDs +corresponding to these groups are stored in the array @var{groups}; the +return value from the function is the number of group IDs actually +stored. If *@var{ngroups} is smaller than the total number of groups +found, then @code{getgrouplist} returns a value of @code{-1} and stores +the actual number of groups in *@var{ngroups}. The group @var{group} is +automatically included in the list of groups returned by +@code{getgrouplist}. + +Here's how to use @code{getgrouplist} to read all supplementary groups +for @var{user}: + +@smallexample +@group +gid_t * +supplementary_groups (char *user) +@{ + int ngroups = 16; + gid_t *groups + = (gid_t *) xmalloc (ngroups * sizeof (gid_t)); + struct passwd *pw = getpwnam (user); + + if (pw == NULL) + return NULL; + + if (getgrouplist (pw->pw_name, pw->pw_gid, groups, &ngroups) < 0) + @{ + groups = xrealloc (ngroups * sizeof (gid_t)); + getgrouplist (pw->pw_name, pw->pw_gid, groups, &ngroups); + @} + return groups; +@} +@end group +@end smallexample @end deftypefun @node Enable/Disable Setuid From drepper@redhat.com Thu Jun 28 17:17:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Thu, 28 Jun 2001 17:17:00 -0000 Subject: initgroups() doesn't match documented behaviour References: <200106261054.f5QAsHq01081@delius.kettenis.local> <200106282208.f5SM8gr02145@delius.kettenis.local> Message-ID: Mark Kettenis writes: > OK, here it is. Thanks, I checked it in. -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Fri Jun 29 00:13:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 29 Jun 2001 00:13:00 -0000 Subject: patch: profiling on powerpc broken References: Message-ID: What's about this patch? Some PPC person has to look at it. -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Fri Jun 29 00:15:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 29 Jun 2001 00:15:00 -0000 Subject: more testing needed Message-ID: I'm currently quite satisfied with the status on x86. But I don't know much about the status on other machines. About a week ago I tried Alpha and had a problem in the test suite. Haven't tried IA-64. And there are some PPC patches outstanding (one from Andreas, the other by Franz). So, let's start concentrating on the missing problems and get 2.2.4 out. -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From jakub@redhat.com Fri Jun 29 02:10:00 2001 From: jakub@redhat.com (Jakub Jelinek) Date: Fri, 29 Jun 2001 02:10:00 -0000 Subject: more testing needed References: Message-ID: <20010629111222.A737@sunsite.ms.mff.cuni.cz> On Fri, Jun 29, 2001 at 12:12:20AM -0700, Ulrich Drepper wrote: > I'm currently quite satisfied with the status on x86. But I don't > know much about the status on other machines. About a week ago I > tried Alpha and had a problem in the test suite. Haven't tried IA-64. > And there are some PPC patches outstanding (one from Andreas, the > other by Franz). I think libgcc_s.so.1 vs. GLIBC needs to be resolved, see my mail in `GCC 3.0 and GLIBC don't work together' thread on libc-alpha. I think glibc 2.2.4 should be compilable by GCC 3.0 now when it is released. Before I hack something, I'd like to know what you and other folks think is best (so far I have just heard from H.J.). Jakub From aj@suse.de Fri Jun 29 05:41:00 2001 From: aj@suse.de (Andreas Jaeger) Date: Fri, 29 Jun 2001 05:41:00 -0000 Subject: patch: profiling on powerpc broken References: Message-ID: Ulrich Drepper writes: > What's about this patch? Some PPC person has to look at it. I tested it and it fixed the problems I have. I propose to add it - even if no PPC developer double checks it. Ok? Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de http://www.suse.de/~aj From drepper@redhat.com Fri Jun 29 10:02:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 29 Jun 2001 10:02:00 -0000 Subject: more testing needed References: <20010629111222.A737@sunsite.ms.mff.cuni.cz> Message-ID: Jakub Jelinek writes: > I think libgcc_s.so.1 vs. GLIBC needs to be resolved, see my mail in > `GCC 3.0 and GLIBC don't work together' thread on libc-alpha. > I think glibc 2.2.4 should be compilable by GCC 3.0 now when it is released. I don't see this as a requirement. In fact, I have no interest to introduce such major changes. > Before I hack something, I'd like to know what you and other folks think is > best (so far I have just heard from H.J.). You won't hear anything from me. I refuse to look at this. -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From drepper@redhat.com Fri Jun 29 10:08:00 2001 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 29 Jun 2001 10:08:00 -0000 Subject: patch: profiling on powerpc broken References: Message-ID: Andreas Jaeger writes: > I tested it and it fixed the problems I have. I propose to add it - > even if no PPC developer double checks it. Ok? OK with me, they had their chance. -- ---------------. ,-. 1325 Chesapeake Terrace Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA Red Hat `--' drepper at redhat.com `------------------------ From hjl@lucon.org Fri Jun 29 10:24:00 2001 From: hjl@lucon.org (H . J . Lu) Date: Fri, 29 Jun 2001 10:24:00 -0000 Subject: more testing needed References: <20010629111222.A737@sunsite.ms.mff.cuni.cz> Message-ID: <20010629102443.A22703@lucon.org> On Fri, Jun 29, 2001 at 11:12:22AM +0200, Jakub Jelinek wrote: > On Fri, Jun 29, 2001 at 12:12:20AM -0700, Ulrich Drepper wrote: > > I'm currently quite satisfied with the status on x86. But I don't > > know much about the status on other machines. About a week ago I > > tried Alpha and had a problem in the test suite. Haven't tried IA-64. > > And there are some PPC patches outstanding (one from Andreas, the > > other by Franz). > > I think libgcc_s.so.1 vs. GLIBC needs to be resolved, see my mail in > `GCC 3.0 and GLIBC don't work together' thread on libc-alpha. > I think glibc 2.2.4 should be compilable by GCC 3.0 now when it is released. > Before I hack something, I'd like to know what you and other folks think is > best (so far I have just heard from H.J.). > I don't think we can go out along without any cooporation from the gcc developers. If we don't do that, who knows what they will do later and how teh other Linux vendors/normal gcc/glibc users will deal with it. Before we do anything, we should set a goal which is acceptable to both the gcc/glibc developers. BTW, personal opinion is a DSO used by every single binary, yes, libgcc_s.so may be used by static binaries, should be treated the same way as glibc. That is installing gcc shouldn't override libgcc_s.so come with the system, one way or the other, unless it is broken, in which case. update of libgcc_s.so should perferably come from the same source as glibc. H.J. From aj@suse.de Fri Jun 29 11:00:00 2001 From: aj@suse.de (Andreas Jaeger) Date: Fri, 29 Jun 2001 11:00:00 -0000 Subject: more testing needed References: <20010629111222.A737@sunsite.ms.mff.cuni.cz> Message-ID: Ulrich Drepper writes: > Jakub Jelinek writes: > >> I think libgcc_s.so.1 vs. GLIBC needs to be resolved, see my mail in >> `GCC 3.0 and GLIBC don't work together' thread on libc-alpha. >> I think glibc 2.2.4 should be compilable by GCC 3.0 now when it is released. > > I don't see this as a requirement. In fact, I have no interest to > introduce such major changes. I would like to see this solved in 2.2.4. If we do not solve it, we should at least come to a conclusion how to solve it for later. Otherwise I fear that this is solved in different - and totally incompatible - ways by some distributors which leads to chaos. Andreas -- Andreas Jaeger SuSE Labs aj@suse.de private aj@arthur.inka.de http://www.suse.de/~aj