diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-08-20 19:50:45 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-08-20 19:50:45 +0200 |
commit | 4dd9e35bfd35d3138bc44169baba098005bad51e (patch) | |
tree | a4939c43a9c3fe00eb27f023e14acc5e1fe8808c /include | |
parent | bd42a4599d1b6f77bcfe1e4f67b7cbd9e1cb2dfd (diff) | |
parent | f76453c31593957fec1a99b986bfa5506618b79c (diff) |
Merge commit 'refs/top-bases/t/bigmem' into t/bigmem
Diffstat (limited to 'include')
58 files changed, 925 insertions, 317 deletions
diff --git a/include/alloca.h b/include/alloca.h index f741d25d54..01500259b8 100644 --- a/include/alloca.h +++ b/include/alloca.h @@ -28,7 +28,7 @@ libc_hidden_proto (__libc_alloca_cutoff) # define extend_alloca(buf, len, newlen) \ (__typeof (buf)) ({ size_t __newlen = stackinfo_alloca_round (newlen); \ char *__newbuf = __alloca (__newlen); \ - if (__newbuf + __newlen == (char *) buf) \ + if (__newbuf + __newlen == (char *) (buf)) \ len += __newlen; \ else \ len = __newlen; \ @@ -37,7 +37,7 @@ libc_hidden_proto (__libc_alloca_cutoff) # define extend_alloca(buf, len, newlen) \ (__typeof (buf)) ({ size_t __newlen = stackinfo_alloca_round (newlen); \ char *__newbuf = __alloca (__newlen); \ - char *__buf = (buf); \ + char *__buf = (char *) (buf); \ if (__buf + len == __newbuf) \ { \ len += __newlen; \ diff --git a/include/arpa/inet.h b/include/arpa/inet.h index 63ece7029a..c3f28f2baa 100644 --- a/include/arpa/inet.h +++ b/include/arpa/inet.h @@ -7,6 +7,9 @@ libc_hidden_proto (__inet_aton) libc_hidden_proto (inet_aton) libc_hidden_proto (inet_ntop) libc_hidden_proto (inet_pton) -libc_hidden_proto (inet_makeaddr) +extern __typeof (inet_pton) __inet_pton; +libc_hidden_proto (__inet_pton) +extern __typeof (inet_makeaddr) __inet_makeaddr; +libc_hidden_proto (__inet_makeaddr) libc_hidden_proto (inet_netof) #endif diff --git a/include/assert.h b/include/assert.h index d0d9259ab3..c452667956 100644 --- a/include/assert.h +++ b/include/assert.h @@ -20,7 +20,7 @@ extern void __assert_fail_base (const char *fmt, const char *assertion, const char *function) __THROW __attribute__ ((__noreturn__)); -# if !defined NOT_IN_libc || defined IS_IN_rtld +# if IS_IN (libc) || IS_IN (rtld) hidden_proto (__assert_fail) hidden_proto (__assert_perror_fail) # endif diff --git a/include/atomic.h b/include/atomic.h index 5a5319a582..221bea0ad3 100644 --- a/include/atomic.h +++ b/include/atomic.h @@ -1,5 +1,5 @@ /* Internal macros for atomic operations for GNU C Library. - Copyright (C) 2002-2014 Free Software Foundation, Inc. + Copyright (C) 2002-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -375,7 +375,7 @@ do \ { \ __atg11_oldval = *__atg11_memp; \ - if (__builtin_expect (__atg11_oldval <= 0, 0)) \ + if (__glibc_unlikely (__atg11_oldval <= 0)) \ break; \ } \ while (__builtin_expect \ @@ -542,9 +542,222 @@ ({ __typeof (x) __x; __asm ("" : "=r" (__x) : "0" (x)); __x; }) #endif +/* This is equal to 1 iff the architecture supports 64b atomic operations. */ +#ifndef __HAVE_64B_ATOMICS +#error Unable to determine if 64-bit atomics are present. +#endif + +/* The following functions are a subset of the atomic operations provided by + C11. Usually, a function named atomic_OP_MO(args) is equivalent to C11's + atomic_OP_explicit(args, memory_order_MO); exceptions noted below. */ + +/* Each arch can request to use compiler built-ins for C11 atomics. If it + does, all atomics will be based on these. */ +#if USE_ATOMIC_COMPILER_BUILTINS + +/* We require 32b atomic operations; some archs also support 64b atomic + operations. */ +void __atomic_link_error (void); +# if __HAVE_64B_ATOMICS == 1 +# define __atomic_check_size(mem) \ + if ((sizeof (*mem) != 4) && (sizeof (*mem) != 8)) \ + __atomic_link_error (); +# else +# define __atomic_check_size(mem) \ + if (sizeof (*mem) != 4) \ + __atomic_link_error (); +# endif + +# define atomic_thread_fence_acquire() \ + __atomic_thread_fence (__ATOMIC_ACQUIRE) +# define atomic_thread_fence_release() \ + __atomic_thread_fence (__ATOMIC_RELEASE) +# define atomic_thread_fence_seq_cst() \ + __atomic_thread_fence (__ATOMIC_SEQ_CST) + +# define atomic_load_relaxed(mem) \ + ({ __atomic_check_size((mem)); __atomic_load_n ((mem), __ATOMIC_RELAXED); }) +# define atomic_load_acquire(mem) \ + ({ __atomic_check_size((mem)); __atomic_load_n ((mem), __ATOMIC_ACQUIRE); }) + +# define atomic_store_relaxed(mem, val) \ + do { \ + __atomic_check_size((mem)); \ + __atomic_store_n ((mem), (val), __ATOMIC_RELAXED); \ + } while (0) +# define atomic_store_release(mem, val) \ + do { \ + __atomic_check_size((mem)); \ + __atomic_store_n ((mem), (val), __ATOMIC_RELEASE); \ + } while (0) + +/* On failure, this CAS has memory_order_relaxed semantics. */ +# define atomic_compare_exchange_weak_relaxed(mem, expected, desired) \ + ({ __atomic_check_size((mem)); \ + __atomic_compare_exchange_n ((mem), (expected), (desired), 1, \ + __ATOMIC_RELAXED, __ATOMIC_RELAXED); }) +# define atomic_compare_exchange_weak_acquire(mem, expected, desired) \ + ({ __atomic_check_size((mem)); \ + __atomic_compare_exchange_n ((mem), (expected), (desired), 1, \ + __ATOMIC_ACQUIRE, __ATOMIC_RELAXED); }) +# define atomic_compare_exchange_weak_release(mem, expected, desired) \ + ({ __atomic_check_size((mem)); \ + __atomic_compare_exchange_n ((mem), (expected), (desired), 1, \ + __ATOMIC_RELEASE, __ATOMIC_RELAXED); }) + +# define atomic_exchange_acquire(mem, desired) \ + ({ __atomic_check_size((mem)); \ + __atomic_exchange_n ((mem), (desired), __ATOMIC_ACQUIRE); }) +# define atomic_exchange_release(mem, desired) \ + ({ __atomic_check_size((mem)); \ + __atomic_exchange_n ((mem), (desired), __ATOMIC_RELEASE); }) + +# define atomic_fetch_add_relaxed(mem, operand) \ + ({ __atomic_check_size((mem)); \ + __atomic_fetch_add ((mem), (operand), __ATOMIC_RELAXED); }) +# define atomic_fetch_add_acquire(mem, operand) \ + ({ __atomic_check_size((mem)); \ + __atomic_fetch_add ((mem), (operand), __ATOMIC_ACQUIRE); }) +# define atomic_fetch_add_release(mem, operand) \ + ({ __atomic_check_size((mem)); \ + __atomic_fetch_add ((mem), (operand), __ATOMIC_RELEASE); }) +# define atomic_fetch_add_acq_rel(mem, operand) \ + ({ __atomic_check_size((mem)); \ + __atomic_fetch_add ((mem), (operand), __ATOMIC_ACQ_REL); }) + +# define atomic_fetch_and_acquire(mem, operand) \ + ({ __atomic_check_size((mem)); \ + __atomic_fetch_and ((mem), (operand), __ATOMIC_ACQUIRE); }) + +# define atomic_fetch_or_relaxed(mem, operand) \ + ({ __atomic_check_size((mem)); \ + __atomic_fetch_or ((mem), (operand), __ATOMIC_RELAXED); }) +# define atomic_fetch_or_acquire(mem, operand) \ + ({ __atomic_check_size((mem)); \ + __atomic_fetch_or ((mem), (operand), __ATOMIC_ACQUIRE); }) + +#else /* !USE_ATOMIC_COMPILER_BUILTINS */ + +/* By default, we assume that read, write, and full barriers are equivalent + to acquire, release, and seq_cst barriers. Archs for which this does not + hold have to provide custom definitions of the fences. */ +# ifndef atomic_thread_fence_acquire +# define atomic_thread_fence_acquire() atomic_read_barrier () +# endif +# ifndef atomic_thread_fence_release +# define atomic_thread_fence_release() atomic_write_barrier () +# endif +# ifndef atomic_thread_fence_seq_cst +# define atomic_thread_fence_seq_cst() atomic_full_barrier () +# endif + +# ifndef atomic_load_relaxed +# define atomic_load_relaxed(mem) \ + ({ __typeof (*(mem)) __atg100_val; \ + __asm ("" : "=r" (__atg100_val) : "0" (*(mem))); \ + __atg100_val; }) +# endif +# ifndef atomic_load_acquire +# define atomic_load_acquire(mem) \ + ({ __typeof (*(mem)) __atg101_val = atomic_load_relaxed (mem); \ + atomic_thread_fence_acquire (); \ + __atg101_val; }) +# endif + +# ifndef atomic_store_relaxed +/* XXX Use inline asm here? */ +# define atomic_store_relaxed(mem, val) do { *(mem) = (val); } while (0) +# endif +# ifndef atomic_store_release +# define atomic_store_release(mem, val) \ + do { \ + atomic_thread_fence_release (); \ + atomic_store_relaxed ((mem), (val)); \ + } while (0) +# endif + +/* On failure, this CAS has memory_order_relaxed semantics. */ +/* XXX This potentially has one branch more than necessary, but archs + currently do not define a CAS that returns both the previous value and + the success flag. */ +# ifndef atomic_compare_exchange_weak_acquire +# define atomic_compare_exchange_weak_acquire(mem, expected, desired) \ + ({ typeof (*(expected)) __atg102_expected = *(expected); \ + *(expected) = \ + atomic_compare_and_exchange_val_acq ((mem), (desired), *(expected)); \ + *(expected) == __atg102_expected; }) +# endif +# ifndef atomic_compare_exchange_weak_relaxed +/* XXX Fall back to CAS with acquire MO because archs do not define a weaker + CAS. */ +# define atomic_compare_exchange_weak_relaxed(mem, expected, desired) \ + atomic_compare_exchange_weak_acquire ((mem), (expected), (desired)) +# endif +# ifndef atomic_compare_exchange_weak_release +# define atomic_compare_exchange_weak_release(mem, expected, desired) \ + ({ typeof (*(expected)) __atg103_expected = *(expected); \ + *(expected) = \ + atomic_compare_and_exchange_val_rel ((mem), (desired), *(expected)); \ + *(expected) == __atg103_expected; }) +# endif + +# ifndef atomic_exchange_acquire +# define atomic_exchange_acquire(mem, val) \ + atomic_exchange_acq ((mem), (val)) +# endif +# ifndef atomic_exchange_release +# define atomic_exchange_release(mem, val) \ + atomic_exchange_rel ((mem), (val)) +# endif + +# ifndef atomic_fetch_add_acquire +# define atomic_fetch_add_acquire(mem, operand) \ + atomic_exchange_and_add_acq ((mem), (operand)) +# endif +# ifndef atomic_fetch_add_relaxed +/* XXX Fall back to acquire MO because the MO semantics of + atomic_exchange_and_add are not documented; the generic version falls back + to atomic_exchange_and_add_acq if atomic_exchange_and_add is not defined, + and vice versa. */ +# define atomic_fetch_add_relaxed(mem, operand) \ + atomic_fetch_add_acquire ((mem), (operand)) +# endif +# ifndef atomic_fetch_add_release +# define atomic_fetch_add_release(mem, operand) \ + atomic_exchange_and_add_rel ((mem), (operand)) +# endif +# ifndef atomic_fetch_add_acq_rel +# define atomic_fetch_add_acq_rel(mem, operand) \ + ({ atomic_thread_fence_release (); \ + atomic_exchange_and_add_acq ((mem), (operand)); }) +# endif + +/* XXX The default for atomic_and_val has acquire semantics, but this is not + documented. */ +# ifndef atomic_fetch_and_acquire +# define atomic_fetch_and_acquire(mem, operand) \ + atomic_and_val ((mem), (operand)) +# endif + +/* XXX The default for atomic_or_val has acquire semantics, but this is not + documented. */ +# ifndef atomic_fetch_or_acquire +# define atomic_fetch_or_acquire(mem, operand) \ + atomic_or_val ((mem), (operand)) +# endif +/* XXX Fall back to acquire MO because archs do not define a weaker + atomic_or_val. */ +# ifndef atomic_fetch_or_relaxed +# define atomic_fetch_or_relaxed(mem, operand) \ + atomic_fetch_or_acquire ((mem), (operand)) +# endif + +#endif /* !USE_ATOMIC_COMPILER_BUILTINS */ -#ifndef atomic_delay -# define atomic_delay() do { /* nothing */ } while (0) +/* This operation does not affect synchronization semantics but can be used + in the body of a spin loop to potentially improve its efficiency. */ +#ifndef atomic_spin_nop +# define atomic_spin_nop() do { /* nothing */ } while (0) #endif #endif /* atomic.h */ diff --git a/include/bits/ipc.h b/include/bits/ipc.h deleted file mode 100644 index 481fe91a8e..0000000000 --- a/include/bits/ipc.h +++ /dev/null @@ -1,23 +0,0 @@ -#include_next <bits/ipc.h> - -__BEGIN_DECLS - -/* The actual system call: all functions are multiplexed by this. */ -extern int __syscall_ipc (int __call, int __first, int __second, - int __third, void *__ptr); - -__END_DECLS - - -/* The codes for the functions to use the multiplexer `__syscall_ipc'. */ -#define IPCOP_semop 1 -#define IPCOP_semget 2 -#define IPCOP_semctl 3 -#define IPCOP_msgsnd 11 -#define IPCOP_msgrcv 12 -#define IPCOP_msgget 13 -#define IPCOP_msgctl 14 -#define IPCOP_shmat 21 -#define IPCOP_shmdt 22 -#define IPCOP_shmget 23 -#define IPCOP_shmctl 24 diff --git a/include/bits/stdlib-float.h b/include/bits/stdlib-float.h index d3f5c5b927..54ab571981 100644 --- a/include/bits/stdlib-float.h +++ b/include/bits/stdlib-float.h @@ -1,4 +1,8 @@ -/* No floating-point inline functions in rtld. */ -#ifndef IS_IN_rtld +/* No floating-point inline functions in rtld and for the conform tests. */ +#ifdef _ISOMAC # include <stdlib/bits/stdlib-float.h> +#else +# if !IS_IN (rtld) +# include <stdlib/bits/stdlib-float.h> +# endif #endif diff --git a/include/bits/xopen_lim.h b/include/bits/xopen_lim.h index 63fd1d8bb9..10918f48d2 100644 --- a/include/bits/xopen_lim.h +++ b/include/bits/xopen_lim.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2014 Free Software Foundation, Inc. +/* Copyright (C) 1996-2015 Free Software 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/include/caller.h b/include/caller.h index 7145fae56b..ed8cac823d 100644 --- a/include/caller.h +++ b/include/caller.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2014 Free Software Foundation, Inc. +/* Copyright (C) 2004-2015 Free Software 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/include/cpio.h b/include/cpio.h new file mode 100644 index 0000000000..38e2ed1b62 --- /dev/null +++ b/include/cpio.h @@ -0,0 +1 @@ +#include <posix/cpio.h> diff --git a/include/ctype.h b/include/ctype.h index 6a18039e3f..f3157b9e7d 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -1,13 +1,17 @@ #ifndef _CTYPE_H +#include <ctype/ctype.h> + #ifndef _ISOMAC /* Initialize ctype locale data. */ extern void __ctype_init (void); libc_hidden_proto (__ctype_init) -extern int __isctype (int __c, int __mask); +/* ctype/ctype.h defined this as a macro and we don't want to #undef it. + So defeat macro expansion with parens for this declaration. */ +extern int (__isctype) (int __c, int __mask); -# ifndef NOT_IN_libc +# if IS_IN (libc) /* These accessors are used by the optimized macros to find the thread-local cache of ctype information from the current thread's @@ -46,22 +50,18 @@ __ctype_tolower_loc (void) return __libc_tsd_address (const int32_t *, CTYPE_TOLOWER); } -# endif /* Not NOT_IN_libc. */ -#endif - -#include <ctype/ctype.h> - -#ifndef _ISOMAC -# if !defined __NO_CTYPE && !defined NOT_IN_libc +# ifndef __NO_CTYPE /* The spec says that isdigit must only match the decimal digits. We can check this without a memory access. */ -# undef isdigit -# define isdigit(c) ({ int __c = (c); __c >= '0' && __c <= '9'; }) -# undef isdigit_l -# define isdigit_l(c, l) ({ int __c = (c); __c >= '0' && __c <= '9'; }) -# undef __isdigit_l -# define __isdigit_l(c, l) ({ int __c = (c); __c >= '0' && __c <= '9'; }) -# endif -#endif +# undef isdigit +# define isdigit(c) ({ int __c = (c); __c >= '0' && __c <= '9'; }) +# undef isdigit_l +# define isdigit_l(c, l) ({ int __c = (c); __c >= '0' && __c <= '9'; }) +# undef __isdigit_l +# define __isdigit_l(c, l) ({ int __c = (c); __c >= '0' && __c <= '9'; }) +# endif /* Not __NO_CTYPE. */ + +# endif /* IS_IN (libc). */ +#endif /* Not _ISOMAC. */ #endif /* ctype.h */ diff --git a/include/dirent.h b/include/dirent.h index 096a9771a1..258f2d0791 100644 --- a/include/dirent.h +++ b/include/dirent.h @@ -46,10 +46,33 @@ extern int __versionsort64 (const struct dirent64 **a, extern DIR *__alloc_dir (int fd, bool close_fd, int flags, const struct stat64 *statp) internal_function; -extern void __scandir_cancel_handler (void *arg); +extern __typeof (rewinddir) __rewinddir; -libc_hidden_proto (rewinddir) -libc_hidden_proto (scandirat) +extern void __scandir_cancel_handler (void *arg) attribute_hidden; +extern int __scandir_tail (DIR *dp, + struct dirent ***namelist, + int (*select) (const struct dirent *), + int (*cmp) (const struct dirent **, + const struct dirent **)) + internal_function attribute_hidden; +# ifdef _DIRENT_MATCHES_DIRENT64 +# define __scandir64_tail (dp, namelist, select, cmp) \ + __scandir_tail (dp, (struct dirent ***) (namelist), \ + (int (*) (const struct dirent *)) (select), \ + (int (*) (const struct dirent **, \ + const struct dirent **)) (cmp)) +# else +extern int __scandir64_tail (DIR *dp, + struct dirent64 ***namelist, + int (*select) (const struct dirent64 *), + int (*cmp) (const struct dirent64 **, + const struct dirent64 **)) + internal_function attribute_hidden; +# endif + +libc_hidden_proto (__rewinddir) +extern __typeof (scandirat) __scandirat; +libc_hidden_proto (__scandirat) libc_hidden_proto (scandirat64) # endif diff --git a/include/dlfcn.h b/include/dlfcn.h index a67b2e3251..0ce0af5276 100644 --- a/include/dlfcn.h +++ b/include/dlfcn.h @@ -54,7 +54,8 @@ struct link_map; extern void _dl_close (void *map) attribute_hidden; /* Same as above, but without locking and safety checks for user provided map arguments. */ -extern void _dl_close_worker (struct link_map *map) attribute_hidden; +extern void _dl_close_worker (struct link_map *map, bool force) + attribute_hidden; /* Look up NAME in shared object HANDLE (which may be RTLD_DEFAULT or RTLD_NEXT). WHO is the calling function, for RTLD_NEXT. Returns diff --git a/include/errno.h b/include/errno.h index f1b93a881b..7df41dfc31 100644 --- a/include/errno.h +++ b/include/errno.h @@ -4,8 +4,13 @@ #if defined _ERRNO_H && !defined _ISOMAC && !defined __cplusplus -# ifdef IS_IN_rtld +# if IS_IN (rtld) # include <dl-sysdep.h> +# ifndef RTLD_PRIVATE_ERRNO +# error "dl-sysdep.h must define RTLD_PRIVATE_ERRNO!" +# endif +# else +# define RTLD_PRIVATE_ERRNO 0 # endif # if RTLD_PRIVATE_ERRNO @@ -17,19 +22,19 @@ # define errno rtld_errno extern int rtld_errno attribute_hidden; -# elif !defined NOT_IN_libc || defined IN_LIB +# elif IS_IN_LIB # include <tls.h> # undef errno -# ifndef NOT_IN_libc +# if IS_IN (libc) # define errno __libc_errno # else # define errno errno /* For #ifndef errno tests. */ # endif extern __thread int errno attribute_tls_model_ie; -# endif /* !NOT_IN_libc || IN_LIB */ +# endif /* IS_IN_LIB */ # define __set_errno(val) (errno = (val)) diff --git a/include/fcntl.h b/include/fcntl.h index b645ffc000..de2372883c 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -8,7 +8,6 @@ libc_hidden_proto (__open64) extern int __libc_open64 (const char *file, int oflag, ...); extern int __libc_open (const char *file, int oflag, ...); libc_hidden_proto (__libc_open) -extern int __libc_creat (const char *file, mode_t mode); extern int __libc_fcntl (int fd, int cmd, ...); #ifndef NO_CANCELLATION extern int __fcntl_nocancel (int fd, int cmd, ...) attribute_hidden; @@ -31,14 +30,6 @@ extern int __openat_2 (int __fd, const char *__path, int __oflag); extern int __openat64_2 (int __fd, const char *__path, int __oflag); -/* Helper functions for the various *at functions. For Linux. */ -extern void __atfct_seterrno (int errval, int fd, const char *buf) - attribute_hidden; -extern void __atfct_seterrno_2 (int errval, int fd1, const char *buf1, - int fd2, const char *buf2) - attribute_hidden; - - /* Flag determining whether the *at system calls are available. */ extern int __have_atfcts attribute_hidden; diff --git a/include/features.h b/include/features.h index 21173a28c3..bb8061073e 100644 --- a/include/features.h +++ b/include/features.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2014 Free Software Foundation, Inc. +/* Copyright (C) 1991-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -37,8 +37,6 @@ _LARGEFILE_SOURCE Some more functions for correct standard I/O. _LARGEFILE64_SOURCE Additional functionality from LFS for large files. _FILE_OFFSET_BITS=N Select default filesystem interface. - _BSD_SOURCE ISO C, POSIX, and 4.3BSD things. - _SVID_SOURCE ISO C, POSIX, and SVID things. _ATFILE_SOURCE Additional *at interfaces. _GNU_SOURCE All of the above, plus GNU extensions. _DEFAULT_SOURCE The default set of features (taking precedence over @@ -51,11 +49,11 @@ The `-ansi' switch to the GNU C compiler, and standards conformance options such as `-std=c99', define __STRICT_ANSI__. If none of these are defined, or if _DEFAULT_SOURCE is defined, the default is - to have _SVID_SOURCE, _BSD_SOURCE, and _POSIX_SOURCE set to one and - _POSIX_C_SOURCE set to 200809L. If more than one of these are - defined, they accumulate. For example __STRICT_ANSI__, - _POSIX_SOURCE and _POSIX_C_SOURCE together give you ISO C, 1003.1, - and 1003.2, but nothing else. + to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to + 200809L, as well as enabling miscellaneous functions from BSD and + SVID. If more than one of these are defined, they accumulate. For + example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together + give you ISO C, 1003.1, and 1003.2, but nothing else. These are defined by this file and are used by the header files to decide what to declare or define: @@ -77,9 +75,7 @@ __USE_LARGEFILE Define correct standard I/O things. __USE_LARGEFILE64 Define LFS things with separate names. __USE_FILE_OFFSET64 Define 64bit interface as default. - __USE_BSD Define 4.3BSD things. - __USE_SVID Define SVID things. - __USE_MISC Define things common to BSD and System V Unix. + __USE_MISC Define things from 4.3BSD or System V Unix. __USE_ATFILE Define *at interfaces and AT_* constants for them. __USE_GNU Define GNU extensions. __USE_REENTRANT Define reentrant/thread-safe *_r functions. @@ -116,8 +112,6 @@ #undef __USE_LARGEFILE #undef __USE_LARGEFILE64 #undef __USE_FILE_OFFSET64 -#undef __USE_BSD -#undef __USE_SVID #undef __USE_MISC #undef __USE_ATFILE #undef __USE_GNU @@ -145,6 +139,16 @@ # define __GNUC_PREREQ(maj, min) 0 #endif +/* _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for + _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not + issue a warning; the expectation is that the source is being + transitioned to use the new macro. */ +#if (defined _BSD_SOURCE || defined _SVID_SOURCE) \ + && !defined _DEFAULT_SOURCE +# warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" +# undef _DEFAULT_SOURCE +# define _DEFAULT_SOURCE 1 +#endif /* If _GNU_SOURCE was defined by the user, turn on all the other features. */ #ifdef _GNU_SOURCE @@ -166,28 +170,19 @@ # define _LARGEFILE64_SOURCE 1 # undef _DEFAULT_SOURCE # define _DEFAULT_SOURCE 1 -# undef _BSD_SOURCE -# define _BSD_SOURCE 1 -# undef _SVID_SOURCE -# define _SVID_SOURCE 1 # undef _ATFILE_SOURCE # define _ATFILE_SOURCE 1 #endif /* If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, - define _DEFAULT_SOURCE, _BSD_SOURCE and _SVID_SOURCE. */ + define _DEFAULT_SOURCE. */ #if (defined _DEFAULT_SOURCE \ || (!defined __STRICT_ANSI__ \ && !defined _ISOC99_SOURCE \ && !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE \ - && !defined _XOPEN_SOURCE \ - && !defined _BSD_SOURCE && !defined _SVID_SOURCE)) + && !defined _XOPEN_SOURCE)) # undef _DEFAULT_SOURCE # define _DEFAULT_SOURCE 1 -# undef _BSD_SOURCE -# define _BSD_SOURCE 1 -# undef _SVID_SOURCE -# define _SVID_SOURCE 1 #endif /* This is to enable the ISO C11 extension. */ @@ -312,18 +307,10 @@ # define __USE_FILE_OFFSET64 1 #endif -#if defined _BSD_SOURCE || defined _SVID_SOURCE +#if defined _DEFAULT_SOURCE # define __USE_MISC 1 #endif -#ifdef _BSD_SOURCE -# define __USE_BSD 1 -#endif - -#ifdef _SVID_SOURCE -# define __USE_SVID 1 -#endif - #ifdef _ATFILE_SOURCE # define __USE_ATFILE 1 #endif @@ -367,7 +354,7 @@ /* Major and minor version number of the GNU C library package. Use these macros to test for features in specific releases. */ #define __GLIBC__ 2 -#define __GLIBC_MINOR__ 19 +#define __GLIBC_MINOR__ 22 #define __GLIBC_PREREQ(maj, min) \ ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min)) diff --git a/include/fenv.h b/include/fenv.h index bd2c99db96..7070199ece 100644 --- a/include/fenv.h +++ b/include/fenv.h @@ -13,14 +13,24 @@ extern int __fesetexceptflag (const fexcept_t *__flagp, int __excepts); extern int __fegetenv (fenv_t *__envp); extern int __fesetenv (const fenv_t *__envp); extern int __feupdateenv (const fenv_t *__envp); +extern __typeof (fegetround) __fegetround; +extern __typeof (feholdexcept) __feholdexcept; +extern __typeof (fesetround) __fesetround; libm_hidden_proto (feraiseexcept) +libm_hidden_proto (__feraiseexcept) libm_hidden_proto (fegetenv) +libm_hidden_proto (__fegetenv) libm_hidden_proto (fegetround) +libm_hidden_proto (__fegetround) libm_hidden_proto (fesetenv) +libm_hidden_proto (__fesetenv) libm_hidden_proto (fesetround) +libm_hidden_proto (__fesetround) libm_hidden_proto (feholdexcept) +libm_hidden_proto (__feholdexcept) libm_hidden_proto (feupdateenv) +libm_hidden_proto (__feupdateenv) libm_hidden_proto (fetestexcept) libm_hidden_proto (feclearexcept) diff --git a/include/fmtmsg.h b/include/fmtmsg.h new file mode 100644 index 0000000000..6ac606df2b --- /dev/null +++ b/include/fmtmsg.h @@ -0,0 +1 @@ +#include <stdlib/fmtmsg.h> diff --git a/include/gnu-versions.h b/include/gnu-versions.h index 6ffbd4716e..f451e3a86e 100644 --- a/include/gnu-versions.h +++ b/include/gnu-versions.h @@ -1,5 +1,5 @@ /* Header with interface version macros for library pieces copied elsewhere. - Copyright (C) 1995-2014 Free Software Foundation, Inc. + Copyright (C) 1995-2015 Free Software 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/include/gnu/libc-version.h b/include/gnu/libc-version.h index b2d32e12e4..55d8e35e22 100644 --- a/include/gnu/libc-version.h +++ b/include/gnu/libc-version.h @@ -1,5 +1,5 @@ /* Interface to GNU libc specific functions for version information. - Copyright (C) 1998-2014 Free Software Foundation, Inc. + Copyright (C) 1998-2015 Free Software 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/include/ifaddrs.h b/include/ifaddrs.h index e1c6cac114..2787f21115 100644 --- a/include/ifaddrs.h +++ b/include/ifaddrs.h @@ -26,7 +26,7 @@ extern void __check_native (uint32_t a1_index, int *a1_native, uint32_t a2_index, int *a2_native) attribute_hidden; -#ifdef IS_IN_nscd +#if IS_IN (nscd) extern uint32_t __bump_nl_timestamp (void) attribute_hidden; #endif diff --git a/include/ifunc-impl-list.h b/include/ifunc-impl-list.h index 149bac9268..93acceae1f 100644 --- a/include/ifunc-impl-list.h +++ b/include/ifunc-impl-list.h @@ -1,5 +1,5 @@ /* Internal header file for __libc_supported_implementations. - Copyright (C) 2012-2014 Free Software Foundation, Inc. + Copyright (C) 2012-2015 Free Software 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/include/inline-hashtab.h b/include/inline-hashtab.h index e84a02bb67..defa0bf107 100644 --- a/include/inline-hashtab.h +++ b/include/inline-hashtab.h @@ -1,5 +1,5 @@ /* Fully-inline hash table, used mainly for managing TLS descriptors. - Copyright (C) 1999-2014 Free Software Foundation, Inc. + Copyright (C) 1999-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Alexandre Oliva <aoliva@redhat.com> diff --git a/include/libc-internal.h b/include/libc-internal.h index 78f82da58a..b37388ecd7 100644 --- a/include/libc-internal.h +++ b/include/libc-internal.h @@ -70,4 +70,50 @@ extern void __init_misc (int, char **, char **); #define PTR_ALIGN_UP(base, size) \ ((__typeof__ (base)) ALIGN_UP ((uintptr_t) (base), (size))) +/* Ignore the value of an expression when a cast to void does not + suffice (in particular, for a call to a function declared with + attribute warn_unused_result). */ +#define ignore_value(x) \ + ({ __typeof__ (x) __ignored_value = (x); (void) __ignored_value; }) + +/* The macros to control diagnostics are structured like this, rather + than a single macro that both pushes and pops diagnostic state and + takes the affected code as an argument, because the GCC pragmas + work by disabling the diagnostic for a range of source locations + and do not work when all the pragmas and the affected code are in a + single macro expansion. */ + +/* Push diagnostic state. */ +#define DIAG_PUSH_NEEDS_COMMENT _Pragma ("GCC diagnostic push") + +/* Pop diagnostic state. */ +#define DIAG_POP_NEEDS_COMMENT _Pragma ("GCC diagnostic pop") + +#define _DIAG_STR1(s) #s +#define _DIAG_STR(s) _DIAG_STR1(s) + +/* Ignore the diagnostic OPTION. VERSION is the most recent GCC + version for which the diagnostic has been confirmed to appear in + the absence of the pragma (in the form MAJOR.MINOR for GCC 4.x, + just MAJOR for GCC 5 and later). Uses of this pragma should be + reviewed when the GCC version given is no longer supported for + building glibc; the version number should always be on the same + source line as the macro name, so such uses can be found with grep. + Uses should come with a comment giving more details of the + diagnostic, and an architecture on which it is seen if possibly + optimization-related and not in architecture-specific code. This + macro should only be used if the diagnostic seems hard to fix (for + example, optimization-related false positives). */ +#define DIAG_IGNORE_NEEDS_COMMENT(version, option) \ + _Pragma (_DIAG_STR (GCC diagnostic ignored option)) + +/* This mirrors the C11 max_align_t type provided by GCC, but it is + also available in C99 mode. The aligned attributes are required + because some ABIs have reduced alignment requirements for struct + and union members. */ +typedef struct { + long long ll __attribute__ ((__aligned__ (__alignof__ (long long)))); + long double ld __attribute__ ((__aligned__ (__alignof__ (long double)))); +} libc_max_align_t; + #endif /* _LIBC_INTERNAL */ diff --git a/include/libc-symbols.h b/include/libc-symbols.h index 4b233be0bd..743b6f6f5b 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -1,6 +1,6 @@ /* Support macros for making weak and strong aliases for symbols, and for using symbol sets and linker warnings with GNU ld. - Copyright (C) 1995-2014 Free Software Foundation, Inc. + Copyright (C) 1995-2015 Free Software 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,6 +20,17 @@ #ifndef _LIBC_SYMBOLS_H #define _LIBC_SYMBOLS_H 1 +#define IN_MODULE PASTE_NAME (MODULE_, MODULE_NAME) +#define IS_IN(lib) (IN_MODULE == MODULE_##lib) + +/* Returns true if the current module is a versioned library. Versioned + library names culled from shlib-versions files are assigned a MODULE_* + value lower than MODULE_LIBS_BEGIN. */ +#define IS_IN_LIB (IN_MODULE > MODULE_LIBS_BEGIN) + +#define PASTE_NAME(a,b) PASTE_NAME1 (a,b) +#define PASTE_NAME1(a,b) a##b + /* This file's macros are included implicitly in the compilation of every file in the C library by -imacros. @@ -48,6 +59,25 @@ #include <config.h> +/* Define this for the benefit of portable GNU code that wants to check it. + Code that checks with #if will not #include <config.h> again, since we've + already done it (and this file is implicitly included in every compile, + via -include). Code that checks with #ifdef will #include <config.h>, + but that file should always be idempotent (i.e., it's just #define/#undef + and nothing else anywhere should be changing the macro state it touches), + so it's harmless. */ +#define HAVE_CONFIG_H 0 + +/* Define these macros for the benefit of portable GNU code that wants to check + them. Of course, STDC_HEADERS is never false when building libc! */ +#define STDC_HEADERS 1 +#define HAVE_MBSTATE_T 1 +#define HAVE_MBSRTOWCS 1 +#define HAVE_LIBINTL_H 1 +#define HAVE_WCTYPE_H 1 +#define HAVE_ISWCTYPE 1 +#define ENABLE_NLS 1 + /* The symbols in all the user (non-_) macros are C symbols. */ #if !defined HAVE_ASM_WEAK_DIRECTIVE && !defined HAVE_ASM_WEAKEXT_DIRECTIVE @@ -66,17 +96,6 @@ # define ASM_LINE_SEP ; #endif -#ifdef HAVE_ASM_GLOBAL_DOT_NAME -# ifndef C_SYMBOL_DOT_NAME -# if defined __GNUC__ && defined __GNUC_MINOR__ \ - && (__GNUC__ << 16) + __GNUC_MINOR__ >= (3 << 16) + 1 -# define C_SYMBOL_DOT_NAME(name) .name -# else -# define C_SYMBOL_DOT_NAME(name) .##name -# endif -# endif -#endif - #ifndef __ASSEMBLER__ /* GCC understands weak symbols and aliases; use its interface where possible, instead of embedded assembly language. */ @@ -112,64 +131,28 @@ #else /* __ASSEMBLER__ */ # ifdef HAVE_ASM_SET_DIRECTIVE -# ifdef HAVE_ASM_GLOBAL_DOT_NAME -# define strong_alias(original, alias) \ - .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP \ - .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original) ASM_LINE_SEP \ - .globl C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \ - .set C_SYMBOL_DOT_NAME (alias),C_SYMBOL_DOT_NAME (original) -# define strong_data_alias(original, alias) \ +# define strong_alias(original, alias) \ .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP \ .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original) -# else -# define strong_alias(original, alias) \ - .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP \ - .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original) -# define strong_data_alias(original, alias) strong_alias(original, alias) -# endif +# define strong_data_alias(original, alias) strong_alias(original, alias) # else -# ifdef HAVE_ASM_GLOBAL_DOT_NAME -# define strong_alias(original, alias) \ - .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP \ - C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \ - .globl C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \ - C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original) -# define strong_data_alias(original, alias) \ +# define strong_alias(original, alias) \ .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP \ C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) -# else -# define strong_alias(original, alias) \ - .globl C_SYMBOL_NAME (alias) ASM_LINE_SEP \ - C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) -# define strong_data_alias(original, alias) strong_alias(original, alias) -# endif +# define strong_data_alias(original, alias) strong_alias(original, alias) # endif # ifdef HAVE_ASM_WEAKEXT_DIRECTIVE -# ifdef HAVE_ASM_GLOBAL_DOT_NAME -# define weak_alias(original, alias) \ - .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original) ASM_LINE_SEP \ - .weakext C_SYMBOL_DOT_NAME (alias), C_SYMBOL_DOT_NAME (original) -# else -# define weak_alias(original, alias) \ +# define weak_alias(original, alias) \ .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original) -# endif # define weak_extern(symbol) \ .weakext C_SYMBOL_NAME (symbol) # else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */ -# ifdef HAVE_ASM_GLOBAL_DOT_NAME -# define weak_alias(original, alias) \ - .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \ - C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \ - .weak C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \ - C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original) -# else -# define weak_alias(original, alias) \ +# define weak_alias(original, alias) \ .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \ C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) -# endif # define weak_extern(symbol) \ .weak C_SYMBOL_NAME (symbol) @@ -328,33 +311,15 @@ for linking") # define default_symbol_version(real, name, version) \ _default_symbol_version(real, name, version) # ifdef __ASSEMBLER__ -# ifdef HAVE_ASM_GLOBAL_DOT_NAME -# define _symbol_version(real, name, version) \ - .symver real, name##@##version ASM_LINE_SEP \ - .symver C_SYMBOL_DOT_NAME(real), C_SYMBOL_DOT_NAME(name##@##version) -# define _default_symbol_version(real, name, version) \ - .symver real, name##@##@##version ASM_LINE_SEP \ - .symver C_SYMBOL_DOT_NAME(real), C_SYMBOL_DOT_NAME(name##@##@##version) -# else -# define _symbol_version(real, name, version) \ +# define _symbol_version(real, name, version) \ .symver real, name##@##version -# define _default_symbol_version(real, name, version) \ +# define _default_symbol_version(real, name, version) \ .symver real, name##@##@##version -# endif # else -# ifdef HAVE_ASM_GLOBAL_DOT_NAME -# define _symbol_version(real, name, version) \ - __asm__ (".symver " #real "," #name "@" #version "\n\t" \ - ".symver ." #real ",." #name "@" #version) -# define _default_symbol_version(real, name, version) \ - __asm__ (".symver " #real "," #name "@@" #version "\n\t" \ - ".symver ." #real ",." #name "@@" #version) -# else -# define _symbol_version(real, name, version) \ +# define _symbol_version(real, name, version) \ __asm__ (".symver " #real "," #name "@" #version) -# define _default_symbol_version(real, name, version) \ +# define _default_symbol_version(real, name, version) \ __asm__ (".symver " #real "," #name "@@" #version) -# endif # endif #else # define symbol_version(real, name, version) @@ -372,26 +337,6 @@ for linking") #define attribute_relro __attribute__ ((section (".data.rel.ro"))) -/* Handling on non-exported internal names. We have to do this only - for shared code. */ -#ifdef SHARED -# define INTUSE(name) name##_internal -# define INTDEF(name) strong_alias (name, name##_internal) -# define INTVARDEF(name) \ - _INTVARDEF (name, name##_internal) -# define _INTVARDEF(name, aliasname) \ - extern __typeof (name) aliasname __attribute__ ((alias (#name), \ - visibility ("hidden"))); -# define INTDEF2(name, newname) strong_alias (name, newname##_internal) -# define INTVARDEF2(name, newname) _INTVARDEF (name, newname##_internal) -#else -# define INTUSE(name) name -# define INTDEF(name) -# define INTVARDEF(name) -# define INTDEF2(name, newname) -# define INTVARDEF2(name, newname) -#endif - /* The following macros are used for PLT bypassing within libc.so (and if needed other libraries similarly). First of all, you need to have the function prototyped somewhere, @@ -449,7 +394,7 @@ for linking") If the function should be internal to multiple objects, say ld.so and libc.so, the best way is to use: - #if !defined NOT_IN_libc || defined IS_IN_rtld + #if IS_IN (libc) || IS_IN (rtld) hidden_proto (foo) #endif @@ -517,11 +462,7 @@ for linking") # define hidden_data_def(name) strong_data_alias (name, __GI_##name) # define hidden_data_weak(name) hidden_data_def (name) # define hidden_data_ver(local, name) strong_data_alias (local, __GI_##name) -# ifdef HAVE_ASM_GLOBAL_DOT_NAME -# define HIDDEN_JUMPTARGET(name) .__GI_##name -# else -# define HIDDEN_JUMPTARGET(name) __GI_##name -# endif +# define HIDDEN_JUMPTARGET(name) __GI_##name # endif #else # ifndef __ASSEMBLER__ @@ -539,7 +480,7 @@ for linking") # define hidden_nolink(name, lib, version) #endif -#if !defined NOT_IN_libc +#if IS_IN (libc) # define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) # define libc_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs) # define libc_hidden_def(name) hidden_def (name) @@ -565,7 +506,7 @@ for linking") # define libc_hidden_data_ver(local, name) #endif -#if defined NOT_IN_libc && defined IS_IN_rtld +#if IS_IN (rtld) # define rtld_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) # define rtld_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs) # define rtld_hidden_def(name) hidden_def (name) @@ -585,7 +526,7 @@ for linking") # define rtld_hidden_data_ver(local, name) #endif -#if defined NOT_IN_libc && defined IS_IN_libm +#if IS_IN (libm) # define libm_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) # define libm_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs) # define libm_hidden_def(name) hidden_def (name) @@ -605,7 +546,27 @@ for linking") # define libm_hidden_data_ver(local, name) #endif -#if defined NOT_IN_libc && defined IS_IN_libresolv +#if IS_IN (libmvec) +# define libmvec_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) +# define libmvec_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs) +# define libmvec_hidden_def(name) hidden_def (name) +# define libmvec_hidden_weak(name) hidden_weak (name) +# define libmvec_hidden_ver(local, name) hidden_ver (local, name) +# define libmvec_hidden_data_def(name) hidden_data_def (name) +# define libmvec_hidden_data_weak(name) hidden_data_weak (name) +# define libmvec_hidden_data_ver(local, name) hidden_data_ver (local, name) +#else +# define libmvec_hidden_proto(name, attrs...) +# define libmvec_hidden_tls_proto(name, attrs...) +# define libmvec_hidden_def(name) +# define libmvec_hidden_weak(name) +# define libmvec_hidden_ver(local, name) +# define libmvec_hidden_data_def(name) +# define libmvec_hidden_data_weak(name) +# define libmvec_hidden_data_ver(local, name) +#endif + +#if IS_IN (libresolv) # define libresolv_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) # define libresolv_hidden_tls_proto(name, attrs...) \ hidden_tls_proto (name, ##attrs) @@ -626,7 +587,7 @@ for linking") # define libresolv_hidden_data_ver(local, name) #endif -#if defined NOT_IN_libc && defined IS_IN_librt +#if IS_IN (librt) # define librt_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) # define librt_hidden_tls_proto(name, attrs...) \ hidden_tls_proto (name, ##attrs) @@ -647,7 +608,7 @@ for linking") # define librt_hidden_data_ver(local, name) #endif -#if defined NOT_IN_libc && defined IS_IN_libdl +#if IS_IN (libdl) # define libdl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) # define libdl_hidden_tls_proto(name, attrs...) \ hidden_tls_proto (name, ##attrs) @@ -668,7 +629,7 @@ for linking") # define libdl_hidden_data_ver(local, name) #endif -#if defined NOT_IN_libc && defined IS_IN_libnss_files +#if IS_IN (libnss_files) # define libnss_files_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) # define libnss_files_hidden_tls_proto(name, attrs...) \ hidden_tls_proto (name, ##attrs) @@ -689,7 +650,7 @@ for linking") # define libnss_files_hidden_data_ver(local, name) #endif -#if defined NOT_IN_libc && defined IS_IN_libnsl +#if IS_IN (libnsl) # define libnsl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) # define libnsl_hidden_tls_proto(name, attrs...) \ hidden_tls_proto (name, ##attrs) @@ -710,7 +671,7 @@ for linking") # define libnsl_hidden_data_ver(local, name) #endif -#if defined NOT_IN_libc && defined IS_IN_libnss_nisplus +#if IS_IN (libnss_nisplus) # define libnss_nisplus_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) # define libnss_nisplus_hidden_tls_proto(name, attrs...) \ hidden_tls_proto (name, ##attrs) @@ -739,7 +700,7 @@ for linking") # define HIDDEN_BUILTIN_JUMPTARGET(name) HIDDEN_JUMPTARGET(name) #endif -#if defined NOT_IN_libc && defined IS_IN_libutil +#if IS_IN (libutil) # define libutil_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) # define libutil_hidden_tls_proto(name, attrs...) \ hidden_tls_proto (name, ##attrs) diff --git a/include/limits.h b/include/limits.h index 311386a23b..381b798931 100644 --- a/include/limits.h +++ b/include/limits.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2014 Free Software Foundation, Inc. +/* Copyright (C) 1991-2015 Free Software 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/include/link.h b/include/link.h index 670d40157b..7e7eb79f10 100644 --- a/include/link.h +++ b/include/link.h @@ -1,6 +1,6 @@ /* Data structure for communication from the run-time dynamic linker for loaded ELF shared objects. - Copyright (C) 1995-2014 Free Software Foundation, Inc. + Copyright (C) 1995-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -40,6 +40,7 @@ extern unsigned int la_objopen (struct link_map *__map, Lmid_t __lmid, #include <stdint.h> #include <stddef.h> #include <bits/linkmap.h> +#include <dl-fileid.h> #include <dl-lookupcfg.h> #include <tls.h> #include <bits/libc-lock.h> @@ -235,8 +236,7 @@ struct link_map /* This information is kept to check for sure whether a shared object is the same as one already loaded. */ - dev_t l_dev; - ino64_t l_ino; + struct r_file_id l_file_id; /* Collected information about own RUNPATH directories. */ struct r_search_path_struct l_runpath_dirs; @@ -302,7 +302,9 @@ struct link_map /* Index of the module in the dtv array. */ size_t l_tls_modid; - /* Number of thread_local objects constructed by this DSO. */ + /* Number of thread_local objects constructed by this DSO. This is + atomically accessed and modified and is not always protected by the load + lock. See also: CONCURRENCY NOTES in cxa_thread_atexit_impl.c. */ size_t l_tls_dtor_count; /* Information used to change permission after the relocations are diff --git a/include/list.h b/include/list.h new file mode 100644 index 0000000000..7d5d9450fc --- /dev/null +++ b/include/list.h @@ -0,0 +1,117 @@ +/* Copyright (C) 2002-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. + + 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 _LIST_H + +#ifndef __need_list_t +# define _LIST_H 1 +#endif + +/* The definitions of this file are adopted from those which can be + found in the Linux kernel headers to enable people familiar with + the latter find their way in these sources as well. */ + + +#if defined __need_list_t || defined _LIST_H +# ifndef __list_t_defined +# define __list_t_defined +/* Basic type for the double-link list. */ +typedef struct list_head +{ + struct list_head *next; + struct list_head *prev; +} list_t; +# endif +# undef __need_list_t +#endif + +#ifdef _LIST_H + +# include <atomic.h> + +/* Define a variable with the head and tail of the list. */ +# define LIST_HEAD(name) \ + list_t name = { &(name), &(name) } + +/* Initialize a new list head. */ +# define INIT_LIST_HEAD(ptr) \ + (ptr)->next = (ptr)->prev = (ptr) + + +/* Add new element at the head of the list. */ +static inline void +list_add (list_t *newp, list_t *head) +{ + newp->next = head->next; + newp->prev = head; + head->next->prev = newp; + atomic_write_barrier (); + head->next = newp; +} + + +/* Remove element from list. */ +static inline void +list_del (list_t *elem) +{ + elem->next->prev = elem->prev; + elem->prev->next = elem->next; +} + + +/* Join two lists. */ +static inline void +list_splice (list_t *add, list_t *head) +{ + /* Do nothing if the list which gets added is empty. */ + if (add != add->next) + { + add->next->prev = head; + add->prev->next = head->next; + head->next->prev = add->prev; + head->next = add->next; + } +} + + +/* Get typed element from list at a given position. */ +# define list_entry(ptr, type, member) \ + ((type *) ((char *) (ptr) - (unsigned long) (&((type *) 0)->member))) + + + +/* Iterate forward over the elements of the list. */ +# define list_for_each(pos, head) \ + for (pos = (head)->next; pos != (head); pos = pos->next) + + +/* Iterate forward over the elements of the list. */ +# define list_for_each_prev(pos, head) \ + for (pos = (head)->prev; pos != (head); pos = pos->prev) + + +/* Iterate backwards over the elements list. The list elements can be + removed from the list while doing this. */ +# define list_for_each_prev_safe(pos, p, head) \ + for (pos = (head)->prev, p = pos->prev; \ + pos != (head); \ + pos = p, p = pos->prev) + +#endif /* _LIST_H */ + +#endif /* list.h */ diff --git a/include/math.h b/include/math.h index cbbce59501..42bb55eb98 100644 --- a/include/math.h +++ b/include/math.h @@ -6,7 +6,7 @@ /* Now define the internal interfaces. */ extern int __matherr (struct exception *__exc); -# if !defined NOT_IN_libc || defined IS_IN_libm +# if IS_IN (libc) || IS_IN (libm) hidden_proto (__finite) hidden_proto (__isinf) hidden_proto (__isnan) diff --git a/include/mqueue.h b/include/mqueue.h index 1ac4f13445..3c66f1711e 100644 --- a/include/mqueue.h +++ b/include/mqueue.h @@ -1,7 +1,13 @@ #include <rt/mqueue.h> -#ifdef IS_IN_librt +#ifndef _ISOMAC +# if IS_IN (librt) hidden_proto (mq_timedsend) +extern __typeof (mq_timedsend) __mq_timedsend __nonnull ((2, 5)); +hidden_proto (__mq_timedsend) hidden_proto (mq_timedreceive) +extern __typeof (mq_timedreceive) __mq_timedreceive __nonnull ((2, 5)); +hidden_proto (__mq_timedreceive) hidden_proto (mq_setattr) +# endif #endif diff --git a/include/net/if.h b/include/net/if.h index 1d862260c7..6c4cbc96c3 100644 --- a/include/net/if.h +++ b/include/net/if.h @@ -4,9 +4,13 @@ #ifndef _ISOMAC libc_hidden_proto (if_nametoindex) +extern __typeof (if_nametoindex) __if_nametoindex; +libc_hidden_proto (__if_nametoindex) libc_hidden_proto (if_indextoname) libc_hidden_proto (if_nameindex) libc_hidden_proto (if_freenameindex) +extern __typeof (if_freenameindex) __if_freenameindex; +libc_hidden_proto (__if_freenameindex) #endif #endif diff --git a/include/netdb.h b/include/netdb.h index a7960ebdf7..e1f051d16a 100644 --- a/include/netdb.h +++ b/include/netdb.h @@ -4,15 +4,15 @@ #ifndef _ISOMAC /* Macros for accessing h_errno from inside libc. */ -# if !defined NOT_IN_libc || defined IN_LIB +# if IS_IN_LIB # undef h_errno -# ifndef NOT_IN_libc +# if IS_IN (libc) # define h_errno __libc_h_errno # else -# define h_errno h_errno /* For #ifndef h_errno tests. */ +# define h_errno __h_errno # endif extern __thread int h_errno attribute_tls_model_ie; -# endif /* !NOT_IN_libc || IN_LIB */ +# endif /* IS_IN_LIB */ # define __set_h_errno(x) (h_errno = (x)) libc_hidden_proto (hstrerror) diff --git a/include/netinet/in.h b/include/netinet/in.h index 6fb5c86de9..5e377469e7 100644 --- a/include/netinet/in.h +++ b/include/netinet/in.h @@ -5,7 +5,11 @@ #ifndef _ISOMAC libc_hidden_proto (bindresvport) libc_hidden_proto (in6addr_loopback) +extern __typeof (in6addr_loopback) __in6addr_loopback; +libc_hidden_proto (__in6addr_loopback) libc_hidden_proto (in6addr_any) +extern __typeof (in6addr_any) __in6addr_any; +libc_hidden_proto (__in6addr_any) #endif #endif diff --git a/include/programs/xmalloc.h b/include/programs/xmalloc.h index 9ef486fcb9..e792ffed1d 100644 --- a/include/programs/xmalloc.h +++ b/include/programs/xmalloc.h @@ -1,5 +1,5 @@ /* Memory related definitions for program modules. - Copyright (C) 1998-2014 Free Software Foundation, Inc. + Copyright (C) 1998-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. This program is free software; you can redistribute it and/or modify diff --git a/include/pthread.h b/include/pthread.h index 51854f6053..858c869a16 100644 --- a/include/pthread.h +++ b/include/pthread.h @@ -1,6 +1,16 @@ #include_next <pthread.h> #ifndef _ISOMAC +/* Prototypes repeated instead of using __typeof because pthread.h is + included in C++ tests, and declaring functions with __typeof and + __THROW doesn't work for C++. */ +extern int __pthread_barrier_init (pthread_barrier_t *__restrict __barrier, + const pthread_barrierattr_t *__restrict + __attr, unsigned int __count) + __THROW __nonnull ((1)); +extern int __pthread_barrier_wait (pthread_barrier_t *__barrier) + __THROWNL __nonnull ((1)); + /* This function is called to initialize the pthread library. */ extern void __pthread_initialize (void) __attribute__ ((weak)); #endif diff --git a/include/resolv.h b/include/resolv.h index 87b3598330..4c614760a8 100644 --- a/include/resolv.h +++ b/include/resolv.h @@ -13,7 +13,7 @@ #ifdef _RESOLV_H_ -# ifndef NOT_IN_libc +# if IS_IN (libc) # define __resp __libc_resp # endif extern __thread struct __res_state *__resp attribute_tls_model_ie; @@ -48,11 +48,11 @@ libc_hidden_proto (__res_randomid) libc_hidden_proto (__res_state) int __libc_res_nquery (res_state, const char *, int, int, u_char *, int, - u_char **, u_char **, int *, int *); + u_char **, u_char **, int *, int *, int *); int __libc_res_nsearch (res_state, const char *, int, int, u_char *, int, - u_char **, u_char **, int *, int *); + u_char **, u_char **, int *, int *, int *); int __libc_res_nsend (res_state, const u_char *, int, const u_char *, int, - u_char *, int, u_char **, u_char **, int *, int *) + u_char *, int, u_char **, u_char **, int *, int *, int *) attribute_hidden; libresolv_hidden_proto (_sethtent) diff --git a/include/rounding-mode.h b/include/rounding-mode.h index 9a048c7857..18682e6c98 100644 --- a/include/rounding-mode.h +++ b/include/rounding-mode.h @@ -1,5 +1,5 @@ /* Handle floating-point rounding mode within libc. - Copyright (C) 2012-2014 Free Software Foundation, Inc. + Copyright (C) 2012-2015 Free Software 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/include/scratch_buffer.h b/include/scratch_buffer.h new file mode 100644 index 0000000000..6f92694bb8 --- /dev/null +++ b/include/scratch_buffer.h @@ -0,0 +1,137 @@ +/* Variable-sized buffer with on-stack default allocation. + Copyright (C) 2015 Free Software 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 _SCRATCH_BUFFER_H +#define _SCRATCH_BUFFER_H + +/* Scratch buffers with a default stack allocation and fallback to + heap allocation. It is expected that this function is used in this + way: + + struct scratch_buffer tmpbuf; + scratch_buffer_init (&tmpbuf); + + while (!function_that_uses_buffer (tmpbuf.data, tmpbuf.length)) + if (!scratch_buffer_grow (&tmpbuf)) + return -1; + + scratch_buffer_free (&tmpbuf); + return 0; + + The allocation functions (scratch_buffer_grow, + scratch_buffer_grow_preserve, scratch_buffer_set_array_size) make + sure that the heap allocation, if any, is freed, so that the code + above does not have a memory leak. The buffer still remains in a + state that can be deallocated using scratch_buffer_free, so a loop + like this is valid as well: + + struct scratch_buffer tmpbuf; + scratch_buffer_init (&tmpbuf); + + while (!function_that_uses_buffer (tmpbuf.data, tmpbuf.length)) + if (!scratch_buffer_grow (&tmpbuf)) + break; + + scratch_buffer_free (&tmpbuf); + + scratch_buffer_grow and scratch_buffer_grow_preserve are guaranteed + to grow the buffer by at least 512 bytes. This means that when + using the scratch buffer as a backing store for a non-character + array whose element size, in bytes, is 512 or smaller, the scratch + buffer only has to grow once to make room for at least one more + element. +*/ + +#include <stdbool.h> +#include <stdlib.h> + +#include <libc-internal.h> + +/* Scratch buffer. Must be initialized with scratch_buffer_init + before its use. */ +struct scratch_buffer { + void *data; /* Pointer to the beginning of the scratch area. */ + size_t length; /* Allocated space at the data pointer, in bytes. */ + char __space[1024] + __attribute__ ((aligned (__alignof__ (libc_max_align_t)))); +}; + +/* Initializes *BUFFER so that BUFFER->data points to BUFFER->__space + and BUFFER->length reflects the available space. */ +static inline void +scratch_buffer_init (struct scratch_buffer *buffer) +{ + buffer->data = buffer->__space; + buffer->length = sizeof (buffer->__space); +} + +/* Deallocates *BUFFER (if it was heap-allocated). */ +static inline void +scratch_buffer_free (struct scratch_buffer *buffer) +{ + if (buffer->data != buffer->__space) + free (buffer->data); +} + +/* Grow *BUFFER by some arbitrary amount. The buffer contents is NOT + preserved. Return true on success, false on allocation failure (in + which case the old buffer is freed). On success, the new buffer is + larger than the previous size. On failure, *BUFFER is deallocated, + but remains in a free-able state, and errno is set. */ +bool __libc_scratch_buffer_grow (struct scratch_buffer *buffer); +libc_hidden_proto (__libc_scratch_buffer_grow) + +/* Alias for __libc_scratch_buffer_grow. */ +static __always_inline bool +scratch_buffer_grow (struct scratch_buffer *buffer) +{ + return __glibc_likely (__libc_scratch_buffer_grow (buffer)); +} + +/* Like __libc_scratch_buffer_grow, but preserve the old buffer + contents on success, as a prefix of the new buffer. */ +bool __libc_scratch_buffer_grow_preserve (struct scratch_buffer *buffer); +libc_hidden_proto (__libc_scratch_buffer_grow_preserve) + +/* Alias for __libc_scratch_buffer_grow_preserve. */ +static __always_inline bool +scratch_buffer_grow_preserve (struct scratch_buffer *buffer) +{ + return __glibc_likely (__libc_scratch_buffer_grow_preserve (buffer)); +} + +/* Grow *BUFFER so that it can store at least NELEM elements of SIZE + bytes. The buffer contents are NOT preserved. Both NELEM and SIZE + can be zero. Return true on success, false on allocation failure + (in which case the old buffer is freed, but *BUFFER remains in a + free-able state, and errno is set). It is unspecified whether this + function can reduce the array size. */ +bool __libc_scratch_buffer_set_array_size (struct scratch_buffer *buffer, + size_t nelem, size_t size); +libc_hidden_proto (__libc_scratch_buffer_set_array_size) + +/* Alias for __libc_scratch_set_array_size. */ +static __always_inline bool +scratch_buffer_set_array_size (struct scratch_buffer *buffer, + size_t nelem, size_t size) +{ + return __glibc_likely (__libc_scratch_buffer_set_array_size + (buffer, nelem, size)); +} + +#endif /* _SCRATCH_BUFFER_H */ diff --git a/include/search.h b/include/search.h index cf9c343708..a941959dbe 100644 --- a/include/search.h +++ b/include/search.h @@ -2,20 +2,27 @@ #include <misc/search.h> #ifndef _ISOMAC -libc_hidden_proto (hcreate_r) -libc_hidden_proto (hdestroy_r) -libc_hidden_proto (hsearch_r) +extern __typeof (hcreate_r) __hcreate_r; +libc_hidden_proto (__hcreate_r) +extern __typeof (hdestroy_r) __hdestroy_r; +libc_hidden_proto (__hdestroy_r) +extern __typeof (hsearch_r) __hsearch_r; +libc_hidden_proto (__hsearch_r) libc_hidden_proto (lfind) /* Now define the internal interfaces. */ extern void __hdestroy (void); extern void *__tsearch (const void *__key, void **__rootp, __compar_fn_t compar); +libc_hidden_proto (__tsearch) extern void *__tfind (const void *__key, void *const *__rootp, __compar_fn_t compar); +libc_hidden_proto (__tfind) extern void *__tdelete (const void *__key, void **__rootp, __compar_fn_t compar); +libc_hidden_proto (__tdelete) extern void __twalk (const void *__root, __action_fn_t action); +libc_hidden_proto (__twalk) extern void __tdestroy (void *__root, __free_fn_t freefct); #endif #endif diff --git a/include/set-hooks.h b/include/set-hooks.h index 85bd771d25..c19dc11b43 100644 --- a/include/set-hooks.h +++ b/include/set-hooks.h @@ -1,5 +1,5 @@ /* Macros for using symbol sets for running lists of functions. - Copyright (C) 1994-2014 Free Software Foundation, Inc. + Copyright (C) 1994-2015 Free Software 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/include/shlib-compat.h b/include/shlib-compat.h index fac0814bc2..ad1c47cde3 100644 --- a/include/shlib-compat.h +++ b/include/shlib-compat.h @@ -1,5 +1,5 @@ /* Macros for managing ABI-compatibility definitions using ELF symbol versions. - Copyright (C) 2000-2014 Free Software Foundation, Inc. + Copyright (C) 2000-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -41,14 +41,10 @@ # define SHLIB_COMPAT(lib, introduced, obsoleted) \ _SHLIB_COMPAT (lib, introduced, obsoleted) # define _SHLIB_COMPAT(lib, introduced, obsoleted) \ - ((IS_IN_##lib - 0) \ + (IS_IN (lib) \ && (!(ABI_##lib##_##obsoleted - 0) \ || ((ABI_##lib##_##introduced - 0) < (ABI_##lib##_##obsoleted - 0)))) -# ifndef NOT_IN_libc -# define IS_IN_libc 1 -# endif - /* That header also defines symbols like `VERSION_libm_GLIBC_2_1' to the version set name to use for e.g. symbols first introduced into libm in the GLIBC_2.1 version. Definitions of symbols with explicit diff --git a/include/signal.h b/include/signal.h index a019395882..b69de03ff6 100644 --- a/include/signal.h +++ b/include/signal.h @@ -10,6 +10,7 @@ libc_hidden_proto (sigfillset) libc_hidden_proto (sigaddset) libc_hidden_proto (sigdelset) libc_hidden_proto (sigismember) +extern int __sigpause (int sig_or_mask, int is_sig); libc_hidden_proto (__sigpause) libc_hidden_proto (raise) libc_hidden_proto (__libc_current_sigrtmin) @@ -40,22 +41,22 @@ extern int __sigtimedwait (const sigset_t *__set, siginfo_t *__info, libc_hidden_proto (__sigtimedwait) extern int __sigqueue (__pid_t __pid, int __sig, const union sigval __val); -extern int __sigvec (int __sig, const struct sigvec *__vec, - struct sigvec *__ovec); +#ifdef __USE_MISC extern int __sigreturn (struct sigcontext *__scp); +#endif extern int __sigaltstack (const struct sigaltstack *__ss, struct sigaltstack *__oss); extern int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact); libc_hidden_proto (__libc_sigaction) -extern int __sigpause (int sig_or_mask, int is_sig); extern int __default_sigpause (int mask); extern int __xpg_sigpause (int sig); /* Simplified sigemptyset() implementation without the parameter checking. */ #undef __sigemptyset -#define __sigemptyset(ss) (__builtin_memset (ss, '\0', sizeof (sigset_t)), 0) +#define __sigemptyset(ss) \ + ({ __builtin_memset (ss, '\0', sizeof (sigset_t)); 0; }) /* Allocate real-time signal with highest/lowest available priority. */ diff --git a/include/stackinfo.h b/include/stackinfo.h new file mode 100644 index 0000000000..fe50dd5b80 --- /dev/null +++ b/include/stackinfo.h @@ -0,0 +1,42 @@ +/* Details about the machine's stack: wrapper header. + Copyright (C) 2014-2015 Free Software 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 _INCLUDE_STACKINFO_H +#define _INCLUDE_STACKINFO_H 1 + +/* A sysdeps/.../stackinfo.h file defines details for the CPU. + It is obliged to define either _STACK_GROWS_DOWN or _STACK_GROWS_UP. */ +#include_next <stackinfo.h> + +#if defined _STACK_GROWS_DOWN && _STACK_GROWS_DOWN +# ifdef _STACK_GROWS_UP +# error "stackinfo.h should not define both!" +# else +# define _STACK_GROWS_UP 0 +# endif +#elif defined _STACK_GROWS_UP && _STACK_GROWS_UP +# ifdef _STACK_GROWS_DOWN +# error "stackinfo.h should not define both!" +# else +# define _STACK_GROWS_DOWN 0 +# endif +#else +# error "stackinfo.h must define _STACK_GROWS_UP or _STACK_GROWS_DOWN!" +#endif + +#endif /* include/stackinfo.h */ diff --git a/include/stap-probe.h b/include/stap-probe.h index 73b88e67ee..433b8fd38f 100644 --- a/include/stap-probe.h +++ b/include/stap-probe.h @@ -1,5 +1,5 @@ /* Macros for defining Systemtap <sys/sdt.h> static probe points. - Copyright (C) 2012-2014 Free Software Foundation, Inc. + Copyright (C) 2012-2015 Free Software 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,22 +30,18 @@ Systemtap's header defines the macros STAP_PROBE (provider, name) and STAP_PROBEn (provider, name, arg1, ..., argn). For "provider" we paste - in the IN_LIB name (libc, libpthread, etc.) automagically. */ - -# ifndef NOT_IN_libc -# define IN_LIB libc -# elif !defined IN_LIB -/* This is intentionally defined with extra unquoted commas in it so - that macro substitution will bomb out when it is used. We don't - just use #error here, so that this header can be included by - other headers that use LIBC_PROBE inside their own macros. We - only want such headers to fail to compile if those macros are - actually used in a context where IN_LIB has not been defined. */ -# define IN_LIB ,,,missing -DIN_LIB=... -- not extra-lib.mk?,,, -# endif + in MODULE_NAME (libc, libpthread, etc.) automagically. + + The format of the arg parameters is discussed here: + + https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation + + The precise details of how register names are specified is + architecture specific and can be found in the gdb and SystemTap + source code. */ # define LIBC_PROBE(name, n, ...) \ - LIBC_PROBE_1 (IN_LIB, name, n, ## __VA_ARGS__) + LIBC_PROBE_1 (MODULE_NAME, name, n, ## __VA_ARGS__) # define LIBC_PROBE_1(lib, name, n, ...) \ STAP_PROBE##n (lib, name, ## __VA_ARGS__) @@ -53,7 +49,7 @@ # define STAP_PROBE0 STAP_PROBE # define LIBC_PROBE_ASM(name, template) \ - STAP_PROBE_ASM (IN_LIB, name, template) + STAP_PROBE_ASM (MODULE_NAME, name, template) # define LIBC_PROBE_ASM_OPERANDS STAP_PROBE_ASM_OPERANDS diff --git a/include/stdc-predef.h b/include/stdc-predef.h index 87e3666502..e5f1139003 100644 --- a/include/stdc-predef.h +++ b/include/stdc-predef.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2014 Free Software Foundation, Inc. +/* Copyright (C) 1991-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -49,9 +49,14 @@ # define __STDC_IEC_559_COMPLEX__ 1 #endif -/* wchar_t uses ISO/IEC 10646 (2nd ed., published 2011-03-15) / - Unicode 6.0. */ -#define __STDC_ISO_10646__ 201103L +/* wchar_t uses Unicode 7.0.0. Version 7.0 of the Unicode Standard is + synchronized with ISO/IEC 10646:2012, plus Amendments 1 (published + on April, 2013) and 2 (not yet published as of February, 2015). + Additionally, it includes the accelerated publication of U+20BD + RUBLE SIGN. Therefore Unicode 7.0.0 is between 10646:2012 and + 10646:2014, and so we use the date ISO/IEC 10646:2012 Amd.1 was + published. */ +#define __STDC_ISO_10646__ 201304L /* We do not support C11 <threads.h>. */ #define __STDC_NO_THREADS__ 1 diff --git a/include/stdio.h b/include/stdio.h index 9f2ea31bc9..1ffbc40b3d 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -76,6 +76,7 @@ extern FILE *__old_tmpfile (void); # define __need_size_t +# define __need_wint_t # include <stddef.h> /* Generate a unique file name (and possibly open it). */ extern int __path_search (char *__tmpl, size_t __tmpl_len, @@ -117,7 +118,7 @@ extern const char *const _sys_errlist_internal[] attribute_hidden; extern int _sys_nerr_internal attribute_hidden; libc_hidden_proto (__asprintf) -# if !defined NOT_IN_libc +# if IS_IN (libc) extern _IO_FILE *_IO_new_fopen (const char*, const char*); # define fopen(fname, mode) _IO_new_fopen (fname, mode) extern _IO_FILE *_IO_new_fdopen (int, const char*); @@ -134,6 +135,9 @@ extern int _IO_new_fgetpos (_IO_FILE *, _IO_fpos_t *); # endif libc_hidden_proto (dprintf) +extern __typeof (dprintf) __dprintf + __attribute__ ((__format__ (__printf__, 2, 3))); +libc_hidden_proto (__dprintf) libc_hidden_proto (fprintf) libc_hidden_proto (vfprintf) libc_hidden_proto (sprintf) @@ -143,18 +147,32 @@ libc_hidden_proto (perror) libc_hidden_proto (remove) libc_hidden_proto (rewind) libc_hidden_proto (fileno) +extern __typeof (fileno) __fileno; +libc_hidden_proto (__fileno) libc_hidden_proto (fwrite) libc_hidden_proto (fseek) -libc_hidden_proto (ftello) +extern __typeof (ftello) __ftello; +libc_hidden_proto (__ftello) libc_hidden_proto (fflush) libc_hidden_proto (fflush_unlocked) -libc_hidden_proto (fread_unlocked) +extern __typeof (fflush_unlocked) __fflush_unlocked; +libc_hidden_proto (__fflush_unlocked) +extern __typeof (fread_unlocked) __fread_unlocked; +libc_hidden_proto (__fread_unlocked) libc_hidden_proto (fwrite_unlocked) libc_hidden_proto (fgets_unlocked) +extern __typeof (fgets_unlocked) __fgets_unlocked; +libc_hidden_proto (__fgets_unlocked) libc_hidden_proto (fputs_unlocked) +extern __typeof (fputs_unlocked) __fputs_unlocked; +libc_hidden_proto (__fputs_unlocked) libc_hidden_proto (fmemopen) -libc_hidden_proto (open_memstream) +/* The prototype needs repeating instead of using __typeof to use + __THROW in C++ tests. */ +extern FILE *__open_memstream (char **, size_t *) __THROW __wur; +libc_hidden_proto (__open_memstream) libc_hidden_proto (__libc_fatal) +rtld_hidden_proto (__libc_fatal) libc_hidden_proto (__vsprintf_chk) libc_hidden_proto (__vsnprintf_chk) libc_hidden_proto (__vfprintf_chk) @@ -180,6 +198,9 @@ gets (char *__str) } # endif +extern FILE * __fmemopen (void *buf, size_t len, const char *mode); +libc_hidden_proto (__fmemopen) + __END_DECLS # endif diff --git a/include/stdlib.h b/include/stdlib.h index e50985a5b8..992b87793c 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -37,7 +37,8 @@ extern __typeof (secure_getenv) __libc_secure_getenv; libc_hidden_proto (__libc_secure_getenv) libc_hidden_proto (bsearch) libc_hidden_proto (qsort) -libc_hidden_proto (qsort_r) +extern __typeof (qsort_r) __qsort_r; +libc_hidden_proto (__qsort_r) libc_hidden_proto (lrand48_r) libc_hidden_proto (wctomb) @@ -97,8 +98,7 @@ extern void _quicksort (void *const pbase, size_t total_elems, extern int __on_exit (void (*__func) (int __status, void *__arg), void *__arg); extern int __cxa_atexit (void (*func) (void *), void *arg, void *d); -extern int __cxa_atexit_internal (void (*func) (void *), void *arg, void *d) - attribute_hidden; +libc_hidden_proto (__cxa_atexit); extern int __cxa_thread_atexit_impl (void (*func) (void *), void *arg, void *d); @@ -226,11 +226,9 @@ extern int __qfcvt_r (long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len); -# ifndef NOT_IN_libc +# if IS_IN (libc) # undef MB_CUR_MAX # define MB_CUR_MAX (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MB_CUR_MAX)) - -# define __cxa_atexit(func, arg, d) INTUSE(__cxa_atexit) (func, arg, d) # endif extern void *__default_morecore (ptrdiff_t) __THROW; diff --git a/include/string.h b/include/string.h index 8323412240..c57671ea63 100644 --- a/include/string.h +++ b/include/string.h @@ -57,7 +57,7 @@ extern __typeof (strcasecmp_l) __strcasecmp_l; extern __typeof (strncasecmp_l) __strncasecmp_l; /* Alternative version which doesn't pollute glibc's namespace. */ -#ifndef NOT_IN_libc +#if IS_IN (libc) # undef strndupa # define strndupa(s, n) \ (__extension__ \ @@ -82,6 +82,8 @@ libc_hidden_proto (__strndup) libc_hidden_proto (__strerror_r) libc_hidden_proto (__strverscmp) libc_hidden_proto (basename) +extern char *__basename (const char *__filename) __THROW __nonnull ((1)); +libc_hidden_proto (__basename) libc_hidden_proto (strcoll) libc_hidden_proto (__strcoll_l) libc_hidden_proto (__strxfrm_l) @@ -89,7 +91,10 @@ libc_hidden_proto (__strtok_r) extern char *__strsep_g (char **__stringp, const char *__delim); libc_hidden_proto (__strsep_g) libc_hidden_proto (strnlen) +libc_hidden_proto (__strnlen) libc_hidden_proto (memmem) +extern __typeof (memmem) __memmem; +libc_hidden_proto (__memmem) libc_hidden_proto (__ffs) libc_hidden_builtin_proto (memchr) @@ -113,6 +118,14 @@ libc_hidden_builtin_proto (strspn) libc_hidden_builtin_proto (strstr) libc_hidden_builtin_proto (ffs) +#if (!IS_IN (libc) || !defined SHARED) \ + && !defined NO_MEMPCPY_STPCPY_REDIRECT +/* Redirect calls to __builtin_mempcpy and __builtin_stpcpy to call + __mempcpy and __stpcpy if not inlined. */ +extern __typeof (mempcpy) mempcpy __asm__ ("__mempcpy"); +extern __typeof (stpcpy) stpcpy __asm__ ("__stpcpy"); +#endif + # ifndef _ISOMAC # ifndef index # define index(s, c) (strchr ((s), (c))) diff --git a/include/sys/resource.h b/include/sys/resource.h index c35df435a5..688c46c4ae 100644 --- a/include/sys/resource.h +++ b/include/sys/resource.h @@ -2,13 +2,22 @@ #include <resource/sys/resource.h> #ifndef _ISOMAC -libc_hidden_proto (getpriority) -libc_hidden_proto (setpriority) +/* Prototypes repeated instead of using __typeof because + sys/resource.h is included in C++ tests, and declaring functions + with __typeof and __THROW doesn't work for C++. */ +extern int __getpriority (__priority_which_t __which, id_t __who) __THROW; +libc_hidden_proto (__getpriority) +extern int __setpriority (__priority_which_t __which, id_t __who, int __prio) + __THROW; +libc_hidden_proto (__setpriority) libc_hidden_proto (getrlimit64) +extern __typeof (getrlimit64) __getrlimit64; +libc_hidden_proto (__getrlimit64); /* Now define the internal interfaces. */ extern int __getrlimit (enum __rlimit_resource __resource, struct rlimit *__rlimits); +libc_hidden_proto (__getrlimit) extern int __getrusage (enum __rusage_who __who, struct rusage *__usage) attribute_hidden; diff --git a/include/sys/socket.h b/include/sys/socket.h index 9caf1bbdf5..2f4bfd3a93 100644 --- a/include/sys/socket.h +++ b/include/sys/socket.h @@ -8,7 +8,8 @@ protocol PROTOCOL. If PROTOCOL is zero, one is chosen automatically. Returns a file descriptor for the new socket, or -1 for errors. */ extern int __socket (int __domain, int __type, - int __protocol) attribute_hidden; + int __protocol); +libc_hidden_proto (__socket) /* Create two new sockets, of type TYPE in domain DOMAIN and using protocol PROTOCOL, which are connected to each other, and put file @@ -64,8 +65,8 @@ libc_hidden_proto (__connect) This function is a cancellation point and therefore not marked with __THROW. */ -extern ssize_t __recv (int __fd, void *__buf, size_t __n, int __flags) - attribute_hidden; +extern ssize_t __recv (int __fd, void *__buf, size_t __n, int __flags); +libc_hidden_proto (__recv) /* Send N bytes of BUF on socket FD to peer at address ADDR (which is ADDR_LEN bytes long). Returns the number sent, or -1 for errors. */ @@ -91,9 +92,11 @@ extern ssize_t __libc_sendmsg (int __fd, const struct msghdr *__message, extern ssize_t __sendmsg (int __fd, const struct msghdr *__message, int __flags) attribute_hidden; +#ifdef __USE_GNU extern int __sendmmsg (int __fd, struct mmsghdr *__vmessages, unsigned int __vlen, int __flags); libc_hidden_proto (__sendmmsg) +#endif /* Receive a message as described by MESSAGE from socket FD. Returns the number of bytes read or -1 for errors. */ diff --git a/include/sys/stat.h b/include/sys/stat.h index 7a65d608c5..873562a99d 100644 --- a/include/sys/stat.h +++ b/include/sys/stat.h @@ -12,7 +12,7 @@ extern __mode_t __umask (__mode_t __mask); extern int __mkdir (const char *__path, __mode_t __mode); extern int __mknod (const char *__path, __mode_t __mode, __dev_t __dev); -#if !defined NOT_IN_libc || defined IS_IN_rtld +#if IS_IN (libc) || IS_IN (rtld) hidden_proto (__fxstat) hidden_proto (__fxstat64) hidden_proto (__lxstat) diff --git a/include/sys/time.h b/include/sys/time.h index d2c628e987..ffaad5dae4 100644 --- a/include/sys/time.h +++ b/include/sys/time.h @@ -1,5 +1,5 @@ /* Time function internal interfaces. - Copyright (C) 1997-2014 Free Software Foundation, Inc. + Copyright (C) 1997-2015 Free Software 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/include/sys/uio.h b/include/sys/uio.h index 7d67d67c0a..f44ce182ba 100644 --- a/include/sys/uio.h +++ b/include/sys/uio.h @@ -5,11 +5,7 @@ /* Now define the internal interfaces. */ extern ssize_t __readv (int __fd, const struct iovec *__iovec, int __count); -extern ssize_t __libc_readv (int __fd, const struct iovec *__iovec, - int __count); extern ssize_t __writev (int __fd, const struct iovec *__iovec, int __count); -extern ssize_t __libc_writev (int __fd, const struct iovec *__iovec, - int __count); #endif #endif diff --git a/include/sys/wait.h b/include/sys/wait.h index 2239501614..9a38e61be7 100644 --- a/include/sys/wait.h +++ b/include/sys/wait.h @@ -8,7 +8,6 @@ extern __pid_t __waitpid (__pid_t __pid, int *__stat_loc, libc_hidden_proto (__waitpid) extern int __waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options); -extern __pid_t __libc_waitpid (pid_t __pid, int *__stat_loc, int __options); extern __pid_t __libc_wait (int *__stat_loc); extern __pid_t __wait (__WAIT_STATUS __stat_loc); extern __pid_t __wait3 (__WAIT_STATUS __stat_loc, diff --git a/include/ttyent.h b/include/ttyent.h index e510df8260..81e52116e5 100644 --- a/include/ttyent.h +++ b/include/ttyent.h @@ -1,8 +1,11 @@ #ifndef _TTYENT_H # include <misc/ttyent.h> -libc_hidden_proto (getttyent) -libc_hidden_proto (setttyent) -libc_hidden_proto (endttyent) +extern __typeof (getttyent) __getttyent __THROW; +libc_hidden_proto (__getttyent) +extern __typeof (setttyent) __setttyent __THROW; +libc_hidden_proto (__setttyent) +extern __typeof (endttyent) __endttyent __THROW; +libc_hidden_proto (__endttyent) #endif diff --git a/include/unistd.h b/include/unistd.h index a5cbc5d2fc..fbba3938ea 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -5,6 +5,7 @@ __BEGIN_DECLS libc_hidden_proto (_exit, __noreturn__) +rtld_hidden_proto (_exit, __noreturn__) libc_hidden_proto (alarm) libc_hidden_proto (confstr) libc_hidden_proto (execl) @@ -14,6 +15,8 @@ libc_hidden_proto (execvp) libc_hidden_proto (getpid) libc_hidden_proto (getsid) libc_hidden_proto (getdomainname) +extern __typeof (getlogin_r) __getlogin_r __nonnull ((1)); +libc_hidden_proto (__getlogin_r) libc_hidden_proto (getlogin_r) libc_hidden_proto (seteuid) libc_hidden_proto (setegid) @@ -151,19 +154,13 @@ libc_hidden_proto (__sbrk) environment variables that normally affect them. */ extern int __libc_enable_secure attribute_relro; extern int __libc_enable_secure_decided; -#ifdef IS_IN_rtld -/* XXX The #ifdef should go. */ -extern int __libc_enable_secure_internal attribute_relro attribute_hidden; -#endif +rtld_hidden_proto (__libc_enable_secure) /* Various internal function. */ extern void __libc_check_standard_fds (void); -/* Special exit function which only terminates the current thread. */ -extern void __exit_thread (int val) __attribute__ ((noreturn)); - /* Internal name for fork function. */ extern __pid_t __libc_fork (void); diff --git a/include/values.h b/include/values.h index 24b1fe6505..a002960732 100644 --- a/include/values.h +++ b/include/values.h @@ -1,5 +1,5 @@ /* Old compatibility names for <limits.h> and <float.h> constants. - Copyright (C) 1995-2014 Free Software Foundation, Inc. + Copyright (C) 1995-2015 Free Software 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/include/wchar.h b/include/wchar.h index f927a95fdf..67d0248f00 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -81,15 +81,31 @@ libc_hidden_proto (vswscanf) libc_hidden_proto (mbrtowc) libc_hidden_proto (wcrtomb) -libc_hidden_proto (wcscmp) +extern int __wcscmp (const wchar_t *__s1, const wchar_t *__s2) + __THROW __attribute_pure__; +libc_hidden_proto (__wcscmp) libc_hidden_proto (wcsftime) libc_hidden_proto (wcsspn) libc_hidden_proto (wcschr) -libc_hidden_proto (wcscoll) +/* The C++ overloading of wcschr means we have to repeat the type to + declare __wcschr instead of using typeof, to avoid errors in C++ + tests; in addition, __THROW cannot be used with a function type + from typeof in C++. The same applies to __wmemchr and, as regards + __THROW, to __wcscmp and __wcscoll. */ +extern wchar_t *__wcschr (const wchar_t *__wcs, wchar_t __wc) + __THROW __attribute_pure__; +libc_hidden_proto (__wcschr) +extern int __wcscoll (const wchar_t *__s1, const wchar_t *__s2) __THROW; +libc_hidden_proto (__wcscoll) libc_hidden_proto (wcspbrk) +extern typeof (wmemset) __wmemset; +extern wchar_t *__wmemchr (const wchar_t *__s, wchar_t __c, size_t __n) + __THROW __attribute_pure__; libc_hidden_proto (wmemchr) +libc_hidden_proto (__wmemchr) libc_hidden_proto (wmemset) +libc_hidden_proto (__wmemset) /* Now define the internal interfaces. */ extern int __wcscasecmp (const wchar_t *__s1, const wchar_t *__s2) @@ -181,7 +197,11 @@ extern int __isoc99_vwscanf (const wchar_t *__restrict __format, extern int __isoc99_vswscanf (const wchar_t *__restrict __s, const wchar_t *__restrict __format, __gnuc_va_list __arg) __THROW; +extern int __vswscanf (const wchar_t *__restrict __s, + const wchar_t *__restrict __format, + __gnuc_va_list __arg) __THROW; libc_hidden_proto (__isoc99_vswscanf) +libc_hidden_proto (__vswscanf) libc_hidden_proto (__isoc99_vfwscanf) /* Internal functions. */ diff --git a/include/wctype.h b/include/wctype.h index a2ee9ff880..a71b10377b 100644 --- a/include/wctype.h +++ b/include/wctype.h @@ -40,26 +40,19 @@ libc_hidden_proto (towupper) #ifndef _ISOMAC /* Internal interfaces. */ -extern int __iswalpha_l_internal (wint_t __wc, __locale_t __locale) - attribute_hidden; -extern int __iswdigit_l_internal (wint_t __wc, __locale_t __locale) - attribute_hidden; -extern int __iswspace_l_internal (wint_t __wc, __locale_t __locale) - attribute_hidden; -extern int __iswxdigit_l_internal (wint_t __wc, __locale_t __locale) - attribute_hidden; extern int __iswspace (wint_t __wc); extern int __iswctype (wint_t __wc, wctype_t __desc); -extern int __iswctype_internal (wint_t __wc, wctype_t __desc) attribute_hidden; extern wctype_t __wctype (const char *__property); extern wctrans_t __wctrans (const char *__property); extern wint_t __towctrans (wint_t __wc, wctrans_t __desc); +extern __typeof (iswalnum) __iswalnum __THROW __attribute_pure__; extern __typeof (iswalnum_l) __iswalnum_l; extern __typeof (iswalpha_l) __iswalpha_l; extern __typeof (iswblank_l) __iswblank_l; extern __typeof (iswcntrl_l) __iswcntrl_l; extern __typeof (iswdigit_l) __iswdigit_l; +extern __typeof (iswlower) __iswlower __THROW __attribute_pure__; extern __typeof (iswlower_l) __iswlower_l; extern __typeof (iswgraph_l) __iswgraph_l; extern __typeof (iswprint_l) __iswprint_l; @@ -69,14 +62,18 @@ extern __typeof (iswupper_l) __iswupper_l; extern __typeof (iswxdigit_l) __iswxdigit_l; extern __typeof (towlower_l) __towlower_l; extern __typeof (towupper_l) __towupper_l; +extern __typeof (towlower) __towlower __THROW __attribute_pure__; +extern __typeof (towupper) __towupper __THROW __attribute_pure__; libc_hidden_proto (__towctrans) libc_hidden_proto (__iswctype) +libc_hidden_proto (__iswalnum) libc_hidden_proto (__iswalnum_l) libc_hidden_proto (__iswalpha_l) libc_hidden_proto (__iswblank_l) libc_hidden_proto (__iswcntrl_l) libc_hidden_proto (__iswdigit_l) +libc_hidden_proto (__iswlower) libc_hidden_proto (__iswlower_l) libc_hidden_proto (__iswgraph_l) libc_hidden_proto (__iswprint_l) @@ -86,10 +83,12 @@ libc_hidden_proto (__iswupper_l) libc_hidden_proto (__iswxdigit_l) libc_hidden_proto (__towlower_l) libc_hidden_proto (__towupper_l) +libc_hidden_proto (__towlower) +libc_hidden_proto (__towupper) /* The spec says that isdigit must only match the decimal digits. We can check this without a memory access. */ -# ifndef NOT_IN_libc +# if IS_IN (libc) # undef iswdigit # define iswdigit(c) ({ wint_t __c = (c); __c >= L'0' && __c <= L'9'; }) # undef iswdigit_l |