Commit Graph

15795 Commits

Author SHA1 Message Date
Siddhesh Poyarekar 977f4b31b7 Fix reads for sizes larger than INT_MAX in AF_INET lookup
Currently for AF_INET lookups from the hosts file, buffer sizes larger
than INT_MAX silently overflow and may result in access beyond bounds
of a buffer.  This happens when the number of results in an AF_INET
lookup in /etc/hosts are very large.

There are two aspects to the problem.  One problem is that the size
computed from the buffer size is stored into an int, which results in
overflow for large sizes.  Additionally, even if this size was
expanded, the function used to read content into the buffer (fgets)
accepts only int sizes.  As a result, the fix is to have a function
wrap around fgets that calls it multiple times with int sizes if
necessary.
2013-10-30 16:19:40 +05:30
Allan McRae 482a077e31 Fix ChangeLog formatting issue 2013-10-30 20:12:59 +10:00
Mike Frysinger cb8a6dbd17 rename configure.in to configure.ac
Autoconf has been deprecating configure.in for quite a long time.
Rename all our configure.in and preconfigure.in files to .ac.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-10-30 17:32:08 +10:00
Andreas Schwab 36a4953a1d Let tst-swscanf find its locale 2013-10-29 17:24:53 +01:00
Siddhesh Poyarekar dfa1b402a0 Benchmark inputs for pow
These inputs cover all normal processing paths for pow including all
its slow paths.
2013-10-28 16:36:46 +05:30
Siddhesh Poyarekar 54f73d9c08 New inputs for exp
A more comprehensive set of inputs for exp, including all slow paths.
The inputs have been shuffled so that they don't give a false-positive
due to a hot cache.
2013-10-28 16:35:08 +05:30
Siddhesh Poyarekar c79a12040c Consolidate conditionals in mp sin/cos functions
Consolidate conditionals in multiple precision sin and cos functions
to prepare the code for addition of probe points.
2013-10-28 16:21:54 +05:30
Adhemerval Zanella 67beb54504 Fix ChangeLog date. 2013-10-28 08:20:30 -02:00
Adhemerval Zanella 69f13dbf06 PowerPC: strcpy/stpcpy optimization for PPC64/POWER7
This patch intends to unify both strcpy and stpcpy implementationsi
for PPC64 and PPC64/POWER7. The idead default powerpc64 implementation
is to provide both doubleword and word aligned memory access.

For PPC64/POWER7 is also provide doubleword and word memory access,
remove the branch hints, use the cmpb instruction for compare
doubleword/words, and add an optimization for inputs of same alignment.
2013-10-25 13:28:24 -05:00
Ondřej Bílka 151659f637 Fix gethostbyname_r example. Fixes bug 2801. 2013-10-25 19:17:58 +02:00
Ondřej Bílka 10b0f26b19 Changelog for last commit. 2013-10-25 19:15:14 +02:00
Ondřej Bílka ca42d35ea1 Acknowledge that fnmatch can fail. Fixes bug 14029. 2013-10-25 10:44:24 +02:00
Fabrice Bauzac 52e6d80122 Document that mmap() returns MAP_FAILED on error, as per the POSIX standard. 2013-10-25 13:51:58 +05:30
Siddhesh Poyarekar 7cbcdb3699 Fix stack overflow due to large AF_INET6 requests
Resolves #16072 (CVE-2013-4458).

This patch fixes another stack overflow in getaddrinfo when it is
called with AF_INET6.  The AF_UNSPEC case was fixed as CVE-2013-1914,
but the AF_INET6 case went undetected back then.
2013-10-25 10:22:12 +05:30
Allan McRae 894f3f1049 Fix incorrect getaddrinfo assertion trigger
[BZ #9954]

With the following /etc/hosts:
127.0.0.1       www.my-domain.es
127.0.1.1       www.my-domain.es
192.168.0.1     www.my-domain.es

Using getaddrinfo() on www.my-domain.es, trigger the following assertion:
../sysdeps/posix/getaddrinfo.c:1473: rfc3484_sort: Assertion
`src->results[i].native == -1 || src->results[i].native == a1_native' failed.

This is due to two different bugs:
- In rfc3484_sort() rule 7, src->results[i].native is assigned even if
src->results[i].index is -1, meaning that no interface is associated.
- In getaddrinfo() the source IP address used with the lo interface needs a
special case, as it can be any IP within 127.X.Y.Z.
2013-10-25 14:28:32 +10:00
Chris Leonard b85545a671 Adjust language-code fields of LC_ADDRESS. 2013-10-24 11:43:38 -04:00
Ondřej Bílka d1f23d46da Document rpcgen -5. Fixes bug 15825 2013-10-21 10:02:31 +02:00
Michael Stahl 4db5b08f91 Print the reason why preloading failed in do_preload() 2013-10-20 10:34:09 +02:00
Ondřej Bílka a471e96a53 When glob pattern contains a trailing slash match only directories. Fixes bug 10278. 2013-10-20 10:03:19 +02:00
Ondřej Bílka 45c30c61c9 Replace alloca in __tzfile_read by malloc. Fixes bug 15670 2013-10-20 08:26:05 +02:00
Carlos O'Donell 3d7dc513b7 Mention FIPS 140-2 compliance and Sun RPC.
The Secure RPC implementation in glibc uses DES encryption
during authentication of the user. This use of DES means
that anyone using Sun RPC will likely not be compliant
with FIPS 140-2 which forbids the use of DES.

One solution to the compliance issue is to disable AUTH_DES
and AUTH_KERB, both use DES, when in FIPS compliance mode.
This is not a good idea because it disables all of the even
mildly secure methods of authentication allowing only plain
text methods.

Instead we leave AUTH_DES and AUTH_KERB enabled in FIPS
compliance mode and document the compliance issue in the
manual. FIPS allows this, that is to say that if you can't
fix it you must document the non-compliance.

This commit adds documentation to that effect in the
"DES encryption and password handling" section of the
manual.
2013-10-19 00:11:31 -04:00
Carlos O'Donell 484c12fb1e Enhance localedef --list-archive option.
The localedef --list-archive option claims that it can
accept a [file] argument and list the contents of that
archive. The support was never implemented. This patch
adds that support and allows --list-archive to work as
expected. You can now use localedef to list the contents
of arbitrary locale archives by using:
./localedef --list-archive file
2013-10-18 23:44:35 -04:00
Joseph Myers 3c8325fb47 Add e500 port. 2013-10-18 21:04:22 +00:00
Richard Sandiford 5abe068233 Fix localedef collation handling of <U0000> (bug 15948). 2013-10-18 20:58:31 +00:00
Siddhesh Poyarekar c7738d0822 Don't include tls.h in test cases
Remove tls.h includes where they are not needed.
2013-10-18 19:45:36 +05:30
Ondřej Bílka 0bfcf2c73c Remove assert in malloc statistic. Fixes bug 12486. 2013-10-18 09:35:15 +02:00
Ondřej Bílka 264aad1e6a Fix inet_network("1 bar"). Fixes bug 15277. 2013-10-17 18:34:29 +02:00
Andreas Schwab b957ced889 Don't use gethostbyaddr to determine canonical name 2013-10-17 16:34:27 +02:00
Ondřej Bílka c5d5d574cb Format floating routines. 2013-10-17 16:03:24 +02:00
Joseph Myers e5c2c2d0c0 soft-fp: make extensions quiet signaling NaNs (bug 16041). 2013-10-17 12:36:02 +00:00
Joseph Myers 51ca9e29af soft-fp: fix horizontal whitespace. 2013-10-16 01:22:21 +00:00
Joseph Myers 9ebb0332fc soft-fp: remove unused macros. 2013-10-15 23:33:37 +00:00
Ondřej Bílka 4b1a6d8bc9 Clear initfini list after freeing. Fixes bug 15308. 2013-10-15 09:47:33 +02:00
Joseph Myers 1e14558915 soft-fp: fix vertical whitespace and indentation. 2013-10-15 00:17:35 +00:00
Ondřej Bílka 17c48a60b8 Fix error_tail overflow in allocation calculation. 2013-10-14 17:15:48 +02:00
Ondřej Bílka cabba9343c Correctly copy resolver address. Fixes bug #13028. 2013-10-14 08:17:09 +02:00
Patrick 'P. J.' McDermott 94bf958a94 ldd: make try_trace more robust and portable
It was noted in 2005 (BZ #832), 2006 (BZ #3266), and 2007 [1] that ldd
fails on shells other than Bash >= 3.0 because of the pipefail option
around try_trace (added on 2004-12-08).  EGLIBC was patched in 2008 [2]
(r6912) to make the pipefail check run only on shells that support it,
but RTLD output would still be lost on other shells with certain SELinux
policies.

This patch rewrites try_trace to work on any POSIX-conformant shell in
such a way as to also work with such SELinux policies.  It also obviates
one difference between glibc and EGLIBC.

URL: https://sourceware.org/ml/libc-alpha/2007-01/msg00041.html
URL: http://www.eglibc.org/archives/patches/msg00526.html

2013-09-11  P. J. McDermott  <pj@pehjota.net>

	[BZ #832]
	* elf/ldd.bash.in (try_trace): More robustly and portably work around
	SELinux terminal write permissions by using a command substitution
	instead of a pipeline and pipefail option.
2013-10-14 01:57:46 -04:00
Joseph Myers 71b4dea7dc soft-fp: fix preprocessor indentation. 2013-10-12 14:15:30 +00:00
Yuri Chornoivan 5560275828 Fix typos. 2013-10-12 14:47:50 +02:00
Reuben Thomas 9cd8330240 Fix typo in setlocale.c. Fixes BZ #15764 2013-10-12 14:32:09 +02:00
Joseph Myers b7ea74f074 soft-fp: make __unord* raise "invalid" for signaling NaNs (bug 16036). 2013-10-12 12:23:28 +00:00
Joseph Myers 8a50944770 soft-fp: make ordered comparisons raise "invalid" for quiet NaNs (bug 14910). 2013-10-12 12:22:14 +00:00
Joseph Myers 98998e9f51 soft-fp: add missing FP_INIT_EXCEPTIONS and FP_INIT_ROUNDMODE calls. 2013-10-12 12:21:04 +00:00
Joseph Myers 8edc4a11cf soft-fp: add macro FP_NO_EXCEPTIONS. 2013-10-12 12:20:12 +00:00
Joseph Myers 8399acaf7c soft-fp: fix _FP_DIV_MEAT_* returning results with wrong exponent (bug 16032). 2013-10-12 12:18:55 +00:00
Joseph Myers 99fd9f47ef soft-fp: fix floating-point to integer unsigned saturation. 2013-10-12 12:17:16 +00:00
Siddhesh Poyarekar 10e1cf6b73 Add systemtap markers to math function slow paths
Add systemtap probes to various slow paths in libm so that application
developers may use systemtap to find out if their applications are
hitting these slow paths.  We have added probes for pow, exp, log,
tan, atan and atan2.
2013-10-11 22:37:53 +05:30
Eric Biggers 3d110c7c6e Fix fwrite() reading beyond end of buffer in error path
Partially revert commits 2b766585f9 and
de2fd463b1, which were intended to fix BZ#11741
but caused another, likely worse bug, namely that fwrite() and fputs() could,
in an error path, read data beyond the end of the specified buffer, and
potentially even write this data to the file.

Fix BZ#11741 properly by checking the return value from _IO_padn() in
stdio-common/vfprintf.c.
2013-10-11 22:29:38 +05:30
David S. Miller 75b4202ab0 Fix readdir regressions on sparc 32-bit.
* sysdeps/posix/dirstream.h (struct __dirstream): Fix alignment of
	directory block.
2013-10-10 22:32:36 -07:00
Joseph Myers 33b853c3b1 Update copyright and license notices in soft-fp files from libgcc. 2013-10-10 23:58:13 +00:00
Joseph Myers 6c6352e698 Add soft-fp files from libgcc. 2013-10-10 23:57:22 +00:00
David S. Miller 3bf78b7174 Update sparc ULPs.
* sysdeps/sparc/fpu/libm-test-ulps: Update.
2013-10-10 14:42:58 -07:00
Joseph Myers bd878fc030 Extend powerpc-nofpu -fno-builtin-fabsl workaround to more files. 2013-10-10 19:12:09 +00:00
Joseph Myers 6f10289efb Avoid ordered comparisons of NaNs in ldbl-128ibm acosl and asinl. 2013-10-10 19:11:30 +00:00
Will Newton 321e268471 malloc/hooks.c: Correct check for overflow in memalign_check.
A large value of bytes passed to memalign_check can cause an integer
overflow in _int_memalign and heap corruption. This issue can be
exposed by running tst-memalign with MALLOC_CHECK_=3.

ChangeLog:

2013-10-10  Will Newton  <will.newton@linaro.org>

	* malloc/hooks.c (memalign_check): Ensure the value of bytes
	passed to _int_memalign does not overflow.
2013-10-10 14:52:05 +01:00
Torvald Riegel 40fefba1b5 benchtests: Add include-sources directive.
This adds the "include-sources" directive to scripts/bench.pl.  This
allows for including source code (vs including headers, which might get
a different search path) after the inclusion of any headers.
2013-10-10 14:45:30 +03:00
Joseph Myers dcc2dd3f46 soft-fp: split FP_INIT_EXCEPTIONS from FP_INIT_ROUNDMODE. 2013-10-10 11:40:25 +00:00
Joseph Myers 2ae21ed2d2 soft-fp: fix negation NaN handling (bug 16034). 2013-10-10 11:38:56 +00:00
Joseph Myers cb8f9562a5 soft-fp: Remove trailing semicolon from _FP_FRAC_DISASSEMBLE_4. 2013-10-09 19:23:05 +00:00
Adam Buchbinder 5b60c59de5 soft-fp: fix typo in comment. 2013-10-09 19:22:15 +00:00
Yogesh Chaudhari b86835ca92 Update gethostbyname2_r documentation. Fixes bug #156. 2013-10-08 21:42:42 +02:00
Ondřej Bílka e7044ea76b Use p2align instead ALIGN 2013-10-08 15:46:48 +02:00
Siddhesh Poyarekar 885766357d Format e_pow.c 2013-10-08 16:23:16 +05:30
Siddhesh Poyarekar e7b2d1dd62 Format e_exp.c 2013-10-08 16:22:28 +05:30
Siddhesh Poyarekar 09544cbcd6 Consolidate multiple precision sin/cos functions 2013-10-08 11:50:17 +05:30
Joseph Myers 7602d070dc Clean up locale file alignment handling. 2013-10-08 00:14:08 +00:00
Siddhesh Poyarekar e3764517a4 Fix ChangeLog formatting 2013-10-07 11:52:44 +05:30
Siddhesh Poyarekar a357259bf8 Add more directives to benchmark input files
This patch adds some more directives to the benchmark inputs file,
moving functionality from the Makefile and making the code generation
script a bit cleaner.  The function argument and return types that
were earlier added as variables in the makefile and passed to the
script via command line arguments are now the 'args' and 'ret'
directive respectively.  'args' should be a colon separated list of
argument types (skipped if the function doesn't accept any arguments)
and 'ret' should be the return type.

Additionally, an 'includes' directive may have a comma separated list
of headers to include in the source.  For example, the pow input file
now looks like this:

42.0, 42.0
1.0000000000000020, 1.5

I did this to unclutter the benchtests Makefile a bit and eventually
eliminate dependency of the tests on the Makefile and have tests
depend on their respective include files only.
2013-10-07 11:51:25 +05:30
Alan Modra 9ec1b13d01 Fix careless merge. 2013-10-07 09:58:30 +10:30
Alan Modra 8b7d57cd0a Mention powerpc64le support in NEWS and README, plus bugs fixed.
* NEWS: Mention powerpc64le support and bugs fixed.
	* README: Both big-endian and little-endian powerpc64 supported.
2013-10-05 16:43:17 +09:30
Samuel Thibault 7b7bab1391 Add fork hooks for pthread_atfork
pthread_atfork needs application callbacks to be called outside any locking.
2013-10-04 22:29:51 +02:00
Ryan S. Arnold d39baad11e Update generic swapon definition to match prototype. 2013-10-04 12:22:14 -05:00
Joseph Myers 29d73d867e Move powerpc ports pieces to libc. 2013-10-04 16:02:33 +00:00
Joseph Myers e246b34759 e500 port: adjust sysdeps/unix/sysv/linux/configure.in case. 2013-10-04 15:57:50 +00:00
Joseph Myers 89c2003e84 e500 port: fix fpu_control.h constant values. 2013-10-04 15:56:48 +00:00
Joseph Myers cd78f7e767 e500 port: getcontext / setcontext / swapcontext. 2013-10-04 15:55:15 +00:00
Chris Leonard c755294d3c Update iso-1366.def and related occurrences 2013-10-04 08:35:44 -04:00
Siddhesh Poyarekar e16d221c06 Fix typo in manual 2013-10-04 17:21:32 +05:30
Will Newton 66a9be9d58 malloc/tst-valloc.c: Tidy up code.
Add some comments and call free on all potentially allocated pointers.
Also remove duplicate check for NULL pointer.

ChangeLog:

2013-10-04  Will Newton  <will.newton@linaro.org>

	* malloc/tst-valloc.c: Add comments.
	(do_test): Add comments and call free on all potentially
	allocated pointers. Remove duplicate check for NULL pointer.
	Add space after cast.
2013-10-04 09:16:41 +01:00
Will Newton 1bc92709f3 malloc/tst-pvalloc.c: Tidy up code.
Add some comments and call free on all potentially allocated pointers.
Also remove duplicate check for NULL pointer.

ChangeLog:

2013-10-04  Will Newton  <will.newton@linaro.org>

	* malloc/tst-pvalloc.c: Add comments.
	(do_test): Add comments and call free on all potentially
	allocated pointers. Remove duplicate check for NULL pointer.
	Add space after cast.
2013-10-04 09:15:33 +01:00
Will Newton 27d0461b7b malloc/tst-posix_memalign.c: Tidy up code.
Add some comments and call free on all potentially allocated pointers.

ChangeLog:

2013-10-04  Will Newton  <will.newton@linaro.org>

	* malloc/tst-posix_memalign.c: Add comments.
	(do_test): Add comments and call free on all potentially
	allocated pointers. Add space after cast.
2013-10-04 09:14:27 +01:00
Will Newton 215c7d4344 malloc: Add memalign test.
ChangeLog:

2013-10-04  Will Newton  <will.newton@linaro.org>

    * malloc/Makefile: Add tst-memalign.
    * malloc/tst-memalign.c: New file.
2013-10-04 09:12:59 +01:00
Alan Modra 4cb81307b3 Use stdint.h types in union unaligned.
* sysdeps/powerpc/powerpc32/dl-machine.c (__process_machine_rela):
	Use stdint types in rather than __attribute__((mode())).
	* sysdeps/powerpc/powerpc64/dl-machine.h (elf_machine_rela): Likewise.
2013-10-04 12:51:11 +09:30
Alan Modra f8e3e9f31b Correct little-endian relocation of UADDR64,32,16.
* sysdeps/powerpc/powerpc32/dl-machine.c (__process_machine_rela):
	Correct handling of unaligned relocs for little-endian.
	* sysdeps/powerpc/powerpc64/dl-machine.h (elf_machine_rela): Likewise.
2013-10-04 11:33:12 +09:30
Alan Modra 8f9ebb08af PowerPC LE configury
http://sourceware.org/ml/libc-alpha/2013-08/msg00096.html

This adds the basic configury bits for powerpc64le and powerpcle.

	* configure.in: Map powerpc64le and powerpcle to base_machine/machine.
	* configure: Regenerate.
	* nptl/shlib-versions: Powerpc*le starts at 2.18.
	* shlib-versions: Likewise.
2013-10-04 10:42:27 +09:30
Alan Modra 0edf96c28f string/tester memrchr test
http://sourceware.org/ml/libc-alpha/2013-08/msg00095.html

I found this useful at one stage when I was seeing a huge number of
memrchr failures all of test number 10.

	* string/tester.c (test_memrchr): Increment reported test cycle.
2013-10-04 10:42:15 +09:30
Alan Modra e0f7a38046 string/test-memcpy error reporting
http://sourceware.org/ml/libc-alpha/2013-08/msg00094.html

Using plain %s here runs the risk of segfaulting when displaying the
string.  src and dst aren't zero terminated strings.

	* string/test-memcpy.c (do_one_test): When reporting errors, print
	string address and don't overrun end of string.
2013-10-04 10:42:02 +09:30
Alan Modra 466b039332 PowerPC LE memchr and memrchr
http://sourceware.org/ml/libc-alpha/2013-08/msg00105.html

Like strnlen, memchr and memrchr had a number of defects fixed by this
patch as well as adding little-endian support.  The first one I
noticed was that the entry to the main loop needlessly checked for
"are we done yet?" when we know the size is large enough that we can't
be done.  The second defect I noticed was that the main loop count was
wrong, which in turn meant that the small loop needed to handle an
extra word.  Thirdly, there is nothing to say that the string can't
wrap around zero, except of course that we'd normally hit a segfault
on trying to read from address zero.  Fixing that simplified a number
of places:

-	/* Are we done already?  */
-	addi    r9,r8,8
-	cmpld	r9,r7
-	bge	L(null)

becomes

+	cmpld	r8,r7
+	beqlr

However, the exit gets an extra test because I test for being on the
last word then if so whether the byte offset is less than the end.
Overall, the change is a win.

Lastly, memrchr used the wrong cache hint.

	* sysdeps/powerpc/powerpc64/power7/memchr.S: Replace rlwimi with
	insrdi.  Make better use of reg selection to speed exit slightly.
	Schedule entry path a little better.  Remove useless "are we done"
	checks on entry to main loop.  Handle wrapping around zero address.
	Correct main loop count.  Handle single left-over word from main
	loop inline rather than by using loop_small.  Remove extra word
	case in loop_small caused by wrong loop count.  Add little-endian
	support.
	* sysdeps/powerpc/powerpc32/power7/memchr.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/memrchr.S: Likewise.  Use proper
	cache hint.
	* sysdeps/powerpc/powerpc32/power7/memrchr.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/rawmemchr.S: Add little-endian
	support.  Avoid rlwimi.
	* sysdeps/powerpc/powerpc32/power7/rawmemchr.S: Likewise.
2013-10-04 10:41:46 +09:30
Alan Modra 3be87c77d2 PowerPC LE memset
http://sourceware.org/ml/libc-alpha/2013-08/msg00104.html

One of the things I noticed when looking at power7 timing is that rlwimi
is cracked and the two resulting insns have a register dependency.
That makes it a little slower than the equivalent rldimi.

	* sysdeps/powerpc/powerpc64/memset.S: Replace rlwimi with
        insrdi.  Formatting.
	* sysdeps/powerpc/powerpc64/power4/memset.S: Likewise.
	* sysdeps/powerpc/powerpc64/power6/memset.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/memset.S: Likewise.
	* sysdeps/powerpc/powerpc32/power4/memset.S: Likewise.
	* sysdeps/powerpc/powerpc32/power6/memset.S: Likewise.
	* sysdeps/powerpc/powerpc32/power7/memset.S: Likewise.
2013-10-04 10:41:35 +09:30
Alan Modra 759cfef3ac PowerPC LE memcpy
http://sourceware.org/ml/libc-alpha/2013-08/msg00103.html

LIttle-endian support for memcpy.  I spent some time cleaning up the
64-bit power7 memcpy, in order to avoid the extra alignment traps
power7 takes for little-endian.  It probably would have been better
to copy the linux kernel version of memcpy.

	* sysdeps/powerpc/powerpc32/power4/memcpy.S: Add little endian support.
	* sysdeps/powerpc/powerpc32/power6/memcpy.S: Likewise.
	* sysdeps/powerpc/powerpc32/power7/memcpy.S: Likewise.
	* sysdeps/powerpc/powerpc32/power7/mempcpy.S: Likewise.
	* sysdeps/powerpc/powerpc64/memcpy.S: Likewise.
	* sysdeps/powerpc/powerpc64/power4/memcpy.S: Likewise.
	* sysdeps/powerpc/powerpc64/power6/memcpy.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/memcpy.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/mempcpy.S: Likewise.  Make better
	use of regs.  Use power7 mtocrf.  Tidy function tails.
2013-10-04 10:41:24 +09:30
Alan Modra fe6e95d717 PowerPC LE memcmp
http://sourceware.org/ml/libc-alpha/2013-08/msg00102.html

This is a rather large patch due to formatting and renaming.  The
formatting changes were to make it possible to compare power7 and
power4 versions of memcmp.  Using different register defines came
about while I was wrestling with the code, trying to find spare
registers at one stage.  I found it much simpler if we refer to a reg
by the same name throughout a function, so it's better if short-term
multiple use regs like rTMP are referred to using their register
number.  I made the cr field usage changes when attempting to reload
rWORDn regs in the exit path to byte swap before comparing when
little-endian.  That proved a bad idea due to the pipelining involved
in the main loop;  Offsets to reload the regs were different first
time around the loop..  Anyway, I left the cr field usage changes in
place for consistency.

Aside from these more-or-less cosmetic changes, I fixed a number of
places where an early exit path restores regs unnecessarily, removed
some dead code, and optimised one or two exits.

	* sysdeps/powerpc/powerpc64/power7/memcmp.S: Add little-endian support.
	Formatting.  Consistently use rXXX register defines or rN defines.
	Use early exit labels that avoid restoring unused non-volatile regs.
	Make cr field use more consistent with rWORDn compares.  Rename
	regs used as shift registers for unaligned loop, using rN defines
	for short lifetime/multiple use regs.
	* sysdeps/powerpc/powerpc64/power4/memcmp.S: Likewise.
	* sysdeps/powerpc/powerpc32/power7/memcmp.S: Likewise.  Exit with
	addi 1,1,64 to pop stack frame.  Simplify return value code.
	* sysdeps/powerpc/powerpc32/power4/memcmp.S: Likewise.
2013-10-04 10:40:56 +09:30
Alan Modra 664318c3eb PowerPC LE strchr
http://sourceware.org/ml/libc-alpha/2013-08/msg00101.html

Adds little-endian support to optimised strchr assembly.  I've also
tweaked the big-endian code a little.  In power7/strchr.S there's a
check in the tail of the function that we didn't match 0 before
finding a c match, done by comparing leading zero counts.  It's just
as valid, and quicker, to compare the raw output from cmpb.

Another little tweak is to use rldimi/insrdi in place of rlwimi for
the power7 strchr functions.  Since rlwimi is cracked, it is a few
cycles slower.  rldimi can be used on the 32-bit power7 functions
too.

	* sysdeps/powerpc/powerpc64/power7/strchr.S (strchr): Add little-endian
	support.  Correct typos, formatting.  Optimize tail.  Use insrdi
	rather than rlwimi.
	* sysdeps/powerpc/powerpc32/power7/strchr.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/strchrnul.S (__strchrnul): Add
	little-endian support.  Correct typos.
	* sysdeps/powerpc/powerpc32/power7/strchrnul.S: Likewise.  Use insrdi
	rather than rlwimi.
	* sysdeps/powerpc/powerpc64/strchr.S (rTMP4, rTMP5): Define.  Use
	in loop and entry code to keep "and." results.
	(strchr): Add little-endian support.  Comment.  Move cntlzd
	earlier in tail.
	* sysdeps/powerpc/powerpc32/strchr.S: Likewise.
2013-10-04 10:40:22 +09:30
Alan Modra 43b8401371 PowerPC LE strcpy
http://sourceware.org/ml/libc-alpha/2013-08/msg00100.html

The strcpy changes for little-endian are quite straight-forward, just
a matter of rotating the last word differently.

I'll note that the powerpc64 version of stpcpy is just begging to be
converted to use 64-bit loads and stores..

	* sysdeps/powerpc/powerpc64/strcpy.S: Add little-endian support:
	* sysdeps/powerpc/powerpc32/strcpy.S: Likewise.
	* sysdeps/powerpc/powerpc64/stpcpy.S: Likewise.
	* sysdeps/powerpc/powerpc32/stpcpy.S: Likewise.
2013-10-04 10:40:11 +09:30
Alan Modra 8a7413f9b0 PowerPC LE strcmp and strncmp
http://sourceware.org/ml/libc-alpha/2013-08/msg00099.html

More little-endian support.  I leave the main strcmp loops unchanged,
(well, except for renumbering rTMP to something other than r0 since
it's needed in an addi insn) and modify the tail for little-endian.

I noticed some of the big-endian tail code was a little untidy so have
cleaned that up too.

	* sysdeps/powerpc/powerpc64/strcmp.S (rTMP2): Define as r0.
	(rTMP): Define as r11.
	(strcmp): Add little-endian support.  Optimise tail.
	* sysdeps/powerpc/powerpc32/strcmp.S: Similarly.
	* sysdeps/powerpc/powerpc64/strncmp.S: Likewise.
	* sysdeps/powerpc/powerpc32/strncmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/power4/strncmp.S: Likewise.
	* sysdeps/powerpc/powerpc32/power4/strncmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/power7/strncmp.S: Likewise.
	* sysdeps/powerpc/powerpc32/power7/strncmp.S: Likewise.
2013-10-04 10:39:52 +09:30
Alan Modra 33ee81de05 PowerPC LE strnlen
http://sourceware.org/ml/libc-alpha/2013-08/msg00098.html

The existing strnlen code has a number of defects, so this patch is more
than just adding little-endian support.  The changes here are similar to
those for memchr.

	* sysdeps/powerpc/powerpc64/power7/strnlen.S (strnlen): Add
	little-endian support.  Remove unnecessary "are we done" tests.
	Handle "s" wrapping around zero and extremely large "size".
	Correct main loop count.  Handle single left-over word from main
	loop inline rather than by using small_loop.  Correct comments.
	Delete "zero" tail, use "end_max" instead.
	* sysdeps/powerpc/powerpc32/power7/strnlen.S: Likewise.
2013-10-04 10:39:42 +09:30
Alan Modra db9b4570c5 PowerPC LE strlen
http://sourceware.org/ml/libc-alpha/2013-08/msg00097.html

This is the first of nine patches adding little-endian support to the
existing optimised string and memory functions.  I did spend some
time with a power7 simulator looking at cycle by cycle behaviour for
memchr, but most of these patches have not been run on cpu simulators
to check that we are going as fast as possible.  I'm sure PowerPC can
do better.  However, the little-endian support mostly leaves main
loops unchanged, so I'm banking on previous authors having done a
good job on big-endian..  As with most code you stare at long enough,
I found some improvements for big-endian too.

Little-endian support for strlen.  Like most of the string functions,
I leave the main word or multiple-word loops substantially unchanged,
just needing to modify the tail.

Removing the branch in the power7 functions is just a tidy.  .align
produces a branch anyway.  Modifying regs in the non-power7 functions
is to suit the new little-endian tail.

	* sysdeps/powerpc/powerpc64/power7/strlen.S (strlen): Add little-endian
	support.  Don't branch over align.
	* sysdeps/powerpc/powerpc32/power7/strlen.S: Likewise.
	* sysdeps/powerpc/powerpc64/strlen.S (strlen): Add little-endian support.
	Rearrange tmp reg use to suit.  Comment.
	* sysdeps/powerpc/powerpc32/strlen.S: Likewise.
2013-10-04 10:39:32 +09:30
Alan Modra f7c399cff5 PowerPC SIGSTKSZ
http://sourceware.org/ml/libc-alpha/2013-08/msg00093.html

This copies the sparc version of sigstack.h, which gives powerpc
 #define MINSIGSTKSZ     4096
 #define SIGSTKSZ        16384

Before the VSX changes, struct rt_sigframe size was 1920 plus 128 for
__SIGNAL_FRAMESIZE giving ppc64 exactly the default MINSIGSTKSZ of
2048.

After VSX, ucontext increased by 256 bytes.  Oops, we're over
MINSIGSTKSZ, so powerpc has been using the wrong value for quite a
while.  Add another ucontext for TM and rt_sigframe is now at 3872,
giving actual MINSIGSTKSZ of 4000.

The glibc testcase that I was looking at was tst-cancel21, which
allocates 2*SIGSTKSZ (not because the test is trying to be
conservative, but because the test actually has nested signal stack
frames).  We blew the allocation by 48 bytes when using current
mainline gcc to compile glibc (le ppc64).

The required stack depth in _dl_lookup_symbol_x from the top of the
next signal frame was 10944 bytes.  I guess you'd want to add 288 to
that, implying an actual SIGSTKSZ of 11232.

	* sysdeps/unix/sysv/linux/powerpc/bits/sigstack.h: New file.
2013-10-04 10:39:11 +09:30
Alan Modra 0b2c2ace36 PowerPC makecontext
http://sourceware.org/ml/libc-alpha/2013-08/msg00092.html

Use conditional form of branch and link to avoid destroying the cpu
link stack used to predict blr return addresses.

	* sysdeps/unix/sysv/linux/powerpc/powerpc32/makecontext.S: Use
	conditional form of branch and link when obtaining pc.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S: Likewise.
2013-10-04 10:38:59 +09:30
Alan Modra 02f04a6c7f PowerPC LE _dl_hwcap access
http://sourceware.org/ml/libc-alpha/2013-08/msg00091.html

More LE support, correcting word accesses to _dl_hwcap.

	* sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext-common.S: Use
	HIWORD/LOWORD.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext-common.S: Ditto.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext-common.S: Ditto.
2013-10-04 10:38:46 +09:30
Alan Modra 9b874b2f1e PowerPC ugly symbol versioning
http://sourceware.org/ml/libc-alpha/2013-08/msg00090.html

This patch fixes symbol versioning in setjmp/longjmp.  The existing
code uses raw versions, which results in wrong symbol versioning when
you want to build glibc with a base version of 2.19 for LE.

Note that the merging the 64-bit and 32-bit versions in novmx-lonjmp.c
and pt-longjmp.c doesn't result in GLIBC_2.0 versions for 64-bit, due
to the base in shlib_versions.

	* sysdeps/powerpc/longjmp.c: Use proper symbol versioning macros.
	* sysdeps/powerpc/novmx-longjmp.c: Likewise.
	* sysdeps/powerpc/powerpc32/bsd-_setjmp.S: Likewise.
	* sysdeps/powerpc/powerpc32/bsd-setjmp.S: Likewise.
	* sysdeps/powerpc/powerpc32/fpu/__longjmp.S: Likewise.
	* sysdeps/powerpc/powerpc32/fpu/setjmp.S: Likewise.
	* sysdeps/powerpc/powerpc32/mcount.c: Likewise.
	* sysdeps/powerpc/powerpc32/setjmp.S: Likewise.
	* sysdeps/powerpc/powerpc64/setjmp.S: Likewise.
	* nptl/sysdeps/unix/sysv/linux/powerpc/pt-longjmp.c: Likewise.
2013-10-04 10:38:28 +09:30