Commit Graph

30657 Commits

Author SHA1 Message Date
Stefan Liebler 98ac7b7c85 Use libc_ifunc macro for clock_* symbols in librt.
This patch uses the libc_ifunc macro to create already existing ifunc functions
clock_getres, clock_gettime, clock_settime, clock_getcpuclockid and
clock_nanosleep. If HAVE_IFUNC is defined, the macro COMPAT_REDIRECT uses
the libc_ifunc macro.
Furthermore some whitespace damage is cleaned.

ChangeLog:

	* rt/clock-compat.c (COMPAT_REDIRECT): Use libc_ifunc macro.
2016-10-07 10:12:47 +02:00
Stefan Liebler a4d7fe35cd ppc: Use libc_ifunc macro for time, gettimeofday.
This patch uses the libc_ifunc_hidden macro to create already existing ifunc functions
time and gettimeofday on power. This way, the libc_hidden_def macro can be used
instead of inline assemblies.
On ppc32, the __GI_* symbols do not target the ifunc symbol and thus the
redirection construct has to be applied here.

ChangeLog:

	* sysdeps/unix/sysv/linux/powerpc/gettimeofday.c (__gettimeofday):
	Use libc_ifunc_hidden and libc_hidden_def macro. Redirect ifunced function
	in header for using it as type for ifunc function because __GI_* symbols
	for ppc32 do not target the ifunc symbols.
	* sysdeps/unix/sysv/linux/powerpc/time.c (time): Likewise.
2016-10-07 10:12:46 +02:00
Stefan Liebler e23faea6ae i386, x86: Use libc_ifunc macro for time, gettimeofday.
This patch uses the libc_ifunc_hidden macro to create already existing ifunc functions
time and gettimeofday on intel. This way, the libc_hidden_def macro can be used
instead of the libc_ifunc_hidden_def one which was only used here. Thus the
macro is removed from libc-symbols.h.
On i386, the __GI_* symbols do not target the ifunc symbol and thus the
redirection construct has to be applied here.

ChangeLog:

	* sysdeps/unix/sysv/linux/x86/gettimeofday.c (__gettimeofday):
	Use libc_ifunc_hidden macro. Use libc_hidden_def instead of
	libc_ifunc_hidden_def.
	* sysdeps/unix/sysv/linux/x86/time.c (time): Likewise.
	* sysdeps/unix/sysv/linux/i386/gettimeofday.c (__gettimeofday):
	Redirect ifunced function in header for using it as type of ifunc'ed
	function. Redefine libc_hidden_def to use fallback non ifunc'ed
	function for __GI_* symbol.
	* sysdeps/unix/sysv/linux/i386/time.c (time): Likewise.
	* include/libc-symbols.h
	(libc_ifunc_hidden_def, libc_ifunc_hidden_def1): Delete macro.
2016-10-07 10:12:42 +02:00
Stefan Liebler 18d6c45e12 s390: Refactor ifunc resolvers due to false debuginfo.
This patch adjusts the s390 specific ifunc helper macros in ifunc-resolve.h to
use the common __ifunc macro, which uses gcc attribute ifunc to get rid of the
false debuginfo. Therefore the redirection construct is applied where needed.

Perhaps in future we can switch some of the internal symbols __GI_* from the
fallback variant to the ifunc function. But this change is not
straightforward due to a segmentation fault while linking libc.so with older
binutils on s390.

ChangeLog:

	[BZ #20478]
	* sysdeps/s390/multiarch/ifunc-resolve.h
	(s390_vx_libc_ifunc2, s390_libc_ifunc): Use __ifunc from libc-symbols.h
	to create ifunc symbols.
	(s390_vx_libc_ifunc_init, s390_vx_libc_ifunc_redirected
	, s390_vx_libc_ifunc2_redirected, s390_libc_ifunc_init): New define.
	* sysdeps/s390/multiarch/memchr.c: Redirect ifunced function in header
	for using it as type for ifunc function.
	* sysdeps/s390/multiarch/mempcpy.c: Likewise.
	* sysdeps/s390/multiarch/rawmemchr.c: Likewise.
	* sysdeps/s390/multiarch/stpcpy.c: Likewise.
	* sysdeps/s390/multiarch/stpncpy.c: Likewise.
	* sysdeps/s390/multiarch/strcat.c: Likewise.
	* sysdeps/s390/multiarch/strchr.c: Likewise.
	* sysdeps/s390/multiarch/strcmp.c: Likewise.
	* sysdeps/s390/multiarch/strcpy.c: Likewise.
	* sysdeps/s390/multiarch/strcspn.c: Likewise.
	* sysdeps/s390/multiarch/strlen.c: Likewise.
	* sysdeps/s390/multiarch/strncmp.c: Likewise.
	* sysdeps/s390/multiarch/strncpy.c: Likewise.
	* sysdeps/s390/multiarch/strnlen.c: Likewise.
	* sysdeps/s390/multiarch/strpbrk.c: Likewise.
	* sysdeps/s390/multiarch/strrchr.c: Likewise.
	* sysdeps/s390/multiarch/strspn.c: Likewise.
	* sysdeps/s390/multiarch/wcschr.c: Likewise.
	* sysdeps/s390/multiarch/wcscmp.c: Likewise.
	* sysdeps/s390/multiarch/wcspbrk.c: Likewise.
	* sysdeps/s390/multiarch/wcsspn.c: Likewise.
	* sysdeps/s390/multiarch/wmemchr.c: Likewise.
	* sysdeps/s390/multiarch/wmemset.c: Likewise.
	* sysdeps/s390/s390-32/multiarch/memcmp.c: Likewise.
	* sysdeps/s390/s390-32/multiarch/memcpy.c: Likewise.
	* sysdeps/s390/s390-32/multiarch/memset.c: Likewise.
	* sysdeps/s390/s390-64/multiarch/memcmp.c: Likewise.
	* sysdeps/s390/s390-64/multiarch/memcpy.c: Likewise.
	* sysdeps/s390/s390-64/multiarch/memset.c: Likewise.
2016-10-07 10:11:21 +02:00
Stefan Liebler 00980d845f Use gcc attribute ifunc in libc_ifunc macro instead of inline assembly due to false debuginfo.
The current s390 ifunc resolver for vector optimized functions and the common
libc_ifunc macro in include/libc-symbols.h uses something like that to generate ifunc'ed functions:
extern void *__resolve___strlen(unsigned long int dl_hwcap) asm (strlen);
asm (".type strlen, %gnu_indirect_function");

This leads to false debug information:
objdump --dwarf=info libc.so:
...
<1><1e6424>: Abbrev Number: 43 (DW_TAG_subprogram)
    <1e6425>   DW_AT_external    : 1
    <1e6425>   DW_AT_name        : (indirect string, offset: 0x1146e): __resolve___strlen
    <1e6429>   DW_AT_decl_file   : 1
    <1e642a>   DW_AT_decl_line   : 23
    <1e642b>   DW_AT_linkage_name: (indirect string, offset: 0x1147a): strlen
    <1e642f>   DW_AT_prototyped  : 1
    <1e642f>   DW_AT_type        : <0x1e4ccd>
    <1e6433>   DW_AT_low_pc      : 0x998e0
    <1e643b>   DW_AT_high_pc     : 0x16
    <1e6443>   DW_AT_frame_base  : 1 byte block: 9c     (DW_OP_call_frame_cfa)
    <1e6445>   DW_AT_GNU_all_call_sites: 1
    <1e6445>   DW_AT_sibling     : <0x1e6459>
 <2><1e6449>: Abbrev Number: 44 (DW_TAG_formal_parameter)
    <1e644a>   DW_AT_name        : (indirect string, offset: 0x1845): dl_hwcap
    <1e644e>   DW_AT_decl_file   : 1
    <1e644f>   DW_AT_decl_line   : 23
    <1e6450>   DW_AT_type        : <0x1e4c8d>
    <1e6454>   DW_AT_location    : 0x122115 (location list)
...

The debuginfo for the ifunc-resolver function contains the DW_AT_linkage_name
field, which names the real function name "strlen". If you perform an inferior
function call to strlen in lldb, then it fails due to something like that:
"error: no matching function for call to 'strlen'
candidate function not viable: no known conversion from 'const char [6]'
to 'unsigned long' for 1st argument"

The unsigned long is the dl_hwcap argument of the resolver function.
The strlen function itself has no debufinfo.

The s390 ifunc resolver for memset & co uses something like that:
asm (".globl FUNC"
     ".type FUNC, @gnu_indirect_function"
     ".set FUNC, __resolve_FUNC");

This way the debuginfo for the ifunc-resolver function does not conain the
DW_AT_linkage_name field and the real function has no debuginfo, too.

Using this strategy for the vector optimized functions leads to some troubles
for functions like strnlen. Here we have __strnlen and a weak alias strnlen.
The __strnlen function is the ifunc function, which is realized with the asm-
statement above. The weak_alias-macro can't be used here due to undefined symbol:
gcc ../sysdeps/s390/multiarch/strnlen.c -c ...
In file included from <command-line>:0:0:
../sysdeps/s390/multiarch/strnlen.c:28:24: error: ‘strnlen’ aliased to undefined symbol ‘__strnlen’
 weak_alias (__strnlen, strnlen)
                        ^
./../include/libc-symbols.h:111:26: note: in definition of macro ‘_weak_alias’
   extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
                          ^
../sysdeps/s390/multiarch/strnlen.c:28:1: note: in expansion of macro ‘weak_alias’
 weak_alias (__strnlen, strnlen)
 ^
make[2]: *** [build/string/strnlen.o] Error 1

As the __strnlen function is defined with asm-statements the function name
__strnlen isn't known by gcc. But the weak alias can also be done with an
asm statement to resolve this issue:
__asm__ (".weak  strnlen\n\t"
         ".set   strnlen,__strnlen\n");

In order to use the weak_alias macro, gcc needs to know the ifunc function. The
minimum gcc to build glibc is currently 4.7, which supports attribute((ifunc)).
See https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Function-Attributes.html.
It is only supported if gcc is configured with --enable-gnu-indirect-function
or gcc supports it by default for at least intel and s390x architecture.
This patch uses the old behaviour if gcc support is not available.
Usage of attribute ifunc is something like that:
__typeof (FUNC) FUNC __attribute__ ((ifunc ("__resolve_FUNC")));

Then gcc produces the same .globl, .type, .set assembler instructions like above.
And the debuginfo does not contain the DW_AT_linkage_name field and there is no
debuginfo for the real function, too.

But in order to get it work, there is also some extra work to do.
Currently, the glibc internal symbol on s390x e.g. __GI___strnlen is not the
ifunc symbol, but the fallback __strnlen_c symbol. Thus I have to omit the
libc_hidden_def macro in strnlen.c (here is the ifunc function __strnlen)
because it is already handled in strnlen-c.c (here is __strnlen_c).

Due to libc_hidden_proto (__strnlen) in string.h, compiling fails:
gcc ../sysdeps/s390/multiarch/strnlen.c -c ...
In file included from <command-line>:0:0:
../sysdeps/s390/multiarch/strnlen.c:53:24: error: ‘strnlen’ aliased to undefined symbol ‘__strnlen’
 weak_alias (__strnlen, strnlen)
                        ^
./../include/libc-symbols.h:111:26: note: in definition of macro ‘_weak_alias’
   extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
                          ^
../sysdeps/s390/multiarch/strnlen.c:53:1: note: in expansion of macro ‘weak_alias’
 weak_alias (__strnlen, strnlen)
 ^
make[2]: *** [build/string/strnlen.os] Error 1

I have to redirect the prototypes for __strnlen in string.h and create a copy
of the prototype for using as ifunc function:
__typeof (__redirect___strnlen) __strnlen __attribute__ ((ifunc ("__resolve_strnlen")));
weak_alias (__strnlen, strnlen)

This way there is no trouble with the internal __GI_* symbols.
Glibc builds fine with this construct and the debuginfo is "correct".
For functions without a __GI_* symbol like memccpy this redirection is not needed.

This patch adjusts the common libc_ifunc and libm_ifunc macro to use gcc
attribute ifunc. Due to this change, the macro users where the __GI_* symbol
does not target the ifunc symbol have to be prepared with the redirection
construct.
Furthermore a configure check to test gcc support is added. If it is not supported,
the old behaviour is used.

This patch also prepares the libc_ifunc macro to be useable in s390-ifunc-macro.
The s390 ifunc-resolver-functions do have an hwcaps parameter and not all
resolvers need the same initialization code. The next patch in this series
changes the s390 ifunc macros to use this common one.

ChangeLog:

	* include/libc-symbols.h (__ifunc_resolver):
	New macro is used by __ifunc* macros.
	(__ifunc): New macro uses gcc attribute ifunc or inline assembly
	depending on HAVE_GCC_IFUNC.
	(libc_ifunc, libm_ifunc): Use __ifunc as base macro.
	(libc_ifunc_redirected, libc_ifunc_hidden, libm_ifunc_init): New macro.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite.c:
	Redirect ifunced function in header for using as type for ifunc function.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finitef.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinff.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/memcmp.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/memcpy.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/memmove.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/memset.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/rawmemchr.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/strchr.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/strlen.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/strncmp.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/multiarch/strnlen.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_finitef.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinff.c: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/memcmp.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/mempcpy.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/rawmemchr.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/stpncpy.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strcat.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strchr.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strcmp.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strcpy.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strncmp.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strncpy.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strnlen.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strrchr.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/strstr.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/wcschr.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnanf.c:
	Add libc_hidden_def() and use libc_ifunc_hidden() macro
	instead of libc_ifunc() macro.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnanf.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/stpcpy.c: Likewise.
2016-10-07 10:03:20 +02:00
Stefan Liebler 022dfdce00 Add configure check to test if gcc supports attribute ifunc.
This patch adds a configure check to test if gcc supports attribute ifunc.
The support can either be enabled in <gcc-src>/gcc/config.gcc for one
architecture in general by setting default_gnu_indirect_function variable to yes
or by configuring gcc with --enable-gnu-indirect-function.

The next patch rewrites libc_ifunc macro to use gcc attribute ifunc instead
of inline assembly to generate the IFUNC symbols due to false debuginfo.

If gcc does not support attribute ifunc, the old approach for generating
ifunc'ed symbols is used. Then the debug-information is false. Thus it is
recommended to use a gcc with indirect function support (See notes in INSTALL).
After this patch-series these inline assemblies for ifunc-handling are not
scattered in multiple files but are used only indirect via ifunc-macros
and can simply removed in libc-symbols.h in future.

If glibc is configured with --enable-multi-arch and gcc does not support
attribute ifunc, a configure warning is dumped!

ChangeLog:

	* config.h.in (HAVE_GCC_IFUNC): New undef.
	* configure.ac: Add check if gcc supports attribute ifunc feature.
	* configure: Regenerated.
	* manual/install.texi: Add recommendation for gcc with
	indirect-function support.
	* INSTALL: Regenerated.
2016-10-07 10:02:59 +02:00
Joseph Myers 1e7c8fcca5 Add iseqsig.
TS 18661-1 adds an iseqsig type-generic comparison macro to <math.h>.
This macro is like the == operator except that unordered operands
result in the "invalid" exception and errno being set to EDOM.

This patch implements this macro for glibc.  Given the need to set
errno, this is implemented with out-of-line functions __iseqsigf,
__iseqsig and __iseqsigl (of which the last only exists at all if long
double is ABI-distinct from double, so no function aliases or compat
support are needed).  The present patch ignores excess precision
issues; I intend to deal with those in a followup patch.  (Like
comparison operators, type-generic comparison macros should *not*
convert operands to their semantic types but should preserve excess
range and precision, meaning that for some argument types and values
of FLT_EVAL_METHOD, an underlying function should be called for a
wider type than that of the arguments.)

The underlying functions are implemented with the type-generic
template machinery.  Comparing x <= y && x >= y is sufficient in ISO C
to achieve an equality comparison with "invalid" raised for unordered
operands (and the results of those two comparisons can also be used to
tell whether errno needs to be set).  However, some architectures have
GCC bugs meaning that unordered comparison instructions are used
instead of ordered ones.  Thus, a mechanism is provided for
architectures to use an explicit call to feraiseexcept to raise
exceptions if required.  If your architecture has such a bug you
should add a fix-fp-int-compare-invalid.h header for it, with a
comment pointing to the relevant GCC bug report; if such a GCC bug is
fixed, that header's contents should have a __GNUC_PREREQ conditional
added so that the workaround can eventually be removed for that
architecture.

Tested for x86_64, x86, mips64, arm and powerpc.

	* math/math.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (iseqsig): New
	macro.
	* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(__iseqsig): New declaration.
	* math/s_iseqsig_template.c: New file.
	* math/Versions (__iseqsigf): New libm symbol at version
	GLIBC_2.25.
	(__iseqsig): Likewise.
	(__iseqsigl): Likewise.
	* math/libm-test.inc (iseqsig_test_data): New array.
	(iseqsig_test): New function.
	(main): Call iseqsig_test.
	* math/Makefile (gen-libm-calls): Add s_iseqsigF.
	* manual/arith.texi (FP Comparison Functions): Document iseqsig.
	* manual/libm-err-tab.pl: Update comment on interfaces without
	ulps tabulated.
	* sysdeps/generic/fix-fp-int-compare-invalid.h: New file.
	* sysdeps/powerpc/fpu/fix-fp-int-compare-invalid.h: Likewise.
	* sysdeps/x86/fpu/fix-fp-int-compare-invalid.h: Likewise.
	* sysdeps/nacl/libm.abilist: Update.
	* 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/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/tilegx/tilegx32/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
2016-10-06 22:19:38 +00:00
Siddhesh Poyarekar 36ee03e6a8 Update comments for some functions in s_sin.c
Update comments for some functions to bring them in sync with what the
functions are actually doing.
2016-10-06 13:09:02 +05:30
Siddhesh Poyarekar 9cb069308c Adjust calls to do_sincos_1 and do_sincos_2 in s_sincos.c
Adjust calls to do_sincos_1 and do_sincos_2 to pass a boolean
shift_quadrant instead of the numeric 0 and 1.

This does not affect codegen.
2016-10-06 12:57:07 +05:30
Siddhesh Poyarekar ead1ef37d2 Make quadrant shift a boolean in reduce_and_compute in s_sin.c
Like the previous change, make the quadrant shift a boolean to make it
clearer that we will do at most a single rotation of the quadrants to
compute the cosine from the sine function.

This does not affect codegen.
2016-10-06 12:54:04 +05:30
Siddhesh Poyarekar 5455692aaf Manual typos: System Databases and Name Service Switch
* manual/nss.texi: Fix typos in the manual.
2016-10-06 12:36:26 +05:30
Rical Jasan be20861940 Manual typos: Contributors to
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/contrib.texi: Fix typos in the manual.
2016-10-06 12:30:03 +05:30
Rical Jasan 6d2857d350 Manual typos: Library Maintenance
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/maint.texi: Fix typos in the manual.
2016-10-06 12:29:11 +05:30
Rical Jasan b55a155f00 Manual typos: Installing
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/install.texi: Fix typos in the manual.
	* INSTALL: Regenerated.
2016-10-06 12:28:45 +05:30
Rical Jasan ae996b9f39 Manual typos: C Language Facilities in the Library
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/lang.texi: Fix typos in the manual.
2016-10-06 12:27:48 +05:30
Rical Jasan 8e52276ef4 Manual typos: Internal probes
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/probes.texi: Fix typos in the manual.
2016-10-06 12:26:35 +05:30
Rical Jasan a309449484 Manual typos: POSIX Threads
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/threads.texi: Fix typos in the manual.
2016-10-06 12:26:06 +05:30
Rical Jasan db5e4e881f Manual typos: Debugging support
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/debug.texi: Fix typos in the manual.
2016-10-06 12:25:38 +05:30
Rical Jasan b8867dabdf Manual typos: DES Encryption and Password Handling
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/crypt.texi: Fix typos in the manual.
2016-10-06 12:25:00 +05:30
Rical Jasan d80cf4a6be Manual typos: System Configuration Parameters
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/conf.texi: Fix typos in the manual.
2016-10-06 12:24:07 +05:30
Rical Jasan 61547c480f Manual typos: System Management
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/sysinfo.texi: Fix typos in the manual.
2016-10-06 12:23:27 +05:30
Rical Jasan 9e302f97d4 Manual typos: Users and Groups
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/users.texi: Fix typos in the manual.
2016-10-06 12:21:46 +05:30
Rical Jasan d72457974d Manual typos: Job Control
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/job.texi: Fix typos in the manual.
2016-10-06 12:20:28 +05:30
Rical Jasan 9cbcfebd02 Manual typos: Processes
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/process.texi: Fix typos in the manual.
2016-10-06 12:20:00 +05:30
Rical Jasan 954cbda0fa Manual typos: The Basic Program/System Interface
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/argp.texi: Fix typos in the manual.
	* manual/getopt.texi: Likewise.
	* manual/startup.texi: Likewise.
2016-10-06 12:19:25 +05:30
Rical Jasan 16c7d1ec26 Manual typos: Signal Handling
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/signal.texi: Fix typos in the manual.
2016-10-06 12:18:05 +05:30
Rical Jasan a96ce75c8e Manual typos: Non-Local Exits
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/setjmp.texi: Fix typos in the manual.
2016-10-06 12:17:29 +05:30
Rical Jasan d3e22d596d Manual typos: Resource Usage and Limitation
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/resource.texi: Fix typos in the manual.
2016-10-06 12:16:53 +05:30
Rical Jasan 9269924c82 Manual typos: Date and Time
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/time.texi: Fix typos in the manual.
2016-10-06 12:14:36 +05:30
Rical Jasan e4fd1876e9 Manual typos: Arithmetic Functions
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/arith.texi: Fix typos in the manual.
2016-10-06 12:12:26 +05:30
Rical Jasan 60843ffbc2 Manual typos: Mathematics
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/math.texi: Fix typos in the manual.
2016-10-06 12:11:08 +05:30
Rical Jasan 56e74aef9c Manual typos: Syslog
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/syslog.texi: Fix typos in the manual.
2016-10-06 12:08:46 +05:30
Rical Jasan dc40b23352 Manual typos: Low-Level Terminal Interface
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/terminal.texi: Fix typos in the manual.
2016-10-06 12:07:28 +05:30
Rical Jasan b57dd24684 Manual typos: Sockets
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/socket.texi: Fix typos in the manual.
2016-10-06 12:05:11 +05:30
Rical Jasan 4ffa3672e1 Manual typos: File System Interface
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/filesys.texi: Fix typos in the manual.
2016-10-06 12:01:51 +05:30
Rical Jasan 9739d2d501 Manual typos: Low-Level Input/Output
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/llio.texi: Fix typos in the manual.
2016-10-06 11:58:02 +05:30
Rical Jasan c703cd7abb Manual typos: Input/Output on Streams
2016-05-06  Rical Jasan  <ricaljasan@pacific.net>

	* manual/stdio.text: Fix typos in the manual.
2016-10-06 11:55:58 +05:30
Siddhesh Poyarekar ba4e688461 Check n instead of k1 to decide on sign of sin/cos result
For k1 in 1 and 3, n can only have values of 0 and 2, so checking k1 &
2 is equivalent to checking n & 2.  We prefer the latter so that we
don't use k1 for anything other than selecting the quadrant in
do_sincos_1, thus dropping it completely.

The previous logic was:

    "Compute sine for the value and based on the new rotated quadrant
     (k1) negate the value if we're in the fourth quadrant."

With this change, the logic now is:

    "Compute sine for the value and negate it if we were either (1) in
     the fourth quadrant or (2) we actually wanted the cosine and were
     in the third quadrant."

	* sysdeps/ieee754/dbl-64/s_sin.c (do_sincos_1): Check N
	instead of K1.
2016-10-06 00:34:26 +05:30
Siddhesh Poyarekar b8b7e5e644 Make the quadrant shift K a bool in do_sincos_* functions
The do_sincos_* functions are helpers to compute sin/cos, where they
get cosine by computing sine for the next quadrant.  This is decided
with the value of K passed to it, which is the amount by which to
shift the quadrant.  Since we will only need the shift to be 0 or 1,
we make K a bool to make that explicit.

	* sysdeps/ieee754/dbl-64/s_sin.c (do_sincos_1): Rename K to
	SHIFT_QUADRANT and make it bool.
	(do_sincos_2): Likewise.
	(sloww): Likewise.
	(sloww1): Likewise.
	(__sin): Adjust calls to do_sincos_1 and do_sincos_2.
	(__cos): Likewise.
2016-10-06 00:33:54 +05:30
Tulio Magno Quites Machado Filho 8028566ed9 powerpc: Regenerate ULPs
* sysdeps/powerpc/fpu/libm-test-ulps: Regenerated.
2016-10-05 08:57:47 -03:00
Joseph Myers ff88ee7edf Fix LONG_WIDTH, ULONG_WIDTH include ordering issue.
As described in
<https://sourceware.org/ml/libc-alpha/2016-10/msg00047.html>, there is
an include ordering issue with the integer width macros in glibc's
<limits.h>, where definitions conditional on LONG_MAX do not work as
intended because when the headers are installed, this part of glibc's
<limits.h> is processed before the part of GCC's <limits.h> that will
define LONG_MAX.  This patch changes the definitions just to use
__WORDSIZE for the expansion of LONG_WIDTH and ULONG_WIDTH rather than
making those definitions conditional on LONG_MAX.

Tested for x86_64 and x86.

	* include/limits.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (LONG_WIDTH):
	Define to __WORDSIZE, not conditional on [LONG_MAX ==
	0x7fffffffL].
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (ULONG_WIDTH): Likewise.
2016-10-04 16:17:59 +00:00
Tulio Magno Quites Machado Filho 22938c4103 powerpc: Installed-header hygiene
Fix powerpc-specific headers:
 - Make it compatible to C89 by replace references to inline by __inline__.
 - Get the definition of sigset_t used by
   sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h.
 - Includes missing header file.
2016-10-04 10:54:40 -03:00
Stefan Liebler 7125ad021d S390: Regenerate ULPs
Regenerated ulps file after recent commit "Use __builtin_fma more in dbl-64 code.".

ChangeLog:

    * sysdeps/s390/fpu/libm-test-ulps: Regenerated.
2016-10-04 15:27:40 +02:00
Joseph Myers dad9a11a93 Add TCP_REPAIR_WINDOW from Linux 4.8.
Linux 4.8 adds TCP_REPAIR_WINDOW to include/uapi/linux/tcp.h.  This
patch adds it to sysdeps/gnu/netinet/tcp.h accordingly, along with
struct tcp_repair_window as requested in
<https://sourceware.org/ml/libc-alpha/2016-10/msg00019.html>.

Tested for x86_64 and x86 (testsuite, and that installed shared
libraries are unchanged by the patch).

	* sysdeps/gnu/netinet/tcp.h (TCP_REPAIR_WINDOW): New macro.
	(struct tcp_repair_window): New type.
2016-10-03 21:01:42 +00:00
Adhemerval Zanella edbdf872ae Fix tst-memstream3 build failure
Add string.h to avoid tst-memstream3 build failure in some environments:

 tst-memstream3.c:32:17: error: implicit declaration of function 'strcmp' [-Werror=implicit-function-declaration]
  # define STRCMP strcmp
                  ^
 tst-memstream3.c:96:7: note: in expansion of macro 'STRCMP'
    if (STRCMP (buf, W("b")) != 0)

Checked on x86_64.

	* libio/tst-memstream3.c: Include string.h.
2016-10-02 10:24:32 -03:00
Adhemerval Zanella 645f97ced4 libio: Multiple fixes for open_{w}memstram (BZ#18241 and BZ#20181)
This patches fixes multiples issues on open_{w}memstream reported on both
BZ#18241 and BZ#20181:

  - failed fseek does not set errno.
  - negative offset in fseek fails even when resulting position is
    a valid one.
  - a flush after write if the current write position is not at the
    end of the stream currupt data.

The main fix is on seek operation for memstream (_IO_{w}str_seekoff), where
both _IO_read_ptr and _IO_read_end pointer are updated if a write operation
has occured (similar to default file operations).  Also, to calculate the
offset on both read and write pointers, a temporary value is instead of
updating the argument supplied value.  Negative offset are valid if resulting
internal pointer is within the range of _IO_{read,write}_base and
_IO_{read,write}_end.

Also POSIX states that a null or wide null shall be appended to the current
buffer iff a write moves the position to a value larger than the current
lenght.  Current implementation appends a null or wide null regardless
of this condition.  This patch fixes it by removing the 'else' condition
on _IO_{w}mem_sync.

Checked on x86_64.

	[BZ #18241]
	[BZ #20181]
	* libio/Makefile (test): Add tst-memstream3 and tst-wmemstream3.
	* libio/memstream.c (_IO_mem_sync): Only append a null byte if
	write position is at the end the buffer.
	* libio/wmemstream.c (_IO_wmem_sync): Likewise.
	* libio/strops.c (_IO_str_switch_to_get_mode): New function.
	(_IO_str_seekoff): Set correct offset from negative displacement and
	set EINVAL for invalid ones.
	* libio/wstrops.c (enlarge_userbuf): Use correct function to calculate
	buffer length.
	(_IO_wstr_switch_to_get_mode): New function.
	(_IO_wstr_seekoff): Set correct offset from negative displacement and
	set EINVAL for invalid ones.
	* libio/tst-memstream3.c: New file.
	* libio/tst-wmemstream3.c: Likewise.
	* manual/examples/memstrm.c: Remove warning when priting size_t.
2016-09-30 09:14:15 -07:00
Joseph Myers f280fa6d17 Use __builtin_fma more in dbl-64 code.
sysdeps/ieee754/dbl-64/dla.h can use a macro DLA_FMS for more
efficient double-width operations when fused multiply-subtract is
supported.  However, this macro is only defined for x86_64,
conditional on architecture-specific __FMA4__.  This patch makes the
code use __builtin_fma conditional on __FP_FAST_FMA, as used elsewhere
in glibc.

Tested for x86_64, x86 and powerpc.  On powerpc (where this is causing
fused operations to be used where they weren't previously) I see an
increase from 1ulp to 2ulp in the imaginary part of clog10:

testing double (without inline functions)
Failure: Test: Imaginary part of: clog10 (0x1.7a858p+0 - 0x6.d940dp-4 i)
Result:
 is:         -1.2237865208199886e-01  -0x1.f5435146bb61ap-4
 should be:  -1.2237865208199888e-01  -0x1.f5435146bb61cp-4
 difference:  2.7755575615628914e-17   0x1.0000000000000p-55
 ulp       :  2.0000
 max.ulp   :  1.0000
Maximal error of real part of: clog10
 is      : 3 ulp
 accepted: 3 ulp
Maximal error of imaginary part of: clog10
 is      : 2 ulp
 accepted: 1 ulp

This is actually resulting from atan2 becoming *more* accurate (atan2
(-0x6.d940dp-4, 0x1.7a858p+0) should ideally be -0x1.208cd6e841554p-2
but was -0x1.208cd6e841555p-2 from a powerpc libm built before this
change, and is -0x1.208cd6e841554p-2 from a powerpc libm built after
this change).  Since these functions are not expected to be correctly
rounding by glibc's accuracy goals, neither result is a problem, but
this does imply that some of this code, although designed to be
correctly rounding, is not in fact correctly rounding (possibly
because of GCC creating fused operations where the code does not
expect it, something we've only disabled for specific functions where
it was found to cause large errors).  (Of course as previously
discussed I think we should remove the slow cases where an error
analysis shows this wouldn't increase the errors much above 0.5ulp;
it's only functions such as cratan2 that are expected to be correctly
rounding, not atan2.)

	* sysdeps/ieee754/dbl-64/dla.h [__FP_FAST_FMA] (DLA_FMS): Define
	macro to use __builtin_fma.
	* sysdeps/x86_64/fpu/dla.h: Remove file.
2016-09-30 15:49:51 +00:00
Joseph Myers 8278d50ce7 Fix ldbl-128ibm iscanonical for -mlong-double-64.
This patch fixes the ldbl-128ibm version of the iscanonical macro not
to use __iscanonicall when long double = double (-mlong-double-64).

Tested for powerpc.

	* sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h
	[__NO_LONG_DOUBLE_MATH] (__iscanonicall): Do not declare.
	[__NO_LONG_DOUBLE_MATH] (iscanonical): Define to evaluate to 1.
2016-09-30 15:08:08 +00:00
Carlos O'Donell d61ef7352b Bug 20292 - Simplify and test _dl_addr_inside_object
The function _dl_addr_inside_object is simplified by removing
the conditional 'reladdr - l->l_phdr[n].p_vaddr >= 0' which is
always true. The function is refactored into it's own object file
and a unit test added to verify the correct behaviour of the
function.
2016-09-30 01:36:56 -04:00
Joseph Myers 29cb929332 Add iscanonical.
TS 18661-1 adds an iscanonical classification macro to <math.h>.

The motivation for this is decimal floating-point, where some values
have both canonical and noncanonical encodings.  For IEEE binary
interchange formats, all encodings are canonical.  For x86/m68k
ldbl-96, and for ldbl-128ibm, there are encodings that do not
represent any valid value of the type; although formally iscanonical
does not need to handle trap representations (and so could just always
return 1), it seems useful, and in line with the description in the TS
of "representations that are extraneous to the floating-point model"
as being non-canonical (as well as "redundant representations of some
or all of its values"), for it to detect those representations and
return 0 for them.

This patch adds iscanonical to glibc.  It goes in a header
<bits/iscanonical.h>, included under appropriate conditions in
<math.h>.  The default header version just evaluates the argument
(converted to its semantic type, though current GCC will probably
discard that conversion and any exceptions resulting from it) and
returns 1.  ldbl-96 and ldbl-128ibm then have versions of the header
that call a function __iscanonicall for long double (the sizeof-based
tests will of course need updating for float128 support, like other
such type-generic macro implementations).  The ldbl-96 version of
__iscanonicall has appropriate conditionals to reflect the differences
in the m68k version of that format (where the high mantissa bit may be
either 0 or 1 when the exponent is 0 or 0x7fff).  Corresponding tests
for those formats are added as well.  Other architectures do not have
any new functions added because just returning 1 is correct for all
their floating-point formats.

Tested for x86_64, x86, mips64 (to test the default macro version) and
powerpc.

	* math/math.h [__GLIBC_USE (IEC_60559_BFP_EXT)]: Include
	<bits/iscanonical.h>.
	* bits/iscanonical.h: New file.
	* math/s_iscanonicall.c: Likewise.
	* math/Versions (__iscanonicall): New libm symbol at version
	GLIBC_2.25.
	* math/libm-test.inc (iscanonical_test_data): New array.
	(iscanonical_test): New function.
	(main): Call iscanonical_test.
	* math/Makefile (headers): Add bits/iscanonical.h.
	(type-ldouble-routines): Add s_iscanonicall.
	* manual/arith.texi (Floating Point Classes): Document
	iscanonical.
	* manual/libm-err-tab.pl: Update comment on interfaces without
	ulps tabulated.
	* sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h: New file.
	* sysdeps/ieee754/ldbl-128ibm/s_iscanonicall.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/test-iscanonical-ldbl-128ibm.c:
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/Makefile (tests): Add
	test-iscanonical-ldbl-128ibm.
	* sysdeps/ieee754/ldbl-96/bits/iscanonical.h: New file.
	* sysdeps/ieee754/ldbl-96/s_iscanonicall.c: Likewise.
	* sysdeps/ieee754/ldbl-96/test-iscanonical-ldbl-96.c: Likewise.
	* sysdeps/ieee754/ldbl-96/Makefile: Likewise.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Update.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/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/x86_64/64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
2016-09-30 00:27:50 +00:00