diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-09-10 16:53:11 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-09-10 16:53:11 -0400 |
| commit | 92a427437c420195a55df4baee1bd0738dc4ed70 (patch) | |
| tree | ce862a6b480b159b8c0bd1a03643d102a44172b5 /lib | |
| parent | 3cd035ba3bb9b324b474cc84e37b654ea64b109f (diff) | |
| parent | 7101e583d6a752fa1145c13c6e1a58f36bd35f2d (diff) | |
| download | zig-92a427437c420195a55df4baee1bd0738dc4ed70.tar.gz zig-92a427437c420195a55df4baee1bd0738dc4ed70.zip | |
Merge remote-tracking branch 'origin/master' into llvm9
Diffstat (limited to 'lib')
33 files changed, 288 insertions, 182 deletions
diff --git a/lib/libc/glibc/elf/elf.h b/lib/libc/glibc/elf/elf.h index 47a514a389..7c6d6094ed 100644 --- a/lib/libc/glibc/elf/elf.h +++ b/lib/libc/glibc/elf/elf.h @@ -360,7 +360,7 @@ typedef struct #define EM_RISCV 243 /* RISC-V */ #define EM_BPF 247 /* Linux BPF -- in-kernel virtual machine */ -#define EM_CSKY 252 /* C_SKY */ +#define EM_CSKY 252 /* C-SKY */ #define EM_NUM 253 @@ -809,9 +809,16 @@ typedef struct #define NT_ARM_SYSTEM_CALL 0x404 /* ARM system call number */ #define NT_ARM_SVE 0x405 /* ARM Scalable Vector Extension registers */ +#define NT_ARM_PAC_MASK 0x406 /* ARM pointer authentication + code masks. */ +#define NT_ARM_PACA_KEYS 0x407 /* ARM pointer authentication + address keys. */ +#define NT_ARM_PACG_KEYS 0x408 /* ARM pointer authentication + generic key. */ #define NT_VMCOREDD 0x700 /* Vmcore Device Dump Note. */ #define NT_MIPS_DSP 0x800 /* MIPS DSP ASE registers. */ #define NT_MIPS_FP_MODE 0x801 /* MIPS floating-point mode. */ +#define NT_MIPS_MSA 0x802 /* MIPS SIMD registers. */ /* Legal values for the note segment descriptor types for object files. */ @@ -987,6 +994,9 @@ typedef struct #define DF_1_SINGLETON 0x02000000 /* Singleton symbols are used. */ #define DF_1_STUB 0x04000000 #define DF_1_PIE 0x08000000 +#define DF_1_KMOD 0x10000000 +#define DF_1_WEAKFILTER 0x20000000 +#define DF_1_NOCOMMON 0x40000000 /* Flags for the feature selection in DT_FEATURE_1. */ #define DTF_1_PARINIT 0x00000001 @@ -2854,6 +2864,13 @@ enum #define R_AARCH64_TLSDESC 1031 /* TLS Descriptor. */ #define R_AARCH64_IRELATIVE 1032 /* STT_GNU_IFUNC relocation. */ +/* AArch64 specific values for the Dyn d_tag field. */ +#define DT_AARCH64_VARIANT_PCS (DT_LOPROC + 5) +#define DT_AARCH64_NUM 6 + +/* AArch64 specific values for the st_other field. */ +#define STO_AARCH64_VARIANT_PCS 0x80 + /* ARM relocs. */ #define R_ARM_NONE 0 /* No reloc */ @@ -3022,7 +3039,7 @@ enum /* Keep this the last entry. */ #define R_ARM_NUM 256 -/* csky */ +/* C-SKY */ #define R_CKCORE_NONE 0 /* no reloc */ #define R_CKCORE_ADDR32 1 /* direct 32 bit (S + A) */ #define R_CKCORE_PCRELIMM8BY4 2 /* disp ((S + A - P) >> 2) & 0xff */ @@ -3086,6 +3103,17 @@ enum #define R_CKCORE_TLS_DTPOFF32 57 #define R_CKCORE_TLS_TPOFF32 58 +/* C-SKY elf header definition. */ +#define EF_CSKY_ABIMASK 0XF0000000 +#define EF_CSKY_OTHER 0X0FFF0000 +#define EF_CSKY_PROCESSOR 0X0000FFFF + +#define EF_CSKY_ABIV1 0X10000000 +#define EF_CSKY_ABIV2 0X20000000 + +/* C-SKY attributes section. */ +#define SHT_CSKY_ATTRIBUTES (SHT_LOPROC + 1) + /* IA-64 specific declarations. */ /* Processor specific flags for the Ehdr e_flags field. */ diff --git a/lib/libc/glibc/include/elf.h b/lib/libc/glibc/include/elf.h index ab76aafb1e..14ed67ff67 100644 --- a/lib/libc/glibc/include/elf.h +++ b/lib/libc/glibc/include/elf.h @@ -23,7 +23,7 @@ # endif # define DT_1_SUPPORTED_MASK \ (DF_1_NOW | DF_1_NODELETE | DF_1_INITFIRST | DF_1_NOOPEN \ - | DF_1_ORIGIN | DF_1_NODEFLIB) + | DF_1_ORIGIN | DF_1_NODEFLIB | DF_1_PIE) #endif /* !_ISOMAC */ #endif /* elf.h */ diff --git a/lib/libc/glibc/include/features.h b/lib/libc/glibc/include/features.h index ba272078cf..bf47d881dd 100644 --- a/lib/libc/glibc/include/features.h +++ b/lib/libc/glibc/include/features.h @@ -414,10 +414,10 @@ instance, with GCC, -std=gnu11 will have C99-compliant scanf with or without -D_GNU_SOURCE, but -std=c89 -D_GNU_SOURCE will have the old extension. */ -#if defined __USE_GNU && \ - (defined __cplusplus \ - ? (__cplusplus < 201103L && !defined __GXX_EXPERIMENTAL_CXX0X__) \ - : (!defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L)) +#if (defined __USE_GNU \ + && (defined __cplusplus \ + ? (__cplusplus < 201103L && !defined __GXX_EXPERIMENTAL_CXX0X__) \ + : (!defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L))) # define __GLIBC_USE_DEPRECATED_SCANF 1 #else # define __GLIBC_USE_DEPRECATED_SCANF 0 @@ -439,7 +439,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__ 29 +#define __GLIBC_MINOR__ 30 #define __GLIBC_PREREQ(maj, min) \ ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min)) diff --git a/lib/libc/glibc/include/stap-probe.h b/lib/libc/glibc/include/stap-probe.h index c53dd86592..85f41c9162 100644 --- a/lib/libc/glibc/include/stap-probe.h +++ b/lib/libc/glibc/include/stap-probe.h @@ -21,6 +21,7 @@ #ifdef USE_STAP_PROBE +# include <stap-probe-machine.h> # include <sys/sdt.h> /* Our code uses one macro LIBC_PROBE (name, n, arg1, ..., argn). @@ -59,11 +60,11 @@ /* Evaluate all the arguments and verify that N matches their number. */ # define LIBC_PROBE(name, n, ...) STAP_PROBE##n (__VA_ARGS__) -# define STAP_PROBE0() -# define STAP_PROBE1(a1) -# define STAP_PROBE2(a1, a2) -# define STAP_PROBE3(a1, a2, a3) -# define STAP_PROBE4(a1, a2, a3, a4) +# define STAP_PROBE0() do {} while (0) +# define STAP_PROBE1(a1) do {} while (0) +# define STAP_PROBE2(a1, a2) do {} while (0) +# define STAP_PROBE3(a1, a2, a3) do {} while (0) +# define STAP_PROBE4(a1, a2, a3, a4) do {} while (0) # else # define LIBC_PROBE(name, n, ...) /* Nothing. */ diff --git a/lib/libc/glibc/io/bits/statx.h b/lib/libc/glibc/io/bits/statx.h index cff14b2543..b3147bfa8a 100644 --- a/lib/libc/glibc/io/bits/statx.h +++ b/lib/libc/glibc/io/bits/statx.h @@ -1,4 +1,4 @@ -/* statx-related definitions and declarations. +/* statx-related definitions and declarations. Generic version. Copyright (C) 2018-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -19,73 +19,8 @@ /* This interface is based on <linux/stat.h> in Linux. */ #ifndef _SYS_STAT_H -# error Never include <bits/stat.x.h> directly, include <sys/stat.h> instead. +# error Never include <bits/statx.h> directly, include <sys/stat.h> instead. #endif -struct statx_timestamp -{ - __int64_t tv_sec; - __uint32_t tv_nsec; - __int32_t __statx_timestamp_pad1[1]; -}; - -/* Warning: The kernel may add additional fields to this struct in the - future. Only use this struct for calling the statx function, not - for storing data. (Expansion will be controlled by the mask - argument of the statx function.) */ -struct statx -{ - __uint32_t stx_mask; - __uint32_t stx_blksize; - __uint64_t stx_attributes; - __uint32_t stx_nlink; - __uint32_t stx_uid; - __uint32_t stx_gid; - __uint16_t stx_mode; - __uint16_t __statx_pad1[1]; - __uint64_t stx_ino; - __uint64_t stx_size; - __uint64_t stx_blocks; - __uint64_t stx_attributes_mask; - struct statx_timestamp stx_atime; - struct statx_timestamp stx_btime; - struct statx_timestamp stx_ctime; - struct statx_timestamp stx_mtime; - __uint32_t stx_rdev_major; - __uint32_t stx_rdev_minor; - __uint32_t stx_dev_major; - __uint32_t stx_dev_minor; - __uint64_t __statx_pad2[14]; -}; - -#define STATX_TYPE 0x0001U -#define STATX_MODE 0x0002U -#define STATX_NLINK 0x0004U -#define STATX_UID 0x0008U -#define STATX_GID 0x0010U -#define STATX_ATIME 0x0020U -#define STATX_MTIME 0x0040U -#define STATX_CTIME 0x0080U -#define STATX_INO 0x0100U -#define STATX_SIZE 0x0200U -#define STATX_BLOCKS 0x0400U -#define STATX_BASIC_STATS 0x07ffU -#define STATX_ALL 0x0fffU -#define STATX_BTIME 0x0800U -#define STATX__RESERVED 0x80000000U - -#define STATX_ATTR_COMPRESSED 0x0004 -#define STATX_ATTR_IMMUTABLE 0x0010 -#define STATX_ATTR_APPEND 0x0020 -#define STATX_ATTR_NODUMP 0x0040 -#define STATX_ATTR_ENCRYPTED 0x0800 -#define STATX_ATTR_AUTOMOUNT 0x1000 - -__BEGIN_DECLS - -/* Fill *BUF with information about PATH in DIRFD. */ -int statx (int __dirfd, const char *__restrict __path, int __flags, - unsigned int __mask, struct statx *__restrict __buf) - __THROW __nonnull ((2, 5)); - -__END_DECLS +/* Use the generic definitions. */ +#include <bits/statx-generic.h> diff --git a/lib/libc/glibc/misc/sys/cdefs.h b/lib/libc/glibc/misc/sys/cdefs.h index 88bc7ac942..f1bd994a10 100644 --- a/lib/libc/glibc/misc/sys/cdefs.h +++ b/lib/libc/glibc/misc/sys/cdefs.h @@ -256,8 +256,8 @@ /* 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__) +#if __GNUC_PREREQ (4,5) \ + || __glibc_clang_has_extension (__attribute_deprecated_with_message__) # define __attribute_deprecated_msg__(msg) \ __attribute__ ((__deprecated__ (msg))) #else @@ -412,6 +412,14 @@ # define __glibc_has_attribute(attr) 0 #endif +#ifdef __has_include +/* Do not use a function-like macro, so that __has_include can inhibit + macro expansion. */ +# define __glibc_has_include __has_include +#else +# define __glibc_has_include(header) 0 +#endif + #if (!defined _Noreturn \ && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \ && !__GNUC_PREREQ (4,7)) diff --git a/lib/libc/glibc/posix/bits/types.h b/lib/libc/glibc/posix/bits/types.h index 27e065c3be..cb737caff0 100644 --- a/lib/libc/glibc/posix/bits/types.h +++ b/lib/libc/glibc/posix/bits/types.h @@ -87,7 +87,7 @@ __extension__ typedef unsigned long long int __uintmax_t; 32 -- "natural" 32-bit type (always int) 64 -- "natural" 64-bit type (long or long long) LONG32 -- 32-bit type, traditionally long - QUAD -- 64-bit type, always long long + QUAD -- 64-bit type, traditionally long long WORD -- natural type of __WORDSIZE bits (int or long) LONGWORD -- type of __WORDSIZE bits, traditionally long @@ -113,14 +113,14 @@ __extension__ typedef unsigned long long int __uintmax_t; #define __SLONGWORD_TYPE long int #define __ULONGWORD_TYPE unsigned long int #if __WORDSIZE == 32 -# define __SQUAD_TYPE __quad_t -# define __UQUAD_TYPE __u_quad_t +# define __SQUAD_TYPE __int64_t +# define __UQUAD_TYPE __uint64_t # define __SWORD_TYPE int # define __UWORD_TYPE unsigned int # define __SLONG32_TYPE long int # define __ULONG32_TYPE unsigned long int -# define __S64_TYPE __quad_t -# define __U64_TYPE __u_quad_t +# define __S64_TYPE __int64_t +# define __U64_TYPE __uint64_t /* We want __extension__ before typedef's that use nonstandard base types such as `long long' in C89 mode. */ # define __STD_TYPE __extension__ typedef @@ -213,10 +213,13 @@ __STD_TYPE __U32_TYPE __socklen_t; It is not currently necessary for this to be machine-specific. */ typedef int __sig_atomic_t; -#if __TIMESIZE == 64 +/* Seconds since the Epoch, visible to user code when time_t is too + narrow only for consistency with the old way of widening too-narrow + types. User code should never use __time64_t. */ +#if __TIMESIZE == 64 && defined __LIBC # define __time64_t __time_t -#else -__STD_TYPE __TIME64_T_TYPE __time64_t; /* Seconds since the Epoch. */ +#elif __TIMESIZE != 64 +__STD_TYPE __TIME64_T_TYPE __time64_t; #endif #undef __STD_TYPE diff --git a/lib/libc/glibc/posix/sys/types.h b/lib/libc/glibc/posix/sys/types.h index 27129c5c23..0e37b1ce6a 100644 --- a/lib/libc/glibc/posix/sys/types.h +++ b/lib/libc/glibc/posix/sys/types.h @@ -154,37 +154,20 @@ typedef unsigned int uint; #include <bits/stdint-intn.h> -#if !__GNUC_PREREQ (2, 7) - /* These were defined by ISO C without the first `_'. */ -typedef unsigned char u_int8_t; -typedef unsigned short int u_int16_t; -typedef unsigned int u_int32_t; -# if __WORDSIZE == 64 -typedef unsigned long int u_int64_t; -# else -__extension__ typedef unsigned long long int u_int64_t; -# endif - -typedef int register_t; - -#else - -/* For GCC 2.7 and later, we can use specific type-size attributes. */ -# define __u_intN_t(N, MODE) \ - typedef unsigned int u_int##N##_t __attribute__ ((__mode__ (MODE))) - -__u_intN_t (8, __QI__); -__u_intN_t (16, __HI__); -__u_intN_t (32, __SI__); -__u_intN_t (64, __DI__); +typedef __uint8_t u_int8_t; +typedef __uint16_t u_int16_t; +typedef __uint32_t u_int32_t; +typedef __uint64_t u_int64_t; +#if __GNUC_PREREQ (2, 7) typedef int register_t __attribute__ ((__mode__ (__word__))); - +#else +typedef int register_t; +#endif /* Some code from BIND tests this macro to see if the types above are defined. */ -#endif #define __BIT_TYPES_DEFINED__ 1 diff --git a/lib/libc/glibc/signal/signal.h b/lib/libc/glibc/signal/signal.h index ee591fcb2d..4c0de7f6ce 100644 --- a/lib/libc/glibc/signal/signal.h +++ b/lib/libc/glibc/signal/signal.h @@ -370,6 +370,9 @@ extern int __libc_current_sigrtmax (void) __THROW; #define SIGRTMIN (__libc_current_sigrtmin ()) #define SIGRTMAX (__libc_current_sigrtmax ()) +/* System-specific extensions. */ +#include <bits/signal_ext.h> + __END_DECLS #endif /* not signal.h */ diff --git a/lib/libc/glibc/stdlib/stdlib.h b/lib/libc/glibc/stdlib/stdlib.h index 15debe1e31..a9fd989d39 100644 --- a/lib/libc/glibc/stdlib/stdlib.h +++ b/lib/libc/glibc/stdlib/stdlib.h @@ -536,10 +536,11 @@ extern int lcong48_r (unsigned short int __param[7], #endif /* Use misc or X/Open. */ /* Allocate SIZE bytes of memory. */ -extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur; +extern void *malloc (size_t __size) __THROW __attribute_malloc__ + __attribute_alloc_size__ ((1)) __wur; /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ extern void *calloc (size_t __nmemb, size_t __size) - __THROW __attribute_malloc__ __wur; + __THROW __attribute_malloc__ __attribute_alloc_size__ ((1, 2)) __wur; /* Re-allocate the previously allocated block in PTR, making the new block SIZE bytes long. */ @@ -547,7 +548,7 @@ extern void *calloc (size_t __nmemb, size_t __size) the same pointer that was passed to it, aliasing needs to be allowed between objects pointed by the old and new pointers. */ extern void *realloc (void *__ptr, size_t __size) - __THROW __attribute_warn_unused_result__; + __THROW __attribute_warn_unused_result__ __attribute_alloc_size__ ((2)); #ifdef __USE_MISC /* Re-allocate the previously allocated block in PTR, making the new @@ -556,7 +557,8 @@ extern void *realloc (void *__ptr, size_t __size) the same pointer that was passed to it, aliasing needs to be allowed between objects pointed by the old and new pointers. */ extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size) - __THROW __attribute_warn_unused_result__; + __THROW __attribute_warn_unused_result__ + __attribute_alloc_size__ ((2, 3)); #endif /* Free a block allocated by `malloc', `realloc' or `calloc'. */ @@ -569,7 +571,8 @@ extern void free (void *__ptr) __THROW; #if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \ || defined __USE_MISC /* Allocate SIZE bytes on a page boundary. The storage cannot be freed. */ -extern void *valloc (size_t __size) __THROW __attribute_malloc__ __wur; +extern void *valloc (size_t __size) __THROW __attribute_malloc__ + __attribute_alloc_size__ ((1)) __wur; #endif #ifdef __USE_XOPEN2K diff --git a/lib/libc/glibc/sysdeps/arm/sysdep.h b/lib/libc/glibc/sysdeps/arm/sysdep.h index f43ba74305..b283ce9600 100644 --- a/lib/libc/glibc/sysdeps/arm/sysdep.h +++ b/lib/libc/glibc/sysdeps/arm/sysdep.h @@ -295,8 +295,8 @@ #endif /* Pointer mangling support. */ -#if (IS_IN (rtld) || \ - (!defined SHARED && (IS_IN (libc) || IS_IN (libpthread)))) +#if (IS_IN (rtld) \ + || (!defined SHARED && (IS_IN (libc) || IS_IN (libpthread)))) # ifdef __ASSEMBLER__ # define PTR_MANGLE_LOAD(guard, tmp) \ LDR_HIDDEN (guard, tmp, C_SYMBOL_NAME(__pointer_chk_guard_local), 0) diff --git a/lib/libc/glibc/sysdeps/generic/single-thread.h b/lib/libc/glibc/sysdeps/generic/single-thread.h new file mode 100644 index 0000000000..0a1520ec49 --- /dev/null +++ b/lib/libc/glibc/sysdeps/generic/single-thread.h @@ -0,0 +1,24 @@ +/* Single thread optimization, generic version. + Copyright (C) 2019 Free Software 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 _SINGLE_THREAD_H +#define _SINGLE_THREAD_H + +#define SINGLE_THREAD_P (0) + +#endif /* _SINGLE_THREAD_H */ diff --git a/lib/libc/glibc/sysdeps/generic/symbol-hacks.h b/lib/libc/glibc/sysdeps/generic/symbol-hacks.h index d614c099c9..3586e6ed38 100644 --- a/lib/libc/glibc/sysdeps/generic/symbol-hacks.h +++ b/lib/libc/glibc/sysdeps/generic/symbol-hacks.h @@ -11,8 +11,8 @@ asm ("memcpy = __GI_memcpy"); __stack_chk_fail itself is a global symbol, exported from libc.so, and cannot be made hidden. */ -# if IS_IN (libc) && defined SHARED && \ - defined STACK_PROTECTOR_LEVEL && STACK_PROTECTOR_LEVEL > 0 +# if IS_IN (libc) && defined SHARED \ + && defined STACK_PROTECTOR_LEVEL && STACK_PROTECTOR_LEVEL > 0 asm (".hidden __stack_chk_fail_local\n" "__stack_chk_fail = __stack_chk_fail_local"); # endif diff --git a/lib/libc/glibc/sysdeps/mach/hurd/bits/stat.h b/lib/libc/glibc/sysdeps/mach/hurd/bits/stat.h index 5ef487e077..0044493ff3 100644 --- a/lib/libc/glibc/sysdeps/mach/hurd/bits/stat.h +++ b/lib/libc/glibc/sysdeps/mach/hurd/bits/stat.h @@ -218,8 +218,8 @@ struct stat64 #define S_IMMAP0 000100000000 /* ALL the unused bits. */ -#define S_ISPARE (~(S_IFMT|S_ITRANS|S_INOCACHE|S_IMMAP0| \ - S_IUSEUNK|S_IUNKNOWN|07777)) +#define S_ISPARE (~(S_IFMT|S_ITRANS|S_INOCACHE|S_IMMAP0 \ + |S_IUSEUNK|S_IUNKNOWN|07777)) #endif #ifdef __USE_MISC diff --git a/lib/libc/glibc/sysdeps/nptl/libc-lockP.h b/lib/libc/glibc/sysdeps/nptl/libc-lockP.h index fc1bfe57e5..07d583f11a 100644 --- a/lib/libc/glibc/sysdeps/nptl/libc-lockP.h +++ b/lib/libc/glibc/sysdeps/nptl/libc-lockP.h @@ -71,23 +71,12 @@ typedef pthread_key_t __libc_key_t; For the C library we take a deeper look at the initializer. For this implementation all fields are initialized to zero. Therefore we don't initialize the variable which allows putting it into the - BSS section. (Except on PA-RISC and other odd architectures, where - initialized locks must be set to one due to the lack of normal - atomic operations.) */ + BSS section. */ +_Static_assert (LLL_LOCK_INITIALIZER == 0, "LLL_LOCK_INITIALIZER != 0"); #define _LIBC_LOCK_INITIALIZER LLL_LOCK_INITIALIZER -#if IS_IN (libc) || IS_IN (libpthread) -# if LLL_LOCK_INITIALIZER == 0 -# define __libc_lock_define_initialized(CLASS,NAME) \ - CLASS __libc_lock_t NAME; -# else -# define __libc_lock_define_initialized(CLASS,NAME) \ - CLASS __libc_lock_t NAME = LLL_LOCK_INITIALIZER; -# endif -#else -# define __libc_lock_define_initialized(CLASS,NAME) \ +#define __libc_lock_define_initialized(CLASS,NAME) \ CLASS __libc_lock_t NAME; -#endif #define __libc_rwlock_define_initialized(CLASS,NAME) \ CLASS __libc_rwlock_t NAME = PTHREAD_RWLOCK_INITIALIZER; diff --git a/lib/libc/glibc/sysdeps/nptl/pthread.h b/lib/libc/glibc/sysdeps/nptl/pthread.h index 704a3c48d6..a767d6f180 100644 --- a/lib/libc/glibc/sysdeps/nptl/pthread.h +++ b/lib/libc/glibc/sysdeps/nptl/pthread.h @@ -770,6 +770,13 @@ extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex, __abstime) __THROWNL __nonnull ((1, 2)); #endif +#ifdef __USE_GNU +extern int pthread_mutex_clocklock (pthread_mutex_t *__restrict __mutex, + clockid_t __clockid, + const struct timespec *__restrict + __abstime) __THROWNL __nonnull ((1, 3)); +#endif + /* Unlock a mutex. */ extern int pthread_mutex_unlock (pthread_mutex_t *__mutex) __THROWNL __nonnull ((1)); @@ -909,6 +916,13 @@ extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock, __abstime) __THROWNL __nonnull ((1, 2)); # endif +# ifdef __USE_GNU +extern int pthread_rwlock_clockrdlock (pthread_rwlock_t *__restrict __rwlock, + clockid_t __clockid, + const struct timespec *__restrict + __abstime) __THROWNL __nonnull ((1, 3)); +# endif + /* Acquire write lock for RWLOCK. */ extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock) __THROWNL __nonnull ((1)); @@ -924,6 +938,13 @@ extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock, __abstime) __THROWNL __nonnull ((1, 2)); # endif +# ifdef __USE_GNU +extern int pthread_rwlock_clockwrlock (pthread_rwlock_t *__restrict __rwlock, + clockid_t __clockid, + const struct timespec *__restrict + __abstime) __THROWNL __nonnull ((1, 3)); +# endif + /* Unlock RWLOCK. */ extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock) __THROWNL __nonnull ((1)); @@ -1003,6 +1024,21 @@ extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond, const struct timespec *__restrict __abstime) __nonnull ((1, 2, 3)); +# ifdef __USE_GNU +/* Wait for condition variable COND to be signaled or broadcast until + ABSTIME measured by the specified clock. MUTEX is assumed to be + locked before. CLOCK is the clock to use. ABSTIME is an absolute + time specification against CLOCK's epoch. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int pthread_cond_clockwait (pthread_cond_t *__restrict __cond, + pthread_mutex_t *__restrict __mutex, + __clockid_t __clock_id, + const struct timespec *__restrict __abstime) + __nonnull ((1, 2, 4)); +# endif + /* Functions for handling condition variable attributes. */ /* Initialize condition variable attribute ATTR. */ diff --git a/lib/libc/glibc/sysdeps/s390/s390-32/sysdep.h b/lib/libc/glibc/sysdeps/s390/s390-32/sysdep.h index 6605dde237..4a441e1204 100644 --- a/lib/libc/glibc/sysdeps/s390/s390-32/sysdep.h +++ b/lib/libc/glibc/sysdeps/s390/s390-32/sysdep.h @@ -32,7 +32,7 @@ #define ENTRY(name) \ .globl C_SYMBOL_NAME(name); \ .type C_SYMBOL_NAME(name),@function; \ - .align ALIGNARG(2); \ + .align ALIGNARG(4); \ C_LABEL(name) \ cfi_startproc; \ CALL_MCOUNT diff --git a/lib/libc/glibc/sysdeps/s390/s390-64/sysdep.h b/lib/libc/glibc/sysdeps/s390/s390-64/sysdep.h index 99dbf3f444..0531fa5823 100644 --- a/lib/libc/glibc/sysdeps/s390/s390-64/sysdep.h +++ b/lib/libc/glibc/sysdeps/s390/s390-64/sysdep.h @@ -32,7 +32,7 @@ #define ENTRY(name) \ .globl C_SYMBOL_NAME(name); \ .type C_SYMBOL_NAME(name),@function; \ - .align ALIGNARG(2); \ + .align ALIGNARG(4); \ C_LABEL(name) \ cfi_startproc; \ CALL_MCOUNT diff --git a/lib/libc/glibc/sysdeps/unix/alpha/sysdep.h b/lib/libc/glibc/sysdeps/unix/alpha/sysdep.h index 05f8cde80b..dcd4c79be5 100644 --- a/lib/libc/glibc/sysdeps/unix/alpha/sysdep.h +++ b/lib/libc/glibc/sysdeps/unix/alpha/sysdep.h @@ -200,7 +200,7 @@ __LABEL(name) \ no matter what the "real" sign of the 32-bit type. We want to preserve that when filling in values for the kernel. */ #define syscall_promote(arg) \ - (sizeof(arg) == 4 ? (long)(int)(long)(arg) : (long)(arg)) + (sizeof (arg) == 4 ? (long)(int)(long)(arg) : (long)(arg)) /* Make sure and "use" the variable that we're not returning, in order to suppress unused variable warnings. */ diff --git a/lib/libc/glibc/sysdeps/unix/sysdep.h b/lib/libc/glibc/sysdeps/unix/sysdep.h index 7cb6c89825..6e503d7688 100644 --- a/lib/libc/glibc/sysdeps/unix/sysdep.h +++ b/lib/libc/glibc/sysdeps/unix/sysdep.h @@ -16,7 +16,7 @@ <http://www.gnu.org/licenses/>. */ #include <sysdeps/generic/sysdep.h> - +#include <single-thread.h> #include <sys/syscall.h> #define HAVE_SYSCALLS diff --git a/lib/libc/glibc/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/lib/libc/glibc/sysdeps/unix/sysv/linux/aarch64/sysdep.h index 10646d62f9..935c507f8c 100644 --- a/lib/libc/glibc/sysdeps/unix/sysv/linux/aarch64/sysdep.h +++ b/lib/libc/glibc/sysdeps/unix/sysv/linux/aarch64/sysdep.h @@ -255,9 +255,9 @@ #endif /* __ASSEMBLER__ */ /* Pointer mangling is supported for AArch64. */ -#if (IS_IN (rtld) || \ - (!defined SHARED && (IS_IN (libc) \ - || IS_IN (libpthread)))) +#if (IS_IN (rtld) \ + || (!defined SHARED && (IS_IN (libc) \ + || IS_IN (libpthread)))) # ifdef __ASSEMBLER__ /* Note, dst, src, guard, and tmp are all register numbers rather than register names so they will work with both ILP32 and LP64. */ diff --git a/lib/libc/glibc/sysdeps/unix/sysv/linux/alpha/kernel-features.h b/lib/libc/glibc/sysdeps/unix/sysv/linux/alpha/kernel-features.h index 0b0a94af2c..81f6c3633a 100644 --- a/lib/libc/glibc/sysdeps/unix/sysv/linux/alpha/kernel-features.h +++ b/lib/libc/glibc/sysdeps/unix/sysv/linux/alpha/kernel-features.h @@ -22,12 +22,16 @@ #include_next <kernel-features.h> -/* There never has been support for fstat64. */ -#undef __ASSUME_STATFS64 -#define __ASSUME_STATFS64 0 +/* Support for statfs64 was added in 5.1. */ +#if __LINUX_KERNEL_VERSION < 0x050100 +# undef __ASSUME_STATFS64 +# define __ASSUME_STATFS64 0 +#endif -/* Alpha defines SysV ipc shmat syscall with a different name. */ -#define __NR_shmat __NR_osf_shmat +/* Alpha used to define SysV ipc shmat syscall with a different name. */ +#ifndef __NR_shmat +# define __NR_shmat __NR_osf_shmat +#endif #define __ASSUME_RECV_SYSCALL 1 #define __ASSUME_SEND_SYSCALL 1 @@ -45,7 +49,6 @@ /* Support for copy_file_range, statx was added in kernel 4.13. */ #if __LINUX_KERNEL_VERSION < 0x040D00 # undef __ASSUME_MLOCK2 -# undef __ASSUME_COPY_FILE_RANGE # undef __ASSUME_STATX #endif diff --git a/lib/libc/glibc/sysdeps/unix/sysv/linux/alpha/sysdep.h b/lib/libc/glibc/sysdeps/unix/sysv/linux/alpha/sysdep.h index dcf2d1e3d7..d61d4df550 100644 --- a/lib/libc/glibc/sysdeps/unix/sysv/linux/alpha/sysdep.h +++ b/lib/libc/glibc/sysdeps/unix/sysv/linux/alpha/sysdep.h @@ -51,7 +51,9 @@ * Some syscalls no Linux program should know about: */ #define __NR_osf_sigprocmask 48 -#define __NR_osf_shmat 209 +#ifndef __NR_osf_shmat +# define __NR_osf_shmat 209 +#endif #define __NR_osf_getsysinfo 256 #define __NR_osf_setsysinfo 257 diff --git a/lib/libc/glibc/sysdeps/unix/sysv/linux/arm/kernel-features.h b/lib/libc/glibc/sysdeps/unix/sysv/linux/arm/kernel-features.h index 2d2d355844..4220adff37 100644 --- a/lib/libc/glibc/sysdeps/unix/sysv/linux/arm/kernel-features.h +++ b/lib/libc/glibc/sysdeps/unix/sysv/linux/arm/kernel-features.h @@ -45,7 +45,6 @@ present in 32-bit kernels from 4.4 and 4.5 respectively. */ #if __LINUX_KERNEL_VERSION < 0x040700 # undef __ASSUME_MLOCK2 -# undef __ASSUME_COPY_FILE_RANGE #endif #undef __ASSUME_CLONE_DEFAULT diff --git a/lib/libc/glibc/sysdeps/unix/sysv/linux/bits/timex.h b/lib/libc/glibc/sysdeps/unix/sysv/linux/bits/timex.h index 6b466417ff..bb272e8b19 100644 --- a/lib/libc/glibc/sysdeps/unix/sysv/linux/bits/timex.h +++ b/lib/libc/glibc/sysdeps/unix/sysv/linux/bits/timex.h @@ -104,7 +104,7 @@ struct timex #define STA_CLK 0x8000 /* clock source (0 = A, 1 = B) (ro) */ /* Read-only bits */ -#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \ - STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK) +#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER \ + | STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK) #endif /* bits/timex.h */ diff --git a/lib/libc/glibc/sysdeps/unix/sysv/linux/hppa/pthread.h b/lib/libc/glibc/sysdeps/unix/sysv/linux/hppa/pthread.h index 45e706c037..5a1c641515 100644 --- a/lib/libc/glibc/sysdeps/unix/sysv/linux/hppa/pthread.h +++ b/lib/libc/glibc/sysdeps/unix/sysv/linux/hppa/pthread.h @@ -746,6 +746,13 @@ extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex, __abstime) __THROWNL __nonnull ((1, 2)); #endif +#ifdef __USE_GNU +extern int pthread_mutex_clocklock (pthread_mutex_t *__restrict __mutex, + clockid_t __clockid, + const struct timespec *__restrict + __abstime) __THROWNL __nonnull ((1, 3)); +#endif + /* Unlock a mutex. */ extern int pthread_mutex_unlock (pthread_mutex_t *__mutex) __THROWNL __nonnull ((1)); @@ -885,6 +892,13 @@ extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock, __abstime) __THROWNL __nonnull ((1, 2)); # endif +# ifdef __USE_GNU +extern int pthread_rwlock_clockrdlock (pthread_rwlock_t *__restrict __rwlock, + clockid_t __clockid, + const struct timespec *__restrict + __abstime) __THROWNL __nonnull ((1, 3)); +# endif + /* Acquire write lock for RWLOCK. */ extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock) __THROWNL __nonnull ((1)); @@ -900,6 +914,13 @@ extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock, __abstime) __THROWNL __nonnull ((1, 2)); # endif +# ifdef __USE_GNU +extern int pthread_rwlock_clockwrlock (pthread_rwlock_t *__restrict __rwlock, + clockid_t __clockid, + const struct timespec *__restrict + __abstime) __THROWNL __nonnull ((1, 3)); +# endif + /* Unlock RWLOCK. */ extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock) __THROWNL __nonnull ((1)); @@ -979,6 +1000,21 @@ extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond, const struct timespec *__restrict __abstime) __nonnull ((1, 2, 3)); +# ifdef __USE_GNU +/* Wait for condition variable COND to be signaled or broadcast until + ABSTIME measured by the specified clock. MUTEX is assumed to be + locked before. CLOCK is the clock to use. ABSTIME is an absolute + time specification against CLOCK's epoch. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int pthread_cond_clockwait (pthread_cond_t *__restrict __cond, + pthread_mutex_t *__restrict __mutex, + __clockid_t __clock_id, + const struct timespec *__restrict __abstime) + __nonnull ((1, 2, 4)); +# endif + /* Functions for handling condition variable attributes. */ /* Initialize condition variable attribute ATTR. */ diff --git a/lib/libc/glibc/sysdeps/unix/sysv/linux/ia64/kernel-features.h b/lib/libc/glibc/sysdeps/unix/sysv/linux/ia64/kernel-features.h index 0f4948b8e0..333947931d 100644 --- a/lib/libc/glibc/sysdeps/unix/sysv/linux/ia64/kernel-features.h +++ b/lib/libc/glibc/sysdeps/unix/sysv/linux/ia64/kernel-features.h @@ -26,8 +26,10 @@ #define __ASSUME_SEND_SYSCALL 1 #define __ASSUME_ACCEPT4_SYSCALL 1 -/* No statx system call on ia64 yet. */ -#undef __ASSUME_STATX +/* Support for statx was added in 5.1. */ +#if __LINUX_KERNEL_VERSION < 0x050100 +# undef __ASSUME_STATX +#endif #undef __ASSUME_CLONE_DEFAULT #define __ASSUME_CLONE2 diff --git a/lib/libc/glibc/sysdeps/unix/sysv/linux/kernel-features.h b/lib/libc/glibc/sysdeps/unix/sysv/linux/kernel-features.h index 0db1b987a4..1518bb5228 100644 --- a/lib/libc/glibc/sysdeps/unix/sysv/linux/kernel-features.h +++ b/lib/libc/glibc/sysdeps/unix/sysv/linux/kernel-features.h @@ -57,9 +57,6 @@ 2.6.27. */ #define __ASSUME_IN_NONBLOCK 1 -/* Support for the FUTEX_CLOCK_REALTIME flag was added in 2.6.29. */ -#define __ASSUME_FUTEX_CLOCK_REALTIME 1 - /* Support for preadv and pwritev was added in 2.6.30. */ #define __ASSUME_PREADV 1 #define __ASSUME_PWRITEV 1 @@ -103,10 +100,6 @@ # define __ASSUME_MLOCK2 1 #endif -#if __LINUX_KERNEL_VERSION >= 0x040500 -# define __ASSUME_COPY_FILE_RANGE 1 -#endif - /* Support for statx was added in kernel 4.11. */ #if __LINUX_KERNEL_VERSION >= 0x040B00 # define __ASSUME_STATX 1 diff --git a/lib/libc/glibc/sysdeps/unix/sysv/linux/microblaze/kernel-features.h b/lib/libc/glibc/sysdeps/unix/sysv/linux/microblaze/kernel-features.h index 8df19400af..a787409295 100644 --- a/lib/libc/glibc/sysdeps/unix/sysv/linux/microblaze/kernel-features.h +++ b/lib/libc/glibc/sysdeps/unix/sysv/linux/microblaze/kernel-features.h @@ -60,11 +60,6 @@ # undef __ASSUME_MLOCK2 #endif -/* Support for the copy_file_range syscall was added in 4.10. */ -#if __LINUX_KERNEL_VERSION < 0x040A00 -# undef __ASSUME_COPY_FILE_RANGE -#endif - /* Support for statx was added in kernel 4.12. */ #if __LINUX_KERNEL_VERSION < 0X040C00 # undef __ASSUME_STATX diff --git a/lib/libc/glibc/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h b/lib/libc/glibc/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h index 1481094cec..640fb52de1 100644 --- a/lib/libc/glibc/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h +++ b/lib/libc/glibc/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h @@ -233,9 +233,9 @@ #undef INTERNAL_SYSCALL #define INTERNAL_SYSCALL(name, err, nr, args...) \ - (((__NR_##name) < 256) ? \ - INTERNAL_SYSCALL_DIRECT(name, err, nr, args) : \ - INTERNAL_SYSCALL_SVC0(name, err,nr, args)) + (((__NR_##name) < 256) \ + ? INTERNAL_SYSCALL_DIRECT(name, err, nr, args) \ + : INTERNAL_SYSCALL_SVC0(name, err,nr, args)) #undef INTERNAL_SYSCALL_ERROR_P #define INTERNAL_SYSCALL_ERROR_P(val, err) \ diff --git a/lib/libc/glibc/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h b/lib/libc/glibc/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h index d230192d11..9a9834c750 100644 --- a/lib/libc/glibc/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h +++ b/lib/libc/glibc/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h @@ -239,9 +239,9 @@ #undef INTERNAL_SYSCALL #define INTERNAL_SYSCALL(name, err, nr, args...) \ - (((__NR_##name) < 256) ? \ - INTERNAL_SYSCALL_DIRECT(name, err, nr, args) : \ - INTERNAL_SYSCALL_SVC0(name, err,nr, args)) + (((__NR_##name) < 256) \ + ? INTERNAL_SYSCALL_DIRECT(name, err, nr, args) \ + : INTERNAL_SYSCALL_SVC0(name, err,nr, args)) #undef INTERNAL_SYSCALL_ERROR_P #define INTERNAL_SYSCALL_ERROR_P(val, err) \ diff --git a/lib/libc/glibc/sysdeps/unix/sysv/linux/sh/kernel-features.h b/lib/libc/glibc/sysdeps/unix/sysv/linux/sh/kernel-features.h index 767df721b8..0f287fbf85 100644 --- a/lib/libc/glibc/sysdeps/unix/sysv/linux/sh/kernel-features.h +++ b/lib/libc/glibc/sysdeps/unix/sysv/linux/sh/kernel-features.h @@ -49,10 +49,11 @@ # undef __ASSUME_RENAMEAT2 # undef __ASSUME_EXECVEAT # undef __ASSUME_MLOCK2 -# undef __ASSUME_COPY_FILE_RANGE #endif -/* sh does not support the statx system call. */ -#undef __ASSUME_STATX +/* sh does not support the statx system call before 5.1. */ +#if __LINUX_KERNEL_VERSION < 0x050100 +# undef __ASSUME_STATX +#endif #endif diff --git a/lib/libc/glibc/sysdeps/unix/sysv/linux/single-thread.h b/lib/libc/glibc/sysdeps/unix/sysv/linux/single-thread.h new file mode 100644 index 0000000000..2c972f37b3 --- /dev/null +++ b/lib/libc/glibc/sysdeps/unix/sysv/linux/single-thread.h @@ -0,0 +1,62 @@ +/* Single thread optimization, Linux version. + Copyright (C) 2019 Free Software 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 _SINGLE_THREAD_H +#define _SINGLE_THREAD_H + +/* The default way to check if the process is single thread is by using the + pthread_t 'multiple_threads' field. However, for some architectures it is + faster to either use an extra field on TCB or global variables (the TCB + field is also used on x86 for some single-thread atomic optimizations). + + The ABI might define SINGLE_THREAD_BY_GLOBAL to enable the single thread + check to use global variables instead of the pthread_t field. */ + +#ifdef SINGLE_THREAD_BY_GLOBAL +# if IS_IN (libc) +extern int __libc_multiple_threads; +# define SINGLE_THREAD_P \ + __glibc_likely (__libc_multiple_threads == 0) +# elif IS_IN (libpthread) +extern int __pthread_multiple_threads; +# define SINGLE_THREAD_P \ + __glibc_likely (__pthread_multiple_threads == 0) +# elif IS_IN (librt) +# define SINGLE_THREAD_P \ + __glibc_likely (THREAD_GETMEM (THREAD_SELF, \ + header.multiple_threads) == 0) +# else +/* For rtld, et cetera. */ +# define SINGLE_THREAD_P (1) +# endif +#else /* SINGLE_THREAD_BY_GLOBAL */ +# if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) +# define SINGLE_THREAD_P \ + __glibc_likely (THREAD_GETMEM (THREAD_SELF, \ + header.multiple_threads) == 0) +# else +/* For rtld, et cetera. */ +# define SINGLE_THREAD_P (1) +# endif +#endif /* SINGLE_THREAD_BY_GLOBAL */ + +#define RTLD_SINGLE_THREAD_P \ + __glibc_likely (THREAD_GETMEM (THREAD_SELF, \ + header.multiple_threads) == 0) + +#endif /* _SINGLE_THREAD_H */ |
