diff options
author | Jakub Jelinek <jakub@redhat.com> | 2005-11-15 08:22:03 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2005-11-15 08:22:03 +0000 |
commit | 22d7fbdbae4032639461a7a081762a05deee0529 (patch) | |
tree | ff70bd4613f1f05823b2417b2687449d73ac45b0 /sysdeps | |
parent | 1beea155aecf2e7d6bfa1399b7c0f4f53dde408c (diff) |
Updated to fedora-glibc-20051115T0809
Diffstat (limited to 'sysdeps')
100 files changed, 2519 insertions, 2078 deletions
diff --git a/sysdeps/generic/check_fds.c b/sysdeps/generic/check_fds.c index 5ae3feee3e..10ba3da395 100644 --- a/sysdeps/generic/check_fds.c +++ b/sysdeps/generic/check_fds.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 2000, 2002, 2003, 2005 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 @@ -44,12 +44,26 @@ check_one_fd (int fd, int mode) if (__builtin_expect (__libc_fcntl (fd, F_GETFD), 0) == -1 && errno == EBADF) { - struct stat64 st; + const char *name; + dev_t dev; + + /* For writable descriptors we use /dev/full. */ + if ((mode & O_ACCMODE) == O_WRONLY) + { + name = _PATH_DEV "full"; + dev = makedev (DEV_FULL_MAJOR, DEV_FULL_MINOR); + } + else + { + name = _PATH_DEVNULL; + dev = makedev (DEV_NULL_MAJOR, DEV_NULL_MINOR); + } /* Something is wrong with this descriptor, it's probably not opened. Open /dev/null so that the SUID program we are about to start does not accidently use this descriptor. */ - int nullfd = open_not_cancel (_PATH_DEVNULL, mode, 0); + int nullfd = open_not_cancel (name, mode, 0); + /* We are very paranoid here. With all means we try to ensure that we are actually opening the /dev/null device and nothing else. @@ -57,13 +71,11 @@ check_one_fd (int fd, int mode) Note that the following code assumes that STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO are the three lowest file decsriptor numbers, in this order. */ + struct stat64 st; if (__builtin_expect (nullfd != fd, 0) || __builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) != 0 || __builtin_expect (S_ISCHR (st.st_mode), 1) == 0 -#if defined DEV_NULL_MAJOR && defined DEV_NULL_MINOR - || st.st_rdev != makedev (DEV_NULL_MAJOR, DEV_NULL_MINOR) -#endif - ) + || st.st_rdev != dev) /* We cannot even give an error message here since it would run into the same problems. */ while (1) @@ -84,7 +96,7 @@ __libc_check_standard_fds (void) # define O_NOFOLLOW 0 #endif /* Check all three standard file descriptors. */ - check_one_fd (STDIN_FILENO, O_RDONLY | O_NOFOLLOW); - check_one_fd (STDOUT_FILENO, O_RDWR | O_NOFOLLOW); - check_one_fd (STDERR_FILENO, O_RDWR | O_NOFOLLOW); + check_one_fd (STDIN_FILENO, O_WRONLY | O_NOFOLLOW); + check_one_fd (STDOUT_FILENO, O_RDONLY | O_NOFOLLOW); + check_one_fd (STDERR_FILENO, O_RDONLY | O_NOFOLLOW); } diff --git a/sysdeps/generic/errlist.c b/sysdeps/generic/errlist.c index 6b459ee40a..6a834fc329 100644 --- a/sysdeps/generic/errlist.c +++ b/sysdeps/generic/errlist.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1994, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1994, 1997, 2005 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 @@ -18,10 +18,6 @@ #include <stddef.h> -#ifndef HAVE_GNU_LD -#define _sys_errlist sys_errlist -#define _sys_nerr sys_nerr -#endif const char *const _sys_errlist[] = { diff --git a/sysdeps/unix/bsd/sun/sunos4/tcsetattr.c b/sysdeps/generic/fchownat.c index 934c4c8cf8..f6921c9012 100644 --- a/sysdeps/unix/bsd/sun/sunos4/tcsetattr.c +++ b/sysdeps/generic/fchownat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1996, 1997, 2002 Free Software Foundation, Inc. +/* Copyright (C) 2005 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 @@ -17,34 +17,35 @@ 02111-1307 USA. */ #include <errno.h> -#include <termios.h> -#include <sys/ioctl.h> +#include <fcntl.h> +#include <stddef.h> +#include <unistd.h> +#include <sys/types.h> -/* Set the state of FD to *TERMIOS_P. */ +/* Change the owner and group of FILE. */ int -tcsetattr (fd, optional_actions, termios_p) +fchownat (fd, file, owner, group, flag) int fd; - int optional_actions; - const struct termios *termios_p; + const char *file; + uid_t owner; + gid_t group; + int flag; { - unsigned long cmd; - - switch (optional_actions) + if (file == NULL || (flag & ~AT_SYMLINK_NOFOLLOW) != 0) { - case TCSANOW: - cmd = TCSETS; - break; - case TCSADRAIN: - cmd = TCSETSW; - break; - case TCSAFLUSH: - cmd = TCSETSF; - break; - default: __set_errno (EINVAL); return -1; } - return __ioctl (fd, cmd, termios_p); + if (fd < 0 && fd != AT_FDCWD) + { + __set_errno (EBADF); + return -1; + } + + __set_errno (ENOSYS); + return -1; } -libc_hidden_def (tcsetattr) +stub_warning (fchownat) + +#include <stub-tag.h> diff --git a/sysdeps/unix/bsd/sun/sunos4/tcsendbrk.c b/sysdeps/generic/futimesat.c index db5ea8c831..33d170862a 100644 --- a/sysdeps/unix/bsd/sun/sunos4/tcsendbrk.c +++ b/sysdeps/generic/futimesat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1997 Free Software Foundation, Inc. +/* Copyright (C) 2005 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 @@ -17,16 +17,36 @@ 02111-1307 USA. */ #include <errno.h> -#include <termios.h> -#include <sys/ioctl.h> -#include <sys/termio.h> /* Sun header file. */ +#include <fcntl.h> +#include <stddef.h> +#include <sys/time.h> -/* Send zero bits on FD. */ + +/* Change the access time of FILE relative to FD to TVP[0] and + the modification time of FILE to TVP[1]. */ int -tcsendbreak (fd, duration) +futimesat (fd, file, tvp) int fd; - int duration; + const char *file; + const struct timeval tvp[2]; { - /* According to SunOS 4.1's termios(4), you can't specify a duration. */ - return __ioctl (fd, TCSBRK, 0); + if (fd < 0 && fd != AT_FDCWD) + { + __set_errno (EBADF); + return -1; + } + + if (file == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; } + +weak_alias (__utimes, utimes) + +stub_warning (utimes) +#include <stub-tag.h> diff --git a/sysdeps/generic/fxstatat.c b/sysdeps/generic/fxstatat.c new file mode 100644 index 0000000000..62f7fe3efb --- /dev/null +++ b/sysdeps/generic/fxstatat.c @@ -0,0 +1,49 @@ +/* Copyright (C) 2005 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <errno.h> +#include <fcntl.h> +#include <stddef.h> +#include <sys/stat.h> + +/* Get information about the file descriptor FD in BUF. */ +int +__fxstatat (int vers, int fd, const char *filename, struct stat *buf, int flag) +{ + if (vers != _STAT_VER) + { + __set_errno (EINVAL); + return -1; + } + + if (fd < 0 && fd != AT_FDCWD) + { + __set_errno (EBADF); + return -1; + } + if (buf == NULL || (flag & ~AT_SYMLINK_NOFOLLOW) != 0) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (fstatat) +#include <stub-tag.h> diff --git a/sysdeps/generic/fxstatat64.c b/sysdeps/generic/fxstatat64.c new file mode 100644 index 0000000000..ba95b73e81 --- /dev/null +++ b/sysdeps/generic/fxstatat64.c @@ -0,0 +1,50 @@ +/* Copyright (C) 2005 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <errno.h> +#include <fcntl.h> +#include <stddef.h> +#include <sys/stat.h> + +/* Get information about the file descriptor FD in BUF. */ +int +__fxstatat64 (int vers, int fd, const char *filename, struct stat64 *buf, + int flag) +{ + if (vers != _STAT_VER) + { + __set_errno (EINVAL); + return -1; + } + + if (fd < 0 && fd != AT_FDCWD) + { + __set_errno (EBADF); + return -1; + } + if (buf == NULL || (flag & ~AT_SYMLINK_NOFOLLOW) != 0) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (fstatat64) +#include <stub-tag.h> diff --git a/sysdeps/generic/getenv.c b/sysdeps/generic/getenv.c index d659f66022..6cdfe2b266 100644 --- a/sysdeps/generic/getenv.c +++ b/sysdeps/generic/getenv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,92,94,96,98,99,2002 Free Software Foundation, Inc. +/* Copyright (C) 1991,92,94,96,98,99,2002,2005 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 @@ -23,9 +23,6 @@ #include <string.h> #include <unistd.h> -#ifndef HAVE_GNU_LD -#define __environ environ -#endif /* Return the value of the environment variable NAME. This implementation is tuned a bit in that it assumes no environment variable has an empty diff --git a/sysdeps/generic/getgroups.c b/sysdeps/generic/getgroups.c index d9970f0e6d..d5868cc1b8 100644 --- a/sysdeps/generic/getgroups.c +++ b/sysdeps/generic/getgroups.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1995, 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1991,1992,1995,1996,1997,2005 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 @@ -40,7 +40,7 @@ __getgroups (size, list) return -1; } -#if defined (HAVE_GNU_LD) && !(defined (NGROUPS_MAX) && NGROUPS_MAX == 0) +#if !(defined (NGROUPS_MAX) && NGROUPS_MAX == 0) stub_warning (getgroups); #endif diff --git a/sysdeps/generic/init-posix.c b/sysdeps/generic/init-posix.c index ae9e1075d1..0c2b717e6d 100644 --- a/sysdeps/generic/init-posix.c +++ b/sysdeps/generic/init-posix.c @@ -1,27 +1 @@ -/* Copyright (C) 1991, 1995, 1997 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef HAVE_GNU_LD - -void -__init_posix (void) -{ - return; -} - -#endif +/* Nothing to do. */ diff --git a/sysdeps/generic/libc-tls.c b/sysdeps/generic/libc-tls.c index bfb6de0f73..3544e396da 100644 --- a/sysdeps/generic/libc-tls.c +++ b/sysdeps/generic/libc-tls.c @@ -60,8 +60,9 @@ bool _dl_tls_dtv_gaps; struct dtv_slotinfo_list *_dl_tls_dtv_slotinfo_list; /* Number of modules in the static TLS block. */ size_t _dl_tls_static_nelem; -/* Size of the static TLS block. */ -size_t _dl_tls_static_size; +/* Size of the static TLS block. Giving this initialized value + preallocates some surplus bytes in the static TLS area. */ +size_t _dl_tls_static_size = 2048; /* Size actually allocated in the static TLS block. */ size_t _dl_tls_static_used; /* Alignment requirement of the static TLS block. */ diff --git a/sysdeps/generic/openat.c b/sysdeps/generic/openat.c new file mode 100644 index 0000000000..f3f699ca23 --- /dev/null +++ b/sysdeps/generic/openat.c @@ -0,0 +1,69 @@ +/* Copyright (C) 2005 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <errno.h> +#include <fcntl.h> +#include <stdarg.h> +#include <stddef.h> +#include <sys/stat.h> + +/* Open FILE with access OFLAG. Interpret relative paths relative to + the directory associated with FD. If OFLAG includes O_CREAT, a + third argument is the file protection. */ +int +openat (fd, file, oflag) + int fd; + const char *file; + int oflag; +{ + int mode; + + if (file == NULL) + { + __set_errno (EINVAL); + return -1; + } + + if (fd != AT_FDCWD && file[0] != '/') + { + /* Check FD is associated with a directory. */ + struct stat64 st; + if (__fxstat64 (_STAT_VER, fd, &st) != 0) + return -1; + + if (!S_ISDIR (st.st_mode)) + { + __set_errno (ENOTDIR); + return -1; + } + } + + if (oflag & O_CREAT) + { + va_list arg; + va_start (arg, oflag); + mode = va_arg (arg, int); + va_end (arg); + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (openat) + +#include <stub-tag.h> diff --git a/sysdeps/generic/openat64.c b/sysdeps/generic/openat64.c new file mode 100644 index 0000000000..87952d38d6 --- /dev/null +++ b/sysdeps/generic/openat64.c @@ -0,0 +1,69 @@ +/* Copyright (C) 2005 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <errno.h> +#include <fcntl.h> +#include <stdarg.h> +#include <stddef.h> +#include <sys/stat.h> + +/* Open FILE with access OFLAG. Interpret relative paths relative to + the directory associated with FD. If OFLAG includes O_CREAT, a + third argument is the file protection. */ +int +openat64 (fd, file, oflag) + int fd; + const char *file; + int oflag; +{ + int mode; + + if (file == NULL) + { + __set_errno (EINVAL); + return -1; + } + + if (fd != AT_FDCWD && file[0] != '/') + { + /* Check FD is associated with a directory. */ + struct stat64 st; + if (__fxstat64 (_STAT_VER, fd, &st) != 0) + return -1; + + if (!S_ISDIR (st.st_mode)) + { + __set_errno (ENOTDIR); + return -1; + } + } + + if (oflag & O_CREAT) + { + va_list arg; + va_start (arg, oflag); + mode = va_arg (arg, int); + va_end (arg); + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (openat64) + +#include <stub-tag.h> diff --git a/sysdeps/unix/bsd/sun/sunos4/tcflow.c b/sysdeps/generic/renameat.c index 6fcc606f61..e8629098df 100644 --- a/sysdeps/unix/bsd/sun/sunos4/tcflow.c +++ b/sysdeps/generic/renameat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1997 Free Software Foundation, Inc. +/* Copyright (C) 2005 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 @@ -17,14 +17,34 @@ 02111-1307 USA. */ #include <errno.h> -#include <termios.h> -#include <sys/ioctl.h> +#include <fcntl.h> +#include <stdio.h> -/* Suspend or restart transmission on FD. */ + +/* Rename the file OLD relative to OLDFD to NEW relative to NEWFD. */ int -tcflow (fd, action) - int fd; - int action; +renameat (oldfd, old, newfd, new) + int oldfd; + const char *old; + int newfd; + const char *new; { - return __ioctl (fd, TCXONC, action); + if ((oldfd < 0 & oldfd !_ AT_FDCWD) || (newfd < 0 && newfd != AT_FDCWD)) + { + __set_errno (EBADF); + return -1; + } + + if (old == NULL || new == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; } + + +stub_warning (renameat) +#include <stub-tag.h> diff --git a/sysdeps/unix/bsd/sun/sunos4/tcgetattr.c b/sysdeps/generic/unlinkat.c index ab74fddf24..f9a08b9903 100644 --- a/sysdeps/unix/bsd/sun/sunos4/tcgetattr.c +++ b/sysdeps/generic/unlinkat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc. +/* Copyright (C) 2005 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 @@ -17,17 +17,33 @@ 02111-1307 USA. */ #include <errno.h> +#include <fcntl.h> #include <stddef.h> -#include <termios.h> -#include <sys/ioctl.h> +#include <unistd.h> -/* Put the state of FD into *TERMIOS_P. */ + +/* Remove the link named NAME. */ int -__tcgetattr (fd, termios_p) +unlinkat (fd, name, flag) int fd; - struct termios *termios_p; + const char *name; + int flag; { - return __ioctl (fd, TCGETS, termios_p); + if (name == NULL || (flag & AT_REMOVEDIR) != 0) + { + __set_errno (EINVAL); + return -1; + } + + if (fd < 0 && fd != AT_FDCWD) + { + __set_errno (EBADF); + return -1; + } + + __set_errno (ENOSYS); + return -1; } +stub_warning (unlinkat) -weak_alias (__tcgetattr, tcgetattr) +#include <stub-tag.h> diff --git a/sysdeps/i386/configure b/sysdeps/i386/configure index ecba16645b..d1d4dc15a7 100755 --- a/sysdeps/i386/configure +++ b/sysdeps/i386/configure @@ -52,6 +52,3 @@ if test $libc_cv_cpp_asm_debuginfo = yes; then _ACEOF fi - -# Tell top-level configure to try -mtune=i386. -libc_mtune_example=i386 diff --git a/sysdeps/i386/configure.in b/sysdeps/i386/configure.in index 93b62b671c..028e1ae8e1 100644 --- a/sysdeps/i386/configure.in +++ b/sysdeps/i386/configure.in @@ -33,6 +33,3 @@ rm -f conftest*])AC_SUBST(libc_cv_cpp_asm_debuginfo) if test $libc_cv_cpp_asm_debuginfo = yes; then AC_DEFINE(HAVE_CPP_ASM_DEBUGINFO) fi - -# Tell top-level configure to try -mtune=i386. -libc_mtune_example=i386 diff --git a/sysdeps/ia64/elf/initfini.c b/sysdeps/ia64/elf/initfini.c index 3aa44de8f1..d0a65ece80 100644 --- a/sysdeps/ia64/elf/initfini.c +++ b/sysdeps/ia64/elf/initfini.c @@ -1,5 +1,5 @@ /* Special .init and .fini section support for ia64. - Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 2000, 2002, 2003, 2005 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 @@ -51,7 +51,6 @@ __asm__ ("\n\n" "\n" "/*@_init_PROLOG_BEGINS*/\n"); -#ifdef HAVE_INITFINI_ARRAY /* If we have working .init_array support, we want to keep the .init section empty (apart from the mandatory prologue/epilogue. This @@ -75,7 +74,6 @@ gmon_initializer (void) __asm__ (".section .init_array, \"aw\"\n" "\tdata8 @fptr(gmon_initializer)\n"); -#endif __asm__ (".section .init\n" " .global _init#\n" @@ -90,27 +88,7 @@ __asm__ (".section .init\n" " mov r33 = b0\n" " .body\n" " adds r12 = -16, r12\n" -#ifdef HAVE_INITFINI_ARRAY " ;;\n" /* see gmon_initializer() above */ -#else -" .weak __gmon_start__#\n" -" addl r14 = @ltoff(@fptr(__gmon_start__#)), gp\n" -" ;;\n" -" ld8 r15 = [r14]\n" -" ;;\n" -" cmp.eq p6, p7 = 0, r15\n" -" (p6) br.cond.dptk .L5\n" -"\n" -"/* we could use r35 to save gp, but we use the stack since that's what\n" -" * all the other init routines will do --davidm 00/04/05 */\n" -" st8 [r12] = gp, -16\n" -" br.call.sptk.many b0 = __gmon_start__# ;;\n" -" adds r12 = 16, r12\n" -" ;;\n" -" ld8 gp = [r12]\n" -" ;;\n" -".L5:\n" -#endif " .endp _init#\n" "\n" "/*@_init_PROLOG_ENDS*/\n" diff --git a/sysdeps/ia64/fpu/libm-symbols.h b/sysdeps/ia64/fpu/libm-symbols.h index 3d0eb37d2a..5b5e4b7d7b 100644 --- a/sysdeps/ia64/fpu/libm-symbols.h +++ b/sysdeps/ia64/fpu/libm-symbols.h @@ -39,13 +39,13 @@ #define WEAK_LIBM_ENTRY(name) \ .align 32; \ - LOCAL_LIBM_ENTRY(name); \ + LOCAL_LIBM_ENTRY(__##name); \ .global __##name; \ __##name: #define WEAK_LIBM_END(name) \ weak_alias (__##name, name); \ .hidden __##name; \ - LOCAL_LIBM_END(name); \ + LOCAL_LIBM_END(__##name); \ ASM_SIZE_DIRECTIVE(__##name); \ ASM_TYPE_DIRECTIVE(__##name, @function) diff --git a/sysdeps/mach/hurd/bits/stat.h b/sysdeps/mach/hurd/bits/stat.h index 172bc5ea8e..c3f96660cc 100644 --- a/sysdeps/mach/hurd/bits/stat.h +++ b/sysdeps/mach/hurd/bits/stat.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 93, 94, 96, 97, 99, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1992,93,94,96,97,99,2000,2005 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 @@ -182,8 +182,11 @@ struct stat64 /* All the bits relevant to translators */ #define S_ITRANS 000070000000 +/* Definitely no mmaps to this. */ +#define S_IMMAP0 000100000000 + /* ALL the unused bits. */ -#define S_ISPARE (~(S_IFMT|S_ITRANS|S_INOCACHE| \ +#define S_ISPARE (~(S_IFMT|S_ITRANS|S_INOCACHE|S_IMMAP0| \ S_IUSEUNK|S_IUNKNOWN|07777)) #endif diff --git a/sysdeps/mach/hurd/getpeername.c b/sysdeps/mach/hurd/getpeername.c index 39071c1da4..325b6fd75d 100644 --- a/sysdeps/mach/hurd/getpeername.c +++ b/sysdeps/mach/hurd/getpeername.c @@ -55,11 +55,14 @@ __getpeername (int fd, __SOCKADDR_ARG addrarg, socklen_t *len) } const sa_family_t family = type; - if (*len < (char *) (&addr->sa_family + 1) - (char *) addr) - memcpy (&addr->sa_family, &family, - *len - offsetof (struct sockaddr, sa_family)); - else - addr->sa_family = family; + if (*len > offsetof (struct sockaddr, sa_family)) + { + if (*len < (char *) (&addr->sa_family + 1) - (char *) addr) + memcpy (&addr->sa_family, &family, + *len - offsetof (struct sockaddr, sa_family)); + else + addr->sa_family = family; + } return 0; } diff --git a/sysdeps/mach/hurd/ioctl.c b/sysdeps/mach/hurd/ioctl.c index 3d590d5845..6a540241a4 100644 --- a/sysdeps/mach/hurd/ioctl.c +++ b/sysdeps/mach/hurd/ioctl.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1992,93,94,95,96,97,99,2000,02 Free Software Foundation, Inc. +/* Copyright (C) 1992,93,94,95,96,97,99,2000,2002,2005 + 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 @@ -136,9 +137,11 @@ __ioctl (int fd, unsigned long int request, ...) Rather than pointing to the value, ARG is the value itself. */ #ifdef MACH_MSG_TYPE_BIT *t++ = io2mach_type (1, _IOTS (integer_t)); - *((integer_t *) t)++ = (integer_t) arg; + *(integer_t *) t = (integer_t) arg; + t = (void *) t + sizeof (integer_t); #else - *((integer_t *) p)++ = (integer_t) arg; + *(integer_t *) p = (integer_t) arg; + p = (void *) p + sizeof (integer_t); #endif } diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index 934aae009c..81a56a0794 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -568,12 +568,14 @@ gaih_inet (const char *name, const struct gaih_service *service, if (at->family == AF_UNSPEC) { - char *namebuf = strdupa (name); - char *scope_delim; + char *namebuf = (char *) name; + char *scope_delim = strchr (name, SCOPE_DELIMITER); - scope_delim = strchr (namebuf, SCOPE_DELIMITER); - if (scope_delim != NULL) - *scope_delim = '\0'; + if (__builtin_expect (scope_delim != NULL, 0)) + { + namebuf = alloca (scope_delim - name + 1); + *((char *) __mempcpy (namebuf, name, scope_delim - name)) = '\0'; + } if (inet_pton (AF_INET6, namebuf, at->addr) > 0) { @@ -629,7 +631,10 @@ gaih_inet (const char *name, const struct gaih_service *service, /* If we do not have to look for IPv4 and IPv6 together, use the simple, old functions. */ - if (req->ai_family == AF_INET || req->ai_family == AF_INET6) + if (req->ai_family == AF_INET + || (req->ai_family == AF_INET6 + && ((req->ai_flags & AI_V4MAPPED) == 0 + || (req->ai_flags & AI_ALL) == 0))) { int family = req->ai_family; size_t tmpbuflen = 512; @@ -888,8 +893,8 @@ gaih_inet (const char *name, const struct gaih_service *service, AF_INET6. Try to find a useful one for both. */ if (inet6_status == NSS_STATUS_TRYAGAIN) status = NSS_STATUS_TRYAGAIN; - else if (status == NSS_STATUS_UNAVAIL && - inet6_status != NSS_STATUS_UNAVAIL) + else if (status == NSS_STATUS_UNAVAIL + && inet6_status != NSS_STATUS_UNAVAIL) status = inet6_status; } @@ -1039,9 +1044,9 @@ gaih_inet (const char *name, const struct gaih_service *service, } } - if (at2->family == AF_INET6) + family = at2->family; + if (family == AF_INET6) { - family = AF_INET6; socklen = sizeof (struct sockaddr_in6); /* If we looked up IPv4 mapped address discard them here if @@ -1053,10 +1058,7 @@ gaih_inet (const char *name, const struct gaih_service *service, goto ignore; } else - { - family = AF_INET; - socklen = sizeof (struct sockaddr_in); - } + socklen = sizeof (struct sockaddr_in); for (st2 = st; st2 != NULL; st2 = st2->next) { diff --git a/sysdeps/posix/gettimeofday.c b/sysdeps/posix/gettimeofday.c index 28f75b0bcc..bda40f48ec 100644 --- a/sysdeps/posix/gettimeofday.c +++ b/sysdeps/posix/gettimeofday.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 94, 95, 96, 97, 2002 Free Software Foundation, Inc. +/* Copyright (C) 1991,1992,1994-1997,2002,2005 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 @@ -20,12 +20,6 @@ #include <time.h> #include <sys/time.h> -#ifndef HAVE_GNU_LD -#define __daylight daylight -#define __timezone timezone -#define __tzname tzname -#endif - #undef __gettimeofday /* Get the current time of day and timezone information, diff --git a/sysdeps/posix/system.c b/sysdeps/posix/system.c index 8548313314..f63dde4dae 100644 --- a/sysdeps/posix/system.c +++ b/sysdeps/posix/system.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2000, 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 1991-2000, 2002, 2003, 2005 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 @@ -27,10 +27,6 @@ #include <sysdep-cancel.h> -#ifndef HAVE_GNU_LD -#define __environ environ -#endif - #define SHELL_PATH "/bin/sh" /* Path of the shell. */ #define SHELL_NAME "sh" /* Name to give it. */ diff --git a/sysdeps/powerpc/powerpc64/Makefile b/sysdeps/powerpc/powerpc64/Makefile index cf29148ff3..cf7c4337e0 100644 --- a/sysdeps/powerpc/powerpc64/Makefile +++ b/sysdeps/powerpc/powerpc64/Makefile @@ -11,6 +11,8 @@ pic-ccflag = -fpic endif ifeq ($(subdir),csu) +sysdep_routines += hp-timing +elide-routines.os += hp-timing ifneq ($(elf),no) # The initfini generation code doesn't work in the presence of -fPIC, so # we use -fpic instead which is much better. diff --git a/sysdeps/unix/bsd/sun/sunos4/tcflush.c b/sysdeps/powerpc/powerpc64/hp-timing.c index 9e78aadd07..4e54e66e5e 100644 --- a/sysdeps/unix/bsd/sun/sunos4/tcflush.c +++ b/sysdeps/powerpc/powerpc64/hp-timing.c @@ -1,5 +1,8 @@ -/* Copyright (C) 1993, 1997 Free Software Foundation, Inc. +/* Support for high precision, low overhead timing functions. + powerpc64 version. + Copyright (C) 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -16,15 +19,7 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include <errno.h> -#include <termios.h> -#include <sys/ioctl.h> +#include <hp-timing.h> -/* Flush pending data on FD. */ -int -tcflush (fd, queue_selector) - int fd; - int queue_selector; -{ - return __ioctl (fd, TCFLSH, queue_selector); -} +/* We have to define the variable for the overhead. */ +hp_timing_t _dl_hp_timing_overhead; diff --git a/sysdeps/powerpc/powerpc64/hp-timing.h b/sysdeps/powerpc/powerpc64/hp-timing.h new file mode 100644 index 0000000000..b58cca9003 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/hp-timing.h @@ -0,0 +1,136 @@ +/* High precision, low overhead timing functions. powerpc64 version. + Copyright (C) 2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _HP_TIMING_H +#define _HP_TIMING_H 1 + +#include <string.h> +#include <sys/param.h> +#include <stdio-common/_itoa.h> +#include <atomic.h> + +/* The macros defined here use the powerpc 64-bit time base register. + The time base is nominally clocked at 1/8th the CPU clock, but this + can vary. + + The list of macros we need includes the following: + + - HP_TIMING_AVAIL: test for availability. + + - HP_TIMING_INLINE: this macro is non-zero if the functionality is not + implemented using function calls but instead uses some inlined code + which might simply consist of a few assembler instructions. We have to + know this since we might want to use the macros here in places where we + cannot make function calls. + + - hp_timing_t: This is the type for variables used to store the time + values. + + - HP_TIMING_ZERO: clear `hp_timing_t' object. + + - HP_TIMING_NOW: place timestamp for current time in variable given as + parameter. + + - HP_TIMING_DIFF_INIT: do whatever is necessary to be able to use the + HP_TIMING_DIFF macro. + + - HP_TIMING_DIFF: compute difference between two times and store it + in a third. Source and destination might overlap. + + - HP_TIMING_ACCUM: add time difference to another variable. This might + be a bit more complicated to implement for some platforms as the + operation should be thread-safe and 64bit arithmetic on 32bit platforms + is not. + + - HP_TIMING_ACCUM_NT: this is the variant for situations where we know + there are no threads involved. + + - HP_TIMING_PRINT: write decimal representation of the timing value into + the given string. This operation need not be inline even though + HP_TIMING_INLINE is specified. + +*/ + +/* We always assume having the timestamp register. */ +#define HP_TIMING_AVAIL (1) + +/* We indeed have inlined functions. */ +#define HP_TIMING_INLINE (1) + +/* We use 64bit values for the times. */ +typedef unsigned long long int hp_timing_t; + +/* Set timestamp value to zero. */ +#define HP_TIMING_ZERO(Var) (Var) = (0) + +/* That's quite simple. Use the `mftb' instruction. Note that the value + might not be 100% accurate since there might be some more instructions + running in this moment. This could be changed by using a barrier like + 'lwsync' right before the `mftb' instruciton. But we are not interested + in accurate clock cycles here so we don't do this. */ +#define HP_TIMING_NOW(Var) __asm__ __volatile__ ("mftb %0" : "=r" (Var)) + +/* Use two 'mftb' instructions in a row to find out how long it takes. + On current POWER4, POWER5, and 970 processors mftb take ~10 cycles. */ +#define HP_TIMING_DIFF_INIT() \ + do { \ + if (GLRO(dl_hp_timing_overhead) == 0) \ + { \ + int __cnt = 5; \ + GLRO(dl_hp_timing_overhead) = ~0ull; \ + do \ + { \ + hp_timing_t __t1, __t2; \ + HP_TIMING_NOW (__t1); \ + HP_TIMING_NOW (__t2); \ + if (__t2 - __t1 < GLRO(dl_hp_timing_overhead)) \ + GLRO(dl_hp_timing_overhead) = __t2 - __t1; \ + } \ + while (--__cnt > 0); \ + } \ + } while (0) + +/* It's simple arithmetic in 64-bit. */ +#define HP_TIMING_DIFF(Diff, Start, End) (Diff) = ((End) - (Start)) + +/* We need to insure that this add is atomic in threaded environments. We use + __arch_atomic_exchange_and_add_64 from atomic.h to get thread safety. */ +#define HP_TIMING_ACCUM(Sum, Diff) \ + do { \ + hp_timing_t __diff = (Diff) - GLRO(dl_hp_timing_overhead); \ + __arch_atomic_exchange_and_add_64 (&(Sum), __diff); \ + } while (0) + +/* No threads, no extra work. */ +#define HP_TIMING_ACCUM_NT(Sum, Diff) (Sum) += (Diff) + +/* Print the time value. */ +#define HP_TIMING_PRINT(Buf, Len, Val) \ + do { \ + char __buf[20]; \ + char *__cp = _itoa (Val, __buf + sizeof (__buf), 10, 0); \ + size_t __len = (Len); \ + char *__dest = (Buf); \ + while (__len-- > 0 && __cp < __buf + sizeof (__buf)) \ + *__dest++ = *__cp++; \ + memcpy (__dest, " ticks", MIN (__len, sizeof (" ticks"))); \ + } while (0) + +#endif /* hp-timing.h */ diff --git a/sysdeps/pthread/configure b/sysdeps/pthread/configure index 229414dd74..e39d31138d 100644 --- a/sysdeps/pthread/configure +++ b/sysdeps/pthread/configure @@ -1,3 +1,3 @@ -# Local configure fragment for sysdeps/unix/sysv/linux. +# Local configure fragment for sysdeps/pthread. DEFINES="$DEFINES -D_LIBC_REENTRANT" diff --git a/sysdeps/unix/bsd/init-posix.c b/sysdeps/unix/bsd/init-posix.c index 06f727684f..b5ea8846f7 100644 --- a/sysdeps/unix/bsd/init-posix.c +++ b/sysdeps/unix/bsd/init-posix.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 94, 95, 97, 98 Free Software Foundation, Inc. +/* Copyright (C) 1991, 94, 95, 97, 98, 2005 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 @@ -30,6 +30,4 @@ __init_posix (void) _posix_start_time = time ((time_t *) NULL); } -#ifdef HAVE_GNU_LD text_set_element(__libc_subinit, __init_posix); -#endif diff --git a/sysdeps/unix/bsd/sun/Dist b/sysdeps/unix/bsd/sun/Dist deleted file mode 100644 index ccd3a610ee..0000000000 --- a/sysdeps/unix/bsd/sun/Dist +++ /dev/null @@ -1 +0,0 @@ -m68k/dl-brk.S diff --git a/sysdeps/unix/bsd/sun/bits/signum.h b/sysdeps/unix/bsd/sun/bits/signum.h deleted file mode 100644 index c13e7cd742..0000000000 --- a/sysdeps/unix/bsd/sun/bits/signum.h +++ /dev/null @@ -1,69 +0,0 @@ -/* Signal number definitions. SunOS version. - Copyright (C) 1994, 1996 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifdef _SIGNAL_H - -/* This file defines the fake signal functions and signal - number constants for SunOS 3 and 4 Unix systems. */ - -/* Fake signal functions. */ -#define SIG_ERR ((__sighandler_t) -1) /* Error return. */ -#define SIG_DFL ((__sighandler_t) 0) /* Default action. */ -#define SIG_IGN ((__sighandler_t) 1) /* Ignore signal. */ - - -/* Signals. */ -#define SIGHUP 1 /* Hangup (POSIX). */ -#define SIGINT 2 /* Interrupt (ANSI). */ -#define SIGQUIT 3 /* Quit (POSIX). */ -#define SIGILL 4 /* Illegal instruction (ANSI). */ -#define SIGABRT SIGIOT /* Abort (ANSI). */ -#define SIGTRAP 5 /* Trace trap (POSIX). */ -#define SIGIOT 6 /* IOT trap (4.2 BSD). */ -#define SIGEMT 7 /* EMT trap (4.2 BSD). */ -#define SIGFPE 8 /* Floating-point exception (ANSI). */ -#define SIGKILL 9 /* Kill, unblockable (POSIX). */ -#define SIGBUS 10 /* Bus error (4.2 BSD). */ -#define SIGSEGV 11 /* Segmentation violation (ANSI). */ -#define SIGSYS 12 /* Bad argument to system call (4.2 BSD). */ -#define SIGPIPE 13 /* Broken pipe (POSIX). */ -#define SIGALRM 14 /* Alarm clock (POSIX). */ -#define SIGTERM 15 /* Termination (ANSI). */ -#define SIGURG 16 /* Urgent condition on socket (4.2 BSD). */ -#define SIGSTOP 17 /* Stop, unblockable (POSIX). */ -#define SIGTSTP 18 /* Keyboard stop (POSIX). */ -#define SIGCONT 19 /* Continue (POSIX). */ -#define SIGCHLD 20 /* Child status has changed (POSIX). */ -#define SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */ -#define SIGTTIN 21 /* Background read from tty (POSIX). */ -#define SIGTTOU 22 /* Background write to tty (POSIX). */ -#define SIGIO 23 /* I/O now possible (4.2 BSD). */ -#define SIGPOLL SIGIO /* Same as SIGIO? (SVID). */ -#define SIGXCPU 24 /* CPU limit exceeded (4.2 BSD). */ -#define SIGXFSZ 25 /* File size limit exceeded (4.2 BSD). */ -#define SIGVTALRM 26 /* Virtual alarm clock (4.2 BSD). */ -#define SIGPROF 27 /* Profiling alarm clock (4.2 BSD). */ -#define SIGWINCH 28 /* Window size change (4.3 BSD, Sun). */ -#define SIGLOST 29 /* Resource lost (Sun). */ -#define SIGUSR1 30 /* User-defined signal 1 (POSIX). */ -#define SIGUSR2 31 /* User-defined signal 2 (POSIX). */ - -#endif /* <signal.h> included. */ - -#define _NSIG 32 /* Biggest signal number + 1. */ diff --git a/sysdeps/unix/bsd/sun/m68k/Dist b/sysdeps/unix/bsd/sun/m68k/Dist deleted file mode 100644 index cd893ff463..0000000000 --- a/sysdeps/unix/bsd/sun/m68k/Dist +++ /dev/null @@ -1 +0,0 @@ -sigtramp.c diff --git a/sysdeps/unix/bsd/sun/m68k/Makefile b/sysdeps/unix/bsd/sun/m68k/Makefile deleted file mode 100644 index ac4121dc2c..0000000000 --- a/sysdeps/unix/bsd/sun/m68k/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -ifeq ($(subdir),signal) -sysdep_routines := $(sysdep_routines) sigtramp -endif diff --git a/sysdeps/unix/bsd/sun/m68k/bits/sigcontext.h b/sysdeps/unix/bsd/sun/m68k/bits/sigcontext.h deleted file mode 100644 index 99a0506a8d..0000000000 --- a/sysdeps/unix/bsd/sun/m68k/bits/sigcontext.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Structure describing state saved while handling a signal. Sun 3 version. - Copyright (C) 1993, 1994, 1997 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _SIGNAL_H -# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead." -#endif - -struct sigcontext - { - int sc_onstack; - __sigset_t sc_mask; - - int sc_sp, sc_pc, sc_ps; - }; diff --git a/sysdeps/unix/bsd/sun/m68k/brk.S b/sysdeps/unix/bsd/sun/m68k/brk.S deleted file mode 100644 index 07af96d23c..0000000000 --- a/sysdeps/unix/bsd/sun/m68k/brk.S +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 1991, 1992, 1994, 1995, 1997 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include <sysdep.h> - -#ifndef SYS_brk -#define SYS_brk 17 -#endif - -#ifndef HAVE_GNU_LD -#define __end _end -#endif - -.data -.globl ___curbrk -___curbrk: - .long __end - -.text -ENTRY (__brk) - movel #__end, d0 - cmpl sp@(4), d0 - ble 0f - movel d0, sp@(4) -0: pea SYS_brk - trap #0 - bcs 1f - movel sp@(4), ___curbrk - clrl d0 - rts -1: - jmp syscall_error - -weak_alias (__brk, brk) diff --git a/sysdeps/unix/bsd/sun/m68k/dl-brk.S b/sysdeps/unix/bsd/sun/m68k/dl-brk.S deleted file mode 100644 index eeb96544e3..0000000000 --- a/sysdeps/unix/bsd/sun/m68k/dl-brk.S +++ /dev/null @@ -1 +0,0 @@ -#include <brk.S> diff --git a/sysdeps/unix/bsd/sun/m68k/sethostid.S b/sysdeps/unix/bsd/sun/m68k/sethostid.S deleted file mode 100644 index 73ee79682e..0000000000 --- a/sysdeps/unix/bsd/sun/m68k/sethostid.S +++ /dev/null @@ -1,44 +0,0 @@ -/* 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include <sysdep.h> - -#ifdef SYS_sethostid - -SYSCALL (sethostid, 1) - ret - -#else - -#include <bits/errno.h> - -.globl _sethostid -.even -_sethostid: - movel #ENOSYS, _errno - moveq #-1, d0 - rts - -#ifdef HAVE_GNU_LD - -.stabs "warning: sethostid is not implemented and will always fail",30,0,0,0 -.stabs "_sethostid",1,0,0,0 - -#endif - -#endif diff --git a/sysdeps/unix/bsd/sun/m68k/sigtramp.c b/sysdeps/unix/bsd/sun/m68k/sigtramp.c deleted file mode 100644 index 5a3ca3cf10..0000000000 --- a/sysdeps/unix/bsd/sun/m68k/sigtramp.c +++ /dev/null @@ -1,145 +0,0 @@ -/* Copyright (C) 1993, 1996, 1997, 2004 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef __GNUC__ - #error This file uses GNU C extensions; you must compile with GCC. -#endif - -/* Get the definition of `struct sigcontext'. */ -#define KERNEL -#define sigvec sun_sigvec -#define sigstack sun_sigstack -#define sigcontext sun_sigcontext -#include "/usr/include/sys/signal.h" -#undef sigvec -#undef sigstack -#undef sigcontext -#undef NSIG -#undef SIGABRT -#undef SIGCLD -#undef SV_ONSTACK -#undef SV_RESETHAND -#undef SV_INTERRUPT -#undef SA_ONSTACK -#undef SA_NOCLDSTOP -#undef SIG_ERR -#undef SIG_DFL -#undef SIG_IGN -#undef sigmask -#undef SIG_BLOCK -#undef SIG_UNBLOCK -#undef SIG_SETMASK - -#include <signal.h> -#include <stddef.h> -#include <errno.h> - -/* Defined in __sigvec.S. */ -extern int __raw_sigvec (int sig, const struct sigvec *vec, - struct sigvec *ovec); - -/* User-specified signal handlers. */ -#define mytramp 1 -#ifdef mytramp -static __sighandler_t handlers[NSIG]; -#else -#define handlers _sigfunc -extern __sighandler_t _sigfunc[]; -#endif - -#if mytramp - -/* Handler for all signals that are handled by a user-specified function. - Saves and restores the general regs %g2-%g7, the %y register, and - all the FPU regs (including %fsr), around calling the user's handler. */ -static void -trampoline (sig, code, context, addr) - int sig; - int code; - struct sigcontext *context; - void *addr; -{ - int save[4]; - - /* Save the call-clobbered registers. */ - asm volatile ("movem%.l d0-d1/a0-a1, %0" : : "m" (save[0])); - - /* XXX should save/restore FP regs */ - - /* Call the user's handler. */ - (*((void (*) (int sig, int code, struct sigcontext *context, - PTR addr)) handlers[sig])) - (sig, code, context, addr); - - /* Restore the call-clobbered registers. */ - asm volatile ("movem%.l %0, d0-d1/a0-a1" : : "g" (save[0]) : - "d0", "d1", "a0", "a1"); - - __sigreturn (context); -} - -#endif - -int -__sigvec (sig, vec, ovec) - int sig; - const struct sigvec *vec; - struct sigvec *ovec; -{ -#ifndef mytramp - extern void _sigtramp (int); -#define trampoline _sigtramp -#endif - struct sigvec myvec; - int mask; - __sighandler_t ohandler; - - if (sig <= 0 || sig >= NSIG) - { - __set_errno (EINVAL); - return -1; - } - - mask = __sigblock(sigmask(sig)); - - ohandler = handlers[sig]; - - if (vec != NULL && - vec->sv_handler != SIG_IGN && vec->sv_handler != SIG_DFL) - { - handlers[sig] = vec->sv_handler; - myvec = *vec; - myvec.sv_handler = trampoline; - vec = &myvec; - } - - if (__raw_sigvec(sig, vec, ovec) < 0) - { - int save = errno; - (void) __sigsetmask(mask); - errno = save; - return -1; - } - - if (ovec != NULL && ovec->sv_handler == trampoline) - ovec->sv_handler = ohandler; - - (void) __sigsetmask(mask); - - return 0; -} diff --git a/sysdeps/unix/bsd/sun/m68k/syscall.S b/sysdeps/unix/bsd/sun/m68k/syscall.S deleted file mode 100644 index 1d4d5be42f..0000000000 --- a/sysdeps/unix/bsd/sun/m68k/syscall.S +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 1993, 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include <sysdep.h> - -ENTRY (syscall) - movel sp@, d0 /* Save return address in D0. */ - movel sp@(4), sp@ /* Put syscall number at top of stack. */ - movel d0, sp@(4) /* Put return address under it. */ - trap #0 /* Do syscall; pops number from stack. */ - jcs error - ret -error: jmp syscall_error diff --git a/sysdeps/unix/bsd/sun/m68k/sysdep.h b/sysdeps/unix/bsd/sun/m68k/sysdep.h deleted file mode 100644 index e51ab0a8e4..0000000000 --- a/sysdeps/unix/bsd/sun/m68k/sysdep.h +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (C) 1991, 1992, 1994, 1995, 1997 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include <sysdeps/unix/sysdep.h> - -#ifdef __ASSEMBLER__ - -#define POUND # - -#ifdef __STDC__ -#define ENTRY(name) \ - .globl _##name; \ - .even; \ - _##name##: -#else -#define ENTRY(name) \ - .globl _/**/name; \ - .even; \ - _/**/name/**/: -#endif - -#ifdef __STDC__ -#define PSEUDO(name, syscall_name, args) \ - .even; \ - .globl syscall_error; \ - error: jmp syscall_error; \ - ENTRY (name) \ - pea SYS_##syscall_name; \ - trap POUND 0; \ - bcs error -#else -#define PSEUDO(name, syscall_name, args) \ - .even; \ - .globl syscall_error; \ - error: jmp syscall_error; \ - ENTRY (name) \ - pea SYS_/**/syscall_name; \ - trap POUND 0; \ - bcs error -#endif - -#define ret rts -#define r0 d0 -#define r1 d1 -#define MOVE(x,y) movel x , y - -#endif /* __ASSEMBLER__ */ diff --git a/sysdeps/unix/bsd/sun/m68k/vfork.S b/sysdeps/unix/bsd/sun/m68k/vfork.S deleted file mode 100644 index cf9e2e9e1a..0000000000 --- a/sysdeps/unix/bsd/sun/m68k/vfork.S +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (C) 1991, 92, 93, 94, 95, 97, 2002 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include <sysdep.h> - -#ifndef SYS_vfork -#define SYS_vfork 66 -#endif - -/* Clone the calling process, but without copying the whole address space. - The calling process is suspended until the new process exits or is - replaced by a call to `execve'. Return -1 for errors, 0 to the new process, - and the process ID of the new process to the old process. */ -.globl ___vfork -___vfork: - /* Pop the return PC value into A0. */ - movel sp@+, a0 - - /* Push the syscall number and trap into the kernel. */ - movel #SYS_vfork, sp@- - trap #0 - bcs error /* Branch forward if it failed. */ - - /* It succeeded. See which fork we're in. D1 is now 0 for the - parent and 1 for the child. Decrement it to make it -1 (all - bits set) for the parent, and 0 (no bits set) for the child. - Then AND it with D0, so the parent gets D0&-1==R0, and the child - gets D0&0==0. */ - subql #1, d1 - andl d1, d0 - - /* Jump to the return PC. */ - jmp a0@ - -error: - movel d0, _errno - moveq #-1, d0 - jmp a0@ -libc_hidden_def (__vfork) - -weak_alias (__vfork, vfork) diff --git a/sysdeps/unix/bsd/sun/sethostid.c b/sysdeps/unix/bsd/sun/sethostid.c deleted file mode 100644 index aeb2940f42..0000000000 --- a/sysdeps/unix/bsd/sun/sethostid.c +++ /dev/null @@ -1 +0,0 @@ -#include <sysdeps/generic/sethostid.c> diff --git a/sysdeps/unix/bsd/sun/sigreturn.S b/sysdeps/unix/bsd/sun/sigreturn.S deleted file mode 100644 index a3ea8e3fae..0000000000 --- a/sysdeps/unix/bsd/sun/sigreturn.S +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include <sysdep.h> - -#ifndef SYS_sigreturn -#define SYS_sigreturn 139 -#endif - -SYSCALL__ (sigreturn, 1) - /* Does not return. */ - -weak_alias (__sigreturn, sigreturn) diff --git a/sysdeps/unix/bsd/sun/sparc/Dist b/sysdeps/unix/bsd/sun/sparc/Dist deleted file mode 100644 index cd893ff463..0000000000 --- a/sysdeps/unix/bsd/sun/sparc/Dist +++ /dev/null @@ -1 +0,0 @@ -sigtramp.c diff --git a/sysdeps/unix/bsd/sun/sparc/Makefile b/sysdeps/unix/bsd/sun/sparc/Makefile deleted file mode 100644 index 59d10dbdbf..0000000000 --- a/sysdeps/unix/bsd/sun/sparc/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# Basically `-e start' is magical to the Sun linker. You would think that -# having start.o first would be enough, but you would be wrong. -LDFLAGS := $(LDFLAGS) -Xlinker -e -Xlinker start - -ifeq ($(subdir),signal) -sysdep_routines := $(sysdep_routines) sigtramp -endif diff --git a/sysdeps/unix/bsd/sun/sparc/bits/sigcontext.h b/sysdeps/unix/bsd/sun/sparc/bits/sigcontext.h deleted file mode 100644 index 7c4bca6049..0000000000 --- a/sysdeps/unix/bsd/sun/sparc/bits/sigcontext.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Structure describing state saved while handling a signal. Sparc version. - Copyright (C) 1992, 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _SIGNAL_H -# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead." -#endif - -struct sigcontext - { - int sc_onstack; - __sigset_t sc_mask; - -#define SPARC_MAXREGWINDOW 31 /* Maximum usable register windows. */ - int sc_sp, sc_pc, sc_npc, sc_psr, sc_g1, sc_o0; - int sc_wbcnt; /* Number of outstanding windows. */ - __ptr_t sc_spbuf[SPARC_MAXREGWINDOW]; /* SP's for each window. */ - int sc_wbuf[SPARC_MAXREGWINDOW][16]; /* Saved register windows. */ - }; diff --git a/sysdeps/unix/bsd/sun/sparc/sethostid.S b/sysdeps/unix/bsd/sun/sparc/sethostid.S deleted file mode 100644 index d07fd3800c..0000000000 --- a/sysdeps/unix/bsd/sun/sparc/sethostid.S +++ /dev/null @@ -1,46 +0,0 @@ -/* 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include <sysdep.h> - -#ifdef SYS_sethostid - -SYSCALL (sethostid, 1) - ret - -#else - -/* <bits/errno.h> only defines E* #ifdef _ERRNO_H. */ -#define _ERRNO_H -#include <bits/errno.h> - -ENTRY (sethostid) - mov ENOSYS, %o0 - sethi %hi(_errno), %g1 - st %o0, [%g1 + %lo(_errno)] - retl - sub %g0, 1, %o0 - -#ifdef HAVE_GNU_LD - -.stabs "warning: sethostid is not implemented and will always fail",30,0,0,0 -.stabs "_sethostid",1,0,0,0 - -#endif - -#endif diff --git a/sysdeps/unix/bsd/sun/sparc/sigtramp.c b/sysdeps/unix/bsd/sun/sparc/sigtramp.c deleted file mode 100644 index e11f7e51d3..0000000000 --- a/sysdeps/unix/bsd/sun/sparc/sigtramp.c +++ /dev/null @@ -1,247 +0,0 @@ -/* Copyright (C) 1991,1992,1994,1996,1997,2004 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef __GNUC__ - #error This file uses GNU C extensions; you must compile with GCC. -#endif - -/* Get the definition of `struct sigcontext'. */ -#define KERNEL -#define sigvec sun_sigvec -#define sigstack sun_sigstack -#define sigcontext sun_sigcontext -#include "/usr/include/sys/signal.h" -#undef sigvec -#undef sigstack -#undef sigcontext -#undef NSIG -#undef SIGABRT -#undef SIGCLD -#undef SV_ONSTACK -#undef SV_RESETHAND -#undef SV_INTERRUPT -#undef SA_ONSTACK -#undef SA_NOCLDSTOP -#undef SIG_ERR -#undef SIG_DFL -#undef SIG_IGN -#undef sigmask -#undef SIG_BLOCK -#undef SIG_UNBLOCK -#undef SIG_SETMASK - -#include <signal.h> -#include <stddef.h> -#include <errno.h> - -/* Defined in __sigvec.S. */ -extern int __raw_sigvec (int sig, CONST struct sigvec *vec, - struct sigvec *ovec); - -/* User-specified signal handlers. */ -#define mytramp 1 -#ifdef mytramp -static __sighandler_t handlers[NSIG]; -#else -#define handlers _sigfunc -extern __sighandler_t _sigfunc[]; -#endif - -#if mytramp - -/* Handler for all signals that are handled by a user-specified function. - Saves and restores the general regs %g2-%g7, the %y register, and - all the FPU regs (including %fsr), around calling the user's handler. */ -static void -trampoline (sig) - int sig; -{ - /* We use `double' and `long long int' so `std' (store doubleword) insns, - which might be faster than single-word stores, will be generated. */ - register double f0 asm("%f0"); - register double f2 asm("%f2"); - register double f4 asm("%f4"); - register double f6 asm("%f6"); - register double f8 asm("%f8"); - register double f10 asm("%f10"); - register double f12 asm("%f12"); - register double f14 asm("%f14"); - register double f16 asm("%f16"); - register double f18 asm("%f18"); - register double f20 asm("%f20"); - register double f22 asm("%f22"); - register double f24 asm("%f24"); - register double f26 asm("%f26"); - register double f28 asm("%f28"); - register double f30 asm("%f30"); - register long long int g2 asm("%g2"); - register long long int g4 asm("%g4"); - register long long int g6 asm("%g6"); - register int *fp asm("%fp"); - - int code; - register struct sigcontext *context asm("%i0"); /* See end of fn. */ - void *addr; - int y; - double fpsave[16]; - int fsr; - int savefpu; - long long int glsave[3]; - - /* SIG isn't really passed as an arg. - The args to the signal handler are at fp[16..19]. */ - sig = fp[16]; - code = fp[17]; - context = (struct sigcontext *) fp[18]; - addr = (PTR) fp[19]; - - /* Save the Y register. */ - asm("rd %%y, %0" : "=r" (y)); - - /* Save the FPU regs if the FPU enable bit is set in the PSR, - and the signal isn't an FP exception. */ - savefpu = (context->sc_psr & 0x1000) && sig != SIGFPE; - if (savefpu) - { - fpsave[0] = f0; - fpsave[1] = f2; - fpsave[2] = f4; - fpsave[3] = f6; - fpsave[4] = f8; - fpsave[5] = f10; - fpsave[6] = f12; - fpsave[7] = f14; - fpsave[8] = f16; - fpsave[9] = f18; - fpsave[10] = f20; - fpsave[11] = f22; - fpsave[12] = f24; - fpsave[13] = f26; - fpsave[14] = f28; - fpsave[15] = f30; - - /* Force it into a stack slot so the asm won't barf. Sigh. */ - (void) &fsr; - asm("st %%fsr, %0" : "=m" (fsr)); - } - - /* Save the global registers (except for %g1, which is a scratch reg). */ - glsave[0] = g2; - glsave[1] = g4; - glsave[2] = g6; - - /* Call the user's handler. */ - (*((void (*) (int sig, int code, struct sigcontext *context, - void *addr)) handlers[sig])) - (sig, code, context, addr); - - /* Restore the Y register. */ - asm("mov %0, %%y" : : "r" (y)); - - if (savefpu) - { - /* Restore the FPU regs. */ - f0 = fpsave[0]; - f2 = fpsave[1]; - f4 = fpsave[2]; - f6 = fpsave[3]; - f8 = fpsave[4]; - f10 = fpsave[5]; - f12 = fpsave[6]; - f14 = fpsave[7]; - f16 = fpsave[8]; - f18 = fpsave[9]; - f20 = fpsave[10]; - f22 = fpsave[11]; - f24 = fpsave[12]; - f26 = fpsave[13]; - f28 = fpsave[14]; - f30 = fpsave[15]; - - asm("ld %0, %%fsr" : : "m" (fsr)); - } - - /* Restore the globals. */ - g2 = glsave[0]; - g4 = glsave[1]; - g6 = glsave[2]; - - /* Unwind a frame, and do a "sigcleanup" system call. - The system call apparently does a return. - I don't know what it's for. Ask Sun. */ - asm("restore %%g0, 139, %%g1\n" - "ta 0\n" - "! this should be i0: %0" /* Useless insn that will never be executed, */ - /* here to make the compiler happy. */ - : /* No outputs. */ : - /* CONTEXT is bound to %i0. We reference it as an input here to make - sure the compiler considers it live at this point, and preserves - the value in that register. The restore makes %i0 become %o0, the - argument to the system call. */ - "r" (context)); -} -#endif - -int -__sigvec (sig, vec, ovec) - int sig; - const struct sigvec *vec; - struct sigvec *ovec; -{ -#ifndef mytramp - extern void _sigtramp (int); -#define trampoline _sigtramp -#endif - struct sigvec myvec; - int mask; - __sighandler_t ohandler; - - if (sig <= 0 || sig >= NSIG) - { - __set_errno (EINVAL); - return -1; - } - - mask = __sigblock (sigmask(sig)); - - ohandler = handlers[sig]; - - if (vec != NULL && - vec->sv_handler != SIG_IGN && vec->sv_handler != SIG_DFL) - { - handlers[sig] = vec->sv_handler; - myvec = *vec; - myvec.sv_handler = trampoline; - vec = &myvec; - } - - if (__raw_sigvec(sig, vec, ovec) < 0) - { - int save = errno; - (void) __sigsetmask(mask); - errno = save; - return -1; - } - - if (ovec != NULL && ovec->sv_handler == trampoline) - ovec->sv_handler = ohandler; - - (void) __sigsetmask (mask); - - return 0; -} diff --git a/sysdeps/unix/bsd/sun/sunos4/.cvsignore b/sysdeps/unix/bsd/sun/sunos4/.cvsignore deleted file mode 100644 index 1f69fd919a..0000000000 --- a/sysdeps/unix/bsd/sun/sunos4/.cvsignore +++ /dev/null @@ -1,4 +0,0 @@ -*.gz *.Z *.tar *.tgz -=* -TODO COPYING* AUTHORS copyr-* copying.* -glibc-* diff --git a/sysdeps/unix/bsd/sun/sunos4/Implies b/sysdeps/unix/bsd/sun/sunos4/Implies deleted file mode 100644 index c99e256ac1..0000000000 --- a/sysdeps/unix/bsd/sun/sunos4/Implies +++ /dev/null @@ -1,2 +0,0 @@ -# SunOS 4 has the canonical set of <sys/mman.h> system calls. -unix/mman diff --git a/sysdeps/unix/bsd/sun/sunos4/Makefile b/sysdeps/unix/bsd/sun/sunos4/Makefile deleted file mode 100644 index d17654a30f..0000000000 --- a/sysdeps/unix/bsd/sun/sunos4/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -ifeq ($(subdir),posix) -sysdep_routines := $(sysdep_routines) sys_wait4 -endif - -ifeq ($(subdir),misc) -sysdep_routines := $(sysdep_routines) sys_mmap -endif diff --git a/sysdeps/unix/bsd/sun/sunos4/bits/fcntl.h b/sysdeps/unix/bsd/sun/sunos4/bits/fcntl.h deleted file mode 100644 index a30b352592..0000000000 --- a/sysdeps/unix/bsd/sun/sunos4/bits/fcntl.h +++ /dev/null @@ -1,142 +0,0 @@ -/* O_*, F_*, FD_* bit values for SunOS 4. - Copyright (C) 1991, 1992, 1997, 2004 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _FCNTL_H -#error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead." -#endif - - -/* File access modes for `open' and `fcntl'. */ -#define O_RDONLY 0 /* Open read-only. */ -#define O_WRONLY 1 /* Open write-only. */ -#define O_RDWR 2 /* Open read/write. */ - - -/* Bits OR'd into the second argument to open. */ -#define O_CREAT 0x0200 /* Create file if it doesn't exist. */ -#define O_EXCL 0x0800 /* Fail if file already exists. */ -#define O_TRUNC 0x0400 /* Truncate file to zero length. */ -#define O_NOCTTY 0x8000 /* Don't assign a controlling terminal. */ -#if defined __USE_BSD || defined __USE_SVID -#define O_ASYNC 0x0040 /* Send SIGIO to owner when data is ready. */ -#define O_FSYNC 0x2000 /* Synchronous writes. */ -#define O_SYNC O_FSYNC -#endif - -/* File status flags for `open' and `fcntl'. */ -#define O_APPEND 0x0008 /* Writes append to the file. */ -#define O_NONBLOCK 0x4000 /* Non-blocking I/O. */ - -/* Sun defines O_NDELAY one way for BSD behavior and another for System V - behavior. In the GNU C library, you get the BSD behavior unless you - define _USG_SOURCE without also defining _BSD_SOURCE or _GNU_SOURCE. */ -#ifdef __USE_BSD -#define O_NDELAY 0x0004 -#endif -#if !defined (O_NDELAY) && defined (__USE_SVID) -#define O_NDELAY 0x1000 -#endif - -#ifdef __USE_BSD -/* Bits in the file status flags returned by F_GETFL. - These are all the O_* flags, plus FREAD and FWRITE, which are - independent bits set by which of O_RDONLY, O_WRONLY, and O_RDWR, was - given to `open'. */ -#define FREAD 1 -#define FWRITE 2 - -/* Traditional Unix names the O_* bits. */ -#define FASYNC O_ASYNC -#define FCREAT O_CREAT -#define FEXCL O_EXCL -#define FTRUNC O_TRUNC -#define FNOCTTY O_NOCTTY -#define FFSYNC O_FSYNC -#define FSYNC O_SYNC -#define FAPPEND O_APPEND -#define FNONBLOCK O_NONBLOCK -#define FNONBIO O_NONBLOCK -#define FNDELAY 0x0004 /* BSD O_NDELAY. */ -#define FNBIO 0x1000 /* System V O_NDELAY. */ -#endif - -/* Mask for file access modes. This is system-dependent in case - some system ever wants to define some other flavor of access. */ -#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) - -/* Values for the second argument to `fcntl'. */ -#define F_DUPFD 0 /* Duplicate file descriptor. */ -#define F_GETFD 1 /* Get file descriptor flags. */ -#define F_SETFD 2 /* Set file descriptor flags. */ -#define F_GETFL 3 /* Get file status flags. */ -#define F_SETFL 4 /* Set file status flags. */ -#if defined __USE_BSD || defined __USE_UNIX98 -#define F_GETOWN 5 /* Get owner (receiver of SIGIO). */ -#define F_SETOWN 6 /* Set owner (receiver of SIGIO). */ -#endif -#define F_GETLK 7 /* Get record locking info. */ -#define F_SETLK 8 /* Set record locking info (non-blocking). */ -#define F_SETLKW 9 /* Set record locking info (blocking). */ -#ifdef __USE_BSD -#define F_RGETLK 10 /* Get remote record locking info. */ -#define F_RSETLK 11 /* Set remote locking info (non-blocking). */ -#define F_CNVT 12 /* Convert a fhandle to an open fd. */ -#define F_RSETLKW 13 /* Set remote locking info (blocking). */ -#endif - -/* File descriptor flags used with F_GETFD and F_SETFD. */ -#define FD_CLOEXEC 1 /* Close on exec. */ - - -#include <bits/types.h> - -/* The structure describing an advisory lock. This is the type of the third - argument to `fcntl' for the F_GETLK, F_SETLK, and F_SETLKW requests. */ -struct flock - { - short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */ - short int l_whence; /* Where `l_start' is relative to (like `lseek'). */ - __off_t l_start; /* Offset where the lock begins. */ - __off_t l_len; /* Size of the locked area; zero means until EOF. */ - short int l_pid; /* Process holding the lock. */ - short int l_xxx; /* Reserved for future use. */ - }; - -#ifdef __USE_BSD -/* The structure describing a remote advisory lock. This is the type of the - third arg to `fcntl' for the F_RGETLK, F_RSETLK, and F_RSETLKW requests. */ -struct eflock - { - short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */ - short int l_whence; /* Where `l_start' is relative to (like `lseek'). */ - __off_t l_start; /* Offset where the lock begins. */ - __off_t l_len; /* Size of the locked area; zero means until EOF. */ - short int l_pid; /* Process holding the lock. */ - short int l_xxx; /* Reserved for future use. */ - long int l_rpid; /* Remote process ID wanting this lock. */ - long int l_rsys; /* Remote system ID wanting this lock. */ - }; - -#endif - - -/* Values for the `l_type' field of a `struct flock'. */ -#define F_RDLCK 1 /* Read lock. */ -#define F_WRLCK 2 /* Write lock. */ -#define F_UNLCK 3 /* Remove lock. */ diff --git a/sysdeps/unix/bsd/sun/sunos4/bits/mman.h b/sysdeps/unix/bsd/sun/sunos4/bits/mman.h deleted file mode 100644 index fdef46522a..0000000000 --- a/sysdeps/unix/bsd/sun/sunos4/bits/mman.h +++ /dev/null @@ -1,68 +0,0 @@ -/* Definitions for BSD-style memory management. SunOS 4 version. - Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _BITS_MMAN_H -#define _BITS_MMAN_H 1 - -/* Protections are chosen from these bits, OR'd together. The - implementation does not necessarily support PROT_EXEC or PROT_WRITE - without PROT_READ. The only guarantees are that no writing will be - allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */ - -#define PROT_NONE 0x00 /* No access. */ -#define PROT_READ 0x01 /* Pages can be read. */ -#define PROT_WRITE 0x02 /* Pages can be written. */ -#define PROT_EXEC 0x04 /* Pages can be executed. */ - -/* Sharing types (must choose one and only one of these). */ -#define MAP_SHARED 0x01 /* Share changes. */ -#define MAP_PRIVATE 0x02 /* Changes private; copy pages on write. */ -#ifdef __USE_BSD -# define MAP_TYPE 0x0f /* Mask for sharing type. */ -#endif - -/* Other flags. */ -#define MAP_FIXED 0x10 /* Map address must be exactly as requested. */ -/* The following three flags are not actually implemented in SunOS 4.1. */ -#ifdef __USE_BSD -# define MAP_RENAME 0x20 /* Rename private pages to file. */ -# define MAP_NORESERVE 0x40 /* Don't reserve needed swap area. */ -# define MAP_INHERIT 0x80 /* Region is retained after exec. */ -#endif - -/* This is an internal flag that is always set in `mmap' system calls. In - older versions of SunOS 4 `mmap' did not return the actual mapping - address, but always returned zero. This flag says to return the - address; the `mmap' C library function always sets it. */ -#define _MAP_NEW 0x80000000 - -/* Advice to `madvise'. */ -#ifdef __USE_BSD -# define MADV_NORMAL 0 /* No further special treatment. */ -# define MADV_RANDOM 1 /* Expect random page references. */ -# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ -# define MADV_WILLNEED 3 /* Will need these pages. */ -# define MADV_DONTNEED 4 /* Don't need these pages. */ -#endif - -/* Flags to `msync'. */ -#define MS_ASYNC 0x1 /* Return immediately, don't fsync. */ -#define MS_INVALIDATE 0x2 /* Invalidate caches. */ - -#endif /* bits/mman.h */ diff --git a/sysdeps/unix/bsd/sun/sunos4/bits/resource.h b/sysdeps/unix/bsd/sun/sunos4/bits/resource.h deleted file mode 100644 index 2f0d2dc73f..0000000000 --- a/sysdeps/unix/bsd/sun/sunos4/bits/resource.h +++ /dev/null @@ -1,174 +0,0 @@ -/* Bit values for resource limits. SunOS 4 version. - Copyright (C) 1994, 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _SYS_RESOURCE_H -# error "Never use <bits/resource.h> directly; include <sys/resource.h> instead." -#endif - -/* These are the values for 4.4 BSD and GNU. Earlier BSD systems have a - subset of these kinds of resource limit. In systems where `getrlimit' - and `setrlimit' are not system calls, these are the values used by the C - library to emulate them. */ - -#include <bits/types.h> - -/* Kinds of resource limit. */ -enum __rlimit_resource - { - /* Per-process CPU limit, in seconds. */ - RLIMIT_CPU, -#define RLIMIT_CPU RLIMIT_CPU - /* Largest file that can be created, in bytes. */ - RLIMIT_FSIZE, -#define RLIMIT_FSIZE RLIMIT_FSIZE - /* Maximum size of data segment, in bytes. */ - RLIMIT_DATA, -#define RLIMIT_DATA RLIMIT_DATA - /* Maximum size of stack segment, in bytes. */ - RLIMIT_STACK, -#define RLIMIT_STACK RLIMIT_STACK - /* Largest core file that can be created, in bytes. */ - RLIMIT_CORE, -#define RLIMIT_CORE RLIMIT_CORE - /* Largest resident set size, in bytes. - This affects swapping; processes that are exceeding their - resident set size will be more likely to have physical memory - taken from them. */ - RLIMIT_RSS, -#define RLIMIT_RSS RLIMIT_RSS - /* Number of open files. */ - RLIMIT_NOFILE, - RLIMIT_OFILE = RLIMIT_NOFILE, /* BSD name for same. */ -#define RLIMIT_NOFILE RLIMIT_NOFILE -#define RLIMIT_OFILE RLIMIT_OFILE - - RLIM_NLIMITS - }; - -/* Value to indicate that there is no limit. */ -#ifndef __USE_FILE_OFFSET64 -# define RLIM_INFINITY 0x7fffffff -#else -# define RLIM_INFINITY 0x7fffffffffffffffLL -#endif - -#ifdef __USE_LARGEFILE64 -# define RLIM64_INFINITY 0x7fffffffffffffffLL -#endif - - -/* Type to represent quantities in resource limits. */ -#ifndef __USE_FILE_OFFSET64 -typedef __rlim_t rlim_t; -#else -typedef __rlim64_t rlim_t; -#endif - -struct rlimit - { - /* The current (soft) limit. */ - rlim_t rlim_cur; - /* The hard limit. */ - rlim_t rlim_max; - }; - -#ifdef __USE_LARGEFILE64 -typedef __rlim64_t rlim64_t; - -struct rlimit64 - { - /* The current (soft) limit. */ - rlim64_t rlim_cur; - /* The hard limit. */ - rlim64_t rlim_max; - }; -#endif - -/* Whose usage statistics do you want? */ -enum __rusage_who -/* The macro definitions are necessary because some programs want - to test for operating system features with #ifdef RUSAGE_SELF. - In ISO C the reflexive definition is a no-op. */ - { - /* The calling process. */ - RUSAGE_SELF = 0, -#define RUSAGE_SELF RUSAGE_SELF - /* All of its terminated child processes. */ - RUSAGE_CHILDREN = -1 -#define RUSAGE_CHILDREN RUSAGE_CHILDREN - }; - -#define __need_timeval -#include <bits/time.h> /* For `struct timeval'. */ - -/* Structure which says how much of each resource has been used. */ -struct rusage - { - /* Total amount of user time used. */ - struct timeval ru_utime; - /* Total amount of system time used. */ - struct timeval ru_stime; - /* Maximum resident set size (in kilobytes). */ - long int ru_maxrss; - /* Amount of sharing of text segment memory - with other processes (kilobyte-seconds). */ - long int ru_ixrss; - /* Amount of data segment memory used (kilobyte-seconds). */ - long int ru_idrss; - /* Amount of stack memory used (kilobyte-seconds). */ - long int ru_isrss; - /* Number of soft page faults (i.e. those serviced by reclaiming - a page from the list of pages awaiting reallocation. */ - long int ru_minflt; - /* Number of hard page faults (i.e. those that required I/O). */ - long int ru_majflt; - /* Number of times a process was swapped out of physical memory. */ - long int ru_nswap; - /* Number of input operations via the file system. Note: This - and `ru_oublock' do not include operations with the cache. */ - long int ru_inblock; - /* Number of output operations via the file system. */ - long int ru_oublock; - /* Number of IPC messages sent. */ - long int ru_msgsnd; - /* Number of IPC messages received. */ - long int ru_msgrcv; - /* Number of signals delivered. */ - long int ru_nsignals; - /* Number of voluntary context switches, i.e. because the process - gave up the process before it had to (usually to wait for some - resource to be available). */ - long int ru_nvcsw; - /* Number of involuntary context switches, i.e. a higher priority process - became runnable or the current process used up its time slice. */ - long int ru_nivcsw; - }; - -/* Priority limits. */ -#define PRIO_MIN -20 /* Minimum priority a process can have. */ -#define PRIO_MAX 20 /* Maximum priority a process can have. */ - -/* The type of the WHICH argument to `getpriority' and `setpriority', - indicating what flavor of entity the WHO argument specifies. */ -enum __priority_which - { - PRIO_PROCESS = 0, /* WHO is a process ID. */ - PRIO_PGRP = 1, /* WHO is a process group ID. */ - PRIO_USER = 2 /* WHO is a user ID. */ - }; diff --git a/sysdeps/unix/bsd/sun/sunos4/bits/termios.h b/sysdeps/unix/bsd/sun/sunos4/bits/termios.h deleted file mode 100644 index 97612c8f0b..0000000000 --- a/sysdeps/unix/bsd/sun/sunos4/bits/termios.h +++ /dev/null @@ -1,212 +0,0 @@ -/* termios type and macro definitions. SunOS 4 version. - Copyright (C) 1993, 1994, 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _TERMIOS_H -# error "Never include <bits/termios.h> directly; use <termios.h> instead." -#endif - -/* Type of terminal control flag masks. */ -typedef unsigned long int tcflag_t; - -/* Type of control characters. */ -typedef unsigned char cc_t; - -/* Type of baud rate specifiers. */ -typedef unsigned int speed_t; - -/* Terminal control structure. */ -struct termios -{ - /* Input modes. */ - tcflag_t c_iflag; -#define IGNBRK 0x0001 /* Ignore break condition. */ -#define BRKINT 0x0002 /* Signal interrupt on break. */ -#define IGNPAR 0x0004 /* Ignore characters with parity errors. */ -#define PARMRK 0x0008 /* Mark parity and framing errors. */ -#define INPCK 0x0010 /* Enable input parity check. */ -#define ISTRIP 0x0020 /* Strip 8th bit off characters. */ -#define INLCR 0x0040 /* Map NL to CR on input. */ -#define IGNCR 0x0080 /* Ignore CR. */ -#define ICRNL 0x0100 /* Map CR to NL on input. */ -#ifdef __USE_BSD -# define IUCLC 0x0200 /* Map upper case to lower case on input. */ -#endif -#define IXON 0x0400 /* Enable start/stop output control. */ -#define IXOFF 0x1000 /* Enable start/stop input control. */ -#ifdef __USE_BSD -# define IXANY 0x0800 /* Any character will restart after stop. */ -# define IMAXBEL 0x2000 /* Ring bell when input queue is full. */ -#endif - - /* Output modes. */ - tcflag_t c_oflag; -#define OPOST 0x0001 /* Perform output processing. */ -#ifdef __USE_BSD -# define OLCUC 0x00000002 /* Map lower case to upper case on output. */ -# define ONLCR 0x00000004 /* Map NL to CR-NL on output. */ -# define OCRNL 0x00000008 -# define ONOCR 0x00000010 -# define ONLRET 0x00000020 -# define OFILL 0x00000040 -# define OFDEL 0x00000080 -# define NLDLY 0x00000100 -# define NL0 0 -# define NL1 0x00000100 -# define CRDLY 0x00000600 -# define CR0 0 -# define CR1 0x00000200 -# define CR2 0x00000400 -# define CR3 0x00000600 -# define TABDLY 0x00001800 -# define TAB0 0 -# define TAB1 0x00000800 -# define TAB2 0x00001000 -# define XTABS 0x00001800 -# define TAB3 XTABS -# define BSDLY 0x00002000 -# define BS0 0 -# define BS1 0x00002000 -# define VTDLY 0x00004000 -# define VT0 0 -# define VT1 0x00004000 -# define FFDLY 0x00008000 -# define FF0 0 -# define FF1 0x00008000 -# define PAGEOUT 0x00010000 -# define WRAP 0x00020000 -#endif - - /* Control modes. */ - tcflag_t c_cflag; -#define CSIZE (CS5|CS6|CS7|CS8) /* Number of bits per byte (mask). */ -#define CS5 0 /* 5 bits per byte. */ -#define CS6 0x00000010 /* 6 bits per byte. */ -#define CS7 0x00000020 /* 7 bits per byte. */ -#define CS8 0x00000030 /* 8 bits per byte. */ -#define CSTOPB 0x00000040 /* Two stop bits instead of one. */ -#define CREAD 0x00000080 /* Enable receiver. */ -#define PARENB 0x00000100 /* Parity enable. */ -#define PARODD 0x00000200 /* Odd parity instead of even. */ -#define HUPCL 0x00000400 /* Hang up on last close. */ -#define CLOCAL 0x00000800 /* Ignore modem status lines. */ -#ifdef __USE_BSD -# define LOBLK 0x00001000 -# define CRTSCTS 0x80000000 -# define CIBAUD 0x000f0000 /* Mask for input speed from c_cflag. */ -# define CBAUD 0x0000000f /* Mask for output speed from c_cflag. */ -# define IBSHIFT 16 /* Bits to shift for input speed. */ -#endif - - /* Input and output baud rates. These are encoded in c_cflag. */ -#define B0 0 -#define B50 1 -#define B75 2 -#define B110 3 -#define B134 4 -#define B150 5 -#define B200 6 -#define B300 7 -#define B600 8 -#define B1200 9 -#define B1800 10 -#define B2400 11 -#define B4800 12 -#define B9600 13 -#define B19200 14 -#define B38400 15 -#ifdef __USE_BSD -# define EXTA 14 -# define EXTB 15 -#endif - - /* Local modes. */ - tcflag_t c_lflag; -#ifdef __USE_BSD -# define ECHOKE 0x00000800 /* Visual erase for KILL. */ -#endif -#define ECHOE 0x00000010 /* Visual erase for ERASE. */ -#define ECHOK 0x00000020 /* Echo NL after KILL. */ -#define ECHO 0x00000008 /* Enable echo. */ -#define ECHONL 0x00000040 /* Echo NL even if ECHO is off. */ -#ifdef __USE_BSD -# define ECHOPRT 0x00000400 /* Hardcopy visual erase. */ -# define ECHOCTL 0x00000200 /* Echo control characters as ^X. */ -#endif -#define ISIG 0x00000001 /* Enable signals. */ -#define ICANON 0x00000002 /* Do erase and kill processing. */ -#define IEXTEN 0x00008000 /* Enable DISCARD and LNEXT. */ -#define TOSTOP 0x00000100 /* Send SIGTTOU for background output. */ -#ifdef __USE_BSD -# define PENDIN 0x00004000 /* Retype pending input (state). */ -#endif -#define NOFLSH 0x00000080 /* Disable flush after interrupt. */ - - char c_line; /* Line discipline (?) */ - - /* Control characters. */ -#define VEOF 4 /* End-of-file character [ICANON]. */ -#define VEOL 5 /* End-of-line character [ICANON]. */ -#ifdef __USE_BSD -# define VEOL2 6 /* Second EOL character [ICANON]. */ -# define VSWTCH 7 /* ??? */ -#endif -#define VERASE 2 /* Erase character [ICANON]. */ -#ifdef __USE_BSD -# define VWERASE 14 /* Word-erase character [ICANON]. */ -#endif -#define VKILL 3 /* Kill-line character [ICANON]. */ -#ifdef __USE_BSD -# define VREPRINT 12 /* Reprint-line character [ICANON]. */ -#endif -#define VINTR 0 /* Interrupt character [ISIG]. */ -#define VQUIT 1 /* Quit character [ISIG]. */ -#define VSUSP 10 /* Suspend character [ISIG]. */ -#ifdef __USE_BSD -# define VDSUSP 11 /* Delayed suspend character [ISIG]. */ -#endif -#define VSTART 8 /* Start (X-ON) character [IXON, IXOFF]. */ -#define VSTOP 9 /* Stop (X-OFF) character [IXON, IXOFF]. */ -#ifdef __USE_BSD -# define VLNEXT 15 /* Literal-next character [IEXTEN]. */ -# define VDISCARD 13 /* Discard character [IEXTEN]. */ -#endif -#define VMIN VEOF /* Minimum number of bytes read at once [!ICANON]. */ -#define VTIME VEOL /* Time-out value (tenths of a second) [!ICANON]. */ -#define NCCS 17 - cc_t c_cc[NCCS]; -}; - -#define _IOT_termios /* Hurd ioctl type field. */ \ - _IOT (_IOTS (cflag_t), 4, _IOTS (cc_t), NCCS, _IOTS (speed_t), 2) - -/* Values for the OPTIONAL_ACTIONS argument to `tcsetattr'. */ -#define TCSANOW 0 /* Change immediately. */ -#define TCSADRAIN 1 /* Change when pending output is written. */ -#define TCSAFLUSH 2 /* Flush pending input before changing. */ - -/* Values for the QUEUE_SELECTOR argument to `tcflush'. */ -#define TCIFLUSH 0 /* Discard data received but not yet read. */ -#define TCOFLUSH 1 /* Discard data written but not yet sent. */ -#define TCIOFLUSH 2 /* Discard all pending data. */ - -/* Values for the ACTION argument to `tcflow'. */ -#define TCOOFF 0 /* Suspend output. */ -#define TCOON 1 /* Restart suspended output. */ -#define TCIOFF 2 /* Send a STOP character. */ -#define TCION 3 /* Send a START character. */ diff --git a/sysdeps/unix/bsd/sun/sunos4/bits/utsname.h b/sysdeps/unix/bsd/sun/sunos4/bits/utsname.h deleted file mode 100644 index a0246c2a36..0000000000 --- a/sysdeps/unix/bsd/sun/sunos4/bits/utsname.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright (C) 1997, 2002 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _SYS_UTSNAME_H -# error "Never include <bits/utsname.h> directly; use <sys/utsname.h> instead." -#endif - -#define _UTSNAME_LENGTH 9 -#define _UTSNAME_NODENAME_LENGTH 65 diff --git a/sysdeps/unix/bsd/sun/sunos4/mmap.c b/sysdeps/unix/bsd/sun/sunos4/mmap.c deleted file mode 100644 index c513ae27eb..0000000000 --- a/sysdeps/unix/bsd/sun/sunos4/mmap.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 1994, 1995, 1997 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include <sys/types.h> -#include <sys/mman.h> -#include <errno.h> - -/* Map addresses starting near ADDR and extending for LEN bytes. from - OFFSET into the file FD describes according to PROT and FLAGS. If ADDR - is nonzero, it is the desired mapping address. If the MAP_FIXED bit is - set in FLAGS, the mapping will be at ADDR exactly (which must be - page-aligned); otherwise the system chooses a convenient nearby address. - The return value is the actual mapping address chosen or MAP_FAILED - for errors (in which case `errno' is set). A successful `mmap' call - deallocates any previous mapping for the affected region. */ - -extern __ptr_t __mmap_syscall (__ptr_t addr, size_t len, - int prot, int flags, int fd, off_t offset); - - -__ptr_t -__mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset) -{ - return __mmap_syscall (addr, len, prot, flags | _MAP_NEW, fd, offset); -} - -weak_alias (__mmap, mmap) diff --git a/sysdeps/unix/bsd/sun/sunos4/speed.c b/sysdeps/unix/bsd/sun/sunos4/speed.c deleted file mode 100644 index 262d70fdfb..0000000000 --- a/sysdeps/unix/bsd/sun/sunos4/speed.c +++ /dev/null @@ -1,118 +0,0 @@ -/* `struct termios' speed frobnication functions. SunOS 4 version. - Copyright (C) 1991,1992,1993,1996,1997,2002 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include <stddef.h> -#include <errno.h> -#include <termios.h> - -static const speed_t speeds[] = - { - 0, - 50, - 75, - 110, - 134, - 150, - 200, - 300, - 600, - 1200, - 1800, - 2400, - 4800, - 9600, - 19200, - 38400, - }; - - -/* Return the output baud rate stored in *TERMIOS_P. */ -speed_t -cfgetospeed (termios_p) - const struct termios *termios_p; -{ - return termios_p->c_cflag & CBAUD; -} - -/* Return the input baud rate stored in *TERMIOS_P. */ -speed_t -cfgetispeed (termios_p) - const struct termios *termios_p; -{ - return (termios_p->c_cflag & CIBAUD) >> IBSHIFT; -} - -/* Set the output baud rate stored in *TERMIOS_P to SPEED. */ -int -cfsetospeed (termios_p, speed) - struct termios *termios_p; - speed_t speed; -{ - register unsigned int i; - - if (termios_p == NULL) - { - __set_errno (EINVAL); - return -1; - } - - /* This allows either B1200 or 1200 to work. XXX - Do we really want to try to support this, given that - fetching the speed must return one or the other? */ - - for (i = 0; i < sizeof (speeds) / sizeof (speeds[0]); ++i) - if (i == speed || speeds[i] == speed) - { - termios_p->c_cflag &= ~CBAUD; - termios_p->c_cflag |= i; - return 0; - } - - __set_errno (EINVAL); - return -1; -} -libc_hidden_def (cfsetospeed) - -/* Set the input baud rate stored in *TERMIOS_P to SPEED. */ -int -cfsetispeed (termios_p, speed) - struct termios *termios_p; - speed_t speed; -{ - register unsigned int i; - - if (termios_p == NULL) - { - __set_errno (EINVAL); - return -1; - } - - /* See comment in cfsetospeed (above). */ - for (i = 0; i < sizeof (speeds) / sizeof (speeds[0]); ++i) - if (i == speed || speeds[i] == speed) - { - termios_p->c_cflag &= ~CIBAUD; - termios_p->c_cflag |= i << IBSHIFT; - return 0; - } - - __set_errno (EINVAL); - return -1; -} -libc_hidden_def (cfsetispeed) diff --git a/sysdeps/unix/bsd/sun/sunos4/sys/ttydefaults.h b/sysdeps/unix/bsd/sun/sunos4/sys/ttydefaults.h deleted file mode 100644 index d18433c6fe..0000000000 --- a/sysdeps/unix/bsd/sun/sunos4/sys/ttydefaults.h +++ /dev/null @@ -1,100 +0,0 @@ -/*- - * Copyright (c) 1982, 1986, 1993 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)ttydefaults.h 8.4 (Berkeley) 1/21/94 - */ - -/* - * System wide defaults for terminal state. SunOS 4 version. - */ -#ifndef _SYS_TTYDEFAULTS_H_ -#define _SYS_TTYDEFAULTS_H_ - -/* - * Defaults on "first" open. - */ -#define TTYDEF_IFLAG (BRKINT | ISTRIP | ICRNL | IMAXBEL | IXON | IXANY) -#define TTYDEF_OFLAG (OPOST | ONLCR | XTABS) -#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL) -#define TTYDEF_CFLAG (CREAD | CS7 | PARENB | HUPCL) -#define TTYDEF_SPEED (B9600) - -/* - * Control Character Defaults - */ -#define CTRL(x) (x&037) -#define CEOF CTRL('d') -#ifdef _POSIX_VDISABLE -# define CEOL _POSIX_VDISABLE -#else -# define CEOL ((unsigned char)'\377') /* XXX avoid _POSIX_VDISABLE */ -#endif -#define CERASE 0177 -#define CINTR CTRL('c') -#ifdef _POSIX_VDISABLE -# define CSTATUS _POSIX_VDISABLE -#else -# define CSTATUS ((unsigned char)'\377') /* XXX avoid _POSIX_VDISABLE */ -#endif -#define CKILL CTRL('u') -#define CMIN 1 -#define CQUIT 034 /* FS, ^\ */ -#define CSUSP CTRL('z') -#define CTIME 0 -#define CDSUSP CTRL('y') -#define CSTART CTRL('q') -#define CSTOP CTRL('s') -#define CLNEXT CTRL('v') -#define CDISCARD CTRL('o') -#define CWERASE CTRL('w') -#define CREPRINT CTRL('r') -#define CEOT CEOF -/* compat */ -#define CBRK CEOL -#define CRPRNT CREPRINT -#define CFLUSH CDISCARD - -/* PROTECTED INCLUSION ENDS HERE */ -#endif /* !_SYS_TTYDEFAULTS_H_ */ - -/* - * #define TTYDEFCHARS to include an array of default control characters. - */ -#ifdef TTYDEFCHARS -cc_t ttydefchars[NCCS] = { - CEOF, CEOL, CEOL, CERASE, CWERASE, CKILL, CREPRINT, - _POSIX_VDISABLE, CINTR, CQUIT, CSUSP, CDSUSP, CSTART, CSTOP, CLNEXT, - CDISCARD, CMIN, CTIME, CSTATUS, _POSIX_VDISABLE -}; -#undef TTYDEFCHARS -#endif diff --git a/sysdeps/unix/bsd/sun/sunos4/syscalls.list b/sysdeps/unix/bsd/sun/sunos4/syscalls.list deleted file mode 100644 index 59992eed53..0000000000 --- a/sysdeps/unix/bsd/sun/sunos4/syscalls.list +++ /dev/null @@ -1,6 +0,0 @@ -# File name Caller Syscall name # args Strong name Weak names - -msync - msync 3 msync -poll - poll 3 poll -sys_mmap mmap mmap 5 __mmap_syscall -sys_wait4 wait4 wait4 4 __wait4_syscall diff --git a/sysdeps/unix/bsd/sun/sunos4/system.c b/sysdeps/unix/bsd/sun/sunos4/system.c deleted file mode 100644 index 2c8e634bc8..0000000000 --- a/sysdeps/unix/bsd/sun/sunos4/system.c +++ /dev/null @@ -1,2 +0,0 @@ -/* SunOS 4 does have `waitpid'. Avoid unix/system.c, which says we don't. */ -#include <sysdeps/posix/system.c> diff --git a/sysdeps/unix/bsd/sun/sunos4/wait.c b/sysdeps/unix/bsd/sun/sunos4/wait.c deleted file mode 100644 index 79d54580fd..0000000000 --- a/sysdeps/unix/bsd/sun/sunos4/wait.c +++ /dev/null @@ -1 +0,0 @@ -#include <sysdeps/unix/bsd/bsd4.4/wait.c> diff --git a/sysdeps/unix/bsd/sun/sunos4/wait3.c b/sysdeps/unix/bsd/sun/sunos4/wait3.c deleted file mode 100644 index 0b3bdee771..0000000000 --- a/sysdeps/unix/bsd/sun/sunos4/wait3.c +++ /dev/null @@ -1 +0,0 @@ -#include <sysdeps/unix/bsd/bsd4.4/wait3.c> diff --git a/sysdeps/unix/bsd/sun/sunos4/wait4.c b/sysdeps/unix/bsd/sun/sunos4/wait4.c deleted file mode 100644 index 097c15e7d9..0000000000 --- a/sysdeps/unix/bsd/sun/sunos4/wait4.c +++ /dev/null @@ -1,50 +0,0 @@ -/* This implements wait4 with the 4.4 BSD semantics (also those documented in - SunOS 4.1) on top of SunOS's wait4 system call, which has semantics - different from those documented. Go Sun! - Copyright (C) 1991,1992,1993,1995,1997,2004 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 Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include <sys/types.h> -#include <sys/wait.h> -#include <unistd.h> - -extern pid_t __wait4_syscall (pid_t pid, __WAIT_STATUS_DEFN stat_loc, - int options, struct rusage *usage); - -pid_t -__wait4 (pid, stat_loc, options, usage) - pid_t pid; - __WAIT_STATUS_DEFN stat_loc; - int options; - struct rusage *usage; -{ - switch (pid) - { - case WAIT_ANY: - pid = 0; - break; - - case WAIT_MYPGRP: - pid = - getpgrp (); - break; - } - - return __wait4_syscall (pid, stat_loc, options, usage); -} - -weak_alias (__wait4, wait4) diff --git a/sysdeps/unix/bsd/sun/sunos4/waitpid.c b/sysdeps/unix/bsd/sun/sunos4/waitpid.c deleted file mode 100644 index 8378982ac7..0000000000 --- a/sysdeps/unix/bsd/sun/sunos4/waitpid.c +++ /dev/null @@ -1 +0,0 @@ -#include <sysdeps/unix/bsd/bsd4.4/waitpid.c> diff --git a/sysdeps/unix/bsd/sun/syscalls.list b/sysdeps/unix/bsd/sun/syscalls.list deleted file mode 100644 index 079aa9157a..0000000000 --- a/sysdeps/unix/bsd/sun/syscalls.list +++ /dev/null @@ -1,3 +0,0 @@ -# File name Caller Syscall name # args Strong name Weak names - -sigvec - sigvec 3 __raw_sigvec diff --git a/sysdeps/unix/bsd/ulimit.c b/sysdeps/unix/bsd/ulimit.c index 91d77e926a..963d156e2c 100644 --- a/sysdeps/unix/bsd/ulimit.c +++ b/sysdeps/unix/bsd/ulimit.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 94, 96, 97, 98, 2001 Free Software Foundation, Inc. +/* Copyright (C) 1991,1992,1994-1998,2001,2005 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 @@ -23,9 +23,6 @@ #include <unistd.h> #include <sys/resource.h> -#ifndef HAVE_GNU_LD -#define _etext etext -#endif extern int _etext; diff --git a/sysdeps/unix/i386/brk.S b/sysdeps/unix/i386/brk.S index a7604d7e7a..d8dd96b4ce 100644 --- a/sysdeps/unix/i386/brk.S +++ b/sysdeps/unix/i386/brk.S @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,92,93,95,97,2002 Free Software Foundation, Inc. +/* Copyright (C) 1991,92,93,95,97,2002,2005 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 @@ -25,11 +25,7 @@ .data .globl C_SYMBOL_NAME(__curbrk) C_LABEL(__curbrk) -#ifdef HAVE_GNU_LD .long C_SYMBOL_NAME(_end) -#else - .long C_SYMBOL_NAME(end) -#endif .text SYSCALL__ (brk, 1) diff --git a/sysdeps/unix/sh/sysdep.S b/sysdeps/unix/sh/sysdep.S index 074b74333c..6e4798e45a 100644 --- a/sysdeps/unix/sh/sysdep.S +++ b/sysdeps/unix/sh/sysdep.S @@ -1,4 +1,4 @@ -/* Copyright (C) 1999, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2000, 2005 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 @@ -98,5 +98,3 @@ skip: #endif #endif END(__syscall_error) - -weak_alias (__syscall_error, syscall_error) diff --git a/sysdeps/unix/sparc/brk.S b/sysdeps/unix/sparc/brk.S index 2a16463b0f..29255fc68e 100644 --- a/sysdeps/unix/sparc/brk.S +++ b/sysdeps/unix/sparc/brk.S @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1995, 1997, 2005 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 @@ -29,11 +29,7 @@ .data .global C_SYMBOL_NAME(__curbrk) C_LABEL(__curbrk) -#ifdef HAVE_GNU_LD .long C_SYMBOL_NAME(_end) -#else - .long C_SYMBOL_NAME(end) -#endif .text ENTRY (__brk) diff --git a/sysdeps/unix/sysv/linux/alpha/fxstatat.c b/sysdeps/unix/sysv/linux/alpha/fxstatat.c new file mode 100644 index 0000000000..65b7ad97a3 --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/fxstatat.c @@ -0,0 +1,100 @@ +/* Copyright (C) 2005 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#define __fxstatat64 __fxstatat64_disable + +#include <errno.h> +#include <fcntl.h> +#include <stddef.h> +#include <stdio.h> +#include <sys/stat.h> +#include <kernel_stat.h> +#include <sysdep.h> +#include <sys/syscall.h> +#include <xstatconv.h> + +#undef __fxstatat64 + + +/* Get information about the file NAME in BUF. */ +int +__fxstatat (int vers, int fd, const char *file, struct stat *st, int flag) +{ + if (flag & ~AT_SYMLINK_NOFOLLOW) + { + __set_errno (EINVAL); + return -1; + } + + char *buf = NULL; + + if (fd != AT_FDCWD && file[0] != '/') + { + size_t filelen = strlen (file); + static const char procfd[] = "/proc/self/fd/%d/%s"; + /* Buffer for the path name we are going to use. It consists of + - the string /proc/self/fd/ + - the file descriptor number + - the file name provided. + The final NUL is included in the sizeof. A bit of overhead + due to the format elements compensates for possible negative + numbers. */ + size_t buflen = sizeof (procfd) + sizeof (int) * 3 + filelen; + buf = alloca (buflen); + + __snprintf (buf, buflen, procfd, fd, file); + file = buf; + } + + INTERNAL_SYSCALL_DECL (err); + int result, errno_out; + struct kernel_stat kst; + + if (vers == _STAT_VER_KERNEL64 && !__libc_missing_axp_stat64) + { + if (flags & AT_SYMLINK_NOFOLLOW) + result = INTERNAL_SYSCALL (lstat64, err, 2, file, st); + else + result = INTERNAL_SYSCALL (stat64, err, 2, file, st); + + if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + return result; + errno_out = INTERNAL_SYSCALL_ERRNO (result, err); + if (errno_out != ENOSYS) + goto fail; + __libc_missing_axp_stat64 = 1; + } + + if (flag & AT_SYMLINK_NOFOLLOW) + result = INTERNAL_SYSCALL (lstat, err, 2, file, &kst); + else + result = INTERNAL_SYSCALL (stat, err, 2, file, &kst); + + if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + return __xstat_conv (vers, &kst, st); + errno_out = INTERNAL_SYSCALL_ERRNO (result, err); + + fail: + __atfct_seterrno (errno_out, fd, buf); + + return -1; +} +hidden_def (__xstat) +weak_alias (__xstat, _xstat); +strong_alias (__xstat, __xstat64); +hidden_ver (__xstat, __xstat64) diff --git a/sysdeps/unix/sysv/linux/device-nrs.h b/sysdeps/unix/sysv/linux/device-nrs.h index 6b6578ec5f..b30c1dbede 100644 --- a/sysdeps/unix/sysv/linux/device-nrs.h +++ b/sysdeps/unix/sysv/linux/device-nrs.h @@ -1,5 +1,5 @@ /* Device numbers of devices used in the implementation. Linux version. - Copyright (C) 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2005 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 @@ -26,6 +26,10 @@ #define DEV_NULL_MAJOR 1 #define DEV_NULL_MINOR 3 +/* /dev/full is (1,7). */ +#define DEV_FULL_MAJOR 1 +#define DEV_FULL_MINOR 7 + /* Pseudo tty slaves. For Linux we use the Unix98 ttys. We could also include the old BSD-style tty buts they should not be used and the extra test would only slow down correctly set up systems. If a diff --git a/sysdeps/unix/sysv/linux/fchownat.c b/sysdeps/unix/sysv/linux/fchownat.c new file mode 100644 index 0000000000..d3cb992a09 --- /dev/null +++ b/sysdeps/unix/sysv/linux/fchownat.c @@ -0,0 +1,73 @@ +/* Copyright (C) 2005 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <errno.h> +#include <fcntl.h> +#include <stddef.h> +#include <stdio.h> +#include <unistd.h> +#include <sys/types.h> + +/* Change the owner and group of FILE. */ +int +fchownat (fd, file, owner, group, flag) + int fd; + const char *file; + uid_t owner; + gid_t group; + int flag; +{ + if (flag & ~AT_SYMLINK_NOFOLLOW) + { + __set_errno (EINVAL); + return -1; + } + + char *buf = NULL; + + if (fd != AT_FDCWD && file[0] != '/') + { + size_t filelen = strlen (file); + static const char procfd[] = "/proc/self/fd/%d/%s"; + /* Buffer for the path name we are going to use. It consists of + - the string /proc/self/fd/ + - the file descriptor number + - the file name provided. + The final NUL is included in the sizeof. A bit of overhead + due to the format elements compensates for possible negative + numbers. */ + size_t buflen = sizeof (procfd) + sizeof (int) * 3 + filelen; + buf = alloca (buflen); + + __snprintf (buf, buflen, procfd, fd, file); + file = buf; + } + + int result; + INTERNAL_SYSCALL_DECL (err); + + if (flag & AT_SYMLINK_NOFOLLOW) + result = INTERNAL_SYSCALL (lchown, err, 3, file, owner, group); + else + result = INTERNAL_SYSCALL (chown, err, 3, file, owner, group); + + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf); + + return result; +} diff --git a/sysdeps/unix/sysv/linux/futimesat.c b/sysdeps/unix/sysv/linux/futimesat.c new file mode 100644 index 0000000000..2fdedb0ff4 --- /dev/null +++ b/sysdeps/unix/sysv/linux/futimesat.c @@ -0,0 +1,97 @@ +/* Copyright (C) 2005 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <errno.h> +#include <fcntl.h> +#include <stddef.h> +#include <stdio.h> +#include <utime.h> +#include <sys/time.h> +#include <sysdep.h> +#include "kernel-features.h" + + +/* Change the access time of FILE relative to FD to TVP[0] and + the modification time of FILE to TVP[1]. */ +int +futimesat (fd, file, tvp) + int fd; + const char *file; + const struct timeval tvp[2]; +{ + char *buf = NULL; + + if (fd != AT_FDCWD && file[0] != '/') + { + size_t filelen = strlen (file); + static const char procfd[] = "/proc/self/fd/%d/%s"; + /* Buffer for the path name we are going to use. It consists of + - the string /proc/self/fd/ + - the file descriptor number + - the file name provided. + The final NUL is included in the sizeof. A bit of overhead + due to the format elements compensates for possible negative + numbers. */ + size_t buflen = sizeof (procfd) + sizeof (int) * 3 + filelen; + buf = alloca (buflen); + + __snprintf (buf, buflen, procfd, fd, file); + file = buf; + } + + int result; + INTERNAL_SYSCALL_DECL (err); + +#ifdef __NR_utimes + result = INTERNAL_SYSCALL (utimes, err, 2, file, tvp); + if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + return result; + +# ifndef __ASSUME_UTIMES + if (INTERNAL_SYSCALL_ERRNO (result, err) != ENOSYS) + goto fail; +# endif +#endif + + /* The utimes() syscall does not exist or is not available in the + used kernel. Use utime(). For this we have to convert to the + data format utime() expects. */ +#ifndef __ASSUME_UTIMES + struct utimbuf tmp; + struct utimbuf *times; + + if (tvp != NULL) + { + times = &tmp; + tmp.actime = tvp[0].tv_sec + tvp[0].tv_usec / 1000000; + tmp.modtime = tvp[1].tv_sec + tvp[1].tv_usec / 1000000; + } + else + times = NULL; + + result = INTERNAL_SYSCALL (utime, err, 2, file, times); + if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + return result; + + fail: +#endif + + __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf); + + return -1; +} diff --git a/sysdeps/unix/sysv/linux/fxstatat.c b/sysdeps/unix/sysv/linux/fxstatat.c new file mode 100644 index 0000000000..9bc3dbc459 --- /dev/null +++ b/sysdeps/unix/sysv/linux/fxstatat.c @@ -0,0 +1,106 @@ +/* Copyright (C) 2005 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* Ho hum, if fxstatat == fxstatat64 we must get rid of the prototype or gcc + will complain since they don't strictly match. */ +#define __fxstatat64 __fxstatat64_disable + +#include <errno.h> +#include <fcntl.h> +#include <stddef.h> +#include <stdio.h> +#include <sys/stat.h> +#include <kernel_stat.h> + +#include <sysdep.h> +#include <sys/syscall.h> +#include <bp-checks.h> + +#include <xstatconv.h> + +/* Get information about the file NAME in BUF. */ +int +__fxstatat (int vers, int fd, const char *file, struct stat *st, int flag) +{ + if (flag & ~AT_SYMLINK_NOFOLLOW) + { + __set_errno (EINVAL); + return -1; + } + + char *buf = NULL; + + if (fd != AT_FDCWD && file[0] != '/') + { + size_t filelen = strlen (file); + static const char procfd[] = "/proc/self/fd/%d/%s"; + /* Buffer for the path name we are going to use. It consists of + - the string /proc/self/fd/ + - the file descriptor number + - the file name provided. + The final NUL is included in the sizeof. A bit of overhead + due to the format elements compensates for possible negative + numbers. */ + size_t buflen = sizeof (procfd) + sizeof (int) * 3 + filelen; + buf = alloca (buflen); + + __snprintf (buf, buflen, procfd, fd, file); + file = buf; + } + + int result; + INTERNAL_SYSCALL_DECL (err); + + if (vers == _STAT_VER_KERNEL) + { + if (flag & AT_SYMLINK_NOFOLLOW) + result = INTERNAL_SYSCALL (lstat, err, 2, CHECK_STRING (file), + CHECK_1 ((struct kernel_stat *) st)); + else + result = INTERNAL_SYSCALL (stat, err, 2, CHECK_STRING (file), + CHECK_1 ((struct kernel_stat *) st)); + + if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + return result; + } + +#ifdef STAT_IS_KERNEL_STAT + __set_errno (EINVAL); + return -1; +#else + struct kernel_stat kst; + + if (flag & AT_SYMLINK_NOFOLLOW) + result = INTERNAL_SYSCALL (lstat, err, 2, CHECK_STRING (file), + __ptrvalue (&kst)); + else + result = INTERNAL_SYSCALL (stat, err, 2, CHECK_STRING (file), + __ptrvalue (&kst)); + + if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + return __xstat_conv (vers, &kst, st); +#endif + + __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf); + + return -1; +} +#ifdef XSTAT_IS_XSTAT64 +# undef __fxstatat64 +strong_alias (__fxstatat, __fxstatat64); +#endif diff --git a/sysdeps/unix/sysv/linux/fxstatat64.c b/sysdeps/unix/sysv/linux/fxstatat64.c new file mode 100644 index 0000000000..8c41db710c --- /dev/null +++ b/sysdeps/unix/sysv/linux/fxstatat64.c @@ -0,0 +1,135 @@ +/* Copyright (C) 2005 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <errno.h> +#include <fcntl.h> +#include <stddef.h> +#include <stdio.h> +#include <sys/stat.h> +#include <kernel_stat.h> + +#include <sysdep.h> +#include <sys/syscall.h> +#include <bp-checks.h> + +#include "kernel-features.h" + +#if __ASSUME_STAT64_SYSCALL == 0 +# include <xstatconv.h> +#endif + +#ifdef __NR_stat64 +# if __ASSUME_STAT64_SYSCALL == 0 +/* The variable is shared between all wrappers around *stat64 calls. + This is the definition. */ +extern int __have_no_stat64; +# endif +#endif + +/* Get information about the file NAME in BUF. */ + +int +__fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag) +{ + if (flag & ~AT_SYMLINK_NOFOLLOW) + { + __set_errno (EINVAL); + return -1; + } + + char *buf = NULL; + + if (fd != AT_FDCWD && file[0] != '/') + { + size_t filelen = strlen (file); + static const char procfd[] = "/proc/self/fd/%d/%s"; + /* Buffer for the path name we are going to use. It consists of + - the string /proc/self/fd/ + - the file descriptor number + - the file name provided. + The final NUL is included in the sizeof. A bit of overhead + due to the format elements compensates for possible negative + numbers. */ + size_t buflen = sizeof (procfd) + sizeof (int) * 3 + filelen; + buf = alloca (buflen); + + __snprintf (buf, buflen, procfd, fd, file); + file = buf; + } + + int result; + INTERNAL_SYSCALL_DECL (err); + +#if __ASSUME_STAT64_SYSCALL > 0 + if (flag & AT_SYMLINK_NOFOLLOW) + result = INTERNAL_SYSCALL (lstat64, err, 2, CHECK_STRING (file), + CHECK_1 (st)); + else + result = INTERNAL_SYSCALL (stat64, err, 2, CHECK_STRING (file), + CHECK_1 (st)); + if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + { +# if defined _HAVE_STAT64___ST_INO && __ASSUME_ST_INO_64_BIT == 0 + if (st->__st_ino != (__ino_t) st->st_ino) + st->st_ino = st->__st_ino; +# endif + return result; + } +#else + struct kernel_stat kst; +# if defined __NR_stat64 + if (! __have_no_stat64) + { + if (flag & AT_SYMLINK_NOFOLLOW) + result = INTERNAL_SYSCALL (lstat64, err, 2, CHECK_STRING (file), + CHECK_1 (st)); + else + result = INTERNAL_SYSCALL (stat64, err, 2, CHECK_STRING (file), + CHECK_1 (st)); + + if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + { +# if defined _HAVE_STAT64___ST_INO && __ASSUME_ST_INO_64_BIT == 0 + if (st->__st_ino != (__ino_t) st->st_ino) + st->st_ino = st->__st_ino; +# endif + return result; + } + if (INTERNAL_SYSCALL_ERRNO (result, err) != ENOSYS) + goto fail; + + __have_no_stat64 = 1; + } +# endif + + if (flag & AT_SYMLINK_NOFOLLOW) + result = INTERNAL_SYSCALL (lstat, err, 2, CHECK_STRING (file), + __ptrvalue (&kst)); + else + result = INTERNAL_SYSCALL (stat, err, 2, CHECK_STRING (file), + __ptrvalue (&kst)); + + if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + return __xstat64_conv (vers, &kst, st); + + fail: + __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf); + + return -1; +#endif +} diff --git a/sysdeps/unix/sysv/linux/i386/fchownat.c b/sysdeps/unix/sysv/linux/i386/fchownat.c new file mode 100644 index 0000000000..331623f73d --- /dev/null +++ b/sysdeps/unix/sysv/linux/i386/fchownat.c @@ -0,0 +1,177 @@ +/* Copyright (C) 2005 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <errno.h> +#include <fcntl.h> +#include <stdio.h> +#include <unistd.h> + +#include <sysdep.h> +#include <sys/syscall.h> +#include <shlib-compat.h> +#include <bp-checks.h> + +#include <linux/posix_types.h> +#include "kernel-features.h" + +/* + In Linux 2.1.x the chown functions have been changed. A new function lchown + was introduced. The new chown now follows symlinks - the old chown and the + new lchown do not follow symlinks. + The new lchown function has the same number as the old chown had and the + new chown has a new number. When compiling with headers from Linux > 2.1.8x + it's impossible to run this libc with older kernels. In these cases libc + has therefore to route calls to chown to the old chown function. +*/ + +extern int __chown_is_lchown (const char *__file, uid_t __owner, + gid_t __group); +extern int __real_chown (const char *__file, uid_t __owner, gid_t __group); + + +#if defined __NR_lchown || __ASSUME_LCHOWN_SYSCALL > 0 +/* Running under Linux > 2.1.80. */ + +# ifdef __NR_chown32 +# if __ASSUME_32BITUIDS == 0 +/* This variable is shared with all files that need to check for 32bit + uids. */ +extern int __libc_missing_32bit_uids; +# endif +# endif /* __NR_chown32 */ +#endif + + +int +fchownat (int fd, const char *file, uid_t owner, gid_t group, int flag) +{ + if (flag & ~AT_SYMLINK_NOFOLLOW) + { + __set_errno (EINVAL); + return -1; + } + + char *buf = NULL; + + if (fd != AT_FDCWD && file[0] != '/') + { + size_t filelen = strlen (file); + static const char procfd[] = "/proc/self/fd/%d/%s"; + /* Buffer for the path name we are going to use. It consists of + - the string /proc/self/fd/ + - the file descriptor number + - the file name provided. + The final NUL is included in the sizeof. A bit of overhead + due to the format elements compensates for possible negative + numbers. */ + size_t buflen = sizeof (procfd) + sizeof (int) * 3 + filelen; + buf = alloca (buflen); + + __snprintf (buf, buflen, procfd, fd, file); + file = buf; + } + + int result; + INTERNAL_SYSCALL_DECL (err); + +#if defined __NR_lchown || __ASSUME_LCHOWN_SYSCALL > 0 +# if __ASSUME_LCHOWN_SYSCALL == 0 + static int __libc_old_chown; + +# ifdef __NR_chown32 + if (__libc_missing_32bit_uids <= 0) + { + if (flag & AT_SYMLINK_NOFOLLOW) + result = INTERNAL_SYSCALL (lchown32, err, 3, CHECK_STRING (file), + owner, group); + else + result = INTERNAL_SYSCALL (chown32, err, 3, CHECK_STRING (file), + owner, group); + + if (!INTERNAL_SYSCALL_ERROR_P (result, err)) + return result; + if (INTERNAL_SYSCALL_ERRNO (result, err) != ENOSYS) + goto fail; + + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_chown32 */ + + if (((owner + 1) > (uid_t) ((__kernel_uid_t) -1U)) + || ((group + 1) > (gid_t) ((__kernel_gid_t) -1U))) + { + __set_errno (EINVAL); + return -1; + } + + if (!__libc_old_chown && (flag & AT_SYMLINK_NOFOLLOW) == 0) + { + result = INTERNAL_SYSCALL (chown, err, 3, CHECK_STRING (file), owner, + group); + + if (!INTERNAL_SYSCALL_ERROR_P (result, err)) + return result; + if (INTERNAL_SYSCALL_ERRNO (result, err) != ENOSYS) + goto fail; + + __libc_old_chown = 1; + } + + result = INTERNAL_SYSCALL (lchown, err, 3, CHECK_STRING (file), owner, + group); +# elif __ASSUME_32BITUIDS + /* This implies __ASSUME_LCHOWN_SYSCALL. */ + result = INTERNAL_SYSCALL (chown32, err, 3, CHECK_STRING (file), owner, + group); +# else + /* !__ASSUME_32BITUIDS && ASSUME_LCHOWN_SYSCALL */ +# ifdef __NR_chown32 + if (__libc_missing_32bit_uids <= 0) + { + result = INTERNAL_SYSCALL (chown32, err, 3, CHECK_STRING (file), owner, + group); + if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + return result; + if (INTERNAL_SYSCALL_ERRNO (result, err) != ENOSYS) + goto fail; + + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_chown32 */ + if (((owner + 1) > (uid_t) ((__kernel_uid_t) -1U)) + || ((group + 1) > (gid_t) ((__kernel_gid_t) -1U))) + { + __set_errno (EINVAL); + return -1; + } + + result = INTERNAL_SYSCALL (chown, err, 3, CHECK_STRING (file), owner, group); +# endif +#else + result = INTERNAL_SYSCALL (chown, err, 3, CHECK_STRING (file), owner, group); +#endif + + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + { + fail: + __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf); + result = -1; + } + + return result; +} diff --git a/sysdeps/unix/sysv/linux/i386/fxstatat.c b/sysdeps/unix/sysv/linux/i386/fxstatat.c new file mode 100644 index 0000000000..2fc89e69c4 --- /dev/null +++ b/sysdeps/unix/sysv/linux/i386/fxstatat.c @@ -0,0 +1,148 @@ +/* Copyright (C) 2005 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* Ho hum, if fxstatat == fxstatat64 we must get rid of the prototype or gcc + will complain since they don't strictly match. */ +#define __fxstatat64 __fxstatat64_disable + +#include <errno.h> +#include <fcntl.h> +#include <stddef.h> +#include <stdio.h> +#include <sys/stat.h> +#include <kernel_stat.h> + +#include <sysdep.h> +#include <sys/syscall.h> +#include <bp-checks.h> + +#include "kernel-features.h" + +#include <xstatconv.h> + +#ifdef __NR_stat64 +# if __ASSUME_STAT64_SYSCALL == 0 +/* The variable is shared between all wrappers around *stat64 calls. */ +extern int __have_no_stat64; +# endif +#endif + + +/* Get information about the file NAME relative to FD in ST. */ +int +__fxstatat (int vers, int fd, const char *file, struct stat *st, int flag) +{ + if (flag & ~AT_SYMLINK_NOFOLLOW) + { + __set_errno (EINVAL); + return -1; + } + + char *buf = NULL; + + if (fd != AT_FDCWD && file[0] != '/') + { + size_t filelen = strlen (file); + static const char procfd[] = "/proc/self/fd/%d/%s"; + /* Buffer for the path name we are going to use. It consists of + - the string /proc/self/fd/ + - the file descriptor number + - the file name provided. + The final NUL is included in the sizeof. A bit of overhead + due to the format elements compensates for possible negative + numbers. */ + size_t buflen = sizeof (procfd) + sizeof (int) * 3 + filelen; + buf = alloca (buflen); + + __snprintf (buf, buflen, procfd, fd, file); + file = buf; + } + +#if __ASSUME_STAT64_SYSCALL == 0 + struct kernel_stat kst; +#endif + int result; + INTERNAL_SYSCALL_DECL (err); + + if (vers == _STAT_VER_KERNEL) + { + if (flag & AT_SYMLINK_NOFOLLOW) + result = INTERNAL_SYSCALL (lstat, err, 2, CHECK_STRING (file), + CHECK_1 ((struct kernel_stat *) st)); + else + result = INTERNAL_SYSCALL (stat, err, 2, CHECK_STRING (file), + CHECK_1 ((struct kernel_stat *) st)); + goto out; + } + +#if __ASSUME_STAT64_SYSCALL > 0 + struct stat64 st64; + + if (flag & AT_SYMLINK_NOFOLLOW) + result = INTERNAL_SYSCALL (lstat64, err, 2, CHECK_STRING (file), + __ptrvalue (&st64)); + else + result = INTERNAL_SYSCALL (stat64, err, 2, CHECK_STRING (file), + __ptrvalue (&st64)); + if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + return __xstat32_conv (vers, &st64, st); +#else +# if defined __NR_stat64 + /* To support 32 bit UIDs, we have to use stat64. The normal stat + call only returns 16 bit UIDs. */ + if (! __have_no_stat64) + { + struct stat64 st64; + + if (flag & AT_SYMLINK_NOFOLLOW) + result = INTERNAL_SYSCALL (lstat64, err, 2, CHECK_STRING (file), + __ptrvalue (&st64)); + else + result = INTERNAL_SYSCALL (stat64, err, 2, CHECK_STRING (file), + __ptrvalue (&st64)); + + if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + result = __xstat32_conv (vers, &st64, st); + + if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1) + || INTERNAL_SYSCALL_ERRNO (result, err) != ENOSYS) + goto out; + + __have_no_stat64 = 1; + } +# endif + if (flag & AT_SYMLINK_NOFOLLOW) + result = INTERNAL_SYSCALL (lstat, err, 2, CHECK_STRING (file), + __ptrvalue (&kst)); + else + result = INTERNAL_SYSCALL (stat, err, 2, CHECK_STRING (file), + __ptrvalue (&kst)); + if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + return __xstat_conv (vers, &kst, st); +#endif /* __ASSUME_STAT64_SYSCALL */ + + out: + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf); + + return result; +} +#ifdef XSTAT_IS_XSTAT64 +# undef __fxstatat64 +strong_alias (__fxstatat, __fxstatat64); +#endif diff --git a/sysdeps/unix/sysv/linux/m68k/fchownat.c b/sysdeps/unix/sysv/linux/m68k/fchownat.c new file mode 100644 index 0000000000..71df4feda7 --- /dev/null +++ b/sysdeps/unix/sysv/linux/m68k/fchownat.c @@ -0,0 +1,121 @@ +/* Copyright (C) 2005 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <errno.h> +#include <fcntl.h> +#include <stdio.h> +#include <unistd.h> + +#include <sysdep.h> +#include <sys/syscall.h> +#include <bp-checks.h> + +#include <linux/posix_types.h> +#include "kernel-features.h" + +#ifdef __NR_chown32 +# if __ASSUME_32BITUIDS == 0 +/* This variable is shared with all files that need to check for 32bit + uids. */ +extern int __libc_missing_32bit_uids; +# endif +#endif /* __NR_chown32 */ + +int +fchownat (int fd, const char *file, uid_t owner, gid_t group, int flag) +{ + if (flag & ~AT_SYMLINK_NOFOLLOW) + { + __set_errno (EINVAL); + return -1; + } + + char *buf = NULL; + + if (fd != AT_FDCWD && file[0] != '/') + { + size_t filelen = strlen (file); + static const char procfd[] = "/proc/self/fd/%d/%s"; + /* Buffer for the path name we are going to use. It consists of + - the string /proc/self/fd/ + - the file descriptor number + - the file name provided. + The final NUL is included in the sizeof. A bit of overhead + due to the format elements compensates for possible negative + numbers. */ + size_t buflen = sizeof (procfd) + sizeof (int) * 3 + filelen; + buf = alloca (buflen); + + __snprintf (buf, buflen, procfd, fd, file); + file = buf; + } + + int result; + INTERNAL_SYSCALL_DECL (err); + +#if __ASSUME_32BITUIDS > 0 + if (flag & AT_SYMLINK_NOFOLLOW) + result = INTERNAL_SYSCALL (lchown32, err, 3, CHECK_STRING (file), owner, + group); + else + result = INTERNAL_SYSCALL (chown32, err, 3, CHECK_STRING (file), owner, + group); +#else +# ifdef __NR_chown32 + if (__libc_missing_32bit_uids <= 0) + { + if (flag & AT_SYMLINK_NOFOLLOW) + result = INTERNAL_SYSCALL (lchown32, err, 3, CHECK_STRING (file), + owner, group); + else + result = INTERNAL_SYSCALL (chown32, err, 3, CHECK_STRING (file), owner, + group); + + if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + return result; + if (INTERNAL_SYSCALL_ERRNO (result, err) != ENOSYS) + goto fail; + + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_chown32 */ + + if (((owner + 1) > (gid_t) ((__kernel_uid_t) -1U)) + || ((group + 1) > (gid_t) ((__kernel_gid_t) -1U))) + { + __set_errno (EINVAL); + return -1; + } + + if (flag & AT_SYMLINK_NOFOLLOW) + result = INTERNAL_SYSCALL (lchown, err, 3, CHECK_STRING (file), owner, + group); + else + result = INTERNAL_SYSCALL (chown, err, 3, CHECK_STRING (file), owner, + group); +#endif + + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + { + fail: + __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf); + result = -1; + } + + return result; +} diff --git a/sysdeps/unix/sysv/linux/m68k/fxstatat.c b/sysdeps/unix/sysv/linux/m68k/fxstatat.c new file mode 100644 index 0000000000..0f8b3135d8 --- /dev/null +++ b/sysdeps/unix/sysv/linux/m68k/fxstatat.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/i386/fxstatat.c> diff --git a/sysdeps/unix/sysv/linux/openat.c b/sysdeps/unix/sysv/linux/openat.c new file mode 100644 index 0000000000..d5d976cbc4 --- /dev/null +++ b/sysdeps/unix/sysv/linux/openat.c @@ -0,0 +1,117 @@ +/* Copyright (C) 2005 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <errno.h> +#include <fcntl.h> +#include <stdarg.h> +#include <stddef.h> +#include <stdio.h> +#include <string.h> +#include <sys/stat.h> +#include <sysdep-cancel.h> + + +#ifndef OPENAT +# define OPENAT openat +# define MORE_OFLAGS 0 + + +void +attribute_hidden +__atfct_seterrno (int errval, int fd, const char *buf) +{ + if (buf != NULL && errval == ENOTDIR) + { + /* This can mean either the file descriptor is invalid or + /proc is not mounted. */ + struct stat64 st; + if (__fxstat64 (_STAT_VER, fd, &st) != 0) + /* errno is already set correctly. */ + return; + + /* If /proc is not mounted there is nothing we can do. */ + if (S_ISDIR (st.st_mode) + && (__xstat64 (_STAT_VER, "/proc/self/fd", &st) != 0 + || !S_ISDIR (st.st_mode))) + errval = ENOSYS; + } + + __set_errno (errval); +} +#endif + +/* Open FILE with access OFLAG. Interpret relative paths relative to + the directory associated with FD. If OFLAG includes O_CREAT, a + third argument is the file protection. */ +int +OPENAT (fd, file, oflag) + int fd; + const char *file; + int oflag; +{ + char *buf = NULL; + + if (fd != AT_FDCWD && file[0] != '/') + { + size_t filelen = strlen (file); + static const char procfd[] = "/proc/self/fd/%d/%s"; + /* Buffer for the path name we are going to use. It consists of + - the string /proc/self/fd/ + - the file descriptor number + - the file name provided. + The final NUL is included in the sizeof. A bit of overhead + due to the format elements compensates for possible negative + numbers. */ + size_t buflen = sizeof (procfd) + sizeof (int) * 3 + filelen; + buf = alloca (buflen); + + __snprintf (buf, buflen, procfd, fd, file); + file = buf; + } + + mode_t mode = 0; + if (oflag & O_CREAT) + { + va_list arg; + va_start (arg, oflag); + mode = va_arg (arg, mode_t); + va_end (arg); + } + + INTERNAL_SYSCALL_DECL (err); + int res; + + if (SINGLE_THREAD_P) + res = INTERNAL_SYSCALL (open, err, 3, file, oflag | MORE_OFLAGS, mode); + else + { + int oldtype = LIBC_CANCEL_ASYNC (); + + res = INTERNAL_SYSCALL (open, err, 3, file, oflag | MORE_OFLAGS, mode); + + LIBC_CANCEL_RESET (oldtype); + } + + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (res, err), 0)) + { + __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (res, err), fd, buf); + res = -1; + } + + return res; +} diff --git a/sysdeps/unix/sysv/linux/openat64.c b/sysdeps/unix/sysv/linux/openat64.c new file mode 100644 index 0000000000..9e7a2b3737 --- /dev/null +++ b/sysdeps/unix/sysv/linux/openat64.c @@ -0,0 +1,4 @@ +#define OPENAT openat64 +#define MORE_OFLAGS O_LARGEFILE + +#include "openat.c" diff --git a/sysdeps/unix/sysv/linux/powerpc/chown.c b/sysdeps/unix/sysv/linux/powerpc/chown.c index 4b283e720c..fdcbd3683a 100644 --- a/sysdeps/unix/sysv/linux/powerpc/chown.c +++ b/sysdeps/unix/sysv/linux/powerpc/chown.c @@ -1,5 +1,5 @@ /* chown() compatibility. - Copyright (C) 1998, 2000, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1998, 2000, 2002, 2003, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -24,6 +24,8 @@ #include <sysdep.h> #include <stdlib.h> +#include <kernel-features.h> + /* In Linux 2.1.x the chown functions have been changed. A new function lchown was introduced. The new chown now follows symlinks - the old chown and the @@ -34,58 +36,61 @@ int __chown (const char *file, uid_t owner, gid_t group) { - int err; - int old_errno; - char link[PATH_MAX+2]; - char path[2*PATH_MAX+4]; - int loopct; - size_t filelen; - static int libc_old_chown = 0 /* -1=old linux, 1=new linux, 0=unknown */; - - if (libc_old_chown == 1) - return INLINE_SYSCALL (chown, 3, __ptrvalue (file), owner, group); - - old_errno = errno; - -#ifdef __NR_lchown - if (libc_old_chown == 0) - { - err = INLINE_SYSCALL (chown, 3, __ptrvalue (file), owner, group); - if (err != -1 || errno != ENOSYS) - { - libc_old_chown = 1; - return err; - } - libc_old_chown = -1; - } -#endif - - err = __readlink (file, link, PATH_MAX+1); - if (err == -1) - { - errno = old_errno; - return __lchown(file, owner, group); - } - - filelen = strlen (file) + 1; - if (filelen > sizeof(path)) - { - errno = ENAMETOOLONG; - return -1; - } - memcpy (path, file, filelen); - - /* 'The system has an arbitrary limit...' In practise, we'll hit - ENAMETOOLONG before this, usually. */ - for (loopct = 0; loopct < 128; loopct++) - { - size_t linklen; - - if (err >= PATH_MAX+1) - { - errno = ENAMETOOLONG; - return -1; - } +#if __ASSUME_LCHOWN_SYSCALL + return INLINE_SYSCALL (chown, 3, file, owner, group); +#else + int err; + int old_errno; + char link[PATH_MAX + 2]; + char path[2 * PATH_MAX + 4]; + int loopct; + size_t filelen; + static int libc_old_chown = 0 /* -1=old linux, 1=new linux, 0=unknown */; + + if (libc_old_chown == 1) + return INLINE_SYSCALL (chown, 3, __ptrvalue (file), owner, group); + + old_errno = errno; + +# ifdef __NR_lchown + if (libc_old_chown == 0) + { + err = INLINE_SYSCALL (chown, 3, __ptrvalue (file), owner, group); + if (err != -1 || errno != ENOSYS) + { + libc_old_chown = 1; + return err; + } + libc_old_chown = -1; + } +# endif + + err = __readlink (file, link, PATH_MAX + 1); + if (err == -1) + { + __set_errno (old_errno); + return __lchown (file, owner, group); + } + + filelen = strlen (file) + 1; + if (filelen > sizeof (path)) + { + __set_errno (ENAMETOOLONG); + return -1; + } + memcpy (path, file, filelen); + + /* 'The system has an arbitrary limit...' In practise, we'll hit + ENAMETOOLONG before this, usually. */ + for (loopct = 0; loopct < 128; ++loopct) + { + size_t linklen; + + if (err >= PATH_MAX + 1) + { + __set_errno (ENAMETOOLONG); + return -1; + } link[err] = 0; /* Null-terminate string, just-in-case. */ @@ -97,28 +102,29 @@ __chown (const char *file, uid_t owner, gid_t group) { filelen = strlen (path); - while (filelen > 1 && path[filelen-1] == '/') - filelen--; - while (filelen > 0 && path[filelen-1] != '/') - filelen--; - if (filelen + linklen > sizeof(path)) + while (filelen > 1 && path[filelen - 1] == '/') + --filelen; + while (filelen > 0 && path[filelen - 1] != '/') + --filelen; + if (filelen + linklen > sizeof (path)) { errno = ENAMETOOLONG; return -1; } - memcpy (path+filelen, link, linklen); + memcpy (path + filelen, link, linklen); } - err = __readlink(path, link, PATH_MAX+1); + err = __readlink (path, link, PATH_MAX + 1); if (err == -1) - { - errno = old_errno; - return __lchown(path, owner, group); - } - } - errno = ELOOP; - return -1; + { + __set_errno (old_errno); + return __lchown (path, owner, group); + } + } + __set_errno (ELOOP); + return -1; +#endif } libc_hidden_def (__chown) diff --git a/sysdeps/unix/sysv/linux/powerpc/fchownat.c b/sysdeps/unix/sysv/linux/powerpc/fchownat.c new file mode 100644 index 0000000000..1fbae5c448 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/fchownat.c @@ -0,0 +1,205 @@ +/* Copyright (C) 2005 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <errno.h> +#include <fcntl.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <limits.h> +#include <sysdep.h> +#include <stdlib.h> + +#include <kernel-features.h> + +/* + In Linux 2.1.x the chown functions have been changed. A new function lchown + was introduced. The new chown now follows symlinks - the old chown and the + new lchown do not follow symlinks. + This file emulates chown() under the old kernels. +*/ + +int +fchownat (int fd, const char *file, uid_t owner, gid_t group, int flag) +{ + if (flag & ~AT_SYMLINK_NOFOLLOW) + { + __set_errno (EINVAL); + return -1; + } + + char *buf = NULL; + + if (fd != AT_FDCWD && file[0] != '/') + { + size_t filelen = strlen (file); + static const char procfd[] = "/proc/self/fd/%d/%s"; + /* Buffer for the path name we are going to use. It consists of + - the string /proc/self/fd/ + - the file descriptor number + - the file name provided. + The final NUL is included in the sizeof. A bit of overhead + due to the format elements compensates for possible negative + numbers. */ + size_t buflen = sizeof (procfd) + sizeof (int) * 3 + filelen; + buf = alloca (buflen); + + __snprintf (buf, buflen, procfd, fd, file); + file = buf; + } + + int result; + INTERNAL_SYSCALL_DECL (err); + +#if __ASSUME_LCHOWN_SYSCALL + if (flag & AT_SYMLINK_NOFOLLOW) + result = INTERNAL_SYSCALL (lchown, err, 3, file, owner, group); + else + result = INTERNAL_SYSCALL (chown, err, 3, file, owner, group); +#else + char link[PATH_MAX + 2]; + char path[2 * PATH_MAX + 4]; + int loopct; + size_t filelen; + static int libc_old_chown = 0 /* -1=old linux, 1=new linux, 0=unknown */; + + if (libc_old_chown == 1) + { + if (flag & AT_SYMLINK_NOFOLLOW) + result = INTERNAL_SYSCALL (lchown, err, 3, __ptrvalue (file), owner, + group); + else + result = INTERNAL_SYSCALL (chown, err, 3, __ptrvalue (file), owner, + group); + goto out; + } + +# ifdef __NR_lchown + if (flag & AT_SYMLINK_NOFOLLOW) + { + result = INTERNAL_SYSCALL (lchown, err, 3, __ptrvalue (file), owner, + group); + goto out; + } + + if (libc_old_chown == 0) + { + result = INTERNAL_SYSCALL (chown, err, 3, __ptrvalue (file), owner, + group); + if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + return result; + if (INTERNAL_SYSCALL_ERRNO (result, err) != ENOSYS) + { + libc_old_chown = 1; + goto fail; + } + libc_old_chown = -1; + } +# else + if (flag & AT_SYMLINK_NOFOLLOW) + { + result = INTERNAL_SYSCALL (chown, err, 3, __ptrvalue (file), owner, + group); + goto out; + } +# endif + + result = __readlink (file, link, PATH_MAX + 1); + if (result == -1) + { +# ifdef __NR_lchown + result = INTERNAL_SYSCALL (lchown, err, 3, __ptrvalue (file), owner, + group); +# else + result = INTERNAL_SYSCALL (chown, err, 3, __ptrvalue (file), owner, + group); +# endif + goto out; + } + + filelen = strlen (file) + 1; + if (filelen > sizeof (path)) + { + errno = ENAMETOOLONG; + return -1; + } + memcpy (path, file, filelen); + + /* 'The system has an arbitrary limit...' In practise, we'll hit + ENAMETOOLONG before this, usually. */ + for (loopct = 0; loopct < 128; ++loopct) + { + size_t linklen; + + if (result >= PATH_MAX + 1) + { + errno = ENAMETOOLONG; + return -1; + } + + link[result] = 0; /* Null-terminate string, just-in-case. */ + + linklen = strlen (link) + 1; + + if (link[0] == '/') + memcpy (path, link, linklen); + else + { + filelen = strlen (path); + + while (filelen > 1 && path[filelen - 1] == '/') + --filelen; + while (filelen > 0 && path[filelen - 1] != '/') + --filelen; + if (filelen + linklen > sizeof (path)) + { + errno = ENAMETOOLONG; + return -1; + } + memcpy (path + filelen, link, linklen); + } + + result = __readlink (path, link, PATH_MAX + 1); + + if (result == -1) + { +# ifdef __NR_lchown + result = INTERNAL_SYSCALL (lchown, err, 3, path, owner, group); +# else + result = INTERNAL_SYSCALL (chown, err, 3, path, owner, group); +# endif + goto out; + } + } + __set_errno (ELOOP); + return -1; + + out: +#endif + + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + { +#if !__ASSUME_LCHOWN_SYSCALL + fail: +#endif + __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf); + result = -1; + } + + return result; +} diff --git a/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c b/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c new file mode 100644 index 0000000000..ddaff303c5 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c @@ -0,0 +1,105 @@ +/* Get frequency of the system processor. powerpc/Linux version. + Copyright (C) 2000, 2001, 2005 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <ctype.h> +#include <fcntl.h> +#include <string.h> +#include <unistd.h> +#include <libc-internal.h> + + +hp_timing_t +__get_clockfreq (void) +{ + /* We read the information from the /proc filesystem. /proc/cpuinfo + contains at least one line like: + timebase : 33333333 + We search for this line and convert the number into an integer. */ + static hp_timing_t timebase_freq; + hp_timing_t result = 0L; + + /* If this function was called before, we know the result. */ + if (timebase_freq != 0) + return timebase_freq; + + int fd = open ("/proc/cpuinfo", O_RDONLY); + if (__builtin_expect (fd != -1, 1)) + { + /* The timebase will be in the 1st 1024 bytes for systems with up + to 8 processors. If the first read returns less then 1024 + bytes read, we have the whole cpuinfo and can start the scan. + Otherwise we will have to read more to insure we have the + timebase value in the scan. */ + char buf[1024]; + ssize_t n; + + n = read (fd, buf, sizeof (buf)); + if (n == sizeof (buf)) + { + /* We are here because the 1st read returned exactly sizeof + (buf) bytes. This implies that we are not at EOF and may + not have read the timebase value yet. So we need to read + more bytes until we know we have EOF. We copy the lower + half of buf to the upper half and read sizeof (buf)/2 + bytes into the lower half of buf and repeat until we + reach EOF. We can assume that the timebase will be in + the last 512 bytes of cpuinfo, so two 512 byte half_bufs + will be sufficient to contain the timebase and will + handle the case where the timebase spans the half_buf + boundry. */ + const ssize_t half_buf = sizeof (buf) / 2; + while (n >= half_buf) + { + memcpy (buf, buf + half_buf, half_buf); + n = read (fd, buf + half_buf, half_buf); + } + if (n >= 0) + n += half_buf; + } + + if (__builtin_expect (n, 1) > 0) + { + char *mhz = memmem (buf, n, "timebase", 7); + + if (__builtin_expect (mhz != NULL, 1)) + { + char *endp = buf + n; + + /* Search for the beginning of the string. */ + while (mhz < endp && (*mhz < '0' || *mhz > '9') && *mhz != '\n') + ++mhz; + + while (mhz < endp && *mhz != '\n') + { + if (*mhz >= '0' && *mhz <= '9') + { + result *= 10; + result += *mhz - '0'; + } + + ++mhz; + } + } + timebase_freq = result; + } + close (fd); + } + + return timebase_freq; +} diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fxstatat.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fxstatat.c new file mode 100644 index 0000000000..0f8b3135d8 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fxstatat.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/i386/fxstatat.c> diff --git a/sysdeps/unix/sysv/linux/renameat.c b/sysdeps/unix/sysv/linux/renameat.c new file mode 100644 index 0000000000..31662ea053 --- /dev/null +++ b/sysdeps/unix/sysv/linux/renameat.c @@ -0,0 +1,121 @@ +/* Copyright (C) 2005 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <errno.h> +#include <fcntl.h> +#include <stdio.h> +#include <sysdep.h> + + +/* Rename the file OLD relative to OLDFD to NEW relative to NEWFD. */ +int +renameat (oldfd, old, newfd, new) + int oldfd; + const char *old; + int newfd; + const char *new; +{ + static const char procfd[] = "/proc/self/fd/%d/%s"; + char *bufold = NULL; + + if (oldfd != AT_FDCWD && old[0] != '/') + { + size_t filelen = strlen (old); + /* Buffer for the path name we are going to use. It consists of + - the string /proc/self/fd/ + - the file descriptor number + - the file name provided. + The final NUL is included in the sizeof. A bit of overhead + due to the format elements compensates for possible negative + numbers. */ + size_t buflen = sizeof (procfd) + sizeof (int) * 3 + filelen; + bufold = alloca (buflen); + + __snprintf (bufold, buflen, procfd, oldfd, old); + old = bufold; + } + + char *bufnew = NULL; + + if (newfd != AT_FDCWD && new[0] != '/') + { + size_t filelen = strlen (new); + /* Buffer for the path name we are going to use. It consists of + - the string /proc/self/fd/ + - the file descriptor number + - the file name provided. + The final NUL is included in the sizeof. A bit of overhead + due to the format elements compensates for possible negative + numbers. */ + size_t buflen = sizeof (procfd) + sizeof (int) * 3 + filelen; + bufnew = alloca (buflen); + + __snprintf (bufnew, buflen, procfd, newfd, new); + new = bufnew; + } + + INTERNAL_SYSCALL_DECL (err); + + int result = INTERNAL_SYSCALL (rename, err, 2, old, new); + + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + { + int errval = INTERNAL_SYSCALL_ERRNO (result, err); + if (errval == ENOTDIR && (bufnew != NULL || bufold != NULL)) + { + /* This can mean either the file descriptor is invalid or + /proc is not mounted. */ + struct stat64 st; + + if (bufnew != NULL) + { + if (__fxstat64 (_STAT_VER, newfd, &st) != 0) + /* errno is already set correctly. */ + return -1; + + /* If /proc is not mounted there is nothing we can do. */ + if (S_ISDIR (st.st_mode) + && (__xstat64 (_STAT_VER, "/proc/self/fd", &st) != 0 + || !S_ISDIR (st.st_mode))) + { + errval = ENOSYS; + goto out; + } + } + + if (bufold != NULL) + { + if (__fxstat64 (_STAT_VER, oldfd, &st) != 0) + /* errno is already set correctly. */ + return -1; + + /* If /proc is not mounted there is nothing we can do. */ + if (S_ISDIR (st.st_mode) + && (__xstat64 (_STAT_VER, "/proc/self/fd", &st) != 0 + || !S_ISDIR (st.st_mode))) + errval = ENOSYS; + } + } + + out: + __set_errno (errval); + result = -1; + } + + return result; +} diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/fchownat.c b/sysdeps/unix/sysv/linux/s390/s390-32/fchownat.c new file mode 100644 index 0000000000..b95665cad3 --- /dev/null +++ b/sysdeps/unix/sysv/linux/s390/s390-32/fchownat.c @@ -0,0 +1,140 @@ +/* Copyright (C) 2005 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <errno.h> +#include <fcntl.h> +#include <stdio.h> +#include <unistd.h> + +#include <sysdep.h> +#include <sys/syscall.h> +#include <shlib-compat.h> +#include <bp-checks.h> + +#include <linux/posix_types.h> +#include "kernel-features.h" + +/* + In Linux 2.1.x the chown functions have been changed. A new function lchown + was introduced. The new chown now follows symlinks - the old chown and the + new lchown do not follow symlinks. + The new lchown function has the same number as the old chown had and the + new chown has a new number. When compiling with headers from Linux > 2.1.8x + it's impossible to run this libc with older kernels. In these cases libc + has therefore to route calls to chown to the old chown function. +*/ + +/* Running under Linux > 2.1.80. */ + +#ifdef __NR_chown32 +# if __ASSUME_32BITUIDS == 0 +/* This variable is shared with all files that need to check for 32bit + uids. */ +extern int __libc_missing_32bit_uids; +# endif +#endif /* __NR_chown32 */ + +int +fchownat (int fd, const char *file, uid_t owner, gid_t group, int flag) +{ + if (flag & ~AT_SYMLINK_NOFOLLOW) + { + __set_errno (EINVAL); + return -1; + } + + char *buf = NULL; + + if (fd != AT_FDCWD && file[0] != '/') + { + size_t filelen = strlen (file); + static const char procfd[] = "/proc/self/fd/%d/%s"; + /* Buffer for the path name we are going to use. It consists of + - the string /proc/self/fd/ + - the file descriptor number + - the file name provided. + The final NUL is included in the sizeof. A bit of overhead + due to the format elements compensates for possible negative + numbers. */ + size_t buflen = sizeof (procfd) + sizeof (int) * 3 + filelen; + buf = alloca (buflen); + + __snprintf (buf, buflen, procfd, fd, file); + file = buf; + } + + int result; + INTERNAL_SYSCALL_DECL (err); + +#if __ASSUME_32BITUIDS > 0 + result = INTERNAL_SYSCALL (chown32, err, 3, CHECK_STRING (file), owner, + group); +#else + static int __libc_old_chown; + +# ifdef __NR_chown32 + if (__libc_missing_32bit_uids <= 0) + { + if (flag & AT_SYMLINK_NOFOLLOW) + result = INTERNAL_SYSCALL (lchown32, err, 3, CHECK_STRING (file), + owner, group); + else + result = INTERNAL_SYSCALL (chown32, err, 3, CHECK_STRING (file), + owner, group); + + if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1)) + return result; + if (INTERNAL_SYSCALL_ERRNO (result, err) != ENOSYS) + goto fail; + + __libc_missing_32bit_uids = 1; + } +# endif /* __NR_chown32 */ + if (((owner + 1) > (uid_t) ((__kernel_uid_t) -1U)) + || ((group + 1) > (gid_t) ((__kernel_gid_t) -1U))) + { + __set_errno (EINVAL); + return -1; + } + + if (!__libc_old_chown && (flag & AT_SYMLINK_NOFOLLOW) == 0) + { + result = INTERNAL_SYSCALL (chown, err, 3, CHECK_STRING (file), owner, + group); + + if (!INTERNAL_SYSCALL_ERROR_P (result, err)) + return result; + if (INTERNAL_SYSCALL_ERRNO (result, err) != ENOSYS) + goto fail; + + __libc_old_chown = 1; + } + + result = INTERNAL_SYSCALL (lchown, err, 3, CHECK_STRING (file), owner, + group); +#endif + + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + { + fail: + __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf); + result = -1; + } + + return result; +} diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/fxstatat.c b/sysdeps/unix/sysv/linux/s390/s390-32/fxstatat.c new file mode 100644 index 0000000000..0f8b3135d8 --- /dev/null +++ b/sysdeps/unix/sysv/linux/s390/s390-32/fxstatat.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/i386/fxstatat.c> diff --git a/sysdeps/unix/sysv/linux/sh/fchownat.c b/sysdeps/unix/sysv/linux/sh/fchownat.c new file mode 100644 index 0000000000..7acf7918ee --- /dev/null +++ b/sysdeps/unix/sysv/linux/sh/fchownat.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/m68k/fchownat.c> diff --git a/sysdeps/unix/sysv/linux/sh/fxstatat.c b/sysdeps/unix/sysv/linux/sh/fxstatat.c new file mode 100644 index 0000000000..0f8b3135d8 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sh/fxstatat.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/i386/fxstatat.c> diff --git a/sysdeps/unix/sysv/linux/sh/socket.S b/sysdeps/unix/sysv/linux/sh/socket.S index f1369eb49b..eb1761b94b 100644 --- a/sysdeps/unix/sysv/linux/sh/socket.S +++ b/sysdeps/unix/sysv/linux/sh/socket.S @@ -1,4 +1,4 @@ -/* Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -33,7 +33,11 @@ The .S files for the other calls just #define socket and #include this. */ #ifndef __socket +#ifndef NO_WEAK_ALIAS #define __socket P(__,socket) +#else +#define __socket socket +#endif #endif #define PUSHARGS_1 mov.l r4,@-r15; \ @@ -173,4 +177,6 @@ ENTRY (__socket) PSEUDO_END (__socket) +#ifndef NO_WEAK_ALIAS weak_alias (__socket, socket) +#endif diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/fchownat.c b/sysdeps/unix/sysv/linux/sparc/sparc32/fchownat.c new file mode 100644 index 0000000000..7acf7918ee --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/fchownat.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/m68k/fchownat.c> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/fxstatat.c b/sysdeps/unix/sysv/linux/sparc/sparc32/fxstatat.c new file mode 100644 index 0000000000..0f8b3135d8 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/fxstatat.c @@ -0,0 +1 @@ +#include <sysdeps/unix/sysv/linux/i386/fxstatat.c> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/fxstatat.c b/sysdeps/unix/sysv/linux/sparc/sparc64/fxstatat.c new file mode 100644 index 0000000000..c2610b2a06 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/fxstatat.c @@ -0,0 +1 @@ +#include "../../fxstatat.c" diff --git a/sysdeps/unix/sysv/linux/tcflow.c b/sysdeps/unix/sysv/linux/tcflow.c index 5be68e2ea2..6e72370272 100644 --- a/sysdeps/unix/sysv/linux/tcflow.c +++ b/sysdeps/unix/sysv/linux/tcflow.c @@ -1 +1,31 @@ -#include <sysdeps/unix/bsd/sun/sunos4/tcflow.c> +/* tcflow -- Suspend or restart transmission on termios file descriptor. + Copyright (C) 1993,1997,2005 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <errno.h> +#include <termios.h> +#include <sys/ioctl.h> + +/* Suspend or restart transmission on FD. */ +int +tcflow (fd, action) + int fd; + int action; +{ + return __ioctl (fd, TCXONC, action); +} diff --git a/sysdeps/unix/sysv/linux/tcflush.c b/sysdeps/unix/sysv/linux/tcflush.c index 78e09b2f75..cae419f4a9 100644 --- a/sysdeps/unix/sysv/linux/tcflush.c +++ b/sysdeps/unix/sysv/linux/tcflush.c @@ -1 +1,31 @@ -#include <sysdeps/unix/bsd/sun/sunos4/tcflush.c> +/* tcflush -- Flush pending data on termios file descriptor. Linux version. + Copyright (C) 1993,1997,2005 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <errno.h> +#include <termios.h> +#include <sys/ioctl.h> + +/* Flush pending data on FD. */ +int +tcflush (fd, queue_selector) + int fd; + int queue_selector; +{ + return __ioctl (fd, TCFLSH, queue_selector); +} diff --git a/sysdeps/unix/sysv/linux/unlinkat.c b/sysdeps/unix/sysv/linux/unlinkat.c new file mode 100644 index 0000000000..c590e71ada --- /dev/null +++ b/sysdeps/unix/sysv/linux/unlinkat.c @@ -0,0 +1,74 @@ +/* Copyright (C) 2005 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <errno.h> +#include <fcntl.h> +#include <stddef.h> +#include <stdio.h> +#include <unistd.h> + + +/* Remove the link named NAME. */ +int +unlinkat (fd, file, flag) + int fd; + const char *file; + int flag; +{ + if (flag & ~AT_REMOVEDIR) + { + __set_errno (EINVAL); + return -1; + } + + char *buf = NULL; + + if (fd != AT_FDCWD && file[0] != '/') + { + size_t filelen = strlen (file); + static const char procfd[] = "/proc/self/fd/%d/%s"; + /* Buffer for the path name we are going to use. It consists of + - the string /proc/self/fd/ + - the file descriptor number + - the file name provided. + The final NUL is included in the sizeof. A bit of overhead + due to the format elements compensates for possible negative + numbers. */ + size_t buflen = sizeof (procfd) + sizeof (int) * 3 + filelen; + buf = alloca (buflen); + + __snprintf (buf, buflen, procfd, fd, file); + file = buf; + } + + int result; + INTERNAL_SYSCALL_DECL (err); + + if (flag & AT_REMOVEDIR) + result = INTERNAL_SYSCALL (rmdir, err, 1, file); + else + result = INTERNAL_SYSCALL (unlink, err, 1, file); + + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0)) + { + __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf); + result = -1; + } + + return result; +} diff --git a/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c b/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c new file mode 100644 index 0000000000..70e73571f7 --- /dev/null +++ b/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c @@ -0,0 +1,78 @@ +/* Copyright (C) 2005 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 Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* Ho hum, since fxstatat == fxstatat64 we must get rid of the + prototype or gcc will complain since they don't strictly match. */ +#define __fxstatat64 __fxstatat64_disable + +#include <errno.h> +#include <fcntl.h> +#include <stddef.h> +#include <stdio.h> +#include <sys/stat.h> + +#include <sysdep.h> +#include <sys/syscall.h> +#include <bp-checks.h> + +/* Get information about the file NAME relative to FD in ST. */ +int +__fxstatat (int vers, int fd, const char *file, struct stat *st, int flag) +{ + if ((vers != _STAT_VER_KERNEL && vers != _STAT_VER_LINUX) + || (flag & ~AT_SYMLINK_NOFOLLOW) != 0) + { + __set_errno (EINVAL); + return -1; + } + + char *buf = NULL; + + if (fd != AT_FDCWD && file[0] != '/') + { + size_t filelen = strlen (file); + static const char procfd[] = "/proc/self/fd/%d/%s"; + /* Buffer for the path name we are going to use. It consists of + - the string /proc/self/fd/ + - the file descriptor number + - the file name provided. + The final NUL is included in the sizeof. A bit of overhead + due to the format elements compensates for possible negative + numbers. */ + size_t buflen = sizeof (procfd) + sizeof (int) * 3 + filelen; + buf = alloca (buflen); + + __snprintf (buf, buflen, procfd, fd, file); + file = buf; + } + + INTERNAL_SYSCALL_DECL (err); + int res; + + if (flag & AT_SYMLINK_NOFOLLOW) + res = INTERNAL_SYSCALL (lstat, err, 2, file, CHECK_1 (st)); + else + res = INTERNAL_SYSCALL (stat, err, 2, file, CHECK_1 (st)); + + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (res, err), 0)) + __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (res, err), fd, buf); + + return res; +} +#undef __fxstatat64 +strong_alias (__fxstatat, __fxstatat64); diff --git a/sysdeps/unix/sysv/linux/wordsize-64/fxstatat64.c b/sysdeps/unix/sysv/linux/wordsize-64/fxstatat64.c new file mode 100644 index 0000000000..05e7f413bb --- /dev/null +++ b/sysdeps/unix/sysv/linux/wordsize-64/fxstatat64.c @@ -0,0 +1 @@ +/* fxstatat64 is in fxstatat.c */ |