From 13a0c712ba41b02bd67a8a891e54fe9e77823595 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Mon, 19 Mar 2001 20:13:39 +0000 Subject: Sync i386 up with _all_ the glibc 2.1.3 include/bits headers, since we will end up needing a few more of them anyways, and all the other arches have the full set anyways. -Erik --- libc/sysdeps/linux/i386/bits/cmathcalls.h | 157 ++++ libc/sysdeps/linux/i386/bits/dlfcn.h | 37 + libc/sysdeps/linux/i386/bits/elfclass.h | 11 + libc/sysdeps/linux/i386/bits/environments.h | 59 ++ libc/sysdeps/linux/i386/bits/errno.h | 60 ++ libc/sysdeps/linux/i386/bits/fenv.h | 90 ++ libc/sysdeps/linux/i386/bits/huge_val.h | 68 ++ libc/sysdeps/linux/i386/bits/libc-lock.h | 214 +++++ libc/sysdeps/linux/i386/bits/mathcalls.h | 336 ++++++++ libc/sysdeps/linux/i386/bits/mathdef.h | 47 ++ libc/sysdeps/linux/i386/bits/mathinline.h | 678 +++++++++++++++ libc/sysdeps/linux/i386/bits/mman.h | 75 ++ libc/sysdeps/linux/i386/bits/msq.h | 70 ++ libc/sysdeps/linux/i386/bits/nan.h | 48 ++ libc/sysdeps/linux/i386/bits/pthreadtypes.h | 122 +++ libc/sysdeps/linux/i386/bits/resource.h | 205 +++++ libc/sysdeps/linux/i386/bits/sched.h | 73 ++ libc/sysdeps/linux/i386/bits/sem.h | 88 ++ libc/sysdeps/linux/i386/bits/stab.def | 234 ++++++ libc/sysdeps/linux/i386/bits/statvfs.h | 94 +++ libc/sysdeps/linux/i386/bits/stdio-lock.h | 39 + libc/sysdeps/linux/i386/bits/stdio.h | 168 ++++ libc/sysdeps/linux/i386/bits/string.h | 876 +++++++++++++++++++ libc/sysdeps/linux/i386/bits/string2.h | 1214 +++++++++++++++++++++++++++ libc/sysdeps/linux/i386/bits/stropts.h | 219 +++++ libc/sysdeps/linux/i386/bits/ustat.h | 27 + libc/sysdeps/linux/i386/bits/utmp.h | 105 +++ libc/sysdeps/linux/i386/bits/utmpx.h | 86 ++ libc/sysdeps/linux/i386/bits/utsname.h | 29 + 29 files changed, 5529 insertions(+) create mode 100644 libc/sysdeps/linux/i386/bits/cmathcalls.h create mode 100644 libc/sysdeps/linux/i386/bits/dlfcn.h create mode 100644 libc/sysdeps/linux/i386/bits/elfclass.h create mode 100644 libc/sysdeps/linux/i386/bits/environments.h create mode 100644 libc/sysdeps/linux/i386/bits/errno.h create mode 100644 libc/sysdeps/linux/i386/bits/fenv.h create mode 100644 libc/sysdeps/linux/i386/bits/huge_val.h create mode 100644 libc/sysdeps/linux/i386/bits/libc-lock.h create mode 100644 libc/sysdeps/linux/i386/bits/mathcalls.h create mode 100644 libc/sysdeps/linux/i386/bits/mathdef.h create mode 100644 libc/sysdeps/linux/i386/bits/mathinline.h create mode 100644 libc/sysdeps/linux/i386/bits/mman.h create mode 100644 libc/sysdeps/linux/i386/bits/msq.h create mode 100644 libc/sysdeps/linux/i386/bits/nan.h create mode 100644 libc/sysdeps/linux/i386/bits/pthreadtypes.h create mode 100644 libc/sysdeps/linux/i386/bits/resource.h create mode 100644 libc/sysdeps/linux/i386/bits/sched.h create mode 100644 libc/sysdeps/linux/i386/bits/sem.h create mode 100644 libc/sysdeps/linux/i386/bits/stab.def create mode 100644 libc/sysdeps/linux/i386/bits/statvfs.h create mode 100644 libc/sysdeps/linux/i386/bits/stdio-lock.h create mode 100644 libc/sysdeps/linux/i386/bits/stdio.h create mode 100644 libc/sysdeps/linux/i386/bits/string.h create mode 100644 libc/sysdeps/linux/i386/bits/string2.h create mode 100644 libc/sysdeps/linux/i386/bits/stropts.h create mode 100644 libc/sysdeps/linux/i386/bits/ustat.h create mode 100644 libc/sysdeps/linux/i386/bits/utmp.h create mode 100644 libc/sysdeps/linux/i386/bits/utmpx.h create mode 100644 libc/sysdeps/linux/i386/bits/utsname.h diff --git a/libc/sysdeps/linux/i386/bits/cmathcalls.h b/libc/sysdeps/linux/i386/bits/cmathcalls.h new file mode 100644 index 000000000..f063042b0 --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/cmathcalls.h @@ -0,0 +1,157 @@ +/* Prototype declarations for complex math functions; + helper file for . + Copyright (C) 1997, 1998 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. */ + +/* NOTE: Because of the special way this file is used by , this + file must NOT be protected from multiple inclusion as header files + usually are. + + This file provides prototype declarations for the math functions. + Most functions are declared using the macro: + + __MATHCALL (NAME, (ARGS...)); + + This means there is a function `NAME' returning `double' and a function + `NAMEf' returning `float'. Each place `_Mdouble_' appears in the + prototype, that is actually `double' in the prototype for `NAME' and + `float' in the prototype for `NAMEf'. Reentrant variant functions are + called `NAME_r' and `NAMEf_r'. + + Functions returning other types like `int' are declared using the macro: + + __MATHDECL (TYPE, NAME, (ARGS...)); + + This is just like __MATHCALL but for a function returning `TYPE' + instead of `_Mdouble_'. In all of these cases, there is still + both a `NAME' and a `NAMEf' that takes `float' arguments. */ + +#ifndef _COMPLEX_H +#error "Never use directly; include instead." +#endif + +#define _Mdouble_complex_ _Mdouble_ _Complex + + +/* Trigonometric functions. */ + +/* Arc cosine of Z. */ +__MATHCALL (cacos, (_Mdouble_complex_ __z)); +/* Arc sine of Z. */ +__MATHCALL (casin, (_Mdouble_complex_ __z)); +/* Arc tangent of Z. */ +__MATHCALL (catan, (_Mdouble_complex_ __z)); + +/* Cosine of Z. */ +__MATHCALL (ccos, (_Mdouble_complex_ __z)); +/* Sine of Z. */ +__MATHCALL (csin, (_Mdouble_complex_ __z)); +/* Tangent of Z. */ +__MATHCALL (ctan, (_Mdouble_complex_ __z)); + + +/* Hyperbolic functions. */ + +/* Hyperbolic arc cosine of Z. */ +__MATHCALL (cacosh, (_Mdouble_complex_ __z)); +/* Hyperbolic arc sine of Z. */ +__MATHCALL (casinh, (_Mdouble_complex_ __z)); +/* Hyperbolic arc tangent of Z. */ +__MATHCALL (catanh, (_Mdouble_complex_ __z)); + +/* Hyperbolic cosine of Z. */ +__MATHCALL (ccosh, (_Mdouble_complex_ __z)); +/* Hyperbolic sine of Z. */ +__MATHCALL (csinh, (_Mdouble_complex_ __z)); +/* Hyperbolic tangent of Z. */ +__MATHCALL (ctanh, (_Mdouble_complex_ __z)); + + +/* Exponential and logarithmic functions. */ + +/* Exponential function of Z. */ +__MATHCALL (cexp, (_Mdouble_complex_ __z)); + +/* Natural logarithm of Z. */ +__MATHCALL (clog, (_Mdouble_complex_ __z)); + +#ifdef __USE_GNU +/* The base 10 logarithm is not defined by the standard but to implement + the standard C++ library it is handy. */ +__MATHCALL (clog10, (_Mdouble_complex_ __z)); +#endif + +/* Power functions. */ + +/* Return X to the Y power. */ +__MATHCALL (cpow, (_Mdouble_complex_ __x, _Mdouble_complex_ __y)); + +/* Return the square root of Z. */ +__MATHCALL (csqrt, (_Mdouble_complex_ __z)); + + +/* Absolute value, conjugates, and projection. */ + +/* Absolute value of Z. */ +__MATHDECL (_Mdouble_,cabs, (_Mdouble_complex_ __z)); + +/* Argument value of Z. */ +__MATHDECL (_Mdouble_,carg, (_Mdouble_complex_ __z)); + +/* Complex conjugate of Z. */ +__MATHCALL (conj, (_Mdouble_complex_ __z)); + +/* Projection of Z onto the Riemann sphere. */ +__MATHCALL (cproj, (_Mdouble_complex_ __z)); + + +/* Decomposing complex values. */ + +/* Imaginary part of Z. */ +__MATHDECL (_Mdouble_,cimag, (_Mdouble_complex_ __z)); + +/* Real part of Z. */ +__MATHDECL (_Mdouble_,creal, (_Mdouble_complex_ __z)); + + +/* Now some optimized versions. GCC has handy notations for these + functions. */ +#if defined __GNUC__ && defined __OPTIMIZE__ + +/* Imaginary part of Z. */ +extern __inline _Mdouble_ +__MATH_PRECNAME(cimag) (_Mdouble_complex_ __z) +{ + return __imag__ __z; +} + +/* Real part of Z. */ +extern __inline _Mdouble_ +__MATH_PRECNAME(creal) (_Mdouble_complex_ __z) +{ + return __real__ __z; +} + +/* Complex conjugate of Z. */ +extern __inline _Mdouble_complex_ +__MATH_PRECNAME(conj) (_Mdouble_complex_ __z) +{ + return ~__z; +} + +#endif diff --git a/libc/sysdeps/linux/i386/bits/dlfcn.h b/libc/sysdeps/linux/i386/bits/dlfcn.h new file mode 100644 index 000000000..f5983d706 --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/dlfcn.h @@ -0,0 +1,37 @@ +/* System dependent definitions for run-time dynamic loading. + Copyright (C) 1996, 1997, 1998, 1999 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 _DLFCN_H +# error "Never use directly; include instead." +#endif + +/* The MODE argument to `dlopen' contains one of the following: */ +#define RTLD_LAZY 0x001 /* Lazy function call binding. */ +#define RTLD_NOW 0x002 /* Immediate function call binding. */ +#define RTLD_BINDING_MASK 0x3 /* Mask of binding time value. */ + +/* If the following bit is set in the MODE argument to `dlopen', + the symbols of the loaded object and its dependencies are made + visible as if the object were linked directly into the program. */ +#define RTLD_GLOBAL 0x100 + +/* Unix98 demands the following flag which is the inverse to RTLD_GLOBAL. + The implementation does this by default and so we can define the + value to zero. */ +#define RTLD_LOCAL 0 diff --git a/libc/sysdeps/linux/i386/bits/elfclass.h b/libc/sysdeps/linux/i386/bits/elfclass.h new file mode 100644 index 000000000..bb4dd545c --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/elfclass.h @@ -0,0 +1,11 @@ +/* This file specifies the native word size of the machine, which indicates + the ELF file class used for executables and shared objects on this + machine. */ + +#ifndef _LINK_H +# error "Never use directly; include instead." +#endif + +#include + +#define __ELF_NATIVE_CLASS __WORDSIZE diff --git a/libc/sysdeps/linux/i386/bits/environments.h b/libc/sysdeps/linux/i386/bits/environments.h new file mode 100644 index 000000000..f3af20655 --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/environments.h @@ -0,0 +1,59 @@ +/* Copyright (C) 1999 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 _UNISTD_H +# error "Never include this file directly. Use instead" +#endif + +#include + +/* This header should define the following symbols under the described + situations. A value `1' means that the model is always supported, + `-1' means it is never supported. Undefined means it cannot be + statically decided. + + _XBS5_ILP32_OFF32 32bit int, long, pointers, and off_t type + _XBS5_ILP32_OFFBIG 32bit int, long, and pointers and larger off_t type + + _XBS5_LP64_OFF32 64bit long and pointers and 32bit off_t type + _XBS5_LPBIG_OFFBIG 64bit long and pointers and large off_t type +*/ + +#if __WORDSIZE == 64 + +/* We can never provide environments with 32-bit wide pointers. */ +# define _XBS5_ILP32_OFF32 -1 +# define _XBS5_ILP32_OFFBIG -1 + +/* By default we have 64-bit wide `long int', pointers and `off_t'. */ +# define _XBS5_LP64_OFF32 1 +# define _XBS5_LPBIG_OFFBIG 1 + +#else /* __WORDSIZE == 32 */ + +/* By default we have 32-bit wide `int', `long int', pointers and `off_t'. */ +# define _XBS5_ILP32_OFF32 1 + +/* We optionally provide an environment with the above size but an 64-bit + side `off_t'. Therefore we don't define _XBS5_ILP32_OFFBIG. */ + +/* We can never provide environments with 64-bit wide pointers. */ +# define _XBS5_LP64_OFF64 -1 +# define _XBS5_LPBIG_OFFBIG -1 + +#endif /* __WORDSIZE == 32 */ diff --git a/libc/sysdeps/linux/i386/bits/errno.h b/libc/sysdeps/linux/i386/bits/errno.h new file mode 100644 index 000000000..35bd61109 --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/errno.h @@ -0,0 +1,60 @@ +/* Error constants. Linux specific version. + Copyright (C) 1996, 1997, 1998 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. */ + +#ifdef _ERRNO_H + +# undef EDOM +# undef EILSEQ +# undef ERANGE +# include + +/* Linux has no ENOTSUP error code. */ +# define ENOTSUP EOPNOTSUPP + +/* Linux also has no ECANCELED error code. Since it is not used here + we define it to an invalid value. */ +# define ECANCELED 125 + +# ifndef __ASSEMBLER__ +/* We now need a declaration of the `errno' variable. */ +extern int errno; + +/* Function to get address of global `errno' variable. */ +extern int *__errno_location __P ((void)) __attribute__ ((__const__)); + +# if defined _LIBC +/* We wouldn't need a special macro anymore but it is history. */ +# define __set_errno(val) (*__errno_location ()) = (val) +# endif /* _LIBC */ + +# if !defined _LIBC || defined _LIBC_REENTRANT +/* When using threads, errno is a per-thread value. */ +# define errno (*__errno_location ()) +# endif +# endif /* !__ASSEMBLER__ */ +#endif /* _ERRNO_H */ + +#if !defined _ERRNO_H && defined __need_Emath +/* This is ugly but the kernel header is not clean enough. We must + define only the values EDOM and ERANGE in case __need_Emath is + defined. The value is the same for all Linux ports. */ +# define EDOM 33 /* Math argument out of domain of function. */ +# define EILSEQ 84 /* Illegal byte sequence. */ +# define ERANGE 34 /* Math result not representable. */ +#endif /* !_ERRNO_H && __need_Emath */ diff --git a/libc/sysdeps/linux/i386/bits/fenv.h b/libc/sysdeps/linux/i386/bits/fenv.h new file mode 100644 index 000000000..08bf67609 --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/fenv.h @@ -0,0 +1,90 @@ +/* Copyright (C) 1997, 1998, 1999 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 _FENV_H +# error "Never use directly; include instead." +#endif + + +/* Define bits representing the exception. We use the bit positions + of the appropriate bits in the FPU control word. */ +enum + { + FE_INVALID = 0x01, +#define FE_INVALID FE_INVALID + __FE_DENORM = 0x02, + FE_DIVBYZERO = 0x04, +#define FE_DIVBYZERO FE_DIVBYZERO + FE_OVERFLOW = 0x08, +#define FE_OVERFLOW FE_OVERFLOW + FE_UNDERFLOW = 0x10, +#define FE_UNDERFLOW FE_UNDERFLOW + FE_INEXACT = 0x20 +#define FE_INEXACT FE_INEXACT + }; + +#define FE_ALL_EXCEPT \ + (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID) + +/* The ix87 FPU supports all of the four defined rounding modes. We + use again the bit positions in the FPU control word as the values + for the appropriate macros. */ +enum + { + FE_TONEAREST = 0, +#define FE_TONEAREST FE_TONEAREST + FE_DOWNWARD = 0x400, +#define FE_DOWNWARD FE_DOWNWARD + FE_UPWARD = 0x800, +#define FE_UPWARD FE_UPWARD + FE_TOWARDZERO = 0xc00 +#define FE_TOWARDZERO FE_TOWARDZERO + }; + + +/* Type representing exception flags. */ +typedef unsigned short int fexcept_t; + + +/* Type representing floating-point environment. This function corresponds + to the layout of the block written by the `fstenv'. */ +typedef struct + { + unsigned short int __control_word; + unsigned short int __unused1; + unsigned short int __status_word; + unsigned short int __unused2; + unsigned short int __tags; + unsigned short int __unused3; + unsigned int __eip; + unsigned short int __cs_selector; + unsigned int __opcode:11; + unsigned int __unused4:5; + unsigned int __data_offset; + unsigned short int __data_selector; + unsigned short int __unused5; + } +fenv_t; + +/* If the default argument is used we use this value. */ +#define FE_DFL_ENV ((fenv_t *) -1) + +#ifdef __USE_GNU +/* Floating-point environment where none of the exception is masked. */ +# define FE_NOMASK_ENV ((fenv_t *) -2) +#endif diff --git a/libc/sysdeps/linux/i386/bits/huge_val.h b/libc/sysdeps/linux/i386/bits/huge_val.h new file mode 100644 index 000000000..23127b403 --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/huge_val.h @@ -0,0 +1,68 @@ +/* `HUGE_VAL' constants for ix86 (where it is infinity). + Used by and 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 _MATH_H +# error "Never use directly; include instead." +#endif + +#include + +/* IEEE positive infinity (-HUGE_VAL is negative infinity). */ + +#define __HUGE_VAL_bytes { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } + +#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 + +# define __HUGE_VALF_bytes { 0, 0, 0x80, 0x7f } + +# 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. */ + + +# define __HUGE_VALL_bytes { 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0x7f, 0, 0 } + +# 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. */ + +#endif /* __USE_ISOC9X. */ diff --git a/libc/sysdeps/linux/i386/bits/libc-lock.h b/libc/sysdeps/linux/i386/bits/libc-lock.h new file mode 100644 index 000000000..a14cea1aa --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/libc-lock.h @@ -0,0 +1,214 @@ +/* libc-internal interface for mutex locks. LinuxThreads version. + Copyright (C) 1996, 1997, 1998, 1999 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 _BITS_LIBC_LOCK_H +#define _BITS_LIBC_LOCK_H 1 + +#include + +/* Mutex type. */ +#ifdef _LIBC +typedef pthread_mutex_t __libc_lock_t; +#else +typedef struct __libc_lock_opaque__ __libc_lock_t; +#endif + +/* Type for key to thread-specific data. */ +typedef pthread_key_t __libc_key_t; + +/* Define a lock variable NAME with storage class CLASS. The lock must be + initialized with __libc_lock_init before it can be used (or define it + with __libc_lock_define_initialized, below). Use `extern' for CLASS to + declare a lock defined in another module. In public structure + definitions you must use a pointer to the lock structure (i.e., NAME + begins with a `*'), because its storage size will not be known outside + of libc. */ +#define __libc_lock_define(CLASS,NAME) \ + CLASS __libc_lock_t NAME; + +/* Define an initialized lock variable NAME with storage class CLASS. + + For the C library we take a deeper look at the initializer. For this + implementation all fields are initialized to zero. Therefore we + don't initialize the variable which allows putting it into the BSS + section. */ +#define __libc_lock_define_initialized(CLASS,NAME) \ + CLASS __libc_lock_t NAME; + +/* Define an initialized recursive lock variable NAME with storage + class CLASS. */ +#define __libc_lock_define_initialized_recursive(CLASS,NAME) \ + CLASS __libc_lock_t NAME = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; + +/* Initialize the named lock variable, leaving it in a consistent, unlocked + state. */ +#define __libc_lock_init(NAME) \ + (__pthread_mutex_init != NULL ? __pthread_mutex_init (&(NAME), NULL) : 0); + +/* Same as last but this time we initialize a recursive mutex. */ +#define __libc_lock_init_recursive(NAME) \ + do { \ + if (__pthread_mutex_init != NULL) \ + { \ + pthread_mutexattr_t __attr; \ + __pthread_mutexattr_init (&__attr); \ + __pthread_mutexattr_settype (&__attr, PTHREAD_MUTEX_RECURSIVE_NP); \ + __pthread_mutex_init (&(NAME), &__attr); \ + __pthread_mutexattr_destroy (&__attr); \ + } \ + } while (0); + +/* Finalize the named lock variable, which must be locked. It cannot be + used again until __libc_lock_init is called again on it. This must be + called on a lock variable before the containing storage is reused. */ +#define __libc_lock_fini(NAME) \ + (__pthread_mutex_destroy != NULL ? __pthread_mutex_destroy (&(NAME)) : 0); + +/* Finalize recursive named lock. */ +#define __libc_lock_fini_recursive(NAME) __libc_lock_fini (NAME) + +/* Lock the named lock variable. */ +#define __libc_lock_lock(NAME) \ + (__pthread_mutex_lock != NULL ? __pthread_mutex_lock (&(NAME)) : 0); + +/* Lock the recursive named lock variable. */ +#define __libc_lock_lock_recursive(NAME) __libc_lock_lock (NAME) + +/* Try to lock the named lock variable. */ +#define __libc_lock_trylock(NAME) \ + (__pthread_mutex_trylock != NULL ? __pthread_mutex_trylock (&(NAME)) : 0) + +/* Try to lock the recursive named lock variable. */ +#define __libc_lock_trylock_recursive(NAME) __libc_lock_trylock (NAME) + +/* Unlock the named lock variable. */ +#define __libc_lock_unlock(NAME) \ + (__pthread_mutex_unlock != NULL ? __pthread_mutex_unlock (&(NAME)) : 0); + +/* Unlock the recursive named lock variable. */ +#define __libc_lock_unlock_recursive(NAME) __libc_lock_unlock (NAME) + + +/* Define once control variable. */ +#if PTHREAD_ONCE_INIT == 0 +/* Special case for static variables where we can avoid the initialization + if it is zero. */ +# define __libc_once_define(CLASS, NAME) \ + CLASS pthread_once_t NAME +#else +# define __libc_once_define(CLASS, NAME) \ + CLASS pthread_once_t NAME = PTHREAD_ONCE_INIT +#endif + +/* Call handler iff the first call. */ +#define __libc_once(ONCE_CONTROL, INIT_FUNCTION) \ + do { \ + if (__pthread_once != NULL) \ + __pthread_once (&(ONCE_CONTROL), (INIT_FUNCTION)); \ + else if ((ONCE_CONTROL) == 0) { \ + INIT_FUNCTION (); \ + (ONCE_CONTROL) = 1; \ + } \ + } while (0) + + +/* Start critical region with cleanup. */ +#define __libc_cleanup_region_start(FCT, ARG) \ + { struct _pthread_cleanup_buffer _buffer; \ + int _avail = _pthread_cleanup_push_defer != NULL; \ + if (_avail) { \ + _pthread_cleanup_push_defer (&_buffer, (FCT), (ARG)); \ + } + +/* End critical region with cleanup. */ +#define __libc_cleanup_region_end(DOIT) \ + if (_avail) { \ + _pthread_cleanup_pop_restore (&_buffer, (DOIT)); \ + } \ + } + +/* Sometimes we have to exit the block in the middle. */ +#define __libc_cleanup_end(DOIT) \ + if (_avail) { \ + _pthread_cleanup_pop_restore (&_buffer, (DOIT)); \ + } + +/* Create thread-specific key. */ +#define __libc_key_create(KEY, DESTRUCTOR) \ + (__pthread_key_create != NULL ? __pthread_key_create (KEY, DESTRUCTOR) : 1) + +/* Get thread-specific data. */ +#define __libc_getspecific(KEY) \ + (__pthread_getspecific != NULL ? __pthread_getspecific (KEY) : NULL) + +/* Set thread-specific data. */ +#define __libc_setspecific(KEY, VALUE) \ + (__pthread_setspecific != NULL ? __pthread_setspecific (KEY, VALUE) : 0) + + +/* Register handlers to execute before and after `fork'. */ +#define __libc_atfork(PREPARE, PARENT, CHILD) \ + (__pthread_atfork != NULL ? __pthread_atfork (PREPARE, PARENT, CHILD) : 0) + + +/* Make the pthread functions weak so that we can elide them from + single-threaded processes. */ +#ifndef __NO_WEAK_PTHREAD_ALIASES +# ifdef weak_extern +weak_extern (__pthread_mutex_init) +weak_extern (__pthread_mutex_destroy) +weak_extern (__pthread_mutex_lock) +weak_extern (__pthread_mutex_trylock) +weak_extern (__pthread_mutex_unlock) +weak_extern (__pthread_mutexattr_init) +weak_extern (__pthread_mutexattr_destroy) +weak_extern (__pthread_mutexattr_settype) +weak_extern (__pthread_key_create) +weak_extern (__pthread_setspecific) +weak_extern (__pthread_getspecific) +weak_extern (__pthread_once) +weak_extern (__pthread_initialize) +weak_extern (__pthread_atfork) +weak_extern (_pthread_cleanup_push_defer) +weak_extern (_pthread_cleanup_pop_restore) +# else +# pragma weak __pthread_mutex_init +# pragma weak __pthread_mutex_destroy +# pragma weak __pthread_mutex_lock +# pragma weak __pthread_mutex_trylock +# pragma weak __pthread_mutex_unlock +# pragma weak __pthread_mutexattr_init +# pragma weak __pthread_mutexattr_destroy +# pragma weak __pthread_mutexattr_settype +# pragma weak __pthread_key_create +# pragma weak __pthread_setspecific +# pragma weak __pthread_getspecific +# pragma weak __pthread_once +# pragma weak __pthread_initialize +# pragma weak __pthread_atfork +# pragma weak _pthread_cleanup_push_defer +# pragma weak _pthread_cleanup_pop_restore +# endif +#endif + +/* We need portable names for some functions. E.g., when they are + used as argument to __libc_cleanup_region_start. */ +#define __libc_mutex_unlock __pthread_mutex_unlock + +#endif /* bits/libc-lock.h */ diff --git a/libc/sysdeps/linux/i386/bits/mathcalls.h b/libc/sysdeps/linux/i386/bits/mathcalls.h new file mode 100644 index 000000000..97bda451a --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/mathcalls.h @@ -0,0 +1,336 @@ +/* Prototype declarations for math functions; helper file for . + Copyright (C) 1996, 1997, 1998, 1999 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. */ + +/* NOTE: Because of the special way this file is used by , this + file must NOT be protected from multiple inclusion as header files + usually are. + + This file provides prototype declarations for the math functions. + Most functions are declared using the macro: + + __MATHCALL (NAME,[_r], (ARGS...)); + + This means there is a function `NAME' returning `double' and a function + `NAMEf' returning `float'. Each place `_Mdouble_' appears in the + prototype, that is actually `double' in the prototype for `NAME' and + `float' in the prototype for `NAMEf'. Reentrant variant functions are + called `NAME_r' and `NAMEf_r'. + + Functions returning other types like `int' are declared using the macro: + + __MATHDECL (TYPE, NAME,[_r], (ARGS...)); + + This is just like __MATHCALL but for a function returning `TYPE' + instead of `_Mdouble_'. In all of these cases, there is still + both a `NAME' and a `NAMEf' that takes `float' arguments. + + Note that there must be no whitespace before the argument passed for + NAME, to make token pasting work with -traditional. */ + +#ifndef _MATH_H + #error "Never include directly; include instead." +#endif + + +/* Trigonometric functions. */ + +/* Arc cosine of X. */ +__MATHCALL (acos,, (_Mdouble_ __x)); +/* Arc sine of X. */ +__MATHCALL (asin,, (_Mdouble_ __x)); +/* Arc tangent of X. */ +__MATHCALL (atan,, (_Mdouble_ __x)); +/* Arc tangent of Y/X. */ +__MATHCALL (atan2,, (_Mdouble_ __y, _Mdouble_ __x)); + +/* Cosine of X. */ +__MATHCALL (cos,, (_Mdouble_ __x)); +/* Sine of X. */ +__MATHCALL (sin,, (_Mdouble_ __x)); +/* Tangent of X. */ +__MATHCALL (tan,, (_Mdouble_ __x)); + +#ifdef __USE_GNU +/* Cosine and sine of X. */ +__MATHDECL (void,sincos,, + (_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx)); +#endif + +/* Hyperbolic functions. */ + +/* Hyperbolic cosine of X. */ +__MATHCALL (cosh,, (_Mdouble_ __x)); +/* Hyperbolic sine of X. */ +__MATHCALL (sinh,, (_Mdouble_ __x)); +/* Hyperbolic tangent of X. */ +__MATHCALL (tanh,, (_Mdouble_ __x)); + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC9X +/* Hyperbolic arc cosine of X. */ +__MATHCALL (acosh,, (_Mdouble_ __x)); +/* Hyperbolic arc sine of X. */ +__MATHCALL (asinh,, (_Mdouble_ __x)); +/* Hyperbolic arc tangent of X. */ +__MATHCALL (atanh,, (_Mdouble_ __x)); +#endif + +/* Exponential and logarithmic functions. */ + +/* Exponential function of X. */ +__MATHCALL (exp,, (_Mdouble_ __x)); + +#ifdef __USE_GNU +/* A function missing in all standards: compute exponent to base ten. */ +__MATHCALL (exp10,, (_Mdouble_ __x)); +/* Another name occasionally used. */ +__MATHCALL (pow10,, (_Mdouble_ __x)); +#endif + +/* Break VALUE into a normalized fraction and an integral power of 2. */ +__MATHCALL (frexp,, (_Mdouble_ __x, int *__exponent)); + +/* X times (two to the EXP power). */ +__MATHCALL (ldexp,, (_Mdouble_ __x, int __exponent)); + +/* Natural logarithm of X. */ +__MATHCALL (log,, (_Mdouble_ __x)); + +/* Base-ten logarithm of X. */ +__MATHCALL (log10,, (_Mdouble_ __x)); + +/* Break VALUE into integral and fractional parts. */ +__MATHCALL (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr)); + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC9X +/* Return exp(X) - 1. */ +__MATHCALL (expm1,, (_Mdouble_ __x)); + +/* Return log(1 + X). */ +__MATHCALL (log1p,, (_Mdouble_ __x)); + +/* Return the base 2 signed integral exponent of X. */ +__MATHCALL (logb,, (_Mdouble_ __x)); +#endif + +#ifdef __USE_ISOC9X +/* Compute base-2 exponential of X. */ +__MATHCALL (exp2,, (_Mdouble_ __x)); + +/* Compute base-2 logarithm of X. */ +__MATHCALL (log2,, (_Mdouble_ __x)); +#endif + + +/* Power functions. */ + +/* Return X to the Y power. */ +__MATHCALL (pow,, (_Mdouble_ __x, _Mdouble_ __y)); + +/* Return the square root of X. */ +__MATHCALL (sqrt,, (_Mdouble_ __x)); + +#if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC9X +/* Return `sqrt(X*X + Y*Y)'. */ +__MATHCALL (hypot,, (_Mdouble_ __x, _Mdouble_ __y)); +#endif + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC9X +/* Return the cube root of X. */ +__MATHCALL (cbrt,, (_Mdouble_ __x)); +#endif + + +/* Nearest integer, absolute value, and remainder functions. */ + +/* Smallest integral value not less than X. */ +__MATHCALL (ceil,, (_Mdouble_ __x)); + +/* Absolute value of X. */ +__MATHCALLX (fabs,, (_Mdouble_ __x), (__const__)); + +/* Largest integer not greater than X. */ +__MATHCALL (floor,, (_Mdouble_ __x)); + +/* Floating-point modulo remainder of X/Y. */ +__MATHCALL (fmod,, (_Mdouble_ __x, _Mdouble_ __y)); + + +/* Return 0 if VALUE is finite or NaN, +1 if it + is +Infinity, -1 if it is -Infinity. */ +__MATHDECL_1 (int,__isinf,, (_Mdouble_ __value)) __attribute__ ((__const__)); + +/* Return nonzero if VALUE is finite and not NaN. */ +__MATHDECL_1 (int,__finite,, (_Mdouble_ __value)) __attribute__ ((__const__)); + +#ifdef __USE_MISC +/* Return 0 if VALUE is finite or NaN, +1 if it + is +Infinity, -1 if it is -Infinity. */ +__MATHDECL_1 (int,isinf,, (_Mdouble_ __value)) __attribute__ ((__const__)); + +/* Return nonzero if VALUE is finite and not NaN. */ +__MATHDECL_1 (int,finite,, (_Mdouble_ __value)) __attribute__ ((__const__)); + +/* Deal with an infinite or NaN result. + If ERROR is ERANGE, result is +Inf; + if ERROR is - ERANGE, result is -Inf; + otherwise result is NaN. + This will set `errno' to either ERANGE or EDOM, + and may return an infinity or NaN, or may do something else. */ +__MATHCALLX (infnan,, (int __error), (__const__)); + +/* Return the remainder of X/Y. */ +__MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y)); + + +/* Return the fractional part of X after dividing out `ilogb (X)'. */ +__MATHCALL (significand,, (_Mdouble_ __x)); +#endif /* Use misc. */ + +#if defined __USE_MISC || defined __USE_ISOC9X +/* Return X with its signed changed to Y's. */ +__MATHCALLX (copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); +#endif + +#ifdef __USE_ISOC9X +/* Return representation of NaN for double type. */ +__MATHCALLX (nan,, (__const char *__tagb), (__const__)); +#endif + + +/* Return nonzero if VALUE is not a number. */ +__MATHDECL_1 (int,__isnan,, (_Mdouble_ __value)) __attribute__ ((__const__)); + +#if defined __USE_MISC || defined __USE_XOPEN +/* Return nonzero if VALUE is not a number. */ +__MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__)); + +/* Bessel functions. */ +__MATHCALL (j0,, (_Mdouble_)); +__MATHCALL (j1,, (_Mdouble_)); +__MATHCALL (jn,, (int, _Mdouble_)); +__MATHCALL (y0,, (_Mdouble_)); +__MATHCALL (y1,, (_Mdouble_)); +__MATHCALL (yn,, (int, _Mdouble_)); +#endif + + +#if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC9X +/* Error and gamma functions. */ +__MATHCALL (erf,, (_Mdouble_)); +__MATHCALL (erfc,, (_Mdouble_)); +__MATHCALL (lgamma,, (_Mdouble_)); +__MATHCALL (tgamma,, (_Mdouble_)); +#endif + +#if defined __USE_MISC || defined __USE_XOPEN +/* Obsolete alias for `lgamma'. */ +__MATHCALL (gamma,, (_Mdouble_)); +#endif + +#ifdef __USE_MISC +/* Reentrant version of lgamma. This function uses the global variable + `signgam'. The reentrant version instead takes a pointer and stores + the value through it. */ +__MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp)); +#endif + + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC9X +/* Return the integer nearest X in the direction of the + prevailing rounding mode. */ +__MATHCALL (rint,, (_Mdouble_ __x)); + +/* Return X + epsilon if X < Y, X - epsilon if X > Y. */ +__MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); +# ifdef __USE_ISOC9X +__MATHCALLX (nexttoward,, (_Mdouble_ __x, long double __y), (__const__)); +# endif + +/* Return the remainder of integer divison X / Y with infinite precision. */ +__MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y)); + +# if defined __USE_MISC || defined __USE_XOPEN_EXTENDED +/* Return X times (2 to the Nth power). */ +__MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n)); +# endif + +/* Return X times (2 to the Nth power). */ +__MATHCALL (scalbn,, (_Mdouble_ __x, int __n)); + +/* Return the binary exponent of X, which must be nonzero. */ +__MATHDECL (int,ilogb,, (_Mdouble_ __x)); +#endif + +#ifdef __USE_ISOC9X +/* Return X times (2 to the Nth power). */ +__MATHCALL (scalbln,, (_Mdouble_ __x, long int __n)); + +/* Round X to integral value in floating-point format using current + rounding direction, but do not raise inexact exception. */ +__MATHCALL (nearbyint,, (_Mdouble_ __x)); + +/* Round X to nearest integral value, rounding halfway cases away from + zero. */ +__MATHCALL (round,, (_Mdouble_ __x)); + +/* Round X to the integral value in floating-point format nearest but + not larger in magnitude. */ +__MATHCALLX (trunc,, (_Mdouble_ __x), (__const__)); + +/* Compute remainder of X and Y and put in *QUO a value with sign of x/y + and magnitude congruent `mod 2^n' to the magnitude of the integral + quotient x/y, with n >= 3. */ +__MATHCALL (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo)); + + +/* Conversion functions. */ + +/* Round X to nearest integral value according to current rounding + direction. */ +__MATHDECL (long int,lrint,, (_Mdouble_ __x)); +__MATHDECL (long long int,llrint,, (_Mdouble_ __x)); + +/* Round X to nearest integral value, rounding halfway cases away from + zero. */ +__MATHDECL (long int,lround,, (_Mdouble_ __x)); +__MATHDECL (long long int,llround,, (_Mdouble_ __x)); + + +/* Return positive difference between X and Y. */ +__MATHCALL (fdim,, (_Mdouble_ __x, _Mdouble_ __y)); + +/* Return maximum numeric value from X and Y. */ +__MATHCALL (fmax,, (_Mdouble_ __x, _Mdouble_ __y)); + +/* Return minimum numeric value from X and Y. */ +__MATHCALL (fmin,, (_Mdouble_ __x, _Mdouble_ __y)); + + +/* Classify given number. */ +__MATHDECL_1 (int, __fpclassify,, (_Mdouble_ __value)) + __attribute__ ((__const__)); + +/* Test for negative number. */ +__MATHDECL_1 (int, __signbit,, (_Mdouble_ __value)) + __attribute__ ((__const__)); + + +/* Multiply-add function computed as a ternary operation. */ +__MATHCALL (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z)); +#endif /* Use ISO C 9X. */ diff --git a/libc/sysdeps/linux/i386/bits/mathdef.h b/libc/sysdeps/linux/i386/bits/mathdef.h new file mode 100644 index 000000000..58b116e8d --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/mathdef.h @@ -0,0 +1,47 @@ +/* Copyright (C) 1997, 1998, 1999 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. */ + +#if !defined _MATH_H && !defined _COMPLEX_H +# error "Never use directly; include instead" +#endif + +#if defined __USE_ISOC9X && defined _MATH_H && !defined _MATH_H_MATHDEF +# define _MATH_H_MATHDEF 1 + +/* The ix87 FPUs evaluate all values in the 80 bit floating-point format + which is also available for the user as `long double'. Therefore we + define: */ +typedef long double float_t; /* `float' expressions are evaluated as + `long double'. */ +typedef long double double_t; /* `double' expressions are evaluated as + `long double'. */ + +/* Signal that both types are `long double'. */ +# define FLT_EVAL_METHOD 2 + +/* Define `INFINITY' as value of type `float'. */ +# define INFINITY HUGE_VALF + +/* The values returned by `ilogb' for 0 and NaN respectively. */ +# define FP_ILOGB0 0x80000000 +# define FP_ILOGBNAN 0x80000000 + +/* Number of decimal digits for the `long double' type. */ +# define DECIMAL_DIG 18 + +#endif /* ISO C99 */ diff --git a/libc/sysdeps/linux/i386/bits/mathinline.h b/libc/sysdeps/linux/i386/bits/mathinline.h new file mode 100644 index 000000000..acc3aa998 --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/mathinline.h @@ -0,0 +1,678 @@ +/* Inline math functions for i387. + Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by John C. Bowman , 1995. + + 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 _MATH_H +# error "Never use directly; include instead." +#endif + +#ifdef __cplusplus +# define __MATH_INLINE __inline +#else +# define __MATH_INLINE extern __inline +#endif + + +#if defined __USE_ISOC9X && defined __GNUC__ && __GNUC__ >= 2 +/* ISO C 9X defines some macros to perform unordered comparisons. The + ix87 FPU supports this with special opcodes and we should use them. + These must not be inline functions since we have to be able to handle + all floating-point types. */ +# ifdef __i686__ +/* For the PentiumPro and more recent processors we can provide + better code. */ +# define isgreater(x, y) \ + ({ register char __result; \ + __asm__ ("fucomip %%st(1), %%st; seta %%al" \ + : "=a" (__result) : "u" (y), "t" (x) : "cc", "st"); \ + __result; }) +# define isgreaterequal(x, y) \ + ({ register char __result; \ + __asm__ ("fucomip %%st(1), %%st; setae %%al" \ + : "=a" (__result) : "u" (y), "t" (x) : "cc", "st"); \ + __result; }) + +# define isless(x, y) \ + ({ register char __result; \ + __asm__ ("fucomip %%st(1), %%st; seta %%al" \ + : "=a" (__result) : "u" (x), "t" (y) : "cc", "st"); \ + __result; }) + +# define islessequal(x, y) \ + ({ register char __result; \ + __asm__ ("fucomip %%st(1), %%st; setae %%al" \ + : "=a" (__result) : "u" (x), "t" (y) : "cc", "st"); \ + __result; }) + +# define islessgreater(x, y) \ + ({ register char __result; \ + __asm__ ("fucomip %%st(1), %%st; setne %%al" \ + : "=a" (__result) : "u" (y), "t" (x) : "cc", "st"); \ + __result; }) + +# define isunordered(x, y) \ + ({ register char __result; \ + __asm__ ("fucomip %%st(1), %%st; setp %%al" \ + : "=a" (__result) : "u" (y), "t" (x) : "cc", "st"); \ + __result; }) +# else +/* This is the dumb, portable code for i386 and above. */ +# define isgreater(x, y) \ + ({ register char __result; \ + __asm__ ("fucompp; fnstsw; testb $0x45, %%ah; setz %%al" \ + : "=a" (__result) : "u" (y), "t" (x) : "cc", "st", "st(1)"); \ + __result; }) + +# define isgreaterequal(x, y) \ + ({ register char __result; \ + __asm__ ("fucompp; fnstsw; testb $0x05, %%ah; setz %%al" \ + : "=a" (__result) : "u" (y), "t" (x) : "cc", "st", "st(1)"); \ + __result; }) + +# define isless(x, y) \ + ({ register char __result; \ + __asm__ ("fucompp; fnstsw; testb $0x45, %%ah; setz %%al" \ + : "=a" (__result) : "u" (x), "t" (y) : "cc", "st", "st(1)"); \ + __result; }) + +# define islessequal(x, y) \ + ({ register char __result; \ + __asm__ ("fucompp; fnstsw; testb $0x05, %%ah; setz %%al" \ + : "=a" (__result) : "u" (x), "t" (y) : "cc", "st", "st(1)"); \ + __result; }) + +# define islessgreater(x, y) \ + ({ register char __result; \ + __asm__ ("fucompp; fnstsw; testb $0x44, %%ah; setz %%al" \ + : "=a" (__result) : "u" (y), "t" (x) : "cc", "st", "st(1)"); \ + __result; }) + +# define isunordered(x, y) \ + ({ register char __result; \ + __asm__ ("fucompp; fnstsw; sahf; setp %%al" \ + : "=a" (__result) : "u" (y), "t" (x) : "cc", "st", "st(1)"); \ + __result; }) +# endif /* __i686__ */ + +/* The gcc, version 2.7 or below, has problems with all this inlining + code. So disable it for this version of the compiler. */ +# if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 7)) +/* Test for negative number. Used in the signbit() macro. */ +__MATH_INLINE int +__signbitf (float __x) +{ + __extension__ union { float __f; int __i; } __u = { __f: __x }; + return __u.__i < 0; +} +__MATH_INLINE int +__signbit (double __x) +{ + __extension__ union { double __d; int __i[2]; } __u = { __d: __x }; + return __u.__i[1] < 0; +} +__MATH_INLINE int +__signbitl (long double __x) +{ + __extension__ union { long double __l; int __i[3]; } __u = { __l: __x }; + return (__u.__i[2] & 0x8000) != 0; +} +# endif +#endif + + +/* The gcc, version 2.7 or below, has problems with all this inlining + code. So disable it for this version of the compiler. */ +#if defined __GNUC__ && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 7)) + +#if ((!defined __NO_MATH_INLINES || defined __LIBC_INTERNAL_MATH_INLINES) \ + && defined __OPTIMIZE__) + +/* A macro to define float, double, and long double versions of various + math functions for the ix87 FPU. FUNC is the function name (which will + be suffixed with f and l for the float and long double version, + respectively). OP is the name of the FPU operation. */ + +#if defined __USE_MISC || defined __USE_ISOC9X +# define __inline_mathop(func, op) \ + __inline_mathop_ (double, func, op) \ + __inline_mathop_ (float, __CONCAT(func,f), op) \ + __inline_mathop_ (long double, __CONCAT(func,l), op) +#else +# define __inline_mathop(func, op) \ + __inline_mathop_ (double, func, op) +#endif + +#define __inline_mathop_(float_type, func, op) \ + __inline_mathop_decl_ (float_type, func, op, "0" (__x)) + + +#if defined __USE_MISC || defined __USE_ISOC9X +# define __inline_mathop_decl(func, op, params...) \ + __inline_mathop_decl_ (double, func, op, params) \ + __inline_mathop_decl_ (float, __CONCAT(func,f), op, params) \ + __inline_mathop_decl_ (long double, __CONCAT(func,l), op, params) +#else +# define __inline_mathop_decl(func, op, params...) \ + __inline_mathop_decl_ (double, func, op, params) +#endif + +#define __inline_mathop_decl_(float_type, func, op, params...) \ + __MATH_INLINE float_type func (float_type); \ + __MATH_INLINE float_type func (float_type __x) \ + { \ + register float_type __result; \ + __asm __volatile__ (op : "=t" (__result) : params); \ + return __result; \ + } + + +#if defined __USE_MISC || defined __USE_ISOC9X +# define __inline_mathcode(func, arg, code) \ + __inline_mathcode_ (double, func, arg, code) \ + __inline_mathcode_ (float, __CONCAT(func,f), arg, code) \ + __inline_mathcode_ (long double, __CONCAT(func,l), arg, code) +# define __inline_mathcode2(func, arg1, arg2, code) \ + __inline_mathcode2_ (double, func, arg1, arg2, code) \ + __inline_mathcode2_ (float, __CONCAT(func,f), arg1, arg2, code) \ + __inline_mathcode2_ (long double, __CONCAT(func,l), arg1, arg2, code) +# define __inline_mathcode3(func, arg1, arg2, arg3, code) \ + __inline_mathcode3_ (double, func, arg1, arg2, arg3, code) \ + __inline_mathcode3_ (float, __CONCAT(func,f), arg1, arg2, arg3, code) \ + __inline_mathcode3_ (long double, __CONCAT(func,l), arg1, arg2, arg3, code) +#else +# define __inline_mathcode(func, arg, code) \ + __inline_mathcode_ (double, func, (arg), code) +# define __inline_mathcode2(func, arg1, arg2, code) \ + __inline_mathcode2_ (double, func, arg1, arg2, code) +# define __inline_mathcode3(func, arg1, arg2, arg3, code) \ + __inline_mathcode3_ (double, func, arg1, arg2, arg3, code) +#endif + +#define __inline_mathcode_(float_type, func, arg, code) \ + __MATH_INLINE float_type func (float_type); \ + __MATH_INLINE float_type func (float_type arg) \ + { \ + code; \ + } + +#define __inline_mathcode2_(float_type, func, arg1, arg2, code) \ + __MATH_INLINE float_type func (float_type, float_type); \ + __MATH_INLINE float_type func (float_type arg1, float_type arg2) \ + { \ + code; \ + } + +#define __inline_mathcode3_(float_type, func, arg1, arg2, arg3, code) \ + __MATH_INLINE float_type func (float_type, float_type, float_type); \ + __MATH_INLINE float_type func (float_type arg1, float_type arg2, \ + float_type arg3) \ + { \ + code; \ + } +#endif + + +#if !defined __NO_MATH_INLINES && defined __OPTIMIZE__ +/* Miscellaneous functions */ + +__inline_mathcode (__sgn, __x, \ + return __x == 0.0 ? 0.0 : (__x > 0.0 ? 1.0 : -1.0)) + +__inline_mathcode (__pow2, __x, \ + register long double __value; \ + register long double __exponent; \ + __extension__ long long int __p = (long long int) __x; \ + if (__x == (long double) __p) \ + { \ + __asm __volatile__ \ + ("fscale" \ + : "=t" (__value) : "0" (1.0), "u" (__x)); \ + return __value; \ + } \ + __asm __volatile__ \ + ("fld %%st(0)\n\t" \ + "frndint # int(x)\n\t" \ + "fxch\n\t" \ + "fsub %%st(1) # fract(x)\n\t" \ + "f2xm1 # 2^(fract(x)) - 1\n\t" \ + : "=t" (__value), "=u" (__exponent) : "0" (__x)); \ + __value += 1.0; \ + __asm __volatile__ \ + ("fscale" \ + : "=t" (__value) : "0" (__value), "u" (__exponent)); \ + return __value) + +#define __sincos_code \ + register long double __cosr; \ + register long double __sinr; \ + __asm __volatile__ \ + ("fsincos\n\t" \ + "fnstsw %%ax\n\t" \ + "testl $0x400, %%eax\n\t" \ + "jz 1f\n\t" \ + "fldpi\n\t" \ + "fadd %%st(0)\n\t" \ + "fxch %%st(1)\n\t" \ + "2: fprem1\n\t" \ + "fnstsw %%ax\n\t" \ + "testl $0x400, %%eax\n\t" \ + "jnz 2b\n\t" \ + "fstp %%st(1)\n\t" \ + "fsincos\n\t" \ + "1:" \ + : "=t" (__cosr), "=u" (__sinr) : "0" (__x)); \ + *__sinx = __sinr; \ + *__cosx = __cosr + +__MATH_INLINE void __sincos (double __x, double *__sinx, double *__cosx); +__MATH_INLINE void +__sincos (double __x, double *__sinx, double *__cosx) +{ + __sincos_code; +} + +__MATH_INLINE void __sincosf (float __x, float *__sinx, float *__cosx); +__MATH_INLINE void +__sincosf (float __x, float *__sinx, float *__cosx) +{ + __sincos_code; +} + +__MATH_INLINE void __sincosl (long double __x, long double *__sinx, + long double *__cosx); +__MATH_INLINE void +__sincosl (long double __x, long double *__sinx, long double *__cosx) +{ + __sincos_code; +} + + +/* Optimized inline implementation, sometimes with reduced precision + and/or argument range. */ + +#define __expm1_code \ + register long double __value; \ + register long double __exponent; \ + register long double __temp; \ + __asm __volatile__ \ + ("fldl2e # e^x - 1 = 2^(x * log2(e)) - 1\n\t" \ + "fmul %%st(1) # x * log2(e)\n\t" \ + "fst %%st(1)\n\t" \ + "frndint # int(x * log2(e))\n\t" \ + "fxch\n\t" \ + "fsub %%st(1) # fract(x * log2(e))\n\t" \ + "f2xm1 # 2^(fract(x * log2(e))) - 1\n\t" \ + "fscale # 2^(x * log2(e)) - 2^(int(x * log2(e)))\n\t" \ + : "=t" (__value), "=u" (__exponent) : "0" (__x)); \ + __asm __volatile__ \ + ("fscale # 2^int(x * log2(e))\n\t" \ + : "=t" (__temp) : "0" (1.0), "u" (__exponent)); \ + __temp -= 1.0; \ + return __temp + __value +__inline_mathcode_ (long double, __expm1l, __x, __expm1_code) + + +#define __exp_code \ + register long double __value; \ + register long double __exponent; \ + __asm __volatile__ \ + ("fldl2e # e^x = 2^(x * log2(e))\n\t" \ + "fmul %%st(1) # x * log2(e)\n\t" \ + "fst %%st(1)\n\t" \ + "frndint # int(x * log2(e))\n\t" \ + "fxch\n\t" \ + "fsub %%st(1) # fract(x * log2(e))\n\t" \ + "f2xm1 # 2^(fract(x * log2(e))) - 1\n\t" \ + : "=t" (__value), "=u" (__exponent) : "0" (__x)); \ + __value += 1.0; \ + __asm __volatile__ \ + ("fscale" \ + : "=t" (__value) : "0" (__value), "u" (__exponent)); \ + return __value +__inline_mathcode (exp, __x, __exp_code) +__inline_mathcode_ (long double, __expl, __x, __exp_code) + + +__inline_mathcode (tan, __x, \ + register long double __value; \ + register long double __value2 __attribute__ ((__unused__)); \ + __asm __volatile__ \ + ("fptan" \ + : "=t" (__value2), "=u" (__value) : "0" (__x)); \ + return __value) + + +#define __atan2_code \ + register long double __value; \ + __asm __volatile__ \ + ("fpatan" \ + : "=t" (__value) : "0" (__x), "u" (__y) : "st(1)"); \ + return __value +__inline_mathcode2 (atan2, __y, __x, __atan2_code) +__inline_mathcode2_ (long double, __atan2l, __y, __x, __atan2_code) + + +__inline_mathcode2 (fmod, __x, __y, \ + register long double __value; \ + __asm __volatile__ \ + ("1: fprem\n\t" \ + "fnstsw %%ax\n\t" \ + "sahf\n\t" \ + "jp 1b" \ + : "=t" (__value) : "0" (__x), "u" (__y) : "ax", "cc"); \ + return __value) + + +__inline_mathcode2 (pow, __x, __y, \ + register long double __value; \ + register long double __exponent; \ + __extension__ long long int __p = (long long int) __y; \ + if (__x == 0.0 && __y > 0.0) \ + return 0.0; \ + if (__y == (double) __p) \ + { \ + long double __r = 1.0; \ + if (__p == 0) \ + return 1.0; \ + if (__p < 0) \ + { \ + __p = -__p; \ + __x = 1.0 / __x; \ + } \ + while (1) \ + { \ + if (__p & 1) \ + __r *= __x; \ + __p >>= 1; \ + if (__p == 0) \ + return __r; \ + __x *= __x; \ + } \ + /* NOTREACHED */ \ + } \ + __asm __volatile__ \ + ("fyl2x" : "=t" (__value) : "0" (__x), "u" (1.0) : "st(1)"); \ + __asm __volatile__ \ + ("fmul %%st(1) # y * log2(x)\n\t" \ + "fst %%st(1)\n\t" \ + "frndint # int(y * log2(x))\n\t" \ + "fxch\n\t" \ + "fsub %%st(1) # fract(y * log2(x))\n\t" \ + "f2xm1 # 2^(fract(y * log2(x))) - 1\n\t" \ + : "=t" (__value), "=u" (__exponent) : "0" (__y), "1" (__value)); \ + __value += 1.0; \ + __asm __volatile__ \ + ("fscale" \ + : "=t" (__value) : "0" (__value), "u" (__exponent)); \ + return __value) + + +__inline_mathop (sqrt, "fsqrt") +__inline_mathop_ (long double, __sqrtl, "fsqrt") + +#if defined __GNUC__ && (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ >= 8) +__inline_mathcode_ (double, fabs, __x, return __builtin_fabs (__x)) +__inline_mathcode_ (float, fabsf, __x, return __builtin_fabsf (__x)) +__inline_mathcode_ (long double, fabsl, __x, return __builtin_fabsl (__x)) +__inline_mathcode_ (long double, __fabsl, __x, return __builtin_fabsl (__x)) +#else +__inline_mathop (fabs, "fabs") +__inline_mathop_ (long double, __fabsl, "fabs") +#endif + +/* The argument range of this inline version is reduced. */ +__inline_mathop (sin, "fsin") +/* The argument range of this inline version is reduced. */ +__inline_mathop (cos, "fcos") + +__inline_mathop_decl (atan, "fld1; fpatan", "0" (__x) : "st(1)") +__inline_mathop_decl (log, "fldln2; fxch; fyl2x", "0" (__x) : "st(1)") +__inline_mathop_decl (log10, "fldlg2; fxch; fyl2x", "0" (__x) : "st(1)") + +__inline_mathcode (asin, __x, return __atan2l (__x, __sqrtl (1.0 - __x * __x))) +__inline_mathcode (acos, __x, return __atan2l (__sqrtl (1.0 - __x * __x), __x)) + +__inline_mathcode_ (long double, __sgn1l, __x, return __x >= 0.0 ? 1.0 : -1.0) + + +/* The argument range of the inline version of sinhl is slightly reduced. */ +__inline_mathcode (sinh, __x, \ + register long double __exm1 = __expm1l (__fabsl (__x)); \ + return 0.5 * (__exm1 / (__exm1 + 1.0) + __exm1) * __sgn1l (__x)) + +__inline_mathcode (cosh, __x, \ + register long double __ex = __expl (__x); \ + return 0.5 * (__ex + 1.0 / __ex)) + +__inline_mathcode (tanh, __x, \ + register long double __exm1 = __expm1l (-__fabsl (__x + __x)); \ + return __exm1 / (__exm1 + 2.0) * __sgn1l (-__x)) + + +__inline_mathcode (floor, __x, \ + register long double __value; \ + __volatile unsigned short int __cw; \ + __volatile unsigned short int __cwtmp; \ + __asm __volatile ("fnstcw %0" : "=m" (__cw)); \ + __cwtmp = (__cw & 0xf3ff) | 0x0400; /* rounding down */ \ + __asm __volatile ("fldcw %0" : : "m" (__cwtmp)); \ + __asm __volatile ("frndint" : "=t" (__value) : "0" (__x)); \ + __asm __volatile ("fldcw %0" : : "m" (__cw)); \ + return __value) + +__inline_mathcode (ceil, __x, \ + register long double __value; \ + __volatile unsigned short int __cw; \ + __volatile unsigned short int __cwtmp; \ + __asm __volatile ("fnstcw %0" : "=m" (__cw)); \ + __cwtmp = (__cw & 0xf3ff) | 0x0800; /* rounding up */ \ + __asm __volatile ("fldcw %0" : : "m" (__cwtmp)); \ + __asm __volatile ("frndint" : "=t" (__value) : "0" (__x)); \ + __asm __volatile ("fldcw %0" : : "m" (__cw)); \ + return __value) + +#define __ldexp_code \ + register long double __value; \ + __asm __volatile__ \ + ("fscale" \ + : "=t" (__value) : "0" (__x), "u" ((long double) __y)); \ + return __value + +__MATH_INLINE double ldexp (double __x, int __y); +__MATH_INLINE double +ldexp (double __x, int __y) +{ + __ldexp_code; +} + + +/* Optimized versions for some non-standardized functions. */ +#if defined __USE_ISOC9X || defined __USE_MISC + +__inline_mathcode (expm1, __x, __expm1_code) + +/* We cannot rely on M_SQRT being defined. So we do it for ourself + here. */ +# define __M_SQRT2 1.41421356237309504880L /* sqrt(2) */ + +__inline_mathcode (log1p, __x, \ + register long double __value; \ + if (__fabsl (__x) >= 1.0 - 0.5 * __M_SQRT2) \ + __value = logl (1.0 + __x); \ + else \ + __asm __volatile__ \ + ("fldln2\n\t" \ + "fxch\n\t" \ + "fyl2xp1" \ + : "=t" (__value) : "0" (__x) : "st(1)"); \ + return __value) + + +/* The argument range of the inline version of asinhl is slightly reduced. */ +__inline_mathcode (asinh, __x, \ + register long double __y = __fabsl (__x); \ + return (log1pl (__y * __y / (__sqrtl (__y * __y + 1.0) + 1.0) + __y) \ + * __sgn1l (__x))) + +__inline_mathcode (acosh, __x, \ + return logl (__x + __sqrtl (__x - 1.0) * __sqrtl (__x + 1.0))) + +__inline_mathcode (atanh, __x, \ + register long double __y = __fabsl (__x); \ + return -0.5 * log1pl (-(__y + __y) / (1.0 + __y)) * __sgn1l (__x)) + +/* The argument range of the inline version of hypotl is slightly reduced. */ +__inline_mathcode2 (hypot, __x, __y, return __sqrtl (__x * __x + __y * __y)) + +__inline_mathcode(logb, __x, \ + register long double __value; \ + register long double __junk; \ + __asm __volatile__ \ + ("fxtract\n\t" \ + : "=t" (__junk), "=u" (__value) : "0" (__x)); \ + return __value) + +#endif + +#ifdef __USE_ISOC9X +__inline_mathop_decl (log2, "fld1; fxch; fyl2x", "0" (__x) : "st(1)") + +__MATH_INLINE float ldexpf (float __x, int __y); +__MATH_INLINE float +ldexpf (float __x, int __y) +{ + __ldexp_code; +} + +__MATH_INLINE long double ldexpl (long double __x, int __y); +__MATH_INLINE long double +ldexpl (long double __x, int __y) +{ + __ldexp_code; +} + +__inline_mathcode3 (fma, __x, __y, __z, return (__x * __y) + __z) + +__inline_mathop(rint, "frndint") + +#define __lrint_code \ + long int __lrintres; \ + __asm__ __volatile__ \ + ("fistpl %0" \ + : "=m" (__lrintres) : "t" (__x) : "st"); \ + return __lrintres +__MATH_INLINE long int +lrintf (float __x) +{ + __lrint_code; +} +__MATH_INLINE long int +lrint (double __x) +{ + __lrint_code; +} +__MATH_INLINE long int +lrintl (long double __x) +{ + __lrint_code; +} +#undef __lrint_code + +#define __llrint_code \ + long long int __llrintres; \ + __asm__ __volatile__ \ + ("fistpll %0" \ + : "=m" (__llrintres) : "t" (__x) : "st"); \ + return __llrintres +__MATH_INLINE long long int +llrintf (float __x) +{ + __llrint_code; +} +__MATH_INLINE long long int +llrint (double __x) +{ + __llrint_code; +} +__MATH_INLINE long long int +llrintl (long double __x) +{ + __llrint_code; +} +#undef __llrint_code + +#endif + + +#ifdef __USE_MISC + +__inline_mathcode2 (drem, __x, __y, \ + register double __value; \ + register int __clobbered; \ + __asm __volatile__ \ + ("1: fprem1\n\t" \ + "fstsw %%ax\n\t" \ + "sahf\n\t" \ + "jp 1b" \ + : "=t" (__value), "=&a" (__clobbered) : "0" (__x), "u" (__y) : "cc"); \ + return __value) + + +/* This function is used in the `isfinite' macro. */ +__MATH_INLINE int __finite (double __x) __attribute__ ((__const__)); +__MATH_INLINE int +__finite (double __x) +{ + return (__extension__ + (((((union { double __d; int __i[2]; }) {__d: __x}).__i[1] + | 0x800fffffu) + 1) >> 31)); +} + +/* Miscellaneous functions */ + +__inline_mathcode (__coshm1, __x, \ + register long double __exm1 = __expm1l (__fabsl (__x)); \ + return 0.5 * (__exm1 / (__exm1 + 1.0)) * __exm1) + +__inline_mathcode (__acosh1p, __x, \ + return log1pl (__x + __sqrtl (__x) * __sqrtl (__x + 2.0))) + +#endif /* __USE_MISC */ + +/* Undefine some of the large macros which are not used anymore. */ +#undef __expm1_code +#undef __exp_code +#undef __atan2_code +#undef __sincos_code + +#endif /* __NO_MATH_INLINES */ + + +/* This code is used internally in the GNU libc. */ +#ifdef __LIBC_INTERNAL_MATH_INLINES +__inline_mathop (__ieee754_sqrt, "fsqrt") +__inline_mathcode2 (__ieee754_atan2, __y, __x, + register long double __value; + __asm __volatile__ ("fpatan\n\t" + : "=t" (__value) + : "0" (__x), "u" (__y) : "st(1)"); + return __value;) +#endif + +#endif /* __GNUC__ */ diff --git a/libc/sysdeps/linux/i386/bits/mman.h b/libc/sysdeps/linux/i386/bits/mman.h new file mode 100644 index 000000000..8738e98c3 --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/mman.h @@ -0,0 +1,75 @@ +/* Definitions for POSIX memory map interface. Linux/i386 version. + 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. */ + +#ifndef _SYS_MMAN_H +# error "Never use directly; include instead." +#endif + +/* The following definitions basically come from the kernel headers. + But the kernel header is not namespace clean. */ + + +/* Protections are chosen from these bits, OR'd together. The + implementation does not necessarily support PROT_EXEC or PROT_WRITE + without PROT_READ. The only guarantees are that no writing will be + allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */ + +#define PROT_READ 0x1 /* Page can be read. */ +#define PROT_WRITE 0x2 /* Page can be written. */ +#define PROT_EXEC 0x4 /* Page can be executed. */ +#define PROT_NONE 0x0 /* Page can not be accessed. */ + +/* Sharing types (must choose one and only one of these). */ +#define MAP_SHARED 0x01 /* Share changes. */ +#define MAP_PRIVATE 0x02 /* Changes are private. */ +#ifdef __USE_MISC +# define MAP_TYPE 0x0f /* Mask for type of mapping. */ +#endif + +/* Other flags. */ +#define MAP_FIXED 0x10 /* Interpret addr exactly. */ +#ifdef __USE_MISC +# define MAP_FILE 0 +# define MAP_ANONYMOUS 0x20 /* Don't use a file. */ +# define MAP_ANON MAP_ANONYMOUS +#endif + +/* These are Linux-specific. */ +#ifdef __USE_MISC +# define MAP_GROWSDOWN 0x0100 /* Stack-like segment. */ +# define MAP_DENYWRITE 0x0800 /* ETXTBSY */ +# define MAP_EXECUTABLE 0x1000 /* Mark it as an executable. */ +# define MAP_LOCKED 0x2000 /* Lock the mapping. */ +# define MAP_NORESERVE 0x4000 /* Don't check for reservations. */ +#endif + +/* Flags to `msync'. */ +#define MS_ASYNC 1 /* Sync memory asynchronously. */ +#define MS_SYNC 4 /* Synchronous memory sync. */ +#define MS_INVALIDATE 2 /* Invalidate the caches. */ + +/* Flags for `mlockall'. */ +#define MCL_CURRENT 1 /* Lock all currently mapped pages. */ +#define MCL_FUTURE 2 /* Lock all additions to address + space. */ + +/* Flags for `mremap'. */ +#ifdef __USE_GNU +# define MREMAP_MAYMOVE 1 +#endif diff --git a/libc/sysdeps/linux/i386/bits/msq.h b/libc/sysdeps/linux/i386/bits/msq.h new file mode 100644 index 000000000..d7a8e5ee0 --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/msq.h @@ -0,0 +1,70 @@ +/* Copyright (C) 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 _SYS_MSG_H +# error "Never use directly; include instead." +#endif + +#include + +/* Define options for message queue functions. */ +#define MSG_NOERROR 010000 /* no error if message is too big */ +#define MSG_EXCEPT 020000 /* recv any msg except of specified type */ + + +/* Structure of record for one message inside the kernel. + The type `struct msg' is opaque. */ +struct msqid_ds +{ + struct ipc_perm msg_perm; /* structure describing operation permission */ + struct msg *__msg_first; /* pointer to first message on queue */ + struct msg *__msg_last; /* pointer to last message on queue */ + __time_t msg_stime; /* time of last msgsnd command */ + __time_t msg_rtime; /* time of last msgrcv command */ + __time_t msg_ctime; /* time of last change */ + struct wait_queue *__wwait; /* ??? */ + struct wait_queue *__rwait; /* ??? */ + unsigned short int __msg_cbytes;/* current number of bytes on queue */ + unsigned short int msg_qnum; /* number of messages currently on queue */ + unsigned short int msg_qbytes;/* max number of bytes allowed on queue */ + __ipc_pid_t msg_lspid; /* pid of last msgsnd() */ + __ipc_pid_t msg_lrpid; /* pid of last msgrcv() */ +}; + +#ifdef __USE_MISC + +# define msg_cbytes __msg_cbytes + +/* ipcs ctl commands */ +# define MSG_STAT 11 +# define MSG_INFO 12 + +/* buffer for msgctl calls IPC_INFO, MSG_INFO */ +struct msginfo + { + int msgpool; + int msgmap; + int msgmax; + int msgmnb; + int msgmni; + int msgssz; + int msgtql; + unsigned short int msgseg; + }; + +#endif /* __USE_MISC */ diff --git a/libc/sysdeps/linux/i386/bits/nan.h b/libc/sysdeps/linux/i386/bits/nan.h new file mode 100644 index 000000000..fbabd7e29 --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/nan.h @@ -0,0 +1,48 @@ +/* `NAN' constant for IEEE 754 machines. + Copyright (C) 1992, 1996, 1997, 1999 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 _MATH_H +# error "Never use directly; include instead." +#endif + + +/* IEEE Not A Number. */ + +#ifdef __GNUC__ + +# define NAN \ + (__extension__ \ + ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) \ + { __l: 0x7fc00000UL }).__d) + +#else + +# include + +# if __BYTE_ORDER == __BIG_ENDIAN +# define __nan_bytes { 0x7f, 0xc0, 0, 0 } +# endif +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define __nan_bytes { 0, 0, 0xc0, 0x7f } +# endif + +static union { unsigned char __c[4]; float __d; } __nan_union = { __nan_bytes }; +# define NAN (__nan_union.__d) + +#endif /* GCC. */ diff --git a/libc/sysdeps/linux/i386/bits/pthreadtypes.h b/libc/sysdeps/linux/i386/bits/pthreadtypes.h new file mode 100644 index 000000000..db4c3790c --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/pthreadtypes.h @@ -0,0 +1,122 @@ +/* Linuxthreads - a simple clone()-based implementation of Posix */ +/* threads for Linux. */ +/* Copyright (C) 1996 Xavier Leroy (Xavier.Leroy@inria.fr) */ +/* */ +/* This program 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. */ +/* */ +/* This program 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. */ + +#if !defined _BITS_TYPES_H && !defined _PTHREAD_H +# error "Never include directly; use instead." +#endif + +#ifndef _BITS_PTHREADTYPES_H +#define _BITS_PTHREADTYPES_H 1 + +#define __need_schedparam +#include + +/* Fast locks (not abstract because mutexes and conditions aren't abstract). */ +struct _pthread_fastlock +{ + long int __status; /* "Free" or "taken" or head of waiting list */ + int __spinlock; /* For compare-and-swap emulation */ +}; + +#ifndef _PTHREAD_DESCR_DEFINED +/* Thread descriptors */ +typedef struct _pthread_descr_struct *_pthread_descr; +# define _PTHREAD_DESCR_DEFINED +#endif + + +/* Attributes for threads. */ +typedef struct +{ + int __detachstate; + int __schedpolicy; + struct __sched_param __schedparam; + int __inheritsched; + int __scope; + size_t __guardsize; + int __stackaddr_set; + void *__stackaddr; + size_t __stacksize; +} pthread_attr_t; + + +/* Conditions (not abstract because of PTHREAD_COND_INITIALIZER */ +typedef struct +{ + struct _pthread_fastlock __c_lock; /* Protect against concurrent access */ + _pthread_descr __c_waiting; /* Threads waiting on this condition */ +} pthread_cond_t; + + +/* Attribute for conditionally variables. */ +typedef struct +{ + int __dummy; +} pthread_condattr_t; + +/* Keys for thread-specific data */ +typedef unsigned int pthread_key_t; + + +/* Mutexes (not abstract because of PTHREAD_MUTEX_INITIALIZER). */ +/* (The layout is unnatural to maintain binary compatibility + with earlier releases of LinuxThreads.) */ +typedef struct +{ + int __m_reserved; /* Reserved for future use */ + int __m_count; /* Depth of recursive locking */ + _pthread_descr __m_owner; /* Owner thread (if recursive or errcheck) */ + int __m_kind; /* Mutex kind: fast, recursive or errcheck */ + struct _pthread_fastlock __m_lock; /* Underlying fast lock */ +} pthread_mutex_t; + + +/* Attribute for mutex. */ +typedef struct +{ + int __mutexkind; +} pthread_mutexattr_t; + + +/* Once-only execution */ +typedef int pthread_once_t; + + +#ifdef __USE_UNIX98 +/* Read-write locks. */ +typedef struct _pthread_rwlock_t +{ + struct _pthread_fastlock __rw_lock; /* Lock to guarantee mutual exclusion */ + int __rw_readers; /* Number of readers */ + _pthread_descr __rw_writer; /* Identity of writer, or NULL if none */ + _pthread_descr __rw_read_waiting; /* Threads waiting for reading */ + _pthread_descr __rw_write_waiting; /* Threads waiting for writing */ + int __rw_kind; /* Reader/Writer preference selection */ + int __rw_pshared; /* Shared between processes or not */ +} pthread_rwlock_t; + + +/* Attribute for read-write locks. */ +typedef struct +{ + int __lockkind; + int __pshared; +} pthread_rwlockattr_t; +#endif + + +/* Thread identifiers */ +typedef unsigned long int pthread_t; + +#endif /* bits/pthreadtypes.h */ diff --git a/libc/sysdeps/linux/i386/bits/resource.h b/libc/sysdeps/linux/i386/bits/resource.h new file mode 100644 index 000000000..b8a492373 --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/resource.h @@ -0,0 +1,205 @@ +/* Bit values & structures for resource limits. Linux version. + Copyright (C) 1994, 1996, 1997, 1998, 1999 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 _SYS_RESOURCE_H +# error "Never use directly; include instead." +#endif + +#include + +/* Transmute defines to enumerations. The macro re-definitions are + necessary because some programs want to test for operating system + features with #ifdef RUSAGE_SELF. In ISO C the reflexive + definition is a no-op. */ + +/* Kinds of resource limit. */ +enum __rlimit_resource +{ + /* Per-process CPU limit, in seconds. */ + RLIMIT_CPU = 0, +#define RLIMIT_CPU RLIMIT_CPU + + /* Largest file that can be created, in bytes. */ + RLIMIT_FSIZE = 1, +#define RLIMIT_FSIZE RLIMIT_FSIZE + + /* Maximum size of data segment, in bytes. */ + RLIMIT_DATA = 2, +#define RLIMIT_DATA RLIMIT_DATA + + /* Maximum size of stack segment, in bytes. */ + RLIMIT_STACK = 3, +#define RLIMIT_STACK RLIMIT_STACK + + /* Largest core file that can be created, in bytes. */ + RLIMIT_CORE = 4, +#define RLIMIT_CORE RLIMIT_CORE + + /* Largest resident set size, in bytes. + This affects swapping; processes that are exceeding their + resident set size will be more likely to have physical memory + taken from them. */ + RLIMIT_RSS = 5, +#define RLIMIT_RSS RLIMIT_RSS + + /* Number of open files. */ + RLIMIT_NOFILE = 7, + RLIMIT_OFILE = RLIMIT_NOFILE, /* BSD name for same. */ +#define RLIMIT_NOFILE RLIMIT_NOFILE +#define RLIMIT_OFILE RLIMIT_OFILE + + /* Address space limit. */ + RLIMIT_AS = 9, +#define RLIMIT_AS RLIMIT_AS + + /* Number of processes. */ + RLIMIT_NPROC = 6, +#define RLIMIT_NPROC RLIMIT_NPROC + + /* Locked-in-memory address space. */ + RLIMIT_MEMLOCK = 8, +#define RLIMIT_MEMLOCK RLIMIT_MEMLOCK + + RLIMIT_NLIMITS = 10, + RLIM_NLIMITS = RLIMIT_NLIMITS +#define RLIMIT_NLIMITS RLIMIT_NLIMITS +#define RLIM_NLIMITS RLIM_NLIMITS +}; + +/* Value to indicate that there is no limit. */ +#ifndef __USE_FILE_OFFSET64 +# define RLIM_INFINITY ((long int) (~0UL >> 1)) +#else +# define RLIM_INFINITY 0x7fffffffffffffffLL +#endif + +#ifdef __USE_LARGEFILE64 +# define RLIM64_INFINITY 0x7fffffffffffffffLL +#endif + +/* We can represent all limits. */ +#define RLIM_SAVED_MAX RLIM_INFINITY +#define RLIM_SAVED_CUR RLIM_INFINITY + + +/* Type for resource quantity measurement. */ +#ifndef __USE_FILE_OFFSET64 +typedef __rlim_t rlim_t; +#else +typedef __rlim64_t rlim_t; +#endif +#ifdef __USE_LARGEFILE64 +typedef __rlim64_t rlim64_t; +#endif + +struct rlimit + { + /* The current (soft) limit. */ + rlim_t rlim_cur; + /* The hard limit. */ + rlim_t rlim_max; + }; + +#ifdef __USE_LARGEFILE64 +struct rlimit64 + { + /* The current (soft) limit. */ + rlim64_t rlim_cur; + /* The hard limit. */ + rlim64_t rlim_max; + }; +#endif + +/* Whose usage statistics do you want? */ +enum __rusage_who +{ + /* The calling process. */ + RUSAGE_SELF = 0, +#define RUSAGE_SELF RUSAGE_SELF + + /* All of its terminated child processes. */ + RUSAGE_CHILDREN = -1, +#define RUSAGE_CHILDREN RUSAGE_CHILDREN + + /* Both. */ + RUSAGE_BOTH = -2 +#define RUSAGE_BOTH RUSAGE_BOTH +}; + +#define __need_timeval +#include /* For `struct timeval'. */ + +/* Structure which says how much of each resource has been used. */ +struct rusage + { + /* Total amount of user time used. */ + struct timeval ru_utime; + /* Total amount of system time used. */ + struct timeval ru_stime; + /* Maximum resident set size (in kilobytes). */ + long int ru_maxrss; + /* Amount of sharing of text segment memory + with other processes (kilobyte-seconds). */ + long int ru_ixrss; + /* Amount of data segment memory used (kilobyte-seconds). */ + long int ru_idrss; + /* Amount of stack memory used (kilobyte-seconds). */ + long int ru_isrss; + /* Number of soft page faults (i.e. those serviced by reclaiming + a page from the list of pages awaiting reallocation. */ + long int ru_minflt; + /* Number of hard page faults (i.e. those that required I/O). */ + long int ru_majflt; + /* Number of times a process was swapped out of physical memory. */ + long int ru_nswap; + /* Number of input operations via the file system. Note: This + and `ru_oublock' do not include operations with the cache. */ + long int ru_inblock; + /* Number of output operations via the file system. */ + long int ru_oublock; + /* Number of IPC messages sent. */ + long int ru_msgsnd; + /* Number of IPC messages received. */ + long int ru_msgrcv; + /* Number of signals delivered. */ + long int ru_nsignals; + /* Number of voluntary context switches, i.e. because the process + gave up the process before it had to (usually to wait for some + resource to be available). */ + long int ru_nvcsw; + /* Number of involuntary context switches, i.e. a higher priority process + became runnable or the current process used up its time slice. */ + long int ru_nivcsw; + }; + +/* Priority limits. */ +#define PRIO_MIN -20 /* Minimum priority a process can have. */ +#define PRIO_MAX 20 /* Maximum priority a process can have. */ + +/* The type of the WHICH argument to `getpriority' and `setpriority', + indicating what flavor of entity the WHO argument specifies. */ +enum __priority_which +{ + PRIO_PROCESS = 0, /* WHO is a process ID. */ +#define PRIO_PROCESS PRIO_PROCESS + PRIO_PGRP = 1, /* WHO is a process group ID. */ +#define PRIO_PGRP PRIO_PGRP + PRIO_USER = 2 /* WHO is a user ID. */ +#define PRIO_USER PRIO_USER +}; diff --git a/libc/sysdeps/linux/i386/bits/sched.h b/libc/sysdeps/linux/i386/bits/sched.h new file mode 100644 index 000000000..7e3c40eb4 --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/sched.h @@ -0,0 +1,73 @@ +/* Definitions of constants and data structure for POSIX 1003.1b-1993 + scheduling interface. + Copyright (C) 1996, 1997, 1998, 1999 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 __need_schedparam + +#ifndef _SCHED_H +# error "Never include directly; use instead." +#endif + + +/* Scheduling algorithms. */ +#define SCHED_OTHER 0 +#define SCHED_FIFO 1 +#define SCHED_RR 2 + +#ifdef __USE_MISC +/* Cloning flags. */ +# define CSIGNAL 0x000000ff /* Signal mask to be sent at exit. */ +# define CLONE_VM 0x00000100 /* Set if VM shared between processes. */ +# define CLONE_FS 0x00000200 /* Set if fs info shared between processes. */ +# define CLONE_FILES 0x00000400 /* Set if open files shared between processes. */ +# define CLONE_SIGHAND 0x00000800 /* Set if signal handlers shared. */ +# define CLONE_PID 0x00001000 /* Set if pid shared. */ +# define CLONE_PTRACE 0x00002000 /* Set if tracing continues on the child. */ +# define CLONE_VFORK 0x00004000 /* Set if the parent wants the child to + wake it up on mm_release. */ +#endif + +/* The official definition. */ +struct sched_param + { + int sched_priority; + }; + +__BEGIN_DECLS + +/* Clone current process. */ +#ifdef __USE_MISC +extern int clone __P ((int (*__fn) (void *__arg), void *__child_stack, + int __flags, void *__arg)); +#endif + +__END_DECLS + +#endif /* need schedparam */ + +#if !defined __defined_schedparam \ + && (defined __need_schedparam || defined _SCHED_H) +# define __defined_schedparam 1 +/* Data structure to describe a process' schedulability. */ +struct __sched_param + { + int sched_priority; + }; +# undef __need_schedparam +#endif diff --git a/libc/sysdeps/linux/i386/bits/sem.h b/libc/sysdeps/linux/i386/bits/sem.h new file mode 100644 index 000000000..3d113a74f --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/sem.h @@ -0,0 +1,88 @@ +/* Copyright (C) 1995, 1996, 1997, 1998 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 _SYS_SEM_H +# error "Never include directly; use instead." +#endif + +#include + +/* Flags for `semop'. */ +#define SEM_UNDO 0x1000 /* undo the operation on exit */ + +/* Commands for `semctl'. */ +#define GETPID 11 /* get sempid */ +#define GETVAL 12 /* get semval */ +#define GETALL 13 /* get all semval's */ +#define GETNCNT 14 /* get semncnt */ +#define GETZCNT 15 /* get semzcnt */ +#define SETVAL 16 /* set semval */ +#define SETALL 17 /* set all semval's */ + + +/* Data structure describing a set of semaphores. */ +struct semid_ds +{ + struct ipc_perm sem_perm; /* operation permission struct */ + __time_t sem_otime; /* last semop() time */ + __time_t sem_ctime; /* last time changed by semctl() */ + struct sem *__sembase; /* ptr to first semaphore in array */ + struct sem_queue *__sem_pending; /* pending operations */ + struct sem_queue *__sem_pending_last; /* last pending operation */ + struct sem_undo *__undo; /* ondo requests on this array */ + unsigned short int sem_nsems; /* number of semaphores in set */ +}; + + +/* The user should define a union like the following to use it for arguments + for `semctl'. + + union semun + { + int val; <= value for SETVAL + struct semid_ds *buf; <= buffer for IPC_STAT & IPC_SET + unsigned short int *array; <= array for GETALL & SETALL + struct seminfo *__buf; <= buffer for IPC_INFO + }; + + Previous versions of this file used to define this union but this is + incorrect. One can test the macro _SEM_SEMUN_UNDEFINED to see whether + one must define the union or not. */ +#define _SEM_SEMUN_UNDEFINED 1 + +#ifdef __USE_MISC + +/* ipcs ctl cmds */ +# define SEM_STAT 18 +# define SEM_INFO 19 + +struct seminfo +{ + int semmap; + int semmni; + int semmns; + int semmnu; + int semmsl; + int semopm; + int semume; + int semusz; + int semvmx; + int semaem; +}; + +#endif /* __USE_MISC */ diff --git a/libc/sysdeps/linux/i386/bits/stab.def b/libc/sysdeps/linux/i386/bits/stab.def new file mode 100644 index 000000000..48ea231e6 --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/stab.def @@ -0,0 +1,234 @@ +/* Table of DBX symbol codes for the GNU system. + Copyright (C) 1988, 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. */ + +/* This contains contribution from Cygnus Support. */ + +/* Global variable. Only the name is significant. + To find the address, look in the corresponding external symbol. */ +__define_stab (N_GSYM, 0x20, "GSYM") + +/* Function name for BSD Fortran. Only the name is significant. + To find the address, look in the corresponding external symbol. */ +__define_stab (N_FNAME, 0x22, "FNAME") + +/* Function name or text-segment variable for C. Value is its address. + Desc is supposedly starting line number, but GCC doesn't set it + and DBX seems not to miss it. */ +__define_stab (N_FUN, 0x24, "FUN") + +/* Data-segment variable with internal linkage. Value is its address. + "Static Sym". */ +__define_stab (N_STSYM, 0x26, "STSYM") + +/* BSS-segment variable with internal linkage. Value is its address. */ +__define_stab (N_LCSYM, 0x28, "LCSYM") + +/* Name of main routine. Only the name is significant. + This is not used in C. */ +__define_stab (N_MAIN, 0x2a, "MAIN") + +/* Global symbol in Pascal. + Supposedly the value is its line number; I'm skeptical. */ +__define_stab (N_PC, 0x30, "PC") + +/* Number of symbols: 0, files,,funcs,lines according to Ultrix V4.0. */ +__define_stab (N_NSYMS, 0x32, "NSYMS") + +/* "No DST map for sym: name, ,0,type,ignored" according to Ultrix V4.0. */ +__define_stab (N_NOMAP, 0x34, "NOMAP") + +/* New stab from Solaris. I don't know what it means, but it + don't seem to contain useful information. */ +__define_stab (N_OBJ, 0x38, "OBJ") + +/* New stab from Solaris. I don't know what it means, but it + don't seem to contain useful information. Possibly related to the + optimization flags used in this module. */ +__define_stab (N_OPT, 0x3c, "OPT") + +/* Register variable. Value is number of register. */ +__define_stab (N_RSYM, 0x40, "RSYM") + +/* Modula-2 compilation unit. Can someone say what info it contains? */ +__define_stab (N_M2C, 0x42, "M2C") + +/* Line number in text segment. Desc is the line number; + value is corresponding address. */ +__define_stab (N_SLINE, 0x44, "SLINE") + +/* Similar, for data segment. */ +__define_stab (N_DSLINE, 0x46, "DSLINE") + +/* Similar, for bss segment. */ +__define_stab (N_BSLINE, 0x48, "BSLINE") + +/* Sun's source-code browser stabs. ?? Don't know what the fields are. + Supposedly the field is "path to associated .cb file". THIS VALUE + OVERLAPS WITH N_BSLINE! */ +__define_stab (N_BROWS, 0x48, "BROWS") + +/* GNU Modula-2 definition module dependency. Value is the modification time + of the definition file. Other is non-zero if it is imported with the + GNU M2 keyword %INITIALIZE. Perhaps N_M2C can be used if there + are enough empty fields? */ +__define_stab(N_DEFD, 0x4a, "DEFD") + +/* THE FOLLOWING TWO STAB VALUES CONFLICT. Happily, one is for Modula-2 + and one is for C++. Still,... */ +/* GNU C++ exception variable. Name is variable name. */ +__define_stab (N_EHDECL, 0x50, "EHDECL") +/* Modula2 info "for imc": name,,0,0,0 according to Ultrix V4.0. */ +__define_stab (N_MOD2, 0x50, "MOD2") + +/* GNU C++ `catch' clause. Value is its address. Desc is nonzero if + this entry is immediately followed by a CAUGHT stab saying what exception + was caught. Multiple CAUGHT stabs means that multiple exceptions + can be caught here. If Desc is 0, it means all exceptions are caught + here. */ +__define_stab (N_CATCH, 0x54, "CATCH") + +/* Structure or union element. Value is offset in the structure. */ +__define_stab (N_SSYM, 0x60, "SSYM") + +/* Name of main source file. + Value is starting text address of the compilation. */ +__define_stab (N_SO, 0x64, "SO") + +/* Automatic variable in the stack. Value is offset from frame pointer. + Also used for type descriptions. */ +__define_stab (N_LSYM, 0x80, "LSYM") + +/* Beginning of an include file. Only Sun uses this. + In an object file, only the name is significant. + The Sun linker puts data into some of the other fields. */ +__define_stab (N_BINCL, 0x82, "BINCL") + +/* Name of sub-source file (#include file). + Value is starting text address of the compilation. */ +__define_stab (N_SOL, 0x84, "SOL") + +/* Parameter variable. Value is offset from argument pointer. + (On most machines the argument pointer is the same as the frame pointer. */ +__define_stab (N_PSYM, 0xa0, "PSYM") + +/* End of an include file. No name. + This and N_BINCL act as brackets around the file's output. + In an object file, there is no significant data in this entry. + The Sun linker puts data into some of the fields. */ +__define_stab (N_EINCL, 0xa2, "EINCL") + +/* Alternate entry point. Value is its address. */ +__define_stab (N_ENTRY, 0xa4, "ENTRY") + +/* Beginning of lexical block. + The desc is the nesting level in lexical blocks. + The value is the address of the start of the text for the block. + The variables declared inside the block *precede* the N_LBRAC symbol. */ +__define_stab (N_LBRAC, 0xc0, "LBRAC") + +/* Place holder for deleted include file. Replaces a N_BINCL and everything + up to the corresponding N_EINCL. The Sun linker generates these when + it finds multiple identical copies of the symbols from an include file. + This appears only in output from the Sun linker. */ +__define_stab (N_EXCL, 0xc2, "EXCL") + +/* Modula-2 scope information. Can someone say what info it contains? */ +__define_stab (N_SCOPE, 0xc4, "SCOPE") + +/* End of a lexical block. Desc matches the N_LBRAC's desc. + The value is the address of the end of the text for the block. */ +__define_stab (N_RBRAC, 0xe0, "RBRAC") + +/* Begin named common block. Only the name is significant. */ +__define_stab (N_BCOMM, 0xe2, "BCOMM") + +/* End named common block. Only the name is significant + (and it should match the N_BCOMM). */ +__define_stab (N_ECOMM, 0xe4, "ECOMM") + +/* End common (local name): value is address. + I'm not sure how this is used. */ +__define_stab (N_ECOML, 0xe8, "ECOML") + +/* These STAB's are used on Gould systems for Non-Base register symbols + or something like that. FIXME. I have assigned the values at random + since I don't have a Gould here. Fixups from Gould folk welcome... */ +__define_stab (N_NBTEXT, 0xF0, "NBTEXT") +__define_stab (N_NBDATA, 0xF2, "NBDATA") +__define_stab (N_NBBSS, 0xF4, "NBBSS") +__define_stab (N_NBSTS, 0xF6, "NBSTS") +__define_stab (N_NBLCS, 0xF8, "NBLCS") + +/* Second symbol entry containing a length-value for the preceding entry. + The value is the length. */ +__define_stab (N_LENG, 0xfe, "LENG") + +/* The above information, in matrix format. + + STAB MATRIX + _________________________________________________ + | 00 - 1F are not dbx stab symbols | + | In most cases, the low bit is the EXTernal bit| + + | 00 UNDEF | 02 ABS | 04 TEXT | 06 DATA | + | 01 |EXT | 03 |EXT | 05 |EXT | 07 |EXT | + + | 08 BSS | 0A INDR | 0C FN_SEQ | 0E | + | 09 |EXT | 0B | 0D | 0F | + + | 10 | 12 COMM | 14 SETA | 16 SETT | + | 11 | 13 | 15 | 17 | + + | 18 SETD | 1A SETB | 1C SETV | 1E WARNING| + | 19 | 1B | 1D | 1F FN | + + |_______________________________________________| + | Debug entries with bit 01 set are unused. | + | 20 GSYM | 22 FNAME | 24 FUN | 26 STSYM | + | 28 LCSYM | 2A MAIN | 2C | 2E | + | 30 PC | 32 NSYMS | 34 NOMAP | 36 | + | 38 OBJ | 3A | 3C OPT | 3E | + | 40 RSYM | 42 M2C | 44 SLINE | 46 DSLINE | + | 48 BSLINE*| 4A DEFD | 4C | 4E | + | 50 EHDECL*| 52 | 54 CATCH | 56 | + | 58 | 5A | 5C | 5E | + | 60 SSYM | 62 | 64 SO | 66 | + | 68 | 6A | 6C | 6E | + | 70 | 72 | 74 | 76 | + | 78 | 7A | 7C | 7E | + | 80 LSYM | 82 BINCL | 84 SOL | 86 | + | 88 | 8A | 8C | 8E | + | 90 | 92 | 94 | 96 | + | 98 | 9A | 9C | 9E | + | A0 PSYM | A2 EINCL | A4 ENTRY | A6 | + | A8 | AA | AC | AE | + | B0 | B2 | B4 | B6 | + | B8 | BA | BC | BE | + | C0 LBRAC | C2 EXCL | C4 SCOPE | C6 | + | C8 | CA | CC | CE | + | D0 | D2 | D4 | D6 | + | D8 | DA | DC | DE | + | E0 RBRAC | E2 BCOMM | E4 ECOMM | E6 | + | E8 ECOML | EA | EC | EE | + | F0 | F2 | F4 | F6 | + | F8 | FA | FC | FE LENG | + +-----------------------------------------------+ + * 50 EHDECL is also MOD2. + * 48 BSLINE is also BROWS. + */ diff --git a/libc/sysdeps/linux/i386/bits/statvfs.h b/libc/sysdeps/linux/i386/bits/statvfs.h new file mode 100644 index 000000000..fc6380684 --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/statvfs.h @@ -0,0 +1,94 @@ +/* Copyright (C) 1997, 1998 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 _SYS_STATVFS_H +# error "Never include directly; use instead." +#endif + +#include /* For __fsid_t, __fsblkcnt_t and __fsfilcnt_t. */ + +struct statvfs + { + unsigned long int f_bsize; + unsigned long int f_frsize; +#ifndef __USE_FILE_OFFSET64 + __fsblkcnt_t f_blocks; + __fsblkcnt_t f_bfree; + __fsblkcnt_t f_bavail; + __fsfilcnt_t f_files; + __fsfilcnt_t f_ffree; + __fsfilcnt_t f_favail; +#else + __fsblkcnt64_t f_blocks; + __fsblkcnt64_t f_bfree; + __fsblkcnt64_t f_bavail; + __fsfilcnt64_t f_files; + __fsfilcnt64_t f_ffree; + __fsfilcnt64_t f_favail; +#endif + __fsid_t f_fsid; + unsigned long int f_flag; + unsigned long int f_namemax; + int f_spare[6]; + }; + +#ifdef __USE_LARGEFILE64 +struct statvfs64 + { + unsigned long int f_bsize; + unsigned long int f_frsize; + __fsblkcnt64_t f_blocks; + __fsblkcnt64_t f_bfree; + __fsblkcnt64_t f_bavail; + __fsfilcnt64_t f_files; + __fsfilcnt64_t f_ffree; + __fsfilcnt64_t f_favail; + __fsid_t f_fsid; + unsigned long int f_flag; + unsigned long int f_namemax; + int f_spare[6]; + }; +#endif + +/* Definitions for the flag in `f_flag'. These definitions should be + kept in sync which the definitions in . */ +enum +{ + ST_RDONLY = 1, /* Mount read-only. */ +#define ST_RDONLY ST_RDONLY + ST_NOSUID = 2, /* Ignore suid and sgid bits. */ +#define ST_NOSUID ST_NOSUID + ST_NODEV = 4, /* Disallow access to device special files. */ +#define ST_NODEV ST_NODEV + ST_NOEXEC = 8, /* Disallow program execution. */ +#define ST_NOEXEC ST_NOEXEC + ST_SYNCHRONOUS = 16, /* Writes are synced at once. */ +#define ST_SYNCHRONOUS ST_SYNCHRONOUS + ST_MANDLOCK = 64, /* Allow mandatory locks on an FS. */ +#define ST_MANDLOCK ST_MANDLOCK + ST_WRITE = 128, /* Write on file/directory/symlink. */ +#define ST_WRITE ST_WRITE + ST_APPEND = 256, /* Append-only file. */ +#define ST_APPEND ST_APPEND + ST_IMMUTABLE = 512, /* Immutable file. */ +#define ST_IMMUTABLE ST_IMMUTABLE + ST_NOATIME = 1024, /* Do not update access times. */ +#define ST_NOATIME ST_NOATIME + ST_NODIRATIME /* Do not update directory access times. */ +#define ST_NODIRATIME ST_NODIRATIME +}; diff --git a/libc/sysdeps/linux/i386/bits/stdio-lock.h b/libc/sysdeps/linux/i386/bits/stdio-lock.h new file mode 100644 index 000000000..edc69f6cf --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/stdio-lock.h @@ -0,0 +1,39 @@ +/* Thread package specific definitions of stream lock type. + Copyright (C) 1996, 1997, 1998 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 + +typedef pthread_mutex_t _IO_lock_t; + +/* We need recursive (counting) mutexes. */ +#define _IO_lock_initializer PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP + + +#define _IO_cleanup_region_start(_fct, _fp) \ + __libc_cleanup_region_start (_fct, _fp) +#define _IO_cleanup_region_end(_doit) \ + __libc_cleanup_region_end (_doit) +#define _IO_lock_init(_name) \ + __libc_lock_init_recursive (_name) +#define _IO_lock_fini(_name) \ + __libc_lock_fini_recursive (_name) +#define _IO_lock_lock(_name) \ + __libc_lock_lock (_name) +#define _IO_lock_unlock(_name) \ + __libc_lock_unlock (_name) diff --git a/libc/sysdeps/linux/i386/bits/stdio.h b/libc/sysdeps/linux/i386/bits/stdio.h new file mode 100644 index 000000000..d69813255 --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/stdio.h @@ -0,0 +1,168 @@ +/* Optimizing macros and inline functions for stdio functions. + Copyright (C) 198 Free Software Foundation, Inc. + + 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 _STDIO_H +# error "Never include directly; use instead." +#endif + +#ifdef __cplusplus +# define __STDIO_INLINE inline +#else +# define __STDIO_INLINE extern __inline +#endif + + +#ifdef __USE_EXTERN_INLINES +/* Write formatted output to stdout from argument list ARG. */ +__STDIO_INLINE int +vprintf (__const char *__restrict __fmt, _G_va_list __arg) __THROW +{ + return vfprintf (stdout, __fmt, __arg); +} + +/* Read a character from stdin. */ +__STDIO_INLINE int +getchar (void) __THROW +{ + return _IO_getc (stdin); +} + + +# if defined __USE_POSIX || defined __USE_MISC +/* This is defined in POSIX.1:1996. */ +__STDIO_INLINE int +getc_unlocked (FILE *__fp) __THROW +{ + return _IO_getc_unlocked (__fp); +} + +/* This is defined in POSIX.1:1996. */ +__STDIO_INLINE int +getchar_unlocked (void) __THROW +{ + return _IO_getc_unlocked (stdin); +} +# endif /* POSIX || misc */ + + +/* Write a character to stdout. */ +__STDIO_INLINE int +putchar (int __c) __THROW +{ + return _IO_putc (__c, stdout); +} + + +# ifdef __USE_MISC +/* Faster version when locking is not necessary. */ +__STDIO_INLINE int +fputc_unlocked (int __c, FILE *__stream) __THROW +{ + return _IO_putc_unlocked (__c, __stream); +} +# endif /* misc */ + + +# if defined __USE_POSIX || defined __USE_MISC +/* This is defined in POSIX.1:1996. */ +__STDIO_INLINE int +putc_unlocked (int __c, FILE *__stream) __THROW +{ + return _IO_putc_unlocked (__c, __stream); +} + +/* This is defined in POSIX.1:1996. */ +__STDIO_INLINE int +putchar_unlocked (int __c) __THROW +{ + return _IO_putc_unlocked (__c, stdout); +} +# endif /* POSIX || misc */ + + +# ifdef __USE_GNU +/* Like `getdelim', but reads up to a newline. */ +__STDIO_INLINE _IO_ssize_t +getline (char **__lineptr, size_t *__n, FILE *__stream) __THROW +{ + return __getdelim (__lineptr, __n, '\n', __stream); +} +# endif /* GNU */ + + +# ifdef __USE_MISC +/* Faster versions when locking is not required. */ +__STDIO_INLINE int +feof_unlocked (FILE *__stream) __THROW +{ + return _IO_feof_unlocked (__stream); +} + +/* Faster versions when locking is not required. */ +__STDIO_INLINE int +ferror_unlocked (FILE *__stream) __THROW +{ + return _IO_ferror_unlocked (__stream); +} +# endif /* misc */ + +#endif /* Use extern inlines. */ + + +#if defined __USE_MISC && defined __GNUC__ && defined __OPTIMIZE__ +/* Perform some simple optimizations. */ +# define fread_unlocked(ptr, size, n, stream) \ + (__extension__ ((__builtin_constant_p (size) && __builtin_constant_p (n) \ + && (size_t) ((size) * (n)) <= 8 && (size) != 0) \ + ? ({ char *__ptr = (char *) (ptr); \ + FILE *__stream = (stream); \ + size_t __cnt; \ + for (__cnt = (size) * (n); __cnt > 0; --__cnt) \ + { \ + int __c = _IO_getc_unlocked (__stream); \ + if (__c == EOF) \ + break; \ + *__ptr++ = __c; \ + } \ + ((size_t) ((size) * (n)) - __cnt) / (size); }) \ + : (((__builtin_constant_p (size) && (size) == 0) \ + || (__builtin_constant_p (n) && (n) == 0)) \ + /* Evaluate all parameters once. */ \ + ? ((void) (ptr), (void) (stream), (void) (size), \ + (void) (n), 0) \ + : fread_unlocked (ptr, size, n, stream)))) + +# define fwrite_unlocked(ptr, size, n, stream) \ + (__extension__ ((__builtin_constant_p (size) && __builtin_constant_p (n) \ + && (size_t) ((size) * (n)) <= 8 && (size) != 0) \ + ? ({ const char *__ptr = (const char *) (ptr); \ + FILE *__stream = (stream); \ + size_t __cnt; \ + for (__cnt = (size) * (n); __cnt > 0; --__cnt) \ + if (_IO_putc_unlocked (*__ptr++, __stream) == EOF) \ + break; \ + ((size_t) ((size) * (n)) - __cnt) / (size); }) \ + : (((__builtin_constant_p (size) && (size) == 0) \ + || (__builtin_constant_p (n) && (n) == 0)) \ + /* Evaluate all parameters once. */ \ + ? ((void) (ptr), (void) (stream), (void) (size), n) \ + : fwrite_unlocked (ptr, size, n, stream)))) +#endif + +/* Define helper macro. */ +#undef __STDIO_INLINE diff --git a/libc/sysdeps/linux/i386/bits/string.h b/libc/sysdeps/linux/i386/bits/string.h new file mode 100644 index 000000000..44d6f8ba4 --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/string.h @@ -0,0 +1,876 @@ +/* Optimized, inlined string functions. i386 version. + Copyright (C) 1997, 1998, 1999 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 _STRING_H +# error "Never use directly; include instead." +#endif + +/* The ix86 processors can access unaligned multi-byte variables. */ +#define _STRING_ARCH_unaligned 1 + + +/* We only provide optimizations if the user selects them and if + GNU CC is used. */ +#if !defined __NO_STRING_INLINES && defined __USE_STRING_INLINES \ + && defined __GNUC__ && __GNUC__ >= 2 + +#ifndef __STRING_INLINE +# ifdef __cplusplus +# define __STRING_INLINE inline +# else +# define __STRING_INLINE extern __inline +# endif +#endif + + +/* Copy N bytes of SRC to DEST. */ +#define _HAVE_STRING_ARCH_memcpy 1 +#define memcpy(dest, src, n) \ + (__extension__ (__builtin_constant_p (n) \ + ? __memcpy_c (dest, src, n) \ + : memcpy (dest, src, n))) +/* This looks horribly ugly, but the compiler can optimize it totally, + as the count is constant. */ +__STRING_INLINE void *__memcpy_c (void *__dest, __const void *__src, + size_t __n); + +__STRING_INLINE void * +__memcpy_c (void *__dest, __const void *__src, size_t __n) +{ + register unsigned long int __d0, __d1, __d2; + union { + unsigned int __ui; + unsigned short int __usi; + unsigned char __uc; + } *__u = __dest; + switch (__n) + { + case 0: + return __dest; + case 1: + __u->__uc = *(const unsigned char *) __src; + return __dest; + case 2: + __u->__usi = *(const unsigned short int *) __src; + return __dest; + case 3: + __u->__usi = *(const unsigned short int *) __src; + __u = (void *) __u + 2; + __u->__uc = *(2 + (const unsigned char *) __src); + return __dest; + case 4: + __u->__ui = *(const unsigned int *) __src; + return __dest; + case 6: + __u->__ui = *(const unsigned int *) __src; + __u = (void *) __u + 4; + __u->__usi = *(2 + (const unsigned short int *) __src); + return __dest; + case 8: + __u->__ui = *(const unsigned int *) __src; + __u = (void *) __u + 4; + __u->__ui = *(1 + (const unsigned int *) __src); + return __dest; + case 12: + __u->__ui = *(const unsigned int *) __src; + __u = (void *) __u + 4; + __u->__ui = *(1 + (const unsigned int *) __src); + __u = (void *) __u + 4; + __u->__ui = *(2 + (const unsigned int *) __src); + return __dest; + case 16: + __u->__ui = *(const unsigned int *) __src; + __u = (void *) __u + 4; + __u->__ui = *(1 + (const unsigned int *) __src); + __u = (void *) __u + 4; + __u->__ui = *(2 + (const unsigned int *) __src); + __u = (void *) __u + 4; + __u->__ui = *(3 + (const unsigned int *) __src); + return __dest; + case 20: + __u->__ui = *(const unsigned int *) __src; + __u = (void *) __u + 4; + __u->__ui = *(1 + (const unsigned int *) __src); + __u = (void *) __u + 4; + __u->__ui = *(2 + (const unsigned int *) __src); + __u = (void *) __u + 4; + __u->__ui = *(3 + (const unsigned int *) __src); + __u = (void *) __u + 4; + __u->__ui = *(4 + (const unsigned int *) __src); + return __dest; + } +#define __COMMON_CODE(x) \ + __asm__ __volatile__ \ + ("cld\n\t" \ + "rep; movsl" \ + x \ + : "=&c" (__d0), "=&D" (__d1), "=&S" (__d2) \ + : "0" (__n / 4), "1" (&__u->__uc), "2" (__src) \ + : "memory"); + + switch (__n % 4) + { + case 0: + __COMMON_CODE (""); + break; + case 1: + __COMMON_CODE ("\n\tmovsb"); + break; + case 2: + __COMMON_CODE ("\n\tmovsw"); + break; + case 3: + __COMMON_CODE ("\n\tmovsw\n\tmovsb"); + break; + } + return __dest; +#undef __COMMON_CODE +} + + +/* Copy N bytes of SRC to DEST, guaranteeing + correct behavior for overlapping strings. */ +#define _HAVE_STRING_ARCH_memmove 1 +#ifndef _FORCE_INLINES +__STRING_INLINE void * +memmove (void *__dest, __const void *__src, size_t __n) +{ + register unsigned long int __d0, __d1, __d2; + if (__dest < __src) + __asm__ __volatile__ + ("cld\n\t" + "rep\n\t" + "movsb" + : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) + : "0" (__n), "1" (__src), "2" (__dest) + : "memory"); + else + __asm__ __volatile__ + ("std\n\t" + "rep\n\t" + "movsb\n\t" + "cld" + : "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) + : "0" (__n), "1" (__n - 1 + (const char *) __src), + "2" (__n - 1 + (char *) __dest) + : "memory"); + return __dest; +} +#endif + +/* Set N bytes of S to C. */ +#define _HAVE_STRING_ARCH_memset 1 +#define memset(s, c, n) \ + (__extension__ (__builtin_constant_p (c) \ + ? (__builtin_constant_p (n) \ + ? __memset_cc (s, 0x01010101UL * (unsigned char) (c), n) \ + : __memset_cg (s, 0x01010101UL * (unsigned char) (c), n))\ + : __memset_gg (s, c, n))) + +__STRING_INLINE void *__memset_cc (void *__s, unsigned long int __pattern, + size_t __n); + +__STRING_INLINE void * +__memset_cc (void *__s, unsigned long int __pattern, size_t __n) +{ + register unsigned long int __d0, __d1; + union { + unsigned int __ui; + unsigned short int __usi; + unsigned char __uc; + } *__u = __s; + switch (__n) + { + case 0: + return __s; + case 1: + __u->__uc = __pattern; + return __s; + case 2: + __u->__usi = __pattern; + return __s; + case 3: + __u->__usi = __pattern; + __u = __extension__ ((void *) __u + 2); + __u->__uc = __pattern; + return __s; + case 4: + __u->__ui = __pattern; + return __s; + } +#define __COMMON_CODE(x) \ + __asm__ __volatile__ \ + ("cld\n\t" \ + "rep; stosl" \ + x \ + : "=&c" (__d0), "=&D" (__d1) \ + : "a" (__pattern), "0" (__n / 4), "1" (&__u->__uc) \ + : "memory") + + switch (__n % 4) + { + case 0: + __COMMON_CODE (""); + break; + case 1: + __COMMON_CODE ("\n\tstosb"); + break; + case 2: + __COMMON_CODE ("\n\tstosw"); + break; + case 3: + __COMMON_CODE ("\n\tstosw\n\tstosb"); + break; + } + return __s; +#undef __COMMON_CODE +} + +__STRING_INLINE void *__memset_cg (void *__s, unsigned long __c, size_t __n); + +__STRING_INLINE void * +__memset_cg (void *__s, unsigned long __c, size_t __n) +{ + register unsigned long int __d0, __d1; + __asm__ __volatile__ + ("cld\n\t" + "rep; stosl\n\t" + "testb $2,%b3\n\t" + "je 1f\n\t" + "stosw\n" + "1:\n\t" + "testb $1,%b3\n\t" + "je 2f\n\t" + "stosb\n" + "2:" + : "=&c" (__d0), "=&D" (__d1) + : "a" (__c), "q" (__n), "0" (__n / 4), "1" (__s) + : "memory"); + return __s; +} + +__STRING_INLINE void *__memset_gg (void *__s, char __c, size_t __n); + +__STRING_INLINE void * +__memset_gg (void *__s, char __c, size_t __n) +{ + register unsigned long int __d0, __d1; + __asm__ __volatile__ + ("cld\n\t" + "rep; stosb" + : "=&D" (__d0), "=&c" (__d1) + : "a" (__c), "0" (__s), "1" (__n) + : "memory"); + return __s; +} + + + + +/* Search N bytes of S for C. */ +#define _HAVE_STRING_ARCH_memchr 1 +#ifndef _FORCE_INLINES +__STRING_INLINE void * +memchr (__const void *__s, int __c, size_t __n) +{ + register unsigned long int __d0; + register void *__res; + if (__n == 0) + return NULL; + __asm__ __volatile__ + ("cld\n\t" + "repne; scasb\n\t" + "je 1f\n\t" + "movl $1,%0\n" + "1:" + : "=D" (__res), "=&c" (__d0) + : "a" (__c), "0" (__s), "1" (__n)); + return __res - 1; +} +#endif + +/* Return the length of S. */ +#define _HAVE_STRING_ARCH_strlen 1 +#ifndef _FORCE_INLINES +__STRING_INLINE size_t +strlen (__const char *__str) +{ + register unsigned long int __d0; + register size_t __res; + __asm__ __volatile__ + ("cld\n\t" + "repne; scasb\n\t" + "notl %0" + : "=c" (__res), "=&D" (__d0) + : "1" (__str), "a" (0), "0" (0xffffffff) + : "cc"); + return __res - 1; +} +#endif + +/* Copy SRC to DEST. */ +#define _HAVE_STRING_ARCH_strcpy 1 +#ifndef _FORCE_INLINES +__STRING_INLINE char * +strcpy (char *__dest, __const char *__src) +{ + register unsigned long int __d0, __d1; + __asm__ __volatile__ + ("cld\n" + "1:\n\t" + "lodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b" + : "=&S" (__d0), "=&D" (__d1) + : "0" (__src), "1" (__dest) + : "ax", "memory", "cc"); + return __dest; +} +#endif + +/* Copy no more than N characters of SRC to DEST. */ +#define _HAVE_STRING_ARCH_strncpy 1 +#ifndef _FORCE_INLINES +__STRING_INLINE char * +strncpy (char *__dest, __const char *__src, size_t __n) +{ + register unsigned long int __d0, __d1, __d2; + __asm__ __volatile__ + ("cld\n" + "1:\n\t" + "decl %2\n\t" + "js 2f\n\t" + "lodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "rep; stosb\n" + "2:" + : "=&S" (__d0), "=&D" (__d1), "=&c" (__d2) + : "0" (__src), "1" (__dest), "2" (__n) + : "ax", "memory", "cc"); + return __dest; +} +#endif + +/* Append SRC onto DEST. */ +#define _HAVE_STRING_ARCH_strcat 1 +#ifndef _FORCE_INLINES +__STRING_INLINE char * +strcat (char *__dest, __const char *__src) +{ + register unsigned long int __d0, __d1, __d2, __d3; + __asm__ __volatile__ + ("cld\n\t" + "repne; scasb\n\t" + "decl %1\n" + "1:\n\t" + "lodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b" + : "=&S" (__d0), "=&D" (__d1), "=&c" (__d2), "=&a" (__d3) + : "0" (__src), "1" (__dest), "2" (0xffffffff), "3" (0) + : "memory", "cc"); + return __dest; +} +#endif + +/* Append no more than N characters from SRC onto DEST. */ +#define _HAVE_STRING_ARCH_strncat 1 +#ifndef _FORCE_INLINES +__STRING_INLINE char * +strncat (char *__dest, __const char *__src, size_t __n) +{ + register unsigned long int __d0, __d1, __d2, __d3; + __asm__ __volatile__ + ("cld\n\t" + "repne; scasb\n\t" + "decl %1\n\t" + "movl %4,%2\n" + "1:\n\t" + "decl %2\n\t" + "js 2f\n\t" + "lodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "jmp 3f\n" + "2:\n\t" + "xorl %3,%3\n\t" + "stosb\n" + "3:" + : "=&S" (__d0), "=&D" (__d1), "=&c" (__d2), "=&a" (__d3) + : "g" (__n), "0" (__src), "1" (__dest), "2" (0xffffffff), "3" (0) + : "memory", "cc"); + return __dest; +} +#endif + +/* Compare S1 and S2. */ +#define _HAVE_STRING_ARCH_strcmp 1 +#ifndef _FORCE_INLINES +__STRING_INLINE int +strcmp (__const char *__s1, __const char *__s2) +{ + register unsigned long int __d0, __d1; + register int __res; + __asm__ __volatile__ + ("cld\n" + "1:\n\t" + "lodsb\n\t" + "scasb\n\t" + "jne 2f\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "xorl %%eax,%%eax\n\t" + "jmp 3f\n" + "2:\n\t" + "sbbl %%eax,%%eax\n\t" + "orb $1,%%eax\n" + "3:" + : "=a" (__res), "=&S" (__d0), "=&D" (__d1) + : "1" (__s1), "2" (__s2) + : "cc"); + return __res; +} +#endif + +/* Compare N characters of S1 and S2. */ +#define _HAVE_STRING_ARCH_strncmp 1 +#ifndef _FORCE_INLINES +__STRING_INLINE int +strncmp (__const char *__s1, __const char *__s2, size_t __n) +{ + register unsigned long int __d0, __d1, __d2; + register int __res; + __asm__ __volatile__ + ("cld\n" + "1:\n\t" + "decl %3\n\t" + "js 2f\n\t" + "lodsb\n\t" + "scasb\n\t" + "jne 3f\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n" + "2:\n\t" + "xorl %%eax,%%eax\n\t" + "jmp 4f\n" + "3:\n\t" + "sbbl %%eax,%%eax\n\t" + "orb $1,%%al\n" + "4:" + : "=a" (__res), "=&S" (__d0), "=&D" (__d1), "=&c" (__d2) + : "1" (__s1), "2" (__s2), "3" (__n) + : "cc"); + return __res; +} +#endif + +/* Find the first occurrence of C in S. */ +#define _HAVE_STRING_ARCH_strchr 1 +#define strchr(s, c) \ + (__extension__ (__builtin_constant_p (c) \ + ? __strchr_c (s, ((c) & 0xff) << 8) \ + : __strchr_g (s, c))) + +__STRING_INLINE char *__strchr_g (__const char *__s, int __c); + +__STRING_INLINE char * +__strchr_g (__const char *__s, int __c) +{ + register unsigned long int __d0; + register char *__res; + __asm__ __volatile__ + ("cld\n\t" + "movb %%al,%%ah\n" + "1:\n\t" + "lodsb\n\t" + "cmpb %%ah,%%al\n\t" + "je 2f\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "movl $1,%1\n" + "2:\n\t" + "movl %1,%0" + : "=a" (__res), "=&S" (__d0) + : "0" (__c), "1" (__s) + : "cc"); + return __res - 1; +} + +__STRING_INLINE char *__strchr_c (__const char *__s, int __c); + +__STRING_INLINE char * +__strchr_c (__const char *__s, int __c) +{ + register unsigned long int __d0; + register char *__res; + __asm__ __volatile__ + ("cld\n\t" + "1:\n\t" + "lodsb\n\t" + "cmpb %%ah,%%al\n\t" + "je 2f\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "movl $1,%1\n" + "2:\n\t" + "movl %1,%0" + : "=a" (__res), "=&S" (__d0) + : "0" (__c), "1" (__s) + : "cc"); + return __res - 1; +} + + +/* Find the first occurrence of C in S or the final NUL byte. */ +#define _HAVE_STRING_ARCH_strchrnul 1 +#define __strchrnul(s, c) \ + (__extension__ (__builtin_constant_p (c) \ + ? ((c) == '\0' \ + ? (char *) __rawmemchr (s, c) \ + : __strchrnul_c (s, ((c) & 0xff) << 8)) \ + : __strchrnul_g (s, c))) + +__STRING_INLINE char *__strchrnul_g (__const char *__s, int __c); + +__STRING_INLINE char * +__strchrnul_g (__const char *__s, int __c) +{ + register unsigned long int __d0; + register char *__res; + __asm__ __volatile__ + ("cld\n\t" + "movb %%al,%%ah\n" + "1:\n\t" + "lodsb\n\t" + "cmpb %%ah,%%al\n\t" + "je 2f\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "2:\n\t" + "movl %1,%0" + : "=a" (__res), "=&S" (__d0) + : "0" (__c), "1" (__s) + : "cc"); + return __res - 1; +} + +__STRING_INLINE char *__strchrnul_c (__const char *__s, int __c); + +__STRING_INLINE char * +__strchrnul_c (__const char *__s, int __c) +{ + register unsigned long int __d0; + register char *__res; + __asm__ __volatile__ + ("cld\n\t" + "1:\n\t" + "lodsb\n\t" + "cmpb %%ah,%%al\n\t" + "je 2f\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "2:\n\t" + "movl %1,%0" + : "=a" (__res), "=&S" (__d0) + : "0" (__c), "1" (__s) + : "cc"); + return __res - 1; +} +#ifdef __USE_GNU +# define strchrnul(s, c) __strchrnul (s, c) +#endif + + +/* Return the length of the initial segment of S which + consists entirely of characters not in REJECT. */ +#define _HAVE_STRING_ARCH_strcspn 1 +#ifndef _FORCE_INLINES +# ifdef __PIC__ +__STRING_INLINE size_t +strcspn (__const char *__s, __const char *__reject) +{ + register unsigned long int __d0, __d1, __d2; + register char *__res; + __asm__ __volatile__ + ("pushl %%ebx\n\t" + "cld\n\t" + "movl %4,%%edi\n\t" + "repne; scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" + "movl %%ecx,%%ebx\n" + "1:\n\t" + "lodsb\n\t" + "testb %%al,%%al\n\t" + "je 2f\n\t" + "movl %4,%%edi\n\t" + "movl %%ebx,%%ecx\n\t" + "repne; scasb\n\t" + "jne 1b\n" + "2:\n\t" + "popl %%ebx" + : "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) + : "d" (__reject), "0" (__s), "1" (0), "2" (0xffffffff) + : "cc"); + return (__res - 1) - __s; +} +# else +__STRING_INLINE size_t +strcspn (__const char *__s, __const char *__reject) +{ + register unsigned long int __d0, __d1, __d2, __d3; + register char *__res; + __asm__ __volatile__ + ("cld\n\t" + "movl %5,%%edi\n\t" + "repne; scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" + "movl %%ecx,%%edx\n" + "1:\n\t" + "lodsb\n\t" + "testb %%al,%%al\n\t" + "je 2f\n\t" + "movl %5,%%edi\n\t" + "movl %%edx,%%ecx\n\t" + "repne; scasb\n\t" + "jne 1b\n" + "2:" + : "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&d" (__d2), "=&D" (__d3) + : "g" (__reject), "0" (__s), "1" (0), "2" (0xffffffff) + : "cc"); + return (__res - 1) - __s; +} +# endif +#endif + + +/* Return the length of the initial segment of S which + consists entirely of characters in ACCEPT. */ +#define _HAVE_STRING_ARCH_strspn 1 +#ifndef _FORCE_INLINES +# ifdef __PIC__ +__STRING_INLINE size_t +strspn (__const char *__s, __const char *__accept) +{ + register unsigned long int __d0, __d1, __d2; + register char *__res; + __asm__ __volatile__ + ("pushl %%ebx\n\t" + "cld\n\t" + "movl %4,%%edi\n\t" + "repne; scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" + "movl %%ecx,%%ebx\n" + "1:\n\t" + "lodsb\n\t" + "testb %%al,%%al\n\t" + "je 2f\n\t" + "movl %4,%%edi\n\t" + "movl %%ebx,%%ecx\n\t" + "repne; scasb\n\t" + "je 1b\n" + "2:\n\t" + "popl %%ebx" + : "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) + : "r" (__accept), "0" (__s), "1" (0), "2" (0xffffffff) + : "cc"); + return (__res - 1) - __s; +} +# else +__STRING_INLINE size_t +strspn (__const char *__s, __const char *__accept) +{ + register unsigned long int __d0, __d1, __d2, __d3; + register char *__res; + __asm__ __volatile__ + ("cld\n\t" + "movl %5,%%edi\n\t" + "repne; scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" + "movl %%ecx,%%edx\n" + "1:\n\t" + "lodsb\n\t" + "testb %%al,%%al\n\t" + "je 2f\n\t" + "movl %5,%%edi\n\t" + "movl %%edx,%%ecx\n\t" + "repne; scasb\n\t" + "je 1b\n" + "2:" + : "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&d" (__d2), "=&D" (__d3) + : "g" (__accept), "0" (__s), "1" (0), "2" (0xffffffff) + : "cc"); + return (__res - 1) - __s; +} +# endif +#endif + + +/* Find the first occurrence in S of any character in ACCEPT. */ +#define _HAVE_STRING_ARCH_strpbrk 1 +#ifndef _FORCE_INLINES +# ifdef __PIC__ +__STRING_INLINE char * +strpbrk (__const char *__s, __const char *__accept) +{ + unsigned long int __d0, __d1, __d2; + register char *__res; + __asm__ __volatile__ + ("pushl %%ebx\n\t" + "cld\n\t" + "movl %4,%%edi\n\t" + "repne; scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" + "movl %%ecx,%%ebx\n" + "1:\n\t" + "lodsb\n\t" + "testb %%al,%%al\n\t" + "je 2f\n\t" + "movl %4,%%edi\n\t" + "movl %%ebx,%%ecx\n\t" + "repne; scasb\n\t" + "jne 1b\n\t" + "decl %0\n\t" + "jmp 3f\n" + "2:\n\t" + "xorl %0,%0\n" + "3:\n\t" + "popl %%ebx" + : "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2) + : "r" (__accept), "0" (__s), "1" (0), "2" (0xffffffff) + : "cc"); + return __res; +} +# else +__STRING_INLINE char * +strpbrk (__const char *__s, __const char *__accept) +{ + register unsigned long int __d0, __d1, __d2, __d3; + register char *__res; + __asm__ __volatile__ + ("cld\n\t" + "movl %5,%%edi\n\t" + "repne; scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" + "movl %%ecx,%%edx\n" + "1:\n\t" + "lodsb\n\t" + "testb %%al,%%al\n\t" + "je 2f\n\t" + "movl %5,%%edi\n\t" + "movl %%edx,%%ecx\n\t" + "repne; scasb\n\t" + "jne 1b\n\t" + "decl %0\n\t" + "jmp 3f\n" + "2:\n\t" + "xorl %0,%0\n" + "3:" + : "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&d" (__d2), "=&D" (__d3) + : "g" (__accept), "0" (__s), "1" (0), "2" (0xffffffff) + : "cc"); + return __res; +} +# endif +#endif + + +/* Find the first occurrence of NEEDLE in HAYSTACK. */ +#define _HAVE_STRING_ARCH_strstr 1 +#ifndef _FORCE_INLINES +# ifdef __PIC__ +__STRING_INLINE char * +strstr (__const char *__haystack, __const char *__needle) +{ + register unsigned long int __d0, __d1, __d2; + register char *__res; + __asm__ __volatile__ + ("pushl %%ebx\n\t" + "cld\n\t" \ + "movl %4,%%edi\n\t" + "repne; scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */ + "movl %%ecx,%%ebx\n" + "1:\n\t" + "movl %4,%%edi\n\t" + "movl %%esi,%%eax\n\t" + "movl %%ebx,%%ecx\n\t" + "repe; cmpsb\n\t" + "je 2f\n\t" /* also works for empty string, see above */ + "xchgl %%eax,%%esi\n\t" + "incl %%esi\n\t" + "cmpb $0,-1(%%eax)\n\t" + "jne 1b\n\t" + "xorl %%eax,%%eax\n\t" + "2:\n\t" + "popl %%ebx" + : "=&a" (__res), "=&c" (__d0), "=&S" (__d1), "=&D" (__d2) + : "r" (__needle), "0" (0), "1" (0xffffffff), "2" (__haystack) + : "cc"); + return __res; +} +# else +__STRING_INLINE char * +strstr (__const char *__haystack, __const char *__needle) +{ + register unsigned long int __d0, __d1, __d2, __d3; + register char *__res; + __asm__ __volatile__ + ("cld\n\t" \ + "movl %5,%%edi\n\t" + "repne; scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */ + "movl %%ecx,%%edx\n" + "1:\n\t" + "movl %5,%%edi\n\t" + "movl %%esi,%%eax\n\t" + "movl %%edx,%%ecx\n\t" + "repe; cmpsb\n\t" + "je 2f\n\t" /* also works for empty string, see above */ + "xchgl %%eax,%%esi\n\t" + "incl %%esi\n\t" + "cmpb $0,-1(%%eax)\n\t" + "jne 1b\n\t" + "xorl %%eax,%%eax\n\t" + "2:" + : "=&a" (__res), "=&c" (__d0), "=&S" (__d1), "=&d" (__d2), "=&D" (__d3) + : "g" (__needle), "0" (0), "1" (0xffffffff), "2" (__haystack) + : "cc"); + return __res; +} +# endif +#endif + +#ifndef _FORCE_INLINES +# undef __STRING_INLINE +#endif + +#endif /* use string inlines && GNU CC */ diff --git a/libc/sysdeps/linux/i386/bits/string2.h b/libc/sysdeps/linux/i386/bits/string2.h new file mode 100644 index 000000000..734f5b0e3 --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/string2.h @@ -0,0 +1,1214 @@ +/* Machine-independant string function optimizations. + Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _STRING_H +# error "Never use directly; include instead." +#endif + +#ifndef __NO_STRING_INLINES + +/* Unlike the definitions in the header the + definitions contained here are not optimized down to assembler + level. Those optimizations are not always a good idea since this + means the code size increases a lot. Instead the definitions here + optimize some functions in a way which do not dramatically + increase the code size and which do not use assembler. The main + trick is to use GNU CC's `__builtin_constant_p' function. + + Every function XXX which has a defined version in + must be accompanied by a symbol _HAVE_STRING_ARCH_XXX + to make sure we don't get redefinitions. + + We must use here macros instead of inline functions since the + trick won't work with the latter. */ + +#ifndef __STRING_INLINE +# ifdef __cplusplus +# define __STRING_INLINE inline +# else +# define __STRING_INLINE extern __inline +# endif +#endif + +#if _STRING_ARCH_unaligned +/* If we can do unaligned memory accesses we must know the endianess. */ +# include +# include + +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define __STRING2_SMALL_GET16(src, idx) \ + (((__const unsigned char *) (__const char *) (src))[idx + 1] << 8 \ + | ((__const unsigned char *) (__const char *) (src))[idx]) +# define __STRING2_SMALL_GET32(src, idx) \ + (((((__const unsigned char *) (__const char *) (src))[idx + 3] << 8 \ + | ((__const unsigned char *) (__const char *) (src))[idx + 2]) << 8 \ + | ((__const unsigned char *) (__const char *) (src))[idx + 1]) << 8 \ + | ((__const unsigned char *) (__const char *) (src))[idx]) +# else +# define __STRING2_SMALL_GET16(src, idx) \ + (((__const unsigned char *) (__const char *) (src))[idx] << 8 \ + | ((__const unsigned char *) (__const char *) (src))[idx + 1]) +# define __STRING2_SMALL_GET32(src, idx) \ + (((((__const unsigned char *) (__const char *) (src))[idx] << 8 \ + | ((__const unsigned char *) (__const char *) (src))[idx + 1]) << 8 \ + | ((__const unsigned char *) (__const char *) (src))[idx + 2]) << 8 \ + | ((__const unsigned char *) (__const char *) (src))[idx + 3]) +# endif +#else +/* These are a few types we need for the optimizations if we cannot + use unaligned memory accesses. */ +# define __STRING2_COPY_TYPE(N) \ + typedef struct { unsigned char __arr[N]; } \ + __STRING2_COPY_ARR##N __attribute__ ((packed)) +__STRING2_COPY_TYPE (2); +__STRING2_COPY_TYPE (3); +__STRING2_COPY_TYPE (4); +__STRING2_COPY_TYPE (5); +__STRING2_COPY_TYPE (6); +__STRING2_COPY_TYPE (7); +__STRING2_COPY_TYPE (8); +# undef __STRING2_COPY_TYPE +#endif + +/* Dereferencing a pointer arg to run sizeof on it fails for the void + pointer case, so we use this instead. + Note that __x is evaluated twice. */ +#define __string2_1bptr_p(__x) \ + ((size_t)(const void *)((__x) + 1) - (size_t)(const void *)(__x) == 1) + +/* Set N bytes of S to C. */ +#ifndef _HAVE_STRING_ARCH_memset +# if _STRING_ARCH_unaligned +# define memset(s, c, n) \ + (__extension__ (__builtin_constant_p (n) && (n) <= 16 \ + ? ((n) == 1 \ + ? __memset_1 (s, c) \ + : __memset_gc (s, c, n)) \ + : (__builtin_constant_p (c) && (c) == '\0' \ + ? ({ void *__s = (s); __bzero (__s, n); __s; }) \ + : memset (s, c, n)))) + +# define __memset_1(s, c) ({ void *__s = (s); \ + *((__uint8_t *) __s) = (__uint8_t) c; __s; }) + +# define __memset_gc(s, c, n) \ + ({ void *__s = (s); \ + union { \ + unsigned int __ui; \ + unsigned short int __usi; \ + unsigned char __uc; \ + } *__u = __s; \ + __uint8_t __c = (__uint8_t) (c); \ + \ + /* This `switch' statement will be removed at compile-time. */ \ + switch ((unsigned int) (n)) \ + { \ + case 15: \ + __u->__ui = __c * 0x01010101; \ + __u = __extension__ (void *)((char *) __u + 4); \ + case 11: \ + __u->__ui = __c * 0x01010101; \ + __u = __extension__ (void *)((char *) __u + 4); \ + case 7: \ + __u->__ui = __c * 0x01010101; \ + __u = __extension__ (void *)((char *) __u + 4); \ + case 3: \ + __u->__usi = (unsigned short int) __c * 0x0101; \ + __u = __extension__ (void *)((char *) __u + 2); \ + __u->__uc = (unsigned char) __c; \ + break; \ + \ + case 14: \ + __u->__ui = __c * 0x01010101; \ + __u = __extension__ (void *)((char *) __u + 4); \ + case 10: \ + __u->__ui = __c * 0x01010101; \ + __u = __extension__ (void *)((char *) __u + 4); \ + case 6: \ + __u->__ui = __c * 0x01010101; \ + __u = __extension__ (void *)((char *) __u + 4); \ + case 2: \ + __u->__usi = (unsigned short int) __c * 0x0101; \ + break; \ + \ + case 13: \ + __u->__ui = __c * 0x01010101; \ + __u = __extension__ (void *)((char *) __u + 4); \ + case 9: \ + __u->__ui = __c * 0x01010101; \ + __u = __extension__ (void *)((char *) __u + 4); \ + case 5: \ + __u->__ui = __c * 0x01010101; \ + __u = __extension__ (void *)((char *) __u + 4); \ + case 1: \ + __u->__uc = (unsigned char) __c; \ + break; \ + \ + case 16: \ + __u->__ui = __c * 0x01010101; \ + __u = __extension__ (void *)((char *) __u + 4); \ + case 12: \ + __u->__ui = __c * 0x01010101; \ + __u = __extension__ (void *)((char *) __u + 4); \ + case 8: \ + __u->__ui = __c * 0x01010101; \ + __u = __extension__ (void *)((char *) __u + 4); \ + case 4: \ + __u->__ui = __c * 0x01010101; \ + case 0: \ + break; \ + } \ + \ + __s; }) +# else +# define memset(s, c, n) \ + (__extension__ (__builtin_constant_p (c) && (c) == '\0' \ + ? ({ void *__s = (s); __bzero (__s, n); __s; }) \ + : memset (s, c, n))) +# endif + +/* GCC optimizes memset(s, 0, n) but not bzero(s, n). + The optimization is broken before EGCS 1.1. */ +# if defined __GNUC__ \ + && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 90)) +# define __bzero(s, n) __builtin_memset (s, '\0', n) +# endif + +#endif + + +/* Copy N bytes from SRC to DEST, returning pointer to byte following the + last copied. */ +#ifdef __USE_GNU +# ifndef _HAVE_STRING_ARCH_mempcpy +# define __mempcpy(dest, src, n) \ + (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \ + && __string2_1bptr_p (src) && n <= 8 \ + ? __mempcpy_small (dest, __mempcpy_args (src), n) \ + : __mempcpy (dest, src, n))) +/* In glibc we use this function frequently but for namespace reasons + we have to use the name `__mempcpy'. */ +# define mempcpy(dest, src, n) __mempcpy (dest, src, n) + +# if _STRING_ARCH_unaligned +# define __mempcpy_args(src) \ + ((char *) (src))[0], ((char *) (src))[2], ((char *) (src))[4], \ + ((char *) (src))[6], \ + __extension__ __STRING2_SMALL_GET16 (src, 0), \ + __extension__ __STRING2_SMALL_GET16 (src, 4), \ + __extension__ __STRING2_SMALL_GET32 (src, 0), \ + __extension__ __STRING2_SMALL_GET32 (src, 4) +__STRING_INLINE void *__mempcpy_small (void *, char, char, char, char, + __uint16_t, __uint16_t, __uint32_t, + __uint32_t, size_t); +__STRING_INLINE void * +__mempcpy_small (void *__dest1, + char __src0_1, char __src2_1, char __src4_1, char __src6_1, + __uint16_t __src0_2, __uint16_t __src4_2, + __uint32_t __src0_4, __uint32_t __src4_4, + size_t __srclen) +{ + union { + __uint32_t __ui; + __uint16_t __usi; + unsigned char __uc; + unsigned char __c; + } *__u = __dest1; + switch ((unsigned int) __srclen) + { + case 1: + __u->__c = __src0_1; + __u = __extension__ (void *)((char *) __u + 1); + break; + case 2: + __u->__usi = __src0_2; + __u = __extension__ (void *)((char *) __u + 2); + break; + case 3: + __u->__usi = __src0_2; + __u = __extension__ (void *)((char *) __u + 2); + __u->__c = __src2_1; + __u = __extension__ (void *)((char *) __u + 1); + break; + case 4: + __u->__ui = __src0_4; + __u = __extension__ (void *)((char *) __u + 4); + break; + case 5: + __u->__ui = __src0_4; + __u = __extension__ (void *)((char *) __u + 4); + __u->__c = __src4_1; + __u = __extension__ (void *)((char *) __u + 1); + break; + case 6: + __u->__ui = __src0_4; + __u = __extension__ (void *)((char *) __u + 4); + __u->__usi = __src4_2; + __u = __extension__ (void *)((char *) __u + 2); + break; + case 7: + __u->__ui = __src0_4; + __u = __extension__ (void *)((char *) __u + 4); + __u->__usi = __src4_2; + __u = __extension__ (void *)((char *) __u + 2); + __u->__c = __src6_1; + __u = __extension__ (void *)((char *) __u + 1); + break; + case 8: + __u->__ui = __src0_4; + __u = __extension__ (void *)((char *) __u + 4); + __u->__ui = __src4_4; + __u = __extension__ (void *)((char *) __u + 4); + break; + } + return (void *) __u; +} +# else +# define __mempcpy_args(src) \ + ((__const char *) (src))[0], \ + __extension__ ((__STRING2_COPY_ARR2) \ + { { ((__const char *) (src))[0], ((__const char *) (src))[1] } }), \ + __extension__ ((__STRING2_COPY_ARR3) \ + { { ((__const char *) (src))[0], ((__const char *) (src))[1], \ + ((__const char *) (src))[2] } }), \ + __extension__ ((__STRING2_COPY_ARR4) \ + { { ((__const char *) (src))[0], ((__const char *) (src))[1], \ + ((__const char *) (src))[2], ((__const char *) (src))[3] } }), \ + __extension__ ((__STRING2_COPY_ARR5) \ + { { ((__const char *) (src))[0], ((__const char *) (src))[1], \ + ((__const char *) (src))[2], ((__const char *) (src))[3], \ + ((__const char *) (src))[4] } }), \ + __extension__ ((__STRING2_COPY_ARR6) \ + { { ((__const char *) (src))[0], ((__const char *) (src))[1], \ + ((__const char *) (src))[2], ((__const char *) (src))[3], \ + ((__const char *) (src))[4], ((__const char *) (src))[5] } }), \ + __extension__ ((__STRING2_COPY_ARR7) \ + { { ((__const char *) (src))[0], ((__const char *) (src))[1], \ + ((__const char *) (src))[2], ((__const char *) (src))[3], \ + ((__const char *) (src))[4], ((__const char *) (src))[5], \ + ((__const char *) (src))[6] } }), \ + __extension__ ((__STRING2_COPY_ARR8) \ + { { ((__const char *) (src))[0], ((__const char *) (src))[1], \ + ((__const char *) (src))[2], ((__const char *) (src))[3], \ + ((__const char *) (src))[4], ((__const char *) (src))[5], \ + ((__const char *) (src))[6], ((__const char *) (src))[7] } }) +__STRING_INLINE void *__mempcpy_small (void *, char, __STRING2_COPY_ARR2, + __STRING2_COPY_ARR3, + __STRING2_COPY_ARR4, + __STRING2_COPY_ARR5, + __STRING2_COPY_ARR6, + __STRING2_COPY_ARR7, + __STRING2_COPY_ARR8, size_t); +__STRING_INLINE void * +__mempcpy_small (void *__dest, char __src1, + __STRING2_COPY_ARR2 __src2, __STRING2_COPY_ARR3 __src3, + __STRING2_COPY_ARR4 __src4, __STRING2_COPY_ARR5 __src5, + __STRING2_COPY_ARR6 __src6, __STRING2_COPY_ARR7 __src7, + __STRING2_COPY_ARR8 __src8, size_t __srclen) +{ + union { + char __c; + __STRING2_COPY_ARR2 __sca2; + __STRING2_COPY_ARR3 __sca3; + __STRING2_COPY_ARR4 __sca4; + __STRING2_COPY_ARR5 __sca5; + __STRING2_COPY_ARR6 __sca6; + __STRING2_COPY_ARR7 __sca7; + __STRING2_COPY_ARR8 __sca8; + } *__u = __dest; + switch ((unsigned int) __srclen) + { + case 1: + __u->__c = __src1; + break; + case 2: + __extension__ __u->__sca2 = __src2; + break; + case 3: + __extension__ __u->__sca3 = __src3; + break; + case 4: + __extension__ __u->__sca4 = __src4; + break; + case 5: + __extension__ __u->__sca5 = __src5; + break; + case 6: + __extension__ __u->__sca6 = __src6; + break; + case 7: + __extension__ __u->__sca7 = __src7; + break; + case 8: + __extension__ __u->__sca8 = __src8; + break; + } + return __extension__ (void *)((char *) __u + __srclen); +} +# endif +# endif +#endif + + +/* Return pointer to C in S. */ +#ifndef _HAVE_STRING_ARCH_strchr +extern __ptr_t __rawmemchr (const __ptr_t __s, int __c); +# define strchr(s, c) \ + (__extension__ (__builtin_constant_p (c) && (c) == '\0' \ + ? (char *) __rawmemchr (s, c) \ + : strchr (s, c))) +#endif + + +/* Copy SRC to DEST. */ +#ifndef _HAVE_STRING_ARCH_strcpy +# define strcpy(dest, src) \ + (__extension__ (__builtin_constant_p (src) \ + ? (__string2_1bptr_p (src) && strlen (src) + 1 <= 8 \ + ? __strcpy_small (dest, __strcpy_args (src), \ + strlen (src) + 1) \ + : (char *) memcpy (dest, src, strlen (src) + 1)) \ + : strcpy (dest, src))) + +# if _STRING_ARCH_unaligned +# define __strcpy_args(src) \ + __extension__ __STRING2_SMALL_GET16 (src, 0), \ + __extension__ __STRING2_SMALL_GET16 (src, 4), \ + __extension__ __STRING2_SMALL_GET32 (src, 0), \ + __extension__ __STRING2_SMALL_GET32 (src, 4) +__STRING_INLINE char *__strcpy_small (char *, __uint16_t, __uint16_t, + __uint32_t, __uint32_t, size_t); +__STRING_INLINE char * +__strcpy_small (char *__dest, + __uint16_t __src0_2, __uint16_t __src4_2, + __uint32_t __src0_4, __uint32_t __src4_4, + size_t __srclen) +{ + union { + __uint32_t __ui; + __uint16_t __usi; + unsigned char __uc; + } *__u = (void *) __dest; + switch ((unsigned int) __srclen) + { + case 1: + __u->__uc = '\0'; + break; + case 2: + __u->__usi = __src0_2; + break; + case 3: + __u->__usi = __src0_2; + __u = __extension__ (void *)((char *) __u + 2); + __u->__uc = '\0'; + break; + case 4: + __u->__ui = __src0_4; + break; + case 5: + __u->__ui = __src0_4; + __u = __extension__ (void *)((char *) __u + 4); + __u->__uc = '\0'; + break; + case 6: + __u->__ui = __src0_4; + __u = __extension__ (void *)((char *) __u + 4); + __u->__usi = __src4_2; + break; + case 7: + __u->__ui = __src0_4; + __u = __extension__ (void *)((char *) __u + 4); + __u->__usi = __src4_2; + __u = __extension__ (void *)((char *) __u + 2); + __u->__uc = '\0'; + break; + case 8: + __u->__ui = __src0_4; + __u = __extension__ (void *)((char *) __u + 4); + __u->__ui = __src4_4; + break; + } + return __dest; +} +# else +# define __strcpy_args(src) \ + __extension__ ((__STRING2_COPY_ARR2) \ + { { ((__const char *) (src))[0], '\0' } }), \ + __extension__ ((__STRING2_COPY_ARR3) \ + { { ((__const char *) (src))[0], ((__const char *) (src))[1], \ + '\0' } }), \ + __extension__ ((__STRING2_COPY_ARR4) \ + { { ((__const char *) (src))[0], ((__const char *) (src))[1], \ + ((__const char *) (src))[2], '\0' } }), \ + __extension__ ((__STRING2_COPY_ARR5) \ + { { ((__const char *) (src))[0], ((__const char *) (src))[1], \ + ((__const char *) (src))[2], ((__const char *) (src))[3], \ + '\0' } }), \ + __extension__ ((__STRING2_COPY_ARR6) \ + { { ((__const char *) (src))[0], ((__const char *) (src))[1], \ + ((__const char *) (src))[2], ((__const char *) (src))[3], \ + ((__const char *) (src))[4], '\0' } }), \ + __extension__ ((__STRING2_COPY_ARR7) \ + { { ((__const char *) (src))[0], ((__const char *) (src))[1], \ + ((__const char *) (src))[2], ((__const char *) (src))[3], \ + ((__const char *) (src))[4], ((__const char *) (src))[5], \ + '\0' } }), \ + __extension__ ((__STRING2_COPY_ARR8) \ + { { ((__const char *) (src))[0], ((__const char *) (src))[1], \ + ((__const char *) (src))[2], ((__const char *) (src))[3], \ + ((__const char *) (src))[4], ((__const char *) (src))[5], \ + ((__const char *) (src))[6], '\0' } }) +__STRING_INLINE char *__strcpy_small (char *, __STRING2_COPY_ARR2, + __STRING2_COPY_ARR3, + __STRING2_COPY_ARR4, + __STRING2_COPY_ARR5, + __STRING2_COPY_ARR6, + __STRING2_COPY_ARR7, + __STRING2_COPY_ARR8, size_t); +__STRING_INLINE char * +__strcpy_small (char *__dest, + __STRING2_COPY_ARR2 __src2, __STRING2_COPY_ARR3 __src3, + __STRING2_COPY_ARR4 __src4, __STRING2_COPY_ARR5 __src5, + __STRING2_COPY_ARR6 __src6, __STRING2_COPY_ARR7 __src7, + __STRING2_COPY_ARR8 __src8, size_t __srclen) +{ + union { + char __c; + __STRING2_COPY_ARR2 __sca2; + __STRING2_COPY_ARR3 __sca3; + __STRING2_COPY_ARR4 __sca4; + __STRING2_COPY_ARR5 __sca5; + __STRING2_COPY_ARR6 __sca6; + __STRING2_COPY_ARR7 __sca7; + __STRING2_COPY_ARR8 __sca8; + } *__u = (void *) __dest; + switch ((unsigned int) __srclen) + { + case 1: + __u->__c = '\0'; + break; + case 2: + __extension__ __u->__sca2 = __src2; + break; + case 3: + __extension__ __u->__sca3 = __src3; + break; + case 4: + __extension__ __u->__sca4 = __src4; + break; + case 5: + __extension__ __u->__sca5 = __src5; + break; + case 6: + __extension__ __u->__sca6 = __src6; + break; + case 7: + __extension__ __u->__sca7 = __src7; + break; + case 8: + __extension__ __u->__sca8 = __src8; + break; + } + return __dest; +} +# endif +#endif + + +/* Copy SRC to DEST, returning pointer to final NUL byte. */ +#ifdef __USE_GNU +# ifndef _HAVE_STRING_ARCH_stpcpy +# define __stpcpy(dest, src) \ + (__extension__ (__builtin_constant_p (src) \ + ? (__string2_1bptr_p (src) && strlen (src) + 1 <= 8 \ + ? __stpcpy_small (dest, __stpcpy_args (src), \ + strlen (src) + 1) \ + : ((char *) __mempcpy (dest, src, strlen (src) + 1) - 1))\ + : __stpcpy (dest, src))) +/* In glibc we use this function frequently but for namespace reasons + we have to use the name `__stpcpy'. */ +# define stpcpy(dest, src) __stpcpy (dest, src) + +# if _STRING_ARCH_unaligned +# define __stpcpy_args(src) \ + __extension__ __STRING2_SMALL_GET16 (src, 0), \ + __extension__ __STRING2_SMALL_GET16 (src, 4), \ + __extension__ __STRING2_SMALL_GET32 (src, 0), \ + __extension__ __STRING2_SMALL_GET32 (src, 4) +__STRING_INLINE char *__stpcpy_small (char *, __uint16_t, __uint16_t, + __uint32_t, __uint32_t, size_t); +__STRING_INLINE char * +__stpcpy_small (char *__dest, + __uint16_t __src0_2, __uint16_t __src4_2, + __uint32_t __src0_4, __uint32_t __src4_4, + size_t __srclen) +{ + union { + unsigned int __ui; + unsigned short int __usi; + unsigned char __uc; + char __c; + } *__u = (void *) __dest; + switch ((unsigned int) __srclen) + { + case 1: + __u->__uc = '\0'; + break; + case 2: + __u->__usi = __src0_2; + __u = __extension__ (void *)((char *) __u + 1); + break; + case 3: + __u->__usi = __src0_2; + __u = __extension__ (void *)((char *) __u + 2); + __u->__uc = '\0'; + break; + case 4: + __u->__ui = __src0_4; + __u = __extension__ (void *)((char *) __u + 3); + break; + case 5: + __u->__ui = __src0_4; + __u = __extension__ (void *)((char *) __u + 4); + __u->__uc = '\0'; + break; + case 6: + __u->__ui = __src0_4; + __u = __extension__ (void *)((char *) __u + 4); + __u->__usi = __src4_2; + __u = __extension__ (void *)((char *) __u + 1); + break; + case 7: + __u->__ui = __src0_4; + __u = __extension__ (void *)((char *) __u + 4); + __u->__usi = __src4_2; + __u = __extension__ (void *)((char *) __u + 2); + __u->__uc = '\0'; + break; + case 8: + __u->__ui = __src0_4; + __u = __extension__ (void *)((char *) __u + 4); + __u->__ui = __src4_4; + __u = __extension__ (void *)((char *) __u + 3); + break; + } + return &__u->__c; +} +# else +# define __stpcpy_args(src) \ + __extension__ ((__STRING2_COPY_ARR2) \ + { { ((__const char *) (src))[0], '\0' } }), \ + __extension__ ((__STRING2_COPY_ARR3) \ + { { ((__const char *) (src))[0], ((__const char *) (src))[1], \ + '\0' } }), \ + __extension__ ((__STRING2_COPY_ARR4) \ + { { ((__const char *) (src))[0], ((__const char *) (src))[1], \ + ((__const char *) (src))[2], '\0' } }), \ + __extension__ ((__STRING2_COPY_ARR5) \ + { { ((__const char *) (src))[0], ((__const char *) (src))[1], \ + ((__const char *) (src))[2], ((__const char *) (src))[3], \ + '\0' } }), \ + __extension__ ((__STRING2_COPY_ARR6) \ + { { ((__const char *) (src))[0], ((__const char *) (src))[1], \ + ((__const char *) (src))[2], ((__const char *) (src))[3], \ + ((__const char *) (src))[4], '\0' } }), \ + __extension__ ((__STRING2_COPY_ARR7) \ + { { ((__const char *) (src))[0], ((__const char *) (src))[1], \ + ((__const char *) (src))[2], ((__const char *) (src))[3], \ + ((__const char *) (src))[4], ((__const char *) (src))[5], \ + '\0' } }), \ + __extension__ ((__STRING2_COPY_ARR8) \ + { { ((__const char *) (src))[0], ((__const char *) (src))[1], \ + ((__const char *) (src))[2], ((__const char *) (src))[3], \ + ((__const char *) (src))[4], ((__const char *) (src))[5], \ + ((__const char *) (src))[6], '\0' } }) +__STRING_INLINE char *__stpcpy_small (char *, __STRING2_COPY_ARR2, + __STRING2_COPY_ARR3, + __STRING2_COPY_ARR4, + __STRING2_COPY_ARR5, + __STRING2_COPY_ARR6, + __STRING2_COPY_ARR7, + __STRING2_COPY_ARR8, size_t); +__STRING_INLINE char * +__stpcpy_small (char *__dest, + __STRING2_COPY_ARR2 __src2, __STRING2_COPY_ARR3 __src3, + __STRING2_COPY_ARR4 __src4, __STRING2_COPY_ARR5 __src5, + __STRING2_COPY_ARR6 __src6, __STRING2_COPY_ARR7 __src7, + __STRING2_COPY_ARR8 __src8, size_t __srclen) +{ + union { + char __c; + __STRING2_COPY_ARR2 __sca2; + __STRING2_COPY_ARR3 __sca3; + __STRING2_COPY_ARR4 __sca4; + __STRING2_COPY_ARR5 __sca5; + __STRING2_COPY_ARR6 __sca6; + __STRING2_COPY_ARR7 __sca7; + __STRING2_COPY_ARR8 __sca8; + } *__u = (void *) __dest; + switch ((unsigned int) __srclen) + { + case 1: + __u->__c = '\0'; + break; + case 2: + __extension__ __u->__sca2 = __src2; + break; + case 3: + __extension__ __u->__sca3 = __src3; + break; + case 4: + __extension__ __u->__sca4 = __src4; + break; + case 5: + __extension__ __u->__sca5 = __src5; + break; + case 6: + __extension__ __u->__sca6 = __src6; + break; + case 7: + __extension__ __u->__sca7 = __src7; + break; + case 8: + __extension__ __u->__sca8 = __src8; + break; + } + return __dest + __srclen - 1; +} +# endif +# endif +#endif + + +/* Copy no more than N characters of SRC to DEST. */ +#ifndef _HAVE_STRING_ARCH_strncpy +# if defined _HAVE_STRING_ARCH_memset && defined _HAVE_STRING_ARCH_mempcpy +# define strncpy(dest, src, n) \ + (__extension__ ({ char *__dest = (dest); \ + __builtin_constant_p (src) && __builtin_constant_p (n) \ + ? (strlen (src) + 1 >= ((size_t) (n)) \ + ? (char *) memcpy (__dest, src, n) \ + : (memset (__mempcpy (__dest, src, strlen (src)), \ + '\0', n - strlen (src)), \ + __dest)) \ + : strncpy (__dest, src, n); })) +# else +# define strncpy(dest, src, n) \ + (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \ + ? (strlen (src) + 1 >= ((size_t) (n)) \ + ? (char *) memcpy (dest, src, n) \ + : strncpy (dest, src, n)) \ + : strncpy (dest, src, n))) +# endif +#endif + + +/* Append no more than N characters from SRC onto DEST. */ +#ifndef _HAVE_STRING_ARCH_strncat +# ifdef _HAVE_STRING_ARCH_strchr +# define strncat(dest, src, n) \ + (__extension__ ({ char *__dest = (dest); \ + __builtin_constant_p (src) && __builtin_constant_p (n) \ + ? (strlen (src) < ((size_t) (n)) \ + ? strcat (__dest, src) \ + : (memcpy (strchr (__dest, '\0'), src, n), __dest)) \ + : strncat (dest, src, n); })) +# else +# define strncat(dest, src, n) \ + (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \ + ? (strlen (src) < ((size_t) (n)) \ + ? strcat (dest, src) \ + : strncat (dest, src, n)) \ + : strncat (dest, src, n))) +# endif +#endif + + +/* Compare characters of S1 and S2. */ +#ifndef _HAVE_STRING_ARCH_strcmp +# define strcmp(s1, s2) \ + __extension__ \ + ({ size_t __s1_len, __s2_len; \ + (__builtin_constant_p (s1) && __builtin_constant_p (s2) \ + && (__s1_len = strlen (s1), __s2_len = strlen (s2), \ + (!__string2_1bptr_p (s1) || __s1_len >= 4) \ + && (!__string2_1bptr_p (s2) || __s2_len >= 4)) \ + ? memcmp ((__const char *) (s1), (__const char *) (s2), \ + (__s1_len < __s2_len ? __s1_len : __s2_len) + 1) \ + : (__builtin_constant_p (s1) && __string2_1bptr_p (s1) \ + && (__s1_len = strlen (s1), __s1_len < 4) \ + ? (__builtin_constant_p (s2) && __string2_1bptr_p (s2) \ + ? __strcmp_cc (s1, s2, __s1_len) \ + : __strcmp_cg (s1, s2, __s1_len)) \ + : (__builtin_constant_p (s2) && __string2_1bptr_p (s2) \ + && (__s2_len = strlen (s2), __s2_len < 4) \ + ? (__builtin_constant_p (s1) && __string2_1bptr_p (s1) \ + ? __strcmp_cc (s1, s2, __s2_len) \ + : __strcmp_gc (s1, s2, __s2_len)) \ + : strcmp (s1, s2)))); }) + +# define __strcmp_cc(s1, s2, l) \ + (__extension__ ({ register int __result = \ + (((__const unsigned char *) (__const char *) (s1))[0] \ + - ((__const unsigned char *) (__const char *)(s2))[0]);\ + if (l > 0 && __result == 0) \ + { \ + __result = (((__const unsigned char *) \ + (__const char *) (s1))[1] \ + - ((__const unsigned char *) \ + (__const char *) (s2))[1]); \ + if (l > 1 && __result == 0) \ + { \ + __result = \ + (((__const unsigned char *) \ + (__const char *) (s1))[2] \ + - ((__const unsigned char *) \ + (__const char *) (s2))[2]); \ + if (l > 2 && __result == 0) \ + __result = \ + (((__const unsigned char *) \ + (__const char *) (s1))[3] \ + - ((__const unsigned char *) \ + (__const char *) (s2))[3]); \ + } \ + } \ + __result; })) + +# define __strcmp_cg(s1, s2, l1) \ + (__extension__ ({ __const unsigned char *__s2 = \ + (__const unsigned char *) (__const char *) (s2); \ + register int __result = \ + (((__const unsigned char *) (__const char *) (s1))[0] \ + - __s2[0]); \ + if (l1 > 0 && __result == 0) \ + { \ + __result = (((__const unsigned char *) \ + (__const char *) (s1))[1] - __s2[1]); \ + if (l1 > 1 && __result == 0) \ + { \ + __result = (((__const unsigned char *) \ + (__const char *) (s1))[2] - __s2[2]);\ + if (l1 > 2 && __result == 0) \ + __result = (((__const unsigned char *) \ + (__const char *) (s1))[3] \ + - __s2[3]); \ + } \ + } \ + __result; })) + +# define __strcmp_gc(s1, s2, l2) \ + (__extension__ ({ __const unsigned char *__s1 = \ + (__const unsigned char *) (__const char *) (s1); \ + register int __result = \ + __s1[0] - ((__const unsigned char *) \ + (__const char *) (s2))[0]; \ + if (l2 > 0 && __result == 0) \ + { \ + __result = (__s1[1] \ + - ((__const unsigned char *) \ + (__const char *) (s2))[1]); \ + if (l2 > 1 && __result == 0) \ + { \ + __result = \ + (__s1[2] - ((__const unsigned char *) \ + (__const char *) (s2))[2]); \ + if (l2 > 2 && __result == 0) \ + __result = \ + (__s1[3] \ + - ((__const unsigned char *) \ + (__const char *) (s2))[3]); \ + } \ + } \ + __result; })) +#endif + + +/* Compare N characters of S1 and S2. */ +#ifndef _HAVE_STRING_ARCH_strncmp +# define strncmp(s1, s2, n) \ + (__extension__ (__builtin_constant_p (n) \ + && ((__builtin_constant_p (s1) \ + && strlen (s1) < ((size_t) (n))) \ + || (__builtin_constant_p (s2) \ + && strlen (s2) < ((size_t) (n)))) \ + ? strcmp (s1, s2) : strncmp (s1, s2, n))) +#endif + + +/* Return the length of the initial segment of S which + consists entirely of characters not in REJECT. */ +#ifndef _HAVE_STRING_ARCH_strcspn +# define strcspn(s, reject) \ + __extension__ \ + ({ char __r0, __r1, __r2; \ + (__builtin_constant_p (reject) && __string2_1bptr_p (reject) \ + ? ((__r0 = ((__const char *) (reject))[0], __r0 == '\0') \ + ? strlen (s) \ + : ((__r1 = ((__const char *) (reject))[1], __r1 == '\0') \ + ? __strcspn_c1 (s, __r0) \ + : ((__r2 = ((__const char *) (reject))[2], __r2 == '\0') \ + ? __strcspn_c2 (s, __r0, __r1) \ + : (((__const char *) (reject))[3] == '\0' \ + ? __strcspn_c3 (s, __r0, __r1, __r2) \ + : strcspn (s, reject))))) \ + : strcspn (s, reject)); }) + +__STRING_INLINE size_t __strcspn_c1 (__const char *__s, char __reject); +__STRING_INLINE size_t +__strcspn_c1 (__const char *__s, char __reject) +{ + register size_t __result = 0; + while (__s[__result] != '\0' && __s[__result] != __reject) + ++__result; + return __result; +} + +__STRING_INLINE size_t __strcspn_c2 (__const char *__s, char __reject1, + char __reject2); +__STRING_INLINE size_t +__strcspn_c2 (__const char *__s, char __reject1, char __reject2) +{ + register size_t __result = 0; + while (__s[__result] != '\0' && __s[__result] != __reject1 + && __s[__result] != __reject2) + ++__result; + return __result; +} + +__STRING_INLINE size_t __strcspn_c3 (__const char *__s, char __reject1, + char __reject2, char __reject3); +__STRING_INLINE size_t +__strcspn_c3 (__const char *__s, char __reject1, char __reject2, + char __reject3) +{ + register size_t __result = 0; + while (__s[__result] != '\0' && __s[__result] != __reject1 + && __s[__result] != __reject2 && __s[__result] != __reject3) + ++__result; + return __result; +} +#endif + + +/* Return the length of the initial segment of S which + consists entirely of characters in ACCEPT. */ +#ifndef _HAVE_STRING_ARCH_strspn +# define strspn(s, accept) \ + __extension__ \ + ({ char __a0, __a1, __a2; \ + (__builtin_constant_p (accept) && __string2_1bptr_p (accept) \ + ? ((__a0 = ((__const char *) (accept))[0], __a0 == '\0') \ + ? 0 \ + : ((__a1 = ((__const char *) (accept))[1], __a1 == '\0') \ + ? __strspn_c1 (s, __a0) \ + : ((__a2 = ((__const char *) (accept))[2], __a2 == '\0') \ + ? __strspn_c2 (s, __a0, __a1) \ + : (((__const char *) (accept))[3] == '\0' \ + ? __strspn_c3 (s, __a0, __a1, __a2) \ + : strspn (s, accept))))) \ + : strspn (s, accept)); }) + +__STRING_INLINE size_t __strspn_c1 (__const char *__s, char __accept); +__STRING_INLINE size_t +__strspn_c1 (__const char *__s, char __accept) +{ + register size_t __result = 0; + /* Please note that __accept never can be '\0'. */ + while (__s[__result] == __accept) + ++__result; + return __result; +} + +__STRING_INLINE size_t __strspn_c2 (__const char *__s, char __accept1, + char __accept2); +__STRING_INLINE size_t +__strspn_c2 (__const char *__s, char __accept1, char __accept2) +{ + register size_t __result = 0; + /* Please note that __accept1 and __accept2 never can be '\0'. */ + while (__s[__result] == __accept1 || __s[__result] == __accept2) + ++__result; + return __result; +} + +__STRING_INLINE size_t __strspn_c3 (__const char *__s, char __accept1, + char __accept2, char __accept3); +__STRING_INLINE size_t +__strspn_c3 (__const char *__s, char __accept1, char __accept2, char __accept3) +{ + register size_t __result = 0; + /* Please note that __accept1 to __accept3 never can be '\0'. */ + while (__s[__result] == __accept1 || __s[__result] == __accept2 + || __s[__result] == __accept3) + ++__result; + return __result; +} +#endif + + +/* Find the first occurrence in S of any character in ACCEPT. */ +#ifndef _HAVE_STRING_ARCH_strpbrk +# define strpbrk(s, accept) \ + __extension__ \ + ({ char __a0, __a1, __a2; \ + (__builtin_constant_p (accept) && __string2_1bptr_p (accept) \ + ? ((__a0 = ((__const char *) (accept))[0], __a0 == '\0') \ + ? NULL \ + : ((__a1 = ((__const char *) (accept))[1], __a1 == '\0') \ + ? strchr (s, __a0) \ + : ((__a2 = ((__const char *) (accept))[2], __a2 == '\0') \ + ? __strpbrk_c2 (s, __a0, __a1) \ + : (((__const char *) (accept))[3] == '\0' \ + ? __strpbrk_c3 (s, __a0, __a1, __a2) \ + : strpbrk (s, accept))))) \ + : strpbrk (s, accept)); }) + +__STRING_INLINE char *__strpbrk_c2 (__const char *__s, char __accept1, + char __accept2); +__STRING_INLINE char * +__strpbrk_c2 (__const char *__s, char __accept1, char __accept2) +{ + /* Please note that __accept1 and __accept2 never can be '\0'. */ + while (*__s != '\0' && *__s != __accept1 && *__s != __accept2) + ++__s; + return *__s == '\0' ? NULL : (char *) (size_t) __s; +} + +__STRING_INLINE char *__strpbrk_c3 (__const char *__s, char __accept1, + char __accept2, char __accept3); +__STRING_INLINE char * +__strpbrk_c3 (__const char *__s, char __accept1, char __accept2, + char __accept3) +{ + /* Please note that __accept1 to __accept3 never can be '\0'. */ + while (*__s != '\0' && *__s != __accept1 && *__s != __accept2 + && *__s != __accept3) + ++__s; + return *__s == '\0' ? NULL : (char *) (size_t) __s; +} +#endif + + +/* Find the first occurrence of NEEDLE in HAYSTACK. */ +#ifndef _HAVE_STRING_ARCH_strstr +# define strstr(haystack, needle) \ + (__extension__ (__builtin_constant_p (needle) && __string2_1bptr_p (needle) \ + ? (((__const char *) (needle))[0] == '\0' \ + ? (char *) (size_t) (haystack) \ + : (((__const char *) (needle))[1] == '\0' \ + ? strchr (haystack, \ + ((__const char *) (needle))[0]) \ + : strstr (haystack, needle))) \ + : strstr (haystack, needle))) +#endif + + +#if defined __USE_GNU && !defined _FORCE_INLINES +# ifndef _HAVE_STRING_ARCH_strnlen +__STRING_INLINE size_t +strnlen (__const char *__string, size_t __maxlen) +{ + __const char *__end = (__const char *) memchr (__string, '\0', __maxlen); + return __end ? (size_t) (__end - __string) : __maxlen; +} +# endif +#endif + + +#ifndef _HAVE_STRING_ARCH_strtok_r +# define __strtok_r(s, sep, nextp) \ + (__extension__ (__builtin_constant_p (sep) && __string2_1bptr_p (sep) \ + ? (((__const char *) (sep))[0] != '\0' \ + && ((__const char *) (sep))[1] == '\0' \ + ? __strtok_r_1c (s, ((__const char *) (sep))[0], nextp) \ + : __strtok_r (s, sep, nextp)) \ + : __strtok_r (s, sep, nextp))) + +__STRING_INLINE char *__strtok_r_1c (char *__s, char __sep, char **__nextp); +__STRING_INLINE char * +__strtok_r_1c (char *__s, char __sep, char **__nextp) +{ + char *__result; + if (__s == NULL) + __s = *__nextp; + while (*__s == __sep) + ++__s; + if (*__s == '\0') + __result = NULL; + else + { + __result = __s; + while (*__s != '\0' && *__s != __sep) + ++__s; + if (*__s == '\0') + *__nextp = __s; + else + { + *__s = '\0'; + *__nextp = __s + 1; + } + } + return __result; +} +# if defined __USE_POSIX || defined __USE_MISC +# define strtok_r(s, sep, nextp) __strtok_r ((s), (sep), (nextp)) +# endif +#endif + + +#ifndef _HAVE_STRING_ARCH_strsep + +# define __strsep(s, reject) \ + __extension__ \ + ({ char __r0, __r1, __r2; \ + (__builtin_constant_p (reject) && __string2_1bptr_p (reject) \ + && (__r0 = ((__const char *) (reject))[0], \ + ((__const char *) (reject))[0] != '\0') \ + ? ((__r1 = ((__const char *) (reject))[1], \ + ((__const char *) (reject))[1] == '\0') \ + ? __strsep_1c (s, __r0) \ + : ((__r2 = ((__const char *) (reject))[2], __r2 == '\0') \ + ? __strsep_2c (s, __r0, __r1) \ + : (((__const char *) (reject))[3] == '\0' \ + ? __strsep_3c (s, __r0, __r1, __r2) \ + : __strsep_g (s, reject)))) \ + : __strsep_g (s, reject)); }) + +__STRING_INLINE char *__strsep_1c (char **__s, char __reject); +__STRING_INLINE char * +__strsep_1c (char **__s, char __reject) +{ + register char *__retval = *__s; + if (__retval == NULL) + return *__s = NULL; + if (*__retval == __reject) + *(*__s)++ = '\0'; + else + if ((*__s = strchr (__retval, __reject)) != NULL) + *(*__s)++ = '\0'; + else + *__s = NULL; + return __retval; +} + +__STRING_INLINE char *__strsep_2c (char **__s, char __reject1, char __reject2); +__STRING_INLINE char * +__strsep_2c (char **__s, char __reject1, char __reject2) +{ + register char *__retval = *__s; + if (__retval == NULL) + return *__s = NULL; + if (*__retval == __reject1 || *__retval == __reject2) + *(*__s)++ = '\0'; + else + { + register char *__cp = __retval; + while (*__cp != '\0' && *__cp != __reject1 && *__cp != __reject2) + ++__cp; + if (*__cp != '\0') + { + *__s = __cp; + *(*__s)++ = '\0'; + } + else + *__s = NULL; + } + return __retval; +} + +__STRING_INLINE char *__strsep_3c (char **__s, char __reject1, char __reject2, + char __reject3); +__STRING_INLINE char * +__strsep_3c (char **__s, char __reject1, char __reject2, char __reject3) +{ + register char *__retval = *__s; + if (__retval == NULL) + return *__s = NULL; + if (*__retval == __reject1 || *__retval == __reject2 + || *__retval == __reject3) + *(*__s)++ = '\0'; + else + { + register char *__cp = __retval; + while (*__cp != '\0' && *__cp != __reject1 && *__cp != __reject2 + && *__cp != __reject3) + ++__cp; + if (*__cp != '\0') + { + *__s = __cp; + *(*__s)++ = '\0'; + } + else + *__s = NULL; + } + return __retval; +} + +__STRING_INLINE char *__strsep_g (char **__s, __const char *__reject); +__STRING_INLINE char * +__strsep_g (char **__s, __const char *__reject) +{ + register char *__retval = *__s; + if (__retval == NULL) + return NULL; + if ((*__s = strpbrk (__retval, __reject)) != NULL) + *(*__s)++ = '\0'; + return __retval; +} +# ifdef __USE_BSD +# define strsep(s, reject) __strsep ((s), (reject)) +# endif +#endif + +/* We need the memory allocation functions for inline strdup(). + Referring to stdlib.h (even minimally) is not allowed + in any of the tight standards compliant modes. */ +#ifdef __USE_MISC + +# if !defined _HAVE_STRING_ARCH_strdup || !defined _HAVE_STRING_ARCH_strndup +# define __need_malloc_and_calloc +# include +# endif + +# ifndef _HAVE_STRING_ARCH_strdup + +# define __strdup(s) \ + (__extension__ (__builtin_constant_p (s) && __string2_1bptr_p (s) \ + ? (((__const char *) (s))[0] == '\0' \ + ? (char *) calloc (1, 1) \ + : ({ size_t __len = strlen (s) + 1; \ + char *__retval = (char *) malloc (__len); \ + if (__retval != NULL) \ + __retval = (char *) memcpy (__retval, s, __len); \ + __retval; })) \ + : __strdup (s))) + +# if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED +# define strdup(s) __strdup (s) +# endif +# endif + +#endif /* Use misc. or use GNU. */ + +#ifndef _FORCE_INLINES +# undef __STRING_INLINE +#endif + +#endif /* No string inlines. */ diff --git a/libc/sysdeps/linux/i386/bits/stropts.h b/libc/sysdeps/linux/i386/bits/stropts.h new file mode 100644 index 000000000..ed807473c --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/stropts.h @@ -0,0 +1,219 @@ +/* Copyright (C) 1998, 1999 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 _BITS_STROPTS_H +#define _BITS_STROPTS_H 1 + +#include + +/* Macros used as `request' argument to `ioctl'. */ +#define __SID ('S' << 8) + +#define I_NREAD (__SID | 1) /* Counts the number of data bytes in the data + block in the first message. */ +#define I_PUSH (__SID | 2) /* Push STREAMS module onto top of the current + STREAM, just below the STREAM head. */ +#define I_POP (__SID | 3) /* Remove STREAMS module from just below the + STREAM head. */ +#define I_LOOK (__SID | 4) /* Retrieve the name of the module just below + the STREAM head and place it in a character + string. */ +#define I_FLUSH (__SID | 5) /* Flush all input and/or output. */ +#define I_SRDOPT (__SID | 6) /* Sets the read mode. */ +#define I_GRDOPT (__SID | 7) /* Returns the current read mode setting. */ +#define I_STR (__SID | 8) /* Construct an internal STREAMS `ioctl' + message and send that message downstream. */ +#define I_SETSIG (__SID | 9) /* Inform the STREAM head that the process + wants the SIGPOLL signal issued. */ +#define I_GETSIG (__SID |10) /* Return the events for which the calling + process is currently registered to be sent + a SIGPOLL signal. */ +#define I_FIND (__SID |11) /* Compares the names of all modules currently + present in the STREAM to the name pointed to + by `arg'. */ +#define I_LINK (__SID |12) /* Connect two STREAMs. */ +#define I_UNLINK (__SID |13) /* Disconnects the two STREAMs. */ +#define I_PEEK (__SID |15) /* Allows a process to retrieve the information + in the first message on the STREAM head read + queue without taking the message off the + queue. */ +#define I_FDINSERT (__SID |16) /* Create a message from the specified + buffer(s), adds information about another + STREAM, and send the message downstream. */ +#define I_SENDFD (__SID |17) /* Requests the STREAM associated with `fildes' + to send a message, containing a file + pointer, to the STREAM head at the other end + of a STREAMS pipe. */ +#define I_RECVFD (__SID |14) /* Non-EFT definition. */ +#define I_SWROPT (__SID |19) /* Set the write mode. */ +#define I_GWRSET (__SID |20) /* Return the current write mode setting. */ +#define I_LIST (__SID |21) /* List all the module names on the STREAM, up + to and including the topmost driver name. */ +#define I_PLINK (__SID |22) /* Connect two STREAMs with a persistent + link. */ +#define I_PUNLINK (__SID |23) /* Disconnect the two STREAMs that were + connected with a persistent link. */ +#define I_FLUSHBAND (__SID |28) /* Flush only band specified. */ +#define I_CKBAND (__SID |29) /* Check if the message of a given priority + band exists on the STREAM head read + queue. */ +#define I_GETBAND (__SID |30) /* Return the priority band of the first + message on the STREAM head read queue. */ +#define I_ATMARK (__SID |31) /* See if the current message on the STREAM + head read queue is "marked" by some module + downstream. */ +#define I_SETCLTIME (__SID |32) /* Set the time the STREAM head will delay when + a STREAM is closing and there is data on + the write queues. */ +#define I_GETCLTIME (__SID |33) /* Get current value for closing timeout. */ +#define I_CANPUT (__SID |34) /* Check if a certain band is writable. */ + + +/* Used in `I_LOOK' request. */ +#define FMNAMESZ 8 /* compatibility w/UnixWare/Solaris. */ + +/* Flush options. */ +#define FLUSHR 0x01 /* Flush read queues. */ +#define FLUSHW 0x02 /* Flush write queues. */ +#define FLUSHRW 0x03 /* Flush read and write queues. */ +#define FLUSHBAND 0x04 /* Flush only specified band. */ + +/* Possible arguments for `I_SETSIG'. */ +#define S_INPUT 0x0001 /* A message, other than a high-priority + message, has arrived. */ +#define S_HIPRI 0x0002 /* A high-priority message is present. */ +#define S_OUTPUT 0x0004 /* The write queue for normal data is no longer + full. */ +#define S_MSG 0x0008 /* A STREAMS signal message that contains the + SIGPOLL signal reaches the front of the + STREAM head read queue. */ +#define S_ERROR 0x0010 /* Notification of an error condition. */ +#define S_HANGUP 0x0020 /* Notification of a hangup. */ +#define S_RDNORM 0x0040 /* A normal message has arrived. */ +#define S_WRNORM S_OUTPUT +#define S_RDBAND 0x0080 /* A message with a non-zero priority has + arrived. */ +#define S_WRBAND 0x0100 /* The write queue for a non-zero priority + band is no longer full. */ +#define S_BANDURG 0x0200 /* When used in conjunction with S_RDBAND, + SIGURG is generated instead of SIGPOLL when + a priority message reaches the front of the + STREAM head read queue. */ + +/* Option for `I_PEEK'. */ +#define RS_HIPRI 0x01 /* Only look for high-priority messages. */ + +/* Options for `I_SRDOPT'. */ +#define RNORM 0x0000 /* Byte-STREAM mode, the default. */ +#define RMSGD 0x0001 /* Message-discard mode. */ +#define RMSGN 0x0002 /* Message-nondiscard mode. */ +#define RPROTDAT 0x0004 /* Deliver the control part of a message as + data. */ +#define RPROTDIS 0x0008 /* Discard the control part of a message, + delivering any data part. */ +#define RPROTNORM 0x0010 /* Fail `read' with EBADMSG if a message + containing a control part is at the front + of the STREAM head read queue. */ +#define RPROTMASK 0x001C /* The RPROT bits */ + +/* Possible mode for `I_SWROPT'. */ +#define SNDZERO 0x001 /* Send a zero-length message downstream when a + `write' of 0 bytes occurs. */ +#define SNDPIPE 0x002 /* Send SIGPIPE on write and putmsg if + sd_werror is set. */ + +/* Arguments for `I_ATMARK'. */ +#define ANYMARK 0x01 /* Check if the message is marked. */ +#define LASTMARK 0x02 /* Check if the message is the last one marked + on the queue. */ + +/* Argument for `I_UNLINK'. */ +#define MUXID_ALL (-1) /* Unlink all STREAMs linked to the STREAM + associated with `fildes'. */ + + +/* Macros for `getmsg', `getpmsg', `putmsg' and `putpmsg'. */ +#define MSG_HIPRI 0x01 /* Send/receive high priority message. */ +#define MSG_ANY 0x02 /* Receive any message. */ +#define MSG_BAND 0x04 /* Receive message from specified band. */ + +/* Values returned by getmsg and getpmsg */ +#define MORECTL 1 /* More control information is left in + message. */ +#define MOREDATA 2 /* More data is left in message. */ + + +/* Structure used for the I_FLUSHBAND ioctl on streams. */ +struct bandinfo + { + unsigned char bi_pri; + int bi_flag; + }; + +struct strbuf + { + int maxlen; /* Maximum buffer length. */ + int len; /* Length of data. */ + char *buf; /* Pointer to buffer. */ + }; + +struct strpeek + { + struct strbuf ctlbuf; + struct strbuf databuf; + __t_uscalar_t flags; /* UnixWare/Solaris compatibility. */ + }; + +struct strfdinsert + { + struct strbuf ctlbuf; + struct strbuf databuf; + __t_uscalar_t flags; /* UnixWare/Solaris compatibility. */ + int fildes; + int offset; + }; + +struct strioctl + { + int ic_cmd; + int ic_timout; + int ic_len; + char *ic_dp; + }; + +struct strrecvfd + { + int fd; + __uid_t uid; + __gid_t gid; + char fill[8]; /* UnixWare/Solaris compatibility */ + }; + + +struct str_mlist + { + char l_name[FMNAMESZ + 1]; + }; + +struct str_list + { + int sl_nmods; + struct str_mlist *sl_modlist; + }; + +#endif /* bits/stropts.h */ diff --git a/libc/sysdeps/linux/i386/bits/ustat.h b/libc/sysdeps/linux/i386/bits/ustat.h new file mode 100644 index 000000000..526069a7f --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/ustat.h @@ -0,0 +1,27 @@ +/* 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. */ + +#include + +struct ustat + { + __daddr_t f_tfree; + __ino_t f_tinode; + char f_fname[6]; + char f_fpack[6]; + }; diff --git a/libc/sysdeps/linux/i386/bits/utmp.h b/libc/sysdeps/linux/i386/bits/utmp.h new file mode 100644 index 000000000..d07486e9c --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/utmp.h @@ -0,0 +1,105 @@ +/* The `struct utmp' type, describing entries in the utmp file. GNU version. + Copyright (C) 1993, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + + 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 _UTMP_H +# error "Never include directly; use instead." +#endif + +#include +#include +#include + + +#define UT_LINESIZE 32 +#define UT_NAMESIZE 32 +#define UT_HOSTSIZE 256 + + +/* The structure describing an entry in the database of + previous logins. */ +struct lastlog + { + __time_t ll_time; + char ll_line[UT_LINESIZE]; + char ll_host[UT_HOSTSIZE]; + }; + + +/* The structure describing the status of a terminated process. This + type is used in `struct utmp' below. */ +struct exit_status + { + short int e_termination; /* Process termination status. */ + short int e_exit; /* Process exit status. */ + }; + + +/* The structure describing an entry in the user accounting database. */ +struct utmp +{ + short int ut_type; /* Type of login. */ + pid_t ut_pid; /* Process ID of login process. */ + char ut_line[UT_LINESIZE]; /* Devicename. */ + char ut_id[4]; /* Inittab ID. */ + char ut_user[UT_NAMESIZE]; /* Username. */ + char ut_host[UT_HOSTSIZE]; /* Hostname for remote login. */ + struct exit_status ut_exit; /* Exit status of a process marked + as DEAD_PROCESS. */ + long int ut_session; /* Session ID, used for windowing. */ + struct timeval ut_tv; /* Time entry was made. */ + int32_t ut_addr_v6[4]; /* Internet address of remote host. */ + char __unused[20]; /* Reserved for future use. */ +}; + +/* Backwards compatibility hacks. */ +#define ut_name ut_user +#ifndef _NO_UT_TIME +/* We have a problem here: `ut_time' is also used otherwise. Define + _NO_UT_TIME if the compiler complains. */ +# define ut_time ut_tv.tv_sec +#endif +#define ut_xtime ut_tv.tv_sec +#define ut_addr ut_addr_v6[0] + + +/* Values for the `ut_type' field of a `struct utmp'. */ +#define EMPTY 0 /* No valid user accounting information. */ + +#define RUN_LVL 1 /* The system's runlevel. */ +#define BOOT_TIME 2 /* Time of system boot. */ +#define NEW_TIME 3 /* Time after system clock changed. */ +#define OLD_TIME 4 /* Time when system clock changed. */ + +#define INIT_PROCESS 5 /* Process spawned by the init process. */ +#define LOGIN_PROCESS 6 /* Session leader of a logged in user. */ +#define USER_PROCESS 7 /* Normal process. */ +#define DEAD_PROCESS 8 /* Terminated process. */ + +#define ACCOUNTING 9 + +/* Old Linux name for the EMPTY type. */ +#define UT_UNKNOWN EMPTY + + +/* Tell the user that we have a modern system with UT_HOST, UT_PID, + UT_TYPE, UT_ID and UT_TV fields. */ +#define _HAVE_UT_TYPE 1 +#define _HAVE_UT_PID 1 +#define _HAVE_UT_ID 1 +#define _HAVE_UT_TV 1 +#define _HAVE_UT_HOST 1 diff --git a/libc/sysdeps/linux/i386/bits/utmpx.h b/libc/sysdeps/linux/i386/bits/utmpx.h new file mode 100644 index 000000000..74befe59e --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/utmpx.h @@ -0,0 +1,86 @@ +/* Structures and defenitions for the user accounting database. GNU version. + Copyright (C) 1997, 1998 Free Software Foundation, Inc. + + 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 _UTMPX_H +# error "Never include directly; use instead." +#endif + +#include +#include + + +#ifdef __USE_GNU +# include +# define _PATH_UTMPX _PATH_UTMP +# define _PATH_WTMPX _PATH_WTMP +#endif + + +#define __UT_LINESIZE 32 +#define __UT_NAMESIZE 32 +#define __UT_HOSTSIZE 256 + + +/* The structure describing the status of a terminated process. This + type is used in `struct utmpx' below. */ +struct __exit_status + { +#ifdef __USE_GNU + short int e_termination; /* Process termination status. */ + short int e_exit; /* Process exit status. */ +#else + short int __e_termination; /* Process termination status. */ + short int __e_exit; /* Process exit status. */ +#endif + }; + + +/* The structure describing an entry in the user accounting database. */ +struct utmpx +{ + short int ut_type; /* Type of login. */ + __pid_t ut_pid; /* Process ID of login process. */ + char ut_line[__UT_LINESIZE]; /* Devicename. */ + char ut_id[4]; /* Inittab ID. */ + char ut_user[__UT_NAMESIZE]; /* Username. */ + char ut_host[__UT_HOSTSIZE]; /* Hostname for remote login. */ + struct __exit_status ut_exit; /* Exit status of a process marked + as DEAD_PROCESS. */ + long int ut_session; /* Session ID, used for windowing. */ + struct timeval ut_tv; /* Time entry was made. */ + __int32_t ut_addr_v6[4]; /* Internet address of remote host. */ + char __unused[20]; /* Reserved for future use. */ +}; + + +/* Values for the `ut_type' field of a `struct utmpx'. */ +#define EMPTY 0 /* No valid user accounting information. */ + +#define RUN_LVL 1 /* The system's runlevel. */ +#define BOOT_TIME 2 /* Time of system boot. */ +#define NEW_TIME 3 /* Time after system clock changed. */ +#define OLD_TIME 4 /* Time when system clock changed. */ + +#define INIT_PROCESS 5 /* Process spawned by the init process. */ +#define LOGIN_PROCESS 6 /* Session leader of a logged in user. */ +#define USER_PROCESS 7 /* Normal process. */ +#define DEAD_PROCESS 8 /* Terminated process. */ + +#ifdef __USE_GNU +# define ACCOUNTING 9 /* System accounting. */ +#endif diff --git a/libc/sysdeps/linux/i386/bits/utsname.h b/libc/sysdeps/linux/i386/bits/utsname.h new file mode 100644 index 000000000..8f4bf16f5 --- /dev/null +++ b/libc/sysdeps/linux/i386/bits/utsname.h @@ -0,0 +1,29 @@ +/* Copyright (C) 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 _SYS_UTSNAME_H +# error "Never include directly; use instead." +#endif + +/* Length of the entries in `struct utsname' is 65. */ +#define _UTSNAME_LENGTH 65 + +/* Linux provides as additional information in the `struct utsname' + the name of the current domain. Define _UTSNAME_DOMAIN_LENGTH + to a value != 0 to activate this entry. */ +#define _UTSNAME_DOMAIN_LENGTH _UTSNAME_LENGTH -- cgit v1.2.3