diff options
96 files changed, 4204 insertions, 345 deletions
diff --git a/ChangeLog b/ChangeLog index 43178f3726..584ec076fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,209 @@ +1997-03-08 05:30 Ulrich Drepper <drepper@cygnus.com> + + * argp/Makefile (routines): Add argp-eexst. + * argp/argp-ba.c (argp_program_bug_address): Make `const'. + * argp/argp-eexst.c: New file. Define exit status variable. + * argp/argp-help.c (__argp_state_help): Use argp_err_exit_status + variable instead of always exiting with value 1. + * argp/argp-pv.c (argp_program_version): Make `const'. + * argp/argp.h: Declare argp_err_exit_status. + Patches by Miles Bader <miles@gnu.ai.mit.edu>. + + * locale/programs/localedef.c: Use argp_err_exit_status to + terminate with correct value. + + * inet/rcmd.c (iruserok): Use euidaccess instead of half-hearted + switching of UID before opening .rhosts. + + * libio/vsnprintf.c: Change implementation to follow ISO C 9X + proposal. The return value now is always the number of characters + which would be written if enough space is available. + * manual/stdio.texi: Update description for new behaviour. + + * locale/locale.h (__locale_t): Don't use __locale_t for struct + name and pointer to struct since old gccs cannot keep the namespaces + apart. Rename struct to __locale_struct. + * locale/duplocale.h: Likewise. + * locale/newlocale.h: Likewise. + + * math/Makefile (headers): Add complex.h and cmathcalls.h. + (routines): Remove w_cabs. Add conj, cimag, creal, and cabs. + * math/math.h: Undefine __MATHDECL_1, __MATHDECL, and __MATHCALL + after use. + (signgam): Move declaration to here from mathcalls.h. + * math/mathcalls.h (cabs, __cabs_complex, signgam): Remove definition. + Correct comment for fmin and fmax. + Start implementing complex math function from ISO C 9X. + * math/complex.h: New file. + * math/cmathcalls.h: New file. + * math/cabs.c: New file. + * math/cabsf.c: New file. + * math/cabsl.c: New file. + * math/cimag.c: New file. + * math/cimagf.c: New file. + * math/cimagl.c: New file. + * math/conj.c: New file. + * math/conjf.c: New file. + * math/conjl.c: New file. + * math/creal.c: New file. + * math/crealf.c: New file. + * math/creall.c: New file. + * sysdeps/libm-ieee754/w_cabs.c: Removed. + * sysdeps/libm-ieee754/w_cabsf.c: Removed. + * sysdeps/libm-ieee754/w_cabsl.c: Removed. + + * posix/regex.c: Merge with regex sources from Arnold Robbins' + version in GNU awk. + * posix/regex.h: Likewise. + + Add regex test suite by Tom Lord. + * posix/Makefile (distribute): Add TESTS, TESTS2C.sed, and testcases.h. + (tests): Add runtests. + (before-compile): Add testcases.h. + (testcases.h): New rule to generate header with tests. + * posix/TESTS: New file. + * posix/TESTS2C.sed.: New file. + * posix/runtests.c: New file. + * posix/testcases.h: New file. + + * sysdeps/unix/sysv/linux/poll.c: Test whether poll syscall is + available and use fall-back implementation if not. + + * sysdeps/unix/sysv/linux/syscalls.list: Sort entries. + + * time/ialloc.c: Update from tzcode1997c. + * time/private.h: Likewise. + * time/scheck.c: Likewise. + * time/tzselect.ksh: Likewise. + * time/zdump.c: Likewise. + * time/zic.c: Likewise. + + * time/tzfile.c: Pretty print. + +1997-03-06 07:37 Geoff Keating <geoffk@ozemail.com.au> + + Port to powerpc-*-linux-gnu. Slightly tested, under MkLinux, + on a 601. + + * sysdeps/powerpc/Implies: Added. + * sysdeps/powerpc/__longjmp.S: Added. + * sysdeps/powerpc/__math.h: Added. + * sysdeps/powerpc/bsd-_setjmp.S: Added. + * sysdeps/powerpc/bsd-setjmp.S: Added. + * sysdeps/powerpc/dl-machine.h: Added. + * sysdeps/powerpc/ffs.c: Added. + * sysdeps/powerpc/fpu_control.h: Added. + * sysdeps/powerpc/jmp_buf.h: Added. + * sysdeps/powerpc/setjmp.S: Added. + * sysdeps/powerpc/strlen.s: Added. + * sysdeps/powerpc/elf/start.c: Added. + * sysdeps/powerpc/fpu_control.h: Added. + * sysdeps/powerpc/jmp_buf.h: Added. + + * sysdeps/unix/sysv/linux/powerpc/Dist: Added. + * sysdeps/unix/sysv/linux/powerpc/_exit.S: Added. + * sysdeps/unix/sysv/linux/powerpc/brk.c: Added. + * sysdeps/unix/sysv/linux/powerpc/clone.S: Added. + * sysdeps/unix/sysv/linux/powerpc/init-first.h: Added. + * sysdeps/unix/sysv/linux/powerpc/ioctl-types.h: Added. + * sysdeps/unix/sysv/linux/powerpc/profil.c: Added. + * sysdeps/unix/sysv/linux/powerpc/sigreturn.S: Added. + * sysdeps/unix/sysv/linux/powerpc/socket.S: Added. + * sysdeps/unix/sysv/linux/powerpc/syscall.S: Added. + * sysdeps/unix/sysv/linux/powerpc/syscalls.list: Added. + * sysdeps/unix/sysv/linux/powerpc/sysdep.c: Added. + * sysdeps/unix/sysv/linux/powerpc/sysdep.h: Added. + * sysdeps/unix/sysv/linux/powerpc/termbits.h: Added. + * sysdeps/unix/sysv/linux/powerpc/sys/syscall.h: Added. + +1997-03-05 05:24 Geoff Keating <geoffk@ozemail.com.au> + + * elf/dl-runtime.c (fixup): Add ELF_FIXUP_RETURNS_ADDRESS switch, + because knowing the first instruction of a PowerPC PLT trampoline + is not very helpful. + +1997-03-04 08:04 Geoff Keating <geoffk@ozemail.com.au> + + * elf/dl-load.c (ELF_PREFERRED_ADDRESS, ELF_PREFERRED_ADDRESS_DATA, + ELF_FIXED_ADDRESS): Added. These are for dl-machine.h to indicate + a preference as to where executables should be loaded. + +1997-02-28 08:50 Geoff Keating <geoffk@ozemail.com.au> + + * elf/elf.h: Add in all those PowerPC reloc types. + +1997-02-24 07:12 Geoff Keating <geoffk@ozemail.com.au> + + * stdio-common/vfscanf.c: Use __va_copy if available. + +1997-03-06 13:50 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> + + * malloc/malloc.c (mprotect) [_LIBC]: Define as __mprotect to + clean up namespace. + +1997-03-07 14:27 Ulrich Drepper <drepper@cygnus.com> + + * sysdeps/libm-ieee754/s_fpclassify.c (__fpclassify): Don't use + non-existing GET_WORDS macro, use EXTRACT_WORDS. + Reported by Andres Schwab <schwab@issan.informatik.uni-dortmund.de>. + +1997-03-07 05:27 Ulrich Drepper <drepper@cygnus.com> + + * sysdeps/unix/sysv/linux/i386/sigaction.c: The user- and + kernel-level sigaction structure is different. handle this + correctly. + Bug report by Andres Jaeger <jaeger@informatik.uni-kl.de>. + +1997-03-06 05:55 David Engel <david@sw.ods.com> + + * sysdeps/generic/dl-cache.c (_dl_load_cache_lookup): Also + recognize cache entries with flag == 3. + +1997-03-06 01:05 Ulrich Drepper <drepper@cygnus.com> + + * sysdeps/generic/netinet/in.h (INADDR_NONE): Cast to unsigned int. + (INADDR_LOOPBACK): Likewise. + * sysdeps/unix/sysv/linux/netinet/in.h: Likewise. + + * manual/socket.texi: Correct types of INADDR_* constants from + unsigned long to unsigned. + +1997-03-05 23:14 Ulrich Drepper <drepper@cygnus.com> + + * time/antarctica: Update from tzdata1997c. + * time/asia: Likewise. + * time/zone.tab: Likewise. + +1997-03-05 00:43 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> + + * configure.in (libc_cv_asm_symver_directive, + libc_cv_ld_version_script_option): Remove unknown instruction from + assembler test file. + +1997-03-04 19:14 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> + + * sysdeps/m68k/fpu/__math.h: Update feature tests to use + __USE_ISOC9X. + [__USE_ISOC9X]: Define __log2 and __exp2 inlines. + (fabs): Remove defininition, it is a gcc builtin. + (sqrt, __sqrt): Remove definition, they have wrappers in libm. + +1997-03-04 10:11 H.J. Lu <hjl@lucon.org> + + * sunrpc/Makefile ($(objpfx)rpc-proto.c): Create subdir before + generating file. + +1997-03-05 03:59 Ulrich Drepper <drepper@cygnus.com> + + * inet/rcmd.c (__ivaliduser): Don't use getline, but __getline + instead to avoid namespace problems. + Reported by David Mosberger-Tang <davidm@AZStarNet.COM>. + +1997-03-03 19:01 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> + + * login/utmp_file.c: Fix previous change. Make portable by + checking the _HAVE_UT_* feature macros. + 1997-03-04 04:31 Ulrich Drepper <drepper@cygnus.com> * Makerules: Add rules to handle versioning. @@ -205,13 +411,6 @@ * math/math.h: Include <__math.h> if __NO_MATH_INLINES is not defined and we want optimization. -1997-02-27 01:13 Ulrich Drepper <drepper@cygnus.com> - - * sysdeps/generic/netinet/in.h (htonl, htons, ntohl, ntohs): Change - prototypes to use types with explicit width. `unsigned long' is - different on 64 bit systems. - Suggested by a sun <asun@zoology.washington.edu>. - 1997-02-02 19:53 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * misc/getpass.c: Don't disable canonical input. @@ -225,7 +424,7 @@ * libio/genops.c (_IO_default_finish): Add second parameter, which is ignored. * libio/memstream.c (_IO_mem_finish): Likewise. - * libio/fileops.c (_IO_mem_finish): Likewise. + * libio/fileops.c (_IO_file_finish): Likewise. * libio/strops.c (_IO_str_finish): Likewise. All callers changed. 1997-02-27 00:23 H.J. Lu <hjl@lucon.org> diff --git a/argp/Makefile b/argp/Makefile index 68fab3cd14..c151569913 100644 --- a/argp/Makefile +++ b/argp/Makefile @@ -24,7 +24,7 @@ subdir := argp headers = argp.h distribute = argp-fmtstream.h argp-namefrob.h routines = $(addprefix argp-, ba fmtstream fs-xinl help parse pv \ - pvh xinl) + pvh xinl eexst) tests = argp-test diff --git a/argp/argp-ba.c b/argp/argp-ba.c index 61efc3466a..5d58cc6c51 100644 --- a/argp/argp-ba.c +++ b/argp/argp-ba.c @@ -23,4 +23,4 @@ the ARGP_HELP_BUG_ADDR flag is set (as it is by various standard help messages), embedded in a sentence that says something like `Report bugs to ADDR.'. */ -char *argp_program_bug_address = 0; +const char *argp_program_bug_address = 0; diff --git a/argp/argp-eexst.c b/argp/argp-eexst.c new file mode 100644 index 0000000000..676d1ec517 --- /dev/null +++ b/argp/argp-eexst.c @@ -0,0 +1,29 @@ +/* Default definition for ARGP_ERR_EXIT_STATUS + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Written by Miles Bader <miles@gnu.ai.mit.edu>. + + 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 HAVE_CONFIG_H +#include <config.h> +#endif + +#include "argp.h" + +/* The exit status that argp will use when exiting due to a parsing error. + If not defined or set by the user program, this defaults to 1. */ +error_t argp_err_exit_status = 1; diff --git a/argp/argp-help.c b/argp/argp-help.c index e954beb5a9..b3d8b36418 100644 --- a/argp/argp-help.c +++ b/argp/argp-help.c @@ -156,7 +156,7 @@ fill_in_uparams (const struct argp_state *state) arg++; SKIPWS (arg); } - + if (unspec) if (var[0] == 'n' && var[1] == 'o' && var[2] == '-') { @@ -878,7 +878,7 @@ arg (const struct argp_option *real, const char *req_fmt, const char *opt_fmt, /* Helper functions for hol_entry_help. */ /* State used during the execution of hol_help. */ -struct hol_help_state +struct hol_help_state { /* PREV_ENTRY should contain the previous entry printed, or 0. */ struct hol_entry *prev_entry; @@ -1600,7 +1600,7 @@ __argp_state_help (const struct argp_state *state, FILE *stream, unsigned flags) if (!state || ! (state->flags & ARGP_NO_EXIT)) { if (flags & ARGP_HELP_EXIT_ERR) - exit (1); + exit (argp_err_exit_status); if (flags & ARGP_HELP_EXIT_OK) exit (0); } @@ -1612,7 +1612,7 @@ weak_alias (__argp_state_help, argp_state_help) /* If appropriate, print the printf string FMT and following args, preceded by the program name and `:', to stderr, and followed by a `Try ... --help' - message, then exit (1). */ + message, then exit (ARGP_ERR_EXIT_STATUS). */ void __argp_error (const struct argp_state *state, const char *fmt, ...) { diff --git a/argp/argp-pv.c b/argp/argp-pv.c index 59e6f8d07b..27d714b361 100644 --- a/argp/argp-pv.c +++ b/argp/argp-pv.c @@ -22,4 +22,4 @@ --version is added (unless the ARGP_NO_HELP flag is used), which will print this this string followed by a newline and exit (unless the ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */ -char *argp_program_version = 0; +const char *argp_program_version = 0; diff --git a/argp/argp.h b/argp/argp.h index cdb32b799a..d418253692 100644 --- a/argp/argp.h +++ b/argp/argp.h @@ -240,7 +240,7 @@ struct argp TEXT is NULL for this key. */ /* Explanatory note emitted when duplicate option arguments have been suppressed. */ -#define ARGP_KEY_HELP_DUP_ARGS_NOTE 0x2000005 +#define ARGP_KEY_HELP_DUP_ARGS_NOTE 0x2000005 /* When an argp has a non-zero CHILDREN field, it should point to a vector of argp_child structures, each of which describes a subsidiary argp. */ @@ -379,7 +379,7 @@ extern error_t __argp_parse __P ((__const struct argp *__argp, option --version is added (unless the ARGP_NO_HELP flag is used), which will print this string followed by a newline and exit (unless the ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */ -extern const char *argp_program_version; +extern __const char *argp_program_version; /* If defined or set by the user program to a non-zero value, then a default option --version is added (unless the ARGP_NO_HELP flag is used), which @@ -395,6 +395,10 @@ extern void (*argp_program_version_hook) __P ((FILE *__stream, standard help messages), embedded in a sentence that says something like `Report bugs to ADDR.'. */ __const extern char *argp_program_bug_address; + +/* The exit status that argp will use when exiting due to a parsing error. + If not defined or set by the user program, this defaults to 1. */ +extern error_t argp_err_exit_status; /* Flags for argp_help. */ #define ARGP_HELP_USAGE 0x01 /* a Usage: message. */ diff --git a/configure b/configure index 414403d84e..3edb97d984 100755 --- a/configure +++ b/configure @@ -1605,7 +1605,7 @@ if eval "test \"`echo '$''{'libc_cv_asm_symver_directive'+set}'`\" = set"; then else cat > conftest.s <<EOF .text -_sym: ret +_sym: .symver _sym,sym@VERS EOF if ${CC-cc} -c $CFLAGS $CPPFLAGS conftest.s 1>&5 2>&5; then @@ -1625,7 +1625,7 @@ else if test $libc_cv_asm_symver_directive = yes; then cat > conftest.s <<EOF .text -_sym: ret +_sym: .symver _sym,sym@VERS EOF cat > conftest.map <<EOF @@ -2069,7 +2069,7 @@ EOF # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in + case `(ac_space=' '; set) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). diff --git a/configure.in b/configure.in index 11421eff9f..f36bcaf1bf 100644 --- a/configure.in +++ b/configure.in @@ -492,7 +492,7 @@ fi AC_CACHE_CHECK(for .symver assembler directive, libc_cv_asm_symver_directive, [cat > conftest.s <<EOF .text -_sym: ret +_sym: .symver _sym,sym@VERS EOF if ${CC-cc} -c $CFLAGS $CPPFLAGS conftest.s 1>&AC_FD_CC 2>&AC_FD_CC; then @@ -505,7 +505,7 @@ AC_CACHE_CHECK(for ld --version-script, libc_cv_ld_version_script_option, [dnl if test $libc_cv_asm_symver_directive = yes; then cat > conftest.s <<EOF .text -_sym: ret +_sym: .symver _sym,sym@VERS EOF cat > conftest.map <<EOF diff --git a/elf/dl-load.c b/elf/dl-load.c index a103d38548..10cc074a6a 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -67,6 +67,18 @@ int _dl_zerofd = -1; #define ANONFD _dl_zerofd #endif +/* Handle situations where we have a preferred location in memory for + the shared objects. */ +#ifdef ELF_PREFERRED_ADDRESS_DATA +ELF_PREFERRED_ADDRESS_DATA; +#endif +#ifndef ELF_PREFERRED_ADDRESS +#define ELF_PREFERRED_ADDRESS(loader, maplength, mapstartpref) (mapstartpref) +#endif +#ifndef ELF_FIXED_ADDRESS +#define ELF_FIXED_ADDRESS(loader, mapstart) ((void) 0) +#endif + size_t _dl_pagesize; @@ -315,11 +327,16 @@ _dl_map_object_from_fd (char *name, int fd, char *realname, So we map the first segment without MAP_FIXED, but with its extent increased to cover all the segments. Then we remove access from excess portion, and there is known sufficient space - there to remap from the later segments. */ + there to remap from the later segments. + + As a refinement, sometimes we have an address that we would + prefer to map such objects at; but this is only a preference, + the OS can do whatever it likes. */ caddr_t mapat; - mapat = map_segment (c->mapstart, - loadcmds[nloadcmds - 1].allocend - c->mapstart, - c->prot, 0, c->mapoff); + ElfW(Addr) mappref; + size_t maplength = loadcmds[nloadcmds - 1].allocend - c->mapstart; + mappref = ELF_PREFERRED_ADDRESS (loader, maplength, c->mapstart); + mapat = map_segment (mappref, maplength, c->prot, 0, c->mapoff); l->l_addr = (ElfW(Addr)) mapat - c->mapstart; /* Change protection on the excess portion to disallow all access; @@ -332,6 +349,12 @@ _dl_map_object_from_fd (char *name, int fd, char *realname, 0); goto postmap; } + else + { + /* Notify ELF_PREFERRED_ADDRESS that we have to load this one + fixed. */ + ELF_FIXED_ADDRESS (loader, c->mapstart); + } while (c < &loadcmds[nloadcmds]) { diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c index 08c605cd0f..502c35d5d2 100644 --- a/elf/dl-runtime.c +++ b/elf/dl-runtime.c @@ -153,7 +153,11 @@ fixup ( *_dl_global_scope_end = NULL; /* Return the address that was written by the relocation. */ +#ifdef ELF_FIXUP_RETURNS_ADDRESS + return (ElfW(Addr))(l->l_addr + reloc->r_offset); +#else return *(ElfW(Addr) *) (l->l_addr + reloc->r_offset); +#endif } diff --git a/elf/elf.h b/elf/elf.h index f6779ba16a..76f6c6865d 100644 --- a/elf/elf.h +++ b/elf/elf.h @@ -915,6 +915,71 @@ typedef Elf32_Addr Elf32_Conflict; #define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */ #define R_ALPHA_RELATIVE 27 /* Adjust by program base */ + +/* PowerPC specific declarations */ + +/* PowerPC relocations defined by the ABIs */ +#define R_PPC_NONE 0 +#define R_PPC_ADDR32 1 +#define R_PPC_ADDR24 2 +#define R_PPC_ADDR16 3 +#define R_PPC_ADDR16_LO 4 +#define R_PPC_ADDR16_HI 5 +#define R_PPC_ADDR16_HA 6 +#define R_PPC_ADDR14 7 +#define R_PPC_ADDR14_BRTAKEN 8 +#define R_PPC_ADDR14_BRNTAKEN 9 +#define R_PPC_REL24 10 +#define R_PPC_REL14 11 +#define R_PPC_REL14_BRTAKEN 12 +#define R_PPC_REL14_BRNTAKEN 13 +#define R_PPC_GOT16 14 +#define R_PPC_GOT16_LO 15 +#define R_PPC_GOT16_HI 16 +#define R_PPC_GOT16_HA 17 +#define R_PPC_PLTREL24 18 +#define R_PPC_COPY 19 +#define R_PPC_GLOB_DAT 20 +#define R_PPC_JMP_SLOT 21 +#define R_PPC_RELATIVE 22 +#define R_PPC_LOCAL24PC 23 +#define R_PPC_UADDR32 24 +#define R_PPC_UADDR16 25 +#define R_PPC_REL32 26 +#define R_PPC_PLT32 27 +#define R_PPC_PLTREL32 28 +#define R_PPC_PLT16_LO 29 +#define R_PPC_PLT16_HI 30 +#define R_PPC_PLT16_HA 31 +#define R_PPC_SDAREL16 32 +#define R_PPC_SECTOFF 33 +#define R_PPC_SECTOFF_LO 34 +#define R_PPC_SECTOFF_HI 35 +#define R_PPC_SECTOFF_HA 36 + +/* The remaining relocs are from the Embedded ELF ABI, and are not + in the SVR4 ELF ABI. */ +#define R_PPC_EMB_NADDR32 101 +#define R_PPC_EMB_NADDR16 102 +#define R_PPC_EMB_NADDR16_LO 103 +#define R_PPC_EMB_NADDR16_HI 104 +#define R_PPC_EMB_NADDR16_HA 105 +#define R_PPC_EMB_SDAI16 106 +#define R_PPC_EMB_SDA2I16 107 +#define R_PPC_EMB_SDA2REL 108 +#define R_PPC_EMB_SDA21 109 +#define R_PPC_EMB_MRKREF 110 +#define R_PPC_EMB_RELSEC16 111 +#define R_PPC_EMB_RELST_LO 112 +#define R_PPC_EMB_RELST_HI 113 +#define R_PPC_EMB_RELST_HA 114 +#define R_PPC_EMB_BIT_FLD 115 +#define R_PPC_EMB_RELSDA 116 + +/* This is a phony reloc to handle any old fashioned TOC16 references + that may still be in object files. */ +#define R_PPC_TOC16 255 + __END_DECLS #endif /* elf.h */ diff --git a/hurd/hurdauth.c b/hurd/hurdauth.c index 7ddfcd34e5..c60b8d8326 100644 --- a/hurd/hurdauth.c +++ b/hurd/hurdauth.c @@ -40,7 +40,7 @@ _S_msg_add_auth (mach_port_t me, if (err = __USEPORT (AUTH, __auth_makeauth (port, - &addauth, 1, MACH_MSG_TYPE_MOVE_SEND, + &addauth, MACH_MSG_TYPE_MOVE_SEND, 1, NULL, 0, NULL, 0, NULL, 0, @@ -108,7 +108,7 @@ _S_msg_del_auth (mach_port_t me, err = __USEPORT (AUTH, __auth_makeauth (port, - NULL, 0, MACH_MSG_TYPE_COPY_SEND, + NULL, MACH_MSG_TYPE_COPY_SEND, 0, newu, nu, _hurd_id.aux.uids, _hurd_id.aux.nuids, newg, ng, diff --git a/inet/rcmd.c b/inet/rcmd.c index f13a2e6bad..354ff35994 100644 --- a/inet/rcmd.c +++ b/inet/rcmd.c @@ -339,10 +339,10 @@ again: * reading an NFS mounted file system, can't read files that * are protected read/write owner only. */ - uid = geteuid(); - (void)seteuid(pwd->pw_uid); - hostf = fopen(pbuf, "r"); - (void)seteuid(uid); + if (euidaccess (pbuf, R_OK) != 0) + hostf = NULL; + else + hostf = fopen(pbuf, "r"); if (hostf == NULL) return (-1); @@ -390,7 +390,7 @@ __ivaliduser(hostf, raddr, luser, ruser) size_t bufsize = 0; ssize_t nread; - while ((nread = getline (&buf, &bufsize, hostf)) > 0) { + while ((nread = __getline (&buf, &bufsize, hostf)) > 0) { buf[bufsize - 1] = '\0'; /* Make sure it's terminated. */ p = buf; while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0') { diff --git a/libio/vsnprintf.c b/libio/vsnprintf.c index af901bf3e6..5ada74215c 100644 --- a/libio/vsnprintf.c +++ b/libio/vsnprintf.c @@ -1,5 +1,5 @@ /* -Copyright (C) 1994 Free Software Foundation +Copyright (C) 1994, 1997 Free Software Foundation, Inc. This file is part of the GNU IO Library. This library is free software; you can redistribute it and/or modify it under the @@ -25,6 +25,73 @@ the executable file might be covered by the GNU General Public License. */ #include "libioP.h" #include "strfile.h" + +typedef struct +{ + _IO_strfile f; + /* This is used for the characters which do not fit in the buffer + provided by the user. */ + char overflow_buf[64]; +} _IO_strnfile; + + +static int +_IO_strn_overflow (_IO_FILE* fp, int c) +{ + /* When we come to here this means the user supplied buffer is + filled. But since we must return the number of characters which + would have been written in total we must provide a buffer for + further use. We can do this by writing on and on in the overflow + buffer in the _IO_strnfile structure. */ + _IO_strnfile *snf = (_IO_strnfile *) fp; + + if (fp->_IO_buf_base != snf->overflow_buf) + { + /* Terminate the string. We know that there is room for at + least one more character since we initialized the stream with + a size to make this possible. */ + *fp->_IO_write_ptr = '\0'; + + _IO_setb (fp, snf->overflow_buf, + snf->overflow_buf + sizeof (snf->overflow_buf), 0); + + fp->_IO_write_base = snf->overflow_buf; + fp->_IO_read_base = snf->overflow_buf; + fp->_IO_read_ptr = snf->overflow_buf; + fp->_IO_read_end = snf->overflow_buf + sizeof (snf->overflow_buf); + } + + fp->_IO_write_ptr = snf->overflow_buf; + fp->_IO_write_end = snf->overflow_buf; + + /* Since we are not really interested in storing the characters + which do not fit in the buffer we simply ignore it. */ + return c; +} + + +static struct _IO_jump_t _IO_strn_jumps = { + JUMP_INIT_DUMMY, + JUMP_INIT(finish, _IO_str_finish), + JUMP_INIT(overflow, _IO_strn_overflow), + JUMP_INIT(underflow, _IO_str_underflow), + JUMP_INIT(uflow, _IO_default_uflow), + JUMP_INIT(pbackfail, _IO_str_pbackfail), + JUMP_INIT(xsputn, _IO_default_xsputn), + JUMP_INIT(xsgetn, _IO_default_xsgetn), + JUMP_INIT(seekoff, _IO_str_seekoff), + JUMP_INIT(seekpos, _IO_default_seekpos), + JUMP_INIT(setbuf, _IO_default_setbuf), + JUMP_INIT(sync, _IO_default_sync), + JUMP_INIT(doallocate, _IO_default_doallocate), + JUMP_INIT(read, _IO_default_read), + JUMP_INIT(write, _IO_default_write), + JUMP_INIT(seek, _IO_default_seek), + JUMP_INIT(close, _IO_default_close), + JUMP_INIT(stat, _IO_default_stat) +}; + + int _IO_vsnprintf (string, maxlen, format, args) char *string; @@ -32,22 +99,28 @@ _IO_vsnprintf (string, maxlen, format, args) const char *format; _IO_va_list args; { - _IO_strfile sf; + _IO_strnfile sf; int ret; #ifdef _IO_MTSAFE_IO _IO_lock_t lock; - sf._sbf._f._lock = &lock; + sf.f._sbf._f._lock = &lock; #endif - /* We need to handle the special case where MAXLEN is 0. */ + /* We need to handle the special case where MAXLEN is 0. Use the + overflow buffer right from the start. */ if (maxlen == 0) - return 0; + { + string = sf.overflow_buf; + maxlen = sizeof (sf.overflow_buf); + } _IO_init ((_IO_FILE *) &sf, 0); - _IO_JUMPS ((_IO_FILE *) &sf) = &_IO_str_jumps; + _IO_JUMPS ((_IO_FILE *) &sf) = &_IO_strn_jumps; _IO_str_init_static ((_IO_FILE *) &sf, string, maxlen - 1, string); ret = _IO_vfprintf ((_IO_FILE *) &sf, format, args); - *((_IO_FILE *) &sf)->_IO_write_ptr = '\0'; + + if (sf.f._sbf._f._IO_buf_base != sf.overflow_buf) + *sf.f._sbf._f._IO_write_ptr = '\0'; return ret; } weak_alias (_IO_vsnprintf, __vsnprintf) diff --git a/locale/duplocale.c b/locale/duplocale.c index f22c4dee95..7b188efc6d 100644 --- a/locale/duplocale.c +++ b/locale/duplocale.c @@ -38,7 +38,7 @@ __duplocale (__locale_t dataset) __libc_lock_lock (__libc_setlocale_lock); /* Get memory. */ - result = (__locale_t) malloc (sizeof (struct __locale_t)); + result = (__locale_t) malloc (sizeof (struct __locale_struct)); if (result != NULL) { int cnt; diff --git a/locale/newlocale.c b/locale/newlocale.c index d4e184b921..33cc7fa09a 100644 --- a/locale/newlocale.c +++ b/locale/newlocale.c @@ -42,7 +42,7 @@ __newlocale (int category_mask, const char *locale, __locale_t base) { /* Intermediate memory for result. */ const char *newnames[LC_ALL]; - struct __locale_t result; + struct __locale_struct result; __locale_t result_ptr; char *locale_path; size_t locale_path_len; @@ -79,7 +79,7 @@ __newlocale (int category_mask, const char *locale, __locale_t base) dataset using the C locale data. */ if (category_mask == 0) { - result_ptr = (__locale_t) malloc (sizeof (struct __locale_t)); + result_ptr = (__locale_t) malloc (sizeof (struct __locale_struct)); *result_ptr = result; goto update; @@ -158,7 +158,7 @@ __newlocale (int category_mask, const char *locale, __locale_t base) if (base == NULL) { /* Allocate new structure. */ - result_ptr = (__locale_t) malloc (sizeof (struct __locale_t)); + result_ptr = (__locale_t) malloc (sizeof (struct __locale_struct)); if (result_ptr == NULL) return NULL; diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c index e8f0d3bc54..96ff12eaff 100644 --- a/locale/programs/localedef.c +++ b/locale/programs/localedef.c @@ -109,7 +109,7 @@ static const struct argp_option options[] = { "posix", OPT_POSIX, NULL, 0, N_("Be strictly POSIX conform") }, { "quiet", OPT_QUIET, NULL, 0, N_("Suppress warnings and information messages") }, - { "verbose", 'V', NULL, 0, N_("print more messages") }, + { "verbose", 'V', NULL, 0, N_("Print more messages") }, { NULL, 0, NULL, 0, NULL } }; @@ -164,11 +164,9 @@ main (int argc, char *argv[]) textdomain (_libc_intl_domainname); /* Parse and process arguments. */ + argp_err_exit_status = 4; argp_parse (&argp, argc, argv, 0, &remaining, NULL); - /* XXX POSIX is violated since for unknown option a exit value > 3 - must be used. */ - /* POSIX.2 requires to be verbose about missing characters in the character map. */ verbose |= posix_conformance; @@ -176,11 +174,8 @@ main (int argc, char *argv[]) if (argc - remaining != 1) { /* We need exactly one non-option parameter. */ - argp_help (&argp, stdout, ARGP_HELP_SEE, + argp_help (&argp, stdout, ARGP_HELP_SEE | ARGP_HELP_EXIT_ERR, program_invocation_short_name); - - /* XXX Currently POSIX is violated. We must exit with code 4 - but the argp_help function currently does not allow this. */ exit (4); } diff --git a/locale/xlocale.h b/locale/xlocale.h index 62b15953a6..809608037d 100644 --- a/locale/xlocale.h +++ b/locale/xlocale.h @@ -25,7 +25,7 @@ (almost) opaque type for the user level programs. The file and this data structure is not standardized. Don't rely on it. It can go away without warning. */ -typedef struct __locale_t +typedef struct __locale_struct { struct locale_data *__locales[6]; /* XXX LC_ALL should be used here */ diff --git a/login/utmp_file.c b/login/utmp_file.c index ad65ec1309..a0b0aa4346 100644 --- a/login/utmp_file.c +++ b/login/utmp_file.c @@ -87,8 +87,10 @@ setutent_file (int reset) } file_offset = 0; +#if _HAVE_UT_TYPE - 0 /* Make sure the entry won't match. */ last_entry.ut_type = -1; +#endif } else if (reset) { @@ -97,8 +99,10 @@ setutent_file (int reset) /* Remember we are at beginning of file. */ file_offset = 0; +#if _HAVE_UT_TYPE - 0 /* Make sure the entry won't match. */ last_entry.ut_type = -1; +#endif } return 1; @@ -213,7 +217,9 @@ static int proc_utmp_eq (const struct utmp *entry, const struct utmp *match) { return - ((entry->ut_type == INIT_PROCESS + ( +#if _HAVE_UT_TYPE - 0 + (entry->ut_type == INIT_PROCESS || entry->ut_type == LOGIN_PROCESS || entry->ut_type == USER_PROCESS || entry->ut_type == DEAD_PROCESS) @@ -223,14 +229,19 @@ proc_utmp_eq (const struct utmp *entry, const struct utmp *match) || match->ut_type == USER_PROCESS || match->ut_type == DEAD_PROCESS) && - (entry->ut_id && match->ut_id - ? strncmp (entry->ut_id, match->ut_id, sizeof match->ut_id) == 0 - : strncmp (entry->ut_line, match->ut_line, sizeof match->ut_line) == 0)); +#endif +#if _HAVE_UT_ID - 0 + strncmp (entry->ut_id, match->ut_id, sizeof match->ut_id) == 0 +#else + strncmp (entry->ut_line, match->ut_line, sizeof match->ut_line) == 0 +#endif + ); } static int internal_getut_r (const struct utmp *id, struct utmp *buffer) { +#if _HAVE_UT_TYPE - 0 if (id->ut_type == RUN_LVL || id->ut_type == BOOT_TIME || id->ut_type == OLD_TIME || id->ut_type == NEW_TIME) { @@ -254,6 +265,7 @@ internal_getut_r (const struct utmp *id, struct utmp *buffer) } } else +#endif /* _HAVE_UT_TYPE */ { /* Search for the next entry with the specified ID and with type INIT_PROCESS, LOGIN_PROCESS, USER_PROCESS, or DEAD_PROCESS. */ @@ -270,7 +282,7 @@ internal_getut_r (const struct utmp *id, struct utmp *buffer) } file_offset += sizeof (struct utmp); - if (proc_utmp_eq (&buffer, id)) + if (proc_utmp_eq (buffer, id)) break; } } @@ -322,12 +334,16 @@ pututline_file (const struct utmp *data) /* Find the correct place to insert the data. */ if (file_offset > 0 - && ((last_entry.ut_type == data->ut_type + && ( +#if _HAVE_UT_TYPE - 0 + (last_entry.ut_type == data->ut_type && (last_entry.ut_type == RUN_LVL || last_entry.ut_type == BOOT_TIME || last_entry.ut_type == OLD_TIME || last_entry.ut_type == NEW_TIME)) - || proc_utmp_eq (&last_entry, data))) + || +#endif + proc_utmp_eq (&last_entry, data))) found = 1; else found = internal_getut_r (data, &buffer); diff --git a/malloc/malloc.c b/malloc/malloc.c index 6b4fc72b20..dee92e37c6 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -835,6 +835,7 @@ Void_t *(*__morecore)() = __default_morecore; #define mmap __mmap #define munmap __munmap #define mremap __mremap +#define mprotect __mprotect #undef malloc_getpagesize #define malloc_getpagesize __getpagesize() diff --git a/manual/socket.texi b/manual/socket.texi index 91084be16d..cb7b5ddc94 100644 --- a/manual/socket.texi +++ b/manual/socket.texi @@ -747,7 +747,7 @@ host address number as an @code{unsigned long int}. @comment netinet/in.h @comment BSD -@deftypevr Macro {unsigned long int} INADDR_LOOPBACK +@deftypevr Macro {unsigned int} INADDR_LOOPBACK You can use this constant to stand for ``the address of this machine,'' instead of finding its actual address. It is the Internet address @samp{127.0.0.1}, which is usually called @samp{localhost}. This @@ -759,7 +759,7 @@ talking to itself. @comment netinet/in.h @comment BSD -@deftypevr Macro {unsigned long int} INADDR_ANY +@deftypevr Macro {unsigned int} INADDR_ANY You can use this constant to stand for ``any incoming address,'' when binding to an address. @xref{Setting Address}. This is the usual address to give in the @code{sin_addr} member of @w{@code{struct @@ -768,14 +768,14 @@ sockaddr_in}} when you want to accept Internet connections. @comment netinet/in.h @comment BSD -@deftypevr Macro {unsigned long int} INADDR_BROADCAST +@deftypevr Macro {unsigned int} INADDR_BROADCAST This constant is the address you use to send a broadcast message. @c !!! broadcast needs further documented @end deftypevr @comment netinet/in.h @comment BSD -@deftypevr Macro {unsigned long int} INADDR_NONE +@deftypevr Macro {unsigned int} INADDR_NONE This constant is returned by some functions to indicate an error. @end deftypevr diff --git a/manual/stdio.texi b/manual/stdio.texi index 04c635b054..103be34abb 100644 --- a/manual/stdio.texi +++ b/manual/stdio.texi @@ -1479,9 +1479,9 @@ the @var{size} argument specifies the maximum number of characters to produce. The trailing null character is counted towards this limit, so you should allocate at least @var{size} characters for the string @var{s}. -The return value is the number of characters stored, not including the -terminating null. If this value equals @code{@var{size} - 1}, then -there was not enough space in @var{s} for all the output. You should +The return value is the number of characters which are generated for the +given input. If this value is greater than @var{size}, not all +characters from the result have been stored in @var{s}. You should try again with a bigger output string. Here is an example of doing this: @@ -1495,21 +1495,24 @@ make_message (char *name, char *value) /* @r{Guess we need no more than 100 chars of space.} */ int size = 100; char *buffer = (char *) xmalloc (size); + int nchars; @end group @group - while (1) + /* @r{Try to print in the allocated space.} */ + nchars = snprintf (buffer, size, "value of %s is %s", + name, value); +@end group +@group + if (nchars) >= size) @{ - /* @r{Try to print in the allocated space.} */ - int nchars = snprintf (buffer, size, - "value of %s is %s", - name, value); - /* @r{If that worked, return the string.} */ - if (nchars < size) - return buffer; - /* @r{Else try again with twice as much space.} */ - size *= 2; - buffer = (char *) xrealloc (size, buffer); + /* @r{Reallocate buffer now that we know how much space is needed.} */ + buffer = (char *) xrealloc (buffer, nchars + 1); + + /* @r{Try again.} */ + snprintf (buffer, size, "value of %s is %s", name, value); @} + /* @r{The last call worked, return the string.} */ + return buffer; @} @end group @end smallexample diff --git a/math/Makefile b/math/Makefile index b8964baa88..c4ed312c2b 100644 --- a/math/Makefile +++ b/math/Makefile @@ -21,7 +21,8 @@ subdir := math # Installed header files. -headers := math.h mathcalls.h __math.h huge_val.h nan.h fpu_control.h +headers := math.h mathcalls.h __math.h huge_val.h nan.h \ + fpu_control.h complex.h cmathcalls.h # Internal header files. distribute := math_private.h machine/asm.h machine/endian.h @@ -43,10 +44,11 @@ libm-calls = e_acos e_acosh e_asin e_atan2 e_atanh e_cosh e_exp e_fmod \ s_floor s_frexp s_ilogb s_ldexp s_log1p s_logb \ s_modf s_nextafter s_rint s_scalbn s_significand \ s_sin s_tan s_tanh w_acos w_acosh w_asin \ - w_atan2 w_atanh w_cabs w_cosh w_drem w_exp w_fmod w_gamma \ + w_atan2 w_atanh w_cosh w_drem w_exp w_fmod w_gamma \ w_gamma_r w_hypot w_j0 w_j1 w_jn w_lgamma w_lgamma_r \ w_log w_log10 w_pow w_remainder w_scalb w_sinh w_sqrt \ - s_signbit s_fpclassify s_fmax s_fmin s_fdim + s_signbit s_fpclassify s_fmax s_fmin s_fdim \ + conj cimag creal cabs libm-routines = $(libm-support) $(libm-calls) \ $(patsubst %_rf,%f_r,$(libm-calls:=f)) \ $(long-m-$(long-double-fcts)) diff --git a/math/cabs.c b/math/cabs.c new file mode 100644 index 0000000000..cf775ded95 --- /dev/null +++ b/math/cabs.c @@ -0,0 +1,33 @@ +/* Return the complex absolute value of double complex value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <complex.h> +#include <math.h> + +double +__cabs (double complex z) +{ + return __hypot (__real__ z, __imag__ z); +} +weak_alias (__cabs, cabs) +#ifdef NO_LONG_DOUBLE +strong_alias (__cabs, __cabsl) +weak_alias (__cabs, cabsl) +#endif diff --git a/math/cabsf.c b/math/cabsf.c new file mode 100644 index 0000000000..2ea2660d97 --- /dev/null +++ b/math/cabsf.c @@ -0,0 +1,29 @@ +/* Return the complex absolute value of float complex value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <complex.h> +#include <math.h> + +float +__cabsf (float complex z) +{ + return __hypotf (__real__ z, __imag__ z); +} +weak_alias (__cabsf, cabsf) diff --git a/math/cabsl.c b/math/cabsl.c new file mode 100644 index 0000000000..1f3554cef2 --- /dev/null +++ b/math/cabsl.c @@ -0,0 +1,29 @@ +/* Return the complex absolute value of long double complex value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <complex.h> +#include <math.h> + +long double +__cabsl (long double complex z) +{ + return __hypotl (__real__ z, __imag__ z); +} +weak_alias (__cabsl, cabsl) diff --git a/math/cimag.c b/math/cimag.c new file mode 100644 index 0000000000..13efa1476e --- /dev/null +++ b/math/cimag.c @@ -0,0 +1,32 @@ +/* Return imaginary part of complex double value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <complex.h> + +double +__cimag (double complex z) +{ + return __imag__ z; +} +weak_alias (__cimag, cimag) +#ifdef NO_LONG_DOUBLE +strong_alias (__cimag, __cimagl) +weak_alias (__cimag, cimagl) +#endif diff --git a/math/cimagf.c b/math/cimagf.c new file mode 100644 index 0000000000..8edb4e613e --- /dev/null +++ b/math/cimagf.c @@ -0,0 +1,28 @@ +/* Return imaginary part of complex float value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <complex.h> + +float +__cimagf (float complex z) +{ + return __imag__ z; +} +weak_alias (__cimagf, cimagf) diff --git a/math/cimagl.c b/math/cimagl.c new file mode 100644 index 0000000000..9c58899274 --- /dev/null +++ b/math/cimagl.c @@ -0,0 +1,28 @@ +/* Return imaginary part of complex long double value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <complex.h> + +long double +__cimagl (long double complex z) +{ + return __imag__ z; +} +weak_alias (__cimagl, cimagl) diff --git a/math/cmathcalls.h b/math/cmathcalls.h new file mode 100644 index 0000000000..658c3a729d --- /dev/null +++ b/math/cmathcalls.h @@ -0,0 +1,152 @@ +/* Prototype declarations for complex math functions; + helper file for <complex.h>. + 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. */ + +/* NOTE: Because of the special way this file is used by <math.h>, 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 include cmathcalls.h directly; include <complex.h> 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)); + + +/* 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, projections, 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/math/complex.h b/math/complex.h new file mode 100644 index 0000000000..6fc5c1975f --- /dev/null +++ b/math/complex.h @@ -0,0 +1,102 @@ +/* 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. */ + +/* + * ISO C 9X: 7.8 Complex arithmetic <complex.h> + */ + +#ifndef _COMPLEX_H +#define _COMPLEX_H 1 + +/* We might need to add support for more compilers here. But once ISO + C 9X is out hopefully all maintained compilers will provide the data + types `float complex' and `double complex'. */ +#if (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || __GNUC__ > 2 +# define complex __complex__ +#endif + + +/* Narrowest imaginary unit. This depends on the floating-point + evaluation method. + XXX This probably has to go into a gcc related file. */ +#define _Imaginary_I (DBL_EPSISON * 1.0i) + +/* Another more descriptive name is `I'. */ +#undef I +#define I _Imaginary_I + + +/* Optimization aids. This is not yet implemented in gcc and yonce it + is this will probably be available in a gcc header. */ +#define CX_LIMITED_RANGE_ON +#define CX_LIMITED_RANGE_OFF +#define CX_LIMITED_RANGE_DEFAULT + + +/* The file <cmathcalls.h> contains the prototypes for all the actual + math functions. These macros are used for those prototypes, so + we can easily declare each function as both `name' and `__name', + and can declare the float versions `namef' and `__namef'. */ + +#define __MATHCALL(function, args) \ + __MATHDECL (_Mdouble_complex_,function, args) +#define __MATHDECL(type, function, args) \ + __MATHDECL_1(type, function, args); \ + __MATHDECL_1(type, __CONCAT(__,function), args) +#define __MATHDECL_1(type, function, args) \ + extern type __MATH_PRECNAME(function) args + +#define _Mdouble_ double +#define __MATH_PRECNAME(name) name +#include <cmathcalls.h> +#undef _Mdouble_ +#undef __MATH_PRECNAME + +/* Now the float versions. */ +#ifndef _Mfloat_ +#define _Mfloat_ float +#endif +#define _Mdouble_ _Mfloat_ +#ifdef __STDC__ +#define __MATH_PRECNAME(name) name##f +#else +#define __MATH_PRECNAME(name) name/**/f +#endif +#include <cmathcalls.h> +#undef _Mdouble_ +#undef __MATH_PRECNAME + +/* And the long double versions. It is non-critical to define them + here unconditionally since `long double' is required in ISO C 9X. */ +#ifndef _Mlong_double_ +#define _Mlong_double_ long double +#endif +#define _Mdouble_ _Mlong_double_ +#ifdef __STDC__ +#define __MATH_PRECNAME(name) name##l +#else +#define __MATH_PRECNAME(name) name/**/l +#endif +#include <cmathcalls.h> +#undef _Mdouble_ +#undef __MATH_PRECNAME +#undef __MATHDECL_1 +#undef __MATHDECL +#undef __MATHCALL + +#endif /* complex.h */ diff --git a/math/conj.c b/math/conj.c new file mode 100644 index 0000000000..c15c417e4c --- /dev/null +++ b/math/conj.c @@ -0,0 +1,32 @@ +/* Return complex conjugate of complex double value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <complex.h> + +double complex +__conj (double complex z) +{ + return ~z; +} +weak_alias (__conj, conj) +#ifdef NO_LONG_DOUBLE +strong_alias (__conj, __conjl) +weak_alias (__conj, conjl) +#endif diff --git a/math/conjf.c b/math/conjf.c new file mode 100644 index 0000000000..828edaf2b7 --- /dev/null +++ b/math/conjf.c @@ -0,0 +1,28 @@ +/* Return complex conjugate of complex float value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <complex.h> + +float complex +__conjf (float complex z) +{ + return ~z; +} +weak_alias (__conjf, conjf) diff --git a/math/conjl.c b/math/conjl.c new file mode 100644 index 0000000000..9e44dc32a1 --- /dev/null +++ b/math/conjl.c @@ -0,0 +1,28 @@ +/* Return complex conjugate of complex long double value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <complex.h> + +long double complex +__conjl (long double complex z) +{ + return ~z; +} +weak_alias (__conjl, conjl) diff --git a/math/creal.c b/math/creal.c new file mode 100644 index 0000000000..c3ec4f7802 --- /dev/null +++ b/math/creal.c @@ -0,0 +1,32 @@ +/* Return real part of complex double value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <complex.h> + +double +__creal (double complex z) +{ + return __real__ z; +} +weak_alias (__creal, creal) +#ifdef NO_LONG_DOUBLE +strong_alias (__creal, __creall) +weak_alias (__creal, creall) +#endif diff --git a/math/crealf.c b/math/crealf.c new file mode 100644 index 0000000000..bb9c2c1418 --- /dev/null +++ b/math/crealf.c @@ -0,0 +1,28 @@ +/* Return real part of complex float value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <complex.h> + +float +__crealf (float complex z) +{ + return __real__ z; +} +weak_alias (__crealf, crealf) diff --git a/math/creall.c b/math/creall.c new file mode 100644 index 0000000000..0ab1aab2cb --- /dev/null +++ b/math/creall.c @@ -0,0 +1,28 @@ +/* Return real part of complex long double value. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <complex.h> + +long double +__creall (long double complex z) +{ + return __real__ z; +} +weak_alias (__creall, creall) diff --git a/math/math.h b/math/math.h index e08d210be8..22274f023e 100644 --- a/math/math.h +++ b/math/math.h @@ -96,6 +96,15 @@ __BEGIN_DECLS #endif /* __STDC__ || __GNUC__ */ #endif /* Use misc or ISO C 9X. */ +#undef __MATHDECL_1 +#undef __MATHDECL +#undef __MATHCALL + + +#if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC9X +/* This variable is used by `gamma' and `lgamma'. */ +extern int signgam; +#endif /* ISO C 9X defines some generic macros which work on any data type. */ diff --git a/math/mathcalls.h b/math/mathcalls.h index fd8ed86e81..d529c1a8e2 100644 --- a/math/mathcalls.h +++ b/math/mathcalls.h @@ -178,14 +178,6 @@ __MATHCALL (scalbn,, (_Mdouble_ __x, int __n)); /* Return the remainder of X/Y. */ __MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y)); -struct __MATH_PRECNAME(__cabs_complex,) -{ - _Mdouble_ x, y; -}; - -/* Return `sqrt(X*X + Y*Y)'. */ -__MATHCALL (cabs,, (struct __MATH_PRECNAME(__cabs_complex,))); - /* Return the fractional part of X after dividing out `ilogb (X)'. */ __MATHCALL (significand,, (_Mdouble_ __x)); @@ -226,9 +218,6 @@ __MATHCALL (erfc,, (_Mdouble_)); __MATHCALL (gamma,, (_Mdouble_)); __MATHCALL (lgamma,, (_Mdouble_)); -/* This variable is used by `gamma' and `lgamma'. */ -extern int signgam; - #ifdef __USE_MISC /* Reentrant versions of gamma and lgamma. Those functions use the global variable `signgam'. The reentrant versions instead take a pointer and @@ -279,10 +268,10 @@ __MATHCALL (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo)); /* Return positive difference between X and Y. */ __MATHCALL (fdim,, (_Mdouble_ __x, _Mdouble_ __y)); -/* Return minimum numeric value from X and Y. */ +/* Return maximum numeric value from X and Y. */ __MATHCALL (fmax,, (_Mdouble_ __x, _Mdouble_ __y)); -/* Return maximum numeric value from X and Y. */ +/* Return minimum numeric value from X and Y. */ __MATHCALL (fmin,, (_Mdouble_ __x, _Mdouble_ __y)); diff --git a/posix/Makefile b/posix/Makefile index d4ae754702..83509f65e6 100644 --- a/posix/Makefile +++ b/posix/Makefile @@ -27,7 +27,7 @@ headers := sys/utsname.h sys/times.h sys/wait.h sys/types.h unistd.h \ utsnamelen.h confname.h waitflags.h waitstatus.h sys/unistd.h \ sched.h schedbits.h re_comp.h wait.h -distribute := confstr.h +distribute := confstr.h TESTS TESTS2C.sed testcases.h routines := \ uname \ @@ -49,12 +49,14 @@ routines := \ getaddrinfo gai_strerror aux := init-posix environ -tests := tstgetopt testfnm +tests := tstgetopt testfnm runtests others := getconf install-bin := getconf install-lib := libposix.a gpl2lgpl := getopt.c getopt1.c getopt.h regex.c regex.h +before-compile := testcases.h + include ../Rules CFLAGS-regex.c = -Wno-unused -Wno-strict-prototypes @@ -62,6 +64,11 @@ CFLAGS-getaddrinfo.c = -DRESOLVER $(objpfx)libposix.a: $(dep-dummy-lib); $(make-dummy-lib) lib: $(objpfx)libposix.a + +testcases.h: TESTS TESTS2C.sed + sed -f TESTS2C.sed < $< > $@T + mv -f $@T $@ + test ! -d CVS || cvs commit -mRegenerated $@ # Make the standalone glob/fnmatch package. diff --git a/posix/TESTS b/posix/TESTS new file mode 100644 index 0000000000..2bb7c93446 --- /dev/null +++ b/posix/TESTS @@ -0,0 +1,159 @@ +0:(.*)*\1:xx +0:^: +0:$: +0:^$: +0:^a$:a +0:abc:abc +1:abc:xbc +1:abc:axc +1:abc:abx +0:abc:xabcy +0:abc:ababc +0:ab*c:abc +0:ab*bc:abc +0:ab*bc:abbc +0:ab*bc:abbbbc +0:ab+bc:abbc +1:ab+bc:abc +1:ab+bc:abq +0:ab+bc:abbbbc +0:ab?bc:abbc +0:ab?bc:abc +1:ab?bc:abbbbc +0:ab?c:abc +0:^abc$:abc +1:^abc$:abcc +0:^abc:abcc +1:^abc$:aabc +0:abc$:aabc +0:^:abc +0:$:abc +0:a.c:abc +0:a.c:axc +0:a.*c:axyzc +1:a.*c:axyzd +1:a[bc]d:abc +0:a[bc]d:abd +1:a[b-d]e:abd +0:a[b-d]e:ace +0:a[b-d]:aac +0:a[-b]:a- +0:a[b-]:a- +1:a[b-a]:- +2:a[]b:- +2:a[:- +0:a]:a] +0:a[]]b:a]b +0:a[^bc]d:aed +1:a[^bc]d:abd +0:a[^-b]c:adc +1:a[^-b]c:a-c +1:a[^]b]c:a]c +0:a[^]b]c:adc +0:ab|cd:abc +0:ab|cd:abcd +0:()ef:def +0:()*:- +1:*a:- +0:^*:- +0:$*:- +1:(*)b:- +1:$b:b +2:a\:- +0:a\(b:a(b +0:a\(*b:ab +0:a\(*b:a((b +1:a\x:a\x +1:abc):- +2:(abc:- +0:((a)):abc +0:(a)b(c):abc +0:a+b+c:aabbabc +0:a**:- +0:a*?:- +0:(a*)*:- +0:(a*)+:- +0:(a|)*:- +0:(a*|b)*:- +0:(a+|b)*:ab +0:(a+|b)+:ab +0:(a+|b)?:ab +0:[^ab]*:cde +0:(^)*:- +0:(ab|)*:- +2:)(:- +1:abc: +1:abc: +0:a*: +0:([abc])*d:abbbcd +0:([abc])*bcd:abcd +0:a|b|c|d|e:e +0:(a|b|c|d|e)f:ef +0:((a*|b))*:- +0:abcd*efg:abcdefg +0:ab*:xabyabbbz +0:ab*:xayabbbz +0:(ab|cd)e:abcde +0:[abhgefdc]ij:hij +1:^(ab|cd)e:abcde +0:(abc|)ef:abcdef +0:(a|b)c*d:abcd +0:(ab|ab*)bc:abc +0:a([bc]*)c*:abc +0:a([bc]*)(c*d):abcd +0:a([bc]+)(c*d):abcd +0:a([bc]*)(c+d):abcd +0:a[bcd]*dcdcde:adcdcde +1:a[bcd]+dcdcde:adcdcde +0:(ab|a)b*c:abc +0:((a)(b)c)(d):abcd +0:[A-Za-z_][A-Za-z0-9_]*:alpha +0:^a(bc+|b[eh])g|.h$:abh +0:(bc+d$|ef*g.|h?i(j|k)):effgz +0:(bc+d$|ef*g.|h?i(j|k)):ij +1:(bc+d$|ef*g.|h?i(j|k)):effg +1:(bc+d$|ef*g.|h?i(j|k)):bcdd +0:(bc+d$|ef*g.|h?i(j|k)):reffgz +1:((((((((((a)))))))))):- +0:(((((((((a))))))))):a +1:multiple words of text:uh-uh +0:multiple words:multiple words, yeah +0:(.*)c(.*):abcde +1:\((.*),:(.*)\) +1:[k]:ab +0:abcd:abcd +0:a(bc)d:abcd +0:a[-]?c:ac +0:(....).*\1:beriberi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Muammar Qaddafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Mo'ammar Gadhafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Muammar Kaddafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Muammar Qadhafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Moammar El Kadhafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Muammar Gadafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Mu'ammar al-Qadafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Moamer El Kazzafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Moamar al-Gaddafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Mu'ammar Al Qathafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Muammar Al Qathafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Mo'ammar el-Gadhafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Moamar El Kadhafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Muammar al-Qadhafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Mu'ammar al-Qadhdhafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Mu'ammar Qadafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Moamar Gaddafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Mu'ammar Qadhdhafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Muammar Khaddafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Muammar al-Khaddafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Mu'amar al-Kadafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Muammar Ghaddafy +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Muammar Ghadafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Muammar Ghaddafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Muamar Kaddafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Muammar Quathafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Muammar Gheddafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Muamar Al-Kaddafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Moammar Khadafy +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Moammar Qudhafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Mu'ammar al-Qaddafi +0:M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]:Mulazim Awwal Mu'ammar Muhammad Abu Minyar al-Qadhafi diff --git a/posix/TESTS2C.sed b/posix/TESTS2C.sed new file mode 100644 index 0000000000..28dd131dac --- /dev/null +++ b/posix/TESTS2C.sed @@ -0,0 +1,2 @@ +s/\\/\\\\/g +s/\(.*\):\(.*\):\(.*\)/ {\1, "\2", "\3"},/ diff --git a/posix/regex.c b/posix/regex.c index 370a612603..202ee19c86 100644 --- a/posix/regex.c +++ b/posix/regex.c @@ -35,8 +35,12 @@ #include <config.h> #endif +#if defined(STDC_HEADERS) && !defined(emacs) +#include <stddef.h> +#else /* We need this for `regex.h', and perhaps for the Emacs include files. */ #include <sys/types.h> +#endif /* This is for other GNU distributions with internationalized messages. */ #if HAVE_LIBINTL_H || defined (_LIBC) @@ -500,6 +504,7 @@ typedef enum } while (0) #ifdef DEBUG +static void extract_number _RE_ARGS ((int *dest, unsigned char *source)); static void extract_number (dest, source) int *dest; @@ -527,6 +532,8 @@ extract_number (dest, source) } while (0) #ifdef DEBUG +static void extract_number_and_incr _RE_ARGS ((int *destination, + unsigned char **source)); static void extract_number_and_incr (destination, source) int *destination; @@ -890,6 +897,13 @@ print_double_string (where, string1, size1, string2, size2) } } +void +printchar (c) + int c; +{ + putc (c, stderr); +} + #else /* not DEBUG */ #undef assert @@ -1007,9 +1021,35 @@ static const char *re_error_msgid[] = #endif /* Roughly the maximum number of failure points on the stack. Would be - exactly that if always used MAX_FAILURE_ITEMS items each time we failed. + exactly that if always used MAX_FAILURE_SPACE each time we failed. This is a variable only so users of regex can assign to it; we never change it ourselves. */ + +#ifdef INT_IS_16BIT + +#if defined (MATCH_MAY_ALLOCATE) +long re_max_failures = 4000; +#else +long re_max_failures = 2000; +#endif + +union fail_stack_elt +{ + unsigned char *pointer; + long integer; +}; + +typedef union fail_stack_elt fail_stack_elt_t; + +typedef struct +{ + fail_stack_elt_t *stack; + unsigned long size; + unsigned long avail; /* Offset of next open position. */ +} fail_stack_type; + +#else /* not INT_IS_16BIT */ + #if defined (MATCH_MAY_ALLOCATE) /* 4400 was enough to cause a crash on Alpha OSF/1, whose default stack limit is 2mb. */ @@ -1033,6 +1073,8 @@ typedef struct unsigned avail; /* Offset of next open position. */ } fail_stack_type; +#endif /* INT_IS_16BIT */ + #define FAIL_STACK_EMPTY() (fail_stack.avail == 0) #define FAIL_STACK_PTR_EMPTY() (fail_stack_ptr->avail == 0) #define FAIL_STACK_FULL() (fail_stack.avail == fail_stack.size) @@ -1123,7 +1165,7 @@ typedef struct /* Used to omit pushing failure point id's when we're not debugging. */ #ifdef DEBUG #define DEBUG_PUSH PUSH_FAILURE_INT -#define DEBUG_POP(item_addr) *(item_addr) = POP_FAILURE_INT () +#define DEBUG_POP(item_addr) (item_addr)->integer = POP_FAILURE_INT () #else #define DEBUG_PUSH(item) #define DEBUG_POP(item_addr) @@ -1144,7 +1186,10 @@ typedef struct char *destination; \ /* Must be int, so when we don't save any registers, the arithmetic \ of 0 + -1 isn't done as unsigned. */ \ - unsigned this_reg; \ + /* Can't be int, since there is not a shred of a guarantee that int \ + is wide enough to hold a value of something to which pointer can \ + be assigned */ \ + s_reg_t this_reg; \ \ DEBUG_STATEMENT (failure_id++); \ DEBUG_STATEMENT (nfailure_points_pushed++); \ @@ -1257,7 +1302,7 @@ typedef struct #define POP_FAILURE_POINT(str, pat, low_reg, high_reg, regstart, regend, reg_info)\ { \ DEBUG_STATEMENT (fail_stack_elt_t failure_id;) \ - unsigned this_reg; \ + s_reg_t this_reg; \ const unsigned char *string_temp; \ \ assert (!FAIL_STACK_EMPTY ()); \ @@ -1288,10 +1333,10 @@ typedef struct DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ \ /* Restore register info. */ \ - high_reg = (unsigned) POP_FAILURE_INT (); \ + high_reg = (active_reg_t) POP_FAILURE_INT (); \ DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \ \ - low_reg = (unsigned) POP_FAILURE_INT (); \ + low_reg = (active_reg_t) POP_FAILURE_INT (); \ DEBUG_PRINT2 (" Popping low active reg: %d\n", low_reg); \ \ if (1) \ @@ -1336,6 +1381,9 @@ typedef struct the type of `word', i.e., is something that fits into one item on the failure stack. */ + +/* Declarations and macros for re_match_2. */ + typedef union { fail_stack_elt_t word; @@ -1365,7 +1413,7 @@ typedef union { \ if (!set_regs_matched_done) \ { \ - unsigned r; \ + active_reg_t r; \ set_regs_matched_done = 1; \ for (r = lowest_active_reg; r <= highest_active_reg; r++) \ { \ @@ -1384,11 +1432,25 @@ static char reg_unset_dummy; /* Subroutine declarations and macros for regex_compile. */ -static void store_op1 (), store_op2 (); -static void insert_op1 (), insert_op2 (); -static boolean at_begline_loc_p (), at_endline_loc_p (); -static boolean group_in_compile_stack (); -static reg_errcode_t compile_range (); +static reg_errcode_t regex_compile _RE_ARGS ((const char *pattern, size_t size, + reg_syntax_t syntax, + struct re_pattern_buffer *bufp)); +static void store_op1 _RE_ARGS ((re_opcode_t op, unsigned char *loc, int arg)); +static void store_op2 _RE_ARGS ((re_opcode_t op, unsigned char *loc, + int arg1, int arg2)); +static void insert_op1 _RE_ARGS ((re_opcode_t op, unsigned char *loc, + int arg, unsigned char *end)); +static void insert_op2 _RE_ARGS ((re_opcode_t op, unsigned char *loc, + int arg1, int arg2, unsigned char *end)); +static boolean at_begline_loc_p _RE_ARGS ((const char *pattern, const char *p, + reg_syntax_t syntax)); +static boolean at_endline_loc_p _RE_ARGS ((const char *p, const char *pend, + reg_syntax_t syntax)); +static reg_errcode_t compile_range _RE_ARGS ((const char **p_ptr, + const char *pend, + char *translate, + reg_syntax_t syntax, + unsigned char *b)); /* Fetch the next character in the uncompiled pattern---translating it if necessary. Also cast from a signed character in the constant @@ -1463,26 +1525,39 @@ static reg_errcode_t compile_range (); /* Store a jump with opcode OP at LOC to location TO. We store a relative address offset by the three bytes the jump itself occupies. */ #define STORE_JUMP(op, loc, to) \ - store_op1 (op, loc, (to) - (loc) - 3) + store_op1 (op, loc, (int) ((to) - (loc) - 3)) /* Likewise, for a two-argument jump. */ #define STORE_JUMP2(op, loc, to, arg) \ - store_op2 (op, loc, (to) - (loc) - 3, arg) + store_op2 (op, loc, (int) ((to) - (loc) - 3), arg) /* Like `STORE_JUMP', but for inserting. Assume `b' is the buffer end. */ #define INSERT_JUMP(op, loc, to) \ - insert_op1 (op, loc, (to) - (loc) - 3, b) + insert_op1 (op, loc, (int) ((to) - (loc) - 3), b) /* Like `STORE_JUMP2', but for inserting. Assume `b' is the buffer end. */ #define INSERT_JUMP2(op, loc, to, arg) \ - insert_op2 (op, loc, (to) - (loc) - 3, arg, b) + insert_op2 (op, loc, (int) ((to) - (loc) - 3), arg, b) /* This is not an arbitrary limit: the arguments which represent offsets into the pattern are two bytes long. So if 2^16 bytes turns out to be too small, many things would have to change. */ +/* Any other compiler which, like MSC, has allocation limit below 2^16 + bytes will have to use approach similar to what was done below for + MSC and drop MAX_BUF_SIZE a bit. Otherwise you may end up + reallocating to 0 bytes. Such thing is not going to work too well. + You have been warned!! */ +#ifdef _MSC_VER +/* Microsoft C 16-bit versions limit malloc to approx 65512 bytes. + The REALLOC define eliminates a flurry of conversion warnings, + but is not required. */ +#define MAX_BUF_SIZE 65500L +#define REALLOC(p,s) realloc ((p), (size_t) (s)) +#else #define MAX_BUF_SIZE (1L << 16) - +#define REALLOC(p,s) realloc ((p), (s)) +#endif /* Extend the buffer by twice its current size via realloc and reset the pointers that pointed into the old block to point to the @@ -1496,7 +1571,7 @@ static reg_errcode_t compile_range (); bufp->allocated <<= 1; \ if (bufp->allocated > MAX_BUF_SIZE) \ bufp->allocated = MAX_BUF_SIZE; \ - bufp->buffer = (unsigned char *) realloc (bufp->buffer, bufp->allocated);\ + bufp->buffer = (unsigned char *) REALLOC (bufp->buffer, bufp->allocated);\ if (bufp->buffer == NULL) \ return REG_ESPACE; \ /* If the buffer moved, move all the pointers into it. */ \ @@ -1528,7 +1603,8 @@ typedef unsigned regnum_t; /* Since offsets can go either forwards or backwards, this type needs to be able to hold values from -(MAX_BUF_SIZE - 1) to MAX_BUF_SIZE - 1. */ -typedef int pattern_offset_t; +/* int may be not enough when sizeof(int) == 2. */ +typedef long pattern_offset_t; typedef struct { @@ -1638,6 +1714,10 @@ regex_grow_registers (num_regs) #endif /* not MATCH_MAY_ALLOCATE */ +static boolean group_in_compile_stack _RE_ARGS ((compile_stack_type + compile_stack, + regnum_t regnum)); + /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. Returns one of error codes defined in `regex.h', or zero for success. @@ -1663,7 +1743,7 @@ regex_grow_registers (num_regs) static reg_errcode_t regex_compile (pattern, size, syntax, bufp) const char *pattern; - int size; + size_t size; reg_syntax_t syntax; struct re_pattern_buffer *bufp; { @@ -2104,6 +2184,9 @@ regex_compile (pattern, size, syntax, bufp) || (is_upper && ISUPPER (ch)) || (is_xdigit && ISXDIGIT (ch))) SET_LIST_BIT (ch); + if ( translate && (is_upper || is_lower) + && (ISUPPER (ch) || ISLOWER (ch))) + SET_LIST_BIT (ch); } had_char_class = true; } @@ -2529,38 +2612,54 @@ regex_compile (pattern, size, syntax, bufp) case 'w': + if (re_syntax_options & RE_NO_GNU_OPS) + goto normal_char; laststart = b; BUF_PUSH (wordchar); break; case 'W': + if (re_syntax_options & RE_NO_GNU_OPS) + goto normal_char; laststart = b; BUF_PUSH (notwordchar); break; case '<': + if (re_syntax_options & RE_NO_GNU_OPS) + goto normal_char; BUF_PUSH (wordbeg); break; case '>': + if (re_syntax_options & RE_NO_GNU_OPS) + goto normal_char; BUF_PUSH (wordend); break; case 'b': + if (re_syntax_options & RE_NO_GNU_OPS) + goto normal_char; BUF_PUSH (wordbound); break; case 'B': + if (re_syntax_options & RE_NO_GNU_OPS) + goto normal_char; BUF_PUSH (notwordbound); break; case '`': + if (re_syntax_options & RE_NO_GNU_OPS) + goto normal_char; BUF_PUSH (begbuf); break; case '\'': + if (re_syntax_options & RE_NO_GNU_OPS) + goto normal_char; BUF_PUSH (endbuf); break; @@ -2575,7 +2674,7 @@ regex_compile (pattern, size, syntax, bufp) FREE_STACK_RETURN (REG_ESUBREG); /* Can't back reference to a subexpression if inside of it. */ - if (group_in_compile_stack (compile_stack, c1)) + if (group_in_compile_stack (compile_stack, (regnum_t) c1)) goto normal_char; laststart = b; @@ -2802,7 +2901,7 @@ at_begline_loc_p (pattern, p, syntax) static boolean at_endline_loc_p (p, pend, syntax) const char *p, *pend; - int syntax; + reg_syntax_t syntax; { const char *next = p; boolean next_backslash = *next == '\\'; @@ -2924,13 +3023,14 @@ re_compile_fastmap (bufp) register char *fastmap = bufp->fastmap; unsigned char *pattern = bufp->buffer; - unsigned long size = bufp->used; unsigned char *p = pattern; - register unsigned char *pend = pattern + size; + register unsigned char *pend = pattern + bufp->used; +#ifdef REL_ALLOC /* This holds the pointer to the failure stack, when it is allocated relocatably. */ fail_stack_elt_t *failure_stack_ptr; +#endif /* Assume that each path through the pattern can be null until proven otherwise. We set this false at the bottom of switch @@ -3406,13 +3506,6 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop) return -1; } /* re_search_2 */ -/* Declarations and macros for re_match_2. */ - -static int bcmp_translate (); -static boolean alt_match_null_string_p (), - common_op_match_null_string_p (), - group_match_null_string_p (); - /* This converts PTR, a pointer into one of the search strings `string1' and `string2' into an offset from the beginning of that string. */ #define POINTER_TO_OFFSET(ptr) \ @@ -3453,14 +3546,12 @@ static boolean alt_match_null_string_p (), : (d) == string2 - 1 ? *(end1 - 1) : *(d)) \ == Sword) -/* Disabled due to a compiler bug -- see comment at case wordbound */ -#if 0 /* Test if the character before D and the one at D differ with respect to being word-constituent. */ #define AT_WORD_BOUNDARY(d) \ (AT_STRINGS_BEG (d) || AT_STRINGS_END (d) \ || WORDCHAR_P (d - 1) != WORDCHAR_P (d)) -#endif + /* Free everything we malloc. */ #ifdef MATCH_MAY_ALLOCATE @@ -3506,11 +3597,26 @@ re_match (bufp, string, size, pos, regs) { int result = re_match_2_internal (bufp, NULL, 0, string, size, pos, regs, size); +#ifndef REGEX_MALLOC +#ifdef C_ALLOCA alloca (0); +#endif +#endif return result; } #endif /* not emacs */ +static boolean group_match_null_string_p _RE_ARGS ((unsigned char **p, + unsigned char *end, + register_info_type *reg_info)); +static boolean alt_match_null_string_p _RE_ARGS ((unsigned char *p, + unsigned char *end, + register_info_type *reg_info)); +static boolean common_op_match_null_string_p _RE_ARGS ((unsigned char **p, + unsigned char *end, + register_info_type *reg_info)); +static int bcmp_translate _RE_ARGS ((const char *s1, const char *s2, + int len, char *translate)); /* re_match_2 matches the compiled pattern in BUFP against the the (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 @@ -3536,7 +3642,11 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) { int result = re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop); +#ifndef REGEX_MALLOC +#ifdef C_ALLOCA alloca (0); +#endif +#endif return result; } @@ -3593,18 +3703,20 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) unsigned nfailure_points_pushed = 0, nfailure_points_popped = 0; #endif +#ifdef REL_ALLOC /* This holds the pointer to the failure stack, when it is allocated relocatably. */ fail_stack_elt_t *failure_stack_ptr; +#endif /* We fill all the registers internally, independent of what we return, for use in backreferences. The number here includes an element for register zero. */ - unsigned num_regs = bufp->re_nsub + 1; + size_t num_regs = bufp->re_nsub + 1; /* The currently active registers. */ - unsigned lowest_active_reg = NO_LOWEST_ACTIVE_REG; - unsigned highest_active_reg = NO_HIGHEST_ACTIVE_REG; + active_reg_t lowest_active_reg = NO_LOWEST_ACTIVE_REG; + active_reg_t highest_active_reg = NO_HIGHEST_ACTIVE_REG; /* Information on the contents of registers. These are pointers into the input strings; they record just what was matched (on this @@ -4511,10 +4623,17 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) = *p2 == (unsigned char) endline ? '\n' : p2[2]; #endif +#if 0 if ((re_opcode_t) p1[3] == exactn && ! ((int) p2[1] * BYTEWIDTH > (int) p1[5] && (p2[2 + p1[5] / BYTEWIDTH] & (1 << (p1[5] % BYTEWIDTH))))) +#else + if ((re_opcode_t) p1[3] == exactn + && ! ((int) p2[1] * BYTEWIDTH > (int) p1[4] + && (p2[2 + p1[4] / BYTEWIDTH] + & (1 << (p1[4] % BYTEWIDTH))))) +#endif { p[-3] = (unsigned char) pop_failure_jump; DEBUG_PRINT3 (" %c != %c => pop_failure_jump.\n", @@ -4580,7 +4699,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) actual values. Otherwise, we will restore only one register from the stack, since lowest will == highest in `pop_failure_point'. */ - unsigned dummy_low_reg, dummy_high_reg; + active_reg_t dummy_low_reg, dummy_high_reg; unsigned char *pdummy; const char *sdummy; @@ -5133,11 +5252,12 @@ common_op_match_null_string_p (p, end, reg_info) static int bcmp_translate (s1, s2, len, translate) - unsigned char *s1, *s2; + const char *s1, *s2; register int len; RE_TRANSLATE_TYPE translate; { - register unsigned char *p1 = s1, *p2 = s2; + register const unsigned char *p1 = (const unsigned char *) s1; + register const unsigned char *p2 = (const unsigned char *) s2; while (len) { if (translate[*p1++] != translate[*p2++]) return 1; @@ -5160,7 +5280,7 @@ bcmp_translate (s1, s2, len, translate) const char * re_compile_pattern (pattern, length, bufp) const char *pattern; - int length; + size_t length; struct re_pattern_buffer *bufp; { reg_errcode_t ret; @@ -5289,7 +5409,7 @@ regcomp (preg, pattern, cflags) int cflags; { reg_errcode_t ret; - unsigned syntax + reg_syntax_t syntax = (cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC; diff --git a/posix/regex.h b/posix/regex.h index 80f9c6d64a..ae0165e89c 100644 --- a/posix/regex.h +++ b/posix/regex.h @@ -37,16 +37,23 @@ extern "C" { #include <stddef.h> #endif +/* The following two types have to be signed and unsigned integer type + wide enough to hold a value of a pointer. For most ANSI compilers + ptrdiff_t and size_t should be likely OK. Still size of these two + types is 2 for Microsoft C. Ugh... */ +typedef long int s_reg_t; +typedef unsigned long int active_reg_t; + /* The following bits are used to determine the regexp syntax we recognize. The set/not-set meanings are chosen so that Emacs syntax remains the value 0. The bits are given in alphabetical order, and the definitions shifted by one from the previous bit; thus, when we add or remove a bit, only one other definition need change. */ -typedef unsigned reg_syntax_t; +typedef unsigned long int reg_syntax_t; /* If this bit is not set, then \ inside a bracket expression is literal. If set, then such a \ quotes the following character. */ -#define RE_BACKSLASH_ESCAPE_IN_LISTS (1) +#define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1) /* If this bit is not set, then + and ? are operators, and \+ and \? are literals. @@ -141,6 +148,10 @@ typedef unsigned reg_syntax_t; without further backtracking. */ #define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1) +/* If this bit is set, do not process the GNU regex operators. + If not set, then the GNU regex operators are recognized. */ +#define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1) + /* This global variable defines the particular regexp syntax to use (for some interfaces). When a regexp is compiled, the syntax used is stored in the pattern buffer, so changing this does not affect @@ -154,13 +165,18 @@ extern reg_syntax_t re_syntax_options; #define RE_SYNTAX_EMACS 0 #define RE_SYNTAX_AWK \ - (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ - | RE_UNMATCHED_RIGHT_PAREN_ORD) + (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ + | RE_NO_BK_PARENS | RE_NO_BK_REFS \ + | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ + | RE_DOT_NEWLINE \ + | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS) + +#define RE_SYNTAX_GNU_AWK \ + ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS) \ + & ~(RE_DOT_NOT_NULL | RE_INTERVALS)) #define RE_SYNTAX_POSIX_AWK \ - (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS) + (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_NO_GNU_OPS) #define RE_SYNTAX_GREP \ (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ @@ -216,7 +232,8 @@ extern reg_syntax_t re_syntax_options; #ifdef RE_DUP_MAX #undef RE_DUP_MAX #endif -#define RE_DUP_MAX ((1 << 15) - 1) +/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */ +#define RE_DUP_MAX (0x7fff) /* POSIX `cflags' bits (i.e., information for `regcomp'). */ @@ -417,7 +434,7 @@ extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax)); and syntax given by the global `re_syntax_options', into the buffer BUFFER. Return NULL if successful, and an error string if not. */ extern const char *re_compile_pattern - _RE_ARGS ((const char *pattern, int length, + _RE_ARGS ((const char *pattern, size_t length, struct re_pattern_buffer *buffer)); @@ -476,10 +493,12 @@ extern void re_set_registers unsigned num_regs, regoff_t *starts, regoff_t *ends)); #ifdef _REGEX_RE_COMP +#ifndef _CRAY /* 4.2 bsd compatibility. */ extern char *re_comp _RE_ARGS ((const char *)); extern int re_exec _RE_ARGS ((const char *)); #endif +#endif /* POSIX compatibility. */ extern int regcomp _RE_ARGS ((regex_t *preg, const char *pattern, int cflags)); diff --git a/posix/runtests.c b/posix/runtests.c new file mode 100644 index 0000000000..b6a292e6f5 --- /dev/null +++ b/posix/runtests.c @@ -0,0 +1,132 @@ +/*********************************************************** + +Copyright 1995 by Tom Lord + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of the copyright holder not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +Tom Lord DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +EVENT SHALL TOM LORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + +******************************************************************/ + + + +#include <sys/types.h> +#include <regex.h> +#include <stdio.h> +#include <stdlib.h> + + + +struct a_test +{ + int expected; + const char * pattern; + const unsigned char * data; +}; + +static const struct a_test the_tests[] = +{ +#include "testcases.h" + {-1, 0, 0} +}; + + + + +int +run_a_test (int id, const struct a_test * t) +{ + static const char * last_pattern = 0; + static regex_t r; + int err; + char errmsg[100]; + int x; + regmatch_t regs[10]; + + if (!last_pattern || strcmp (last_pattern, t->pattern)) + { + if (last_pattern) + regfree (&r); + last_pattern = t->pattern; + err = regcomp (&r, t->pattern, REG_EXTENDED); + if (err) + { + if (t->expected) + { + puts (" OK."); + return 0; + } + regerror (err, &r, errmsg, 100); + printf ("test %d\n", id); + puts (errmsg); + return 1; + } + } + + err = regexec (&r, t->data, 10, regs, 0); + + if (err != t->expected) + { + printf ("test %d\n", id); + printf ("pattern \"%s\" data \"%s\" wanted %d got %d\n", + t->pattern, t->data, t->expected, err); + for (x = 0; x < 10; ++x) + printf ("reg %d == (%d, %d) %.*s\n", + x, + regs[x].rm_so, + regs[x].rm_eo, + regs[x].rm_eo - regs[x].rm_so, + t->data + regs[x].rm_so); + return 1; + } + puts (" OK."); + return 0; +} + + + +int +main (int argc, char * argv[]) +{ + int x; + int lo; + int hi; + int res = 0; + + lo = 0; + hi = (sizeof (the_tests) / sizeof (the_tests[0])) - 1; + + if (argc > 1) + { + lo = atoi (argv[1]); + hi = lo + 1; + + if (argc > 2) + hi = atoi (argv[2]); + } + + for (x = lo; x < hi; ++x) + { + printf ("#%d:", x); + res |= run_a_test (x, &the_tests[x]); + } + { + exit (0); + } +} + + diff --git a/posix/testcases.h b/posix/testcases.h new file mode 100644 index 0000000000..c471ca0613 --- /dev/null +++ b/posix/testcases.h @@ -0,0 +1,159 @@ + {0, "(.*)*\\1", "xx"}, + {0, "^", ""}, + {0, "$", ""}, + {0, "^$", ""}, + {0, "^a$", "a"}, + {0, "abc", "abc"}, + {1, "abc", "xbc"}, + {1, "abc", "axc"}, + {1, "abc", "abx"}, + {0, "abc", "xabcy"}, + {0, "abc", "ababc"}, + {0, "ab*c", "abc"}, + {0, "ab*bc", "abc"}, + {0, "ab*bc", "abbc"}, + {0, "ab*bc", "abbbbc"}, + {0, "ab+bc", "abbc"}, + {1, "ab+bc", "abc"}, + {1, "ab+bc", "abq"}, + {0, "ab+bc", "abbbbc"}, + {0, "ab?bc", "abbc"}, + {0, "ab?bc", "abc"}, + {1, "ab?bc", "abbbbc"}, + {0, "ab?c", "abc"}, + {0, "^abc$", "abc"}, + {1, "^abc$", "abcc"}, + {0, "^abc", "abcc"}, + {1, "^abc$", "aabc"}, + {0, "abc$", "aabc"}, + {0, "^", "abc"}, + {0, "$", "abc"}, + {0, "a.c", "abc"}, + {0, "a.c", "axc"}, + {0, "a.*c", "axyzc"}, + {1, "a.*c", "axyzd"}, + {1, "a[bc]d", "abc"}, + {0, "a[bc]d", "abd"}, + {1, "a[b-d]e", "abd"}, + {0, "a[b-d]e", "ace"}, + {0, "a[b-d]", "aac"}, + {0, "a[-b]", "a-"}, + {0, "a[b-]", "a-"}, + {1, "a[b-a]", "-"}, + {2, "a[]b", "-"}, + {2, "a[", "-"}, + {0, "a]", "a]"}, + {0, "a[]]b", "a]b"}, + {0, "a[^bc]d", "aed"}, + {1, "a[^bc]d", "abd"}, + {0, "a[^-b]c", "adc"}, + {1, "a[^-b]c", "a-c"}, + {1, "a[^]b]c", "a]c"}, + {0, "a[^]b]c", "adc"}, + {0, "ab|cd", "abc"}, + {0, "ab|cd", "abcd"}, + {0, "()ef", "def"}, + {0, "()*", "-"}, + {1, "*a", "-"}, + {0, "^*", "-"}, + {0, "$*", "-"}, + {1, "(*)b", "-"}, + {1, "$b", "b"}, + {2, "a\\", "-"}, + {0, "a\\(b", "a(b"}, + {0, "a\\(*b", "ab"}, + {0, "a\\(*b", "a((b"}, + {1, "a\\x", "a\\x"}, + {1, "abc)", "-"}, + {2, "(abc", "-"}, + {0, "((a))", "abc"}, + {0, "(a)b(c)", "abc"}, + {0, "a+b+c", "aabbabc"}, + {0, "a**", "-"}, + {0, "a*?", "-"}, + {0, "(a*)*", "-"}, + {0, "(a*)+", "-"}, + {0, "(a|)*", "-"}, + {0, "(a*|b)*", "-"}, + {0, "(a+|b)*", "ab"}, + {0, "(a+|b)+", "ab"}, + {0, "(a+|b)?", "ab"}, + {0, "[^ab]*", "cde"}, + {0, "(^)*", "-"}, + {0, "(ab|)*", "-"}, + {2, ")(", "-"}, + {1, "abc", ""}, + {1, "abc", ""}, + {0, "a*", ""}, + {0, "([abc])*d", "abbbcd"}, + {0, "([abc])*bcd", "abcd"}, + {0, "a|b|c|d|e", "e"}, + {0, "(a|b|c|d|e)f", "ef"}, + {0, "((a*|b))*", "-"}, + {0, "abcd*efg", "abcdefg"}, + {0, "ab*", "xabyabbbz"}, + {0, "ab*", "xayabbbz"}, + {0, "(ab|cd)e", "abcde"}, + {0, "[abhgefdc]ij", "hij"}, + {1, "^(ab|cd)e", "abcde"}, + {0, "(abc|)ef", "abcdef"}, + {0, "(a|b)c*d", "abcd"}, + {0, "(ab|ab*)bc", "abc"}, + {0, "a([bc]*)c*", "abc"}, + {0, "a([bc]*)(c*d)", "abcd"}, + {0, "a([bc]+)(c*d)", "abcd"}, + {0, "a([bc]*)(c+d)", "abcd"}, + {0, "a[bcd]*dcdcde", "adcdcde"}, + {1, "a[bcd]+dcdcde", "adcdcde"}, + {0, "(ab|a)b*c", "abc"}, + {0, "((a)(b)c)(d)", "abcd"}, + {0, "[A-Za-z_][A-Za-z0-9_]*", "alpha"}, + {0, "^a(bc+|b[eh])g|.h$", "abh"}, + {0, "(bc+d$|ef*g.|h?i(j|k))", "effgz"}, + {0, "(bc+d$|ef*g.|h?i(j|k))", "ij"}, + {1, "(bc+d$|ef*g.|h?i(j|k))", "effg"}, + {1, "(bc+d$|ef*g.|h?i(j|k))", "bcdd"}, + {0, "(bc+d$|ef*g.|h?i(j|k))", "reffgz"}, + {1, "((((((((((a))))))))))", "-"}, + {0, "(((((((((a)))))))))", "a"}, + {1, "multiple words of text", "uh-uh"}, + {0, "multiple words", "multiple words, yeah"}, + {0, "(.*)c(.*)", "abcde"}, + {1, "\\((.*),", "(.*)\\)"}, + {1, "[k]", "ab"}, + {0, "abcd", "abcd"}, + {0, "a(bc)d", "abcd"}, + {0, "a[-]?c", "ac"}, + {0, "(....).*\\1", "beriberi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar Qaddafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Mo'ammar Gadhafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar Kaddafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar Qadhafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Moammar El Kadhafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar Gadafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Mu'ammar al-Qadafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Moamer El Kazzafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Moamar al-Gaddafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Mu'ammar Al Qathafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar Al Qathafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Mo'ammar el-Gadhafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Moamar El Kadhafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar al-Qadhafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Mu'ammar al-Qadhdhafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Mu'ammar Qadafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Moamar Gaddafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Mu'ammar Qadhdhafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar Khaddafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar al-Khaddafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Mu'amar al-Kadafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar Ghaddafy"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar Ghadafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar Ghaddafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muamar Kaddafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar Quathafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muammar Gheddafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Muamar Al-Kaddafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Moammar Khadafy "}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Moammar Qudhafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Mu'ammar al-Qaddafi"}, + {0, "M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy]", "Mulazim Awwal Mu'ammar Muhammad Abu Minyar al-Qadhafi"}, diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c index 106c62b8e0..4780f51021 100644 --- a/stdio-common/vfscanf.c +++ b/stdio-common/vfscanf.c @@ -163,8 +163,7 @@ int __vfscanf (FILE *s, const char *format, va_list argptr) #endif { - va_list arg = (va_list) argptr; - + va_list arg; register const char *f = format; register unsigned char fc; /* Current character of the format. */ register size_t done = 0; /* Assignments done. */ @@ -224,6 +223,12 @@ __vfscanf (FILE *s, const char *format, va_list argptr) } \ while (0) +#ifdef __va_copy + __va_copy (arg, argptr); +#else + arg = (va_list) argptr; +#endif + ARGCHECK (s, format); /* Figure out the decimal point character. */ @@ -245,23 +250,34 @@ __vfscanf (FILE *s, const char *format, va_list argptr) /* Extract the next argument, which is of type TYPE. For a %N$... spec, this is the Nth argument from the beginning; otherwise it is the next argument after the state now in ARG. */ -#if 0 - /* XXX Possible optimization. */ +#ifdef __va_copy # define ARG(type) (argpos == 0 ? va_arg (arg, type) : \ + ({ unsigned int pos = argpos; \ + va_list arg; \ + __va_copy (arg, argptr); \ + while (--pos > 0) \ + (void) va_arg (arg, void *); \ + va_arg (arg, type); \ + })) +#else +# if 0 + /* XXX Possible optimization. */ +# define ARG(type) (argpos == 0 ? va_arg (arg, type) : \ ({ va_list arg = (va_list) argptr; \ arg = (va_list) ((char *) arg \ + (argpos - 1) \ * __va_rounded_size (void *)); \ va_arg (arg, type); \ })) -#else -# define ARG(type) (argpos == 0 ? va_arg (arg, type) : \ +# else +# define ARG(type) (argpos == 0 ? va_arg (arg, type) : \ ({ unsigned int pos = argpos; \ va_list arg = (va_list) argptr; \ while (--pos > 0) \ (void) va_arg (arg, void *); \ va_arg (arg, type); \ })) +# endif #endif if (!isascii (*f)) diff --git a/stdlib/testdiv.c b/stdlib/testdiv.c index e927ad431a..a3ae5c98d0 100644 --- a/stdlib/testdiv.c +++ b/stdlib/testdiv.c @@ -20,7 +20,7 @@ #include <stdio.h> int -main () +main (void) { int i, j; while (scanf ("%d %d\n", &i, &j) == 2) diff --git a/sunrpc/Makefile b/sunrpc/Makefile index 2cc64cc10b..1981c75941 100644 --- a/sunrpc/Makefile +++ b/sunrpc/Makefile @@ -155,6 +155,7 @@ $(objpfx)rpc-proto.d: $(objpfx)%.d: $(objpfx)%.c # Special file to generate dependencies for the RPC service objects. # Collect all include directives from the source files. $(objpfx)rpc-proto.c: $(rpcsvc:%=rpcsvc/%) + $(make-target-directory) { echo '#include <rpc/types.h>'; \ echo '#include <rpc/xdr.h>'; \ echo '#include <rpc/rpc.h>'; \ diff --git a/sysdeps/generic/dl-cache.c b/sysdeps/generic/dl-cache.c index 7b471787f4..c704fd869d 100644 --- a/sysdeps/generic/dl-cache.c +++ b/sysdeps/generic/dl-cache.c @@ -77,7 +77,8 @@ _dl_load_cache_lookup (const char *name) } for (i = 0; i < cache->nlibs; ++i) - if (cache->libs[i].flags == 1 && /* ELF library entry. */ + if ((cache->libs[i].flags == 1 || + cache->libs[i].flags == 3) && /* ELF library entry. */ /* Make sure string table indices are not bogus before using them. */ cache->libs[i].key < cachesize - sizeof *cache && cache->libs[i].value < cachesize - sizeof *cache && diff --git a/sysdeps/generic/netinet/in.h b/sysdeps/generic/netinet/in.h index 5531fc2ece..a59f584085 100644 --- a/sysdeps/generic/netinet/in.h +++ b/sysdeps/generic/netinet/in.h @@ -128,13 +128,13 @@ struct in_addr /* Address to send to all hosts. */ #define INADDR_BROADCAST ((unsigned) 0xffffffff) /* Address indicating an error return. */ -#define INADDR_NONE 0xffffffff +#define INADDR_NONE ((unsigned) 0xffffffff) /* Network number for local host loopback. */ #define IN_LOOPBACKNET 127 /* Address to loopback in software to local host. */ #ifndef INADDR_LOOPBACK -#define INADDR_LOOPBACK 0x7f000001 /* Internet address 127.0.0.1. */ +#define INADDR_LOOPBACK ((unsigned) 0x7f000001) /* Inet address 127.0.0.1. */ #endif diff --git a/sysdeps/libm-ieee754/w_cabs.c b/sysdeps/libm-ieee754/w_cabs.c deleted file mode 100644 index bf62f22be3..0000000000 --- a/sysdeps/libm-ieee754/w_cabs.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * cabs() wrapper for hypot(). - * - * Written by J.T. Conklin, <jtc@wimsey.com> - * Placed into the Public Domain, 1994. - */ - -#include <math.h> - -double -__cabs(z) - struct __cabs_complex z; -{ - return __hypot(z.x, z.y); -} -weak_alias (__cabs, cabs) - -#ifdef NO_LONG_DOUBLE -double -__cabsl(z) - struct __cabs_complexl z; -{ - return __hypotl(z.x, z.y); -} -weak_alias (__cabsl, cabsl) -#endif diff --git a/sysdeps/libm-ieee754/w_cabsf.c b/sysdeps/libm-ieee754/w_cabsf.c deleted file mode 100644 index 20ff5b7744..0000000000 --- a/sysdeps/libm-ieee754/w_cabsf.c +++ /dev/null @@ -1,17 +0,0 @@ -/* - * cabsf() wrapper for hypotf(). - * - * Written by J.T. Conklin, <jtc@wimsey.com> - * Placed into the Public Domain, 1994. - */ - -#include "math.h" -#include "math_private.h" - -float -__cabsf(z) - struct __cabs_complexf z; -{ - return __hypotf(z.x, z.y); -} -weak_alias (__cabsf, cabsf) diff --git a/sysdeps/libm-ieee754/w_cabsl.c b/sysdeps/libm-ieee754/w_cabsl.c deleted file mode 100644 index 21ef860a95..0000000000 --- a/sysdeps/libm-ieee754/w_cabsl.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * cabsl() wrapper for hypotl(). - * - * Written by J.T. Conklin, <jtc@wimsey.com> - * Conversion to long double by Ulrich Drepper, - * Cygnus Support, drepper@cygnus.com. - * Placed into the Public Domain, 1994. - */ - -#include <math.h> - -long double -__cabsl(z) - struct __cabs_complexl z; -{ - return __hypotl(z.x, z.y); -} -weak_alias (__cabsl, cabsl) diff --git a/sysdeps/m68k/fpu/__math.h b/sysdeps/m68k/fpu/__math.h index 1a29a56d92..fe01c254d7 100644 --- a/sysdeps/m68k/fpu/__math.h +++ b/sysdeps/m68k/fpu/__math.h @@ -43,7 +43,7 @@ suffixed with f and l for the float and long double version, resp). OP is the name of the fpu operation (without leading f). */ -#ifdef __USE_MISC +#if defined __USE_MISC || defined __USE_ISOC9X #define __inline_mathop(func, op) \ __inline_mathop1(double, func, op) \ __inline_mathop1(float, __CONCAT(func,f), op) \ @@ -81,7 +81,6 @@ __inline_mathop(__sin, sin) __inline_mathop(__tan, tan) __inline_mathop(__tanh, tanh) __inline_mathop(__fabs, abs) -__inline_mathop(__sqrt, sqrt) __inline_mathop(__rint, int) __inline_mathop(__expm1, etoxm1) @@ -89,6 +88,9 @@ __inline_mathop(__log1p, lognp1) __inline_mathop(__logb, log2) __inline_mathop(__significand, getman) +__inline_mathop(__log2, log2) +__inline_mathop(__exp2, twotox) + #if !defined __NO_MATH_INLINES && defined __OPTIMIZE__ __inline_mathop(atan, atan) @@ -96,10 +98,8 @@ __inline_mathop(cos, cos) __inline_mathop(sin, sin) __inline_mathop(tan, tan) __inline_mathop(tanh, tanh) -__inline_mathop(fabs, abs) -__inline_mathop(sqrt, sqrt) -#if defined(__USE_MISC) || defined(__USE_XOPEN_EXTENDED) +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC9X __inline_mathop(rint, int) __inline_mathop(expm1, etoxm1) __inline_mathop(log1p, lognp1) @@ -110,6 +110,11 @@ __inline_mathop(logb, log2) __inline_mathop(significand, getman) #endif +#ifdef __USE_ISOC9X +__inline_mathop(log2, log2) +__inline_mathop(exp2, twotox) +#endif + #endif /* !__NO_MATH_INLINES && __OPTIMIZE__ */ /* This macro contains the definition for the rest of the inline @@ -375,11 +380,13 @@ __inline_forward_c(int,finite, (double __value), (__value)) __inline_forward_c(double,scalbn, (double __x, int __n), (__x, __n)) #endif #if defined __USE_MISC || defined __USE_XOPEN +#ifndef __USE_ISOC9X /* Conflict with macro of same name. */ __inline_forward_c(int,isnan, (double __value), (__value)) +#endif __inline_forward_c(int,ilogb, (double __value), (__value)) #endif -#ifdef __USE_MISC +#if defined __USE_MISC || defined __USE_ISOC9X __inline_forward(float,frexpf, (float __value, int *__expptr), (__value, __expptr)) @@ -387,11 +394,13 @@ __inline_forward_c(float,floorf, (float __x), (__x)) __inline_forward_c(float,ceilf, (float __x), (__x)) __inline_forward(float,modff, (float __value, float *__iptr), (__value, __iptr)) +#ifdef __USE_MISC __inline_forward_c(int,isinff, (float __value), (__value)) __inline_forward_c(int,finitef, (float __value), (__value)) __inline_forward_c(float,scalbnf, (float __x, int __n), (__x, __n)) __inline_forward_c(int,isnanf, (float __value), (__value)) __inline_forward_c(int,ilogbf, (float __value), (__value)) +#endif __inline_forward(long double,frexpl, (long double __value, int *__expptr), (__value, __expptr)) @@ -400,14 +409,16 @@ __inline_forward_c(long double,ceill, (long double __x), (__x)) __inline_forward(long double,modfl, (long double __value, long double *__iptr), (__value, __iptr)) +#ifdef __USE_MISC __inline_forward_c(int,isinfl, (long double __value), (__value)) __inline_forward_c(int,finitel, (long double __value), (__value)) __inline_forward_c(long double,scalbnl, (long double __x, int __n), (__x, __n)) __inline_forward_c(int,isnanl, (long double __value), (__value)) __inline_forward_c(int,ilogbl, (long double __value), (__value)) +#endif -#endif /* __USE_MISC */ +#endif /* Use misc or ISO C9X */ #undef __inline_forward #undef __inline_forward_c diff --git a/sysdeps/powerpc/Implies b/sysdeps/powerpc/Implies new file mode 100644 index 0000000000..d6acf04a82 --- /dev/null +++ b/sysdeps/powerpc/Implies @@ -0,0 +1,2 @@ +wordsize-32 +ieee754 diff --git a/sysdeps/powerpc/__longjmp.S b/sysdeps/powerpc/__longjmp.S new file mode 100644 index 0000000000..928b5c540a --- /dev/null +++ b/sysdeps/powerpc/__longjmp.S @@ -0,0 +1,66 @@ +/* longjmp for PowerPC. + 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. */ + +#include <sysdep.h> +#define _ASM +#include <jmp_buf.h> + +ENTRY (__longjmp) + lwz 1,(JB_GPR1*4)(3) + lwz 2,(JB_GPR2*4)(3) + lwz 0,(JB_LR*4)(3) + lwz 14,((JB_GPRS+0)*4)(3) + lfd 14,((JB_FPRS+0*2)*4)(3) + lwz 15,((JB_GPRS+1)*4)(3) + lfd 15,((JB_FPRS+1*2)*4)(3) + lwz 16,((JB_GPRS+2)*4)(3) + lfd 16,((JB_FPRS+2*2)*4)(3) + lwz 17,((JB_GPRS+3)*4)(3) + lfd 17,((JB_FPRS+3*2)*4)(3) + lwz 18,((JB_GPRS+4)*4)(3) + lfd 18,((JB_FPRS+4*2)*4)(3) + lwz 19,((JB_GPRS+5)*4)(3) + lfd 19,((JB_FPRS+5*2)*4)(3) + lwz 20,((JB_GPRS+6)*4)(3) + lfd 20,((JB_FPRS+6*2)*4)(3) + mtlr 0 + lwz 21,((JB_GPRS+7)*4)(3) + lfd 21,((JB_FPRS+7*2)*4)(3) + lwz 22,((JB_GPRS+8)*4)(3) + lfd 22,((JB_FPRS+8*2)*4)(3) + lwz 23,((JB_GPRS+9)*4)(3) + lfd 23,((JB_FPRS+9*2)*4)(3) + lwz 24,((JB_GPRS+10)*4)(3) + lfd 24,((JB_FPRS+10*2)*4)(3) + lwz 25,((JB_GPRS+11)*4)(3) + lfd 25,((JB_FPRS+11*2)*4)(3) + lwz 26,((JB_GPRS+12)*4)(3) + lfd 26,((JB_FPRS+12*2)*4)(3) + lwz 27,((JB_GPRS+13)*4)(3) + lfd 27,((JB_FPRS+13*2)*4)(3) + lwz 28,((JB_GPRS+14)*4)(3) + lfd 28,((JB_FPRS+14*2)*4)(3) + lwz 29,((JB_GPRS+15)*4)(3) + lfd 29,((JB_FPRS+15*2)*4)(3) + lwz 30,((JB_GPRS+16)*4)(3) + lfd 30,((JB_FPRS+16*2)*4)(3) + lwz 31,((JB_GPRS+17)*4)(3) + lfd 31,((JB_FPRS+17*2)*4)(3) + blr +END (__longjmp) diff --git a/sysdeps/powerpc/__math.h b/sysdeps/powerpc/__math.h new file mode 100644 index 0000000000..9dc19a91a5 --- /dev/null +++ b/sysdeps/powerpc/__math.h @@ -0,0 +1,89 @@ +/* Inline math functions for powerpc. + 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 __MATH_H +#define __MATH_H + +#ifdef __GNUC__ +#ifndef __NO_MATH_INLINES + +#ifdef __cplusplus +#define __MATH_INLINE __inline +#else +#define __MATH_INLINE extern __inline +#endif + +__MATH_INLINE double __sgn1 (double __x); +__MATH_INLINE double +__sgn1 (double __x) +{ + return __x >= 0.0 ? 1.0 : -1.0; +} + +/* We'd want to use this if it was implemented in hardware, but + how can we tell? */ +#if 0 +__MATH_INLINE double sqrt (double __x); +__MATH_INLINE double +sqrt (double __x) +{ + register double __value; + __asm + ("fsqrt %0,%1" + : "=f" (__value) : "f" (__x)); + + return __value; +} +#endif + +__MATH_INLINE double fabs (double __x); +__MATH_INLINE double +fabs (double __x) +{ + register double __value; + __asm + ("fabs %0,%1" + : "=f" (__value) : "f" (__x)); + + return __value; +} + +/* Optimized versions for some non-standardized functions. */ +#ifdef __USE_MISC + +__MATH_INLINE double hypot (double __x, double __y); +__MATH_INLINE double +hypot (double __x, double __y) +{ + return sqrt (__x * __x + __y * __y); +} + +__MATH_INLINE double __sgn (double __x); +__MATH_INLINE double +sgn (double __x) +{ + return (__x == 0.0 ? 0.0 : (__x > 0.0 ? 1.0 : -1.0)); +} + +#endif /* __USE_MISC */ + +#endif /* __NO_MATH_INLINES */ +#endif /* __GNUC__ */ + +#endif /* __MATH_H */ diff --git a/sysdeps/powerpc/bsd-_setjmp.S b/sysdeps/powerpc/bsd-_setjmp.S new file mode 100644 index 0000000000..90171ea616 --- /dev/null +++ b/sysdeps/powerpc/bsd-_setjmp.S @@ -0,0 +1,29 @@ +/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. PowerPC version. + Copyright (C) 1994, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is 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 just does a tail-call to `__sigsetjmp (ARG, 0)'. + We cannot do it in C because it must be a tail-call, so frame-unwinding + in setjmp doesn't clobber the state restored by longjmp. */ + +#include <sysdep.h> + +ENTRY (_setjmp) + li 4,0 /* Set second argument to 0. */ + b C_SYMBOL_NAME(__sigsetjmp) +END (_setjmp) diff --git a/sysdeps/powerpc/dl-machine.h b/sysdeps/powerpc/dl-machine.h new file mode 100644 index 0000000000..a60a29723d --- /dev/null +++ b/sysdeps/powerpc/dl-machine.h @@ -0,0 +1,529 @@ +/* Machine-dependent ELF dynamic relocation inline functions. PowerPC version. + 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. */ + +#define ELF_MACHINE_NAME "powerpc" + +#include <assert.h> +#include <string.h> +#include <link.h> + +/* stuff for the PLT */ +#define PLT_INITIAL_ENTRY_WORDS 18 +#define PLT_LONGBRANCH_ENTRY_WORDS 10 +#define OPCODE_ADDI(rd,ra,simm) \ + (0x38000000 | (rd) << 21 | (ra) << 16 | (simm) & 0xffff) +#define OPCODE_ADDIS(rd,ra,simm) \ + (0x3c000000 | (rd) << 21 | (ra) << 16 | (simm) & 0xffff) +#define OPCODE_ADD(rd,ra,rb) \ + (0x7c000214 | (rd) << 21 | (ra) << 16 | (rb) << 11) +#define OPCODE_B(target) (0x48000000 | (target) & 0x03fffffc) +#define OPCODE_BA(target) (0x48000002 | (target) & 0x03fffffc) +#define OPCODE_BCTR() 0x4e800420 +#define OPCODE_LWZ(rd,d,ra) \ + (0x80000000 | (rd) << 21 | (ra) << 16 | (d) & 0xffff) +#define OPCODE_MTCTR(rd) (0x7C0903A6 | (rd) << 21) +#define OPCODE_RLWINM(ra,rs,sh,mb,me) \ + (0x54000000 | (rs) << 21 | (ra) << 16 | (sh) << 11 | (mb) << 6 | (me) << 1) + +#define OPCODE_LI(rd,simm) OPCODE_ADDI(rd,0,simm) +#define OPCODE_SLWI(ra,rs,sh) OPCODE_RLWINM(ra,rs,sh,0,31-sh) + + +/* Return nonzero iff E_MACHINE is compatible with the running host. */ +static inline int +elf_machine_matches_host (Elf32_Half e_machine) +{ + return e_machine == EM_PPC; +} + + +/* Return the link-time address of _DYNAMIC, the first value in the GOT. */ +static inline Elf32_Addr +elf_machine_dynamic (void) +{ + Elf32_Addr *got; + asm (" bl _GLOBAL_OFFSET_TABLE_-4@local" + : "=l"(got)); + return *got; +} + +/* Return the run-time load address of the shared object. */ +static inline Elf32_Addr +elf_machine_load_address (void) +{ + unsigned *got; + unsigned *branchaddr; + + /* This is much harder than you'd expect. Possibly I'm missing something. + The 'obvious' way: + + Apparently, "bcl 20,31,$+4" is what should be used to load LR + with the address of the next instruction. + I think this is so that machines that do bl/blr pairing don't + get confused. + + asm ("bcl 20,31,0f ;" + "0: mflr 0 ;" + "lis %0,0b@ha;" + "addi %0,%0,0b@l;" + "subf %0,%0,0" + : "=b" (addr) : : "r0", "lr"); + + doesn't work, because the linker doesn't have to (and in fact doesn't) + update the @ha and @l references; the loader (which runs after this + code) will do that. + + Instead, we use the following trick: + + The linker puts the _link-time_ address of _DYNAMIC at the first + word in the GOT. We could branch to that address, if we wanted, + by using an @local reloc; the linker works this out, so it's safe + to use now. We can't, of course, actually branch there, because + we'd cause an illegal instruction exception; so we need to compute + the address ourselves. That gives us the following code: */ + + /* Get address of the 'b _DYNAMIC@local'... */ + asm ("bl 0f ;" + "b _DYNAMIC@local;" + "0:" + : "=l"(branchaddr)); + + /* ... and the address of the GOT. */ + asm (" bl _GLOBAL_OFFSET_TABLE_-4@local" + : "=l"(got)); + + /* So now work out the difference between where the branch actually points, + and the offset of that location in memory from the start of the file. */ + return (Elf32_Addr)branchaddr - *got + + (*branchaddr & 0x3fffffc | + (int)(*branchaddr << 6 & 0x80000000) >> 6); +} + +#define ELF_MACHINE_BEFORE_RTLD_RELOC(dynamic_info) /* nothing */ + +/* Perform the relocation specified by RELOC and SYM (which is fully resolved). + LOADADDR is the load address of the object; INFO is an array indexed + by DT_* of the .dynamic section info. */ + +#ifdef RESOLVE + +static inline void +elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, + const Elf32_Sym *sym, const struct r_found_version *version) +{ + Elf32_Addr *const reloc_addr = (Elf32_Addr *)(map->l_addr + reloc->r_offset); + Elf32_Word loadbase, finaladdr; + const int rinfo = ELF32_R_TYPE (reloc->r_info); + + if (rinfo == R_PPC_NONE) + return; + + if (sym && ELF32_ST_TYPE (sym->st_info) == STT_SECTION || + rinfo == R_PPC_RELATIVE) + { + /* Has already been relocated. */ + loadbase = map->l_addr; + finaladdr = loadbase + reloc->r_addend; + } + else + { + assert (sym != NULL); + if (rinfo == R_PPC_JMP_SLOT) + loadbase = (Elf32_Word) (char *) RESOLVE (&sym, + version, DL_LOOKUP_NOPLT); + else + loadbase = (Elf32_Word) (char *) RESOLVE (&sym, version, 0); + if (sym == NULL) + { + /* Weak symbol that wasn't actually defined anywhere. */ + assert (loadbase == 0); + finaladdr = reloc->r_addend; + } + else + finaladdr = (loadbase + (Elf32_Word)(char *)sym->st_value + + reloc->r_addend); + } + + switch (rinfo) + { + case R_PPC_UADDR16: + case R_PPC_ADDR16_LO: + case R_PPC_ADDR16: + *(Elf32_Half*) reloc_addr = finaladdr; + break; + + case R_PPC_ADDR16_HI: + *(Elf32_Half*) reloc_addr = finaladdr >> 16; + break; + + case R_PPC_ADDR16_HA: + *(Elf32_Half*) reloc_addr = finaladdr + 0x8000 >> 16; + break; + + case R_PPC_REL24: + { + Elf32_Sword delta = finaladdr - (Elf32_Word) (char *) reloc_addr; + assert (delta << 6 >> 6 == delta); + *reloc_addr = *reloc_addr & 0xfc000003 | delta & 0x3fffffc; + } + break; + + case R_PPC_UADDR32: + case R_PPC_GLOB_DAT: + case R_PPC_ADDR32: + case R_PPC_RELATIVE: + *reloc_addr = finaladdr; + break; + + case R_PPC_ADDR24: + *reloc_addr = *reloc_addr & 0xfc000003 | finaladdr & 0x3fffffc; + break; + + case R_PPC_REL14_BRTAKEN: + case R_PPC_REL14_BRNTAKEN: + case R_PPC_REL14: + { + Elf32_Sword delta = finaladdr - (Elf32_Word) (char *) reloc_addr; + *reloc_addr = *reloc_addr & 0xffdf0003 | delta & 0xfffc; + if (rinfo == R_PPC_REL14_BRTAKEN && delta >= 0 || + rinfo == R_PPC_REL14_BRNTAKEN && delta < 0) + *reloc_addr |= 0x00200000; + } + break; + + case R_PPC_COPY: + { + /* Can't use memcpy (because we can't call any functions here). */ + int i; + for (i = 0; i < sym->st_size; ++i) + ((unsigned char *) reloc_addr)[i] = + ((unsigned char *)finaladdr)[i]; + } + break; + + case R_PPC_REL32: + *reloc_addr = finaladdr - (Elf32_Word) (char *) reloc_addr; + break; + + case R_PPC_JMP_SLOT: + if (finaladdr <= 0x01fffffc || finaladdr >= 0xfe000000) + *reloc_addr = OPCODE_BA (finaladdr); + else + { + Elf32_Sword delta = finaladdr - (Elf32_Word) (char *) reloc_addr; + if (delta <= 0x01fffffc && delta >= 0xfe000000) + *reloc_addr = OPCODE_B (delta); + else + { + Elf32_Word *plt = + (Elf32_Word *) ((char *) map->l_addr + + map->l_info[DT_PLTGOT]->d_un.d_val); + Elf32_Word index =((reloc_addr - plt - PLT_INITIAL_ENTRY_WORDS) + / 2); + int num_plt_entries = (map->l_info[DT_PLTRELSZ]->d_un.d_val + / sizeof (Elf32_Rela)); + int rel_offset_words = (PLT_INITIAL_ENTRY_WORDS + + num_plt_entries * 2); + + if (index >= (1 << 13)) + { + /* Indexes greater than or equal to 2^13 have 4 + words available instead of two. */ + plt[index * 2 + PLT_INITIAL_ENTRY_WORDS] = + OPCODE_LI (11, finaladdr); + plt[index * 2 + 1 + PLT_INITIAL_ENTRY_WORDS] = + OPCODE_ADDIS (11, 11, finaladdr + 0x8000 >> 16); + plt[index * 2 + 2 + PLT_INITIAL_ENTRY_WORDS] = + OPCODE_MTCTR (11); + plt[index * 2 + 2 + PLT_INITIAL_ENTRY_WORDS] = + OPCODE_BCTR (); + } + else + { + plt[index * 2 + PLT_INITIAL_ENTRY_WORDS] = + OPCODE_LI (11, index * 4); + plt[index * 2 + 1 + PLT_INITIAL_ENTRY_WORDS] = + OPCODE_B(-(4 * (index * 2 + 1 + PLT_INITIAL_ENTRY_WORDS + + PLT_LONGBRANCH_ENTRY_WORDS))); + plt[index + rel_offset_words] = finaladdr; + } + } + } + break; + + default: + assert (! "unexpected dynamic reloc type"); + } +} + +#define ELF_MACHINE_NO_REL 1 + +#endif + +/* Nonzero iff TYPE describes relocation of a PLT entry, so + PLT entries should not be allowed to define the value. */ +#define elf_machine_pltrel_p(type) ((type) == R_PPC_JMP_SLOT) + +/* Set up the loaded object described by L so its unrelocated PLT + entries will jump to the on-demand fixup code in dl-runtime.c. */ + +/* This code does not presently work if there are more than 2^13 PLT + entries. */ +static inline void +elf_machine_runtime_setup (struct link_map *map, int lazy) +{ + Elf32_Word *plt; + int i; + Elf32_Word num_plt_entries; + Elf32_Word rel_offset_words; + extern void _dl_runtime_resolve (void); + + if (map->l_info[DT_JMPREL]) + { + /* Fill in the PLT. Its initial contents are directed to a + function earlier in the PLT which arranges for the dynamic + linker to be called back. */ + plt = (Elf32_Word *) ((char *) map->l_addr + + map->l_info[DT_PLTGOT]->d_un.d_val); + num_plt_entries = (map->l_info[DT_PLTRELSZ]->d_un.d_val + / sizeof (Elf32_Rela)); + rel_offset_words = PLT_INITIAL_ENTRY_WORDS + num_plt_entries * 2; + + if (lazy) + for (i = 0; i < num_plt_entries; i++) + if (i >= (1 << 13)) + { + plt[i * 2 + (i - (1 << 13)) * 2 + PLT_INITIAL_ENTRY_WORDS] = + OPCODE_LI (11, i * 4); + plt[i * 2 + (i - (1 << 13)) * 2 + 1 + PLT_INITIAL_ENTRY_WORDS] = + OPCODE_ADDIS (11, 11, i * 4 + 0x8000 >> 16); + plt[i * 2 + (i - (1 << 13)) * 2 + 2 + PLT_INITIAL_ENTRY_WORDS] = + OPCODE_B (-(4 * ( i * 2 + 1 + PLT_INITIAL_ENTRY_WORDS))); + } + else + { + plt[i * 2 + PLT_INITIAL_ENTRY_WORDS] = OPCODE_LI (11, i * 4); + plt[i * 2 + 1 + PLT_INITIAL_ENTRY_WORDS] = + OPCODE_B (-(4 * (i * 2 + 1 + PLT_INITIAL_ENTRY_WORDS))); + } + + /* Multiply index of entry, by 0xC. */ + plt[0] = OPCODE_SLWI (12, 11, 1); + plt[1] = OPCODE_ADD (11, 12, 11); + if ((Elf32_Word) (char *) _dl_runtime_resolve <= 0x01fffffc || + (Elf32_Word) (char *) _dl_runtime_resolve >= 0xfe000000) + { + plt[2] = OPCODE_LI (12, (Elf32_Word) (char *) map); + plt[3] = OPCODE_ADDIS (12, 12, + (Elf32_Word) (char *) map + 0x8000 >> 16); + plt[4] = OPCODE_BA ((Elf32_Word) (char *) _dl_runtime_resolve); + } + else + { + plt[2] = OPCODE_LI (12, (Elf32_Word) (char *) _dl_runtime_resolve); + plt[3] = OPCODE_ADDIS (12, 12, 0x8000 + + ((Elf32_Word) (char *) _dl_runtime_resolve + >> 16)); + plt[4] = OPCODE_MTCTR (12); + plt[5] = OPCODE_LI (12, (Elf32_Word) (char *) map); + plt[6] = OPCODE_ADDIS (12, 12, ((Elf32_Word) (char *) map + + 0x8000 >> 16)); + plt[7] = OPCODE_BCTR (); + } + plt[PLT_LONGBRANCH_ENTRY_WORDS] = + OPCODE_ADDIS (11, 11, ((Elf32_Word) (char*) (plt+rel_offset_words) + + 0x8000 >> 16)); + plt[PLT_LONGBRANCH_ENTRY_WORDS+1] = + OPCODE_LWZ (11, (Elf32_Word) (char*) (plt + rel_offset_words), 11); + plt[PLT_LONGBRANCH_ENTRY_WORDS+2] = OPCODE_MTCTR (11); + plt[PLT_LONGBRANCH_ENTRY_WORDS+3] = OPCODE_BCTR (); + } +} + +static inline void +elf_machine_lazy_rel (struct link_map *map, const Elf32_Rela *reloc) +{ + if (ELF32_R_TYPE (reloc->r_info) != R_PPC_JMP_SLOT) + assert (! "unexpected PLT reloc type"); + + /* elf_machine_runtime_setup handles this. */ +} + +/* The PLT uses Elf32_Rela relocs. */ +#define elf_machine_relplt elf_machine_rela + + /* This code is used in dl-runtime.c to call the `fixup' function + and then redirect to the address it returns. */ +#define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\ + .section \".text\" + .globl _dl_runtime_resolve +_dl_runtime_resolve: + stwu 1,-48(1) + mflr 0 + stw 3,16(1) + stw 4,20(1) + stw 0,52(1) + stw 5,24(1) + mfcr 0 + stw 6,28(1) + stw 7,32(1) + stw 8,36(1) + stw 9,40(1) + stw 10,44(1) + stw 0,12(1) + mr 3,12 + mr 4,11 + bl fixup + mtctr 3 + lwz 0,52(1) + lwz 10,44(1) + lwz 9,40(1) + mtlr 0 + lwz 0,12(1) + lwz 8,36(1) + lwz 7,32(1) + lwz 6,28(1) + mtcrf 0xFF,0 + lwz 5,24(1) + lwz 4,20(1) + lwz 3,16(1) + addi 1,1,48 + bctr +"); + +/* Initial entry point code for the dynamic linker. + The C function `_dl_start' is the real entry point; + its return value is the user program's entry point. */ + +/* FIXME! We don't make provision for calling _dl_fini, + because Linux/PPC is somewhat broken. */ +#define RTLD_START \ +asm ("\ + .text + .align 2 + .globl _start + .type _start,@function +_start: + # We start with the following on the stack, from top: + # argc (4 bytes) + # arguments for program (terminated by NULL) + # environment variables (terminated by NULL) + # arguments for the program loader + + # Call _dl_start with one parameter pointing at argc + mr 3,1 + # (we have to frob the stack pointer a bit to allow room for + # _dl_start to save the link register) + li 4,0 + addi 1,1,-16 + stw 4,0(1) + bl _dl_start@local + + # Now, we do our main work of calling initialisation procedures. + # The ELF ABI doesn't say anything about parameters for these, + # so we just pass argc, argv, and the environment. + # Changing these is strongly discouraged (not least because argc is + # passed by value!). + + # put our GOT pointer in r31 + bl _GLOBAL_OFFSET_TABLE_-4@local + mflr 31 + # the address of _start in r30 + mr 30,3 + # &_dl_argc in 29, &_dl_argv in 27, and _dl_default_scope in 28 + lwz 28,_dl_default_scope@got(31) + lwz 29,_dl_argc@got(31) + lwz 27,_dl_argv@got(31) +0: + # call initfunc = _dl_init_next(_dl_default_scope[2]) + lwz 3,8(28) + bl _dl_init_next@plt + # if initfunc is NULL, we exit the loop + mr. 0,3 + beq 1f + # call initfunc(_dl_argc, _dl_argv, _dl_argv+_dl_argc+1) + mtlr 0 + lwz 3,0(29) + lwz 4,0(27) + slwi 5,3,2 + add 5,4,5 + addi 5,5,4 + blrl + # and loop. + b 0b +1: + # Now, to conform to the ELF ABI, we have to: + # pass argv (actually _dl_argv) in r4 + lwz 4,0(27) + # pass argc (actually _dl_argc) in r3 + lwz 3,0(29) + # pass envp (actually _dl_argv+_dl_argc+1) in r5 + slwi 5,3,2 + add 5,4,5 + addi 5,5,4 + # pass the auxilary vector in r6. This is passed just after _envp. + addi 6,5,-4 +2: lwzu 0,4(6) + cmpwi 1,0,0 + bne 2b + addi 6,6,4 + # pass a termination function pointer (in this case _dl_fini) in r7 + lwz 7,_dl_fini@got(31) + # now, call the start function in r30... + mtctr 30 + # pass the stack pointer in r1 (so far so good), pointing to a NULL value + # (this lets our startup code distinguish between a program linked statically, + # which linux will call with argc on top of the stack which will hopefully + # never be zero, and a dynamically linked program which will always have + # a NULL on the top of the stack). + # Take the opportunity to clear LR, so anyone who accidentally returns + # from _start gets SEGV. + li 0,0 + stw 0,0(1) + mtlr 0 + # and also clear _dl_starting_up + lwz 26,_dl_starting_up@got(31) + stw 0,0(3) + # go do it! + bctr +"); + +#define ELF_PREFERRED_ADDRESS_DATA static ElfW(Addr) _dl_preferred_address = 0; +#define ELF_PREFERRED_ADDRESS(loader, maplength, mapstartpref) \ +( { \ + ElfW(Addr) prefd; \ + if (mapstartpref != 0 && _dl_preferred_address == 0) \ + _dl_preferred_address = mapstartpref; \ + if (mapstartpref != 0) \ + prefd = mapstartpref; \ + else if (_dl_preferred_address < maplength + 0x50000) \ + prefd = 0; \ + else \ + prefd = _dl_preferred_address = \ + (_dl_preferred_address - maplength - 0x10000) & \ + ~(_dl_pagesize - 1); \ + prefd; \ +} ) +#define ELF_FIXED_ADDRESS(loader, mapstart) \ +( { \ + if (mapstart != 0 && _dl_preferred_address == 0) \ + _dl_preferred_address = mapstart; \ +} ) + +#define ELF_FIXUP_RETURNS_ADDRESS 1 diff --git a/sysdeps/powerpc/elf/start.c b/sysdeps/powerpc/elf/start.c new file mode 100644 index 0000000000..9b1cf1c026 --- /dev/null +++ b/sysdeps/powerpc/elf/start.c @@ -0,0 +1,111 @@ +/* Startup code compliant to the ELF PowerPC ABI. + 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. */ + +/* This is SVR4/PPC ABI compliant, and works under Linux when + statically linked. */ + +#include <unistd.h> +#include <stdlib.h> + +/* Just a little assembler stub before gcc gets its hands on our + stack pointer... */ +asm ("\ + .text + .globl _start +_start: + # save the stack pointer, in case we're statically linked under Linux + mr 8,1 + # set up an initial stack frame, and clear the LR + addi 1,1,-16 + clrrwi 1,1,4 + li 0,0 + stw 0,0(1) + mtlr 0 + # set r13 to point at the 'small data area' + lis 13,_SDA_BASE_@ha + addi 13,13,_SDA_BASE_@l + # and continue below. + b __start1 +"); + +/* Define a symbol for the first piece of initialized data. */ +int __data_start = 0; +weak_alias (__data_start, data_start) + +/* these probably should go, at least go somewhere else + (sysdeps/mach/something?). */ +void (*_mach_init_routine) (void); +void (*_thread_init_routine) (void); + +void __libc_init_first (int argc, char **argv, char **envp); +int main (int argc, char **argv, char **envp, void *auxvec); +#ifdef HAVE_INITFINI +void _init (void); +void _fini (void); +#endif + + +static void __start1(int argc, char **argv, char **envp, + void *auxvec, void (*exitfn) (void), char **arguments) + __attribute__ ((unused)); +static void +__start1(int argc, char **argv, char **envp, + void *auxvec, void (*exitfn) (void), + char **arguments) +{ + /* the PPC SVR4 ABI says that the top thing on the stack will + be a NULL pointer, so if not we assume that we're being called + as a statically-linked program by Linux. */ + int abi_compliant_startup = *arguments == NULL; + + if (!abi_compliant_startup) + { + argc = *(int *) arguments; + argv = arguments+1; + envp = argv+argc+1; + auxvec = envp; + while (auxvec != NULL) + auxvec++; + auxvec++; + exitfn = NULL; + } + + if (exitfn != NULL) + atexit (exitfn); + + /* libc init routine, in case we are statically linked + (otherwise ld.so will have called it when it loaded libc, but + calling it twice doesn't hurt). */ + __libc_init_first (argc, argv, envp); + +#ifdef HAVE_INITFINI + /* ELF constructors/destructors */ + atexit (_fini); + _init (); +#endif + + /* Stuff so we can build Mach/Linux executables (like vmlinux). */ + if (_mach_init_routine != 0) + _mach_init_routine (); + if (_thread_init_routine != 0) + _thread_init_routine (); + + /* the rest of the program */ + exit (main (argc, argv, envp, auxvec)); +} diff --git a/sysdeps/powerpc/ffs.c b/sysdeps/powerpc/ffs.c new file mode 100644 index 0000000000..d9d7f267af --- /dev/null +++ b/sysdeps/powerpc/ffs.c @@ -0,0 +1,38 @@ +/* Find first set bit in a word, counted from least significant end. + For PowerPC. + Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc. + Contributed by Torbjorn Granlund (tege@sics.se). + + 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 <bstring.h> + +#undef ffs + +#ifdef __GNUC__ + +int +ffs (int x) +{ + int cnt; + + asm ("cntlzw %0,%1" : "=r" (cnt) : "r" (x & -x)); + return 32 - cnt; +} + +#else +#include <sysdeps/generic/ffs.c> +#endif diff --git a/sysdeps/powerpc/fpu_control.h b/sysdeps/powerpc/fpu_control.h new file mode 100644 index 0000000000..b31e0eeefd --- /dev/null +++ b/sysdeps/powerpc/fpu_control.h @@ -0,0 +1,77 @@ +/* FPU control word definitions. PowerPC version. + Copyright (C) 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is 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 _FPU_CONTROL_H +#define _FPU_CONTROL_H + +/* rounding control */ +#define _FPU_RC_NEAREST 0x00 /* RECOMMENDED */ +#define _FPU_RC_DOWN 0x03 +#define _FPU_RC_UP 0x02 +#define _FPU_RC_ZERO 0x01 + +#define _FPU_MASK_NI 0x04 /* non-ieee mode */ + +/* masking of interrupts */ +#define _FPU_MASK_ZM 0x10 /* zero divide */ +#define _FPU_MASK_OM 0x40 /* overflow */ +#define _FPU_MASK_UM 0x20 /* underflow */ +#define _FPU_MASK_XM 0x08 /* inexact */ +#define _FPU_MASK_IM 0x80 /* invalid operation */ +#define _FPU_MASK_VXCVI 0x100 /* invalid operation for integer convert */ +#define _FPU_MASK_VXSQRT 0x200 /* invalid operation for square root */ +#define _FPU_MASK_VXSOFT 0x400 /* invalid operation raised by software */ + +#define _FPU_RESERVED 0xfffff800 /* These bits are reserved are not changed. */ + +/* The fdlibm code requires no interrupts for exceptions. Don't + change the rounding mode, it would break long double I/O! */ +#define _FPU_DEFAULT 0x00000000 /* Default value. */ + +/* IEEE: same as above, but (some) exceptions; + we leave the 'inexact' exception off. + */ +#define _FPU_IEEE 0x000003f0 + +/* Type of the control word. */ +typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__))); + +/* Macros for accessing the hardware control word. */ +#define _FPU_GETCW(cw) ( { \ + fpu_control_t tmp[2] __attribute__ ((__aligned__(8))); \ + __asm__ ("mffs 0; stfd 0,%0" : "=m" (*tmp) : : "fr0"); \ + tmp[1]; } ) +#define _FPU_SETCW(cw) { \ + fpu_control_t tmp[2] __attribute__ ((__aligned__(8))); \ + tmp[0] = 0xFFF80000; /* arbitrary, more-or-less */ \ + tmp[1] = cw; \ + __asm__ ("lfd 0,%0; mtfsf 255,0" : : "m" (*tmp) : "fr0"); \ +} + +/* Default control word set at startup. */ +extern fpu_control_t __fpu_control; + +__BEGIN_DECLS + +/* Called at startup. It can be used to manipulate fpu control register. */ +extern void __setfpucw __P ((fpu_control_t)); + +__END_DECLS + +#endif /* _FPU_CONTROL_H */ diff --git a/sysdeps/powerpc/jmp_buf.h b/sysdeps/powerpc/jmp_buf.h new file mode 100644 index 0000000000..df832b157c --- /dev/null +++ b/sysdeps/powerpc/jmp_buf.h @@ -0,0 +1,19 @@ +/* Define the machine-dependent type `jmp_buf'. PowerPC version. */ + +/* The previous jmp_buf.h had __jmp_buf defined as a structure. + We use an array of 'long int' instead, to make writing the + assembler easier. Naturally, user code should not depend on + either representation. */ + +#if defined (__USE_MISC) || defined (_ASM) +#define JB_GPR1 0 /* also known as the stack pointer */ +#define JB_GPR2 1 +#define JB_LR 2 +#define JB_GPRS 3 /* GPRs 14 through 31 are saved, 18 in total */ +#define JB_UNUSED 21 /* it's sometimes faster to store doubles word-aligned */ +#define JB_FPRS 22 /* FPRs 14 through 31 are saved, 18*2 words total */ +#endif + +#ifndef _ASM +typedef long int __jmp_buf[58]; +#endif diff --git a/sysdeps/powerpc/setjmp.S b/sysdeps/powerpc/setjmp.S new file mode 100644 index 0000000000..a2c0b8c53d --- /dev/null +++ b/sysdeps/powerpc/setjmp.S @@ -0,0 +1,66 @@ +/* setjmp for PowerPC. + 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. */ + +#include <sysdep.h> +#define _ASM +#include <jmp_buf.h> + +ENTRY (__sigsetjmp) + stw 1,(JB_GPR1*4)(3) + mflr 0 + stw 2,(JB_GPR2*4)(3) + stw 14,((JB_GPRS+0)*4)(3) + stfd 14,((JB_FPRS+0*2)*4)(3) + stw 0,(JB_LR*4)(3) + stw 15,((JB_GPRS+1)*4)(3) + stfd 15,((JB_FPRS+1*2)*4)(3) + stw 16,((JB_GPRS+2)*4)(3) + stfd 16,((JB_FPRS+2*2)*4)(3) + stw 17,((JB_GPRS+3)*4)(3) + stfd 17,((JB_FPRS+3*2)*4)(3) + stw 18,((JB_GPRS+4)*4)(3) + stfd 18,((JB_FPRS+4*2)*4)(3) + stw 19,((JB_GPRS+5)*4)(3) + stfd 19,((JB_FPRS+5*2)*4)(3) + stw 20,((JB_GPRS+6)*4)(3) + stfd 20,((JB_FPRS+6*2)*4)(3) + stw 21,((JB_GPRS+7)*4)(3) + stfd 21,((JB_FPRS+7*2)*4)(3) + stw 22,((JB_GPRS+8)*4)(3) + stfd 22,((JB_FPRS+8*2)*4)(3) + stw 23,((JB_GPRS+9)*4)(3) + stfd 23,((JB_FPRS+9*2)*4)(3) + stw 24,((JB_GPRS+10)*4)(3) + stfd 24,((JB_FPRS+10*2)*4)(3) + stw 25,((JB_GPRS+11)*4)(3) + stfd 25,((JB_FPRS+11*2)*4)(3) + stw 26,((JB_GPRS+12)*4)(3) + stfd 26,((JB_FPRS+12*2)*4)(3) + stw 27,((JB_GPRS+13)*4)(3) + stfd 27,((JB_FPRS+13*2)*4)(3) + stw 28,((JB_GPRS+14)*4)(3) + stfd 28,((JB_FPRS+14*2)*4)(3) + stw 29,((JB_GPRS+15)*4)(3) + stfd 29,((JB_FPRS+15*2)*4)(3) + stw 30,((JB_GPRS+16)*4)(3) + stfd 30,((JB_FPRS+16*2)*4)(3) + stw 31,((JB_GPRS+17)*4)(3) + stfd 31,((JB_FPRS+17*2)*4)(3) + b __sigjmp_save +END (__sigsetjmp) diff --git a/sysdeps/powerpc/strlen.S b/sysdeps/powerpc/strlen.S new file mode 100644 index 0000000000..95eaf94de1 --- /dev/null +++ b/sysdeps/powerpc/strlen.S @@ -0,0 +1,52 @@ +/* Optimized strlen implementation for PowerPC. + 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. */ + + .section ".text" + .align 2 + .globl strlen + .type strlen,@function +strlen: + rlwinm 7,3,0,0,29 + lis 8,0x7f7f + lwz 11,0(7) + ori 8,8,32639 + rlwinm 4,3,3,27,28 + li 9,-1 + or 10,11,8 + and 0,11,8 + srw 9,9,4 + add 0,0,8 + nor 0,10,0 + and. 11,0,9 + bc 4,2,.L2 +.L3: + lwzu 11,4(7) + or 10,11,8 + and 0,11,8 + add 0,0,8 + nor. 11,10,0 + bc 12,2,.L3 +.L2: + subf 0,3,7 + cntlzw 3,11 + srwi 3,3,3 + add 3,0,3 + blr +.Lfe1: + .size strlen,.Lfe1-strlen diff --git a/sysdeps/unix/sysv/linux/i386/sigaction.c b/sysdeps/unix/sysv/linux/i386/sigaction.c index f3ecd4bd15..3f9d9463a0 100644 --- a/sysdeps/unix/sysv/linux/i386/sigaction.c +++ b/sysdeps/unix/sysv/linux/i386/sigaction.c @@ -1,42 +1,49 @@ /* POSIX.1 `sigaction' call for Linux/i386. -Copyright (C) 1991, 1995, 1996 Free Software Foundation, Inc. -This file is part of the GNU C Library. + Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include <sysdep.h> #include <errno.h> #include <stddef.h> #include <signal.h> +/* The difference here is that the sigaction structure used in the + kernel is not the same as we use in the libc. Therefore we must + translate it here. */ +#include <kernel_sigaction.h> + /* If ACT is not NULL, change the action for SIG to *ACT. If OACT is not NULL, put the old action for SIG in *OACT. */ int __sigaction (int sig, const struct sigaction *act, struct sigaction *oact) { - struct sigaction newact; + struct kernel_sigaction k_newact, k_oldact; int result; if (act) { - newact = *act; - newact.sa_restorer = ((act->sa_flags & SA_NOMASK) - ? &&restore_nomask : &&restore); - act = &newact; + k_newact.sa_handler = act->sa_handler; + k_newact.sa_mask = act->sa_mask.__val[0]; + k_newact.sa_flags = act->sa_flags; + + k_newact.sa_restorer = ((act->sa_flags & SA_NOMASK) + ? &&restore_nomask : &&restore); } asm volatile ("pushl %%ebx\n" @@ -44,13 +51,23 @@ __sigaction (int sig, const struct sigaction *act, struct sigaction *oact) "int $0x80\n" "popl %%ebx" : "=a" (result) - : "0" (SYS_ify (sigaction)), "r" (sig), "c" (act), "d" (oact)); + : "0" (SYS_ify (sigaction)), "r" (sig), + "c" (act ? &k_newact : 0), "d" (oact ? &k_oldact : 0)); if (result < 0) { __set_errno (-result); return -1; } + + if (oact) + { + oact->sa_handler = k_oldact.sa_handler; + oact->sa_mask.__val[0] = k_oldact.sa_mask; + oact->sa_flags = k_oldact.sa_flags; + oact->sa_restorer = k_oldact.sa_restorer; + } + return 0; restore: diff --git a/sysdeps/unix/sysv/linux/netinet/in.h b/sysdeps/unix/sysv/linux/netinet/in.h index 5b6cc78821..bbc625435c 100644 --- a/sysdeps/unix/sysv/linux/netinet/in.h +++ b/sysdeps/unix/sysv/linux/netinet/in.h @@ -127,13 +127,13 @@ struct in_addr /* Address to send to all hosts. */ #define INADDR_BROADCAST ((unsigned) 0xffffffff) /* Address indicating an error return. */ -#define INADDR_NONE 0xffffffff +#define INADDR_NONE ((unsigned) 0xffffffff) /* Network number for local host loopback. */ #define IN_LOOPBACKNET 127 /* Address to loopback in software to local host. */ #ifndef INADDR_LOOPBACK -#define INADDR_LOOPBACK 0x7f000001 /* Internet address 127.0.0.1. */ +#define INADDR_LOOPBACK ((unsigned) 0x7f000001) /* Inet address 127.0.0.1. */ #endif diff --git a/sysdeps/unix/sysv/linux/poll.c b/sysdeps/unix/sysv/linux/poll.c index 337b85005f..875c3b48f8 100644 --- a/sysdeps/unix/sysv/linux/poll.c +++ b/sysdeps/unix/sysv/linux/poll.c @@ -22,7 +22,9 @@ extern int __syscall_poll __P ((struct pollfd *fds, unsigned int nfds, int timeout)); -extern int __emulate_poll __P ((struct pollfd *fds, unsigned long int nfds, +weak_extern (__syscall_poll) + +static int __emulate_poll __P ((struct pollfd *fds, unsigned long int nfds, int timeout)); /* The real implementation. */ @@ -33,13 +35,17 @@ poll (fds, nfds, timeout) int timeout; { static int must_emulate = 0; + int (*syscall) __P ((struct pollfd *, unsigned int, int)) = __syscall_poll; if (!must_emulate) { - int retval = __syscall_poll (fds, nfds, timeout); + if (syscall) + { + int retval = __syscall_poll (fds, nfds, timeout); - if (retval >= 0 || errno != ENOSYS) - return retval; + if (retval >= 0 || errno != ENOSYS) + return retval; + } must_emulate = 1; } @@ -49,5 +55,5 @@ poll (fds, nfds, timeout) /* Get the emulation code. */ -#define poll(fds, nfds, timeout) __emulate_poll (fds, nfds, timeout) +#define poll(fds, nfds, timeout) static __emulate_poll (fds, nfds, timeout) #include <sysdeps/unix/bsd/poll.c> diff --git a/sysdeps/unix/sysv/linux/powerpc/Dist b/sysdeps/unix/sysv/linux/powerpc/Dist new file mode 100644 index 0000000000..3df65c325c --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/Dist @@ -0,0 +1,4 @@ +clone.S +ioctl-types.h +termbits.h +termios.h diff --git a/sysdeps/unix/sysv/linux/powerpc/_exit.S b/sysdeps/unix/sysv/linux/powerpc/_exit.S new file mode 100644 index 0000000000..a1ca375d54 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/_exit.S @@ -0,0 +1,26 @@ +/* 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. */ + +#include <sysdep.h> + +/* The 'exit' syscall does not return. */ + + .text +ENTRY(_exit) + DO_CALL (SYS_ify (exit)) +PSEUDO_END (_exit) diff --git a/sysdeps/unix/sysv/linux/powerpc/brk.c b/sysdeps/unix/sysv/linux/powerpc/brk.c new file mode 100644 index 0000000000..e9826bd098 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/brk.c @@ -0,0 +1,47 @@ +/* brk system call for Linux/ppc. + 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. */ + +#include <sysdep.h> +#include <errno.h> + +void *__curbrk; + +int +__brk (void *addr) +{ + register void *syscall_arg asm ("r3") = addr; + register int syscall_number asm ("r0") = SYS_ify (brk); + register void *newbrk asm ("r3"); + asm ("sc" + : "=r" (newbrk) + : "r" (syscall_arg), "r" (syscall_number) + : "r4","r5","r6","r7","r8","r9","r10","r11","r12", + "ctr", "mq", "cr0", "cr1", "cr6", "cr7"); + + __curbrk = newbrk; + + if (newbrk < addr) + { + __set_errno (ENOMEM); + return -1; + } + + return 0; +} +weak_alias (__brk, brk) diff --git a/sysdeps/unix/sysv/linux/powerpc/clone.S b/sysdeps/unix/sysv/linux/powerpc/clone.S new file mode 100644 index 0000000000..e5fa16d8c5 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/clone.S @@ -0,0 +1,74 @@ +/* Wrapper around clone system call. + 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 <sysdep.h> +#define _ERRNO_H 1 +#include <errnos.h> + +/* This is the only really unusual system call in PPC linux, but not + because of any weirdness in the system call itself; because of + all the freaky stuff we have to do to make the call useful. */ + +/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */ + +ENTRY(clone) + /* Set up stack frame, save registers. */ + stwu 1,-20(1) + stw 31,16(1) + + /* Check for child_stack == NULL, fn == NULL. */ + mr. 31,4 + cmpwi 1,3,0 + cror 2+0*4,2+0*4,2+1*4 + beq- 0,badargs + + /* Save 'fn' and its argument on the new stack. */ + stw 3,0(4) + stw 6,4(4) + + /* 'flags' argument is (only) parameter to clone syscall. */ + mr 3,5 + + /* Do the call. */ + DO_CALL(SYS_ify(clone)) + bso- error + beq child + + /* Parent. Restore registers & return. */ + lwz 31,20(1) + addi 1,1,20 + blr + +child: + /* Get address of procedure to call. */ + lwz 0,0(31) + /* Set up argument register. */ + lwz 3,4(31) + mtlr 0 + /* Switch to new stack. */ + mr 1,31 + /* Call procedure. */ + blrl + /* Call _exit with result from procedure. */ + DO_CALL (SYS_ify (exit)) + +badargs: + li 3,-EINVAL +error: + b __syscall_error diff --git a/sysdeps/unix/sysv/linux/powerpc/init-first.h b/sysdeps/unix/sysv/linux/powerpc/init-first.h new file mode 100644 index 0000000000..df702380fa --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/init-first.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. */ + +/* The job of this fragment it to find argc and friends for INIT. + They are passed to this routine by either the program loader + code in start.c, or by by dlopen.*/ + +#define SYSDEP_CALL_INIT(NAME, INIT) \ +void NAME (int argc, char **argv, char **envp) \ +{ \ + INIT (argc, argv, envp); \ +} diff --git a/sysdeps/unix/sysv/linux/powerpc/ioctl-types.h b/sysdeps/unix/sysv/linux/powerpc/ioctl-types.h new file mode 100644 index 0000000000..9e2695652e --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/ioctl-types.h @@ -0,0 +1 @@ +#include <termios.h> diff --git a/sysdeps/unix/sysv/linux/powerpc/profil.c b/sysdeps/unix/sysv/linux/powerpc/profil.c new file mode 100644 index 0000000000..6ab8065da3 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/profil.c @@ -0,0 +1,2 @@ +/* For now. */ +#include <sysdeps/stub/profil.c> diff --git a/sysdeps/unix/sysv/linux/powerpc/sigreturn.S b/sysdeps/unix/sysv/linux/powerpc/sigreturn.S new file mode 100644 index 0000000000..748c26761f --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/sigreturn.S @@ -0,0 +1,26 @@ +/* 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. */ + +#include <sysdep.h> + +/* The 'sigreturn' syscall does not return. */ + + .text +ENTRY(__sigreturn) + DO_CALL(SYS_ify(sigreturn)) +PSEUDO_END (__sigreturn) diff --git a/sysdeps/unix/sysv/linux/powerpc/socket.S b/sysdeps/unix/sysv/linux/powerpc/socket.S new file mode 100644 index 0000000000..32bb8f64cd --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/socket.S @@ -0,0 +1,83 @@ +/* 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. */ + +#include <sysdep.h> +#include <sys/socketcall.h> + +#define P(a, b) P2(a, b) +#define P2(a, b) a##b + +/* The socket-oriented system calls are handled unusally in Linux. + They are all gated through the single `socketcall' system call number. + `socketcall' takes two arguments: the first is the subcode, specifying + which socket function is being called; and the second is a pointer to + the arguments to the specific function. + + The .S files for the other calls just #define socket and #include this. + They also #define a 'number-of-arguments' word in NARGS, which + defaults to 3. */ + +#ifndef NARGS +#ifdef socket +#error NARGS not defined +#endif +#define NARGS 3 +#endif + +#define stackblock 20 + + .text +ENTRY(P(__,socket)) + stwu 1,-48(1) +#if NARGS >= 1 + stw 3,stackblock(1) +#endif +#if NARGS >= 2 + stw 4,4+stackblock(1) +#endif +#if NARGS >= 3 + stw 5,8+stackblock(1) +#endif +#if NARGS >= 4 + stw 6,12+stackblock(1) +#endif +#if NARGS >= 5 + stw 7,16+stackblock(1) +#endif +#if NARGS >= 6 + stw 8,20+stackblock(1) +#endif +#if NARGS >= 7 + stw 9,24+stackblock(1) +#endif +#if NARGS >= 8 + stw 10,28+stackblock(1) +#endif +#if NARGS >= 9 +#error too many arguments! +#endif + li 3,P(SOCKOP_,socket) + addi 4,1,stackblock + DO_CALL(SYS_ify(socketcall)) + addi 1,1,48 + bnslr + b __syscall_error + +PSEUDO_END (P(__,socket)) + +weak_alias (P(__,socket), socket) diff --git a/sysdeps/unix/sysv/linux/powerpc/syscall.S b/sysdeps/unix/sysv/linux/powerpc/syscall.S new file mode 100644 index 0000000000..9b3f66682e --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/syscall.S @@ -0,0 +1,32 @@ +/* Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <sysdep.h> + + .text +ENTRY (syscall) + mr 0,3 + mr 3,4 + mr 4,5 + mr 5,6 + mr 6,7 + mr 7,8 + sc + bnslr + b __syscall_error +PSEUDO_END (syscall) diff --git a/sysdeps/unix/sysv/linux/powerpc/syscall.h b/sysdeps/unix/sysv/linux/powerpc/syscall.h new file mode 100644 index 0000000000..c6bac3de5b --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/syscall.h @@ -0,0 +1,357 @@ +/* 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 _SYSCALL_H +#define _SYSCALL_H 1 + +/* normally, we'd get syscalls from asm/unistd.h under Linux, but this + is very broken under MkLinux/PPC, so we list them right here directly. */ + +#define __NR_setup 0 +#define __NR_exit 1 +#define __NR_fork 2 +#define __NR_read 3 +#define __NR_write 4 +#define __NR_open 5 +#define __NR_close 6 +#define __NR_waitpid 7 +#define __NR_creat 8 +#define __NR_link 9 +#define __NR_unlink 10 +#define __NR_execve 11 +#define __NR_chdir 12 +#define __NR_time 13 +#define __NR_mknod 14 +#define __NR_chmod 15 +#define __NR_chown 16 +#define __NR_break 17 +#define __NR_oldstat 18 +#define __NR_lseek 19 +#define __NR_getpid 20 +#define __NR_mount 21 +#define __NR_umount 22 +#define __NR_setuid 23 +#define __NR_getuid 24 +#define __NR_stime 25 +#define __NR_ptrace 26 +#define __NR_alarm 27 +#define __NR_oldfstat 28 +#define __NR_pause 29 +#define __NR_utime 30 +#define __NR_stty 31 +#define __NR_gtty 32 +#define __NR_access 33 +#define __NR_nice 34 +#define __NR_ftime 35 +#define __NR_sync 36 +#define __NR_kill 37 +#define __NR_rename 38 +#define __NR_mkdir 39 +#define __NR_rmdir 40 +#define __NR_dup 41 +#define __NR_pipe 42 +#define __NR_times 43 +#define __NR_prof 44 +#define __NR_brk 45 +#define __NR_setgid 46 +#define __NR_getgid 47 +#define __NR_signal 48 +#define __NR_geteuid 49 +#define __NR_getegid 50 +#define __NR_acct 51 +#define __NR_phys 52 +#define __NR_lock 53 +#define __NR_ioctl 54 +#define __NR_fcntl 55 +#define __NR_mpx 56 +#define __NR_setpgid 57 +#define __NR_ulimit 58 +#define __NR_oldolduname 59 +#define __NR_umask 60 +#define __NR_chroot 61 +#define __NR_ustat 62 +#define __NR_dup2 63 +#define __NR_getppid 64 +#define __NR_getpgrp 65 +#define __NR_setsid 66 +#define __NR_sigaction 67 +#define __NR_sgetmask 68 +#define __NR_ssetmask 69 +#define __NR_setreuid 70 +#define __NR_setregid 71 +#define __NR_sigsuspend 72 +#define __NR_sigpending 73 +#define __NR_sethostname 74 +#define __NR_setrlimit 75 +#define __NR_getrlimit 76 +#define __NR_getrusage 77 +#define __NR_gettimeofday 78 +#define __NR_settimeofday 79 +#define __NR_getgroups 80 +#define __NR_setgroups 81 +#define __NR_select 82 +#define __NR_symlink 83 +#define __NR_oldlstat 84 +#define __NR_readlink 85 +#define __NR_uselib 86 +#define __NR_swapon 87 +#define __NR_reboot 88 +#define __NR_readdir 89 +#define __NR_mmap 90 +#define __NR_munmap 91 +#define __NR_truncate 92 +#define __NR_ftruncate 93 +#define __NR_fchmod 94 +#define __NR_fchown 95 +#define __NR_getpriority 96 +#define __NR_setpriority 97 +#define __NR_profil 98 +#define __NR_statfs 99 +#define __NR_fstatfs 100 +#define __NR_ioperm 101 +#define __NR_socketcall 102 +#define __NR_syslog 103 +#define __NR_setitimer 104 +#define __NR_getitimer 105 +#define __NR_stat 106 +#define __NR_lstat 107 +#define __NR_fstat 108 +#define __NR_olduname 109 +#define __NR_iopl 110 +#define __NR_vhangup 111 +#define __NR_idle 112 +#define __NR_vm86 113 +#define __NR_wait4 114 +#define __NR_swapoff 115 +#define __NR_sysinfo 116 +#define __NR_ipc 117 +#define __NR_fsync 118 +#define __NR_sigreturn 119 +#define __NR_clone 120 +#define __NR_setdomainname 121 +#define __NR_uname 122 +#define __NR_modify_ldt 123 +#define __NR_adjtimex 124 +#define __NR_mprotect 125 +#define __NR_sigprocmask 126 +#define __NR_create_module 127 +#define __NR_init_module 128 +#define __NR_delete_module 129 +#define __NR_get_kernel_syms 130 +#define __NR_quotactl 131 +#define __NR_getpgid 132 +#define __NR_fchdir 133 +#define __NR_bdflush 134 +#define __NR_sysfs 135 +#define __NR_personality 136 +#define __NR_afs_syscall 137 /* Syscall for Andrew File System */ +#define __NR_setfsuid 138 +#define __NR_setfsgid 139 +#define __NR__llseek 140 +#define __NR_getdents 141 +#define __NR__newselect 142 +#define __NR_flock 143 +#define __NR_msync 144 +#define __NR_readv 145 +#define __NR_writev 146 +#define __NR_getsid 147 +#define __NR_fdatasync 148 +#define __NR__sysctl 149 +#define __NR_mlock 150 +#define __NR_munlock 151 +#define __NR_mlockall 152 +#define __NR_munlockall 153 +#define __NR_sched_setparam 154 +#define __NR_sched_getparam 155 +#define __NR_sched_setscheduler 156 +#define __NR_sched_getscheduler 157 +#define __NR_sched_yield 158 +#define __NR_sched_get_priority_max 159 +#define __NR_sched_get_priority_min 160 +#define __NR_sched_rr_get_interval 161 +#define __NR_nanosleep 162 +#define __NR_mremap 163 + +#ifndef _LIBC +#define SYS_setup 0 +#define SYS_exit 1 +#define SYS_fork 2 +#define SYS_read 3 +#define SYS_write 4 +#define SYS_open 5 +#define SYS_close 6 +#define SYS_waitpid 7 +#define SYS_creat 8 +#define SYS_link 9 +#define SYS_unlink 10 +#define SYS_execve 11 +#define SYS_chdir 12 +#define SYS_time 13 +#define SYS_mknod 14 +#define SYS_chmod 15 +#define SYS_chown 16 +#define SYS_break 17 +#define SYS_oldstat 18 +#define SYS_lseek 19 +#define SYS_getpid 20 +#define SYS_mount 21 +#define SYS_umount 22 +#define SYS_setuid 23 +#define SYS_getuid 24 +#define SYS_stime 25 +#define SYS_ptrace 26 +#define SYS_alarm 27 +#define SYS_oldfstat 28 +#define SYS_pause 29 +#define SYS_utime 30 +#define SYS_stty 31 +#define SYS_gtty 32 +#define SYS_access 33 +#define SYS_nice 34 +#define SYS_ftime 35 +#define SYS_sync 36 +#define SYS_kill 37 +#define SYS_rename 38 +#define SYS_mkdir 39 +#define SYS_rmdir 40 +#define SYS_dup 41 +#define SYS_pipe 42 +#define SYS_times 43 +#define SYS_prof 44 +#define SYS_brk 45 +#define SYS_setgid 46 +#define SYS_getgid 47 +#define SYS_signal 48 +#define SYS_geteuid 49 +#define SYS_getegid 50 +#define SYS_acct 51 +#define SYS_phys 52 +#define SYS_lock 53 +#define SYS_ioctl 54 +#define SYS_fcntl 55 +#define SYS_mpx 56 +#define SYS_setpgid 57 +#define SYS_ulimit 58 +#define SYS_oldolduname 59 +#define SYS_umask 60 +#define SYS_chroot 61 +#define SYS_ustat 62 +#define SYS_dup2 63 +#define SYS_getppid 64 +#define SYS_getpgrp 65 +#define SYS_setsid 66 +#define SYS_sigaction 67 +#define SYS_sgetmask 68 +#define SYS_ssetmask 69 +#define SYS_setreuid 70 +#define SYS_setregid 71 +#define SYS_sigsuspend 72 +#define SYS_sigpending 73 +#define SYS_sethostname 74 +#define SYS_setrlimit 75 +#define SYS_getrlimit 76 +#define SYS_getrusage 77 +#define SYS_gettimeofday 78 +#define SYS_settimeofday 79 +#define SYS_getgroups 80 +#define SYS_setgroups 81 +#define SYS_select 82 +#define SYS_symlink 83 +#define SYS_oldlstat 84 +#define SYS_readlink 85 +#define SYS_uselib 86 +#define SYS_swapon 87 +#define SYS_reboot 88 +#define SYS_readdir 89 +#define SYS_mmap 90 +#define SYS_munmap 91 +#define SYS_truncate 92 +#define SYS_ftruncate 93 +#define SYS_fchmod 94 +#define SYS_fchown 95 +#define SYS_getpriority 96 +#define SYS_setpriority 97 +#define SYS_profil 98 +#define SYS_statfs 99 +#define SYS_fstatfs 100 +#define SYS_ioperm 101 +#define SYS_socketcall 102 +#define SYS_syslog 103 +#define SYS_setitimer 104 +#define SYS_getitimer 105 +#define SYS_stat 106 +#define SYS_lstat 107 +#define SYS_fstat 108 +#define SYS_olduname 109 +#define SYS_iopl 110 +#define SYS_vhangup 111 +#define SYS_idle 112 +#define SYS_vm86 113 +#define SYS_wait4 114 +#define SYS_swapoff 115 +#define SYS_sysinfo 116 +#define SYS_ipc 117 +#define SYS_fsync 118 +#define SYS_sigreturn 119 +#define SYS_clone 120 +#define SYS_setdomainname 121 +#define SYS_uname 122 +#define SYS_modify_ldt 123 +#define SYS_adjtimex 124 +#define SYS_mprotect 125 +#define SYS_sigprocmask 126 +#define SYS_create_module 127 +#define SYS_init_module 128 +#define SYS_delete_module 129 +#define SYS_get_kernel_syms 130 +#define SYS_quotactl 131 +#define SYS_getpgid 132 +#define SYS_fchdir 133 +#define SYS_bdflush 134 +#define SYS_sysfs 135 +#define SYS_personality 136 +#define SYS_afs_syscall 137 /* Syscall for Andrew File System */ +#define SYS_setfsuid 138 +#define SYS_setfsgid 139 +#define SYS__llseek 140 +#define SYS_getdents 141 +#define SYS__newselect 142 +#define SYS_flock 143 +#define SYS_msync 144 +#define SYS_readv 145 +#define SYS_writev 146 +#define SYS_getsid 147 +#define SYS_fdatasync 148 +#define SYS__sysctl 149 +#define SYS_mlock 150 +#define SYS_munlock 151 +#define SYS_mlockall 152 +#define SYS_munlockall 153 +#define SYS_sched_setparam 154 +#define SYS_sched_getparam 155 +#define SYS_sched_setscheduler 156 +#define SYS_sched_getscheduler 157 +#define SYS_sched_yield 158 +#define SYS_sched_get_priority_max 159 +#define SYS_sched_get_priority_min 160 +#define SYS_sched_rr_get_interval 161 +#define SYS_nanosleep 162 +#define SYS_mremap 163 +#endif + +#endif diff --git a/sysdeps/unix/sysv/linux/powerpc/syscalls.list b/sysdeps/unix/sysv/linux/powerpc/syscalls.list new file mode 100644 index 0000000000..7883d70719 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/syscalls.list @@ -0,0 +1,3 @@ +# File name Caller Syscall name # args Strong name Weak names + +s_llseek llseek _llseek 5 __sys_llseek diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.c b/sysdeps/unix/sysv/linux/powerpc/sysdep.c new file mode 100644 index 0000000000..3896111005 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.c @@ -0,0 +1,33 @@ +/* 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 <sysdep.h> +#include <errno.h> + +/* This routine is jumped to by all the syscall handlers, to stash + an error number into errno. */ +int +__syscall_error (int err_no) +{ + __set_errno (err_no); + return -1; +} + +/* We also have to have a 'real' definition of errno. */ +#undef errno +int errno = 0; diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h new file mode 100644 index 0000000000..c08e3d8060 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h @@ -0,0 +1,53 @@ +/* Copyright (C) 1992, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <sysdeps/unix/sysdep.h> + +/* For Linux we can use the system call table in the header file + /usr/include/asm/unistd.h + of the kernel. But these symbols do not follow the SYS_* syntax + so we have to redefine the `SYS_ify' macro here. */ +#undef SYS_ify +#ifdef __STDC__ +# define SYS_ify(syscall_name) __NR_##syscall_name +#else +# define SYS_ify(syscall_name) __NR_/**/syscall_name +#endif + +#ifdef ASSEMBLER + +#define ENTRY(name) \ + .globl name; \ + .type name,@function; \ + .align 2; \ + C_LABEL(name) + +#define DO_CALL(syscall) \ + li 0,syscall; \ + sc + +#define PSEUDO(name, syscall_name, args) \ + .text; \ + ENTRY (name) \ + DO_CALL (SYS_ify (syscall_name)); \ + bnslr; \ + b __syscall_error + +#define ret /* Nothing (should be 'blr', but never reached). */ + +#endif /* ASSEMBLER */ diff --git a/sysdeps/unix/sysv/linux/powerpc/termbits.h b/sysdeps/unix/sysv/linux/powerpc/termbits.h new file mode 100644 index 0000000000..d1b0a3e3cb --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/termbits.h @@ -0,0 +1,356 @@ +/* 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 _TERMBITS_H +#define _TERMBITS_H + +#include <linux/posix_types.h> + +typedef unsigned char cc_t; +typedef unsigned int speed_t; +typedef unsigned int tcflag_t; + +/* + * termios type and macro definitions. Be careful about adding stuff + * to this file since it's used in GNU libc and there are strict rules + * concerning namespace pollution. + */ + +#define NCCS 19 +struct termios { + tcflag_t c_iflag; /* input mode flags */ + tcflag_t c_oflag; /* output mode flags */ + tcflag_t c_cflag; /* control mode flags */ + tcflag_t c_lflag; /* local mode flags */ + cc_t c_cc[NCCS]; /* control characters */ + cc_t c_line; /* line discipline (== c_cc[19]) */ + speed_t c_ispeed; /* input speed */ + speed_t c_ospeed; /* output speed */ +}; + +/* c_cc characters */ +#define VINTR 0 +#define VQUIT 1 +#define VERASE 2 +#define VKILL 3 +#define VEOF 4 +#define VMIN 5 +#define VEOL 6 +#define VTIME 7 +#define VEOL2 8 +#define VSWTC 9 + +#define VWERASE 10 +#define VREPRINT 11 +#define VSUSP 12 +#define VSTART 13 +#define VSTOP 14 +#define VLNEXT 15 +#define VDISCARD 16 + +/* c_iflag bits */ +#define IGNBRK 0000001 +#define BRKINT 0000002 +#define IGNPAR 0000004 +#define PARMRK 0000010 +#define INPCK 0000020 +#define ISTRIP 0000040 +#define INLCR 0000100 +#define IGNCR 0000200 +#define ICRNL 0000400 +#define IXON 0001000 +#define IXOFF 0002000 +#if !defined(KERNEL) || defined(__USE_BSD) + /* POSIX.1 doesn't want these... */ +# define IXANY 0004000 +# define IUCLC 0010000 +# define IMAXBEL 0020000 +#endif + +/* c_oflag bits */ +#define OPOST 0000001 +#define ONLCR 0000002 +#define OLCUC 0000004 + +#define OCRNL 0000010 +#define ONOCR 0000020 +#define ONLRET 0000040 + +#define OFILL 00000100 +#define OFDEL 00000200 +#define NLDLY 00001400 +#define NL0 00000000 +#define NL1 00000400 +#define NL2 00001000 +#define NL3 00001400 +#define TABDLY 00006000 +#define TAB0 00000000 +#define TAB1 00002000 +#define TAB2 00004000 +#define TAB3 00006000 +#define CRDLY 00030000 +#define CR0 00000000 +#define CR1 00010000 +#define CR2 00020000 +#define CR3 00030000 +#define FFDLY 00040000 +#define FF0 00000000 +#define FF1 00040000 +#define BSDLY 00100000 +#define BS0 00000000 +#define BS1 00100000 +#define VTDLY 00200000 +#define VT0 00000000 +#define VT1 00200000 +#define XTABS 01000000 /* Hmm.. Linux/i386 considers this part of TABDLY.. */ + +/* c_cflag bit meaning */ +#define CBAUD 0000377 +#define B0 0000000 /* hang up */ +#define B50 0000001 +#define B75 0000002 +#define B110 0000003 +#define B134 0000004 +#define B150 0000005 +#define B200 0000006 +#define B300 0000007 +#define B600 0000010 +#define B1200 0000011 +#define B1800 0000012 +#define B2400 0000013 +#define B4800 0000014 +#define B9600 0000015 +#define B19200 0000016 +#define B38400 0000017 +#define EXTA B19200 +#define EXTB B38400 +#define CBAUDEX 0000020 +#define B57600 00020 +#define B115200 00021 +#define B230400 00022 +#define B460800 00023 + +#define CSIZE 00001400 +#define CS5 00000000 +#define CS6 00000400 +#define CS7 00001000 +#define CS8 00001400 + +#define CSTOPB 00002000 +#define CREAD 00004000 +#define PARENB 00010000 +#define PARODD 00020000 +#define HUPCL 00040000 + +#define CLOCAL 00100000 +#define CRTSCTS 020000000000 /* flow control */ + +/* c_lflag bits */ +#define ISIG 0x00000080 +#define ICANON 0x00000100 +#define XCASE 0x00004000 +#define ECHO 0x00000008 +#define ECHOE 0x00000002 +#define ECHOK 0x00000004 +#define ECHONL 0x00000010 +#define NOFLSH 0x80000000 +#define TOSTOP 0x00400000 +#define ECHOCTL 0x00000040 +#define ECHOPRT 0x00000020 +#define ECHOKE 0x00000001 +#define FLUSHO 0x00800000 +#define PENDIN 0x20000000 +#define IEXTEN 0x00000400 + +/* Values for the ACTION argument to `tcflow'. */ +#define TCOOFF 0 +#define TCOON 1 +#define TCIOFF 2 +#define TCION 3 + +/* Values for the QUEUE_SELECTOR argument to `tcflush'. */ +#define TCIFLUSH 0 +#define TCOFLUSH 1 +#define TCIOFLUSH 2 + +/* Values for the OPTIONAL_ACTIONS argument to `tcsetattr'. */ +#define TCSANOW 0 +#define TCSADRAIN 1 +#define TCSAFLUSH 2 + +struct sgttyb { + char sg_ispeed; + char sg_ospeed; + char sg_erase; + char sg_kill; + short sg_flags; +}; + +struct tchars { + char t_intrc; + char t_quitc; + char t_startc; + char t_stopc; + char t_eofc; + char t_brkc; +}; + +struct ltchars { + char t_suspc; + char t_dsuspc; + char t_rprntc; + char t_flushc; + char t_werasc; + char t_lnextc; +}; + +#define FIOCLEX _IO('f', 1) +#define FIONCLEX _IO('f', 2) +#define FIOASYNC _IOW('f', 125, int) +#define FIONBIO _IOW('f', 126, int) +#define FIONREAD _IOR('f', 127, int) +#define TIOCINQ FIONREAD + +#define TIOCGETP _IOR('t', 8, struct sgttyb) +#define TIOCSETP _IOW('t', 9, struct sgttyb) +#define TIOCSETN _IOW('t', 10, struct sgttyb) /* TIOCSETP wo flush */ + +#define TIOCSETC _IOW('t', 17, struct tchars) +#define TIOCGETC _IOR('t', 18, struct tchars) +#define TCGETS _IOR('t', 19, struct termios) +#define TCSETS _IOW('t', 20, struct termios) +#define TCSETSW _IOW('t', 21, struct termios) +#define TCSETSF _IOW('t', 22, struct termios) + +#define TCGETA _IOR('t', 23, struct termio) +#define TCSETA _IOW('t', 24, struct termio) +#define TCSETAW _IOW('t', 25, struct termio) +#define TCSETAF _IOW('t', 28, struct termio) + +#define TCSBRK _IO('t', 29) +#define TCXONC _IO('t', 30) +#define TCFLSH _IO('t', 31) + +#define TIOCSWINSZ _IOW('t', 103, struct winsize) +#define TIOCGWINSZ _IOR('t', 104, struct winsize) +#define TIOCSTART _IO('t', 110) /* start output, like ^Q */ +#define TIOCSTOP _IO('t', 111) /* stop output, like ^S */ +#define TIOCOUTQ _IOR('t', 115, int) /* output queue size */ + +#define TIOCGLTC _IOR('t', 116, struct ltchars) +#define TIOCSLTC _IOW('t', 117, struct ltchars) +#define TIOCSPGRP _IOW('t', 118, int) +#define TIOCGPGRP _IOR('t', 119, int) + +#define TIOCEXCL 0x540C +#define TIOCNXCL 0x540D +#define TIOCSCTTY 0x540E + +#define TIOCSTI 0x5412 +#define TIOCMGET 0x5415 +#define TIOCMBIS 0x5416 +#define TIOCMBIC 0x5417 +#define TIOCMSET 0x5418 +#define TIOCGSOFTCAR 0x5419 +#define TIOCSSOFTCAR 0x541A +#define TIOCLINUX 0x541C +#define TIOCCONS 0x541D +#define TIOCGSERIAL 0x541E +#define TIOCSSERIAL 0x541F +#define TIOCPKT 0x5420 + +#define TIOCNOTTY 0x5422 +#define TIOCSETD 0x5423 +#define TIOCGETD 0x5424 +#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ +#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */ + +#define TIOCSERCONFIG 0x5453 +#define TIOCSERGWILD 0x5454 +#define TIOCSERSWILD 0x5455 +#define TIOCGLCKTRMIOS 0x5456 +#define TIOCSLCKTRMIOS 0x5457 +#define TIOCSERGSTRUCT 0x5458 /* For debugging only */ +#define TIOCSERGETLSR 0x5459 /* Get line status register */ +#define TIOCSERGETMULTI 0x545A /* Get multiport config */ +#define TIOCSERSETMULTI 0x545B /* Set multiport config */ + +#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ +#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ + +/* Used for packet mode */ +#define TIOCPKT_DATA 0 +#define TIOCPKT_FLUSHREAD 1 +#define TIOCPKT_FLUSHWRITE 2 +#define TIOCPKT_STOP 4 +#define TIOCPKT_START 8 +#define TIOCPKT_NOSTOP 16 +#define TIOCPKT_DOSTOP 32 + +struct winsize { + unsigned short ws_row; + unsigned short ws_col; + unsigned short ws_xpixel; + unsigned short ws_ypixel; +}; + +#define NCC 10 +struct termio { + unsigned short c_iflag; /* input mode flags */ + unsigned short c_oflag; /* output mode flags */ + unsigned short c_cflag; /* control mode flags */ + unsigned short c_lflag; /* local mode flags */ + unsigned char c_line; /* line discipline */ + unsigned char c_cc[NCC]; /* control characters */ +}; + +/* c_cc characters */ +#define _VINTR 0 +#define _VQUIT 1 +#define _VERASE 2 +#define _VKILL 3 +#define _VEOF 4 +#define _VMIN 5 +#define _VEOL 6 +#define _VTIME 7 +#define _VEOL2 8 +#define _VSWTC 9 + +/* modem lines */ +#define TIOCM_LE 0x001 +#define TIOCM_DTR 0x002 +#define TIOCM_RTS 0x004 +#define TIOCM_ST 0x008 +#define TIOCM_SR 0x010 +#define TIOCM_CTS 0x020 +#define TIOCM_CAR 0x040 +#define TIOCM_RNG 0x080 +#define TIOCM_DSR 0x100 +#define TIOCM_CD TIOCM_CAR +#define TIOCM_RI TIOCM_RNG + +/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ +#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ + +/* line disciplines */ +#define N_TTY 0 +#define N_SLIP 1 +#define N_MOUSE 2 +#define N_PPP 3 + +#endif /* _TERMBITS_H */ diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list index 867e3bce3e..4e92f6d35c 100644 --- a/sysdeps/unix/sysv/linux/syscalls.list +++ b/sysdeps/unix/sysv/linux/syscalls.list @@ -30,10 +30,10 @@ nanosleep - nanosleep 2 __libc_nanosleep __nanosleep nanosleep pause - pause 0 __libc_pause pause personality init-first personality 1 __personality personality pipe - pipe 1 __pipe pipe -s_poll EXTRA poll 3 __syscall_poll query_module EXTRA query_module 5 query_module s_getdents EXTRA getdents 3 __getdents s_getpriority getpriority getpriority 2 __syscall_getpriority +s_poll poll poll 3 __syscall_poll s_ptrace ptrace ptrace 4 __syscall_ptrace s_reboot EXTRA reboot 3 __syscall_reboot s_sigaction sigaction sigaction 3 __syscall_sigaction diff --git a/time/antarctica b/time/antarctica index 1cff7552d1..c06231e454 100644 --- a/time/antarctica +++ b/time/antarctica @@ -1,4 +1,4 @@ -# @(#)antarctica 7.6 +# @(#)antarctica 7.7 # From Paul Eggert (1997-01-20): # To keep things manageable, we list only locations occupied year-round; @@ -79,7 +79,7 @@ Zone Indian/Kerguelen 0 - ___ 1950 # Port-aux-Francais 5:00 - TFT # ISO code TF Time # # year-round base in the main continent -# Dumont-d'Urville, Terre Adelie (Adelie Land), -6040+14001, since 1956-11 +# Dumont-d'Urville, Terre Adelie (Adelie Land), -6640+14001, since 1956-11 # # Another base at Port-Martin, 50km east, began operation in 1947. # It was destroyed by fire on 1952-01-14. diff --git a/time/asia b/time/asia index 07cdb113c4..0a3c4fed00 100644 --- a/time/asia +++ b/time/asia @@ -1,4 +1,4 @@ -# @(#)asia 7.27 +# @(#)asia 7.28 # This data is by no means authoritative; if you think you know better, # go ahead and edit the file (and please send any changes to @@ -506,8 +506,10 @@ Rule Zion 1987 only - Sep 13 0:00 0 S Rule Zion 1988 only - Apr 9 0:00 1:00 D Rule Zion 1988 only - Sep 3 0:00 0 S -# From Ephraim Silverberg (1996-01-02): -# +# From Ephraim Silverberg (ephraim@cs.huji.ac.il), 1997-03-04: + +# Zone Information Compiler (ZIC) File for the State of Israel (1989-2009) + # According to the Office of the Secretary General of the Ministry of # Interior, there is NO set rule for Daylight-Savings/Standard time changes. # Each year they decide anew what havoc to wreak on the country. However, @@ -516,55 +518,82 @@ Rule Zion 1988 only - Sep 3 0:00 0 S # government, the phase of the moon and the direction of the wind. Hence, # changes may need to be made on a semi-annual basis. One thing is entrenched # in law, however: that there must be at least 150 days of daylight savings -# time annually. Ever since 1993, the change to daylight savings time has -# been from midnight Thursday night to 1 a.m. Friday morning and the change -# back to standard time on Saturday night from midnight daylight savings time +# time annually. Ever since 1993, the change to daylight savings time is +# on a Thursday night from midnight IST to 1 a.m IDT. The change back to +# standard time is on a Saturday night from midnight daylight savings time # to 11 p.m. standard time. 1996 is an exception to this rule where the -# change back to standard time takes place on Sunday night instead of Saturday +# change back to standard time took place on Sunday night instead of Saturday # night to avoid conflicts with the Jewish New Year. -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Zion 1989 only - Apr 30 0:00 1:00 D -Rule Zion 1989 only - Sep 3 0:00 0 S -Rule Zion 1990 only - Mar 25 0:00 1:00 D -Rule Zion 1990 only - Aug 26 0:00 0 S -Rule Zion 1991 only - Mar 24 0:00 1:00 D -Rule Zion 1991 only - Sep 1 0:00 0 S -Rule Zion 1992 only - Mar 29 0:00 1:00 D -Rule Zion 1992 only - Sep 6 0:00 0 S -Rule Zion 1993 only - Apr 2 0:00 1:00 D -Rule Zion 1993 only - Sep 5 0:00 0 S +# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S +Rule Zion 1989 only - Apr 30 0:00 1:00 D +Rule Zion 1989 only - Sep 3 0:00 0:00 S +Rule Zion 1990 only - Mar 25 0:00 1:00 D +Rule Zion 1990 only - Aug 26 0:00 0:00 S +Rule Zion 1991 only - Mar 24 0:00 1:00 D +Rule Zion 1991 only - Sep 1 0:00 0:00 S +Rule Zion 1992 only - Mar 29 0:00 1:00 D +Rule Zion 1992 only - Sep 6 0:00 0:00 S +Rule Zion 1993 only - Apr 2 0:00 1:00 D +Rule Zion 1993 only - Sep 5 0:00 0:00 S # The dates for 1994-1995 were obtained from Office of the Spokeswoman for the # Ministry of Interior, Jerusalem, Israel. The spokeswoman can be reached by -# calling the switchboard at 972-2-701411 and asking for the spokeswoman. +# calling the office directly at 972-2-6701447 or 972-2-6701448. -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Zion 1994 only - Apr 1 0:00 1:00 D -Rule Zion 1994 only - Aug 28 0:00 0 S -Rule Zion 1995 only - Mar 31 0:00 1:00 D -Rule Zion 1995 only - Sep 3 0:00 0 S - -# The dates for 1996-1998 were also obtained from Office of the Spokeswoman -# for the Ministry of Interior, Jerusalem, Israel. The official announcement -# can be viewed (in Hebrew) at the following URL: +# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S +Rule Zion 1994 only - Apr 1 0:00 1:00 D +Rule Zion 1994 only - Aug 28 0:00 0:00 S +Rule Zion 1995 only - Mar 31 0:00 1:00 D +Rule Zion 1995 only - Sep 3 0:00 0:00 S + +# The dates for 1996 were determined by the Minister of Interior of the +# time, Haim Ramon. The official announcement regarding 1996-1998 +# (with the dates for 1997 no longer being relevant) can be viewed at: # -# ftp://ftp.huji.ac.il/pub/misc/timezones/announcements/1996-1998.ps.gz +# ftp://ftp.huji.ac.il/pub/tz/announcements/1996-1998.ramon.ps.gz # -# Caveat emptor: The dates for the years 1996-1998 were originally announced -# on 1995-08-31, by the previous Minister of Interior. The new Minister -# of Interior changed the dates on 1996-01-01, to take into account the -# desires of certain portions of Israeli society (the next election is in the -# Fall of 1996). After this (1996) year's Daylight Savings Time is over, the -# new minister has announced that a study will be conducted as to the wishes of -# the populace regarding the length of Daylight Savings Time and the Interior -# Committee will meet to review the results of the study and make any necessary -# changes to the 1997-1998 dates. Never a dull moment in the State of Israel. - -# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -Rule Zion 1996 1998 - Mar Fri>=14 0:00 1:00 D -Rule Zion 1996 only - Sep 16 0:00 0 S -Rule Zion 1997 1998 - Oct Sun>=14 0:00 0 S +# The dates for 1997 were altered by his successor, Rabbi Eli Suissa. +# No changes have been made regarding 1998 as of yet. +# +# The official announcement for the year 1997 can be viewed at: +# +# ftp://ftp.huji.ac.il/pub/tz/announcements/1997.ps.gz + +# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S +Rule Zion 1996 only - Mar 15 0:00 1:00 D +Rule Zion 1996 only - Sep 16 0:00 0:00 S +Rule Zion 1997 only - Mar 21 0:00 1:00 D +Rule Zion 1997 only - Sep 14 0:00 0:00 S +Rule Zion 1998 only - Mar 20 0:00 1:00 D +Rule Zion 1998 only - Oct 18 0:00 0:00 S + +# These rules are probably wrong, but they are close approximations (usually +# within a few weeks): + +# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S +Rule Zion 1999 only - Apr 11 0:00 1:00 D +Rule Zion 1999 only - Sep 5 0:00 0:00 S +Rule Zion 2000 only - Apr 30 0:00 1:00 D +Rule Zion 2000 only - Sep 24 0:00 0:00 S +Rule Zion 2001 only - Apr 15 0:00 1:00 D +Rule Zion 2001 only - Sep 9 0:00 0:00 S +Rule Zion 2002 only - Apr 7 0:00 1:00 D +Rule Zion 2002 only - Sep 1 0:00 0:00 S +Rule Zion 2003 only - Apr 27 0:00 1:00 D +Rule Zion 2003 only - Sep 21 0:00 0:00 S +Rule Zion 2004 only - Apr 18 0:00 1:00 D +Rule Zion 2004 only - Sep 12 0:00 0:00 S +Rule Zion 2005 only - May 1 0:00 1:00 D +Rule Zion 2005 only - Sep 25 0:00 0:00 S +Rule Zion 2006 only - Apr 23 0:00 1:00 D +Rule Zion 2006 only - Sep 17 0:00 0:00 S +Rule Zion 2007 only - Apr 15 0:00 1:00 D +Rule Zion 2007 only - Sep 9 0:00 0:00 S +Rule Zion 2008 only - Apr 27 0:00 1:00 D +Rule Zion 2008 only - Sep 21 0:00 0:00 S +Rule Zion 2009 only - Apr 19 0:00 1:00 D +Rule Zion 2009 only - Sep 13 0:00 0:00 S # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Jerusalem 2:20:56 - LMT 1880 diff --git a/time/ialloc.c b/time/ialloc.c index 5631947d07..8a0c701578 100644 --- a/time/ialloc.c +++ b/time/ialloc.c @@ -1,6 +1,6 @@ #ifndef lint #ifndef NOID -static char elsieid[] = "@(#)ialloc.c 8.28"; +static char elsieid[] = "@(#)ialloc.c 8.29"; #endif /* !defined NOID */ #endif /* !defined lint */ @@ -10,13 +10,6 @@ static char elsieid[] = "@(#)ialloc.c 8.28"; #define nonzero(n) (((n) == 0) ? 1 : (n)) -char * icalloc P((int nelem, int elsize)); -char * icatalloc P((char * old, const char * new)); -char * icpyalloc P((const char * string)); -char * imalloc P((int n)); -void * irealloc P((void * pointer, int size)); -void ifree P((char * pointer)); - char * imalloc(n) const int n; diff --git a/time/private.h b/time/private.h index f81bf4867b..5a5b516d0f 100644 --- a/time/private.h +++ b/time/private.h @@ -4,7 +4,7 @@ /* ** This file is in the public domain, so clarified as of -** June 5, 1996 by Arthur David Olson (arthur_david_olson@nih.gov). +** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). */ /* @@ -21,7 +21,7 @@ #ifndef lint #ifndef NOID -static char privatehid[] = "@(#)private.h 7.43"; +static char privatehid[] = "@(#)private.h 7.45"; #endif /* !defined NOID */ #endif /* !defined lint */ @@ -173,6 +173,19 @@ extern int errno; #endif /* !defined errno */ /* +** Private function declarations. +*/ +char * icalloc P((int nelem, int elsize)); +char * icatalloc P((char * old, const char * new)); +char * icpyalloc P((const char * string)); +char * imalloc P((int n)); +void * irealloc P((void * pointer, int size)); +void icfree P((char * pointer)); +void ifree P((char * pointer)); +char * scheck P((const char *string, char *format)); + + +/* ** Finally, some convenience items. */ diff --git a/time/scheck.c b/time/scheck.c index 64f25076ed..b51f58d042 100644 --- a/time/scheck.c +++ b/time/scheck.c @@ -1,6 +1,6 @@ #ifndef lint #ifndef NOID -static char elsieid[] = "@(#)scheck.c 8.13"; +static char elsieid[] = "@(#)scheck.c 8.14"; #endif /* !defined lint */ #endif /* !defined NOID */ @@ -8,9 +8,6 @@ static char elsieid[] = "@(#)scheck.c 8.13"; #include "private.h" -extern char * imalloc P((int n)); -extern void ifree P((char * p)); - char * scheck(string, format) const char * const string; diff --git a/time/tzfile.c b/time/tzfile.c index 94b8a3c8fe..44b33cb02c 100644 --- a/time/tzfile.c +++ b/time/tzfile.c @@ -120,7 +120,7 @@ __tzfile_read (const char *file) and which is not the system wide default TZDEFAULT. */ if (__libc_enable_secure && ((*file == '/' - && memcmp (file, TZDEFAULT, sizeof (TZDEFAULT) - 1) + && memcmp (file, TZDEFAULT, sizeof TZDEFAULT) && memcmp (file, default_tzdir, sizeof (default_tzdir) - 1)) || strstr (file, "../") != NULL)) /* This test is certainly a bit too restrictive but it should diff --git a/time/tzselect.ksh b/time/tzselect.ksh index 33bdbc7431..031cda1de6 100644 --- a/time/tzselect.ksh +++ b/time/tzselect.ksh @@ -11,23 +11,20 @@ # you can use either of the following free programs instead: # # Bourne-Again shell (bash) -# <URL:ftp://prep.ai.mit.edu:/pub/gnu/bash-2.0.tar.gz> -# (or any later version) +# <URL:ftp://ftp.gnu.ai.mit.edu/pub/gnu/> # # Public domain ksh -# <URL:ftp://ftp.cs.mun.ca:/pub/pdksh/pdksh.tar.gz> +# <URL:ftp://ftp.cs.mun.ca/pub/pdksh/pdksh.tar.gz> # # This script also uses several features of modern awk programs. # If your host lacks awk, or has an old awk that does not conform to Posix.2, # you can use either of the following free programs instead: # # GNU awk (gawk) -# <URL:ftp://prep.ai.mit.edu:/pub/gnu/gawk-3.0.2.tar.gz> -# (or any later version) +# <URL:ftp://ftp.gnu.ai.mit.edu/pub/gnu/> # # mawk -# <URL:ftp://oxy.edu/public/mawk1.2.2.tar.gz> -# (or any later version) +# <URL:ftp://ftp.whidbey.net/pub/brennan/> # Specify default values for environment variables if they are unset. @@ -57,7 +54,7 @@ newline=' IFS=$newline -# Work around a bash bug, where $PS3 is sent to stdout. +# Work around a bug in bash 1.14.7 and earlier, where $PS3 is sent to stdout. case $(echo 1 | (select x in x; do break; done) 2>/dev/null) in ?*) PS3= esac diff --git a/time/zdump.c b/time/zdump.c index e5ed82f104..01c79ca7fb 100644 --- a/time/zdump.c +++ b/time/zdump.c @@ -1,6 +1,6 @@ #ifndef lint #ifndef NOID -static char elsieid[] = "@(#)zdump.c 7.25"; +static char elsieid[] = "@(#)zdump.c 7.26"; #endif /* !defined NOID */ #endif /* !defined lint */ @@ -111,19 +111,28 @@ static char elsieid[] = "@(#)zdump.c 7.25"; #define TZ_DOMAIN "tz" #endif /* !defined TZ_DOMAIN */ +#ifndef P +#ifdef __STDC__ +#define P(x) x +#endif /* defined __STDC__ */ +#ifndef __STDC__ +#define P(x) () +#endif /* !defined __STDC__ */ +#endif /* !defined P */ + extern char ** environ; -extern int getopt(); +extern int getopt P((int argc, char * const argv[], + const char * options)); extern char * optarg; extern int optind; -extern time_t time(); extern char * tzname[2]; -static char * abbr(); -static long delta(); -static time_t hunt(); -static int longest; +static char * abbr P((struct tm * tmp)); +static long delta P((struct tm * newp, struct tm * oldp)); +static time_t hunt P((char * name, time_t lot, time_t hit)); +static size_t longest; static char * progname; -static void show(); +static void show P((char * zone, time_t t, int v)); int main(argc, argv) @@ -191,8 +200,7 @@ _("%s: usage is %s [ -v ] [ -c cutoff ] zonename ...\n"), fakeenv = (char **) malloc((size_t) ((i + 2) * sizeof *fakeenv)); if (fakeenv == NULL || - (fakeenv[0] = (char *) malloc((size_t) (longest + - 4))) == NULL) { + (fakeenv[0] = (char *) malloc(longest + 4)) == NULL) { (void) perror(progname); (void) exit(EXIT_FAILURE); } @@ -326,8 +334,6 @@ struct tm * oldp; return result; } -extern struct tm * localtime(); - static void show(zone, t, v) char * zone; @@ -336,7 +342,7 @@ int v; { struct tm * tmp; - (void) printf("%-*s ", longest, zone); + (void) printf("%-*s ", (int) longest, zone); if (v) (void) printf("%.24s GMT = ", asctime(gmtime(&t))); tmp = localtime(&t); diff --git a/time/zic.c b/time/zic.c index c4c9a3ae25..b9518c4649 100644 --- a/time/zic.c +++ b/time/zic.c @@ -1,6 +1,6 @@ #ifndef lint #ifndef NOID -static char elsieid[] = "@(#)zic.c 7.82"; +static char elsieid[] = "@(#)zic.c 7.83"; #endif /* !defined NOID */ #endif /* !defined lint */ @@ -79,15 +79,9 @@ struct zone { extern int getopt P((int argc, char * const argv[], const char * options)); -extern char * icatalloc P((char * old, const char * new)); -extern char * icpyalloc P((const char * string)); -extern void ifree P((char * p)); -extern char * imalloc P((int n)); -extern void * irealloc P((void * old, int n)); extern int link P((const char * fromname, const char * toname)); extern char * optarg; extern int optind; -extern char * scheck P((const char * string, const char * format)); static void addtt P((time_t starttime, int type)); static int addtype P((long gmtoff, const char * abbr, int isdst, @@ -1289,6 +1283,8 @@ const char * const timep; } rp->r_yrtype = ecpyalloc(typep); } + if (rp->r_loyear < min_year && rp->r_loyear > 0) + min_year = rp->r_loyear; /* ** Day work. ** Accept things such as: @@ -1397,8 +1393,10 @@ const char * const name; toi = 0; fromi = 0; + while (fromi < timecnt && attypes[fromi].at < min_time) + ++fromi; if (isdsts[0] == 0) - while (attypes[fromi].type == 0) + while (fromi < timecnt && attypes[fromi].type == 0) ++fromi; /* handled by default rule */ for ( ; fromi < timecnt; ++fromi) { if (toi != 0 @@ -1723,8 +1721,22 @@ error(_("can't determine time zone abbreviation to use just after until time")); static void addtt(starttime, type) const time_t starttime; -const int type; +int type; { + if (starttime <= min_time || + (timecnt == 1 && attypes[0].at < min_time)) { + gmtoffs[0] = gmtoffs[type]; + isdsts[0] = isdsts[type]; + ttisstds[0] = ttisstds[type]; + ttisgmts[0] = ttisgmts[type]; + if (abbrinds[type] != 0) + (void) strcpy(chars, &chars[abbrinds[type]]); + abbrinds[0] = 0; + charcnt = strlen(chars) + 1; + typecnt = 1; + timecnt = 0; + type = 0; + } if (timecnt >= TZ_MAX_TIMES) { error(_("too many transitions?!")); (void) exit(EXIT_FAILURE); @@ -2130,7 +2142,7 @@ char * const argname; ** created by some other multiprocessor, so we get ** to do extra checking. */ - if (mkdir(name, 0755) != 0) { + if (mkdir(name, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) != 0) { const char *e = strerror(errno); if (errno != EEXIST || !itsdir(name)) { diff --git a/time/zone.tab b/time/zone.tab index 6d91b4ea6c..074749916a 100644 --- a/time/zone.tab +++ b/time/zone.tab @@ -34,7 +34,7 @@ AQ -9000+00000 Antarctica/South_Pole Amundsen-Scott Station, South Pole AQ -6448-06406 Antarctica/Palmer Palmer Station, Anvers Island AQ -6736+06253 Antarctica/Mawson Mawson Station, Holme Bay AQ -6617+11031 Antarctica/Casey Casey Station, Bailey Peninsula -AQ -6040+14001 Antarctica/DumontDUrville Dumont-d'Urville Base, Terre Adelie +AQ -6640+14001 Antarctica/DumontDUrville Dumont-d'Urville Base, Terre Adelie AR -3436-05827 America/Buenos_Aires E Argentina (BA, DF, SC, TF) AR -3257-06040 America/Rosario NE Argentina (SF, ER, CN, MN, CC, FM, LP, CH) AR -3124-06411 America/Cordoba W Argentina (CB, SA, TM, LR, SJ, SL, NQ, RN) |