Commit Graph

22114 Commits

Author SHA1 Message Date
Florian Weimer 71aa429b02 Record CVE-2018-6551 in NEWS and ChangeLog [BZ #22774] 2018-02-06 09:19:13 +01:00
Zack Weinberg 26c07172cd Remove getc and putc macros from the public stdio.h.
The getc and putc macros in the public stdio.h expand to call _IO_getc
and _IO_putc respectively.  As _IO_getc, fgetc, and getc are all aliases
for the same function, and _IO_putc, fputc, and putc are also all aliases
for the same function, the macros are pointless.  The C standard does
not require getc and putc to be macros, so let's just not have macros.
All four symbols are exported from libc.so at the same, ancient symbol
version, so there should be no risks for binary compatibility.  Similarly,
the getchar and putchar inlines in bits/stdio.h forward to getc and putc
instead of their _IO_ aliases.

As a change from longstanding historical practice, this does seem
like it might break _something_, so there is a note in NEWS, which
is also a convenient place to advise people that if they thought getc
and putc had reduced per-character overhead they should consider using
getc_unlocked and putc_unlocked instead.  (These are also not macros,
but when optimizing, they are inlines.)

	* libio/stdio.h: Don't define getc or putc as macros.
	* libio/bits/stdio.h (getchar, putchar): Use getc and putc,
	not _IO_getc and _IO_putc.
2018-02-05 19:59:03 -05:00
Zack Weinberg de6da571ee Remove some unnecessary redefinitions of std symbols.
Two files in stdio-common were unnecessarily redefining some standard
symbols as their _IO_ aliases.

	* stdio-common/vfprintf.c: Don't redefine FILE, va_list, or BUFSIZ.
        * stdio-common/tstgetln.c: Don't redefine ssize_t.
2018-02-05 19:58:01 -05:00
Joseph Myers c2b84df9b0 Add TCP_FASTOPEN_KEY, TCP_FASTOPEN_NO_COOKIE from Linux 4.15.
This patch adds the TCP_FASTOPEN_KEY and TCP_FASTOPEN_NO_COOKIE macros
from Linux 4.15 to sysdeps/gnu/netinet/tcp.h.

Tested for x86_64.

	* sysdeps/gnu/netinet/tcp.h (TCP_FASTOPEN_KEY): New macro.
	(TCP_FASTOPEN_NO_COOKIE): Likewise.
2018-02-06 00:42:22 +00:00
Joseph Myers 41376f8c62 Add IPV6_FREEBIND from Linux 4.15.
This patch adds the IPV6_FREEBIND macro from Linux 4.15 to
sysdeps/unix/sysv/linux/bits/in.h.

Tested for x86_64.

	* sysdeps/unix/sysv/linux/bits/in.h (IPV6_FREEBIND): New macro.
2018-02-06 00:41:34 +00:00
Joseph Myers d28bf64897 Add elf.h NT_* macros from Linux 4.15 (bug 14890).
Linux 4.15 adds NT_S390_RI_CB to linux/elf.h (and NT_ARM_SVE, which we
already have in glibc).  This shows up that various other ELF note
values from linux/elf.h are missing from glibc's elf.h.

This patch adds the missing values that are relevant to glibc
architectures.  As elf.h is a general description of the ELF format,
not necessarily limited to glibc configurations, there's an argument
for having the remaining NT_* values that Linux uses for non-glibc
architectures in glibc's elf.h as well, but this patch does not add
them.

Adding the NT_PRFPREG name is bug 14890.  That bug also requests
making the NT_FPREGSET name obsolete.  Given that elf.h is not just
for Linux but can describe ELF for other operating systems, I don't
think that a change of name in the Linux kernel is sufficient
justification for declaring the other name obsolete; there can be
multiple names for the same note value, even with incompatible
semantics, if those reflect variants of the ELF format in actual use.
For example, FreeBSD appears still to have the name NT_FPREGSET
<https://github.com/freebsd/freebsd/blob/master/sys/sys/elf_common.h>
(note: I haven't checked whether the FreeBSD kernel actually generates
such notes or whether this is actually an other-OS definition present
in FreeBSD's header).

	[BZ #14890]
	* elf/elf.h (NT_PRFPREG): New macro.
	(NT_S390_VXRS_LOW): Likewise.
	(NT_S390_VXRS_HIGH): Likewise.
	(NT_S390_GS_CB): Likewise.
	(NT_S390_GS_BC): Likewise.
	(NT_S390_RI_CB): Likewise.
2018-02-06 00:37:17 +00:00
Joseph Myers e76def72eb Add MAP_SYNC from Linux 4.15.
This patch adds the MAP_SYNC macro from Linux 4.15 to various
bits/mman.h headers.  Note that this is *not* added to all
architectures: in Linux 4.15, this macro is only in
asm-generic/mman.h, and only some architectures' asm/mman.h include
the asm-generic file - the architectures not using the asm-generic
file will need their own values of MAP_SYNC allocated to support this
functionality (some of them also already have conflicting mmap flags
so the value there will have to be different from the generic
0x80000).  Specifically, for glibc architectures, alpha hppa mips
powerpc sparc tile lack allocations of values for MAP_SYNC.

Tested for x86_64.

	* sysdeps/unix/sysv/linux/aarch64/bits/mman.h [__USE_MISC]
	(MAP_SYNC): New macro.
	* sysdeps/unix/sysv/linux/arm/bits/mman.h [__USE_MISC] (MAP_SYNC):
	Likewise.
	* sysdeps/unix/sysv/linux/ia64/bits/mman.h [__USE_MISC]
	(MAP_SYNC): Likewise.
	* sysdeps/unix/sysv/linux/m68k/bits/mman.h [__USE_MISC]
	(MAP_SYNC): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/bits/mman.h [__USE_MISC]
	(MAP_SYNC): Likewise.
	* sysdeps/unix/sysv/linux/nios2/bits/mman.h [__USE_MISC]
	(MAP_SYNC): Likewise.
	* sysdeps/unix/sysv/linux/riscv/bits/mman.h [__USE_MISC]
	(MAP_SYNC): Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/mman.h [__USE_MISC]
	(MAP_SYNC): Likewise.
	* sysdeps/unix/sysv/linux/sh/bits/mman.h [__USE_MISC] (MAP_SYNC):
	Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/mman.h [__USE_MISC] (MAP_SYNC):
	Likewise.
2018-02-06 00:36:14 +00:00
Joseph Myers 92669d6ee3 Add MAP_SHARED_VALIDATE from Linux 4.15.
This patch adds the MAP_SHARED_VALIDATE macro from Linux 4.15 to
bits/mman-linux.h and the hppa bits/mman.h.

Tested for x86_64.

	* sysdeps/unix/sysv/linux/bits/mman-linux.h [__USE_MISC]
	(MAP_SHARED_VALIDATE): New macro.
	* sysdeps/unix/sysv/linux/hppa/bits/mman.h [__USE_MISC]
	(MAP_SHARED_VALIDATE): Likewise.
2018-02-06 00:35:09 +00:00
H.J. Lu 6a5cac49b6 Use ADDRIDX with DT_GNU_HASH
The only differences in ld.so are line numbers for asserts.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>

	* elf/dl-addr.c (determine_info): Use ADDRIDX with DT_GNU_HASH.
	* elf/dl-lookup.c (_dl_setup_hash): Likewise.
	* elf/get-dynamic-info.h (elf_get_dynamic_info): Likewise.
2018-02-05 14:58:57 -08:00
H.J. Lu b44e0dfbac Add DT_SYMTAB_SHNDX from gABI
* elf/elf.h (DT_SYMTAB_SHNDX): New.  Set to 34.
	(DT_NUM): Updated to 35.
2018-02-05 06:30:17 -08:00
H.J. Lu f886c16ca5 i386: Use __glibc_likely/__glibc_likely in dl-machine.h
The differences in elf/dl-reloc.os are

--- before    	2018-02-05 03:53:31.970492246 -0800
+++ after     	2018-02-05 03:53:49.719902340 -0800
@@ -1202,9 +1202,9 @@ _dl_relocate_object:
 	movl	-60(%ebp), %eax
 	testl	%eax, %eax
 	je	.L249
-	movl	8(%eax), %eax
-	movl	8(%ebx), %esi
-	cmpl	%esi, %eax
+	movl	8(%eax), %esi
+	movl	8(%ebx), %eax
+	cmpl	%eax, %esi
 	ja	.L284
 	jb	.L707
 .L285:
@@ -2255,7 +2255,7 @@ _dl_relocate_object:
 	cmpl	$6, %edi
 	movl	$4, %edx
 	je	.L132
-	cmpl	%ecx, %eax
+	cmpl	%eax, %ecx
 	je	.L350
 	cmpl	$7, %edi
 	je	.L419
@@ -2735,7 +2735,7 @@ _dl_relocate_object:
 	je	.L120
 .L121:
 	movl	-96(%ebp), %edx
-	movl	$640, 8(%esp)
+	movl	$639, 8(%esp)
 	leal	__PRETTY_FUNCTION__.9431@GOTOFF(%edx), %eax
 	movl	%eax, 12(%esp)
 	leal	.LC9@GOTOFF(%edx), %eax
@@ -3454,10 +3454,10 @@ _dl_relocate_object:
 	movl	-152(%ebp), %eax
 	movl	%eax, 4(%esp)
 	call	_dl_dprintf
-	movl	-60(%ebp), %eax
-	movl	8(%ebx), %esi
+	movl	8(%ebx), %eax
+	movl	-60(%ebp), %ebx
 	movl	-112(%ebp), %edx
-	movl	8(%eax), %eax
+	movl	8(%ebx), %esi
 	jmp	.L285
 .L713:
 	movl	%esi, (%esp)

	* sysdeps/i386/dl-machine.h (elf_machine_rel): Replace
	__builtin_expect with __glibc_likely and __glibc_unlikely.
	(elf_machine_rela): Likewise.
	(elf_machine_lazy_rel): Likewise.
2018-02-05 06:22:40 -08:00
H.J. Lu 8f4bf93fb9 Fix a typo in ChangeLog entry 2018-02-05 06:21:45 -08:00
H.J. Lu 658050164d Add a missing ChangeLog item in commit 371b220f62 2018-02-05 06:20:49 -08:00
H.J. Lu 06fbebfff7 x86-64: Use __glibc_likely/__glibc_likely in dl-machine.h
The differences in elf/dl-reloc.os are

--- before    	2018-02-05 03:52:32.803125207 -0800
+++ after     	2018-02-05 03:52:14.913711879 -0800
@@ -1129,7 +1129,7 @@ _dl_relocate_object:
 	leaq	__PRETTY_FUNCTION__.9767(%rip), %rcx
 	leaq	.LC11(%rip), %rsi
 	leaq	.LC12(%rip), %rdi
-	movl	$540, %edx
+	movl	$539, %edx
 	call	__GI___assert_fail
 	.p2align 4,,10
 	.p2align 3

	* sysdeps/x86_64/dl-machine.h (elf_machine_rela): Replace
	__builtin_expect with __glibc_likely and __glibc_likely.
	(elf_machine_lazy_rel): Likewise.
2018-02-05 06:08:07 -08:00
H.J. Lu 371b220f62 sparc: Check PIC instead of SHARED in start.S [BZ #22638]
Since start.o may be compiled as PIC, we should check PIC instead of
SHARED.

	[BZ #22638]
	* sysdeps/sparc/sparc32/start.S (_start): Check PIC instead of
	SHARED.
	* sysdeps/sparc/sparc64/start.S (_start): Likewise.
2018-02-05 05:46:56 -08:00
Andreas Schwab f649a1b8b0 Fix uninitialized variable in assert_perror (bug 22761) 2018-02-05 11:06:15 +01:00
Samuel Thibault 9fdb340e64 hurd: Fix build
* stdlib/test-atexit-race-common.c [!defined PTHREAD_STACK_MIN]: Do
	not check against PTHREAD_STACK_MIN.
2018-02-04 14:02:36 +01:00
Sean McKean 09e56b9e18 time: Reference CLOCKS_PER_SEC in clock comment [BZ #22735] 2018-02-02 11:59:31 +01:00
Florian Weimer d4b4a00a46 preadv2/pwritev2: Handle offset == -1 [BZ #22753]
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2018-02-02 10:46:26 +01:00
Siddhesh Poyarekar 84c94d2fd9 aarch64: Use the L() macro for labels in memcmp
The L() macro makes the assembly a bit more readable.

	* sysdeps/aarch64/memcmp.S: Use L() macro for labels.
2018-02-02 10:15:21 +05:30
Siddhesh Poyarekar 96e6a7167e benchtests: Make bench-memcmp print json
The benchamrk result can now be studied using the compare_strings.py
script.

	* benchtests/bench-memcmp.c: Print json instead of plain text.
2018-02-02 09:56:47 +05:30
Siddhesh Poyarekar 3dfcbfa1a4 benchtests: Reallocate buffers for every test run
Keeping the buffers the same across test runs gives later invocations
the advantage since they access cached data.  Reallocate so that all
test runs are on equal grounds.

	* benchtests/bench-memcmp.c (do_test): Call realloc_buf for
	every test run.
2018-02-02 09:55:45 +05:30
Joseph Myers 39f898c692 Update syscall-names.list for 4.15.
This patch updates sysdeps/unix/sysv/linux/syscall-names.list for
Linux 4.15.  There only appears to be one new syscall to add to the
list.  (The riscv_flush_icache syscall is *not* added because for
whatever reason it doesn't appear in the uapi asm/unistd.h; only in
arch/riscv/include/uapi/asm/syscalls.h, which is only included by the
non-uapi asm/unistd.h - and only syscalls whose __NR_* macros are
defined in the uapi asm/unistd.h are relevant for this list.)

Tested for x86_64, and with build-many-glibcs.py.

	* sysdeps/unix/sysv/linux/syscall-names.list: Update kernel
	version to 4.15.
	(s390_sthyi): New syscall.
2018-02-01 21:10:04 +00:00
Joseph Myers 6f9a3dd8b8 Move LDBL_CLASSIFY_COMPAT to its own header.
The general rule in glibc is that it's better for a macro to be always
defined, and tested with #if, than for it to be tested with #ifdef,
because the latter is prone to typos in the macro name as well as to
the header with the macro accidentally not being included in a file
testing it.  (Testing with an "if" statement is even better, in those
cases where it's possible to do things that way, as it then means both
cases in the code get checked for syntax in glibc builds with either
value of the condition.)

math_private.h has several different groups of macros, meaning that
architectures wanting to override some of them need to define those
then include the generic version, which then defines macros if not
already defined.  It's hard to avoid that arrangement completely, but
various cases can be improved by splitting out macros or groups of
macros into separate files.

This patch splits out the LDBL_CLASSIFY_COMPAT macro into a separate
ldbl-classify-compat.h header.  This macro is tested with #ifdef; this
patch changes it to testing with #if, with a default definition to 0
in the generic header and then architecture-specific headers defining
it to 1.

Tested with build-many-glibcs.py that installed stripped shared
libraries are unchanged by the patch.

	* sysdeps/generic/ldbl-classify-compat.h: New file.
	* sysdeps/arm/ldbl-classify-compat.h: Likewise.
	* sysdeps/m68k/coldfire/ldbl-classify-compat.h: Likewise.
	* sysdeps/microblaze/ldbl-classify-compat.h: Likewise.
	* sysdeps/mips/ldbl-classify-compat.h: Likewise.
	* sysdeps/nios2/ldbl-classify-compat.h: Likewise.
	* sysdeps/sh/ldbl-classify-compat.h: Likewise.
	* sysdeps/ieee754/dbl-64/s_finite.c: Include
	<ldbl-classify-compat.h>.
	[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
	* sysdeps/ieee754/dbl-64/s_isinf.c: Include
	<ldbl-classify-compat.h>.
	[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
	* sysdeps/ieee754/dbl-64/s_isnan.c: Include
	<ldbl-classify-compat.h>.
	[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c: Include
	<ldbl-classify-compat.h>.
	[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c: Include
	<ldbl-classify-compat.h>.
	[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c: Include
	<ldbl-classify-compat.h>.
	[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
	* sysdeps/arm/math_private.h (LDBL_CLASSIFY_COMPAT): Remove macro.
	* sysdeps/mips/math_private.h (LDBL_CLASSIFY_COMPAT): Likewise.
	* sysdeps/m68k/coldfire/math_private.h: Remove file.
	* sysdeps/microblaze/math_private.h: Likewise.
	* sysdeps/nios2/math_private.h: Likewise.
	* sysdeps/sh/math_private.h: Likewise.
2018-02-01 21:01:00 +00:00
Joseph Myers eb65a3d545 Remove some math_private.h libc_feholdexcept_setround overrides.
math_private.h headers for configurations lacking support for
floating-point exceptions and rounding modes define
libc_feholdexcept_setround to override the default version with one
that discards its rounding mode argument.

Unlike other such libc_fe* macros that I removed, this one is actually
used for such configurations (in dbl-64/e_sqrt.c).  However, this does
not make the macro required.  It's only used for such configurations
with FE_TONEAREST as the rounding mode (anything needing another mode
should not be used when that mode is unavailable), and the default
definition just calls __feholdexcept and __fesetround.  Since we now
have suitable inline do-nothing definitions of __feholdexcept and
__fesetround for the cases of no exceptions and rounding modes, we can
just rely on those inlines to achieve the same optimization as this
macro definition.  Thus, this patch removes those macro definitions
(and the math_private.h headers containing them, when no longer needed
after that removal).

Tested with build-many-glibcs.py that installed stripped shared
libraries are unchanged by the patch.

	* sysdeps/m68k/coldfire/fpu/math_private.h: Move to ....
	* sysdeps/m68k/coldfire/math_private.h: ... here.
	* sysdeps/m68k/coldfire/nofpu/math_private.h: Remove file.
	* sysdeps/tile/math_private.h: Likewise.
	* sysdeps/microblaze/math_private.h (libc_feholdexcept_setround):
	Remove macro.
	* sysdeps/nios2/math_private.h (libc_feholdexcept_setround):
	Likewise.
2018-02-01 20:58:57 +00:00
Joseph Myers 8a6bb1d086 Remove some math_private.h libc_fe* overrides.
math_private.h headers for configurations lacking support for
floating-point exceptions and rounding modes define various libc_fe*
macros to override the default versions with ones that discard any
exception or rounding mode arguments.

Three of the four macros defined in these headers are no longer needed
there: those macros are only used in fma implementations that are not
used for such configurations, now all those configurations properly
use soft-fp fma implementations instead.  (Effectively, those macros
were a workaround to allow glibc to build in the absence of a proper
fma implementation for this case - now there is such an
implementation, there is no need to support building the wrong
implementation for those configurations.)  Thus, this patch removes
the unnecessary macros.

Tested with build-many-glibcs.py that installed stripped shared
libraries are unchanged by the patch.

	* sysdeps/m68k/coldfire/nofpu/math_private.h (libc_fesetround):
	Remove macro.
	(libc_fetestexcept): Likewise.
	(libc_feupdateenv_test): Likewise.
	* sysdeps/microblaze/math_private.h (libc_fesetround): Likewise.
	(libc_fetestexcept): Likewise.
	(libc_feupdateenv_test): Likewise.
	* sysdeps/nios2/math_private.h (libc_fesetround): Likewise.
	(libc_fetestexcept): Likewise.
	(libc_feupdateenv_test): Likewise.
	* sysdeps/tile/math_private.h (libc_fesetround): Likewise.
	(libc_fetestexcept): Likewise.
	(libc_feupdateenv_test): Likewise.
2018-02-01 20:57:22 +00:00
Joseph Myers ae1fcb7b92 Add feholdexcept inline in generic math_private.h.
Continuing the process of improving and cleaning up the handling of
configurations lacking support for floating-point exceptions and
rounding modes, this patch adds trivial inline definitions of
feholdexcept and __feholdexcept to the set of inlines for such
configurations in math_private.h.  These inlines were missing from the
tile version used as a basis for the previous inlines, despite a few
such function calls ending up in libm.so.

Tested with build-many-glibcs.py.  As expected, installed stripped
shared libraries are unchanged for architectures supporting exceptions
and rounding modes, but changed for architectures lacking such
support.

	* sysdeps/generic/math_private.h
	[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (feholdexcept):
	New inline function.
	[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (__feholdexcept):
	Likewise.
2018-02-01 20:56:08 +00:00
Joseph Myers b1c347e2cd Move fenv.h override inline functions to generic math_private.h.
The tile version of math_private.h defines some inline functions for
fenv.h functions, to optimize away internal calls to these functions
that do nothing given no support for floating-point exceptions and
rounding modes.  (Some functions may have error cases for invalid
arguments, but those aren't applicable to the internal calls from
within glibc.)  Other configurations lacking support for exceptions
and rounding modes lack such inline functions.  This patch moves them
to the generic math_private.h, appropriately conditioned, so that all
such configurations can benefit from the.

include/fenv.h is made to check whether there are any non-default
rounding modes; that needs to be done there, rather than later,
because get-rounding-mode.h defines values for otherwise unsupported
FE_* rounding modes.  It also gives an error for FE_TONEAREST
undefined, a case that already did not work for building the glibc
testsuite; the convention has by now been established that all
architectures need to provide a version of bits/fenv.h that at least
defines FE_TONEAREST.

Tested with build-many-glibcs.py.  As expected, installed stripped
shared libraries are unchanged for tile and for architectures
supporting exceptions and rounding modes, but changed for non-tile
architectures not supporting exceptions and rounding modes that
previously lacked this optimization (e.g. Nios II libm.so is about 1kB
smaller).

The optimization is not in fact complete (does not cover feholdexcept
/ __feholdexcept, so a few calls to those remain unnecessarily within
libm even after this patch), but that can be dealt with separately.

	* include/fenv.h [!_ISOMAC && !FE_TONEAREST]: Give #error.
	[!_ISOMAC] (FE_HAVE_ROUNDING_MODES): New macro.
	* sysdeps/generic/math_private.h
	[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (fegetenv): New
	inline function.
	[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (__fegetenv):
	Likewise.
	[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (fesetenv):
	Likewise.
	[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (__fesetenv):
	Likewise.
	[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (feupdateenv):
	Likewise.
	[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (__feupdateenv):
	Likewise.
	[!FE_HAVE_ROUNDING_MODES] (fegetround): Likewise.
	[!FE_HAVE_ROUNDING_MODES] (__fegetround): Likewise.
	[!FE_HAVE_ROUNDING_MODES] (fesetround): Likewise.
	[!FE_HAVE_ROUNDING_MODES] (__fesetround): Likewise.
	* sysdeps/tile/math_private.h (fegetenv): Remove inline function.
	(__fegetenv): Likewise.
	(fesetenv): Likewise.
	(__fesetenv): Likewise.
	(feupdateenv): Likewise.
	(__feupdateenv): Likewise.
	(fegetround): Likewise.
	(__fegetround): Likewise.
	(fesetround): Likewise.
	(__fesetround): Likewise.
2018-02-01 20:54:44 +00:00
Joseph Myers d23a4962bb Move some fenv.h override macros to generic math_private.h.
Various configurations lacking support for floating-point exceptions
and rounding modes have a math_private.h that overrides certain
functions and macros, internal and external, to avoid references to
FE_* constants that are undefined in those configurations.  For
example, there are unconditional feraiseexcept (FE_INVALID) calls in
generic libm code, and these macro definitions duly define
feraiseexcept to ignore its argument to avoid an error from FE_INVALID
being undefined.

In fact it is easy to tell in an architecture-independent way whether
this is needed, by testing whether FE_ALL_EXCEPT == 0.  Thus, this
patch puts such a test, and feraiseexcept and __feraiseexcept macros,
in the generic math_private.h, so reducing the duplication between
architecture versions of this header.  The feclearexcept macro present
in several versions of this header, and fetestexcept in the tile
version, are not needed; they would have been needed before there were
proper soft-fp fma implementations (when generic versions, that depend
on FE_TOWARDZERO and FE_INEXACT, were being used for configurations
not supporting those features), but aren't needed any more, and so are
removed.

The tile version of this header has several inline functions for
fenv.h functions to optimize calls to them away in such configurations
where they do nothing useful, and all these header versions also have
definitions of some of the libc_fe* internal macros.  I intend to make
those generic in subsequent patches.

Tested with build-many-glibcs.py that installed stripped shared
libraries are unchanged by this patch.

	* sysdeps/generic/math_private.h [FE_ALL_EXCEPT == 0]
	(feraiseexcept): New macro.
	[FE_ALL_EXCEPT == 0] (__feraiseexcept): Likewise.
	* sysdeps/m68k/coldfire/nofpu/math_private.h (feraiseexcept):
	Remove macro.
	(__feraiseexcept): Likewise.
	(feclearexcept): Likewise.
	* sysdeps/microblaze/math_private.h (feraiseexcept): Likewise.
	(__feraiseexcept): Likewise.
	(feclearexcept): Likewise.
	* sysdeps/nios2/math_private.h (feraiseexcept): Likewise.
	(__feraiseexcept): Likewise.
	(feclearexcept): Likewise.
	* sysdeps/tile/math_private.h (feraiseexcept): Likewise.
	(__feraiseexcept): Likewise.
	(feclearexcept): Likewise.
	(fetestexcept): Likewise.
2018-02-01 20:52:59 +00:00
Joseph Myers 5f167950df Add ColdFire math-tests.h.
Since I've been fixing build issues for ColdFire, this patch adds a
math-tests.h file for ColdFire, reflecting the lack of support for
exceptions and rounding modes for soft float.  I think it is logically
correct, but have not tested it beyond build-many-glibcs.py for both
hard and soft float.

	* sysdeps/m68k/coldfire/math-tests.h: New file.
2018-02-01 20:50:00 +00:00
Joseph Myers ccc9035a67 Fix m68k bits/fenv.h for no-FPU ColdFire.
The m68k bits/fenv.h is in sysdeps/m68k/fpu/, meaning that no-FPU
ColdFire instead gets the generic (top-level) bits/fenv.h.

That top-level bits/fenv.h defines no rounding mode constants.  That
no longer works for building glibc tests: some tests fail to build (at
least with warnings) if no rounding mode macros are defined, so at
least FE_TONEAREST must be defined in all cases (as various
architectures without rounding mode support indeed do), while
__FE_UNDEFINED must be defined in the case where not all the standard
rounding modes are supported.

On general principles of supporting multilib toolchains with a single
set of headers shared between multilibs for a given architecture, it's
also desirable for the same bits/fenv.h header to work for both FPU
and no-FPU configurations.  Thus, this patch moves the m68k
bits/fenv.h to sysdeps/m68k/bits/fenv.h, and inserts appropriate
conditionals to handle the no-FPU case.  All the exception macros, and
FE_NOMASK_ENV, are disabled in the no-FPU case; FE_ALL_EXCEPT is
defined to 0 in that case.  All rounding modes except FE_TONEAREST are
disabled in that case, and __FE_UNDEFINED is defined accordingly.  To
avoid an unnecessary ABI change, fenv_t is defined in the no-FPU case
to match the definition it would have got from the generic
bits/fenv.h.

This suffices to get a clean glibc and testsuite build for this
configuration with build-many-glibcs.py (and keeps a clean build for
the other m68k configurations); it has not been otherwise tested.

	* sysdeps/m68k/fpu/bits/fenv.h: Move to ....
	* sysdeps/m68k/bits/fenv.h: ... here.
	[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__] (FE_INEXACT): Do
	not define.
	[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__] (FE_DIVBYZERO):
	Likewise.
	[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__] (FE_UNDERFLOW):
	Likewise.
	[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__] (FE_OVERFLOW):
	Likewise.
	[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__] (FE_INVALID):
	Likewise.
	[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__] (FE_ALL_EXCEPT):
	Define to 0.
	[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__]
	(__FE_UNDEFINED): New enum constant.
	[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__] (FE_TOWARDZERO):
	Do not define.
	[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__] (FE_DOWNWARD):
	Likewise.
	[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__] (FE_UPWARD):
	Likewise.
	[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__] (fenv_t): Define
	to match generic bits/fenv.h.
	[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__] (FE_NOMASK_ENV):
	Do not define.
2018-02-01 20:48:22 +00:00
Joseph Myers 049375e2b5 Do not use packed structures in soft-fp.
Building for soft-float ColdFire produces an error in soft-fp:

In file included from ../sysdeps/ieee754/soft-fp/s_fmaf.c:42:
../soft-fp/single.h:85:3: error: 'packed' attribute ignored for field of type 'struct <anonymous>' [-Werror=attributes]
   } bits __attribute__ ((packed));
   ^

While this error only appears in that particular case, this attribute
is in fact never useful, on any architecture.  If you have

  struct __attribute__ ((packed)) { ... } bits;

or

  struct { ... } __attribute__ ((packed)) bits;

then the attribute affects the layout of the structure type.  But with
the form used in this code

  struct { ... } bits __attribute__ ((packed));

the field bits is being declared packed, but the layout of its type
has already been determined at that point.  If on any platform the
layout of the sequence of bit-fields were wrong without the use of a
packed attribute, the attribute would need to be used via a definition
of _FP_STRUCT_LAYOUT, not in its present position.

So this patch removes the useless attribute to fix the build for
ColdFire soft-float.  Tested with build-many-glibcs.py that installed
stripped shared libraries are unchanged by the patch.

	* soft-fp/double.h (union _FP_UNION_D): Do not use attribute
	packed on bits.
	* soft-fp/extended.h (union _FP_UNION_E): Likewise.
	* soft-fp/half.h (union _FP_UNION_H): Likewise.
	* soft-fp/quad.h (union _FP_UNION_Q): Likewise.
	* soft-fp/single.h (union _FP_UNION_S): Likewise.
2018-02-01 20:44:49 +00:00
Carlos O'Donell f1d7368196 Fix -Os log1p, log1pf build (bug 21314).
As reported in bug 21314, building log1p and log1pf fails with -Os
because of a spurious -Wmaybe-uninitialized warning (reported there
for GCC 5 for MIPS, I see it also with GCC 7 for x86_64).  This patch,
based on the patches in the bug, fixes this using the DIAG_* macros.

Tested for x86_64 with -Os that this eliminates those warnings and so
allows the build to progress further.

2018-02-01  Carlos O'Donell  <carlos@redhat.com>
	    Ramin Seyed-Moussavi  <lordrasmus@gmail.com>
	    Joseph Myers  <joseph@codesourcery.com>

	[BZ #21314]
	* sysdeps/ieee754/dbl-64/s_log1p.c: Include <libc-diag.h>.
	(__log1p): Disable -Wmaybe-uninitialized for -Os around
	computation using c.
	* sysdeps/ieee754/flt-32/s_log1pf.c: Include <libc-diag.h>.
	(__log1pf): Disable -Wmaybe-uninitialized for -Os around
	computation using c.
2018-02-01 20:40:48 +00:00
Dmitry V. Levin 086ee48eae Open master branch for glibc 2.28 development 2018-02-01 17:18:19 +00:00
Dmitry V. Levin 23158b08a0 Update for 2.27 release 2018-02-01 16:17:18 +00:00
Dmitry V. Levin 363e4519a6 Fix ChangeLog formatting 2018-02-01 16:17:18 +00:00
Dmitry V. Levin 242cbc9047 NEWS: add the list of bugs fixed in 2.27 2018-02-01 16:17:18 +00:00
Florian Weimer 4590634fd6 Record CVE-2018-6485 in ChangeLog and NEWS [BZ #22343] 2018-02-01 17:16:53 +01:00
Adhemerval Zanella 673e230560 stdlib: Fixing test-*atexit*-race tests on ia64
These tests require a new thread stack size set to a value (0x20000)
lower than the architecture minimum (0x30000).  Set the stack size
to PTHREAD_STACK_MIN in this case.

Checked on ia64-linux-gnu.

	* stdlib/test-atexit-race-common.c (do_test): Check stack size
	against PTHREAD_STACK_MIN.
2018-02-01 11:17:44 -02:00
Dmitry V. Levin ced64e014c Update contributions in the manual
* manual/contrib.texi (Palmer Dabbelt, Arjun Shankar, Florian Weimer):
New entries.
(Rafal Luzynski, Andreas Schwab): Update.
2018-02-01 13:07:39 +00:00
Rafal Luzynski c10c9a5efe NEWS: List the languages which use the alternative months.
[BZ #10871]
	* NEWS: List the languages which actually use the alternative
	months feature in this release.  Also explain that "alt_mon" and
	"ab_alt_mon" are optional.
2018-02-01 11:19:29 +01:00
Il'ya Malakhov 650ba77ad5 crypt: Fix badsalttest test (Bug 22765)
The value of 'cd.initialized' is left uninitialized before the
first invocation of 'crypt_r ()' in this test despite the fact
that it should be set to zero according to the API.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-02-01 00:02:49 -08:00
Dmitry V. Levin 9349311964 Update information about the newest versions of tools used to build glibc
* manual/install.texi (Tools for Compilation): Update the newest
versions of gcc, binutils, texinfo, gawk, bison, and sed.
* INSTALL: Regenerated.
2018-01-31 14:20:10 +00:00
Samuel Thibault 407552cf0b allocalim.h: use __glibc_likely instead of __builtin_expect
* sysdeps/pthread/allocalim.h (__libc_use_alloca): Use __glibc_likely
	instead of __builtin_expect.
2018-01-30 21:42:21 +01:00
Samuel Thibault d31a4a4803 hurd: Fix ChangeLog date 2018-01-30 19:56:30 +01:00
Florian Weimer d7536874b8 nss: Adjust tests to use nss_files only 2018-01-30 14:26:31 +01:00
Rafal Luzynski 9a1b267d47 hr_HR: Add alternative month names (bug 10871).
[BZ #10871]
	* localedata/locales/hr_HR (mon): Rename to...
	(alt_mon): This.
	(mon): Import from CLDR (genitive case).
	(d_t_fmt): Update the comment.
2018-01-30 12:48:17 +01:00
Samuel Thibault ef4cf463e5 hurd: Add tlsdesc.sym
* sysdeps/mach/hurd/i386/tlsdesc.sym: New file.
2018-01-30 00:52:48 +01:00
Samuel Thibault ac56adbb0c hurd: disable hp timing
We don't have support for hp timing for now, even the i686 variant, which needs
to know the CPU speed.
Copied from sysdeps/generic/hp-timing.h

	* sysdeps/mach/hurd/hp-timing.h: New file.
2018-01-30 00:47:31 +01:00
Samuel Thibault 99dfbef48d hurd: Fix comments for FREAD and FWRITE
* bits/fcntl.h: Fix comment for FREAD and FWRITE.
	* sysdeps/mach/hurd/bits/fcntl.h: Likewise.
2018-01-29 23:00:17 +01:00
Samuel Thibault 406e7a0a47 malloc: Use assert.h's assert macro
This avoids assert definition conflicts if some of the headers used by
malloc.c happens to include assert.h.  Malloc still needs a malloc-avoiding
implementation, which we get by redirecting __assert_fail to malloc's
__malloc_assert.

	* malloc/malloc.c: Include <assert.h>.
	(assert): Do not define.
	[!defined NDEBUG] (__assert_fail): Define to __malloc_assert.
2018-01-29 23:00:17 +01:00
Samuel Thibault 2aadb70562 libio: Rename _FWRITE to FWRITE_FUNC
_FWRITE would be in the reserved-namespace.

	* libio/tst-memstream3.c (_FWRITE): Rename to FWRITE_FUNC.
	(do_test_bz20181): Rename accordingly.
2018-01-29 23:00:17 +01:00
Samuel Thibault ba729de643 allocalim.h: Fix codestyle
* sysdeps/pthread/allocalim.h (__libc_use_alloca): Commute operands of
	|| to respect codestyle.
2018-01-29 23:00:17 +01:00
Samuel Thibault 1fd1e27ca7 hurd: Fix ChangeLog date 2018-01-29 23:00:17 +01:00
Andreas Schwab 9a1793289b Reject invalid definitions of _POSIX_CHOWN_RESTRICTED, _POSIX_NO_TRUNC, _POSIX_VDISABLE
POSIX requires that the constants _POSIX_CHOWN_RESTRICTED,
_POSIX_NO_TRUNC, and _POSIX_VDISABLE are always defined to a value other
than -1.
2018-01-29 22:21:21 +01:00
Samuel Thibault e01e0ddc42 hurd: Add expected ABI lists
* hurd/Versions: Fix version when _hurd_exec_paths was added.
* mach/Versions: Fix version when __mach_host_self_ was added.
* sysdeps/mach/hurd/i386/ld.abilist: New file.
* sysdeps/mach/hurd/i386/libBrokenLocale.abilist: New file.
* sysdeps/mach/hurd/i386/libanl.abilist: New file.
* sysdeps/mach/hurd/i386/libc.abilist: New file.
* sysdeps/mach/hurd/i386/libcrypt.abilist: New file.
* sysdeps/mach/hurd/i386/libdl.abilist: New file.
* sysdeps/mach/hurd/i386/libm.abilist: New file.
* sysdeps/mach/hurd/i386/libnsl.abilist: New file.
* sysdeps/mach/hurd/i386/libresolv.abilist: New file.
* sysdeps/mach/hurd/i386/librt.abilist: New file.
* sysdeps/mach/hurd/i386/libutil.abilist: New file.
2018-01-29 22:07:44 +01:00
Palmer Dabbelt 521877e10c
RISC-V: Add ipc_priv.h
This contains a definition of __IPC_64 that matches the RISC-V Linux
ABI.

2018-01-29  Darius Rad  <darius@bluespec.com>

        * sysdeps/unix/sysv/linux/riscv/ipc_priv.h: New file.
2018-01-29 10:43:15 -08:00
Palmer Dabbelt 0fd5d876d2
Add RISC-V to build-many-glibcs.py
For full disclosure, I've only run build-many-glibcs.py with the
additional diff below.

    diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
    index 1c7b85050b57..22cc7b427041 100755
    --- a/scripts/build-many-glibcs.py
    +++ b/scripts/build-many-glibcs.py
    @@ -706,7 +706,7 @@ class Context(object):
                                 'gcc': 'vcs-7',
                                 'glibc': 'vcs-mainline',
                                 'gmp': '6.1.2',
    -                            'linux': '4.14',
    +                            'linux': '4.15-rc8',
                                 'mpc': '1.0.3',
                                 'mpfr': '3.1.6'}
             use_versions = {}
    @@ -841,7 +841,7 @@ class Context(object):
             url_map = {'binutils':
    'https://ftp.gnu.org/gnu/binutils/binutils-%(version)s.tar.bz2',
                        'gcc':
    'https://ftp.gnu.org/gnu/gcc/gcc-%(version)s/gcc-%(version)s.tar.bz2',
                        'gmp':
    'https://ftp.gnu.org/gnu/gmp/gmp-%(version)s.tar.xz',
    -                   'linux':
                        'https://www.kernel.org/pub/linux/kernel/v4.x/linux-%(version)s.tar.xz',
    +                   'linux':
    'https://git.kernel.org/torvalds/t/linux-%(version)s.tar.gz',
                        'mpc':
    'https://ftp.gnu.org/gnu/mpc/mpc-%(version)s.tar.gz',
                        'mpfr':
    'https://ftp.gnu.org/gnu/mpfr/mpfr-%(version)s.tar.xz'}
             if component not in url_map:

2018-01-29  Palmer Dabbelt  <palmer@sifive.com>

        * scripts/build-many-glibcs.py (Context): Add RISC-V targets.
        (Config): Likewise.
2018-01-29 10:43:15 -08:00
Palmer Dabbelt c506155709
RISC-V: Build Infastructure
This patch lays out the top-level orginazition of the RISC-V port.  It
contains all the Implies files as well as various other fragments of
build infastructure for the RISC-V port.  This contains the only change
to a shared file: config.h.in.

RISC-V is a family of base ISAs with optional extensions.  The base ISAs
are RV32I and RV64I, which are 32-bit and 64-bit integer-only ISAs, but
this port currently only supports RV64I based systems.  Support for
RISC-V lives in in sysdeps/riscv.  In addition to these ISAs, our glibc
port supports most of the currently-defined extensions: the A extension
for atomics, the M extension for multiplication, the C extension for
compressed instructions, and the F/D extensions for single/double
precision IEEE floating-point.  Most of these extensions are handled by
GCC, but glibc defines various floating-point wrappers and emulation
routines as well as some atomic wrappers.

We support running glibc-based programs on Linux, the support for which
lives in sysdeps/unix/sysv/linux/riscv.

2018-01-29  Palmer Dabbelt  <palmer@sifive.com>

        * sysdeps/riscv/Implies: New file.
        * sysdeps/riscv/Makefile: Likewise.
        * sysdeps/riscv/configure: Likewise.
        * sysdeps/riscv/configure.ac: Likewise.
        * sysdeps/riscv/nptl/Makefile: Likewise.
        * sysdeps/riscv/preconfigure: Likewise.
        * sysdeps/riscv/rv64/Implies-after: Likewise.
        * sysdeps/riscv/rv64/rvd/Implies: Likewise.
        * sysdeps/riscv/rv64/rvf/Implies: Likewise.
        * sysdeps/unix/sysv/linux/riscv/Implies: Likewise.
        * sysdeps/unix/sysv/linux/riscv/Makefile: Likewise.
        * sysdeps/unix/sysv/linux/riscv/Versions: Likewise.
        * sysdeps/unix/sysv/linux/riscv/configure: Likewise.
        * sysdeps/unix/sysv/linux/riscv/configure.ac: Likewise.
        * sysdeps/unix/sysv/linux/riscv/ldd-rewrite.sed: Likewise.
        * sysdeps/unix/sysv/linux/riscv/rv64/Implies: Likewise.
        * sysdeps/unix/sysv/linux/riscv/rv64/Makefile: Likewise.
        * sysdeps/unix/sysv/linux/riscv/shlib-versions: Likewise.
2018-01-29 10:43:15 -08:00
Palmer Dabbelt 2268c4337c
RISC-V: Add ABI Lists
I started with the aarch64 ABI lists and manually went through each
difference, ensuring that the missing entries had been deprecated along
the line.  Darius generated the ulps files by running the test cases on QEMU.

2018-01-29  Palmer Dabbelt  <palmer@sifive.com>

        * sysdeps/riscv/nofpu/libm-test-ulps: New file.
        * sysdeps/riscv/nofpu/libm-test-ulps-name: Likewise.
        * sysdeps/riscv/rv64/rvd/libm-test-ulps: Likewise.
        * sysdeps/riscv/rv64/rvd/libm-test-ulps-name: Likewise.
        * sysdeps/unix/sysv/linux/riscv/localplt.data: Likewise.
        * sysdeps/unix/sysv/linux/riscv/rv64/c++-types.data: Likewise.
        * sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist: Likewise.
        * sysdeps/unix/sysv/linux/riscv/rv64/libanl.abilist: Likewise.
        * sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist: Likewise.
        * sysdeps/unix/sysv/linux/riscv/rv64/libdl.abilist: Likewise.
        * sysdeps/unix/sysv/linux/riscv/rv64/libm.abilist: Likewise.
        * sysdeps/unix/sysv/linux/riscv/rv64/libnsl.abilist: Likewise.
        * sysdeps/unix/sysv/linux/riscv/rv64/librt.abilist: Likewise.
        * sysdeps/unix/sysv/linux/riscv/rv64/libutil.abilist: Likewise.
2018-01-29 10:37:28 -08:00
Palmer Dabbelt ee53fed9d8
RISC-V: Linux Startup and Dynamic Loading Code
This contains the Linux-specific code for loading programs on RISC-V.

2018-01-29  Palmer Dabbelt  <palmer@sifive.com>

        * sysdeps/unix/sysv/linux/riscv/dl-static.c: New file.
        * sysdeps/unix/sysv/linux/riscv/ldconfig.h: Likewise.
        * sysdeps/unix/sysv/linux/riscv/ldsodefs.h: Likewise.
2018-01-29 10:37:28 -08:00
Palmer Dabbelt 7f33b09c65
RISC-V: Linux ABI
Linux-specific code that is required for maintaining ABI compatibility.
This doesn't contain the actual system call interface, that is split out
in order to avoid having a patch that's too big.

2018-01-29  Palmer Dabbelt  <palmer@sifive.com>

        * sysdeps/riscv/nptl/pthread-offsets.h: New file.
        * sysdeps/riscv/nptl/pthreaddef.h: Likewise.
        * sysdeps/unix/sysv/linux/riscv/bits/fcntl.h: Likewise.
        * sysdeps/unix/sysv/linux/riscv/bits/mman.h: Likewise.
        * sysdeps/unix/sysv/linux/riscv/bits/sigcontext.h: Likewise.
        * sysdeps/unix/sysv/linux/riscv/dl-cache.h: Likewise.
        * sysdeps/unix/sysv/linux/riscv/flush-icache.c: Likewise.
        * sysdeps/unix/sysv/linux/riscv/getcontext.S: Likewise.
        * sysdeps/unix/sysv/linux/riscv/init-first.c: Likewise.
        * sysdeps/unix/sysv/linux/riscv/libc-vdso.h: Likewise.
        * sysdeps/unix/sysv/linux/riscv/makecontext.c: Likewise.
        * sysdeps/unix/sysv/linux/riscv/readelflib.c: Likewise.
        * sysdeps/unix/sysv/linux/riscv/register-dump.h: Likewise.
        * sysdeps/unix/sysv/linux/riscv/setcontext.S: Likewise.
        * sysdeps/unix/sysv/linux/riscv/sigcontextinfo.h: Likewise.
        * sysdeps/unix/sysv/linux/riscv/swapcontext.S: Likewise.
        * sysdeps/unix/sysv/linux/riscv/sys/cachectl.h: Likewise.
        * sysdeps/unix/sysv/linux/riscv/sys/procfs.h: Likewise.
        * sysdeps/unix/sysv/linux/riscv/sys/ucontext.h: Likewise.
        * sysdeps/unix/sysv/linux/riscv/sys/user.h: Likewise.
        * sysdeps/unix/sysv/linux/riscv/ucontext-macros.h: Likewise.
        * sysdeps/unix/sysv/linux/riscv/ucontext_i.sym: Likewise.
2018-01-29 10:37:27 -08:00
Palmer Dabbelt 36960f0c76
RISC-V: Linux Syscall Interface
Contains the Linux system call interface, as well as the definitions of
a handful of system calls.

2018-01-29  Palmer Dabbelt  <palmer@sifive.com>

        * sysdeps/riscv/nptl/nptl-sysdep.S: New file.
        * sysdeps/unix/sysv/linux/riscv/arch-fork.h: Likewise.
        * sysdeps/unix/sysv/linux/riscv/clone.S: Likewise.
        * sysdeps/unix/sysv/linux/riscv/profil-counter.h: Likewise.
        * sysdeps/unix/sysv/linux/riscv/pt-vfork.S: Likewise.
        * sysdeps/unix/sysv/linux/riscv/syscall.c: Likewise.
        * sysdeps/unix/sysv/linux/riscv/sysdep.S: Likewise.
        * sysdeps/unix/sysv/linux/riscv/sysdep.h: Likewise.
        * sysdeps/unix/sysv/linux/riscv/vfork.S: Likewise.
2018-01-29 10:27:52 -08:00
Palmer Dabbelt d1c09b2471
RISC-V: Atomic and Locking Routines
This patch implements various atomic and locking routines on RISC-V.  We
mandate the A extension on Linux-capable RISC-V systems, so this can
rely on always having the various atomic instructions availiable.

2018-01-29  Palmer Dabbelt  <palmer@sifive.com>

        * sysdeps/riscv/nptl/bits/pthreadtypes-arch.h: New file.
        * sysdeps/riscv/nptl/bits/semaphore.h: Likewise.
        * sysdeps/riscv/nptl/libc-lowlevellock.c: Likewise.
        * sysdeps/unix/sysv/linux/riscv/atomic-machine.h: Likewise.
2018-01-29 10:27:17 -08:00
Palmer Dabbelt b2cb5e0298
RISC-V: Hard Float Support
This patch contains hardware floating-point support for the RISC-V ISA.
While we currently only support hard-float systems with both the F and D
extensions, I've left the F-specific code split out into seperate
folders in order to ease adding support for F-only and RV32I-based
systems in the future.  I gave this a quick once-over and believe I've
removed all the code that implements RV32IF, RV32IFD, and RV64IF
targets.

2018-01-29  Palmer Dabbelt  <palmer@sifive.com>

        * sysdeps/riscv/rv64/rvd/s_ceil.c: New file.
        * sysdeps/riscv/rv64/rvd/s_floor.c: Likewise.
        * sysdeps/riscv/rv64/rvd/s_llrint.c: Likewise.
        * sysdeps/riscv/rv64/rvd/s_llround.c: Likewise.
        * sysdeps/riscv/rv64/rvd/s_lrint.c: Likewise.
        * sysdeps/riscv/rv64/rvd/s_lround.c: Likewise.
        * sysdeps/riscv/rv64/rvd/s_nearbyint.c: Likewise.
        * sysdeps/riscv/rv64/rvd/s_rint.c: Likewise.
        * sysdeps/riscv/rv64/rvd/s_round.c: Likewise.
        * sysdeps/riscv/rv64/rvd/s_roundeven.c: Likewise.
        * sysdeps/riscv/rv64/rvd/s_trunc.c: Likewise.
        * sysdeps/riscv/rv64/rvf/s_llrintf.c: Likewise.
        * sysdeps/riscv/rv64/rvf/s_llroundf.c: Likewise.
        * sysdeps/riscv/rv64/rvf/s_lrintf.c: Likewise.
        * sysdeps/riscv/rv64/rvf/s_lroundf.c: Likewise.
        * sysdeps/riscv/rvd/e_sqrt.c: Likewise.
        * sysdeps/riscv/rvd/s_copysign.c: Likewise.
        * sysdeps/riscv/rvd/s_finite.c: Likewise.
        * sysdeps/riscv/rvd/s_fma.c: Likewise.
        * sysdeps/riscv/rvd/s_fmax.c: Likewise.
        * sysdeps/riscv/rvd/s_fmin.c: Likewise.
        * sysdeps/riscv/rvd/s_fpclassify.c: Likewise.
        * sysdeps/riscv/rvd/s_isinf.c: Likewise.
        * sysdeps/riscv/rvd/s_isnan.c: Likewise.
        * sysdeps/riscv/rvd/s_issignaling.c: Likewise.
        * sysdeps/riscv/rvf/e_sqrtf.c: Likewise.
        * sysdeps/riscv/rvf/fclrexcpt.c: Likewise.
        * sysdeps/riscv/rvf/fegetenv.c: Likewise.
        * sysdeps/riscv/rvf/fegetmode.c: Likewise.
        * sysdeps/riscv/rvf/fegetround.c: Likewise.
        * sysdeps/riscv/rvf/feholdexcpt.c: Likewise.
        * sysdeps/riscv/rvf/fesetenv.c: Likewise.
        * sysdeps/riscv/rvf/fesetexcept.c: Likewise.
        * sysdeps/riscv/rvf/fesetmode.c: Likewise.
        * sysdeps/riscv/rvf/fesetround.c: Likewise.
        * sysdeps/riscv/rvf/feupdateenv.c: Likewise.
        * sysdeps/riscv/rvf/fgetexcptflg.c: Likewise.
        * sysdeps/riscv/rvf/fraiseexcpt.c: Likewise.
        * sysdeps/riscv/rvf/fsetexcptflg.c: Likewise.
        * sysdeps/riscv/rvf/ftestexcept.c: Likewise.
        * sysdeps/riscv/rvf/get-rounding-mode.h: Likewise.
        * sysdeps/riscv/rvf/math_private.h: Likewise.
        * sysdeps/riscv/rvf/s_ceilf.c: Likewise.
        * sysdeps/riscv/rvf/s_copysignf.c: Likewise.
        * sysdeps/riscv/rvf/s_finitef.c: Likewise.
        * sysdeps/riscv/rvf/s_floorf.c: Likewise.
        * sysdeps/riscv/rvf/s_fmaf.c: Likewise.
        * sysdeps/riscv/rvf/s_fmaxf.c: Likewise.
        * sysdeps/riscv/rvf/s_fminf.c: Likewise.
        * sysdeps/riscv/rvf/s_fpclassifyf.c: Likewise.
        * sysdeps/riscv/rvf/s_isinff.c: Likewise.
        * sysdeps/riscv/rvf/s_isnanf.c: Likewise.
        * sysdeps/riscv/rvf/s_issignalingf.c: Likewise.
        * sysdeps/riscv/rvf/s_nearbyintf.c: Likewise.
        * sysdeps/riscv/rvf/s_rintf.c: Likewise.
        * sysdeps/riscv/rvf/s_roundevenf.c: Likewise.
        * sysdeps/riscv/rvf/s_roundf.c: Likewise.
        * sysdeps/riscv/rvf/s_truncf.c: Likewise.
2018-01-29 10:26:43 -08:00
Palmer Dabbelt 67236aeb6e
RISC-V: Generic <math.h> and soft-fp Routines
This patch contains the miscellaneous math routines and headers we have
implemented for RISC-V.  This includes things from <math.h> that aren't
completely ISA-generic, floating-point bit manipulation, and soft-fp
hooks.

2018-01-29  Palmer Dabbelt  <palmer@sifive.com>

        * sysdeps/riscv/bits/fenv.h: New file.
        * sysdeps/riscv/e_sqrtl.c: Likewise.
        * sysdeps/riscv/fpu_control.h: Likewise.
        * sysdeps/riscv/math-tests.h: Likewise.
        * sysdeps/riscv/nofpu/Implies: Likewise.
        * sysdeps/riscv/sfp-machine.h: Likewise.
        * sysdeps/riscv/tininess.h: Likewise.
2018-01-29 10:26:35 -08:00
Palmer Dabbelt 337126607f
RISC-V: Thread-Local Storage Support
This patch implements TLS support for RISC-V.  We support all four
standard TLS addressing modes (LE, IE, LD, and GD) when running on
Linux via NPTL.  There is a draft psABI document that defines our TLS
ABI here

  https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md#thread-local-storage

2018-01-29  Palmer Dabbelt  <palmer@sifive.com>

        * sysdeps/riscv/dl-tls.h: New file.
        * sysdeps/riscv/libc-tls.c: Likewise.
        * sysdeps/riscv/nptl/tcb-offsets.sym: Likewise.
        * sysdeps/riscv/nptl/tls.h: Likewise.
        * sysdeps/riscv/stackinfo.h: Likewise.
2018-01-29 10:25:58 -08:00
Palmer Dabbelt c776fa113d
RISC-V: ABI Implementation
This patch contains code that needs to directly know about the RISC-V
ABI, which is specified in a work-in-progress psABI document:

  https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md

This is meant to contain all the RISC-V code that needs to explicitly
name registers or manage in-memory structure layout.  This does not
contain any of the Linux-specific code.

2018-01-29  Palmer Dabbelt  <palmer@sifive.com>

        * sysdeps/riscv/__longjmp.S: New file.
        * sysdeps/riscv/backtrace.c: Likewise.
        * sysdeps/riscv/bits/endian.h: Likewise.
        * sysdeps/riscv/bits/setjmp.h: Likewise.
        * sysdeps/riscv/bits/wordsize.h: Likewise.
        * sysdeps/riscv/bsd-_setjmp.c: Likewise.
        * sysdeps/riscv/bsd-setjmp.c: Likewise.
        * sysdeps/riscv/dl-trampoline.S: Likewise.
        * sysdeps/riscv/gccframe.h: Likewise.
        * sysdeps/riscv/jmpbuf-offsets.h: Likewise.
        * sysdeps/riscv/jmpbuf-unwind.h: Likewise.
        * sysdeps/riscv/machine-gmon.h: Likewise.
        * sysdeps/riscv/memusage.h: Likewise.
        * sysdeps/riscv/setjmp.S: Likewise.
        * sysdeps/riscv/sys/asm.h: Likewise.
        * sysdeps/riscv/tls-macros.h: Likewise.
2018-01-29 10:25:29 -08:00
Palmer Dabbelt ba9e25a62b
Add documentation for __riscv_flush_icache
This function is used by GCC to enforce ordering between data writes and
instruction fetches, and while we'd prefer that users rely on the GCC
intrinsic when possible this is user visible in case that's not
possible.

2018-01-29  Palmer Dabbelt  <palmer@sifive.com>

        * manual/platform.texi: Add RISC-V documenation for
        __riscv_flush_icache.
2018-01-29 10:25:23 -08:00
Palmer Dabbelt 4215e27674
Add RISC-V entries to config.h.in
These were autogenerated.

2018-01-29  Palmer Dabbelt  <palmer@sifive.com>

        * config.h.in: Regenerate.
2018-01-29 10:24:57 -08:00
Palmer Dabbelt 40ca951bdb
Skeleton documentation for the RISC-V port
During the upstreaming process it was suggested that I add a handful of
small documentation entries about the RISC-V port, which I've collected
here.

2018-01-29  Palmer Dabbelt  <palmer@sifive.com>

        * manual/math.texi: RISC-V supports _Float128 and _Float64x.
2018-01-29 10:22:26 -08:00
Palmer Dabbelt 532cf290d0
sysdeps/init_array: Add PREINIT_FUNCTION to crti.S
The RISC-V port contains a crti.S that simply contains a link to
PREINIT_FUNCTION (when defined).  As this should be entirely generic,
Joseph Myers suggested that we update the generic init_array version to
contain this.  Since RISC-V is the only user of init_array this won't
break any existing ports.

2018-01-29  Palmer Dabbelt  <palmer@sifive.com>

        * sysdeps/init_array/crti.S (.section .init_array): Add
        PREINIT_FUNCTION when defined.
2018-01-29 10:22:26 -08:00
Florian Weimer cdd14619a7 libnsl: Turn remaining symbols into compat symbols [BZ #22701] 2018-01-29 17:42:30 +01:00
Romain Naour b7ccb5de35 microblaze: don't use copy_file_range syscall with kernel headers < 4.10
copy_file_range syscall was added for microblaze in 4.10.

This patch makes the MicroBlaze kernel-features.h undefine
__ASSUME_COPY_FILE_RANGE for toolchains built with kernel headers < 4.10.

	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	(__ASSUME_COPY_FILE_RANGE) [__LINUX_KERNEL_VERSION < 0x040A00]: Undef.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=7181e5590e5ba898804aef3ee6be7f27606e6f8b

Signed-off-by: Romain Naour <romain.naour@gmail.com>
2018-01-29 16:12:08 +00:00
Joseph Myers e3aa6999d7 Make build-many-glibcs.py clean git source directories.
With the git checkouts of Hurd components in build-many-glibcs.py
involving running autoreconf, there's a risk that generated files
could be left behind by an old autoreconf run (if an old version of
the sources generates those files in the source directory but a new
version does not).

This patch avoids that by using git clean -dxfq when updating git
checkouts.  In this patch, that's conditional on --replace-sources, to
avoid removing any local not-checked-in files someone may have in
their checkout unless the option has been specifically passed that
says it's OK to blow old checkouts away, complete with any local
changes to them.

	* scripts/build-many-glibcs.py (Context.git_checkout): Use git
	clean -dxfq for git updates when replacing sources.
2018-01-29 13:59:33 +00:00
Joseph Myers 088de7d009 Clean up build-many-glibcs.py libcilkrts disabling.
The disabling of libcilkrts in build-many-glibcs.py has some
peculiarities.  It's only for the final GCC build, not the initial
bootstrap one, whereas normally anything disabled for the final build
should be disabled for the bootstrap one as well.  And it's only for
Hurd, when it's more natural by analogy with the libsanitizer
disabling to disable this library unconditionally, not only for
targets where it's known to break.  This patch cleans up that
disabling accordingly, adding a comment so it's obvious it can be
removed once GCC 7 is too old to build glibc.

	* scripts/build-many-glibcs.py (Config.build_gcc): Use
	--disable-libcilkrts unconditionally, not just for the final GCC
	build for Hurd.
2018-01-29 13:49:21 +00:00
Joseph Myers 522623e4aa Use Linux 4.15 in build-many-glibcs.py.
This patch makes build-many-glibcs.py use Linux 4.15.  Other glibc
updates for Linux 4.15 can wait until after the 2.27 release.

	* scripts/build-many-glibcs.py (Context.checkout): Default Linux
	version to 4.15.
2018-01-29 13:38:21 +00:00
Rafal Luzynski 8b406f8776 lt_LT: Add alternative month names (bug 10871).
[BZ #10871]
	* localedata/locales/lt_LT (alt_mon): Import from CLDR (nominative
	case).
2018-01-29 13:14:45 +01:00
Rafal Luzynski 105e90bd83 be_BY, be_BY@latin: Add alternative month names (bug 10871).
This patch also fixes spelling of lang_name in be_BY@latin, as reported
by Ihar Hrachyshka.

	[BZ #10871]
	* localedata/locales/be_BY (mon): Rename to...
	(alt_mon): This, then synchronize with CLDR (nominative case).
	(abmon): Rename to...
	(ab_alt_mon): This, then synchronize with CLDR (nominative case).
	(mon): Import from CLDR (genitive case).
	(abmon): Likewise.
	* localedata/locales/be_BY@latin (mon): Rename to...
	(alt_mon): This.
	(mon): Add, proper genitive forms provided by Viktar Siarheichyk.

	* localedata/locales/be_BY@latin (lang_name): Reworded to
	"biełaruskaja mova".
2018-01-29 13:14:45 +01:00
Rafal Luzynski 561cb41473 el_CY, el_GR: Add alternative month names (bug 10871).
[BZ #10871]
	* localedata/locales/el_CY (mon): Renamed to...
	(alt_mon): This.
	(mon): Import from CLDR (genitive case).
	* localedata/locales/el_GR: Likewise.
2018-01-29 13:14:45 +01:00
Rafal Luzynski f7bdf30d15 ru_RU, ru_UA: Add alternative month names (bug 10871).
[BZ #10871]
	* localedata/locales/ru_RU (mon): Rename to...
	(alt_mon): This.
	(abmon): Rename to...
	(ab_alt_mon): This.
	(mon): Import from CLDR (genitive case).
	(abmon): Copy from the old content except the 5th month which is
	now in the genitive case, even when abbreviated.
	* localedata/locales/ru_UA: Likewise.
	* time/tst-strptime.c (day_tests): Add an actual example of
	a difference between %b and %Ob in Russian.
2018-01-29 13:14:45 +01:00
Samuel Thibault 1f89ac7190 hurd: Fix includes
* sysdeps/mach/hurd/net/ethernet.h: Include <stdint.h>.
	* sysdeps/mach/hurd/net/if_arp.h: Include <stdint.h>.
	* sysdeps/mach/hurd/net/if_ppp.h: Do not include non-existing
	<net/ppp_defs.h>.
2018-01-29 01:48:24 +01:00
Samuel Thibault 80463dc69d hurd: Fix _POSIX_VDISABLE value
* sysdeps/mach/hurd/bits/posix_opt.h (_POSIX_VDISABLE): Set to '\0'
	instead of invalid -1.
2018-01-29 00:05:20 +01:00
Samuel Thibault 2e52dff41f hurd: Build stubs for new gnumach.defs
* mach/Makefile (user-interfaces): Add mach/gnumach.
* sysdeps/mach/configure.ac (mach_interface_list): Add gnumach.
* sysdeps/mach/configure (mach_interface_list): Regenerate.
2018-01-28 19:38:29 +01:00
Samuel Thibault 625ba81ef5 hurd: Include <sigsetops.h> from hurd/hurd/signal.h
* hurd/hurd/signal.h [__USE_EXTERN_INLINES][_LIBC][IS_IN(libc) ||
IS_IN(libpthread)]: Include <sigsetops.h>.
2018-01-28 19:36:49 +01:00
Samuel Thibault a902a0866a hurd: Fix allocalim build
* sysdeps/pthread/allocalim.h [!defined PTHREAD_STACK_MIN]: Do not
check size against PTHREAD_STACK_MIN.
2018-01-28 19:35:02 +01:00
Samuel Thibault b10253044b hurd: Fix posix options
_POSIX_CHOWN_RESTRICTED and _POSIX_NO_TRUNC should be always defined.

	* sysdeps/mach/hurd/bits/posix_opt.h (_POSIX_CHOWN_RESTRICTED,
	_POSIX_NO_TRUNC): Define to 0.
2018-01-28 19:13:55 +01:00
Samuel Thibault d23965cf88 Revert "hurd: Fix building io/tst-fchownat.c"
This reverts commit fc221145a7.
2018-01-28 19:13:20 +01:00
Samuel Thibault 7c5b106dcb hurd: Fix getifaddrs / freeifaddrs exposition
400669754d ('hurd: Fix nscd build') had the side effect of making
libc's freeaddrinfo expose freeifaddrs through __check_pf.  We can just
move the renames to gai.c itself, along others.

* sysdeps/mach/hurd/check_pf.c (__getifaddrs, __freeifaddrs): Do not
define macros.
* nscd/gai.c (__getifaddrs): Define macro to getifaddrs.
(__freeifaddrs): Define macro to freeifaddrs.
2018-01-28 19:06:15 +01:00
Samuel Thibault 28f6186f3e hurd: take __USE_EXTERN_INLINES into account and restrict inlines
* hurd/hurd.h (__hurd_fail): Always declare function, and provide inline
version only if __USE_EXTERN_INLINES is defined.
* hurd/hurd/fd.h (_hurd_fd_error_signal, _hurd_fd_error, __hurd_dfail,
__hurd_sockfail): Likewise.
(_hurd_fd_get): Always declare functions, and provide inline versions
only if __USE_EXTERN_INLINES and _LIBC are defined and IS_IN(libc).
* hurd/hurd/port.h (_hurd_port_init, _hurd_port_locked_get,
_hurd_port_get, _hurd_port_free, _hurd_port_locked_set,
_hurd_port_set): Always declare functions, and provide inline versions
only if __USE_EXTERN_INLINES and _LIBC are defined and
IS_IN(libc).
* hurd/hurd/signal.h (_hurd_self_sigstate, _hurd_critical_section_lock,
_hurd_critical_section_unlock): Likewise.
* hurd/hurd/threadvar.h (__hurd_threadvar_location_from_sp,
* __hurd_threadvar_location): Likewise.
* hurd/hurd/userlink.h (_hurd_userlink_link, _hurd_userlink_unlink,
_hurd_userlink_clear): Likewise.
* mach/lock-intern.h (__spin_lock_init, __spin_lock, __mutex_lock,
__mutex_unlock, __mutex_trylock): Always declare functions, and provide
inline versions only if __USE_EXTERN_INLINES and _LIBC are defined.
* mach/mach/mig_support.h (__mig_strncpy): Likewise.
* sysdeps/generic/machine-lock.h (__spin_unlock, __spin_try_lock,
__spin_lock_locked): Likewise.
* sysdeps/mach/i386/machine-lock.h (__spin_unlock, __spin_try_lock,
__spin_lock_locked): Likewise.
* mach/spin-lock.c (__USE_EXTERN_INLINES): Define to 1.
* hurd/Versions (libc: GLIBC_2.27): Add _hurd_fd_error_signal,
_hurd_fd_error, __hurd_dfail, __hurd_sockfail, _hurd_port_locked_set,
__hurd_threadvar_location_from_sp, __hurd_threadvar_location,
_hurd_userlink_link, _hurd_userlink_unlink, _hurd_userlink_clear.
2018-01-28 18:46:23 +01:00
Samuel Thibault 3fc1ecf935 hurd: Fix building io/tst-copy_file_range.c
* io/tst-copy_file_range.c [!defined CLONE_NEWNS]: Do not include
	<sys/mount.h>.
2018-01-28 17:56:49 +01:00
Samuel Thibault fc221145a7 hurd: Fix building io/tst-fchownat.c
* io/tst-fchownat.c [!defined _POSIX_CHOWN_RESTRICTED]: Act like when
	_POSIX_CHOWN_RESTRICTED is defined to 0.
2018-01-28 17:52:46 +01:00
Samuel Thibault cef7166ac1 hurd: Fix building libio/tst-memstream3.c
FWRITE is already an fcntl.h macro.

	* libio/tst-memstream3.c (FWRITE): Rename to _FWRITE.
	(do_test_bz20181): Rename accordingly.
	* libio/tst-wmemstream3.c (FWRITE): Rename accordingly.
2018-01-28 17:45:41 +01:00
Samuel Thibault 5f982b0beb hurd: add base abilist files
* sysdeps/mach/hurd/libhurduser.abilist: New file.
	* sysdeps/mach/libmachuser.abilist: New file.
2018-01-28 17:26:35 +01:00
Thomas Schwinge 84814e2a40 hurd: Add missing fcntl-internal.h
* hurd/fcntl-internal.h: New file.
2018-01-28 17:05:40 +01:00
Samuel Thibault 400669754d hurd: Fix nscd build
nscd won't find check_* from inet/, it needs a sysdeps file.

	* sysdeps/mach/hurd/check_native.c: New file.
	* sysdeps/mach/hurd/check_pf.c: New file.
2018-01-28 16:28:48 +01:00
Samuel Thibault f8bee46cc2 hurd: Fix warnings
* hurd/hurd/lookup.h (__hurd_file_name_lookup, hurd_file_name_lookup,
	__hurd_file_name_split, hurd_file_name_split,
	__hurd_directory_name_split, hurd_directory_name_split,
	__hurd_file_name_lookup_retry, hurd_file_name_lookup_retry,
	hurd_file_name_path_lookup): Make lookup function parameter take a
	const char *name instead of char *name.
	* hurd/hurdlookup.c (__hurd_file_name_lookup, __hurd_file_name_split,
	__hurd_directory_name_split): Likewise.
	* hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Likewise.
	* hurd/path-lookup.c (hurd_file_name_path_lookup): Likewise.
2018-01-28 16:23:59 +01:00
Samuel Thibault 844bf92148 hurd: Fix warning
* sysdeps/mach/hurd/spawni.c (__spawni): Make relpath and abspath
	const char * instead of char *.
2018-01-28 16:21:28 +01:00
Samuel Thibault 19fd8d0d3e hurd: Make build-many-glibcs.py use mainline gnumach
Some warnings need a couple of fixes in the gnumach headers.

        * scripts/build-many-glibcs.py (checkout_vcs): Add gnumach
        repository URLs, run autoreconf, and make it the default for now.
2018-01-28 15:48:04 +01:00
Samuel Thibault 660b7bff81 hurd: fix warning
* sysdeps/mach/hurd/getresgid.c (__getresgid): Set result from
	critical section to make code simpler and avoid warning.
	* sysdeps/mach/hurd/getresuid.c (__getresuid): Set result from
	critical section to make code simpler and avoid warning.
2018-01-27 23:49:18 +01:00