From 0ecb606cb6cf65de1d9fc8a919bceb4be476c602 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 12 Jul 2007 18:26:36 +0000 Subject: 2.5-18.1 --- misc/Makefile | 23 ++- misc/Versions | 4 + misc/acct.c | 34 ++++ misc/bits/syslog-ldbl.h | 36 +++++ misc/bits/syslog.h | 39 +++++ misc/brk.c | 37 +++++ misc/chflags.c | 43 +++++ misc/chroot.c | 34 ++++ misc/efgcvt.c | 49 ++++-- misc/efgcvt_r.c | 40 ++++- misc/error.c | 207 ++++++++---------------- misc/error.h | 10 +- misc/fchflags.c | 43 +++++ misc/fdatasync.c | 28 ++++ misc/fgetxattr.c | 31 ++++ misc/flistxattr.c | 30 ++++ misc/fremovexattr.c | 30 ++++ misc/fsetxattr.c | 31 ++++ misc/fsync.c | 33 ++++ misc/ftruncate.c | 36 +++++ misc/ftruncate64.c | 36 +++++ misc/futimes.c | 34 ++++ misc/futimesat.c | 46 ++++++ misc/getclktck.c | 30 ++++ misc/getdomain.c | 64 ++++++++ misc/getdtsz.c | 33 ++++ misc/gethostid.c | 32 ++++ misc/gethostname.c | 36 +++++ misc/getloadavg.c | 37 +++++ misc/getpagesize.c | 33 ++++ misc/getpass.c | 20 +-- misc/getsysstats.c | 69 ++++++++ misc/getusershell.c | 49 +++--- misc/getxattr.c | 31 ++++ misc/gtty.c | 40 +++++ misc/hsearch_r.c | 4 +- misc/insremque.c | 22 ++- misc/ioctl.c | 35 ++++ misc/lgetxattr.c | 31 ++++ misc/listxattr.c | 30 ++++ misc/llistxattr.c | 30 ++++ misc/lremovexattr.c | 30 ++++ misc/lseek.c | 53 ++++++ misc/lsetxattr.c | 31 ++++ misc/lutimes.c | 35 ++++ misc/madvise.c | 34 ++++ misc/mincore.c | 30 ++++ misc/mlock.c | 35 ++++ misc/mlockall.c | 36 +++++ misc/mmap.c | 41 +++++ misc/mmap64.c | 48 ++++++ misc/mntent_r.c | 12 +- misc/mprotect.c | 36 +++++ misc/msync.c | 35 ++++ misc/munlock.c | 34 ++++ misc/munlockall.c | 34 ++++ misc/munmap.c | 35 ++++ misc/pselect.c | 70 ++++++++ misc/ptrace.c | 103 ++++++++++++ misc/qefgcvt_r.c | 2 + misc/readv.c | 41 +++++ misc/reboot.c | 34 ++++ misc/remap_file_pages.c | 35 ++++ misc/removexattr.c | 30 ++++ misc/revoke.c | 31 ++++ misc/sbrk.c | 56 +++++++ misc/select.c | 43 +++++ misc/setdomain.c | 34 ++++ misc/setegid.c | 32 ++++ misc/seteuid.c | 32 ++++ misc/sethostid.c | 34 ++++ misc/sethostname.c | 35 ++++ misc/setregid.c | 36 +++++ misc/setreuid.c | 36 +++++ misc/setxattr.c | 31 ++++ misc/sstk.c | 35 ++++ misc/stty.c | 40 +++++ misc/swapoff.c | 31 ++++ misc/swapon.c | 34 ++++ misc/sync.c | 31 ++++ misc/sys/cdefs.h | 51 +++++- misc/sys/mman.h | 18 ++- misc/sys/queue.h | 420 ++++++++++++++++++++++++++++++++++++++++++------ misc/sys/syslog.h | 19 ++- misc/syscall.c | 35 ++++ misc/syslog.c | 78 ++++++--- misc/truncate.c | 34 ++++ misc/truncate64.c | 35 ++++ misc/tsearch.c | 15 +- misc/tst-error1.c | 26 +++ misc/tst-insremque.c | 61 +++++++ misc/tst-mntent2.c | 41 +++++ misc/tst-pselect.c | 128 +++++++++++++++ misc/ualarm.c | 37 +++++ misc/usleep.c | 32 ++++ misc/ustat.c | 33 ++++ misc/utimes.c | 43 +++++ misc/vhangup.c | 33 ++++ misc/writev.c | 41 +++++ 99 files changed, 3860 insertions(+), 325 deletions(-) create mode 100644 misc/acct.c create mode 100644 misc/bits/syslog-ldbl.h create mode 100644 misc/bits/syslog.h create mode 100644 misc/brk.c create mode 100644 misc/chflags.c create mode 100644 misc/chroot.c create mode 100644 misc/fchflags.c create mode 100644 misc/fdatasync.c create mode 100644 misc/fgetxattr.c create mode 100644 misc/flistxattr.c create mode 100644 misc/fremovexattr.c create mode 100644 misc/fsetxattr.c create mode 100644 misc/fsync.c create mode 100644 misc/ftruncate.c create mode 100644 misc/ftruncate64.c create mode 100644 misc/futimes.c create mode 100644 misc/futimesat.c create mode 100644 misc/getclktck.c create mode 100644 misc/getdomain.c create mode 100644 misc/getdtsz.c create mode 100644 misc/gethostid.c create mode 100644 misc/gethostname.c create mode 100644 misc/getloadavg.c create mode 100644 misc/getpagesize.c create mode 100644 misc/getsysstats.c create mode 100644 misc/getxattr.c create mode 100644 misc/gtty.c create mode 100644 misc/ioctl.c create mode 100644 misc/lgetxattr.c create mode 100644 misc/listxattr.c create mode 100644 misc/llistxattr.c create mode 100644 misc/lremovexattr.c create mode 100644 misc/lseek.c create mode 100644 misc/lsetxattr.c create mode 100644 misc/lutimes.c create mode 100644 misc/madvise.c create mode 100644 misc/mincore.c create mode 100644 misc/mlock.c create mode 100644 misc/mlockall.c create mode 100644 misc/mmap.c create mode 100644 misc/mmap64.c create mode 100644 misc/mprotect.c create mode 100644 misc/msync.c create mode 100644 misc/munlock.c create mode 100644 misc/munlockall.c create mode 100644 misc/munmap.c create mode 100644 misc/pselect.c create mode 100644 misc/ptrace.c create mode 100644 misc/readv.c create mode 100644 misc/reboot.c create mode 100644 misc/remap_file_pages.c create mode 100644 misc/removexattr.c create mode 100644 misc/revoke.c create mode 100644 misc/sbrk.c create mode 100644 misc/select.c create mode 100644 misc/setdomain.c create mode 100644 misc/setegid.c create mode 100644 misc/seteuid.c create mode 100644 misc/sethostid.c create mode 100644 misc/sethostname.c create mode 100644 misc/setregid.c create mode 100644 misc/setreuid.c create mode 100644 misc/setxattr.c create mode 100644 misc/sstk.c create mode 100644 misc/stty.c create mode 100644 misc/swapoff.c create mode 100644 misc/swapon.c create mode 100644 misc/sync.c create mode 100644 misc/syscall.c create mode 100644 misc/truncate.c create mode 100644 misc/truncate64.c create mode 100644 misc/tst-error1.c create mode 100644 misc/tst-insremque.c create mode 100644 misc/tst-mntent2.c create mode 100644 misc/tst-pselect.c create mode 100644 misc/ualarm.c create mode 100644 misc/usleep.c create mode 100644 misc/ustat.c create mode 100644 misc/utimes.c create mode 100644 misc/vhangup.c create mode 100644 misc/writev.c (limited to 'misc') diff --git a/misc/Makefile b/misc/Makefile index 862eb1b800..9eac1b6275 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991-2002, 2003, 2004 Free Software Foundation, Inc. +# Copyright (C) 1991-2002,2003,2004,2005,2006 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,13 @@ subdir := misc headers := sys/uio.h bits/uio.h sys/ioctl.h bits/ioctls.h bits/ioctl-types.h \ sys/ptrace.h sys/file.h sys/dir.h sys/cdefs.h \ ar.h a.out.h libgen.h stab.h bits/stab.def sgtty.h \ - ttyent.h syslog.h sys/syslog.h paths.h sys/reboot.h \ + ttyent.h paths.h sys/reboot.h \ sys/mman.h sys/param.h fstab.h mntent.h search.h err.h error.h \ sys/queue.h sysexits.h syscall.h sys/syscall.h sys/swap.h \ sys/select.h ustat.h sys/ustat.h bits/ustat.h sys/sysinfo.h \ - regexp.h bits/select.h bits/mman.h sys/xattr.h + regexp.h bits/select.h bits/mman.h sys/xattr.h \ + syslog.h sys/syslog.h \ + bits/syslog.h bits/syslog-ldbl.h bits/syslog-path.h routines := brk sbrk sstk ioctl \ readv writev \ @@ -47,7 +49,7 @@ routines := brk sbrk sstk ioctl \ gtty stty \ ptrace \ fstab mntent mntent_r \ - utimes lutimes futimes \ + utimes lutimes futimes futimesat \ truncate ftruncate truncate64 ftruncate64 \ chflags fchflags \ insremque getttyent getusershell getpass ttyslot \ @@ -65,6 +67,8 @@ routines := brk sbrk sstk ioctl \ distribute := device-nrs.h +generated := tst-error1.mtrace tst-error1-mem + include ../Makeconfig aux := init-misc @@ -73,7 +77,11 @@ install-lib := libbsd-compat.a libg.a endif gpl2lgpl := error.c error.h -tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent tst-hsearch +tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent tst-hsearch \ + tst-error1 tst-pselect tst-insremque tst-mntent2 +ifeq (no,$(cross-compiling)) +tests: $(objpfx)tst-error1-mem +endif CFLAGS-tsearch.c = $(uses-callbacks) CFLAGS-lsearch.c = $(uses-callbacks) @@ -106,3 +114,8 @@ endif ifeq ($(build-bounded),yes) $(objpfx)tst-tsearch-bp: $(common-objpfx)math/libm_b.a endif + +tst-error1-ENV = MALLOC_TRACE=$(objpfx)tst-error1.mtrace +tst-error1-ARGS = $(objpfx)tst-error1.out +$(objpfx)tst-error1-mem: $(objpfx)tst-error1.out + $(common-objpfx)malloc/mtrace $(objpfx)tst-error1.mtrace > $@ diff --git a/misc/Versions b/misc/Versions index 13b38eec72..fdf2d9d2af 100644 --- a/misc/Versions +++ b/misc/Versions @@ -130,4 +130,8 @@ libc { GLIBC_2.3.3 { remap_file_pages; } + GLIBC_2.4 { + futimesat; + __syslog_chk; __vsyslog_chk; + } } diff --git a/misc/acct.c b/misc/acct.c new file mode 100644 index 0000000000..b626b5d938 --- /dev/null +++ b/misc/acct.c @@ -0,0 +1,34 @@ +/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU 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 +#include + +/* Turn accounting on if NAME is an existing file. The system will then write + a record for each process as it terminates, to this file. If NAME is NULL, + turn accounting off. This call is restricted to the super-user. */ +int +acct (name) + const char *name; +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (acct) +#include diff --git a/misc/bits/syslog-ldbl.h b/misc/bits/syslog-ldbl.h new file mode 100644 index 0000000000..d153c8f8cd --- /dev/null +++ b/misc/bits/syslog-ldbl.h @@ -0,0 +1,36 @@ +/* -mlong-double-64 compatibility mode for syslog functions. + Copyright (C) 2006 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_SYSLOG_H +# error "Never include directly; use instead." +#endif + +__LDBL_REDIR_DECL (syslog) + +#ifdef __USE_BSD +__LDBL_REDIR_DECL (vsyslog) +#endif + +#if __USE_FORTIFY_LEVEL > 0 && !defined __cplusplus +__LDBL_REDIR_DECL (__syslog_chk) + +# ifdef __USE_BSD +__LDBL_REDIR_DECL (__vsyslog_chk) +# endif +#endif diff --git a/misc/bits/syslog.h b/misc/bits/syslog.h new file mode 100644 index 0000000000..c0427214e3 --- /dev/null +++ b/misc/bits/syslog.h @@ -0,0 +1,39 @@ +/* Checking macros for syslog functions. + 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. */ + +#ifndef _SYS_SYSLOG_H +# error "Never include directly; use instead." +#endif + + +extern void __syslog_chk (int __pri, int __flag, __const char *__fmt, ...) + __attribute__ ((__format__ (__printf__, 3, 4))); + +#define syslog(pri, ...) \ + __syslog_chk (pri, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) + + +#ifdef __USE_BSD +extern void __vsyslog_chk (int __pri, int __flag, __const char *__fmt, + __gnuc_va_list __ap) + __attribute__ ((__format__ (__printf__, 3, 0))); + +# define vsyslog(pri, fmt, ap) \ + __vsyslog_chk (pri, __USE_FORTIFY_LEVEL - 1, fmt, ap) +#endif diff --git a/misc/brk.c b/misc/brk.c new file mode 100644 index 0000000000..b951819f21 --- /dev/null +++ b/misc/brk.c @@ -0,0 +1,37 @@ +/* Copyright (C) 1991, 1995, 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 +#include + +/* sbrk.c expects this. */ +void *__curbrk; + +/* Set the end of the process's data space to ADDR. + Return 0 if successful, -1 if not. */ +int +__brk (addr) + void *addr; +{ + __set_errno (ENOSYS); + return -1; +} +stub_warning (brk) + +weak_alias (__brk, brk) +#include diff --git a/misc/chflags.c b/misc/chflags.c new file mode 100644 index 0000000000..b678121265 --- /dev/null +++ b/misc/chflags.c @@ -0,0 +1,43 @@ +/* Copyright (C) 1991, 1995, 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. */ + +#include +#include +#include + +/* Change the flags of FILE to FLAGS. */ + +int chflags (const char *file, int flags) __THROW; + +int +chflags (file, flags) + const char *file; + int flags; +{ + if (file == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} + +stub_warning (chflags) +#include diff --git a/misc/chroot.c b/misc/chroot.c new file mode 100644 index 0000000000..f20ccf4c2b --- /dev/null +++ b/misc/chroot.c @@ -0,0 +1,34 @@ +/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU 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 +#include + +/* Make PATH be the root directory (the starting point for absolute paths). + This call is restricted to the super-user. */ +int +chroot (path) + const char *path; +{ + __set_errno (ENOSYS); + return -1; +} + + +stub_warning (chroot) +#include diff --git a/misc/efgcvt.c b/misc/efgcvt.c index 915d00dfd5..b9fb4a9b71 100644 --- a/misc/efgcvt.c +++ b/misc/efgcvt.c @@ -1,5 +1,6 @@ /* Compatibility functions for floating point formatting. - Copyright (C) 1995, 1996, 1997, 1999, 2002 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1999, 2002, 2006 + 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,6 +24,7 @@ #include #include #include +#include #ifndef FLOAT_TYPE # define FLOAT_TYPE double @@ -44,10 +46,14 @@ # error "NDIGIT_MAX must be precomputed" # define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * DBL_MANT_DIG + 1.0))) # endif +#else +# define LONG_DOUBLE_CVT #endif #define APPEND(a, b) APPEND2 (a, b) #define APPEND2(a, b) a##b +#define __APPEND(a, b) __APPEND2 (a, b) +#define __APPEND2(a, b) __##a##b #define FCVT_BUFFER APPEND (FUNC_PREFIX, fcvt_buffer) @@ -60,14 +66,14 @@ static char ECVT_BUFFER[MAXDIG]; libc_freeres_ptr (static char *FCVT_BUFPTR); char * -APPEND (FUNC_PREFIX, fcvt) (value, ndigit, decpt, sign) +__APPEND (FUNC_PREFIX, fcvt) (value, ndigit, decpt, sign) FLOAT_TYPE value; int ndigit, *decpt, *sign; { if (FCVT_BUFPTR == NULL) { - if (APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign, - FCVT_BUFFER, MAXDIG) != -1) + if (__APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign, + FCVT_BUFFER, MAXDIG) != -1) return FCVT_BUFFER; FCVT_BUFPTR = (char *) malloc (FCVT_MAXDIG); @@ -75,26 +81,26 @@ APPEND (FUNC_PREFIX, fcvt) (value, ndigit, decpt, sign) return FCVT_BUFFER; } - (void) APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign, - FCVT_BUFPTR, FCVT_MAXDIG); + (void) __APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign, + FCVT_BUFPTR, FCVT_MAXDIG); return FCVT_BUFPTR; } char * -APPEND (FUNC_PREFIX, ecvt) (value, ndigit, decpt, sign) +__APPEND (FUNC_PREFIX, ecvt) (value, ndigit, decpt, sign) FLOAT_TYPE value; int ndigit, *decpt, *sign; { - (void) APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign, - ECVT_BUFFER, MAXDIG); + (void) __APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign, + ECVT_BUFFER, MAXDIG); return ECVT_BUFFER; } char * -APPEND (FUNC_PREFIX, gcvt) (value, ndigit, buf) +__APPEND (FUNC_PREFIX, gcvt) (value, ndigit, buf) FLOAT_TYPE value; int ndigit; char *buf; @@ -102,3 +108,26 @@ APPEND (FUNC_PREFIX, gcvt) (value, ndigit, buf) sprintf (buf, "%.*" FLOAT_FMT_FLAG "g", MIN (ndigit, NDIGIT_MAX), value); return buf; } + +#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0) +# ifdef LONG_DOUBLE_CVT +# define cvt_symbol(symbol) \ + cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \ + APPEND (FUNC_PREFIX, symbol), GLIBC_2_4) +# define cvt_symbol_1(lib, local, symbol, version) \ + versioned_symbol (lib, local, symbol, version) +# else +# define cvt_symbol(symbol) \ + cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \ + APPEND (q, symbol), GLIBC_2_0); \ + strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) +# define cvt_symbol_1(lib, local, symbol, version) \ + compat_symbol (lib, local, symbol, version) +# endif +#else +# define cvt_symbol(symbol) \ + strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) +#endif +cvt_symbol(fcvt); +cvt_symbol(ecvt); +cvt_symbol(gcvt); diff --git a/misc/efgcvt_r.c b/misc/efgcvt_r.c index 69cca9038f..ba9566d22c 100644 --- a/misc/efgcvt_r.c +++ b/misc/efgcvt_r.c @@ -1,5 +1,6 @@ /* Compatibility functions for floating point formatting, reentrant versions. - Copyright (C) 1995,96,97,98,99,2000,01,02,04 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2006 + 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,6 +26,7 @@ #include #include #include +#include #ifndef FLOAT_TYPE # define FLOAT_TYPE double @@ -55,10 +57,14 @@ # error "FLOAT_MIN_10_NORM must be precomputed" # define FLOAT_MIN_10_NORM exp10 (DBL_MIN_10_EXP) # endif +#else +# define LONG_DOUBLE_CVT #endif #define APPEND(a, b) APPEND2 (a, b) #define APPEND2(a, b) a##b +#define __APPEND(a, b) __APPEND2 (a, b) +#define __APPEND2(a, b) __##a##b #define FLOOR APPEND(floor, FLOAT_NAME_EXT) #define FABS APPEND(fabs, FLOAT_NAME_EXT) @@ -67,7 +73,7 @@ int -APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign, buf, len) +__APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign, buf, len) FLOAT_TYPE value; int ndigit, *decpt, *sign; char *buf; @@ -163,10 +169,9 @@ APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign, buf, len) return 0; } -libc_hidden_def (APPEND (FUNC_PREFIX, fcvt_r)) int -APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign, buf, len) +__APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign, buf, len) FLOAT_TYPE value; int ndigit, *decpt, *sign; char *buf; @@ -229,11 +234,32 @@ APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign, buf, len) *sign = isfinite (value) ? signbit (value) != 0 : 0; } else - if (APPEND (FUNC_PREFIX, fcvt_r) (value, MIN (ndigit, NDIGIT_MAX) - 1, - decpt, sign, buf, len)) + if (__APPEND (FUNC_PREFIX, fcvt_r) (value, MIN (ndigit, NDIGIT_MAX) - 1, + decpt, sign, buf, len)) return -1; *decpt += exponent; return 0; } -libc_hidden_def (APPEND (FUNC_PREFIX, ecvt_r)) + +#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0) +# ifdef LONG_DOUBLE_CVT +# define cvt_symbol(symbol) \ + cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \ + APPEND (FUNC_PREFIX, symbol), GLIBC_2_4) +# define cvt_symbol_1(lib, local, symbol, version) \ + versioned_symbol (lib, local, symbol, version) +# else +# define cvt_symbol(symbol) \ + cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \ + APPEND (q, symbol), GLIBC_2_0); \ + strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) +# define cvt_symbol_1(lib, local, symbol, version) \ + compat_symbol (lib, local, symbol, version) +# endif +#else +# define cvt_symbol(symbol) \ + strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) +#endif +cvt_symbol(fcvt_r); +cvt_symbol(ecvt_r); diff --git a/misc/error.c b/misc/error.c index 2501583366..85d1cffbf9 100644 --- a/misc/error.c +++ b/misc/error.c @@ -1,7 +1,6 @@ /* Error handler for noninteractive utilities - Copyright (C) 1990-1998, 2000-2003, 2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. Its master source is NOT part of - the C library, however. The master source lives in /gd/gnu/lib. + Copyright (C) 1990-1998, 2000-2005, 2006 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 @@ -24,33 +23,19 @@ # include #endif +#include #include -#include +#include +#include + #ifdef _LIBC +# include +# include +# include # include # define mbsrtowcs __mbsrtowcs #endif -#if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC -# if __STDC__ -# include -# define VA_START(args, lastarg) va_start(args, lastarg) -# else -# include -# define VA_START(args, lastarg) va_start(args) -# endif -#else -# define va_alist a1, a2, a3, a4, a5, a6, a7, a8 -# define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8; -#endif - -#if STDC_HEADERS || _LIBC -# include -# include -#else -void exit (); -#endif - #include "error.h" #ifndef _ @@ -60,11 +45,7 @@ void exit (); /* If NULL, error will flush stdout, then print on stderr the program name, a colon and a space. Otherwise, error will call this function without parameters instead. */ -void (*error_print_progname) ( -#if __STDC__ - 0 - void -#endif - ); +void (*error_print_progname) (void); /* This variable is incremented each time `error' is called. */ unsigned int error_message_count; @@ -74,6 +55,7 @@ unsigned int error_message_count; # define program_name program_invocation_name # include +# include # include /* In GNU libc we want do not want to use the common name `error' directly. @@ -109,27 +91,6 @@ extern char *program_name; # if HAVE_STRERROR_R || defined strerror_r # define __strerror_r strerror_r -# else -# if HAVE_STRERROR -# ifndef HAVE_DECL_STRERROR -"this configure-time declaration test was not run" -# endif -# if !HAVE_DECL_STRERROR -char *strerror (); -# endif -# else -static char * -private_strerror (int errnum) -{ - extern char *sys_errlist[]; - extern int sys_nerr; - - if (errnum > 0 && errnum <= sys_nerr) - return _(sys_errlist[errnum]); - return _("Unknown system error"); -} -# define strerror private_strerror -# endif /* HAVE_STRERROR */ # endif /* HAVE_STRERROR_R || defined strerror_r */ #endif /* not _LIBC */ @@ -158,38 +119,33 @@ print_errno_message (int errnum) #endif #if _LIBC - if (_IO_fwide (stderr, 0) > 0) - { - __fwprintf (stderr, L": %s", s); - return; - } -#endif - + __fxprintf (NULL, ": %s", s); +#else fprintf (stderr, ": %s", s); +#endif } -#ifdef VA_START static void error_tail (int status, int errnum, const char *message, va_list args) { -# if HAVE_VPRINTF || _LIBC -# if _LIBC +#if _LIBC if (_IO_fwide (stderr, 0) > 0) { -# define ALLOCA_LIMIT 2000 +# define ALLOCA_LIMIT 2000 size_t len = strlen (message) + 1; wchar_t *wmessage = NULL; mbstate_t st; size_t res; const char *tmp; + bool use_malloc = false; - do + while (1) { - if (len < ALLOCA_LIMIT) + if (__libc_use_alloca (len * sizeof (wchar_t))) wmessage = (wchar_t *) alloca (len * sizeof (wchar_t)); else { - if (wmessage != NULL && len / 2 < ALLOCA_LIMIT) + if (!use_malloc) wmessage = NULL; wchar_t *p = (wchar_t *) realloc (wmessage, @@ -201,62 +157,69 @@ error_tail (int status, int errnum, const char *message, va_list args) return; } wmessage = p; + use_malloc = true; } memset (&st, '\0', sizeof (st)); tmp = message; + + res = mbsrtowcs (wmessage, &tmp, len, &st); + if (res != len) + break; + + if (__builtin_expect (len >= SIZE_MAX / 2, 0)) + { + /* This really should not happen if everything is fine. */ + res = (size_t) -1; + break; + } + + len *= 2; } - while ((res = mbsrtowcs (wmessage, &tmp, len, &st)) == len); if (res == (size_t) -1) - /* The string cannot be converted. */ - wmessage = (wchar_t *) L"???"; + { + /* The string cannot be converted. */ + if (use_malloc) + { + free (wmessage); + use_malloc = false; + } + wmessage = (wchar_t *) L"???"; + } __vfwprintf (stderr, wmessage, args); + + if (use_malloc) + free (wmessage); } else -# endif +#endif vfprintf (stderr, message, args); -# else - _doprnt (message, args, stderr); -# endif va_end (args); ++error_message_count; if (errnum) print_errno_message (errnum); -# if _LIBC - if (_IO_fwide (stderr, 0) > 0) - putwc (L'\n', stderr); - else -# endif - putc ('\n', stderr); +#if _LIBC + __fxprintf (NULL, "\n"); +#else + putc ('\n', stderr); +#endif fflush (stderr); if (status) exit (status); } -#endif /* Print the program name and error message MESSAGE, which is a printf-style format string with optional args. If ERRNUM is nonzero, print its corresponding system error message. Exit with status STATUS if it is nonzero. */ -/* VARARGS */ void -#if defined VA_START && __STDC__ error (int status, int errnum, const char *message, ...) -#else -error (status, errnum, message, va_alist) - int status; - int errnum; - char *message; - va_dcl -#endif { -#ifdef VA_START va_list args; -#endif #if defined _LIBC && defined __libc_ptf_call /* We do not want this call to be cut short by a thread @@ -275,27 +238,14 @@ error (status, errnum, message, va_alist) else { #if _LIBC - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s: ", program_name); - else + __fxprintf (NULL, "%s: ", program_name); +#else + fprintf (stderr, "%s: ", program_name); #endif - fprintf (stderr, "%s: ", program_name); } -#ifdef VA_START - VA_START (args, message); + va_start (args, message); error_tail (status, errnum, message, args); -#else - fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8); - - ++error_message_count; - if (errnum) - print_errno_message (errnum); - putc ('\n', stderr); - fflush (stderr); - if (status) - exit (status); -#endif #ifdef _LIBC _IO_funlockfile (stderr); @@ -310,22 +260,10 @@ error (status, errnum, message, va_alist) int error_one_per_line; void -#if defined VA_START && __STDC__ error_at_line (int status, int errnum, const char *file_name, unsigned int line_number, const char *message, ...) -#else -error_at_line (status, errnum, file_name, line_number, message, va_alist) - int status; - int errnum; - const char *file_name; - unsigned int line_number; - char *message; - va_dcl -#endif { -#ifdef VA_START va_list args; -#endif if (error_one_per_line) { @@ -359,37 +297,22 @@ error_at_line (status, errnum, file_name, line_number, message, va_alist) else { #if _LIBC - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s: ", program_name); - else + __fxprintf (NULL, "%s:", program_name); +#else + fprintf (stderr, "%s:", program_name); #endif - fprintf (stderr, "%s:", program_name); } - if (file_name != NULL) - { #if _LIBC - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s:%d: ", file_name, line_number); - else + __fxprintf (NULL, file_name != NULL ? "%s:%d: " : " ", + file_name, line_number); +#else + fprintf (stderr, file_name != NULL ? "%s:%d: " : " ", + file_name, line_number); #endif - fprintf (stderr, "%s:%d: ", file_name, line_number); - } -#ifdef VA_START - VA_START (args, message); + va_start (args, message); error_tail (status, errnum, message, args); -#else - fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8); - - ++error_message_count; - if (errnum) - print_errno_message (errnum); - putc ('\n', stderr); - fflush (stderr); - if (status) - exit (status); -#endif #ifdef _LIBC _IO_funlockfile (stderr); diff --git a/misc/error.h b/misc/error.h index 3638bc6e98..f25005b0e8 100644 --- a/misc/error.h +++ b/misc/error.h @@ -1,5 +1,5 @@ /* Declaration for error-reporting function - Copyright (C) 1995, 1996, 1997, 2003 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 2003, 2006 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 @@ -37,8 +37,6 @@ extern "C" { #endif -#if defined __STDC__ && __STDC__ - /* Print a message with `fprintf (stderr, FORMAT, ...)'; if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). If STATUS is nonzero, terminate the program with `exit (STATUS)'. */ @@ -55,12 +53,6 @@ extern void error_at_line (int __status, int __errnum, const char *__fname, function without parameters instead. */ extern void (*error_print_progname) (void); -#else -void error (); -void error_at_line (); -extern void (*error_print_progname) (); -#endif - /* This variable is incremented each time `error' is called. */ extern unsigned int error_message_count; diff --git a/misc/fchflags.c b/misc/fchflags.c new file mode 100644 index 0000000000..f191194c12 --- /dev/null +++ b/misc/fchflags.c @@ -0,0 +1,43 @@ +/* Copyright (C) 1991, 1995, 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. */ + +#include +#include +#include + +/* Change the flags of the file FD refers to to FLAGS. */ + +int fchflags (int fd, int flags) __THROW; + +int +fchflags (fd, flags) + int fd; + int flags; +{ + if (fd < 0) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} + +stub_warning (fchflags) +#include diff --git a/misc/fdatasync.c b/misc/fdatasync.c new file mode 100644 index 0000000000..3edeef0c9e --- /dev/null +++ b/misc/fdatasync.c @@ -0,0 +1,28 @@ +/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU 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 + + +/* Synchronize at least the data part of a file with the underlying + media. */ +int +fdatasync (int fildes) +{ + return fsync (fildes); +} diff --git a/misc/fgetxattr.c b/misc/fgetxattr.c new file mode 100644 index 0000000000..610ed32d1f --- /dev/null +++ b/misc/fgetxattr.c @@ -0,0 +1,31 @@ +/* Copyright (C) 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 +#include + +ssize_t +fgetxattr (int __fd, const char *__name, + void *__value, size_t __size) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (fgetxattr) +#include diff --git a/misc/flistxattr.c b/misc/flistxattr.c new file mode 100644 index 0000000000..fc2863d31c --- /dev/null +++ b/misc/flistxattr.c @@ -0,0 +1,30 @@ +/* Copyright (C) 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 +#include + +ssize_t +flistxattr (int __fd, char *__list, size_t __size) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (flistxattr) +#include diff --git a/misc/fremovexattr.c b/misc/fremovexattr.c new file mode 100644 index 0000000000..9719d42d40 --- /dev/null +++ b/misc/fremovexattr.c @@ -0,0 +1,30 @@ +/* Copyright (C) 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 +#include + +int +fremovexattr (int __fd, const char *__name) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (fremovexattr) +#include diff --git a/misc/fsetxattr.c b/misc/fsetxattr.c new file mode 100644 index 0000000000..8a52e72529 --- /dev/null +++ b/misc/fsetxattr.c @@ -0,0 +1,31 @@ +/* Copyright (C) 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 +#include + +int +fsetxattr (int __fd, const char *__name, const void *__value, + size_t __size, int __flags) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (fsetxattr) +#include diff --git a/misc/fsync.c b/misc/fsync.c new file mode 100644 index 0000000000..e2a4d700d5 --- /dev/null +++ b/misc/fsync.c @@ -0,0 +1,33 @@ +/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU 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 +#include + +/* Make all changes done to FD actually appear on disk. */ +int +fsync (fd) + int fd; +{ + __set_errno (ENOSYS); + return -1; +} + + +stub_warning (fsync) +#include diff --git a/misc/ftruncate.c b/misc/ftruncate.c new file mode 100644 index 0000000000..d4cca2e267 --- /dev/null +++ b/misc/ftruncate.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1991, 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. */ + +#include +#include +#include + +/* Truncate the file FD refers to to LENGTH bytes. */ +int +__ftruncate (fd, length) + int fd; + off_t length; +{ + __set_errno (ENOSYS); + return -1; +} + +weak_alias (__ftruncate, ftruncate) + +stub_warning (ftruncate) +#include diff --git a/misc/ftruncate64.c b/misc/ftruncate64.c new file mode 100644 index 0000000000..df84b7c3c1 --- /dev/null +++ b/misc/ftruncate64.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1997, 1998, 2001 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 +#include +#include + +/* Truncate the file FD refers to to LENGTH bytes. */ +int +__ftruncate64 (fd, length) + int fd; + off64_t length; +{ + if ((off_t) length != length) + { + __set_errno (EINVAL); + return -1; + } + return __ftruncate (fd, (off_t) length); +} +weak_alias (__ftruncate64, ftruncate64) diff --git a/misc/futimes.c b/misc/futimes.c new file mode 100644 index 0000000000..3378dbf416 --- /dev/null +++ b/misc/futimes.c @@ -0,0 +1,34 @@ +/* futimes -- change access and modification times of open file. Stub version. + Copyright (C) 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 +#include + +/* Change the access time of FILE to TVP[0] and + the modification time of FILE to TVP[1], but do not follow symlinks. */ +int +__futimes (int fd, const struct timeval tvp[2]) +{ + __set_errno (ENOSYS); + return -1; +} +weak_alias (__futimes, futimes) + +stub_warning (futimes) +#include diff --git a/misc/futimesat.c b/misc/futimesat.c new file mode 100644 index 0000000000..bf16ce8de0 --- /dev/null +++ b/misc/futimesat.c @@ -0,0 +1,46 @@ +/* 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 +#include +#include +#include + + +/* 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]; +{ + if (fd < 0 + && (file == NULL + || (fd != AT_FDCWD && file[0] != '/'))) + { + __set_errno (EBADF); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} + +stub_warning (futimesat) +#include diff --git a/misc/getclktck.c b/misc/getclktck.c new file mode 100644 index 0000000000..897c6a25ba --- /dev/null +++ b/misc/getclktck.c @@ -0,0 +1,30 @@ +/* Copyright (C) 2000 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 + +/* Return frequency of times(). */ +int +__getclktck () +{ +#ifdef CLK_TCK + return CLK_TCK; +#else + return 60; +#endif +} diff --git a/misc/getdomain.c b/misc/getdomain.c new file mode 100644 index 0000000000..6074ccfb79 --- /dev/null +++ b/misc/getdomain.c @@ -0,0 +1,64 @@ +/* Copyright (C) 1994,95,97,2000,02 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. */ + +/* Put the name of the current YP domain in no more than LEN bytes of NAME. + The result is null-terminated if LEN is large enough for the full + name and the terminator. */ + +#include +#include +#include +#include +#include + +#if _UTSNAME_DOMAIN_LENGTH +/* The `uname' information includes the domain name. */ + +int +getdomainname (name, len) + char *name; + size_t len; +{ + struct utsname u; + size_t u_len; + + if (uname (&u) < 0) + return -1; + + u_len = strlen (u.domainname); + memcpy (name, u.domainname, MIN (u_len + 1, len)); + return 0; +} + +#else + +int +getdomainname (name, len) + char *name; + size_t len; +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (getdomainname) +#include + +#endif + +libc_hidden_def (getdomainname) diff --git a/misc/getdtsz.c b/misc/getdtsz.c new file mode 100644 index 0000000000..38b7577914 --- /dev/null +++ b/misc/getdtsz.c @@ -0,0 +1,33 @@ +/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU 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 +#include + +/* Return the maximum number of file descriptors + the current process could possibly have. */ +int +__getdtablesize () +{ + __set_errno (ENOSYS); + return -1; +} +stub_warning (getdtablesize) + +weak_alias (__getdtablesize, getdtablesize) +#include diff --git a/misc/gethostid.c b/misc/gethostid.c new file mode 100644 index 0000000000..01baf12230 --- /dev/null +++ b/misc/gethostid.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU 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 +#include + +/* Return the current machine's Internet number. */ +long int +gethostid () +{ + __set_errno (ENOSYS); + return -1L; +} + + +stub_warning (gethostid) +#include diff --git a/misc/gethostname.c b/misc/gethostname.c new file mode 100644 index 0000000000..bc59ab57c6 --- /dev/null +++ b/misc/gethostname.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1991,1995,1996,1997,2000,2001 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 +#include + +/* Put the name of the current host in no more than LEN bytes of NAME. + The result is null-terminated if LEN is large enough for the full + name and the terminator. */ +int +__gethostname (name, len) + char *name; + size_t len; +{ + __set_errno (ENOSYS); + return -1; +} +stub_warning (gethostname) + +weak_alias (__gethostname, gethostname) +#include diff --git a/misc/getloadavg.c b/misc/getloadavg.c new file mode 100644 index 0000000000..070c879fd5 --- /dev/null +++ b/misc/getloadavg.c @@ -0,0 +1,37 @@ +/* Get system load averages. Stub version. + Copyright (C) 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU 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 +#include +#include + + +/* Put the 1 minute, 5 minute and 15 minute load averages + into the first NELEM elements of LOADAVG. + Return the number written (never more than 3, but may be less than NELEM), + or -1 if an error occurred. */ + +int +getloadavg (double loadavg[], int nelem) +{ + __set_errno (ENOSYS); + return -1; +} +stub_warning (getloadavg) +#include diff --git a/misc/getpagesize.c b/misc/getpagesize.c new file mode 100644 index 0000000000..40ed1ee2b1 --- /dev/null +++ b/misc/getpagesize.c @@ -0,0 +1,33 @@ +/* Copyright (C) 1991, 1993, 1995, 1996, 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 +#include + +/* Return the system page size. */ +int +__getpagesize () +{ + __set_errno (ENOSYS); + return 0; +} +libc_hidden_def (__getpagesize) +stub_warning (getpagesize) + +weak_alias (__getpagesize, getpagesize) +#include diff --git a/misc/getpass.c b/misc/getpass.c index 62e56866a1..5290c3c7d3 100644 --- a/misc/getpass.c +++ b/misc/getpass.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-1999, 2001, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1992-1999,2001,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 @@ -91,12 +91,7 @@ getpass (prompt) tty_changed = 0; /* Write the prompt. */ -#ifdef USE_IN_LIBIO - if (_IO_fwide (out, 0) > 0) - __fwprintf (out, L"%s", prompt); - else -#endif - fputs_unlocked (prompt, out); + __fxprintf (out, "%s", prompt); fflush_unlocked (out); /* Read the password. */ @@ -110,15 +105,8 @@ getpass (prompt) /* Remove the newline. */ buf[nread - 1] = '\0'; if (tty_changed) - { - /* Write the newline that was not echoed. */ -#ifdef USE_IN_LIBIO - if (_IO_fwide (out, 0) > 0) - putwc_unlocked (L'\n', out); - else -#endif - putc_unlocked ('\n', out); - } + /* Write the newline that was not echoed. */ + __fxprintf (out, "\n"); } } diff --git a/misc/getsysstats.c b/misc/getsysstats.c new file mode 100644 index 0000000000..bc67e23e79 --- /dev/null +++ b/misc/getsysstats.c @@ -0,0 +1,69 @@ +/* getsysstats - Determine various system internal values, stub version. + Copyright (C) 1996, 1997, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1996. + + 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 +#include + +int +__get_nprocs_conf () +{ + /* We don't know how to determine the number. Simply return always 1. */ + return 1; +} +weak_alias (__get_nprocs_conf, get_nprocs_conf) + +link_warning (get_nprocs_conf, "warning: get_nprocs_conf will always return 1") + + + +int +__get_nprocs () +{ + /* We don't know how to determine the number. Simply return always 1. */ + return 1; +} +weak_alias (__get_nprocs, get_nprocs) + +link_warning (get_nprocs, "warning: get_nprocs will always return 1") + + +long int +__get_phys_pages () +{ + /* We have no general way to determine this value. */ + __set_errno (ENOSYS); + return -1; +} +weak_alias (__get_phys_pages, get_phys_pages) + +stub_warning (get_phys_pages) + + +long int +__get_avphys_pages () +{ + /* We have no general way to determine this value. */ + __set_errno (ENOSYS); + return -1; +} +weak_alias (__get_avphys_pages, get_avphys_pages) + +stub_warning (get_avphys_pages) +#include diff --git a/misc/getusershell.c b/misc/getusershell.c index 95f0eab5e2..636da322f9 100644 --- a/misc/getusershell.c +++ b/misc/getusershell.c @@ -46,7 +46,15 @@ static char sccsid[] = "@(#)getusershell.c 8.1 (Berkeley) 6/4/93"; * /etc/shells. */ -static const char *okshells[] = { _PATH_BSHELL, _PATH_CSHELL, NULL }; +/* NB: we do not initialize okshells here. The initialization needs + relocations. These interfaces are used so rarely that this is not + justified. Instead explicitly initialize the array when it is + used. */ +#if 0 +static const char *const okshells[] = { _PATH_BSHELL, _PATH_CSHELL, NULL }; +#else +static const char *okshells[3]; +#endif static char **curshell, **shells, *strings; static char **initshells (void) __THROW; @@ -70,11 +78,9 @@ void endusershell() { - if (shells != NULL) - free(shells); + free(shells); shells = NULL; - if (strings != NULL) - free(strings); + free(strings); strings = NULL; curshell = NULL; } @@ -92,40 +98,39 @@ initshells() register char **sp, *cp; register FILE *fp; struct stat64 statb; - int flen; + size_t flen; - if (shells != NULL) - free(shells); + free(shells); shells = NULL; - if (strings != NULL) - free(strings); + free(strings); strings = NULL; if ((fp = fopen(_PATH_SHELLS, "rc")) == NULL) - return (char **) okshells; + goto init_okshells_noclose; if (fstat64(fileno(fp), &statb) == -1) { + init_okshells: (void)fclose(fp); + init_okshells_noclose: + okshells[0] = _PATH_BSHELL; + okshells[1] = _PATH_CSHELL; return (char **) okshells; } - if ((strings = malloc((u_int)statb.st_size + 1)) == NULL) { - (void)fclose(fp); - return (char **) okshells; - } - shells = calloc((unsigned)statb.st_size / 3, sizeof (char *)); + if (statb.st_size > ~(size_t)0 / sizeof (char *) * 3) + goto init_okshells; + if ((strings = malloc(statb.st_size + 2)) == NULL) + goto init_okshells; + shells = malloc(statb.st_size / 3 * sizeof (char *)); if (shells == NULL) { - (void)fclose(fp); free(strings); strings = NULL; - return (char **) okshells; + goto init_okshells; } - /* No threads using this stream. */ - __fsetlocking (fp, FSETLOCKING_BYCALLER); sp = shells; cp = strings; - flen = statb.st_size; + flen = statb.st_size + 2; while (fgets_unlocked(cp, flen - (cp - strings), fp) != NULL) { while (*cp != '#' && *cp != '/' && *cp != '\0') cp++; - if (*cp == '#' || *cp == '\0') + if (*cp == '#' || *cp == '\0' || cp[1] == '\0') continue; *sp++ = cp; while (!isspace(*cp) && *cp != '#' && *cp != '\0') diff --git a/misc/getxattr.c b/misc/getxattr.c new file mode 100644 index 0000000000..ebf7bf2b4d --- /dev/null +++ b/misc/getxattr.c @@ -0,0 +1,31 @@ +/* Copyright (C) 2002 Free Software Foundation, Inc