diff options
Diffstat (limited to 'sysdeps')
74 files changed, 2106 insertions, 427 deletions
diff --git a/sysdeps/generic/getpgrp.c b/sysdeps/generic/getpgrp.c index d745b0f..805fbfb 100644 --- a/sysdeps/generic/getpgrp.c +++ b/sysdeps/generic/getpgrp.c @@ -1,28 +1,27 @@ -/* Copyright (C) 1991, 1995 Free Software Foundation, Inc. -This file is part of the GNU C Library. +/* Copyright (C) 1991, 1995, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. + The GNU C Library is 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. + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ + 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 <ansidecl.h> #include <errno.h> #include <unistd.h> /* Get the process group ID of the calling process. */ int -DEFUN_VOID(getpgrp) +getpgrp (void) { return __getpgid (0); } diff --git a/sysdeps/generic/netinet/in.h b/sysdeps/generic/netinet/in.h index a59f584..1f3e241 100644 --- a/sysdeps/generic/netinet/in.h +++ b/sysdeps/generic/netinet/in.h @@ -22,6 +22,7 @@ #include <features.h> #include <sys/socket.h> +#include <sys/types.h> __BEGIN_DECLS @@ -138,6 +139,34 @@ struct in_addr #endif +/* IPv6 address */ +struct in6_addr + { + union + { + u_int8_t u6_addr8[16]; + u_int16_t u6_addr16[8]; + u_int32_t u6_addr32[4]; +#if (~0UL) > 0xffffffff + u_int64_t u6_addr64[2]; +#endif + } in6_u; +#define s6_addr in6_u.u6_addr8 +#define s6_addr16 in6_u.u6_addr16 +#define s6_addr32 in6_u.u6_addr32 +#define s6_addr64 in6_u.u6_addr64 + }; + +extern const struct in6_addr in6addr_any; /* :: */ +extern const struct in6_addr in6addr_loopback; /* ::1 */ +#define IN6ADDR_ANY_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } +#define IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } + +#define INET_ADDRSTRLEN 16 +#define INET6_ADDRSTRLEN 46 + + + /* Get the definition of the macro to define the common sockaddr members. */ #include <sockaddrcom.h> @@ -156,6 +185,24 @@ struct sockaddr_in sizeof(struct in_addr)]; }; +/* Ditto, for IPv6. */ +struct sockaddr_in6 + { + __SOCKADDR_COMMON (sin6_); + u_int16_t sin6_port; /* Transport layer port # */ + u_int32_t sin6_flowinfo; /* IPv6 flow information */ + struct in6_addr sin6_addr; /* IPv6 address */ + }; + +/* IPv6 multicast request. */ +struct ipv6_mreq + { + /* IPv6 multicast address of group */ + struct in6_addr ipv6mr_multiaddr; + + /* local IPv6 address of interface */ + int ipv6mr_ifindex; + }; /* Options for use with `getsockopt' and `setsockopt' at the IP level. The first word in the comment at the right is the data type used; @@ -213,6 +260,52 @@ extern u_int16_t htons __P ((u_int16_t __hostshort)); #define htons(x) (x) #endif +/* IPV6 socket options. */ +#define IPV6_ADDRFORM 1 +#define IPV6_RXINFO 2 +#define IPV6_RXHOPOPTS 3 +#define IPV6_RXDSTOPTS 4 +#define IPV6_RXSRCRT 5 +#define IPV6_PKTOPTIONS 6 +#define IPV6_CHECKSUM 7 +#define IPV6_HOPLIMIT 8 + +#define IPV6_TXINFO IPV6_RXINFO +#define SCM_SRCINFO IPV6_TXINFO +#define SCM_SRCRT IPV6_RXSRCRT + +#define IPV6_UNICAST_HOPS 16 +#define IPV6_MULTICAST_IF 17 +#define IPV6_MULTICAST_HOPS 18 +#define IPV6_MULTICAST_LOOP 19 +#define IPV6_ADD_MEMBERSHIP 20 +#define IPV6_DROP_MEMBERSHIP 21 + +#define IN6_IS_ADDR_UNSPECIFIED(a) \ + ((((u_int32_t *)(a))[0] == 0) && ((u_int32_t *)(a))[1] == 0) && \ + (((u_int32_t *)(a))[2] == 0) && ((u_int32_t *)(a))[3] == 0)) + +#define IN6_IS_ADDR_LOOPBACK(a) \ + ((((u_int32_t *)(a))[0] == 0) && ((u_int32_t *)(a))[1] == 0) && \ + (((u_int32_t *)(a))[2] == 0) && ((u_int32_t *)(a))[3] == htonl(1))) + +#define IN6_IS_ADDR_MULTICAST(a) (((u_int8_t *)(a))[0] == 0xff) + +#define IN6_IS_ADDR_LINKLOCAL(a) \ + ((((u_int32_t *)(a))[0] & htonl(0xffc00000)) == htonl(0xfe800000)) + +#define IN6_IS_ADDR_SITELOCAL(a) \ + ((((u_int32_t *)(a))[0] & htonl(0xffc00000)) == htonl(0xfec00000)) + +#define IN6_IS_ADDR_V4MAPPED(a) \ + ((((u_int32_t *)(a))[0] == 0) && (((u_int32_t *)(a))[1] == 0) && \ + (((u_int32_t *)(a))[2] == htonl(0xffff))) + +#define IN6_IS_ADDR_V4COMPAT(a) \ + ((((u_int32_t *)(a))[0] == 0) && (((u_int32_t *)(a))[1] == 0) && \ + (((u_int32_t *)(a))[2] == 0) && (ntohl(((u_int32_t *)(a))[3]) > 1)) + + __END_DECLS #endif /* netinet/in.h */ diff --git a/sysdeps/generic/sys/mman.h b/sysdeps/generic/sys/mman.h index bcda90f..32b152e 100644 --- a/sysdeps/generic/sys/mman.h +++ b/sysdeps/generic/sys/mman.h @@ -1,5 +1,5 @@ /* Definitions for BSD-style memory management. Generic/4.4 BSD version. - Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997 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 @@ -97,8 +97,8 @@ int mprotect __P ((__caddr_t __addr, size_t __len, int __prot)); /* Synchronize the region starting at ADDR and extending LEN bytes with the file it maps. Filesystem operations on a file being mapped are - unpredictable before this is done. */ -int msync __P ((__caddr_t __addr, size_t __len)); + unpredictable before this is done. Flags are from the MS_* set. */ +int msync __P ((__caddr_t __addr, size_t __len, int flags)); /* Advise the system about particular usage patterns the program follows for the region starting at ADDR and extending LEN bytes. */ diff --git a/sysdeps/i386/huge_val.h b/sysdeps/i386/huge_val.h new file mode 100644 index 0000000..8af745f --- /dev/null +++ b/sysdeps/i386/huge_val.h @@ -0,0 +1,92 @@ +/* `HUGE_VAL' constants for ix86 (where it is infinity). + Used by <stdlib.h> and <math.h> functions for overflow. + Copyright (C) 1992, 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _HUGE_VAL_H +#define _HUGE_VAL_H 1 + +#include <features.h> +#include <sys/cdefs.h> +#include <endian.h> + +/* IEEE positive infinity (-HUGE_VAL is negative infinity). */ + +#if __BYTE_ORDER == __BIG_ENDIAN +#define __HUGE_VAL_bytes { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } +#endif +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define __HUGE_VAL_bytes { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } +#endif + +#define __huge_val_t union { unsigned char __c[8]; double __d; } +#ifdef __GNUC__ +#define HUGE_VAL (__extension__ \ + ((__huge_val_t) { __c: __HUGE_VAL_bytes }).__d) +#else /* Not GCC. */ +static __huge_val_t __huge_val = { __HUGE_VAL_bytes }; +#define HUGE_VAL (__huge_val.__d) +#endif /* GCC. */ + + +/* ISO C 9X extensions: (float) HUGE_VALF and (long double) HUGE_VALL. */ + +#ifdef __USE_ISOC9X + +#if __BYTE_ORDER == __BIG_ENDIAN +#define __HUGE_VALF_bytes { 0x7f, 0x80, 0, 0 } +#endif +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define __HUGE_VALF_bytes { 0, 0, 0x80, 0x7f } +#endif + +#define __huge_valf_t union { unsigned char __c[4]; float __f; } +#ifdef __GNUC__ +#define HUGE_VALF (__extension__ \ + ((__huge_valf_t) { __c: __HUGE_VALF_bytes }).__f) +#else /* Not GCC. */ +static __huge_valf_t __huge_valf = { __HUGE_VALF_bytes }; +#define HUGE_VALF (__huge_valf.__f) +#endif /* GCC. */ + + +#if __BYTE_ORDER == __BIG_ENDIAN +#define __HUGE_VALL_bytes { 0x7f, 0xff, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0 } +#endif +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define __HUGE_VALL_bytes { 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0x7f, 0, 0 } +#endif + +#define __huge_vall_t union { unsigned char __c[12]; long double __ld; } +#ifdef __GNUC__ +#define HUGE_VALL (__extension__ \ + ((__huge_vall_t) { __c: __HUGE_VALL_bytes }).__ld) +#else /* Not GCC. */ +static __huge_vall_t __huge_vall = { __HUGE_VALL_bytes }; +#define HUGE_VALL (__huge_vall.__ld) +#endif /* GCC. */ + + +/* Expression representing positive infinity. Here it is the same as + HUGE_VALF. */ +#define INFINITY HUGE_VALF + +#endif /* __USE_ISOC9X. */ + + +#endif /* huge_val.h */ diff --git a/sysdeps/ieee754/huge_val.h b/sysdeps/ieee754/huge_val.h index 4f8b0a9..ef9fa65 100644 --- a/sysdeps/ieee754/huge_val.h +++ b/sysdeps/ieee754/huge_val.h @@ -65,21 +65,9 @@ static __huge_valf_t __huge_valf = { __HUGE_VALF_bytes }; #endif /* GCC. */ -#if __BYTE_ORDER == __BIG_ENDIAN -#define __HUGE_VALL_bytes { 0x7f, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } -#endif -#if __BYTE_ORDER == __LITTLE_ENDIAN -#define __HUGE_VALL_bytes { 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0x7f, 0, 0 } -#endif - -#define __huge_vall_t union { unsigned char __c[12]; long double __ld; } -#ifdef __GNUC__ -#define HUGE_VALL (__extension__ \ - ((__huge_vall_t) { __c: __HUGE_VALL_bytes }).__ld) -#else /* Not GCC. */ -static __huge_vall_t __huge_vall = { __HUGE_VALL_bytes }; -#define HUGE_VALL (__huge_vall.__ld) -#endif /* GCC. */ +/* Generally there is no separate `long double' format and it is the + same as `double'. */ +#define HUGE_VALL HUGE_VAL /* Expression representing positive infinity. Here it is the same as diff --git a/sysdeps/libm-i387/e_acos.S b/sysdeps/libm-i387/e_acos.S index becae36..b9d07b1 100644 --- a/sysdeps/libm-i387/e_acos.S +++ b/sysdeps/libm-i387/e_acos.S @@ -10,12 +10,12 @@ RCSID("$NetBSD: e_acos.S,v 1.4 1995/05/08 23:44:37 jtc Exp $") /* acos = atan (sqrt(1 - x^2) / x) */ ENTRY(__ieee754_acos) fldl 4(%esp) /* x */ - fst %st(1) - fmul %st(0) /* x^2 */ - fld1 - fsubp /* 1 - x^2 */ - fsqrt /* sqrt (1 - x^2) */ - fxch %st(1) - fpatan + fld %st /* x : x */ + fmul %st(0) /* x^2 : x */ + fld1 /* 1 : x^2 : x */ + fsubp /* 1 - x^2 : x */ + fsqrt /* sqrt (1 - x^2) : x */ + fxch %st(1) /* x : sqrt (1 - x^2) */ + fpatan /* atan (sqrt(1 - x^2) / x) */ ret END (__ieee754_acos) diff --git a/sysdeps/libm-i387/e_acosf.S b/sysdeps/libm-i387/e_acosf.S index 87ee2fb..50b13fd 100644 --- a/sysdeps/libm-i387/e_acosf.S +++ b/sysdeps/libm-i387/e_acosf.S @@ -11,7 +11,7 @@ RCSID("$NetBSD: $") /* acos = atan (sqrt(1 - x^2) / x) */ ENTRY(__ieee754_acosf) flds 4(%esp) /* x */ - fst %st(1) + fld %st fmul %st(0) /* x^2 */ fld1 fsubp /* 1 - x^2 */ diff --git a/sysdeps/libm-i387/e_acosl.S b/sysdeps/libm-i387/e_acosl.S index e8f9748..d69f056 100644 --- a/sysdeps/libm-i387/e_acosl.S +++ b/sysdeps/libm-i387/e_acosl.S @@ -11,7 +11,7 @@ /* acosl = atanl (sqrtl(1 - x^2) / x) */ ENTRY(__ieee754_acosl) fldt 4(%esp) /* x */ - fst %st(1) + fld %st fmul %st(0) /* x^2 */ fld1 fsubp /* 1 - x^2 */ diff --git a/sysdeps/libm-i387/e_asin.S b/sysdeps/libm-i387/e_asin.S index 1202753..945e308 100644 --- a/sysdeps/libm-i387/e_asin.S +++ b/sysdeps/libm-i387/e_asin.S @@ -10,7 +10,7 @@ RCSID("$NetBSD: e_asin.S,v 1.4 1995/05/08 23:45:40 jtc Exp $") /* asin = atan (x / sqrt(1 - x^2)) */ ENTRY(__ieee754_asin) fldl 4(%esp) /* x */ - fst %st(1) + fld %st fmul %st(0) /* x^2 */ fld1 fsubp /* 1 - x^2 */ diff --git a/sysdeps/libm-i387/e_asinf.S b/sysdeps/libm-i387/e_asinf.S index d2159ba..d450e9a 100644 --- a/sysdeps/libm-i387/e_asinf.S +++ b/sysdeps/libm-i387/e_asinf.S @@ -11,7 +11,7 @@ RCSID("$NetBSD: $") /* asin = atan (x / sqrt(1 - x^2)) */ ENTRY(__ieee754_asinf) flds 4(%esp) /* x */ - fst %st(1) + fld %st fmul %st(0) /* x^2 */ fld1 fsubp /* 1 - x^2 */ diff --git a/sysdeps/libm-i387/e_asinl.S b/sysdeps/libm-i387/e_asinl.S index ab421f3..3919fbc 100644 --- a/sysdeps/libm-i387/e_asinl.S +++ b/sysdeps/libm-i387/e_asinl.S @@ -12,7 +12,7 @@ RCSID("$NetBSD: $") /* asinl = atanl (x / sqrtl(1 - x^2)) */ ENTRY(__ieee754_asinl) fldt 4(%esp) /* x */ - fst %st(1) + fld %st fmul %st(0) /* x^2 */ fld1 fsubp /* 1 - x^2 */ diff --git a/sysdeps/libm-i387/e_exp.S b/sysdeps/libm-i387/e_exp.S index e76b9c6..4a75fa1 100644 --- a/sysdeps/libm-i387/e_exp.S +++ b/sysdeps/libm-i387/e_exp.S @@ -22,7 +22,7 @@ ENTRY(__ieee754_exp) je 1f /* Is +-Inf, jump. */ fldl2e fmulp /* x * log2(e) */ - fstl %st(1) + fld %st frndint /* int(x * log2(e)) */ fsubr %st,%st(1) /* fract(x * log2(e)) */ fxch @@ -35,6 +35,7 @@ ENTRY(__ieee754_exp) 1: testl $0x200, %eax /* Test sign. */ jz 2f /* If positive, jump. */ + fstp %st fldz /* Set result to 0. */ 2: ret END (__ieee754_exp) diff --git a/sysdeps/libm-i387/e_expf.S b/sysdeps/libm-i387/e_expf.S index 9a669cf..5fd49b8 100644 --- a/sysdeps/libm-i387/e_expf.S +++ b/sysdeps/libm-i387/e_expf.S @@ -23,7 +23,7 @@ ENTRY(__ieee754_expf) je 1f /* Is +-Inf, jump. */ fldl2e fmulp /* x * log2(e) */ - fstl %st(1) + fld %st frndint /* int(x * log2(e)) */ fsubr %st,%st(1) /* fract(x * log2(e)) */ fxch @@ -36,6 +36,7 @@ ENTRY(__ieee754_expf) 1: testl $0x200, %eax /* Test sign. */ jz 2f /* If positive, jump. */ + fstp %st fldz /* Set result to 0. */ 2: ret END (__ieee754_expf) diff --git a/sysdeps/libm-i387/e_expl.S b/sysdeps/libm-i387/e_expl.S index e83d306..2bcdf58 100644 --- a/sysdeps/libm-i387/e_expl.S +++ b/sysdeps/libm-i387/e_expl.S @@ -24,7 +24,7 @@ ENTRY(__ieee754_expl) je 1f /* Is +-Inf, jump. */ fldl2e fmulp /* x * log2(e) */ - fstl %st(1) + fld %st frndint /* int(x * log2(e)) */ fsubr %st,%st(1) /* fract(x * log2(e)) */ fxch @@ -37,6 +37,7 @@ ENTRY(__ieee754_expl) 1: testl $0x200, %eax /* Test sign. */ jz 2f /* If positive, jump. */ + fstp %st fldz /* Set result to 0. */ 2: ret END (__ieee754_expl) diff --git a/sysdeps/libm-i387/e_log.S b/sysdeps/libm-i387/e_log.S index e7f567d..c7cacdf 100644 --- a/sysdeps/libm-i387/e_log.S +++ b/sysdeps/libm-i387/e_log.S @@ -47,8 +47,8 @@ ENTRY(__ieee754_log) fabs // |x-1| : x-1 : x : log(2) fcompl MO(limit) // x-1 : x : log(2) fnstsw // x-1 : x : log(2) - sahf - ja 2f + andb $0x45, %ah + jz 2f fstp %st(1) // x-1 : log(2) fyl2xp1 // log(x) ret diff --git a/sysdeps/libm-i387/e_log10.S b/sysdeps/libm-i387/e_log10.S index ecb691b..2c8488c 100644 --- a/sysdeps/libm-i387/e_log10.S +++ b/sysdeps/libm-i387/e_log10.S @@ -47,8 +47,8 @@ ENTRY(__ieee754_log10) fabs // |x-1| : x-1 : x : log10(2) fcompl MO(limit) // x-1 : x : log10(2) fnstsw // x-1 : x : log10(2) - sahf - ja 2f + andb $0x45, %ah + jz 2f fstp %st(1) // x-1 : log10(2) fyl2xp1 // log10(x) ret diff --git a/sysdeps/libm-i387/e_log10f.S b/sysdeps/libm-i387/e_log10f.S index aac58d0..2c07161 100644 --- a/sysdeps/libm-i387/e_log10f.S +++ b/sysdeps/libm-i387/e_log10f.S @@ -48,8 +48,8 @@ ENTRY(__ieee754_log10f) fabs // |x-1| : x-1 : x : log10(2) fcompl MO(limit) // x-1 : x : log10(2) fnstsw // x-1 : x : log10(2) - sahf - ja 2f + andb $0x45, %ah + jz 2f fstp %st(1) // x-1 : log10(2) fyl2xp1 // log10(x) ret diff --git a/sysdeps/libm-i387/e_log10l.S b/sysdeps/libm-i387/e_log10l.S index 4f51818..6fe7c5a 100644 --- a/sysdeps/libm-i387/e_log10l.S +++ b/sysdeps/libm-i387/e_log10l.S @@ -49,8 +49,8 @@ ENTRY(__ieee754_log10l) fabs // |x-1| : x-1 : x : log10(2) fcompl MO(limit) // x-1 : x : log10(2) fnstsw // x-1 : x : log10(2) - sahf - ja 2f + andb $0x45, %ah + jz 2f fstp %st(1) // x-1 : log10(2) fyl2xp1 // log10(x) ret diff --git a/sysdeps/libm-i387/e_logf.S b/sysdeps/libm-i387/e_logf.S index 4459b7f..bdba1d3 100644 --- a/sysdeps/libm-i387/e_logf.S +++ b/sysdeps/libm-i387/e_logf.S @@ -48,8 +48,8 @@ ENTRY(__ieee754_logf) fabs // |x-1| : x-1 : x : log(2) fcompl MO(limit) // x-1 : x : log(2) fnstsw // x-1 : x : log(2) - sahf - ja 2f + andb $0x45, %ah + jz 2f fstp %st(1) // x-1 : log(2) fyl2xp1 // log(x) ret diff --git a/sysdeps/libm-i387/e_logl.S b/sysdeps/libm-i387/e_logl.S index 08447a2..bda3ea5 100644 --- a/sysdeps/libm-i387/e_logl.S +++ b/sysdeps/libm-i387/e_logl.S @@ -48,8 +48,8 @@ ENTRY(__ieee754_logl) fabs // |x-1| : x-1 : x : log(2) fcompl MO(limit) // x-1 : x : log(2) fnstsw // x-1 : x : log(2) - sahf - ja 2f + andb $0x45, %ah + jz 2f fstp %st(1) // x-1 : log(2) fyl2xp1 // log(x) ret diff --git a/sysdeps/libm-i387/e_pow.S b/sysdeps/libm-i387/e_pow.S index f6c7562..efe1841 100644 --- a/sysdeps/libm-i387/e_pow.S +++ b/sysdeps/libm-i387/e_pow.S @@ -1,5 +1,5 @@ /* ix87 specific implementation of pow function. - Copyright (C) 1996 Free Software Foundation, Inc. + Copyright (C) 1996, 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -27,31 +27,77 @@ #endif .align ALIGNARG(4) + ASM_TYPE_DIRECTIVE(infinity,@object) +inf_zero: +infinity: + .byte 0, 0, 0, 0, 0, 0, 0xf0, 0x7f + ASM_SIZE_DIRECTIVE(infinity) + ASM_TYPE_DIRECTIVE(zero,@object) +zero: .double 0.0 + ASM_SIZE_DIRECTIVE(zero) + ASM_TYPE_DIRECTIVE(minf_mzero,@object) +minf_mzero: +minfinity: + .byte 0, 0, 0, 0, 0, 0, 0xf0, 0xff +mzero: + .byte 0, 0, 0, 0, 0, 0, 0, 0x80 + ASM_SIZE_DIRECTIVE(minf_mzero) ASM_TYPE_DIRECTIVE(one,@object) one: .double 1.0 ASM_SIZE_DIRECTIVE(one) ASM_TYPE_DIRECTIVE(limit,@object) limit: .double 0.29 ASM_SIZE_DIRECTIVE(limit) + ASM_TYPE_DIRECTIVE(nan,@object) +nan: .byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f + ASM_SIZE_DIRECTIVE(nan) #ifdef PIC #define MO(op) op##@GOTOFF(%ecx) +#define MOX(op,x,f) op##@GOTOFF(%ecx,x,f) #else #define MO(op) op +#define MOX(op,x,f) op(,x,f) #endif .text ENTRY(__ieee754_pow) - fldl 4(%esp) // x - fldl 12(%esp) // y : x + fldl 12(%esp) // y + fxam + fnstsw + movb %ah, %dl + andb $0x45, %ah + cmpb $0x40, %ah // is y == 0 ? + je 11f + + cmpb $0x05, %ah // is y == ±inf ? + je 12f + + cmpb $0x01, %ah // is y == NaN ? + je 30f #ifdef PIC call 1f 1: popl %ecx addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ecx #endif + + fldl 4(%esp) // x : y + subl $8,%esp + fxam + fnstsw + movb %ah, %dh + andb $0x45, %ah + cmpb $0x40, %ah + je 20f // x is ±0 + + cmpb $0x05, %ah + je 15f // x is ±inf + + fxch // y : x + /* First see whether `y' is a natural number. In this case we can use a more precise algorithm. */ fld %st // y : y : x @@ -63,13 +109,11 @@ ENTRY(__ieee754_pow) jne 2f /* OK, we have an integer value for y. */ - ftst // y : x - fstp %st(0) // x - fnstsw - sahf popl %eax popl %edx - jnc 4f // y >= 0, jump + orl $0, %edx + fstp %st(0) // x + jns 4f // y >= 0, jump fdivrl MO(one) // 1/x (now referred to as x) negl %eax adcl $0, %edx @@ -87,7 +131,7 @@ ENTRY(__ieee754_pow) orl %edx, %ecx jnz 6b fstp %st(0) // ST*x - ret +30: ret .align ALIGNARG(4) 2: /* y is a real number. */ @@ -117,4 +161,161 @@ ENTRY(__ieee754_pow) addl $8, %esp fstp %st(1) // 2^fract(y*log2(x))*2^int(y*log2(x)) ret + + + // pow(x,±0) = 1 + .align ALIGNARG(4) +11: fstp %st(0) // pop y + fldl MO(one) + ret + + // y == ±inf + .align ALIGNARG(4) +12: fstp %st(0) // pop y + fldl 4(%esp) // x + fabs + fcompl MO(one) // < 1, == 1, or > 1 + fnstsw + andb $0x45, %ah + cmpb $0x45, %ah + je 13f // jump if x is NaN + + cmpb $0x40, %ah + je 14f // jump if |x| == 1 + + shlb $1, %ah + xorb %ah, %dl + andl $2, %edx + fldl MOX(inf_zero, %edx, 4) + ret + + .align ALIGNARG(4) +14: fldl MO(nan) + faddl MO(zero) // raise invalid exception + ret + + .align ALIGNARG(4) +13: fldl 4(%esp) // load x == NaN + ret + + .align ALIGNARG(4) + // x is ±inf +15: fstp %st(0) // y + testb $2, %dh + jz 16f // jump if x == +inf + + // We must find out whether y is an odd integer. + fld %st // y : y + fistpll (%esp) // y + fildll (%esp) // int(y) : y + fucompp // <empty> + fnstsw + sahf + jne 17f + + // OK, the value is an integer, but is the number of bits small + // enough so that all are coming from the mantissa? + popl %eax + popl %edx + andb $1, %al + jz 18f // jump if not odd + movl %edx, %eax + orl %edx, %edx + jns 155f + negl %eax +155: cmpl $0x00200000, %eax + ja 18f // does not fit in mantissa bits + // It's an odd integer. + shrl $31, %edx + fldl MOX(minf_mzero, %edx, 8) + ret + + .align ALIGNARG(4) +16: fcompl MO(zero) + addl $8, %esp + fnstsw + shrl $5, %eax + andl $8, %eax + fldl MOX(inf_zero, %eax, 1) + ret + + .align ALIGNARG(4) +17: shll $30, %edx // sign bit for y in right position + addl $8, %esp +18: shrl $31, %edx + fldl MOX(inf_zero, %edx, 8) + ret + + .align ALIGNARG(4) + // x is ±0 +20: fstp %st(0) // y + testb $2, %dl + jz 21f // y > 0 + + // x is ±0 and y is < 0. We must find out whether y is an odd integer. + testb $2, %dh + jz 25f + + fld %st // y : y + fistpll (%esp) // y + fildll (%esp) // int(y) : y + fucompp // <empty> + fnstsw + sahf + jne 26f + + // OK, the value is an integer, but is the number of bits small + // enough so that all are coming from the mantissa? + popl %eax + popl %edx + andb $1, %al + jz 27f // jump if not odd + cmpl $0xffe00000, %edx + jbe 27f // does not fit in mantissa bits + // It's an odd integer. + // Raise divide-by-zero exception and get minus infinity value. + fldl MO(one) + fdivl MO(zero) + fchs + ret + +25: fstp %st(0) +26: popl %eax + popl %edx +27: // Raise divide-by-zero exception and get infinity value. + fldl MO(one) + fdivl MO(zero) + ret + + .align ALIGNARG(4) + // x is ±0 and y is > 0. We must find out whether y is an odd integer. +21: testb $2, %dh + jz 22f + + fld %st // y : y + fistpll (%esp) // y + fildll (%esp) // int(y) : y + fucompp // <empty> + fnstsw + sahf + jne 23f + + // OK, the value is an integer, but is the number of bits small + // enough so that all are coming from the mantissa? + popl %eax + popl %edx + andb $1, %al + jz 24f // jump if not odd + cmpl $0xffe00000, %edx + jbe 24f // does not fit in mantissa bits + // It's an odd integer. + fldl MO(mzero) + ret + +22: fstp %st(0) +23: popl %eax + popl %edx +24: fldl MO(zero) + ret + END(__ieee754_pow) diff --git a/sysdeps/libm-i387/e_powf.S b/sysdeps/libm-i387/e_powf.S index 9d6bc51..54af93c 100644 --- a/sysdeps/libm-i387/e_powf.S +++ b/sysdeps/libm-i387/e_powf.S @@ -1,5 +1,5 @@ /* ix87 specific implementation of pow function. - Copyright (C) 1996 Free Software Foundation, Inc. + Copyright (C) 1996, 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -27,67 +27,107 @@ #endif .align ALIGNARG(4) + ASM_TYPE_DIRECTIVE(infinity,@object) +inf_zero: +infinity: + .byte 0, 0, 0, 0, 0, 0, 0xf0, 0x7f + ASM_SIZE_DIRECTIVE(infinity) + ASM_TYPE_DIRECTIVE(zero,@object) +zero: .double 0.0 + ASM_SIZE_DIRECTIVE(zero) + ASM_TYPE_DIRECTIVE(minf_mzero,@object) +minf_mzero: +minfinity: + .byte 0, 0, 0, 0, 0, 0, 0xf0, 0xff +mzero: + .byte 0, 0, 0, 0, 0, 0, 0, 0x80 + ASM_SIZE_DIRECTIVE(minf_mzero) ASM_TYPE_DIRECTIVE(one,@object) one: .double 1.0 ASM_SIZE_DIRECTIVE(one) ASM_TYPE_DIRECTIVE(limit,@object) limit: .double 0.29 ASM_SIZE_DIRECTIVE(limit) + ASM_TYPE_DIRECTIVE(nan,@object) +nan: .byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f + ASM_SIZE_DIRECTIVE(nan) #ifdef PIC #define MO(op) op##@GOTOFF(%ecx) +#define MOX(op,x,f) op##@GOTOFF(%ecx,x,f) #else #define MO(op) op +#define MOX(op,x,f) op(,x,f) #endif .text ENTRY(__ieee754_powf) - flds 4(%esp) // x - flds 8(%esp) // y : x + flds 8(%esp) // y + fxam + fnstsw + movb %ah, %dl + andb $0x45, %ah + cmpb $0x40, %ah // is y == 0 ? + je 11f + + cmpb $0x05, %ah // is y == ±inf ? + je 12f + + cmpb $0x01, %ah // is y == NaN ? + je 30f #ifdef PIC call 1f 1: popl %ecx addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ecx #endif - subl $8,%esp + + flds 4(%esp) // x : y + + subl $4, %esp + + fxam + fnstsw + movb %ah, %dh + andb $0x45, %ah + cmpb $0x40, %ah + je 20f // x is ±0 + + cmpb $0x05, %ah + je 15f // x is ±inf + + fxch // y : x /* First see whether `y' is a natural number. In this case we can use a more precise algorithm. */ fld %st // y : y : x - fistpll (%esp) // y : x - fildll (%esp) // int(y) : y : x + fistpl (%esp) // y : x + fildl (%esp) // int(y) : y : x fucomp %st(1) // y : x fnstsw sahf jne 2f /* OK, we have an integer value for y. */ - ftst // y : x - fstp %st(0) // x - fnstsw - sahf - popl %eax popl %edx - jnc 4f // y >= 0, jump + orl $0, %edx + fstp %st(0) // x + jns 4f // y >= 0, jump fdivrl MO(one) // 1/x (now referred to as x) - negl %eax - adcl $0, %edx negl %edx 4: fldl MO(one) // 1 : x fxch -6: shrdl $1, %edx, %eax +6: shrl $1, %edx jnc 5f fxch fmul %st(1) // x : ST*x fxch 5: fmul %st(0), %st // x*x : ST*x - movl %eax, %ecx - orl %edx, %ecx + testl %edx, %edx jnz 6b fstp %st(0) // ST*x - ret +30: ret .align ALIGNARG(4) 2: /* y is a real number. */ @@ -114,7 +154,159 @@ ENTRY(__ieee754_powf) f2xm1 // 2^fract(y*log2(x))-1 : int(y*log2(x)) faddl MO(one) // 2^fract(y*log2(x)) : int(y*log2(x)) fscale // 2^fract(y*log2(x))*2^int(y*log2(x)) : int(y*log2(x)) - addl $8, %esp + addl $4, %esp fstp %st(1) // 2^fract(y*log2(x))*2^int(y*log2(x)) ret + + + // pow(x,±0) = 1 + .align ALIGNARG(4) +11: fstp %st(0) // pop y + fldl MO(one) + ret + + // y == ±inf + .align ALIGNARG(4) +12: fstp %st(0) // pop y + flds 4(%esp) // x + fabs + fcompl MO(one) // < 1, == 1, or > 1 + fnstsw + andb $0x45, %ah + cmpb $0x45, %ah + je 13f // jump if x is NaN + + cmpb $0x40, %ah + je 14f // jump if |x| == 1 + + shlb $1, %ah + xorb %ah, %dl + andl $2, %edx + fldl MOX(inf_zero, %edx, 4) + ret + + .align ALIGNARG(4) +14: fldl MO(nan) + faddl MO(zero) // raise invalid exception + ret + + .align ALIGNARG(4) +13: flds 4(%esp) // load x == NaN + ret + + .align ALIGNARG(4) + // x is ±inf +15: fstp %st(0) // y + testb $2, %dh + jz 16f // jump if x == +inf + + // We must find out whether y is an odd integer. + fld %st // y : y + fistpl (%esp) // y + fildl (%esp) // int(y) : y + fucompp // <empty> + fnstsw + sahf + jne 17f + + // OK, the value is an integer, but is the number of bits small + // enough so that all are coming from the mantissa? + popl %edx + testb $1, %dl + jz 18f // jump if not odd + movl %edx, %eax + orl %edx, %edx + jns 155f + negl %eax +155: cmpl $0x01000000, %eax + ja 18f // does not fit in mantissa bits + // It's an odd integer. + shrl $31, %edx + fldl MOX(minf_mzero, %edx, 8) + ret + + .align ALIGNARG(4) +16: fcompl MO(zero) + addl $4, %esp + fnstsw + shrl $5, %eax + andl $8, %eax + fldl MOX(inf_zero, %eax, 1) + ret + + .align ALIGNARG(4) +17: shll $30, %edx // sign bit for y in right position + addl $4, %esp +18: shrl $31, %edx + fldl MOX(inf_zero, %edx, 8) + ret + + .align ALIGNARG(4) + // x is ±0 +20: fstp %st(0) // y + testb $2, %dl + jz 21f // y > 0 + + // x is ±0 and y is < 0. We must find out whether y is an odd integer. + testb $2, %dh + jz 25f + + fld %st // y : y + fistpl (%esp) // y + fildl (%esp) // int(y) : y + fucompp // <empty> + fnstsw + sahf + jne 26f + + // OK, the value is an integer, but is the number of bits small + // enough so that all are coming from the mantissa? + popl %edx + testb $1, %dl + jz 27f // jump if not odd + cmpl $0xff000000, %edx + jbe 27f // does not fit in mantissa bits + // It's an odd integer. + // Raise divide-by-zero exception and get minus infinity value. + fldl MO(one) + fdivl MO(zero) + fchs + ret + +25: fstp %st(0) +26: popl %eax +27: // Raise divide-by-zero exception and get infinity value. + fldl MO(one) + fdivl MO(zero) + ret + + .align ALIGNARG(4) + // x is ±0 and y is > 0. We must find out whether y is an odd integer. +21: testb $2, %dh + jz 22f + + fld %st // y : y + fistpl (%esp) // y + fildl (%esp) // int(y) : y + fucompp // <empty> + fnstsw + sahf + jne 23f + + // OK, the value is an integer, but is the number of bits small + // enough so that all are coming from the mantissa? + popl %edx + testb $1, %dl + jz 24f // jump if not odd + cmpl $0xff000000, %edx + jbe 24f // does not fit in mantissa bits + // It's an odd integer. + fldl MO(mzero) + ret + +22: fstp %st(0) +23: popl %eax +24: fldl MO(zero) + ret + END(__ieee754_powf) diff --git a/sysdeps/libm-i387/e_powl.S b/sysdeps/libm-i387/e_powl.S index ea44580..3cfb96b 100644 --- a/sysdeps/libm-i387/e_powl.S +++ b/sysdeps/libm-i387/e_powl.S @@ -1,5 +1,5 @@ /* ix87 specific implementation of pow function. - Copyright (C) 1996 Free Software Foundation, Inc. + Copyright (C) 1996, 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -27,31 +27,77 @@ #endif .align ALIGNARG(4) + ASM_TYPE_DIRECTIVE(infinity,@object) +inf_zero: +infinity: + .byte 0, 0, 0, 0, 0, 0, 0xf0, 0x7f + ASM_SIZE_DIRECTIVE(infinity) + ASM_TYPE_DIRECTIVE(zero,@object) +zero: .double 0.0 + ASM_SIZE_DIRECTIVE(zero) + ASM_TYPE_DIRECTIVE(minf_mzero,@object) +minf_mzero: +minfinity: + .byte 0, 0, 0, 0, 0, 0, 0xf0, 0xff +mzero: + .byte 0, 0, 0, 0, 0, 0, 0, 0x80 + ASM_SIZE_DIRECTIVE(minf_mzero) ASM_TYPE_DIRECTIVE(one,@object) one: .double 1.0 ASM_SIZE_DIRECTIVE(one) ASM_TYPE_DIRECTIVE(limit,@object) limit: .double 0.29 ASM_SIZE_DIRECTIVE(limit) + ASM_TYPE_DIRECTIVE(nan,@object) +nan: .byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f + ASM_SIZE_DIRECTIVE(nan) #ifdef PIC #define MO(op) op##@GOTOFF(%ecx) +#define MOX(op,x,f) op##@GOTOFF(%ecx,x,f) #else #define MO(op) op +#define MOX(op,x,f) op(,x,f) #endif .text ENTRY(__ieee754_powl) - fldt 4(%esp) // x - fldt 16(%esp) // y : x + fldt 16(%esp) // y + fxam + fnstsw + movb %ah, %dl + andb $0x45, %ah + cmpb $0x40, %ah // is y == 0 ? + je 11f + + cmpb $0x05, %ah // is y == ±inf ? + je 12f + + cmpb $0x01, %ah // is y == NaN ? + je 30f #ifdef PIC call 1f 1: popl %ecx addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ecx #endif + + fldt 4(%esp) // x : y + subl $8,%esp + fxam + fnstsw + movb %ah, %dh + andb $0x45, %ah + cmpb $0x40, %ah + je 20f // x is ±0 + + cmpb $0x05, %ah + je 15f // x is ±inf + + fxch // y : x + /* First see whether `y' is a natural number. In this case we can use a more precise algorithm. */ fld %st // y : y : x @@ -63,13 +109,11 @@ ENTRY(__ieee754_powl) jne 2f /* OK, we have an integer value for y. */ - ftst // y : x - fstp %st(0) // x - fnstsw - sahf popl %eax popl %edx - jnc 4f // y >= 0, jump + orl $0, %edx + fstp %st(0) // x + jns 4f // y >= 0, jump fdivrl MO(one) // 1/x (now referred to as x) negl %eax adcl $0, %edx @@ -87,7 +131,7 @@ ENTRY(__ieee754_powl) orl %edx, %ecx jnz 6b fstp %st(0) // ST*x - ret +30: ret .align ALIGNARG(4) 2: /* y is a real number. */ @@ -117,4 +161,148 @@ ENTRY(__ieee754_powl) addl $8, %esp fstp %st(1) // 2^fract(y*log2(x))*2^int(y*log2(x)) ret + + + // pow(x,±0) = 1 + .align ALIGNARG(4) +11: fstp %st(0) // pop y + fldl MO(one) + ret + + // y == ±inf + .align ALIGNARG(4) +12: fstp %st(0) // pop y + fldt 4(%esp) // x + fabs + fcompl MO(one) // < 1, == 1, or > 1 + fnstsw + andb $0x45, %ah + cmpb $0x45, %ah + je 13f // jump if x is NaN + + cmpb $0x40, %ah + je 14f // jump if |x| == 1 + + shlb $1, %ah + xorb %ah, %dl + andl $2, %edx + fldl MOX(inf_zero, %edx, 4) + ret + + .align ALIGNARG(4) +14: fldl MO(nan) + faddl MO(zero) // raise invalid exception + ret + + .align ALIGNARG(4) +13: fldt 4(%esp) // load x == NaN + ret + + .align ALIGNARG(4) + // x is ±inf +15: fstp %st(0) // y + testb $2, %dh + jz 16f // jump if x == +inf + + // We must find out whether y is an odd integer. + fld %st // y : y + fistpll (%esp) // y + fildll (%esp) // int(y) : y + fucompp // <empty> + fnstsw + sahf + jne 17f + + // OK, the value is an integer, but is it odd? + popl %eax + popl %edx + andb $1, %al + jz 18f // jump if not odd + // It's an odd integer. + shrl $31, %edx + fldl MOX(minf_mzero, %edx, 8) + ret + + .align ALIGNARG(4) +16: fcompl MO(zero) + addl $8, %esp + fnstsw + shrl $5, %eax + andl $8, %eax + fldl MOX(inf_zero, %eax, 1) + ret + + .align ALIGNARG(4) +17: shll $30, %edx // sign bit for y in right position + addl $8, %esp +18: shrl $31, %edx + fldl MOX(inf_zero, %edx, 8) + ret + + .align ALIGNARG(4) + // x is ±0 +20: fstp %st(0) // y + testb $2, %dl + jz 21f // y > 0 + + // x is ±0 and y is < 0. We must find out whether y is an odd integer. + testb $2, %dh + jz 25f + + fld %st // y : y + fistpll (%esp) // y + fildll (%esp) // int(y) : y + fucompp // <empty> + fnstsw + sahf + jne 26f + + // OK, the value is an integer, but is it odd? + popl %eax + popl %edx + andb $1, %al + jz 27f // jump if not odd + // It's an odd integer. + // Raise divide-by-zero exception and get minus infinity value. + fldl MO(one) + fdivl MO(zero) + fchs + ret + +25: fstp %st(0) +26: popl %eax + popl %edx +27: // Raise divide-by-zero exception and get infinity value. + fldl MO(one) + fdivl MO(zero) + ret + + .align ALIGNARG(4) + // x is ±0 and y is > 0. We must find out whether y is an odd integer. +21: testb $2, %dh + jz 22f + + fld %st // y : y + fistpll (%esp) // y + fildll (%esp) // int(y) : y + fucompp // <empty> + fnstsw + sahf + jne 23f + + // OK, the value is an integer, but is it odd? + popl %eax + popl %edx + andb $1, %al + jz 24f // jump if not odd + // It's an odd integer. + fldl MO(mzero) + ret + +22: fstp %st(0) +23: popl %eax + popl %edx +24: fldl MO(zero) + ret + END(__ieee754_powl) diff --git a/sysdeps/libm-i387/s_expm1.S b/sysdeps/libm-i387/s_expm1.S index 78e8013..e1b198d 100644 --- a/sysdeps/libm-i387/s_expm1.S +++ b/sysdeps/libm-i387/s_expm1.S @@ -30,9 +30,9 @@ .text #endif .align ALIGNARG(4) - ASM_TYPE_DIRECTIVE(zero,@object) -zero: .double 0.0 - ASM_SIZE_DIRECTIVE(zero) + ASM_TYPE_DIRECTIVE(minus1,@object) +minus1: .double -1.0 + ASM_SIZE_DIRECTIVE(minus1) ASM_TYPE_DIRECTIVE(one,@object) one: .double 1.0 ASM_SIZE_DIRECTIVE(one) @@ -79,7 +79,8 @@ ENTRY(__expm1) 2: testl $0x200, %eax // Test sign. jz 3f // If positive, jump. - fldl MO(zero) // Set result to 0. + fstp %st + fldl MO(minus1) // Set result to -1.0. 3: ret END(__expm1) weak_alias (__expm1, expm1) diff --git a/sysdeps/libm-i387/s_expm1f.S b/sysdeps/libm-i387/s_expm1f.S index 00f1562..8626fee 100644 --- a/sysdeps/libm-i387/s_expm1f.S +++ b/sysdeps/libm-i387/s_expm1f.S @@ -30,9 +30,9 @@ .text #endif .align ALIGNARG(4) - ASM_TYPE_DIRECTIVE(zero,@object) -zero: .double 0.0 - ASM_SIZE_DIRECTIVE(zero) + ASM_TYPE_DIRECTIVE(minus1,@object) +minus1: .double -1.0 + ASM_SIZE_DIRECTIVE(minus1) ASM_TYPE_DIRECTIVE(one,@object) one: .double 1.0 ASM_SIZE_DIRECTIVE(one) @@ -79,7 +79,8 @@ ENTRY(__expm1f) 2: testl $0x200, %eax // Test sign. jz 3f // If positive, jump. - fldl MO(zero) // Set result to 0. + fstp %st + fldl MO(minus1) // Set result to -1.0. 3: ret END(__expm1f) weak_alias (__expm1f, expm1f) diff --git a/sysdeps/libm-i387/s_expm1l.S b/sysdeps/libm-i387/s_expm1l.S index b7e6b36..46290ca 100644 --- a/sysdeps/libm-i387/s_expm1l.S +++ b/sysdeps/libm-i387/s_expm1l.S @@ -30,9 +30,9 @@ .text #endif .align ALIGNARG(4) - ASM_TYPE_DIRECTIVE(zero,@object) -zero: .double 0.0 - ASM_SIZE_DIRECTIVE(zero) + ASM_TYPE_DIRECTIVE(minus1,@object) +minus1: .double -1.0 + ASM_SIZE_DIRECTIVE(minus1) ASM_TYPE_DIRECTIVE(one,@object) one: .double 1.0 ASM_SIZE_DIRECTIVE(one) @@ -79,7 +79,8 @@ ENTRY(__expm1l) 2: testl $0x200, %eax // Test sign. jz 3f // If positive, jump. - fldl MO(zero) // Set result to 0. + fstp %st + fldl MO(minus1) // Set result to -1.0. 3: ret END(__expm1l) weak_alias (__expm1l, expm1l) diff --git a/sysdeps/libm-i387/s_isinfl.c b/sysdeps/libm-i387/s_isinfl.c index 3ee53d5..f07898f 100644 --- a/sysdeps/libm-i387/s_isinfl.c +++ b/sysdeps/libm-i387/s_isinfl.c @@ -10,7 +10,7 @@ static char rcsid[] = "$NetBSD: $"; #endif /* - * isinfl(x) returns 1 is x is inf, else 0; + * isinfl(x) returns 1 if x is inf, -1 if x is -inf, else 0; * no branching! */ @@ -26,11 +26,11 @@ static char rcsid[] = "$NetBSD: $"; { int32_t se,hx,lx; GET_LDOUBLE_WORDS(se,hx,lx,x); - se &= 0x7fff; - se ^= 0x7fff; /* This additional ^ 0x80000000 is necessary because in Intel's - internal representation the implicit one is explicit. */ - se |= (hx ^ 0x80000000) | lx; - return (se == 0); + internal representation of the implicit one is explicit. */ + lx |= (hx ^ 0x80000000) | ((se & 0x7fff) ^ 0x7fff); + lx |= -lx; + se &= 0x8000; + return ~(lx >> 31) & (1 - (se >> 14)); } weak_alias (__isinfl, isinfl) diff --git a/sysdeps/libm-i387/s_logbl.S b/sysdeps/libm-i387/s_logbl.S index 6ce274c..5c9a9c1 100644 --- a/sysdeps/libm-i387/s_logbl.S +++ b/sysdeps/libm-i387/s_logbl.S @@ -11,6 +11,7 @@ RCSID("$NetBSD: $") ENTRY(__logbl) fldt 4(%esp) fxtract + fstp %st ret END (__logbl) weak_alias (__logbl, logbl) diff --git a/sysdeps/libm-i387/s_scalbn.S b/sysdeps/libm-i387/s_scalbn.S index 3ec56d4..709b7a4 100644 --- a/sysdeps/libm-i387/s_scalbn.S +++ b/sysdeps/libm-i387/s_scalbn.S @@ -11,6 +11,7 @@ ENTRY(__scalbn) fildl 12(%esp) fldl 4(%esp) fscale + fstp %st(1) ret END (__scalbn) weak_alias (__scalbn, scalbn) diff --git a/sysdeps/libm-i387/s_scalbnf.S b/sysdeps/libm-i387/s_scalbnf.S index b1a1c46..ce92113 100644 --- a/sysdeps/libm-i387/s_scalbnf.S +++ b/sysdeps/libm-i387/s_scalbnf.S @@ -11,6 +11,7 @@ ENTRY(__scalbnf) fildl 8(%esp) flds 4(%esp) fscale + fstp %st(1) ret END (__scalbnf) weak_alias (__scalbnf, scalbnf) diff --git a/sysdeps/libm-i387/s_scalbnl.S b/sysdeps/libm-i387/s_scalbnl.S index 0f33238..09e0645 100644 --- a/sysdeps/libm-i387/s_scalbnl.S +++ b/sysdeps/libm-i387/s_scalbnl.S @@ -12,6 +12,7 @@ ENTRY(__scalbnl) fildl 16(%esp) fldt 4(%esp) fscale + fstp %st(1) ret END (__scalbnl) weak_alias (__scalbnl, scalbnl) diff --git a/sysdeps/libm-ieee754/e_atan2l.c b/sysdeps/libm-ieee754/e_atan2l.c new file mode 100644 index 0000000..6b76f96 --- /dev/null +++ b/sysdeps/libm-ieee754/e_atan2l.c @@ -0,0 +1,136 @@ +/* e_atan2l.c -- long double version of e_atan2.c. + * Conversion to long double by Ulrich Drepper, + * Cygnus Support, drepper@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* __ieee754_atan2l(y,x) + * Method : + * 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x). + * 2. Reduce x to positive by (if x and y are unexceptional): + * ARG (x+iy) = arctan(y/x) ... if x > 0, + * ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0, + * + * Special cases: + * + * ATAN2((anything), NaN ) is NaN; + * ATAN2(NAN , (anything) ) is NaN; + * ATAN2(+-0, +(anything but NaN)) is +-0 ; + * ATAN2(+-0, -(anything but NaN)) is +-pi ; + * ATAN2(+-(anything but 0 and NaN), 0) is +-pi/2; + * ATAN2(+-(anything but INF and NaN), +INF) is +-0 ; + * ATAN2(+-(anything but INF and NaN), -INF) is +-pi; + * ATAN2(+-INF,+INF ) is +-pi/4 ; + * ATAN2(+-INF,-INF ) is +-3pi/4; + * ATAN2(+-INF, (anything but,0,NaN, and INF)) is +-pi/2; + * + * 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 long double +#else +static long double +#endif +tiny = 1.0e-4900L, +zero = 0.0, +pi_o_4 = 7.85398163397448309628202E-01L, /* 0x3FFE, 0xC90FDAA2, 0x2168C235 */ +pi_o_2 = 1.5707963267948966192564E+00L, /* 0x3FFF, 0xC90FDAA2, 0x2168C235 */ +pi = 3.14159265358979323851281E+00L, /* 0x4000, 0xC90FDAA2, 0x2168C235 */ +pi_lo = -5.01655761266833202345176e-20L;/* 0xBFBE, 0xECE675D1, 0xFC8F8CBB */ + +#ifdef __STDC__ + long double __ieee754_atan2l(long double y, long double x) +#else + long double __ieee754_atan2l(y,x) + long double y,x; +#endif +{ + long double z; + int32_t k,m,hx,hy,ix,iy; + u_int32_t sx,sy,lx,ly; + + EXTRACT_LDOUBLE_WORDS(sx,hx,lx,x); + ix = sx&0x7fff; + lx |= hx ^ 0x80000000; + EXTRACT_LDOUBLE_WORDS(sy,hy,ly,y); + iy = sy&0x7fff; + ly |= hy ^ 0x80000000; + if(((2*ix|((lx|-lx)>>31))>0xfffe)|| + ((2*iy|((ly|-ly)>>31))>0xfffe)) /* x or y is NaN */ + return x+y; + if((sx-0x3fff|lx)==0) return __atanl(y); /* x=1.0 */ + m = ((sy>>15)&1)|((sx>>14)&2); /* 2*sign(x)+sign(y) */ + + /* when y = 0 */ + if((iy|ly)==0) { + switch(m) { + case 0: + case 1: return y; /* atan(+-0,+anything)=+-0 */ + case 2: return pi+tiny;/* atan(+0,-anything) = pi */ + case 3: return -pi-tiny;/* atan(-0,-anything) =-pi */ + } + } + /* when x = 0 */ + if((ix|lx)==0) return (sy>=0x8000)? -pi_o_2-tiny: pi_o_2+tiny; + + /* when x is INF */ + if(ix==0x7fff) { + if(iy==0x7fff) { + switch(m) { + case 0: return pi_o_4+tiny;/* atan(+INF,+INF) */ + case 1: return -pi_o_4-tiny;/* atan(-INF,+INF) */ + case 2: return 3.0*pi_o_4+tiny;/*atan(+INF,-INF)*/ + case 3: return -3.0*pi_o_4-tiny;/*atan(-INF,-INF)*/ + } + } else { + switch(m) { + case 0: return zero ; /* atan(+...,+INF) */ + case 1: return -zero ; /* atan(-...,+INF) */ + case 2: return pi+tiny ; /* atan(+...,-INF) */ + case 3: return -pi-tiny ; /* atan(-...,-INF) */ + } + } + } + /* when y is INF */ + if(iy==0x7fff) return (hy>=0x8000)? -pi_o_2-tiny: pi_o_2+tiny; + + /* compute y/x */ + k = sy-sx; + if(k > 70) z=pi_o_2+0.5*pi_lo; /* |y/x| > 2**70 */ + else if(sx>=0x8000&&k<-70) z=0.0; /* |y|/x < -2**70 */ + else z=__atanl(fabsl(y/x)); /* safe to do y/x */ + switch (m) { + case 0: return z ; /* atan(+,+) */ + case 1: { + u_int32_t sz; + GET_LDOUBLE_EXP(sz,z); + SET_LDOUBLE_EXP(z,sy ^ 0x8000); + } + return z ; /* atan(-,+) */ + case 2: return pi-(z-pi_lo);/* atan(+,-) */ + default: /* case 3 */ + return (z-pi_lo)-pi;/* atan(-,-) */ + } +} diff --git a/sysdeps/libm-ieee754/s_fpclassifyl.c b/sysdeps/libm-ieee754/s_fpclassifyl.c index ef37e6f..d7a0e94 100644 --- a/sysdeps/libm-ieee754/s_fpclassifyl.c +++ b/sysdeps/libm-ieee754/s_fpclassifyl.c @@ -30,6 +30,7 @@ __fpclassifyl (long double x) int retval = FP_NORMAL; GET_LDOUBLE_WORDS (ex, hx, lx, x); + hx &= 0x7fffffff; hx |= lx; ex &= 0x7fff; if ((ex | hx) == 0) diff --git a/sysdeps/libm-ieee754/s_isinf.c b/sysdeps/libm-ieee754/s_isinf.c index b35fc1c..d3c2cb5 100644 --- a/sysdeps/libm-ieee754/s_isinf.c +++ b/sysdeps/libm-ieee754/s_isinf.c @@ -1,5 +1,6 @@ /* * Written by J.T. Conklin <jtc@netbsd.org>. + * Changed to return -1 for -Inf by Ulrich Drepper <drepper@cygnus.com>. * Public domain. */ @@ -8,7 +9,7 @@ static char rcsid[] = "$NetBSD: s_isinf.c,v 1.3 1995/05/11 23:20:14 jtc Exp $"; #endif /* - * isinf(x) returns 1 is x is inf, else 0; + * isinf(x) returns 1 is x is inf, -1 if x is -inf, else 0; * no branching! */ @@ -22,12 +23,12 @@ static char rcsid[] = "$NetBSD: s_isinf.c,v 1.3 1995/05/11 23:20:14 jtc Exp $"; double x; #endif { - int32_t hx,lx; + u_int32_t hx; + int32_t lx; EXTRACT_WORDS(hx,lx,x); - hx &= 0x7fffffff; - hx ^= 0x7ff00000; - hx |= lx; - return (hx == 0); + lx |= (hx & 0x7fffffff) ^ 0x7ff00000; + lx |= -lx; + return ~(lx >> 31) & (1 - ((hx >> 30) & 2)); } weak_alias (__isinf, isinf) #ifdef NO_LONG_DOUBLE diff --git a/sysdeps/libm-ieee754/s_isinff.c b/sysdeps/libm-ieee754/s_isinff.c index 1d81f15..9acc0df 100644 --- a/sysdeps/libm-ieee754/s_isinff.c +++ b/sysdeps/libm-ieee754/s_isinff.c @@ -8,7 +8,7 @@ static char rcsid[] = "$NetBSD: s_isinff.c,v 1.3 1995/05/11 23:20:21 jtc Exp $"; #endif /* - * isinff(x) returns 1 is x is inf, else 0; + * isinff(x) returns 1 if x is inf, -1 if x is -inf, else 0; * no branching! */ @@ -22,10 +22,11 @@ static char rcsid[] = "$NetBSD: s_isinff.c,v 1.3 1995/05/11 23:20:21 jtc Exp $"; float x; #endif { - int32_t ix; + int32_t ix,t; GET_FLOAT_WORD(ix,x); - ix &= 0x7fffffff; - ix ^= 0x7f800000; - return (ix == 0); + t = ix & 0x7fffffff; + t ^= 0x7f800000; + t |= -t; + return ~(t >> 31) & (1 - ((ix & 0x80000000) >> 30)); } weak_alias (__isinff, isinff) diff --git a/sysdeps/libm-ieee754/s_isinfl.c b/sysdeps/libm-ieee754/s_isinfl.c index 22dff75..b499821 100644 --- a/sysdeps/libm-ieee754/s_isinfl.c +++ b/sysdeps/libm-ieee754/s_isinfl.c @@ -9,7 +9,7 @@ static char rcsid[] = "$NetBSD: $"; #endif /* - * isinfl(x) returns 1 is x is inf, else 0; + * isinfl(x) returns 1 if x is inf, -1 if x is -inf, else 0; * no branching! */ @@ -25,9 +25,9 @@ static char rcsid[] = "$NetBSD: $"; { int32_t se,hx,lx; GET_LDOUBLE_WORDS(se,hx,lx,x); - se &= 0x7fff; - se ^= 0x7fff; - se |= hx | lx; - return (se == 0); + hx |= lx | ((se & 0x7fff) ^ 0x7fff); + hx |= -hx; + se &= 0x8000; + return ~(hx >> 31) & (1 - (se >> 14)); } weak_alias (__isinfl, isinfl) diff --git a/sysdeps/libm-ieee754/s_scalbnl.c b/sysdeps/libm-ieee754/s_scalbnl.c index d00eb88..6825e9c 100644 --- a/sysdeps/libm-ieee754/s_scalbnl.c +++ b/sysdeps/libm-ieee754/s_scalbnl.c @@ -33,10 +33,10 @@ static const long double #else static long double #endif -two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ -twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */ -huge = 1.0e+300, -tiny = 1.0e-300; +two54 = 1.80143985094819840000e+16, /* 0x4035, 0x00000000, 0x00000000 */ +twom54 = 5.55111512312578270212e-17, /* 0x3FC9, 0x00000000, 0x00000000 */ +huge = 1.0e+4900L, +tiny = 1.0e-4900L; #ifdef __STDC__ long double __scalbnl (long double x, int n) diff --git a/sysdeps/libm-ieee754/w_atan2.c b/sysdeps/libm-ieee754/w_atan2.c index ec29d55..3f6032f 100644 --- a/sysdeps/libm-ieee754/w_atan2.c +++ b/sysdeps/libm-ieee754/w_atan2.c @@ -34,11 +34,10 @@ static char rcsid[] = "$NetBSD: w_atan2.c,v 1.6 1995/05/10 20:48:39 jtc Exp $"; #else double z; z = __ieee754_atan2(y,x); - if(_LIB_VERSION == _IEEE_||__isnan(x)||__isnan(y)) return z; + if(_LIB_VERSION != _SVID_||__isnan(x)||__isnan(y)) return z; if(x==0.0&&y==0.0) { - return __kernel_standard(y,x,3); /* atan2(+-0,+-0) */ - } else - return z; + return __kernel_standard(y,x,3); /* atan2(+-0,+-0) */ + return z; #endif } weak_alias (__atan2, atan2) diff --git a/sysdeps/libm-ieee754/w_atan2f.c b/sysdeps/libm-ieee754/w_atan2f.c index 4d67638..00b2ce7 100644 --- a/sysdeps/libm-ieee754/w_atan2f.c +++ b/sysdeps/libm-ieee754/w_atan2f.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. * ==================================================== */ @@ -17,7 +17,7 @@ static char rcsid[] = "$NetBSD: w_atan2f.c,v 1.3 1995/05/10 20:48:42 jtc Exp $"; #endif -/* +/* * wrapper atan2f(y,x) */ @@ -38,11 +38,7 @@ static char rcsid[] = "$NetBSD: w_atan2f.c,v 1.3 1995/05/10 20:48:42 jtc Exp $"; float z; z = __ieee754_atan2f(y,x); if(_LIB_VERSION == _IEEE_||__isnanf(x)||__isnanf(y)) return z; - if(x==(float)0.0&&y==(float)0.0) { - /* atan2f(+-0,+-0) */ - return (float)__kernel_standard((double)y,(double)x,103); - } else - return z; + return z; #endif } weak_alias (__atan2f, atan2f) diff --git a/sysdeps/libm-ieee754/w_atan2l.c b/sysdeps/libm-ieee754/w_atan2l.c index 9e6e56b..437a04c 100644 --- a/sysdeps/libm-ieee754/w_atan2l.c +++ b/sysdeps/libm-ieee754/w_atan2l.c @@ -39,10 +39,7 @@ static char rcsid[] = "$NetBSD: $"; long double z; z = __ieee754_atan2l(y,x); if(_LIB_VERSION == _IEEE_||__isnanl(x)||__isnanl(y)) return z; - if(x==0.0&&y==0.0) { - return __kernel_standard(y,x,203); /* atan2l(+-0,+-0) */ - } else - return z; + return z; #endif } weak_alias (__atan2l, atan2l) diff --git a/sysdeps/libm-ieee754/w_pow.c b/sysdeps/libm-ieee754/w_pow.c index ea19e1f..1711d71 100644 --- a/sysdeps/libm-ieee754/w_pow.c +++ b/sysdeps/libm-ieee754/w_pow.c @@ -43,7 +43,10 @@ if(y==0.0) return __kernel_standard(x,y,20); /* pow(0.0,0.0) */ if(__finite(y)&&y<0.0) - return __kernel_standard(x,y,23); /* pow(0.0,negative) */ + if (signbit (x) && signbit (z)) + return __kernel_standard(x,y,23); /* pow(-0.0,negative) */ + else + return __kernel_standard(x,y,43); /* pow(+0.0,negative) */ return z; } if(!__finite(z)) { diff --git a/sysdeps/libm-ieee754/w_powf.c b/sysdeps/libm-ieee754/w_powf.c index 3f9d5c8..0b20822 100644 --- a/sysdeps/libm-ieee754/w_powf.c +++ b/sysdeps/libm-ieee754/w_powf.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. * ==================================================== */ @@ -17,7 +17,7 @@ static char rcsid[] = "$NetBSD: w_powf.c,v 1.3 1995/05/10 20:49:41 jtc Exp $"; #endif -/* +/* * wrapper powf(x,y) return x**y */ @@ -39,19 +39,22 @@ static char rcsid[] = "$NetBSD: w_powf.c,v 1.3 1995/05/10 20:49:41 jtc Exp $"; z=__ieee754_powf(x,y); if(_LIB_VERSION == _IEEE_|| __isnanf(y)) return z; if(__isnanf(x)) { - if(y==(float)0.0) + if(y==(float)0.0) /* powf(NaN,0.0) */ return (float)__kernel_standard((double)x,(double)y,142); - else + else return z; } - if(x==(float)0.0){ + if(x==(float)0.0){ if(y==(float)0.0) /* powf(0.0,0.0) */ return (float)__kernel_standard((double)x,(double)y,120); if(__finitef(y)&&y<(float)0.0) + if (signbit (x) && signbit (z)) /* powf(0.0,negative) */ return (float)__kernel_standard((double)x,(double)y,123); + else + return (float)__kernel_standard((double)x,(double)y,143); return z; } if(!__finitef(z)) { @@ -59,11 +62,11 @@ static char rcsid[] = "$NetBSD: w_powf.c,v 1.3 1995/05/10 20:49:41 jtc Exp $"; if(__isnanf(z)) /* powf neg**non-int */ return (float)__kernel_standard((double)x,(double)y,124); - else + else /* powf overflow */ return (float)__kernel_standard((double)x,(double)y,121); } - } + } if(z==(float)0.0&&__finitef(x)&&__finitef(y)) /* powf underflow */ return (float)__kernel_standard((double)x,(double)y,122); diff --git a/sysdeps/libm-ieee754/w_powl.c b/sysdeps/libm-ieee754/w_powl.c index 019664e..aea572d 100644 --- a/sysdeps/libm-ieee754/w_powl.c +++ b/sysdeps/libm-ieee754/w_powl.c @@ -45,7 +45,10 @@ if(y==0.0) return __kernel_standard(x,y,220); /* pow(0.0,0.0) */ if(__finite(y)&&y<0.0) - return __kernel_standard(x,y,223); /* pow(0.0,negative) */ + if (signbit (x) && signbit (z)) + return __kernel_standard(x,y,223); /* pow(-0.0,negative) */ + else + return __kernel_standard(x,y,243); /* pow(+0.0,negative) */ return z; } if(!__finitel(z)) { diff --git a/sysdeps/m68k/huge_val.h b/sysdeps/m68k/huge_val.h new file mode 100644 index 0000000..c213958 --- /dev/null +++ b/sysdeps/m68k/huge_val.h @@ -0,0 +1,92 @@ +/* `HUGE_VAL' constants for m68k (where it is infinity). + Used by <stdlib.h> and <math.h> functions for overflow. + Copyright (C) 1992, 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _HUGE_VAL_H +#define _HUGE_VAL_H 1 + +#include <features.h> +#include <sys/cdefs.h> +#include <endian.h> + +/* IEEE positive infinity (-HUGE_VAL is negative infinity). */ + +#if __BYTE_ORDER == __BIG_ENDIAN +#define __HUGE_VAL_bytes { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } +#endif +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define __HUGE_VAL_bytes { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } +#endif + +#define __huge_val_t union { unsigned char __c[8]; double __d; } +#ifdef __GNUC__ +#define HUGE_VAL (__extension__ \ + ((__huge_val_t) { __c: __HUGE_VAL_bytes }).__d) +#else /* Not GCC. */ +static __huge_val_t __huge_val = { __HUGE_VAL_bytes }; +#define HUGE_VAL (__huge_val.__d) +#endif /* GCC. */ + + +/* ISO C 9X extensions: (float) HUGE_VALF and (long double) HUGE_VALL. */ + +#ifdef __USE_ISOC9X + +#if __BYTE_ORDER == __BIG_ENDIAN +#define __HUGE_VALF_bytes { 0x7f, 0x80, 0, 0 } +#endif +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define __HUGE_VALF_bytes { 0, 0, 0x80, 0x7f } +#endif + +#define __huge_valf_t union { unsigned char __c[4]; float __f; } +#ifdef __GNUC__ +#define HUGE_VALF (__extension__ \ + ((__huge_valf_t) { __c: __HUGE_VALF_bytes }).__f) +#else /* Not GCC. */ +static __huge_valf_t __huge_valf = { __HUGE_VALF_bytes }; +#define HUGE_VALF (__huge_valf.__f) +#endif /* GCC. */ + + +#if __BYTE_ORDER == __BIG_ENDIAN +#define __HUGE_VALL_bytes { 0x7f, 0xff, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0 } +#endif +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define __HUGE_VALL_bytes { 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0x7f, 0, 0 } +#endif + +#define __huge_vall_t union { unsigned char __c[12]; long double __ld; } +#ifdef __GNUC__ +#define HUGE_VALL (__extension__ \ + ((__huge_vall_t) { __c: __HUGE_VALL_bytes }).__ld) +#else /* Not GCC. */ +static __huge_vall_t __huge_vall = { __HUGE_VALL_bytes }; +#define HUGE_VALL (__huge_vall.__ld) +#endif /* GCC. */ + + +/* Expression representing positive infinity. Here it is the same as + HUGE_VALF. */ +#define INFINITY HUGE_VALF + +#endif /* __USE_ISOC9X. */ + + +#endif /* huge_val.h */ diff --git a/sysdeps/mach/hurd/euidaccess.c b/sysdeps/mach/hurd/euidaccess.c index bbd2d21..d206b86 100644 --- a/sysdeps/mach/hurd/euidaccess.c +++ b/sysdeps/mach/hurd/euidaccess.c @@ -1,5 +1,5 @@ /* Test for access to FILE using effective UID and GID. Hurd version. -Copyright (C) 1991, 1995 Free Software Foundation, Inc. +Copyright (C) 1991, 1995, 1997 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 @@ -24,7 +24,7 @@ Cambridge, MA 02139, USA. */ #include <hurd.h> int -euidaccess (file, type) +__euidaccess (file, type) const char *file; int type; { @@ -56,3 +56,4 @@ euidaccess (file, type) return 0; } +weak_alias (__euidaccess, euidaccess) diff --git a/sysdeps/posix/isfdtype.c b/sysdeps/posix/isfdtype.c index 8edcf59..ec4568e 100644 --- a/sysdeps/posix/isfdtype.c +++ b/sysdeps/posix/isfdtype.c @@ -1,25 +1,26 @@ -/* isfdtype - Determine whether descriptor has given property. -Copyright (C) 1996 Free Software Foundation, Inc. -This file is part of the GNU C Library. +/* Determine whether descriptor has given property. + Copyright (C) 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. + The GNU C Library is 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. + 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. */ + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include <errno.h> #include <sys/stat.h> #include <sys/socket.h> +#include <sys/types.h> int isfdtype (int fildes, int fdtype) @@ -33,5 +34,5 @@ isfdtype (int fildes, int fdtype) __set_errno (save_error); } - return result ?: (st.st_mode & S_IFMT) == fdtype; + return result ?: (st.st_mode & S_IFMT) == (mode_t) fdtype; } diff --git a/sysdeps/sparc/dl-machine.h b/sysdeps/sparc/dl-machine.h index 5240b0c..6f1d7eb 100644 --- a/sysdeps/sparc/dl-machine.h +++ b/sysdeps/sparc/dl-machine.h @@ -98,8 +98,8 @@ elf_machine_load_address (void) MAP is the object containing the reloc. */ static inline void -elf_machine_rela (struct link_map *map, - const Elf32_Rela *reloc, const Elf32_Sym *sym) +elf_machine_rela (struct link_map *map, const Elf32_Rela *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; @@ -107,31 +107,31 @@ elf_machine_rela (struct link_map *map, switch (ELF32_R_TYPE (reloc->r_info)) { case R_SPARC_COPY: - loadbase = RESOLVE (&sym, DL_LOOKUP_NOEXEC); + 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, 0); + 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, DL_LOOKUP_NOPLT); + loadbase = RESOLVE (&sym, version, DL_LOOKUP_NOPLT); { Elf32_Addr value = ((sym ? (loadbase + sym->st_value) : 0) + reloc->r_addend); - reloc_addr[1] = OPCODE_SETHI | (value >> 10); + reloc_addr[1] = OPCODE_SETHI_G1 | (value >> 10); reloc_addr[2] = OPCODE_JMP_G1 | (value & 0x3ff); } break; case R_SPARC_8: - loadbase = RESOLVE (&sym, 0); + 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, 0); + loadbase = RESOLVE (&sym, version, 0); *(short *) reloc_addr = ((sym ? (loadbase + sym->st_value) : 0) + reloc->r_addend); break; @@ -139,19 +139,19 @@ elf_machine_rela (struct link_map *map, *reloc_addr += map->l_addr + reloc->r_addend; break; case R_SPARC_DISP8: - loadbase = RESOLVE (&sym, 0); + 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, (Elf32_Addr) reloc_addr, 0); + 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, 0); + loadbase = RESOLVE (&sym, version, 0); *reloc_addr = ((sym ? (loadbase + sym->st_value) : 0) + reloc->r_addend - (Elf32_Addr) reloc_addr); @@ -160,17 +160,27 @@ elf_machine_rela (struct link_map *map, { unsigned int saddr; - loadbase = RESOLVE (&sym, 0); + loadbase = RESOLVE (&sym, version, 0); saddr = (loadbase ? loadbase : map->l_addr) + reloc->r_addend; *reloc_addr = (*reloc_addr & ~0x3ff) | (saddr & 0x3ff); } 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, 0); + loadbase = RESOLVE (&sym, version, 0); saddr = (loadbase ? loadbase : map->l_addr) + reloc->r_addend; *reloc_addr = (*reloc_addr & 0xffc00000)|(saddr >> 10); @@ -199,9 +209,7 @@ elf_machine_lazy_rel (struct link_map *map, const Elf32_Rela *reloc) } } -#define ELF_ADJUST_ARG(arg) __asm__("\tadd %%fp,64,%0\n" : "=r" (arg)) - -#endif /* RESOLV */ +#endif /* RESOLVE */ /* Nonzero iff TYPE describes relocation of a PLT entry, so PLT entries should not be allowed to define the value. */ @@ -285,8 +293,49 @@ _dl_runtime_resolve: .globl _start\n\ .type _start,@function\n\ _start:\n\ + /* Pass pointer to argument block to _dl_start. */\n\ + add %sp,64,%o0\n\ call _dl_start\n\ - nop\n\ - call %o0\n\ + nop\n\ + \n\ + mov %o0,%l0\n\ + \n\ +2:\n\ + call 1f\n\ + nop\n\ +1:\n\ + sethi %hi(_GLOBAL_OFFSET_TABLE_-(2b-.)),%l2\n\ + sethi %hi(_dl_default_scope),%l3\n\ + or %l2,%lo(_GLOBAL_OFFSET_TABLE_-(2b-.)),%l2\n\ + or %l3,%lo(_dl_default_scope),%l3\n\ + add %o7,%l2,%l1\n\ + # %l1 has the GOT. %l3 has _dl_default_scope offset\n\ + # Now, load _dl_default_scope [2]\n\ + add %l3,4,%l3\n\ + ld [%l1+%l3],%l4\n\ + # %l4 has _dl_default_scope [2]\n\ + # call _dl_init_next until it returns 0, pass _dl_default_scope [2]\n\ +3:\n\ + call _dl_init_next\n\ + mov %l4,%o0\n\ + cmp %o0,%g0\n\ + bz,a 4f\n\ + nop\n\ + call %o0\n\ + nop\n\ + b,a 3b\n\ +4:\n\ + # Clear the _dl_starting_up variable and pass _dl_fini in %g1 as per ELF ABI.\n\ + sethi %hi(_dl_starting_up),%l4\n\ + sethi %hi(_dl_fini),%l3\n\ + or %l4,%lo(_dl_starting_up),%l4\n\ + or %l3,%lo(_dl_fini),%l3\n\ + # clear _dl_starting_up\n\ + ld [%l1+%l4],%l5\n\ + st %g0,[%l5]\n\ + # load out fini function for atexit in %g1\n\ + ld [%l3+%l1],%g1\n\ + # jump to the user program entry point.\n\ + jmpl %l0,%g0\n\ nop\n\ "); diff --git a/sysdeps/sparc/elf/Makefile b/sysdeps/sparc/elf/Makefile new file mode 100644 index 0000000..319fbde --- /dev/null +++ b/sysdeps/sparc/elf/Makefile @@ -0,0 +1,4 @@ +# Sparc/ELF specific definitions. + +# The assembler on SPARC needs the -fPIC flag even when it's assembler code. +ASFLAGS-.so = -fPIC diff --git a/sysdeps/sparc/elf/start.c b/sysdeps/sparc/elf/start.c new file mode 100644 index 0000000..f9c97f8 --- /dev/null +++ b/sysdeps/sparc/elf/start.c @@ -0,0 +1,68 @@ +/* Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <stdlib.h> +#include <unistd.h> +#include <fcntl.h> + +extern char **__environ; + +extern void __libc_init_first __P ((int argc, char **argv, char **envp)); +extern int main __P ((int argc, char **argv, char **envp)); + +register long int sp asm("%sp"), fp asm("%fp"); + +void +_start (void) +{ + /* It is important that these be declared `register'. + Otherwise, when compiled without optimization, they are put on the + stack, which loses completely after we zero the FP. */ + register int argc; + register char **argv, **envp; + register long int g1 asm ("%g1"); + unsigned long int copy_g1 = g1; + + /* Unwind the frame built when we entered the function. */ + asm("restore"); + if (copy_g1) + atexit (copy_g1); + + /* And clear the frame pointer. */ + fp = 0; + + /* The argument info starts after one register + window (64 bytes) past the SP. */ + argc = ((int *) sp)[16]; + argv = (char **) &((int *) sp)[17]; + envp = &argv[argc + 1]; + __environ = envp; + + /* Allocate 24 bytes of stack space for the register save area. */ + sp -= 24; + __libc_init_first (argc, argv, envp); +#ifdef ELF_INIT_FINI + { + extern void _fini (void); + atexit (_fini); + _init (); + } +#endif + exit (main (argc, argv, envp)); +} diff --git a/sysdeps/stub/fcntlbits.h b/sysdeps/stub/fcntlbits.h index 2365201..48237f5 100644 --- a/sysdeps/stub/fcntlbits.h +++ b/sysdeps/stub/fcntlbits.h @@ -1,21 +1,21 @@ /* O_*, F_*, FD_* bit values for stub configuration. -Copyright (C) 1991, 1992 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ + Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ /* These values should be changed as appropriate for your system. */ diff --git a/sysdeps/unix/bsd/bsd4.4/fcntlbits.h b/sysdeps/unix/bsd/bsd4.4/fcntlbits.h index bb61392..3ab2bf0 100644 --- a/sysdeps/unix/bsd/bsd4.4/fcntlbits.h +++ b/sysdeps/unix/bsd/bsd4.4/fcntlbits.h @@ -1,21 +1,21 @@ /* O_*, F_*, FD_* bit values for 4.4 BSD. -Copyright (C) 1991, 1992 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ + Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #ifndef _FCNTLBITS_H diff --git a/sysdeps/unix/bsd/fcntlbits.h b/sysdeps/unix/bsd/fcntlbits.h index dd8b2a9..1e87a37 100644 --- a/sysdeps/unix/bsd/fcntlbits.h +++ b/sysdeps/unix/bsd/fcntlbits.h @@ -1,21 +1,21 @@ /* O_*, F_*, FD_* bit values for 4.3 BSD. -Copyright (C) 1991, 1992 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ + Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #ifndef _FCNTLBITS_H diff --git a/sysdeps/unix/bsd/sun/sunos4/fcntlbits.h b/sysdeps/unix/bsd/sun/sunos4/fcntlbits.h index 2100722..a9f66c4 100644 --- a/sysdeps/unix/bsd/sun/sunos4/fcntlbits.h +++ b/sysdeps/unix/bsd/sun/sunos4/fcntlbits.h @@ -1,21 +1,21 @@ /* O_*, F_*, FD_* bit values for SunOS 4. -Copyright (C) 1991, 1992 Free Software Foundation, Inc. -This file is part of the GNU C Library. + Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. + The GNU C Library is 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. + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ + 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. */ #ifndef _FCNTLBITS_H @@ -33,7 +33,7 @@ Cambridge, MA 02139, USA. */ #define O_EXCL 0x0800 /* Fail if file already exists. */ #define O_TRUNC 0x0400 /* Truncate file to zero length. */ #define O_NOCTTY 0x8000 /* Don't assign a controlling terminal. */ -#if defined (__USE_BSD) || defined (__USE_SVID) +#if defined __USE_BSD || defined __USE_SVID #define O_ASYNC 0x0040 /* Send SIGIO to owner when data is ready. */ #define O_FSYNC 0x2000 /* Synchronous writes. */ #define O_SYNC O_FSYNC diff --git a/sysdeps/unix/bsd/ultrix4/fcntlbits.h b/sysdeps/unix/bsd/ultrix4/fcntlbits.h index bf8e7b2..ba736e4 100644 --- a/sysdeps/unix/bsd/ultrix4/fcntlbits.h +++ b/sysdeps/unix/bsd/ultrix4/fcntlbits.h @@ -1,21 +1,21 @@ /* O_*, F_*, FD_* bit values for Ultrix 4. -Copyright (C) 1991, 1992 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ + Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #ifndef _FCNTLBITS_H diff --git a/sysdeps/unix/common/fcntlbits.h b/sysdeps/unix/common/fcntlbits.h index 0f84433..e416e0d 100644 --- a/sysdeps/unix/common/fcntlbits.h +++ b/sysdeps/unix/common/fcntlbits.h @@ -1,21 +1,21 @@ -/* O_*, F_*, FD_* bit values for SVR4 and Irix 4. -Copyright (C) 1991, 1992, 1995 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ +/* O_*, F_*, FD_* bit values for general Unix system. + Copyright (C) 1991, 1992, 1995, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #ifndef _FCNTLBITS_H diff --git a/sysdeps/unix/readdir_r.c b/sysdeps/unix/readdir_r.c index fca3eee..fa26db6 100644 --- a/sysdeps/unix/readdir_r.c +++ b/sysdeps/unix/readdir_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 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 @@ -33,13 +33,12 @@ int __readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result) { struct dirent *dp; + size_t reclen; __libc_lock_lock (dirp->lock); do { - size_t reclen; - if (dirp->offset >= dirp->size) { /* We've emptied out our buffer. Refill it. */ @@ -60,6 +59,7 @@ __readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result) if (bytes <= 0) { dp = NULL; + reclen = 0; break; } dirp->size = (size_t) bytes; @@ -97,7 +97,7 @@ __readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result) if (dp != NULL) { - *entry = *dp; + memcpy (entry, dp, reclen); *result = entry; } diff --git a/sysdeps/unix/sysv/fcntlbits.h b/sysdeps/unix/sysv/fcntlbits.h index d049014..7f38422 100644 --- a/sysdeps/unix/sysv/fcntlbits.h +++ b/sysdeps/unix/sysv/fcntlbits.h @@ -32,8 +32,9 @@ #define O_CREAT 00400 /* Create file if it doesn't exist. */ #define O_EXCL 02000 /* Fail if file already exists. */ #define O_TRUNC 01000 /* Truncate file to zero length. */ -#if defined (__USE_BSD) || defined (__USE_SVID) +#if defined __USE_BSD || defined __USE_SVID #define O_SYNC 00020 /* Synchronous writes. */ +#define O_FSYNC O_SYNC #endif /* File status flags for `open' and `fcntl'. */ @@ -83,4 +84,13 @@ struct flock #define F_UNLCK 3 /* Remove lock. */ +/* Define some more compatibility macros to be backward compatible with + BSD systems which did not managed to hide these kernel macros. */ +#ifdef __USE_BSD +#define FAPPEND O_APPEND +#define FFSYNC O_FSYNC +#define FNONBLOCK O_NONBLOCK +#define FNDELAY O_NDELAY +#endif /* Use BSD. */ + #endif /* fcntlbits.h */ diff --git a/sysdeps/unix/sysv/irix4/fcntlbits.h b/sysdeps/unix/sysv/irix4/fcntlbits.h index a8bb776..318e483 100644 --- a/sysdeps/unix/sysv/irix4/fcntlbits.h +++ b/sysdeps/unix/sysv/irix4/fcntlbits.h @@ -1,21 +1,21 @@ /* O_*, F_*, FD_* bit values for SGI Irix 4. -Copyright (C) 1994 Free Software Foundation, Inc. -This file is part of the GNU C Library. + Copyright (C) 1994, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. + The GNU C Library is 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. + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ + 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. */ #ifndef _FCNTLBITS_H @@ -34,6 +34,7 @@ Cambridge, MA 02139, USA. */ #define O_TRUNC 01000 /* Truncate file to zero length. */ #ifdef __USE_MISC #define O_SYNC 00020 /* Synchronous writes. */ +#define O_FSYNC O_SYNC #define O_ASYNC 00100 /* Send SIGIO to owner when data is ready. */ #endif @@ -95,4 +96,15 @@ struct flock #define F_UNLCK 3 /* Remove lock. */ +/* Define some more compatibility macros to be backward compatible with + BSD systems which did not managed to hide these kernel macros. */ +#ifdef __USE_BSD +#define FAPPEND O_APPEND +#define FFSYNC O_FSYNC +#define FASYNC O_ASYNC +#define FNONBLOCK O_NONBLOCK +#define FNDELAY O_NDELAY +#endif /* Use BSD. */ + + #endif /* fcntlbits.h */ diff --git a/sysdeps/unix/sysv/linux/Dist b/sysdeps/unix/sysv/linux/Dist index 9c41e50..7b94300 100644 --- a/sysdeps/unix/sysv/linux/Dist +++ b/sysdeps/unix/sysv/linux/Dist @@ -1,6 +1,7 @@ cmsg_nxthdr.c init-first.h kernel_sigaction.h +kernel_stat.h llseek.c siglist.h sysctl.c diff --git a/sysdeps/unix/sysv/linux/alpha/Dist b/sysdeps/unix/sysv/linux/alpha/Dist index 344ffa5..80fca49 100644 --- a/sysdeps/unix/sysv/linux/alpha/Dist +++ b/sysdeps/unix/sysv/linux/alpha/Dist @@ -4,6 +4,7 @@ ioperm.c init-first.h clone.S kernel_sigaction.h +kernel_stat.h sys/io.h sys/acct.h sys/kernel_termios.h diff --git a/sysdeps/unix/sysv/linux/alpha/fcntlbits.h b/sysdeps/unix/sysv/linux/alpha/fcntlbits.h index e8697d9..faf1983 100644 --- a/sysdeps/unix/sysv/linux/alpha/fcntlbits.h +++ b/sysdeps/unix/sysv/linux/alpha/fcntlbits.h @@ -23,6 +23,12 @@ #include <sys/types.h> +/* In GNU, read and write are bits (unlike BSD). */ +#ifdef __USE_GNU +#define O_READ O_RDONLY /* Open for reading. */ +#define O_WRITE O_WRONLY /* Open for writing. */ +#define O_NORW 0 /* Open without R/W access. */ +#endif /* open/fcntl - O_SYNC is only implemented on blocks devices and on files located on an ext2 file system */ #define O_ACCMODE 0003 @@ -38,7 +44,8 @@ #define O_APPEND 00010 #define O_NDELAY O_NONBLOCK #define O_SYNC 040000 -#define FASYNC 020000 /* fcntl, for BSD compatibility */ +#define O_FSYNC O_SYNC +#define O_ASYNC 020000 /* fcntl, for BSD compatibility */ #define F_DUPFD 0 /* dup */ #define F_GETFD 1 /* get f_flags */ @@ -86,6 +93,7 @@ struct flock #ifdef __USE_BSD #define FAPPEND O_APPEND #define FFSYNC O_FSYNC +#define FASYNC O_ASYNC #define FNONBLOCK O_NONBLOCK #define FNDELAY O_NDELAY #endif /* Use BSD. */ diff --git a/sysdeps/unix/sysv/linux/alpha/kernel_stat.h b/sysdeps/unix/sysv/linux/alpha/kernel_stat.h new file mode 100644 index 0000000..7109677 --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/kernel_stat.h @@ -0,0 +1,19 @@ +/* Definition of `struct stat' used in the kernel.. */ +struct kernel_stat + { + unsigned int st_dev; + unsigned int st_ino; + unsigned int st_mode; + unsigned int st_nlink; + unsigned int st_uid; + unsigned int st_gid; + unsigned int st_rdev; + long int st_size; + unsigned long int st_atime; + unsigned long int st_mtime; + unsigned long int st_ctime; + unsigned int st_blksize; + int st_blocks; + unsigned int st_flags; + unsigned int st_gen; + }; diff --git a/sysdeps/unix/sysv/linux/alpha/statbuf.h b/sysdeps/unix/sysv/linux/alpha/statbuf.h index 92c9df7..207fa0c 100644 --- a/sysdeps/unix/sysv/linux/alpha/statbuf.h +++ b/sysdeps/unix/sysv/linux/alpha/statbuf.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1996 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997 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 @@ -19,30 +19,30 @@ #ifndef _STATBUF_H #define _STATBUF_H 1 -/* The Alpha has no additional syscall versions. */ - /* Versions of the `struct stat' data structure. */ -#define _STAT_VER 0 +#define _STAT_VER_LINUX_OLD 0 +#define _STAT_VER_LINUX 1 +#define _STAT_VER _STAT_VER_LINUX /* Versions of the `xmknod' interface. */ #define _MKNOD_VER_LINUX 0 struct stat { - unsigned int st_dev; /* Device. */ - unsigned int st_ino; /* File serial number. */ - unsigned int st_mode; /* File mode. */ - unsigned int st_nlink; /* Link count. */ - unsigned int st_uid; /* User ID of the file's owner. */ - unsigned int st_gid; /* Group ID of the file's group.*/ - unsigned int st_rdev; /* Device number, if device. */ - long int st_size; /* Size of file, in bytes. */ - unsigned long int st_atime; /* Time of last access. */ - unsigned long int st_mtime; /* Time of last modification. */ - unsigned long int st_ctime; /* Time of last status change. */ - unsigned int st_blksize; /* Optimal block size for I/O. */ -#define _STATBUF_ST_BLKSIZE /* Tell code we have this member. */ - int st_blocks; /* Nr. of 512-byte blocks allocated. */ + __dev_t st_dev; /* Device. */ + __ino_t st_ino; /* File serial number. */ + __mode_t st_mode; /* File mode. */ + __nlink_t st_nlink; /* Link count. */ + __uid_t st_uid; /* User ID of the file's owner. */ + __gid_t st_gid; /* Group ID of the file's group.*/ + __dev_t st_rdev; /* Device number, if device. */ + __off_t st_size; /* Size of file, in bytes. */ + __time_t st_atime; /* Time of last access. */ + __time_t st_mtime; /* Time of last modification. */ + __time_t st_ctime; /* Time of last status change. */ + unsigned int st_blksize; /* Optimal block size for I/O. */ +#define _STATBUF_ST_BLKSIZE /* Tell code we have this member. */ + int st_blocks; /* Nr. of 512-byte blocks allocated. */ unsigned int st_flags; unsigned int st_gen; }; diff --git a/sysdeps/unix/sysv/linux/fcntlbits.h b/sysdeps/unix/sysv/linux/fcntlbits.h index d7e889f..fdc67ce 100644 --- a/sysdeps/unix/sysv/linux/fcntlbits.h +++ b/sysdeps/unix/sysv/linux/fcntlbits.h @@ -23,6 +23,12 @@ #include <sys/types.h> +/* In GNU, read and write are bits (unlike BSD). */ +#ifdef __USE_GNU +#define O_READ O_RDONLY /* Open for reading. */ +#define O_WRITE O_WRONLY /* Open for writing. */ +#define O_NORW 0 /* Open without R/W access. */ +#endif /* open/fcntl - O_SYNC is only implemented on blocks devices and on files located on an ext2 file system */ #define O_ACCMODE 0003 @@ -37,7 +43,8 @@ #define O_NONBLOCK 04000 #define O_NDELAY O_NONBLOCK #define O_SYNC 010000 -#define FASYNC 020000 /* fcntl, for BSD compatibility */ +#define O_FSYNC O_SYNC +#define O_ASYNC 020000 #define F_DUPFD 0 /* dup */ #define F_GETFD 1 /* get f_flags */ @@ -85,6 +92,7 @@ struct flock #ifdef __USE_BSD #define FAPPEND O_APPEND #define FFSYNC O_FSYNC +#define FASYNC O_ASYNC #define FNONBLOCK O_NONBLOCK #define FNDELAY O_NDELAY #endif /* Use BSD. */ diff --git a/sysdeps/unix/sysv/linux/fxstat.c b/sysdeps/unix/sysv/linux/fxstat.c new file mode 100644 index 0000000..1032187 --- /dev/null +++ b/sysdeps/unix/sysv/linux/fxstat.c @@ -0,0 +1,92 @@ +/* fxstat using old-style Unix fstat system call. + Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <stddef.h> +#include <sys/stat.h> + +#include "kernel_stat.h" + +extern int __syscall_fstat (int, struct kernel_stat *); + +/* Get information about the file descriptor FD in BUF. */ +int +__fxstat (int vers, int fd, struct stat *buf) +{ + struct kernel_stat kbuf; + int result; + + switch (vers) + { + case _STAT_VER_LINUX_OLD: + /* Nothing to do. The struct is in the form the kernel expects + it to be. */ + result = __syscall_fstat (fd, (struct kernel_stat *) buf); + break; + + case _STAT_VER_LINUX: + /* Do the system call. */ + result = __syscall_fstat (fd, &kbuf); + + /* Convert to current kernel version of `struct stat'. */ + buf->st_dev = kbuf.st_dev; +#ifdef _HAVE___PAD1 + buf->__pad1 = 0; +#endif + buf->st_ino = kbuf.st_ino; + buf->st_mode = kbuf.st_mode; + buf->st_nlink = kbuf.st_nlink; + buf->st_uid = kbuf.st_uid; + buf->st_gid = kbuf.st_gid; + buf->st_rdev = kbuf.st_rdev; +#ifdef _HAVE___PAD2 + buf->__pad2 = 0; +#endif + buf->st_size = kbuf.st_size; + buf->st_blksize = kbuf.st_blksize; + buf->st_blocks = kbuf.st_blocks; + buf->st_atime = kbuf.st_atime; +#ifdef _HAVE___UNUSED1 + buf->__unused1 = 0; +#endif + buf->st_mtime = kbuf.st_mtime; +#ifdef _HAVE___UNUSED2 + buf->__unused2 = 0; +#endif + buf->st_ctime = kbuf.st_ctime; +#ifdef _HAVE___UNUSED3 + buf->__unused3 = 0; +#endif +#ifdef _HAVE___UNUSED4 + buf->__unused4 = 0; +#endif +#ifdef _HAVE___UNUSED5 + buf->__unused5 = 0; +#endif + break; + + default: + __set_errno (EINVAL); + result = -1; + break; + } + + return result; +} +weak_alias (__fxstat, _fxstat) diff --git a/sysdeps/unix/sysv/linux/init-first.h b/sysdeps/unix/sysv/linux/init-first.h index dd4f85a..a9df8da 100644 --- a/sysdeps/unix/sysv/linux/init-first.h +++ b/sysdeps/unix/sysv/linux/init-first.h @@ -1,3 +1,22 @@ +/* Prepare arguments for library initialization function. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + /* The job of this fragment it to find argc and friends for INIT. This is done in one of two ways: either in the stack context of program start, or having dlopen pass them in. */ @@ -7,7 +26,7 @@ void NAME (void *arg) \ { \ int argc; \ char **argv, **envp; \ - /* The next variable is only here to work around a bug in gcc <= 2.7.2.1. \ + /* The next variable is only here to work around a bug in gcc <= 2.7.2.2. \ If the address would be taken inside the expression the optimizer \ would try to be too smart and throws it away. Grrr. */ \ int *dummy_addr = &_dl_starting_up; \ diff --git a/sysdeps/unix/sysv/linux/kernel_stat.h b/sysdeps/unix/sysv/linux/kernel_stat.h new file mode 100644 index 0000000..bd7ddcc --- /dev/null +++ b/sysdeps/unix/sysv/linux/kernel_stat.h @@ -0,0 +1,31 @@ +/* Definition of `struct stat' used in the kernel.. */ +struct kernel_stat + { + unsigned short int st_dev; + unsigned short int __pad1; +#define _HAVE___PAD1 + unsigned long int st_ino; + unsigned short int st_mode; + unsigned short int st_nlink; + unsigned short int st_uid; + unsigned short int st_gid; + unsigned short int st_rdev; + unsigned short int __pad2; +#define _HAVE___PAD2 + unsigned long int st_size; + unsigned long int st_blksize; + unsigned long int st_blocks; + unsigned long int st_atime; + unsigned long int __unused1; +#define _HAVE___UNUSED1 + unsigned long int st_mtime; + unsigned long int __unused2; +#define _HAVE___UNUSED2 + unsigned long int st_ctime; + unsigned long int __unused3; +#define _HAVE___UNUSED3 + unsigned long int __unused4; +#define _HAVE___UNUSED4 + unsigned long int __unused5; +#define _HAVE___UNUSED5 + }; diff --git a/sysdeps/unix/sysv/linux/lxstat.c b/sysdeps/unix/sysv/linux/lxstat.c new file mode 100644 index 0000000..713490c --- /dev/null +++ b/sysdeps/unix/sysv/linux/lxstat.c @@ -0,0 +1,92 @@ +/* lxstat using old-style Unix fstat system call. + Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <stddef.h> +#include <sys/stat.h> + +#include "kernel_stat.h" + +extern int __syscall_lstat (const char *, struct kernel_stat *); + +/* Get information about the file NAME in BUF. */ +int +__lxstat (int vers, const char *name, struct stat *buf) +{ + struct kernel_stat kbuf; + int result; + + switch (vers) + { + case _STAT_VER_LINUX_OLD: + /* Nothing to do. The struct is in the form the kernel expects + it to be. */ + result = __syscall_lstat (name, (struct kernel_stat *) buf); + break; + + case _STAT_VER_LINUX: + /* Do the system call. */ + result = __syscall_lstat (name, &kbuf); + + /* Convert to current kernel version of `struct stat'. */ + buf->st_dev = kbuf.st_dev; +#ifdef _HAVE___PAD1 + buf->__pad1 = 0; +#endif + buf->st_ino = kbuf.st_ino; + buf->st_mode = kbuf.st_mode; + buf->st_nlink = kbuf.st_nlink; + buf->st_uid = kbuf.st_uid; + buf->st_gid = kbuf.st_gid; + buf->st_rdev = kbuf.st_rdev; +#ifdef _HAVE___PAD2 + buf->__pad2 = 0; +#endif + buf->st_size = kbuf.st_size; + buf->st_blksize = kbuf.st_blksize; + buf->st_blocks = kbuf.st_blocks; + buf->st_atime = kbuf.st_atime; +#ifdef _HAVE___UNUSED1 + buf->__unused1 = 0; +#endif + buf->st_mtime = kbuf.st_mtime; +#ifdef _HAVE___UNUSED2 + buf->__unused2 = 0; +#endif + buf->st_ctime = kbuf.st_ctime; +#ifdef _HAVE___UNUSED3 + buf->__unused3 = 0; +#endif +#ifdef _HAVE___UNUSED4 + buf->__unused4 = 0; +#endif +#ifdef _HAVE___UNUSED5 + buf->__unused5 = 0; +#endif + break; + + default: + __set_errno (EINVAL); + result = -1; + break; + } + + return result; +} +weak_alias (__lxstat, _lxstat) diff --git a/sysdeps/unix/sysv/linux/net/if_ppp.h b/sysdeps/unix/sysv/linux/net/if_ppp.h index 2765254..567dcce 100644 --- a/sysdeps/unix/sysv/linux/net/if_ppp.h +++ b/sysdeps/unix/sysv/linux/net/if_ppp.h @@ -1 +1,157 @@ -#include <linux/if_ppp.h> +/* From: if_ppp.h,v 1.3 1995/06/12 11:36:50 paulus Exp */ + +/* + * if_ppp.h - Point-to-Point Protocol definitions. + * + * Copyright (c) 1989 Carnegie Mellon University. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by Carnegie Mellon University. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +/* + * ==FILEVERSION 960926== + * + * NOTE TO MAINTAINERS: + * If you modify this file at all, please set the above date. + * if_ppp.h is shipped with a PPP distribution as well as with the kernel; + * if everyone increases the FILEVERSION number above, then scripts + * can do the right thing when deciding whether to install a new if_ppp.h + * file. Don't change the format of that line otherwise, so the + * installation script can recognize it. + */ + + +#ifndef __NET_IF_PPP_H +#define __NET_IF_PPP_H 1 + +#include <sys/types.h> +#include <sys/cdefs.h> + +#include <net/if.h> +#include <sys/ioctl.h> +#include <net/ppp_defs.h> + +__BEGIN_DECLS + +/* + * Packet sizes + */ + +#define PPP_MTU 1500 /* Default MTU (size of Info field) */ +#define PPP_MAXMRU 65000 /* Largest MRU we allow */ +#define PPP_VERSION "2.3.0" +#define PPP_MAGIC 0x5002 /* Magic value for the ppp structure */ +#define PROTO_IPX 0x002b /* protocol numbers */ +#define PROTO_DNA_RT 0x0027 /* DNA Routing */ + + +/* + * Bit definitions for flags. + */ + +#define SC_COMP_PROT 0x00000001 /* protocol compression (output) */ +#define SC_COMP_AC 0x00000002 /* header compression (output) */ +#define SC_COMP_TCP 0x00000004 /* TCP (VJ) compression (output) */ +#define SC_NO_TCP_CCID 0x00000008 /* disable VJ connection-id comp. */ +#define SC_REJ_COMP_AC 0x00000010 /* reject adrs/ctrl comp. on input */ +#define SC_REJ_COMP_TCP 0x00000020 /* reject TCP (VJ) comp. on input */ +#define SC_CCP_OPEN 0x00000040 /* Look at CCP packets */ +#define SC_CCP_UP 0x00000080 /* May send/recv compressed packets */ +#define SC_ENABLE_IP 0x00000100 /* IP packets may be exchanged */ +#define SC_COMP_RUN 0x00001000 /* compressor has been inited */ +#define SC_DECOMP_RUN 0x00002000 /* decompressor has been inited */ +#define SC_DEBUG 0x00010000 /* enable debug messages */ +#define SC_LOG_INPKT 0x00020000 /* log contents of good pkts recvd */ +#define SC_LOG_OUTPKT 0x00040000 /* log contents of pkts sent */ +#define SC_LOG_RAWIN 0x00080000 /* log all chars received */ +#define SC_LOG_FLUSH 0x00100000 /* log all chars flushed */ +#define SC_MASK 0x0fE0ffff /* bits that user can change */ + +/* state bits */ +#define SC_ESCAPED 0x80000000 /* saw a PPP_ESCAPE */ +#define SC_FLUSH 0x40000000 /* flush input until next PPP_FLAG */ +#define SC_VJ_RESET 0x20000000 /* Need to reset the VJ decompressor */ +#define SC_XMIT_BUSY 0x10000000 /* ppp_write_wakeup is active */ +#define SC_RCV_ODDP 0x08000000 /* have rcvd char with odd parity */ +#define SC_RCV_EVNP 0x04000000 /* have rcvd char with even parity */ +#define SC_RCV_B7_1 0x02000000 /* have rcvd char with bit 7 = 1 */ +#define SC_RCV_B7_0 0x01000000 /* have rcvd char with bit 7 = 0 */ +#define SC_DC_FERROR 0x00800000 /* fatal decomp error detected */ +#define SC_DC_ERROR 0x00400000 /* non-fatal decomp error detected */ + +/* + * Ioctl definitions. + */ + +struct npioctl { + int protocol; /* PPP protocol, e.g. PPP_IP */ + enum NPmode mode; +}; + +/* Structure describing a CCP configuration option, for PPPIOCSCOMPRESS */ +struct ppp_option_data { + u_int8_t *ptr; + u_int32_t length; + int transmit; +}; + +struct ifpppstatsreq { + struct ifreq b; + struct ppp_stats stats; /* statistic information */ +}; + +struct ifpppcstatsreq { + struct ifreq b; + struct ppp_comp_stats stats; +}; + +#define ifr__name b.ifr_ifrn.ifrn_name +#define stats_ptr b.ifr_ifru.ifru_data + +/* + * Ioctl definitions. + */ + +#define PPPIOCGFLAGS _IOR('t', 90, int) /* get configuration flags */ +#define PPPIOCSFLAGS _IOW('t', 89, int) /* set configuration flags */ +#define PPPIOCGASYNCMAP _IOR('t', 88, int) /* get async map */ +#define PPPIOCSASYNCMAP _IOW('t', 87, int) /* set async map */ +#define PPPIOCGUNIT _IOR('t', 86, int) /* get ppp unit number */ +#define PPPIOCGRASYNCMAP _IOR('t', 85, int) /* get receive async map */ +#define PPPIOCSRASYNCMAP _IOW('t', 84, int) /* set receive async map */ +#define PPPIOCGMRU _IOR('t', 83, int) /* get max receive unit */ +#define PPPIOCSMRU _IOW('t', 82, int) /* set max receive unit */ +#define PPPIOCSMAXCID _IOW('t', 81, int) /* set VJ max slot ID */ +#define PPPIOCGXASYNCMAP _IOR('t', 80, ext_accm) /* get extended ACCM */ +#define PPPIOCSXASYNCMAP _IOW('t', 79, ext_accm) /* set extended ACCM */ +#define PPPIOCXFERUNIT _IO('t', 78) /* transfer PPP unit */ +#define PPPIOCSCOMPRESS _IOW('t', 77, struct ppp_option_data) +#define PPPIOCGNPMODE _IOWR('t', 76, struct npioctl) /* get NP mode */ +#define PPPIOCSNPMODE _IOW('t', 75, struct npioctl) /* set NP mode */ +#define PPPIOCGDEBUG _IOR('t', 65, int) /* Read debug level */ +#define PPPIOCSDEBUG _IOW('t', 64, int) /* Set debug level */ +#define PPPIOCGIDLE _IOR('t', 63, struct ppp_idle) /* get idle time */ + +#define SIOCGPPPSTATS (SIOCDEVPRIVATE + 0) +#define SIOCGPPPVER (SIOCDEVPRIVATE + 1) /* NEVER change this!! */ +#define SIOCGPPPCSTATS (SIOCDEVPRIVATE + 2) + +#if !defined(ifr_mtu) +#define ifr_mtu ifr_ifru.ifru_metric +#endif + +__END_DECLS + +#endif /* net/if_ppp.h */ diff --git a/sysdeps/unix/sysv/linux/net/ppp_defs.h b/sysdeps/unix/sysv/linux/net/ppp_defs.h index dfd40e1..5d613e0 100644 --- a/sysdeps/unix/sysv/linux/net/ppp_defs.h +++ b/sysdeps/unix/sysv/linux/net/ppp_defs.h @@ -1,8 +1,7 @@ #ifndef _NET_PPP_DEFS_H #define _NET_PPP_DEFS_H 1 -#include <sys/types.h> -typedef u_int32_t __u32; +#include <asm/types.h> #include <linux/ppp_defs.h> #endif /* net/ppp_defs.h */ diff --git a/sysdeps/unix/sysv/linux/netinet/ip.h b/sysdeps/unix/sysv/linux/netinet/ip.h index c779db4..89c2b1d 100644 --- a/sysdeps/unix/sysv/linux/netinet/ip.h +++ b/sysdeps/unix/sysv/linux/netinet/ip.h @@ -26,62 +26,65 @@ __BEGIN_DECLS -struct timestamp { - u_int8_t len; - u_int8_t ptr; +struct timestamp + { + u_int8_t len; + u_int8_t ptr; #if __BYTE_ORDER == __LITTLE_ENDIAN - u_int8_t flags:4, - overflow:4; + u_int8_t flags:4; + u_int8_t overflow:4; #elif __BYTE_ORDER == __BIG_ENDIAN - u_int8_t overflow:4, - flags:4; + u_int8_t overflow:4; + u_int8_t flags:4; #else #error "Please fix <bytesex.h>" -#endif - u_int32_t data[9]; -}; - -struct ip_options { - u_int32_t faddr; /* Saved first hop address */ - u_int8_t optlen; - u_int8_t srr; - u_int8_t rr; - u_int8_t ts; - u_int8_t is_setbyuser:1, /* Set by setsockopt? */ - is_data:1, /* Options in __data, rather than skb */ - is_strictroute:1, /* Strict source route */ - srr_is_hit:1, /* Packet destination addr was our one */ - is_changed:1, /* IP checksum more not valid */ - rr_needaddr:1, /* Need to record addr of outgoing dev */ - ts_needtime:1, /* Need to record timestamp */ - ts_needaddr:1; /* Need to record addr of outgoing dev */ - u_int8_t router_alert; - u_int8_t __pad1; - u_int8_t __pad2; - u_int8_t __data[0]; -}; - -struct iphdr { +#endif + u_int32_t data[9]; + }; + +struct ip_options + { + u_int32_t faddr; /* Saved first hop address */ + u_int8_t optlen; + u_int8_t srr; + u_int8_t rr; + u_int8_t ts; + u_int8_t is_setbyuser:1; /* Set by setsockopt? */ + u_int8_t is_data:1; /* Options in __data, rather than skb */ + u_int8_t is_strictroute:1; /* Strict source route */ + u_int8_t srr_is_hit:1; /* Packet destination addr was our one */ + u_int8_t is_changed:1; /* IP checksum more not valid */ + u_int8_t rr_needaddr:1; /* Need to record addr of outgoing dev */ + u_int8_t ts_needtime:1; /* Need to record timestamp */ + u_int8_t ts_needaddr:1; /* Need to record addr of outgoing dev */ + u_int8_t router_alert; + u_int8_t __pad1; + u_int8_t __pad2; + u_int8_t __data[0]; + }; + +struct iphdr + { #if __BYTE_ORDER == __LITTLE_ENDIAN - u_int8_t ihl:4, - version:4; + u_int8_t ihl:4; + u_int8_t version:4; #elif __BYTE_ORDER == __BIG_ENDIAN - u_int8_t version:4, - ihl:4; + u_int8_t version:4; + u_int8_t ihl:4; #else #error "Please fix <bytesex.h>" #endif - u_int8_t tos; - u_int16_t tot_len; - u_int16_t id; - u_int16_t frag_off; - u_int8_t ttl; - u_int8_t protocol; - u_int16_t check; - u_int32_t saddr; - u_int32_t daddr; - /*The options start here. */ -}; + u_int8_t tos; + u_int16_t tot_len; + u_int16_t id; + u_int16_t frag_off; + u_int8_t ttl; + u_int8_t protocol; + u_int16_t check; + u_int32_t saddr; + u_int32_t daddr; + /*The options start here. */ + }; #ifdef __USE_BSD /* @@ -127,46 +130,48 @@ struct iphdr { /* * Structure of an internet header, naked of options. */ -struct ip { +struct ip + { #if __BYTE_ORDER == __LITTLE_ENDIAN - u_int8_t ip_hl:4, /* header length */ - ip_v:4; /* version */ + u_int8_t ip_hl:4; /* header length */ + u_int8_t ip_v:4; /* version */ #endif #if __BYTE_ORDER == __BIG_ENDIAN - u_int8_t ip_v:4, /* version */ - ip_hl:4; /* header length */ + u_int8_t ip_v:4; /* version */ + u_int8_t ip_hl:4; /* header length */ #endif - u_int8_t ip_tos; /* type of service */ - u_short ip_len; /* total length */ - u_short ip_id; /* identification */ - u_short ip_off; /* fragment offset field */ + u_int8_t ip_tos; /* type of service */ + u_short ip_len; /* total length */ + u_short ip_id; /* identification */ + u_short ip_off; /* fragment offset field */ #define IP_RF 0x8000 /* reserved fragment flag */ #define IP_DF 0x4000 /* dont fragment flag */ #define IP_MF 0x2000 /* more fragments flag */ #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ - u_int8_t ip_ttl; /* time to live */ - u_int8_t ip_p; /* protocol */ - u_short ip_sum; /* checksum */ - struct in_addr ip_src, ip_dst; /* source and dest address */ -}; + u_int8_t ip_ttl; /* time to live */ + u_int8_t ip_p; /* protocol */ + u_short ip_sum; /* checksum */ + struct in_addr ip_src, ip_dst; /* source and dest address */ + }; /* * Time stamp option structure. */ -struct ip_timestamp { - u_int8_t ipt_code; /* IPOPT_TS */ - u_int8_t ipt_len; /* size of structure (variable) */ - u_int8_t ipt_ptr; /* index of current entry */ +struct ip_timestamp + { + u_int8_t ipt_code; /* IPOPT_TS */ + u_int8_t ipt_len; /* size of structure (variable) */ + u_int8_t ipt_ptr; /* index of current entry */ #if __BYTE_ORDER == __LITTLE_ENDIAN - u_int8_t ipt_flg:4, /* flags, see below */ - ipt_oflw:4; /* overflow counter */ + u_int8_t ipt_flg:4, /* flags, see below */ + u_int8_t ipt_oflw:4; /* overflow counter */ #endif #if __BYTE_ORDER == __BIG_ENDIAN - u_int8_t ipt_oflw:4, /* overflow counter */ - ipt_flg:4; /* flags, see below */ + u_int8_t ipt_oflw:4, /* overflow counter */ + u_int8_t ipt_flg:4; /* flags, see below */ #endif - u_int32_t data[9]; -}; + u_int32_t data[9]; + }; #endif /* __USE_BSD */ #define IPVERSION 4 /* IP version number */ @@ -175,6 +180,8 @@ struct ip_timestamp { /* * Definitions for IP type of service (ip_tos) */ +#define IPTOS_TOS_MASK 0x1E +#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK) #define IPTOS_LOWDELAY 0x10 #define IPTOS_THROUGHPUT 0x08 #define IPTOS_RELIABILITY 0x04 @@ -184,6 +191,8 @@ struct ip_timestamp { /* * Definitions for IP precedence (also in ip_tos) (hopefully unused) */ +#define IPTOS_PREC_MASK 0xe0 +#define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK) #define IPTOS_PREC_NETCONTROL 0xe0 #define IPTOS_PREC_INTERNETCONTROL 0xc0 #define IPTOS_PREC_CRITIC_ECP 0xa0 @@ -196,24 +205,35 @@ struct ip_timestamp { /* * Definitions for options. */ -#define IPOPT_COPIED(o) ((o)&0x80) -#define IPOPT_CLASS(o) ((o)&0x60) -#define IPOPT_NUMBER(o) ((o)&0x1f) +#define IPOPT_COPY 0x80 +#define IPOPT_CLASS_MASK 0x60 +#define IPOPT_NUMBER_MASK 0x1f + +#define IPOPT_COPIED(o) ((o) & IPOPT_COPY) +#define IPOPT_CLASS(o) ((o) & IPOPT_CLASS_MASK) +#define IPOPT_NUMBER(o) ((o) & IPOPT_NUMBER_MASK) #define IPOPT_CONTROL 0x00 #define IPOPT_RESERVED1 0x20 #define IPOPT_DEBMEAS 0x40 +#define IPOPT_MEASUREMENT IPOPT_DEBMEAS #define IPOPT_RESERVED2 0x60 #define IPOPT_EOL 0 /* end of option list */ +#define IPOPT_END IPOPT_EOL #define IPOPT_NOP 1 /* no operation */ +#define IPOPT_NOOP IP_NOP #define IPOPT_RR 7 /* record packet route */ #define IPOPT_TS 68 /* timestamp */ +#define IPOPT_TIMESTAMP IPOPT_TS #define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ +#define IPOPT_SEC IPOPT_SECURITY #define IPOPT_LSRR 131 /* loose source route */ #define IPOPT_SATID 136 /* satnet id */ +#define IPOPT_SID IPOPT_SATID #define IPOPT_SSRR 137 /* strict source route */ +#define IPOPT_RA 148 /* router alert */ /* * Offsets to fields in options other than EOL and NOP. diff --git a/sysdeps/unix/sysv/linux/sparc/brk.c b/sysdeps/unix/sysv/linux/sparc/brk.c index 13bcb04..8f079bf 100644 --- a/sysdeps/unix/sysv/linux/sparc/brk.c +++ b/sysdeps/unix/sysv/linux/sparc/brk.c @@ -40,7 +40,7 @@ __brk (void *addr) "t 0x10\n\t" "mov %%o0, %0\n\t" : "=r" (newbrk) - : "0" (SYS_brk), "r" (addr) + : "0" (__NR_brk), "r" (addr) : "g1", "o0"); __curbrk = newbrk; diff --git a/sysdeps/unix/sysv/linux/statbuf.h b/sysdeps/unix/sysv/linux/statbuf.h index 39bbdc9..15ffe63 100644 --- a/sysdeps/unix/sysv/linux/statbuf.h +++ b/sysdeps/unix/sysv/linux/statbuf.h @@ -20,8 +20,9 @@ #define _STATBUF_H 1 /* Versions of the `struct stat' data structure. */ -#define _STAT_VER_LINUX 1 +#define _STAT_VER_LINUX_OLD 1 #define _STAT_VER_SVR4 2 +#define _STAT_VER_LINUX 3 #define _STAT_VER _STAT_VER_LINUX /* The one defined below. */ /* Versions of the `xmknod' interface. */ @@ -32,25 +33,25 @@ struct stat { - unsigned short int st_dev; /* Device. */ + __dev_t st_dev; /* Device. */ unsigned short int __pad1; - unsigned long int st_ino; /* File serial number. */ - unsigned short int st_mode; /* File mode. */ - unsigned short int st_nlink; /* Link count. */ - unsigned short int st_uid; /* User ID of the file's owner. */ - unsigned short int st_gid; /* Group ID of the file's group.*/ - unsigned short int st_rdev; /* Device number, if device. */ + __ino_t st_ino; /* File serial number. */ + __mode_t st_mode; /* File mode. */ + __nlink_t st_nlink; /* Link count. */ + __uid_t st_uid; /* User ID of the file's owner. */ + __gid_t st_gid; /* Group ID of the file's group.*/ + __dev_t st_rdev; /* Device number, if device. */ unsigned short int __pad2; - long int st_size; /* Size of file, in bytes. */ + __off_t st_size; /* Size of file, in bytes. */ unsigned long int st_blksize; /* Optimal block size for I/O. */ #define _STATBUF_ST_BLKSIZE /* Tell code we have this member. */ unsigned long int st_blocks; /* Number of 512-byte blocks allocated. */ - long int st_atime; /* Time of last access. */ + __time_t st_atime; /* Time of last access. */ unsigned long int __unused1; - long int st_mtime; /* Time of last modification. */ + __time_t st_mtime; /* Time of last modification. */ unsigned long int __unused2; - long int st_ctime; /* Time of last status change. */ + __time_t st_ctime; /* Time of last status change. */ unsigned long int __unused3; unsigned long int __unused4; unsigned long int __unused5; diff --git a/sysdeps/unix/sysv/linux/xstat.c b/sysdeps/unix/sysv/linux/xstat.c new file mode 100644 index 0000000..be49b9d --- /dev/null +++ b/sysdeps/unix/sysv/linux/xstat.c @@ -0,0 +1,92 @@ +/* xstat using old-style Unix fstat system call. + Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <errno.h> +#include <stddef.h> +#include <sys/stat.h> + +#include "kernel_stat.h" + +extern int __syscall_stat (const char *, struct kernel_stat *); + +/* Get information about the file NAME in BUF. */ +int +__xstat (int vers, const char *name, struct stat *buf) +{ + struct kernel_stat kbuf; + int result; + + switch (vers) + { + case _STAT_VER_LINUX_OLD: + /* Nothing to do. The struct is in the form the kernel expects + it to be. */ + result = __syscall_stat (name, (struct kernel_stat *) buf); + break; + + case _STAT_VER_LINUX: + /* Do the system call. */ + result = __syscall_stat (name, &kbuf); + + /* Convert to current kernel version of `struct stat'. */ + buf->st_dev = kbuf.st_dev; +#ifdef _HAVE___PAD1 + buf->__pad1 = 0; +#endif + buf->st_ino = kbuf.st_ino; + buf->st_mode = kbuf.st_mode; + buf->st_nlink = kbuf.st_nlink; + buf->st_uid = kbuf.st_uid; + buf->st_gid = kbuf.st_gid; + buf->st_rdev = kbuf.st_rdev; +#ifdef _HAVE___PAD2 + buf->__pad2 = 0; +#endif + buf->st_size = kbuf.st_size; + buf->st_blksize = kbuf.st_blksize; + buf->st_blocks = kbuf.st_blocks; + buf->st_atime = kbuf.st_atime; +#ifdef _HAVE___UNUSED1 + buf->__unused1 = 0; +#endif + buf->st_mtime = kbuf.st_mtime; +#ifdef _HAVE___UNUSED2 + buf->__unused2 = 0; +#endif + buf->st_ctime = kbuf.st_ctime; +#ifdef _HAVE___UNUSED3 + buf->__unused3 = 0; +#endif +#ifdef _HAVE___UNUSED4 + buf->__unused4 = 0; +#endif +#ifdef _HAVE___UNUSED5 + buf->__unused5 = 0; +#endif + break; + + default: + __set_errno (EINVAL); + result = -1; + break; + } + + return result; +} +weak_alias (__xstat, _xstat) |