about summary refs log tree commit diff
Commit message (Collapse)AuthorAgeFilesLines
* Mechanically remove _IO_ name aliases for types and constants.Zack Weinberg2018-02-21128-971/+937
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch mechanically removes all remaining uses, and the definitions, of the following libio name aliases: name replaced with ---- ------------- _IO_FILE FILE _IO_fpos_t __fpos_t _IO_fpos64_t __fpos64_t _IO_size_t size_t _IO_ssize_t ssize_t or __ssize_t _IO_off_t off_t _IO_off64_t off64_t _IO_pid_t pid_t _IO_uid_t uid_t _IO_wint_t wint_t _IO_va_list va_list or __gnuc_va_list _IO_BUFSIZ BUFSIZ _IO_cookie_io_functions_t cookie_io_functions_t __io_read_fn cookie_read_function_t __io_write_fn cookie_write_function_t __io_seek_fn cookie_seek_function_t __io_close_fn cookie_close_function_t I used __fpos_t and __fpos64_t instead of fpos_t and fpos64_t because the definitions of fpos_t and fpos64_t depend on the largefile mode. I used __ssize_t and __gnuc_va_list in a handful of headers where namespace cleanliness might be relevant even though they're internal-use-only. In all other cases, I used the public-namespace name. There are a tiny handful of places where I left a use of 'struct _IO_FILE' alone, because it was being used together with 'struct _IO_FILE_plus' or 'struct _IO_FILE_complete' in the same arithmetic expression. Because this patch was almost entirely done with search and replace, I may have introduced indentation botches. I did proofread the diff, but I may have missed something. The ChangeLog below calls out all of the places where this was not a pure search-and-replace change. Installed stripped libraries and executables are unchanged by this patch, except that some assertions in vfscanf.c change line numbers. * libio/libio.h (_IO_FILE): Delete; all uses changed to FILE. (_IO_fpos_t): Delete; all uses changed to __fpos_t. (_IO_fpos64_t): Delete; all uses changed to __fpos64_t. (_IO_size_t): Delete; all uses changed to size_t. (_IO_ssize_t): Delete; all uses changed to ssize_t or __ssize_t. (_IO_off_t): Delete; all uses changed to off_t. (_IO_off64_t): Delete; all uses changed to off64_t. (_IO_pid_t): Delete; all uses changed to pid_t. (_IO_uid_t): Delete; all uses changed to uid_t. (_IO_wint_t): Delete; all uses changed to wint_t. (_IO_va_list): Delete; all uses changed to va_list or __gnuc_va_list. (_IO_BUFSIZ): Delete; all uses changed to BUFSIZ. (_IO_cookie_io_functions_t): Delete; all uses changed to cookie_io_functions_t. (__io_read_fn): Delete; all uses changed to cookie_read_function_t. (__io_write_fn): Delete; all uses changed to cookie_write_function_t. (__io_seek_fn): Delete; all uses changed to cookie_seek_function_t. (__io_close_fn): Delete: all uses changed to cookie_close_function_t. * libio/iofopncook.c: Remove unnecessary forward declarations. * libio/iolibio.h: Correct outdated commentary. * malloc/malloc.c (__malloc_stats): Remove unnecessary casts. * stdio-common/fxprintf.c (__fxprintf_nocancel): Remove unnecessary casts. * stdio-common/getline.c: Use _IO_getdelim directly. Don't redefine ssize_t. * stdio-common/printf_fp.c, stdio_common/printf_fphex.c * stdio-common/printf_size.c: Don't redefine size_t or FILE. Remove outdated comments. * stdio-common/vfscanf.c: Don't redefine va_list.
* Remove vestiges of external build support from libio headers.Zack Weinberg2018-02-214-43/+12
| | | | | | | | | | | | | | As requested by Adhemerval, this patch removes some preprocessor conditionals from the libio headers that were only relevant when building libio outside glibc. Installed stripped libraries and executables are unchanged by this patch. * libio/iolibio.h, libio/libioP.h: Remove extern "C". * libio/libio.h: Remove __BEGIN_DECLS and __END_DECLS. Remove preprocessor conditionals on _LIBC and __USE_GNU, which are always true, and __cplusplus, which is always false.
* Fix -Os putc_unlocked, fputc_unlocked linknamespace, localplt issues (bug ↵Joseph Myers2018-02-215-3/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 15105, bug 19463). Continuing the fixes for linknamespace and localplt test failures with -Os that arise from functions not being inlined in that case, this patch fixes such failures for putc_unlocked and fputc_unlocked. libc_hidden_* are used for both functions, while namespace issues are addressed by making putc_unlocked a weak alias of hidden __putc_unlocked, which is called in the one place where namespace issues arise (and defined as an inline function in include/stdio.h). Tested for x86_64 (both without -Os to make sure that case continues to work, and with -Os to make sure all the relevant linknamespace and localplt test failures are resolved). This completes fixing the -Os linknamespace failures (at least for x86_64); localplt failures remain after this patch. 2018-02-19 Joseph Myers <joseph@codesourcery.com> [BZ #15105] [BZ #19463] * libio/fputc_u.c (fputc_unlocked): Use libc_hidden_def. * libio/putc_u.c (putc_unlocked): Rename to __putc_unlocked and define as weak alias of __putc_unlocked. Use libc_hidden_weak. * include/stdio.h [!_ISOMAC] (fputc_unlocked): Use libc_hidden_proto. [!_ISOMAC] (putc_unlocked): Likewise. [!_ISOMAC] (__putc_unlocked): Declare as hidden function, and define inline if [__USE_EXTERN_INLINES]. * misc/syslog.c (__vsyslog_chk): Call __putc_unlocked instead of putc_unlocked.
* Fix -Os getc_unlocked linknamespace, localplt issues (bug 15105, bug 19463).Joseph Myers2018-02-215-8/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | Continuing the fixes for linknamespace and localplt test failures with -Os that arise from functions not being inlined in that case, this patch fixes such failures for getc_unlocked. __getc_unlocked already exists; this patch makes it explicitly hidden, calls it where needed for namespace reasons, adds an inline function for it when inline functions are used and adds libc_hidden_proto / libc_hidden_weak for getc_unlocked. Tested for x86_64 (both without -Os to make sure that case continues to work, and with -Os to make sure all the relevant linknamespace and localplt test failures are resolved). Because of other such failures that remain after this patch, neither of the bugs can yet be closed. [BZ #15105] [BZ #19463] * libio/getc_u.c (getc_unlocked): Use libc_hidden_weak. * include/stdio.h [!_ISOMAC] (__getc_unlocked): Use attribute_hidden, and define inline if [__USE_EXTERN_INLINES]. [!_ISOMAC] (getc_unlocked): Use libc_hidden_proto. * misc/getttyent.c (__getttyent): Call __getc_unlocked instead of getc_unlocked. * time/tzfile.c (__tzfile_read): Likewise.
* Add missing “reorder-end” in LC_COLLATE of et_EE [BZ #22517]Mike FABIAN2018-02-212-0/+7
| | | | | [BZ #22517] * localedata/locales/et_EE (LC_COLLATE): add missing “reorder-end”
* Fix a typo in a comment.Rical Jasan2018-02-212-1/+5
| | | | * io/fcntl.h: Fix a typo in a comment.
* manual: Update _DEFAULT_SOURCE. [BZ #22862]Rical Jasan2018-02-213-8/+22
| | | | | | | | | | | | | | | | | The description of the interplay between feature test macros and compiler options in the description of _DEFAULT_SOURCE is a little confusing, and dated, so clarify the situation, and don't assume a specific value for _DEFAULT_SOURCE. Also, _DEFAULT_SOURCE is supposed to be defined if none of the C/POSIX feature test macros are defined, but the condition was lacking a test for _ISOC11_SOURCE, so that is also addressed. [BZ #22862] * include/features.h: Add _ISOC11_SOURCE to test for whether to define _DEFAULT_SOURCE. * manual/creature.texi (_DEFAULT_SOURCE): Improve documentation.
* ldconfig: Sync temporary files to disk before renaming them [BZ #20890]Florian Weimer2018-02-212-3/+15
| | | | | | | If the system crashes before the file data has been written to disk, the file system recovery upon the next mount may restore a partially rewritten temporary file under the non-temporary (final) name (after the rename operation).
* elf: Remove ad-hoc restrictions on dlopen callers [BZ #22787]Florian Weimer2018-02-219-148/+22
| | | | | | | | | | | | | | | | | | | | | | This looks like a post-exploitation hardening measure: If an attacker is able to redirect execution flow, they could use that to load a DSO which contains additional code (or perhaps make the stack executable). However, the checks are not in the correct place to be effective: If they are performed before the critical operation, an attacker with sufficient control over execution flow could simply jump directly to the code which performs the operation, bypassing the check. The check would have to be executed unconditionally after the operation and terminate the process in case a caller violation was detected. Furthermore, in _dl_check_caller, there was a fallback reading global writable data (GL(dl_rtld_map).l_map_start and GL(dl_rtld_map).l_text_end), which could conceivably be targeted by an attacker to disable the check, too. Other critical functions (such as system) remain completely unprotected, so the value of these additional checks does not appear that large. Therefore this commit removes this functionality.
* hurd: fix buildSamuel Thibault2018-02-212-0/+6
| | | | * sysdeps/mach/hurd/dl-sysdep.c (_dl_random): New variable.
* manual: Update the _ISOC99_SOURCE description.Rical Jasan2018-02-202-4/+8
| | | | | | | | The current description refers to ISO C99 not being widely adopted, which it is believed to be now. * manual/creature.texi (_ISOC99_SOURCE): Update the dated description.
* manual: Document missing feature test macros.Rical Jasan2018-02-202-2/+46
| | | | | | | | | | | | | | Several feature test macros are documented in features.h but absent in the manual, and some documented macros accept undocumented values. This commit updates the manual to mention all the accepted macros, along with any values that hold special meaning. * manual/creature.texi (_POSIX_C_SOURCE): Document special values of 199606L, 200112L, and 200809L. (_XOPEN_SOURCE): Document special values of 600 and 700. (_ISOC11_SOURCE): Document macro. (_ATFILE_SOURCE): Likewise. (_FORTIFY_SOURCE): Likewise.
* Fix -Os ferror_unlocked linknamespace, localplt issues (bug 15105, bug 19463).Joseph Myers2018-02-194-2/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Continuing the fixes for linknamespace and localplt test failures with -Os that arise from functions not being inlined in that case, this patch fixes such failures for ferror_unlocked. The usual approach is followed of adding __ferror_unlocked (inlined when ferror_unlocked is), making calls use it when required for namespace reasons (only one such call), and using libc_hidden_proto / libc_hidden_weak for the ferror_unlocked weak alias when only localplt but not namespace issues are involved. Tested for x86_64 (both without -Os to make sure that case continues to work, and with -Os to make sure all the relevant linknamespace and localplt test failures are resolved). Because of other such failures that remain after this patch, neither of the bugs can yet be closed. [BZ #15105] [BZ #19463] * libio/ferror_u.c (ferror_unlocked): Rename to __ferror_unlocked and define as weak alias of __ferror_unlocked. Use libc_hidden_weak. * include/stdio.h [!_ISOMAC] (ferror_unlocked): Use libc_hidden_proto. [!_ISOMAC] (__ferror_unlocked) New declaration, and inline function if [__USE_EXTERN_INLINES]. * time/getdate.c (__getdate_r): Call __ferror_unlocked instead of ferror_unlocked.
* manual: Improve documentation of get_current_dir_name. [BZ #6889]Rical Jasan2018-02-192-8/+14
| | | | | | | | | | | This is a minor rewording to clarify the behaviour of get_current_dir_name. Additionally, the @vindex is moved above the @deftypefun so that following links give a better result with regard to context. [BZ #6889] * manual/filesys.texi (get_current_dir_name): Clarify behaviour.
* Fix posix/tst-glob_lstat_compat on alpha [BZ #22818]Aurelien Jarno2018-02-182-0/+13
| | | | | | | | | | | | | The tst-glob_lstat_compat test needs to run tests on the previous version of glob. On alpha, there are three versions of glob, GLIBC_2.0, GLIBC_2.1 and GLIBC_2.27, while on other architectures there are only the GLIBC_2.0 and GLIBC_2.27 version. Therefore on alpha the previous version is GLIBC_2.1 and not GLIBC_2.0. Changelog: [BZ #22818] * posix/tst-glob_lstat_compat.c [__alpha__] (glob): Access the GLIBC_2.1 version.
* intl/tst-gettext: fix failure with newest msgfmtAurelien Jarno2018-02-184-3/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since upstream gettext commit d13f165b83 (msgfmt: Remove POT-Creation-Date field from the header in the output.), msgfmt does not copy the POT-Creation-Date field in the header entry from the po file to the mo file anymore. This breaks the assumption that we can test gettext by comparing each message in the po files with the corresponding string return by gettext. This makes the intl/tst-gettext to fail. While it would have been possible to modify the po2test.awk script to also strip the line POT-Creation-Date field when creating the msgs.h file, it would not work with both the old and new msgfmt. Instead create a tst-gettext-de.po file from de.po by removing the POT-Creation-Date line. Another alternative would be to use a static tst-gettext-de.po file, but I guess the reason for using de.po is to also catch issues caused by newly added strings. As tst-catgets also uses msg.h, it should also be updated. Instead of using the new tst-gettext-de.po file, the patch modifies xopen-msg.awk to avoid creating a second catgets->intl dependency. Changelog: [BZ #21508] * catgets/xopen-msg.awk: Ignore POT-Creation-Date line. * intl/Makefile ($(objpfx)tst-gettext-de.po): Generate intl/tst-gettext-de.po from po/de.po by removing the POT-Creation-Date line. ($(objpfx)msgs.h): Depend on $(objpfx)tst-gettext-de.po instead of ../po/de.po. * intl/tst-gettext.sh: Use ${objpfx}tst-gettext-de.po instead of ../po/de.po.
* hurd: Fix build on missing __ptsname_internal functionSamuel Thibault2018-02-172-4/+23
| | | | | | | * sysdeps/mach/hurd/ptsname.c: Include <sys/stat.h>. (__ptsname_r): Move implementation to... (__ptsname_internal): ... new function. Add filling the STP structure.
* hurd: Define EXEC_PAGESIZESamuel Thibault2018-02-174-1/+34
| | | | | | * mach/Makefile (headers): Add mach/param.h. * sysdeps/mach/hurd/bits/param.h: Include <mach/param.h>. * sysdeps/mach/i386/mach/param.h: New file, defines EXEC_PAGESIZE
* Fix ulps for pow on hppa.John David Anglin2018-02-172-0/+7
| | | | | * sysdeps/hppa/fpu/libm-test-ulps (pow): Increase double and idouble to 1 ULP.
* manual: Fix a syntax error.Rical Jasan2018-02-162-1/+6
| | | | | | | | | | | | | The opening parenthesis for function arguments in an @deftypefun need to be separated from the function name. This isn't just a matter of the GNU coding style---it causes the "(void" (in this case) to be rendered as a part of the function name, causing a visual defect, and also results in a warning to the following effect during `make pdf': Warning: unbalanced parentheses in @def...) * manual/platform.texi (__riscv_flush_icache): Fix @deftypefun syntax.
* Add runtime check if mutex will be elided in tst-mutex8 testcases.Stefan Liebler2018-02-163-47/+89
| | | | | | | | | | | | | | | | | | | | | | | | | An elided mutex don't fail destroy. Elision was disabled for the test nptl/tst-mutex8 in nptl/Makefile. Thus we can run tests which destroy a locked mutex. As elision is only disabled for tst-mutex8, the variants tst-mutex8-static, tst-mutexpi8 and tst-mutexpi8-static are still failing if lock elision is enabled. This patch adds a runtime check, if the checked type of mutex will be elided. This check is using TUNABLE_GET_FULL to determine if elision is enabled via the tunables framework. The pthread_mutex_destroy tests are only run if we dont't assume an elided mutex. This way, we can run the whole glibc testsuite with or without enabled lock elision. ChangeLog: * nptl/Makefile (tst-mutex8-ENV): Delete. * nptl/tst-mutex8.c (check_type): Add runtime check if mutex will be elided.
* Document use of CC and CFLAGS in more detail (bug 20980, bug 21234).Joseph Myers2018-02-153-12/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | There are some bug reports from people setting CFLAGS not including a -O option and then being confused when the build fails. This patch addresses this by documenting the proper use of CC and CFLAGS in more detail - saying what options should go where and specifying the requirement to compile with optimization. The previous text incorrectly used @var markup with CC and CFLAGS. The correct markup for environment variables is @env, but it's also the case that passing such variables explicitly on the configure command line is preferred to passing them in the environment, so this patch changes the documentation to describe passing them on the command line (and uses @code). In many cases putting options in the wrong place may in fact work, but I believe what I've specified is the correct rule for which options to put where. [BZ #20980] [BZ #21234] * manual/install.texi (Configuring and compiling): Describe passing CC and CFLAGS on configure command line, not as environment variables. Use @code markup on those variables. Specify what options go in CC and what go in CFLAGS. Note the requirement to compile with optimization. * INSTALL: Regenerated.
* Fix hppa local PLT entries for sigprocmask (bug 18124).Joseph Myers2018-02-154-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When adding/updating localplt.data for various architectures to get the compilation tests passing everywhere, I generally made it reflect the existing state of what local PLT entries were actually seen, rather than an ideal state with as few as possible such entries, mainly for functions that are intended to be interposable. This patch eliminates some local PLT entries for hppa by using __sigprocmask instead of sigprocmask in getcontext and setcontext. The specific case of sigprocmask called by setcontext is the third of four items in bug 18124 (the other three have already been fixed for 2.26 or earlier releases). Note that hppa-specific localplt.data entries for __sigsetjmp, _IO_funlockfile and __errno_location remain, but the causes / fixes are less immediately obvious from source inspection. Tested (compilation tests only) with build-many-glibcs.py for hppa-linux-gnu. [BZ #18124] * sysdeps/hppa/bsd-setjmp.S: Include <sysdep.h>. (setjmp): Use HIDDEN_JUMPTARGET with __sigsetjmp. * sysdeps/unix/sysv/linux/hppa/getcontext.S (__getcontext): Call __sigprocmask instead of sigprocmask. * sysdeps/unix/sysv/linux/hppa/setcontext.S (__setcontext): Likewise. * sysdeps/unix/sysv/linux/hppa/localplt.data: Remove entries for __sigsetjmp and sigprocmask.
* Use libc_hidden_* for argz_next, __argz_next (bug 15105).Joseph Myers2018-02-153-0/+10
| | | | | | | | | | | | | | | | | | Among other localplt test failures when building with -Os, there are libc.so PLT references for argz_next and __argz_next. This is a simple case of functions that are inlined for -O2 but not for -Os; this patch adds libc_hidden_proto / libc_hidden_def for them to avoid localplt failures even when not inlined. Tested for x86_64 (both that it removes these particular localplt failures for -Os - but other such failures remain so the bug can't yet be closed - and that the testsuite continues to pass without -Os). [BZ #15105] * include/argz.h (argz_next): Use libc_hidden_proto. (__argz_next): Likewise. * string-argz-next.c (__argz_next): Use libc_hidden_def. (argz_next): Use libc_hidden_weak.
* Use libc_hidden_* for __cmsg_nxthdr (bug 15105).Joseph Myers2018-02-153-0/+9
| | | | | | | | | | | | | | | | | | Among other localplt test failures when building with -Os, there are libc.so PLT references for __cmsg_nxthdr. This is a simple case of a function that is inlined for -O2 but not for -Os; this patch adds libc_hidden_proto / libc_hidden_def for it to avoid a localplt failure even when it is not inlined. Tested for x86_64 (both that it removes this particular localplt failure for -Os - but other such failures remain so the bug can't yet be closed - and that the testsuite continues to pass without -Os). [BZ #15105] * include/sys/socket.h [!_ISOMAC] (__cmsg_nxthdr): Use libc_hidden_proto. * sysdeps/unix/sysv/linux/cmsg_nxthdr.c (__cmsg_nxthdr): Use libc_hidden_def.
* Use libc_hidden_* for fputs (bug 15105).Joseph Myers2018-02-153-0/+10
| | | | | | | | | | | | | | | | | | | | | | | Among other localplt test failures when building with -Os, there are libc.so PLT references for fputs. fputs calls normally get redirected to _IO_fputs by a macro in include/stdio.h (and _IO_fputs in turn uses libc_hidden_proto), but GCC can convert an fprintf call with a constant string argument into an fputs call, which of course is then unaffected by the macro redirection. (I don't know why this issue only appears with -Os.) This patch duly adds a use of libc_hidden_proto for fputs. I see no obvious reason why the fputs macro redirection is needed at all, but this patch does not change it. Tested for x86_64 (both that it removes this particular localplt failure for -Os - but other such failures remain so the bug can't yet be closed - and that the testsuite continues to pass without -Os). [BZ #15105] * include/stdio.h [!_ISOMAC && IS_IN (libc)] (fputs): Use libc_hidden_proto. * libio/iofputs.c (fputs): Use libc_hidden_weak.
* Fix -Os feof_unlocked linknamespace, localplt issues (bug 15105, bug 19463).Joseph Myers2018-02-159-6/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Continuing the fixes for linknamespace and localplt test failures with -Os that arise from functions not being inlined in that case, this patch fixes such failures for feof_unlocked. The usual approach is followed of adding __feof_unlocked (inlined when feof_unlocked is), making calls use it when required for namespace reasons, and using libc_hidden_proto / libc_hidden_weak for the feof_unlocked weak alias when only localplt but not namespace issues are involved. In the case of getaddrinfo.c, use of __feof_unlocked needs to be conditional since that code is also used in nscd (where __feof_unlocked is not available). Tested for x86_64 (both without -Os to make sure that case continues to work, and with -Os to make sure all the relevant linknamespace and localplt test failures are resolved). Because of other such failures that remain after this patch, neither of the bugs can yet be closed. [BZ #15105] [BZ #19463] * libio/feof_u.c (feof_unlocked): Rename to __feof_unlocked and define as weak alias of __feof_unlocked. Use libc_hidden_weak. * include/stdio.h (feof_unlocked): Use libc_hidden_proto. (__feof_unlocked): New declaration, and inline function if [__USE_EXTERN_INLINES]. * iconv/gconv_conf.c (read_conf_file): Call __feof_unlocked instead of feof_unlocked. * intl/localealias.c [_LIBC] (FEOF): Likewise. * nss/nsswitch.c (nss_parse_file): Likewise. * sysdeps/unix/sysv/linux/readonly-area.c (__readonly_area): Likewise. * time/getdate.c (__getdate_r): Likewise. * sysdeps/posix/getaddrinfo.c [IS_IN (libc)] (feof_unlocked): Define as macro to call __feof_unlocked.
* [AArch64] Fix include.Wilco Dijkstra2018-02-152-1/+5
| | | | | | Fix include to use <>. * sysdeps/aarch64/fpu/fpu_control.h: Use <> in include.
* Remove mplog and mpexpWilco Dijkstra2018-02-1522-342/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | Remove the now unused mplog and mpexp files. * math/Makefile: Remove mpexp.c and mplog.c * sysdeps/i386/fpu/mpexp.c: Delete file. * sysdeps/i386/fpu/mplog.c: Likewise. * sysdeps/ia64/fpu/mpexp.c: Likewise. * sysdeps/ia64/fpu/mplog.c: Likewise. * sysdeps/ieee754/dbl-64/e_exp.c: Remove mention of mpexp and mplog. * sysdeps/ieee754/dbl-64/mpa.h (__pow_mp): Remove unused function. * sysdeps/ieee754/dbl-64/mpexp.c: Delete file. * sysdeps/ieee754/dbl-64/mplog.c: Likewise. * sysdeps/m68k/m680x0/fpu/mpexp.c: Likewise. * sysdeps/m68k/m680x0/fpu/mplog.c: Likewise. * sysdeps/x86_64/fpu/multiarch/Makefile: Remove mpexp* and mplog*. * sysdeps/x86_64/fpu/multiarch/e_log-avx.c: Remove unused defines. * sysdeps/x86_64/fpu/multiarch/e_log-fma.c: Likewise. * sysdeps/x86_64/fpu/multiarch/e_log-fma4.c: Likewise. * sysdeps/x86_64/fpu/multiarch/mpexp-avx.c: Delete file. * sysdeps/x86_64/fpu/multiarch/mpexp-fma.c: Likewise. * sysdeps/x86_64/fpu/multiarch/mpexp-fma4.c: Likewise. * sysdeps/x86_64/fpu/multiarch/mplog-avx.c: Likewise. * sysdeps/x86_64/fpu/multiarch/mplog-fma.c: Likewise. * sysdeps/x86_64/fpu/multiarch/mplog-fma4.c: Likewise.
* S390: Regenerate ULPs.Stefan Liebler2018-02-152-68/+24
| | | | | | | | Regenerated ulps file from scratch due to recent pow changes. ChangeLog: * sysdeps/s390/fpu/libm-test-ulps: Regenerated.
* Update SH libm-tests-ulpsAdhemerval Zanella2018-02-142-48/+449
| | | | | | * sysdeps/sh/libm-test-ulps: Update. Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* powerpc: Update pow() ULPsTulio Magno Quites Machado Filho2018-02-122-0/+7
| | | | | | | * sysdeps/powerpc/fpu/libm-test-ulps (pow): Increase double and idouble to 1 ULP. Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
* [BZ #19239] Don't include sys/sysmacros.h from sys/types.h.Zack Weinberg2018-02-124-58/+21
| | | | | | | | | This completes the deprecation and removal of this inclusion, which was begun in the 2.25 release. * posix/sys/types.h: Don't include sys/sysmacros.h. * misc/sys/sysmacros.h: Remove the conditional deprecation warnings for the macros defined by this header.
* Remove slow paths from expSzabolcs Nagy2018-02-1218-189/+43
| | | | | | | | | | | | | | | | | | | | | | | | | Remove the __slowexp code, so exp is no longer correctly rounded. The result is computed to about 70 bits precision so the worst case ulp error is about 0.500007 in nearest rounding mode. * manual/probes.texi: Remove slowexp probes. * math/Makefile: Remove slowexp. * sysdeps/generic/math_private.h (__slowexp): Remove. * sysdeps/ieee754/dbl-64/e_exp.c (__ieee754_exp): Remove __slowexp and document error bounds. * sysdeps/i386/fpu/slowexp.c: Remove. * sysdeps/ia64/fpu/slowexp.c: Remove. * sysdeps/ieee754/dbl-64/slowexp.c: Remove. * sysdeps/ieee754/dbl-64/uexp.h (err_0): Remove. * sysdeps/m68k/m680x0/fpu/slowexp.c: Remove. * sysdeps/powerpc/power4/fpu/Makefile (CPPFLAGS-slowexp.c): Remove. * sysdeps/x86_64/fpu/multiarch/Makefile: Remove slowexp-fma. * sysdeps/x86_64/fpu/multiarch/e_exp-avx.c (__slowexp): Remove. * sysdeps/x86_64/fpu/multiarch/e_exp-fma.c (__slowexp): Remove. * sysdeps/x86_64/fpu/multiarch/e_exp-fma4.c (__slowexp): Remove. * sysdeps/x86_64/fpu/multiarch/slowexp-avx.c: Remove. * sysdeps/x86_64/fpu/multiarch/slowexp-fma.c: Remove. * sysdeps/x86_64/fpu/multiarch/slowexp-fma4.c: Remove.
* Remove slow paths from powWilco Dijkstra2018-02-1226-525/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove the slow paths from pow. Like several other double precision math functions, pow is exactly rounded. This is not required from math functions and causes major overheads as it requires multiple fallbacks using higher precision arithmetic if a result is close to 0.5ULP. Ridiculous slowdowns of up to 100000x have been reported when the highest precision path triggers. All GLIBC math tests pass on AArch64 and x64 (with ULP of pow set to 1). The worst case error is ~0.506ULP. A simple test over a few hundred million values shows pow is 10% faster on average. This fixes BZ #13932. [BZ #13932] * sysdeps/ieee754/dbl-64/uexp.h (err_1): Remove. * benchtests/pow-inputs: Update comment for slow path cases. * manual/probes.texi (slowpow_p10): Delete removed probe. (slowpow_p10): Likewise. * math/Makefile: Remove halfulp.c and slowpow.c. * sysdeps/aarch64/libm-test-ulps: Set ULP of pow to 1. * sysdeps/generic/math_private.h (__exp1): Remove error argument. (__halfulp): Remove. (__slowpow): Remove. * sysdeps/i386/fpu/halfulp.c: Delete file. * sysdeps/i386/fpu/slowpow.c: Likewise. * sysdeps/ia64/fpu/halfulp.c: Likewise. * sysdeps/ia64/fpu/slowpow.c: Likewise. * sysdeps/ieee754/dbl-64/e_exp.c (__exp1): Remove error argument, improve comments and add error analysis. * sysdeps/ieee754/dbl-64/e_pow.c (__ieee754_pow): Add error analysis. (power1): Remove function: (log1): Remove error argument, add error analysis. (my_log2): Remove function. * sysdeps/ieee754/dbl-64/halfulp.c: Delete file. * sysdeps/ieee754/dbl-64/slowpow.c: Likewise. * sysdeps/m68k/m680x0/fpu/halfulp.c: Likewise. * sysdeps/m68k/m680x0/fpu/slowpow.c: Likewise. * sysdeps/powerpc/power4/fpu/Makefile: Remove CPPFLAGS-slowpow.c. * sysdeps/x86_64/fpu/libm-test-ulps: Set ULP of pow to 1. * sysdeps/x86_64/fpu/multiarch/Makefile: Remove slowpow-fma.c, slowpow-fma4.c, halfulp-fma.c, halfulp-fma4.c. * sysdeps/x86_64/fpu/multiarch/e_pow-fma.c (__slowpow): Remove define. * sysdeps/x86_64/fpu/multiarch/e_pow-fma4.c (__slowpow): Likewise. * sysdeps/x86_64/fpu/multiarch/halfulp-fma.c: Delete file. * sysdeps/x86_64/fpu/multiarch/halfulp-fma4.c: Likewise. * sysdeps/x86_64/fpu/multiarch/slowpow-fma.c: Likewise. * sysdeps/x86_64/fpu/multiarch/slowpow-fma4.c: Likewise.
* nscd: don't unconditionally use ↵Samuel Thibault2018-02-112-5/+16
| | | | | | | | | | | | PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP is Linux-only. * nscd/connections.c (RWLOCK_INITIALIZER): Define to PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP or PTHREAD_RWLOCK_INITIALIZER if that is not available. (dbs): Use RWLOCK_INITIALIZER instead of PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP.
* linux/aarch64: sync sys/ptrace.h with Linux 4.15 [BZ #22433]Dmitry V. Levin2018-02-102-8/+7
| | | | | | | | | | | Remove compat-specific constants that were never exported by kernel headers under these names. Before linux commit v3.7-rc1~16^2~1 they were exported with COMPAT_ prefix, and since that commit they are not exported at all. * sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h (__ptrace_request): Remove arm-specific PTRACE_GET_THREAD_AREA, PTRACE_GETHBPREGS, and PTRACE_SETHBPREGS.
* [BZ #22830] malloc_stats: restore cancellation for stderr correctly.Zack Weinberg2018-02-104-1/+227
| | | | | | | | | | | | malloc_stats means to disable cancellation for writes to stderr while it runs, but it restores stderr->_flags2 with |= instead of =, so what it actually does is disable cancellation on stderr permanently. [BZ #22830] * malloc/malloc.c (__malloc_stats): Restore stderr->_flags2 correctly. * malloc/tst-malloc-stats-cancellation.c: New test case. * malloc/Makefile: Add new test case.
* [AArch64] Fix testsuite error due to fpsr/fscr changeWilco Dijkstra2018-02-102-0/+6
| | | | | | Add features.h include for __GNUC_PREREQ. * sysdeps/aarch64/fpu/fpu_control.h: Add features.h to fix build error.
* Add narrowing add functions.Joseph Myers2018-02-1061-4/+24818
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds the narrowing add functions from TS 18661-1 to glibc's libm: fadd, faddl, daddl, f32addf64, f32addf32x, f32xaddf64 for all configurations; f32addf64x, f32addf128, f64addf64x, f64addf128, f32xaddf64x, f32xaddf128, f64xaddf128 for configurations with _Float64x and _Float128; __nldbl_daddl for ldbl-opt. As discussed for the build infrastructure patch, tgmath.h support is deliberately deferred, and FP_FAST_* macros are not applicable without optimized function implementations. Function implementations are added for all relevant pairs of formats (including certain cases of a format and itself where more than one type has that format). The main implementations use round-to-odd, or a trivial computation in the case where both formats are the same or where the wider format is IBM long double (in which case we don't attempt to be correctly rounding). The sysdeps/ieee754/soft-fp implementations use soft-fp, and are used automatically for configurations without exceptions and rounding modes by virtue of existing Implies files. As previously discussed, optimized versions for particular architectures are possible, but not included. i386 gets a special version of f32xaddf64 to avoid problems with double rounding (similar to the existing fdim version), since this function must round just once without an intermediate rounding to long double. (No such special version is needed for any other function, because the nontrivial functions use round-to-odd, which does the intermediate computation with the rounding mode set to round-to-zero, and double rounding is OK except in round-to-nearest mode, so is OK for that intermediate round-to-zero computation.) mul and div will need slightly different special versions for i386 (using round-to-odd on long double instead of precision control) because of the possibility of inexact intermediate results in the subnormal range for double. To reduce duplication among the different function implementations, math-narrow.h gets macros CHECK_NARROW_ADD, NARROW_ADD_ROUND_TO_ODD and NARROW_ADD_TRIVIAL. In the trivial cases and for any architecture-specific optimized implementations, the overhead of the errno setting might be significant, but I think that's best handled through compiler built-in functions rather than providing separate no-errno versions in glibc (and likewise there are no __*_finite entry points for these function provided, __*_finite effectively being no-errno versions at present in most cases). Tested for x86_64 and x86, with both GCC 6 and GCC 7. Tested for mips64 (all three ABIs, both hard and soft float) and powerpc with GCC 7. Tested with build-many-glibcs.py with both GCC 6 and GCC 7. * math/Makefile (libm-narrow-fns): Add add. (libm-test-funcs-narrow): Likewise. * math/Versions (GLIBC_2.28): Add narrowing add functions. * math/bits/mathcalls-narrow.h (add): Use __MATHCALL_NARROW . * math/gen-auto-libm-tests.c (test_functions): Add add. * math/math-narrow.h (CHECK_NARROW_ADD): New macro. (NARROW_ADD_ROUND_TO_ODD): Likewise. (NARROW_ADD_TRIVIAL): Likewise. * sysdeps/ieee754/float128/float128_private.h (__faddl): New macro. (__daddl): Likewise. * sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add fadd and dadd. (CFLAGS-nldbl-dadd.c): New variable. (CFLAGS-nldbl-fadd.c): Likewise. * sysdeps/ieee754/ldbl-opt/Versions (GLIBC_2.28): Add __nldbl_daddl. * sysdeps/ieee754/ldbl-opt/nldbl-compat.h (__nldbl_daddl): New prototype. * manual/arith.texi (Misc FP Arithmetic): Document fadd, faddl, daddl, fMaddfN, fMaddfNx, fMxaddfN and fMxaddfNx. * math/auto-libm-test-in: Add tests of add. * math/auto-libm-test-out-narrow-add: New generated file. * math/libm-test-narrow-add.inc: New file. * sysdeps/i386/fpu/s_f32xaddf64.c: Likewise. * sysdeps/ieee754/dbl-64/s_f32xaddf64.c: Likewise. * sysdeps/ieee754/dbl-64/s_fadd.c: Likewise. * sysdeps/ieee754/float128/s_f32addf128.c: Likewise. * sysdeps/ieee754/float128/s_f64addf128.c: Likewise. * sysdeps/ieee754/float128/s_f64xaddf128.c: Likewise. * sysdeps/ieee754/ldbl-128/s_daddl.c: Likewise. * sysdeps/ieee754/ldbl-128/s_f64xaddf128.c: Likewise. * sysdeps/ieee754/ldbl-128/s_faddl.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/s_daddl.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/s_faddl.c: Likewise. * sysdeps/ieee754/ldbl-96/s_daddl.c: Likewise. * sysdeps/ieee754/ldbl-96/s_faddl.c: Likewise. * sysdeps/ieee754/ldbl-opt/nldbl-dadd.c: Likewise. * sysdeps/ieee754/ldbl-opt/nldbl-fadd.c: Likewise. * sysdeps/ieee754/soft-fp/s_daddl.c: Likewise. * sysdeps/ieee754/soft-fp/s_fadd.c: Likewise. * sysdeps/ieee754/soft-fp/s_faddl.c: Likewise. * sysdeps/powerpc/fpu/libm-test-ulps: Update. * sysdeps/mach/hurd/i386/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/riscv/rv64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
* Fix narrowing function tests build for powerpc64le.Joseph Myers2018-02-102-0/+16
| | | | | | | | | | | | | | | | | | | | Testing narrowing functions with build-many-glibcs.py showed up a further testsuite fix needed to enable building such functions for powerpc64le: tests test-<narrower-type>-float128-<function> (and likewise for float64x) needed the same special handling for powerpc64le as test-float128-* and test-float64x-*. This patch adds that special handling. Tested with build-many-glibcs.py for powerpc64le in conjunction with the main patch adding narrowing add functions. * sysdeps/powerpc/powerpc64le/Makefile [$(subdir) = math] (f128-pairs): New variable. [$(subdir) = math] ($(foreach suf,$(all-object-suffixes),$(foreach pair,$(f128-pairs),$(objpfx)test-$(pair)%$(suf)))): Add -mfloat128 to CFLAGS. [$(subdir) = math] ($(foreach pair,$(f128-pairs),test-$(pair)%)): Also make tests add $(f128-loader-link) to gnulib-tests.
* [RISC-V] Fix parsing flags in ELF64 files.DJ Delorie2018-02-092-1/+8
| | | | | | | | | | | | | | When ldconfig reads Elf64 files to determine the ABI, it used the Elf32 type, so read the wrong location, and stored the wrong ABI type in the cache, making the cache useless. This patch uses an Elf64 type for Elf64 objects instead. Note that pre-patch caches might need to be manually removed and regenerated to get the correct ABIs stored. [BZ #22827] * sysdeps/unix/sysv/linux/riscv/readelflib.c (process_elf_file): Use 64-bit ELF type for 64-bit ELF objects.
* Handle narrowing function sNaN test disabling based on argument format.Joseph Myers2018-02-094-1/+13
| | | | | | | | | | | | | | | | | Testing narrowing functions for x86_64 with GCC 6 showed up a further testsuite fix needed: there is no _Float128 sNaN support before GCC 7 on x86_64 / x86, and the existing tests of SNAN_TESTS only checked it for the return type, not for the argument type. This patch fixes the code to check SNAN_TESTS (ARG_FLOAT) as well (in a variable set in libm-test-driver.c, since libm-test-support.c is compiled only once for each choice of FLOAT). Tested for x86_64 and x86 with GCC 6 in conjunction with the main patch adding narrowing add functions. * math/libm-test-driver.c (snan_tests_arg): New variable. * math/libm-test-support.h (snan_tests_arg): New declaration. * math/libm-test-support.c (enable_test): Check snan_tests_arg.
* Add test infrastructure for narrowing libm functions.Joseph Myers2018-02-0927-57/+668
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch continues preparations for adding TS 18661-1 narrowing libm functions by adding the required testsuite infrastructure to test such functions through the libm-test infrastructure. That infrastructure is based around testing for a single type, FLOAT. For the narrowing functions, FLOAT, the "main" type for testing, is the function return type; the argument type is ARG_FLOAT. This is consistent with how the code built once for each type, libm-test-support.c, depends on FLOAT for such things as calculating ulps errors in results but can already handle different argument types (pointers, integers, long double for nexttoward). Makefile machinery is added to handle building tests for all pairs of types for which there are narrowing functions (as with non-narrowing functions, aliases are tested just the same as the functions they alias). gen-auto-libm-tests gains a --narrow option for building outputs for narrowing functions (so narrowing sqrt and fma will share the same inputs as non-narrowing, but gen-auto-libm-tests will be run with and without that option to generate different output files). In the narrowing case, the auto-libm-test-out-narrow-* files include annotations for each test about what properties ARG_FLOAT must have to be able to represent all the inputs for that test; those annotations result in calls to the TEST_COND_arg_fmt macro. gen-libm-test.pl has some minor updates to handle narrowing tests (for example, arguments in such tests must be surrounded by ARG_LIT calls instead of LIT calls). Various new macros are added to the C test support code (for example, sNaN initializers need to be properly typed, so arg_snan_value is added; other such arg_* macros are added as it seems cleanest to do so, though some are not strictly required). Special-casing of the ibm128 format to allow for its limitations is adjusted to handle it as the argument format as well as as the result format; thus, the tests of the new functions allow nonzero ulps only in the case where ibm128 is the argument format, as otherwise the functions correspond to fully-defined IEEE operations. The ulps in question appear as e.g. 'Function: "add_ldouble"' in libm-test-ulps (with 1ulp errors then listed for double and float for that function in powerpc); no support is added to generate corresponding faddl / daddl ulps listings in the ulps table in the manual. For the previous patch, I noted the need to avoid spurious macro expansions of identifiers such as "add". A test test-narrow-macros.c is added to verify such macro expansions are successfully avoided, and there is also a -mlong-double-64 version of that test for ldbl-opt. This test is set up to cover the full set of relevant identifiers from the start rather than adding functions one at a time as each function group is added. Tested for x86_64 (this patch in isolation, as well as testing for various configurations in conjunction with the actual addition of "add" functions). * math/Makefile (test-type-pairs): New variable. (test-type-pairs-f64xf128-yes): Likewise. (tests): Add test-narrow-macros. (libm-test-funcs-narrow): New variable. (libm-test-c-narrow): Likewise. (generated): Add $(libm-test-c-narrow). (libm-tests-base-narrow): New variable. (libm-tests-narrow): Likewise. (libm-tests): Add $(libm-tests-narrow). (libm-tests-for-type): Handle $(libm-tests-narrow). (libm-test-c-narrow-obj): New variable. ($(libm-test-c-narrow-obj)): New rule. ($(foreach t,$(libm-tests-narrow),$(objpfx)$(t).c)): Likewise. ($(foreach f,$(libm-test-funcs-narrow),$(objpfx)$(o)-$(f).o)): Use $(o-iterator) to set dependencies and CFLAGS. * math/gen-auto-libm-tests.c: Document use for narrowing functions. (output_for_one_input_case): Take argument NARROW. (generate_output): Likewise. Update call to output_for_one_input_case. (main): Take --narrow option. Update call to generate_output. * math/gen-libm-test.pl (_apply_lit): Take macro name as argument. (apply_lit): Update call to _apply_lit. (apply_arglit): New function. (parse_args): Handle "a" arguments. (parse_auto_input): Handle format names using ":". * math/README.libm-test: Document "a" parameter type. * math/libm-test-support.h (ARG_TYPE_MIN): New macro. (ARG_TYPE_TRUE_MIN): Likewise. (ARG_TYPE_MAX): Likwise. (ARG_MIN_EXP): Likewise. (ARG_MAX_EXP): Likewise. (ARG_MANT_DIG): Likewise. (TEST_COND_arg_ibm128): Likewise. (TEST_COND_ibm128_libgcc): Define conditional on [ARG_FLOAT]. (TEST_COND_arg_fmt): New macro. (init_max_error): Update prototype. * math/libm-test-support.c (test_ibm128): New variable. (init_max_error): Take argument testing_ibm128 and set test_ibm128 instead of using [TEST_COND_ibm128] conditional. (test_exceptions): Use test_ibm128 instead of TEST_COND_ibm128. * math/libm-test-driver.c (STR_ARG_FLOAT): New macro. [TEST_NARROW] (TEST_MSG): New definition. (arg_plus_zero): New macro. (arg_minus_zero): Likewise. (arg_plus_infty): Likewise. (arg_minus_infty): Likewise. (arg_qnan_value_pl): Likewise. (arg_qnan_value): Likewise. (arg_snan_value_pl): Likewise. (arg_snan_value): Likewise. (arg_max_value): Likewise. (arg_min_value): Likewise. (arg_min_subnorm_value): Likewise. [ARG_FLOAT] (struct test_aa_f_data): New struct type. (RUN_TEST_LOOP_aa_f): New macro. (TEST_SUFF): New macro. (TEST_SUFF_STR): Likewise. [!TEST_MATHVEC] (VEC_SUFF): Don't define. (TEST_COND_any_ibm128): New macro. (START): Use TEST_SUFF and TEST_SUFF_STR in initializer for this_func. Update call to init_max_error. * math/test-double.h (FUNC_NARROW_PREFIX): New macro. * math/test-float.h (FUNC_NARROW_PREFIX): Likewise. * math/test-float128.h (FUNC_NARROW_PREFIX): Likewise. * math/test-float32.h (FUNC_NARROW_PREFIX): Likewise. * math/test-float32x.h (FUNC_NARROW_PREFIX): Likewise. * math/test-float64.h (FUNC_NARROW_PREFIX): Likewise. * math/test-float64x.h (FUNC_NARROW_PREFIX): Likewise. * math/test-math-scalar.h (TEST_NARROW): Likewise. * math/test-math-vector.h (TEST_NARROW): Likewise. * math/test-arg-double.h: New file. * math/test-arg-float128.h: Likewise. * math/test-arg-float32x.h: Likewise. * math/test-arg-float64.h: Likewise. * math/test-arg-float64x.h: Likewise. * math/test-arg-ldouble.h: Likewise. * math/test-math-narrow.h: Likewise. * math/test-narrow-macros.c: Likewise. * sysdeps/ieee754/ldbl-opt/test-narrow-macros-ldbl-64.c: Likewise. * sysdeps/ieee754/ldbl-opt/Makefile (tests): Add test-narrow-macros-ldbl-64. (CFLAGS-test-narrow-macros-ldbl-64.c): New variable.
* Add build infrastructure for narrowing libm functions.Joseph Myers2018-02-098-1/+516
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TS 18661-1 defines libm functions that carry out an operation (+ - * / sqrt fma) on their arguments and return a result rounded to a (usually) narrower type, as if the original result were computed to infinite precision and then rounded directly to the result type without any intermediate rounding to the argument type. For example, fadd, faddl and daddl for addition. These are the last remaining TS 18661-1 functions left to be added to glibc. TS 18661-3 extends this to corresponding functions for _FloatN and _FloatNx types. As functions parametrized by two rather than one varying floating-point types, these functions require infrastructure in glibc that was not required for previous libm functions. This patch provides such infrastructure - excluding test support, and actual function implementations, which will be in subsequent patches. Declaring the functions uses a header bits/mathcalls-narrow.h, which is included many times, for each relevant pair of types. This will end up containing macro calls of the form __MATHCALL_NARROW (__MATHCALL_NAME (add), __MATHCALL_REDIR_NAME (add), 2); for each family of narrowing functions. (The structure of this macro call, with the calls to __MATHCALL_NAME and __MATHCALL_REDIR_NAME there rather than in the definition of __MATHCALL_NARROW, arises from the names such as "add" *not* themselves being reserved identifiers - meaning it's necessary to avoid any indirection that would result in a user-defined "add" macro being expanded.) Whereas for existing functions declaring long double functions is disabled if _LIBC in the case where they alias double functions, to facilitate defining the long double functions as aliases of the double ones, there is no such logic for the narrowing functions in this patch. Rather, the files defining such functions are expected to use #define to hide the original declarations of the alias names, to avoid errors about defining aliases with incompatible types. math/Makefile support is added for building the functions (listed in libm-narrow-fns, currently empty) for all relevant pairs of types. An internal header math-narrow.h is added for macros shared between multiple function implementations - currently a ROUND_TO_ODD macro to facilitate writing functions using the round-to-odd implementation approach, and alias macros to create all the required function aliases. libc_feholdexcept_setroundf128 and libc_feupdateenv_testf128 are added for use when required (only for x86_64). float128_private.h support is added for ldbl-128 narrowing functions to be used for _Float128. Certain things are specifically omitted from this patch and the immediate followups. tgmath.h support is deferred; there remain unresolved questions about how the type-generic macros for these functions are supposed to work, especially in the case of arguments of integer type. The math.h / bits/mathcalls-narrow.h logic, and the logic for determining what functions / aliases to define, will need some adjustments to support the sqrt and fma functions, where e.g. f32xsqrtf64 can just be an alias for sqrt rather than a separate function. TS 18661-1 defines FP_FAST_* macros but no support is included for defining them (they won't in general be true without architecture-specific optimized function versions). For each of the function groups (add sub mul div sqrt fma) there are always six functions present (e.g. fadd, faddl, daddl, f32addf64, f32addf32x, f32xaddf64). When _Float64x and _Float128 are supported, there are seven more (e.g. f32addf64x, f32addf128, f64addf64x, f64addf128, f32xaddf64x, f32xaddf128, f64xaddf128). In addition, in the ldbl-opt case there are function names such as __nldbl_daddl (an alias for f32xaddf64, which is not a reserved name in TS 18661-1, only in TS 18661-3), for calls to daddl to be mapped to in the -mlong-double-64 case. (Calls to faddl just get mapped to fadd, and for sqrt and fma there won't be __nldbl_* functions because dsqrtl and dfmal can just be mapped to sqrt and fma with -mlong-double-64.) While there are six or thirteen functions present in each group (plus __nldbl_* names only as an ABI, not an API), not all are distinct; they fall in various groups of aliases. There are two distinct versions built if long double has the same format as double; four if they have distinct formats but there is no _Float64x or _Float128 support; five if long double has binary128 format; seven when _Float128 is distinct from long double. Architecture-specific optimized versions are possible, but not included in my patches. For example, IA64 generally supports narrowing the result of most floating-point instructions; Power ISA 2.07 (POWER8) supports double values as arguments to float instructions, with the results narrowed as expected; Power ISA 3 (POWER9) supports round-to-odd for float128 instructions, so meaning that approach can be used without needing to set and restore the rounding mode and test "inexact". I intend to leave any such optimized versions to the architecture maintainers. Generally in such cases it would also make sense for calls to these functions to be expanded inline (given -fno-math-errno); I put a suggestion for TS 18661-1 built-in functions at <https://gcc.gnu.org/wiki/SummerOfCode>. Tested for x86_64 (this patch in isolation, as well as testing for various configurations in conjunction with further patches). * math/bits/mathcalls-narrow.h: New file. * include/bits/mathcalls-narrow.h: Likewise. * math/math-narrow.h: Likewise. * math/math.h (__MATHCALL_NARROW_ARGS_1): New macro. (__MATHCALL_NARROW_ARGS_2): Likewise. (__MATHCALL_NARROW_ARGS_3): Likewise. (__MATHCALL_NARROW_NORMAL): Likewise. (__MATHCALL_NARROW_REDIR): Likewise. (__MATHCALL_NARROW): Likewise. [__GLIBC_USE (IEC_60559_BFP_EXT)]: Repeatedly include <bits/mathcalls-narrow.h> with _Mret_, _Marg_ and __MATHCALL_NAME defined. [__GLIBC_USE (IEC_60559_TYPES_EXT)]: Likewise. * math/Makefile (headers): Add bits/mathcalls-narrow.h. (libm-narrow-fns): New variable. (libm-narrow-types-basic): Likewise. (libm-narrow-types-ldouble-yes): Likewise. (libm-narrow-types-float128-yes): Likewise. (libm-narrow-types-float128-alias-yes): Likewise. (libm-narrow-types): Likewise. (libm-routines): Add narrowing functions. * sysdeps/i386/fpu/fenv_private.h [__x86_64__] (libc_feholdexcept_setroundf128): New macro. [__x86_64__] (libc_feupdateenv_testf128): Likewise. * sysdeps/ieee754/float128/float128_private.h: Include <math/math-narrow.h>. [libc_feholdexcept_setroundf128] (libc_feholdexcept_setroundl): Undefine and redefine. [libc_feupdateenv_testf128] (libc_feupdateenv_testl): Likewise. (libm_alias_float_ldouble): Undefine and redefine. (libm_alias_double_ldouble): Likewise.
* Remove unused math/Makefile variable libm-test-incs.Joseph Myers2018-02-092-2/+4
| | | | | | | | | The math/Makefile variable libm-test-incs was formerly used, but no longer is. This patch removes it. Tested for x86_64. * math/Makefile [$(PERL) != no] (libm-test-incs): Remove variable.
* [AArch64] Use builtins for fpcr/fpsrWilco Dijkstra2018-02-092-4/+16
| | | | | | | | | | Since GCC has support for accessing FPSR/FPCR, use them when possible so that the asm instructions can be removed eventually. Although GCC 5 supports the builtins, it has an optimization bug, so use them from GCC 6 onwards. * sysdeps/aarch64/fpu/fpu_control.h: Use builtins for accessing FPCR/FPSR.
* manual: Fix Texinfo warnings about improper node names.Rical Jasan2018-02-094-6/+12
| | | | | | | | | | | | | | | A number of cross-references to the GCC info manual cause Texinfo warnings; e.g.: ./creature.texi:11: warning: @xref node name should not contain `.' This is due to "gcc.info" being used in the INFO-FILE-NAME (fourth) argument. Changing it to "gcc" removes these warnings. (Manually confirmed equivalent behaviour for make info, html, and pdf.) * manual/creature.texi: Convert references to gcc.info to gcc. * manual/stdio.texi: Likewise. * manual/string.texi: Likewise.
* Define char16_t, char32_t consistently with uint_least16_t, uint_least32_t ↵Joseph Myers2018-02-076-31/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (bug 17979). As noted in bug 17979 (and as I noted earlier in <https://sourceware.org/ml/libc-alpha/2012-02/msg00647.html>), uchar.h has gratuitously complicated code to determine the types for char16_t and char32_t, and to reject including that header for pre-C11 compilers not defining __CHAR16_TYPE__ and __CHAR32_TYPE__. Since those types are always required to match uint_least16_t and uint_least32_t, which glibc knows how to define without reference to such predefined macros, it's safe just to define those types the same as the *least* types are defined in stdint.h, so allowing the header to work with (for example) GCC 4.3. This patch implements that. bits/types.h is made to define __int_leastN_t and __uint_leastN_t so the logic for those types can stay in a single place, and stdint.h is made to use those __*_t to define the public *_t types. uchar.h is then made to use __uint_least16_t and __uint_least32_t to define char16_t and char32_t, so simplifying the logic there. A new test is added that verifies the types chosen for char16_t and char32_t do indeed match the types the compiler uses for u"" and U"" string literals. Tested for x86_64. (I have not tested with any of the older compilers for which this would actually make a difference to whether you can include uchar.h.) [BZ #17979] * posix/bits/types.h (__int_least8_t): New typedef. (__uint_least8_t): Likewise. (__int_least16_t): Likewise. (__uint_least16_t): Likewise. (__int_least32_t): Likewise. (__uint_least32_t): Likewise. (__int_least64_t): Likewise. (__uint_least64_t): Likewise. * sysdeps/generic/stdint.h (int_least8_t): Define using __int_least8_t. (int_least16_t): Define using __int_least16_t. (int_least32_t): Define using __int_least32_t. (int_least64_t): Define using __int_least64_t. (uint_least8_t): Define using __uint_least8_t. (uint_least16_t): Define using __uint_least16_t. (uint_least32_t): Define using __uint_least32_t. (uint_least64_t): Define using __uint_least64_t. * wcsmbs/uchar.h: Include <bits/types.h>. (char16_t): Define using __uint_least16_t conditional only on [!__USE_ISOCXX11]. (char32_t): Define using __uint_least32_t conditional only on [!__USE_ISOCXX11]. * wcsmbs/test-char-types.c: New file. * wcsmbs/Makefile (tests): Add test-char-types.
* Use MPFR 4.0.1 in build-many-glibcs.py.Joseph Myers2018-02-072-1/+6
| | | | | * scripts/build-many-glibcs.py (Context.checkout): Default MPFR version to 4.0.1.