external/glibc.git
5 years agowcsmbs: optimize wcsncpy
Adhemerval Zanella [Tue, 5 Feb 2019 20:48:31 +0000 (18:48 -0200)]
wcsmbs: optimize wcsncpy

This patch rewrites wcsncpy using wcsnlen, wmemset, and wmemcpy.  This is
similar to the optimization done on strncpy by f6482cf29d and 6423d4754c.

Checked on x86_64-linux-gnu.

* wcsmbs/wcsncpy.c (__wcsncpy): Rewrite using wcsnlen, wmemset, and
wmemcpy.

5 years agowcsmbs: optimize wcsncat
Adhemerval Zanella [Tue, 5 Feb 2019 20:43:18 +0000 (18:43 -0200)]
wcsmbs: optimize wcsncat

This patch rewrites wcsncat using wcslen, wcsnlen, and wmemcpy.  This is
similar to the optimization done on strncat by 3eb38795db and e80514b5a8.

Checked on x86_64-linux-gnu.

* wcsmbs/wcsncat.c (wcsncat): Rewrite using wcslen, wcsnlen, and
wmemcpy.

5 years agowcsmbs: optimize wcscpy
Adhemerval Zanella [Tue, 5 Feb 2019 20:32:03 +0000 (18:32 -0200)]
wcsmbs: optimize wcscpy

This patch rewrites wcscpy using wcslen and wmemcpy.  This is similar
to the optimization done on strcpy by b863d2bc4d.

Checked on x86_64-linux-gnu.

* wcsmbs/wcscpy.c (__wcpcpy): Rewrite using wcslen and wmemcpy.

5 years agowcsmbs: optimize wcscat
Adhemerval Zanella [Tue, 5 Feb 2019 19:35:12 +0000 (17:35 -0200)]
wcsmbs: optimize wcscat

This patch rewrites wcscat using wcslen and wcscpy.  This is similar to
the optimization done on strcat by 6e46de42fe.

The strcpy changes are mainly to add the internal alias to avoid PLT
calls.

Checked on x86_64-linux-gnu and a build against the affected
architectures.

* include/wchar.h (__wcscpy): New prototype.
* sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-ppc32.c
(__wcscpy): Route internal symbol to generic implementation.
* sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy.c (wcscpy):
Add internal __wcscpy alias.
* sysdeps/powerpc/powerpc64/multiarch/wcscpy.c (wcscpy): Likewise.
* sysdeps/s390/wcscpy.c (wcscpy): Likewise.
* sysdeps/x86_64/multiarch/wcscpy.c (wcscpy): Likewise.
* wcsmbs/wcscpy.c (wcscpy): Add
* sysdeps/x86_64/multiarch/wcscpy-c.c (WCSCPY): Adjust macro to
use generic implementation.
* wcsmbs/wcscat.c (wcscat): Rewrite using wcslen and wcscpy.

5 years agowcsmbs: optimize wcpncpy
Adhemerval Zanella [Tue, 5 Feb 2019 19:34:21 +0000 (17:34 -0200)]
wcsmbs: optimize wcpncpy

This patch rewrites wcpncpy using wcslen, wmemcpy, and wmemset.  This is
similar to the optimization done on stpncpy by 48497aba8e.

Checked on x86_64-linux-gnu.

        * wcsmbs/wcpncpy.c (__wcpcpy): Rewrite using wcslen, wmemcpy, and
wmemset.

5 years agowcsmbs: optimize wcpcpy
Adhemerval Zanella [Tue, 5 Feb 2019 19:34:05 +0000 (17:34 -0200)]
wcsmbs: optimize wcpcpy

This patch rewrites wcpcpy using wcslen and wmemcpy.  This is
similar to the optimizatio done on stpcpy by f559d8cf29.

Checked on x86_64-linux-gnu and string tests on a simulated
m68k-linux-gnu.

* sysdeps/m68k/wcpcpy.c: Remove file.
* wcsmbs/wcpcpy.c (__wcpcpy): Rewrite using wcslen and wmemcpy.

5 years agoBreak further lines before not after operators.
Joseph Myers [Tue, 26 Feb 2019 15:01:50 +0000 (15:01 +0000)]
Break further lines before not after operators.

This patch continues the process of fixing coding style to break lines
before not after operators in accordance with the GNU Coding
Standards, fixing such issues in a non-exhaustive selection of sysdeps
files that had them.

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

* sysdeps/arm/sysdep.h (#if condition): Break lines before rather
than after operators.
* sysdeps/mach/hurd/fork.c (__fork): Likewise.
* sysdeps/mach/hurd/getcwd.c
(__hurd_canonicalize_directory_name_internal): Likewise.
* sysdeps/mach/hurd/htl/pt-mutex-consistent.c
(pthread_mutex_consistent): Likewise.
* sysdeps/mach/hurd/htl/pt-mutex-init.c (_pthread_mutex_init):
Likewise.
* sysdeps/mach/hurd/htl/pt-mutex-transfer-np.c
(__pthread_mutex_transfer_np): Likewise.
* sysdeps/mach/hurd/htl/pt-mutex-unlock.c
(__pthread_mutex_unlock): Likewise.
* sysdeps/mach/hurd/htl/pt-mutex.h (ROBUST_LOCK): Likewise.
(mtx_owned_p): Likewise.
* sysdeps/mach/hurd/htl/pt-mutexattr-getrobust.c
(pthread_mutexattr_getrobust): Likewise.
* sysdeps/mach/hurd/i386/init-first.c (init1): Likewise.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Likewise.
* sysdeps/mach/hurd/ioctl.c (__ioctl): Likewise.
* sysdeps/mach/hurd/jmp-unwind.c (_longjmp_unwind): Likewise.
* sysdeps/mach/hurd/kill.c (__kill): Likewise.
* sysdeps/mach/hurd/mig-reply.c (__mig_get_reply_port): Likewise.
* sysdeps/mach/hurd/ptrace.c (ptrace): Likewise.
* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela): Likewise.
* sysdeps/unix/sysv/linux/aarch64/sysdep.h (#if condition):
Likewise.
* sysdeps/unix/sysv/linux/alpha/ioperm.c (process_cpuinfo):
Likewise.
* sysdeps/unix/sysv/linux/bits/timex.h (STA_RONLY): Likewise.
* sysdeps/unix/sysv/linux/csky/sysdep.h (#if condition): Likewise.
* sysdeps/unix/sysv/linux/generic/____longjmp_chk.c
(____longjmp_chk): Likewise.
* sysdeps/unix/sysv/linux/generic/futimesat.c (futimesat):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
(INTERNAL_SYSCALL): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
(INTERNAL_SYSCALL): Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/get_clockfreq.c
(__get_clockfreq_via_cpuinfo): Likewise.

5 years agoAdd and move fall-through comments in system-specific code.
Joseph Myers [Tue, 26 Feb 2019 02:09:18 +0000 (02:09 +0000)]
Add and move fall-through comments in system-specific code.

This patch fixes -Wimplicit-fallthrough warnings in system-specific
code that show up building glibc with -Wextra, by adding fall-through
comments, or moving existing such comments to the place required for
them to work (immediately before the case label being fallen through).

Tested with build-many-glibcs.py.

* sysdeps/i386/dl-machine.h (elf_machine_rela): Add fall-through
comments.
* sysdeps/m68k/m680x0/fpu/s_cexp_template.c (s(__cexp)): Likewise.
* sysdeps/m68k/memcopy.h (WORD_COPY_FWD): Likewise.
(WORD_COPY_BWD): Likewise.
* sysdeps/mach/hurd/ioctl.c (__ioctl): Likewise.
* sysdeps/powerpc/powerpc64/dl-machine.h (elf_machine_rela):
Likewise.
* sysdeps/s390/iso-8859-1_cp037_z900.c (TR_LOOP): Likewise.
* sysdeps/mips/dl-machine.h (elf_machine_reloc): Move fall-through
comment.
* sysdeps/mips/dl-trampoline.c (__dl_runtime_resolve): Likewise.

5 years agoBreak more lines before not after operators.
Joseph Myers [Mon, 25 Feb 2019 13:19:19 +0000 (13:19 +0000)]
Break more lines before not after operators.

This patch makes further coding style fixes where code was breaking
lines after an operator, contrary to the GNU Coding Standards.  As
with the previous patch, it is limited to files following a reasonable
approximation to GNU style already, and is not exhaustive; more such
issues remain to be fixed.

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

* dirent/dirent.h [!_DIRENT_HAVE_D_NAMLEN
&& _DIRENT_HAVE_D_RECLEN] (_D_ALLOC_NAMLEN): Break lines before
rather than after operators.
* elf/cache.c (print_cache): Likewise.
* gshadow/fgetsgent_r.c (__fgetsgent_r): Likewise.
* htl/pt-getattr.c (__pthread_getattr_np): Likewise.
* hurd/hurdinit.c (_hurd_setproc): Likewise.
* hurd/hurdkill.c (_hurd_sig_post): Likewise.
* hurd/hurdlookup.c (__file_name_lookup_under): Likewise.
* hurd/hurdsig.c (_hurd_internal_post_signal): Likewise.
(reauth_proc): Likewise.
* hurd/lookup-at.c (__file_name_lookup_at): Likewise.
(__file_name_split_at): Likewise.
(__directory_name_split_at): Likewise.
* hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Likewise.
* hurd/port2fd.c (_hurd_port2fd): Likewise.
* iconv/gconv_dl.c (do_print): Likewise.
* inet/netinet/in.h (struct sockaddr_in): Likewise.
* libio/wstrops.c (_IO_wstr_seekoff): Likewise.
* locale/setlocale.c (new_composite_name): Likewise.
* malloc/memusagestat.c (main): Likewise.
* misc/fstab.c (fstab_convert): Likewise.
* nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock_usercnt):
Likewise.
* nss/nss_compat/compat-grp.c (getgrent_next_nss): Likewise.
(getgrent_next_file): Likewise.
(internal_getgrnam_r): Likewise.
(internal_getgrgid_r): Likewise.
* nss/nss_compat/compat-initgroups.c (getgrent_next_nss):
Likewise.
(internal_getgrent_r): Likewise.
* nss/nss_compat/compat-pwd.c (getpwent_next_nss_netgr): Likewise.
(getpwent_next_nss): Likewise.
(getpwent_next_file): Likewise.
(internal_getpwnam_r): Likewise.
(internal_getpwuid_r): Likewise.
* nss/nss_compat/compat-spwd.c (getspent_next_nss_netgr):
Likewise.
(getspent_next_nss): Likewise.
(internal_getspnam_r): Likewise.
* pwd/fgetpwent_r.c (__fgetpwent_r): Likewise.
* shadow/fgetspent_r.c (__fgetspent_r): Likewise.
* string/strchr.c (STRCHR): Likewise.
* string/strchrnul.c (STRCHRNUL): Likewise.
* sysdeps/aarch64/fpu/fpu_control.h (_FPU_FPCR_IEEE): Likewise.
* sysdeps/aarch64/sfp-machine.h (_FP_CHOOSENAN): Likewise.
* sysdeps/csky/dl-machine.h (elf_machine_rela): Likewise.
* sysdeps/generic/memcopy.h (PAGE_COPY_FWD_MAYBE): Likewise.
* sysdeps/generic/symbol-hacks.h (__stack_chk_fail_local):
Likewise.
* sysdeps/gnu/netinet/ip_icmp.h (ICMP_INFOTYPE): Likewise.
* sysdeps/gnu/updwtmp.c (TRANSFORM_UTMP_FILE_NAME): Likewise.
* sysdeps/gnu/utmp_file.c (TRANSFORM_UTMP_FILE_NAME): Likewise.
* sysdeps/hppa/jmpbuf-unwind.h (_JMPBUF_UNWINDS): Likewise.
* sysdeps/mach/hurd/bits/stat.h (S_ISPARE): Likewise.
* sysdeps/mach/hurd/dl-sysdep.c (_dl_sysdep_start): Likewise.
(open_file): Likewise.
* sysdeps/mach/hurd/htl/pt-mutexattr-setprotocol.c
(pthread_mutexattr_setprotocol): Likewise.
* sysdeps/mach/hurd/ioctl.c (__ioctl): Likewise.
* sysdeps/mach/hurd/mmap.c (__mmap): Likewise.
* sysdeps/mach/hurd/ptrace.c (ptrace): Likewise.
* sysdeps/mach/hurd/spawni.c (__spawni): Likewise.
* sysdeps/microblaze/dl-machine.h (elf_machine_type_class):
Likewise.
(elf_machine_rela): Likewise.
* sysdeps/mips/mips32/sfp-machine.h (_FP_CHOOSENAN): Likewise.
* sysdeps/mips/mips64/sfp-machine.h (_FP_CHOOSENAN): Likewise.
* sysdeps/mips/sys/asm.h (multiple #if conditionals): Likewise.
* sysdeps/posix/rename.c (rename): Likewise.
* sysdeps/powerpc/novmx-sigjmp.c (__novmx__sigjmp_save): Likewise.
* sysdeps/powerpc/sigjmp.c (__vmx__sigjmp_save): Likewise.
* sysdeps/s390/fpu/fenv_libc.h (FPC_VALID_MASK): Likewise.
* sysdeps/s390/utf8-utf16-z9.c (gconv_end): Likewise.
* sysdeps/unix/grantpt.c (grantpt): Likewise.
* sysdeps/unix/sysv/linux/a.out.h (N_TXTOFF): Likewise.
* sysdeps/unix/sysv/linux/updwtmp.c (TRANSFORM_UTMP_FILE_NAME):
Likewise.
* sysdeps/unix/sysv/linux/utmp_file.c (TRANSFORM_UTMP_FILE_NAME):
Likewise.
* sysdeps/x86/cpu-features.c (get_common_indices): Likewise.
* time/tzfile.c (__tzfile_compute): Likewise.

5 years agoBreak some lines before not after operators.
Joseph Myers [Fri, 22 Feb 2019 01:32:36 +0000 (01:32 +0000)]
Break some lines before not after operators.

The GNU Coding Standards specify that line breaks in expressions
should go before an operator, not after one.  This patch fixes various
code to do this.  It only changes code that appears to be mostly
following GNU style anyway, not files and directories with
substantially different formatting.  It is not exhaustive even for
files using GNU style (for example, changes to sysdeps files are
deferred for subsequent cleanups).  Some files changed are shared with
gnulib, but most are specific to glibc.  Changes were made manually,
with places to change found by grep (so some cases, e.g. where the
operator was followed by a comment at end of line, are particularly
liable to have been missed by grep, but I did include cases where the
operator was followed by backslash-newline).

This patch generally does not attempt to address other coding style
issues in the expressions changed (for example, missing spaces before
'(', or lack of parentheses to ensure indentation of continuation
lines properly reflects operator precedence).

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

* benchtests/bench-memmem.c (simple_memmem): Break lines before
rather than after operators.
* benchtests/bench-skeleton.c (TIMESPEC_AFTER): Likewise.
* crypt/md5.c (md5_finish_ctx): Likewise.
* crypt/sha256.c (__sha256_finish_ctx): Likewise.
* crypt/sha512.c (__sha512_finish_ctx): Likewise.
* elf/cache.c (load_aux_cache): Likewise.
* elf/dl-load.c (open_verify): Likewise.
* elf/get-dynamic-info.h (elf_get_dynamic_info): Likewise.
* elf/readelflib.c (process_elf_file): Likewise.
* elf/rtld.c (dl_main): Likewise.
* elf/sprof.c (generate_call_graph): Likewise.
* hurd/ctty-input.c (_hurd_ctty_input): Likewise.
* hurd/ctty-output.c (_hurd_ctty_output): Likewise.
* hurd/dtable.c (reauth_dtable): Likewise.
* hurd/getdport.c (__getdport): Likewise.
* hurd/hurd/signal.h (_hurd_interrupted_rpc_timeout): Likewise.
* hurd/hurd/sigpreempt.h (HURD_PREEMPT_SIGNAL_P): Likewise.
* hurd/hurdfault.c (_hurdsig_fault_catch_exception_raise):
Likewise.
* hurd/hurdioctl.c (fioctl): Likewise.
* hurd/hurdselect.c (_hurd_select): Likewise.
* hurd/hurdsig.c (_hurdsig_abort_rpcs): Likewise.
(STOPSIGS): Likewise.
* hurd/hurdstartup.c (_hurd_startup): Likewise.
* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Likewise.
* hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Likewise.
* hurd/msgportdemux.c (msgport_server): Likewise.
* hurd/setauth.c (_hurd_setauth): Likewise.
* include/features.h (__GLIBC_USE_DEPRECATED_SCANF): Likewise.
* libio/libioP.h [IO_DEBUG] (CHECK_FILE): Likewise.
* locale/programs/ld-ctype.c (set_class_defaults): Likewise.
* localedata/tests-mbwc/tst_swscanf.c (tst_swscanf): Likewise.
* login/tst-utmp.c (do_check): Likewise.
(simulate_login): Likewise.
* mach/lowlevellock.h (lll_lock): Likewise.
(lll_trylock): Likewise.
* math/test-fenv.c (ALL_EXC): Likewise.
* math/test-fenvinline.c (ALL_EXC): Likewise.
* misc/sys/cdefs.h (__attribute_deprecated_msg__): Likewise.
* nis/nis_call.c (__do_niscall3): Likewise.
* nis/nis_callback.c (cb_prog_1): Likewise.
* nis/nis_defaults.c (searchaccess): Likewise.
* nis/nis_findserv.c (__nis_findfastest_with_timeout): Likewise.
* nis/nis_ismember.c (internal_ismember): Likewise.
* nis/nis_local_names.c (nis_local_principal): Likewise.
* nis/nss_nis/nis-rpc.c (_nss_nis_getrpcbyname_r): Likewise.
* nis/nss_nisplus/nisplus-netgrp.c (_nss_nisplus_getnetgrent_r):
Likewise.
* nis/ypclnt.c (yp_match): Likewise.
(yp_first): Likewise.
(yp_next): Likewise.
(yp_master): Likewise.
(yp_order): Likewise.
* nscd/hstcache.c (cache_addhst): Likewise.
* nscd/initgrcache.c (addinitgroupsX): Likewise.
* nss/nss_compat/compat-pwd.c (copy_pwd_changes): Likewise.
(internal_getpwuid_r): Likewise.
* nss/nss_compat/compat-spwd.c (copy_spwd_changes): Likewise.
* posix/glob.h (__GLOB_FLAGS): Likewise.
* posix/regcomp.c (peek_token): Likewise.
(peek_token_bracket): Likewise.
(parse_expression): Likewise.
* posix/regexec.c (sift_states_iter_mb): Likewise.
(check_node_accept_bytes): Likewise.
* posix/tst-spawn3.c (do_test): Likewise.
* posix/wordexp-test.c (testit): Likewise.
* posix/wordexp.c (parse_tilde): Likewise.
(exec_comm): Likewise.
* posix/wordexp.h (__WRDE_FLAGS): Likewise.
* resource/vtimes.c (TIMEVAL_TO_VTIMES): Likewise.
* setjmp/sigjmp.c (__sigjmp_save): Likewise.
* stdio-common/printf_fp.c (__printf_fp_l): Likewise.
* stdio-common/tst-fileno.c (do_test): Likewise.
* stdio-common/vfprintf-internal.c (vfprintf): Likewise.
* stdlib/strfmon_l.c (__vstrfmon_l_internal): Likewise.
* stdlib/strtod_l.c (round_and_return): Likewise.
(____STRTOF_INTERNAL): Likewise.
* stdlib/tst-strfrom.h (TEST_STRFROM): Likewise.
* string/strcspn.c (STRCSPN): Likewise.
* string/test-memmem.c (simple_memmem): Likewise.
* termios/tcsetattr.c (tcsetattr): Likewise.
* time/alt_digit.c (_nl_parse_alt_digit): Likewise.
* time/asctime.c (asctime_internal): Likewise.
* time/strptime_l.c (__strptime_internal): Likewise.
* time/sys/time.h (timercmp): Likewise.
* time/tzfile.c (__tzfile_compute): Likewise.

5 years agonss: tst-nss-files-hosts-long: Add host.conf [BZ #21915]
Patsy Franklin [Wed, 20 Feb 2019 22:07:19 +0000 (17:07 -0500)]
nss: tst-nss-files-hosts-long: Add host.conf [BZ #21915]

Add /etc/host.conf file with 'multi on' to tst-nss-files-hosts-long.root.
Ensures the entire file, and all long lines, need to be parsed for the
test.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoAdd internal implementations for argp.h, err.h, and error.h functions
Gabriel F. T. Gomes [Wed, 6 Jun 2018 14:48:49 +0000 (11:48 -0300)]
Add internal implementations for argp.h, err.h, and error.h functions

Since the introduction of explicit flags in the internal implementation
of the printf family of functions, the 'mode' parameter can be used to
select which format long double parameters have (with the mode flag:
PRINTF_LDBL_IS_DBL).  This patch uses this feature in the implementation
of some functions in argp.h, err.h, and error.h (only those that take a
format string and positional parameters).  Future patches will add
support for 'nldbl' and 'ieee128' versions of these functions.

Tested for powerpc64le and x86_64.

5 years agoAdd new Fortran vector math header file.
marxin [Wed, 20 Feb 2019 13:54:35 +0000 (14:54 +0100)]
Add new Fortran vector math header file.

5 years agopowerpc64le: Remove test for GCC 6.2
Gabriel F. T. Gomes [Mon, 4 Feb 2019 10:44:35 +0000 (08:44 -0200)]
powerpc64le: Remove test for GCC 6.2

The configure fragment for powerpc64le contains a test for the presence
of several compiler builtins and of the __float128 type, which are
provided by GCC 6.2 for powerpc64le.  Since this configure test was
added, the compiler version required to build glibc for powerpc64le was
different than that required for the other architectures.

Now that glibc requires GCC 6.2 globally (since commit ID 4dcbbc3b28aa),
this patch removes the powerpc64le-specific test.

Even tough the configure test checks for compiler features rather than
compiler version, the intent of the test was to stop build attempts at
early stages, if they had been configured with a too old compiler.  It
was not the intention of the test to detect compiler breakage (such as
the removal of the required compiler features in future GCC versions),
and glibc is not the place to test for compiler regressions, anyway.

Tested for powerpc64le with GCC 6.2 (built with build-many-glibcs.py).

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
5 years agonptl: Fix comment typo in pthread_mutex_trylock.c
Wolfram Sang [Tue, 19 Feb 2019 15:59:31 +0000 (10:59 -0500)]
nptl: Fix comment typo in pthread_mutex_trylock.c

5 years agonptl: Fix pthread_tryjoin comment.
Carlos O'Donell [Mon, 11 Feb 2019 21:02:56 +0000 (16:02 -0500)]
nptl: Fix pthread_tryjoin comment.

In pthread_tryjoin if pd->tid == 0 then we will not block on a
futex operation because we will immediately see the join is already
complete and return. The comment is fixed to reflect that.

Signed-off-by: Carlos O'Donell <carlos@redhat.com>
5 years agoFix SPARC64 handling of R_SPARC_H34 (bug 24231).
Joseph Myers [Mon, 18 Feb 2019 22:33:29 +0000 (22:33 +0000)]
Fix SPARC64 handling of R_SPARC_H34 (bug 24231).

Building glibc with -Wextra shows a -Wimplicit-fallthrough warning for
SPARC64 that appears to be a real bug in glibc.  The dynamic linker
handling of R_SPARC_H34 falls through to that of R_SPARC_H44, which in
the case of this code is nonsensical (it means the value computed for
R_SPARC_H34 gets overwritten by one computed with the different logic
for R_SPARC_H44).  Thus, this patch adds the missing break there.
Note: I do not have a testcase to demonstrate this bug.

Tested with build-many-glibcs.py.

[BZ #24231]
* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela): Add break
after R_SPARC_H34 case.

5 years agoresolv: Remove debugging code from compat-gethnamaddr.c
Florian Weimer [Mon, 18 Feb 2019 12:42:00 +0000 (13:42 +0100)]
resolv: Remove debugging code from compat-gethnamaddr.c

5 years agolibio: Eliminate _IO_stdin, _IO_stdout, _IO_stderr
Florian Weimer [Mon, 18 Feb 2019 10:49:54 +0000 (11:49 +0100)]
libio: Eliminate _IO_stdin, _IO_stdout, _IO_stderr

These variables are only used to determine if a stdio stream is
a pre-allocated stream, but it is possible to do so by comparing
a FILE * to all pre-allocated stream objects.  As a result, it is
not necessary to keep those pointers in separate variables.

Behavior with symbol interposition is unchanged because _IO_stdin_,
_IO_stdout_, _IO_stderr_ are exported, and refer to objects outside of
libc if symbol interposition or copy relocations are involved.  (The
removed variables _IO_stdin, _IO_stdout, _IO_stderr were not exported,
of course.)

5 years agomisc/tst-clone3: Fix waiting for exited thread.
Stefan Liebler [Mon, 18 Feb 2019 15:12:01 +0000 (16:12 +0100)]
misc/tst-clone3: Fix waiting for exited thread.

From time to time the test misc/tst-clone3 fails with a timeout.
Then futex_wait is blocking.  Usually ctid should be set to zero
due to CLONE_CHILD_CLEARTID and the futex should be waken up.
But the fail occures if the thread has already exited before
ctid is set to the return value of clone().  Then futex_wait() will
block as there will be nobody who wakes the futex up again.

This patch initializes ctid to a known value before calling clone
and the kernel is the only one who updates the value to zero after clone.
If futex_wait is called then it is either waked up due to the exited thread
or the futex syscall fails as *ctid_ptr is already zero instead of the
specified value 1.

ChangeLog:

* sysdeps/unix/sysv/linux/tst-clone3.c (do_test):
Initialize ctid with a known value and remove update of ctid
after clone.
(wait_tid): Adjust arguments and call futex_wait with ctid_val
as assumed current value of ctid_ptr.

5 years agoAdd check for missing wrapper headers
Florian Weimer [Fri, 15 Feb 2019 20:51:58 +0000 (21:51 +0100)]
Add check for missing wrapper headers

If building on a subset of architectures only, it is easy to miss
wrapper headers which are required by other architectures because
they lack the corresponding sysdeps header.  The check ensures
that every installed header which is not itself a sysdeps header
has a header under include/ (that presumably wraps the header,
and perhaps also adding declarations and definitions for !_ISOMAC).

Also check for the absence of the sysdeps/generic/bits directory
removed in commit c72565e5f1124c2dc72573e83406fe999e56091f, to make
accidental re-introduction more difficult.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoAdd missing header wrappers under include/
Florian Weimer [Fri, 15 Feb 2019 20:51:35 +0000 (21:51 +0100)]
Add missing header wrappers under include/

With a complete set of wrapper headers, it will be possible to check
for automatically for new installed headers which lack such wrappers.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoMove remaining nptl_db headers to sysdeps/nptl
Florian Weimer [Fri, 15 Feb 2019 20:51:20 +0000 (21:51 +0100)]
Move remaining nptl_db headers to sysdeps/nptl

sys/procfs.h was already using this sysdeps directory.

This avoids the need for  nptl-specific wrapper headers under
include/, a generic location in the source tree.

5 years agoio: Consolidate lockf implementation
Adhemerval Zanella [Wed, 21 Nov 2018 11:41:05 +0000 (11:41 +0000)]
io: Consolidate lockf implementation

With internal fcntl64 internal (commit 06ab719d), it is possible to
consolidate lockf implementation by using the LFS fcntl interface
instead of using arch and system-specific implementations.

For Linux, the i386 implementation is used as generic implementation
by replacing the direct syscall with fcntl64 call.  The LFS symbol
alias for default LFS ABI (__OFF_T_MATCHES_OFF64_T) is used to avoid
the duplicate symbol (instead of overriding the implementation with an
empty file).

For Hurd lockf64 semantic is changed: previous generic lockf64
implementation returned EOVERFLOW if LEN input is larger than 32-bit
off_t.  However, Hurd fcntl64 implementation for F_GETLK64, F_SETLK64,
and F_SETLKW64 do accept off64_t inputs (__f_setlk accepts only off64_t
inputs).

Checked on i686-linux-gnu and x86_64-linux-gnu along with a i686-gnu
build.

* io/Makefile (tests): Add tst-lockf.
* io/lockf.c (lockf): Use __fcntl and only define for
!__OFF_T_MATCHES_OFF64_T.
* io/lockf64.c (__lockf64): Call __fcntl64 and alias to lockf for
__OFF_T_MATCHES_OFF64_T case.
* io/tst-lockf.c: New file.
* sysdeps/unix/sysv/linux/i386/lockf64.c: Remove file.
* sysdeps/unix/sysv/linux/arm/lockf64.c: Likewise.
* sysdeps/unix/sysv/linux/m68k/lockf64.c: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/lockf64.c: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n32/lockf64.c: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/lockf64.c: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/lockf64.c: Likewise.
* sysdeps/unix/sysv/linux/sh/lockf64.c: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/lockf64.c: Likewise.

5 years agonptl: Fix invalid Systemtap probe in pthread_join [BZ #24211]
Florian Weimer [Fri, 15 Feb 2019 18:09:00 +0000 (19:09 +0100)]
nptl: Fix invalid Systemtap probe in pthread_join [BZ #24211]

After commit f1ac7455831546e5dca0ed98fe8af2686fae7ce6 ("arm: Use "nr"
constraint for Systemtap probes [BZ #24164]"), we load pd->result into
a register in the probe below:

      /* Free the TCB.  */
      __free_tcb (pd);
    }
  else
    pd->joinid = NULL;

  LIBC_PROBE (pthread_join_ret, 3, threadid, result, pd->result);

However, at this point, the thread descriptor has been freed.  If the
thread stack does not fit into the thread stack cache, the memory will
have been unmapped, and the program will crash in the probe.

5 years agoRemove qualifier from function return type in tst-svc_register.c.
Joseph Myers [Fri, 15 Feb 2019 13:45:19 +0000 (13:45 +0000)]
Remove qualifier from function return type in tst-svc_register.c.

Building the testsuite with -Wextra produces a warning in
sunrpc/tst-svc_register.c for a useless qualifier on a function return
type.  This patch removes that qualifier.

Tested for x86_64.

* sunrpc/tst-svc_register.c (rpcbind_address): Remove qualifier
from function return type.

5 years agoFix implicit-fallthrough warnings in tst-setjmp.c.
Joseph Myers [Fri, 15 Feb 2019 13:44:17 +0000 (13:44 +0000)]
Fix implicit-fallthrough warnings in tst-setjmp.c.

Building the testsuite with -Wextra (together with
-Wno-cast-function-type -Wno-clobbered -Wno-expansion-to-defined
-Wno-missing-field-initializers -Wno-old-style-declaration
-Wno-shift-negative-value -Wno-sign-compare -Wno-type-limits
-Wno-unused-parameter, which reflect the set of -Wextra warnings for
which glibc itself is not currently clean on x86_64) showed up
implicit-fallthrough warnings in tst-setjmp.c.  Those warnings appear
to be false positives, arising from a function "jump" that calls
longjmp not itself being marked as noreturn; thus, this patch adds the
noreturn marking to that function to fix the warnings.

Tested for x86_64.

* setjmp/tst-setjmp.c (jump): Use __attribute__ ((__noreturn__)).

5 years agoAvoid readline conflicts in pexpect
Jan Kratochvil [Fri, 8 Feb 2019 18:49:19 +0000 (13:49 -0500)]
Avoid readline conflicts in pexpect

In some cases, sensitive to readline version and the user's
environment, gdb might emit escape codes while run under python's
pexpect (i.e. testing pretty printers).  This patch, suggested
by Jan, helps isolate the test from the user's environment.

Tested on RHEL 7 x86_64 with DTS 7 and EPEL, which is one
magic combination of components that triggers this bug.

5 years agoFix fall-through warnings in sunrpc/xdr.c.
Joseph Myers [Thu, 14 Feb 2019 20:35:16 +0000 (20:35 +0000)]
Fix fall-through warnings in sunrpc/xdr.c.

This patch fixes implicit-fallthrough warnings in sunrpc/xdr.c when
building with -Wextra.  A fall-through comment is added in three
places; in two other places, an existing comment is reworded so it
matches the default patterns used by -Wimplicit-fallthrough.

Tested for x86_64.

* sunrpc/xdr.c (xdr_int): Add fall-through comment.
(xdr_u_int): Likewise.
(xdr_enum): Likewise.
(xdr_bytes): Reword fall-through comment.
(xdr_string): Likewise.

5 years agonptl: Reinstate pthread_timedjoin_np as a cancellation point (BZ#24215)
Adhemerval Zanella [Tue, 12 Feb 2019 14:36:46 +0000 (12:36 -0200)]
nptl: Reinstate pthread_timedjoin_np as a cancellation point (BZ#24215)

Patch ce7eb0e90315 ("nptl: Cleanup cancellation macros") changed the
join sequence for internal common __pthread_timedjoin_ex to use the
new macro lll_wait_tid.  The idea was this macro would issue the
cancellable futex operation depending whether the timeout is used or
not.  However if a timeout is used, __lll_timedwait_tid is called and
it is not a cancellable entrypoint.

This patch fixes it by simplifying the code in various ways:

  - Instead of adding the cancellation handling on __lll_timedwait_tid,
    it moves the generic implementation to pthread_join_common.c (called
    now timedwait_tid with some fixes to use the correct type for pid).

  - The llvm_wait_tid macro is removed, along with its replication on
    x86_64, i686, and sparc arch-specific lowlevellock.h.

  - sparc32 __lll_timedwait_tid is also removed, since the code is similar
    to generic one.

  - x86_64 and i386 provides arch-specific __lll_timedwait_tid which is
    also removed since they are similar in functionality to generic C code
    and there is no indication it is better than compiler generated code.

New tests, tst-join8 and tst-join9, are provided to check if
pthread_timedjoin_np acts as a cancellation point.

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

[BZ #24215]
* nptl/Makefile (lpthread-routines): Remove lll_timedwait_tid.
(tests): Add tst-join8 tst-join9.
* nptl/lll_timedwait_tid.c: Remove file.
* sysdeps/sparc/sparc32/lll_timedwait_tid.c: Likewise.
* sysdeps/unix/sysv/linux/i386/lll_timedwait_tid.c: Likewise.
* sysdeps/sysv/linux/x86_64/lll_timedwait_tid.c: Likewise.
* nptl/pthread_join_common.c (timedwait_tid): New function.
(__pthread_timedjoin_ex): Act as cancellation entrypoint is block
is set.
* nptl/tst-join5.c (thread_join): New function.
(tf1, tf2, do_test): Use libsupport and add pthread_timedjoin_np
check.
* nptl/tst-join8.c: New file.
* nptl/tst-join9.c: Likewise.
* sysdeps/nptl/lowlevellock-futex.h (lll_futex_wait_cancel,
lll_futex_timed_wait_cancel): Add generic macros.
* sysdeps/nptl/lowlevellock.h (__lll_timedwait_tid, lll_wait_tid):
Remove definitions.
* sysdeps/unix/sysv/linux/i386/lowlevellock.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/lowlevellock.h: Likewise.
* sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Likewise.
* sysdeps/sparc/sparc32/lowlevellock.c (__lll_timedwait_tid):
Remove function.
* sysdeps/unix/sysv/linux/i386/lowlevellock.S (__lll_timedwait_tid):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Likewise.
* sysdeps/unix/sysv/linux/lowlevellock-futex.h
(lll_futex_timed_wait_cancel): New macro.

5 years agoAdd missing bench-malloc-simple.c file.
Wilco Dijkstra [Thu, 14 Feb 2019 17:10:47 +0000 (17:10 +0000)]
Add missing bench-malloc-simple.c file.

5 years agoAdd malloc micro benchmark
Wilco Dijkstra [Thu, 14 Feb 2019 16:37:11 +0000 (16:37 +0000)]
Add malloc micro benchmark

Add a malloc micro benchmark to enable accurate testing of the
various paths in malloc and free.  The benchmark does a varying
number of allocations of a given block size, then frees them again.

It tests 3 different scenarios: single-threaded using main arena,
multi-threaded using thread-arena, main arena with SINGLE_THREAD_P
false.

* benchtests/Makefile: Add malloc-simple benchmark.
* benchtests/bench-malloc-simple.c: New benchmark.

5 years agobenchtests: Remove useless ORIG_SRC in memmove benchmarks
Siddhesh Poyarekar [Thu, 14 Feb 2019 02:52:34 +0000 (08:22 +0530)]
benchtests: Remove useless ORIG_SRC in memmove benchmarks

The ORIG_SRC argument is likely a useless relic from the original
correctness tests that are not needed in the benchmarks.  Remove the
argument and use S1 to point to the source to avoid confusion.

        * benchtests/bench-memmove.c (do_one_test): Remove unused
        ORIG_SRC.
        (do_test): Adjust.
        * benchtests/bench-memmove-large.c (do_one_test): Remove unused
        ORIG_SRC.
        (do_test): Adjust.

5 years agoRISC-V: Fix elfutils testsuite unwind failures.
Jim Wilson [Sun, 13 Jan 2019 23:48:09 +0000 (15:48 -0800)]
RISC-V: Fix elfutils testsuite unwind failures.

The clone.S patch fixes 2 elfutils testsuite unwind failures, where the
backtrace gets stuck repeating __thread_start until we hit the backtrace
limit.  This was confirmed by building and installing a patched glibc and
then building elfutils and running its testsuite.

Unfortunately, the testcase isn't working as expected and I don't know why.
The testcase passes even when my clone.S patch is not installed.  The testcase
looks logically similarly to the elfutils testcases that are failing.  Maybe
there is a subtle difference in how the glibc unwinding works versus the
elfutils unwinding?  I don't have good gdb pthread support yet, so I haven't
found a way to debug this.  Anyways, I don't know if the testcase is useful or
not.  If the testcase isn't useful then maybe the clone.S patch is OK without
a testcase?

Jim

[BZ #24040]
* elf/Makefile (CFLAGS-tst-unwind-main.c): Add -DUSE_PTHREADS=0.
* elf/tst-unwind-main.c: If USE_PTHEADS, include pthread.h and error.h
(func): New.
(main): If USE_PTHREADS, call pthread_create to run func.  Otherwise
call func directly.
* nptl/Makefile (tests): Add tst-unwind-thread.
(CFLAGS-tst-unwind-thread.c): Define.
* nptl/tst-unwind-thread.c: New file.
* sysdeps/unix/sysv/linux/riscv/clone.S (__thread_start): Mark ra
as undefined.

5 years agoAdjust wording of two fall-through comments.
Joseph Myers [Wed, 13 Feb 2019 18:37:54 +0000 (18:37 +0000)]
Adjust wording of two fall-through comments.

In two places in glibc, -Wextra produces implicit-fallthrough warnings
where there are comments about the fall-through but their wording
doesn't match one of the forms expected by the default
implicit-fallthrough level.  This patch adjusts those two places to
have a comment in a form that is accepted, so avoiding the warning
(this seems preferable to only being able to use a looser level of the
warning that allows any comment at all as evidence of deliberate
fall-through).

Tested for x86_64.

* iconvdata/cns11643.h (ucs4_to_cns11643): Adjust fall-through
comment wording.
* nis/nis_call.c (__do_niscall3): Likewise.

5 years agoFix -Wempty-body warnings in glibc.
Joseph Myers [Wed, 13 Feb 2019 13:50:13 +0000 (13:50 +0000)]
Fix -Wempty-body warnings in glibc.

One group of warnings seen building glibc with -Wextra is -Wempty-body
warnings about an 'if' body (or in one case an 'else' body) that is
just a semicolon, "warning: suggest braces around empty body in an
'if' statement [-Wempty-body]" - I think the point of the warning
being to make it more visible whether an 'if' body is actually present
or not.

This patch fixes such warnings in glibc.  There's one place, with a
semicolon at the end of a comment, where this is clearly making the
presence of an 'else' body more visible.  The other cases involve
macro definitions expanding to nothing.  While there's no issue there
with visibility at the call sites, I think it's still cleaner to have
a macro that expands to something nonempty appropriate for the context
- so do {} while (0) if it's only intended to be usable as a
statement, or ((void) 0) where the macro definition is an alternative
to a call to a function returning void, so this patch makes those
changes.

Tested for x86_64.

* catgets/gencat.c (normalize_line): Use braces around empty
'else' body.
* include/stap-probe.h [!USE_STAP_PROBE && !__ASSEMBLER__]
(STAP_PROBE0): Use do {} while (0) for do-nothing definition.
[!USE_STAP_PROBE && !__ASSEMBLER__] (STAP_PROBE1): Likewise.
[!USE_STAP_PROBE && !__ASSEMBLER__] (STAP_PROBE2): Likewise.
[!USE_STAP_PROBE && !__ASSEMBLER__] (STAP_PROBE3): Likewise.
[!USE_STAP_PROBE && !__ASSEMBLER__] (STAP_PROBE4): Likewise.
* libio/libio.h (_IO_funlockfile): Use ((void) 0) for do-nothing
definition.

5 years agoAvoid fall-through in test-container if execlp fails.
Joseph Myers [Wed, 13 Feb 2019 13:34:24 +0000 (13:34 +0000)]
Avoid fall-through in test-container if execlp fails.

One of the implicit-fallthrough warnings from compiling glibc with
-Wextra appears to indicate an actual bug: the test-container code
could fall through inappropriately if execlp returns (which only
occurs on error).  This patch adds appropriate error handling in this
case to avoid that fall-through.

Tested for x86_64.

* support/test-container.c (recursive_remove): Use FAIL_EXIT1 if
execlp returns.

5 years agoString benchtest cleanup
Wilco Dijkstra [Tue, 12 Feb 2019 17:19:51 +0000 (17:19 +0000)]
String benchtest cleanup

Continue cleanup of the string benchtests.  Remove simplistic
byte-oriented versions with faster generic implementations.
Remove bcopy/bzero benchmarks (bcopy/bzero are obsolete and never
emitted by compilers).  Remove builtin versions of memcpy, memset
and strlen.  Remove all remaining "stupid" implementations given
they are always slower than the "simple" variants and thus don't
add anything useful.

* benchtests/bench-strcasecmp.c (stupid_strcasecmp): Remove.
* benchtests/bench-strcasestr.c (stupid_strcasestr): Remove.
* benchtests/bench-strchr.c (stupid_strchr): Remove.
* benchtests/bench-strcmp.c (stupid_strcmp): Remove.
* benchtests/bench-strcspn.c (stupid_strcspn): Remove.
* benchtests/bench-strlen.c (builtin_strlen): Remove.
* benchtests/bench-strncasecmp.c (stupid_strncasecmp): Remove.
* benchtests/bench-strncmp.c (stupid_strncmp): Remove.
* benchtests/bench-strpbrk.c (stupid_strpbrk): Remove.
* benchtests/bench-strspn.c (stupid_strspn): Remove.
* benchtests/Makefile: Remove bench-bcopy.c and bench-bzero.c.
* benchtests/bench-bcopy.c: Delete file.
* benchtests/bench-bzero.c: Likewise.
* benchtests/bench-memccpy.c (stupid_memccpy): Remove.
(simple_memccpy): Remove.
(generic_memccpy): Add function.
* benchtests/bench-memcpy.c: (builtin_memcpy): Remove.
* benchtests/bench-memmove.c (simple_bcopy): Remove.
* benchtests/bench-mempcpy.c (simple_mempcpy): Remove.
(generic_mempcpy): Add new function.
* benchtests/bench-memset.c (simple_bzero): Remove.
(builtin_bzero): Remove.
(builtin_memset): Remove.
* benchtests/bench-rawmemchr.c (simple_rawmemchr): Remove.
(generic_rawmemchr): Add new function.

5 years agonss: getent: Print IPv6 scope ID for ahosts/ahostsv6 if available
Florian Weimer [Tue, 12 Feb 2019 13:26:20 +0000 (14:26 +0100)]
nss: getent: Print IPv6 scope ID for ahosts/ahostsv6 if available

This information is sometimes useful and actually required for
link-local addresses.

5 years agoelf: Test for LD_AUDIT module returning zero from la_version [BZ #24122]
Adhemerval Zanella [Tue, 12 Feb 2019 12:51:43 +0000 (13:51 +0100)]
elf: Test for LD_AUDIT module returning zero from la_version [BZ #24122]

This includes the original test case from commit
8e889c5da3c5981c5a46a93fec02de40131ac5a6 ("elf: Fix LD_AUDIT for
modules with invalid version (BZ#24122)).

5 years agoelf: Ignore LD_AUDIT interfaces if la_version returns 0 [BZ #24122]
Florian Weimer [Tue, 12 Feb 2019 12:36:56 +0000 (13:36 +0100)]
elf: Ignore LD_AUDIT interfaces if la_version returns 0 [BZ #24122]

This change moves the audit module loading and early notification into
separate functions out of dl_main.

It restores the bug fix from commit
8e889c5da3c5981c5a46a93fec02de40131ac5a6  ("elf: Fix LD_AUDIT for
modules with invalid version (BZ#24122)") which was reverted in commit
83e6b59625f45db1eee93e5684091f740c52a083  ("[elf] Revert 8e889c5da3
(BZ#24122)").

The actual bug fix is the separate error message for the case when
la_version returns zero.  The dynamic linker error message (which is
NULL in this case) is no longer used.  Based on the intended use of
version zero (ignore this module due to explicit request), the message
is only printed if debugging is enabled.

5 years agoAdd fall-through comments.
Joseph Myers [Tue, 12 Feb 2019 10:30:34 +0000 (10:30 +0000)]
Add fall-through comments.

This patch adds fall-through comments in some cases where -Wextra
produces implicit-fallthrough warnings.

The patch is non-exhaustive.  Apart from architecture-specific code
for non-x86_64 architectures, it does not change sunrpc/xdr.c (legacy
code, probably should have such changes, but left to be dealt with
separately), or places that already had comments about the
fall-through but not matching the form expected by
-Wimplicit-fallthrough=3 (the default level with -Wextra; my
inclination is to adjust those comments to match rather than
downgrading to -Wimplicit-fallthrough=1 to allow any comment), or one
place where I thought the implicit fallthrough was not correct and so
should be handled separately as a bug fix.  I think the key thing to
consider in review of this patch is whether the fall-through is indeed
intended and correct in each place where such a comment is added.

Tested for x86_64.

* elf/dl-exception.c (_dl_exception_create_format): Add
fall-through comments.
* elf/ldconfig.c (parse_conf_include): Likewise.
* elf/rtld.c (print_statistics): Likewise.
* locale/programs/charmap.c (parse_charmap): Likewise.
* misc/mntent_r.c (__getmntent_r): Likewise.
* posix/wordexp.c (parse_arith): Likewise.
(parse_backtick): Likewise.
* resolv/ns_ttl.c (ns_parse_ttl): Likewise.
* sysdeps/x86/cpu-features.c (init_cpu_features): Likewise.
* sysdeps/x86_64/dl-machine.h (elf_machine_rela): Likewise.

5 years agoUse float in e_sqrt.c
Paul Clarke [Tue, 5 Feb 2019 01:16:50 +0000 (19:16 -0600)]
Use float in e_sqrt.c

The type used within e_sqrt.c(__slow_ieee754_sqrtf) was, unnecessarily and
likely inadvertently, double.  float is not only appropriate, but also
more efficient, avoiding the need for the compiler to emit a
round-to-single-precision instruction.

This is the difference in compiled code:
 0000000000000000 <__ieee754_sqrtf>:
    0:  2c 08 20 ec     fsqrts  f1,f1
-   4:  18 08 20 fc     frsp    f1,f1
-   8:  20 00 80 4e     blr
+   4:  20 00 80 4e     blr

(Found by Anton Blanchard.)

5 years agoFix a few whitespace arrangement inconsistencies in time/strftime_l.c
TAMUKI Shoichi [Mon, 11 Feb 2019 03:13:55 +0000 (12:13 +0900)]
Fix a few whitespace arrangement inconsistencies in time/strftime_l.c

Having checked the arrangement of whitespace in time/strftime_l.c
using "unexpand" and "unexpand -a" command, three inconsistencies are
detected.  So fix them for consistency.

ChangeLog:

* time/strftime_l.c: Fix a few whitespace arrangement inconsistencies.

5 years agoRemove powerpc bits/mathinline.h.
Joseph Myers [Fri, 8 Feb 2019 23:26:21 +0000 (23:26 +0000)]
Remove powerpc bits/mathinline.h.

Continuing the process of moving away from having bits/mathinline.h
headers in glibc, leaving the compiler to inline functions as
appropriate depending on the options passed to it, this patch removes
the header for powerpc.
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88558> is the
corresponding GCC bug for adding replacements for these powerpc
(32-bit-only) lrint / lrintf inlines.

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

* sysdeps/powerpc/bits/mathinline.h: Remove.

5 years agomath: Enable <bits/math-finite.h> sysdeps override
Florian Weimer [Fri, 8 Feb 2019 20:04:24 +0000 (21:04 +0100)]
math: Enable <bits/math-finite.h> sysdeps override

sysdeps/ia64/fpu/bits/math-finite.h exists and will be installed on
ia64, but during the build, the default math/bits/math-finite.h file
is used, which is wrong.

Fixes commit 0ac5ae2335292908f39031b1ea9fe8edce433c0f ("Optimize
libm").

5 years agoMove generic <bits/unistd_ext.h> to a more regular location
Florian Weimer [Fri, 8 Feb 2019 20:06:11 +0000 (21:06 +0100)]
Move generic <bits/unistd_ext.h> to a more regular location

No functional change; the previous path worked as well, but it
re-added the obsolete sysdeps/generic/bits directory, which was
removed (for the first time) in commit
c72565e5f1124c2dc72573e83406fe999e56091f.

Fixes commit e47d82c99a6db060419b421768aced76bea92997 ("Provide
<bits/unistd_ext.h> as a sysdeps header exclusively").

5 years agonss: Add tst-nss-files-hosts-long test [BZ #21915]
Patsy Franklin [Wed, 30 Jan 2019 23:49:27 +0000 (18:49 -0500)]
nss: Add tst-nss-files-hosts-long test [BZ #21915]

When the /etc/hosts file has a line longer than 1028
characters getent ahostsv4 and ahostsv6 will fail.

This test performs a getent call on a /etc/hosts file that contains
a very long line (greater than 1028) using the test-in-container
framework.

5 years agoProvide <bits/unistd_ext.h> as a sysdeps header exclusively
Florian Weimer [Fri, 8 Feb 2019 15:51:17 +0000 (16:51 +0100)]
Provide <bits/unistd_ext.h> as a sysdeps header exclusively

Non-sysdeps headers cannot be overriden by sysdeps headers across the
entire build, so it is necessary to turn such extension headers into
sysdeps headers themselves.  The approach here follows the existing
<bits/shm.h> header (although it uses sysdeps/gnu instead of
sysdeps/generic).

Fixes commit 1d0fc213824eaa2a8f8c4385daaa698ee8fb7c92 ("Linux: Add
gettid system call wrapper [BZ #6399]") and commit
8f89ab216f205c2ffd90d1fc8454efdfc0b01dee ("posix: Fix missing wrapper
header for <bits/unistd_ext.h>").

5 years agoposix: Fix missing wrapper header for <bits/unistd_ext.h>
Florian Weimer [Fri, 8 Feb 2019 15:33:00 +0000 (16:33 +0100)]
posix: Fix missing wrapper header for <bits/unistd_ext.h>

Fixes commit 1d0fc213824eaa2a8f8c4385daaa698ee8fb7c92
("Linux: Add gettid system call wrapper [BZ #6399]").

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agotst-strftime2: Use array_length macros instead of magic numbers
TAMUKI Shoichi [Fri, 8 Feb 2019 13:03:14 +0000 (22:03 +0900)]
tst-strftime2: Use array_length macros instead of magic numbers

ChangeLog:

* time/tst-strftime2.c: Use array_length macros instead of magic
numbers.

5 years agonptl: Avoid fork handler lock for async-signal-safe fork [BZ #24161]
Florian Weimer [Fri, 8 Feb 2019 11:46:19 +0000 (12:46 +0100)]
nptl: Avoid fork handler lock for async-signal-safe fork [BZ #24161]

Commit 27761a1042daf01987e7d79636d0c41511c6df3c ("Refactor atfork
handlers") introduced a lock, atfork_lock, around fork handler list
accesses.  It turns out that this lock occasionally results in
self-deadlocks in malloc/tst-mallocfork2:

(gdb) bt
#0  __lll_lock_wait_private ()
    at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:63
#1  0x00007f160c6f927a in __run_fork_handlers (who=(unknown: 209394016),
    who@entry=atfork_run_prepare) at register-atfork.c:116
#2  0x00007f160c6b7897 in __libc_fork () at ../sysdeps/nptl/fork.c:58
#3  0x00000000004027d6 in sigusr1_handler (signo=<optimized out>)
    at tst-mallocfork2.c:80
#4  sigusr1_handler (signo=<optimized out>) at tst-mallocfork2.c:64
#5  <signal handler called>
#6  0x00007f160c6f92e4 in __run_fork_handlers (who=who@entry=atfork_run_parent)
    at register-atfork.c:136
#7  0x00007f160c6b79a2 in __libc_fork () at ../sysdeps/nptl/fork.c:152
#8  0x0000000000402567 in do_test () at tst-mallocfork2.c:156
#9  0x0000000000402dd2 in support_test_main (argc=1, argv=0x7ffc81ef1ab0,
    config=config@entry=0x7ffc81ef1970) at support_test_main.c:350
#10 0x0000000000402362 in main (argc=<optimized out>, argv=<optimized out>)
    at ../support/test-driver.c:168

If no locking happens in the single-threaded case (where fork is
expected to be async-signal-safe), this deadlock is avoided.
(pthread_atfork is not required to be async-signal-safe, so a fork
call from a signal handler interrupting pthread_atfork is not
a problem.)

5 years agoChangeLog: Correct date of last commit
Florian Weimer [Fri, 8 Feb 2019 11:44:48 +0000 (12:44 +0100)]
ChangeLog: Correct date of last commit

5 years agoLinux: Add gettid system call wrapper [BZ #6399]
Florian Weimer [Sat, 2 Feb 2019 14:17:02 +0000 (15:17 +0100)]
Linux: Add gettid system call wrapper [BZ #6399]

This commit adds gettid to <unistd.h> on Linux, and not to the
kernel-independent GNU API.

gettid is now supportable on Linux because too many things assume a
1:1 mapping between libpthread threads and kernel threads.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agort: Turn forwards from librt to libc into compat symbols [BZ #24194]
Florian Weimer [Fri, 8 Feb 2019 09:21:56 +0000 (10:21 +0100)]
rt: Turn forwards from librt to libc into compat symbols [BZ #24194]

As the  result of commit 6e6249d0b461b952d0f544792372663feb6d792a
("BZ#14743: Move clock_* symbols from librt to libc."), in glibc 2.17,
clock_gettime, clock_getres, clock_settime, clock_getcpuclockid,
clock_nanosleep were added to libc, and the file rt/clock-compat.c
was added with forwarders to the actual implementations in libc.
These forwarders were wrapped in

#if SHLIB_COMPAT (librt, GLIBC_2_2, GLIBC_2_17)

so that they are not present for newer architectures (such as
powerpc64le) with a 2.17 or later ABI baseline.  But the forwarders
were not marked as compatibility symbols.  As a result, on older
architectures, historic configure checks such as

AC_CHECK_LIB(rt, clock_gettime)

still cause linking against librt, even though this is completely
unnecessary.  It also creates a needless porting hazard because
architectures behave differently when it comes to symbol availability.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoAdd compiler barriers around modifications of the robust mutex list for pthread_mutex...
Stefan Liebler [Thu, 7 Feb 2019 14:18:36 +0000 (15:18 +0100)]
Add compiler barriers around modifications of the robust mutex list for pthread_mutex_trylock. [BZ #24180]

While debugging a kernel warning, Thomas Gleixner, Sebastian Sewior and
Heiko Carstens found a bug in pthread_mutex_trylock due to misordered
instructions:
140:   a5 1b 00 01             oill    %r1,1
144:   e5 48 a0 f0 00 00       mvghi   240(%r10),0   <--- THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
14a:   e3 10 a0 e0 00 24       stg     %r1,224(%r10) <--- last THREAD_SETMEM of ENQUEUE_MUTEX_PI

vs (with compiler barriers):
140:   a5 1b 00 01             oill    %r1,1
144:   e3 10 a0 e0 00 24       stg     %r1,224(%r10)
14a:   e5 48 a0 f0 00 00       mvghi   240(%r10),0

Please have a look at the discussion:
"Re: WARN_ON_ONCE(!new_owner) within wake_futex_pi() triggerede"
(https://lore.kernel.org/lkml/20190202112006.GB3381@osiris/)

This patch is introducing the same compiler barriers and comments
for pthread_mutex_trylock as introduced for pthread_mutex_lock and
pthread_mutex_timedlock by commit 8f9450a0b7a9e78267e8ae1ab1000ebca08e473e
"Add compiler barriers around modifications of the robust mutex list."

ChangeLog:

[BZ #24180]
* nptl/pthread_mutex_trylock.c (__pthread_mutex_trylock):

5 years agoarray_length: Make usable as a constant expression
Florian Weimer [Thu, 7 Feb 2019 08:03:02 +0000 (09:03 +0100)]
array_length: Make usable as a constant expression

Do not use a statement expression in array_length, so that
array_length can be used at file scope and as a constant expression.
Instead, put the _Static_assert into a struct (as a declaration),
and nest this in the expression using a sizeof expression.

5 years agosupport: Implement xdlmopen
Florian Weimer [Thu, 7 Feb 2019 08:02:00 +0000 (09:02 +0100)]
support: Implement xdlmopen

Put xdlmopen into its own file, to avoid disturbing static linking
tests (where dlmopen pulls in additional code).

5 years agoAvoid "inline" after return type in function definitions.
Joseph Myers [Wed, 6 Feb 2019 17:16:43 +0000 (17:16 +0000)]
Avoid "inline" after return type in function definitions.

One group of warnings seen with -Wextra is warnings for static or
inline not at the start of a declaration (-Wold-style-declaration).

This patch fixes various such cases for inline, ensuring it comes at
the start of the declaration (after any static).  A common case of the
fix is "static inline <type> __always_inline"; the definition of
__always_inline starts with __inline, so the natural change is to
"static __always_inline <type>".  Other cases of the warning may be
harder to fix (one pattern is a function definition that gets
rewritten to be static by an including file, "#define funcname static
wrapped_funcname" or similar), but it seems worth fixing these cases
with inline anyway.

Tested for x86_64.

* elf/dl-load.h (_dl_postprocess_loadcmd): Use __always_inline
before return type, without separate inline.
* elf/dl-tunables.c (maybe_enable_malloc_check): Likewise.
* elf/dl-tunables.h (tunable_is_name): Likewise.
* malloc/malloc.c (do_set_trim_threshold): Likewise.
(do_set_top_pad): Likewise.
(do_set_mmap_threshold): Likewise.
(do_set_mmaps_max): Likewise.
(do_set_mallopt_check): Likewise.
(do_set_perturb_byte): Likewise.
(do_set_arena_test): Likewise.
(do_set_arena_max): Likewise.
(do_set_tcache_max): Likewise.
(do_set_tcache_count): Likewise.
(do_set_tcache_unsorted_limit): Likewise.
* nis/nis_subr.c (count_dots): Likewise.
* nptl/allocatestack.c (advise_stack_range): Likewise.
* sysdeps/ieee754/dbl-64/s_sin.c (do_cos): Likewise.
(do_sin): Likewise.
(reduce_sincos): Likewise.
(do_sincos): Likewise.
* sysdeps/unix/sysv/linux/x86/elision-conf.c
(do_set_elision_enable): Likewise.
(TUNABLE_CALLBACK_FNDECL): Likewise.

5 years agosupport: Use dlerror to detect NULL symbols in xdlsym
Florian Weimer [Wed, 6 Feb 2019 15:26:39 +0000 (16:26 +0100)]
support: Use dlerror to detect NULL symbols in xdlsym

5 years agox86: Remove unnecessary <stap-probe.h> include from lowlevellock.h
Florian Weimer [Wed, 6 Feb 2019 14:23:13 +0000 (15:23 +0100)]
x86: Remove unnecessary <stap-probe.h> include from lowlevellock.h

In the i386 case, it appears that the sole remaining LIBC_PROBE was
removed in commit a9fe4c5aa8e53ee30f7d0a1c878391d5d6324e6e ("Support
six-argument syscalls from C for 32-bit x86, use generic
lowlevellock-futex.h (bug 18138)."), when
sysdeps/unix/sysv/linux/i386/lowlevellock-futex.h was replaced with
the generic version.

For x86_64, the relevant change is commit
76f71081cd3fe355b9c18d1fc5e87643c788cfac ("Use generic
lowlevellock-futex.h in x86_64 lowlevellock.h."), again by using the
generic version of <lowlevellock-futex.h>.

Tested on i386 and x86_64, with and without --enable-systemtap.

5 years agoFix wide char format specifier in libio/tst-bz24153.c.
Stefan Liebler [Wed, 6 Feb 2019 11:29:02 +0000 (12:29 +0100)]
Fix wide char format specifier in libio/tst-bz24153.c.

On big endian systems the test fails with:
tst-bz24153.c:88: numeric comparison failure
   left: 1660944385 (0x63000001); from: ch
  right: 99 (0x63); from: L'c'
tst-bz24153.c:90: numeric comparison failure
   left: 1677721601 (0x64000001); from: ch
  right: 100 (0x64); from: L'd'
error: 2 test failures

One 'char' ("%c") is stored to the 'wchar_t *':
ch = 0x00000001 | 0x63000000

This patch is using "%lc" as format specifier to read a wchar_t.

ChangeLog:

* libio/tst-bz24153.c (wide): Use wide char format specifier.

5 years agoS390: Fix introduction of __wmemcmp and weak wmemcmp symbols.
Stefan Liebler [Wed, 6 Feb 2019 08:10:31 +0000 (09:10 +0100)]
S390: Fix introduction of __wmemcmp and weak wmemcmp symbols.

The recent commit 65f7767a914144ae303f7b9ae81865061793dcb9
has introduced __wmemcmp and the weak alias wmemcmp.
This patch also introduces those symbols if glibc is build
with CFLAGS="-march=z13" where the ifunc is omitted.

ChangeLog:

* sysdeps/s390/wmemcmp-vx.S: Add strong alias to
__wmemcmp and weak alias to wmemcmp.

5 years agoFix alignment of TLS variables for tls variant TLS_TCB_AT_TP [BZ #23403]
Stefan Liebler [Wed, 6 Feb 2019 08:06:34 +0000 (09:06 +0100)]
Fix alignment of TLS variables for tls variant TLS_TCB_AT_TP [BZ #23403]

The alignment of TLS variables is wrong if accessed from within a thread
for architectures with tls variant TLS_TCB_AT_TP.
For the main thread the static tls data is properly aligned.
For other threads the alignment depends on the alignment of the thread
pointer as the static tls data is located relative to this pointer.

This patch adds this alignment for TLS_TCB_AT_TP variants in the same way
as it is already done for TLS_DTV_AT_TP. The thread pointer is also already
properly aligned if the user provides its own stack for the new thread.

This patch extends the testcase nptl/tst-tls1.c in order to check the
alignment of the tls variables and it adds a pthread_create invocation
with a user provided stack.
The test itself is migrated from test-skeleton.c to test-driver.c
and the missing support functions xpthread_attr_setstack and xposix_memalign
are added.

ChangeLog:

[BZ #23403]
* nptl/allocatestack.c (allocate_stack): Align pointer pd for
TLS_TCB_AT_TP tls variant.
* nptl/tst-tls1.c: Migrate to support/test-driver.c.
Add alignment checks.
* support/Makefile (libsupport-routines): Add xposix_memalign and
xpthread_setstack.
* support/support.h: Add xposix_memalign.
* support/xthread.h: Add xpthread_attr_setstack.
* support/xposix_memalign.c: New File.
* support/xpthread_attr_setstack.c: Likewise.

5 years agoarm: Use "nr" constraint for Systemtap probes [BZ #24164]
Florian Weimer [Tue, 5 Feb 2019 12:01:08 +0000 (13:01 +0100)]
arm: Use "nr" constraint for Systemtap probes [BZ #24164]

With the default "nor" constraint, current GCC will use the "o"
constraint for constants, after emitting the constant to memory.  That
results in unparseable Systemtap probe notes such as "-4@.L1052".
Removing the "o" alternative and using "nr" instead avoids this.

5 years agoFix assertion in malloc.c:tcache_get.
Joseph Myers [Mon, 4 Feb 2019 23:46:58 +0000 (23:46 +0000)]
Fix assertion in malloc.c:tcache_get.

One of the warnings that appears with -Wextra is "ordered comparison
of pointer with integer zero" in malloc.c:tcache_get, for the
assertion:

  assert (tcache->entries[tc_idx] > 0);

Indeed, a "> 0" comparison does not make sense for
tcache->entries[tc_idx], which is a pointer.  My guess is that
tcache->counts[tc_idx] is what's intended here, and this patch changes
the assertion accordingly.

Tested for x86_64.

* malloc/malloc.c (tcache_get): Compare tcache->counts[tc_idx]
with 0, not tcache->entries[tc_idx].

5 years agoRemove duplicate initialization of field in nscd.
Joseph Myers [Mon, 4 Feb 2019 14:48:43 +0000 (14:48 +0000)]
Remove duplicate initialization of field in nscd.

I'm looking at the warnings from building glibc with -Wextra, to see
if we could use -Wextra by default, possibly with a few of its
warnings disabled, and so benefit from warnings in -Wextra but not in
-Wall.  (The vast bulk of the extra warnings so produced are from
-Wunused-parameter -Wsign-compare -Wmissing-field-initializers
-Wtype-limits, so I expect those would be disabled at least at first.)

Various miscellaneous warnings show up with -Wextra that it clearly
seems to make sense to fix independent of whether we add -Wextra to
the normal options for building glibc.  This patch fixes one:
"initialized field overwritten [-Woverride-init]" in nscd.

Tested for x86_64.

* nscd/connections.c (reqinfo): Initialize SHUTDOWN element only
once.

5 years agoFix handling of collating elements in fnmatch (bug 17396, bug 16976)
Andreas Schwab [Tue, 16 Sep 2014 09:17:04 +0000 (11:17 +0200)]
Fix handling of collating elements in fnmatch (bug 17396, bug 16976)

This fixes the same bug in fnmatch that was fixed by commit 7e2f0d2d77 for
regexp matching.  As a side effect it also removes the use of an unbound
VLA.

5 years agox86-64 memcmp: Use unsigned Jcc instructions on size [BZ #24155]
H.J. Lu [Mon, 4 Feb 2019 14:31:01 +0000 (06:31 -0800)]
x86-64 memcmp: Use unsigned Jcc instructions on size [BZ #24155]

Since the size argument is unsigned. we should use unsigned Jcc
instructions, instead of signed, to check size.

Tested on x86-64 and x32, with and without --disable-multi-arch.

[BZ #24155]
CVE-2019-7309
* NEWS: Updated for CVE-2019-7309.
* sysdeps/x86_64/memcmp.S: Use RDX_LP for size.  Clear the
upper 32 bits of RDX register for x32.  Use unsigned Jcc
instructions, instead of signed.
* sysdeps/x86_64/x32/Makefile (tests): Add tst-size_t-memcmp-2.
* sysdeps/x86_64/x32/tst-size_t-memcmp-2.c: New test.

5 years ago<spawn.h>: Add missing nonnull attributes and __restrict qualifiers
Florian Weimer [Mon, 4 Feb 2019 13:37:05 +0000 (14:37 +0100)]
<spawn.h>: Add missing nonnull attributes and __restrict qualifiers

For consistency with execve, the __argv arguments are not marked
nonnull.

5 years agoelf: Implement --preload option for the dynamic linker
David Newall [Mon, 4 Feb 2019 12:35:11 +0000 (13:35 +0100)]
elf: Implement --preload option for the dynamic linker

5 years agotestrun.sh: Exit in case of incorrect argument
Matthew Malcomson [Mon, 4 Feb 2019 12:06:15 +0000 (13:06 +0100)]
testrun.sh: Exit in case of incorrect argument

5 years agotime: Avoid alignment gaps in __tzfile_read
Florian Weimer [Mon, 4 Feb 2019 09:01:29 +0000 (10:01 +0100)]
time: Avoid alignment gaps in __tzfile_read

By ordering the suballocations by decreasing alignment, alignment
gaps can be avoided.

Also use __glibc_unlikely for reading the transitions and type
indexes.  In the 8-byte case, two reads are now needed because the
transitions and type indexes are no longer adjacent.  The separate
call to __fread_unlocked does not matter from a performance point of
view because __tzfile_read is only invoked rarely.

5 years agotime: Use struct alloc_buffer in __tzfile_read
Florian Weimer [Sun, 3 Feb 2019 21:13:51 +0000 (22:13 +0100)]
time: Use struct alloc_buffer in __tzfile_read

The computation of tzspec_len is moved in front of the total_size
computation, so that the allocation size computation and the
suballocations are next to each other.  Also add an assert that
tzspec_len is positive when it is actually used later.

5 years agotestsuite: stdlib/isomac.c: add missing include
Aurelien Jarno [Tue, 8 Jan 2019 20:10:28 +0000 (21:10 +0100)]
testsuite: stdlib/isomac.c: add missing include

When running the testsuite, building stdlib/isomac.c outputs the
following warning:

  gcc -O   -D_GNU_SOURCE -DIS_IN_build -include /home/aurel32/glibc-build/config.h isomac.c -o /home/aurel32/glibc-build/stdlib/isomac
  isomac.c: In function ‘get_null_defines’:
  isomac.c:260:3: warning: implicit declaration of function ‘close’; did you mean ‘pclose’? [-Wimplicit-function-declaration]
     close (fd);
     ^~~~~
     pclose

Fix that by adding the <unistd.h> include.

Changelog:
* stdlib/isomac.c: Include <unistd.h>.

5 years agotime: Use int, not long int, for internal GMT offsets
Florian Weimer [Sun, 3 Feb 2019 08:55:41 +0000 (09:55 +0100)]
time: Use int, not long int, for internal GMT offsets

The GMT offset can be outside the range of a 16-bit int type, which
is presumably the reason why long int was used in struct tm.  We
cannot change struct tm, but we can change the internal type for
the offset.

5 years agolibio: Use stdin consistently for input functions [BZ #24153]
Florian Weimer [Sun, 3 Feb 2019 08:37:30 +0000 (09:37 +0100)]
libio: Use stdin consistently for input functions [BZ #24153]

The internal _IO_stdin_ variable is not updated when the application
assigns to stdin, which is a GNU extension.

5 years agomanual: Document lack of conformance of sched_* functions [BZ #14829]
Florian Weimer [Sat, 2 Feb 2019 13:13:33 +0000 (14:13 +0100)]
manual: Document lack of conformance of sched_* functions [BZ #14829]

On Linux, we define _POSIX_PRIORITY_SCHEDULING, but functions such
as sched_setparam and sched_setscheduler apply to individual threads,
not processes.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoRequire GCC 6.2 or later to build glibc.
Joseph Myers [Fri, 1 Feb 2019 16:27:44 +0000 (16:27 +0000)]
Require GCC 6.2 or later to build glibc.

As discussed during development for glibc 2.29, when we increased the
required minimum GCC version for building glibc to GCC 5, working
purely based on the times at which such requirements have been
increased in the past it would be appropriate for glibc 2.30 to
require GCC 6 (matching GCC 4.9 having been required for glibc 2.26).
Naming 6.2 specifically as the minimum version then means a separate
version requirement no longer needs to be specified for powerpc64le.

Thus, this patch increases the minimum to 6.2, removing the
documentation of the separate requirement for powerpc64le.  It does
not remove the powerpc64le configure test, or any __GNUC_PREREQ that
could be removed as not being in installed headers or files shared
with gnulib; I think such cleanups are best done separately.

Tested for x86_64.

* configure.ac (libc_cv_compiler_ok): Require GCC 6.2 or later.
* configure: Regenerated.
* manual/install.texi (Tools for Compilation): Update minimum GCC
version.
* INSTALL: Regenerated.

5 years agosupport: Correct error message for TEST_COMPARE_STRING
Florian Weimer [Fri, 1 Feb 2019 13:04:42 +0000 (14:04 +0100)]
support: Correct error message for TEST_COMPARE_STRING

It should say "string", not "blob".

5 years agosupport: Handle AF_LOCAL, AF_UNSPEC in support_format_address_family
Florian Weimer [Fri, 1 Feb 2019 13:04:02 +0000 (14:04 +0100)]
support: Handle AF_LOCAL, AF_UNSPEC in support_format_address_family

5 years agomanual: Update struct sockaddr_in, struct sockaddr_sin6 description
Florian Weimer [Fri, 1 Feb 2019 13:03:39 +0000 (14:03 +0100)]
manual: Update struct sockaddr_in, struct sockaddr_sin6 description

Clarify the byte order of the the struct fields and document
sin6_flowinfo and sin6_scope_id.

5 years agoCleanup clock_*time includes
Wilco Dijkstra [Fri, 1 Feb 2019 12:19:42 +0000 (12:19 +0000)]
Cleanup clock_*time includes

Clock_gettime, settime and getres implementations are unncessarily
complex due to using defines and C file inclusion.  Simplify the
code by replacing the redundant defines and removing the inclusion,
making it much easier to understand.  No functional changes.

* sysdeps/posix/clock_getres.c (__clock_getres): Cleanup.
* sysdeps/unix/clock_gettime.c (__clock_gettime): Cleanup.
* sysdeps/unix/clock_settime.c (__clock_settime): Cleanup.
* sysdeps/unix/sysv/linux/clock_getres.c (__clock_getres): Cleanup.
* sysdeps/unix/sysv/linux/clock_gettime.c (__clock_gettime): Cleanup.
* sysdeps/unix/sysv/linux/clock_settime.c (__clock_settime): Cleanup.

5 years agoaarch64: Optimized memchr specific to AmpereComputing emag
Feng Xue [Thu, 9 Aug 2018 08:38:03 +0000 (04:38 -0400)]
aarch64: Optimized memchr specific to AmpereComputing emag

This version uses general register based memory instruction to load
data, because vector register based is slightly slower in emag.

Character-matching is performed on 16-byte (both size and alignment)
memory block in parallel each iteration.

    * sysdeps/aarch64/memchr.S (__memchr): Rename to MEMCHR.
    [!MEMCHR](MEMCHR): Set to __memchr.
    * sysdeps/aarch64/multiarch/Makefile (sysdep_routines):
    Add memchr_generic and memchr_nosimd.
    * sysdeps/aarch64/multiarch/ifunc-impl-list.c
    (__libc_ifunc_impl_list): Add memchr ifuncs.
    * sysdeps/aarch64/multiarch/memchr.c: New file.
    * sysdeps/aarch64/multiarch/memchr_generic.S: Likewise.
    * sysdeps/aarch64/multiarch/memchr_nosimd.S: Likewise.

5 years agoaarch64: Optimized memset specific to AmpereComputing emag
Feng Xue [Mon, 30 Jul 2018 06:21:42 +0000 (02:21 -0400)]
aarch64: Optimized memset specific to AmpereComputing emag

This version uses general register based memory store instead of
vector register based, for the former is faster than the latter
in emag.

The fact that DC ZVA size in emag is 64-byte, is used by IFUNC
dispatch to select this memset, so that cost of runtime-check on
DC ZVA size can be saved.

    * sysdeps/aarch64/multiarch/Makefile (sysdep_routines):
    Add memset_emag.
    * sysdeps/aarch64/multiarch/ifunc-impl-list.c
    (__libc_ifunc_impl_list): Add __memset_emag to memset ifunc.
    * sysdeps/aarch64/multiarch/memset.c (libc_ifunc):
    Add IS_EMAG check for ifunc dispatch.
    * sysdeps/aarch64/multiarch/memset_base64.S: New file.
    * sysdeps/aarch64/multiarch/memset_emag.S: New file.

5 years agoaarch64: Add AmpereComputing emag to tunable cpu list
Feng Xue [Wed, 1 Aug 2018 07:42:44 +0000 (03:42 -0400)]
aarch64: Add AmpereComputing emag to tunable cpu list

Emag is a 64-bit CPU core released by AmpereComputing.

Add its name to cpu list, and corresponding macro as utilities for
later IFUNC dispatch.

    * manual/tunables.texi (Tunable glibc.cpu.name): Add emag.
    * sysdeps/unix/sysv/linux/aarch64/cpu-features.c (cpu_list):
    Add emag.
    * sysdeps/unix/sysv/linux/aarch64/cpu-features.h (IS_EMAG):
    New macro.

5 years agoposix/tst-spawn: Fix racy tests in spawned processes.
Stefan Liebler [Fri, 1 Feb 2019 10:03:35 +0000 (11:03 +0100)]
posix/tst-spawn: Fix racy tests in spawned processes.

From time to time I get fails in tst-spawn like:
tst-spawn.c:111: numeric comparison failure
   left: 0 (0x0); from: xlseek (fd2, 0, SEEK_CUR)
  right: 28 (0x1c); from: strlen (fd2string)
error: 1 test failures
tst-spawn.c:252: numeric comparison failure
   left: 1 (0x1); from: WEXITSTATUS (status)
  right: 0 (0x0); from: 0
error: 1 test failures

It turned out, that a child process is testing it's open file descriptors
with e.g. a sequence of testing the current position, setting the position
to zero and reading a specific amount of bytes.

Unfortunately starting with commit 2a69f853c03034c2e383e0f9c35b5402ce8b5473
the test is spawning a second child process which is sharing some of the
file descriptors.  If the test sequence as mentioned above is running in parallel
it leads to test failures.

As the second call of posix_spawn shall test a NULL pid argument,
this patch is just moving the waitpid of the first child
before the posix_spawn of the second child.

ChangeLog:

* posix/tst-spawn do_test(): Move waitpid before posix_spawn.

5 years agomake-syscalls.sh: fix comment referencing syscall-template
Vineet Gupta [Fri, 1 Feb 2019 03:45:10 +0000 (22:45 -0500)]
make-syscalls.sh: fix comment referencing syscall-template

5 years agonptl: Fix pthread_rwlock_try*lock stalls (Bug 23844)
Carlos O'Donell [Tue, 22 Jan 2019 03:50:12 +0000 (22:50 -0500)]
nptl: Fix pthread_rwlock_try*lock stalls (Bug 23844)

For a full analysis of both the pthread_rwlock_tryrdlock() stall
and the pthread_rwlock_trywrlock() stall see:
https://sourceware.org/bugzilla/show_bug.cgi?id=23844#c14

In the pthread_rwlock_trydlock() function we fail to inspect for
PTHREAD_RWLOCK_FUTEX_USED in __wrphase_futex and wake the waiting
readers.

In the pthread_rwlock_trywrlock() function we write 1 to
__wrphase_futex and loose the setting of the PTHREAD_RWLOCK_FUTEX_USED
bit, again failing to wake waiting readers during unlock.

The fix in the case of pthread_rwlock_trydlock() is to check for
PTHREAD_RWLOCK_FUTEX_USED and wake the readers.

The fix in the case of pthread_rwlock_trywrlock() is to only write
1 to __wrphase_futex if we installed the write phase, since all other
readers would be spinning waiting for this step.

We add two new tests, one exercises the stall for
pthread_rwlock_trywrlock() which is easy to exercise, and one exercises
the stall for pthread_rwlock_trydlock() which is harder to exercise.

The pthread_rwlock_trywrlock() test fails consistently without the fix,
and passes after. The pthread_rwlock_tryrdlock() test fails roughly
5-10% of the time without the fix, and passes all the time after.

Signed-off-by: Carlos O'Donell <carlos@redhat.com>
Signed-off-by: Torvald Riegel <triegel@redhat.com>
Signed-off-by: Rik Prohaska <prohaska7@gmail.com>
Co-authored-by: Torvald Riegel <triegel@redhat.com>
Co-authored-by: Rik Prohaska <prohaska7@gmail.com>
5 years agoUse MPFR 4.0.2 in build-many-glibcs.py.
Joseph Myers [Fri, 1 Feb 2019 00:11:37 +0000 (00:11 +0000)]
Use MPFR 4.0.2 in build-many-glibcs.py.

* scripts/build-many-glibcs.py (Context.checkout): Default MPFR
version to 4.0.2.

5 years agolibio: use stdout in puts and putchar, etc [BZ #24051].
Paul Pluzhnikov [Tue, 1 Jan 2019 03:14:28 +0000 (19:14 -0800)]
libio: use stdout in puts and putchar, etc [BZ #24051].

GLIBC explicitly allows one to assign a new FILE pointer to stdout and
other standard streams.  printf and wprintf were honouring assignment to
stdout and using the new value, but puts, putchar, and wide char variants
did not.

The stdout part is fixed here.  The stdin part will be fixed in a followup.

5 years agoregex: fix read overrun [BZ #24114]
Paul Eggert [Mon, 21 Jan 2019 19:08:13 +0000 (11:08 -0800)]
regex: fix read overrun [BZ #24114]

Problem found by AddressSanitizer, reported by Hongxu Chen in:
https://debbugs.gnu.org/34140
* posix/regexec.c (proceed_next_node):
Do not read past end of input buffer.

5 years agonss_files: Fix /etc/aliases null pointer dereference [BZ #24059]
Florian Weimer [Thu, 31 Jan 2019 17:49:58 +0000 (18:49 +0100)]
nss_files: Fix /etc/aliases null pointer dereference [BZ #24059]

If /etc/aliases ends with a continuation line (a line that starts
with whitespace) which does not have a trailing newline character,
the file parser would crash due to a null pointer dereference.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoOpen master for 2.30 development
Siddhesh Poyarekar [Thu, 31 Jan 2019 17:09:14 +0000 (22:39 +0530)]
Open master for 2.30 development

5 years agoTag 2.29 release
Siddhesh Poyarekar [Thu, 31 Jan 2019 16:45:36 +0000 (22:15 +0530)]
Tag 2.29 release

* version.h (RELEASE): Set to "stable".
(VERSION): Set to "2.29".
* include/features.h (__GLIBC_MINOR__): Set to 2.29.

5 years agoPrepare for 2.29 release
Siddhesh Poyarekar [Thu, 31 Jan 2019 16:31:21 +0000 (22:01 +0530)]
Prepare for 2.29 release

* NEWS: Add the list of bugs fixed in 2.29.
* manual/contrib.texi: Update contributors list with some more
names.
  * manual/install.texi: Update latest versions of packages
  tested.
  * INSTALL: Regenerated.

5 years agoUpdate translations
Siddhesh Poyarekar [Fri, 25 Jan 2019 16:35:42 +0000 (22:05 +0530)]
Update translations

Update translations from translationproject.org for 2.28.9000.

5 years ago[elf] Revert 8e889c5da3 (BZ#24122)
Adhemerval Zanella [Fri, 25 Jan 2019 10:10:15 +0000 (08:10 -0200)]
[elf] Revert 8e889c5da3 (BZ#24122)

It triggers an invalid build issue on GCC8+ and does not covers all
corner cases.

5 years agohurd: Fix initial sigaltstack state
Samuel Thibault [Thu, 24 Jan 2019 19:15:01 +0000 (20:15 +0100)]
hurd: Fix initial sigaltstack state

Previous commit fixed
[BZ #24110]

5 years agoRISC-V: Update nofpu ULPs
Darius Rad [Thu, 24 Jan 2019 18:44:56 +0000 (13:44 -0500)]
RISC-V: Update nofpu ULPs

This patch fixes 36 math related test failures.