diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-12-27 19:51:23 +0000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-12-27 19:51:23 +0000 |
commit | 9a47d57c4784163dcf838c7461c53de29ca7a61f (patch) | |
tree | 80c130f3da27db25996b0a5f93270df554dcd8b4 /misc | |
parent | e0b77a51a258fc7554aeb194ac6b219ee3078f0d (diff) | |
parent | 82dd75a7f436a19047325d62182590c9f9e23a78 (diff) |
Merge branch 't/tls' into refs/top-bases/tschwinge/Roger_Whittaker
Diffstat (limited to 'misc')
167 files changed, 2334 insertions, 439 deletions
diff --git a/misc/Makefile b/misc/Makefile index 4bfc935fd8..1294a21302 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991-2016 Free Software Foundation, Inc. +# Copyright (C) 1991-2018 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,21 +23,24 @@ subdir := misc include ../Makeconfig -headers := sys/uio.h bits/uio.h sys/ioctl.h bits/ioctls.h bits/ioctl-types.h \ +headers := sys/uio.h bits/uio-ext.h bits/uio_lim.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 paths.h sys/reboot.h \ sys/mman.h sys/param.h bits/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 \ + sys/select.h sys/sysinfo.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 bits/error.h \ - bits/select2.h bits/hwcap.h sys/auxv.h + bits/select2.h bits/hwcap.h sys/auxv.h \ + sys/sysmacros.h bits/sysmacros.h bits/types/struct_iovec.h routines := brk sbrk sstk ioctl \ readv writev preadv preadv64 pwritev pwritev64 \ + preadv2 preadv64v2 pwritev2 pwritev64v2 \ setreuid setregid \ seteuid setegid \ getpagesize \ @@ -67,9 +70,11 @@ routines := brk sbrk sstk ioctl \ getloadavg getclktck \ fgetxattr flistxattr fremovexattr fsetxattr getxattr \ listxattr lgetxattr llistxattr lremovexattr lsetxattr \ - removexattr setxattr getauxval ifunc-impl-list + removexattr setxattr getauxval ifunc-impl-list makedev \ + allocate_once -generated += tst-error1.mtrace tst-error1-mem.out +generated += tst-error1.mtrace tst-error1-mem.out \ + tst-allocate_once.mtrace tst-allocate_once-mem.out aux := init-misc install-lib := libg.a @@ -77,27 +82,52 @@ gpl2lgpl := error.c error.h tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent tst-hsearch \ tst-error1 tst-pselect tst-insremque tst-mntent2 bug-hsearch1 \ - tst-mntent-blank-corrupt tst-mntent-blank-passno bug18240 + tst-mntent-blank-corrupt tst-mntent-blank-passno bug18240 \ + tst-preadvwritev tst-preadvwritev64 tst-makedev tst-empty \ + tst-preadvwritev2 tst-preadvwritev64v2 + +tests-internal := tst-atomic tst-atomic-long tst-allocate_once +tests-static := tst-empty + ifeq ($(run-built-tests),yes) -tests-special += $(objpfx)tst-error1-mem.out +tests-special += $(objpfx)tst-error1-mem.out \ + $(objpfx)tst-allocate_once-mem.out endif -CFLAGS-select.c = -fexceptions -fasynchronous-unwind-tables -CFLAGS-tsearch.c = $(uses-callbacks) -CFLAGS-lsearch.c = $(uses-callbacks) -CFLAGS-pselect.c = -fexceptions -CFLAGS-readv.c = -fexceptions -fasynchronous-unwind-tables -CFLAGS-writev.c = -fexceptions -fasynchronous-unwind-tables -CFLAGS-usleep.c = -fexceptions -CFLAGS-syslog.c = -fexceptions -CFLAGS-error.c = -fexceptions -CFLAGS-getpass.c = -fexceptions -CFLAGS-mkstemp.c = -fexceptions -CFLAGS-mkstemp64.c = -fexceptions -CFLAGS-getsysstats.c = -fexceptions -CFLAGS-getusershell.c = -fexceptions -CFLAGS-err.c = -fexceptions -CFLAGS-tst-tsearch.c = $(stack-align-test-flags) +CFLAGS-select.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-tsearch.c += $(uses-callbacks) +CFLAGS-lsearch.c += $(uses-callbacks) +CFLAGS-pselect.c += -fexceptions +CFLAGS-readv.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-writev.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-preadv.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-preadv64.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-pwritev.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-pwritev64.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-preadv2.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-preadv64v2.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-pwritev2.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-pwritev64v2.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-usleep.c += -fexceptions +CFLAGS-syslog.c += -fexceptions +CFLAGS-error.c += -fexceptions +CFLAGS-getpass.c += -fexceptions +CFLAGS-mkstemp.c += -fexceptions +CFLAGS-mkstemp64.c += -fexceptions +CFLAGS-getsysstats.c += -fexceptions +CFLAGS-getusershell.c += -fexceptions +CFLAGS-err.c += -fexceptions +CFLAGS-tst-tsearch.c += $(stack-align-test-flags) +CFLAGS-msync.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-fdatasync.c += -fexceptions -fasynchronous-unwind-tables +CFLAGS-fsync.c += -fexceptions -fasynchronous-unwind-tables + +# Called during static library initialization, so turn stack-protection +# off for non-shared builds. +CFLAGS-sbrk.o = $(no-stack-protector) +CFLAGS-sbrk.op = $(no-stack-protector) +CFLAGS-brk.o = $(no-stack-protector) +CFLAGS-brk.op = $(no-stack-protector) tests += tst-sbrk tst-sbrk-pie tst-sbrk-static tests-pie += tst-sbrk-pie @@ -114,3 +144,8 @@ tst-error1-ARGS = $(objpfx)tst-error1.out $(objpfx)tst-error1-mem.out: $(objpfx)tst-error1.out $(common-objpfx)malloc/mtrace $(objpfx)tst-error1.mtrace > $@; \ $(evaluate-test) + +tst-allocate_once-ENV = MALLOC_TRACE=$(objpfx)tst-allocate_once.mtrace +$(objpfx)tst-allocate_once-mem.out: $(objpfx)tst-allocate_once.out + $(common-objpfx)malloc/mtrace $(objpfx)tst-allocate_once.mtrace > $@; \ + $(evaluate-test) diff --git a/misc/Versions b/misc/Versions index 671f4870e9..900e4ffb79 100644 --- a/misc/Versions +++ b/misc/Versions @@ -152,10 +152,19 @@ libc { GLIBC_2.23 { # SHLIB_COMPAT(GLIBC_2_0, GLIBC_2_23) used in regexp.c } + GLIBC_2.25 { + gnu_dev_major; gnu_dev_minor; gnu_dev_makedev; + } + GLIBC_2.26 { + preadv2; preadv64v2; pwritev2; pwritev64v2; + } GLIBC_PRIVATE { __madvise; __mktemp; __libc_ifunc_impl_list; __tdelete; __tfind; __tsearch; __twalk; + __mmap; __munmap; __mprotect; + __sched_get_priority_min; __sched_get_priority_max; + __libc_allocate_once_slow; } } diff --git a/misc/acct.c b/misc/acct.c index 74ff43a233..bfe5faba62 100644 --- a/misc/acct.c +++ b/misc/acct.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/allocate_once.c b/misc/allocate_once.c new file mode 100644 index 0000000000..2108014604 --- /dev/null +++ b/misc/allocate_once.c @@ -0,0 +1,59 @@ +/* Concurrent allocation and initialization of a pointer. + Copyright (C) 2018 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, see + <http://www.gnu.org/licenses/>. */ + +#include <allocate_once.h> +#include <stdlib.h> +#include <stdbool.h> + +void * +__libc_allocate_once_slow (void **place, void *(*allocate) (void *closure), + void (*deallocate) (void *closure, void *ptr), + void *closure) +{ + void *result = allocate (closure); + if (result == NULL) + return NULL; + + /* This loop implements a strong CAS on *place, with acquire-release + MO semantics, from a weak CAS with relaxed-release MO. */ + while (true) + { + /* Synchronizes with the acquire MO load in allocate_once. */ + void *expected = NULL; + if (atomic_compare_exchange_weak_release (place, &expected, result)) + return result; + + /* The failed CAS has relaxed MO semantics, so perform another + acquire MO load. */ + void *other_result = atomic_load_acquire (place); + if (other_result == NULL) + /* Spurious failure. Try again. */ + continue; + + /* We lost the race. Free what we allocated and return the + other result. */ + if (deallocate == NULL) + free (result); + else + deallocate (closure, result); + return other_result; + } + + return result; +} +libc_hidden_def (__libc_allocate_once_slow) @@ -1,5 +1,5 @@ /* Header describing `ar' archive file format. - Copyright (C) 1996-2016 Free Software Foundation, Inc. + Copyright (C) 1996-2018 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 diff --git a/misc/bits/error.h b/misc/bits/error.h index 84082897f8..682cf2060e 100644 --- a/misc/bits/error.h +++ b/misc/bits/error.h @@ -1,5 +1,5 @@ /* Specializations for error functions. - Copyright (C) 2007-2016 Free Software Foundation, Inc. + Copyright (C) 2007-2018 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 diff --git a/misc/bits/select2.h b/misc/bits/select2.h index 56f2205ad5..7194148997 100644 --- a/misc/bits/select2.h +++ b/misc/bits/select2.h @@ -1,5 +1,5 @@ /* Checking macros for select functions. - Copyright (C) 2011-2016 Free Software Foundation, Inc. + Copyright (C) 2011-2018 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 diff --git a/misc/bits/stab.def b/misc/bits/stab.def index 2af2ddfc63..ab44580e95 100644 --- a/misc/bits/stab.def +++ b/misc/bits/stab.def @@ -1,5 +1,5 @@ /* Table of DBX symbol codes for the GNU system. - Copyright (C) 1988, 1997-2016 Free Software Foundation, Inc. + Copyright (C) 1988, 1997-2018 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 diff --git a/misc/bits/syslog-ldbl.h b/misc/bits/syslog-ldbl.h index 7c1c03de95..977f90a9fe 100644 --- a/misc/bits/syslog-ldbl.h +++ b/misc/bits/syslog-ldbl.h @@ -1,5 +1,5 @@ /* -mlong-double-64 compatibility mode for syslog functions. - Copyright (C) 2006-2016 Free Software Foundation, Inc. + Copyright (C) 2006-2018 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 diff --git a/misc/bits/syslog.h b/misc/bits/syslog.h index 31dae38e57..6719fbe795 100644 --- a/misc/bits/syslog.h +++ b/misc/bits/syslog.h @@ -1,5 +1,5 @@ /* Checking macros for syslog functions. - Copyright (C) 2005-2016 Free Software Foundation, Inc. + Copyright (C) 2005-2018 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 diff --git a/misc/sys/ustat.h b/misc/bits/types/struct_iovec.h index b58a1def7c..490b06b89b 100644 --- a/misc/sys/ustat.h +++ b/misc/bits/types/struct_iovec.h @@ -1,5 +1,5 @@ -/* Header describing obsolete `ustat' interface. - Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Define struct iovec. + Copyright (C) 1996-2018 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 @@ -16,22 +16,17 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -/* - * This interface is obsolete. Use <sys/statfs.h> instead. - */ +#ifndef __iovec_defined +#define __iovec_defined 1 -#ifndef _SYS_USTAT_H -#define _SYS_USTAT_H 1 +#define __need_size_t +#include <stddef.h> -#include <features.h> +/* Structure for scatter/gather I/O. */ +struct iovec + { + void *iov_base; /* Pointer to data. */ + size_t iov_len; /* Length of data. */ + }; -#include <sys/types.h> -#include <bits/ustat.h> - -__BEGIN_DECLS - -extern int ustat (__dev_t __dev, struct ustat *__ubuf) __THROW; - -__END_DECLS - -#endif /* sys/ustat.h */ +#endif diff --git a/misc/brk.c b/misc/brk.c index 76bd1b740d..2dea69acb3 100644 --- a/misc/brk.c +++ b/misc/brk.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/bug18240.c b/misc/bug18240.c index 773586ee10..b1471698d0 100644 --- a/misc/bug18240.c +++ b/misc/bug18240.c @@ -1,5 +1,5 @@ /* Test integer wraparound in hcreate. - Copyright (C) 2016 Free Software Foundation, Inc. + Copyright (C) 2016-2018 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 diff --git a/misc/chflags.c b/misc/chflags.c index 49c2fec851..7e6a21478e 100644 --- a/misc/chflags.c +++ b/misc/chflags.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/chroot.c b/misc/chroot.c index b863f3108f..630f88329c 100644 --- a/misc/chroot.c +++ b/misc/chroot.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/daemon.c b/misc/daemon.c index 9d186b24bd..21e785966a 100644 --- a/misc/daemon.c +++ b/misc/daemon.c @@ -63,7 +63,7 @@ daemon (int nochdir, int noclose) if (!noclose) { struct stat64 st; - if ((fd = open_not_cancel(_PATH_DEVNULL, O_RDWR, 0)) != -1 + if ((fd = __open_nocancel(_PATH_DEVNULL, O_RDWR, 0)) != -1 && (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) == 0)) { if (__builtin_expect (S_ISCHR (st.st_mode), 1) != 0 @@ -80,12 +80,12 @@ daemon (int nochdir, int noclose) } else { /* We must set an errno value since no function call actually failed. */ - close_not_cancel_no_status (fd); + __close_nocancel_nostatus (fd); __set_errno (ENODEV); return -1; } } else { - close_not_cancel_no_status (fd); + __close_nocancel_nostatus (fd); return -1; } } diff --git a/misc/dirname.c b/misc/dirname.c index a3dd52f2e8..11797a1492 100644 --- a/misc/dirname.c +++ b/misc/dirname.c @@ -1,5 +1,5 @@ /* dirname - return directory part of PATH. - Copyright (C) 1996-2016 Free Software Foundation, Inc. + Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/misc/efgcvt.c b/misc/efgcvt.c index c5b5f23558..0081c1a499 100644 --- a/misc/efgcvt.c +++ b/misc/efgcvt.c @@ -1,5 +1,5 @@ /* Compatibility functions for floating point formatting. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 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 diff --git a/misc/efgcvt_r.c b/misc/efgcvt_r.c index a172760ecc..aa3a3cd279 100644 --- a/misc/efgcvt_r.c +++ b/misc/efgcvt_r.c @@ -1,5 +1,5 @@ /* Compatibility functions for floating point formatting, reentrant versions. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 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 @@ -240,6 +240,7 @@ __APPEND (FUNC_PREFIX, ecvt_r) (FLOAT_TYPE value, int ndigit, int *decpt, cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \ APPEND (FUNC_PREFIX, symbol), GLIBC_2_4) # define cvt_symbol_1(lib, local, symbol, version) \ + libc_hidden_def (local) \ versioned_symbol (lib, local, symbol, version) # else # define cvt_symbol(symbol) \ @@ -247,11 +248,15 @@ __APPEND (FUNC_PREFIX, ecvt_r) (FLOAT_TYPE value, int ndigit, int *decpt, APPEND (q, symbol), GLIBC_2_0); \ weak_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) # define cvt_symbol_1(lib, local, symbol, version) \ + libc_hidden_def (local) \ compat_symbol (lib, local, symbol, version) # endif #else # define cvt_symbol(symbol) \ - weak_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) + cvt_symbol_1 (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) +# define cvt_symbol_1(local, symbol) \ + libc_hidden_def (local) \ + weak_alias (local, symbol) #endif cvt_symbol(fcvt_r); cvt_symbol(ecvt_r); diff --git a/misc/err.c b/misc/err.c index 3067835a5d..2b836e8358 100644 --- a/misc/err.c +++ b/misc/err.c @@ -1,5 +1,5 @@ /* 4.4BSD utility functions for error messages. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 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 diff --git a/misc/err.h b/misc/err.h index b43fe68fea..fec4fd2f77 100644 --- a/misc/err.h +++ b/misc/err.h @@ -1,5 +1,5 @@ /* 4.4BSD utility functions for error messages. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -24,7 +24,7 @@ #define __need___va_list #include <stdarg.h> #ifndef __GNUC_VA_LIST -# define __gnuc_va_list __ptr_t +# define __gnuc_va_list void * #endif __BEGIN_DECLS diff --git a/misc/error.c b/misc/error.c index c4c0ae95fd..b4e8b6c938 100644 --- a/misc/error.c +++ b/misc/error.c @@ -1,5 +1,5 @@ /* Error handler for noninteractive utilities - Copyright (C) 1990-2016 Free Software Foundation, Inc. + Copyright (C) 1990-2018 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 diff --git a/misc/error.h b/misc/error.h index 32d84ee92d..fcd5ad90dc 100644 --- a/misc/error.h +++ b/misc/error.h @@ -1,5 +1,5 @@ /* Declaration for error-reporting function - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 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 diff --git a/misc/fchflags.c b/misc/fchflags.c index b3115f7660..53ec953f54 100644 --- a/misc/fchflags.c +++ b/misc/fchflags.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/fdatasync.c b/misc/fdatasync.c index 8bc1ec38e3..67a95eb818 100644 --- a/misc/fdatasync.c +++ b/misc/fdatasync.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 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 diff --git a/misc/fgetxattr.c b/misc/fgetxattr.c index 6ab1cc08b6..5c8e20accc 100644 --- a/misc/fgetxattr.c +++ b/misc/fgetxattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2016 Free Software Foundation, Inc. +/* Copyright (C) 2002-2018 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 diff --git a/misc/flistxattr.c b/misc/flistxattr.c index 22db5b44fd..46e371964c 100644 --- a/misc/flistxattr.c +++ b/misc/flistxattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2016 Free Software Foundation, Inc. +/* Copyright (C) 2002-2018 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 diff --git a/misc/fremovexattr.c b/misc/fremovexattr.c index a51ef00988..b03ce2e535 100644 --- a/misc/fremovexattr.c +++ b/misc/fremovexattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2016 Free Software Foundation, Inc. +/* Copyright (C) 2002-2018 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 diff --git a/misc/fsetxattr.c b/misc/fsetxattr.c index 8a2a7a1a48..635ab1cc96 100644 --- a/misc/fsetxattr.c +++ b/misc/fsetxattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2016 Free Software Foundation, Inc. +/* Copyright (C) 2002-2018 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 diff --git a/misc/fstab.c b/misc/fstab.c index 41b4874431..8fbe3c7767 100644 --- a/misc/fstab.c +++ b/misc/fstab.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2016 Free Software Foundation, Inc. +/* Copyright (C) 1995-2018 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 diff --git a/misc/fsync.c b/misc/fsync.c index a6f1901c1c..e52be4cc6a 100644 --- a/misc/fsync.c +++ b/misc/fsync.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/ftruncate.c b/misc/ftruncate.c index c64cad1dcb..7e30b159d5 100644 --- a/misc/ftruncate.c +++ b/misc/ftruncate.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/ftruncate64.c b/misc/ftruncate64.c index 8c5231410e..a90e949f93 100644 --- a/misc/ftruncate64.c +++ b/misc/ftruncate64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997-2016 Free Software Foundation, Inc. +/* Copyright (C) 1997-2018 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 diff --git a/misc/futimes.c b/misc/futimes.c index 88f28d4a6d..3ffa40b0b1 100644 --- a/misc/futimes.c +++ b/misc/futimes.c @@ -1,5 +1,5 @@ /* futimes -- change access and modification times of open file. Stub version. - Copyright (C) 2002-2016 Free Software Foundation, Inc. + Copyright (C) 2002-2018 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 diff --git a/misc/futimesat.c b/misc/futimesat.c index 401b270d83..b467184b41 100644 --- a/misc/futimesat.c +++ b/misc/futimesat.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2005-2016 Free Software Foundation, Inc. +/* futimesat -- Change access and modification times of file. Stub version. + Copyright (C) 2005-2018 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 diff --git a/misc/getauxval.c b/misc/getauxval.c index 61113766da..0a5c1ec384 100644 --- a/misc/getauxval.c +++ b/misc/getauxval.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2012-2016 Free Software Foundation, Inc. +/* Copyright (C) 2012-2018 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,7 +23,9 @@ unsigned long int __getauxval (unsigned long int type) { +#ifdef HAVE_AUX_VECTOR ElfW(auxv_t) *p; +#endif if (type == AT_HWCAP) return GLRO(dl_hwcap); @@ -41,3 +43,4 @@ __getauxval (unsigned long int type) } weak_alias (__getauxval, getauxval) +libc_hidden_def (__getauxval) diff --git a/misc/getclktck.c b/misc/getclktck.c index c94f3ecef1..19a69f6806 100644 --- a/misc/getclktck.c +++ b/misc/getclktck.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2016 Free Software Foundation, Inc. +/* Copyright (C) 2000-2018 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 diff --git a/misc/getdomain.c b/misc/getdomain.c index 8f75cc6c8d..c25f8ae128 100644 --- a/misc/getdomain.c +++ b/misc/getdomain.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1994-2016 Free Software Foundation, Inc. +/* Copyright (C) 1994-2018 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 diff --git a/misc/getdtsz.c b/misc/getdtsz.c index 5398b79667..fe5cc1e9b2 100644 --- a/misc/getdtsz.c +++ b/misc/getdtsz.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/gethostid.c b/misc/gethostid.c index 70af0b09f7..bec2b03dc6 100644 --- a/misc/gethostid.c +++ b/misc/gethostid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/gethostname.c b/misc/gethostname.c index f9a508a096..a78ce235d8 100644 --- a/misc/gethostname.c +++ b/misc/gethostname.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/getloadavg.c b/misc/getloadavg.c index 9fa3440976..bb5613de65 100644 --- a/misc/getloadavg.c +++ b/misc/getloadavg.c @@ -1,5 +1,5 @@ /* Get system load averages. Stub version. - Copyright (C) 1999-2016 Free Software Foundation, Inc. + Copyright (C) 1999-2018 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 diff --git a/misc/getpagesize.c b/misc/getpagesize.c index ea795c7742..5fc162773d 100644 --- a/misc/getpagesize.c +++ b/misc/getpagesize.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/getpass.c b/misc/getpass.c index 7d34796da9..a7023e37a8 100644 --- a/misc/getpass.c +++ b/misc/getpass.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2016 Free Software Foundation, Inc. +/* Copyright (C) 1992-2018 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 diff --git a/misc/getsysstats.c b/misc/getsysstats.c index 048e407759..4b886f2f88 100644 --- a/misc/getsysstats.c +++ b/misc/getsysstats.c @@ -1,5 +1,5 @@ /* getsysstats - Determine various system internal values, stub version. - Copyright (C) 1996-2016 Free Software Foundation, Inc. + Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -26,6 +26,7 @@ __get_nprocs_conf (void) /* We don't know how to determine the number. Simply return always 1. */ return 1; } +libc_hidden_def (__get_nprocs_conf) weak_alias (__get_nprocs_conf, get_nprocs_conf) link_warning (get_nprocs_conf, "warning: get_nprocs_conf will always return 1") @@ -38,6 +39,7 @@ __get_nprocs (void) /* We don't know how to determine the number. Simply return always 1. */ return 1; } +libc_hidden_def (__get_nprocs) weak_alias (__get_nprocs, get_nprocs) link_warning (get_nprocs, "warning: get_nprocs will always return 1") @@ -50,6 +52,7 @@ __get_phys_pages (void) __set_errno (ENOSYS); return -1; } +libc_hidden_def (__get_phys_pages) weak_alias (__get_phys_pages, get_phys_pages) stub_warning (get_phys_pages) @@ -62,6 +65,7 @@ __get_avphys_pages (void) __set_errno (ENOSYS); return -1; } +libc_hidden_def (__get_avphys_pages) weak_alias (__get_avphys_pages, get_avphys_pages) stub_warning (get_avphys_pages) diff --git a/misc/getttyent.c b/misc/getttyent.c index d2af870123..92d92b026f 100644 --- a/misc/getttyent.c +++ b/misc/getttyent.c @@ -57,8 +57,8 @@ __getttynam (const char *tty) } weak_alias (__getttynam, getttynam) -static char *skip (char *) __THROW internal_function; -static char *value (char *) __THROW internal_function; +static char *skip (char *) __THROW; +static char *value (char *) __THROW; struct ttyent * __getttyent (void) @@ -78,8 +78,8 @@ __getttyent (void) return (NULL); } /* skip lines that are too big */ - if (!index(p, '\n')) { - while ((c = getc_unlocked(tf)) != '\n' && c != EOF) + if (!strchr (p, '\n')) { + while ((c = __getc_unlocked(tf)) != '\n' && c != EOF) ; continue; } @@ -127,7 +127,7 @@ __getttyent (void) tty.ty_comment = p; if (*p == 0) tty.ty_comment = 0; - if ((p = index(p, '\n'))) + if ((p = strchr (p, '\n'))) *p = '\0'; return (&tty); } @@ -141,7 +141,6 @@ weak_alias (__getttyent, getttyent) * the next field. */ static char * -internal_function skip (char *p) { char *t; @@ -175,11 +174,10 @@ skip (char *p) } static char * -internal_function value (char *p) { - return ((p = index(p, '=')) ? ++p : NULL); + return ((p = strchr (p, '=')) ? ++p : NULL); } int diff --git a/misc/getxattr.c b/misc/getxattr.c index 23c70030e2..003eeb82ec 100644 --- a/misc/getxattr.c +++ b/misc/getxattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2016 Free Software Foundation, Inc. +/* Copyright (C) 2002-2018 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 diff --git a/misc/gtty.c b/misc/gtty.c index 2d88455575..c84d07fc0b 100644 --- a/misc/gtty.c +++ b/misc/gtty.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/hsearch.c b/misc/hsearch.c index 80ae881ecd..1c061170b5 100644 --- a/misc/hsearch.c +++ b/misc/hsearch.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993-2016 Free Software Foundation, Inc. +/* Copyright (C) 1993-2018 Free Software Foundation, Inc. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu> This file is part of the GNU C Library. diff --git a/misc/hsearch_r.c b/misc/hsearch_r.c index 1fca6b3222..83c6b0a512 100644 --- a/misc/hsearch_r.c +++ b/misc/hsearch_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993-2016 Free Software Foundation, Inc. +/* Copyright (C) 1993-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1993. @@ -21,6 +21,7 @@ #include <string.h> #include <stdint.h> #include <search.h> +#include <limits.h> /* [Aho,Sethi,Ullman] Compilers: Principles, Techniques and Tools, 1986 [Knuth] The Art of Computer Programming, part 3 (6.4) */ diff --git a/misc/ifunc-impl-list.c b/misc/ifunc-impl-list.c index 11a1becbd1..a161ece386 100644 --- a/misc/ifunc-impl-list.c +++ b/misc/ifunc-impl-list.c @@ -1,5 +1,5 @@ /* Enumerate available IFUNC implementations of a function. Stub version. - Copyright (C) 2012-2016 Free Software Foundation, Inc. + Copyright (C) 2012-2018 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 diff --git a/misc/init-misc.c b/misc/init-misc.c index a9bf1da74a..2a1b82710e 100644 --- a/misc/init-misc.c +++ b/misc/init-misc.c @@ -1,5 +1,5 @@ /* Define and initialize `__progname' et. al. - Copyright (C) 1994-2016 Free Software Foundation, Inc. + Copyright (C) 1994-2018 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 diff --git a/misc/insremque.c b/misc/insremque.c index cb435dc0df..d5552316f9 100644 --- a/misc/insremque.c +++ b/misc/insremque.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2016 Free Software Foundation, Inc. +/* Copyright (C) 1992-2018 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 diff --git a/misc/ioctl.c b/misc/ioctl.c index a6ba0879e1..b2b3787ff0 100644 --- a/misc/ioctl.c +++ b/misc/ioctl.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 @@ -28,4 +28,5 @@ __ioctl (int fd, unsigned long int request, ...) } stub_warning (ioctl) +libc_hidden_def (__ioctl) weak_alias (__ioctl, ioctl) diff --git a/misc/lgetxattr.c b/misc/lgetxattr.c index bddbfa3468..453c36221e 100644 --- a/misc/lgetxattr.c +++ b/misc/lgetxattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2016 Free Software Foundation, Inc. +/* Copyright (C) 2002-2018 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 diff --git a/misc/libgen.h b/misc/libgen.h index 38f4d195d3..f1d7b28e40 100644 --- a/misc/libgen.h +++ b/misc/libgen.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 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 diff --git a/misc/listxattr.c b/misc/listxattr.c index b5dafa57ba..f749b6db8b 100644 --- a/misc/listxattr.c +++ b/misc/listxattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2016 Free Software Foundation, Inc. +/* Copyright (C) 2002-2018 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 diff --git a/misc/llistxattr.c b/misc/llistxattr.c index 7efcf91e85..ae76c44b93 100644 --- a/misc/llistxattr.c +++ b/misc/llistxattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2016 Free Software Foundation, Inc. +/* Copyright (C) 2002-2018 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 diff --git a/misc/lremovexattr.c b/misc/lremovexattr.c index 6c48e69f07..9e556d9a85 100644 --- a/misc/lremovexattr.c +++ b/misc/lremovexattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2016 Free Software Foundation, Inc. +/* Copyright (C) 2002-2018 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 diff --git a/misc/lsearch.c b/misc/lsearch.c index 3873638a1d..3d37c072ee 100644 --- a/misc/lsearch.c +++ b/misc/lsearch.c @@ -1,5 +1,5 @@ /* Linear search functions. - Copyright (C) 1996-2016 Free Software Foundation, Inc. + Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/misc/lsetxattr.c b/misc/lsetxattr.c index 28d10a094c..8898dd97bf 100644 --- a/misc/lsetxattr.c +++ b/misc/lsetxattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2016 Free Software Foundation, Inc. +/* Copyright (C) 2002-2018 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 diff --git a/misc/lutimes.c b/misc/lutimes.c index ed15db7108..b241c14c56 100644 --- a/misc/lutimes.c +++ b/misc/lutimes.c @@ -1,5 +1,5 @@ /* lutimes -- change access and modification times of a symlink. Stub version. - Copyright (C) 2002-2016 Free Software Foundation, Inc. + Copyright (C) 2002-2018 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 diff --git a/misc/madvise.c b/misc/madvise.c index 91674bd769..988f7b09d5 100644 --- a/misc/madvise.c +++ b/misc/madvise.c @@ -1,5 +1,5 @@ /* Advise system about intentions for a memory region. Stub version. - Copyright (C) 1994-2016 Free Software Foundation, Inc. + Copyright (C) 1994-2018 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 diff --git a/misc/makedev.c b/misc/makedev.c new file mode 100644 index 0000000000..bc5bfc577a --- /dev/null +++ b/misc/makedev.c @@ -0,0 +1,36 @@ +/* Definitions of functions to access `dev_t' values. + Copyright (C) 2003-2018 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, see + <http://www.gnu.org/licenses/>. */ + +#include <features.h> + +#undef __USE_EXTERN_INLINES +#define __SYSMACROS_NEED_IMPLEMENTATION +#include <sys/sysmacros.h> + +#define OUT_OF_LINE_IMPL_TEMPL(rtype, name, proto) \ + rtype __gnu_dev_##name proto + +__SYSMACROS_DEFINE_MAJOR(OUT_OF_LINE_IMPL_TEMPL) +weak_alias (__gnu_dev_major, gnu_dev_major) +libc_hidden_weak (gnu_dev_major) +__SYSMACROS_DEFINE_MINOR(OUT_OF_LINE_IMPL_TEMPL) +weak_alias (__gnu_dev_minor, gnu_dev_minor) +libc_hidden_weak (gnu_dev_minor) +__SYSMACROS_DEFINE_MAKEDEV(OUT_OF_LINE_IMPL_TEMPL) +weak_alias (__gnu_dev_makedev, gnu_dev_makedev) +libc_hidden_weak (gnu_dev_makedev) diff --git a/misc/mincore.c b/misc/mincore.c index f01aa983a6..984eace7ee 100644 --- a/misc/mincore.c +++ b/misc/mincore.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2016 Free Software Foundation, Inc. +/* Copyright (C) 2000-2018 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 diff --git a/misc/mkdtemp.c b/misc/mkdtemp.c index 34dde72d42..6673f36858 100644 --- a/misc/mkdtemp.c +++ b/misc/mkdtemp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1999-2016 Free Software Foundation, Inc. +/* Copyright (C) 1999-2018 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 diff --git a/misc/mkostemp.c b/misc/mkostemp.c index c990bbd75b..4ef55003bf 100644 --- a/misc/mkostemp.c +++ b/misc/mkostemp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 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 @@ -15,6 +15,7 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> diff --git a/misc/mkostemp64.c b/misc/mkostemp64.c index 0c32c908e6..6563112921 100644 --- a/misc/mkostemp64.c +++ b/misc/mkostemp64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2016 Free Software Foundation, Inc. +/* Copyright (C) 2000-2018 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 diff --git a/misc/mkostemps.c b/misc/mkostemps.c index fcc6053ef3..3f93670092 100644 --- a/misc/mkostemps.c +++ b/misc/mkostemps.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2016 Free Software Foundation, Inc. +/* Copyright (C) 2009-2018 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 @@ -16,6 +16,7 @@ <http://www.gnu.org/licenses/>. */ #include <errno.h> +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> diff --git a/misc/mkostemps64.c b/misc/mkostemps64.c index 4351978d70..279d5d9a93 100644 --- a/misc/mkostemps64.c +++ b/misc/mkostemps64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2016 Free Software Foundation, Inc. +/* Copyright (C) 2000-2018 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 diff --git a/misc/mkstemp.c b/misc/mkstemp.c index 69c6c00b79..373141353a 100644 --- a/misc/mkstemp.c +++ b/misc/mkstemp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 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 @@ -15,6 +15,7 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> diff --git a/misc/mkstemp64.c b/misc/mkstemp64.c index b09c590850..f83f207b6b 100644 --- a/misc/mkstemp64.c +++ b/misc/mkstemp64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2016 Free Software Foundation, Inc. +/* Copyright (C) 2000-2018 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 diff --git a/misc/mkstemps.c b/misc/mkstemps.c index 1f46ef57fe..8b90b095bc 100644 --- a/misc/mkstemps.c +++ b/misc/mkstemps.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2016 Free Software Foundation, Inc. +/* Copyright (C) 2009-2018 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 @@ -16,6 +16,7 @@ <http://www.gnu.org/licenses/>. */ #include <errno.h> +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> diff --git a/misc/mkstemps64.c b/misc/mkstemps64.c index 93b7adbea3..37bda50646 100644 --- a/misc/mkstemps64.c +++ b/misc/mkstemps64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2016 Free Software Foundation, Inc. +/* Copyright (C) 2000-2018 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 diff --git a/misc/mktemp.c b/misc/mktemp.c index f14e10a0d3..1417ab37f4 100644 --- a/misc/mktemp.c +++ b/misc/mktemp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 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 diff --git a/misc/mlock.c b/misc/mlock.c index acca6dba2a..49827d0d6a 100644 --- a/misc/mlock.c +++ b/misc/mlock.c @@ -1,5 +1,5 @@ /* mlock -- guarantee pages are resident in memory. Stub version. - Copyright (C) 2001-2016 Free Software Foundation, Inc. + Copyright (C) 2001-2018 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 diff --git a/misc/mlockall.c b/misc/mlockall.c index 62bc07ce46..98dbbd3814 100644 --- a/misc/mlockall.c +++ b/misc/mlockall.c @@ -1,5 +1,5 @@ /* mlockall -- lock in core all the pages in this process. Stub version. - Copyright (C) 2001-2016 Free Software Foundation, Inc. + Copyright (C) 2001-2018 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 diff --git a/misc/mmap.c b/misc/mmap.c index 6e96cbbacd..f92218ce57 100644 --- a/misc/mmap.c +++ b/misc/mmap.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1994-2016 Free Software Foundation, Inc. +/* Copyright (C) 1994-2018 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 @@ -28,8 +28,8 @@ for errors (in which case `errno' is set). A successful `mmap' call deallocates any previous mapping for the affected region. */ -__ptr_t -__mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset) +void * +__mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset) { __set_errno (ENOSYS); return MAP_FAILED; @@ -37,3 +37,4 @@ __mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset) stub_warning (mmap) weak_alias (__mmap, mmap) +libc_hidden_def (__mmap) diff --git a/misc/mmap64.c b/misc/mmap64.c index 8c0faa5e0d..e4a22742f4 100644 --- a/misc/mmap64.c +++ b/misc/mmap64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997-2016 Free Software Foundation, Inc. +/* Copyright (C) 1997-2018 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 @@ -28,8 +28,8 @@ for errors (in which case `errno' is set). A successful `mmap' call deallocates any previous mapping for the affected region. */ -__ptr_t -__mmap64 (__ptr_t addr, size_t len, int prot, int flags, int fd, +void * +__mmap64 (void *addr, size_t len, int prot, int flags, int fd, __off64_t offset) { off_t small_offset = (off_t) offset; @@ -45,3 +45,4 @@ __mmap64 (__ptr_t addr, size_t len, int prot, int flags, int fd, } weak_alias (__mmap64, mmap64) +libc_hidden_def (__mmap64) diff --git a/misc/mntent.c b/misc/mntent.c index d1828bdc0f..6718b56553 100644 --- a/misc/mntent.c +++ b/misc/mntent.c @@ -1,5 +1,5 @@ /* Utilities for reading/writing fstab, mtab, etc. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 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 diff --git a/misc/mntent.h b/misc/mntent.h index 43c083b146..9af685fae0 100644 --- a/misc/mntent.h +++ b/misc/mntent.h @@ -1,5 +1,5 @@ /* Utilities for reading/writing fstab, mtab, etc. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 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,10 +20,8 @@ #define _MNTENT_H 1 #include <features.h> -#define __need_FILE -#include <stdio.h> #include <paths.h> - +#include <bits/types/FILE.h> /* File listing canonical interesting mount points. */ #define MNTTAB _PATH_MNTTAB /* Deprecated alias. */ diff --git a/misc/mntent_r.c b/misc/mntent_r.c index 4ca42e6dbc..7a82658654 100644 --- a/misc/mntent_r.c +++ b/misc/mntent_r.c @@ -1,5 +1,5 @@ /* Utilities for reading/writing fstab, mtab, etc. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 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 @@ -293,4 +293,5 @@ __hasmntopt (const struct mntent *mnt, const char *opt) return NULL; } +libc_hidden_def (__hasmntopt) weak_alias (__hasmntopt, hasmntopt) diff --git a/misc/mprotect.c b/misc/mprotect.c index 34251b0694..4a08f2f67b 100644 --- a/misc/mprotect.c +++ b/misc/mprotect.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1994-2016 Free Software Foundation, Inc. +/* Copyright (C) 1994-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -24,7 +24,7 @@ (and sets errno). */ int -__mprotect (__ptr_t addr, size_t len, int prot) +__mprotect (void *addr, size_t len, int prot) { __set_errno (ENOSYS); return -1; diff --git a/misc/msync.c b/misc/msync.c index 6db8ee8df5..9785068444 100644 --- a/misc/msync.c +++ b/misc/msync.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1994-2016 Free Software Foundation, Inc. +/* Copyright (C) 1994-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -24,7 +24,7 @@ unpredictable before this is done. */ int -msync (__ptr_t addr, size_t len, int flags) +msync (void *addr, size_t len, int flags) { __set_errno (ENOSYS); return -1; diff --git a/misc/munlock.c b/misc/munlock.c index f6d1e160fd..710aedf4ad 100644 --- a/misc/munlock.c +++ b/misc/munlock.c @@ -1,5 +1,5 @@ /* munlock -- undo the effects of prior mlock calls. Stub version. - Copyright (C) 2001-2016 Free Software Foundation, Inc. + Copyright (C) 2001-2018 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 diff --git a/misc/munlockall.c b/misc/munlockall.c index 66ed33292d..a948d07d42 100644 --- a/misc/munlockall.c +++ b/misc/munlockall.c @@ -1,5 +1,5 @@ /* munlockall -- undo the effects of all prior mlock calls. Stub version. - Copyright (C) 2001-2016 Free Software Foundation, Inc. + Copyright (C) 2001-2018 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 diff --git a/misc/munmap.c b/misc/munmap.c index d6d2d3ac10..5237e4ed69 100644 --- a/misc/munmap.c +++ b/misc/munmap.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1994-2016 Free Software Foundation, Inc. +/* Copyright (C) 1994-2018 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,7 +23,7 @@ bytes. Returns 0 if successful, -1 for errors (and sets errno). */ int -__munmap (__ptr_t addr, size_t len) +__munmap (void *addr, size_t len) { __set_errno (ENOSYS); return -1; diff --git a/misc/preadv.c b/misc/preadv.c index 7ecebdbedf..da6a325db0 100644 --- a/misc/preadv.c +++ b/misc/preadv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2016 Free Software Foundation, Inc. +/* Copyright (C) 2009-2018 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 diff --git a/misc/preadv2.c b/misc/preadv2.c new file mode 100644 index 0000000000..63fd8942c1 --- /dev/null +++ b/misc/preadv2.c @@ -0,0 +1,31 @@ +/* Default implementation of preadv2. + Copyright (C) 2017-2018 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, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <sys/uio.h> + +/* Same as preadv but with an additional flags argument. */ +ssize_t +preadv2 (int fd, const struct iovec *vector, int count, off_t offset, + int flags) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (preadv2) diff --git a/misc/preadv64.c b/misc/preadv64.c index 9326c92244..810e364433 100644 --- a/misc/preadv64.c +++ b/misc/preadv64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2016 Free Software Foundation, Inc. +/* Copyright (C) 2009-2018 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 diff --git a/misc/preadv64v2.c b/misc/preadv64v2.c new file mode 100644 index 0000000000..728ebc35da --- /dev/null +++ b/misc/preadv64v2.c @@ -0,0 +1,31 @@ +/* Default implementation of preadv2 (LFS version). + Copyright (C) 2017-2018 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, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <sys/uio.h> + +/* Same as preadv64 but with an addional flag argument. */ +ssize_t +preadv64v2 (int fd, const struct iovec *vector, int count, off64_t offset, + int flags) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (preadv64v2) diff --git a/misc/pselect.c b/misc/pselect.c index bfced60473..2c29230596 100644 --- a/misc/pselect.c +++ b/misc/pselect.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/misc/ptrace.c b/misc/ptrace.c index 1a97062e27..244f130610 100644 --- a/misc/ptrace.c +++ b/misc/ptrace.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -19,7 +19,6 @@ #include <sys/ptrace.h> #include <sys/types.h> #include <stdarg.h> -#include <libc-internal.h> /* Perform process tracing functions. REQUEST is one of the values in <sys/ptrace.h>, and determines the action to be taken. diff --git a/misc/pwritev.c b/misc/pwritev.c index 405cad3bdd..7a9e7c8dbf 100644 --- a/misc/pwritev.c +++ b/misc/pwritev.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2016 Free Software Foundation, Inc. +/* Copyright (C) 2009-2018 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 diff --git a/misc/pwritev2.c b/misc/pwritev2.c new file mode 100644 index 0000000000..69f11d8922 --- /dev/null +++ b/misc/pwritev2.c @@ -0,0 +1,31 @@ +/* Default implementation of pwritev2. + Copyright (C) 2017-2018 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, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <sys/uio.h> + +/* Same as pwritev but with an additional flags argument. */ +ssize_t +pwritev2 (int fd, const struct iovec *vector, int count, off_t offset, + int flags) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (pwritev2) diff --git a/misc/pwritev64.c b/misc/pwritev64.c index ce88f0e62d..348e10c3d0 100644 --- a/misc/pwritev64.c +++ b/misc/pwritev64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2016 Free Software Foundation, Inc. +/* Copyright (C) 2009-2018 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 diff --git a/misc/pwritev64v2.c b/misc/pwritev64v2.c new file mode 100644 index 0000000000..6230e72222 --- /dev/null +++ b/misc/pwritev64v2.c @@ -0,0 +1,31 @@ +/* Default implementation of pwritev2 (LFS version). + Copyright (C) 2017-2018 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, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <sys/uio.h> + +/* Same as preadv64 but with an addional flag argument. */ +ssize_t +pwritev64v2 (int fd, const struct iovec *vector, int count, off64_t offset, + int flags) +{ + __set_errno (ENOSYS); + return -1; +} + +stub_warning (pwritev64v2) diff --git a/misc/qefgcvt.c b/misc/qefgcvt.c index 6e082c28be..88033a5ac7 100644 --- a/misc/qefgcvt.c +++ b/misc/qefgcvt.c @@ -1,5 +1,5 @@ /* Compatibility functions for floating point formatting, long double version. - Copyright (C) 1996-2016 Free Software Foundation, Inc. + Copyright (C) 1996-2018 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 diff --git a/misc/qefgcvt_r.c b/misc/qefgcvt_r.c index 0c0bc0d1f2..341d06a58b 100644 --- a/misc/qefgcvt_r.c +++ b/misc/qefgcvt_r.c @@ -1,6 +1,6 @@ /* Compatibility functions for floating point formatting, reentrant, long double versions. - Copyright (C) 1996-2016 Free Software Foundation, Inc. + Copyright (C) 1996-2018 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 diff --git a/misc/readv.c b/misc/readv.c index c0bdb0ebf0..17d967a496 100644 --- a/misc/readv.c +++ b/misc/readv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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,7 @@ __readv (int fd, const struct iovec *vector, int count) __set_errno (ENOSYS); return -1; } +libc_hidden_def (__readv) weak_alias (__readv, readv) stub_warning (readv) diff --git a/misc/reboot.c b/misc/reboot.c index 2391309876..640c7a32f1 100644 --- a/misc/reboot.c +++ b/misc/reboot.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2016 Free Software Foundation, Inc. +/* Copyright (C) 1992-2018 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,7 +18,7 @@ #include <errno.h> #include <unistd.h> #include <sys/reboot.h> -#include <libc-internal.h> +#include <libc-diag.h> /* Reboot the system. */ int diff --git a/misc/regexp.c b/misc/regexp.c index 3b3668272f..0996f1d939 100644 --- a/misc/regexp.c +++ b/misc/regexp.c @@ -1,5 +1,5 @@ /* Compatibility symbols for the obsolete <regexp.h> interface. - Copyright (C) 1996-2016 Free Software Foundation, Inc. + Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -29,14 +29,15 @@ #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23) -/* Define the variables used for the interface. */ -char *loc1; -char *loc2; +/* Define the variables used for the interface. Avoid .symver on common + symbol, which just creates a new common symbol, not an alias. */ +char *loc1 __attribute__ ((nocommon)); +char *loc2 __attribute__ ((nocommon)); compat_symbol (libc, loc1, loc1, GLIBC_2_0); compat_symbol (libc, loc2, loc2, GLIBC_2_0); /* Although we do not support the use we define this variable as well. */ -char *locs; +char *locs __attribute__ ((nocommon)); compat_symbol (libc, locs, locs, GLIBC_2_0); diff --git a/misc/regexp.h b/misc/regexp.h index 6d3bc3075c..b15f43b909 100644 --- a/misc/regexp.h +++ b/misc/regexp.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/misc/remap_file_pages.c b/misc/remap_file_pages.c index 7c2352ebb7..36e942fd96 100644 --- a/misc/remap_file_pages.c +++ b/misc/remap_file_pages.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003-2016 Free Software Foundation, Inc. +/* Copyright (C) 2003-2018 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 diff --git a/misc/removexattr.c b/misc/removexattr.c index 3d18a92079..56d29fce9e 100644 --- a/misc/removexattr.c +++ b/misc/removexattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2016 Free Software Foundation, Inc. +/* Copyright (C) 2002-2018 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 diff --git a/misc/revoke.c b/misc/revoke.c index 2c395e9639..28269a05d0 100644 --- a/misc/revoke.c +++ b/misc/revoke.c @@ -1,5 +1,5 @@ /* Revoke the access of all descriptors currently open on a file. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 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,9 +20,11 @@ #include <errno.h> int -revoke (const char *file) +__revoke (const char *file) { __set_errno (ENOSYS); return -1; } + +weak_alias (__revoke, revoke) stub_warning (revoke) diff --git a/misc/sbrk.c b/misc/sbrk.c index 4948dbfce6..e0747ace8d 100644 --- a/misc/sbrk.c +++ b/misc/sbrk.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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,14 +18,12 @@ #include <errno.h> #include <stdint.h> #include <unistd.h> +#include <libc-internal.h> /* Defined in brk.c. */ extern void *__curbrk; extern int __brk (void *addr); -/* Defined in init-first.c. */ -extern int __libc_multiple_libcs attribute_hidden; - /* Extend the process's data space by INCREMENT. If INCREMENT is negative, shrink data space by - INCREMENT. Return start of new space allocated, or -1 for errors. */ diff --git a/misc/search.h b/misc/search.h index bbf4b1d325..4cd1bff09f 100644 --- a/misc/search.h +++ b/misc/search.h @@ -1,5 +1,5 @@ /* Declarations for System V style searching functions. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 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 diff --git a/misc/select.c b/misc/select.c index 320afb848f..58c4688876 100644 --- a/misc/select.c +++ b/misc/select.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/setdomain.c b/misc/setdomain.c index e4053c07ec..e2990939a1 100644 --- a/misc/setdomain.c +++ b/misc/setdomain.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1994-2016 Free Software Foundation, Inc. +/* Copyright (C) 1994-2018 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 diff --git a/misc/setegid.c b/misc/setegid.c index 81fe42c9f9..5c70e4545d 100644 --- a/misc/setegid.c +++ b/misc/setegid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2016 Free Software Foundation, Inc. +/* Copyright (C) 1992-2018 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 diff --git a/misc/seteuid.c b/misc/seteuid.c index e6c53b6882..4c8bf10945 100644 --- a/misc/seteuid.c +++ b/misc/seteuid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2016 Free Software Foundation, Inc. +/* Copyright (C) 1992-2018 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 diff --git a/misc/sethostid.c b/misc/sethostid.c index 0010012e94..5249ed123f 100644 --- a/misc/sethostid.c +++ b/misc/sethostid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/sethostname.c b/misc/sethostname.c index 6fb15b4248..98608e519a 100644 --- a/misc/sethostname.c +++ b/misc/sethostname.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/setregid.c b/misc/setregid.c index 2f4f51a186..b4400fcfd9 100644 --- a/misc/setregid.c +++ b/misc/setregid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/setreuid.c b/misc/setreuid.c index d7e35cf9c6..696c54760c 100644 --- a/misc/setreuid.c +++ b/misc/setreuid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/setxattr.c b/misc/setxattr.c index 09fe443dd9..0877a0e299 100644 --- a/misc/setxattr.c +++ b/misc/setxattr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2016 Free Software Foundation, Inc. +/* Copyright (C) 2002-2018 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 diff --git a/misc/sgtty.h b/misc/sgtty.h index 121cd26638..baa7005446 100644 --- a/misc/sgtty.h +++ b/misc/sgtty.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/sstk.c b/misc/sstk.c index d7527be7e5..4caa01f7c2 100644 --- a/misc/sstk.c +++ b/misc/sstk.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/stty.c b/misc/stty.c index 6d2687d1f3..3c7d0d042e 100644 --- a/misc/stty.c +++ b/misc/stty.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/swapoff.c b/misc/swapoff.c index 448033381f..c0853febdc 100644 --- a/misc/swapoff.c +++ b/misc/swapoff.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2016 Free Software Foundation, Inc. +/* Copyright (C) 1996-2018 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 diff --git a/misc/swapon.c b/misc/swapon.c index d05bdc53fb..6224fe3aa9 100644 --- a/misc/swapon.c +++ b/misc/swapon.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/sync.c b/misc/sync.c index 2bb75b6551..f8c51e780d 100644 --- a/misc/sync.c +++ b/misc/sync.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/syncfs.c b/misc/syncfs.c index f5b64cbaa7..5195e56b4e 100644 --- a/misc/syncfs.c +++ b/misc/syncfs.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2011-2016 Free Software Foundation, Inc. +/* Copyright (C) 2011-2018 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 diff --git a/misc/sys/auxv.h b/misc/sys/auxv.h index 73d48916d7..0d75a1d1cc 100644 --- a/misc/sys/auxv.h +++ b/misc/sys/auxv.h @@ -1,5 +1,5 @@ /* Access to the auxiliary vector. - Copyright (C) 2012-2016 Free Software Foundation, Inc. + Copyright (C) 2012-2018 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 diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h index 7fd41549db..3f6fe3cc85 100644 --- a/misc/sys/cdefs.h +++ b/misc/sys/cdefs.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2016 Free Software Foundation, Inc. +/* Copyright (C) 1992-2018 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 @@ -55,21 +55,29 @@ # define __THROW __attribute__ ((__nothrow__ __LEAF)) # define __THROWNL __attribute__ ((__nothrow__)) # define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct +# define __NTHNL(fct) __attribute__ ((__nothrow__)) fct # else # if defined __cplusplus && __GNUC_PREREQ (2,8) # define __THROW throw () # define __THROWNL throw () # define __NTH(fct) __LEAF_ATTR fct throw () +# define __NTHNL(fct) fct throw () # else # define __THROW # define __THROWNL # define __NTH(fct) fct +# define __NTHNL(fct) fct # endif # endif #else /* Not GCC. */ -# define __inline /* No inline functions. */ +# if (defined __cplusplus \ + || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)) +# define __inline inline +# else +# define __inline /* No inline functions. */ +# endif # define __THROW # define __THROWNL @@ -77,6 +85,15 @@ #endif /* GCC. */ +/* Compilers that are not clang may object to + #if defined __clang__ && __has_extension(...) + even though they do not need to evaluate the right-hand side of the &&. */ +#if defined __clang__ && defined __has_extension +# define __glibc_clang_has_extension(ext) __has_extension (ext) +#else +# define __glibc_clang_has_extension(ext) 0 +#endif + /* These two macros are not used in glibc anymore. They are kept here only because some other projects expect the macros to be defined. */ #define __P(args) args @@ -90,7 +107,6 @@ /* This is not a typedef so `const __ptr_t' does the right thing. */ #define __ptr_t void * -#define __long_double_t long double /* C++ needs to know that types and declarations are C, not C++. */ @@ -103,31 +119,6 @@ #endif -/* The standard library needs the functions from the ISO C90 standard - in the std namespace. At the same time we want to be safe for - future changes and we include the ISO C99 code in the non-standard - namespace __c99. The C++ wrapper header take case of adding the - definitions to the global namespace. */ -#if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES -# define __BEGIN_NAMESPACE_STD namespace std { -# define __END_NAMESPACE_STD } -# define __USING_NAMESPACE_STD(name) using std::name; -# define __BEGIN_NAMESPACE_C99 namespace __c99 { -# define __END_NAMESPACE_C99 } -# define __USING_NAMESPACE_C99(name) using __c99::name; -#else -/* For compatibility we do not add the declarations into any - namespace. They will end up in the global namespace which is what - old code expects. */ -# define __BEGIN_NAMESPACE_STD -# define __END_NAMESPACE_STD -# define __USING_NAMESPACE_STD(name) -# define __BEGIN_NAMESPACE_C99 -# define __END_NAMESPACE_C99 -# define __USING_NAMESPACE_C99(name) -#endif - - /* Fortify support. */ #define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) #define __bos0(ptr) __builtin_object_size (ptr, 0) @@ -144,21 +135,27 @@ # define __errordecl(name, msg) extern void name (void) #endif -/* Support for flexible arrays. */ -#if __GNUC_PREREQ (2,97) -/* GCC 2.97 supports C99 flexible array members. */ +/* Support for flexible arrays. + Headers that should use flexible arrays only if they're "real" + (e.g. only if they won't affect sizeof()) should test + #if __glibc_c99_flexarr_available. */ +#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L +# define __flexarr [] +# define __glibc_c99_flexarr_available 1 +#elif __GNUC_PREREQ (2,97) +/* GCC 2.97 supports C99 flexible array members as an extension, + even when in C89 mode or compiling C++ (any version). */ # define __flexarr [] +# define __glibc_c99_flexarr_available 1 +#elif defined __GNUC__ +/* Pre-2.97 GCC did not support C99 flexible arrays but did have + an equivalent extension with slightly different notation. */ +# define __flexarr [0] +# define __glibc_c99_flexarr_available 1 #else -# ifdef __GNUC__ -# define __flexarr [0] -# else -# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L -# define __flexarr [] -# else /* Some other non-C99 compiler. Approximate with [1]. */ -# define __flexarr [1] -# endif -# endif +# define __flexarr [1] +# define __glibc_c99_flexarr_available 0 #endif @@ -249,13 +246,24 @@ # define __attribute_noinline__ /* Ignore */ #endif -/* gcc allows marking deprecated functions. */ +/* Since version 3.2, gcc allows marking deprecated functions. */ #if __GNUC_PREREQ (3,2) # define __attribute_deprecated__ __attribute__ ((__deprecated__)) #else # define __attribute_deprecated__ /* Ignore */ #endif +/* Since version 4.5, gcc also allows one to specify the message printed + when a deprecated function is used. clang claims to be gcc 4.2, but + may also support this feature. */ +#if __GNUC_PREREQ (4,5) || \ + __glibc_clang_has_extension (__attribute_deprecated_with_message__) +# define __attribute_deprecated_msg__(msg) \ + __attribute__ ((__deprecated__ (msg))) +#else +# define __attribute_deprecated_msg__(msg) __attribute_deprecated__ +#endif + /* At some point during the gcc 2.8 development the `format_arg' attribute for functions was introduced. We don't want to use it unconditionally (although this would be possible) since it generates warnings. @@ -304,8 +312,13 @@ /* Forces a function to be always inlined. */ #if __GNUC_PREREQ (3,2) +/* The Linux kernel defines __always_inline in stddef.h (283d7573), and + it conflicts with this definition. Therefore undefine it first to + allow either header to be included first. */ +# undef __always_inline # define __always_inline __inline __attribute__ ((__always_inline__)) #else +# undef __always_inline # define __always_inline __inline #endif @@ -360,7 +373,11 @@ /* __restrict is known in EGCS 1.2 and above. */ #if !__GNUC_PREREQ (2,92) -# define __restrict /* Ignore */ +# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L +# define __restrict restrict +# else +# define __restrict /* Ignore */ +# endif #endif /* ISO C99 also allows to declare arrays as non-overlapping. The syntax is @@ -389,6 +406,12 @@ # define __glibc_likely(cond) (cond) #endif +#ifdef __has_attribute +# define __glibc_has_attribute(attr) __has_attribute (attr) +#else +# define __glibc_has_attribute(attr) 0 +#endif + #if (!defined _Noreturn \ && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \ && !__GNUC_PREREQ (4,7)) @@ -399,6 +422,15 @@ # endif #endif +#if __GNUC_PREREQ (8, 0) +/* Describes a char array whose address can safely be passed as the first + argument to strncpy and strncat, as the char array is not necessarily + a NUL-terminated string. */ +# define __attribute_nonstring__ __attribute__ ((__nonstring__)) +#else +# define __attribute_nonstring__ +#endif + #if (!defined _Static_assert && !defined __cplusplus \ && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \ && (!__GNUC_PREREQ (4, 6) || defined __STRICT_ANSI__)) @@ -408,6 +440,7 @@ #endif #include <bits/wordsize.h> +#include <bits/long-double.h> #if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH # define __LDBL_COMPAT 1 @@ -441,4 +474,34 @@ # endif #endif +/* __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is + intended for use in preprocessor macros. + + Note: MESSAGE must be a _single_ string; concatenation of string + literals is not supported. */ +#if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5) +# define __glibc_macro_warning1(message) _Pragma (#message) +# define __glibc_macro_warning(message) \ + __glibc_macro_warning1 (GCC warning message) +#else +# define __glibc_macro_warning(msg) +#endif + +/* Generic selection (ISO C11) is a C-only feature, available in GCC + since version 4.9. Previous versions do not provide generic + selection, even though they might set __STDC_VERSION__ to 201112L, + when in -std=c11 mode. Thus, we must check for !defined __GNUC__ + when testing __STDC_VERSION__ for generic selection support. + On the other hand, Clang also defines __GNUC__, so a clang-specific + check is required to enable the use of generic selection. */ +#if !defined __cplusplus \ + && (__GNUC_PREREQ (4, 9) \ + || __glibc_clang_has_extension (c_generic_selections) \ + || (!defined __GNUC__ && defined __STDC_VERSION__ \ + && __STDC_VERSION__ >= 201112L)) +# define __HAVE_GENERIC_SELECTION 1 +#else +# define __HAVE_GENERIC_SELECTION 0 +#endif + #endif /* sys/cdefs.h */ diff --git a/misc/sys/dir.h b/misc/sys/dir.h index 73b04bf4c6..c4dbfcce71 100644 --- a/misc/sys/dir.h +++ b/misc/sys/dir.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/sys/file.h b/misc/sys/file.h index cd2a6410fc..e6494fa333 100644 --- a/misc/sys/file.h +++ b/misc/sys/file.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/sys/ioctl.h b/misc/sys/ioctl.h index 4bc5a1a976..49f7ff1294 100644 --- a/misc/sys/ioctl.h +++ b/misc/sys/ioctl.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/sys/mman.h b/misc/sys/mman.h index a7879eafd3..12e1b069d6 100644 --- a/misc/sys/mman.h +++ b/misc/sys/mman.h @@ -1,5 +1,5 @@ /* Definitions for BSD-style memory management. - Copyright (C) 1994-2016 Free Software Foundation, Inc. + Copyright (C) 1994-2018 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 diff --git a/misc/sys/param.h b/misc/sys/param.h index 7e0e331450..359bc96056 100644 --- a/misc/sys/param.h +++ b/misc/sys/param.h @@ -1,5 +1,5 @@ /* Compatibility header for old-style Unix parameters and limits. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 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 diff --git a/misc/sys/select.h b/misc/sys/select.h index b852dac2d8..6dd0c83227 100644 --- a/misc/sys/select.h +++ b/misc/sys/select.h @@ -1,5 +1,5 @@ /* `fd_set' type and related macros, and `select'/`pselect' declarations. - Copyright (C) 1996-2016 Free Software Foundation, Inc. + Copyright (C) 1996-2018 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,20 +29,15 @@ /* Get __FD_* definitions. */ #include <bits/select.h> -/* Get __sigset_t. */ -#include <bits/sigset.h> - -#ifndef __sigset_t_defined -# define __sigset_t_defined -typedef __sigset_t sigset_t; -#endif +/* Get sigset_t. */ +#include <bits/types/sigset_t.h> /* Get definition of timer specification structures. */ -#define __need_time_t -#define __need_timespec -#include <time.h> -#define __need_timeval -#include <bits/time.h> +#include <bits/types/time_t.h> +#include <bits/types/struct_timeval.h> +#ifdef __USE_XOPEN2K +# include <bits/types/struct_timespec.h> +#endif #ifndef __suseconds_t_defined typedef __suseconds_t suseconds_t; diff --git a/misc/sys/sysmacros.h b/misc/sys/sysmacros.h new file mode 100644 index 0000000000..699e03865f --- /dev/null +++ b/misc/sys/sysmacros.h @@ -0,0 +1,64 @@ +/* Definitions of macros to access `dev_t' values. + Copyright (C) 1996-2018 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, see + <http://www.gnu.org/licenses/>. */ + +#ifndef _SYS_SYSMACROS_H +#define _SYS_SYSMACROS_H 1 + +#include <features.h> +#include <bits/types.h> +#include <bits/sysmacros.h> + +#define __SYSMACROS_DECL_TEMPL(rtype, name, proto) \ + extern rtype gnu_dev_##name proto __THROW __attribute_const__; + +#define __SYSMACROS_IMPL_TEMPL(rtype, name, proto) \ + __extension__ __extern_inline __attribute_const__ rtype \ + __NTH (gnu_dev_##name proto) + +__BEGIN_DECLS + +__SYSMACROS_DECLARE_MAJOR (__SYSMACROS_DECL_TEMPL) +__SYSMACROS_DECLARE_MINOR (__SYSMACROS_DECL_TEMPL) +__SYSMACROS_DECLARE_MAKEDEV (__SYSMACROS_DECL_TEMPL) + +#ifdef __USE_EXTERN_INLINES + +__SYSMACROS_DEFINE_MAJOR (__SYSMACROS_IMPL_TEMPL) +__SYSMACROS_DEFINE_MINOR (__SYSMACROS_IMPL_TEMPL) +__SYSMACROS_DEFINE_MAKEDEV (__SYSMACROS_IMPL_TEMPL) + +#endif + +__END_DECLS + +#ifndef __SYSMACROS_NEED_IMPLEMENTATION +# undef __SYSMACROS_DECL_TEMPL +# undef __SYSMACROS_IMPL_TEMPL +# undef __SYSMACROS_DECLARE_MAJOR +# undef __SYSMACROS_DECLARE_MINOR +# undef __SYSMACROS_DECLARE_MAKEDEV +# undef __SYSMACROS_DEFINE_MAJOR +# undef __SYSMACROS_DEFINE_MINOR +# undef __SYSMACROS_DEFINE_MAKEDEV +#endif + +#define major(dev) gnu_dev_major (dev) +#define minor(dev) gnu_dev_minor (dev) +#define makedev(maj, min) gnu_dev_makedev (maj, min) + +#endif /* sys/sysmacros.h */ diff --git a/misc/sys/uio.h b/misc/sys/uio.h index 2c98077c57..ff586c7b16 100644 --- a/misc/sys/uio.h +++ b/misc/sys/uio.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -19,15 +19,17 @@ #define _SYS_UIO_H 1 #include <features.h> - #include <sys/types.h> +#include <bits/types/struct_iovec.h> +#include <bits/uio_lim.h> +#ifdef __IOV_MAX +# define UIO_MAXIOV __IOV_MAX +#else +# undef UIO_MAXIOV +#endif __BEGIN_DECLS -/* This file defines `struct iovec'. */ -#include <bits/uio.h> - - /* Read data from file descriptor FD, and put the result in the buffers described by IOVEC, which is a vector of COUNT 'struct iovec's. The buffers are filled in the order specified. @@ -76,6 +78,7 @@ extern ssize_t preadv (int __fd, const struct iovec *__iovec, int __count, __THROW. */ extern ssize_t pwritev (int __fd, const struct iovec *__iovec, int __count, __off_t __offset) __wur; + # else # ifdef __REDIRECT extern ssize_t __REDIRECT (preadv, (int __fd, const struct iovec *__iovec, @@ -117,6 +120,52 @@ extern ssize_t pwritev64 (int __fd, const struct iovec *__iovec, int __count, # endif #endif /* Use misc. */ + +#ifdef __USE_GNU +# ifndef __USE_FILE_OFFSET64 +/* Same as preadv but with an additional flag argumenti defined at uio.h. */ +extern ssize_t preadv2 (int __fp, const struct iovec *__iovec, int __count, + __off_t __offset, int ___flags) __wur; + +/* Same as preadv but with an additional flag argument defined at uio.h. */ +extern ssize_t pwritev2 (int __fd, const struct iovec *__iodev, int __count, + __off_t __offset, int __flags) __wur; + +# else +# ifdef __REDIRECT +extern ssize_t __REDIRECT (pwritev2, (int __fd, const struct iovec *__iovec, + int __count, __off64_t __offset, + int __flags), + pwritev64v2) __wur; +extern ssize_t __REDIRECT (preadv2, (int __fd, const struct iovec *__iovec, + int __count, __off64_t __offset, + int __flags), + preadv64v2) __wur; +# else +# define preadv2 preadv64v2 +# define pwritev2 pwritev64v2 +# endif +# endif + +# ifdef __USE_LARGEFILE64 +/* Same as preadv but with an additional flag argumenti defined at uio.h. */ +extern ssize_t preadv64v2 (int __fp, const struct iovec *__iovec, + int __count, __off64_t __offset, + int ___flags) __wur; + +/* Same as preadv but with an additional flag argument defined at uio.h. */ +extern ssize_t pwritev64v2 (int __fd, const struct iovec *__iodev, + int __count, __off64_t __offset, + int __flags) __wur; +# endif +#endif /* Use GNU. */ + __END_DECLS +/* Some operating systems provide system-specific extensions to this + header. */ +#ifdef __USE_GNU +# include <bits/uio-ext.h> +#endif + #endif /* sys/uio.h */ diff --git a/misc/sys/xattr.h b/misc/sys/xattr.h index 0bdce5721f..5278cc2727 100644 --- a/misc/sys/xattr.h +++ b/misc/sys/xattr.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002-2016 Free Software Foundation, Inc. +/* Copyright (C) 2002-2018 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 diff --git a/misc/syscall.c b/misc/syscall.c index 35eec2ab12..f15b64c570 100644 --- a/misc/syscall.c +++ b/misc/syscall.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993-2016 Free Software Foundation, Inc. +/* Copyright (C) 1993-2018 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 diff --git a/misc/syslog.c b/misc/syslog.c index 6922ad685c..644dbe80ec 100644 --- a/misc/syslog.c +++ b/misc/syslog.c @@ -72,7 +72,7 @@ extern char *__progname; /* Program name, from crt0. */ /* Define the lock. */ __libc_lock_define_initialized (static, syslog_lock) -static void openlog_internal(const char *, int, int) internal_function; +static void openlog_internal(const char *, int, int); static void closelog_internal(void); #ifndef NO_SIGPIPE static void sigpipe_handler (int); @@ -207,8 +207,8 @@ __vsyslog_chk(int pri, int flag, const char *fmt, va_list ap) fprintf (f, "[%d]", (int) __getpid ()); if (LogTag != NULL) { - putc_unlocked (':', f); - putc_unlocked (' ', f); + __putc_unlocked (':', f); + __putc_unlocked (' ', f); } /* Restore errno for %m format. */ @@ -330,7 +330,6 @@ static struct sockaddr_un SyslogAddr; /* AF_UNIX address of local logger */ static void -internal_function openlog_internal(const char *ident, int logstat, int logfac) { if (ident != NULL) diff --git a/misc/truncate.c b/misc/truncate.c index c79bec04af..52a2682050 100644 --- a/misc/truncate.c +++ b/misc/truncate.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/truncate64.c b/misc/truncate64.c index c1e032aa3c..fd50da2531 100644 --- a/misc/truncate64.c +++ b/misc/truncate64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997-2016 Free Software Foundation, Inc. +/* Copyright (C) 1997-2018 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 diff --git a/misc/tsearch.c b/misc/tsearch.c index ffb89ec0f8..caca1b496c 100644 --- a/misc/tsearch.c +++ b/misc/tsearch.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2016 Free Software Foundation, Inc. +/* Copyright (C) 1995-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Bernd Schmidt <crux@Pool.Informatik.RWTH-Aachen.DE>, 1997. @@ -83,19 +83,70 @@ In this case, A has been rotated left. This preserves the ordering of the binary tree. */ +#include <assert.h> +#include <stdalign.h> +#include <stddef.h> #include <stdlib.h> #include <string.h> #include <search.h> +/* Assume malloc returns naturally aligned (alignof (max_align_t)) + pointers so we can use the low bits to store some extra info. This + works for the left/right node pointers since they are not user + visible and always allocated by malloc. The user provides the key + pointer and so that can point anywhere and doesn't have to be + aligned. */ +#define USE_MALLOC_LOW_BIT 1 + +#ifndef USE_MALLOC_LOW_BIT +typedef struct node_t +{ + /* Callers expect this to be the first element in the structure - do not + move! */ + const void *key; + struct node_t *left_node; + struct node_t *right_node; + unsigned int is_red:1; +} *node; + +#define RED(N) (N)->is_red +#define SETRED(N) (N)->is_red = 1 +#define SETBLACK(N) (N)->is_red = 0 +#define SETNODEPTR(NP,P) (*NP) = (P) +#define LEFT(N) (N)->left_node +#define LEFTPTR(N) (&(N)->left_node) +#define SETLEFT(N,L) (N)->left_node = (L) +#define RIGHT(N) (N)->right_node +#define RIGHTPTR(N) (&(N)->right_node) +#define SETRIGHT(N,R) (N)->right_node = (R) +#define DEREFNODEPTR(NP) (*(NP)) + +#else /* USE_MALLOC_LOW_BIT */ + typedef struct node_t { /* Callers expect this to be the first element in the structure - do not move! */ const void *key; - struct node_t *left; - struct node_t *right; - unsigned int red:1; + uintptr_t left_node; /* Includes whether the node is red in low-bit. */ + uintptr_t right_node; } *node; + +#define RED(N) (node)((N)->left_node & ((uintptr_t) 0x1)) +#define SETRED(N) (N)->left_node |= ((uintptr_t) 0x1) +#define SETBLACK(N) (N)->left_node &= ~((uintptr_t) 0x1) +#define SETNODEPTR(NP,P) (*NP) = (node)((((uintptr_t)(*NP)) \ + & (uintptr_t) 0x1) | (uintptr_t)(P)) +#define LEFT(N) (node)((N)->left_node & ~((uintptr_t) 0x1)) +#define LEFTPTR(N) (node *)(&(N)->left_node) +#define SETLEFT(N,L) (N)->left_node = (((N)->left_node & (uintptr_t) 0x1) \ + | (uintptr_t)(L)) +#define RIGHT(N) (node)((N)->right_node) +#define RIGHTPTR(N) (node *)(&(N)->right_node) +#define SETRIGHT(N,R) (N)->right_node = (uintptr_t)(R) +#define DEREFNODEPTR(NP) (node)((uintptr_t)(*(NP)) & ~((uintptr_t) 0x1)) + +#endif /* USE_MALLOC_LOW_BIT */ typedef const struct node_t *const_node; #undef DEBUGGING @@ -104,8 +155,6 @@ typedef const struct node_t *const_node; /* Routines to check tree invariants. */ -#include <assert.h> - #define CHECK_TREE(a) check_tree(a) static void @@ -117,12 +166,14 @@ check_tree_recurse (node p, int d_sofar, int d_total) return; } - check_tree_recurse (p->left, d_sofar + (p->left && !p->left->red), d_total); - check_tree_recurse (p->right, d_sofar + (p->right && !p->right->red), d_total); - if (p->left) - assert (!(p->left->red && p->red)); - if (p->right) - assert (!(p->right->red && p->red)); + check_tree_recurse (LEFT(p), d_sofar + (LEFT(p) && !RED(LEFT(p))), + d_total); + check_tree_recurse (RIGHT(p), d_sofar + (RIGHT(p) && !RED(RIGHT(p))), + d_total); + if (LEFT(p)) + assert (!(RED(LEFT(p)) && RED(p))); + if (RIGHT(p)) + assert (!(RED(RIGHT(p)) && RED(p))); } static void @@ -132,13 +183,12 @@ check_tree (node root) node p; if (root == NULL) return; - root->red = 0; - for(p = root->left; p; p = p->left) - cnt += !p->red; + SETBLACK(root); + for(p = LEFT(root); p; p = LEFT(p)) + cnt += !RED(p); check_tree_recurse (root, 0, cnt); } - #else #define CHECK_TREE(a) @@ -155,28 +205,31 @@ static void maybe_split_for_insert (node *rootp, node *parentp, node *gparentp, int p_r, int gp_r, int mode) { - node root = *rootp; + node root = DEREFNODEPTR(rootp); node *rp, *lp; - rp = &(*rootp)->right; - lp = &(*rootp)->left; + node rpn, lpn; + rp = RIGHTPTR(root); + rpn = RIGHT(root); + lp = LEFTPTR(root); + lpn = LEFT(root); /* See if we have to split this node (both successors red). */ if (mode == 1 - || ((*rp) != NULL && (*lp) != NULL && (*rp)->red && (*lp)->red)) + || ((rpn) != NULL && (lpn) != NULL && RED(rpn) && RED(lpn))) { /* This node becomes red, its successors black. */ - root->red = 1; - if (*rp) - (*rp)->red = 0; - if (*lp) - (*lp)->red = 0; + SETRED(root); + if (rpn) + SETBLACK(rpn); + if (lpn) + SETBLACK(lpn); /* If the parent of this node is also red, we have to do rotations. */ - if (parentp != NULL && (*parentp)->red) + if (parentp != NULL && RED(DEREFNODEPTR(parentp))) { - node gp = *gparentp; - node p = *parentp; + node gp = DEREFNODEPTR(gparentp); + node p = DEREFNODEPTR(parentp); /* There are two main cases: 1. The edge types (left or right) of the two red edges differ. 2. Both red edges are of the same type. @@ -186,45 +239,45 @@ maybe_split_for_insert (node *rootp, node *parentp, node *gparentp, { /* Put the child at the top of the tree, with its parent and grandparent as successors. */ - p->red = 1; - gp->red = 1; - root->red = 0; + SETRED(p); + SETRED(gp); + SETBLACK(root); if (p_r < 0) { /* Child is left of parent. */ - p->left = *rp; - *rp = p; - gp->right = *lp; - *lp = gp; + SETLEFT(p,rpn); + SETNODEPTR(rp,p); + SETRIGHT(gp,lpn); + SETNODEPTR(lp,gp); } else { /* Child is right of parent. */ - p->right = *lp; - *lp = p; - gp->left = *rp; - *rp = gp; + SETRIGHT(p,lpn); + SETNODEPTR(lp,p); + SETLEFT(gp,rpn); + SETNODEPTR(rp,gp); } - *gparentp = root; + SETNODEPTR(gparentp,root); } else { - *gparentp = *parentp; + SETNODEPTR(gparentp,p); /* Parent becomes the top of the tree, grandparent and child are its successors. */ - p->red = 0; - gp->red = 1; + SETBLACK(p); + SETRED(gp); if (p_r < 0) { /* Left edges. */ - gp->left = p->right; - p->right = gp; + SETLEFT(gp,RIGHT(p)); + SETRIGHT(p,gp); } else { /* Right edges. */ - gp->right = p->left; - p->left = gp; + SETRIGHT(gp,LEFT(p)); + SETLEFT(p,gp); } } } @@ -237,25 +290,30 @@ maybe_split_for_insert (node *rootp, node *parentp, node *gparentp, void * __tsearch (const void *key, void **vrootp, __compar_fn_t compar) { - node q; + node q, root; node *parentp = NULL, *gparentp = NULL; node *rootp = (node *) vrootp; node *nextp; int r = 0, p_r = 0, gp_r = 0; /* No they might not, Mr Compiler. */ +#ifdef USE_MALLOC_LOW_BIT + static_assert (alignof (max_align_t) > 1, "malloc must return aligned ptrs"); +#endif + if (rootp == NULL) return NULL; /* This saves some additional tests below. */ - if (*rootp != NULL) - (*rootp)->red = 0; + root = DEREFNODEPTR(rootp); + if (root != NULL) + SETBLACK(root); - CHECK_TREE (*rootp); + CHECK_TREE (root); nextp = rootp; - while (*nextp != NULL) + while (DEREFNODEPTR(nextp) != NULL) { - node root = *rootp; + root = DEREFNODEPTR(rootp); r = (*compar) (key, root->key); if (r == 0) return root; @@ -265,8 +323,8 @@ __tsearch (const void *key, void **vrootp, __compar_fn_t compar) That doesn't matter, because the values they contain are never used again in that case. */ - nextp = r < 0 ? &root->left : &root->right; - if (*nextp == NULL) + nextp = r < 0 ? LEFTPTR(root) : RIGHTPTR(root); + if (DEREFNODEPTR(nextp) == NULL) break; gparentp = parentp; @@ -280,10 +338,20 @@ __tsearch (const void *key, void **vrootp, __compar_fn_t compar) q = (struct node_t *) malloc (sizeof (struct node_t)); if (q != NULL) { - *nextp = q; /* link new node to old */ + /* Make sure the malloc implementation returns naturally aligned + memory blocks when expected. Or at least even pointers, so we + can use the low bit as red/black flag. Even though we have a + static_assert to make sure alignof (max_align_t) > 1 there could + be an interposed malloc implementation that might cause havoc by + not obeying the malloc contract. */ +#ifdef USE_MALLOC_LOW_BIT + assert (((uintptr_t) q & (uintptr_t) 0x1) == 0); +#endif + SETNODEPTR(nextp,q); /* link new node to old */ q->key = key; /* initialize new node */ - q->red = 1; - q->left = q->right = NULL; + SETRED(q); + SETLEFT(q,NULL); + SETRIGHT(q,NULL); if (nextp != rootp) /* There may be two red edges in a row now, which we must avoid by @@ -303,23 +371,25 @@ weak_alias (__tsearch, tsearch) void * __tfind (const void *key, void *const *vrootp, __compar_fn_t compar) { + node root; node *rootp = (node *) vrootp; if (rootp == NULL) return NULL; - CHECK_TREE (*rootp); + root = DEREFNODEPTR(rootp); + CHECK_TREE (root); - while (*rootp != NULL) + while (DEREFNODEPTR(rootp) != NULL) { - node root = *rootp; + root = DEREFNODEPTR(rootp); int r; r = (*compar) (key, root->key); if (r == 0) return root; - rootp = r < 0 ? &root->left : &root->right; + rootp = r < 0 ? LEFTPTR(root) : RIGHTPTR(root); } return NULL; } @@ -346,13 +416,14 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar) if (rootp == NULL) return NULL; - p = *rootp; + p = DEREFNODEPTR(rootp); if (p == NULL) return NULL; CHECK_TREE (p); - while ((cmp = (*compar) (key, (*rootp)->key)) != 0) + root = DEREFNODEPTR(rootp); + while ((cmp = (*compar) (key, root->key)) != 0) { if (sp == stacksize) { @@ -363,11 +434,18 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar) } nodestack[sp++] = rootp; - p = *rootp; - rootp = ((cmp < 0) - ? &(*rootp)->left - : &(*rootp)->right); - if (*rootp == NULL) + p = DEREFNODEPTR(rootp); + if (cmp < 0) + { + rootp = LEFTPTR(p); + root = LEFT(p); + } + else + { + rootp = RIGHTPTR(p); + root = RIGHT(p); + } + if (root == NULL) return NULL; } @@ -380,16 +458,17 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar) it with its successor and unchain the successor. If there is no successor, we really unchain the node to be deleted. */ - root = *rootp; + root = DEREFNODEPTR(rootp); - r = root->right; - q = root->left; + r = RIGHT(root); + q = LEFT(root); if (q == NULL || r == NULL) unchained = root; else { - node *parent = rootp, *up = &root->right; + node *parentp = rootp, *up = RIGHTPTR(root); + node upn; for (;;) { if (sp == stacksize) @@ -399,34 +478,35 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar) newstack = alloca (sizeof (node *) * stacksize); nodestack = memcpy (newstack, nodestack, sp * sizeof (node *)); } - nodestack[sp++] = parent; - parent = up; - if ((*up)->left == NULL) + nodestack[sp++] = parentp; + parentp = up; + upn = DEREFNODEPTR(up); + if (LEFT(upn) == NULL) break; - up = &(*up)->left; + up = LEFTPTR(upn); } - unchained = *up; + unchained = DEREFNODEPTR(up); } /* We know that either the left or right successor of UNCHAINED is NULL. R becomes the other one, it is chained into the parent of UNCHAINED. */ - r = unchained->left; + r = LEFT(unchained); if (r == NULL) - r = unchained->right; + r = RIGHT(unchained); if (sp == 0) - *rootp = r; + SETNODEPTR(rootp,r); else { - q = *nodestack[sp-1]; - if (unchained == q->right) - q->right = r; + q = DEREFNODEPTR(nodestack[sp-1]); + if (unchained == RIGHT(q)) + SETRIGHT(q,r); else - q->left = r; + SETLEFT(q,r); } if (unchained != root) root->key = unchained->key; - if (!unchained->red) + if (!RED(unchained)) { /* Now we lost a black edge, which means that the number of black edges on every path is no longer constant. We must balance the @@ -435,17 +515,17 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar) in the first iteration. */ /* NULL nodes are considered black throughout - this is necessary for correctness. */ - while (sp > 0 && (r == NULL || !r->red)) + while (sp > 0 && (r == NULL || !RED(r))) { node *pp = nodestack[sp - 1]; - p = *pp; + p = DEREFNODEPTR(pp); /* Two symmetric cases. */ - if (r == p->left) + if (r == LEFT(p)) { /* Q is R's brother, P is R's parent. The subtree with root R has one black edge less than the subtree with root Q. */ - q = p->right; - if (q->red) + q = RIGHT(p); + if (RED(q)) { /* If Q is red, we know that P is black. We rotate P left so that Q becomes the top node in the tree, with P below @@ -454,21 +534,21 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar) leaf in the tree, but we will be able to recognize one of the following situations, which all require that Q is black. */ - q->red = 0; - p->red = 1; + SETBLACK(q); + SETRED(p); /* Left rotate p. */ - p->right = q->left; - q->left = p; - *pp = q; + SETRIGHT(p,LEFT(q)); + SETLEFT(q,p); + SETNODEPTR(pp,q); /* Make sure pp is right if the case below tries to use it. */ - nodestack[sp++] = pp = &q->left; - q = p->right; + nodestack[sp++] = pp = LEFTPTR(q); + q = RIGHT(p); } /* We know that Q can't be NULL here. We also know that Q is black. */ - if ((q->left == NULL || !q->left->red) - && (q->right == NULL || !q->right->red)) + if ((LEFT(q) == NULL || !RED(LEFT(q))) + && (RIGHT(q) == NULL || !RED(RIGHT(q)))) { /* Q has two black successors. We can simply color Q red. The whole subtree with root P is now missing one black @@ -478,7 +558,7 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar) valid and also makes the black edge count come out right. If P is black, we are at least one step closer to the root and we'll try again the next iteration. */ - q->red = 1; + SETRED(q); r = p; } else @@ -486,7 +566,7 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar) /* Q is black, one of Q's successors is red. We can repair the tree with one operation and will exit the loop afterwards. */ - if (q->right == NULL || !q->right->red) + if (RIGHT(q) == NULL || !RED(RIGHT(q))) { /* The left one is red. We perform the same action as in maybe_split_for_insert where two red edges are @@ -498,14 +578,17 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar) P becomes black, and Q2 gets the color that P had. This changes the black edge count only for node R and its successors. */ - node q2 = q->left; - q2->red = p->red; - p->right = q2->left; - q->left = q2->right; - q2->right = q; - q2->left = p; - *pp = q2; - p->red = 0; + node q2 = LEFT(q); + if (RED(p)) + SETRED(q2); + else + SETBLACK(q2); + SETRIGHT(p,LEFT(q2)); + SETLEFT(q,RIGHT(q2)); + SETRIGHT(q2,q); + SETLEFT(q2,p); + SETNODEPTR(pp,q2); + SETBLACK(p); } else { @@ -513,15 +596,18 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar) and Q gets the color that P had. Q's right successor also becomes black. This changes the black edge count only for node R and its successors. */ - q->red = p->red; - p->red = 0; + if (RED(p)) + SETRED(q); + else + SETBLACK(q); + SETBLACK(p); - q->right->red = 0; + SETBLACK(RIGHT(q)); /* left rotate p */ - p->right = q->left; - q->left = p; - *pp = q; + SETRIGHT(p,LEFT(q)); + SETLEFT(q,p); + SETNODEPTR(pp,q); } /* We're done. */ @@ -532,44 +618,50 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar) else { /* Comments: see above. */ - q = p->left; - if (q->red) + q = LEFT(p); + if (RED(q)) { - q->red = 0; - p->red = 1; - p->left = q->right; - q->right = p; - *pp = q; - nodestack[sp++] = pp = &q->right; - q = p->left; + SETBLACK(q); + SETRED(p); + SETLEFT(p,RIGHT(q)); + SETRIGHT(q,p); + SETNODEPTR(pp,q); + nodestack[sp++] = pp = RIGHTPTR(q); + q = LEFT(p); } - if ((q->right == NULL || !q->right->red) - && (q->left == NULL || !q->left->red)) + if ((RIGHT(q) == NULL || !RED(RIGHT(q))) + && (LEFT(q) == NULL || !RED(LEFT(q)))) { - q->red = 1; + SETRED(q); r = p; } else { - if (q->left == NULL || !q->left->red) + if (LEFT(q) == NULL || !RED(LEFT(q))) { - node q2 = q->right; - q2->red = p->red; - p->left = q2->right; - q->right = q2->left; - q2->left = q; - q2->right = p; - *pp = q2; - p->red = 0; + node q2 = RIGHT(q); + if (RED(p)) + SETRED(q2); + else + SETBLACK(q2); + SETLEFT(p,RIGHT(q2)); + SETRIGHT(q,LEFT(q2)); + SETLEFT(q2,q); + SETRIGHT(q2,p); + SETNODEPTR(pp,q2); + SETBLACK(p); } else { - q->red = p->red; - p->red = 0; - q->left->red = 0; - p->left = q->right; - q->right = p; - *pp = q; + if (RED(p)) + SETRED(q); + else + SETBLACK(q); + SETBLACK(p); + SETBLACK(LEFT(q)); + SETLEFT(p,RIGHT(q)); + SETRIGHT(q,p); + SETNODEPTR(pp,q); } sp = 1; r = NULL; @@ -578,7 +670,7 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar) --sp; } if (r != NULL) - r->red = 0; + SETBLACK(r); } free (unchained); @@ -592,21 +684,20 @@ weak_alias (__tdelete, tdelete) ROOT is the root of the tree to be walked, ACTION the function to be called at each node. LEVEL is the level of ROOT in the whole tree. */ static void -internal_function trecurse (const void *vroot, __action_fn_t action, int level) { const_node root = (const_node) vroot; - if (root->left == NULL && root->right == NULL) + if (LEFT(root) == NULL && RIGHT(root) == NULL) (*action) (root, leaf, level); else { (*action) (root, preorder, level); - if (root->left != NULL) - trecurse (root->left, action, level + 1); + if (LEFT(root) != NULL) + trecurse (LEFT(root), action, level + 1); (*action) (root, postorder, level); - if (root->right != NULL) - trecurse (root->right, action, level + 1); + if (RIGHT(root) != NULL) + trecurse (RIGHT(root), action, level + 1); (*action) (root, endorder, level); } } @@ -620,7 +711,7 @@ __twalk (const void *vroot, __action_fn_t action) { const_node root = (const_node) vroot; - CHECK_TREE (root); + CHECK_TREE ((node) root); if (root != NULL && action != NULL) trecurse (root, action, 0); @@ -633,13 +724,12 @@ weak_alias (__twalk, twalk) /* The standardized functions miss an important functionality: the tree cannot be removed easily. We provide a function to do this. */ static void -internal_function tdestroy_recurse (node root, __free_fn_t freefct) { - if (root->left != NULL) - tdestroy_recurse (root->left, freefct); - if (root->right != NULL) - tdestroy_recurse (root->right, freefct); + if (LEFT(root) != NULL) + tdestroy_recurse (LEFT(root), freefct); + if (RIGHT(root) != NULL) + tdestroy_recurse (RIGHT(root), freefct); (*freefct) ((void *) root->key); /* Free the node itself. */ free (root); @@ -655,4 +745,5 @@ __tdestroy (void *vroot, __free_fn_t freefct) if (root != NULL) tdestroy_recurse (root, freefct); } +libc_hidden_def (__tdestroy) weak_alias (__tdestroy, tdestroy) diff --git a/misc/tst-allocate_once.c b/misc/tst-allocate_once.c new file mode 100644 index 0000000000..89277b33b7 --- /dev/null +++ b/misc/tst-allocate_once.c @@ -0,0 +1,181 @@ +/* Test the allocate_once function. + Copyright (C) 2018 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, see + <http://www.gnu.org/licenses/>. */ + +#include <allocate_once.h> +#include <mcheck.h> +#include <string.h> +#include <support/check.h> +#include <support/support.h> + +/* Allocate a new string. */ +static void * +allocate_string (void *closure) +{ + return xstrdup (closure); +} + +/* Allocation and deallocation functions which are not expected to be + called. */ + +static void * +allocate_not_called (void *closure) +{ + FAIL_EXIT1 ("allocation function called unexpectedly (%p)", closure); +} + +static void +deallocate_not_called (void *closure, void *ptr) +{ + FAIL_EXIT1 ("deallocate function called unexpectedly (%p, %p)", + closure, ptr); +} + +/* Counter for various function calls. */ +static int function_called; + +/* An allocation function which returns NULL and records that it has + been called. */ +static void * +allocate_return_null (void *closure) +{ + /* The function should only be called once. */ + TEST_COMPARE (function_called, 0); + ++function_called; + return NULL; +} + + +/* The following is used to check the retry logic, by causing a fake + race condition. */ +static void *fake_race_place; +static char fake_race_region[3]; /* To obtain unique addresses. */ + +static void * +fake_race_allocate (void *closure) +{ + TEST_VERIFY (closure == &fake_race_region[0]); + TEST_COMPARE (function_called, 0); + ++function_called; + /* Fake allocation by another thread. */ + fake_race_place = &fake_race_region[1]; + return &fake_race_region[2]; +} + +static void +fake_race_deallocate (void *closure, void *ptr) +{ + /* Check that the pointer returned from fake_race_allocate is + deallocated (and not the one stored in fake_race_place). */ + TEST_VERIFY (ptr == &fake_race_region[2]); + + TEST_VERIFY (fake_race_place == &fake_race_region[1]); + TEST_VERIFY (closure == &fake_race_region[0]); + TEST_COMPARE (function_called, 1); + ++function_called; +} + +/* Similar to fake_race_allocate, but expects to be paired with free + as the deallocation function. */ +static void * +fake_race_allocate_for_free (void *closure) +{ + TEST_VERIFY (closure == &fake_race_region[0]); + TEST_COMPARE (function_called, 0); + ++function_called; + /* Fake allocation by another thread. */ + fake_race_place = &fake_race_region[1]; + return xstrdup ("to be freed"); +} + +static int +do_test (void) +{ + mtrace (); + + /* Simple allocation. */ + void *place1 = NULL; + char *string1 = allocate_once (&place1, allocate_string, + deallocate_not_called, + (char *) "test string 1"); + TEST_VERIFY_EXIT (string1 != NULL); + TEST_VERIFY (strcmp ("test string 1", string1) == 0); + /* Second call returns the first pointer, without calling any + callbacks. */ + TEST_VERIFY (string1 + == allocate_once (&place1, allocate_not_called, + deallocate_not_called, + (char *) "test string 1a")); + + /* Different place should result in another call. */ + void *place2 = NULL; + char *string2 = allocate_once (&place2, allocate_string, + deallocate_not_called, + (char *) "test string 2"); + TEST_VERIFY_EXIT (string2 != NULL); + TEST_VERIFY (strcmp ("test string 2", string2) == 0); + TEST_VERIFY (string1 != string2); + + /* Check error reporting (NULL return value from the allocation + function). */ + void *place3 = NULL; + char *string3 = allocate_once (&place3, allocate_return_null, + deallocate_not_called, NULL); + TEST_VERIFY (string3 == NULL); + TEST_COMPARE (function_called, 1); + + /* Check that the deallocation function is called if the race is + lost. */ + function_called = 0; + TEST_VERIFY (allocate_once (&fake_race_place, + fake_race_allocate, + fake_race_deallocate, + &fake_race_region[0]) + == &fake_race_region[1]); + TEST_COMPARE (function_called, 2); + function_called = 3; + TEST_VERIFY (allocate_once (&fake_race_place, + fake_race_allocate, + fake_race_deallocate, + &fake_race_region[0]) + == &fake_race_region[1]); + TEST_COMPARE (function_called, 3); + + /* Similar, but this time rely on that free is called. */ + function_called = 0; + fake_race_place = NULL; + TEST_VERIFY (allocate_once (&fake_race_place, + fake_race_allocate_for_free, + NULL, + &fake_race_region[0]) + == &fake_race_region[1]); + TEST_COMPARE (function_called, 1); + function_called = 3; + TEST_VERIFY (allocate_once (&fake_race_place, + fake_race_allocate_for_free, + NULL, + &fake_race_region[0]) + == &fake_race_region[1]); + TEST_COMPARE (function_called, 3); + + free (place2); + free (place1); + + return 0; +} + +#include <support/test-driver.c> diff --git a/misc/tst-atomic-long.c b/misc/tst-atomic-long.c new file mode 100644 index 0000000000..e5caa10760 --- /dev/null +++ b/misc/tst-atomic-long.c @@ -0,0 +1,27 @@ +/* Tests for atomic.h macros. + Copyright (C) 2003-2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek <jakub@redhat.com>, 2003. + + 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, see + <http://www.gnu.org/licenses/>. */ + +#include <bits/wordsize.h> + +#define atomic_t long +#if __WORDSIZE == 64 +# define TEST_ATOMIC64 1 +#endif + +#include "tst-atomic.c" diff --git a/misc/tst-atomic.c b/misc/tst-atomic.c new file mode 100644 index 0000000000..90a309bcd3 --- /dev/null +++ b/misc/tst-atomic.c @@ -0,0 +1,639 @@ +/* Tests for atomic.h macros. + Copyright (C) 2003-2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek <jakub@redhat.com>, 2003. + + 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, see + <http://www.gnu.org/licenses/>. */ + +#include <stdio.h> +#include <atomic.h> + +#ifndef atomic_t +# define atomic_t int +#endif + +/* Test various atomic.h macros. */ +static int +do_test (void) +{ + atomic_t mem, expected; + int ret = 0; + +#ifdef atomic_compare_and_exchange_val_acq + mem = 24; + if (atomic_compare_and_exchange_val_acq (&mem, 35, 24) != 24 + || mem != 35) + { + puts ("atomic_compare_and_exchange_val_acq test 1 failed"); + ret = 1; + } + + mem = 12; + if (atomic_compare_and_exchange_val_acq (&mem, 10, 15) != 12 + || mem != 12) + { + puts ("atomic_compare_and_exchange_val_acq test 2 failed"); + ret = 1; + } + + mem = -15; + if (atomic_compare_and_exchange_val_acq (&mem, -56, -15) != -15 + || mem != -56) + { + puts ("atomic_compare_and_exchange_val_acq test 3 failed"); + ret = 1; + } + + mem = -1; + if (atomic_compare_and_exchange_val_acq (&mem, 17, 0) != -1 + || mem != -1) + { + puts ("atomic_compare_and_exchange_val_acq test 4 failed"); + ret = 1; + } +#endif + + mem = 24; + if (atomic_compare_and_exchange_bool_acq (&mem, 35, 24) + || mem != 35) + { + puts ("atomic_compare_and_exchange_bool_acq test 1 failed"); + ret = 1; + } + + mem = 12; + if (! atomic_compare_and_exchange_bool_acq (&mem, 10, 15) + || mem != 12) + { + puts ("atomic_compare_and_exchange_bool_acq test 2 failed"); + ret = 1; + } + + mem = -15; + if (atomic_compare_and_exchange_bool_acq (&mem, -56, -15) + || mem != -56) + { + puts ("atomic_compare_and_exchange_bool_acq test 3 failed"); + ret = 1; + } + + mem = -1; + if (! atomic_compare_and_exchange_bool_acq (&mem, 17, 0) + || mem != -1) + { + puts ("atomic_compare_and_exchange_bool_acq test 4 failed"); + ret = 1; + } + + mem = 64; + if (atomic_exchange_acq (&mem, 31) != 64 + || mem != 31) + { + puts ("atomic_exchange_acq test failed"); + ret = 1; + } + + mem = 2; + if (atomic_exchange_and_add (&mem, 11) != 2 + || mem != 13) + { + puts ("atomic_exchange_and_add test failed"); + ret = 1; + } + + mem = 2; + if (atomic_exchange_and_add_acq (&mem, 11) != 2 + || mem != 13) + { + puts ("atomic_exchange_and_add test failed"); + ret = 1; + } + + mem = 2; + if (atomic_exchange_and_add_rel (&mem, 11) != 2 + || mem != 13) + { + puts ("atomic_exchange_and_add test failed"); + ret = 1; + } + + mem = -21; + atomic_add (&mem, 22); + if (mem != 1) + { + puts ("atomic_add test failed"); + ret = 1; + } + + mem = -1; + atomic_increment (&mem); + if (mem != 0) + { + puts ("atomic_increment test failed"); + ret = 1; + } + + mem = 2; + if (atomic_increment_val (&mem) != 3) + { + puts ("atomic_increment_val test failed"); + ret = 1; + } + + mem = 0; + if (atomic_increment_and_test (&mem) + || mem != 1) + { + puts ("atomic_increment_and_test test 1 failed"); + ret = 1; + } + + mem = 35; + if (atomic_increment_and_test (&mem) + || mem != 36) + { + puts ("atomic_increment_and_test test 2 failed"); + ret = 1; + } + + mem = -1; + if (! atomic_increment_and_test (&mem) + || mem != 0) + { + puts ("atomic_increment_and_test test 3 failed"); + ret = 1; + } + + mem = 17; + atomic_decrement (&mem); + if (mem != 16) + { + puts ("atomic_decrement test failed"); + ret = 1; + } + + if (atomic_decrement_val (&mem) != 15) + { + puts ("atomic_decrement_val test failed"); + ret = 1; + } + + mem = 0; + if (atomic_decrement_and_test (&mem) + || mem != -1) + { + puts ("atomic_decrement_and_test test 1 failed"); + ret = 1; + } + + mem = 15; + if (atomic_decrement_and_test (&mem) + || mem != 14) + { + puts ("atomic_decrement_and_test test 2 failed"); + ret = 1; + } + + mem = 1; + if (! atomic_decrement_and_test (&mem) + || mem != 0) + { + puts ("atomic_decrement_and_test test 3 failed"); + ret = 1; + } + + mem = 1; + if (atomic_decrement_if_positive (&mem) != 1 + || mem != 0) + { + puts ("atomic_decrement_if_positive test 1 failed"); + ret = 1; + } + + mem = 0; + if (atomic_decrement_if_positive (&mem) != 0 + || mem != 0) + { + puts ("atomic_decrement_if_positive test 2 failed"); + ret = 1; + } + + mem = -1; + if (atomic_decrement_if_positive (&mem) != -1 + || mem != -1) + { + puts ("atomic_decrement_if_positive test 3 failed"); + ret = 1; + } + + mem = -12; + if (! atomic_add_negative (&mem, 10) + || mem != -2) + { + puts ("atomic_add_negative test 1 failed"); + ret = 1; + } + + mem = 0; + if (atomic_add_negative (&mem, 100) + || mem != 100) + { + puts ("atomic_add_negative test 2 failed"); + ret = 1; + } + + mem = 15; + if (atomic_add_negative (&mem, -10) + || mem != 5) + { + puts ("atomic_add_negative test 3 failed"); + ret = 1; + } + + mem = -12; + if (atomic_add_negative (&mem, 14) + || mem != 2) + { + puts ("atomic_add_negative test 4 failed"); + ret = 1; + } + + mem = 0; + if (! atomic_add_negative (&mem, -1) + || mem != -1) + { + puts ("atomic_add_negative test 5 failed"); + ret = 1; + } + + mem = -31; + if (atomic_add_negative (&mem, 31) + || mem != 0) + { + puts ("atomic_add_negative test 6 failed"); + ret = 1; + } + + mem = -34; + if (atomic_add_zero (&mem, 31) + || mem != -3) + { + puts ("atomic_add_zero test 1 failed"); + ret = 1; + } + + mem = -36; + if (! atomic_add_zero (&mem, 36) + || mem != 0) + { + puts ("atomic_add_zero test 2 failed"); + ret = 1; + } + + mem = 113; + if (atomic_add_zero (&mem, -13) + || mem != 100) + { + puts ("atomic_add_zero test 3 failed"); + ret = 1; + } + + mem = -18; + if (atomic_add_zero (&mem, 20) + || mem != 2) + { + puts ("atomic_add_zero test 4 failed"); + ret = 1; + } + + mem = 10; + if (atomic_add_zero (&mem, -20) + || mem != -10) + { + puts ("atomic_add_zero test 5 failed"); + ret = 1; + } + + mem = 10; + if (! atomic_add_zero (&mem, -10) + || mem != 0) + { + puts ("atomic_add_zero test 6 failed"); + ret = 1; + } + + mem = 0; + atomic_bit_set (&mem, 1); + if (mem != 2) + { + puts ("atomic_bit_set test 1 failed"); + ret = 1; + } + + mem = 8; + atomic_bit_set (&mem, 3); + if (mem != 8) + { + puts ("atomic_bit_set test 2 failed"); + ret = 1; + } + +#ifdef TEST_ATOMIC64 + mem = 16; + atomic_bit_set (&mem, 35); + if (mem != 0x800000010LL) + { + puts ("atomic_bit_set test 3 failed"); + ret = 1; + } +#endif + + mem = 0; + if (atomic_bit_test_set (&mem, 1) + || mem != 2) + { + puts ("atomic_bit_test_set test 1 failed"); + ret = 1; + } + + mem = 8; + if (! atomic_bit_test_set (&mem, 3) + || mem != 8) + { + puts ("atomic_bit_test_set test 2 failed"); + ret = 1; + } + +#ifdef TEST_ATOMIC64 + mem = 16; + if (atomic_bit_test_set (&mem, 35) + || mem != 0x800000010LL) + { + puts ("atomic_bit_test_set test 3 failed"); + ret = 1; + } + + mem = 0x100000000LL; + if (! atomic_bit_test_set (&mem, 32) + || mem != 0x100000000LL) + { + puts ("atomic_bit_test_set test 4 failed"); + ret = 1; + } +#endif + +#ifdef catomic_compare_and_exchange_val_acq + mem = 24; + if (catomic_compare_and_exchange_val_acq (&mem, 35, 24) != 24 + || mem != 35) + { + puts ("catomic_compare_and_exchange_val_acq test 1 failed"); + ret = 1; + } + + mem = 12; + if (catomic_compare_and_exchange_val_acq (&mem, 10, 15) != 12 + || mem != 12) + { + puts ("catomic_compare_and_exchange_val_acq test 2 failed"); + ret = 1; + } + + mem = -15; + if (catomic_compare_and_exchange_val_acq (&mem, -56, -15) != -15 + || mem != -56) + { + puts ("catomic_compare_and_exchange_val_acq test 3 failed"); + ret = 1; + } + + mem = -1; + if (catomic_compare_and_exchange_val_acq (&mem, 17, 0) != -1 + || mem != -1) + { + puts ("catomic_compare_and_exchange_val_acq test 4 failed"); + ret = 1; + } +#endif + + mem = 24; + if (catomic_compare_and_exchange_bool_acq (&mem, 35, 24) + || mem != 35) + { + puts ("catomic_compare_and_exchange_bool_acq test 1 failed"); + ret = 1; + } + + mem = 12; + if (! catomic_compare_and_exchange_bool_acq (&mem, 10, 15) + || mem != 12) + { + puts ("catomic_compare_and_exchange_bool_acq test 2 failed"); + ret = 1; + } + + mem = -15; + if (catomic_compare_and_exchange_bool_acq (&mem, -56, -15) + || mem != -56) + { + puts ("catomic_compare_and_exchange_bool_acq test 3 failed"); + ret = 1; + } + + mem = -1; + if (! catomic_compare_and_exchange_bool_acq (&mem, 17, 0) + || mem != -1) + { + puts ("catomic_compare_and_exchange_bool_acq test 4 failed"); + ret = 1; + } + + mem = 2; + if (catomic_exchange_and_add (&mem, 11) != 2 + || mem != 13) + { + puts ("catomic_exchange_and_add test failed"); + ret = 1; + } + + mem = -21; + catomic_add (&mem, 22); + if (mem != 1) + { + puts ("catomic_add test failed"); + ret = 1; + } + + mem = -1; + catomic_increment (&mem); + if (mem != 0) + { + puts ("catomic_increment test failed"); + ret = 1; + } + + mem = 2; + if (catomic_increment_val (&mem) != 3) + { + puts ("catomic_increment_val test failed"); + ret = 1; + } + + mem = 17; + catomic_decrement (&mem); + if (mem != 16) + { + puts ("catomic_decrement test failed"); + ret = 1; + } + + if (catomic_decrement_val (&mem) != 15) + { + puts ("catomic_decrement_val test failed"); + ret = 1; + } + + /* Tests for C11-like atomics. */ + mem = 11; + if (atomic_load_relaxed (&mem) != 11 || atomic_load_acquire (&mem) != 11) + { + puts ("atomic_load_{relaxed,acquire} test failed"); + ret = 1; + } + + atomic_store_relaxed (&mem, 12); + if (mem != 12) + { + puts ("atomic_store_relaxed test failed"); + ret = 1; + } + atomic_store_release (&mem, 13); + if (mem != 13) + { + puts ("atomic_store_release test failed"); + ret = 1; + } + + mem = 14; + expected = 14; + if (!atomic_compare_exchange_weak_relaxed (&mem, &expected, 25) + || mem != 25 || expected != 14) + { + puts ("atomic_compare_exchange_weak_relaxed test 1 failed"); + ret = 1; + } + if (atomic_compare_exchange_weak_relaxed (&mem, &expected, 14) + || mem != 25 || expected != 25) + { + puts ("atomic_compare_exchange_weak_relaxed test 2 failed"); + ret = 1; + } + mem = 14; + expected = 14; + if (!atomic_compare_exchange_weak_acquire (&mem, &expected, 25) + || mem != 25 || expected != 14) + { + puts ("atomic_compare_exchange_weak_acquire test 1 failed"); + ret = 1; + } + if (atomic_compare_exchange_weak_acquire (&mem, &expected, 14) + || mem != 25 || expected != 25) + { + puts ("atomic_compare_exchange_weak_acquire test 2 failed"); + ret = 1; + } + mem = 14; + expected = 14; + if (!atomic_compare_exchange_weak_release (&mem, &expected, 25) + || mem != 25 || expected != 14) + { + puts ("atomic_compare_exchange_weak_release test 1 failed"); + ret = 1; + } + if (atomic_compare_exchange_weak_release (&mem, &expected, 14) + || mem != 25 || expected != 25) + { + puts ("atomic_compare_exchange_weak_release test 2 failed"); + ret = 1; + } + + mem = 23; + if (atomic_exchange_acquire (&mem, 42) != 23 || mem != 42) + { + puts ("atomic_exchange_acquire test failed"); + ret = 1; + } + mem = 23; + if (atomic_exchange_release (&mem, 42) != 23 || mem != 42) + { + puts ("atomic_exchange_release test failed"); + ret = 1; + } + + mem = 23; + if (atomic_fetch_add_relaxed (&mem, 1) != 23 || mem != 24) + { + puts ("atomic_fetch_add_relaxed test failed"); + ret = 1; + } + mem = 23; + if (atomic_fetch_add_acquire (&mem, 1) != 23 || mem != 24) + { + puts ("atomic_fetch_add_acquire test failed"); + ret = 1; + } + mem = 23; + if (atomic_fetch_add_release (&mem, 1) != 23 || mem != 24) + { + puts ("atomic_fetch_add_release test failed"); + ret = 1; + } + mem = 23; + if (atomic_fetch_add_acq_rel (&mem, 1) != 23 || mem != 24) + { + puts ("atomic_fetch_add_acq_rel test failed"); + ret = 1; + } + + mem = 3; + if (atomic_fetch_and_acquire (&mem, 2) != 3 || mem != 2) + { + puts ("atomic_fetch_and_acquire test failed"); + ret = 1; + } + + mem = 4; + if (atomic_fetch_or_relaxed (&mem, 2) != 4 || mem != 6) + { + puts ("atomic_fetch_or_relaxed test failed"); + ret = 1; + } + mem = 4; + if (atomic_fetch_or_acquire (&mem, 2) != 4 || mem != 6) + { + puts ("atomic_fetch_or_acquire test failed"); + ret = 1; + } + + /* This is a single-threaded test, so we can't test the effects of the + fences. */ + atomic_thread_fence_acquire (); + atomic_thread_fence_release (); + atomic_thread_fence_seq_cst (); + + return ret; +} + +#include <support/test-driver.c> diff --git a/misc/tst-dirname.c b/misc/tst-dirname.c index c6ae20d9c0..714b67aa53 100644 --- a/misc/tst-dirname.c +++ b/misc/tst-dirname.c @@ -1,5 +1,5 @@ /* Test program for dirname function a la XPG. - Copyright (C) 1996-2016 Free Software Foundation, Inc. + Copyright (C) 1996-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/misc/tst-efgcvt.c b/misc/tst-efgcvt.c index b8a7ef20ad..bb716d5198 100644 --- a/misc/tst-efgcvt.c +++ b/misc/tst-efgcvt.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2016 Free Software Foundation, Inc. +/* Copyright (C) 1998-2018 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 diff --git a/misc/tst-empty.c b/misc/tst-empty.c new file mode 100644 index 0000000000..31860b06b3 --- /dev/null +++ b/misc/tst-empty.c @@ -0,0 +1,8 @@ +/* The most useful C program known to man. */ +static int +do_test (void) +{ + return 0; +} + +#include <support/test-driver.c> diff --git a/misc/tst-error1.c b/misc/tst-error1.c index a97a22ce9d..9c4a62fbd0 100644 --- a/misc/tst-error1.c +++ b/misc/tst-error1.c @@ -3,7 +3,7 @@ #include <stdio.h> #include <string.h> #include <wchar.h> -#include <libc-internal.h> +#include <libc-diag.h> static int do_test (int argc, char *argv[]) diff --git a/misc/tst-fdset.c b/misc/tst-fdset.c index 861c31607e..5452485a31 100644 --- a/misc/tst-fdset.c +++ b/misc/tst-fdset.c @@ -1,5 +1,5 @@ /* Test FD* macros. - Copyright (C) 1997-2016 Free Software Foundation, Inc. + Copyright (C) 1997-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Robert Bihlmeyer <robbe@orcus.priv.at>. diff --git a/misc/tst-makedev.c b/misc/tst-makedev.c new file mode 100644 index 0000000000..0a38060cd1 --- /dev/null +++ b/misc/tst-makedev.c @@ -0,0 +1,104 @@ +/* Tests of functions to access `dev_t' values. + Copyright (C) 2016-2018 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, see + <http://www.gnu.org/licenses/>. */ + +#include <sys/types.h> +#include <sys/sysmacros.h> +#include <stdio.h> +#include <inttypes.h> + +/* Confirm that makedev (major (d), minor (d)) == d. */ +static int +do_test_split_combine (dev_t d1) +{ + unsigned int maj = major (d1); + unsigned int min = minor (d1); + dev_t d2 = makedev (maj, min); + if (d1 != d2) + { + printf ("FAIL: %016" PRIx64 " != %016" PRIx64 " (maj %08x min %08x)\n", + (uint64_t)d2, (uint64_t)d1, maj, min); + return 1; + } + else + return 0; +} + +/* Confirm that major (makedev (maj, min)) == maj and + minor (makedev (maj, min)) == min. */ +static int +do_test_combine_split (unsigned int maj1, unsigned int min1) +{ + dev_t d = makedev (maj1, min1); + unsigned int maj2 = major (d); + unsigned int min2 = minor (d); + if (maj1 != maj2 && min1 != min2) + { + printf ("FAIL: %08x != %08x, %08x != %08x (dev %016" PRIx64 ")\n", + maj2, maj1, min2, min1, (uint64_t)d); + return 1; + } + else if (maj1 != maj2) + { + printf ("FAIL: %08x != %08x, %08x == %08x (dev %016" PRIx64 ")\n", + maj2, maj1, min2, min1, (uint64_t)d); + return 1; + } + else if (min1 != min2) + { + printf ("FAIL: %08x == %08x, %08x != %08x (dev %016" PRIx64 ")\n", + maj2, maj1, min2, min1, (uint64_t)d); + return 1; + } + else + return 0; +} + +static int +do_test (void) +{ + dev_t d; + unsigned int maj, min; + int status = 0; + + /* Test the traditional range (16-bit dev_t, 8-bit each maj/min) + exhaustively. */ + for (d = 0; d <= 0xFFFF; d++) + status |= do_test_split_combine (d); + + for (maj = 0; maj <= 0xFF; maj++) + for (min = 0; min <= 0xFF; min++) + status |= do_test_combine_split (maj, min); + + /* Test glibc's expanded range (64-bit dev_t, 32-bit each maj/min). + Exhaustive testing would take much too long, instead we shift a + pair of 1-bits over each range. */ + { + unsigned int a, b; + for (a = 0; a <= 63; a++) + do_test_split_combine (((dev_t) 0x03) << a); + + for (a = 0; a < 31; a++) + for (b = 0; b <= 31; b++) + do_test_combine_split (0x03u << a, 0x03u << b); + } + + return status; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/misc/tst-mntent-blank-corrupt.c b/misc/tst-mntent-blank-corrupt.c index 9e33ea083a..bb9939779c 100644 --- a/misc/tst-mntent-blank-corrupt.c +++ b/misc/tst-mntent-blank-corrupt.c @@ -1,6 +1,6 @@ /* Make sure blank lines does not cause memory corruption BZ #18887. - Copyright (C) 2009-2016 Free Software Foundation, Inc. + Copyright (C) 2009-2018 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 diff --git a/misc/tst-mntent-blank-passno.c b/misc/tst-mntent-blank-passno.c index 1bc21faa64..17b0536a77 100644 --- a/misc/tst-mntent-blank-passno.c +++ b/misc/tst-mntent-blank-passno.c @@ -1,6 +1,6 @@ /* Make sure trailing whitespace is handled properly BZ #17273. - Copyright (C) 2009-2016 Free Software Foundation, Inc. + Copyright (C) 2009-2018 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 diff --git a/misc/tst-preadvwritev-common.c b/misc/tst-preadvwritev-common.c new file mode 100644 index 0000000000..b59a3de465 --- /dev/null +++ b/misc/tst-preadvwritev-common.c @@ -0,0 +1,160 @@ +/* Common definitions for preadv and pwritev. + Copyright (C) 2016-2018 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, see + <http://www.gnu.org/licenses/>. */ + +#include <array_length.h> +#include <stdio.h> +#include <stdint.h> +#include <errno.h> +#include <string.h> +#include <sys/uio.h> +#include <sys/stat.h> + +#include <support/check.h> +#include <support/temp_file.h> +#include <support/xunistd.h> + +static char *temp_filename; +static int temp_fd; + +static int do_test (void); + +static void +do_prepare (int argc, char **argv) +{ + temp_fd = create_temp_file ("tst-preadvwritev.", &temp_filename); + if (temp_fd == -1) + FAIL_EXIT1 ("cannot create temporary file"); +} +#define PREPARE do_prepare + +#ifndef PREADV +# define PREADV(__fd, __iov, __iovcnt, __offset) \ + preadv (__fd, __iov, __iovcnt, __offset) +#endif + +#ifndef PWRITEV +# define PWRITEV(__fd, __iov, __iovcnt, __offset) \ + pwritev (__fd, __iov, __iovcnt, __offset) +#endif + +static __attribute__ ((unused)) void +do_test_without_offset (void) +{ + xftruncate (temp_fd, 0); + + xwrite (temp_fd, "123", 3); + xlseek (temp_fd, 2, SEEK_SET); + { + struct iovec iov[] = + { + { (void *) "abc", 3 }, + { (void *) "xyzt", 4 }, + }; + TEST_COMPARE (PWRITEV (temp_fd, iov, array_length (iov), -1), 7); + } + TEST_COMPARE (xlseek (temp_fd, 0, SEEK_CUR), 9); + + xlseek (temp_fd, 1, SEEK_SET); + char buf1[3]; + char buf2[2]; + { + struct iovec iov[] = + { + { buf1, sizeof (buf1) }, + { buf2, sizeof (buf2) }, + }; + TEST_COMPARE (PREADV (temp_fd, iov, array_length (iov), -1), + sizeof (buf1) + sizeof (buf2)); + TEST_COMPARE (memcmp ("2ab", buf1, sizeof (buf1)), 0); + TEST_COMPARE (memcmp ("cx", buf2, sizeof (buf2)), 0); + TEST_COMPARE (xlseek (temp_fd, 0, SEEK_CUR), 6); + } + + xftruncate (temp_fd, 0); +} + +static int +do_test_with_offset (off_t offset) +{ + struct iovec iov[2]; + ssize_t ret; + + char buf1[32]; + char buf2[64]; + + memset (buf1, 0xf0, sizeof buf1); + memset (buf2, 0x0f, sizeof buf2); + + /* Write two buffer with 32 and 64 bytes respectively. */ + memset (iov, 0, sizeof iov); + iov[0].iov_base = buf1; + iov[0].iov_len = sizeof buf1; + iov[1].iov_base = buf2; + iov[1].iov_len = sizeof buf2; + + ret = PWRITEV (temp_fd, iov, 2, offset); + if (ret == -1) + FAIL_RET ("first pwritev returned -1"); + if (ret != (sizeof buf1 + sizeof buf2)) + FAIL_RET ("first pwritev returned an unexpected value"); + + ret = PWRITEV (temp_fd, iov, 2, sizeof buf1 + sizeof buf2 + offset); + if (ret == -1) + FAIL_RET ("second pwritev returned -1"); + if (ret != (sizeof buf1 + sizeof buf2)) + FAIL_RET ("second pwritev returned an unexpected value"); + + char buf3[32]; + char buf4[64]; + + memset (buf3, 0x0f, sizeof buf3); + memset (buf4, 0xf0, sizeof buf4); + + iov[0].iov_base = buf3; + iov[0].iov_len = sizeof buf3; + iov[1].iov_base = buf4; + iov[1].iov_len = sizeof buf4; + + /* Now read two buffer with 32 and 64 bytes respectively. */ + ret = PREADV (temp_fd, iov, 2, offset); + if (ret == -1) + FAIL_RET ("first preadv returned -1"); + if (ret != (sizeof buf3 + sizeof buf4)) + FAIL_RET ("first preadv returned an unexpected value"); + + if (memcmp (buf1, buf3, sizeof buf1) != 0) + FAIL_RET ("first buffer from first preadv different than expected"); + if (memcmp (buf2, buf4, sizeof buf2) != 0) + FAIL_RET ("second buffer from first preadv different than expected"); + + ret = PREADV (temp_fd, iov, 2, sizeof buf3 + sizeof buf4 + offset); + if (ret == -1) + FAIL_RET ("second preadv returned -1"); + if (ret != (sizeof buf3 + sizeof buf4)) + FAIL_RET ("second preadv returned an unexpected value"); + + /* And compare the buffers read and written to check if there are equal. */ + if (memcmp (buf1, buf3, sizeof buf1) != 0) + FAIL_RET ("first buffer from second preadv different than expected"); + if (memcmp (buf2, buf4, sizeof buf2) != 0) + FAIL_RET ("second buffer from second preadv different than expected"); + + return 0; +} + +#include <support/test-driver.c> diff --git a/misc/tst-preadvwritev.c b/misc/tst-preadvwritev.c new file mode 100644 index 0000000000..1b0c9af435 --- /dev/null +++ b/misc/tst-preadvwritev.c @@ -0,0 +1,25 @@ +/* Tests for preadv and pwritev. + Copyright (C) 2016-2018 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, see + <http://www.gnu.org/licenses/>. */ + +#include "tst-preadvwritev-common.c" + +static int +do_test (void) +{ + return do_test_with_offset (0); +} diff --git a/misc/tst-preadvwritev2-common.c b/misc/tst-preadvwritev2-common.c new file mode 100644 index 0000000000..f889a21544 --- /dev/null +++ b/misc/tst-preadvwritev2-common.c @@ -0,0 +1,59 @@ +/* Common function for preadv2 and pwritev2 tests. + Copyright (C) 2017-2018 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, see + <http://www.gnu.org/licenses/>. */ + +#include <limits.h> +#include <support/check.h> + +static void +do_test_with_invalid_flags (void) +{ +#ifndef RWF_HIPRI +# define RWF_HIPRI 0 +#endif +#ifndef RWF_DSYNC +# define RWF_DSYNC 0 +#endif +#ifndef RWF_SYNC +# define RWF_SYNC 0 +#endif +#ifndef RWF_NOWAIT +# define RWF_NOWAIT 0 +#endif +#ifndef RWF_APPEND +# define RWF_APPEND 0 +#endif +#define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT \ + | RWF_APPEND) + /* Set the next bit from the mask of all supported flags. */ + int invalid_flag = RWF_SUPPORTED != 0 ? __builtin_clz (RWF_SUPPORTED) : 2; + invalid_flag = 0x1 << ((sizeof (int) * CHAR_BIT) - invalid_flag); + + char buf[32]; + const struct iovec vec = { .iov_base = buf, .iov_len = sizeof (buf) }; + if (preadv2 (temp_fd, &vec, 1, 0, invalid_flag) != -1) + FAIL_EXIT1 ("preadv2 did not fail with an invalid flag"); + if (errno != ENOTSUP) + FAIL_EXIT1 ("preadv2 failure did not set errno to ENOTSUP (%d)", errno); + + /* This might fail for compat syscall (32 bits running on 64 bits kernel) + due a kernel issue. */ + if (pwritev2 (temp_fd, &vec, 1, 0, invalid_flag) != -1) + FAIL_EXIT1 ("pwritev2 did not fail with an invalid flag"); + if (errno != ENOTSUP) + FAIL_EXIT1 ("pwritev2 failure did not set errno to ENOTSUP (%d)", errno); +} diff --git a/misc/tst-preadvwritev2.c b/misc/tst-preadvwritev2.c new file mode 100644 index 0000000000..be22802dbe --- /dev/null +++ b/misc/tst-preadvwritev2.c @@ -0,0 +1,35 @@ +/* Tests for preadv2 and pwritev2. + Copyright (C) 2016-2018 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, see + <http://www.gnu.org/licenses/>. */ + +#define PREADV(__fd, __iov, __iovcnt, __offset) \ + preadv2 (__fd, __iov, __iovcnt, __offset, 0) + +#define PWRITEV(__fd, __iov, __iovcnt, __offset) \ + pwritev2 (__fd, __iov, __iovcnt, __offset, 0) + +#include "tst-preadvwritev-common.c" +#include "tst-preadvwritev2-common.c" + +static int +do_test (void) +{ + do_test_with_invalid_flags (); + do_test_without_offset (); + + return do_test_with_offset (0); +} diff --git a/misc/tst-preadvwritev64.c b/misc/tst-preadvwritev64.c new file mode 100644 index 0000000000..b718da6be5 --- /dev/null +++ b/misc/tst-preadvwritev64.c @@ -0,0 +1,51 @@ +/* Tests for pread64 and pwrite64. + Copyright (C) 2016-2018 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, see + <http://www.gnu.org/licenses/>. */ + +#define _FILE_OFFSET_BITS 64 +#include "tst-preadvwritev-common.c" + +static int +do_test (void) +{ + int ret; + + ret = do_test_with_offset (0); + + /* Create a sparse file larger than 4GB to check if offset is handled + correctly in p{write,read}v64. */ + off_t base_offset = UINT32_MAX + 2048LL; + ret += do_test_with_offset (base_offset); + + struct stat st; + if (fstat (temp_fd, &st) == -1) + { + printf ("error: fstat on temporary file failed: %m"); + return 1; + } + + /* The total size should base_offset plus 2 * 96. */ + off_t expected_value = base_offset + (2 * (96LL)); + if (st.st_size != expected_value) + { + printf ("error: file size different than expected (%jd != %jd)\n", + (intmax_t) expected_value, (intmax_t) st.st_size); + return 1; + } + + return ret; +} diff --git a/misc/tst-preadvwritev64v2.c b/misc/tst-preadvwritev64v2.c new file mode 100644 index 0000000000..8d3cc32b28 --- /dev/null +++ b/misc/tst-preadvwritev64v2.c @@ -0,0 +1,37 @@ +/* Tests for preadv2 and pwritev2 (LFS version). + Copyright (C) 2017-2018 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, see + <http://www.gnu.org/licenses/>. */ + +#define _FILE_OFFSET_BITS 64 + +#define PREADV(__fd, __iov, __iovcnt, __offset) \ + preadv2 (__fd, __iov, __iovcnt, __offset, 0) + +#define PWRITEV(__fd, __iov, __iovcnt, __offset) \ + pwritev2 (__fd, __iov, __iovcnt, __offset, 0) + +#include "tst-preadvwritev-common.c" +#include "tst-preadvwritev2-common.c" + +static int +do_test (void) +{ + do_test_with_invalid_flags (); + do_test_without_offset (); + + return do_test_with_offset (0); +} diff --git a/misc/tst-pselect.c b/misc/tst-pselect.c index 0d11a809a0..fc28d64238 100644 --- a/misc/tst-pselect.c +++ b/misc/tst-pselect.c @@ -1,3 +1,20 @@ +/* Copyright (C) 2006-2018 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, see + <http://www.gnu.org/licenses/>. */ + #include <errno.h> #include <signal.h> #include <stdio.h> diff --git a/misc/tst-tsearch.c b/misc/tst-tsearch.c index 01912460eb..7d164f9a0a 100644 --- a/misc/tst-tsearch.c +++ b/misc/tst-tsearch.c @@ -1,5 +1,5 @@ /* Test program for tsearch et al. - Copyright (C) 1997-2016 Free Software Foundation, Inc. + Copyright (C) 1997-2018 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 @@ -351,6 +351,5 @@ do_test (void) return total_error; } -#define TIMEOUT 10 #define TEST_FUNCTION do_test () #include "../test-skeleton.c" diff --git a/misc/ttyslot.c b/misc/ttyslot.c index 0ed14d73ea..2f3c7953d7 100644 --- a/misc/ttyslot.c +++ b/misc/ttyslot.c @@ -56,7 +56,7 @@ ttyslot (void) __setttyent(); for (cnt = 0; cnt < 3; ++cnt) if (__ttyname_r (cnt, name, buflen) == 0) { - if ((p = rindex(name, '/'))) + if ((p = strrchr (name, '/'))) ++p; else p = name; diff --git a/misc/ualarm.c b/misc/ualarm.c index 510198a56a..7974076367 100644 --- a/misc/ualarm.c +++ b/misc/ualarm.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/usleep.c b/misc/usleep.c index 2e61362526..7903cbe8ba 100644 --- a/misc/usleep.c +++ b/misc/usleep.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/ustat.c b/misc/ustat.c index c460ef183f..2c40e2a3cb 100644 --- a/misc/ustat.c +++ b/misc/ustat.c @@ -1,5 +1,5 @@ /* Return info on filesystem. - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2018 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 @@ -16,14 +16,28 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -#include <unistd.h> -#include <errno.h> -#include <sys/ustat.h> +#include <shlib-compat.h> + +/* This deprecated syscall is no longer used (replaced with {f}statfs). */ +#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_28) + +# include <unistd.h> +# include <errno.h> + +struct ustat + { + __daddr_t f_tfree; /* Number of free blocks. */ + __ino_t f_tinode; /* Number of free inodes. */ + char f_fname[6]; + char f_fpack[6]; +}; int -ustat (dev_t dev, struct ustat *ust) +__old_ustat (dev_t dev, struct ustat *ust) { __set_errno (ENOSYS); return -1; } stub_warning (ustat) +compat_symbol (libc, __old_ustat, ustat, GLIBC_2_0); +#endif diff --git a/misc/ustat.h b/misc/ustat.h deleted file mode 100644 index cba150e446..0000000000 --- a/misc/ustat.h +++ /dev/null @@ -1 +0,0 @@ -#include <sys/ustat.h> diff --git a/misc/utimes.c b/misc/utimes.c index 62acd2cb96..0ae6946142 100644 --- a/misc/utimes.c +++ b/misc/utimes.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* utimes -- Change access and modification times of file. Stub version. + Copyright (C) 1991-2018 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 diff --git a/misc/vhangup.c b/misc/vhangup.c index e0ed8ed9be..4a31aa6f26 100644 --- a/misc/vhangup.c +++ b/misc/vhangup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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 diff --git a/misc/writev.c b/misc/writev.c index 3531d617e8..92f93889f8 100644 --- a/misc/writev.c +++ b/misc/writev.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2016 Free Software Foundation, Inc. +/* Copyright (C) 1991-2018 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,7 @@ __writev (int fd, const struct iovec *vector, int count) __set_errno (ENOSYS); return -1; } +libc_hidden_def (__writev) weak_alias (__writev, writev) stub_warning (writev) |