summaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/dl-sysdep.c2
-rw-r--r--sysdeps/i386/dl-machine.h108
-rw-r--r--sysdeps/libm-i387/s_nextafterl.c2
-rw-r--r--sysdeps/libm-i387/s_remquo.S31
-rw-r--r--sysdeps/libm-i387/s_remquof.S31
-rw-r--r--sysdeps/libm-i387/s_remquol.S31
-rw-r--r--sysdeps/libm-ieee754/s_nan.c47
-rw-r--r--sysdeps/libm-ieee754/s_nanf.c47
-rw-r--r--sysdeps/libm-ieee754/s_nanl.c48
-rw-r--r--sysdeps/libm-ieee754/s_nextafter.c2
-rw-r--r--sysdeps/libm-ieee754/s_nextafterf.c12
-rw-r--r--sysdeps/libm-ieee754/s_nextafterl.c2
-rw-r--r--sysdeps/libm-ieee754/s_remquo.c106
-rw-r--r--sysdeps/libm-ieee754/s_remquof.c105
-rw-r--r--sysdeps/libm-ieee754/s_remquol.c106
-rw-r--r--sysdeps/libm-ieee754/s_rintl.c4
-rw-r--r--sysdeps/libm-ieee754/s_trunc.c61
-rw-r--r--sysdeps/libm-ieee754/s_truncf.c52
-rw-r--r--sysdeps/libm-ieee754/s_truncl.c57
-rw-r--r--sysdeps/sparc/dl-machine.h148
-rw-r--r--sysdeps/unix/sysv/linux/alpha/termbits.h4
-rw-r--r--sysdeps/unix/sysv/linux/termbits.h4
22 files changed, 864 insertions, 146 deletions
diff --git a/sysdeps/generic/dl-sysdep.c b/sysdeps/generic/dl-sysdep.c
index 9408e61dbf..e9fbcdf4bc 100644
--- a/sysdeps/generic/dl-sysdep.c
+++ b/sysdeps/generic/dl-sysdep.c
@@ -154,7 +154,7 @@ _dl_sysdep_read_whole_file (const char *file, size_t *sizep, int prot)
int fd = __open (file, O_RDONLY);
if (fd < 0)
return NULL;
- if (__fstat (fd, &st) < 0)
+ if (__fxstat (_STAT_VER, fd, &st) < 0)
result = NULL;
else
{
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
index 40623e795c..8e6df12d6b 100644
--- a/sysdeps/i386/dl-machine.h
+++ b/sysdeps/i386/dl-machine.h
@@ -218,7 +218,14 @@ _dl_start_user:\n\
/* 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_386_JMP_SLOT)
+#define elf_machine_lookup_noexec_p(type) ((type) == R_386_COPY)
+
+/* Nonzero iff TYPE describes relocation of a PLT entry, so
+ PLT entries should not be allowed to define the value. */
+#define elf_machine_lookup_noplt_p(type) ((type) == R_386_JMP_SLOT)
+
+/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */
+#define ELF_MACHINE_RELOC_NOPLT R_386_JMP_SLOT
/* The i386 never uses Elf32_Rela relocations. */
#define ELF_MACHINE_NO_RELA 1
@@ -235,62 +242,63 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
const Elf32_Sym *sym, const struct r_found_version *version)
{
Elf32_Addr *const reloc_addr = (void *) (map->l_addr + reloc->r_offset);
- Elf32_Addr loadbase;
- switch (ELF32_R_TYPE (reloc->r_info))
+ if (ELF32_R_TYPE (reloc->r_info) == R_386_RELATIVE)
{
- case R_386_COPY:
- loadbase = RESOLVE (&sym, version, DL_LOOKUP_NOEXEC);
- memcpy (reloc_addr, (void *) (loadbase + sym->st_value), sym->st_size);
- break;
- case R_386_GLOB_DAT:
- loadbase = RESOLVE (&sym, version, 0);
- *reloc_addr = sym ? (loadbase + sym->st_value) : 0;
- break;
- case R_386_JMP_SLOT:
- loadbase = RESOLVE (&sym, version, DL_LOOKUP_NOPLT);
- *reloc_addr = sym ? (loadbase + sym->st_value) : 0;
- break;
- case R_386_32:
- {
- Elf32_Addr undo = 0;
-#ifndef RTLD_BOOTSTRAP
- /* This is defined in rtld.c, but nowhere in the static libc.a;
- make the reference weak so static programs can still link. This
- declaration cannot be done when compiling rtld.c (i.e. #ifdef
- RTLD_BOOTSTRAP) because rtld.c contains the common defn for
- _dl_rtld_map, which is incompatible with a weak decl in the same
- file. */
- weak_extern (_dl_rtld_map);
- if (map == &_dl_rtld_map)
- /* Undo the relocation done here during bootstrapping. Now we will
- relocate it anew, possibly using a binding found in the user
- program or a loaded library rather than the dynamic linker's
- built-in definitions used while loading those libraries. */
- undo = map->l_addr + sym->st_value;
-#endif
- loadbase = RESOLVE (&sym, version, 0);
- *reloc_addr += (sym ? (loadbase + sym->st_value) : 0) - undo;
- break;
- }
- case R_386_RELATIVE:
#ifndef RTLD_BOOTSTRAP
if (map != &_dl_rtld_map) /* Already done in rtld itself. */
#endif
*reloc_addr += map->l_addr;
- break;
- case R_386_PC32:
- loadbase = RESOLVE (&sym, version, 0);
- *reloc_addr += ((sym ? (loadbase + sym->st_value) : 0) -
- (Elf32_Addr) reloc_addr);
- break;
- case R_386_NONE: /* Alright, Wilbur. */
- break;
- default:
- assert (! "unexpected dynamic reloc type");
- break;
}
-
+ else
+ {
+#ifndef RTLD_BOOTSTRAP
+ const Elf32_Sym *const refsym = sym;
+#endif
+ Elf32_Addr value = RESOLVE (&sym, version, ELF32_R_TYPE (reloc->r_info));
+ if (sym)
+ value += sym->st_value;
+
+ switch (ELF32_R_TYPE (reloc->r_info))
+ {
+ case R_386_COPY:
+ memcpy (reloc_addr, (void *) value, sym->st_size);
+ break;
+ case R_386_GLOB_DAT:
+ case R_386_JMP_SLOT:
+ *reloc_addr = value;
+ break;
+ case R_386_32:
+ {
+#ifndef RTLD_BOOTSTRAP
+ /* This is defined in rtld.c, but nowhere in the static
+ libc.a; make the reference weak so static programs can
+ still link. This declaration cannot be done when
+ compiling rtld.c (i.e. #ifdef RTLD_BOOTSTRAP) because
+ rtld.c contains the common defn for _dl_rtld_map, which
+ is incompatible with a weak decl in the same file. */
+ weak_extern (_dl_rtld_map);
+ if (map == &_dl_rtld_map)
+ /* Undo the relocation done here during bootstrapping.
+ Now we will relocate it anew, possibly using a
+ binding found in the user program or a loaded library
+ rather than the dynamic linker's built-in definitions
+ used while loading those libraries. */
+ value -= map->l_addr + refsym->st_value;
+#endif
+ *reloc_addr += value;
+ break;
+ }
+ case R_386_PC32:
+ *reloc_addr += (value - (Elf32_Addr) reloc_addr);
+ break;
+ case R_386_NONE: /* Alright, Wilbur. */
+ break;
+ default:
+ assert (! "unexpected dynamic reloc type");
+ break;
+ }
+ }
}
static inline void
diff --git a/sysdeps/libm-i387/s_nextafterl.c b/sysdeps/libm-i387/s_nextafterl.c
index b574430832..4596c6b93c 100644
--- a/sysdeps/libm-i387/s_nextafterl.c
+++ b/sysdeps/libm-i387/s_nextafterl.c
@@ -49,7 +49,7 @@ static char rcsid[] = "$NetBSD: $";
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 */
return x+y;
- if(x==y) return x; /* x=y, return x */
+ 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 */
y = x*x;
diff --git a/sysdeps/libm-i387/s_remquo.S b/sysdeps/libm-i387/s_remquo.S
new file mode 100644
index 0000000000..a4c5a35468
--- /dev/null
+++ b/sysdeps/libm-i387/s_remquo.S
@@ -0,0 +1,31 @@
+/*
+ * Written by Ulrich Drepper <drepper@cygnus.com>.
+ * Based on e_remainder by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+ENTRY(__remquo)
+ fldl 12(%esp)
+ fldl 4(%esp)
+1: fprem1
+ fstsw %ax
+ sahf
+ jp 1b
+ fstpl %st(1)
+ /* Compute the congruent of the quotient. */
+ movl %eax, %ecx
+ shrl $8, %eax
+ shrl $12, %ecx
+ andl $4, %ecx
+ andl $3, %eax
+ orl %eax, %ecx
+ movl $0xef2960, %eax
+ shrl %cl, %eax
+ andl $3, %eax
+ movl 20(%esp), %ecx
+ movl %eax, (%ecx)
+ ret
+END (__remquo)
+weak_alias (__remquo, remquo)
diff --git a/sysdeps/libm-i387/s_remquof.S b/sysdeps/libm-i387/s_remquof.S
new file mode 100644
index 0000000000..56954323a6
--- /dev/null
+++ b/sysdeps/libm-i387/s_remquof.S
@@ -0,0 +1,31 @@
+/*
+ * Written by Ulrich Drepper <drepper@cygnus.com>.
+ * Based on e_remainder by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+ENTRY(__remquof)
+ flds 8(%esp)
+ flds 4(%esp)
+1: fprem1
+ fstsw %ax
+ sahf
+ jp 1b
+ fstpl %st(1)
+ /* Compute the congruent of the quotient. */
+ movl %eax, %ecx
+ shrl $8, %eax
+ shrl $12, %ecx
+ andl $4, %ecx
+ andl $3, %eax
+ orl %eax, %ecx
+ movl $0xef2960, %eax
+ shrl %cl, %eax
+ andl $3, %eax
+ movl 12(%esp), %ecx
+ movl %eax, (%ecx)
+ ret
+END (__remquof)
+weak_alias (__remquof, remquof)
diff --git a/sysdeps/libm-i387/s_remquol.S b/sysdeps/libm-i387/s_remquol.S
new file mode 100644
index 0000000000..9c91d90c45
--- /dev/null
+++ b/sysdeps/libm-i387/s_remquol.S
@@ -0,0 +1,31 @@
+/*
+ * Written by Ulrich Drepper <drepper@cygnus.com>.
+ * Based on e_remainder by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+ENTRY(__remquol)
+ fldt 16(%esp)
+ fldt 4(%esp)
+1: fprem1
+ fstsw %ax
+ sahf
+ jp 1b
+ fstpl %st(1)
+ /* Compute the congruent of the quotient. */
+ movl %eax, %ecx
+ shrl $8, %eax
+ shrl $12, %ecx
+ andl $4, %ecx
+ andl $3, %eax
+ orl %eax, %ecx
+ movl $0xef2960, %eax
+ shrl %cl, %eax
+ andl $3, %eax
+ movl 28(%esp), %ecx
+ movl %eax, (%ecx)
+ ret
+END (__remquol)
+weak_alias (__remquol, remquol)
diff --git a/sysdeps/libm-ieee754/s_nan.c b/sysdeps/libm-ieee754/s_nan.c
new file mode 100644
index 0000000000..58551c1ad5
--- /dev/null
+++ b/sysdeps/libm-ieee754/s_nan.c
@@ -0,0 +1,47 @@
+/* Return quiet nan.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 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. */
+
+/* XXX The ISO C 9X standard mentions a `n-char-sequence' which is provided
+ as the argument to this function but I have no clue what this means.
+ Perhaps it is a description of the bits set in the mantissa. */
+#include <math.h>
+#ifdef HANDLE_TAGP
+# include <stdlib.h>
+# include <string.h>
+#else
+# include <ieee754.h>
+#endif
+
+
+double
+nan (const char *tagp)
+{
+#ifdef HANDLE_TAGP
+ /* If we ever should have use of the TAGP parameter we will use the
+ strtod function to analyze it. */
+ char buf[6 + strlen (tagp)];
+ sprintf (buf, "NAN(%s)", tagp);
+ return strtod (buf, NULL);
+#else
+ static const union ieee754_double nan_value =
+ { ieee: { mantissa1: 0x1, mantissa0: 0x0, exponent: 0x7ff, negative: 0 } };
+ return nan_value.d;
+#endif
+}
diff --git a/sysdeps/libm-ieee754/s_nanf.c b/sysdeps/libm-ieee754/s_nanf.c
new file mode 100644
index 0000000000..e965b94b33
--- /dev/null
+++ b/sysdeps/libm-ieee754/s_nanf.c
@@ -0,0 +1,47 @@
+/* Return quiet nan.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 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. */
+
+/* XXX The ISO C 9X standard mentions a `n-char-sequence' which is provided
+ as the argument to this function but I have no clue what this means.
+ Perhaps it is a description of the bits set in the mantissa. */
+#include <math.h>
+#ifdef HANDLE_TAGP
+# include <stdlib.h>
+# include <string.h>
+#else
+# include <ieee754.h>
+#endif
+
+
+float
+nanf (const char *tagp)
+{
+#ifdef HANDLE_TAGP
+ /* If we ever should have use of the TAGP parameter we will use the
+ strtod function to analyze it. */
+ char buf[6 + strlen (tagp)];
+ sprintf (buf, "NAN(%s)", tagp);
+ return strtof (buf, NULL);
+#else
+ static const union ieee754_float nan_value =
+ { ieee: { mantissa: 0x1, exponent: 0xff, negative: 0 } };
+ return nan_value.f;
+#endif
+}
diff --git a/sysdeps/libm-ieee754/s_nanl.c b/sysdeps/libm-ieee754/s_nanl.c
new file mode 100644
index 0000000000..df0180ee46
--- /dev/null
+++ b/sysdeps/libm-ieee754/s_nanl.c
@@ -0,0 +1,48 @@
+/* Return quiet nan.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 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. */
+
+/* XXX The ISO C 9X standard mentions a `n-char-sequence' which is provided
+ as the argument to this function but I have no clue what this means.
+ Perhaps it is a description of the bits set in the mantissa. */
+#include <math.h>
+#ifdef HANDLE_TAGP
+# include <stdlib.h>
+# include <string.h>
+#else
+# include <ieee754.h>
+#endif
+
+
+long double
+nanl (const char *tagp)
+{
+#ifdef HANDLE_TAGP
+ /* If we ever should have use of the TAGP parameter we will use the
+ strtod function to analyze it. */
+ char buf[6 + strlen (tagp)];
+ sprintf (buf, "NAN(%s)", tagp);
+ return strtold (buf, NULL);
+#else
+ static const union ieee854_long_double nan_value =
+ { ieee: { mantissa1: 0x1, mantissa0: 0x80000000,
+ exponent: 0x7fff, negative: 0 } };
+ return nan_value.d;
+#endif
+}
diff --git a/sysdeps/libm-ieee754/s_nextafter.c b/sysdeps/libm-ieee754/s_nextafter.c
index ee973bcee8..b98a161cf2 100644
--- a/sysdeps/libm-ieee754/s_nextafter.c
+++ b/sysdeps/libm-ieee754/s_nextafter.c
@@ -42,7 +42,7 @@ static char rcsid[] = "$NetBSD: s_nextafter.c,v 1.8 1995/05/10 20:47:58 jtc Exp
if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) || /* x is nan */
((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0)) /* y is nan */
return x+y;
- if(x==y) return x; /* x=y, return x */
+ if(x==y) return y; /* x=y, return y */
if((ix|lx)==0) { /* x == 0 */
INSERT_WORDS(x,hy&0x80000000,1); /* return +-minsubnormal */
y = x*x;
diff --git a/sysdeps/libm-ieee754/s_nextafterf.c b/sysdeps/libm-ieee754/s_nextafterf.c
index bc8d04260f..611742bdf4 100644
--- a/sysdeps/libm-ieee754/s_nextafterf.c
+++ b/sysdeps/libm-ieee754/s_nextafterf.c
@@ -8,7 +8,7 @@
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
@@ -34,15 +34,15 @@ static char rcsid[] = "$NetBSD: s_nextafterf.c,v 1.4 1995/05/10 20:48:01 jtc Exp
ix = hx&0x7fffffff; /* |x| */
iy = hy&0x7fffffff; /* |y| */
- if((ix>0x7f800000) || /* x is nan */
- (iy>0x7f800000)) /* y is nan */
- return x+y;
- if(x==y) return x; /* x=y, return x */
+ if((ix>0x7f800000) || /* x is nan */
+ (iy>0x7f800000)) /* y is nan */
+ return x+y;
+ if(x==y) return y; /* x=y, return y */
if(ix==0) { /* x == 0 */
SET_FLOAT_WORD(x,(hy&0x80000000)|1);/* return +-minsubnormal */
y = x*x;
if(y==x) return y; else return x; /* raise underflow flag */
- }
+ }
if(hx>=0) { /* x > 0 */
if(hx>hy) { /* x > y, x -= ulp */
hx -= 1;
diff --git a/sysdeps/libm-ieee754/s_nextafterl.c b/sysdeps/libm-ieee754/s_nextafterl.c
index 0327261f33..1d3fc86c44 100644
--- a/sysdeps/libm-ieee754/s_nextafterl.c
+++ b/sysdeps/libm-ieee754/s_nextafterl.c
@@ -46,7 +46,7 @@ static char rcsid[] = "$NetBSD: $";
if(((ix==0x7fff)&&((hx|lx)|-(hx|lx))!=0) || /* x is nan */
((iy==0x7fff)&&((hy|ly)|-(hy|ly))!=0)) /* y is nan */
return x+y;
- if(x==y) return x; /* x=y, return x */
+ 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 */
y = x*x;
diff --git a/sysdeps/libm-ieee754/s_remquo.c b/sysdeps/libm-ieee754/s_remquo.c
new file mode 100644
index 0000000000..5a96f75f3b
--- /dev/null
+++ b/sysdeps/libm-ieee754/s_remquo.c
@@ -0,0 +1,106 @@
+/* Compute remainder and a congruent to the quotient.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 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 <math.h>
+
+#include "math_private.h"
+
+
+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;
+
+ EXTRACT_WORDS (hx, lx, x);
+ EXTRACT_WORDS (hp, lp, p);
+ sx = hx & 0x80000000;
+ qs = (sx ^ (hp & 0x80000000)) >> 31;
+ hp &= 0x7fffffff;
+ hx &= 0x7fffffff;
+
+ /* Purge off exception values. */
+ if ((hp | lp) == 0)
+ return (x * p) / (x * p); /* p = 0 */
+ if ((hx >= 0x7ff00000) /* x not finite */
+ || ((hp >= 0x7ff00000) /* p is NaN */
+ && (((hp - 0x7ff00000) | lp) != 0)))
+ return (x * p) / (x * p);
+
+ if (hp <= 0x7fbfffff)
+ {
+ x = __ieee754_fmod (x, 8 * p); /* now x < 8p */
+
+ if (fabs (x) >= 4 * fabs (p))
+ cquo += 4;
+ }
+
+ if (((hx - hp) | (lx - lp)) == 0)
+ {
+ *quo = qs ? -1 : 1;
+ return zero * x;
+ }
+
+ x = fabs (x);
+ p = fabs (p);
+ cquo = 0;
+
+ if (x >= 2 * p)
+ {
+ x -= 4 * p;
+ cquo += 2;
+ }
+ if (x >= p)
+ {
+ x -= 2 * p;
+ ++cquo;
+ }
+
+ if (hp < 0x00200000)
+ {
+ if (x + x > p)
+ {
+ x -= p;
+ if (x + x >= p)
+ x -= p;
+ }
+ }
+ else
+ {
+ double p_half = 0.5 * p;
+ if(x > p_half)
+ {
+ x -= p;
+ if (x >= p_half)
+ x -= p;
+ }
+ }
+
+ *quo = qs ? -cquo : cquo;
+
+ GET_HIGH_WORD (hx, x);
+ SET_HIGH_WORD (x, hx ^ sx);
+ return x;
+}
+weak_alias (__remquo, remquo)
diff --git a/sysdeps/libm-ieee754/s_remquof.c b/sysdeps/libm-ieee754/s_remquof.c
new file mode 100644
index 0000000000..cce5495ce8
--- /dev/null
+++ b/sysdeps/libm-ieee754/s_remquof.c
@@ -0,0 +1,105 @@
+/* Compute remainder and a congruent to the quotient.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 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 <math.h>
+
+#include "math_private.h"
+
+
+static const float zero = 0.0;
+
+
+float
+__remquof (float x, float y, int *quo)
+{
+ int32_t hx,hp;
+ u_int32_t sx;
+ int cquo;
+
+ GET_FLOAT_WORD (hx, x);
+ GET_FLOAT_WORD (hp, p);
+ sx = hx & 0x80000000;
+ qs = (sx ^ (hp & 0x80000000)) >> 31;
+ hp &= 0x7fffffff;
+ hx &= 0x7fffffff;
+
+ /* Purge off exception values. */
+ if (hp == 0)
+ return (x * p) / (x * p); /* p = 0 */
+ if ((hx >= 0x7f800000) /* x not finite */
+ || (hp > 0x7f800000)) /* p is NaN */
+ return (x * p) / (x * p);
+
+ if (hp <= 0x7dffffff)
+ {
+ x = __ieee754_fmodf (x, 8 * p); /* now x < 8p */
+
+ if (fabs (x) >= 4 * fabs (p))
+ cquo += 4;
+ }
+
+ if ((hx - hp) == 0)
+ {
+ *quo = qs ? -1 : 1;
+ return zero * x;
+ }
+
+ x = fabsf (x);
+ p = fabsf (p);
+ cquo = 0;
+
+ if (x >= 2 * p)
+ {
+ x -= 4 * p;
+ cquo += 2;
+ }
+ if (x >= p)
+ {
+ x -= 2 * p;
+ ++cquo;
+ }
+
+ if (hp < 0x01000000)
+ {
+ if (x + x > p)
+ {
+ x -= p;
+ if (x + x >= p)
+ x -= p;
+ }
+ }
+ else
+ {
+ float p_half = 0.5 * p;
+ if(x > p_half)
+ {
+ x -= p;
+ if (x >= p_half)
+ x -= p;
+ }
+ }
+
+ *quo = qs ? -cquo : cquo;
+
+ GET_FLOAT_WORD (hx, x);
+ SET_FLOAT_WORD (x, hx ^ sx);
+ return x;
+}
+weak_alias (__remquof, remquof)
diff --git a/sysdeps/libm-ieee754/s_remquol.c b/sysdeps/libm-ieee754/s_remquol.c
new file mode 100644
index 0000000000..9515b218c6
--- /dev/null
+++ b/sysdeps/libm-ieee754/s_remquol.c
@@ -0,0 +1,106 @@
+/* Compute remainder and a congruent to the quotient.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 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 <math.h>
+
+#include "math_private.h"
+
+
+static const double zero = 0.0;
+
+
+long double
+__remquol (long double x, long double y, int *quo)
+{
+ int32_t ex,ep,hx,hp;
+ u_int32_t sx,lx,lp;
+ int cquo;
+
+ GET_LDOUBLE_WORDS (ex, hx, lx, x);
+ GET_LDOUBLE_WORDS (ep, hp, lp, p);
+ sx = ex & 0x8000;
+ qs = (sx ^ (ep & 0x8000)) >> 15;
+ ep &= 0x7fff;
+ ex &= 0x7fff;
+
+ /* Purge off exception values. */
+ if ((ep | hp | lp) == 0)
+ return (x * p) / (x * p); /* p = 0 */
+ if ((ex == 0x7fff) /* x not finite */
+ || ((ep == 0x7fff) /* p is NaN */
+ && ((hp | lp) != 0)))
+ return (x * p) / (x * p);
+
+ if (ep <= 0x7ffb)
+ {
+ x = __ieee754_fmodl (x, 8 * p); /* now x < 8p */
+
+ if (fabsl (x) >= 4 * fabsl (p))
+ cquo += 4;
+ }
+
+ if (((ex - ep) | (hx - hp) | (lx - lp)) == 0)
+ {
+ *quo = qs ? -1 : 1;
+ return zero * x;
+ }
+
+ x = fabsl (x);
+ p = fabsl (p);
+ cquo = 0;
+
+ if (x >= 2 * p)
+ {
+ x -= 4 * p;
+ cquo += 2;
+ }
+ if (x >= p)
+ {
+ x -= 2 * p;
+ ++cquo;
+ }
+
+ if (ep < 0x0002)
+ {
+ if (x + x > p)
+ {
+ x -= p;
+ if (x + x >= p)
+ x -= p;
+ }
+ }
+ else
+ {
+ long double p_half = 0.5 * p;
+ if(x > p_half)
+ {
+ x -= p;
+ if (x >= p_half)
+ x -= p;
+ }
+ }
+
+ *quo = qs ? -cquo : cquo;
+
+ GET_LDOUBLE_EXP (ex, x);
+ SET_LDOUBLE_EXP (x, ex ^ sx);
+ return x;
+}
+weak_alias (__remquol, remquol)
diff --git a/sysdeps/libm-ieee754/s_rintl.c b/sysdeps/libm-ieee754/s_rintl.c
index c9f12b162a..5b4b647880 100644
--- a/sysdeps/libm-ieee754/s_rintl.c
+++ b/sysdeps/libm-ieee754/s_rintl.c
@@ -54,7 +54,7 @@ TWO64[2]={
GET_LDOUBLE_WORDS(se,i0,i1,x);
sx = (se>>15)&1;
j0 = (se&0x7fff)-0x3fff;
- if(j0<32) {
+ if(j0<31) {
if(j0<0) {
if(((se&0x7fff)|i0|i1)==0) return x;
i1 |= i0;
@@ -67,7 +67,7 @@ TWO64[2]={
SET_LDOUBLE_EXP(t,(i0&0x7fff)|(sx<<15));
return t;
} else {
- i = (0xffffffff)>>j0;
+ i = (0x7fffffff)>>j0;
if(((i0&i)|i1)==0) return x; /* x is integral */
i>>=1;
if(((i0&i)|i1)!=0) {
diff --git a/sysdeps/libm-ieee754/s_trunc.c b/sysdeps/libm-ieee754/s_trunc.c
new file mode 100644
index 0000000000..721dce5a55
--- /dev/null
+++ b/sysdeps/libm-ieee754/s_trunc.c
@@ -0,0 +1,61 @@
+/* Truncate argument to nearest integral value not larger than the argument.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 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 <math.h>
+
+#include "math_private.h"
+
+
+double
+__trunc (double x)
+{
+ int32_t i0, j0;
+ u_int32_t i1;
+ int sx;
+
+ EXTRACT_WORDS (i0, i1, x);
+ sx = i0 & 0x80000000;
+ j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
+ if (j0 < 20)
+ {
+ if (j0 < 0)
+ /* The magnitude of the number is < 1 so the result is +-0. */
+ INSERT_WORDS (x, sx, 0);
+ else
+ INSERT_WORDS (x, sx | i0 & ~(0x000fffff >> j0), 0);
+ }
+ else if (j0 > 51)
+ {
+ if (j0 == 0x400)
+ /* x is inf or NaN. */
+ return x + x;
+ }
+ else
+ {
+ INSERT_WORDS (x, i0, i1 & ~(0xffffffffu >> (j0 - 20)));
+ }
+
+ return x;
+}
+weak_alias (__trunc, trunc)
+#ifdef NO_LONG_DOUBLE
+strong_alias (__trunc, __truncl)
+weak_alias (__trunc, truncl)
+#endif
diff --git a/sysdeps/libm-ieee754/s_truncf.c b/sysdeps/libm-ieee754/s_truncf.c
new file mode 100644
index 0000000000..3e7b133c37
--- /dev/null
+++ b/sysdeps/libm-ieee754/s_truncf.c
@@ -0,0 +1,52 @@
+/* Truncate argument to nearest integral value not larger than the argument.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 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 <math.h>
+
+#include "math_private.h"
+
+
+float
+__truncf (float x)
+{
+ int32_t i0, j0;
+ int sx;
+
+ GET_FLOAT_WORD (i0, x);
+ sx = i0 & 0x80000000;
+ j0 = ((i0 >> 23) & 0xff) - 0x7f;
+ if (j0 < 23)
+ {
+ if (j0 < 0)
+ /* The magnitude of the number is < 1 so the result is +-0. */
+ SET_FLOAT_WORD (x, sx);
+ else
+ SET_FLOAT_WORD (x, sx | i0 & ~(0x007fffff >> j0));
+ }
+ else
+ {
+ if (j0 == 0x80)
+ /* x is inf or NaN. */
+ return x + x;
+ }
+
+ return x;
+}
+weak_alias (__truncf, truncf)
diff --git a/sysdeps/libm-ieee754/s_truncl.c b/sysdeps/libm-ieee754/s_truncl.c
new file mode 100644
index 0000000000..206eab2f22
--- /dev/null
+++ b/sysdeps/libm-ieee754/s_truncl.c
@@ -0,0 +1,57 @@
+/* Truncate argument to nearest integral value not larger than the argument.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 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 <math.h>
+
+#include "math_private.h"
+
+
+long double
+__truncl (long double x)
+{
+ int32_t i0, j0;
+ u_int32_t se, i1;
+ int sx;
+
+ GET_LDOUBLE_WORDS (se, i0, i1, x);
+ sx = se & 0x8000;
+ j0 = se & 0x7fff;
+ if (j0 < 31)
+ {
+ if (j0 < 0)
+ /* The magnitude of the number is < 1 so the result is +-0. */
+ SET_LDOUBLE_WORDS (x, sx, 0, 0);
+ else
+ SET_LDOUBLE_WORDS (x, se, i0 & ~(0x7fffffff >> j0), 0);
+ }
+ else if (j0 > 63)
+ {
+ if (j0 == 0x4000)
+ /* x is inf or NaN. */
+ return x + x;
+ }
+ else
+ {
+ SET_LDOUBLE_WORDS (x, se, i0, i1 & ~(0xffffffffu >> (j0 - 31)));
+ }
+
+ return x;
+}
+weak_alias (__truncl, truncl)
diff --git a/sysdeps/sparc/dl-machine.h b/sysdeps/sparc/dl-machine.h
index e87f1970e7..880542d2b3 100644
--- a/sysdeps/sparc/dl-machine.h
+++ b/sysdeps/sparc/dl-machine.h
@@ -104,93 +104,66 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
Elf32_Addr *const reloc_addr = (void *) (map->l_addr + reloc->r_offset);
Elf32_Addr loadbase;
- switch (ELF32_R_TYPE (reloc->r_info))
+ if (ELF32_R_TYPE (reloc->r_info) == R_SPARC_RELATIVE)
+ *reloc_addr += map->l_addr + reloc->r_addend;
+ else
{
- case R_SPARC_COPY:
- loadbase = RESOLVE (&sym, version, DL_LOOKUP_NOEXEC);
- memcpy (reloc_addr, (void *) (loadbase + sym->st_value), sym->st_size);
- break;
- case R_SPARC_GLOB_DAT:
- case R_SPARC_32:
- loadbase = RESOLVE (&sym, version, 0);
- *reloc_addr = ((sym ? (loadbase + sym->st_value) : 0)
- + reloc->r_addend);
- break;
- case R_SPARC_JMP_SLOT:
- loadbase = RESOLVE (&sym, version, DL_LOOKUP_NOPLT);
- {
- Elf32_Addr value = ((sym ? (loadbase + sym->st_value) : 0)
- + reloc->r_addend);
- reloc_addr[1] = OPCODE_SETHI_G1 | (value >> 10);
- reloc_addr[2] = OPCODE_JMP_G1 | (value & 0x3ff);
- }
- break;
- case R_SPARC_8:
- loadbase = RESOLVE (&sym, version, 0);
- *(char *) reloc_addr = ((sym ? (loadbase + sym->st_value) : 0)
- + reloc->r_addend);
- break;
- case R_SPARC_16:
- loadbase = RESOLVE (&sym, version, 0);
- *(short *) reloc_addr = ((sym ? (loadbase + sym->st_value) : 0)
- + reloc->r_addend);
- break;
- case R_SPARC_RELATIVE:
- *reloc_addr += map->l_addr + reloc->r_addend;
- break;
- case R_SPARC_DISP8:
- loadbase = RESOLVE (&sym, version, 0);
- *(char *) reloc_addr = ((sym ? (loadbase + sym->st_value) : 0)
- + reloc->r_addend
- - (Elf32_Addr) reloc_addr);
- break;
- case R_SPARC_DISP16:
- loadbase = RESOLVE (&sym, version, 0);
- *(short *) reloc_addr = ((sym ? (loadbase + sym->st_value) : 0)
- + reloc->r_addend
- - (Elf32_Addr) reloc_addr);
- break;
- case R_SPARC_DISP32:
- loadbase = RESOLVE (&sym, version, 0);
- *reloc_addr = ((sym ? (loadbase + sym->st_value) : 0)
- + reloc->r_addend
- - (Elf32_Addr) reloc_addr);
- break;
- case R_SPARC_LO10:
+ Elf32_Addr value;
+ if (sym->st_shndx != SHN_UNDEF &&
+ ELF32_ST_BIND (sym->st_info) == STB_LOCAL)
+ value = map->l_addr;
+ else
{
- unsigned int saddr;
-
- loadbase = RESOLVE (&sym, version, 0);
- saddr = (loadbase ? loadbase : map->l_addr) + reloc->r_addend;
-
- *reloc_addr = (*reloc_addr & ~0x3ff) | (saddr & 0x3ff);
+ value = RESOLVE (&sym, version, ELF32_R_TYPE (reloc->r_info));
+ if (sym)
+ value += sym->st_value;
}
- break;
- case R_SPARC_WDISP30:
- {
- unsigned int saddr;
-
- loadbase = RESOLVE (&sym, version, 0);
- saddr = (loadbase ? loadbase : map->l_addr) + reloc->r_addend;
- *reloc_addr = ((*reloc_addr & 0xc0000000)
- | ((saddr - (unsigned int) reloc_addr)>>2));
- }
- break;
- case R_SPARC_HI22:
- {
- unsigned int saddr;
-
- loadbase = RESOLVE (&sym, version, 0);
- saddr = (loadbase ? loadbase : map->l_addr) + reloc->r_addend;
+ value += reloc->r_addend; /* Assume copy relocs have zero addend. */
- *reloc_addr = (*reloc_addr & 0xffc00000)|(saddr >> 10);
- }
- break;
- case R_SPARC_NONE: /* Alright, Wilbur. */
- break;
- default:
- assert (! "unexpected dynamic reloc type");
- break;
+ switch (ELF32_R_TYPE (reloc->r_info))
+ {
+ case R_SPARC_COPY:
+ memcpy (reloc_addr, (void *) value, sym->st_size);
+ break;
+ case R_SPARC_GLOB_DAT:
+ case R_SPARC_32:
+ *reloc_addr = value;
+ break;
+ case R_SPARC_JMP_SLOT:
+ reloc_addr[1] = OPCODE_SETHI_G1 | (value >> 10);
+ reloc_addr[2] = OPCODE_JMP_G1 | (value & 0x3ff);
+ break;
+ case R_SPARC_8:
+ *(char *) reloc_addr = value;
+ break;
+ case R_SPARC_16:
+ *(short *) reloc_addr = value;
+ break;
+ case R_SPARC_DISP8:
+ *(char *) reloc_addr = (value - (Elf32_Addr) reloc_addr);
+ break;
+ case R_SPARC_DISP16:
+ *(short *) reloc_addr = (value - (Elf32_Addr) reloc_addr);
+ break;
+ case R_SPARC_DISP32:
+ *reloc_addr = (value - (Elf32_Addr) reloc_addr);
+ break;
+ case R_SPARC_LO10:
+ *reloc_addr = (*reloc_addr & ~0x3ff) | (value & 0x3ff);
+ break;
+ case R_SPARC_WDISP30:
+ *reloc_addr = ((*reloc_addr & 0xc0000000)
+ | ((value - (unsigned int) reloc_addr) >> 2));
+ break;
+ case R_SPARC_HI22:
+ *reloc_addr = (*reloc_addr & 0xffc00000) | (value >> 10);
+ break;
+ case R_SPARC_NONE: /* Alright, Wilbur. */
+ break;
+ default:
+ assert (! "unexpected dynamic reloc type");
+ break;
+ }
}
}
@@ -213,7 +186,14 @@ elf_machine_lazy_rel (struct link_map *map, const Elf32_Rela *reloc)
/* 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_SPARC_JMP_SLOT)
+#define elf_machine_lookup_noexec_p(type) ((type) == R_SPARC_COPY)
+
+/* Nonzero iff TYPE describes relocation of a PLT entry, so
+ PLT entries should not be allowed to define the value. */
+#define elf_machine_lookup_noplt_p(type) ((type) == R_SPARC_JMP_SLOT)
+
+/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */
+#define ELF_MACHINE_RELOC_NOPLT R_SPARC_JMP_SLOT
/* The SPARC never uses Elf32_Rel relocations. */
#define ELF_MACHINE_NO_REL 1
diff --git a/sysdeps/unix/sysv/linux/alpha/termbits.h b/sysdeps/unix/sysv/linux/alpha/termbits.h
index d0932c1cd7..743bb3d283 100644
--- a/sysdeps/unix/sysv/linux/alpha/termbits.h
+++ b/sysdeps/unix/sysv/linux/alpha/termbits.h
@@ -112,6 +112,10 @@ struct termios
#define VT1 00200000
#define XTABS 01000000 /* Hmm.. Linux/i386 considers this part of TABDLY.. */
+/* On Linux there is no OXTABS bit defined. Take it as an alias for
+ XTABS. */
+#define OXTABS XTABS
+
/* c_cflag bit meaning */
#define CBAUD 0000037
#define B0 0000000 /* hang up */
diff --git a/sysdeps/unix/sysv/linux/termbits.h b/sysdeps/unix/sysv/linux/termbits.h
index 8224ac5403..91ba78b950 100644
--- a/sysdeps/unix/sysv/linux/termbits.h
+++ b/sysdeps/unix/sysv/linux/termbits.h
@@ -105,6 +105,10 @@ struct termios
#define FF0 0000000
#define FF1 0100000
+/* On Linux there is no OXTABS bit defined. Take it as an alias for
+ XTABS. */
+#define OXTABS XTABS
+
/* c_cflag bit meaning */
#define CBAUD 0010017
#define B0 0000000 /* hang up */