From 34b402e5a967b97fc73cc45fbef61bbeb8526f3d Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 25 Mar 1997 02:25:35 +0000 Subject: [PATCH] Update. 1997-03-24 19:58 Richard Henderson * stdlib/tst-strtol.c (tests): Correct 64-bit entry. * sysdeps/alpha/bsd-_setjmp.S: Alias _setjmp to __setjmp for change to tst-setjmp.c. * sysdeps/alpha/dl-machine.h: Mirror Roland's recent changes. * sysdeps/i386/dl-machine.h: Correct noexec_p comment. * sysdeps/sparc/dl-machine.h: Likewise. * sysdeps/libm-ieee754/s_remquo.c: Rename {hp,lp} -> {hy,ly}. Add missing qs variable. * sysdeps/libm-ieee754/s_remquof.c: Likewise. --- ChangeLog | 15 +++++++ PROJECTS | 70 +++++++++++++++++++++++++++----- stdlib/tst-strtol.c | 2 +- sysdeps/alpha/bsd-_setjmp.S | 2 + sysdeps/alpha/dl-machine.h | 30 ++++++++------ sysdeps/i386/dl-machine.h | 4 +- sysdeps/libm-ieee754/s_cexp.c | 63 ++++++++++++++++++++++++++++ sysdeps/libm-ieee754/s_remquo.c | 60 +++++++++++++-------------- sysdeps/libm-ieee754/s_remquof.c | 56 ++++++++++++------------- sysdeps/sparc/dl-machine.h | 4 +- 10 files changed, 221 insertions(+), 85 deletions(-) create mode 100644 sysdeps/libm-ieee754/s_cexp.c diff --git a/ChangeLog b/ChangeLog index ac94705d7f..7534c9fd6f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +1997-03-24 19:58 Richard Henderson + + * stdlib/tst-strtol.c (tests): Correct 64-bit entry. + + * sysdeps/alpha/bsd-_setjmp.S: Alias _setjmp to __setjmp for + change to tst-setjmp.c. + + * sysdeps/alpha/dl-machine.h: Mirror Roland's recent changes. + * sysdeps/i386/dl-machine.h: Correct noexec_p comment. + * sysdeps/sparc/dl-machine.h: Likewise. + + * sysdeps/libm-ieee754/s_remquo.c: Rename {hp,lp} -> {hy,ly}. + Add missing qs variable. + * sysdeps/libm-ieee754/s_remquof.c: Likewise. + 1997-03-25 02:15 Ulrich Drepper * gmon/gmon.c: Optimize a bit by using more sets of records to diff --git a/PROJECTS b/PROJECTS index ea1c208161..db5a25f485 100644 --- a/PROJECTS +++ b/PROJECTS @@ -19,7 +19,16 @@ contact standards if they do not contradict each other. -[ 3] Write translations for the GNU libc message for the so far +[ 3] The IMHO opinion most important task is to write a more complete + test suite. We cannot get too many people working on this. It is + not difficult to write a test, find a definition of the function + which I normally can provide, if necessary, and start writing tests + to test for compliance. Beside this, take a look at the sources + and write tests which in total test as many paths of execution as + possible. + + +[ 4] Write translations for the GNU libc message for the so far unsupported languages. GNU libc is fully internationalized and users can immediately benefit from this. @@ -28,7 +37,7 @@ contact for the current status (of course better use a mirror of prep). -[ 4] Write wordexp() function; this is described in POSIX.2, the +[ 5] Write wordexp() function; this is described in POSIX.2, the header already exists. Implementation idea: use some functions from bash. @@ -36,7 +45,7 @@ contact **** Somebody is working on this. Help may or may not be appreciated. -[ 5] Write `long double' versions of the math functions. This should be +[ 6] Write `long double' versions of the math functions. This should be done in collaboration with the NetBSD and FreeBSD people. The libm is in fact fdlibm (not the same as in Linux libc). @@ -45,7 +54,42 @@ contact the rest. -[ 6] If you enjoy assembler programming (as I do --drepper :-) you might +[ 7] Several math functions have to be written: + + - exp2 + - log2 + + each with float, double, and long double arguments. Writing these + functions should be possible when following the implementation of + the existing exp/log functions for other bases. + + Beside this most of the complex math functions which are new in + ISO C 9X. gcc already has support for numbers of complex type so the + implementation should be possible today. I mention here the names + and the way to write them (argument is z = x + iy): + + - cexp(z) = e^x (cos y + i sin y) + - sin(z) = 1/(2i) (e^(iz) - e^-(iz)) = sin(x) cosh(y) + i cos(x) sinh(y) + - cos(z) = 1/2 (e^(iz) + e^-(iz)) = cos(x) cosh(y) - i sin(x) sinh(y) + - tan(z) = 1/i (e^(iz) - e^-(iz))/(e^(iz) + e^-(iz)) + - cot(z) = i (e^(iz) + e^-(iz))/(e^(iz) - e^-(iz)) + - asin(z) = -i ln(iz + sqrt(1-z^2)) + - acos(z) = -i ln(z + sqrt(z^2-1)) + - atan(z) = 1/(2i) ln((1+iz)/(1-iz)) + - acot(z) = -1/(2i) ln((iz+1)/(iz-1)) + - sinh(z) = 1/2 (e^z - e^-z) + - cosh(z) = 1/2 (e^z + e^-z) + - tanh(z) = (e^z - e^-z)/(e^z + e^-z) + - coth(z) = (e^z + e^-z)/(e^z - e^-z) + + All functions should we written with all the parallelism in mind. + And assembler versions are highly expreciated since, e.g., the ix87 + FPU provides an `fsincos' instructions which is certainly useful for + the `sin' function. The implementations for the normal math functions + shows other optimization techniques. + + +[ 8] If you enjoy assembler programming (as I do --drepper :-) you might be interested in writing optimized versions for some functions. Especially the string handling functions can be optimized a lot. @@ -60,38 +104,38 @@ contact work. -[ 7] Write nftw() function. Perhaps it might be good to reimplement the +[ 9] Write nftw() function. Perhaps it might be good to reimplement the ftw() function as well to share most of the code. **** Almost done! -[ 8] Write AVL-tree based tsearch() et.al. functions. Currently only +[10] Write AVL-tree based tsearch() et.al. functions. Currently only a very simple algorithm is used. There is a public domain version but using this would cause problems with the assignment. -[ 9] Extend regex and/or rx to work with wide characters and complete +[11] Extend regex and/or rx to work with wide characters and complete implementation of character class and collation class handling. It is planed to do a complete rewrite. -[10] Write access function for netmasks, bootparams, and automount +[12] Write access function for netmasks, bootparams, and automount databases for nss_files and nss_db module. The functions should be embedded in the nss scheme. This is not hard and not all services must be supported at once. -[11] Rewrite utmp/wtmp functions to use database functions. This is much +[13] Rewrite utmp/wtmp functions to use database functions. This is much better than the normal flat file format. **** There are plans for a new approach to this problem. Please contact bug-glibc@prep.ai.mit.edu before starting to work.) -[12] Several more or less small functions have to be written: +[14] Several more or less small functions have to be written: + tcgetid() and waitid() from XPG4.2 + grantpt(), ptsname(), unlockpt() from XPG4.2 @@ -99,3 +143,9 @@ contact + fmtmsg() from SVID More information are available on request. + + +[15] We need to write a library for on-the-fly transformation of streams + of text. In fact, this would be a recode-library (you know, GNU recode). + This is needed in several places in the GNU libc and I already have + rather concrete plans but so far no possibility to start this. diff --git a/stdlib/tst-strtol.c b/stdlib/tst-strtol.c index 13286912c7..8719d4b9ed 100644 --- a/stdlib/tst-strtol.c +++ b/stdlib/tst-strtol.c @@ -66,7 +66,7 @@ static const struct ltest tests[] = { "0xffffffffffffffffg", 0xffffffffffffffff, 0, 'g', 0 }, { "0xf1f2f3f4f5f6f7f8f9", 0xffffffffffffffff, 0, 0, ERANGE }, { "-0x123456789abcdef01", 0xffffffffffffffff, 0, 0, ERANGE }, - { "-0xfedcba987654321", 0x0123456789abcdf, 0, 0, 0 }, + { "-0xfedcba987654321", 0xf0123456789abcdf, 0, 0, 0 }, { NULL, 0, 0, 0, 0 }, #endif }; diff --git a/sysdeps/alpha/bsd-_setjmp.S b/sysdeps/alpha/bsd-_setjmp.S index 1bb3e4ab37..07fb0c7637 100644 --- a/sysdeps/alpha/bsd-_setjmp.S +++ b/sysdeps/alpha/bsd-_setjmp.S @@ -35,3 +35,5 @@ ENTRY(_setjmp) bis $31, $31, $17 /* Pass a second argument of zero. */ jmp $31, __sigsetjmp /* Call __sigsetjmp. */ END(_setjmp) + +strong_alias_asm(_setjmp, __setjmp) diff --git a/sysdeps/alpha/dl-machine.h b/sysdeps/alpha/dl-machine.h index fc9f9712cb..7a51df5f00 100644 --- a/sysdeps/alpha/dl-machine.h +++ b/sysdeps/alpha/dl-machine.h @@ -239,7 +239,14 @@ _dl_start_user: /* Nonzero iff TYPE describes relocation of a PLT entry, so PLT entries should not be allowed to define the value. */ -#define elf_machine_pltrel_p(type) ((type) == R_ALPHA_JMP_SLOT) +#define elf_machine_lookup_noplt_p(type) ((type) == R_ALPHA_JMP_SLOT) + +/* Nonzero iff TYPE should not be allowed to resolve to one of + the main executable's symbols, as for a COPY reloc, which we don't use. */ +#define elf_machine_lookup_noexec_p(type) (0) + +/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */ +#define ELF_MACHINE_RELOC_NOPLT R_ALPHA_JMP_SLOT /* The alpha never uses Elf64_Rel relocations. */ #define ELF_MACHINE_NO_REL 1 @@ -328,7 +335,7 @@ elf_machine_rela (struct link_map *map, const struct r_found_version *version) { Elf64_Addr * const reloc_addr = (void *)(map->l_addr + reloc->r_offset); - unsigned long const r_info = ELF64_R_TYPE (reloc->r_info); + unsigned long const r_type = ELF64_R_TYPE (reloc->r_info); #ifndef RTLD_BOOTSTRAP /* This is defined in rtld.c, but nowhere in the static libc.a; make the @@ -342,7 +349,7 @@ elf_machine_rela (struct link_map *map, /* We cannot use a switch here because we cannot locate the switch jump table until we've self-relocated. */ - if (r_info == R_ALPHA_RELATIVE) + if (r_type == R_ALPHA_RELATIVE) { #ifndef RTLD_BOOTSTRAP /* Already done in dynamic linker. */ @@ -350,24 +357,23 @@ elf_machine_rela (struct link_map *map, #endif *reloc_addr += map->l_addr; } - else if (r_info == R_ALPHA_NONE) + else if (r_type == R_ALPHA_NONE) return; else { Elf64_Addr loadbase, sym_value; - loadbase = RESOLVE (&sym, version, - r_info == R_ALPHA_JMP_SLOT ? DL_LOOKUP_NOPLT : 0); + loadbase = RESOLVE (&sym, version, r_type); sym_value = sym ? loadbase + sym->st_value : 0; - if (r_info == R_ALPHA_GLOB_DAT) + if (r_type == R_ALPHA_GLOB_DAT) *reloc_addr = sym_value; - else if (r_info == R_ALPHA_JMP_SLOT) + else if (r_type == R_ALPHA_JMP_SLOT) { *reloc_addr = sym_value; elf_alpha_fix_plt (map, reloc, (Elf64_Addr) reloc_addr, sym_value); } - else if (r_info == R_ALPHA_REFQUAD) + else if (r_type == R_ALPHA_REFQUAD) { sym_value += *reloc_addr; #ifndef RTLD_BOOTSTRAP @@ -397,15 +403,15 @@ static inline void elf_machine_lazy_rel (struct link_map *map, const Elf64_Rela *reloc) { Elf64_Addr * const reloc_addr = (void *)(map->l_addr + reloc->r_offset); - unsigned long const r_info = ELF64_R_TYPE (reloc->r_info); + unsigned long const r_type = ELF64_R_TYPE (reloc->r_info); - if (r_info == R_ALPHA_JMP_SLOT) + if (r_type == R_ALPHA_JMP_SLOT) { /* Perform a RELATIVE reloc on the .got entry that transfers to the .plt. */ *reloc_addr += map->l_addr; } - else if (r_info == R_ALPHA_NONE) + else if (r_type == R_ALPHA_NONE) return; else assert (! "unexpected PLT reloc type"); diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h index 8e6df12d6b..f6b28444a3 100644 --- a/sysdeps/i386/dl-machine.h +++ b/sysdeps/i386/dl-machine.h @@ -216,8 +216,8 @@ _dl_start_user:\n\ jmp *%edi\n\ "); -/* Nonzero iff TYPE describes relocation of a PLT entry, so - PLT entries should not be allowed to define the value. */ +/* Nonzero iff TYPE should not be allowed to resolve to one of + the main executable's symbols, as for a COPY reloc. */ #define elf_machine_lookup_noexec_p(type) ((type) == R_386_COPY) /* Nonzero iff TYPE describes relocation of a PLT entry, so diff --git a/sysdeps/libm-ieee754/s_cexp.c b/sysdeps/libm-ieee754/s_cexp.c new file mode 100644 index 0000000000..46f9f612eb --- /dev/null +++ b/sysdeps/libm-ieee754/s_cexp.c @@ -0,0 +1,63 @@ +/* Return value of complex exponential function for double complex value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include + + +__complex__ double +__cexp (__complex__ double x) +{ + __complex__ double retval; + + if (isfinite (__real__ x)) + { + if (isfinite (__imag__ x)) + { + retval = __exp (__real__ x) * (__cos (__imag__ x) + + 1i * __sin (__imag__ x)); + } + else + /* If the imaginary part is +-inf or NaN and the real part is + not +-inf the result is NaN + iNan. */ + retval = __nan ("") + 1.0i * __nan (""); + } + else if (__isinf (__real__ x)) + { + if (isfinite (__imag x)) + { + if (signbit (__real__ x) == 0 && __imag__ x == 0.0) + retval = HUGE_VAL; + else + retval = ((signbit (__real__ x) ? 0.0 : HUGE_VAL) + * (__cos (__imag__ x) + 1i * __sin (__imag__ x))); + } + else if (signbit (__real__ x)) + retval = HUGE_VAL + 1.0i * __nan (""); + else + retval = 0.0; + } + else + /* If the real part is NaN the result is NaN + iNan. */ + retval = __nan ("") + 1.0i * __nan (""); + + return retval; +} +weak_alias (__cexp, cexp) diff --git a/sysdeps/libm-ieee754/s_remquo.c b/sysdeps/libm-ieee754/s_remquo.c index 5a96f75f3b..53f26c6d89 100644 --- a/sysdeps/libm-ieee754/s_remquo.c +++ b/sysdeps/libm-ieee754/s_remquo.c @@ -29,71 +29,71 @@ static const double zero = 0.0; double __remquo (double x, double y, int *quo) { - int32_t hx,hp; - u_int32_t sx,lx,lp; - int cquo; + int32_t hx,hy; + u_int32_t sx,lx,ly; + int cquo, qs; EXTRACT_WORDS (hx, lx, x); - EXTRACT_WORDS (hp, lp, p); + EXTRACT_WORDS (hy, ly, y); sx = hx & 0x80000000; - qs = (sx ^ (hp & 0x80000000)) >> 31; - hp &= 0x7fffffff; + qs = sx ^ (hy & 0x80000000); + hy &= 0x7fffffff; hx &= 0x7fffffff; /* Purge off exception values. */ - if ((hp | lp) == 0) - return (x * p) / (x * p); /* p = 0 */ + if ((hy | ly) == 0) + return (x * y) / (x * y); /* y = 0 */ if ((hx >= 0x7ff00000) /* x not finite */ - || ((hp >= 0x7ff00000) /* p is NaN */ - && (((hp - 0x7ff00000) | lp) != 0))) - return (x * p) / (x * p); + || ((hy >= 0x7ff00000) /* p is NaN */ + && (((hy - 0x7ff00000) | ly) != 0))) + return (x * y) / (x * y); - if (hp <= 0x7fbfffff) + if (hy <= 0x7fbfffff) { - x = __ieee754_fmod (x, 8 * p); /* now x < 8p */ + x = __ieee754_fmod (x, 8 * y); /* now x < 8y */ - if (fabs (x) >= 4 * fabs (p)) + if (fabs (x) >= 4 * fabs (y)) cquo += 4; } - if (((hx - hp) | (lx - lp)) == 0) + if (((hx - hy) | (lx - ly)) == 0) { *quo = qs ? -1 : 1; return zero * x; } x = fabs (x); - p = fabs (p); + y = fabs (y); cquo = 0; - if (x >= 2 * p) + if (x >= 2 * y) { - x -= 4 * p; + x -= 4 * y; cquo += 2; } - if (x >= p) + if (x >= y) { - x -= 2 * p; + x -= 2 * y; ++cquo; } - if (hp < 0x00200000) + if (hy < 0x00200000) { - if (x + x > p) + if (x + x > y) { - x -= p; - if (x + x >= p) - x -= p; + x -= y; + if (x + x >= y) + x -= y; } } else { - double p_half = 0.5 * p; - if(x > p_half) + double y_half = 0.5 * y; + if(x > y_half) { - x -= p; - if (x >= p_half) - x -= p; + x -= y; + if (x >= y_half) + x -= y; } } diff --git a/sysdeps/libm-ieee754/s_remquof.c b/sysdeps/libm-ieee754/s_remquof.c index cce5495ce8..0968fe650b 100644 --- a/sysdeps/libm-ieee754/s_remquof.c +++ b/sysdeps/libm-ieee754/s_remquof.c @@ -29,70 +29,70 @@ static const float zero = 0.0; float __remquof (float x, float y, int *quo) { - int32_t hx,hp; + int32_t hx,hy; u_int32_t sx; - int cquo; + int cquo, qs; GET_FLOAT_WORD (hx, x); - GET_FLOAT_WORD (hp, p); + GET_FLOAT_WORD (hy, y); sx = hx & 0x80000000; - qs = (sx ^ (hp & 0x80000000)) >> 31; - hp &= 0x7fffffff; + qs = sx ^ (hy & 0x80000000); + hy &= 0x7fffffff; hx &= 0x7fffffff; /* Purge off exception values. */ - if (hp == 0) - return (x * p) / (x * p); /* p = 0 */ + if (hy == 0) + return (x * y) / (x * y); /* y = 0 */ if ((hx >= 0x7f800000) /* x not finite */ - || (hp > 0x7f800000)) /* p is NaN */ - return (x * p) / (x * p); + || (hy > 0x7f800000)) /* y is NaN */ + return (x * y) / (x * y); - if (hp <= 0x7dffffff) + if (hy <= 0x7dffffff) { - x = __ieee754_fmodf (x, 8 * p); /* now x < 8p */ + x = __ieee754_fmodf (x, 8 * y); /* now x < 8y */ - if (fabs (x) >= 4 * fabs (p)) + if (fabs (x) >= 4 * fabs (y)) cquo += 4; } - if ((hx - hp) == 0) + if ((hx - hy) == 0) { *quo = qs ? -1 : 1; return zero * x; } x = fabsf (x); - p = fabsf (p); + y = fabsf (y); cquo = 0; - if (x >= 2 * p) + if (x >= 2 * y) { - x -= 4 * p; + x -= 4 * y; cquo += 2; } - if (x >= p) + if (x >= y) { - x -= 2 * p; + x -= 2 * y; ++cquo; } - if (hp < 0x01000000) + if (hy < 0x01000000) { - if (x + x > p) + if (x + x > y) { - x -= p; - if (x + x >= p) - x -= p; + x -= y; + if (x + x >= y) + x -= y; } } else { - float p_half = 0.5 * p; - if(x > p_half) + float y_half = 0.5 * y; + if(x > y_half) { - x -= p; - if (x >= p_half) - x -= p; + x -= y; + if (x >= y_half) + x -= y; } } diff --git a/sysdeps/sparc/dl-machine.h b/sysdeps/sparc/dl-machine.h index 880542d2b3..cadf353878 100644 --- a/sysdeps/sparc/dl-machine.h +++ b/sysdeps/sparc/dl-machine.h @@ -184,8 +184,8 @@ elf_machine_lazy_rel (struct link_map *map, const Elf32_Rela *reloc) #endif /* RESOLVE */ -/* Nonzero iff TYPE describes relocation of a PLT entry, so - PLT entries should not be allowed to define the value. */ +/* Nonzero iff TYPE should not be allowed to resolve to one of + the main executable's symbols, as for a COPY reloc. */ #define elf_machine_lookup_noexec_p(type) ((type) == R_SPARC_COPY) /* Nonzero iff TYPE describes relocation of a PLT entry, so