Commit Graph

23160 Commits

Author SHA1 Message Date
Zack Weinberg b87eb3f8fe Use SCANF_ISOC99_A instead of _IO_FLAGS2_SCANF_STD.
Change the callers of __vfscanf_internal and __vfwscanf_internal that
want C99-compliant behavior to communicate this via the new flags
argument, rather than setting bits on the FILE object.  This also
means these functions do not need to do their own locking.

Tested for powerpc and powerpc64le.
2018-12-05 18:15:42 -02:00
Zack Weinberg 349718d4d7 Add __vfscanf_internal and __vfwscanf_internal with flags arguments.
There are two flags currently defined: SCANF_LDBL_IS_DBL is the mode
used by __nldbl_ scanf variants, and SCANF_ISOC99_A is the mode used
by __isoc99_ scanf variants.  In this patch, the new functions honor
these flag bits if they're set, but they still also look at the
corresponding bits of environmental state, and callers all pass zero.

The new functions do *not* have the "errp" argument possessed by
_IO_vfscanf and _IO_vfwscanf.  All internal callers passed NULL for
that argument.  External callers could theoretically exist, so I
preserved wrappers, but they are flagged as compat symbols and they
don't preserve the three-way distinction among types of errors that
was formerly exposed.  These functions probably should have been in
the list of deprecated _IO_ symbols in 2.27 NEWS -- they're not just
aliases for vfscanf and vfwscanf.

(It was necessary to introduce ldbl_compat_symbol for _IO_vfscanf.
Please check that part of the patch very carefully, I am still not
confident I understand all of the details of ldbl-opt.)

This patch also introduces helper inlines in libio/strfile.h that
encapsulate the process of initializing an _IO_strfile object for
reading.  This allows us to call __vfscanf_internal directly from
sscanf, and __vfwscanf_internal directly from swscanf, without
duplicating the initialization code.  (Previously, they called their
v-counterparts, but that won't work if we want to control *both* C99
mode and ldbl-is-dbl mode using the flags argument to__vfscanf_internal.)
It's still a little awkward, especially for wide strfiles, but it's
much better than what we had.

Tested for powerpc and powerpc64le.
2018-12-05 18:15:42 -02:00
Albert ARIBAUD (3ADEV) 72b8692d7e Y2038: make __tz_convert compatible with 64-bit-time
Now that __time64_t exists, we can switch internal function
__tz_convert from 32-bit to 64-bit time. This involves switching
some other internal functions as well, namely __tz_compute and
__offtime.

Tested with 'make check' on x86_64-linux-gnu and i686-linux.gnu.

	* include/time.h
	(__tz_compute): Replace time_t with __time64_t.
	(__tz_convert): Replace time_t* with __time64_t.
	(__offtime): Replace time_t* with __time64_t.
	* time/gmtime.c
	(__gmtime_r): Adjust call to __tz_convert.
	(gmtime): Likewise.
	* time/localtime.c
	(__localtime_r): Likewise.
	(localtime): Likewise.
	* time/offtime.c: Replace time_t with __time64_t.
	* time/tzset.c: Likewise.
2018-12-05 21:01:22 +01:00
Joseph Myers bd598da9f4 Stop test-in-container trying to run other-OS binaries.
I noticed that, now that build-many-glibcs.py no longer copies glibc
sources, I was getting core dumps in my glibc source directories.  The
cause appears to be, from the i686-gnu build:

for dso in ` env LD_TRACE_LOADED_OBJECTS=1  \
        /scratch/jmyers/glibc-bot/build/glibcs/i686-gnu/glibc/elf/ld.so.1 \
        /scratch/jmyers/glibc-bot/build/glibcs/i686-gnu/glibc/testroot.pristine/bin/sh \
[...]
Segmentation fault (core dumped)

In this case, the x86 architecture means the binary executes, but
dumps core rather than actually working.

Anything involving running the newly built glibc should only be done
ifeq ($(run-built-tests),yes).  This patch conditions the relevant
part of the testroot setup accordingly.

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

	* Makefile ($(objpfx)testroot.pristine/install.stamp): Do not run
	dynamic linker unless [$(run-built-tests) = yes].
2018-12-04 16:52:39 +00:00
DJ Delorie b2e93de0ff test-container: add "su" command to run test as root, add unshare hints
* support/test-container.c (check_for_unshare_hints): New.
(main): Call it if unshare fails.  Add support for "su" scriptlet
command.
2018-12-04 00:03:12 -05:00
Joseph Myers 477a02f637 Make gen-as-const.py handle '--' consistently with awk script.
It was reported in
<https://sourceware.org/ml/libc-alpha/2018-12/msg00045.html> that
gen-as-const.py fails to generate test code in the case where a .sym
file has no symbols in it, so resulting in a test failing to link for
Hurd.

The relevant difference from the old awk script is that the old script
treated '--' lines as indicating that the text to do at the start of
the test (or file used to compute constants) should be output at that
point if not already output, as well as treating lines with actual
entries for constants like that.  This patch changes gen-as-const.py
accordingly, making it the sole responsibility of the code parsing
.sym files to determine when such text should be output and ensuring
it's always output at some point even if there are no symbols and no
'--' lines, since not outputting it means the test fails to link.
Handling '--' like that also avoids any problems that would arise if
the first entry for a symbol were inside #ifdef (since the text in
question must not be output inside #ifdef).

Tested for x86_64, and with build-many-glibcs.py for i686-gnu.  Note
that there are still compilation test failures for i686-gnu
(linknamespace tests, possibly arising from recent posix_spawn-related
changes).

	* scripts/gen-as-const.py (compute_c_consts): Take an argument
	'START' to indicate that start text should be output.
	(gen_test): Likewise.
	(main): Generate 'START' for first symbol or '--' line, or at end
	of input if not previously generated.
2018-12-03 22:08:50 +00:00
Rafael Ávila de Espíndola 6af956e5c0 Enable VDSO for static linking on arm
I have tested that this builds and the resulting program still work.
The kernel in gcc117 (which I ussed for testing) seems to be missing
https://patchwork.kernel.org/patch/10060431/, so the vdso is never used.

	[BZ #19767]
	* sysdeps/unix/sysv/linux/arm/init-first.c: Remove #ifdef SHARED.
	* sysdeps/unix/sysv/linux/arm/libc-vdso.h: Remove #ifdef SHARED.
	* sysdeps/unix/sysv/linux/arm/sysdep.h: Define
	ALWAYS_USE_VSYSCALL.
2018-12-03 20:59:22 +00:00
Adhemerval Zanella f5ec0ea9ea posix: Fix segfault in maybe_script_execute
This patch is essentially 28669f86f6 adjusted for the generic
implementation.

Checked on x86_64-linux-gnu with Linux spawni.c removed.  The only
failure is posix/tst-spawn3, which is expected.

	[BZ #23913]
	* sysdeps/posix/spawni.c (maybe_script_execute):
	Increment size of new_argv by one.
2018-12-03 18:23:11 -02:00
Carlos O'Donell 8cebd4ffe6 Add --no-hard-links option to localedef (bug 23923)
Downstream distributions need consistent sets of hardlinks in
order for rpm to operate effectively. This means that even if
locales are built with a high level of parallelism that the
resulting files need to have consistent hardlink counts. The only
way to achieve this is with a post-install hardlink pass using a
program like 'hardlink' (shipped in Fedora).

If the downstream distro wants to post-process the hardlinks then
the time spent in localedef looking up sibling directories and
processing hardlinks is wasted effort.

To optimize the build and install pass we add a --no-hard-links
option to localedef to avoid doing the hardlink optimziation for
size.

Tested on x86_64 with 'make localedata/install-locale-files'
before and after. Without the patch we have files with 100+
hardlink counts. After the patch and running with --no-hard-links
all link counts are 1. This patch also alters the convenience
target 'make localedata/install-locale-files' to use the new
option.

Signed-off-by: Carlos O'Donell <carlos@redhat.com>
2018-12-03 10:15:39 -05:00
H.J. Lu c22e4c2a14 x86: Extend CPUID support in struct cpu_features
Extend CPUID support for all feature bits from CPUID.  Add a new macro,
CPU_FEATURE_USABLE, which can be used to check if a feature is usable at
run-time, instead of HAS_CPU_FEATURE and HAS_ARCH_FEATURE.

Add COMMON_CPUID_INDEX_D_ECX_1, COMMON_CPUID_INDEX_80000007 and
COMMON_CPUID_INDEX_80000008 to check CPU feature bits in them.

Tested on i686 and x86-64 as well as using build-many-glibcs.py with
x86 targets.

	* sysdeps/x86/cacheinfo.c (intel_check_word): Updated for
	cpu_features_basic.
	(__cache_sysconf): Likewise.
	(init_cacheinfo): Likewise.
	* sysdeps/x86/cpu-features.c (get_extended_indeces): Also
	populate COMMON_CPUID_INDEX_80000007 and
	COMMON_CPUID_INDEX_80000008.
	(get_common_indices): Also populate COMMON_CPUID_INDEX_D_ECX_1.
	Use CPU_FEATURES_CPU_P (cpu_features, XSAVEC) to check if
	XSAVEC is available.  Set the bit_arch_XXX_Usable bits.
	(init_cpu_features): Use _Static_assert on
	index_arch_Fast_Unaligned_Load.
	__get_cpuid_registers and __get_arch_feature.  Updated for
	cpu_features_basic.  Set stepping in cpu_features.
	* sysdeps/x86/cpu-features.h: (FEATURE_INDEX_1): Changed to enum.
	(FEATURE_INDEX_2): New.
	(FEATURE_INDEX_MAX): Changed to enum.
	(COMMON_CPUID_INDEX_D_ECX_1): New.
	(COMMON_CPUID_INDEX_80000007): Likewise.
	(COMMON_CPUID_INDEX_80000008): Likewise.
	(cpuid_registers): Likewise.
	(cpu_features_basic): Likewise.
	(CPU_FEATURE_USABLE): Likewise.
	(bit_arch_XXX_Usable): Likewise.
	(cpu_features): Use cpuid_registers and cpu_features_basic.
	(bit_arch_XXX): Reweritten.
	(bit_cpu_XXX): Likewise.
	(index_cpu_XXX): Likewise.
	(reg_XXX): Likewise.
	* sysdeps/x86/tst-get-cpu-features.c: Include <stdio.h> and
	<support/check.h>.
	(CHECK_CPU_FEATURE): New.
	(CHECK_CPU_FEATURE_USABLE): Likewise.
	(cpu_kinds): Likewise.
	(do_test): Print vendor, family, model and stepping.  Check
	HAS_CPU_FEATURE and CPU_FEATURE_USABLE.
	(TEST_FUNCTION): Removed.
	Include <support/test-driver.c> instead of
	"../../test-skeleton.c".
	* sysdeps/x86_64/multiarch/sched_cpucount.c (__sched_cpucount):
	Check POPCNT instead of POPCOUNT.
	* sysdeps/x86_64/multiarch/test-multiarch.c (do_test): Likewise.
2018-12-03 05:54:56 -08:00
Samuel Thibault 7b36d26b22 Fix test-as-const-jmp_buf-ssp.c generation on gnu-i386
hurd's jmp_buf-ssp.sym does not define any symbol.
scripts/gen-as-const.py currently was emitting an empty line in that
case, and the gawk invocation was prepending "asconst_" to it, ending up
with:

.../build/glibc/setjmp/test-as-const-jmp_buf-ssp.c:1:2: error: expected « = », « , », « ; », « asm » or
« __attribute__ » at end of input
    1 |  asconst_
      |  ^~~~~~~~

        * scripts/gen-as-const.py (main): Avoid emitting empty line when
        there is no element in `consts'.
2018-12-03 14:40:48 +01:00
Florian Weimer 02cd5c1a8d support: Close original descriptors in support_capture_subprocess 2018-12-01 22:41:46 +01:00
Samuel Thibault fc493bc9e6 htl: Fix comparing attr with default values
Fortunately we were previously only missing an optimization.

Thanks dcb <dcb314@hotmail.com> for the report

	[BZ #23032]
	* sysdeps/htl/pt-barrier-init.c (pthread_barrier_init): Fix comparing
	attr with __pthread_default_barrierattr.
	* sysdeps/htl/pt-cond-init.c (__pthread_cond_init): Fix comparing
	attr with __pthread_default_condattr.
	* sysdeps/htl/pt-mutex-init.c (_pthread_mutex_init): Fix comparing
	attr with __pthread_default_mutexattr.
	* sysdeps/htl/pt-rwlock-init.c (_pthread_rwlock_init): Fix comparing
	attr with __pthread_default_rwlockattr.
2018-12-01 21:42:12 +01:00
Kemi Wang 6310e6be9b Mutex: Add pthread mutex tunables
This patch does not have any functionality change, we only provide a spin
count tunes for pthread adaptive spin mutex. The tunable
glibc.pthread.mutex_spin_count tunes can be used by system administrator to
squeeze system performance according to different hardware capabilities and
workload characteristics.

The maximum value of spin count is limited to 32767 to avoid the overflow
of mutex->__data.__spins variable with the possible type of short in
pthread_mutex_lock ().

The default value of spin count is set to 100 with the reference to the
previous number of times of spinning via trylock. This value would be
architecture-specific and can be tuned with kinds of benchmarks to fit most
cases in future.

I would extend my appreciation sincerely to H.J.Lu for his help to refine
this patch series.

	* manual/tunables.texi (POSIX Thread Tunables): New node.
	* nptl/Makefile (libpthread-routines): Add pthread_mutex_conf.
	* nptl/nptl-init.c: Include pthread_mutex_conf.h
	(__pthread_initialize_minimal_internal) [HAVE_TUNABLES]: Call
	 __pthread_tunables_init.
	* nptl/pthreadP.h (MAX_ADAPTIVE_COUNT): Remove.
	(max_adaptive_count): Define.
	* nptl/pthread_mutex_conf.c: New file.
	* nptl/pthread_mutex_conf.h: New file.
	* sysdeps/generic/adaptive_spin_count.h: New file.
	* sysdeps/nptl/dl-tunables.list: New file.
	* nptl/pthread_mutex_lock.c (__pthread_mutex_lock): Use
	max_adaptive_count () not MAX_ADAPTIVE_COUNT.
	* nptl/pthread_mutex_timedlock.c (__pthrad_mutex_timedlock):
	Likewise.

Suggested-by: Andi Kleen <andi.kleen@intel.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Signed-off-by: Kemi.wang <kemi.wang@intel.com>
2018-12-01 08:19:20 -08:00
Paul Pluzhnikov 8e67b39eb4 stdlib: assert on NULL function pointer in atexit etc. [BZ #20544] 2018-11-30 16:18:34 -08:00
Rafael Ávila de Espíndola 15b8d67e29 Enable VDSO on i386 statically linked programs
[BZ #19767]
	* sysdeps/unix/sysv/linux/i386/init-first.c: Don't check SHARED.
	* sysdeps/unix/sysv/linux/i386/sysdep.h (ALWAYS_USE_VSYSCALL):
	New.
2018-11-30 14:32:35 -08:00
Florian Weimer 5e63c240a2 scripts/abilist.awk: Handle special _end symbol for Hurd
Hurd has this in libc.so:

0024db9c g    D  .bss   00000000  GLIBC_2.2.6 _end

This g/D combination was not recognized before.
2018-11-30 22:22:57 +01:00
Adhemerval Zanella 7105860262 Fix ChangeLog date from previous commit 2018-11-30 19:10:50 -02:00
Adhemerval Zanella 5fb7fc9635 posix: Use posix_spawn on system
This patch uses posix_spawn on system implementation.  On Linux this has
the advantage of much lower memory consumption (usually 32 Kb minimum for
the mmap stack area).

Although POSIX does not require, glibc system implementation aims to be
thread and cancellation safe.  The cancellation code is moved to generic
implementation and enabled iff SIGCANCEL is defined (similar on how the
cancellation handler is enabled on nptl-init.c).

Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu,
arm-linux-gnueabihf, and powerpc64le-linux-gnu.

	* sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Use
	__sigismember instead of sigismember.
	* sysdeps/posix/system.c [SIGCANCEL] (cancel_handler_args,
	cancel_handler): New definitions.
	(CLEANUP_HANDLER, CLEANUP_RESET): Likewise.
	(DO_LOCK, DO_UNLOCK, INIT_LOCK, ADD_REF, SUB_REF): Remove.
	(do_system): Use posix_spawn instead of fork and execl and remove
	reentracy code.
	* sysdeps/generic/not-errno.h (__kill_noerrno): New prototype.
	* sysdeps/unix/sysv/linux/not-errno.h (__kill_noerrno): Likewise.
	* sysdeps/unix/sysv/linux/ia64/system.c: Remove file.
	* sysdeps/unix/sysv/linux/s390/system.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/system.c: Likewise.
	* sysdeps/unix/sysv/linux/system.c: Likewise.
2018-11-30 18:42:05 -02:00
Adhemerval Zanella 14d0e87d9b posix: Use posix_spawn on popen
This patch uses posix_spawn on popen instead of fork and execl.  On Linux
this has the advantage of much lower memory consumption (usually 32 Kb
minimum for the mmap stack area).

Two issues are also fixed with this change:

  * BZ#17490: although POSIX pthread_atfork description only list 'fork'
    as the function that should execute the atfork handlers, popen
    description states that:

      '[...] shall be *as if* a child process were created within the popen()
       call using the fork() function [...]'

    Other libc/system seems to follow the idea atfork handlers should not be
    executed for popen:

    libc/system	| run atfork handles   | notes
    ------------|----------------------|---------------------------------------
    Freebsd	|        no            | uses vfork
    Solaris 11	|        no            |
    MacOSX 11   |        no            | implemented through posix_spawn syscall
    ------------|----------------------|----------------------------------------

    Similar to posix_spawn and system, popen idea is to spawn a different
    binary so all the POSIX rationale to run the atfork handlers to avoid
    internal process inconsistency is not really required and in some cases
    might be unsafe.

  * BZ#22834: the described scenario, where the forked process might access
    invalid memory due an inconsistent state in multithreaded environment,
    should not happen because posix_spawn does not access the affected
    data structure (proc_file_chain).

Checked on x86_64-linux-gnu and i686-linux-gnu.

	[BZ #22834]
	[BZ #17490]
	* NEWS: Add new semantic for atfork with popen and system.
	* libio/iopopen.c (_IO_new_proc_open): use posix_spawn instead of
	fork and execl.
2018-11-30 18:42:05 -02:00
Tulio Magno Quites Machado Filho e5d262effe Fix _dl_profile_fixup data-dependency issue (Bug 23690)
There is a data-dependency between the fields of struct l_reloc_result
and the field used as the initialization guard. Users of the guard
expect writes to the structure to be observable when they also observe
the guard initialized. The solution for this problem is to use an acquire
and release load and store to ensure previous writes to the structure are
observable if the guard is initialized.

The previous implementation used DL_FIXUP_VALUE_ADDR (l_reloc_result->addr)
as the initialization guard, making it impossible for some architectures
to load and store it atomically, i.e. hppa and ia64, due to its larger size.

This commit adds an unsigned int to l_reloc_result to be used as the new
initialization guard of the struct, making it possible to load and store
it atomically in all architectures. The fix ensures that the values
observed in l_reloc_result are consistent and do not lead to crashes.
The algorithm is documented in the code in elf/dl-runtime.c
(_dl_profile_fixup). Not all data races have been eliminated.

Tested with build-many-glibcs and on powerpc, powerpc64, and powerpc64le.

	[BZ #23690]
	* elf/dl-runtime.c (_dl_profile_fixup): Guarantee memory
	modification order when accessing reloc_result->addr.
	* include/link.h (reloc_result): Add field init.
	* nptl/Makefile (tests): Add tst-audit-threads.
	(modules-names): Add tst-audit-threads-mod1 and
	tst-audit-threads-mod2.
	Add rules to build tst-audit-threads.
	* nptl/tst-audit-threads-mod1.c: New file.
	* nptl/tst-audit-threads-mod2.c: Likewise.
	* nptl/tst-audit-threads.c: Likewise.
	* nptl/tst-audit-threads.h: Likewise.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-11-30 18:05:32 -02:00
Joseph Myers 7e1d42400c Replace gen-as-const.awk by gen-as-const.py.
This patch replaces gen-as-const.awk, and some fragments of the
Makefile code that used it, by a Python script.  The point is not such
much that awk is problematic for this particular script, as that I'd
like to build up a general Python infrastructure for extracting
information from C headers, for use in writing tests of such headers.
Thus, although this patch does not set up such infrastructure, the
compute_c_consts function in gen-as-const.py might be moved to a
separate Python module in a subsequent patch as a starting point for
such infrastructure.

The general idea of the code is the same as in the awk version, but no
attempt is made to make the output files textually identical.  When
generating a header, a dict of constant names and values is generated
internally then defines are printed in sorted order (rather than the
order in the .sym file, which would have been used before).  When
generating a test that the values computed match those from a normal
header inclusion, the test code is made into a compilation test using
_Static_assert, where previously the comparisons were done only when
the test was executed.  One fragment of test generation (converting
the previously generated header to use asconst_* prefixes on its macro
names) is still in awk code in the makefiles; only the .sym processing
and subsequent execution of the compiler to extract constants have
moved to the Python script.

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

	* scripts/gen-as-const.py: New file.
	* scripts/gen-as-const.awk: Remove.
	* Makerules ($(common-objpfx)%.h $(common-objpfx)%.h.d): Use
	gen-as-const.py.
	($(objpfx)test-as-const-%.c): Likewise.
2018-11-30 15:20:41 +00:00
H.J. Lu ce7387cc25 elf/dl-exception.c: Include <_itoa.h> for _itoa prototype
Tested with build-many-glibcs.py.

	* elf/dl-exception.c: Include <_itoa.h>.
2018-11-29 20:03:46 -08:00
Samuel Thibault c6a5bdc189 hurd: Fix returning value for fcntl(F_*LK*)
to avoid calling va_end again, etc.

	* sysdeps/mach/hurd/fcntl.c (__libc_fcntl): Directly return value
	returned by __f_setlk.
2018-11-30 02:41:50 +01:00
H.J. Lu a5275ba537 _dl_exception_create_format: Support %x/%lx/%zx
Add support for %x, %lx and %zx to _dl_exception_create_format and pad
to the full width with 0.

	* elf/Makefile (tests-internal): Add tst-create_format1.
	* elf/dl-exception.c (_dl_exception_create_format): Support
	%x, %lx and %zx.
	* elf/tst-create_format1.c: New file.
2018-11-29 14:47:27 -08:00
Charles-Antoine Couret 3a67e81d75 argp: do not call _IO_fwide() if _LIBC is not defined
_IO_fwide() is defined in libio.h file. This file is included only
when _LIBC is defined.

So, in case of compilation of these files without _LIBC definition,
the compilation failed due to this unknown function.

Now this function is called when libio.h file is included.

(Change merged from gnulib.  Tested on x86_64.)

	* argp/argp-fmtstream.c (__argp_fmtstream_update): Use [_LIBC]
	conditional on calls to _IO_fwide and putwc_unlocked.  (Merge from
	gnulib.)
	* argp/argp-help.c (__argp_failure): Likewise.
2018-11-29 17:56:55 +00:00
Mao Han 4975f0c3d0 C-SKY: Add dynamic relocations to elf.h
* elf/elf.h (EM_CSKY, R_CKCORE_NONE, R_CKCORE_ADDR32)
	(R_CKCORE_PCRELIMM8BY4, R_CKCORE_PCRELIMM11BY2, R_CKCORE_PCREL32)
	(R_CKCORE_PCRELJSR_IMM11BY2, R_CKCORE_RELATIVE, R_CKCORE_COPY)
	(R_CKCORE_GLOB_DAT, R_CKCORE_JUMP_SLOT, R_CKCORE_GOTOFF)
	(R_CKCORE_GOTPC, R_CKCORE_GOT32, R_CKCORE_PLT32, R_CKCORE_ADDRGOT)
	(R_CKCORE_ADDRPLT, R_CKCORE_PCREL_IMM26BY2, R_CKCORE_PCREL_IMM16BY2)
	(R_CKCORE_PCREL_IMM16BY4, R_CKCORE_PCREL_IMM10BY2)
	(R_CKCORE_PCREL_IMM10BY4, R_CKCORE_ADDR_HI16, R_CKCORE_ADDR_LO16)
	(R_CKCORE_GOTPC_HI16, R_CKCORE_GOTPC_LO16, R_CKCORE_GOTOFF_HI16)
	(R_CKCORE_GOTOFF_LO16, R_CKCORE_GOT12, R_CKCORE_GOT_HI16)
	(R_CKCORE_GOT_LO16, R_CKCORE_PLT12, R_CKCORE_PLT_HI16)
	(R_CKCORE_PLT_LO16, R_CKCORE_ADDRGOT_HI16, R_CKCORE_ADDRGOT_LO16)
	(R_CKCORE_ADDRPLT_HI16, R_CKCORE_ADDRPLT_LO16)
	(R_CKCORE_PCREL_JSR_IMM26BY2, R_CKCORE_TOFFSET_LO16)
	(R_CKCORE_DOFFSET_LO16, R_CKCORE_PCREL_IMM18BY2)
	(R_CKCORE_DOFFSET_IMM18, R_CKCORE_DOFFSET_IMM18BY2)
	(R_CKCORE_DOFFSET_IMM18BY4, R_CKCORE_GOT_IMM18BY4)
	(R_CKCORE_PLT_IMM18BY4, R_CKCORE_PCREL_IMM7BY4, R_CKCORE_TLS_LE32)
	(R_CKCORE_TLS_IE32, R_CKCORE_TLS_GD32, R_CKCORE_TLS_LDM32)
	(R_CKCORE_TLS_LDO32, R_CKCORE_TLS_DTPMOD32, R_CKCORE_TLS_DTPOFF32)
	(R_CKCORE_TLS_TPOFF32): New defines.
2018-11-29 17:32:13 +00:00
Florian Weimer 250102c844 posix: Do not include testcases.h, ptestcases.h in source tree
These files were both auto-generated and shipped in the source tree.
We can assume that sed is available and always generate the files
during the build.
2018-11-29 13:51:25 +01:00
Florian Weimer 96cd0558bc support: Add signal support to support_capture_subprocess_check
Signal zero does not terminate a process, so it is safe to use negative
values for signal numbers.

Adjust libio/tst-vtables-common.c to use this new functionality,
instead of determining the termination status for a signal indirectly.
2018-11-28 20:57:18 +01:00
Joseph Myers 530504e3a8 Do not copy glibc sources in build-many-glibcs.py.
Now that build-many-glibcs.py touches at checkout time all files that
might get rebuilt in the glibc source directory in a normal glibc
build and test run, this patch stops the script from copying the glibc
source directory, so that all builds use the original directory
directly (and less disk space is used, less I/O is involved and cached
copies of the sources in memory can be shared between all the builds -
as well as avoiding spurious failures from copying while "git gc" is
running).  This is similar to how all other components were already
handled.  Any bugs involving writing into the source directory can be
dealt with in future as normal bugs, just as such bugs already are
handled.

Tested with build-many-glibcs.py runs with a read-only glibc source
directory, with all files not touched by the script having timestamps
in forwards alphabetical order and separately with all files not
touched by the script having timestamps in backwards alphabetical
order.

	* scripts/build-many-glibcs.py (Glibc.build_glibc): Use original
	source directory instead of a copy.
	(CommandList.create_copy_dir): Remove.
2018-11-28 17:28:50 +00:00
Stefan Liebler 9a0b697033 S390: Regenerate ULPs.
Regenerated ulps from scratch as builds with gcc 5.5 / 6.4
resulted in +1 ulps.

ChangeLog:

	* sysdeps/s390/fpu/libm-test-ulps: Regenerated.
2018-11-28 15:20:18 +01:00
Florian Weimer 47d8d9a217 support_quote_string: Do not use str parameter name
This avoids a build failure if this identifier is used as a macro
in a test.
2018-11-28 07:16:48 +01:00
Joseph Myers b473b7d88e Fix Hurd build with read-only source directory.
The logic for generating sysdeps/mach/hurd/bits/errno.h involves a
stamp file and $(move-if-change).

The temporary file (generated unconditionally) is generated in the
source directory.  This means that even if
sysdeps/mach/hurd/bits/errno.h is up to date, and has an up to date
timestamp, the build will fail if the source directory is read-only.
Even with a writable source directory, multiple concurrent builds for
i686-gnu with the same source directory could race to access the
temporary file (which always has the same name).

This patch uses the build directory for the temporary file instead to
avoid those problems.  (In the case where the file is out of date and
the temporary file does need to be moved to the source directory, if
there are multiple concurrent builds for i686-gnu with the same source
directory, and the source and build directories are on different
filesystems, it's possible there might still be races replacing the
file in the source directory, depending on exactly how mv handles such
cross-filesystem moves.  This is certainly no worse than the present
situation, where such a case would have races regardless of whether
the file is out of date or whether different filesystems are in use.)

Tested with a build-many-glibcs.py build for i686-gnu.

	* sysdeps/mach/hurd/Makefile ($(common-objpfx)stamp-errnos): Use
	$(hurd-objpfx)bits/errno.h-tmp, not $(hurd)/bits/errno.h-tmp.
2018-11-27 22:05:49 +00:00
Florian Weimer c74a91deaa support: Implement support_quote_string
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
2018-11-27 21:35:56 +01:00
Florian Weimer d527c860f5 CVE-2018-19591: if_nametoindex: Fix descriptor for overlong name [BZ #23927] 2018-11-27 18:12:49 +01:00
Rafael Ávila de Espíndola 979cfed05d Enable VDSO for static linking on aarch64
[BZ #19767]
	* sysdeps/unix/sysv/linux/aarch64/init-first.c: Remove #ifdef SHARED.
	* sysdeps/unix/sysv/linux/aarch64/libc-vdso.h: Remove #ifdef SHARED.
	* sysdeps/unix/sysv/linux/aarch64/sysdep.h (ALWAYS_USE_VSYSCALL):
	Define.
2018-11-27 12:27:39 +00:00
Carlos O'Donell ce035c6e90 abilist.awk: Treat .tdata like .tbss and reject unknown combinations.
Mathieu Desnoyers ran into an issue with his rseq patch where he
was the first person to add weak thread-local data and this
resulted in an ABI list update with entries like this:
"GLIBC_2.29 w ? D .tdata 0000000000000020".

The weakness of the symbol has nothing to do with the DSOs ABI
and so we should not write anything about weak symbols here. The
.tdata entries should be treated exactly like .tbss entries and
the output should have been: "GLIBC_2.29 __rseq_abi T 0x20"

This change makes abilist.awk handle .tdata just like .tbss,
while at the same time adding an error case for the default, and
the unknown line cases.  We never want anyone to be able to add
such entries to any ABI list files and should see an immediate
error and consult with experts.

Tested by Mathieu Desnoyers <mathieu.desnoyers@efficios.com> with
the rseq patch set and 'make update-all-abi'.

Tested myself with 'make update-all-abi' on x86_64 with no
changes.

Signed-off-by: Carlos O'Donell <carlos@redhat.com>
2018-11-26 21:23:50 -05:00
Joseph Myers 2bd0bfcc68 Touch more glibc source files in build-many-glibcs.py.
build-many-glibcs.py currently copies the source tree to avoid issues
with parallel builds trying to write into it.  This copying can result
in occasional spurious build failures from bots, when a "git gc" is in
progress that changes .git contents while copying is taking place, and
it would also be desirable to avoid the need to copy to save on disk
space, I/O and memory used in build-many-glibcs.py builds.

In preparation for removing the copying, this patch arranges for
build-many-glibcs.py to touch more files on checkout so their
timestamps do not result in make attempting to rebuild them.  Before
actually removing the copying, I intend to do further tests to ensure
I haven't missed any other such makefile dependencies.

This is of course without prejudice to possibly moving more of these
files to being generated in the build directory rather than being
checked in at all, where that can be done using build tools already
required for the build.  For sysdeps files (installed and otherwise)
it would be necessary to make sure this does not affect the search
ordering, for headers used in the build it would be necessary to
ensure they are generated early enough, and for errlist.c there may be
dual licensing reasons for keeping it checked in.

Tested that a checkout with build-many-glibcs.py does touch the
expected files and that a glibcs build for aarch64-linux-gnu succeeds.

	* scripts/build-many-glibcs.py (Context.fix_glibc_timestamps):
	Touch additional files.
2018-11-26 23:52:43 +00:00
Florian Weimer affec03b71 malloc: tcache: Validate tc_idx before checking for double-frees [BZ #23907]
The previous check could read beyond the end of the tcache entry
array.  If the e->key == tcache cookie check happened to pass, this
would result in crashes.
2018-11-26 20:06:37 +01:00
Rafael Ávila de Espíndola 8ae74eadb6 Enable VDSO on powerpc statically linked programs (bug 19767)
[BZ #19767]
	* sysdeps/unix/sysv/linux/powerpc/init-first.c: Remove #ifdef SHARED.
	* sysdeps/unix/sysv/linux/powerpc/libc-vdso.h: Remove #ifdef
	SHARED.  Include sysdep.h.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h: Define
	ALWAYS_USE_VSYSCALL.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h: Define
	ALWAYS_USE_VSYSCALL.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2018-11-26 11:37:19 -02:00
Rafael Ávila de Espíndola 1e8bdc3a2b Enable VDSO on x86_64 statically linked programs [BZ #19767]
All the required code already existed, and some of it was already
running.

AT_SYSINFO_EHDR is processed if NEED_DL_SYSINFO_DSO is defined, but it
looks like it always is. The call to setup_vdso is also unconditional,
so all that was left to do was setup the function pointers and use
them. This patch just deletes some #ifdef to enable that.

	[BZ #19767]
	* nptl/Makefile (tests-static): Add tst-cond11-static.
	(tests): Likewise.
	* nptl/tst-cond11-static.c: New File.
	* sysdeps/unix/sysv/linux/Makefile (tests-static): Add
	tst-affinity-static.
	(tests): Likewise.
	* sysdeps/unix/sysv/linux/sysdep-vdso.h: Check USE_VSYSCALL
	instead of SHARED.
	* sysdeps/unix/sysv/linux/sysdep.h (ALWAYS_USE_VSYSCALL): New.
	(USE_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/tst-affinity-static.c: New file.
	* sysdeps/unix/sysv/linux/x86/libc-vdso.h: Check USE_VSYSCALL
	instead of SHARED.
	* sysdeps/unix/sysv/linux/x86_64/init-first.c: Don't check
	SHARED.
	* sysdeps/unix/sysv/linux/x86_64/sysdep.h (ALWAYS_USE_VSYSCALL):
	New.
2018-11-23 16:50:29 -08:00
Joseph Myers 1283c478aa Fix Arm __ASSUME_COPY_FILE_RANGE (bug 23915).
The generic kernel-features.h defines __ASSUME_COPY_FILE_RANGE for 4.5
and later kernels.  However, for 32-bit Arm binaries running on 64-bit
Arm kernels, the syscall was only wired up in the 4.7 kernel, although
the 32-bit Arm kernel had the syscall from 4.5 onwards.  This patch
corrects the Arm kernel-features.h to undefine the macro for
configured minimum kernel versions before 4.7.

Tested (compilation only) with a build-many-glibcs.py build for
arm-linux-gnueabi.

	[BZ #23915]
	* sysdeps/unix/sysv/linux/arm/kernel-features.h
	[__LINUX_KERNEL_VERSION < 0x040700] (__ASSUME_COPY_FILE_RANGE):
	Undefine.
2018-11-23 17:53:50 +00:00
H.J. Lu c089fd80c7 x86/CET: Add a re-exec test with legacy bitmap
Add a re-exec test with legacy bitmap to verify that legacy bitmap is
properly hanlded by kernel.

	* sysdeps/x86/Makefile (tests): Add tst-cet-legacy-1a.
	(tst-cet-legacy-1a-ARGS): New.
	($(objpfx)tst-cet-legacy-1a): New target.
	* sysdeps/x86/tst-cet-legacy-1a.c: New file.
2018-11-23 07:31:07 -08:00
Joseph Myers 95edd05c75 Combine more conformtest tests into single execution of the compiler.
In <https://sourceware.org/ml/libc-alpha/2018-11/msg00225.html>,
Florian reported that the change from conformtest.pl to conformtest.py
had increased conform/ test time, possibly because of increased
startup overhead for Python scripts.

This patch improves conformtest.py performance by arranging for as
many tests of a (header, standard) pair as possible to use a single
execution of the compiler, so it does not need to initialize and parse
the whole header under test separately for every test assertion.
Specifically, compilation tests that are not marked as "optional" or
"xfail" are combined into a single source file, and are only then run
separately if compilation of that combined file fails.  For me, this
reduces the wall clock time for the conformtest.py tests (not the
whole of the conform/ directory) from two minutes to 15 seconds.

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

	* conform/conformtest.py (CompileSubTest.__init__): Set
	self.run_early to False.
	(ExecuteSubTest.__init__): Likewise.
	(HeaderTests.run): Try running all non-optional, non-XFAILed
	compilation tests in a single execution of the compiler.
2018-11-22 21:21:36 +00:00
Joseph Myers cc6c89faf3 Separate conformtest subtest generation and execution.
This patch continues moving conformtest towards running more tests in
a single compiler execution by separating the generation and execution
of the subtests of each test.

Instead of test classes having a run method that both generates the
text of the programs to be compiled or executed, and compiles or
executes them, they are changed to having a gen_subtests method that
just generates CompileSubTest and ExecuteSubTest objects to store the
subtest names and text, and then a separate loop in HeaderTests.run
deals with actually executing those subtests.

This will allow for future changes to extract the text for all
non-optional, non-xfail compilation subtests to try compiling those
all at once, with separate compilations only if that fails, so
massively reducing the number of separate compiler executions (each of
which needs to parse the entire contents of the header under test, in
addition to the startup cost that applies even for compiling an empty
file).

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

	* conform/conformtest.py (CompileSubTest): New class.
	(ExecuteSubTest): Likewise.
	(ElementTest.run): Rename to gen_subtests.  Append tests to
	self.subtests instead of running them.
	(ConstantTest.run): Likewise.
	(SymbolTest.run): Likewise.
	(TypeTest.run): Likewise.
	(TagTest.run): Likewise.
	(FunctionTest.run): Likewise.
	(VariableTest.run): Likewise.
	(MacroFunctionTest.run): Likewise.
	(MacroStrTest.run): Likewise.
	(HeaderTests.handle_test_line): Generate subtests for tests.
	(HeaderTests.run): Run subtests for tests.
2018-11-22 00:47:20 +00:00
Szabolcs Nagy a502c5294b Remove the error handling wrapper from pow
Introduce new pow symbol version that doesn't do SVID compatible error
handling.  The standard errno and fp exception based error handling is
inline in the new code and does not have significant overhead.

The wrapper is disabled for sysdeps/ieee754/dbl-64 by using empty
w_pow.c and enabled for targets with their own pow implementation or
ifunc dispatch on __ieee754_pow by including math/w_pow.c.

The compatibility symbol version still uses the wrapper with SVID error
handling around the new code.  There is no new symbol version nor
compatibility code on !LIBM_SVID_COMPAT targets (e.g. riscv).

On targets where previously powl was an alias of pow, now it points to
the compatibility symbol with the wrapper, because it still need the
SVID compatible error handling.  This affects NO_LONG_DOUBLE (e.g. arm)
and LONG_DOUBLE_COMPAT (e.g. alpha) targets as well.

The __pow_finite symbol is now an alias of pow.  Both __pow_finite and
pow set errno and thus not const functions.

The ia64 asm is changed so the compat and new symbol versions map to the
same address.

On x86_64 #include <math.h> was added before macro definitions that
may affect that header.

Tested with build-many-glibcs.py.

	* math/Versions (GLIBC_2.29): Add pow.
	* math/w_pow_compat.c (__pow_compat): Change to versioned compat
	symbol.
	* math/w_pow.c: New file.
	* sysdeps/i386/fpu/w_pow.c: New file.
	* sysdeps/ia64/fpu/e_pow.S: Add versioned symbols.
	* sysdeps/ieee754/dbl-64/e_pow.c (__ieee754_pow): Rename to __pow
	and add necessary aliases.
	* sysdeps/ieee754/dbl-64/w_pow.c: New file.
	* sysdeps/m68k/m680x0/fpu/w_pow.c: New file.
	* sysdeps/mach/hurd/i386/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/arm/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/hppa/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/nios2/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sh/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Update.
	* sysdeps/x86_64/fpu/multiarch/e_pow-fma.c (__ieee754_pow): Rename to
	__pow.
	* sysdeps/x86_64/fpu/multiarch/e_pow-fma4.c (__ieee754_pow): Likewise.
	* sysdeps/x86_64/fpu/multiarch/e_pow.c (__ieee754_pow): Likewise.
	* sysdeps/x86_64/fpu/multiarch/w_pow.c: New file.
2018-11-21 09:58:36 +00:00
Szabolcs Nagy 718d6542f2 Remove the error handling wrapper from log2
Introduce new log2 symbol version that doesn't do SVID compatible error
handling.  The standard errno and fp exception based error handling is
inline in the new code and does not have significant overhead.

The wrapper is disabled for sysdeps/ieee754/dbl-64 by using empty
w_log2.c and enabled for targets with their own log2 implementation by
including math/w_log2.c.

The compatibility symbol version still uses the wrapper with SVID error
handling around the new code.  There is no new symbol version nor
compatibility code on !LIBM_SVID_COMPAT targets (e.g. riscv).

On targets where previously log2l was an alias of log2, now it points to
the compatibility symbol with the wrapper, because it still need the
SVID compatible error handling.  This affects NO_LONG_DOUBLE (e.g. arm)
and LONG_DOUBLE_COMPAT (e.g. alpha) targets as well.

The __log2_finite symbol is now an alias of log2.  Both __log2_finite
and log2 set errno and thus not const functions.

The ia64 asm is changed so the compat and new symbol versions map to the
same address.

Tested with build-many-glibcs.py.

	* math/Versions (GLIBC_2.29): Add log2.
	* math/w_log2_compat.c (__log2_compat): Change to versioned compat
	symbol.
	* math/w_log2.c: New file.
	* sysdeps/i386/fpu/w_log2.c: New file.
	* sysdeps/ia64/fpu/e_log2.S: Add versioned symbols.
	* sysdeps/ieee754/dbl-64/e_log2.c (__ieee754_log2): Rename to __log2
	and add necessary aliases.
	* sysdeps/ieee754/dbl-64/w_log2.c: New file.
	* sysdeps/m68k/m680x0/fpu/w_log2.c: New file.
	* sysdeps/mach/hurd/i386/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/arm/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/hppa/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/nios2/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sh/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Update.
2018-11-21 09:57:21 +00:00
Szabolcs Nagy f29b7c492d Remove the error handling wrapper from log
Introduce new log symbol version that doesn't do SVID compatible error
handling.  The standard errno and fp exception based error handling is
inline in the new code and does not have significant overhead.

The wrapper is disabled for sysdeps/ieee754/dbl-64 by using empty
w_log.c and enabled for targets with their own log implementation by
including math/w_log.c.

The compatibility symbol version still uses the wrapper with SVID error
handling around the new code.  There is no new symbol version nor
compatibility code on !LIBM_SVID_COMPAT targets (e.g. riscv).

On targets where previously logl was an alias of log, now it points to
the compatibility symbol with the wrapper, because it still need the
SVID compatible error handling.  This affects NO_LONG_DOUBLE (e.g. arm)
and LONG_DOUBLE_COMPAT (e.g. alpha) targets as well.

The __log_finite symbol is now an alias of log.  Both __log_finite and
log set errno and thus not const functions.

The ia64 asm is changed so the compat and new symbol versions map to the
same address.

On x86_64 #include <math.h> was added before macro definitions that may
affect that header.

Tested with build-many-glibcs.py.

	* math/Versions (GLIBC_2.29): Add log.
	* math/w_log_compat.c (__log_compat): Change to versioned compat
	symbol.
	* math/w_log.c: New file.
	* sysdeps/i386/fpu/w_log.c: New file.
	* sysdeps/ia64/fpu/e_log.S: Update.
	* sysdeps/ieee754/dbl-64/e_log.c (__ieee754_log): Rename to __log
	and add necessary aliases.
	* sysdeps/ieee754/dbl-64/w_log.c: New file.
	* sysdeps/m68k/m680x0/fpu/w_log.c: New file.
	* sysdeps/mach/hurd/i386/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/arm/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/hppa/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/nios2/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sh/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Update.
	* sysdeps/x86_64/fpu/multiarch/e_log-avx.c (__ieee754_log): Rename to
	__log.
	* sysdeps/x86_64/fpu/multiarch/e_log-fma.c (__ieee754_log): Likewise.
	* sysdeps/x86_64/fpu/multiarch/e_log-fma4.c (__ieee754_log): Likewise.
	* sysdeps/x86_64/fpu/multiarch/e_log.c (__ieee754_log): Likewise.
	* sysdeps/x86_64/fpu/multiarch/w_log.c: New file.
2018-11-21 09:56:27 +00:00
Szabolcs Nagy c20a10561a Remove the error handling wrapper from exp and exp2
Introduce new exp and exp2 symbol version that don't do SVID compatible
error handling.  The standard errno and fp exception based error handling
is inline in the new code and does not have significant overhead.

The double precision wrappers are disabled for sysdeps/ieee754/dbl-64
by using empty w_exp.c and w_exp2.c files, the math/w_exp.c and
math/w_exp2.c files use the wrapper template and can be included by
targets that have their own exp and exp2 implementations or use ifunc
on the glibc internal __ieee754_exp symbol.

The compatibility symbol versions still use the wrapper with SVID error
handling around the new code.  There is no new symbol version nor
compatibility code on !LIBM_SVID_COMPAT targets (e.g. riscv).

On targets where previously expl and exp2l were aliases of exp and exp2,
now they point to the compatibility symbols with the wrapper, because
they still need the SVID compatible error handling.  This affects
NO_LONG_DOUBLE (e.g arm) and LONG_DOUBLE_COMPAT (e.g. alpha) targets
as well.

The _finite symbols are now aliases of the standard symbols (they have
no performance advantage anymore).  Both the standard symbols and
_finite symbols set errno and thus not const functions.

The ia64 asm is changed so the compat and new symbol versions map to the
same address.

On x86_64 #include <math.h> was added before macro definitions that may
affect that header (the new macro name is __exp instead of __ieee754_exp
which breaks some math.h macros).

Tested with build-many-glibcs.py.

	* math/Versions (GLIBC_2.29): Add exp and exp2.
	* math/w_exp2_compat.c (__exp2_compat): Change to versioned compat
	symbol, handle NO_LONG_DOUBLE and LONG_DOUBLE_COMPAT explicitly.
	* math/w_exp_compat.c (__exp_compat): Likewise.
	* math/w_exp.c: New file.
	* math/w_exp2.c: New file.
	* sysdeps/i386/fpu/w_exp.c: New file.
	* sysdeps/i386/fpu/w_exp2.c: New file.
	* sysdeps/ia64/fpu/e_exp.S: Add versioned symbols.
	* sysdeps/ia64/fpu/e_exp2.S: Likewise.
	* sysdeps/ieee754/dbl-64/e_exp.c (__ieee754_exp): Rename to __exp
	and add necessary aliases.
	* sysdeps/ieee754/dbl-64/e_exp2.c (__ieee754_exp2): Rename to __exp2
	and add necessary aliases.
	* sysdeps/ieee754/dbl-64/w_exp.c: New file.
	* sysdeps/ieee754/dbl-64/w_exp2.c: New file.
	* sysdeps/m68k/m680x0/fpu/w_exp.c: New file.
	* sysdeps/m68k/m680x0/fpu/w_exp2.c: New file.
	* sysdeps/mach/hurd/i386/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/arm/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/hppa/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/nios2/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Update.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sh/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Update.
	* sysdeps/x86_64/fpu/multiarch/e_exp-avx.c (__exp1): Remove.
	(__ieee754_exp): Rename to __exp.
	* sysdeps/x86_64/fpu/multiarch/e_exp-fma.c (__exp1): Remove.
	(__ieee754_exp): Rename to __exp.
	* sysdeps/x86_64/fpu/multiarch/e_exp-fma4.c (__exp1): Remove.
	(__ieee754_exp): Rename to __exp.
	* sysdeps/x86_64/fpu/multiarch/e_exp.c (__ieee754_exp): Rename to
	__exp.
	* sysdeps/x86_64/fpu/multiarch/w_exp.c: New file.
2018-11-21 09:55:02 +00:00
DJ Delorie bcdaad21d4 malloc: tcache double free check
* malloc/malloc.c (tcache_entry): Add key field.
(tcache_put): Set it.
(tcache_get): Likewise.
(_int_free): Check for double free in tcache.
* malloc/tst-tcfree1.c: New.
* malloc/tst-tcfree2.c: New.
* malloc/Makefile: Run the new tests.
* manual/probes.texi: Document memory_tcache_double_free probe.

* dlfcn/dlerror.c (check_free): Prevent double frees.
2018-11-20 13:24:09 -05:00
Wilco Dijkstra 5770c0ad1e [AArch64] Adjust writeback in non-zero memset
This fixes an ineffiency in the non-zero memset.  Delaying the writeback
until the end of the loop is slightly faster on some cores - this shows
~5% performance gain on Cortex-A53 when doing large non-zero memsets.

	* sysdeps/aarch64/memset.S (MEMSET): Improve non-zero memset loop.
2018-11-20 12:37:00 +00:00
Joseph Myers 9a62a9397d Use unique identifiers in conformtest.
This patch makes tests in conformtest use unique identifiers, in
preparation for trying to cover more tests in a single compilation to
speed up these tests as suggested in
<https://sourceware.org/ml/libc-alpha/2018-11/msg00229.html>.

Tests are assigned a number, used in generating identifiers; where a
single call to a run method does multiple compilations (sharing that
number), identifiers are changed as needed to avoid duplication
between those compilations, so they can be combined in future.

Large numbers of positional arguments to format strings make the code
harder to follow, and using the test numbers serves to increase the
number of arguments to such format strings, so the code is generally
changed to use %(name)s where all the arguments come from attributes
of the test object and so vars(self) is sufficient to provide all
those names for the format string.  Cases where some arguments aren't
attributes of self still use positional format arguments.

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

	* conform/conformtest.py (ElementTest.run): Use unique identifiers
	in tests.  Use names for format arguments.
	(ConstantTest.run): Likewise.
	(SymbolTest.run): Likewise.
	(TypeTest.run): Likewise.
	(TagTest.run): Likewise.
	(FunctionTest.run): Likewise.
	(VariableTest.run): Likewise.
	(MacroFunctionTest.run): Likewise.
	(MacroStrTest.run): Likewise.
	(HeaderTests.__init__): Set self.num_tests.
	(HeaderTests.handle_test_line): Set test.num.  Increment
	self.num_tests.
2018-11-20 03:54:53 +00:00
Samuel Thibault b15b1a9590 hurd: Support lockf at offset 0 with size 0 or 1.
* sysdeps/mach/hurd/f_setlk.c: Include <unistd.h>.
	(__f_setlk): When whence is SEEK_CUR, use __lseek64 to convert it to
	SEEK_SET.
2018-11-19 20:22:30 +01:00
Mao Han 0c7f97aead Update config.guess and config.sub to current versions.
* scripts/config.guess: Update to version 2018-08-29.
	* scripts/config.sub: Update to version 2018-08-29.
2018-11-19 16:51:42 +00:00
Florian Weimer 35e3fbc451 support: Print timestamps in timeout handler
This is sometimes useful to determine if a test truly got stuck, or if
it was making progress (logging information to standard output) and
was merely slow to finish.
2018-11-19 15:35:03 +01:00
Zack Weinberg c75772e3f0 Use STRFMON_LDBL_IS_DBL instead of __ldbl_is_dbl.
On platforms where long double used to have the same format as double,
but later switched to a different format (alpha, s390, sparc, and
powerpc), accessing the older behavior is possible and it happens via
__nldbl_* functions (not on the API, but accessible from header
redirection and from compat symbols).  These functions write to the
global flag __ldbl_is_dbl, which tells other functions that long double
variables should be handled as double.  This patch takes the first step
towards removing this global flag and creates __vstrfmon_l_internal,
which takes an explicit flags parameter.

This change arguably makes the generated code slightly worse on
architectures where __ldbl_is_dbl is never true; right now, on those
architectures, it's a compile-time constant; after this change, the
compiler could theoretically prove that __vstrfmon_l_internal was
never called with a nonzero flags argument, but it would probably need
LTO to do it.  This is not performance critical code and I tend to
think that the maintainability benefits of removing action at a
distance are worth it.  However, we _could_ wrap the runtime flag
check with a macro that was defined to ignore its argument and always
return false on architectures where __ldbl_is_dbl is never true, if
people think the codegen benefits are important.

Tested for powerpc and powerpc64le.
2018-11-16 09:21:14 -02:00
Samuel Thibault 346ef23f19 hurd: Fix F_*LK* fcntl with __USE_FILE_OFFSET64
struct flock64 uses 64bit values. This introduces other values for F_GETLK,
F_SETLK, F_SETLKW to distinguish between both.

	* sysdeps/mach/hurd/bits/fcntl.h (F_GETLK64, F_SETLK64, F_SETLKW64): New
	macros
	[__USE_FILE_OFFSET64] (F_GETLK, F_SETLK, F_SETLKW): Define to F_GETLK64,
	F_SETLK64, F_SETLKW64, respectively.
	* sysdeps/mach/hurd/f_setlk.c: New file.
	* sysdeps/mach/hurd/f_setlk.h: New file.
	* sysdeps/mach/hurd/Makefile [$(subdir) = io] (sysdeps_routines): Add
	f_setlk.
	* sysdeps/mach/hurd/fcntl.c: Include "f_setlk.h".h".
	(__libc_fcntl): Move non-flock operations to...
	* sysdeps/mach/hurd/vfcntl.c (__libc_vfcntl): ... New file.
	* sysdeps/mach/hurd/fcntl.c (fcntl64): Add missing alias.
2018-11-16 09:41:05 +01:00
Paul Eggert 5d8af1566b mktime: DEBUG_MKTIME cleanup
The DEBUG_MKTIME code no longer works in glibc or in Gnulib.
And it’s no longer needed now that glibc and Gnulib both have
their own testing mechanisms for mktime.
* time/mktime.c (DEBUG_MKTIME): Remove.  All uses removed.
2018-11-15 22:59:33 +01:00
Paul Eggert 86aece3bfb mktime: fix non-EOVERFLOW errno handling
[BZ#23789]
mktime was not properly reporting failures when the underlying
localtime_r fails with errno != EOVERFLOW; it incorrectly treated
them like EOVERFLOW failures, and set errno to EOVERFLOW.
The problem could happen on non-glibc platforms, with Gnulib.
* time/mktime.c (guess_time_tm): Remove, replacing with ...
(tm_diff): ... this simpler function, which does not change errno.
All callers changed to deal with errno themselves.
(ranged_convert, __mktime_internal): Return failure immediately if
the underlying function reports any failure other than EOVERFLOW.
(__mktime_internal): Set errno to EOVERFLOW if the spring-forward
gap code fails.
2018-11-15 22:59:33 +01:00
Paul Eggert f6b3331bba mktime: fix bug with Y2038 DST transition
[BZ#23789]
* time/mktime.c (ranged_convert): On 32-bit platforms, don’t
mishandle a DST transition that jumps over the Y2038 boundary.
No such DST transitions are known so this is only a theoretical
bug, but we might as well do things right.
2018-11-15 22:59:33 +01:00
Paul Eggert efbdddc381 mktime: make more room for overflow
[BZ#23789]
* time/mktime.c (long_int): Now 4⨯ int, not just 3⨯.
This is so that we can add tm_diff results to a previous guess,
which will be useful in a later patch.
2018-11-15 22:59:33 +01:00
Paul Eggert 6c90d759f6 mktime: simplify offset guess
[BZ#23789]
* time/mktime.c (__mktime_internal): Omit excess precision.
2018-11-15 22:59:33 +01:00
Paul Eggert 32c12f3f7a mktime: new test for mktime failure
[BZ#23789]
Based on a test suggested by Albert Aribaud in:
https://www.sourceware.org/ml/libc-alpha/2018-10/msg00662.html
* time/Makefile (tests): Add bug-mktime4.
* time/bug-mktime4.c: New file.
2018-11-15 22:59:33 +01:00
Paul Eggert de20b81a03 mktime: fix EOVERFLOW bug
[BZ#23789]
* time/mktime.c [!_LIBC && !DEBUG_MKTIME]:
Include libc-config.h, not config.h, for __set_errno.
(guess_time_tm, __mktime_internal): Set errno to EOVERFLOW on overflow.
2018-11-15 22:59:33 +01:00
Samuel Thibault 8c6c3fb0bc hurd: Fix build with GCC 9
* sysdeps/mach/hurd/dl-sysdep.c (check_no_hidden): Use
	__attribute_copy__ to copy attributes from name. Drop static qualifier
	to avoid warnings about leaf attribute not having effect on static
	functions.
2018-11-14 01:36:44 +01:00
Florian Weimer 6923f6db1e malloc: Use current (C11-style) atomics for fastbin access 2018-11-13 10:36:10 +01:00
Joseph Myers 0c096dcf14 Fix mips build with GCC 9.
This patch fixes the build for MIPS (o32) with GCC 9 by stopping MIPS
__longjmp from using strong_alias, instead defining the alias
manually, so that the intended effect of not copying the nomips16
attribute is achieved, as explained in the included comment.

Tested with build-many-glibcs.py compilers build for mips64-linux-gnu
(which includes glibc builds for all three ABIs).

	* sysdeps/mips/__longjmp.c (__longjmp): Define alias manually with
	alias attribute, not with strong_alias.
2018-11-13 01:55:15 +00:00
Joseph Myers 9c4b457e1b Add hidden_tls_def macros, fix powerpc-soft build with GCC 9.
Soft-float powerpc fails to build with current GCC mainline because of
use of libc_hidden_data_def for TLS variables, resulting in a non-TLS
alias being defined, to which the tls_model attribute is now copied,
resulting in a warning about it being ignored.

The problem here appears to be the non-TLS alias.  This patch adds a
hidden_tls_def macro family, corresponding to the hidden_tls_proto
macros, to define TLS aliases properly in such a case, and uses it for
those powerpc soft-float variables.

Tested with build-many-glibcs.py compilers build for powerpc-linux-gnu
soft-float.  Also tested for x86_64.

	* include/libc-symbols.h [SHARED && !NO_HIDDEN && !__ASSEMBLER__]
	(__hidden_ver2): New macro.  Use old definition of __hidden_ver1
	with additional parameter thread.
	[SHARED && !NO_HIDDEN && !__ASSEMBLER__] (__hidden_ver1): Define
	in terms of __hidden_ver2.
	(hidden_tls_def): New macro.
	(libc_hidden_tls_def): Likewise.
	(rtld_hidden_tls_def): Likewise.
	(libm_hidden_tls_def): Likewise.
	(libmvec_hidden_tls_def): Likewise.
	(libresolv_hidden_tls_def): Likewise.
	(librt_hidden_tls_def): Likewise.
	(libdl_hidden_tls_def): Likewise.
	(libnss_files_hidden_tls_def): Likewise.
	(libnsl_hidden_tls_def): Likewise.
	(libnss_nisplus_hidden_tls_def): Likewise.
	(libutil_hidden_tls_def): Likewise.
	(libutil_hidden_tls_def): Likweise.
	* sysdeps/powerpc/nofpu/sim-full.c (__sim_exceptions_thread): Use
	libc_hidden_tls_def.
	(__sim_disabled_exceptions_thread): Likewise.
	(__sim_round_mode_thread): Likewise.
2018-11-13 01:53:53 +00:00
Joseph Myers 53f5c65914 Fix sparc64 build with GCC 9.
Similar to the x86_64 and armv7 build issues, glibc fails to build for
sparc64 with current mainline GCC because of aliases declared in the
course of defining IFUNCs, which copy their attributes from a header
declaration, ending up with fewer attributes than the (built-in)
string function they alias.  This patch fixes the issue similarly to
the fixes for those other architectures.

Tested with build-many-glibcs.py compilers build for
sparc64-linux-gnu.

	* sysdeps/sparc/sparc-ifunc.h [SHARED]
	(sparc_ifunc_redirected_hidden_def): Use __attribute_copy__ to
	copy attributes from name.
2018-11-13 00:27:06 +00:00
Joseph Myers f578f97b97 Fix armv7 build with GCC 9.
Similar to the x86_64 build issues, glibc fails to build for armv7
with current mainline GCC because of aliases declared in the course of
defining IFUNCs, which copy their attributes from a header
declaration, ending up with fewer attributes than the (built-in)
string function they alias: the relevant attributes (nonnull, leaf)
are present on the header declaration, but elided therefrom when glibc
itself if being built (whatever the reasons are for disabling the
nonnull and leaf attributes in that case, and whether or not those
reasons are actually still valid).  This patch fixes the issue
similarly to the x86_64 fix, by adding an addition __attribute_copy__
use (in this case, on the definition of arm_libc_ifunc_hidden_def).

Tested with build-many-glibcs.py build for armeb-linux-gnueabi-be8.

	* sysdeps/arm/arm-ifunc.h [SHARED] (arm_libc_ifunc_hidden_def):
	Use __attribute_copy__ to copy attributes from name.
2018-11-12 23:59:29 +00:00
Joseph Myers 9a7c643ac2 Fix i686 build with GCC 9.
This patch fixes the glibc build for i686 with current mainline GCC,
where there are warnings about inconsistent attributes for aliases in
certain files defining libm IFUNCs.

In three of the files, the aliases were defined in terms of internal
symbols such as __sinf, and copied attributes from file-local
declarations of those functions which lacked the nothrow attribute.
Since the nothrow attribute is present on the declarations from
<math.h> (which include declarations of those __-prefixed functions),
the natural fix was to include <math.h> in those files, replacing the
local declarations.

In the other three files, a more complicated __hidden_ver1 call was
involved in the warnings.  <math.h> has not been included at this
point and, furthermore, it is included indirectly only later in the
source file after macros have been defined to remap a function name
therein.  So there isn't an obvious declaration from which to copy the
attribute and it seems simplest and safest just to add __THROW to the
hidden_ver1 calls.

Tested for i686 (build-many-glibcs.py compilers build for
x86_64-linux-gnu with GCC mainline; full testsuite run with GCC 7).

	* sysdeps/i386/i686/fpu/multiarch/e_expf.c [SHARED]: Use __THROW
	with __hidden_ver1 call.
	* sysdeps/i386/i686/fpu/multiarch/e_log2f.c [SHARED]: Likewise.
	* sysdeps/i386/i686/fpu/multiarch/e_logf.c [SHARED]: Likewise.
	* sysdeps/i386/i686/fpu/multiarch/s_cosf.c: Include <math.h>.
	(__cosf): Do not declare here.
	* sysdeps/i386/i686/fpu/multiarch/s_sincosf.c: Include <math.h>.
	(__sincosf): Do not declare here.
	* sysdeps/i386/i686/fpu/multiarch/s_sinf.c: Include <math.h>.
	(__sinf): Do not declare here.
2018-11-12 18:47:05 +00:00
Joseph Myers 092dfde68f Remove redundant macro definitions from ia64 sfp-machine.h.
After the changes to use the copy attribute, building glibc for ia64
fails, even with older compilers, because
sysdeps/ia64/fpu/sfp-machine.h has a definition of _strong_alias that
now differs from the one in libc-symbols.h.

That definition is a relic of this file coming from libgcc, as are
some other such macro definitions in this file; in the glibc context,
there is no need for those macros, and this patch removes them to fix
the build.

Tested with build-many-glibcs.py for ia64-linux-gnu.

	* sysdeps/ia64/fpu/sfp-machine.h (__LITTLE_ENDIAN): Remove.
	(__BIG_ENDIAN): Likewise.
	(__BYTE_ORDER): Likewise.
	(strong_alias): Likewise.
	(_strong_alias): Likewise.
2018-11-12 14:37:45 +00:00
Florian Weimer 1ecba1fafc malloc: Convert the unlink macro to the unlink_chunk function
This commit is in preparation of turning the macro into a proper
function.  The output arguments of the macro were in fact unused.

Also clean up uses of __builtin_expect.
2018-11-12 14:35:06 +01:00
Samuel Thibault 58bb655acb hurd: Document dtable_cloexec size convention.
* sysdeps/mach/hurd/spawni.c (__spawni): Use orig_dtablesize instead
	of dtablesize for allocating dtable_cloexec.
2018-11-11 18:55:24 +01:00
Samuel Thibault 88b26b7e91 Hurd: export _hurd_port_move
* hurd/Versions (_hurd_port_move): Export function.
	* sysdeps/mach/hurd/i386/libc.abilist (_hurd_port_move): Expect
	symbol.
2018-11-10 13:13:12 +00:00
Samuel Thibault 7fa495cdf7 Hurd: Fix ulinks in fd table reallocation
* hurd/hurd/userlink.h (_hurd_userlink_move): New function.
	* hurd/hurd/port.h (_hurd_port_move): New function.
	* sysdeps/mach/hurd/spawni.c (NEW_ULINK_TABLE): New macro.
	(EXPAND_DTABLE): Use NEW_ULINK_TABLE macro for ulink_dtable.
2018-11-10 11:20:12 +00:00
Samuel Thibault 434c34bd8e Hurd: Implement chdir support in posix_spawn
This fixes build-many-glibcs.py on i686-gnu.

Thanks Florian Weimer for the initial version.

* sysdeps/mach/hurd/spawni.c (__spawni): Add ccwdir port. Test and use
it, free it if needed.
(reauthenticate): Test and use ccwdir.
(child_init_port): In non-resetids case, test and use ccwdir.
(child_chdir): New nested function to set ccwdir.
2018-11-10 10:45:13 +00:00
Martin Sebor 1626a1cfcd Add support for GCC 9 attribute copy.
GCC 9 has gained an enhancement to help detect attribute mismatches
between alias declarations and their targets.  It consists of a new
warning, -Wattribute-alias, an enhancement to an existing warning,
-Wmissing-attributes, and a new attribute called copy.

The purpose of the warnings is to help identify either possible bugs
(an alias declared with more restrictive attributes than its target
promises) or optimization or diagnostic opportunities (an alias target
missing some attributes that it could be declared with that might
benefit analysis and code generation).  The purpose of the new
attribute is to easily apply (almost) the same set of attributes
to one declaration as those already present on another.

As expected (and intended) the enhancement triggers warnings for
many alias declarations in Glibc code.  This change, tested on
x86_64-linux, avoids all instances of the new warnings by making
use of the attribute where appropriate.  To fully benefit from
the enhancement Glibc will need to be compiled with
 -Wattribute-alias=2 and remaining warnings reviewed and dealt with
(there are a couple of thousand but most should be straightforward
to deal with).

ChangeLog:

	* include/libc-symbols.h (__attribute_copy__): Define macro unless
	it's already defined.
	(_strong_alias): Use __attribute_copy__.
	(_weak_alias,  __hidden_ver1,  __hidden_nolink2): Same.
	* misc/sys/cdefs.h (__attribute_copy__): New macro.
	* sysdeps/x86_64/multiarch/memchr.c (memchr): Use __attribute_copy__.
	* sysdeps/x86_64/multiarch/memcmp.c (memcmp): Same.
	* sysdeps/x86_64/multiarch/mempcpy.c (mempcpy): Same.
	* sysdeps/x86_64/multiarch/memset.c (memset): Same.
	* sysdeps/x86_64/multiarch/stpcpy.c (stpcpy): Same.
	* sysdeps/x86_64/multiarch/strcat.c (strcat): Same.
	* sysdeps/x86_64/multiarch/strchr.c (strchr): Same.
	* sysdeps/x86_64/multiarch/strcmp.c (strcmp): Same.
	* sysdeps/x86_64/multiarch/strcpy.c (strcpy): Same.
	* sysdeps/x86_64/multiarch/strcspn.c (strcspn): Same.
	* sysdeps/x86_64/multiarch/strlen.c (strlen): Same.
	* sysdeps/x86_64/multiarch/strncmp.c (strncmp): Same.
	* sysdeps/x86_64/multiarch/strncpy.c (strncpy): Same.
	* sysdeps/x86_64/multiarch/strnlen.c (strnlen): Same.
	* sysdeps/x86_64/multiarch/strpbrk.c (strpbrk): Same.
	* sysdeps/x86_64/multiarch/strrchr.c (strrchr): Same.
	* sysdeps/x86_64/multiarch/strspn.c (strspn): Same.
2018-11-09 17:24:12 -07:00
Gabriel F. T. Gomes 968ed5301d Convert tst-efgcvt to the new test framework
The function do_test, in tst-efgcvt.c, increments an error counter for
each error that it finds, then returns it to the test framework.
However, the test framework does not expect an error count as return,
but zero for a passing test, one for a failing test, or 77 for an
unsupported test.  Alternatively, the framework provides the function
support_record_failure that records errors, which then allows the test
program to return zero unconditionally.

This patch removes the error counter, replaces each increment of the
counter with a call to support_record_failure, and makes do_test
unconditionally return zero.

Tested for powerpc64le (as-is and with a patched results table to check
that the error reporting actually works).

	* misc/tst-efgcvt.c: Include support/check.h and
	support/test-driver.c.  Do not include test-skeleton.c.
	(error_count): Remove.
	(output_error): Replace increments to error_count with calls to
	support_record_failure.
	(output_r_error): Likewise.
	(special): Likewise.
	(do_test): Unconditionally return zero.
	(TEST_FUNCTION): Remove.
2018-11-09 16:16:38 -02:00
Joseph Myers 91faaa93a5 Update conform/Makefile mkdir commands.
conform/Makefile creates $(@D)/scratch for the per-standard per-header
tests.  That directory was formerly used by the Perl scripts for
temporary files, but the Python implementations use
tempfile.TemporaryDirectory to get such files cleaned up
automatically.  This patch changes the Makefile to create only $(@D)
(required for the output redirection to work), not the scratch
subdirectory.

Tested for x86_64.

	* conform/Makefile ($(conformtest-header-tests)): Create $(@D),
	not $(@D)/scratch.
	($(linknamespace-header-tests)): Likewise.
2018-11-09 17:40:58 +00:00
Joseph Myers c3ec097256 Replace conformtest.pl with conformtest.py.
Continuing the consolidation on Python for various miscellaneous build
and test scripts, this patch moves conformtest from Perl to Python.

The substance of the tests run is intended to be the same as before,
except that the previous test for tags did not actually achieve the
intended purpose of verifying whether a tag was already declared, so
is changed to one that would actually fail for a tag that wasn't
declared, and a typo in the old test for variables being available
($xyzzy instead of xyzzy) would have made that test not use the
correct type (but it would have passed anyway with warnings).  No
attempt is made to keep the details of what the test output looks
like; instead, tests are given names which are made to follow PASS: /
FAIL: / XFAIL: / SKIP: / MISSING: as appropriate.

In the new version, there is more consistent parsing of test lines
(into a series of words, either surrounded by {} or separated by
spaces) that applies for all kinds of test lines, rather than the old
approach of different regular expressions for every kind of test.  A
few of the conform/data/ files are adjusted so their syntax works with
the new script (which now requires spaces in certain cases where the
old script tolerated them being missing, and does not allow stray
semicolons at the end of "function" lines).  Similarly, common logic
is used around what happens with a second subtest if a first one fails
(e.g., a test for a symbol's type if the test for availability fails),
rather than such logic being replicated separately for each kind of
test.  Common parsing also applies for test lines both when they are
lines for the header under test and when they are lines for another
header specified with allow-header, again unlike the old script.

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

	* conform/conformtest.py: New file.
	* conform/conformtest.pl: Remove.
	* conform/GlibcConform.pm: Likewise.
	* conform/glibcconform.py (KEYWORDS_C90): New constant.
	(KEYWORDS_C99): Likewise.
	(KEYWORDS): Likewise.
	* conform/Makefile ($(conformtest-header-tests)): Use
	conformtest.py instead of conformtest.pl.  Do not pass --tmpdir
	option.  Use --header instead of --headers.
	* conform/data/arpa/inet.h-data: Remove trailing semicolons on
	function entries.
	* conform/data/spawn.h-data: Likewise.
	* conform/data/fcntl.h-data (openat): Add space after function
	name.
	* conform/data/wchar.h-data (wcscasecmp): Likewise.
	(wcscasecmp_l): Likewise.
	* conform/data/termios.h-data (c_cc): Add space after element
	name.
2018-11-09 13:54:06 +00:00
Gabriel F. T. Gomes 43257c335a Use TEST_COMPARE_STRING in recently added test
The commit

commit 1df872fd74
Author: Florian Weimer <fweimer@redhat.com>
Date:   Wed Nov 7 12:42:44 2018 +0100

    support: Implement TEST_COMPARE_STRING

added the new macro TEST_COMPARE_STRING, which compares the output of
functions under test against expected strings, and, when there's a
mismatch, automatically reports an error and prints the differences.
This patch adapts recently added test cases to use this new macro.

Tested for powerpc64le (as is, and locally patched to intentionally fail
and produce error output).

	* argp/tst-ldbl-argp.c (do_one_test): Use TEST_COMPARE_STRING,
	instead of manually comparing and reporting mismatching strings.
	* misc/tst-ldbl-error.c (do_one_test): Likewise.
	* misc/tst-ldbl-warn.c (do_one_test): Likewise.
2018-11-08 22:42:01 -02:00
Joseph Myers e5de3b5b72 Remove __ASSUME_SOCKETCALL.
The __ASSUME_SOCKETCALL macro in kernel-features.h is no longer used
for anything.  (It used to be used in defining other macros related to
accept4 / recvmmsg / sendmmsg availability, but the code in that area
was simplified once we could assume a kernel with those features,
whether through a syscall or through socketcall, so allowing those
functions to be handled much like other socket operations, without
requring __ASSUME_SOCKETCALL.)  This patch removes that unused macro.

(Note: once we can assume a Linux 4.4 or later kernel, much of the
support for using socketcall at all can be removed from glibc,
although a few functions may need that support in glibc for longer.)

Tested with build-many-glibcs.py.

	* sysdeps/unix/sysv/linux/kernel-features.h: Remove comment about
	__ASSUME_SOCKETCALL.
	* sysdeps/unix/sysv/linux/i386/kernel-features.h
	(__ASSUME_SOCKETCALL): Remove.
	* sysdeps/unix/sysv/linux/m68k/kernel-features.h
	(__ASSUME_SOCKETCALL): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	(__ASSUME_SOCKETCALL): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/kernel-features.h
	(__ASSUME_SOCKETCALL): Likewise.
	* sysdeps/unix/sysv/linux/s390/kernel-features.h
	(__ASSUME_SOCKETCALL): Likewise.
	* sysdeps/unix/sysv/linux/sh/kernel-features.h
	(__ASSUME_SOCKETCALL): Likewise.
	* sysdeps/unix/sysv/linux/sparc/kernel-features.h
	(__ASSUME_SOCKETCALL): Likewise.
2018-11-08 20:28:07 +00:00
H.J. Lu d524fa6c35 Check multiple NT_GNU_PROPERTY_TYPE_0 notes [BZ #23509]
Linkers group input note sections with the same name into one output
note section with the same name.  One output note section is placed in
one PT_NOTE segment.  Since new linkers merge input .note.gnu.property
sections into one output .note.gnu.property section, there is only
one NT_GNU_PROPERTY_TYPE_0 note in one PT_NOTE segment with new linkers.
Since older linkers treat input .note.gnu.property section as a generic
note section and just concatenate all input .note.gnu.property sections
into one output .note.gnu.property section without merging them, we may
see multiple NT_GNU_PROPERTY_TYPE_0 notes in one PT_NOTE segment with
older linkers.

When an older linker is used to created the program on CET-enabled OS,
the linker output has a single .note.gnu.property section with multiple
NT_GNU_PROPERTY_TYPE_0 notes, some of which have IBT and SHSTK enable
bits set even if the program isn't CET enabled.  Such programs will
crash on CET-enabled machines.  This patch updates the note parser:

1. Skip note parsing if a NT_GNU_PROPERTY_TYPE_0 note has been processed.
2. Check multiple NT_GNU_PROPERTY_TYPE_0 notes.

	[BZ #23509]
	* sysdeps/x86/dl-prop.h (_dl_process_cet_property_note): Skip
	note parsing if a NT_GNU_PROPERTY_TYPE_0 note has been processed.
	Update the l_cet field when processing NT_GNU_PROPERTY_TYPE_0 note.
	Check multiple NT_GNU_PROPERTY_TYPE_0 notes.
	* sysdeps/x86/link_map.h (l_cet): Expand to 3 bits,  Add
	lc_unknown.
2018-11-08 10:07:10 -08:00
Alexandra Hájková ac8060265b Add an additional test to resolv/tst-resolv-network.c
Test for the infinite loop in getnetbyname, bug #17630.
2018-11-08 13:47:34 +01:00
Joseph Myers 596cc360aa Fix __ASSUME_MLOCK2 for ARM, MicroBlaze (bug 23867).
The generic kernel-features.h defines __ASSUME_MLOCK2 for 4.4 and
later kernels.  However, for 32-bit ARM binaries running on 64-bit ARM
kernels, and for MicroBlaze, the syscall was only wired up in the 4.7
kernel.  (32-bit ARM kernels did have the syscall from 4.4 onwards.)
This patch duly arranges for the macro to be undefined for those
architectures for kernels before 4.7.

Tested with build-many-glibcs.py for its ARM and MicroBlaze
configurations.

	[BZ #23867]
	* sysdeps/unix/sysv/linux/arm/kernel-features.h
	[__LINUX_KERNEL_VERSION < 0x040700] (__ASSUME_MLOCK2): Undefine.
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	[__LINUX_KERNEL_VERSION < 0x040700] (__ASSUME_MLOCK2): Undefine.
2018-11-07 16:27:35 +00:00
Adhemerval Zanella 00c86a37d1 support: Fix printf format for TEST_COMPARE_STRING
Fix the following on 32 bits targets:

support_test_compare_string.c: In function ‘support_test_compare_string’:
support_test_compare_string.c:80:37: error: format ‘%lu’ expects argument of
type ‘long unsigned int’, but argument 2 has type ‘size_t’ {aka ‘unsigned int’}
[-Werror=format=]
         printf ("  string length: %lu bytes\n", left_length);
                                   ~~^           ~~~~~~~~~~~
                                   %u
Checked on arm-linux-gnueabihf.

	* support/support_test_compare_string.c
	(support_test_compare_string): Fix printf format.
2018-11-07 11:11:06 -02:00
Florian Weimer 1df872fd74 support: Implement TEST_COMPARE_STRING 2018-11-07 12:42:44 +01:00
Andreas Schwab 295132ff05 RISC-V: don't assume PI mutexes and robust futexes before 4.20 (bug 23864)
Support for futex_cmpxchg as only been added to 4.20-rc1.
2018-11-07 09:37:48 +01:00
Joseph Myers e143ceba56 Correct SH kernel-features.h undefines (bug 23862).
The SH kernel-features.h undefines __ASSUME_RENAMEAT2 for kernel
versions before 4.8, but fails to undefine __ASSUME_EXECVEAT,
__ASSUME_MLOCK2 and __ASSUME_COPY_FILE_RANGE, although all those
syscalls (and several others) were added for SH in the same Linux
kernel commit (first released in 4.8).  This patch adds the proper
undefines of those macros.

Tested with build-many-glibcs.py for its SH configurations.

	[BZ #23862]
	* sysdeps/unix/sysv/linux/sh/kernel-features.h
	[__LINUX_KERNEL_VERSION < 0x040800] (__ASSUME_EXECVEAT): Undefine.
	[__LINUX_KERNEL_VERSION < 0x040800] (__ASSUME_MLOCK2): Likewise.
	[__LINUX_KERNEL_VERSION < 0x040800] (__ASSUME_COPY_FILE_RANGE):
	Likewise.
2018-11-06 17:22:50 +00:00
Florian Weimer 4a938cb273 posix: New function posix_spawn_file_actions_addchdir_np [BZ #17405] 2018-11-06 16:08:12 +01:00
Gabriel F. T. Gomes 7597b0c7f7 Add tests with floating-point arguments for err* and verr* functions
Similarly to what has been done for argp_error, and argp_failure, as
well as for warn, warnx, vwarn, and vwarnx, this patch adds new tests
for the following functions: err, errx, verr, verrx, error, and
error_at_line.  The new tests check that the conversion of long double
variables into string works correctly on the default format of the type.
Future patches will reuse these tests for other formats that long double
can take.

Tested for powerpc64le.

	* misc/Makefile (tests): Add tst-ldbl-error.
	* misc/tst-ldbl-error.c: New file.
2018-11-06 11:22:34 -02:00
Gabriel F. T. Gomes 9771e6cb51 Add test for warn, warnx, vwarn, and vwarnx with floating-point parameters
Similarly to what has been done for argp_error and argp_failure, this
patch patch adds new tests for the warn, warnx, vwarn, and vwarnx
functions.  The new tests use the format string to request the
conversion of long double parameters into string.  Currently, these
tests only check that the default format of the long double type works.
Future patches will extend the test for platforms that can have an
optional format for long double.

Tested for powerpc64le.

	* misc/Makefile (tests): Add tst-ldbl-warn.
	* misc/tst-ldbl-warn.c: New file.
2018-11-06 11:21:54 -02:00
Gabriel F. T. Gomes 2c03961fce Add tests for argp_error and argp_failure with floating-point parameters
The functions argp_error and argp_failure, from argp.h, have a format
string as parameter, which can possibly request the printing of
floating-point values.  These values could be of long double type, which
can have different formats, depending on the architecture and on
compilation parameters (for instance, on powerpc, long double values can
have double format (-mlong-double-64) or IBM Extended Precision format
(-mlong-double-128)).

This patch adds tests for argp_error and argp_failure that contain a
format string with double and long double conversion specifiers ('%f'
and '%Lf').  These tests automatically check that the default format of
the long double type works.  A future patch will extend the test for
platforms that can have an optional format for long double.

Tested for powerpc64le.

	* argp/Makefile (tests): Add tst-ldbl-argp.
	* argp/tst-ldbl-argp.c: New file.
2018-11-06 11:19:54 -02:00
Arjun Shankar 6d6ee04622 Unconditionally call __gconv_get_path when reading iconv configuration
__gconv_read_conf is only ever called once during the program's lifetime.
This means that __gconv_path_elem is always uninitialized when the function
begins executing.  __gconv_get_path has an assert to ensure that this
expected runtime behaviour is always exhibited.  Given this, checking for a
NULL value before calling __gconv_get_path is unnecessary.  This commit
drops the condition and calls __gconv_get_path unconditionally.
2018-11-05 15:45:07 +01:00
Andreas Schwab bd3b0fbae3 libanl: properly cleanup if first helper thread creation failed (bug 22927) 2018-11-05 14:48:24 +01:00
Samuel Thibault 2e96e9808e hurd: Support msync
* sysdeps/mach/hurd/msync.c: New file.
2018-11-03 22:47:57 +01:00
Florian Weimer 6e36266cec support/shell-container.c: Use support_copy_file_range
Reviewed-by: DJ Delorie <dj@redhat.com>
2018-11-02 18:15:04 +01:00
Florian Weimer 599f7beee7 support/test-container.c: Include <libc-pointer-arith.h>
Reviewed-by: DJ Delorie <dj@redhat.com>
2018-11-02 18:14:58 +01:00
Zong Li af1d5782c1 soft-fp: Add implementation for 128 bit self-contained
Here only add the implementation when building the RV32 port.

These macros are used when the following situations occur at the same
time: soft-fp fma, ldbl-128 and 32-bit _FP_W_TYPE_SIZE. The RISC-V
32-bit port is the first port which use all three together.

This is the building flow about the situation:
When building soft-fp/s_fmal.c, there uses the FP_FMA_Q in __fmal.
The _FP_W_TYPE_SIZE is defined to 32-bit in sysdeps/riscv/sfp-machine.h,
so the FP_FMA_Q was defined to _FP_FMA (Q, 4, 8, R, X, Y, Z) in
soft-fp/quad.h.

Something in the soft-fp/quad.h:
 #if _FP_W_TYPE_SIZE < 64
    # define FP_FMA_Q(R, X, Y, Z)    _FP_FMA (Q, 4, 8, R, X, Y, Z)
 #else
    # define FP_FMA_Q(R, X, Y, Z)    _FP_FMA (Q, 2, 4, R, X, Y, Z)
 #endif

Finally, in _FP_FMA (fs, wc, dwc, R, X, Y, Z), it will use the
_FP_FRAC_HIGHBIT_DW_##dwc macro, and it will be expanded to
_FP_FRAC_HIGHBIT_DW_8, but the _FP_FRAC_HIGHBIT_DW_8 is not be
implemented in soft-fp/op-8.h. there is only _FP_FRAC_HIGHBIT_DW_1,
_FP_FRAC_HIGHBIT_DW_2 and _FP_FRAC_HIGHBIT_DW_4 in the
soft-fp/op-*.h.

After this modification, we can pass the soft floating testing of glibc
testsuites on RV32.

	* soft-fp/op-8.h (_FP_FRAC_SET_8, _FP_FRAC_ADD_8, _FP_FRAC_SUB_8)
	(_FP_FRAC_CLZ_8, _FP_MINFRAC_8, _FP_FRAC_NEGP_8, _FP_FRAC_ZEROP_8)
	(_FP_FRAC_HIGHBIT_DW_8, _FP_FRAC_COPY_4_8, _FP_FRAC_COPY_8_4)
	(__FP_FRAC_SET_8): Add implementation for RV32 use.
2018-11-01 18:22:00 +00:00
Zong Li ff48ea6787 soft-fp: Use temporary variable in FP_FRAC_SUB_3/FP_FRAC_SUB_4
In FRAC_SUB_3(R, X, Y) and FRAC_SUB_4(R,, X, Y), it reference both
the X[N] and X[N] after R[N] have been set. If one of the X and Y is
the same address with R, the result of the calculation is wrong,
because the value of the original X and Y are overwritten.

In glibc, there are two places use FRAC_SUB and occurs the overlap.
The first is _FP_DIV_MEAT_N_loop in op-common.h, it uses the source
_FP_DIV_MEAT_N_loop_u as the destination. This macro only be used
when N is one(_FP_DIV_MEAT_1_loop) and then the _FP_FRAC_SUB_##wc
extend to _FP_FRAC_SUB_1 in this macro. so it also work because
_FP_FRAC_SUB_1 has no overlap problem in its implementation.
The second places is _FP_DIV_MEAT_4_udiv, the original value of X##_f[0]
is overwritten before the calculatation.

In FRAC_SUB_1 and FRAC_SUB_2, there don't refer the source after
destination have been set, so they have no problem.

After this modification, we can pass the soft floating testing of glibc
testsuites on RV32.

	* soft-fp/op-4.h (_FP_FRAC_SUB_3, _FP_FRAC_SUB_4): Use temporary
	variable to avoid overlap arguments.
2018-11-01 17:34:39 +00:00
Joseph Myers eac4405af0 Avoid printf ("%s", NULL) in posix/bug-regex22.c.
Building posix/bug-regex22.c fails with GCC mainline because of
-Wformat-overflow= warnings for NULL arguments to %s formats.

This is *not* testing how glibc handles such format arguments; in the
context of the messages in question it makes no sense to pass NULL to
such a %s format (the code passes s, inside "if (s == NULL)").  So
this patch changes the code not to pass such a format argument at all
(which means the string passed is constant, so no need to use printf
at all - however, there are two separate tests here with different
length arguments passed to re_compile_pattern, so it *does* make sense
to make the strings used different so that in the event of failure
it's clear which one of the tests failed).

Tested with build-many-glibcs.py with GCC mainline for
aarch64-linux-gnu.

	* posix/bug-regex22.c (main): Use puts with distinct error
	messages for unexpected success of re_compile_pattern, not printf
	with NULL argument to %s.
2018-11-01 17:20:27 +00:00
Joseph Myers 6f30e59fc9 Disable -Wformat-overflow= warnings for some printf tests.
Recent GCC -Wformat-overflow= changes result in some printf tests
failing to build, because those tests are deliberately testing the
handling of formats writing more than INT_MAX characters and the
handling of NULL arguments to the %s format, which GCC now warns
about.  This patch duly disables -Wformat-overflow= for the relevant
calls to printf functions.

Tested with build-many-glibcs.py with GCC mainline for
aarch64-linux-gnu.

	* stdio-common/bug22.c: Include <libc-diag.h>.
	(do_test): Disable -Wformat-overflow= warnings around fprintf
	calls outputting more than INT_MAX characters.
	* stdio-common/tst-printf.c: Disable -Wformat-overflow= warnings
	around printf call with NULL %s argument.
2018-11-01 17:13:55 +00:00
Joseph Myers daea71c2e4 Update and correct SPARC configuration for supported socket syscalls (bug 23848).
Looking at kernel-features.h files, I saw that SPARC was missing full
information on when it gained separate socket syscalls.

This patch adds such information to the SPARC kernel-features.h.  It
also corrects what appear to be bugs in the existing code (that would
cause syscalls to be assumed to be present when not actually present).
Various __ASSUME_* macros, defined by default, were not undefined for
32-bit despite those syscalls only being added for 32-bit in Linux
4.4.  Some syscalls were used in the SPARC64 syscalls.list but only
added in 4.4; this was harmless before the __NR_* macros were defined
at all, but once the macros were defined it means a build with
post-4.4 headers would assume the syscalls to be present regardless of
--enable-kernel version.  Then, various __ASSUME_* macros were
previously not defined in cases where they could be defined (this part
of the patch is just an optimization, not a bug fix).

Note the observation in a comment in the patch that even the latest
Linux kernel for SPARC does not have getpeername and getsockname
syscalls in the compat syscall table for 32-bit binaries on 64-bit
kernels (so glibc can't assume those syscalls to be present for 32-bit
at all, although the 32-bit syscall table gained them in 4.4).

Tested (compilation only) for SPARC with build-many-glibcs.py.

	[BZ #23848]
	* sysdeps/unix/sysv/linux/sparc/kernel-features.h [!__arch64__ &&
	__LINUX_KERNEL_VERSION < 0x040400] (__ASSUME_SENDMSG_SYSCALL):
	Undefine.
	[!__arch64__ && __LINUX_KERNEL_VERSION < 0x040400]
	(__ASSUME_RECVMSG_SYSCALL): Likewise.
	[!__arch64__ && __LINUX_KERNEL_VERSION < 0x040400]
	(__ASSUME_SENDTO_SYSCALL): Likewise.
	[!__arch64__ && __LINUX_KERNEL_VERSION < 0x040400]
	(__ASSUME_ACCEPT_SYSCALL): Undefine under this condition, not just
	[!__arch64__].
	[!__arch64__ && __LINUX_KERNEL_VERSION < 0x040400]
	(__ASSUME_CONNECT_SYSCALL): Likewise.
	[!__arch64__ && __LINUX_KERNEL_VERSION < 0x040400]
	(__ASSUME_RECVFROM_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040400] (__ASSUME_BIND_SYSCALL):
	Define.
	[__LINUX_KERNEL_VERSION >= 0x040400] (__ASSUME_LISTEN_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040400]
	(__ASSUME_SETSOCKOPT_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list (bind):
	Remove.
	(listen): Likewise.
	(setsockopt): Likewise.
2018-11-01 16:30:15 +00:00
Fredrik Noring 8e3c00db16 MIPS: Use `.set mips2' to emulate LL/SC for the R5900 too
GAS treats the R5900 as MIPS III, with some modifications.  The MIPS III
designation means that the GNU C Library will try to assemble the LL and
SC instructions, even though they are not implemented in the R5900.  GAS
will therefore produce the following errors:

Error: opcode not supported on this processor: r5900 (mips3) `ll $2,0($4)'
Error: opcode not supported on this processor: r5900 (mips3) `sc $6,0($4)'

The MIPS II ISA override as used here enables the kernel to trap and
emulate the LL and SC instructions, as required.

This change has been tested by compiling the GNU C Library 2.27 with a
GCC 8.2.0 cross-compiler for mipsr5900el-unknown-linux-gnu under Gentoo.

	* sysdeps/mips/sys/tas.h (_test_and_set): Handle the R5900 CPU
	with the ISA override.
2018-11-01 14:36:48 +00:00
Samuel Thibault fc783076ec hurd: Add pci RPC stubs
* hurd/Makefile (user-interfaces): Add pci.
2018-10-31 22:43:44 +01:00
Rafael Avila de Espindola 9c3dbdbe29 Simplify an #if #else #endif
The #else of two nested #if clauses were identical.

	* sysdeps/unix/sysv/linux/sysdep-vdso.h: Simplify an #if #else
	#endif.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
2018-10-31 10:32:40 -07:00
Samuel Thibault a67377e7f7 hurd: Fix errno* generation
* sysdeps/mach/hurd/errnos.awk: Avoid printing errnos.d.
	* sysdeps/gnu/errlist.c (EIEIO): Move text to...
	* manual/errno.texi (EIEIO): ... here.
	* sysdeps/gnu/errlist.c (EIEIO): Regenerate.
	* sysdeps/mach/hurd/bits/errno.h: Regenerate.
2018-10-31 10:32:39 +01:00
Samuel Thibault e3a88b3e9d hurd: Document how to translate EIEIO error message
* sysdeps/gnu/errlist.c (EIEIO): Document how translators should
	translate the error message.
2018-10-31 01:49:43 +01:00
Joseph Myers 3ca235ed36 Convert linknamespace tests from Perl to Python.
This patch replaces conform/linknamespace.pl with a new
conform/linknamespace.py, so continuing the consolidation on Python
instead of Perl for miscellaneous scripts used in building and testing
glibc.  The new script follows the same logic as the old one; as a
recently-added script, there were no major cleanups to be made in the
course of the language conversion.

Tested for x86_64, and with build-many-glibcs.py.  For x86_64 I also
tested that if the Perl and Python scripts were made to print all the
symbols in seen_where and the paths of symbol references by which
those symbols were linked in, even when those symbols were OK,
identical symbol lists appeared in the output with both versions of
the script (the differences in linknamespace.out files were only in
paths to temporary files in diagnostics for e.g. deprecated functions,
and error output for the expected compilation failures when testing
ndbm.h and varargs.h).

	* conform/linknamespace.py: New file.
	* conform/linknamespace.pl: Remove file.
	* conform/Makefile ($(linknamespace-header-tests)): Use
	linknamespace.py instead of linknamespace.pl.  Do not use --tmpdir
	option.
2018-10-30 22:18:34 +00:00
Florian Weimer 6070803053 stdlib/test-bz22786: Avoid memory leaks in the test itself 2018-10-30 13:56:40 +01:00
Florian Weimer a91e9301c4 support_blob_repeat: Call mkstemp directory for the backing file
This avoids a warning during post-test cleanup.
2018-10-30 13:55:50 +01:00
Florian Weimer 07da99aad9 stdlib/tst-strtod-overflow: Switch to support_blob_repeat
This is another test with an avoidable large memory allocation.
2018-10-30 13:55:01 +01:00
Florian Weimer f5e7e95921 stdlib/test-bz22786: Avoid spurious test failures using alias mappings
On systems without enough random-access memory, stdlib/test-bz22786
will go deeply into swap and time out, even with a substantial
TIMEOUTFACTOR.  This commit adds a facility to construct repeating
strings with alias mappings, so that the requirement for physical
memory, and uses it in stdlib/test-bz22786.
2018-10-30 13:17:36 +01:00
Andreas Schwab 2dd12baa04 RISC-V: properly terminate call chain (bug 23125)
Mark the ra register as undefined in _start, so that unwinding through
main works correctly.  Also, don't use a tail call so that ra points after
the call to __libc_start_main, not after the previous call.
2018-10-30 12:07:25 +01:00
Sergi Almacellas Abellana fec8bb7ca9 Currency symbol should not preceed amount for [BZ #23791]
CLDR also has the currency symbol after the amount for Catalan.

Also set grouping in LC_NUMERIC to 3;3.

Reviewed-by: Mike FABIAN <mfabian@redhat.com>
2018-10-29 19:23:11 +01:00
Samuel Thibault b6e7c449f9 hurd: return EIEIO instead of EIO
EIO would be understood as hardware failure, while this is software
failure.

	* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Return EIEIO instead of EIO
2018-10-29 18:57:13 +01:00
Joseph Myers 954cf3c29b Use tempfile.TemporaryDirectory in conform/glibcconform.py.
Now that we require Python 3.4 or later, Python code creating
temporary directories can use tempfile.TemporaryDirectory in "with" to
have the directory deleted automatically instead of needing to use
try/finally to handle removing a directory created with
tempfile.mkdtemp.  This patch does so in conform/glibcconform.py.

Tested for x86_64.

	* conform/glibcconform.py: Do not import shutil.
	(list_exported_functions): Use tempfile.TemporaryDirectory instead
	of mkdtemp.
2018-10-29 17:49:07 +00:00
Joseph Myers c6982f7efc Patch to require Python 3.4 or later to build glibc.
This patch makes Python 3.4 or later a required tool for building
glibc, so allowing changes of awk, perl etc. code used in the build
and test to Python code without any such changes needing makefile
conditionals or to handle older Python versions.

This patch makes the configure test for Python check the version and
give an error if Python is missing or too old, and removes makefile
conditionals that are no longer needed.  It does not itself convert
any code from another language to Python, and does not remove any
compatibility with older Python versions from existing scripts.

Tested for x86_64.

	* configure.ac (PYTHON_PROG): Use AC_CHECK_PROG_VER.  Set
	critic_missing for versions before 3.4.
	* configure: Regenerated.
	* manual/install.texi (Tools for Compilation): Document
	requirement for Python to build glibc.
	* INSTALL: Regenerated.
	* Rules [PYTHON]: Make code unconditional.
	* benchtests/Makefile [PYTHON]: Likewise.
	* conform/Makefile [PYTHON]: Likewise.
	* manual/Makefile [PYTHON]: Likewise.
	* math/Makefile [PYTHON]: Likewise.
2018-10-29 15:28:05 +00:00
Samuel Thibault 5c81be5340 hurd: Fix race between calling RPC and handling a signal
* sysdeps/mach/hurd/i386/intr-msg.h (INTR_MSG_TRAP): Make
	_hurd_intr_rpc_msg_about_to global point to start of controlled
	assembly snippet. Make it check canceled flag.
	* hurd/hurdsig.c (_hurdsig_abort_rpcs): Only mutate thread if it passed
	the _hurd_intr_rpc_msg_about_to point.
	* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Remove comment on mutation
	issue, remove cancel flag check.
2018-10-28 13:41:51 +01:00
Samuel Thibault 2d0d1d3876 hurd: Return EIO on non-responding interrupted servers
since we do not actually know whether the RPC was completed or not,
which makes a huge difference for e.g. write(), so better really error
out than letting caller think that the RPC did not happen.

	* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): When the server does not
	answer to interrupt_operation, return EIO instead of EINTR.
2018-10-28 10:25:44 +01:00
Samuel Thibault 46a7f24c84 hurd: set interrupt timeout to 1 minute
Seeing a server not able to get interrupted for 3s is not so surprising when
e.g. a lot of writes are happening. 1 minute allows to actually notice the
issue and be able to debug it.

	* hurd/hurdsig.c (_hurd_interrupted_rpc_timeout): Set to 60000.
2018-10-28 10:23:22 +01:00
Joseph Myers e5b8756dc2 Remove pre-Python-3.4 compatibility from build-many-glibcs.py.
Since we have consensus on requiring Python 3.4 or later to build
glibc, it follows that compatibility with older Python versions is
also no longer relevant to auxiliary Python scripts for use in glibc
development.  This patch removes such compatibility code from
build-many-glibcs.py (compatibility code needed for 3.4, which lacks
the newer subprocess interface, is kept).  Because
build-many-glibcs.py is not itself called from the glibc build system,
this patch is independent of the configure checks for having a
new-enough Python version, which are only relevant to uses of Python
from the main build and test process.

Tested with build-many-glibcs.py building glibc for aarch64-linux-gnu
(with Python 3.4 to make sure that still works).

	* scripts/build-many-glibcs.py: Remove compatibility for missing
	os.cpu_count and re.fullmatch.
2018-10-26 15:47:23 +00:00
Szabolcs Nagy ba5b14c761 i64: fix missing exp2f, log2f and powf symbols in libm.a [BZ #23822]
When new symbol versions were introduced without SVID compatible
error handling the exp2f, log2f and powf symbols were accidentally
removed from the ia64 lim.a.  The regression was introduced by
the commits

f5f0f52651
New expf and exp2f version without SVID compat wrapper

72d3d28108
New symbol version for logf, log2f and powf without SVID compat

With WEAK_LIBM_ENTRY(foo), there is a hidden __foo and weak foo
symbol definition in both SHARED and !SHARED build.

	[BZ #23822]
	* sysdeps/ia64/fpu/e_exp2f.S (exp2f): Use WEAK_LIBM_ENTRY.
	* sysdeps/ia64/fpu/e_log2f.S (log2f): Likewise.
	* sysdeps/ia64/fpu/e_exp2f.S (powf): Likewise.
2018-10-26 14:39:42 +01:00
Joseph Myers fe61f17cfc Add IN_MASK_CREATE from Linux 4.19 to sys/inotify.h.
This patch adds the IN_MASK_CREATE macro from Linux 4.19 to
sys/inotify.h.

Tested for x86_64.

	* sysdeps/unix/sysv/linux/sys/inotify.h (IN_MASK_CREATE): New
	macro.
2018-10-25 15:57:23 +00:00
Florian Weimer 7c5e34d7f1 conform: XFAIL siginfo_t si_band test on sparc64
We can use long int on sparcv9, but on sparc64, we must match the int
type used by the kernel (and not long int, as in POSIX).
2018-10-25 14:36:57 +02:00
Joseph Myers 5b784e8834 Add new ELF note types from Linux 4.19 to elf.h.
This patch adds NT_MIPS_DSP and NT_MIPS_FP_MODE from Linux 4.19 to
elf.h.

Tested for x86_64.

	* elf/elf.h (NT_MIPS_DSP): New macro.
	(NT_MIPS_FP_MODE): Likewise.
2018-10-25 11:55:23 +00:00
Zong Li 41432ebe15 elf: Fix the ld flags not be applied to tst-execstack-mod.so
The Makefile variable name lacked the file extension (.so).  As a
result, tst-execstack-mod.so was not linked with the -z execstack
flag.
2018-10-25 13:08:24 +02:00
Samuel Thibault d026efea0f hurd: XFAIL absence of C11 threads implementation
* sysdeps/mach/hurd/i386/Makefile [$(subdir) = conform]
	(test-xfail-ISO11/threads.h/linknamespace,
	test-xfail-ISO11/threads.h/conform): Add.
2018-10-25 01:31:09 +02:00
Joseph Myers b71ac2b9ce Use gen-libm-test.py to generate ulps table for manual.
This patch extends gen-libm-test.py to generate the ulps table for the
manual, so meaning there is only a single ulps file parser needed and
another Perl script is eliminated.  As with the introduction of
gen-libm-test.py, this is designed to generate exactly the same
libm-err.texi as libm-err-tab.pl did.  (gen-libm-test.py is still
shorter in lines than the old gen-libm-test.pl even after this patch.)
Note that this introduces a Python dependency for building the manual,
which is thus noted in install.texi and NEWS.

Tested building html / info / pdf versions of the manual.

	* math/gen-libm-test.py: Import os.
	(ALL_FLOATS_MANUAL): New constant.
	(ALL_FLOATS_SUFFIX): Likewise.
	(Ulps.all_functions): New function.
	(real_all_ulps): Likewise.
	(generate_err_table_sub): Likewise.
	(generate_err_table): Likewise.
	(main): Handle -s and -m options.
	* manual/libm-err-tab.pl: Remove.
	* manual/Makefile ($(objpfx)stamp-libm-err): Use gen-libm-test.py
	instead of libm-err-tab.pl.
	[$(PERL) != no]: Change condition to [$(if $(PYTHON),$(PERL),no)
	!= no].
	* manual/install.texi (Tools for Compilation): Document
	requirement for Python to build manual.
	* INSTALL: Regenerated.
2018-10-24 20:34:31 +00:00
Albert ARIBAUD (3ADEV) d51f99ce80 Y2038: Add 64-bit time for all architectures
glibc support for 64-bit time_t on 32-bit architectures
will involve:

- Using 64-bit times inside glibc, with conversions
  to and from 32-bit times taking place as necessary
  for interfaces using such times.

- Adding 64-bit-time support in the glibc public API.
  This support should be dynamic, i.e. glibc should
  provide both 32-bit and 64-bit implementations and
   let user code choose at compile time whether to use
   the 32-bit or 64-bit interfaces.

This requires a glibc-internal name for a type for times
that are always 64-bit.

Based on __TIMESIZE, a new macro is defined, __TIME64_T_TYPE,
 which is always the right __*_T_TYPE to hold a 64-bit-time.
__TIME64_T_TYPE equals __TIME_T_TYPE if __TIMESIZE equals 64
and equals __SQUAD_T_TYPE otherwise.

__time64_t can then replace uses of internal_time_t.

This patch was tested by running 'make check' on branch
master then applying this patch and its predecessor and
running 'make check' again, and checking that both 'make
check' yield identical results. This was done on
x86_64-linux-gnu and i686-linux-gnu.

	* bits/time64.h: New file.
	* include/time.h: Replace internal_time_t with __time64_t.
	* posix/bits/types (__time64_t): Add.
	* stdlib/Makefile: Add bits/time64.h to includes.
	* time/tzfile.c: Replace internal_time_t with __time64_t.
2018-10-24 22:09:34 +02:00
Albert ARIBAUD (3ADEV) 97d91fccc8 Fix date typo in ChangeLog 2018-10-24 21:48:54 +02:00
Adhemerval Zanella 2a973ab7f1 posix: Add internal symbols for posix_spawn interface
This patch adds internal hidden definition for mostly of the posix_spawn
function so it can be used internally on both popen and system
implementations.

Checked on x86_64-linux-gnu.

	* include/spawn.h (__posix_spawn, posix_spawn_file_actions_addclose,
	__posix_spawn_file_actions_adddup2, __posix_spawn_file_actions_destroy,
	__posix_spawn_file_actions_init, __posix_spawnattr_init,
	__posix_spawnattr_destroy, __posix_spawnattr_setflags,
	__posix_spawnattr_setsigdefault, __posix_spawnattr_setsigmask): New
	prototype.
	* posix/spawn.c (__posix_spawn): Add libc_hidden_def.
	* posix/spawn_faction_addclose.c
	(__posix_spawn_file_actions_addclose): Add hidden definition.
	* posix/spawn_faction_adddup2.c
	(__posix_spawn_file_actions_adddup2): Likewise.
	* posix/spawn_faction_destroy.c
	(__posix_spawn_file_actions_destroy): Likewise.
	* posix/spawn_faction_init.c (__posix_spawn_file_actions_init):
	Likewise.
	* posix/spawnattr_destroy.c (__posix_spawnattr_destroy): Likewise.
	* posix/spawnattr_init.c (__posix_spawnattr_init): Likewise.
	* posix/spawnattr_setdefault.c (__posix_spawnattr_setsigdefault):
	Likewise.
	* posix/spawnattr_setflags.c (__posix_spawnattr_setflags): Likewise.
	* posix/spawnattr_setsigmask.c (__posix_spawnattr_setsigmask):
	Likewise.
2018-10-24 15:22:27 -03:00
Andreas Schwab 2954daf00b Add more checks for valid ld.so.cache file (bug 18093) 2018-10-24 16:34:02 +02:00
Albert ARIBAUD (3ADEV) a27a4f4721 Y2038: provide size of default time_t for target architecture
To determine whether the default time_t interfaces are 32-bit
    and so need conversions, or are 64-bit and so are compatible
    with the internal 64-bit type without conversions, a macro
    giving the size of the  default time_t is also required.
    This macro is called __TIMESIZE.

    This macro can then be used instead of __WORDSIZE in msq-pad.h
    and shm-pad.h files, which in turn allows removing their x86
    variants, and in sem-pad.h files but keeping the x86 variant.

    This patch was tested by running 'make check' on branch master
    then applying this patch and running 'make check' again, and
    checking that both 'make check' yield identical results.
    This was done on x86_64-linux-gnu and i686-linux-gnu.

	* bits/timesize.h: New file.
	* stdlib/Makefile (headers): Add bits/timesize.h.
	* sysdeps/unix/sysv/linux/bits/msq-pad.h
	(__MSQ_PAD_AFTER_TIME): Use __TIMESIZE instead of __WORDSIZE.
	* sysdeps/unix/sysv/linux/bits/sem-pad.h
	(__SEM_PAD_AFTER_TIME): Likewise.
	* sysdeps/unix/sysv/linux/bits/shm-pad.h
	(__SHM_PAD_AFTER_TIME): Likewise.
	* sysdeps/unix/sysv/linux/hppa/bits/msq-pad.h
	(__MSQ_PAD_BEFORE_TIME): Likewise.
	* sysdeps/unix/sysv/linux/hppa/bits/sem-pad.h
	(__SEM_PAD_BEFORE_TIME): Likewise.
	* sysdeps/unix/sysv/linux/hppa/bits/shm-pad.h
	(__SHM_PAD_BEFORE_TIME, __SHM_PAD_BETWEEN_TIME_AND_SEGSZ): Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/msq-pad.h
        (__MSQ_PAD_AFTER_TIME, __MSQ_PAD_BEFORE_TIME): Likewise.
        * sysdeps/unix/sysv/linux/powerpc/bits/msq-pad.h
        (__MSQ_PAD_BEFORE_TIME): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/sem-pad.h
	(__SEM_PAD_BEFORE_TIME): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/shm-pad.h
	(__SHM_PAD_BEFORE_TIME, __SHM_PAD_BETWEEN_TIME_AND_SEGSZ): Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/msq-pad.h
	(__MSQ_PAD_BEFORE_TIME): Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/sem-pad.h
	(__SEM_PAD_BEFORE_TIME): Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/shm-pad.h
	(__SHM_PAD_BEFORE_TIME): Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/msq-pad.h: Delete file.
	* sysdeps/unix/sysv/linux/x86/bits/shm-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/timesize.h: New file.
2018-10-24 11:37:09 +02:00
H.J. Lu 7cc65773f0 x86: Support RDTSCP for benchtests
RDTSCP waits until all previous instructions have executed and all
previous loads are globally visible before reading the counter.  RDTSC
doesn't wait until all previous instructions have been executed before
reading the counter.  All x86 processors since 2010 support RDTSCP
instruction.  This patch adds RDTSCP support to benchtests.

	* benchtests/Makefile (CPPFLAGS-nonlib): Add -DUSE_RDTSCP if
	USE_RDTSCP is defined.
	* sysdeps/x86/hp-timing.h (HP_TIMING_NOW): Use RDTSCP if
	USE_RDTSCP is defined.
2018-10-24 02:19:34 -07:00
Adhemerval Zanella 18ad0de651 Fix tst-preadvwritev2 build failure on HURD
Commit 7a16bdbb9f uses IOV_MAX, which is not defined on hurd.

Checked on a build for i686-gnu.

	* misc/tst-preadvwritev2-common.c (IOV_MAX): Define if not
	defined.
2018-10-23 14:57:02 -03:00
Adhemerval Zanella c3d8dc45c9 x86: Fix Haswell strong flags (BZ#23709)
Th commit 'Disable TSX on some Haswell processors.' (2702856bf4) changed the
default flags for Haswell models.  Previously, new models were handled by the
default switch path, which assumed a Core i3/i5/i7 if AVX is available. After
the patch, Haswell models (0x3f, 0x3c, 0x45, 0x46) do not set the flags
Fast_Rep_String, Fast_Unaligned_Load, Fast_Unaligned_Copy, and
Prefer_PMINUB_for_stringop (only the TSX one).

This patch fixes it by disentangle the TSX flag handling from the memory
optimization ones.  The strstr case cited on patch now selects the
__strstr_sse2_unaligned as expected for the Haswell cpu.

Checked on x86_64-linux-gnu.

	[BZ #23709]
	* sysdeps/x86/cpu-features.c (init_cpu_features): Set TSX bits
	independently of other flags.
2018-10-23 14:57:02 -03:00
Florian Weimer f1034472e2 time/tst-mktime2: Improve test error reporting 2018-10-23 11:25:05 +02:00
Andreas Schwab 367d7cc2cb Don't use PSEUDO_END for non-PSEUDO function 2018-10-23 09:41:43 +02:00
Joseph Myers 029ad711b8 Update kernel version in syscall-names.list to 4.19.
Linux 4.19 does not add any new syscalls (some existing ones are added
to more architectures); this patch updates the version number in
syscall-names.list to reflect that it's still current for 4.19.

Tested with build-many-glibcs.py.

	* sysdeps/unix/sysv/linux/syscall-names.list: Update kernel
	version to 4.19.
2018-10-22 23:26:37 +00:00
Joseph Myers 8190520f2a Use Linux 4.19 in build-many-glibcs.py.
* scripts/build-many-glibcs.py (Context.checkout): Default Linux
	version to 4.19.
2018-10-22 16:49:37 +00:00
Joseph Myers be8ff03f92 Stop c32rtomb and mbrtoc32 aliasing wcrtomb and mbrtowc (bug 23793).
glibc does:

/* There should be no difference between the UTF-32 handling required
   by c32rtomb and the wchar_t handling which has long since been
   implemented in wcrtomb.  */
weak_alias (__wcrtomb, c32rtomb)

/* There should be no difference between the UTF-32 handling required
   by mbrtoc32 and the wchar_t handling which has long since been
   implemented in mbrtowc.  */
weak_alias (__mbrtowc, mbrtoc32)

The reasoning in those comments to justify those aliases is incorrect:
ISO C requires that, for the case of a NULL mbstate_t* being passed,
each function has its *own* internal static mbstate_t.  Thus a program
must be able to use both wcrtomb and c32rtomb at the same time with
each keeping its own separate state, and likewise for mbrtowc and
mbrtoc32.

This patch duly sets up separarate char32_t function that wrap the
wchar_t ones.  Note that the included test only covers the mbrtoc32 /
mbrtowc pair.  While I think the change made is logically correct for
c32rtomb / wcrtomb as well, I'm not sure we have a locale with a
suitable state-dependent multibyte encoding for testing that part of
the change.

Tested for x86_64.

	[BZ #23793]
	* wcsmbs/c32rtomb.c: New file.
	* wcsmbs/mbrtoc32.c: Likewise.
	* wcsmbs/tst-c32-state.c: Likewise.
	* wcsmbs/mbrtowc.c (mbrtoc32): Do not define as alias.
	* wcsmbs/wcrtomb.c (c32rtomb): Likewise.
	* wcsmbs/Makefile (routines): Add mbrtoc32 and c32rtomb.
	(tests): Add tst-c32-state.
	[$(run-built-tests) = yes] ($(objpfx)tst-c32-state.out): Depend on
	$(gen-locales).
2018-10-22 14:52:14 +00:00
H.J. Lu 2dd8e58cc5 x86: Don't include <x86intrin.h>
Use __builtin_ia32_rdtsc directly since including <x86intrin.h> makes
building glibc very slow.  On Intel Core i5-6260U, this patch reduces
x86-64 build time from 8 minutes 33 seconds to 3 minutes 48 seconds
with "make -j4" and GCC 8.2.1.

	* sysdeps/x86/hp-timing.h: Don't include <x86intrin.h>.
	(HP_TIMING_NOW): Replace _rdtsc with __builtin_ia32_rdtsc.
2018-10-21 00:37:29 -07:00
Joseph Myers d0a7415979 Handle surrogate pairs in c16rtomb (bug 23794, DR#488, C2X).
The c16rtomb implementation has:

  // XXX The ISO C 11 spec I have does not say anything about handling
  // XXX surrogates in this interface.

The DR#488 resolution, as applied to C2X, requires surrogate pairs to
be handled here (so the first call returns 0 and stores the high
surrogate in the mbstate_t, while the second call combines the
surrogates, produces a multibyte character and returns the number of
bytes written).  This patch implements that.  (mbrtoc16 already
handled producing surrogates as output.)

Tested for x86_64.

	[BZ #23794]
	* wcsmbs/c16rtomb.c (c16rtomb): Save first character of surrogate
	pair and return 0 in that case, and use saved character to
	interpret following character.
	* wcsmbs/tst-c16-surrogate.c: New file.
	* wcsmbs/Makefile (tests): Add tst-c16-surrogate.c.
	[$(run-built-tests) = yes] ($(objpfx)tst-c16-surrogate.out):
	Depend on $(gen-locales)
2018-10-19 16:31:29 +00:00
Ilya Yu. Malakhov f997b4be18 signal: Use correct type for si_band in siginfo_t [BZ #23562] 2018-10-19 18:06:32 +02:00
Florian Weimer 53b2bb8747 resource: Update struct rusage comments [BZ #23689] 2018-10-19 18:03:21 +02:00
David S. Miller 94a3a27f5d Add VDSO support to sparc.
* sysdeps/unix/sysv/linux/sparc/init-first.c: New file.
	* sysdeps/unix/sysv/linux/sparc/libc-vdso.h: New file.
	* sysdeps/unix/sysv/linux/sparc/Makefile: Add dl-vdso to
	sysdep_routines in subdir elf.
	* sysdeps/unix/sysv/linux/sparc/Versions: Add GLIBC_PRIVATE
	version for __vdso_clock_gettime.
	* sysdeps/unix/sysv/linux/sparc/sysdep.h (INTERNAL_VSYSCALL_CALL):
	Define.
	(HAVE_CLOCK_GETTIME_VSYSCALL): Define.
	(HAVE_GETTIMEOFDAY_VSYSCALL): Define.
2018-10-18 11:44:32 -07:00
David S. Miller 0a271c8f25 Regenerate sparc ulps.
* sysdeps/sparc/fpu/libm-test-ulps: Regenerated.
2018-10-18 11:43:56 -07:00
H.J. Lu 72771e5375 x86: Use _rdtsc intrinsic for HP_TIMING_NOW
Since _rdtsc intrinsic is supported in GCC 4.9, we can use it for
HP_TIMING_NOW.  This patch

1. Create x86 hp-timing.h to replace i686 and x86_64 hp-timing.h.
2. Move MINIMUM_ISA from init-arch.h to isa.h so that x86 hp-timing.h
can check minimum x86 ISA to decide if _rdtsc can be used.

NB: Checking if __i686__ isn't sufficient since __i686__ may not be
defined when building for i686 class processors.

	* sysdeps/i386/init-arch.h: Removed.
	* sysdeps/i386/i586/init-arch.h: Likewise.
	* sysdeps/i386/i686/init-arch.h: Likewise.
	* sysdeps/i386/i686/hp-timing.h: Likewise.
	* sysdeps/x86_64/hp-timing.h: Likewise.
	* sysdeps/i386/isa.h: New file.
	* sysdeps/i386/i586/isa.h: Likewise.
	* sysdeps/i386/i686/isa.h: Likewise.
	* sysdeps/x86_64/isa.h: Likewise.
	* sysdeps/x86/hp-timing.h: New file.
	* sysdeps/x86/init-arch.h: Include <isa.h>.
2018-10-17 15:16:45 -07:00
Joseph Myers c2b7ccad93 Do not allow divide-by-zero exception for pow(+/- 0, -Inf).
C99 wrongly specified a divide-by-zero exception for pow(+/- 0, -Inf);
C11 made it optional after this was pointed out, and the permission
for this exception has been removed in the current C2x draft.  This
patch makes the glibc pow tests reflect the stricter requirement
(which follows the normal IEEE rules that a divide-by-zero exception
is for the case of exact infinite results from *finite* operands, not
for such results when any operand is infinite).

Tested for x86_64 and x86.  (If any other pow implementation in glibc,
not exercised on those architectures, turns out to fail the stricter
test, it should be fixed to avoid the exception in this case.)

	* math/libm-test-pow.inc (pow_test_data): Do not allow
	divide-by-zero exception for pow(+/- 0, -Inf).
2018-10-17 21:23:40 +00:00
Zack Weinberg 26756e5756
[manual] Job control is no longer optional.
Job control was made mandatory in POSIX.1-2001: compare
<http://pubs.opengroup.org/onlinepubs/7990989775/xsh/unistd.h.html> with
<http://pubs.opengroup.org/onlinepubs/009695399/basedefs/unistd.h.html>.
Seventeen years later, we need not devote an entire manual @node to
warning people that this was once an optional POSIX feature.

	* manual/job.texi (Job Control is Optional): Remove node, as
	job control has not been optional in quite some time.
	(Job Control): Mention briefly that systems older than
	POSIX.1-2001 might not support job control.
	* manual/conf.texi (_POSIX_JOB_CONTROL): Will always be
	defined on systems conforming to POSIX.1-2001.
2018-10-17 14:10:51 -04:00
Arjun Shankar c5288d378a Remove unnecessary locking when reading iconv configuration [BZ #22062]
In iconv/gconv_conf.c, __gconv_get_path unnecessarily obtains a lock when
populating the array pointed to by __gconv_path_elem. The locking is not
necessary because all calls to __gconv_read_conf (which in turn calls
__gconv_get_path) are serialized using __libc_once.

This patch:
- removes all locking in __gconv_get_path;
- replaces all explicitly serialized __gconv_read_conf calls with calls to
  __gconv_load_conf, a new wrapper that is serialized internally;
- adds a new test, iconv/tst-iconv_mt.c, to exercise iconv initialization,
  usage, and cleanup in a multi-threaded program;
- indents __gconv_get_path correctly, removing tab characters (which makes
  the patch look a little bigger than it really is).

After removing the unnecessary locking, it was confirmed that the test case
fails if the relevant __libc_once is removed. Additionally, four localedata
and iconvdata tests also fail. This gives confidence that the testsuite
sufficiently guards against some regressions relating to multi-threading
with iconv.

Tested on x86_64 and i686.
2018-10-17 17:47:29 +02:00
Joseph Myers 729f34028a Use single bits/shm.h for all architectures.
After my patch to move SHMLBA to its own header, the bits/shm.h
headers for architectures using the Linux kernel still vary in a few
ways: the use of __syscall_ulong_t; whether padding for 32-bit systems
is present before or after time fields, or missing altogether (mips,
x32); whether shm_segsz is before or after the time fields; whether,
if after time fields, there is extra padding before shm_segsz.

This patch arranges for a single header to be used.  __syscall_ulong_t
is safe to use everywhere, while bits/shm-pad.h is added with new
macros __SHM_PAD_AFTER_TIME, __SHM_PAD_BEFORE_TIME,
__SHM_SEGSZ_AFTER_TIME and __SHM_PAD_BETWEEN_TIME_AND_SEGSZ to
describe the differences.

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

	* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add
	bits/shm-pad.h.
	* sysdeps/unix/sysv/linux/bits/shm.h: Include <bits/shm-pad.h>.
	(shmatt_t): Define as __syscall_ulong_t.
	(__SHM_PAD_TIME): New macro, depending on [__SHM_PAD_BEFORE_TIME]
	and [__SHM_PAD_AFTER_TIME].
	(struct shmid_ds): Define time fields using __SHM_PAD_TIME.
	Define shm_segsz and associated padding based on
	[__SHM_SEGSZ_AFTER_TIME] and [__SHM_PAD_BETWEEN_TIME_AND_SEGSZ].
	Use __syscall_ulong_t instead of unsigned long int.
	[__USE_MISC] (struct shminfo): Use __syscall_ulong_t instead of
	unsigned long int.
	[__USE_MISC] (struct shm_info): Likewise.
	* sysdeps/unix/sysv/linux/bits/shm-pad.h: New file.
	* sysdeps/unix/sysv/linux/hppa/bits/shm-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/shm-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/shm-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/shm-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/shm-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/hppa/bits/shm.h: Remove.
	* sysdeps/unix/sysv/linux/mips/bits/shm.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/shm.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/shm.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/shm.h: Likewise.
2018-10-17 11:56:28 +00:00
Joseph Myers 8c8d2a8aff Move SHMLBA to its own header.
One difference between bits/shm.h headers for architectures using the
Linux kernel is the definition of SHMLBA.  This was noted in
<https://sourceware.org/ml/libc-alpha/2018-09/msg00175.html> as a
reason why even a new architecture (C-SKY) might need its own
bits/shm.h; thus, splitting it out of bits/shm.h can allow less
duplication of headers for new architectures.

This patch moves that definition to its own header, bits/shmlba.h, to
allow more sharing of headers between architectures.  That move allows
the arm, ia64 and sh variants of bits/shm.h to be removed, as they had
no other significant differences from the generic bits/shm.h; powerpc
and x86 have their own bits/shm.h but do not need to get their own
bits/shmlba.h because they use the same SHMLBA as the generic header.
Other architectures with their own bits/shm.h get their own
bits/shmlba.h without being able to remove their own bits/shm.h until
the generic one has been adapted to be able to handle more
architectures (where, in addition to the differences seen for
bits/msq.h and bits/sem.h, the position of shm_segsz in struct
shmid_ds also depends on the architecture).

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

	* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add
	bits/shmlba.h.
	* sysdeps/unix/sysv/linux/bits/shm.h: Include <bits/shmlba.h>.
	(SHMLBA): Remove macro.
	(__getpagesize): Remove function declaration.
	* sysdeps/unix/sysv/linux/hppa/bits/shm.h: Include
	<bits/shmlba.h>.
	(SHMLBA): Remove macro.
	* sysdeps/unix/sysv/linux/mips/bits/shm.h: Include
	<bits/shmlba.h>.
	(SHMLBA): Remove macro.
	* sysdeps/unix/sysv/linux/powerpc/bits/shm.h: Include
	<bits/shmlba.h>.
	(SHMLBA): Remove macro.
	(__getpagesize): Remove function declaration.
	* sysdeps/unix/sysv/linux/sparc/bits/shm.h: Include
	<bits/shmlba.h>.
	(SHMLBA): Remove macro.
	(__getshmlba): Remove function declaration.
	* sysdeps/unix/sysv/linux/x86/bits/shm.h: Include <bits/shmlba.h>.
	(SHMLBA): Remove macro.
	(__getpagesize): Remove function declaration.
	* sysdeps/unix/sysv/linux/arm/bits/shm.h: Remove file.
	* sysdeps/unix/sysv/linux/ia64/bits/shm.h: Likewise.
	* sysdeps/unix/sysv/linux/sh/bits/shm.h: Likewise.
	* sysdeps/unix/sysv/linux/bits/shmlba.h: New file.
	* sysdeps/unix/sysv/linux/arm/bits/shmlba.h: Likewise.
	* sysdeps/unix/sysv/linux/hppa/bits/shmlba.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/bits/shmlba.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/shmlba.h: Likewise.
	* sysdeps/unix/sysv/linux/sh/bits/shmlba.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/shmlba.h: Likewise.
2018-10-17 11:55:10 +00:00
Stefan Liebler 403b4feb22 Fix race in pthread_mutex_lock while promoting to PTHREAD_MUTEX_ELISION_NP [BZ #23275]
The race leads either to pthread_mutex_destroy returning EBUSY
or triggering an assertion (See description in bugzilla).

This patch is fixing the race by ensuring that the elision path is
used in all cases if elision is enabled by the GLIBC_TUNABLES framework.

The __kind variable in struct __pthread_mutex_s is accessed concurrently.
Therefore we are now using the atomic macros.

The new testcase tst-mutex10 is triggering the race on s390x and intel.
Presumably also on power, but I don't have access to a power machine
with lock-elision. At least the code for power is the same as on the other
two architectures.

ChangeLog:

	[BZ #23275]
	* nptl/tst-mutex10.c: New File.
	* nptl/Makefile (tests): Add tst-mutex10.
	(tst-mutex10-ENV): New variable.
	* sysdeps/unix/sysv/linux/s390/force-elision.h: (FORCE_ELISION):
	Ensure that elision path is used if elision is available.
	* sysdeps/unix/sysv/linux/powerpc/force-elision.h (FORCE_ELISION):
	Likewise.
	* sysdeps/unix/sysv/linux/x86/force-elision.h: (FORCE_ELISION):
	Likewise.
	* nptl/pthreadP.h (PTHREAD_MUTEX_TYPE, PTHREAD_MUTEX_TYPE_ELISION)
	(PTHREAD_MUTEX_PSHARED): Use atomic_load_relaxed.
	* nptl/pthread_mutex_consistent.c (pthread_mutex_consistent): Likewise.
	* nptl/pthread_mutex_getprioceiling.c (pthread_mutex_getprioceiling):
	Likewise.
	* nptl/pthread_mutex_lock.c (__pthread_mutex_lock_full)
	(__pthread_mutex_cond_lock_adjust): Likewise.
	* nptl/pthread_mutex_setprioceiling.c (pthread_mutex_setprioceiling):
	Likewise.
	* nptl/pthread_mutex_timedlock.c (__pthread_mutex_timedlock): Likewise.
	* nptl/pthread_mutex_trylock.c (__pthread_mutex_trylock): Likewise.
	* nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock_full): Likewise.
	* sysdeps/nptl/bits/thread-shared-types.h (struct __pthread_mutex_s):
	Add comments.
	* nptl/pthread_mutex_destroy.c (__pthread_mutex_destroy):
	Use atomic_load_relaxed and atomic_store_relaxed.
	* nptl/pthread_mutex_init.c (__pthread_mutex_init):
	Use atomic_store_relaxed.
2018-10-17 12:23:04 +02:00
Andreas Schwab ce5a7de6cd Don't reduce test timeout to less than default
This removes all overrides of TIMEOUT that are less than or equal to the
default timeout.
2018-10-17 09:34:13 +02:00
Anton Youdkevitch 75c1aee500 aarch64: optimized memcpy implementation for thunderx2
Since aligned loads and stores are huge performance
advantage the implementation always tries to do aligned
access. Among the cases when src and dst addresses are
aligned or unaligned evenly there are cases of not evenly
unaligned src and dst. For such cases (if the length is
big enough) ext instruction is used to merge-and-shift
two memory chunks loaded from two adjacent aligned
locations and then the adjusted chunk gets stored to
aligned address.

Performance gain against the current T2 implementation:
     memcpy-large: 65K-32M: +40% - +10%
     memcpy-walk:  128-32M: +20% - +2%
2018-10-16 11:00:27 -07:00
Joseph Myers bcdb1bfa0c Use single bits/sem.h for all architectures.
The bits/sem.h headers for architectures using the Linux kernel vary
in a few ways:

* x32 uses __syscall_ulong_t instead of unsigned long int.

* The x86 header uses padding after time fields unconditionally
  (including for both x86_64 ABIs), not just for 32-bit time (unlike
  in msqid_ds where there is only padding for 32-bit time).  Because
  this padding is present for x32, and is __syscall_ulong_t there, it
  does have to be __syscall_ulong_t, not unsigned long int.

* The MIPS header never uses padding around time fields, even when
  32-bit (unlike in msqid_ds where it has endian-dependent padding for
  32-bit time).

* Some older 32-bit big-endian architectures have padding before
  rather than after time fields, although the preferred generic
  approach is padding after the time fields independent of endianness.

(There are also insubstantial differences such as use of unsigned int
for padding instead of unsigned long int, which makes no difference to
layout since the padding fields using unsigned int are only present on
32-bit architectures.)

For the first, __syscall_ulong_t can be used in the generic version as
it's the same as unsigned long int everywhere except x32.  For the
other differences, this patch adds macros __SEM_PAD_BEFORE_TIME and
__SEM_PAD_AFTER_TIME in a new bits/sem-pad.h header, so that header is
the only one needing to be provided on architectures with differences
in this area, and everything else can go in a single common bits/sem.h
header.

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

	* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add
	bits/sem-pad.h.
	* sysdeps/unix/sysv/linux/bits/sem.h: Include <bits/sem-pad.h>
	instead of <bits/wordsize.h>.
	(__SEM_PAD_TIME): New macro, depending on [__SEM_PAD_BEFORE_TIME]
	and [__SEM_PAD_AFTER_TIME].
	(struct semid_ds): Define time fields using __SEM_PAD_TIME.  Use
	__syscall_ulong_t instead of unsigned long int.
	* sysdeps/unix/sysv/linux/bits/sem-pad.h: New file.
	* sysdeps/unix/sysv/linux/hppa/bits/sem-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/sem-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/sem-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/sem-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/sem-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/hppa/bits/sem.h: Remove.
	* sysdeps/unix/sysv/linux/mips/bits/sem.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/sem.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/sem.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/sem.h: Likewise.
2018-10-15 19:28:04 +00:00
Paul Eggert 620a5d4cb1 regex: simplify by using intprops.h
[BZ#23744]
* posix/regex_internal.h [_LIBC]: Include intprops.h.
(TYPE_SIGNED, INT_ADD_WRAPV) [_LIBC]: Remove.
intprops.h defines them.
2018-10-14 23:36:55 -05:00
Paul Eggert f4efbdfb44 regex: __builtin_expect → __glibc_unlikely
[BZ#23744]
This refactoring was prompted by a problem when the regex code is
used as part of Gnulib and when the builder’s compiler does not grok
__builtin_expect.  Problem reported for Gawk by Nelson H.F. Beebe in:
https://lists.gnu.org/r/bug-gnulib/2018-09/msg00137.html
Although this refactoring does not fix the problem directly,
we might as well have Gawk use the now-preferred glibc style for when
__builtin_expect is unavailable.
* posix/regex_internal.h (BE): Remove.
All uses replaced by __glibc_unlikely or __glibc_likely.
2018-10-14 23:36:55 -05:00
Joseph Myers 9f9feb6d5d Use single bits/msq.h for all architectures.
The bits/msq.h headers for architectures using the Linux kernel vary
in a few ways:

* x32 uses __syscall_ulong_t instead of unsigned long int.

* x32 has 64-bit time_t, so no padding around time fields despite
  __WORDSIZE == 32.

* Some older 32-bit big-endian architectures have padding before
  rather than after time fields, although the preferred generic
  approach is padding after the time fields independent of endianness.

(There are also insubstantial differences such as use of unsigned int
for padding instead of unsigned long int, which makes no difference to
layout since the padding fields using unsigned int are only present on
32-bit architectures.)

For the first, __syscall_ulong_t can be used in the generic version as
it's the same as unsigned long int everywhere except x32.  For the
other two differences, this patch adds macros __MSQ_PAD_BEFORE_TIME
and __MSQ_PAD_AFTER_TIME in a new bits/msq-pad.h header, so that
header is the only one needing to be provided on architectures with
differences in this area, and everything else can go in a single
common bits/msq.h header.  Once we have __TIMESIZE, the generic
bits/msq-pad.h can change to use that instead of __WORDSIZE, at which
point the x86 version of bits/msq-pad.h won't be needed either.

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

	* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add
	bits/msq-pad.h.
	* sysdeps/unix/sysv/linux/bits/msq.h: Include <bits/msq-pad.h>
	instead of <bits/wordsize.h>.
	(msgqnum_t): Define as __syscall_ulong_t.
	(msglen_t): Likewise.
	(__MSQ_PAD_TIME): New macro, depending on [__MSQ_PAD_BEFORE_TIME]
	and [__MSQ_PAD_AFTER_TIME].
	(struct msqid_ds): Define time fields using __MSQ_PAD_TIME.  Use
	__syscall_ulong_t instead of unsigned long int.
	* sysdeps/unix/sysv/linux/bits/msq-pad.h: New file.
	* sysdeps/unix/sysv/linux/hppa/bits/msq-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/msq-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/msq-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/msq-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/msq-pad.h: Likewise.
	* sysdeps/unix/sysv/linux/hppa/bits/msq.h: Remove.
	* sysdeps/unix/sysv/linux/mips/bits/msq.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/msq.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/msq.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/msq.h: Likewise.
2018-10-11 12:07:27 +00:00
Joseph Myers 2a4b25fad8 Use common bits/shm.h for more architectures.
sysdeps/unix/sysv/linux/bits/shm.h has padding after time fields in
struct shmid_ds unconditionally, and thus is only suitable for 32-bit
architectures (no 64-bit configurations use this file);
sysdeps/unix/sysv/linux/generic/bits/shm.h is substantively the same,
except that the padding is conditioned on __WORDSIZE == 32, and so it
can be used for 64-bit architectures as well.

This patch adds the conditionals to
sysdeps/unix/sysv/linux/bits/shm.h.  The linux/generic/ version is
then no longer needed and so is removed, as are the alpha and s390
versions which are also no longer needed.  The other
architecture-specific versions have different padding, layout, types
or SHMLBA definitions and so are still needed after this change.

This is essentially the same change for bits/shm.h as the bits/msq.h
patch and the bits/sem.h patch.  However, the details of the padding
variations for the architectures that aren't changed are not all the
same between msqid_ds, shmid_ds and semid_ds.

Tested with build-many-glibcs.py.

	* sysdeps/unix/sysv/linux/bits/shm.h: Include <bits/wordsize.h>.
	(struct shmid_ds): Condition padding after time fields on
	[__WORDSIZE == 32].
	* sysdeps/unix/sysv/linux/alpha/bits/shm.h: Remove file.
	* sysdeps/unix/sysv/linux/generic/bits/shm.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/shm.h: Likewise.
2018-10-10 00:56:17 +00:00
Joseph Myers 19e62f2690 Use common bits/sem.h for more architectures.
sysdeps/unix/sysv/linux/bits/sem.h has padding after time fields in
struct semid_ds unconditionally, and thus is only suitable for 32-bit
architectures (no 64-bit configurations use this file);
sysdeps/unix/sysv/linux/generic/bits/sem.h is substantively the same,
except that the padding is conditioned on __WORDSIZE == 32, and so it
can be used for 64-bit architectures as well.

This patch adds the conditionals to
sysdeps/unix/sysv/linux/bits/sem.h.  The linux/generic/ version is
then no longer needed and so is removed, as are the alpha, ia64 and
s390 versions which are also no longer needed.  The other
architecture-specific versions have different padding or types and so
are still needed after this change.

This is essentially the same change for bits/sem.h as the bits/msq.h
patch.  However, the details of the padding variations for the
architectures that aren't changed are not all the same between
msqid_ds and semid_ds.

Tested with build-many-glibcs.py.

	* sysdeps/unix/sysv/linux/bits/sem.h: Include <bits/wordsize.h>.
	(struct semid_ds): Condition padding after time fields on
	[__WORDSIZE == 32].
	* sysdeps/unix/sysv/linux/alpha/bits/sem.h: Remove file.
	* sysdeps/unix/sysv/linux/generic/bits/sem.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/bits/sem.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/sem.h: Likewise.
2018-10-10 00:54:27 +00:00
Joseph Myers b9c0f6c11a Use common bits/msq.h for more architectures.
sysdeps/unix/sysv/linux/bits/msq.h has padding after time fields in
struct msqid_ds unconditionally, and thus is only suitable for 32-bit
architectures (no 64-bit configurations use this file);
sysdeps/unix/sysv/linux/generic/bits/msq.h is substantively the same,
except that the padding is conditioned on __WORDSIZE == 32, and so it
can be used for 64-bit architectures as well.

This patch adds the conditionals to
sysdeps/unix/sysv/linux/bits/msq.h.  The linux/generic/ version is
then no longer needed and so is removed, as are the alpha, ia64 and
s390 versions which are also no longer needed.  The other
architecture-specific versions have different padding or types and so
are still needed after this change.

Tested with build-many-glibcs.py.

	* sysdeps/unix/sysv/linux/bits/msq.h: Include <bits/wordsize.h>.
	(struct msqid_ds): Condition padding after time fields on
	[__WORDSIZE == 32].
	* sysdeps/unix/sysv/linux/alpha/bits/msq.h: Remove file.
	* sysdeps/unix/sysv/linux/generic/bits/msq.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/bits/msq.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/msq.h: Likewise.
2018-10-10 00:52:47 +00:00
Szabolcs Nagy 97785a61af Increase timeout of nss/tst-nss-files-hosts-multi
Increase timeout from the default 20s to 40s. This test makes close to
2 million syscalls with distribution:

1180249 connect
 297952 getsockname
 144040 lseek
 143734 read
  14466 close
...

connect can be slow, so the default timeout was not enough on slow
systems.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* nss/tst-nss-files-hosts-multi.c (TIMEOUT): Define.
2018-10-09 15:57:01 +01:00
Szabolcs Nagy ed643089cd Increase timeout of libio/tst-readline
Increase timeout from the default 20s to 100s. This test makes close to
20 million syscalls with distribution:

12327675 read
 4143204 lseek
  929475 close
  929471 openat
   92817 fstat
    1431 write
...

The default timeout assumes each can finish in 1us on average which
is not true on slow machines.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* libio/tst-readline.c (TIMEOUT): Define.
2018-10-09 15:56:12 +01:00
Paul Eggert 5a58064311 mktime fix for Gnulib + coreutils
[BZ#23745]
This fix affects only Gnulib.  Problem discovered when
mktime.c was used as part of Gnulib in bleeding-edge Coreutils.
* time/mktime.c:
(my_tzset) [!_LIBC && !NEED_MKTIME_WORKING && !NEED_MKTIME_WINDOWS]:
Do not define since it is not used.  Defining an unused static
function prompts a warning from GCC when Coreutils is configured
with --enable-gcc-warnings.
2018-10-08 11:28:25 -07:00
Leonardo Sandoval c892ae04f4 benchtests: Set float type on --threshold argument
Otherwise, we see the following runtime error when using the parameter:

  File "./glibc/benchtests/scripts/compare_bench.py", line 46, in do_compare
    if d > threshold:
TypeError: '>' not supported between instances of 'float' and 'str'

	* benchtests/scripts/compare_bench.py (main): set float type on
	threshold argument.
2018-10-08 09:11:30 -05:00
Rafal Luzynski a68ec8eac2 kl_GL: Update the month names and date formats (bug 23740).
Month names as provided by Oqaasileriffik, the official Greenlandic
language regulator.  They have recently reached the consensus regarding
the orthography of the month names.

Date formats updated to match the correct Greenlandic order which is MDY.

	[BZ #23740]
	* localedata/locales/kl_GL (mon): Update, the relative case.
	(alt_mon): Add, fill with month names in the nominative case.
	(d_t_fmt): Set to "%a %b %d %Y %T %Z".
	(d_fmt): Set to "%b %d %Y".
2018-10-08 12:28:02 +02:00
Joseph Myers 47c49251d5 Use bits/mman-linux.h for hppa.
hppa currently has a bits/mman.h that does not include
bits/mman-linux.h, unlike all other architectures using the Linux
kernel.  This sort of variation between architectures is generally
unhelpful when making global changes for new constants added to new
Linux kernel releases.

This patch changes hppa to use bits/mman-linux.h, overriding constants
with different values as necessary (including with #undef after
bits/mman.h inclusion when needed, as already done for alpha).  While
there could possibly be further improvements through e.g. splitting
more sets of definitions into separate bits/ headers, I think this is
still an improvement on the current state.  diffstat shows 27 lines
added, 51 deleted (and some of that is actually existing lines moving
to a different place in the file).

Tested with build-many-glibcs.py for hppa-linux-gnu.

	* sysdeps/unix/sysv/linux/hppa/bits/mman.h: Include
	<bits/mman-linux.h>.
	(PROT_READ): Don't define here.
	(PROT_WRITE): Likewise.
	(PROT_EXEC): Likewise.
	(PROT_NONE): Likewise.
	(PROT_GROWSDOWN): Likewise.
	(PROT_GROWSUP): Likewise.
	(MAP_SHARED): Likewise.
	(MAP_PRIVATE): Likewise.
	[__USE_MISC] (MAP_SHARED_VALIDATE): Likewise.
	[__USE_MISC] (MAP_FILE): Likewise.
	[__USE_MISC] (MAP_ANONYMOUS): Likewise.
	[__USE_MISC] (MAP_ANON): Likewise.
	[__USE_MISC] (MAP_HUGE_SHIFT): Likewise.
	[__USE_MISC] (MAP_HUGE_MASK): Likewise.
	(MCL_CURRENT): Likewise.
	(MCL_FUTURE): Likewise.
	(MCL_ONFAULT): Likewise.
	[__USE_MISC] (MADV_NORMAL): Likewise.
	[__USE_MISC] (MADV_RANDOM): Likewise.
	[__USE_MISC] (MADV_SEQUENTIAL): Likewise.
	[__USE_MISC] (MADV_WILLNEED): Likewise.
	[__USE_MISC] (MADV_DONTNEED): Likewise.
	[__USE_MISC] (MADV_FREE): Likewise.
	[__USE_MISC] (MADV_REMOVE): Likewise.
	[__USE_MISC] (MADV_DONTFORK): Likewise.
	[__USE_MISC] (MADV_DOFORK): Likewise.
	[__USE_MISC] (MADV_HWPOISON): Likewise.
	[__USE_XOPEN2K] (POSIX_MADV_NORMAL): Likewise.
	[__USE_XOPEN2K] (POSIX_MADV_RANDOM): Likewise.
	[__USE_XOPEN2K] (POSIX_MADV_SEQUENTIAL): Likewise.
	[__USE_XOPEN2K] (POSIX_MADV_WILLNEED): Likewise.
	[__USE_XOPEN2K] (POSIX_MADV_DONTNEED): Likewise.
	(__MAP_ANONYMOUS): New macro.
	[__USE_MISC] (MAP_TYPE): Undefine and redefine after
	<bits/mman-linux.h> inclusion.
	(MAP_FIXED): Likewise.
	(MS_SYNC): Likewise.
	(MS_ASYNC): Likewise.
	(MS_INVALIDATE): Likewise.
	[__USE_MISC] (MADV_MERGEABLE): Likewise.
	[__USE_MISC] (MADV_UNMERGEABLE): Likewise.
	[__USE_MISC] (MADV_HUGEPAGE): Likewise.
	[__USE_MISC] (MADV_NOHUGEPAGE): Likewise.
	[__USE_MISC] (MADV_DONTDUMP): Likewise.
	[__USE_MISC] (MADV_DODUMP): Likewise.
	[__USE_MISC] (MADV_WIPEONFORK): Likewise.
	[__USE_MISC] (MADV_KEEPONFORK): Likewise.
2018-10-04 19:47:23 +00:00
Joseph Myers a19876214a Fix libnldbl_nonshared.a references to internal libm symbols (bug 23735).
The redirection of built-in functions such as sqrt in include/math.h
applies when the wrappers for those functions in libnldbl_nonshared.a
are built, resulting in references to internal names such as
__ieee754_sqrt that aren't actually exported from the shared libm.
(This applies for sqrt in 2.28, also for the round-to-integer
functions in current master because of my changes there.)  This patch
arranges for NO_MATH_REDIRECT to be used for all the affected
functions, and adds a test for those functions in
libnldbl_nonshared.a.

(We could of course choose to obsolete libnldbl_nonshared.a and
require that people building with -mlong-double-64 either include the
relevant headers and have a compiler supporting asm redirection, or
have some other means of achieving that redirection at compile time if
not including those headers.  But while we have libnldbl_nonshared.a,
it seems appropriate to fix such bugs in it.)

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

	[BZ #23735]
	* sysdeps/ieee754/ldbl-opt/nldbl-compat.h (NO_MATH_REDIRECT):
	Define.
	* sysdeps/ieee754/ldbl-opt/test-nldbl-redirect.c: New file.
	* sysdeps/ieee754/ldbl-opt/Makefile [$(subdir) = math] (tests):
	Add test-nldbl-redirect.
	[$(subdir) = math] (CFLAGS-test-nldbl-redirect.c): New variable.
	[$(subdir) = math] ($(objpfx)test-nldbl-redirect): Depend on
	$(objpfx)libnldbl_nonshared.a.
2018-10-04 12:16:05 +00:00
Stefan Liebler e7624d708d Adjust name of ld.so in test-container.c.
The test-container.c file assumes that ld.so is always named
something like /elf/ld-linux-*.
But e.g. on s390x it is named ld64.so.1 or ld.so.1 on s390.
There are other architectures like power or mips with similar names.

This patch introduces the new global variable support_objdir_elf_ldso
which contains the absolute path to the runtime linker used by the
testsuite, e.g. OBJDIR_PATH/elf/ld-linux-x86-64.so.2.
The check in test-container.c is now comparing against this path.
Without this patch, test-container.c is searching invalid files / directories
and fails to find glibc/nss/tst-nss-test3.root/tst-nss-test3.script.
Then the test tst-nss-test3 fails!

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

ChangeLog:

	* support/support.h (support_objdir_elf_ldso): New variable.
	* support/support_paths.c (support_objdir_elf_ldso): Likewise.
	* support/Makefile (CFLAGS-support_paths.c): Add definition
	for OBJDIR_ELF_LDSO_PATH.
	* support/test-container.c (main): Search for the ld.so
	which is also used by the testsuite.
2018-10-04 13:07:29 +02:00
Rafal Luzynski dae3ed958c kl_GL: Fix spelling of Sunday, should be "sapaat" (bug 20209).
Although CLDR says otherwise, it is confirmed by Oqaasileriffik, the
official Greenlandic language regulator, that this change is correct.

	[BZ #20209]
	* localedata/locales/kl_GL: (abday): Fix spelling of Sun (Sunday),
	should be "sap" rather than "sab".
	(day): Fix spelling of Sunday, should be "sapaat" rather than
	"sabaat".
2018-10-02 23:55:13 +02:00
Joseph Myers f346b5b38c Add more fma tests.
In my review
<https://sourceware.org/ml/libc-alpha/2018-06/msg00375.html> of a
patch for bug 23584, I expressed concern that the proposed changes
didn't deal with certain cases similar to the ones in the bug but
where test coverage was missing.

This patch adds such tests of fma (Inf, finite, finite) and fma
(finite, Inf, finite) to libm-test-fma.inc.  It does *not* do anything
to fix the bug, simply adds test coverage to provide stronger evidence
of whether any proposed revised fix does address the cases I was
concerned with.

Tested for x86_64 and x86.

	* math/libm-test-fma.inc (fma_test_data): Add more tests.
2018-10-02 17:17:15 +00:00
Martin Jansa 4a06ceea33 sysdeps/ieee754/soft-fp: ignore maybe-uninitialized with -O [BZ #19444]
* with -O, -O1, -Os it fails with:

In file included from ../soft-fp/soft-fp.h:318,
                 from ../sysdeps/ieee754/soft-fp/s_fdiv.c:28:
../sysdeps/ieee754/soft-fp/s_fdiv.c: In function '__fdiv':
../soft-fp/op-2.h:98:25: error: 'R_f1' may be used uninitialized in this function [-Werror=maybe-uninitialized]
        X##_f0 = (X##_f1 << (_FP_W_TYPE_SIZE - (N)) | X##_f0 >> (N) \
                         ^~
../sysdeps/ieee754/soft-fp/s_fdiv.c:38:14: note: 'R_f1' was declared here
   FP_DECL_D (R);
              ^
../soft-fp/op-2.h:37:36: note: in definition of macro '_FP_FRAC_DECL_2'
   _FP_W_TYPE X##_f0 _FP_ZERO_INIT, X##_f1 _FP_ZERO_INIT
                                    ^
../soft-fp/double.h:95:24: note: in expansion of macro '_FP_DECL'
 # define FP_DECL_D(X)  _FP_DECL (2, X)
                        ^~~~~~~~
../sysdeps/ieee754/soft-fp/s_fdiv.c:38:3: note: in expansion of macro 'FP_DECL_D'
   FP_DECL_D (R);
   ^~~~~~~~~
../soft-fp/op-2.h:101:17: error: 'R_f0' may be used uninitialized in this function [-Werror=maybe-uninitialized]
       : (X##_f0 << (_FP_W_TYPE_SIZE - (N))) != 0)); \
                 ^~
../sysdeps/ieee754/soft-fp/s_fdiv.c:38:14: note: 'R_f0' was declared here
   FP_DECL_D (R);
              ^
../soft-fp/op-2.h:37:14: note: in definition of macro '_FP_FRAC_DECL_2'
   _FP_W_TYPE X##_f0 _FP_ZERO_INIT, X##_f1 _FP_ZERO_INIT
              ^
../soft-fp/double.h:95:24: note: in expansion of macro '_FP_DECL'
 # define FP_DECL_D(X)  _FP_DECL (2, X)
                        ^~~~~~~~
../sysdeps/ieee754/soft-fp/s_fdiv.c:38:3: note: in expansion of macro 'FP_DECL_D'
   FP_DECL_D (R);
   ^~~~~~~~~

Build tested with Yocto for ARM, AARCH64, X86, X86_64, PPC, MIPS, MIPS64
with -O, -O1, -Os.
For AARCH64 it needs one more fix in locale for -Os.

	[BZ #19444]
	* sysdeps/ieee754/soft-fp/s_fdiv.c: Include <libc-diag.h> and use
	DIAG_PUSH_NEEDS_COMMENT, DIAG_IGNORE_NEEDS_COMMENT and
	DIAG_POP_NEEDS_COMMENT to disable -Wmaybe-uninitialized.
2018-10-02 15:40:57 +00:00
Adhemerval Zanella a06fc4a533 Fix build from commit 0b727ed
* sysdeps/unix/sysv/linux/fd_to_filename.h: Add missing includes.
2018-10-02 12:29:02 -03:00
H.J. Lu a1ccc0654b x86: Use RTM intrinsics in pthread mutex lock elision
Since RTM intrinsics are supported in GCC 4.9, we can use them in
pthread mutex lock elision.

	* sysdeps/unix/sysv/linux/x86/Makefile (CFLAGS-elision-lock.c):
	Add -mrtm.
	(CFLAGS-elision-unlock.c): Likewise.
	(CFLAGS-elision-timed.c): Likewise.
	(CFLAGS-elision-trylock.c): Likewise.
	* sysdeps/unix/sysv/linux/x86/hle.h: Rewritten.
2018-10-02 07:51:57 -07:00
Adhemerval Zanella 0b727ed4d6 libio: Flush stream at freopen (BZ#21037)
As POSIX states [1] a freopen call should first flush the stream as if by a
call fflush.  C99 (n1256) and C11 (n1570) only states the function should
first close any file associated with the specific stream.  Although current
implementation only follow C specification, current BSD and other libc
implementation (musl) are in sync with POSIX and fflush the stream.

This patch change freopen{64} to fflush the stream before actually reopening
it (or returning if the stream does not support reopen).  It also changes the
Linux implementation to avoid a dynamic allocation on 'fd_to_filename'.

Checked on x86_64-linux-gnu.

	[BZ #21037]
	* libio/Makefile (tests): Add tst-memstream4 and tst-wmemstream4.
	* libio/freopen.c (freopen): Sync stream before reopen and adjust to
	new fd_to_filename interface.
	* libio/freopen64.c (freopen64): Likewise.
	* libio/tst-memstream.h: New file.
	* libio/tst-memstream4.c: Likewise.
	* libio/tst-wmemstream4.c: Likewise.
	* sysdeps/generic/fd_to_filename.h (fd_to_filename): Change signature.
	* sysdeps/unix/sysv/linux/fd_to_filename.h (fd_to_filename): Likewise
	and remove internal dynamic allocation.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/
2018-10-02 10:01:56 -03:00
Joseph Myers d0e91e8c4e Move MREMAP_* to bits/mman-shared.h.
The MREMAP_* flags are identical between bits/mman-linux.h and the
hppa bits/mman.h; thus, they should be in bits/mman-shared.h instead
to avoid unnecessary duplication.  This patch moves them there.

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

	* sysdeps/unix/sysv/linux/bits/mman-linux.h [__USE_GNU]
	(MREMAP_MAYMOVE): Do not define here.
	[__USE_GNU] (MREMAP_FIXED): Likewise.
	* sysdeps/unix/sysv/linux/bits/mman-shared.h [__USE_GNU]
	(MREMAP_MAYMOVE): Define here instead.
	[__USE_GNU] (MREMAP_FIXED): Likewise.
	* sysdeps/unix/sysv/linux/hppa/bits/mman.h [__USE_GNU]
	(MREMAP_MAYMOVE): Remove.
	[__USE_GNU] (MREMAP_FIXED): Likewise.
2018-10-01 20:30:57 +00:00
Joseph Myers c52944e8cc Remove unnecessary math_private.h includes.
After my changes to move various macros, inlines and other content
from math_private.h to more specific headers, many files including
math_private.h no longer need to do so.  Furthermore, since the
optimized inlines of various functions have been moved to
include/fenv.h or replaced by use of function names GCC inlines
automatically, a missing math_private.h include where one is
appropriate will reliably cause a build failure rather than possibly
causing code to be less well optimized while still building
successfully.  Thus, this patch removes includes of math_private.h
that are now unnecessary.  In the case of two RISC-V files, the
include is replaced by one of stdbool.h because the files in question
were relying on math_private.h to get a definition of bool.

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

	* math/fromfp.h: Do not include <math_private.h>.
	* math/s_cacosh_template.c: Likewise.
	* math/s_casin_template.c: Likewise.
	* math/s_casinh_template.c: Likewise.
	* math/s_ccos_template.c: Likewise.
	* math/s_cproj_template.c: Likewise.
	* math/s_fdim_template.c: Likewise.
	* math/s_fmaxmag_template.c: Likewise.
	* math/s_fminmag_template.c: Likewise.
	* math/s_iseqsig_template.c: Likewise.
	* math/s_ldexp_template.c: Likewise.
	* math/s_nextdown_template.c: Likewise.
	* math/w_log1p_template.c: Likewise.
	* math/w_scalbln_template.c: Likewise.
	* sysdeps/aarch64/fpu/feholdexcpt.c: Likewise.
	* sysdeps/aarch64/fpu/fesetround.c: Likewise.
	* sysdeps/aarch64/fpu/fgetexcptflg.c: Likewise.
	* sysdeps/aarch64/fpu/ftestexcept.c: Likewise.
	* sysdeps/aarch64/fpu/s_llrint.c: Likewise.
	* sysdeps/aarch64/fpu/s_llrintf.c: Likewise.
	* sysdeps/aarch64/fpu/s_lrint.c: Likewise.
	* sysdeps/aarch64/fpu/s_lrintf.c: Likewise.
	* sysdeps/i386/fpu/s_atanl.c: Likewise.
	* sysdeps/i386/fpu/s_f32xaddf64.c: Likewise.
	* sysdeps/i386/fpu/s_f32xsubf64.c: Likewise.
	* sysdeps/i386/fpu/s_fdim.c: Likewise.
	* sysdeps/i386/fpu/s_logbl.c: Likewise.
	* sysdeps/i386/fpu/s_rintl.c: Likewise.
	* sysdeps/i386/fpu/s_significandl.c: Likewise.
	* sysdeps/ia64/fpu/s_matherrf.c: Likewise.
	* sysdeps/ia64/fpu/s_matherrl.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_atan.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_cbrt.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_fma.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_fmaf.c: Likewise.
	* sysdeps/ieee754/flt-32/s_cbrtf.c: Likewise.
	* sysdeps/ieee754/k_standardf.c: Likewise.
	* sysdeps/ieee754/k_standardl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_copysignl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_finitel.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_fpclassifyl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_isinfl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_isnanl.c: Likewise.
	* sysdeps/ieee754/ldbl-64-128/s_signbitl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_cbrtl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_fma.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_fmal.c: Likewise.
	* sysdeps/ieee754/s_signgam.c: Likewise.
	* sysdeps/powerpc/power5+/fpu/s_modf.c: Likewise.
	* sysdeps/powerpc/power5+/fpu/s_modff.c: Likewise.
	* sysdeps/powerpc/power7/fpu/s_logbf.c: Likewise.
	* sysdeps/riscv/rv64/rvd/s_ceil.c: Likewise.
	* sysdeps/riscv/rv64/rvd/s_floor.c: Likewise.
	* sysdeps/riscv/rv64/rvd/s_nearbyint.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/rvd/s_finite.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/fegetround.c: Likewise.
	* sysdeps/riscv/rvf/feholdexcpt.c: Likewise.
	* sysdeps/riscv/rvf/fesetenv.c: Likewise.
	* sysdeps/riscv/rvf/fesetround.c: Likewise.
	* sysdeps/riscv/rvf/feupdateenv.c: Likewise.
	* sysdeps/riscv/rvf/fgetexcptflg.c: Likewise.
	* sysdeps/riscv/rvf/ftestexcept.c: Likewise.
	* sysdeps/riscv/rvf/s_ceilf.c: Likewise.
	* sysdeps/riscv/rvf/s_finitef.c: Likewise.
	* sysdeps/riscv/rvf/s_floorf.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_roundevenf.c: Likewise.
	* sysdeps/riscv/rvf/s_roundf.c: Likewise.
	* sysdeps/riscv/rvf/s_truncf.c: Likewise.
	* sysdeps/riscv/rv64/rvd/s_rint.c: Include <stdbool.h> instead of
	<math_private.h>.
	* sysdeps/riscv/rvf/s_rintf.c: Likewise.
2018-09-28 21:53:33 +00:00
H.J. Lu 7b1f940676 i386: Use _dl_runtime_[resolve|profile]_shstk for SHSTK [BZ #23716]
When elf_machine_runtime_setup is called to set up resolver, it should
use _dl_runtime_resolve_shstk or _dl_runtime_profile_shstk if SHSTK is
enabled by kernel.

Tested on i686 with and without --enable-cet as well as on CET emulator
with --enable-cet.

	[BZ #23716]
	* sysdeps/i386/dl-cet.c: Removed.
	* sysdeps/i386/dl-machine.h (_dl_runtime_resolve_shstk): New
	prototype.
	(_dl_runtime_profile_shstk): Likewise.
	(elf_machine_runtime_setup): Use _dl_runtime_profile_shstk or
	_dl_runtime_resolve_shstk if SHSTK is enabled by kernel.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2018-09-28 13:31:30 -07:00
Adhemerval Zanella 7a16bdbb9f Fix misreported errno on preadv2/pwritev2 (BZ#23579)
The fallback code of Linux wrapper for preadv2/pwritev2 executes
regardless of the errno code for preadv2, instead of the case where
the syscall is not supported.

This fixes it by calling the fallback code iff errno is ENOSYS. The
patch also adds tests for both invalid file descriptor and invalid
iov_len and vector count.

The only discrepancy between preadv2 and fallback code regarding
error reporting is when an invalid flags are used.  The fallback code
bails out earlier with ENOTSUP instead of EINVAL/EBADF when the syscall
is used.

Checked on x86_64-linux-gnu on a 4.4.0 and 4.15.0 kernel.

	[BZ #23579]
	* misc/tst-preadvwritev2-common.c (do_test_with_invalid_fd): New
	test.
	* misc/tst-preadvwritev2.c, misc/tst-preadvwritev64v2.c (do_test):
	Call do_test_with_invalid_fd.
	* sysdeps/unix/sysv/linux/preadv2.c (preadv2): Use fallback code iff
	errno is ENOSYS.
	* sysdeps/unix/sysv/linux/preadv64v2.c (preadv64v2): Likewise.
	* sysdeps/unix/sysv/linux/pwritev2.c (pwritev2): Likewise.
	* sysdeps/unix/sysv/linux/pwritev64v2.c (pwritev64v2): Likewise.
2018-09-28 10:08:09 -03:00
Joseph Myers 81dca813cc Use copysign functions not __copysign functions in glibc libm.
Continuing the move to use, within libm, public names for libm
functions that can be inlined as built-in functions on many
architectures, this patch moves calls to __copysign functions to call
the corresponding copysign names instead, with asm redirection to
__copysign when the calls are not inlined (all cases are inlined
except for IBM long double for powerpc soft-float / e500v1).  This
eliminates the need for an inline function defining __copysign in
terms of __builtin_copysign.

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

	* include/math.h [!_ISOMAC && !(__FINITE_MATH_ONLY__ &&
	__FINITE_MATH_ONLY__ > 0) && !NO_MATH_REDIRECT]
	(MATH_REDIRECT_BINARY_ARGS): New macro.
	[!_ISOMAC && !(__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0)
	&& !NO_MATH_REDIRECT] (copysign): Redirect using MATH_REDIRECT.
	* sysdeps/alpha/fpu/s_copysign.c: Define NO_MATH_REDIRECT before
	header inclusion.
	* sysdeps/alpha/fpu/s_copysignf.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_copysign.c: Likewise.
	* sysdeps/ieee754/float128/s_copysignf128.c: Likewise.
	* sysdeps/ieee754/flt-32/s_copysignf.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_copysignl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_copysignl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_copysignl.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign.c:
	Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysignf.c:
	Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysignf.c: Likewise.
	* sysdeps/riscv/rvd/s_copysign.c: Likewise.
	* sysdeps/riscv/rvf/s_copysignf.c: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign.c:
	Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf.c:
	Likewise.
	* sysdeps/generic/math_private_calls.h
	[!__MATH_DECLARING_LONG_DOUBLE || !NO_LONG_DOUBLE] (__copysign):
	Do not declare and define as an inline function.
	* math/divtc3.c (__divtc3): Use copysign functions instead of
	__copysign variants.
	* math/multc3.c (__multc3): Likewise.
	* sysdeps/generic/math-type-macros.h (M_COPYSIGN): Likewise.
	* sysdeps/ieee754/dbl-64/e_atan2.c (signArctan2): Likewise.
	* sysdeps/ieee754/dbl-64/e_atanh.c (__ieee754_atanh): Likewise.
	* sysdeps/ieee754/dbl-64/e_gamma_r.c (__ieee754_gamma_r):
	Likewise.
	* sysdeps/ieee754/dbl-64/e_jn.c (__ieee754_jn): Likewise.
	(__ieee754_yn): Likewise.
	* sysdeps/ieee754/dbl-64/s_asinh.c (__asinh): Likewise.
	* sysdeps/ieee754/dbl-64/s_atan.c (__signArctan): Likewise.
	* sysdeps/ieee754/dbl-64/s_scalbln.c (__scalbln): Likewise.
	* sysdeps/ieee754/dbl-64/s_scalbn.c (__scalbn): Likewise.
	* sysdeps/ieee754/dbl-64/s_sin.c (do_sin): Likewise.
	(__sin): Likewise.
	* sysdeps/ieee754/dbl-64/s_sincos.c (__sincos): Likewise.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_nearbyint.c (__nearbyint):
	Likewise.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_scalbln.c (__scalbln):
	Likewise.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_scalbn.c (__scalbn):
	Likewise.
	* sysdeps/ieee754/flt-32/e_atanhf.c (__ieee754_atanhf): Likewise.
	* sysdeps/ieee754/flt-32/e_gammaf_r.c (__ieee754_gammaf_r):
	Likewise.
	* sysdeps/ieee754/flt-32/e_jnf.c (__ieee754_jnf): Likewise.
	(__ieee754_ynf): Likewise.
	* sysdeps/ieee754/flt-32/s_asinhf.c (__asinhf): Likewise.
	* sysdeps/ieee754/flt-32/s_scalbnf.c (__scalbnf): Likewise.
	* sysdeps/ieee754/k_standard.c (__kernel_standard): Likewise.
	* sysdeps/ieee754/ldbl-128/e_gammal_r.c (__ieee754_gammal_r):
	Likewise.
	* sysdeps/ieee754/ldbl-128/e_jnl.c (__ieee754_jnl): Likewise.
	(__ieee754_ynl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_scalblnl.c (__scalblnl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_scalbnl.c (__scalbnl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c (__ieee754_gammal_r):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_jnl.c (__ieee754_jnl): Likewise.
	(__ieee754_ynl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_fmal.c (__fmal): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_scalblnl.c (__scalblnl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_scalbnl.c (__scalbnl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_gammal_r.c (__ieee754_gammal_r):
	Likewise.
	* sysdeps/ieee754/ldbl-96/e_jnl.c (__ieee754_jnl): Likewise.
	(__ieee754_ynl)
	* sysdeps/ieee754/ldbl-96/s_asinhl.c (__asinhl): Likewise.
	* sysdeps/ieee754/ldbl-96/s_scalblnl.c (__scalblnl): Likewise.
	* sysdeps/ieee754/ldbl-opt/nldbl-copysign.c (copysignl): Likewise.
	* sysdeps/powerpc/power5+/fpu/s_modf.c (__modf): Likewise.
	* sysdeps/powerpc/power5+/fpu/s_modff.c (__modff): Likewise.
2018-09-27 20:04:48 +00:00
Joseph Myers 9755bc4686 Use round functions not __round functions in glibc libm.
Continuing the move to use, within libm, public names for libm
functions that can be inlined as built-in functions on many
architectures, this patch moves calls to __round functions to call the
corresponding round names instead, with asm redirection to __round
when the calls are not inlined.

An additional complication arises in
sysdeps/ieee754/ldbl-128ibm/e_expl.c, where a call to roundl, with the
result converted to int, gets converted by the compiler to call
lroundl in the case of 32-bit long, so resulting in localplt test
failures.  It's logically correct to let the compiler make such an
optimization; an appropriate asm redirection of lroundl to __lroundl
is thus added to that file (it's not needed anywhere else).

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

	* include/math.h [!_ISOMAC && !(__FINITE_MATH_ONLY__ &&
	__FINITE_MATH_ONLY__ > 0) && !NO_MATH_REDIRECT] (round): Redirect
	using MATH_REDIRECT.
	* sysdeps/aarch64/fpu/s_round.c: Define NO_MATH_REDIRECT before
	header inclusion.
	* sysdeps/aarch64/fpu/s_roundf.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_round.c: Likewise.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_round.c: Likewise.
	* sysdeps/ieee754/float128/s_roundf128.c: Likewise.
	* sysdeps/ieee754/flt-32/s_roundf.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_roundl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_roundl.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_round.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf.c: Likewise.
	* sysdeps/riscv/rv64/rvd/s_round.c: Likewise.
	* sysdeps/riscv/rvf/s_roundf.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_roundl.c: Likewise.
	(round): Redirect to __round.
	(__roundl): Call round instead of __round.
	* sysdeps/powerpc/fpu/math_private.h [_ARCH_PWR5X] (__round):
	Remove macro.
	[_ARCH_PWR5X] (__roundf): Likewise.
	* sysdeps/ieee754/dbl-64/e_gamma_r.c (gamma_positive): Use round
	functions instead of __round variants.
	* sysdeps/ieee754/flt-32/e_gammaf_r.c (gammaf_positive): Likewise.
	* sysdeps/ieee754/ldbl-128/e_gammal_r.c (gammal_positive):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c (gammal_positive):
	Likewise.
	* sysdeps/ieee754/ldbl-96/e_gammal_r.c (gammal_positive):
	Likewise.
	* sysdeps/x86/fpu/powl_helper.c (__powl_helper): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_expl.c (lroundl): Redirect to
	__lroundl.
	(__ieee754_expl): Call roundl instead of __roundl.
2018-09-27 12:35:23 +00:00
Andreas Schwab f841c97e51 Fix stack overflow in tst-setcontext9 (bug 23717)
The function f1a, executed on a stack of size 32k, allocates an object of
size 32k on the stack.  Make the stack variables static to reduce
excessive stack usage.
2018-09-27 12:31:03 +02:00
Andreas Schwab 6ca8284e7a Add missing unwind information to ld.so on powerpc32 (bug 23707) 2018-09-26 16:49:30 +02:00
Joseph Myers 61d8b5feee Share MAP_* flags between more architectures.
Continuing bits/mman.h unification between architectures using the
Linux kernel, this patch arranges for the common set of MAP_* flags to
be used by two more architectures.  That common set is moved to
bits/mman-map-flags-generic.h, which is included by bits/mman.h, to
allow architectures to use that common set even if they also have
architecture-specific additions to it.  As well as the generic
bits/mman.h, the versions for x86 and ia64 are also then made to
include bits/mman-map-flags-generic.h, so while they still need
architecture-specific bits/mman.h (for MAP_32BIT and MAP_GROWSUP
respectively), they do not need to duplicate the generic flag
definitions in there.

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

	* sysdeps/unix/sysv/linux/bits/mman-map-flags-generic.h: New
	file.  Most contents moved from ....
	* sysdeps/unix/sysv/linux/bits/mman.h: ... here.  Move contents to
	and include <bits/mman-map-flags-generic.h>.
	* sysdeps/unix/sysv/linux/Makefile [$(subdir) = misc]
	(sysdep_headers): Add bits/mman-map-flags-generic.h.
	* sysdeps/unix/sysv/linux/ia64/bits/mman.h: Include
	<bits/mman-map-flags-generic.h>.
	[__USE_MISC] (MAP_GROWSUP): Only define this macro, not other
	macros defined in <bits/mman-map-flags-generic.h>.
	* sysdeps/unix/sysv/linux/x86/bits/mman.h: Include
	<bits/mman-map-flags-generic.h>.
	[__USE_MISC] (MAP_32BIT): Only define this macro, not other macros
	defined in <bits/mman-map-flags-generic.h>.
2018-09-26 12:33:14 +00:00
Andreas Schwab 4634128642 Remove leading space from testrun.sh 2018-09-26 10:13:13 +02:00
Adhemerval Zanella b5c45e8375 Fix ifunc support with DT_TEXTREL segments (BZ#20480)
Currently, DT_TEXTREL is incompatible with IFUNC.  When DT_TEXTREL or
DF_TEXTREL is seen, the dynamic linker calls __mprotect on the segments
with PROT_READ|PROT_WRITE before applying dynamic relocations. It leads
to segfault when performing IFUNC resolution (which requires PROT_EXEC
as well for the IFUNC resolver).

This patch makes it call __mprotect with extra PROT_WRITE bit, which
will keep the PROT_EXEC bit if exists, and thus fixes the segfault.
FreeBSD rtld libexec/rtld-elf/rtld.c (reloc_textrel_prot) does the same.

Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu,
sparc64-linux-gnu, sparcv9-linux-gnu, and armv8-linux-gnueabihf.

	Adam J. Richte  <adam_richter2004@yahoo.com>
	Adhemerval Zanella  <adhemerval.zanella@linaro.org>
	Fangrui Song  <maskray@google.com>

	[BZ #20480]
	* config.h.in (CAN_TEXTREL_IFUNC): New define.
	* configure.ac: Add check if linker supports textrel relocation with
	ifunc.
	* elf/dl-reloc.c (_dl_relocate_object): Use all required flags on
	DT_TEXTREL segments, not only PROT_READ and PROT_WRITE.
	* elf/Makefile (ifunc-pie-tests): Add tst-ifunc-textrel.
	(CFLAGS-tst-ifunc-textrel.c): New rule.
	* elf/tst-ifunc-textrel.c: New file.
2018-09-25 16:27:50 -03:00
Joseph Myers d62f9ec0cc Complete sys/procfs.h unification.
This patch completes the process of unifying sys/procfs.h headers for
architectures using the Linux kernel by making alpha use the generic
version.

That was previously deferred because alpha has different definitions
of prgregset_t and prfpregset_t from other architectures, so changing
to the common definitions would change C++ name mangling.  To avoid
such a change, a header bits/procfs-prregset.h is added, and alpha
gets its own version of that header.

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

	* sysdeps/unix/sysv/linux/sys/procfs.h: Include
	<bits/procfs-prregset.h>.
	(prgregset_t): Define using __prgregset_t.
	(prfpregset_t): Define using __prfpregset_t.
	* sysdeps/unix/sysv/linux/Makefile [$(subdir) = misc]
	(sysdep_headers): Add bits/procfs-prregset.h.
	* sysdeps/unix/sysv/linux/bits/procfs-prregset.h: New file.
	* sysdeps/unix/sysv/linux/alpha/bits/procfs-prregset.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/sys/procfs.h: Remove file.
2018-09-25 16:50:30 +00:00
Joseph Myers d0d8eb4328 Unify more sys/procfs.h headers.
This patch continues the process of unifying sys/procfs.h headers for
architectures using the Linux kernel.

A bits/procfs-id.h header is added to define __pr_uid_t and __pr_gid_t
for the types of pr_uid and pr_gid; the default version of this header
uses unsigned int.  On some architectures, sys/procfs.h has copies of
32-bit structures for 64-bit builds; those move into a
bits/procfs-extra.h header (they can't go in bits/procfs.h because
they have to come *after* other declarations from sys/procfs.h).
Given appropriate versions of these headers, six more architectures
can then move to providing only bits/procfs*.h without duplicating the
rest of the contents of sys/procfs.h.  Only alpha needs a further
bits/ header to be added before it can stop having its own
sys/procfs.h.

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

	* sysdeps/unix/sysv/linux/sys/procfs.h: Include
	<bits/procfs-id.h> and <bits/procfs-extra.h>.
	(struct elf_prpsinfo): Use __pr_uid_t and __pr_gid_t as types of
	pr_uid and pr_gid.
	* sysdeps/unix/sysv/linux/Makefile [$(subdir) = misc]
	(sysdep_headers): Add bits/procfs-id.h and bits/procfs-extra.h.
	* sysdeps/unix/sysv/linux/bits/procfs-extra.h: New file.
	* sysdeps/unix/sysv/linux/bits/procfs-id.h: Likewise.
	* sysdeps/unix/sysv/linux/arm/bits/procfs-id.h: Likewise.
	* sysdeps/unix/sysv/linux/arm/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/m68k/bits/procfs-id.h: Likewise.
	* sysdeps/unix/sysv/linux/m68k/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/procfs-extra.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/procfs-id.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/sh/bits/procfs-id.h: Likewise.
	* sysdeps/unix/sysv/linux/sh/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/procfs-extra.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/procfs-id.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/procfs-id.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/arm/sys/procfs.h: Remove file.
	* sysdeps/unix/sysv/linux/m68k/sys/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/sys/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/sh/sys/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sys/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/sys/procfs.h: Likewise.
2018-09-25 16:49:25 +00:00
Joseph Myers 8ea4d2b7d1 Unify some sys/procfs.h headers.
As per recent discussions, this patch unifies some of the sys/procfs.h
headers for architectures using the Linux kernel, producing a generic
version that can hopefully be used by all new architectures as well.

The new generic version is based on the AArch64 one.  The register
definitions, the only part that generally needs to vary by
architecture, go in a new bits/procfs.h header (which each
architecture using the generic version needs to provide); that header
also has any #includes that were in the architecture-specific
sys/procfs.h, where those includes went beyond the generic set.

The generic version is used for eight architectures where the generic
definitions were the same as the architecture-specific ones.  (Some of
those architectures had #if 0 fields, now removed; some defined types
or fields using different type names which were typedefs for the same
underlying types.)

Six of the remaining architectures with their own sys/procfs.h use
unsigned short for pr_uid / pr_gid in some cases; moving those to the
generic header will require a bits/ header to define a typedef for the
type of those fields.  In the case of alpha, the generic sys/procfs.h
uses elf_gregset_t (= unsigned long int[33]) to define prgregset_t and
elf_fpregset_t (= double[32]) to define prfpregset_t, but the alpha
version uses gregset_t (= long int[33]) and fpregset_t (= long
int[32]), so avoiding unnecessarily changing the underlying types (and
thus C++ name mangling) again means a bits/ header will need to be
able to define a different choice for those typedefs.

bits/procfs.h is included outside the __BEGIN_DECLS / __END_DECLS pair
(whereas the definitions it contains were previously inside that pair
in various sys/procfs.h headers), because it sometimes includes other
headers and putting those other #includes inside that pair seems
risky.  Because none of the declarations in bits/procfs.h are of
functions or variables or involve function types, I don't think it
makes any difference whether they are inside or outside an extern "C"
context.

Tested with build-many-glibcs.py (again, that does not provide much
validation for the correctness of this patch).

	* sysdeps/unix/sysv/linux/sys/procfs.h: Replace with file based on
	AArch64 version.  Include <bits/procfs.h>.
	* sysdeps/unix/sysv/linux/Makefile [$(subdir) = misc]
	(sysdep_headers): Add bits/procfs.h.
	* sysdeps/unix/sysv/linux/bits/procfs.h: New file.
	* sysdeps/unix/sysv/linux/aarch64/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/hppa/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/nios2/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/riscv/bits/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/sys/procfs.h: Remove file.
	* sysdeps/unix/sysv/linux/hppa/sys/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/sys/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/sys/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/sys/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/nios2/sys/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sys/procfs.h: Likewise.
	* sysdeps/unix/sysv/linux/riscv/sys/procfs.h: Likewise.
2018-09-25 16:48:15 +00:00
Adhemerval Zanella c70271662a Use libsupport for tst-spawn.c
No function changes is done.  Checked on x86_64-linux-gnu.

	* posix/tst-spawn.c (do_prepare, handle_restart, do_test):
	Use libsupport.
2018-09-25 10:49:23 -03:00
Arjun Shankar 335a3b0a0d Clean up iconv/gconv_int.h for unnecessary declarations
The variables __gconv_path_elem, __gconv_max_path_elem_len and function
__gconv_get_path declared in, as well as the type path_elem and macro
GCONV_NCHAR_GOAL defined in gconv_int.h are all used in only one iconv
compilation unit each. In addition, the extern declaration of the variable
__gconv_nmodules refers to a variable that does not exist any more.
Considering this, these symbols do not need to be exposed via a header file.

This patch removes the extern declarations from the header file and moves
the definitions to the compilation units where they are used.
2018-09-25 15:13:15 +02:00
Andreas Schwab 462d348caa Don't build libnsl for new ABIs
For architectures and ABIs that are added in version 2.29 or later the
option --enable-obsolete-nsl is no longer available, and no libnsl
compatibility library is built.
2018-09-24 10:23:10 +02:00
Adhemerval Zanella f0458cf4f9 powerpc: Only enable TLE with PPC_FEATURE2_HTM_NOSC
Linux from 3.9 through 4.2 does not abort HTM transaction on syscalls,
instead it suspend and resume it when leaving the kernel.  The
side-effects of the syscall will always remain visible, even if the
transaction is aborted.  This is an issue when transaction is used along
with futex syscall, on pthread_cond_wait for instance, where the futex
call might succeed but the transaction is rolled back leading the
pthread_cond object in an inconsistent state.

Glibc used to prevent it by always aborting a transaction before issuing
a syscall.  Linux 4.2 also decided to abort active transaction in
syscalls which makes the glibc workaround superfluous.  Worse, glibc
transaction abortion leads to a performance issue on recent kernels
where the HTM state is saved/restore lazily (v4.9).  By aborting a
transaction on every syscalls, regardless whether a transaction has being
initiated before, GLIBS makes the kernel always save/restore HTM state
(it can not even lazily disable it after a certain number of syscall
iterations).

Because of this shortcoming, Transactional Lock Elision is just enabled
when it has been explicitly set (either by tunables of by a configure
switch) and if kernel aborts HTM transactions on syscalls
(PPC_FEATURE2_HTM_NOSC).  It is reported that using simple benchmark [1],
the context-switch is about 5% faster by not issuing a tabort in every
syscall in newer kernels.

Checked on powerpc64le-linux-gnu with 4.4.0 kernel (Ubuntu 16.04).

	* NEWS: Add note about new TLE support on powerpc64le.
	* sysdeps/powerpc/nptl/tcb-offsets.sym (TM_CAPABLE): Remove.
	* sysdeps/powerpc/nptl/tls.h (tcbhead_t): Rename tm_capable to
	__ununsed1.
	(TLS_INIT_TP, TLS_DEFINE_INIT_TP): Remove tm_capable setup.
	(THREAD_GET_TM_CAPABLE, THREAD_SET_TM_CAPABLE): Remove macros.
	* sysdeps/powerpc/powerpc32/sysdep.h,
	sysdeps/powerpc/powerpc64/sysdep.h (ABORT_TRANSACTION_IMPL,
	ABORT_TRANSACTION): Remove macros.
	* sysdeps/powerpc/sysdep.h (ABORT_TRANSACTION): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/elision-conf.c (elision_init): Set
	__pthread_force_elision iff PPC_FEATURE2_HTM_NOSC is set.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h,
	sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
	sysdeps/unix/sysv/linux/powerpc/syscall.S (ABORT_TRANSACTION): Remove
	usage.
	* sysdeps/unix/sysv/linux/powerpc/not-errno.h: Remove file.

Reported-by: Breno Leitão <leitao@debian.org>
2018-09-21 10:18:03 -07:00
Rafal Luzynski 434d45fd70 it_CH/it_IT locales: Correct some LC_TIME formats (bug 10425).
Synchronize some values with CLDR and apply some suggestions from Bugzilla.

	[BZ #10425]
	* localedata/locales/it_IT (d_t_fmt): Use "%a %-d %b %Y, %T".
	(date_fmt): Use "%a %-d %b %Y, %T, %Z".
	* localedata/locales/it_CH (d_t_fmt): Use "%a %-d %b %Y, %T"
	which is the same as in it_IT.
	(d_fmt): Use "%d.%m.%Y" which is the same as in de_CH.
	(date_fmt): Use "%a %-d %b %Y, %T, %Z" which is the same as in it_IT.
2018-09-21 10:40:20 +02:00
Joseph Myers 7abf97bed9 Use trunc functions not __trunc functions in glibc libm.
Continuing the move to use, within libm, public names for libm
functions that can be inlined as built-in functions on many
architectures, this patch moves calls to __trunc functions to call the
corresponding trunc names instead, with asm redirection to __trunc
when the calls are not inlined.

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

	* include/math.h [!_ISOMAC && !(__FINITE_MATH_ONLY__ &&
	__FINITE_MATH_ONLY__ > 0) && !NO_MATH_REDIRECT] (trunc): Redirect
	using MATH_REDIRECT.
	* sysdeps/aarch64/fpu/s_trunc.c: Define NO_MATH_REDIRECT before
	header inclusion.
	* sysdeps/aarch64/fpu/s_truncf.c: Likewise.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_trunc.c: Likewise.
	* sysdeps/ieee754/float128/s_truncf128.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_trunc.c: Likewise.
	* sysdeps/ieee754/flt-32/s_truncf.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_truncl.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf.c: Likewise.
	* sysdeps/riscv/rv64/rvd/s_trunc.c: Likewise.
	* sysdeps/riscv/rvf/s_truncf.c: Likewise.
	* sysdeps/sparc/sparc64/fpu/multiarch/s_trunc.c: Likewise.
	* sysdeps/sparc/sparc64/fpu/multiarch/s_truncf.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/s_trunc.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/s_truncf.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/s_trunc_template.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_truncl.c: Likewise.
	(ceil): Redirect to __ceil.
	(floor): Redirect to __floor.
	(trunc): Redirect to __trunc.
	(__truncl): Call trunc instead of __trunc.
	* sysdeps/powerpc/fpu/math_private.h [_ARCH_PWR5X] (__trunc):
	Remove macro.
	[_ARCH_PWR5X] (__truncf): Likewise.
	* sysdeps/ieee754/dbl-64/e_gamma_r.c (__ieee754_gamma_r): Use
	trunc functions instead of __trunc variants.
	* sysdeps/ieee754/flt-32/e_gammaf_r.c (__ieee754_gammaf_r):
	Likewise.
	* sysdeps/ieee754/ldbl-128/e_gammal_r.c (__ieee754_gammal_r):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c (__ieee754_gammal_r):
	Likewise.
	* sysdeps/ieee754/ldbl-96/e_gammal_r.c (__ieee754_gammal_r):
	Likewise.
2018-09-20 21:11:10 +00:00
Joseph Myers d90c9b1a12 Invert sense of list of i686-class processors in sysdeps/x86/cpu-features.h.
I noticed that sysdeps/x86/cpu-features.h had conditionals on whether
to define HAS_CPUID, HAS_I586 and HAS_I686 with a long list of
preprocessor macros for i686-and-later processors which however was
out of date.  This patch avoids the problem of the list getting out of
date by instead having conditionals on all the (few, old) pre-i686
processors for which GCC has preprocessor macros, rather than the
(many, expanding list) i686-and-later processors.  It seems HAS_I586
and HAS_I686 are unused so the only effect of these macros being
missing is that 32-bit glibc built for one of these processors would
end up doing runtime detection of CPUID availability.

i386 builds are prevented by a configure test so there is no need to
allow for them here.  __geode__ (no long nops?) and __k6__ (no CMOV,
at least according to GCC) are conservatively handled as i586, not
i686, here (as noted above, this is a theoretical distinction at
present in that only HAS_CPUID appears to be used).

Tested for x86.

	* sysdeps/x86/cpu-features.h [__geode__ || __k6__]: Handle like
	[__i586__ || __pentium__].
	[__i486__]: Handle explicitly.
	(HAS_CPUID): Define to 1 if above macros are undefined.
	(HAS_I586): Likewise.
	(HAS_I686): Likewise.
2018-09-20 12:43:41 +00:00