Compare commits

...

911 Commits

Author SHA1 Message Date
Brian Carlstrom
7751d9158f Use kernel default for initial thread size
Bug: 10697851

Change-Id: I8d980f5e0b584799536f6e6b891056c968d26cdf
2013-09-13 11:16:50 -07:00
The Android Automerger
25519f0fb0 merge in klp-release history after reset to klp-dev 2013-09-11 06:00:09 -07:00
Christopher Ferris
883ef2499c __memcpy_chk: Fix signed cmp of unsigned values.
I accidentally did a signed comparison of the size_t values passed in
for three of the _chk functions. Changing them to unsigned compares.

Add three new tests to verify this failure is fixed.

Bug: 10691831
Change-Id: Ia831071f7dffd5972a748d888dd506c7cc7ddba3
2013-09-10 17:34:03 -07:00
The Android Automerger
82a8fe37d7 merge in klp-release history after reset to klp-dev 2013-09-02 06:00:18 -07:00
Christopher Ferris
49c0d471a8 Merge "Fix all debug directives." into klp-dev 2013-08-29 21:21:20 +00:00
Christopher Ferris
05332f2ce7 Fix all debug directives.
The backtrace when a fortify check failed was not correct. This change
adds all of the necessary directives to get a correct backtrace.

Fix the strcmp directives and change all labels to local labels.

Testing:
- Verify that the runtime can decode the stack for __memcpy_chk, __memset_chk,
  __strcpy_chk, __strcat_chk fortify failures.
- Verify that gdb can decode the stack properly when hitting a fortify check.
- Verify that the runtime can decode the stack for a seg fault for all of the
  _chk functions and for memcpy/memset.
- Verify that gdb can decode the stack for a seg fault for all of the _chk
  functions and for memcpy/memset.
- Verify that the runtime can decode the stack for a seg fault for strcmp.
- Verify that gdb can decode the stack for a seg fault in strcmp.

Bug: 10342460
Bug: 10345269

Change-Id: I1dedadfee207dce4a285e17a21e8952bbc63786a
2013-08-28 15:42:05 -07:00
The Android Automerger
da4bedf52f merge in klp-release history after reset to klp-dev 2013-08-27 06:00:58 -07:00
Brian Carlstrom
6ab75bf41e Merge "Fix pthread_getcpuclockid." into klp-dev 2013-08-26 21:21:17 +00:00
Jeff Hao
e9e10c13ff Fix pthread_getcpuclockid.
clock_gettime was returning EINVAL for the values
produced by pthread_getcpuclockid.

Bug: 10346183

(cherry picked from commit 9b06cc3c1b)

Change-Id: Ib81a7024c218a4502f256c3002b9030e2aaa278d
2013-08-26 14:04:16 -07:00
The Android Automerger
8eca269b4b merge in klp-release history after reset to klp-dev 2013-08-26 06:00:41 -07:00
Robert Greenwalt
26ac803232 Merge "Change how DNS resolver handle no default iface" into klp-dev 2013-08-24 12:20:01 +00:00
Robert Greenwalt
d67662b9d6 Change how DNS resolver handle no default iface
We used to just try any iface we'd been told about as a
fallback, but that will end up mistakenly using a secondary
network's dns when we really don't have a default connection.

It also messed up our detection of whether we were doing the
lookup on the default or not (we'd get back our secondary net
iface as the default, do the compare and think we were on default).

Remove the lies and let dns fail if we don't have an iface for it.

bug:10132565

Conflicts:
	libc/netbsd/resolv/res_cache.c

Change-Id: I357a9c34dad83215f44c5e0dd41ce2a7d6fe8f3f
2013-08-23 11:48:26 -07:00
Elliott Hughes
345eb225ae Apply upstream commit 943a6621866e9d6e654f5cfe1494378c1fb8957a.
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Aug 22 12:47:51 2013 -0700

    * localtime.c: Fix another integer overflow bug in mktime.

    (time2sub): Avoid undefined behavior on time_t overflow.
    Reported by Elliott Hughes in
    <http://mm.icann.org/pipermail/tz/2013-August/019580.html>.

Bug: 10310929

(cherry picked from commit 713fe6463e)

Change-Id: I9ec79fd8d825e6b9e8bb5af549dbfc2182346c05
2013-08-22 14:29:07 -07:00
Elliott Hughes
f0c10a4a16 Work around tzcode's reliance on signed overflow.
I've mailed the tz list about this, and will switch to whatever upstream
fix comes along as soon as it's available.

Bug: 10310929

(cherry picked from commit 7843d44a59)

Change-Id: I205e2440703444c50cecd91d3458d33613ddbc59
2013-08-22 12:23:47 -07:00
The Android Automerger
13ea69528e merge in klp-release history after reset to klp-dev 2013-08-22 06:00:33 -07:00
Brian Carlstrom
9ef1fbb644 Make mips_relocate_got tolerate a missing got
Bug: 10094803

(cherry picked from commit 7ee26878065abb494600595349ce58b2b2db3709)

Change-Id: I9fbb65d20011f2f625fde3b15ac8c6887dd03ae4
2013-08-21 10:20:53 -07:00
The Android Automerger
948fbefa2a merge in klp-release history after reset to klp-dev 2013-08-21 06:01:31 -07:00
Christopher Ferris
5f7ccea3ff Update all debug directives.
The libcorkscrew stack unwinder does not understand cfi directives,
so add .save directives so that it can function properly.

Also add the directives in to strcmp.S and fix a missing set of
directives in cortex-a9/memcpy_base.S.

Bug: 10345269

Change-Id: I043f493e0bb6c45bd3f4906fbe1d9f628815b015
2013-08-20 11:22:34 -07:00
The Android Automerger
de19a0c55d merge in klp-release history after reset to klp-dev 2013-08-14 06:04:54 -07:00
Christopher Ferris
f0c3d90913 Create optimized __strcpy_chk/__strcat_chk.
This change pulls the memcpy code out into a new file so that the
__strcpy_chk and __strcat_chk can use it with an include.

The new versions of the two chk functions uses assembly versions
of strlen and memcpy to implement this check. This allows near
parity with the assembly versions of strcpy/strcat. It also means that
as memcpy implementations get faster, so do the chk functions.

Other included changes:
- Change all of the assembly labels to local labels. The other labels
  confuse gdb and mess up backtracing.
- Add .cfi_startproc and .cfi_endproc directives so that gdb is not
  confused when falling through from one function to another.
- Change all functions to use cfi directives since they are more powerful.
- Move the memcpy_chk fail code outside of the memcpy function definition
  so that backtraces work properly.
- Preserve lr before the calls to __fortify_chk_fail so that the backtrace
  actually works.

Testing:

- Ran the bionic unit tests. Verified all error messages in logs are set
  correctly.
- Ran libc_test, replacing strcpy with __strcpy_chk and replacing
  strcat with __strcat_chk.
- Ran the debugger on nexus10, nexus4, and old nexus7. Verified that the
  backtrace is correct for all fortify check failures. Also verify that
  when falling through from __memcpy_chk to memcpy that the backtrace is
  still correct. Also verified the same for __memset_chk and bzero.
  Verified the two different paths in the cortex-a9 memset routine that
  save variables to the stack still show the backtrace properly.

Bug: 9293744
Change-Id: Id5aec8c3cb14101d91bd125eaf3770c9c8aa3f57
(cherry picked from commit 2be91915dc)
2013-08-14 07:46:00 +00:00
Elliott Hughes
3912f90e56 Make ctype.h a little less unhygienic.
This caused trouble for stlport.

(cherry picked from commit 5e9b20f721)

Change-Id: I85d09c12c6de1e8502f83e0ef0f17747fdfe08a5
2013-08-13 14:42:43 -07:00
Elliott Hughes
5951e84646 Fix our missing abs/labs/llabs/imaxabs (and imaxdiv) symbols.
(cherry picked from commit aec2ffbc5a)

Change-Id: Ib61b52dc37e63493094a0a7af23bf89d4a9f0ce5
2013-08-13 14:41:07 -07:00
The Android Automerger
f63a467cdd merge in klp-release history after reset to klp-dev 2013-08-12 06:00:44 -07:00
Elliott Hughes
9e9d1e016f resolved conflicts for merge of 86125aca to klp-dev
Change-Id: I78622ecbad27301b285193a085fa04374aa60033
2013-08-08 18:08:33 -07:00
Elliott Hughes
ceb670cfc0 Merge branch 'klp-dev' of https://googleplex-android.googlesource.com/_direct/platform/bionic into klp-dev 2013-08-08 17:53:31 -07:00
Christopher Ferris
1036cd7939 am 6beb3ea6: (-s ours) am d7d5049d: (-s ours) am 632fd518: (-s ours) Merge "Fix strcpy.c that should have been strcpy.S. DO NOT MERGE"
* commit '6beb3ea6a1a49baef001ddd8c6872631f5e90f82':
  Fix strcpy.c that should have been strcpy.S. DO NOT MERGE
2013-08-08 17:53:19 -07:00
Christopher Ferris
5ec2ab68f9 am 21b4ffa7: (-s ours) am 5427eb5c: (-s ours) am e2066293: (-s ours) Merge "Optimize strcat/strcpy, small tweaks to strlen. DO NOT MERGE"
* commit '21b4ffa7372b029e5a4898b877feb843da2831e9':
  Optimize strcat/strcpy, small tweaks to strlen. DO NOT MERGE
2013-08-08 17:53:18 -07:00
Elliott Hughes
840a114eb1 Add futimens.
(cherry picked from commit d0be7c8f9a)

Bug: 10239370
Change-Id: I0087e85a94d83b6ce68ec6a0768c44cbe4bd0132
2013-08-08 17:52:06 -07:00
Elliott Hughes
86125acacd am dce94165: am ee48fed5: Merge "Add futimens."
* commit 'dce94165a5624935db9855e208420d36c763f771':
  Add futimens.
2013-08-08 17:45:45 -07:00
Christopher Ferris
6beb3ea6a1 am d7d5049d: (-s ours) am 632fd518: (-s ours) Merge "Fix strcpy.c that should have been strcpy.S. DO NOT MERGE"
* commit 'd7d5049d58427e23318fa1920d63712676fc7725':
  Fix strcpy.c that should have been strcpy.S. DO NOT MERGE
2013-08-08 17:45:45 -07:00
Christopher Ferris
21b4ffa737 am 5427eb5c: (-s ours) am e2066293: (-s ours) Merge "Optimize strcat/strcpy, small tweaks to strlen. DO NOT MERGE"
* commit '5427eb5c63417c7bc59bbfe112c97917dcef4e8c':
  Optimize strcat/strcpy, small tweaks to strlen. DO NOT MERGE
2013-08-08 17:45:44 -07:00
Elliott Hughes
dce94165a5 am ee48fed5: Merge "Add futimens."
* commit 'ee48fed51894f3db324e957058ed2ddcf23dddc7':
  Add futimens.
2013-08-08 17:41:15 -07:00
Christopher Ferris
d7d5049d58 am 632fd518: (-s ours) Merge "Fix strcpy.c that should have been strcpy.S. DO NOT MERGE"
* commit '632fd5183a611b80e009be36f881f572acc41619':
  Fix strcpy.c that should have been strcpy.S. DO NOT MERGE
2013-08-08 17:41:15 -07:00
Christopher Ferris
5427eb5c63 am e2066293: (-s ours) Merge "Optimize strcat/strcpy, small tweaks to strlen. DO NOT MERGE"
* commit 'e2066293e8279641d4abd13ec3fbdd6f42def83d':
  Optimize strcat/strcpy, small tweaks to strlen. DO NOT MERGE
2013-08-08 17:41:14 -07:00
Elliott Hughes
ee48fed518 Merge "Add futimens." 2013-08-09 00:37:32 +00:00
Elliott Hughes
d0be7c8f9a Add futimens.
Bug: 10239370
Change-Id: I518340084103dc339ef8a065d4837d6258a1381d
2013-08-08 17:13:33 -07:00
Christopher Ferris
632fd5183a Merge "Fix strcpy.c that should have been strcpy.S. DO NOT MERGE" 2013-08-08 19:12:20 +00:00
Christopher Ferris
e2066293e8 Merge "Optimize strcat/strcpy, small tweaks to strlen. DO NOT MERGE" 2013-08-08 19:12:00 +00:00
Christopher Ferris
b922ed3498 Fix strcpy.c that should have been strcpy.S. DO NOT MERGE
Merge from internal master.

(cherry-picked from 1ce6654163)

Change-Id: I376b831df42248baadde7202a30a68112f752ff7
2013-08-08 12:09:37 -07:00
Christopher Ferris
4e24dcc8d8 Optimize strcat/strcpy, small tweaks to strlen. DO NOT MERGE
Create one version of strcat/strcpy/strlen for cortex-a15/krait and another
version for cortex-a9.

Tested with the libc_test strcat/strcpy/strlen tests.
Including new tests that verify that the src for strcat/strcpy do not
overread across page boundaries.

NOTE: The handling of unaligned strcpy (same code in strcat) could probably
be optimized further such that the src is read 64 bits at a time instead of
the partial reads occurring now.

strlen improves slightly since it was recently optimized.

Performance improvements for strcpy and strcat (using an empty dest string):

cortex-a9
- Small copies vary from about 5% to 20% as the size gets above 10 bytes.
- Copies >= 1024, about a 60% improvement.
- Unaligned copies, from about 40% improvement.

cortex-a15
- Most small copies exhibit a 100% improvement, a few copies only
  improve by 20%.
- Copies >= 1024, about 150% improvement.
- Unaligned copies, about 100% improvement.

krait
- Most small copies vary widely, but on average 20% improvement, then
  the performance gets better, hitting about a 100% improvement when
  copies 64 bytes of data.
- Copies >= 1024, about 100% improvement.
- When coping MBs of data, about 50% improvement.
- Unaligned copies, about 90% improvement.

As strcat destination strings get larger in size:

cortex-a9
- about 40% improvement for small dst strings (>= 32).
- about 250% improvement for dst strings >= 1024.

cortex-a15
- about 200% improvement for small dst strings (>=32).
- about 250% improvement for dst strings >= 1024.

krait
- about 25% improvement for small dst strings (>=32).
- about 100% improvement for dst strings >=1024.

Merge from internal master.

(cherry-picked from d119b7b6f4)

Change-Id: I296463b251ef9fab004ee4dded2793feca5b547a
2013-08-08 11:13:46 -07:00
The Android Automerger
b683cf117d merge in klp-release history after reset to klp-dev 2013-08-08 07:53:11 -07:00
Colin Cross
7f4074d17d bionic: name malloc'd regions
Use the new __bionic_name_mem function to name malloc'd memory as
"libc_malloc" on kernels that support it.

Change-Id: I7235eae6918fa107010039b9ab8b7cb362212272
2013-08-08 00:42:39 +00:00
Colin Cross
6771b9cef6 bionic: add function to name memory
Only works on some kernels, and only on page-aligned regions of
anonymous memory.  It will show up in /proc/pid/maps as
[anon:<name>] and in /proc/pid/smaps as Name: <name>

Change-Id: If31667cf45ff41cc2a79a140ff68707526def80e
2013-08-07 15:41:30 -07:00
Christopher Ferris
7c860db074 Optimize __memset_chk, __memcpy_chk.
This change creates assembler versions of __memcpy_chk/__memset_chk
that is implemented in the memcpy/memset assembler code. This change
avoids an extra call to memcpy/memset, instead allowing a simple fall
through to occur from the chk code into the body of the real
implementation.

Testing:

- Ran the libc_test on __memcpy_chk/__memset_chk on all nexus devices.
- Wrote a small test executable that has three calls to __memcpy_chk and
  three calls to __memset_chk. First call dest_len is length + 1. Second
  call dest_len is length. Third call dest_len is length - 1.
  Verified that the first two calls pass, and the third fails. Examined
  the logcat output on all nexus devices to verify that the fortify
  error message was sent properly.
- I benchmarked the new __memcpy_chk and __memset_chk on all systems. For
  __memcpy_chk and large copies, the savings is relatively small (about 1%).
  For small copies, the savings is large on cortex-a15/krait devices
  (between 5% to 30%).
  For cortex-a9 and small copies, the speed up is present, but relatively
  small (about 3% to 5%).
  For __memset_chk and large copies, the savings is also small (about 1%).
  However, all processors show larger speed-ups on small copies (about 30% to
  100%).

Bug: 9293744

Change-Id: I8926d59fe2673e36e8a27629e02a7b7059ebbc98
2013-08-06 15:38:29 -07:00
The Android Automerger
2b899b04e9 merge in klp-release history after reset to master 2013-08-06 08:16:59 -07:00
Christopher Ferris
1ce6654163 Fix strcpy.c that should have been strcpy.S.
Change-Id: Ib4609baad3a14c8b0f37556269781fa2b06916dc
2013-08-05 17:08:06 -07:00
Christopher Ferris
e1857431e8 Merge "Optimize strcat/strcpy, small tweaks to strlen." 2013-08-05 23:32:06 +00:00
Elliott Hughes
e66ffef900 am cd927519: Merge "Fix stdint.h intptr_t/uintptr_t for x86_64/x32"
* commit 'cd927519a94939f2ebc307544f827baade529bc9':
  Fix stdint.h intptr_t/uintptr_t for x86_64/x32
2013-08-05 15:51:54 -07:00
Elliott Hughes
28e0ec8d61 am a0473d77: Merge "syslog needs a valid socket path for _PATH_LOG"
* commit 'a0473d77b2d3a6f26e29cc8c2fdaeb2a4b3ab8f8':
  syslog needs a valid socket path for _PATH_LOG
2013-08-05 15:51:53 -07:00
Elliott Hughes
cd927519a9 Merge "Fix stdint.h intptr_t/uintptr_t for x86_64/x32" 2013-08-05 20:55:24 +00:00
Elliott Hughes
a0473d77b2 Merge "syslog needs a valid socket path for _PATH_LOG" 2013-08-05 20:41:50 +00:00
Robert Greenwalt
662bb875e4 am a9c5bb97: Merge "Fix the detection of alt-network in dns resolver."
* commit 'a9c5bb972df7cbb4e65cfb53673b26f9d42deacd':
  Fix the detection of alt-network in dns resolver.
2013-08-05 11:55:53 -07:00
Robert Greenwalt
a9c5bb972d Merge "Fix the detection of alt-network in dns resolver." 2013-08-05 18:45:03 +00:00
Robert Greenwalt
1d8d9a308c Fix the detection of alt-network in dns resolver.
Used to determine proper A/AAAA record request.

bug:10132565
Change-Id: I7229f6672e879920a6fae58672cddd72db78546c
2013-08-05 18:44:30 +00:00
The Android Automerger
1714c787b6 merge in klp-release history after reset to master 2013-08-05 06:00:46 -07:00
Elliott Hughes
49b24b4efb am 3287dccf: Merge "Add ssse3 implementation of __memcmp16."
* commit '3287dccf2ecced89bb39b857abc8eba997bc3f51':
  Add ssse3 implementation of __memcmp16.
2013-08-02 18:04:01 -07:00
Ben Cheng
b78f43579f am aa2733d1: Merge "Update the comments to reflect the current status."
* commit 'aa2733d17b87c607fccbd6e6a0f44d2d411ffd77':
  Update the comments to reflect the current status.
2013-08-02 17:58:47 -07:00
Elliott Hughes
3287dccf2e Merge "Add ssse3 implementation of __memcmp16." 2013-08-03 00:58:46 +00:00
Elliott Hughes
d0313e7a2a am a6ed05c1: Merge "libgcc_compat: Introduce __aeabi_lasr for cortex-a9 and higher"
* commit 'a6ed05c1c4c787241b56df132e77512c64cbc595':
  libgcc_compat: Introduce __aeabi_lasr for cortex-a9 and higher
2013-08-02 17:58:46 -07:00
Alexander Ivchenko
baa91f4f89 Add ssse3 implementation of __memcmp16.
__memcmp16 was missing in x86. Also added C-version for backward
compatibility. Added bionic test for __memcmp16 and for wmemcmp.

Change-Id: I33718441e7ee343cdb021d91dbeaf9ce2d4d7eb4
Signed-off-by: Alexander Ivchenko <alexander.ivchenko@intel.com>
2013-08-02 17:57:23 -07:00
Ben Cheng
aa2733d17b Merge "Update the comments to reflect the current status." 2013-08-02 23:06:10 +00:00
Ben Cheng
772b797b7b Update the comments to reflect the current status.
Change-Id: I3a6348b568230fe8b21d121e5b8d30561a9703c2
2013-08-02 15:53:18 -07:00
Elliott Hughes
a6ed05c1c4 Merge "libgcc_compat: Introduce __aeabi_lasr for cortex-a9 and higher" 2013-08-02 22:39:08 +00:00
Christopher Ferris
d119b7b6f4 Optimize strcat/strcpy, small tweaks to strlen.
Create one version of strcat/strcpy/strlen for cortex-a15/krait and another
version for cortex-a9.

Tested with the libc_test strcat/strcpy/strlen tests.
Including new tests that verify that the src for strcat/strcpy do not
overread across page boundaries.

NOTE: The handling of unaligned strcpy (same code in strcat) could probably
be optimized further such that the src is read 64 bits at a time instead of
the partial reads occurring now.

strlen improves slightly since it was recently optimized.

Performance improvements for strcpy and strcat (using an empty dest string):

cortex-a9
- Small copies vary from about 5% to 20% as the size gets above 10 bytes.
- Copies >= 1024, about a 60% improvement.
- Unaligned copies, from about 40% improvement.

cortex-a15
- Most small copies exhibit a 100% improvement, a few copies only
  improve by 20%.
- Copies >= 1024, about 150% improvement.
- Unaligned copies, about 100% improvement.

krait
- Most small copies vary widely, but on average 20% improvement, then
  the performance gets better, hitting about a 100% improvement when
  copies 64 bytes of data.
- Copies >= 1024, about 100% improvement.
- When coping MBs of data, about 50% improvement.
- Unaligned copies, about 90% improvement.

As strcat destination strings get larger in size:

cortex-a9
- about 40% improvement for small dst strings (>= 32).
- about 250% improvement for dst strings >= 1024.

cortex-a15
- about 200% improvement for small dst strings (>=32).
- about 250% improvement for dst strings >= 1024.

krait
- about 25% improvement for small dst strings (>=32).
- about 100% improvement for dst strings >=1024.

Change-Id: Ifd091ebdbce70fe35a7c5d8f71d5914255f3af35
2013-08-02 10:31:51 -07:00
Pavel Chupin
0a9c615a89 Fix stdint.h intptr_t/uintptr_t for x86_64/x32
Patch is required in NDK headers as well to be able to build multilib
GCC with libgomp support.
It's here: https://android-review.googlesource.com/#/c/62982

Change-Id: I2bec25d8cbca0e5ef1a0857008ececd92f4911be
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2013-08-02 19:23:37 +04:00
Robert Greenwalt
7e5d7485b7 am e6345f1a: Merge "Tell the dns resolver about our domains."
* commit 'e6345f1a1ec691690c69d5663ca8bb2b70240d93':
  Tell the dns resolver about our domains.
2013-07-31 17:57:45 -07:00
Robert Greenwalt
e6345f1a1e Merge "Tell the dns resolver about our domains." 2013-08-01 00:47:29 +00:00
Robert Greenwalt
e0805a94c5 Tell the dns resolver about our domains.
A refactor caused us to not tell the resolver about search domains
until after it had done the domain fanout.

bug:6799630
Change-Id: Ibabd8fa5bcc69b1490fc5e329e62eb0f2d1a5e63
2013-07-31 16:53:46 -07:00
The Android Automerger
1d1fe3bb69 merge in klp-release history after reset to master 2013-07-30 11:08:39 -07:00
Elliott Hughes
abf3638317 am 101b5e1f: Merge "Define PTHREAD_KEYS_MAX and _POSIX_THREAD_KEYS_MAX in a POSIX-compliant way."
* commit '101b5e1f6cc4e24635760928b3d2c1e51c1e5774':
  Define PTHREAD_KEYS_MAX and _POSIX_THREAD_KEYS_MAX in a POSIX-compliant way.
2013-07-29 17:35:49 -07:00
Elliott Hughes
101b5e1f6c Merge "Define PTHREAD_KEYS_MAX and _POSIX_THREAD_KEYS_MAX in a POSIX-compliant way." 2013-07-30 00:29:58 +00:00
Elliott Hughes
c03e1e7439 Define PTHREAD_KEYS_MAX and _POSIX_THREAD_KEYS_MAX in a POSIX-compliant way.
Also make sysconf use PTHREAD_STACK_MIN rather than redefining its
own, different, constant.

Bug: 9997352
Change-Id: I9a8e7d2b18e691439abfb45533e82c36eee9e81d
2013-07-29 17:09:36 -07:00
synergydev
efddf44c8e libgcc_compat: Introduce __aeabi_lasr for cortex-a9 and higher
This is needed when passing -mcpu=cortex-a9 or higher on a modern
toolchain for prebuilt library compatibility

Change-Id: I73eb2393377914ae26216a8c2828ad973d1c1225
2013-07-29 16:55:08 -07:00
Elliott Hughes
326b52760d am 9a73d08f: Merge "Bump the number of TLS slots to 128."
* commit '9a73d08f4c334c00fe06d583d37e038ebe063eba':
  Bump the number of TLS slots to 128.
2013-07-25 17:04:18 -07:00
Elliott Hughes
9a73d08f4c Merge "Bump the number of TLS slots to 128." 2013-07-25 21:51:05 +00:00
Elliott Hughes
838f01fdc7 Bump the number of TLS slots to 128.
Bug: 9997352
Change-Id: I7bde7228d803e9d4bb83309c5891d54a07e3b025
2013-07-25 14:14:22 -07:00
Elliott Hughes
478314a109 am a9feb5e3: Merge "Avoid sign extension of the mmap offset."
* commit 'a9feb5e33a5261f45fb25fd5e90a56792c6a437e':
  Avoid sign extension of the mmap offset.
2013-07-25 10:51:00 -07:00
Elliott Hughes
a9feb5e33a Merge "Avoid sign extension of the mmap offset." 2013-07-25 17:28:59 +00:00
Elliott Hughes
e320a8c780 Avoid sign extension of the mmap offset.
off_t is signed to support seeking backwards, but that's a liability
when using off_t to represent a subset of a file.

Change-Id: I2a3615166eb16212347eb47f1242e3bfb93c2022
2013-07-25 10:15:07 -07:00
The Android Automerger
48161c898b merge in klp-release history after reset to master 2013-07-24 06:00:57 -07:00
Elliott Hughes
a59b7ed8c3 am bfba6aac: am a8d06766: Merge "[MIPS] __dso_handle.S and __dso_handle_so.S not needed."
* commit 'bfba6aac99115972fad3341aef595c0ca1f7258b':
  [MIPS] __dso_handle.S and __dso_handle_so.S not needed.
2013-07-23 18:10:51 -07:00
Elliott Hughes
bfba6aac99 am a8d06766: Merge "[MIPS] __dso_handle.S and __dso_handle_so.S not needed."
* commit 'a8d06766c7674bbfde852e8bfee4200e75ad8f24':
  [MIPS] __dso_handle.S and __dso_handle_so.S not needed.
2013-07-23 18:07:12 -07:00
Elliott Hughes
a8d06766c7 Merge "[MIPS] __dso_handle.S and __dso_handle_so.S not needed." 2013-07-24 01:05:18 +00:00
Rom Lemarchand
c847f749fe am c5749f1f: am 061246b6: Merge "Restore dlmalloc mmap threshold to 64k"
* commit 'c5749f1f4232e59e66737488036aba1f583867d5':
  Restore dlmalloc mmap threshold to 64k
2013-07-23 13:58:12 -07:00
Rom Lemarchand
c5749f1f42 am 061246b6: Merge "Restore dlmalloc mmap threshold to 64k"
* commit '061246b600c16a80b246804221b9e3fa65e507d9':
  Restore dlmalloc mmap threshold to 64k
2013-07-23 13:52:29 -07:00
Rom Lemarchand
061246b600 Merge "Restore dlmalloc mmap threshold to 64k" 2013-07-23 20:49:46 +00:00
Rom Lemarchand
d0f2a6014c Restore dlmalloc mmap threshold to 64k
Restoring DEFAULT_MMAP_THRESHOLD to 64k, the way it was before
999089181e.

This forces allocations in the 64k-256k range to be mmaped.

Change-Id: Iace55ed638edd272b3e94fa6cd2ddd349042be84
Signed-off-by: Rom Lemarchand <romlem@google.com>
2013-07-23 13:48:39 -07:00
Pete Delaney
0995a7b322 [MIPS] __dso_handle.S and __dso_handle_so.S not needed.
Global hidden variable __dso_handle is now declared in:
       bionic/libc/private/__dso_handle.h

Change-Id: I8e951a8d7c65877bafc1be23a7fff6d44d3a2846
Signed-off-by: Pete Delaney  <piet.delaney@imgtec.com>
Signed-off-by: Chao-Ying Fu  <chao-ying.fu@imgtec.com>
2013-07-22 23:16:02 -07:00
The Android Automerger
58ccd60877 merge in klp-release history after reset to master 2013-07-22 06:00:33 -07:00
Elliott Hughes
aa9116f0ed am c2902edf: am 6fe4a58f: Merge "Move stuff only needed by pthread-timers.c into pthread-timers.c."
* commit 'c2902edfc4aaa02977eef7154d05d5369bc48281':
  Move stuff only needed by pthread-timers.c into pthread-timers.c.
2013-07-19 17:19:46 -07:00
Elliott Hughes
c2902edfc4 am 6fe4a58f: Merge "Move stuff only needed by pthread-timers.c into pthread-timers.c."
* commit '6fe4a58f84954523f17114f1f7cf060a3573c073':
  Move stuff only needed by pthread-timers.c into pthread-timers.c.
2013-07-19 17:13:33 -07:00
Elliott Hughes
6fe4a58f84 Merge "Move stuff only needed by pthread-timers.c into pthread-timers.c." 2013-07-20 00:10:32 +00:00
Elliott Hughes
8b56ba8896 am 178c4185: am e8bd8c2e: Merge "Upgrade mktemp.c to the current upstream version."
* commit '178c41857321732259c3e22d73c86c22ae4359b5':
  Upgrade mktemp.c to the current upstream version.
2013-07-19 16:43:07 -07:00
Elliott Hughes
4cf1395217 Move stuff only needed by pthread-timers.c into pthread-timers.c.
Change-Id: I4915b3fff9c4f5a36b4f51027fb22019c11607b0
2013-07-19 16:42:27 -07:00
Elliott Hughes
178c418573 am e8bd8c2e: Merge "Upgrade mktemp.c to the current upstream version."
* commit 'e8bd8c2ed9c71c73682f29020456934c55f260e3':
  Upgrade mktemp.c to the current upstream version.
2013-07-19 16:37:52 -07:00
Elliott Hughes
e8bd8c2ed9 Merge "Upgrade mktemp.c to the current upstream version." 2013-07-19 23:35:29 +00:00
Elliott Hughes
284f788032 Upgrade mktemp.c to the current upstream version.
Yet another archaic relic containing bugs that had been fixed years before the
Android project even started...

Bug: 9935113
Change-Id: I3c9d019a216efd609ee568cf8c70bc360f357403
2013-07-19 15:20:31 -07:00
Colin Cross
15d2784fc1 Merge "Kexec header generated from linux header 3.10" 2013-07-18 17:41:09 +00:00
The Android Automerger
00196d1a46 merge in klp-release history after reset to master 2013-07-18 06:00:28 -07:00
Elliott Hughes
3c212645a0 am 81b46980: am f8a66bb3: Merge "Remove some non-unused makefile generality."
* commit '81b4698059c37ac36aa74d1498bef5654580ad3f':
  Remove some non-unused makefile generality.
2013-07-17 17:45:03 -07:00
Elliott Hughes
81b4698059 am f8a66bb3: Merge "Remove some non-unused makefile generality."
* commit 'f8a66bb31204b42f830c1865a795b5f3eb1e0147':
  Remove some non-unused makefile generality.
2013-07-17 17:41:43 -07:00
Elliott Hughes
ac74b8565a am b6b2375d: am 8fa9081f: Merge "[MIPS] Rewrite MIPS crtbegin* as C files."
* commit 'b6b2375df8ca63a5e349d8277d425ab58e16aeb1':
  [MIPS] Rewrite MIPS crtbegin* as C files.
2013-07-17 17:40:46 -07:00
Elliott Hughes
f8a66bb312 Merge "Remove some non-unused makefile generality." 2013-07-18 00:39:35 +00:00
Elliott Hughes
4c6b925bac Remove some non-unused makefile generality.
MIPS uses .c files like ARM and x86 now.

Change-Id: Ie580647e385121c380316c443ec199dabf657ff8
2013-07-17 17:38:45 -07:00
Elliott Hughes
b6b2375df8 am 8fa9081f: Merge "[MIPS] Rewrite MIPS crtbegin* as C files."
* commit '8fa9081f48c4861f83737d59bf2c2c8f21c7da3f':
  [MIPS] Rewrite MIPS crtbegin* as C files.
2013-07-17 17:36:26 -07:00
Elliott Hughes
8fa9081f48 Merge "[MIPS] Rewrite MIPS crtbegin* as C files." 2013-07-18 00:34:22 +00:00
Pete Delaney
368860124c [MIPS] Rewrite MIPS crtbegin* as C files.
This updates the MIPS arch to be much more in
sync with the commit Nick Kralevich made last
June; see 9d40326830.

    Rewrite
     crtbegin.S        -> crtbegin.c
     crtbegin_so.S     -> crtbegin_so.c
     __dso_handle.S    -> __dso_handle.c
     __dso_handle_so.S -> __dso_handle_so.c
     atexit.S          -> atexit.c

Previously __do_global_dtors_aux was in the tasks
__FINI_ARRAY__ linked with crtbegin.S and it now being
removed as there is no need to call a destructor just
before terminating a process.

Shared libraries, on the other hand, are linked with
crtbegin_so.c and have a hidden destructor declared
to allow the bionic linker to call __on_dlclose().

Change-Id: Ieb4da5199b54573de05743990e309db381a11cb8
Signed-off-by: Pete Delaney  <piet.delaney@imgtec.com>
Signed-off-by: Chao-Ying Fu  <chao-ying.fu@imgtec.com>
Signed-off-by: Chris Dearman <chris.dearman@imgtec.com>
2013-07-17 14:23:29 -07:00
Elliott Hughes
66f8452a14 am cbf07a25: am 2be511d4: Merge "Improve stack overflow diagnostics (take 2)."
* commit 'cbf07a25149cd924a348e4dc0395c5d08f86fd7f':
  Improve stack overflow diagnostics (take 2).
2013-07-17 13:53:06 -07:00
Elliott Hughes
cbf07a2514 am 2be511d4: Merge "Improve stack overflow diagnostics (take 2)."
* commit '2be511d405d47eccc61a6e3c338d1877bf33b4fa':
  Improve stack overflow diagnostics (take 2).
2013-07-17 13:50:15 -07:00
Elliott Hughes
2be511d405 Merge "Improve stack overflow diagnostics (take 2)." 2013-07-17 20:48:25 +00:00
Elliott Hughes
84114c8dd5 Improve stack overflow diagnostics (take 2).
This reverts commits eb1b07469f and
d14dc3b87f, and fixes the bug where
we were calling mmap (which might cause errno to be set) before
__set_tls (which is required to implement errno).

Bug: 8557703
Change-Id: I2c36d00240c56e156e1bb430d8c22a73a068b70c
2013-07-17 13:33:19 -07:00
Elliott Hughes
4add6968be resolved conflicts for merge of e35d6c28 to master
Change-Id: I237bfc35d872a2e2ff10984012f9811488a5cea7
2013-07-17 13:28:30 -07:00
Elliott Hughes
e35d6c28df am 40e7a878: Merge "Prevent the madvise(MADV_MERGEABLE) mmap hack from affecting errno."
* commit '40e7a87864fee75f7af2caf8e1972d0d764135cd':
  Prevent the madvise(MADV_MERGEABLE) mmap hack from affecting errno.
2013-07-17 13:22:39 -07:00
Elliott Hughes
40e7a87864 Merge "Prevent the madvise(MADV_MERGEABLE) mmap hack from affecting errno." 2013-07-17 20:20:41 +00:00
Elliott Hughes
a5a3b3bdb1 resolved conflicts for merge of 4763ef2b to master
Change-Id: I4d424f9fb438c2ed845bca0bbcae69b4d0f5e3dc
2013-07-17 13:18:43 -07:00
Elliott Hughes
107cdd406b Prevent the madvise(MADV_MERGEABLE) mmap hack from affecting errno.
Bug: 9889616
Change-Id: I4a7323e0ae5aeb5cbe0da1b2bc7501d83b3a2aa4
2013-07-17 13:12:26 -07:00
Elliott Hughes
4763ef2b5b am b7b36b81: Merge "mmap: Reinstate passing MADV_MERGEABLE on private anonymous maps"
* commit 'b7b36b819e8029a152859f3204ba2da38a0e2879':
  mmap: Reinstate passing MADV_MERGEABLE on private anonymous maps
2013-07-17 13:05:13 -07:00
Elliott Hughes
b7b36b819e Merge "mmap: Reinstate passing MADV_MERGEABLE on private anonymous maps" 2013-07-17 20:02:11 +00:00
Rom Lemarchand
e459bba398 mmap: Reinstate passing MADV_MERGEABLE on private anonymous maps
Reinstate mmap calling madvise(MADV_MERGEABLE) removed in
635df850e5

(cherry-pick of c702a904679a36511bead29c51eeac15d81f4fd2.)

Change-Id: I18803fb54701b2b3d8186dff5c678211ee3efa1f
2013-07-17 13:00:45 -07:00
The Android Automerger
0976c97fe4 merge in klp-release history after reset to master 2013-07-17 06:00:13 -07:00
Guang Zhu
81b7df7315 am 6f08b865: am 2cf5a6f6: Merge "Revert "Improve stack overflow diagnostics.""
* commit '6f08b8659a3682b7e774af6ed68b1b613e147f1b':
  Revert "Improve stack overflow diagnostics."
2013-07-16 20:23:42 -07:00
Guang Zhu
dd4eb67a48 am 849bfd58: am 8c1b9668: Merge "Revert "Clean up our alternate signal stacks.""
* commit '849bfd58118e8c8a4b1ad8a7c3de74bb3cd13863':
  Revert "Clean up our alternate signal stacks."
2013-07-16 20:23:41 -07:00
Guang Zhu
6f08b8659a am 2cf5a6f6: Merge "Revert "Improve stack overflow diagnostics.""
* commit '2cf5a6f6627549842c0c840ff3615ae942a90ea3':
  Revert "Improve stack overflow diagnostics."
2013-07-16 20:18:57 -07:00
Guang Zhu
849bfd5811 am 8c1b9668: Merge "Revert "Clean up our alternate signal stacks.""
* commit '8c1b96681af91fda86a5493e7f7e4381ce489648':
  Revert "Clean up our alternate signal stacks."
2013-07-16 20:18:57 -07:00
Guang Zhu
2cf5a6f662 Merge "Revert "Improve stack overflow diagnostics."" 2013-07-17 03:17:19 +00:00
Guang Zhu
d14dc3b87f Revert "Improve stack overflow diagnostics."
This reverts commit aa754dca90.

Change-Id: Ifa76eee31f7f44075eb3a48554315b2693062f44
2013-07-17 03:17:05 +00:00
Guang Zhu
8c1b96681a Merge "Revert "Clean up our alternate signal stacks."" 2013-07-17 03:16:52 +00:00
Guang Zhu
eb1b07469f Revert "Clean up our alternate signal stacks."
This reverts commit 5cf87951ab.

Change-Id: Idd6ca7d80a018755da3bd315d91193723ce7f3bf
2013-07-17 03:16:04 +00:00
Christopher Ferris
66cb2edba5 am 7ff868a6: am f63c28f0: Merge "Fix assembler errors in generic arm strlen.c."
* commit '7ff868a6307f0d5e63555b5d320b8ad6e490e3c4':
  Fix assembler errors in generic arm strlen.c.
2013-07-16 17:24:40 -07:00
Christopher Ferris
69205c5433 am b1d7fd49: am 6f4fed74: Merge "Add new optimized strlen for arm."
* commit 'b1d7fd4969fdd3d3402b500840561beb30962c1d':
  Add new optimized strlen for arm.
2013-07-16 17:24:40 -07:00
Christopher Ferris
7ff868a630 am f63c28f0: Merge "Fix assembler errors in generic arm strlen.c."
* commit 'f63c28f0338fd647e88f1f9300b2220093af1aae':
  Fix assembler errors in generic arm strlen.c.
2013-07-16 17:22:05 -07:00
Christopher Ferris
b1d7fd4969 am 6f4fed74: Merge "Add new optimized strlen for arm."
* commit '6f4fed74cb9405c0f5322307085d15afed6be764':
  Add new optimized strlen for arm.
2013-07-16 17:21:55 -07:00
Christopher Ferris
f63c28f033 Merge "Fix assembler errors in generic arm strlen.c." 2013-07-17 00:19:42 +00:00
Christopher Ferris
6f4fed74cb Merge "Add new optimized strlen for arm." 2013-07-17 00:19:30 +00:00
Christopher Ferris
9ad2a73ed6 Fix assembler errors in generic arm strlen.c.
Tested using a static version of the strlen libc_test program
on a nexus7 that uses the generic code.

Merge from internal master.

(cherry-picked from d8d10a8994)

Change-Id: I88f7dc01dc5b5c3ac2d5580d92153bc1bc36c564
2013-07-16 16:47:54 -07:00
Christopher Ferris
0aa9b52efa Add new optimized strlen for arm.
This optimized version is primarily targeted at cortex-a15.

Tested on all nexus devices using the system/extras/libc_test strlen test.
Tested alignments from 1 to 32 that are powers of 2.
Tested that strlen does not cross page boundaries at all alignments.

Speed improvements listed below:

cortex-a15
- Sizes >= 32 bytes, ~75% improvement.
- Sizes >= 1024 bytes, ~250% improvement.

cortex-a9
- Sizes >= 32 bytes, ~75% improvement.
- Sizes >= 1024 bytes, ~85% improvement.

krait
- Sizes >= 32 bytes, ~95% improvement.
- Sizes >= 1024 bytes, ~160% improvement.

Merge from internal master.

(cherry-picked from 2fc0717977)

Change-Id: I1ceceb4e745fd68e9d946f96d1d42e0cdaff6ccf
2013-07-16 16:47:37 -07:00
Elliott Hughes
152dcf3b3f am 79dfb1af: am f35e0c14: Merge "Clean up our alternate signal stacks."
* commit '79dfb1afda16565a0dd378eca7f72bfe81fae205':
  Clean up our alternate signal stacks.
2013-07-16 15:56:16 -07:00
Elliott Hughes
79dfb1afda am f35e0c14: Merge "Clean up our alternate signal stacks."
* commit 'f35e0c149f1a6801a5af7c339f84d81ae05c3adf':
  Clean up our alternate signal stacks.
2013-07-16 15:50:18 -07:00
Elliott Hughes
f35e0c149f Merge "Clean up our alternate signal stacks." 2013-07-16 22:47:41 +00:00
Elliott Hughes
617a1e4977 am 10a954de: am 026867c7: Merge "Improve stack overflow diagnostics."
* commit '10a954dea6732232ed6cf56d3aa6ca38673dacbf':
  Improve stack overflow diagnostics.
2013-07-16 15:36:12 -07:00
Elliott Hughes
f2f6b2bad3 am d2acf124: am 9562d38d: Merge "Clean up __builtin_expect usage."
* commit 'd2acf124ed7ad18f8adb5159544c92234cade90e':
  Clean up __builtin_expect usage.
2013-07-16 15:36:12 -07:00
Elliott Hughes
62d6b7526a am 2a18ea14: am f152e386: Merge "EABI syscall cleanup."
* commit '2a18ea1462cf65cc51bfcb1a1c46972ee5af1d01':
  EABI syscall cleanup.
2013-07-16 15:36:11 -07:00
Elliott Hughes
10a954dea6 am 026867c7: Merge "Improve stack overflow diagnostics."
* commit '026867c7dcce7828212dcd4a61806146908e9039':
  Improve stack overflow diagnostics.
2013-07-16 15:31:40 -07:00
Elliott Hughes
d2acf124ed am 9562d38d: Merge "Clean up __builtin_expect usage."
* commit '9562d38df1e4aba941b3433cfd0922fee5ea258b':
  Clean up __builtin_expect usage.
2013-07-16 15:31:39 -07:00
Elliott Hughes
2a18ea1462 am f152e386: Merge "EABI syscall cleanup."
* commit 'f152e386fcf477f3f5de9dc020c3660d4f9c4b81':
  EABI syscall cleanup.
2013-07-16 15:31:39 -07:00
Elliott Hughes
5cf87951ab Clean up our alternate signal stacks.
Bug: 8557703
Change-Id: Ie93901dd1c29e9d3bf795b0f0400616d9ef08f75
2013-07-16 14:35:52 -07:00
Elliott Hughes
026867c7dc Merge "Improve stack overflow diagnostics." 2013-07-16 20:38:55 +00:00
Elliott Hughes
aa754dca90 Improve stack overflow diagnostics.
We notify debuggerd of problems by installing signal handlers. That's
fine except for when the signal is caused by us running off the end of
a thread's stack and into the guard page.

Bug: 8557703
Change-Id: I1ef65b4bb3bbca7e9a9743056177094921e60ed3
2013-07-16 13:14:24 -07:00
Elliott Hughes
9562d38df1 Merge "Clean up __builtin_expect usage." 2013-07-16 19:52:30 +00:00
Elliott Hughes
d4e753fea9 Clean up __builtin_expect usage.
Also remove some dead code; our malloc debugging doesn't use this
any more.

Change-Id: Id69cf182371f5f37d40b5bbd08f2744ade286e66
2013-07-16 12:45:46 -07:00
Elliott Hughes
f152e386fc Merge "EABI syscall cleanup." 2013-07-16 19:35:58 +00:00
Elliott Hughes
da4a3e6515 EABI syscall cleanup.
We cleaned up the auto-generated ones a while back to not touch
the stack unnecessarily if they have <= 4 arguments. This patch
cleans up some hand-crafted ones.

Also improve comments in clone.S.

Change-Id: I8850bf98f2b26829385315304472a760e6880ed8
2013-07-16 11:52:24 -07:00
The Android Automerger
7256fbd9b2 merge in klp-release history after reset to master 2013-07-16 06:00:36 -07:00
Elliott Hughes
993ea1061b am 5148661f: am 67750c85: Merge "Fix pthread_getattr_np, pthread_attr_setguardsize, and pthread_attr_setstacksize."
* commit '5148661f8d2be514d0e3c191bc1e489157ae1154':
  Fix pthread_getattr_np, pthread_attr_setguardsize, and pthread_attr_setstacksize.
2013-07-15 16:45:54 -07:00
Elliott Hughes
5148661f8d am 67750c85: Merge "Fix pthread_getattr_np, pthread_attr_setguardsize, and pthread_attr_setstacksize."
* commit '67750c8515573cba294b2f3840249dd7f7d817d5':
  Fix pthread_getattr_np, pthread_attr_setguardsize, and pthread_attr_setstacksize.
2013-07-15 16:42:34 -07:00
Elliott Hughes
67750c8515 Merge "Fix pthread_getattr_np, pthread_attr_setguardsize, and pthread_attr_setstacksize." 2013-07-15 23:39:39 +00:00
Elliott Hughes
b95cf0d23a Fix pthread_getattr_np, pthread_attr_setguardsize, and pthread_attr_setstacksize.
pthread_getattr_np was reporting the values supplied to us, not the values we
actually used, which is kinda the whole point of pthread_getattr_np.

pthread_attr_setguardsize and pthread_attr_setstacksize were reporting EINVAL
for any size that wasn't a multiple of the system page size. This is
unnecessary. We can just round like POSIX suggests and glibc already does.

Also improve the error reporting for pthread_create failures.

Change-Id: I7ebc518628a8a1161ec72e111def911d500bba71
2013-07-15 14:51:07 -07:00
Christopher Ferris
d8d10a8994 Fix assembler errors in generic arm strlen.c.
Tested using a static version of the strlen libc_test program
on a nexus7 that uses the generic code.

Change-Id: If04d15dcb6c0b18f27f2fefadca5510ed49016c5
2013-07-15 13:56:45 -07:00
Szymon Starzycki
674be7e0fc Kexec header generated from linux header 3.10
Change-Id: Iac26fcc6e0e25905ab52dba91bec16a4fb479d43
2013-07-15 13:51:56 -07:00
Christopher Ferris
67e9f47476 Merge "Add new optimized strlen for arm." 2013-07-15 19:44:26 +00:00
Christopher Ferris
2fc0717977 Add new optimized strlen for arm.
This optimized version is primarily targeted at cortex-a15.

Tested on all nexus devices using the system/extras/libc_test strlen test.
Tested alignments from 1 to 32 that are powers of 2.
Tested that strlen does not cross page boundaries at all alignments.

Speed improvements listed below:

cortex-a15
- Sizes >= 32 bytes, ~75% improvement.
- Sizes >= 1024 bytes, ~250% improvement.

cortex-a9
- Sizes >= 32 bytes, ~75% improvement.
- Sizes >= 1024 bytes, ~85% improvement.

krait
- Sizes >= 32 bytes, ~95% improvement.
- Sizes >= 1024 bytes, ~160% improvement.

Change-Id: I361b1a36ed89ab991f2a8f0abbf0d7416d39c8f5
2013-07-15 12:37:51 -07:00
Elliott Hughes
fc2ada9741 am f384be3b: am 59ed029b: Merge "Upgrade to tzcode2013d."
* commit 'f384be3b5c2062e7ef4e7449b466bf2f24f7bcc8':
  Upgrade to tzcode2013d.
2013-07-15 10:15:45 -07:00
Elliott Hughes
f384be3b5c am 59ed029b: Merge "Upgrade to tzcode2013d."
* commit '59ed029b286a1564f635377296e4f088e0fd2afa':
  Upgrade to tzcode2013d.
2013-07-15 10:11:04 -07:00
Elliott Hughes
59ed029b28 Merge "Upgrade to tzcode2013d." 2013-07-15 17:08:41 +00:00
The Android Automerger
2d7d92e811 merge in klp-release history after reset to master 2013-07-15 06:00:50 -07:00
Elliott Hughes
ce4783ce76 Upgrade to tzcode2013d.
Well, kinda... localtime.c still contains a bunch of Android-specific
hacks, as does strftime.c. But the other files are now exactly the same
as upstream.

This catches up with several years of bug fixes, and fixes most of the
compiler warnings that were in this code. (Just two remain.)

Bug: 1744909
Change-Id: I2ddfecb6fd408c847397c17afb0fff859e27feef
2013-07-12 17:52:44 -07:00
Elliott Hughes
d3522051ce am 7e56f462: am 3db1f359: Merge "Add a trivial gmtime(3) test."
* commit '7e56f462ad19791d7b270e297fc994d18df43252':
  Add a trivial gmtime(3) test.
2013-07-12 14:35:19 -07:00
Elliott Hughes
7e56f462ad am 3db1f359: Merge "Add a trivial gmtime(3) test."
* commit '3db1f359e9f218f5f73a7a9f4d80e4be362a526e':
  Add a trivial gmtime(3) test.
2013-07-12 14:28:40 -07:00
Elliott Hughes
3db1f359e9 Merge "Add a trivial gmtime(3) test." 2013-07-12 21:23:48 +00:00
Elliott Hughes
ee178bfb79 Add a trivial gmtime(3) test.
Change-Id: I849f200a455cd6971646fa45766ab22ba19fb866
2013-07-12 11:25:20 -07:00
Elliott Hughes
47c7e33ccb am ff20b911: am 8a363692: Merge "Add TCP_INFO state enum values."
* commit 'ff20b9110659e67433ce641a6224cdc9ccc01301':
  Add TCP_INFO state enum values.
2013-07-11 18:57:42 -07:00
Nick Kralevich
4fa5d6a5db am ef49e99d: am d30877ae: Merge "syslog.h: add __printflike to syslog functions"
* commit 'ef49e99d92597a4e9fddbba0e1e3feddc06fee53':
  syslog.h: add __printflike to syslog functions
2013-07-11 18:57:41 -07:00
Elliott Hughes
ff20b91106 am 8a363692: Merge "Add TCP_INFO state enum values."
* commit '8a363692be45ed1b36e1f1f21707b6f35f5519c8':
  Add TCP_INFO state enum values.
2013-07-11 18:52:22 -07:00
Nick Kralevich
ef49e99d92 am d30877ae: Merge "syslog.h: add __printflike to syslog functions"
* commit 'd30877ae28f3c308edf142c091b3a8acc4467c6d':
  syslog.h: add __printflike to syslog functions
2013-07-11 18:52:01 -07:00
Elliott Hughes
8a363692be Merge "Add TCP_INFO state enum values." 2013-07-11 23:58:48 +00:00
Elliott Hughes
0dff43cab4 Add TCP_INFO state enum values.
Bug: https://code.google.com/p/android/issues/detail?id=38881
Change-Id: Ie22816c666474e6441e0ec3afd2a6eb04d64a673
2013-07-11 16:21:32 -07:00
Geremy Condra
bb17967761 Merge "Add marking of DNS sockets for mark based routing" 2013-07-11 22:10:31 +00:00
Elliott Hughes
f9a1d1cf5f am 09f561b3: am b7f49237: Merge "Fix MIPS build."
* commit '09f561b38b880e551097b807585d0e037fa36442':
  Fix MIPS build.
2013-07-11 10:16:33 -07:00
Elliott Hughes
1087e0df4f am 731f7c2d: am 9d476716: Merge "Add <sys/statvfs.h>."
* commit '731f7c2d0e531d5e0ecdd771d743053f8d093e16':
  Add <sys/statvfs.h>.
2013-07-11 10:16:32 -07:00
Nick Kralevich
d30877ae28 Merge "syslog.h: add __printflike to syslog functions" 2013-07-11 15:32:49 +00:00
Nick Kralevich
6b1dd1797e syslog.h: add __printflike to syslog functions
Allow the compiler to detect formating bugs.

Change-Id: I6a4af6cae59dc3adf14b075431a41885213a649a
2013-07-10 07:37:11 -07:00
Elliott Hughes
09f561b38b am b7f49237: Merge "Fix MIPS build."
* commit 'b7f492375291306065472b67011eebb324de1022':
  Fix MIPS build.
2013-07-09 14:21:50 -07:00
Elliott Hughes
b7f4923752 Merge "Fix MIPS build." 2013-07-09 21:19:15 +00:00
Elliott Hughes
6184c1feaa Fix MIPS build.
Change-Id: I583b1794dbc12fcded8c4f57f367593a742ab33f
2013-07-09 14:18:36 -07:00
Elliott Hughes
731f7c2d0e am 9d476716: Merge "Add <sys/statvfs.h>."
* commit '9d476716c2bd7bc5a018a71e121257c35e965058':
  Add <sys/statvfs.h>.
2013-07-09 13:44:57 -07:00
Elliott Hughes
9d476716c2 Merge "Add <sys/statvfs.h>." 2013-07-09 20:43:13 +00:00
Elliott Hughes
06040fd75c Add <sys/statvfs.h>.
Bug: 2512019
Change-Id: I6e7fd3fa281977cc4bc270481a95416b5b2dc351
2013-07-09 13:25:03 -07:00
Chad Brubaker
c39214e0ac Add marking of DNS sockets for mark based routing
Adds an extra mark parameter to android_getaddrinfoforiface,
android_gethostbyaddrforiface and android_gethostbynameforiface that if set
will cause all packets sent by DNS requests to have that mark

Change-Id: I6f72390e4ce5bfc3cc73183f9b2fb3705a11685f
2013-07-09 13:16:22 -07:00
The Android Automerger
b89a334df8 merge in klp-release history after reset to master 2013-07-09 06:00:16 -07:00
Elliott Hughes
273df910b5 am f3f72e7f: am 4fc8a0c1: Merge "Remove <netinet/icmp6.h> ni_* macros."
* commit 'f3f72e7f277215e9fede7c6f6695654cf7aa0c63':
  Remove <netinet/icmp6.h> ni_* macros.
2013-07-08 15:13:35 -07:00
Elliott Hughes
4df412cba6 am 74b06f8d: am ff145277: Merge "Upgrade to tzdata2013d."
* commit '74b06f8ddcaaa48c7bab418d15aacaf513423ac3':
  Upgrade to tzdata2013d.
2013-07-08 15:09:57 -07:00
Elliott Hughes
f3f72e7f27 am 4fc8a0c1: Merge "Remove <netinet/icmp6.h> ni_* macros."
* commit '4fc8a0c1165537b693c900ac3e2c61470bd7e484':
  Remove <netinet/icmp6.h> ni_* macros.
2013-07-08 15:09:07 -07:00
Elliott Hughes
4fc8a0c116 Merge "Remove <netinet/icmp6.h> ni_* macros." 2013-07-08 22:08:12 +00:00
Elliott Hughes
c2cd33efc4 Remove <netinet/icmp6.h> ni_* macros.
glibc doesn't have these, and they prevent ping from building out of
the box because it assumes it can define them.

Bug: 9671560
Change-Id: I815f2a9c4fd96a0ea2952eb5a71ddf51e0763660
2013-07-08 15:07:41 -07:00
Elliott Hughes
74b06f8ddc am ff145277: Merge "Upgrade to tzdata2013d."
* commit 'ff145277da9b7fe3d48a27839fc1d6f2ed11604b':
  Upgrade to tzdata2013d.
2013-07-08 14:55:41 -07:00
Elliott Hughes
ff145277da Merge "Upgrade to tzdata2013d." 2013-07-08 21:53:02 +00:00
Elliott Hughes
5149de09ad Upgrade to tzdata2013d.
From the release notes:

  Changes affecting future time stamps:

    Morocco's midsummer transitions this year are July 7 and August 10,
    not July 9 and August 8.  (Thanks to Andrew Paprocki.)

    Israel now falls back on the last Sunday of October.
    (Thanks to Ephraim Silverberg.)

  Changes affecting past time stamps:

    Specify Jerusalem's location more precisely; this changes the pre-1880
    times by 2 s.

  Changing affecting metadata only:

    Fix typos in the entries for country codes BQ and SX.

Change-Id: I87f992e4c406d4f254dc274f206536e9484024a2
2013-07-08 14:51:15 -07:00
Elliott Hughes
f33dce1ab6 am 233050b1: am e31c45c9: Merge "Make bionic\'s <netinet/icmp6.h> standalone, like glibc\'s."
* commit '233050b15ec3ce0db534ec6cc24a6061559993d2':
  Make bionic's <netinet/icmp6.h> standalone, like glibc's.
2013-07-08 11:27:53 -07:00
Elliott Hughes
233050b15e am e31c45c9: Merge "Make bionic\'s <netinet/icmp6.h> standalone, like glibc\'s."
* commit 'e31c45c9fa5e0d2853941282e619b753550b82ae':
  Make bionic's <netinet/icmp6.h> standalone, like glibc's.
2013-07-08 11:21:53 -07:00
Elliott Hughes
e31c45c9fa Merge "Make bionic's <netinet/icmp6.h> standalone, like glibc's." 2013-07-08 18:17:57 +00:00
Elliott Hughes
3a040d8379 Make bionic's <netinet/icmp6.h> standalone, like glibc's.
This removes the need for a bionic-specific hack in external/iproute2.

Bug: 9671560
Change-Id: I9f15be0711d26bca863bd66be9a39606500fb948
2013-07-08 11:16:24 -07:00
Elliott Hughes
b1397f97f1 am 62bdd031: am 6b33f31b: Merge "Fix IPv6 filtering definitions in netinet/icmp6.h."
* commit '62bdd03120286708d8c1562eadf5dda00e24911c':
  Fix IPv6 filtering definitions in netinet/icmp6.h.
2013-07-08 10:38:41 -07:00
Elliott Hughes
62bdd03120 am 6b33f31b: Merge "Fix IPv6 filtering definitions in netinet/icmp6.h."
* commit '6b33f31b0994b8132bed8936685522e2e01754d8':
  Fix IPv6 filtering definitions in netinet/icmp6.h.
2013-07-08 10:34:41 -07:00
Elliott Hughes
6b33f31b09 Merge "Fix IPv6 filtering definitions in netinet/icmp6.h." 2013-07-08 17:32:17 +00:00
Lorenzo Colitti
bfc6a59556 Fix IPv6 filtering definitions in netinet/icmp6.h.
Linux and *BSD kernels use opposite values to indicate pass/block
in ICMPv6 filters, and assign a different value to the
ICMP6_FILTER sockopt.

Bug: 9671560
Bug: 9469682
Change-Id: Ic0f1fcd48891add992acf97632f60aebd172c1d7
2013-07-08 10:31:29 -07:00
Elliott Hughes
b611d36c3a am 24400ac1: am e63ea6ac: Merge "Clean up <sys/mount.h>/<linux/fs.h> duplication."
* commit '24400ac1e390615ebcb45deacc1c9213b00f75ff':
  Clean up <sys/mount.h>/<linux/fs.h> duplication.
2013-07-08 10:17:38 -07:00
Elliott Hughes
24400ac1e3 am e63ea6ac: Merge "Clean up <sys/mount.h>/<linux/fs.h> duplication."
* commit 'e63ea6aca7d01ba9219b877ed5fab6de5c6037fb':
  Clean up <sys/mount.h>/<linux/fs.h> duplication.
2013-07-08 10:12:32 -07:00
Elliott Hughes
e63ea6aca7 Merge "Clean up <sys/mount.h>/<linux/fs.h> duplication." 2013-07-08 17:08:52 +00:00
The Android Automerger
1456ec759c merge in klp-release history after reset to master 2013-07-08 06:00:29 -07:00
Elliott Hughes
e42e51d563 Clean up <sys/mount.h>/<linux/fs.h> duplication.
Roll on uapi...

Bug: 6340120
Change-Id: Ic9521905683946e836574e4d768e34853ea777fa
2013-07-03 14:58:04 -07:00
Nick Kralevich
20cb10824b am 601f968c: am 84983592: Merge "bionic_atomic_arm.h: Remove < ARMv6 support"
* commit '601f968cedf015c060de8dcf21e7e10bf596901f':
  bionic_atomic_arm.h: Remove < ARMv6 support
2013-07-03 14:33:22 -07:00
Nick Kralevich
601f968ced am 84983592: Merge "bionic_atomic_arm.h: Remove < ARMv6 support"
* commit '84983592ade3ec7d72d082262fb6646849979bfc':
  bionic_atomic_arm.h: Remove < ARMv6 support
2013-07-03 14:28:14 -07:00
Nick Kralevich
84983592ad Merge "bionic_atomic_arm.h: Remove < ARMv6 support" 2013-07-03 21:25:35 +00:00
Nick Kralevich
e91f71783b bionic_atomic_arm.h: Remove < ARMv6 support
This is dead code for most modern Android devices.

Bug: 9674955
Change-Id: Ic63a66b0331a0f07b9183f14a1d5e678c25e4b12
2013-07-03 14:14:06 -07:00
Elliott Hughes
1f75ee8606 am a8b954c5: am de2781d9: Merge changes I01345c23,I3b57517c
* commit 'a8b954c51edd9ec8c09a5d1dccacaadf5869d78a':
  Include linux/termios.h from sys/ioctl.h.
  Update linux/types.h to linux 2.6.20.
2013-07-03 13:45:45 -07:00
Elliott Hughes
a8b954c51e am de2781d9: Merge changes I01345c23,I3b57517c
* commit 'de2781d906f27be4df3e03a8e5041dcc1aeb281d':
  Include linux/termios.h from sys/ioctl.h.
  Update linux/types.h to linux 2.6.20.
2013-07-03 13:39:16 -07:00
Elliott Hughes
de2781d906 Merge changes I01345c23,I3b57517c
* changes:
  Include linux/termios.h from sys/ioctl.h.
  Update linux/types.h to linux 2.6.20.
2013-07-03 20:37:28 +00:00
Lorenzo Colitti
f936ef1a9f Include linux/termios.h from sys/ioctl.h.
On NetBSD and glibc, including sys/ioctl.h provides some
terminal ioctl data structures such as struct winsize. For
compatibility, provide these via sys/ioctl.h in bionic as well.
bionic does not have its own definitions for these structures, so
get them from the Linux kernel definitions.

Change-Id: I01345c23c0bebd60b0a80fc33668e7c0ad7356c3
2013-07-03 13:35:18 -07:00
Lorenzo Colitti
d7b0d6e1e1 Update linux/types.h to linux 2.6.20.
This picks up the source kernel header change
I984154487c38f6fa827bd78234f7fc2e4e1c383f .

Bug: 9469682
Change-Id: I3b57517cc6442ba4d0b8003d7398617e8226233f
2013-07-03 13:15:20 -07:00
Elliott Hughes
be438a4c40 am fac9199c: am ebc8ce1d: Merge "libc/arch-arm/bionic/memcpy.a9.S: memcpy from cortex-strings."
* commit 'fac9199c7698481805dd9b1adaf89a2584719f4c':
  libc/arch-arm/bionic/memcpy.a9.S: memcpy from cortex-strings.
2013-07-03 10:28:19 -07:00
Elliott Hughes
fac9199c76 am ebc8ce1d: Merge "libc/arch-arm/bionic/memcpy.a9.S: memcpy from cortex-strings."
* commit 'ebc8ce1de68a83d772106af98c7cb98150bb5662':
  libc/arch-arm/bionic/memcpy.a9.S: memcpy from cortex-strings.
2013-07-03 10:23:41 -07:00
Elliott Hughes
ebc8ce1de6 Merge "libc/arch-arm/bionic/memcpy.a9.S: memcpy from cortex-strings." 2013-07-03 17:21:47 +00:00
Will Newton
2753e12af5 libc/arch-arm/bionic/memcpy.a9.S: memcpy from cortex-strings.
This memcpy code uses NEON/VFP to achieve very good performance
on ARMv7-A processors. It is specifically tuned for A15 but should
provide good performance on A9 also. It is equivalent to the code
in cortex-strings rev 116.

This patch is a follow up the existing gerrit change:

I7f6f77995f3ca903ad9c66d14261441667a2a935

This version includes a tweak for performance on misaligned
buffers and splits the header comment into license and
documentation sections.

Change-Id: Ibd2e23c8d8e01357ba0247be1d05192de3ceba69
Signed-off-by: Will Newton <will.newton@linaro.org>
2013-07-03 10:20:43 -07:00
Elliott Hughes
997368d60d am 833dc584: am 87b4286f: Merge "Expose dn_comp and dn_expand to system C code."
* commit '833dc584d4d02ab8e396b877b38a8a5ad8ba4882':
  Expose dn_comp and dn_expand to system C code.
2013-07-02 16:05:34 -07:00
Elliott Hughes
833dc584d4 am 87b4286f: Merge "Expose dn_comp and dn_expand to system C code."
* commit '87b4286f092094a2e8069a06e20ef5036a258172':
  Expose dn_comp and dn_expand to system C code.
2013-07-02 16:02:30 -07:00
Elliott Hughes
87b4286f09 Merge "Expose dn_comp and dn_expand to system C code." 2013-07-02 23:00:38 +00:00
Lorenzo Colitti
b8e435c1d5 Expose dn_comp and dn_expand to system C code.
This is needed to compile open-source code that wants to
expand/compress domain names itself, such as ping6.

Bug: 9469682
Change-Id: I339c6538936d05c031bc6fb0a8793aaf1429dea4
2013-07-02 15:57:57 -07:00
Elliott Hughes
742aad3584 am 7c808b29: am feec97a7: Merge "Fix inttypes.h PRI?PTR and SCN?PTR macros."
* commit '7c808b29d5cea61e5bda90a1b0f2f0e669ee135e':
  Fix inttypes.h PRI?PTR and SCN?PTR macros.
2013-07-02 15:50:36 -07:00
Elliott Hughes
7c808b29d5 am feec97a7: Merge "Fix inttypes.h PRI?PTR and SCN?PTR macros."
* commit 'feec97a7c7fbd032174fb4870a02422c2acd891a':
  Fix inttypes.h PRI?PTR and SCN?PTR macros.
2013-07-02 15:44:48 -07:00
Elliott Hughes
feec97a7c7 Merge "Fix inttypes.h PRI?PTR and SCN?PTR macros." 2013-07-02 22:42:49 +00:00
Elliott Hughes
74f0833df6 Fix inttypes.h PRI?PTR and SCN?PTR macros.
Our intptr_t and uintptr_t aren't "long". Add a compilation test so we remember
to fix this to cope with 32- and 64-bit later.

Bug: http://code.google.com/p/android/issues/detail?id=57218
Change-Id: I2f816d339edb4f7d57e4418b818fb4c602093f38
2013-07-02 15:35:27 -07:00
Nick Kralevich
e4723161d5 Merge "mmap: Don't call madvise if mmap fails" 2013-07-02 19:52:44 +00:00
Elliott Hughes
2aac0fcc20 am dcd237a8: am 1ba3a2c2: Merge "Update icmp6.h to current NetBSD."
* commit 'dcd237a89707357ead904a2476bb2210e251c173':
  Update icmp6.h to current NetBSD.
2013-07-02 12:41:37 -07:00
Elliott Hughes
dcd237a897 am 1ba3a2c2: Merge "Update icmp6.h to current NetBSD."
* commit '1ba3a2c26937c68a4a0bd4fdffe95f5162077997':
  Update icmp6.h to current NetBSD.
2013-07-02 12:34:36 -07:00
Nick Kralevich
553a5ec407 mmap: Don't call madvise if mmap fails
Fix improper check of return value from __mmap2. On a failed
mmap(), it returns MAP_FAILED, not 0. This ended up clobbering errno
when madvise subsequently failed.

Change-Id: I364fb2f158fe258c55a73e552195384b2c11c193
2013-07-02 12:31:07 -07:00
Elliott Hughes
1ba3a2c269 Merge "Update icmp6.h to current NetBSD." 2013-07-02 16:40:42 +00:00
Lorenzo Colitti
ce7c404dc7 Update icmp6.h to current NetBSD.
This adds a few bits we need such as RFC 6106 support and the
definition of MLD_LISTENER_REDUCTION.

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/netinet/icmp6.h?rev=1.47

Bug: 9469682
Change-Id: I97a4c2f0893012ce315334367c055097d0f8bb10
2013-07-02 09:38:59 -07:00
The Android Automerger
9db12e44af merge in klp-release history after reset to master 2013-07-02 07:07:20 -07:00
Christopher Ferris
c6ac3ae269 am 269daac2: am 7c14d67b: Merge "libc/arch-arm/bionic/memcpy.a9.S: memcpy from cortex-strings."
* commit '269daac2f1d76a478b83ba4cbb57d28b47eef5ec':
  libc/arch-arm/bionic/memcpy.a9.S: memcpy from cortex-strings.
2013-07-01 10:39:08 -07:00
Christopher Ferris
269daac2f1 am 7c14d67b: Merge "libc/arch-arm/bionic/memcpy.a9.S: memcpy from cortex-strings."
* commit '7c14d67bc1cc2679365a784e68518bf602b81dc7':
  libc/arch-arm/bionic/memcpy.a9.S: memcpy from cortex-strings.
2013-07-01 10:32:17 -07:00
Christopher Ferris
7c14d67bc1 Merge "libc/arch-arm/bionic/memcpy.a9.S: memcpy from cortex-strings." 2013-07-01 17:29:07 +00:00
Nick Kralevich
4b17283c98 am 28d298a6: am 413eef71: Merge "More FORTIFY_SOURCE functions under clang"
* commit '28d298a673da4367f27f428db5e12d7dad3d8e83':
  More FORTIFY_SOURCE functions under clang
2013-07-01 10:04:18 -07:00
Nick Kralevich
28d298a673 am 413eef71: Merge "More FORTIFY_SOURCE functions under clang"
* commit '413eef716f822d5eb4f57618f6780c6af5036460':
  More FORTIFY_SOURCE functions under clang
2013-07-01 10:00:09 -07:00
Nick Kralevich
413eef716f Merge "More FORTIFY_SOURCE functions under clang" 2013-07-01 16:57:05 +00:00
The Android Automerger
5da8df2840 merge in klp-release history after reset to master 2013-07-01 07:07:20 -07:00
Will Newton
b61103dff4 libc/arch-arm/bionic/memcpy.a9.S: memcpy from cortex-strings.
This memcpy code uses NEON/VFP to achieve very good performance
on ARMv7-A processors. It is specifically tuned for A15 but should
provide good performance on A9 also. It is equivalent to the code
in cortex-strings rev 116.

This patch is a follow up the existing gerrit change:

I7f6f77995f3ca903ad9c66d14261441667a2a935

But this version includes a tweak for performance on misaligned
buffers.

Change-Id: I285abac0068f8ae29a1cbf7862ea8590aadaf0a7
Signed-off-by: Will Newton <will.newton@linaro.org>
2013-07-01 11:15:27 +01:00
Nick Kralevich
a6cde39276 More FORTIFY_SOURCE functions under clang
* bzero
* umask
* strlcat

Change-Id: I65065208e0b8b37e10f6a266d5305de8fa9e59fc
2013-06-29 08:16:22 -07:00
Nick Kralevich
22570f51a5 am a289964b: am 227b47a4: Merge "resolv_private.h: remove #define b64_ntop and b64_pton"
* commit 'a289964bca39c591b54e0c336da1a6730e85cd61':
  resolv_private.h: remove #define b64_ntop and b64_pton
2013-06-28 13:37:08 -07:00
Nick Kralevich
a289964bca am 227b47a4: Merge "resolv_private.h: remove #define b64_ntop and b64_pton"
* commit '227b47a461b27d746b373feb66001cdddc9ba1db':
  resolv_private.h: remove #define b64_ntop and b64_pton
2013-06-28 13:32:43 -07:00
Nick Kralevich
227b47a461 Merge "resolv_private.h: remove #define b64_ntop and b64_pton" 2013-06-28 20:31:11 +00:00
Nick Kralevich
ca43d73d23 resolv_private.h: remove #define b64_ntop and b64_pton
This was gated off of "#ifndef ADNROID_CHANGES" (note mispelling)
and is unconditionally defined in libc/include/resolv.h
(which this file includes). No need for duplicate definitions.

Change-Id: I00719bcf39eaa26eb96ab4274f171f3d2b5bae61
2013-06-28 13:18:32 -07:00
Nick Kralevich
fda0c06605 am 2018cfa8: am 394df35e: Merge "Reorganize FORTIFY_SOURCE tests."
* commit '2018cfa85d4c7f36316376f5b090be5f0d3d13dc':
  Reorganize FORTIFY_SOURCE tests.
2013-06-28 13:15:39 -07:00
Nick Kralevich
2018cfa85d am 394df35e: Merge "Reorganize FORTIFY_SOURCE tests."
* commit '394df35e641816a3b9f0e065840b673dec9c73e5':
  Reorganize FORTIFY_SOURCE tests.
2013-06-28 13:11:14 -07:00
Nick Kralevich
394df35e64 Merge "Reorganize FORTIFY_SOURCE tests." 2013-06-28 20:05:57 +00:00
Nick Kralevich
5bcf39842e Reorganize FORTIFY_SOURCE tests.
Get rid of a lot of the duplication in the various FORTIFY_SOURCE
tests. Instead, we build 4 separate static libraries, with
4 different compile time options, and link them into the final test
binary.

Change-Id: Idb0b7cccc8dd837adb037bf4ddfe8942ae138230
2013-06-28 11:54:29 -07:00
Nick Kralevich
9a268a10bb am f9ef0106: am 78a7bf99: Merge "stdio.h: enable vs?printf clang FORTIFY_SOURCE"
* commit 'f9ef0106da43d21e6cb68d87b86d806f63b215fd':
  stdio.h: enable vs?printf clang FORTIFY_SOURCE
2013-06-27 10:18:17 -07:00
Nick Kralevich
f9ef0106da am 78a7bf99: Merge "stdio.h: enable vs?printf clang FORTIFY_SOURCE"
* commit '78a7bf998d2d29592504984fcf419cd2701c6c54':
  stdio.h: enable vs?printf clang FORTIFY_SOURCE
2013-06-27 10:15:31 -07:00
Nick Kralevich
78a7bf998d Merge "stdio.h: enable vs?printf clang FORTIFY_SOURCE" 2013-06-27 17:13:25 +00:00
Nick Kralevich
c8ae8bd941 stdio.h: enable vs?printf clang FORTIFY_SOURCE
Enable FORTIFY_SOURCE protections under clang for the following
functions:

  * vsprintf
  * vsnprintf

and add unittests.

Change-Id: I90f8a27f7b202c78b5dd8ebf53050bf9e33496f7
2013-06-27 09:17:48 -07:00
The Android Automerger
e4450b447e merge in klp-release history after reset to master 2013-06-26 07:07:28 -07:00
Colin Cross
2f76830a01 am 146d79c2: am fbec57d4: Merge changes Ib496e818,I074204e9
* commit '146d79c22a70d772defc63acfa6ac6128102a15f':
  bionic: add compatibility mode for properties
  bionic: use the size of the file to determine property area size
2013-06-25 18:29:14 -07:00
Colin Cross
146d79c22a am fbec57d4: Merge changes Ib496e818,I074204e9
* commit 'fbec57d46c42460b2381484d1610ff21922d162e':
  bionic: add compatibility mode for properties
  bionic: use the size of the file to determine property area size
2013-06-25 17:08:48 -07:00
Colin Cross
fbec57d46c Merge changes Ib496e818,I074204e9
* changes:
  bionic: add compatibility mode for properties
  bionic: use the size of the file to determine property area size
2013-06-26 00:03:24 +00:00
Elliott Hughes
9145ae66d7 am db6dd600: am b116bf76: Merge "Switch to current upstream getopt_long."
* commit 'db6dd600d23eafb1742e5114bae7a4b8be4c04e1':
  Switch to current upstream getopt_long.
2013-06-25 17:02:11 -07:00
Rom Lemarchand
6937468d37 am baa61864: am 995f17e6: Merge "libc: add swapon and swapoff syscalls"
* commit 'baa61864c515a56d4dbeac46b149b4317b01797b':
  libc: add swapon and swapoff syscalls
2013-06-25 17:02:06 -07:00
Elliott Hughes
43508014c4 am 51371ee0: am c76550b3: Merge "Update x86 machine/endian.h from upstream"
* commit '51371ee0d897285b869aa2af670e153ead471e03':
  Update x86 machine/endian.h from upstream
2013-06-25 17:01:53 -07:00
Elliott Hughes
d9643a3119 am d31287d6: am 7d624e9a: Merge "Kernel dso support for \'dl_iterate_phdr\' function"
* commit 'd31287d6017475209cfee2fea0532bdc8c0f4aac':
  Kernel dso support for 'dl_iterate_phdr' function
2013-06-25 17:01:47 -07:00
Colin Cross
5e9a086145 bionic: add compatibility mode for properties
Allow a new bionic to work with an old init property area by supporting
the old format.

(cherry picked from commit ad76c85b9c)

Change-Id: Ib496e818a62a5834d40c71eb4745783d998be893
2013-06-25 16:52:40 -07:00
Colin Cross
1ec20a086c bionic: use the size of the file to determine property area size
On the reader size, don't assume that the property size is PA_SIZE,
read it from the size of the file.  Allows init to use a different
property size without recompiling statically linked executables.

(cherry picked from commit 285b42a04c)

Change-Id: I074204e9e6591b35faf7c1c58fb11ec162aff7bf
2013-06-25 16:52:34 -07:00
Nick Kralevich
caad18c7d1 am 71802135: am bfacb603: Merge "libc: enable FORTIFY_SOURCE snprintf under clang"
* commit '7180213557f3120b391053b4f5861037eda6ebb6':
  libc: enable FORTIFY_SOURCE snprintf under clang
2013-06-25 16:30:53 -07:00
Colin Cross
4fc4c9be84 am a99e29e6: (-s ours) am 1642edb5: Merge changes Ib074192d,I6df3afed,I69070455,Icbe31908,Id3fa4526,I038d451f
* commit 'a99e29e61090da9c21c17cae54211083a2268d6e':
  bionic: store property names as variable-length strings
  bionic: prevent root processes from calling __system_property_add
  bionic: revert to a single (larger) property area
  bionic: reimplement property area as hybrid trie/binary tree
  bionic: add missing memory barriers to system properties
  bionic: make property area expandable
2013-06-25 16:30:34 -07:00
Elliott Hughes
db6dd600d2 am b116bf76: Merge "Switch to current upstream getopt_long."
* commit 'b116bf76286178a7d552c4d0a72b79212c8c93d1':
  Switch to current upstream getopt_long.
2013-06-25 15:58:53 -07:00
Elliott Hughes
b116bf7628 Merge "Switch to current upstream getopt_long." 2013-06-25 22:56:59 +00:00
Rom Lemarchand
baa61864c5 am 995f17e6: Merge "libc: add swapon and swapoff syscalls"
* commit '995f17e6a9a9903f03f542192da9a83b1cabc684':
  libc: add swapon and swapoff syscalls
2013-06-25 15:28:21 -07:00
Rom Lemarchand
995f17e6a9 Merge "libc: add swapon and swapoff syscalls" 2013-06-25 22:25:31 +00:00
Elliott Hughes
d278b828fe Switch to current upstream getopt_long.
Change-Id: I4c646dcb8be9e88dd54d069a03bbc5fbfd92de03
2013-06-25 14:56:17 -07:00
Elliott Hughes
51371ee0d8 am c76550b3: Merge "Update x86 machine/endian.h from upstream"
* commit 'c76550b3377f50a2bc53536e2713e14edc8dbeac':
  Update x86 machine/endian.h from upstream
2013-06-25 14:22:14 -07:00
Elliott Hughes
c76550b337 Merge "Update x86 machine/endian.h from upstream" 2013-06-25 21:20:18 +00:00
Pavel Chupin
64a4f6adf7 Update x86 machine/endian.h from upstream
After download new version from upstream (OpenBSD 1.17) did the
following:
 * changed all u_int* types to uint*
 * add #include <sys/types.h>

All these changes are Android-specific and had been done before for
previous version (1.14).

Bug: http://code.google.com/p/android/issues/detail?id=54465
Change-Id: Ieb44e7fce4e794d997bb00ee0dd417fb61521720
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2013-06-25 14:17:58 -07:00
Colin Cross
ad76c85b9c bionic: add compatibility mode for properties
Allow a new bionic to work with an old init property area by supporting
the old format.

Change-Id: I9268214b2f8930e75e3b5c26afe94fa92068bf0b
2013-06-25 13:34:45 -07:00
Colin Cross
285b42a04c bionic: use the size of the file to determine property area size
On the reader size, don't assume that the property size is PA_SIZE,
read it from the size of the file.  Allows init to use a different
property size without recompiling statically linked executables.

Change-Id: I87fb0bf40c4724e3759a583fd9ea1f49492bc958
2013-06-25 13:34:45 -07:00
Greg Hackmann
4fe82929eb bionic: store property names as variable-length strings
Names are immutable, so the fixed-sized arrays can be replaced with
variable-length ones to save memory (especially on internal tree nodes).

Change-Id: Iddf7856fba579b97f355e9ad4b3663a78767b96d
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-06-25 13:34:42 -07:00
Colin Cross
fc761f8cc0 bionic: prevent root processes from calling __system_property_add
If a root process other than init calls __system_property_add, which
it should never do, it will break the design assumption that there is
only one mutator.

Pass O_EXCL to open() in map_prop_region_rw to ensure that only one
process ever has the property pages open for write.

Change-Id: I8233bfe0beaa40a5003ad53b98c661536b15f6b7
2013-06-25 13:34:36 -07:00
Greg Hackmann
be30c7a78a bionic: revert to a single (larger) property area
d329697 is too complicated.  Change the multiple property pages back to
a single 128K property area that's mapped in entirely at initialization
(the memory will not get allocated until the pages are touched).

d329697 has other changes useful for testing (moving property area
initialization inside bionic and adding __system_property_set_filename)
so undo the change manually rather than with git revert.

Change-Id: Icd137669a4f8bc248e9dd2c1e8cc54e9193c9a6d
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-06-25 13:34:32 -07:00
Greg Hackmann
d5276422ca bionic: add hierarchical properties test
Deliberately put items several levels deep in the trie hierarchy to test
the trie traversal

Change-Id: I995a1cdd3b5e74162fb5d25bc0f65140bdf2f719
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-06-25 13:34:29 -07:00
Greg Hackmann
4482d85139 bionic: reimplement property area as hybrid trie/binary tree
See the comments for an explanation of how properties are stored.

The trie structure is designed to scale better than the previous
array-based implementation.  Searching an array with n properties
required average O(n) string compares of the entire key; searching the
trie requires average O(log n) string compares of each token (substrings
between '.' characters).

Change-Id: Ic28b3c5246004a3c502eb02d6e1c9b512884d872
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-06-25 13:34:24 -07:00
Rom Lemarchand
d206b560e7 libc: add swapon and swapoff syscalls
Change-Id: Ie79dc8e3f2ff1cd427dd6d95e3850920c4b407b0
Signed-off-by: Rom Lemarchand <romlem@google.com>
2013-06-25 13:18:03 -07:00
Elliott Hughes
d31287d601 am 7d624e9a: Merge "Kernel dso support for \'dl_iterate_phdr\' function"
* commit '7d624e9aff4c6addea7f2275fe58ff0815d95c70':
  Kernel dso support for 'dl_iterate_phdr' function
2013-06-25 13:17:37 -07:00
Elliott Hughes
7d624e9aff Merge "Kernel dso support for 'dl_iterate_phdr' function" 2013-06-25 20:15:30 +00:00
Sergey Melnikov
c45087bffa Kernel dso support for 'dl_iterate_phdr' function
Kernel provides virtual DSO for stack unwinding/exception handlind info for
signal usage case. Stack unwinding routines use 'dl_iterate_phdr' function
for additional DWARF info gathering from DSOs. Patch enables virtual DSO
enumeration via dl_iterate_phdr function.

Signed-off-by: Sergey Melnikov <sergey.melnikov@intel.com>
Change-Id: Ic2882b28f40b456a088bc1e63c50cbfda7e4a102
2013-06-25 13:12:39 -07:00
Nick Kralevich
7180213557 am bfacb603: Merge "libc: enable FORTIFY_SOURCE snprintf under clang"
* commit 'bfacb603e417c1e2c25ce8482b5c6e31b4db8c9b':
  libc: enable FORTIFY_SOURCE snprintf under clang
2013-06-25 10:34:20 -07:00
Nick Kralevich
bfacb603e4 Merge "libc: enable FORTIFY_SOURCE snprintf under clang" 2013-06-25 17:26:20 +00:00
Nick Kralevich
621b19dddb libc: enable FORTIFY_SOURCE snprintf under clang
Change-Id: I8b8059782a720104722b0841994b38f873ed02aa
2013-06-25 10:02:35 -07:00
The Android Automerger
4261a08409 merge in klp-release history after reset to master 2013-06-25 07:07:12 -07:00
Nick Kralevich
5f7f7fca27 am 95448039: am 0ea1d5c0: Merge "libc: enable sprintf FORTIFY_SOURCE under clang"
* commit '954480393f4539f62cdc3f6cb83c562050ea4f51':
  libc: enable sprintf FORTIFY_SOURCE under clang
2013-06-25 05:59:32 -07:00
Greg Hackmann
c79de97ccc bionic: replace 4K property pages with 32K property pages
Fixes apps compiled statically against new libc but running with old
init

Bug: 9558625
Change-Id: I79e6f02575d278d4c7d8e8546d772ed0529bcaab
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-06-24 19:23:34 -07:00
Greg Hackmann
de76bafb21 bionic: replace 4K property pages with 32K property pages
Fixes apps compiled statically against new libc but running with old
init

Bug: 9558625
Change-Id: I79e6f02575d278d4c7d8e8546d772ed0529bcaab
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-06-24 18:41:46 -07:00
Greg Hackmann
44c273c293 Revert "bionic: reimplement property area as hybrid trie/binary tree"
This reverts commit 6ac8e6a46d.
2013-06-24 18:05:20 -07:00
Greg Hackmann
890aa0d937 Revert "bionic: add hierarchical properties test"
This reverts commit 0f76e2340c.
2013-06-24 18:05:18 -07:00
Greg Hackmann
fa8cc0629f Revert "bionic: revert to a single (larger) property area"
This reverts commit 5f05348c18.
2013-06-24 18:05:16 -07:00
Greg Hackmann
b938756eb3 Revert "bionic: prevent root processes from calling __system_property_add"
This reverts commit fb9b7b436f.
2013-06-24 18:05:14 -07:00
Greg Hackmann
982463d99b Revert "bionic: store property names as variable-length strings"
This reverts commit 492ce95d9f.
2013-06-24 18:05:10 -07:00
Colin Cross
a99e29e610 am 1642edb5: Merge changes Ib074192d,I6df3afed,I69070455,Icbe31908,Id3fa4526,I038d451f
* commit '1642edb5208fe02ef64d5734fffaf7c4a724fd2f':
  bionic: store property names as variable-length strings
  bionic: prevent root processes from calling __system_property_add
  bionic: revert to a single (larger) property area
  bionic: reimplement property area as hybrid trie/binary tree
  bionic: add missing memory barriers to system properties
  bionic: make property area expandable
2013-06-24 17:10:16 -07:00
Colin Cross
1642edb520 Merge changes Ib074192d,I6df3afed,I69070455,Icbe31908,Id3fa4526,I038d451f
* changes:
  bionic: store property names as variable-length strings
  bionic: prevent root processes from calling __system_property_add
  bionic: revert to a single (larger) property area
  bionic: reimplement property area as hybrid trie/binary tree
  bionic: add missing memory barriers to system properties
  bionic: make property area expandable
2013-06-25 00:07:53 +00:00
Greg Hackmann
836dbf65e4 bionic: store property names as variable-length strings
Names are immutable, so the fixed-sized arrays can be replaced with
variable-length ones to save memory (especially on internal tree nodes).

Signed-off-by: Greg Hackmann <ghackmann@google.com>

(cherry picked from commit 492ce95d9f)

Change-Id: Ib074192d1b71150233d78c58e9ffcf7ecf688b6b
2013-06-24 16:35:46 -07:00
Colin Cross
1d36ee1a6e bionic: prevent root processes from calling __system_property_add
If a root process other than init calls __system_property_add, which
it should never do, it will break the design assumption that there is
only one mutator.

Pass O_EXCL to open() in map_prop_region_rw to ensure that only one
process ever has the property pages open for write.

(cherry picked from commit fb9b7b436f)

Change-Id: I6df3afedbfb5d07891b095aa24b78278381a5aaf
2013-06-24 16:35:41 -07:00
Greg Hackmann
1540f601be bionic: revert to a single (larger) property area
d329697 is too complicated.  Change the multiple property pages back to
a single 128K property area that's mapped in entirely at initialization
(the memory will not get allocated until the pages are touched).

d329697 has other changes useful for testing (moving property area
initialization inside bionic and adding __system_property_set_filename)
so undo the change manually rather than with git revert.

Signed-off-by: Greg Hackmann <ghackmann@google.com>

(cherry picked from commit 5f05348c18)

Change-Id: I690704552afc07a4dd410277893ca9c40bc13e5f
2013-06-24 16:35:37 -07:00
Greg Hackmann
996cdc4b1a bionic: reimplement property area as hybrid trie/binary tree
See the comments for an explanation of how properties are stored.

The trie structure is designed to scale better than the previous
array-based implementation.  Searching an array with n properties
required average O(n) string compares of the entire key; searching the
trie requires average O(log n) string compares of each token (substrings
between '.' characters).

Signed-off-by: Greg Hackmann <ghackmann@google.com>

(cherry picked from commit 6ac8e6a46d)

Change-Id: Icbe31908572f33b4d9b85d5b62ac837cbd0f85e0
2013-06-24 16:35:32 -07:00
Greg Hackmann
f7511e3bc9 bionic: add missing memory barriers to system properties
1) Reading the value must finish before checking whether it's intact

2) Setting the serial's dirty bit must visible before modifying the
value

3) The modified value must be visible before clearing the serial's dirty
bit

4) New properties and their TOC entries must be visible before updating
the property count

Signed-off-by: Greg Hackmann <ghackmann@google.com>

(cherry picked from commit 5bfa3ee8b3)

Change-Id: Id3fa45261fc2df2ae493ab5194bc2b6bff04e966
2013-06-24 16:35:27 -07:00
Greg Hackmann
cb215a7e9e bionic: make property area expandable
The property area is initially one 4K region, automatically expanding as
needed up to 64 regions.

To avoid duplicating code, __system_property_area_init() now allocates
and initializes the first region (previously it was allocated in init's
init_property_area() and initialized in bionic).  For testing purposes,
__system_property_set_filename() may be used to override the file used
to map in regions.

Signed-off-by: Greg Hackmann <ghackmann@google.com>

(cherry picked from commit d32969701b)

Change-Id: I038d451fe8849b0c4863663eec6f57f6521bf4a7
2013-06-24 16:35:15 -07:00
Greg Hackmann
492ce95d9f bionic: store property names as variable-length strings
Names are immutable, so the fixed-sized arrays can be replaced with
variable-length ones to save memory (especially on internal tree nodes).

Change-Id: Iee77874b4b55b0f9c5e531d1334be7f7f40086d2
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-06-24 16:15:52 -07:00
Colin Cross
fb9b7b436f bionic: prevent root processes from calling __system_property_add
If a root process other than init calls __system_property_add, which
it should never do, it will break the design assumption that there is
only one mutator.

Pass O_EXCL to open() in map_prop_region_rw to ensure that only one
process ever has the property pages open for write.

Change-Id: I6b7c118e5e2fd2b92a2b168b8454fe9707325462
2013-06-24 16:15:52 -07:00
Greg Hackmann
5f05348c18 bionic: revert to a single (larger) property area
d329697 is too complicated.  Change the multiple property pages back to
a single 128K property area that's mapped in entirely at initialization
(the memory will not get allocated until the pages are touched).

d329697 has other changes useful for testing (moving property area
initialization inside bionic and adding __system_property_set_filename)
so undo the change manually rather than with git revert.

Change-Id: I0ecb27843404f93af5489f15bfe657d65175e4f0
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-06-24 16:15:52 -07:00
Nick Kralevich
954480393f am 0ea1d5c0: Merge "libc: enable sprintf FORTIFY_SOURCE under clang"
* commit '0ea1d5c0ae94ee581c72451b20813c028f51090c':
  libc: enable sprintf FORTIFY_SOURCE under clang
2013-06-24 15:20:39 -07:00
Nick Kralevich
0ea1d5c0ae Merge "libc: enable sprintf FORTIFY_SOURCE under clang" 2013-06-24 22:15:12 +00:00
Nick Kralevich
c6eb985454 libc: enable sprintf FORTIFY_SOURCE under clang
clang doesn't support __builtin_va_arg_pack(), so we have
to use #define instead.

Change-Id: I2ee75e6267d60cdf997fee6b9b0547bf68f062a1
2013-06-24 14:10:29 -07:00
Greg Hackmann
0f76e2340c bionic: add hierarchical properties test
Deliberately put items several levels deep in the trie hierarchy to test
the trie traversal

Change-Id: Id3cbd2e7d3500216b1ac8025eac70c0939622903
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-06-24 13:14:10 -07:00
Greg Hackmann
6ac8e6a46d bionic: reimplement property area as hybrid trie/binary tree
See the comments for an explanation of how properties are stored.

The trie structure is designed to scale better than the previous
array-based implementation.  Searching an array with n properties
required average O(n) string compares of the entire key; searching the
trie requires average O(log n) string compares of each token (substrings
between '.' characters).

Change-Id: I491305bc7aca59609abcd871a5f33d97f89ce714
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-06-24 13:14:09 -07:00
Greg Hackmann
a823883548 Merge "bionic: add missing memory barriers to system properties" 2013-06-24 17:15:43 +00:00
The Android Automerger
22476056b0 merge in klp-release history after reset to master 2013-06-24 09:44:30 -07:00
Nick Kralevich
ae9353387d am 100d6784: am 53ddcc90: Merge "linker: Emit a warning on text relocations"
* commit '100d678438f222ad6ef8f3dc0646911b218c50a9':
  linker: Emit a warning on text relocations
2013-06-21 16:01:02 -07:00
Nick Kralevich
100d678438 am 53ddcc90: Merge "linker: Emit a warning on text relocations"
* commit '53ddcc90701d86c7d809a84cf4710c651066e3c7':
  linker: Emit a warning on text relocations
2013-06-21 15:39:21 -07:00
Nick Kralevich
53ddcc9070 Merge "linker: Emit a warning on text relocations" 2013-06-21 22:36:50 +00:00
Nick Kralevich
c9084427aa linker: Emit a warning on text relocations
Text relocations unnecessarily mark pages as dirty, preventing them
from being swapped out, wasting memory. Also, text relocations
prevent the code from running on certain hardened systems.

Print a message in logcat and stderr when we see a text relocation,
to encourage developers to fix their code.

Change-Id: I6051a7463911e090ae5727a355397d539669d5b9
2013-06-21 15:33:15 -07:00
Nick Kralevich
cf3c9ce0f5 am cb25359a: am 68197731: Merge "libc_logging: don\'t keep file descriptors open forever"
* commit 'cb25359a2e20489a3a9f65795a2079abc8fe0b65':
  libc_logging: don't keep file descriptors open forever
2013-06-21 15:15:22 -07:00
Nick Kralevich
cb25359a2e am 68197731: Merge "libc_logging: don\'t keep file descriptors open forever"
* commit '6819773103495a6fd81f024dc6711771320ae4ec':
  libc_logging: don't keep file descriptors open forever
2013-06-21 14:33:48 -07:00
Nick Kralevich
6819773103 Merge "libc_logging: don't keep file descriptors open forever" 2013-06-21 21:26:09 +00:00
Nick Kralevich
17fc25d20f libc_logging: don't keep file descriptors open forever
Avoid keeping unnecessary file descriptors around when they're not
needed. Libc doesn't log so much that opening / closing overhead
matters.

Change-Id: I590ec5c27562db9bac025f781c48ec9a7724ce77
2013-06-21 13:28:42 -07:00
Greg Hackmann
5bfa3ee8b3 bionic: add missing memory barriers to system properties
1) Reading the value must finish before checking whether it's intact

2) Setting the serial's dirty bit must visible before modifying the
value

3) The modified value must be visible before clearing the serial's dirty
bit

4) New properties and their TOC entries must be visible before updating
the property count

Change-Id: I26c680ec025fdb72362d5f618ec0d2b93d381233
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-06-20 14:41:58 -07:00
Nick Kralevich
33ae76abf3 am 5fed0eea: am 0ce28d20: Merge "libc: enable FORTIFY_SOURCE clang strlcpy"
* commit '5fed0eeabd88bfe241c416f2c2f44a14b6e447fa':
  libc: enable FORTIFY_SOURCE clang strlcpy
2013-06-20 12:34:11 -07:00
Nick Kralevich
5fed0eeabd am 0ce28d20: Merge "libc: enable FORTIFY_SOURCE clang strlcpy"
* commit '0ce28d20ea5fde250576f355004dbcd741b0b884':
  libc: enable FORTIFY_SOURCE clang strlcpy
2013-06-20 12:29:38 -07:00
Nick Kralevich
0ce28d20ea Merge "libc: enable FORTIFY_SOURCE clang strlcpy" 2013-06-20 19:27:48 +00:00
Nick Kralevich
8bafa7452e libc: enable FORTIFY_SOURCE clang strlcpy
Change-Id: Idcfe08f5afc3dde592416df9eba83f64e130c7c2
2013-06-20 12:17:44 -07:00
Elliott Hughes
cb4fd62762 am 33df38a0: am 4eed6509: Merge "stdint.h header is not fully compatible with C99(ISO9899:1999)"
* commit '33df38a04c31de0fca431c549469edb6d2de75e2':
  stdint.h header is not fully compatible with C99(ISO9899:1999)
2013-06-19 12:57:39 -07:00
Elliott Hughes
33df38a04c am 4eed6509: Merge "stdint.h header is not fully compatible with C99(ISO9899:1999)"
* commit '4eed65090b1f0d0d087f26bd7367da90a0cca92d':
  stdint.h header is not fully compatible with C99(ISO9899:1999)
2013-06-19 12:46:40 -07:00
Elliott Hughes
4eed65090b Merge "stdint.h header is not fully compatible with C99(ISO9899:1999)" 2013-06-19 19:45:09 +00:00
Greg Hackmann
d32969701b bionic: make property area expandable
The property area is initially one 4K region, automatically expanding as
needed up to 64 regions.

To avoid duplicating code, __system_property_area_init() now allocates
and initializes the first region (previously it was allocated in init's
init_property_area() and initialized in bionic).  For testing purposes,
__system_property_set_filename() may be used to override the file used
to map in regions.

Change-Id: Ibe00ef52464bfa590953c4699a6d98383b0142b1
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-06-19 11:02:15 -07:00
Nick Kralevich
373ea006ce am 1d174a9c: am 02ca0e31: Merge "Fix FORTIFY_SOURCE unittests."
* commit '1d174a9c17f645a27d766a66e7477d797f955e90':
  Fix FORTIFY_SOURCE unittests.
2013-06-19 10:40:46 -07:00
Nick Kralevich
1d174a9c17 am 02ca0e31: Merge "Fix FORTIFY_SOURCE unittests."
* commit '02ca0e314219a4c7205a180a414c509651043f13':
  Fix FORTIFY_SOURCE unittests.
2013-06-19 10:36:55 -07:00
Nick Kralevich
02ca0e3142 Merge "Fix FORTIFY_SOURCE unittests." 2013-06-19 17:33:57 +00:00
Colin Cross
700b548738 am f4250508: am 3225f498: Merge "bionic: add __system_property_foreach"
* commit 'f4250508d5de415e200888ffdf143f870dc0f829':
  bionic: add __system_property_foreach
2013-06-19 10:31:11 -07:00
Colin Cross
f4250508d5 am 3225f498: Merge "bionic: add __system_property_foreach"
* commit '3225f4984837c4d9e6e9495d2154f2d9987cf457':
  bionic: add __system_property_foreach
2013-06-19 10:27:23 -07:00
Colin Cross
3225f49848 Merge "bionic: add __system_property_foreach" 2013-06-19 17:26:17 +00:00
Nick Kralevich
3cd4cac2ce Fix FORTIFY_SOURCE unittests.
The compiler is too damn smart.

Change-Id: Ibef3ef41ec99f8cd9c06f1dbca535819f9a08197
2013-06-19 10:25:44 -07:00
The Android Automerger
6e06d4b106 merge in klp-release history after reset to master 2013-06-19 07:40:48 -07:00
Sergey Melnikov
dc5d3426d8 stdint.h header is not fully compatible with C99(ISO9899:1999)
stdint.h provides macros with incorrect type:
  * UINT8_C
  * UINT16_C
  * UINT8_MAX
  * UINT16_MAX

Signed-off-by: Sergey Melnikov <sergey.melnikov@intel.com>
Change-Id: I2d130c782d4485bf6c9e9f068de0bdaa4ba7303f
2013-06-19 12:33:31 +04:00
Greg Hackmann
c6ff844d75 bionic: add __system_property_foreach
find_nth() will be inefficient on a trie.  Since find_nth() is only used
internally and only for enumerating properties, we can add a foreach()
function to do this directly.

Signed-off-by: Greg Hackmann <ghackmann@google.com>

(cherry picked from commit 577418403d)

Change-Id: Iaca97d1182ce2c28863ba85241cbb5cf6185eb2f
2013-06-18 19:24:29 -07:00
Greg Hackmann
577418403d bionic: add __system_property_foreach
find_nth() will be inefficient on a trie.  Since find_nth() is only used
internally and only for enumerating properties, we can add a foreach()
function to do this directly.

Change-Id: I66bde9926c193073d74b244cce9fffd52108fff8
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-06-18 15:38:31 -07:00
Geremy Condra
1791cb0001 Merge "Fix remove_uidiface_info failing on first entry" 2013-06-18 21:43:52 +00:00
Elliott Hughes
fb11350c81 am 13e23302: am c656d732: Merge "Always use v1 for MIPS TLS access."
* commit '13e23302c93fdd8b52c606277f32dec0627ddbbd':
  Always use v1 for MIPS TLS access.
2013-06-18 14:00:59 -07:00
Elliott Hughes
13e23302c9 am c656d732: Merge "Always use v1 for MIPS TLS access."
* commit 'c656d732c7712b0f73d9c560ccf3cb5ae47d219d':
  Always use v1 for MIPS TLS access.
2013-06-18 13:57:57 -07:00
Elliott Hughes
c656d732c7 Merge "Always use v1 for MIPS TLS access." 2013-06-18 20:56:25 +00:00
Nick Kralevich
83476f0747 am d98d35c5: am 0846109c: Merge "libc: Rename fortify error functions."
* commit 'd98d35c5380ce398038d3062d40bc4fe082dce80':
  libc: Rename fortify error functions.
2013-06-18 13:31:56 -07:00
Nick Kralevich
227079bb67 am 3bf62790: am dd0880fe: Merge "libc: add limited FORTIFY_SOURCE support for clang"
* commit '3bf6279034e6a92c3550fae31c5c136bec61344a':
  libc: add limited FORTIFY_SOURCE support for clang
2013-06-18 13:31:56 -07:00
Elliott Hughes
6a87df87a2 am 45ef218b: am 6807af77: Merge "Make LD_PRELOAD failures just warnings."
* commit '45ef218bde353df455062aa3c9a9f84ffed769fc':
  Make LD_PRELOAD failures just warnings.
2013-06-18 13:31:55 -07:00
Colin Cross
bf03f1b4d6 am e421bd71: am 02002443: Merge "bionic: fix deleting property arrays in property benchmark"
* commit 'e421bd71c32e35b8f39f2e51f2d534d2f21f139f':
  bionic: fix deleting property arrays in property benchmark
2013-06-18 13:27:29 -07:00
Nick Kralevich
d98d35c538 am 0846109c: Merge "libc: Rename fortify error functions."
* commit '0846109c96d54a28e413893b0cd4b4acb3aa87fc':
  libc: Rename fortify error functions.
2013-06-18 13:27:18 -07:00
Nick Kralevich
3bf6279034 am dd0880fe: Merge "libc: add limited FORTIFY_SOURCE support for clang"
* commit 'dd0880fec3bb8c998680e78aff9e2ddc2bcf6d7a':
  libc: add limited FORTIFY_SOURCE support for clang
2013-06-18 13:27:17 -07:00
Elliott Hughes
45ef218bde am 6807af77: Merge "Make LD_PRELOAD failures just warnings."
* commit '6807af773f862750efb6860e00402580a5f463f3':
  Make LD_PRELOAD failures just warnings.
2013-06-18 13:27:16 -07:00
Elliott Hughes
a33dc57c7c Always use v1 for MIPS TLS access.
Change-Id: Ic2850b90185cfbc5b0eff804c8b74a1c553c0852
2013-06-18 13:26:22 -07:00
Nick Kralevich
0846109c96 Merge "libc: Rename fortify error functions." 2013-06-18 20:24:04 +00:00
Colin Cross
e421bd71c3 am 02002443: Merge "bionic: fix deleting property arrays in property benchmark"
* commit '02002443d4b17de78418d51fc303b4c976ad071a':
  bionic: fix deleting property arrays in property benchmark
2013-06-18 13:23:51 -07:00
Nick Kralevich
dd0880fec3 Merge "libc: add limited FORTIFY_SOURCE support for clang" 2013-06-18 20:23:49 +00:00
Elliott Hughes
6807af773f Merge "Make LD_PRELOAD failures just warnings." 2013-06-18 20:23:07 +00:00
Colin Cross
02002443d4 Merge "bionic: fix deleting property arrays in property benchmark" 2013-06-18 20:22:25 +00:00
Nick Kralevich
ce7c2f28c6 am ba6c021a: am e2fb05b4: Merge "libc: Introduce __errordecl()"
* commit 'ba6c021a53376c75993cc9866deb7c7ff6e1750d':
  libc: Introduce __errordecl()
2013-06-18 13:21:00 -07:00
Nick Kralevich
ba6c021a53 am e2fb05b4: Merge "libc: Introduce __errordecl()"
* commit 'e2fb05b45b9af7b9af8df0ea15bfec63d331d882':
  libc: Introduce __errordecl()
2013-06-18 13:17:35 -07:00
Nick Kralevich
e2fb05b45b Merge "libc: Introduce __errordecl()" 2013-06-18 20:15:33 +00:00
Elliott Hughes
7e5a8cc523 Make LD_PRELOAD failures just warnings.
This matches glibc and makes life easier for developers who want to
sometimes preload a library from init (which has no conditionals); they
can simply move/remove the library to disable.

Change-Id: I579b8633f958235af6e46bb53b378b9e363afb1f
2013-06-18 13:15:00 -07:00
Colin Cross
7d06813d93 bionic: fix deleting property arrays in property benchmark
Use delete[] to delete arrays allocated with new []

Change-Id: Icc2a6b23df09049c008f7f1f50ed93a277174308
2013-06-18 13:08:28 -07:00
Colin Cross
3b599c1dde am 1a38e063: am 0005b354: Merge "bionic: change properties benchmarks to read a single property"
* commit '1a38e063830924efb8a6d9d7a6135ef54460cb9b':
  bionic: change properties benchmarks to read a single property
2013-06-18 13:07:58 -07:00
Nick Kralevich
a641c18f0c libc: Rename fortify error functions.
__umask_error -> __umask_invalid_mode
__creat_error -> __creat_missing_mode
__too_many_args_error -> __creat_too_many_args

Change-Id: I4036f344a3a93628e70f2e948ad73cfed3a967ea
2013-06-18 13:07:18 -07:00
Colin Cross
1a38e06383 am 0005b354: Merge "bionic: change properties benchmarks to read a single property"
* commit '0005b3544be345e697592b4dc199ebaa37048559':
  bionic: change properties benchmarks to read a single property
2013-06-18 13:04:10 -07:00
Colin Cross
0005b3544b Merge "bionic: change properties benchmarks to read a single property" 2013-06-18 20:01:05 +00:00
Colin Cross
7d90cfa6b5 bionic: change properties benchmarks to read a single property
The properties benchmarks were reading n properties from a property
area with n properties in it, which was making it hard to compare
the time between runs of different sizes.  Change the benchmark
to read a random property per iteration so the numbers between
runs are comparable.

Change-Id: Ib1648ce0948d9038fce76d209608427376cfb8da
2013-06-18 12:55:52 -07:00
Nick Kralevich
16d1af167f libc: add limited FORTIFY_SOURCE support for clang
In 829c089f83, we disabled all
FORTIFY_SOURCE support when compiling under clang. At the time,
we didn't have proper test cases, and couldn't easily create targeted
clang tests.

This change re-enables FORTIFY_SOURCE support under clang for a
limited set of functions, where we have explicit unittests available.
The functions are:

* memcpy
* memmove
* strcpy
* strncpy
* strcat
* strncat
* memset
* strlen (with modifications)
* strchr (with modifications)
* strrchr (with modifications)

It may be possible, in the future, to enable other functions. However,
I need to write unittests first.

For strlen, strchr, and strrchr, clang unconditionally calls the
fortified version of the relevant function. If it doesn't know the
size of the buffer it's dealing with, it passes in ((size_t) -1),
which is the largest possible size_t.

I added two new clang specific unittest files, primarily copied
from fortify?_test.cpp.

I've also rebuild the entire system with these changes, and didn't
observe any obvious problems.

Change-Id: If12a15089bb0ffe93824b485290d05b14355fcaa
2013-06-18 12:14:20 -07:00
Nick Kralevich
b24c0637d0 libc: Introduce __errordecl()
Define __errordecl and replace __attribute__((__error__("foo")))
with __errordecl. Make sure __errordecl is a no-op on clang, as it
generates a compile time warning.

Change-Id: Ifa1a2d3afd6881de9d479fc2adac6737871a2949
2013-06-18 12:13:52 -07:00
The Android Automerger
cb83bdfa6b merge in master-release history after reset to master 2013-06-18 07:49:19 -07:00
Colin Cross
66a061c8b5 am f6e6e5e7: am 977a3313: Merge changes Iac00ce10,I192d3825
* commit 'f6e6e5e72774e302c461767ca0c194f25502108e':
  bionic: add tests for properties
  bionic: move system property writing from init to bionic
2013-06-17 18:33:50 -07:00
Colin Cross
f6e6e5e727 am 977a3313: Merge changes Iac00ce10,I192d3825
* commit '977a33137d2be0093f474055f839cf665b82b588':
  bionic: add tests for properties
  bionic: move system property writing from init to bionic
2013-06-17 18:21:37 -07:00
Colin Cross
977a33137d Merge changes Iac00ce10,I192d3825
* changes:
  bionic: add tests for properties
  bionic: move system property writing from init to bionic
2013-06-18 01:11:58 +00:00
Colin Cross
b27e200ad6 bionic: add tests for properties
(cherry picked from commit 37d9f75dde)

Change-Id: Iac00ce10a4272032a1cbdbc4204277d6876e3365
2013-06-17 16:58:47 -07:00
Colin Cross
5cf32de7a0 bionic: move system property writing from init to bionic
Move the implementation of writing to the system property area
from init to bionic, next to the reader implementation.  This
will allow full property testing to be added to bionic tests.

Add new accessor and waiting functions to hide the implementation
from watchprops and various bionic users.

Also hide some of the implementation details of the property area
from init by moving them into _system_properties.h, and other details
from everybody by moving them into system_properties.h.

(cherry picked from commit dc1038b790)

Change-Id: I192d3825ee276c5047bc751039fe6cfe226a7cca
2013-06-17 16:58:43 -07:00
Elliott Hughes
9edf071a5d am d2dbf163: am 5995bf88: Merge "don\'t hardcode register r0/v1 when reading the TLS"
* commit 'd2dbf16358bee4777a3e4937cf316fa8bb905559':
  don't hardcode register r0/v1 when reading the TLS
2013-06-17 14:56:04 -07:00
Elliott Hughes
d2dbf16358 am 5995bf88: Merge "don\'t hardcode register r0/v1 when reading the TLS"
* commit '5995bf880e2a7fac249382f0a929b7271c843122':
  don't hardcode register r0/v1 when reading the TLS
2013-06-17 14:53:12 -07:00
Elliott Hughes
5995bf880e Merge "don't hardcode register r0/v1 when reading the TLS" 2013-06-17 21:51:50 +00:00
Mathias Agopian
b6e340080a don't hardcode register r0/v1 when reading the TLS
this leads to much improved code when calling __get_tls()

Change-Id: I21d870fb33c33a921ca55c4e100772e0f7a8d1e4
2013-06-17 14:50:30 -07:00
Colin Cross
37d9f75dde bionic: add tests for properties
Change-Id: I09b212966f1c9624631653ef2c7a71de78bbbec1
2013-06-17 12:58:18 -07:00
Colin Cross
dc1038b790 bionic: move system property writing from init to bionic
Move the implementation of writing to the system property area
from init to bionic, next to the reader implementation.  This
will allow full property testing to be added to bionic tests.

Add new accessor and waiting functions to hide the implementation
from watchprops and various bionic users.

Also hide some of the implementation details of the property area
from init by moving them into _system_properties.h, and other details
from everybody by moving them into system_properties.h.

Change-Id: I9026e604109e30546b2849b60cab2e7e5ff00ba5
2013-06-17 12:44:34 -07:00
Elliott Hughes
a658ed09e5 am afd4e299: am 657d0da7: Merge "Slight script cleanup; make gensyscalls work from any directory."
* commit 'afd4e2999c3e726498c407fcaf9cccdcd4d24637':
  Slight script cleanup; make gensyscalls work from any directory.
2013-06-17 11:22:01 -07:00
Elliott Hughes
afd4e2999c am 657d0da7: Merge "Slight script cleanup; make gensyscalls work from any directory."
* commit '657d0da7513e01b0eb104c8a8a522c28fdbc807d':
  Slight script cleanup; make gensyscalls work from any directory.
2013-06-17 11:18:58 -07:00
Elliott Hughes
657d0da751 Merge "Slight script cleanup; make gensyscalls work from any directory." 2013-06-17 18:16:36 +00:00
Elliott Hughes
18bc975bfe Slight script cleanup; make gensyscalls work from any directory.
Also remove a ton of dead code.

Change-Id: I1315623695a004f643b155f121cbafe24b715b8a
2013-06-17 10:39:33 -07:00
The Android Automerger
31d61f13ab merge in master-release history after reset to master 2013-06-17 07:49:47 -07:00
Chad Brubaker
638503b515 Fix remove_uidiface_info failing on first entry
Change-Id: Ic23506581ff835a6b679e1593eab550a84548056
2013-06-14 15:25:42 -07:00
Elliott Hughes
8f5440c486 am c1e4183c: am 560e9f7e: Merge "Ensure that <stdint.h> defines SIZE_MAX and friends."
* commit 'c1e4183c7ad6943f9cc44fe0b769884370a739cd':
  Ensure that <stdint.h> defines SIZE_MAX and friends.
2013-06-13 18:04:19 -07:00
Elliott Hughes
c1e4183c7a am 560e9f7e: Merge "Ensure that <stdint.h> defines SIZE_MAX and friends."
* commit '560e9f7e7a39e02aca96709043ca06f562f75d58':
  Ensure that <stdint.h> defines SIZE_MAX and friends.
2013-06-13 16:21:55 -07:00
Elliott Hughes
560e9f7e7a Merge "Ensure that <stdint.h> defines SIZE_MAX and friends." 2013-06-13 23:19:09 +00:00
Elliott Hughes
7c89506e3a Ensure that <stdint.h> defines SIZE_MAX and friends.
We were missing SIG_ATOMIC_MAX, SIG_ATOMIC_MIN, SIZE_MAX,
WCHAR_MAX, WCHAR_MIN, WINT_MAX, and WINT_MIN.

Change-Id: I2535f36bc220fbaea009b483599b7af811c4cb5c
2013-06-13 16:02:53 -07:00
Elliott Hughes
fa3af2dd67 am af975b07: am c843a3e7: Merge "Fix the qsort copyright notice (fixed upstream this afternoon)."
* commit 'af975b076f79b35cb115c0f77fc8fc0e5d3dba67':
  Fix the qsort copyright notice (fixed upstream this afternoon).
2013-06-12 17:51:25 -07:00
Elliott Hughes
af975b076f am c843a3e7: Merge "Fix the qsort copyright notice (fixed upstream this afternoon)."
* commit 'c843a3e7b215bca5e896e1d56c2fa6332770ea83':
  Fix the qsort copyright notice (fixed upstream this afternoon).
2013-06-12 17:46:57 -07:00
Elliott Hughes
c843a3e7b2 Merge "Fix the qsort copyright notice (fixed upstream this afternoon)." 2013-06-13 00:44:05 +00:00
Elliott Hughes
4eeec44e29 Fix the qsort copyright notice (fixed upstream this afternoon).
Change-Id: I786feb42719bceaa7da91565e350c1333b0d301f
2013-06-12 17:42:43 -07:00
Elliott Hughes
050374836f am ddbf561e: am c843d766: Merge "Handles spurious wake-ups in pthread_join()"
* commit 'ddbf561e5ee8f16fc15d26b085d19ce6abf7e4e0':
  Handles spurious wake-ups in pthread_join()
2013-06-12 17:38:26 -07:00
Elliott Hughes
de1b73dd70 am 7ae23868: am 92e841d0: Merge "Take upstream libm changes."
* commit '7ae23868b4741f9b1af874ebbb13ec3ba930d679':
  Take upstream libm changes.
2013-06-12 17:35:02 -07:00
Elliott Hughes
ddbf561e5e am c843d766: Merge "Handles spurious wake-ups in pthread_join()"
* commit 'c843d7667ada205ecbaf773531067076ed4ad271':
  Handles spurious wake-ups in pthread_join()
2013-06-12 17:34:17 -07:00
Elliott Hughes
c843d7667a Merge "Handles spurious wake-ups in pthread_join()" 2013-06-13 00:31:50 +00:00
Elliott Hughes
7ae23868b4 am 92e841d0: Merge "Take upstream libm changes."
* commit '92e841d0aa8d118882a74e3c3fc4b6a6062dcc09':
  Take upstream libm changes.
2013-06-12 17:30:59 -07:00
msg555
0f020d18b1 Handles spurious wake-ups in pthread_join()
Removed 'join_count' from pthread_internal_t and switched to using the flag
PTHREAD_ATTR_FLAG_JOINED to indicate if a thread is being joined. Combined with
a switch to a while loop in pthread_join, this fixes spurious wake-ups but
prevents a thread from being joined multiple times. This is fine for
two reasons:

1) The pthread_join specification allows for undefined behavior when multiple
   threads try to join a single thread.

2) There is no thread safe way to allow multiple threads to join a single
   thread with the pthread interface.  The second thread calling pthread_join
   could be pre-empted until the thread is destroyed and its handle reused for
   a different thread.  Therefore multi-join is always an error.

Bug: https://code.google.com/p/android/issues/detail?id=52255
Change-Id: I8b6784d47620ffdcdbfb14524e7402e21d46c5f7
2013-06-12 17:30:58 -07:00
Elliott Hughes
92e841d0aa Merge "Take upstream libm changes." 2013-06-13 00:29:21 +00:00
Elliott Hughes
78419467a2 Take upstream libm changes.
Mostly workarounds for GCC and Clang bugs.

Change-Id: I4ef428a42d4ac6d622659053711a8cc416925727
2013-06-12 16:37:58 -07:00
Elliott Hughes
b0cd876974 am 5065eef8: am 6a44d227: Merge "Take some fixed upstream copyright headers and regenerate NOTICE."
* commit '5065eef801aa78a8a64a016fcf644a6ca91a8133':
  Take some fixed upstream copyright headers and regenerate NOTICE.
2013-06-12 16:23:33 -07:00
Elliott Hughes
5065eef801 am 6a44d227: Merge "Take some fixed upstream copyright headers and regenerate NOTICE."
* commit '6a44d2271f372d0c65b05a5d3377bd00ce92824e':
  Take some fixed upstream copyright headers and regenerate NOTICE.
2013-06-12 16:16:09 -07:00
Elliott Hughes
6a44d2271f Merge "Take some fixed upstream copyright headers and regenerate NOTICE." 2013-06-12 23:13:34 +00:00
Elliott Hughes
3267163200 am 5f4d2df2: am 55189a0f: Merge "Switch to current upstream stdio makebuf.c and setvbuf.c."
* commit '5f4d2df2fcddfe62f9e08d1607a8c4e029f01b3d':
  Switch to current upstream stdio makebuf.c and setvbuf.c.
2013-06-12 16:03:49 -07:00
Elliott Hughes
2815b1dd45 Take some fixed upstream copyright headers and regenerate NOTICE.
Change-Id: Ifff41d69c13322dbc6f928ce7d4c65f76fe36772
2013-06-12 16:00:41 -07:00
Elliott Hughes
5f4d2df2fc am 55189a0f: Merge "Switch to current upstream stdio makebuf.c and setvbuf.c."
* commit '55189a0fbd26cfd84939d9d3a42a1800a63bd2c5':
  Switch to current upstream stdio makebuf.c and setvbuf.c.
2013-06-12 15:58:41 -07:00
Elliott Hughes
55189a0fbd Merge "Switch to current upstream stdio makebuf.c and setvbuf.c." 2013-06-12 22:56:20 +00:00
Elliott Hughes
460b70d063 am dc5f5f85: am f1867d47: Merge "Revert "Add SIZE_MAX to <stdint.h> in a way that might actually work.""
* commit 'dc5f5f857c7bf218d33212044539eb73b3fab5f1':
  Revert "Add SIZE_MAX to <stdint.h> in a way that might actually work."
2013-06-12 15:26:46 -07:00
Elliott Hughes
677ee56477 Switch to current upstream stdio makebuf.c and setvbuf.c.
Change-Id: I4761b5e94459815520f01062eef39abf62af621f
2013-06-12 15:24:15 -07:00
Elliott Hughes
dc5f5f857c am f1867d47: Merge "Revert "Add SIZE_MAX to <stdint.h> in a way that might actually work.""
* commit 'f1867d47cbce4225d712a2684da67031f7350909':
  Revert "Add SIZE_MAX to <stdint.h> in a way that might actually work."
2013-06-12 15:22:04 -07:00
Elliott Hughes
f1867d47cb Merge "Revert "Add SIZE_MAX to <stdint.h> in a way that might actually work."" 2013-06-12 22:19:03 +00:00
Elliott Hughes
9248d3a58c Revert "Add SIZE_MAX to <stdint.h> in a way that might actually work."
This reverts commit d8627af159 which caused build breakage:

In file included from bionic/libc/include/limits.h:86:0,
                 from bionic/libc/include/stdint.h:33,
                 from bionic/libc/arch-arm/bionic/crtbegin.c:31:
bionic/libc/include/sys/limits.h:30:26: fatal error: linux/limits.h: No such file or directory
compilation terminated.
make: *** [out/target/product/generic/obj/lib/crtbegin_dynamic1.o] Error 1

Change-Id: I128095ecb99df92626e1f57e34c61e08c98a4078
2013-06-12 22:18:47 +00:00
Elliott Hughes
7e06ab5655 am b0a2262c: am 55c5ec64: Merge "Add SIZE_MAX to <stdint.h> in a way that might actually work."
* commit 'b0a2262c3f91085e79c3fd491379e45821254427':
  Add SIZE_MAX to <stdint.h> in a way that might actually work.
2013-06-12 15:11:12 -07:00
Elliott Hughes
b0a2262c3f am 55c5ec64: Merge "Add SIZE_MAX to <stdint.h> in a way that might actually work."
* commit '55c5ec64bd26d92bd1882a9a4c91445de73ebfa2':
  Add SIZE_MAX to <stdint.h> in a way that might actually work.
2013-06-12 15:06:51 -07:00
Elliott Hughes
55c5ec64bd Merge "Add SIZE_MAX to <stdint.h> in a way that might actually work." 2013-06-12 22:05:10 +00:00
Elliott Hughes
7ac852fb05 am 3da47942: am 944ea1a3: Merge "Clean up abort."
* commit '3da47942d3fdeb6f39cf84b03c75cfeb69f91449':
  Clean up abort.
2013-06-12 15:02:34 -07:00
Elliott Hughes
3da47942d3 am 944ea1a3: Merge "Clean up abort."
* commit '944ea1a32018c44d6cb55c9454e670b0e152da6d':
  Clean up abort.
2013-06-12 14:58:32 -07:00
Elliott Hughes
d8627af159 Add SIZE_MAX to <stdint.h> in a way that might actually work.
Take two.

Change-Id: I7d08b6d14c82a171312a7f5898270b4441d5cfa2
2013-06-12 14:54:16 -07:00
Elliott Hughes
944ea1a320 Merge "Clean up abort." 2013-06-12 21:53:58 +00:00
Elliott Hughes
61e699a133 Clean up abort.
* A dlmalloc usage error shouldn't call abort(3) because we want to
  cause a SIGSEGV by writing the address dlmalloc didn't like to an
  address the kernel won't like, so that debuggerd will dump the
  memory around the address that upset dlmalloc.

* Switch to the simpler FreeBSD/NetBSD style of registering stdio
  cleanup. Hopefully this will let us simplify more of the stdio
  implementation.

* Clear the stdio cleanup handler before we abort because of a dlmalloc
  corruption error. This fixes the reported bug, where we'd hang inside
  dlmalloc because the stdio cleanup reentered dlmalloc.

Bug: 9301265
Change-Id: Ief31b389455d6876e5a68f0f5429567d37277dbc
2013-06-12 14:14:53 -07:00
Elliott Hughes
1e88a7abca am 834f83de: am 5cde15eb: Merge "<stdint.h> should expose SIZE_MAX."
* commit '834f83de3f3363090385963eef1cd9a053a51a71':
  <stdint.h> should expose SIZE_MAX.
2013-06-12 11:05:18 -07:00
Elliott Hughes
834f83de3f am 5cde15eb: Merge "<stdint.h> should expose SIZE_MAX."
* commit '5cde15eb17f4ddc0949c0cbd38a46e6c0bad7019':
  <stdint.h> should expose SIZE_MAX.
2013-06-12 10:58:23 -07:00
Elliott Hughes
5cde15eb17 Merge "<stdint.h> should expose SIZE_MAX." 2013-06-12 17:56:24 +00:00
Elliott Hughes
2c157aec9b <stdint.h> should expose SIZE_MAX.
Change-Id: Id27222c24955c83f29ad953933cbdc48b6f1e900
2013-06-12 10:28:26 -07:00
The Android Automerger
2df16acc42 merge in master-release history after reset to master 2013-06-12 07:49:39 -07:00
Nick Kralevich
6d88e4e96b am 26cc1d68: am b6e88020: Merge "fix unittests."
* commit '26cc1d6838c0c4fd18abbf6ea5a38d24aea93893':
  fix unittests.
2013-06-11 16:03:32 -07:00
Nick Kralevich
26cc1d6838 am b6e88020: Merge "fix unittests."
* commit 'b6e880200d1690c00cb843e59c6849a275dbfbb7':
  fix unittests.
2013-06-11 15:56:42 -07:00
Nick Kralevich
b6e880200d Merge "fix unittests." 2013-06-11 22:52:54 +00:00
Nick Kralevich
fd0325bd98 fix unittests.
7e6ce1a3c5 fixed abort() to raise
SIGABRT rather than causing SIGSEGV. However, the unittests were
not updated.

Fix unittests.

Change-Id: I73db194127b9b9e9440358aa94273863765a736b
2013-06-11 15:45:23 -07:00
The Android Automerger
4a0c222bb1 merge in master-release history after reset to master 2013-06-11 07:49:16 -07:00
Ben Cheng
d20a04c5cf am 77f90de7: am fc104f89: Merge "Fix abort(3) to raise SIGABRT rather than causing SIGSEGV."
* commit '77f90de728b9fa60b83b7f12a45c1113f3189cb2':
  Fix abort(3) to raise SIGABRT rather than causing SIGSEGV.
2013-06-10 17:28:46 -07:00
Ben Cheng
77f90de728 am fc104f89: Merge "Fix abort(3) to raise SIGABRT rather than causing SIGSEGV."
* commit 'fc104f899d47916f76c91127caf9aeaf7b69d4ef':
  Fix abort(3) to raise SIGABRT rather than causing SIGSEGV.
2013-06-10 17:25:31 -07:00
Ben Cheng
fc104f899d Merge "Fix abort(3) to raise SIGABRT rather than causing SIGSEGV." 2013-06-11 00:22:14 +00:00
Ben Cheng
7e6ce1a3c5 Fix abort(3) to raise SIGABRT rather than causing SIGSEGV.
tgkill() needs the .save stack unwinding directive to get the complete
stack trace.

BUG: https://code.google.com/p/android/issues/detail?id=16672

Change-Id: Ifb447dca2147a592c48baf32769dfc175d8aea72
2013-06-10 17:17:46 -07:00
Brian Carlstrom
b181747aa1 am d978d21d: am 8252b8e4: Merge "Honor p_vaddr if set"
* commit 'd978d21d195976fa3f257b8d17ec2fe18fb436a7':
  Honor p_vaddr if set
2013-06-10 15:44:13 -07:00
Brian Carlstrom
d978d21d19 am 8252b8e4: Merge "Honor p_vaddr if set"
* commit '8252b8e4b730b13623f31dc66396e000586d1c58':
  Honor p_vaddr if set
2013-06-10 15:41:19 -07:00
Brian Carlstrom
8252b8e4b7 Merge "Honor p_vaddr if set" 2013-06-10 22:39:07 +00:00
Geremy Condra
72254952e1 Merge "Add clearing of resolv uid and pid interface maps" 2013-06-10 18:45:01 +00:00
The Android Automerger
5074892e0a merge in master-release history after reset to master 2013-06-10 09:52:26 -07:00
Elliott Hughes
efc78bbb9f am 6bcf71c9: am 2fbc9dda: Merge "bionic/x86: Optimization for string routines"
* commit '6bcf71c9ac8395038ca243160d4367759be8dd80':
  bionic/x86: Optimization for string routines
2013-06-07 17:52:16 -07:00
Elliott Hughes
1b14c72420 am fc6f5a08: am 157c4299: Merge "Revert "libc x86: Remove strcat.S""
* commit 'fc6f5a086557f81fce2542b7015268bff697d10c':
  Revert "libc x86: Remove strcat.S"
2013-06-07 17:48:53 -07:00
Elliott Hughes
6bcf71c9ac am 2fbc9dda: Merge "bionic/x86: Optimization for string routines"
* commit '2fbc9dda345486005569be4ec586c6aae9d51650':
  bionic/x86: Optimization for string routines
2013-06-07 17:47:33 -07:00
Elliott Hughes
2fbc9dda34 Merge "bionic/x86: Optimization for string routines" 2013-06-08 00:45:07 +00:00
Elliott Hughes
fc6f5a0865 am 157c4299: Merge "Revert "libc x86: Remove strcat.S""
* commit '157c42997b7aa31b36cca63ad03dbb5a601ce347':
  Revert "libc x86: Remove strcat.S"
2013-06-07 17:44:20 -07:00
Elliott Hughes
157c42997b Merge "Revert "libc x86: Remove strcat.S"" 2013-06-08 00:42:44 +00:00
Elliott Hughes
06708df6fb Revert "libc x86: Remove strcat.S"
This reverts commit 4fe461b3a6

Change-Id: Ibeb76e24f054abd7c96ad6899366c2f9bfc2a5ad
2013-06-08 00:42:35 +00:00
Christopher Ferris
b3a7db2dc2 am 83245ba4: am 9647f797: Merge "Implement malloc_usable_size for debug impls."
* commit '83245ba45facf0caff3beb18a27e6604df9094ba':
  Implement malloc_usable_size for debug impls.
2013-06-07 17:36:50 -07:00
Christopher Ferris
83245ba45f am 9647f797: Merge "Implement malloc_usable_size for debug impls."
* commit '9647f797d59222cd91507d4554bf62166ba88e0a':
  Implement malloc_usable_size for debug impls.
2013-06-07 15:16:30 -07:00
Christopher Ferris
9647f797d5 Merge "Implement malloc_usable_size for debug impls." 2013-06-07 22:15:33 +00:00
Christopher Ferris
885f3b9cad Implement malloc_usable_size for debug impls.
- Implemented chk_memalign.
- Fixed a few bugs in leak_memalign.
- Implemented {leak,fill,check,qemu}_malloc_usable_size.
- Make malloc_usable_size update at run time.
- Add malloc_test.cpp as a small set of tests for the
  malloc debug routines.
- Fix the qemu routines since it's been broken since it moved to C++.
- Add support for the %u format to the out_vformat in libc_logging.cpp.
  This is used by the emulator code.

Tested using the bionic-unit-tests with setprop libc.debug.malloc
set to 1, 5, and 10.

I tested as much as possible on the emulator, but tracing doesn't appear
to be working properly.

Bug: 6143477

Merge change from internal master.

(cherry-picked from commit 3d594c2580)

Change-Id: I4ae00fffba82315a8c283f35893fd554460722fb
2013-06-07 14:55:32 -07:00
Chad Brubaker
87594a32b8 Add clearing of resolv uid and pid interface maps
Cleanup uid interface map variable names

Change-Id: I712dd83276bb23b149af4180515ef33a1bade5ea
2013-06-07 13:03:23 -07:00
Christopher Ferris
3d594c2580 Implement malloc_usable_size for debug impls.
- Implemented chk_memalign.
- Fixed a few bugs in leak_memalign.
- Implemented {leak,fill,check,qemu}_malloc_usable_size.
- Make malloc_usable_size update at run time.
- Add malloc_test.cpp as a small set of tests for the
  malloc debug routines.
- Fix the qemu routines since it's been broken since it moved to C++.
- Add support for the %u format to the out_vformat in libc_logging.cpp.
  This is used by the emulator code.

Tested using the bionic-unit-tests with setprop libc.debug.malloc
set to 1, 5, and 10.

I tested as much as possible on the emulator, but tracing doesn't appear
to be working properly.

Bug: 6143477

Change-Id: Ieba99b58c2228c88d80afd264501004a4dadd212
2013-06-07 12:56:09 -07:00
Brian Carlstrom
e7dffe150b Honor p_vaddr if set
(cherry picked from commit 88ff15c2c279d2bbe3569101b36cd2aa0931a0a9)

Change-Id: I4aabbe911d30aea8ace69e29bb6e980a4e89de90
2013-06-07 12:47:58 -07:00
Geremy Condra
a24d14c05d Merge "Add per UID interface support to resolv cache" 2013-06-06 20:48:44 +00:00
Chad Brubaker
0c9bb49a9d Add per UID interface support to resolv cache
Add methods to attach/detach UID ranges to a specific dns cache/interface.

This mirrors the already existing code for attaching specific processes to
specific interfaces but will be used to push all processes from a given
user to a specific cache/interface.

Change-Id: Ic24391e92d3ca46fcb46cc4fc53e13984dec40b3
2013-06-06 12:31:16 -07:00
Elliott Hughes
b166e699dc am e84cfbef: am b7b4f5b8: Merge "update signal.h to be C90 compatable"
* commit 'e84cfbefd82f552490c580d35a54db4f53b6e5fb':
  update signal.h to be C90 compatable
2013-06-05 18:14:30 -07:00
Elliott Hughes
e51cd6f9c9 am 5a6a0a94: am 18af4503: Merge "Ensure header files using __BEGIN_DECLS include sys/cdefs.h."
* commit '5a6a0a9445d80bf2bd847088921f6d1d99315552':
  Ensure header files using __BEGIN_DECLS include sys/cdefs.h.
2013-06-05 18:11:05 -07:00
Elliott Hughes
e84cfbefd8 am b7b4f5b8: Merge "update signal.h to be C90 compatable"
* commit 'b7b4f5b838cd41407c734af74e8211f5c7da0036':
  update signal.h to be C90 compatable
2013-06-05 18:09:17 -07:00
Elliott Hughes
b7b4f5b838 Merge "update signal.h to be C90 compatable" 2013-06-06 01:06:41 +00:00
Elliott Hughes
5a6a0a9445 am 18af4503: Merge "Ensure header files using __BEGIN_DECLS include sys/cdefs.h."
* commit '18af450393b005b4ead896d82cda750e6876fd33':
  Ensure header files using __BEGIN_DECLS include sys/cdefs.h.
2013-06-05 18:06:04 -07:00
Erik Gilling
156ccf42ff update signal.h to be C90 compatable
sigismember, sigaddset, and sigdelset had mixed code and declarations
which are not allowed in C90 and before.

Change-Id: I662af944fc1489e34bed228ce592e41f50d00e17
Signed-off-by: Erik Gilling <konkers@android.com>
2013-06-05 18:05:36 -07:00
Elliott Hughes
18af450393 Merge "Ensure header files using __BEGIN_DECLS include sys/cdefs.h." 2013-06-06 01:04:13 +00:00
Elliott Hughes
36fa67bcdd Ensure header files using __BEGIN_DECLS include sys/cdefs.h.
We keep fixing these one-by-one; let's fix them all at once.

Found thus:

  find . -name *.h | xargs grep -L sys/cdefs.h | xargs grep -l BEGIN_DECL | xargs grep -L sys/types

Change-Id: I188842aa2484dc6176e96556d57c38a0f785b59b
2013-06-05 17:58:08 -07:00
Elliott Hughes
0ecb96c3a2 am b9e2dae4: am c5bfb624: Merge "sys/personality.h: include <sys/cdefs.h>"
* commit 'b9e2dae427ef1e1cfdbb3faa1442d4a66a2d3bcd':
  sys/personality.h: include <sys/cdefs.h>
2013-06-05 17:32:20 -07:00
Elliott Hughes
b9e2dae427 am c5bfb624: Merge "sys/personality.h: include <sys/cdefs.h>"
* commit 'c5bfb62433751579e86d5fd24cddf3ae28a49b43':
  sys/personality.h: include <sys/cdefs.h>
2013-06-05 17:29:01 -07:00
Elliott Hughes
c5bfb62433 Merge "sys/personality.h: include <sys/cdefs.h>" 2013-06-06 00:28:07 +00:00
Elliott Hughes
bedd8e3de1 am ce208f33: am 8d36050a: Merge "Clean up useless declaration in thread_private.h"
* commit 'ce208f3389769026df02f7aebd85c8f5d3e74c73':
  Clean up useless declaration in thread_private.h
2013-06-05 17:06:50 -07:00
Elliott Hughes
ce208f3389 am 8d36050a: Merge "Clean up useless declaration in thread_private.h"
* commit '8d36050ac2bb1c4a6a04462e64c5440e3c23c9f0':
  Clean up useless declaration in thread_private.h
2013-06-05 17:02:29 -07:00
Elliott Hughes
8d36050ac2 Merge "Clean up useless declaration in thread_private.h" 2013-06-06 00:00:40 +00:00
The Android Automerger
a7b5635e60 merge in master-release history after reset to master 2013-06-05 07:49:30 -07:00
Kito Cheng
328223230b sys/personality.h: include <sys/cdefs.h>
Change-Id: Ia3fa558a38e0cffe5287bc454e85d5d3bdaa6ba1
2013-06-05 11:30:17 +08:00
Kito Cheng
94d0daa2dd Clean up useless declaration in thread_private.h
Change-Id: Ie7bcdc7195a3fcbcd09a95f73b0c49e8897ad50b
2013-06-05 11:26:24 +08:00
Elliott Hughes
8ed5aec934 am 4b47d9f9: am 4c001859: Merge "Fix declaration of malloc_usable_size()"
* commit '4b47d9f978296e5bb2eaabb8069960eb6f207c80':
  Fix declaration of malloc_usable_size()
2013-06-04 19:02:21 -07:00
Elliott Hughes
4b47d9f978 am 4c001859: Merge "Fix declaration of malloc_usable_size()"
* commit '4c001859feeda27727917c5bd00338e90b801742':
  Fix declaration of malloc_usable_size()
2013-06-04 19:00:03 -07:00
Elliott Hughes
4c001859fe Merge "Fix declaration of malloc_usable_size()" 2013-06-05 01:58:26 +00:00
Nick Kralevich
f1b25d0788 am ae533cb1: am a24e81ef: Merge "Add tests for __strcpy_chk()"
* commit 'ae533cb1118be39a3a0587da46fa95bb4d8ee494':
  Add tests for __strcpy_chk()
2013-06-04 12:14:19 -07:00
Nick Kralevich
ae533cb111 am a24e81ef: Merge "Add tests for __strcpy_chk()"
* commit 'a24e81efd30d106cdfa6a019acf7c77cd88b40cc':
  Add tests for __strcpy_chk()
2013-06-04 12:07:16 -07:00
Nick Kralevich
a24e81efd3 Merge "Add tests for __strcpy_chk()" 2013-06-04 19:05:33 +00:00
Nick Kralevich
13476deec4 Add tests for __strcpy_chk()
Change-Id: I5675d04fcd471732c1b87b83879a54fbcd27762e
2013-06-04 11:55:08 -07:00
The Android Automerger
680e3f94a0 merge in master-release history after reset to master 2013-06-04 07:49:30 -07:00
Brian Carlstrom
20b0fec8ab am 81bfade8: am 06713930: Merge "Small cleanup of soinfo_elf_lookup."
* commit '81bfade818f1b76cf822f0e7e0862fe61e7c580a':
  Small cleanup of soinfo_elf_lookup.
2013-06-03 20:43:30 -07:00
Brian Carlstrom
81bfade818 am 06713930: Merge "Small cleanup of soinfo_elf_lookup."
* commit '0671393072a78e75a726c58aa3ca718e55eeac3e':
  Small cleanup of soinfo_elf_lookup.
2013-06-03 20:21:04 -07:00
Brian Carlstrom
0671393072 Merge "Small cleanup of soinfo_elf_lookup." 2013-06-04 03:18:23 +00:00
Christopher Ferris
6bec5b792a Small cleanup of soinfo_elf_lookup.
- Remove unnecessary line.
- Move declarations to first use.

Change-Id: I1d8398d6c13f7cb86bffe0b68af849e35a4b234d
2013-06-03 20:15:14 -07:00
Rom Lemarchand
8ea08d3ff9 Merge "mmap: Reinstate passing MADV_MERGEABLE on private anonymous maps" 2013-06-03 19:40:21 +00:00
The Android Automerger
b472f50057 merge in master-release history after reset to master 2013-06-03 07:49:38 -07:00
Ben Cheng
7ca9057f53 am 72ce296f: am 404d491e: Merge "Use bl instead of blx to support interworking properly."
* commit '72ce296f282803cb026aff5ab180e8a43656612e':
  Use bl instead of blx to support interworking properly.
2013-06-01 09:51:29 -07:00
Ben Cheng
72ce296f28 am 404d491e: Merge "Use bl instead of blx to support interworking properly."
* commit '404d491eb655839bf4260cc168bb79864473e129':
  Use bl instead of blx to support interworking properly.
2013-06-01 08:19:07 -07:00
Ben Cheng
404d491eb6 Merge "Use bl instead of blx to support interworking properly." 2013-05-31 21:40:37 +00:00
Ben Cheng
a123b5d319 Use bl instead of blx to support interworking properly.
(cherry picked from commit 9e1905794b in
master)

Change-Id: I9b8c35ea9e201e00f84315f9f105013c23c94d85
2013-05-31 14:39:23 -07:00
Ben Cheng
dc1782b156 Merge "Use bl instead of blx to support interworking properly." 2013-05-31 21:36:55 +00:00
Ben Cheng
9e1905794b Use bl instead of blx to support interworking properly.
BUG: 9227177
Change-Id: I742c2f2ecbe332f9c9743e3f4bde8de791a1d289
2013-05-31 14:25:48 -07:00
Nick Kralevich
75c9e17682 am 027a8fae: am 8539961f: Merge "FORTIFY_SOURCE: strcat / strncat optimize"
* commit '027a8fae7750855af2ec0f8dd655e4a48ebf9352':
  FORTIFY_SOURCE: strcat / strncat optimize
2013-05-31 11:21:18 -07:00
Nick Kralevich
027a8fae77 am 8539961f: Merge "FORTIFY_SOURCE: strcat / strncat optimize"
* commit '8539961ff299b05d8feac9be8b119698be22da03':
  FORTIFY_SOURCE: strcat / strncat optimize
2013-05-31 11:14:56 -07:00
Nick Kralevich
8539961ff2 Merge "FORTIFY_SOURCE: strcat / strncat optimize" 2013-05-31 18:13:23 +00:00
Rom Lemarchand
c702a90467 mmap: Reinstate passing MADV_MERGEABLE on private anonymous maps
Reinstate mmap calling madvise(MADV_MERGEABLE) removed in
635df850e5

Change-Id: I290bc5ac6bb32735a3f61dd21e2fce1dfb6dfd4b
Signed-off-by: Rom Lemarchand <romlem@google.com>
2013-05-31 10:05:50 -07:00
Nick Kralevich
cf870199d5 FORTIFY_SOURCE: strcat / strncat optimize
__strcat_chk and __strncat_chk are slightly inefficient,
because they end up traversing over the same memory region
two times.

This change optimizes __strcat_chk / __strncat_chk so they
only access the memory once. Although I haven't benchmarked these
changes, it should improve the performance of these functions.

__strlen_chk - expose this function, even if -D_FORTIFY_SOURCE
isn't defined. This is needed to compile libc itself without
-D_FORTIFY_SOURCE.

Change-Id: Id2c70dff55a276b47c59db27a03734d659f84b74
2013-05-31 09:07:46 -07:00
Liubov Dmitrieva
0a490665a3 bionic/x86: Optimization for string routines
Optimized strcpy, strcat,
strncpy, strncat, strlcpy, strlcat,
memchr, memrchr, strchr, strrchr, index,
strnlen, strlen, wcslen, wmemcmp, wcscmp,
wcschr, wcsrchr, wcscpy, wcscat

Change-Id: I82b29132edf9a2e144e0bb3ee4ff5217df8d2a6d
Signed-off-by: Liubov Dmitrieva <liubov.dmitrieva@intel.com>
2013-05-31 13:37:03 +04:00
Nick Kralevich
b5aa654be6 am d9349abf: am 72f59c84: Merge "Add strncpy FORTIFY_SOURCE tests."
* commit 'd9349abf29506529790abf83cd239b77fa771038':
  Add strncpy FORTIFY_SOURCE tests.
2013-05-30 17:02:01 -07:00
Nick Kralevich
9b7ae336ee am 5630e54c: am d515f468: Merge "libc x86: Remove strcat.S"
* commit '5630e54c3b1a90ee741bbcff129d0c711160ba02':
  libc x86: Remove strcat.S
2013-05-30 17:02:01 -07:00
Nick Kralevich
d9349abf29 am 72f59c84: Merge "Add strncpy FORTIFY_SOURCE tests."
* commit '72f59c84fd73a0a701ce6448d103e9021c1cb060':
  Add strncpy FORTIFY_SOURCE tests.
2013-05-30 16:54:24 -07:00
Nick Kralevich
5630e54c3b am d515f468: Merge "libc x86: Remove strcat.S"
* commit 'd515f46888cf381c1fbbc99a62be727174b30a23':
  libc x86: Remove strcat.S
2013-05-30 16:54:18 -07:00
Nick Kralevich
72f59c84fd Merge "Add strncpy FORTIFY_SOURCE tests." 2013-05-30 20:33:02 +00:00
Nick Kralevich
8cc145edf4 Add strncpy FORTIFY_SOURCE tests.
Change-Id: Id108b1d72b44d7e5fb911268e80bbdf896808f60
2013-05-30 13:21:14 -07:00
Nick Kralevich
d515f46888 Merge "libc x86: Remove strcat.S" 2013-05-30 19:59:38 +00:00
Nick Kralevich
4fe461b3a6 libc x86: Remove strcat.S
This file is never used.

Change-Id: Iae4bba4a5a12a86a775af05e7477fb7b6511480b
2013-05-30 11:15:40 -07:00
The Android Automerger
fe09748a5f merge in master-release history after reset to master 2013-05-27 07:50:00 -07:00
Nick Kralevich
3010061a53 am cf342653: am 8d79fd1c: Merge "libc x86: Remove index.S, strcpy.S, strchr.S"
* commit 'cf342653388682c96b3c4eec6a5ed4dbcb6112ef':
  libc x86: Remove index.S, strcpy.S, strchr.S
2013-05-24 13:02:11 -07:00
Nick Kralevich
af5d6029e5 am 080d2aa8: am 2317275f: Merge "libc: delete x86 memchr.S"
* commit '080d2aa8dc0ae318a12f7a424f9bca32b1216791':
  libc: delete x86 memchr.S
2013-05-24 13:02:06 -07:00
Nick Kralevich
cf34265338 am 8d79fd1c: Merge "libc x86: Remove index.S, strcpy.S, strchr.S"
* commit '8d79fd1c94cb021b6852e6f44e27183ec83fe04c':
  libc x86: Remove index.S, strcpy.S, strchr.S
2013-05-24 11:37:30 -07:00
Nick Kralevich
8d79fd1c94 Merge "libc x86: Remove index.S, strcpy.S, strchr.S" 2013-05-24 18:34:57 +00:00
Nick Kralevich
e4c4ada580 libc x86: Remove index.S, strcpy.S, strchr.S
These files are never used.

Change-Id: Iab8474bdff3bd4d225597c62b3c0f0849f808818
2013-05-24 10:50:05 -07:00
Nick Kralevich
080d2aa8dc am 2317275f: Merge "libc: delete x86 memchr.S"
* commit '2317275f859a685386889139855f2f3314337d53':
  libc: delete x86 memchr.S
2013-05-24 10:43:58 -07:00
Nick Kralevich
2317275f85 Merge "libc: delete x86 memchr.S" 2013-05-24 17:27:47 +00:00
Nick Kralevich
615684c256 libc: delete x86 memchr.S
This file is never used.

Change-Id: Ief08ad176713b5194048852609613801969e1364
2013-05-24 08:52:04 -07:00
David 'Digit' Turner
25a87f7641 Fix declaration of malloc_usable_size()
The function should take a 'const void*' parameter, instead of 'void*'.
Note that the implementation in upstream-dlmalloc/malloc.c already does
this.

For context, see http://b.android.com/55725

Change-Id: Iefd55cdb8996699189e0545f9195972490306227
2013-05-23 10:02:02 +02:00
The Android Automerger
88cc328c17 merge in master-release history after reset to master 2013-05-22 07:49:33 -07:00
Brian Carlstrom
47b2e046cd am 46bf467a: am f5f29de6: Merge "Fix bionic linker to support segments with zero p_filesz"
* commit '46bf467a151eafaf37f6e3578d8d9bad705b8e44':
  Fix bionic linker to support segments with zero p_filesz
2013-05-21 17:28:40 -07:00
Brian Carlstrom
46bf467a15 am f5f29de6: Merge "Fix bionic linker to support segments with zero p_filesz"
* commit 'f5f29de6ae5a0b74234f111b5691a1e5588671cb':
  Fix bionic linker to support segments with zero p_filesz
2013-05-21 17:23:09 -07:00
Brian Carlstrom
f5f29de6ae Merge "Fix bionic linker to support segments with zero p_filesz" 2013-05-21 23:59:52 +00:00
Brian Carlstrom
82dcc7910d Fix bionic linker to support segments with zero p_filesz
(cherry picked from commit 96362fb9d11beef6233aa03db396f25688e70860)

Change-Id: Ib075a6dfc45d5d0746d8b278f317dd9b8d772f2a
2013-05-21 16:57:55 -07:00
The Android Automerger
33cf35317b merge in master-release history after reset to master 2013-05-20 07:49:40 -07:00
Erik Gilling
d5234a3b08 am 4c8eba6f: am 2e317075: Merge "libc/arm: add cortex-a8 cpu variant"
* commit '4c8eba6f2aaf351e29881ca4dc2ec47fc0246446':
  libc/arm: add cortex-a8 cpu variant
2013-05-16 13:20:53 -07:00
Erik Gilling
4c8eba6f2a am 2e317075: Merge "libc/arm: add cortex-a8 cpu variant"
* commit '2e317075b044e94fc75e36d08bec8a7eb5fc31ae':
  libc/arm: add cortex-a8 cpu variant
2013-05-16 13:19:07 -07:00
Erik Gilling
2e317075b0 Merge "libc/arm: add cortex-a8 cpu variant" 2013-05-16 19:57:28 +00:00
The Android Open Source Project
0ae3304f83 am 5b75f3bf: (-s ours) Reconcile with jb-mr2-release - do not merge
* commit '5b75f3bfa1a8f380ce213a0088afec7a7901a25b':
2013-05-16 05:44:28 -07:00
The Android Open Source Project
5b75f3bfa1 Reconcile with jb-mr2-release - do not merge
Change-Id: I0839dac295b83f3c5d53d0bb81925b44e3ec17cc
2013-05-16 05:42:53 -07:00
Rom Lemarchand
22bda4bd67 libc/arm: add cortex-a8 cpu variant
Change-Id: I30e8dd6d4b2e7889aea8f5ed21182a5941bfb489
2013-05-15 20:13:28 -07:00
The Android Automerger
231ea5a414 merge in master-release history after reset to master 2013-05-15 07:49:27 -07:00
Elliott Hughes
217c816480 am 0a7fe991: am 5217fb52: Merge "Fix sysconf(3) for _SC_GETGR_R_SIZE_MAX and _SC_GETPW_R_SIZE_MAX."
* commit '0a7fe991530308fbae9ca033c0045bfc27a7f4c1':
  Fix sysconf(3) for _SC_GETGR_R_SIZE_MAX and _SC_GETPW_R_SIZE_MAX.
2013-05-14 18:11:57 -07:00
Elliott Hughes
0a7fe99153 am 5217fb52: Merge "Fix sysconf(3) for _SC_GETGR_R_SIZE_MAX and _SC_GETPW_R_SIZE_MAX."
* commit '5217fb528ca40ece0dbb459dedf7d6fae81dde68':
  Fix sysconf(3) for _SC_GETGR_R_SIZE_MAX and _SC_GETPW_R_SIZE_MAX.
2013-05-14 18:10:45 -07:00
Elliott Hughes
5217fb528c Merge "Fix sysconf(3) for _SC_GETGR_R_SIZE_MAX and _SC_GETPW_R_SIZE_MAX." 2013-05-15 00:56:06 +00:00
Elliott Hughes
d35106fd55 Fix sysconf(3) for _SC_GETGR_R_SIZE_MAX and _SC_GETPW_R_SIZE_MAX.
Change-Id: Ie16cb21c1a5a2bdce8502b5974e2c4dbb1d679ce
2013-05-14 17:20:34 -07:00
Elliott Hughes
543f3f0ec4 am 975d4464: am 6f502bc7: Merge "Add more __restricts, clean up __format__ attributes."
* commit '975d4464cef774768cf99a68f3537cfc0678e3f7':
  Add more __restricts, clean up __format__ attributes.
2013-05-14 16:59:34 -07:00
Elliott Hughes
975d4464ce am 6f502bc7: Merge "Add more __restricts, clean up __format__ attributes."
* commit '6f502bc74374804766639e6b1515644875810bda':
  Add more __restricts, clean up __format__ attributes.
2013-05-14 16:56:49 -07:00
Elliott Hughes
6f502bc743 Merge "Add more __restricts, clean up __format__ attributes." 2013-05-14 23:45:49 +00:00
Elliott Hughes
940e30cf34 am 20516923: am 349ef893: Merge "Pull upstream FreeBSD revision 249810."
* commit '20516923f59b859f8ca1bfdb3927bc23819ecdb3':
  Pull upstream FreeBSD revision 249810.
2013-05-14 16:26:42 -07:00
Elliott Hughes
20516923f5 am 349ef893: Merge "Pull upstream FreeBSD revision 249810."
* commit '349ef893e82f37632a705f39efc47c0d440f63c7':
  Pull upstream FreeBSD revision 249810.
2013-05-14 16:25:49 -07:00
Elliott Hughes
d04c183979 Add more __restricts, clean up __format__ attributes.
Change-Id: I7e2d270cc722d339d221eaea92747eaff3b51403
2013-05-14 16:08:43 -07:00
Elliott Hughes
349ef893e8 Merge "Pull upstream FreeBSD revision 249810." 2013-05-14 23:06:34 +00:00
Elliott Hughes
b2e1abda05 Pull upstream FreeBSD revision 249810.
Fix license clause numbering.

Convert libc/stdio from K&R to ANSI C.

And add '__restrict' where it appeared in the header prototypes.

Change-Id: I5fdb22f79d3effa2298d03f9aa8412b4b087da04
Upstream: http://svnweb.freebsd.org/base?view=revision&revision=249810
2013-05-14 15:02:16 -07:00
Elliott Hughes
0128b2c752 am 01678789: am 5b7b2809: Merge "epoll: add EPOLLRDHUP, EPOLLWAKEUP, and EPOLLONESHOT events"
* commit '01678789bca18d1a4894ae7f987f847b5ae0ce62':
  epoll: add EPOLLRDHUP, EPOLLWAKEUP, and EPOLLONESHOT events
2013-05-14 15:01:33 -07:00
Elliott Hughes
7c7f098995 am 562804ff: am f0f4fa3f: Merge "libc: add timerfd calls"
* commit '562804ff878ede5d0ce0cb0c79ffb9b26777bf76':
  libc: add timerfd calls
2013-05-14 15:01:32 -07:00
Elliott Hughes
d3d014da91 am 31366236: am e1c58ab5: Merge "libc: remove obsolete CLOCK_REALTIME_HR and CLOCK_MONOTONIC_HR"
* commit '3136623600a9488859ed7c1681b084ea8315ed50':
  libc: remove obsolete CLOCK_REALTIME_HR and CLOCK_MONOTONIC_HR
2013-05-14 15:01:32 -07:00
Elliott Hughes
47e46ed157 am 91cc8014: am 7cb82791: Merge "libc: add clock ids CLOCK_REALTIME_ALARM and CLOCK_BOOTTIME_ALARM"
* commit '91cc8014e8cbc5ebfa90708f77f4f319e553a904':
  libc: add clock ids CLOCK_REALTIME_ALARM and CLOCK_BOOTTIME_ALARM
2013-05-14 15:01:31 -07:00
Elliott Hughes
01678789bc am 5b7b2809: Merge "epoll: add EPOLLRDHUP, EPOLLWAKEUP, and EPOLLONESHOT events"
* commit '5b7b2809a2110dad1b2434f1070e13a08085d94b':
  epoll: add EPOLLRDHUP, EPOLLWAKEUP, and EPOLLONESHOT events
2013-05-14 14:59:16 -07:00
Elliott Hughes
562804ff87 am f0f4fa3f: Merge "libc: add timerfd calls"
* commit 'f0f4fa3fb1ea8623b1e1bc59f7967e0470c8e532':
  libc: add timerfd calls
2013-05-14 14:59:16 -07:00
Elliott Hughes
3136623600 am e1c58ab5: Merge "libc: remove obsolete CLOCK_REALTIME_HR and CLOCK_MONOTONIC_HR"
* commit 'e1c58ab5bb6284b3e3a2d0e54c295a93780b3f70':
  libc: remove obsolete CLOCK_REALTIME_HR and CLOCK_MONOTONIC_HR
2013-05-14 14:59:15 -07:00
Elliott Hughes
91cc8014e8 am 7cb82791: Merge "libc: add clock ids CLOCK_REALTIME_ALARM and CLOCK_BOOTTIME_ALARM"
* commit '7cb82791cada0283648fedc316171cbffda79af7':
  libc: add clock ids CLOCK_REALTIME_ALARM and CLOCK_BOOTTIME_ALARM
2013-05-14 14:59:15 -07:00
Elliott Hughes
5b7b2809a2 Merge "epoll: add EPOLLRDHUP, EPOLLWAKEUP, and EPOLLONESHOT events" 2013-05-14 21:49:09 +00:00
Todd Poynor
b0a2fc35d6 epoll: add EPOLLRDHUP, EPOLLWAKEUP, and EPOLLONESHOT events
(cherry-pick of d1ad4f6dab06189d4d3dcfa19ae4bc301481eb3f.)

Change-Id: I4a8476bff068951533d4188de94097c8b84bc489
2013-05-14 14:48:43 -07:00
Elliott Hughes
f0f4fa3fb1 Merge "libc: add timerfd calls" 2013-05-14 21:45:29 +00:00
Todd Poynor
4200e6203a libc: add timerfd calls
(cherry-pick of 04c0ac14a49e0969333008a9522b64046d58fbdc.)

Change-Id: I06d0b6c2a8781602362b81f48faf1cca76b9ec05
2013-05-14 14:45:02 -07:00
Elliott Hughes
e1c58ab5bb Merge "libc: remove obsolete CLOCK_REALTIME_HR and CLOCK_MONOTONIC_HR" 2013-05-14 21:44:28 +00:00
Todd Poynor
5c4340b2ab libc: remove obsolete CLOCK_REALTIME_HR and CLOCK_MONOTONIC_HR
Add CLOCK_MONOTONIC_RAW, CLOCK_REALTIME_COARSE, and CLOCK_MONOTONIC_COARSE
as supported by recent linux kernels.

(cherry-pick of 60e5144ca312b210b54ac8e6966108da0c97ff80.)

Bug: 8895727
Change-Id: If79a4d05d1301108f49a37588f9416c4be19277a
2013-05-14 14:43:59 -07:00
Elliott Hughes
7cb82791ca Merge "libc: add clock ids CLOCK_REALTIME_ALARM and CLOCK_BOOTTIME_ALARM" 2013-05-14 21:43:37 +00:00
Todd Poynor
23b9fd2c1d libc: add clock ids CLOCK_REALTIME_ALARM and CLOCK_BOOTTIME_ALARM
(cherry-pick of b928bda83d4413b703329f607e2706602f15293f.)

Change-Id: Ica6aad84299819ffc5e57ae4891e057d2e401fa1
2013-05-14 14:43:09 -07:00
Elliott Hughes
ff5fb5cc4b am 509fc806: am d8a9cccb: Merge "Fix all printf warnings in res_send.c."
* commit '509fc8069757aa6091e044f659f76da0bf59723c':
  Fix all printf warnings in res_send.c.
2013-05-14 11:13:39 -07:00
Elliott Hughes
509fc80697 am d8a9cccb: Merge "Fix all printf warnings in res_send.c."
* commit 'd8a9cccb4d77eecc36425c9240a12bd305031ee3':
  Fix all printf warnings in res_send.c.
2013-05-14 11:10:23 -07:00
Elliott Hughes
d8a9cccb4d Merge "Fix all printf warnings in res_send.c." 2013-05-14 17:10:21 +00:00
Kito Cheng
bb0b09cad6 Fix all printf warnings in res_send.c.
Change-Id: I4bf959140b5a5475897bd80704e64e3c4645fc3f
2013-05-14 10:09:23 -07:00
The Android Automerger
46fa11a0ae merge in master-release history after reset to master 2013-05-14 07:49:17 -07:00
Todd Poynor
d1ad4f6dab epoll: add EPOLLRDHUP, EPOLLWAKEUP, and EPOLLONESHOT events
Change-Id: I4a579fc4a74adaee57911b3974ec2f93d9321e8b
2013-05-13 12:06:36 -07:00
Todd Poynor
04c0ac14a4 libc: add timerfd calls
Change-Id: Id63b907266d5b87c7422a51d393a1430551ca33d
2013-05-13 12:06:15 -07:00
Todd Poynor
60e5144ca3 libc: remove obsolete CLOCK_REALTIME_HR and CLOCK_MONOTONIC_HR
Add CLOCK_MONOTONIC_RAW, CLOCK_REALTIME_COARSE, and CLOCK_MONOTONIC_COARSE
as supported by recent linux kernels.

Bug: 8895727
Change-Id: I3d415a2edbcf2928dd855e876337bf2239ac134a
2013-05-13 11:00:07 -07:00
Todd Poynor
b928bda83d libc: add clock ids CLOCK_REALTIME_ALARM and CLOCK_BOOTTIME_ALARM
Change-Id: I3bf934ab207e39b435e6b41a5fbe7eb318496dc0
2013-05-13 11:00:06 -07:00
The Android Automerger
5ff2b9aafd merge in master-release history after reset to master 2013-05-13 07:49:31 -07:00
Elliott Hughes
a28cb8bd35 am 30d7485d: am 738370d9: Don\'t fail to run DT_INIT and DT_INIT_ARRAY constructors if a shared library has DT_PREINIT_ARRAY constructors.
* commit '30d7485dd30a06e2fb7b8134b6e1a3ecb0ac7ba7':
  Don't fail to run DT_INIT and DT_INIT_ARRAY constructors if a shared library has DT_PREINIT_ARRAY constructors.
2013-05-10 03:06:52 -07:00
Elliott Hughes
30d7485dd3 am 738370d9: Don\'t fail to run DT_INIT and DT_INIT_ARRAY constructors if a shared library has DT_PREINIT_ARRAY constructors.
* commit '738370d9387396922c10910edb61272e585be107':
  Don't fail to run DT_INIT and DT_INIT_ARRAY constructors if a shared library has DT_PREINIT_ARRAY constructors.
2013-05-09 23:40:47 -07:00
Elliott Hughes
a74e6c21e7 am 58f3dbda: am 98f7659d: Merge "Don\'t fail to run DT_INIT and DT_INIT_ARRAY constructors if a shared library has DT_PREINIT_ARRAY constructors."
* commit '58f3dbdacd496838661affce358518e0b3a4f7f6':
  Don't fail to run DT_INIT and DT_INIT_ARRAY constructors if a shared library has DT_PREINIT_ARRAY constructors.
2013-05-09 17:56:31 -07:00
Elliott Hughes
58f3dbdacd am 98f7659d: Merge "Don\'t fail to run DT_INIT and DT_INIT_ARRAY constructors if a shared library has DT_PREINIT_ARRAY constructors."
* commit '98f7659d7e3a7d75c68a41299f6ee55d7d35c27b':
  Don't fail to run DT_INIT and DT_INIT_ARRAY constructors if a shared library has DT_PREINIT_ARRAY constructors.
2013-05-09 17:53:38 -07:00
Elliott Hughes
98f7659d7e Merge "Don't fail to run DT_INIT and DT_INIT_ARRAY constructors if a shared library has DT_PREINIT_ARRAY constructors." 2013-05-09 22:30:21 +00:00
Elliott Hughes
8147d3c284 Don't fail to run DT_INIT and DT_INIT_ARRAY constructors if a shared library has DT_PREINIT_ARRAY constructors.
The GNU dynamic linker silently ignores a DT_PREINIT_ARRAY section
in a shared library. We had ineffectual code that tried to report
an error, which I tried to fix but got wrong --- my version still
wouldn't report the error to the caller, but would prevent us from
continuing to call constructors.

Bug: 8825226
Change-Id: I4fd8450ecc44d8767a1cb808aeecfbfbfc77c070
2013-05-09 15:29:54 -07:00
Ben Cheng
3c2ab6ffbb am ca54ae44: am 262b7384: Adjust PC value in ARM stack trace.
* commit 'ca54ae44a4c8764028b3092f9f1cfdd619a94fa6':
  Adjust PC value in ARM stack trace.
2013-05-09 09:41:18 -07:00
Ben Cheng
ca54ae44a4 am 262b7384: Adjust PC value in ARM stack trace.
* commit '262b7384e4e691d42070a57472ecc64cf668c480':
  Adjust PC value in ARM stack trace.
2013-05-09 09:37:50 -07:00
The Android Automerger
0d4e9fe58a merge in master-release history after reset to master 2013-05-09 07:49:16 -07:00
Ben Cheng
a078f9dcf0 am 49f6e970: am ff220f70: Merge "Remove a spurious FIXME and unnecessary type cast."
* commit '49f6e9706202b5caef3a68690153a96baa14cab1':
  Remove a spurious FIXME and unnecessary type cast.
2013-05-08 15:04:56 -07:00
Ben Cheng
77a2932836 am 3353e653: am b9256ada: Merge "Adjust PC value in ARM stack trace."
* commit '3353e6535a6964c92c280c36c99e1493befa9dc0':
  Adjust PC value in ARM stack trace.
2013-05-08 15:04:56 -07:00
Nick Kralevich
f8867a5632 am 37cd8800: am d541ba17: Merge "Use restrict pointers for various libc functions."
* commit '37cd8800d532e5901cc3b332bc39d8580f2ba9ab':
  Use restrict pointers for various libc functions.
2013-05-08 15:04:55 -07:00
Ben Cheng
49f6e97062 am ff220f70: Merge "Remove a spurious FIXME and unnecessary type cast."
* commit 'ff220f70036178aa0d7dcf1cbc4825085a84441e':
  Remove a spurious FIXME and unnecessary type cast.
2013-05-08 13:26:12 -07:00
Ben Cheng
3353e6535a am b9256ada: Merge "Adjust PC value in ARM stack trace."
* commit 'b9256adab3aa7e7628d7bbd015132a511de7a43d':
  Adjust PC value in ARM stack trace.
2013-05-08 13:26:11 -07:00
Nick Kralevich
37cd8800d5 am d541ba17: Merge "Use restrict pointers for various libc functions."
* commit 'd541ba17197fd3ef1f60462e51261c4340369218':
  Use restrict pointers for various libc functions.
2013-05-08 13:26:11 -07:00
Ben Cheng
ff220f7003 Merge "Remove a spurious FIXME and unnecessary type cast." 2013-05-07 23:56:11 +00:00
Ben Cheng
63dd03cced Remove a spurious FIXME and unnecessary type cast.
Change-Id: I05dcefdec7f047bef7eef5c5ceb7453992d56c24
2013-05-07 16:53:33 -07:00
Ben Cheng
b9256adab3 Merge "Adjust PC value in ARM stack trace." 2013-05-07 22:45:42 +00:00
Ben Cheng
52171b9bdc Adjust PC value in ARM stack trace.
-2 for Thumb BLX(2) or -4 for the rest.

Change-Id: I804fdabfa1db4709bede222d4b432e8d42d53167
2013-05-07 15:44:13 -07:00
Nick Kralevich
d541ba1719 Merge "Use restrict pointers for various libc functions." 2013-05-07 17:37:48 +00:00
Nick Kralevich
1c462b7a04 Use restrict pointers for various libc functions.
All the cool kids say this is the best thing since sliced bread.
http://cellperformance.beyond3d.com/articles/2006/05/demystifying-the-restrict-keyword.html

For the most part, these changes match what glibc does.

Change-Id: I176268f27f82800162fe5f2515b08d5469ea2dfe
2013-05-07 10:00:21 -07:00
The Android Automerger
237ac7be01 merge in master-release history after reset to master 2013-05-06 07:49:08 -07:00
Christopher Ferris
a14f7933f4 Merge "Tune the memcpy for krait." 2013-05-03 23:12:18 +00:00
The Android Automerger
e68c711e78 merge in master-release history after reset to master 2013-05-03 07:49:10 -07:00
Nick Kralevich
f0c9683e17 am c9757ac8: am b01f7afd: Merge "Use __predict_false on some fortify methods."
* commit 'c9757ac81eb48f9cfee0ba7833fed8a3363ecee2':
  Use __predict_false on some fortify methods.
2013-05-02 15:00:41 -07:00
Nick Kralevich
c9757ac81e am b01f7afd: Merge "Use __predict_false on some fortify methods."
* commit 'b01f7afd5fd5df5f8fe925b4fe493269191b62a2':
  Use __predict_false on some fortify methods.
2013-05-02 14:56:37 -07:00
Nick Kralevich
b01f7afd5f Merge "Use __predict_false on some fortify methods." 2013-05-02 21:52:19 +00:00
Nick Kralevich
532d6f09b1 Use __predict_false on some fortify methods.
Give the compiler some hints that these error conditions
are unlikely to occur in practice.

Change-Id: Ifaf7322a12120ef663c8315c1a18c2dcbe4bda23
2013-05-02 14:31:51 -07:00
Nick Kralevich
137a9ad176 am 4f614a70: am e4ac8feb: Merge "libc: cleanup strchr"
* commit '4f614a7036b37480695884a4be3f3fe70188cd60':
  libc: cleanup strchr
2013-05-02 14:28:18 -07:00
Nick Kralevich
4f614a7036 am e4ac8feb: Merge "libc: cleanup strchr"
* commit 'e4ac8feb58ed1f963db9a1f32fa74a06a1f594f2':
  libc: cleanup strchr
2013-05-02 14:25:42 -07:00
Nick Kralevich
e4ac8feb58 Merge "libc: cleanup strchr" 2013-05-02 21:17:16 +00:00
Christopher Ferris
4d8fe5177e Tune the memcpy for krait.
Streamline the memcpy a bit removing some unnecessary instructions.

The biggest speed improvement comes from changing the size of
the preload. On krait, the sweet spot for the preload in the main
loop is twice the L1 cache line size.

In most cases, these small tweaks yield > 1000MB/s speed ups. As
the size of the memcpy approaches about 1MB, the speed improvement
disappears.

Change-Id: Ief79694d65324e2db41bee4707dae19b8c24be62
2013-05-02 14:04:31 -07:00
Nick Kralevich
4f40e511b0 libc: cleanup strchr
Move strchr to a .cpp file, and change to bionic directory.

Change-Id: I64ade7df326c0a9a714aca4caf5647b6833b1c97
2013-05-02 13:58:03 -07:00
The Android Automerger
2a9966da82 merge in master-release history after reset to master 2013-05-02 07:49:13 -07:00
Nick Kralevich
240bc95be1 am 65fe3ea7: am 5e3b502b: Merge "keep test names consistent with other tests."
* commit '65fe3ea708bf16ebaa354080b90b6e6c83a24e70':
  keep test names consistent with other tests.
2013-05-01 15:11:32 -07:00
Nick Kralevich
874ea191de am b9aab3a4: am 8c00c91a: Merge "add strrchr -D_FORTIFY_SOURCE=2 test."
* commit 'b9aab3a462efb79cdae83d9b819e299216f9cf5f':
  add strrchr -D_FORTIFY_SOURCE=2 test.
2013-05-01 15:11:32 -07:00
Nick Kralevich
65fe3ea708 am 5e3b502b: Merge "keep test names consistent with other tests."
* commit '5e3b502b6b56634953ea152409363088974fa5e9':
  keep test names consistent with other tests.
2013-05-01 15:10:07 -07:00
Nick Kralevich
b9aab3a462 am 8c00c91a: Merge "add strrchr -D_FORTIFY_SOURCE=2 test."
* commit '8c00c91aa051f18e107466b5d8c9280a2e1fabc1':
  add strrchr -D_FORTIFY_SOURCE=2 test.
2013-05-01 15:10:07 -07:00
Nick Kralevich
5e3b502b6b Merge "keep test names consistent with other tests." 2013-05-01 22:06:15 +00:00
Nick Kralevich
277226bf43 keep test names consistent with other tests.
Change-Id: I23dc4d963af40406b270af83cd17f6c8c95f1de3
2013-05-01 15:05:01 -07:00
Nick Kralevich
8c00c91aa0 Merge "add strrchr -D_FORTIFY_SOURCE=2 test." 2013-05-01 22:01:20 +00:00
Nick Kralevich
80541922e3 add strrchr -D_FORTIFY_SOURCE=2 test.
Change-Id: I1b95bb0086ae9f2f506f3cc90cee834c0ce3b1d8
2013-05-01 14:55:33 -07:00
The Android Automerger
33cd3f6848 merge in master-release history after reset to master 2013-05-01 07:49:28 -07:00
Nick Kralevich
6c6949fc00 am 8355ab55: am bee0ab16: Merge "libc: upgrade strrchr to FORTIFY_SOURCE=2"
* commit '8355ab5524557da2737ea9084a8131c1015ae14f':
  libc: upgrade strrchr to FORTIFY_SOURCE=2
2013-04-30 16:30:20 -07:00
Nick Kralevich
8355ab5524 am bee0ab16: Merge "libc: upgrade strrchr to FORTIFY_SOURCE=2"
* commit 'bee0ab16e47086d2f31f6f9ff41328066d5a7128':
  libc: upgrade strrchr to FORTIFY_SOURCE=2
2013-04-30 16:25:23 -07:00
Nick Kralevich
bee0ab16e4 Merge "libc: upgrade strrchr to FORTIFY_SOURCE=2" 2013-04-30 23:13:04 +00:00
Nick Kralevich
3b2e6bc9ac libc: upgrade strrchr to FORTIFY_SOURCE=2
Change-Id: I4c34c2ce22c5092c4446dc1ab55f37604c1c223f
2013-04-30 14:19:23 -07:00
Nick Kralevich
c9bf778112 am 2ff94a09: am c4687130: Merge "libc: upgrade some libc functions to _FORTIFY_SOURCE=2"
* commit '2ff94a096427a5b5e729ae356c98463c9a9dabf1':
  libc: upgrade some libc functions to _FORTIFY_SOURCE=2
2013-04-30 11:57:22 -07:00
Nick Kralevich
2ff94a0964 am c4687130: Merge "libc: upgrade some libc functions to _FORTIFY_SOURCE=2"
* commit 'c46871302e7bd099aaf54d91da93a2248acbf733':
  libc: upgrade some libc functions to _FORTIFY_SOURCE=2
2013-04-30 11:56:08 -07:00
Nick Kralevich
c46871302e Merge "libc: upgrade some libc functions to _FORTIFY_SOURCE=2" 2013-04-30 18:51:22 +00:00
Nick Kralevich
9020fd503c libc: upgrade some libc functions to _FORTIFY_SOURCE=2
Upgrade the following functions:

* vsnprintf
* vsprintf
* snprintf
* fgets
* strcpy
* strcat
* strncat
* strlcpy
* strlcat
* strlen
* strchr

Change-Id: Icc036fc7f0bb317e05f7c051617887a1601271aa
2013-04-30 11:31:35 -07:00
The Android Automerger
3fa53b5978 merge in master-release history after reset to master 2013-04-30 10:23:01 -07:00
Nick Kralevich
d411fbd497 am aed0c3ac: am b94b2851: Merge "libc: upgrade sprintf to _FORTIFY_SOURCE=2"
* commit 'aed0c3ac54fa944b1f8512938277e7dc6b6fa2ee':
  libc: upgrade sprintf to _FORTIFY_SOURCE=2
2013-04-30 08:54:30 -07:00
Nick Kralevich
90a293f7d3 am 56a1b492: am 382a7753: Merge "strncpy: implement _FORTIFY_SOURCE=2"
* commit '56a1b492c40b51204ad1b46a6b46819775c8912a':
  strncpy: implement _FORTIFY_SOURCE=2
2013-04-30 08:54:28 -07:00
Nick Kralevich
780cf25bf4 am 89357dc7: am c6dc62f0: Merge "[NETFILTER]: Fix iptables ABI breakage"
* commit '89357dc730f6bfd532c4aed80373c84904cc3319':
  [NETFILTER]: Fix iptables ABI breakage
2013-04-30 08:46:47 -07:00
Nick Kralevich
aed0c3ac54 am b94b2851: Merge "libc: upgrade sprintf to _FORTIFY_SOURCE=2"
* commit 'b94b2851d72187cc9095864a9c99429ee62d7786':
  libc: upgrade sprintf to _FORTIFY_SOURCE=2
2013-04-29 16:56:29 -07:00
Nick Kralevich
b94b2851d7 Merge "libc: upgrade sprintf to _FORTIFY_SOURCE=2" 2013-04-29 23:50:46 +00:00
Nick Kralevich
78d6d9888c libc: upgrade sprintf to _FORTIFY_SOURCE=2
Upgrade sprintf to fortify_source level 2, to catch
additional security bugs.

Change-Id: Ibc957d65e4cb96152de84b3745a04e00fa22659e
2013-04-29 16:41:54 -07:00
Nick Kralevich
56a1b492c4 am 382a7753: Merge "strncpy: implement _FORTIFY_SOURCE=2"
* commit '382a7753786646483a8101f4e337f9e3a82ec852':
  strncpy: implement _FORTIFY_SOURCE=2
2013-04-29 16:25:41 -07:00
Nick Kralevich
382a775378 Merge "strncpy: implement _FORTIFY_SOURCE=2" 2013-04-29 23:07:33 +00:00
Nick Kralevich
1aae9bd170 strncpy: implement _FORTIFY_SOURCE=2
Add support for fortify source level 2 to strncpy.
This will enable detection of more areas where strncpy
is used inappropriately. For example, this would have detected
bug 8727221.

Move the fortify_source tests out of string_test.cpp, and
put it into fortify1_test.cpp.

Create a new fortify2_test.cpp file, which copies all
the tests in fortify1_test.cpp, and adds fortify_source level
2 specific tests.

Change-Id: Ica0fba531cc7d0609e4f23b8176739b13f7f7a83
2013-04-29 15:22:10 -07:00
Nick Kralevich
89357dc730 am c6dc62f0: Merge "[NETFILTER]: Fix iptables ABI breakage"
* commit 'c6dc62f09c814b9688aee83e80dcfe80cb0ef604':
  [NETFILTER]: Fix iptables ABI breakage
2013-04-29 12:51:35 -07:00
Nick Kralevich
c6dc62f09c Merge "[NETFILTER]: Fix iptables ABI breakage" 2013-04-29 19:44:30 +00:00
Nick Kralevich
e66ad7809e [NETFILTER]: Fix iptables ABI breakage
Pick up Linux kernel patch 2748e5dec7ca8a3804852c7c4171f9156384d15c
from 2007

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=2748e5dec7ca8a3804852c7c4171f9156384d15c

[NETFILTER]: Fix iptables ABI breakage on (at least) CRIS
With the introduction of x_tables we accidentally broke compatibility
by defining IPT_TABLE_MAXNAMELEN to XT_FUNCTION_MAXNAMELEN instead of
XT_TABLE_MAXNAMELEN, which is two bytes larger.

On most architectures it doesn't really matter since we don't have
any tables with names that long in the kernel and the structure
layout didn't change because of alignment requirements of following
members. On CRIS however (and other architectures that don't align
data) this changed the structure layout and thus broke compatibility
with old iptables binaries.

Changing it back will break compatibility with binaries compiled
against recent kernels again, but since the breakage has only been
there for three releases this seems like the better choice.

Change-Id: Ie9552b25892109c7042b9752132dc8ebd3552dc3
2013-04-29 12:31:01 -07:00
Andrew Hsieh
cfb0b8bd5e am 83966db8: am f7153fd1: Merge "Remove redundant space within square brackets"
* commit '83966db80b9cccc3417db7566242d30a330cde29':
  Remove redundant space within square brackets
2013-04-25 21:26:46 -07:00
Andrew Hsieh
83966db80b am f7153fd1: Merge "Remove redundant space within square brackets"
* commit 'f7153fd13f469e9ba5aecbfa00fde42530ca2124':
  Remove redundant space within square brackets
2013-04-25 21:22:26 -07:00
Elliott Hughes
b03dc7cfa3 am 9aa57e09: am 9ff1ffd8: Merge "Improve diagnostics in the face of bad tzdata."
* commit '9aa57e09ef7234b6d82ffa4a4889508e64e424b9':
  Improve diagnostics in the face of bad tzdata.
2013-04-25 21:19:48 -07:00
Nick Kralevich
95a46909c7 am ed572aaa: am 5f28fde8: Merge "linker: only re-open std* for setuid programs."
* commit 'ed572aaa0d275eed753afd4b92e05991310e76ac':
  linker: only re-open std* for setuid programs.
2013-04-25 21:19:48 -07:00
Andrew Hsieh
f7153fd13f Merge "Remove redundant space within square brackets" 2013-04-26 01:54:38 +00:00
Elliott Hughes
9aa57e09ef am 9ff1ffd8: Merge "Improve diagnostics in the face of bad tzdata."
* commit '9ff1ffd805b57160079f42d7eea051c63e0e2bca':
  Improve diagnostics in the face of bad tzdata.
2013-04-25 17:01:42 -07:00
Nick Kralevich
ed572aaa0d am 5f28fde8: Merge "linker: only re-open std* for setuid programs."
* commit '5f28fde8aeee047a70e344c9da937695dc51a3ba':
  linker: only re-open std* for setuid programs.
2013-04-25 17:01:41 -07:00
Elliott Hughes
9ff1ffd805 Merge "Improve diagnostics in the face of bad tzdata." 2013-04-25 22:31:14 +00:00
Elliott Hughes
e7aaad8b83 Improve diagnostics in the face of bad tzdata.
Bug: 8373554
Change-Id: If8df5e956105e01cce95221ff0a7fa9d2b474db3
2013-04-25 14:02:59 -07:00
Nick Kralevich
5f28fde8ae Merge "linker: only re-open std* for setuid programs." 2013-04-25 20:31:41 +00:00
Nick Kralevich
8d3e91d4f8 linker: only re-open std* for setuid programs.
get_AT_SECURE() was getting called before linker_env_init() had
been called, and returning the default value ("true"). This was
causing us to reopen closed stdin, stdout, and stderr for ALL
processes, not just privileged (setuid) processes.

Calling path:
  - __linker_init
    - soinfo_link_image
      - get_AT_SECURE
    - __linker_init_post_relocation
      - linker_env_init

This change restores the intended behavior of only re-opening
stdin, stdout, and stderr for privileged processes.

Change-Id: I8b085ea6597710ac4c1a3c93f1bf8b81eecb08c0
2013-04-25 13:15:24 -07:00
The Android Automerger
59f27ec089 merge in master-release history after reset to master 2013-04-25 07:49:12 -07:00
Andrew Hsieh
e8f46e8edd Remove redundant space within square brackets
The new "as" in binutils-2.23 (with gcc4.8) is more picky:
it expects register right after [

Change-Id: I876124841582070ab2083ffafe38bc333b5812d0
2013-04-25 15:05:03 +08:00
Elliott Hughes
baa836baa4 am eb22fc33: am 389b5c1e: Upgrade to tzdata2013c.
* commit 'eb22fc331ed1bff5ee146c252fb4b9fa7f198523':
  Upgrade to tzdata2013c.
2013-04-24 14:28:10 -07:00
Elliott Hughes
eb22fc331e am 389b5c1e: Upgrade to tzdata2013c.
* commit '389b5c1ee52cbf0de4dcdfe266832d251f55db62':
  Upgrade to tzdata2013c.
2013-04-24 14:25:33 -07:00
Elliott Hughes
537e1aa9c6 am b6e895e8: am 87efcd2e: Merge "Don\'t avoid IPv6 when looking for new tzdata."
* commit 'b6e895e80f96301b3921a2ec7327c337ab988b41':
  Don't avoid IPv6 when looking for new tzdata.
2013-04-24 11:01:28 -07:00
Elliott Hughes
b6e895e80f am 87efcd2e: Merge "Don\'t avoid IPv6 when looking for new tzdata."
* commit '87efcd2e63c9f218f476ef88f21e660f9bce633f':
  Don't avoid IPv6 when looking for new tzdata.
2013-04-24 10:58:37 -07:00
Elliott Hughes
87efcd2e63 Merge "Don't avoid IPv6 when looking for new tzdata." 2013-04-24 17:52:29 +00:00
Elliott Hughes
85aeb49144 Don't avoid IPv6 when looking for new tzdata.
Our internal IPv6 FTP networking problems have been fixed.

Change-Id: I9949a13fa20a3b0f3845e565e1461320078d3f14
2013-04-24 10:50:45 -07:00
The Android Automerger
70ef50862c merge in master-release history after reset to master 2013-04-23 07:49:08 -07:00
Elliott Hughes
14cbb15b99 am 41dcafc2: am c705daa0: Merge "Disable IPv6 when looking for tzdata updates."
* commit '41dcafc27627dbc79e492056799b3cde4056d412':
  Disable IPv6 when looking for tzdata updates.
2013-04-22 16:57:46 -07:00
Elliott Hughes
41dcafc276 am c705daa0: Merge "Disable IPv6 when looking for tzdata updates."
* commit 'c705daa0a2684d31b8ddc9230e7aa5573880adef':
  Disable IPv6 when looking for tzdata updates.
2013-04-22 16:55:59 -07:00
Elliott Hughes
c705daa0a2 Merge "Disable IPv6 when looking for tzdata updates." 2013-04-22 23:41:37 +00:00
Elliott Hughes
21da42ea91 Disable IPv6 when looking for tzdata updates.
My problems connecting to ftp.iana.org are only via IPv6.

Change-Id: I42e4bae7981ec4b64822f745a7a15544d77ef22d
2013-04-22 13:44:50 -07:00
Elliott Hughes
dd15d3cb28 am dc7e8b89: am 2c60c18c: Merge "Upgrade to tzdata2013c."
* commit 'dc7e8b892db0e997c12a6574ee2468cb3f8a6a2c':
  Upgrade to tzdata2013c.
2013-04-22 12:29:42 -07:00
Elliott Hughes
dc7e8b892d am 2c60c18c: Merge "Upgrade to tzdata2013c."
* commit '2c60c18c505491631a07380f80438fafa80d39f0':
  Upgrade to tzdata2013c.
2013-04-22 12:27:17 -07:00
Elliott Hughes
6180ab7850 am 4f89ab31: am bda2fb5e: Merge "Add signature checking to HTTP tzdata updates."
* commit '4f89ab3166586378d448ca8d5eb4688ab33bb28b':
  Add signature checking to HTTP tzdata updates.
2013-04-22 12:14:04 -07:00
Elliott Hughes
4f89ab3166 am bda2fb5e: Merge "Add signature checking to HTTP tzdata updates."
* commit 'bda2fb5efab914e8442ec9c38961b7182ac5978c':
  Add signature checking to HTTP tzdata updates.
2013-04-22 12:11:48 -07:00
Elliott Hughes
2c60c18c50 Merge "Upgrade to tzdata2013c." 2013-04-22 19:10:08 +00:00
Elliott Hughes
bda2fb5efa Merge "Add signature checking to HTTP tzdata updates." 2013-04-22 19:03:06 +00:00
Elliott Hughes
676e66db25 Add signature checking to HTTP tzdata updates.
Change-Id: Idcfd217eb215d6a170e6884be8d8ad28cd4fe70d
2013-04-22 11:41:57 -07:00
Elliott Hughes
652c68c50e am 9f10e6a9: am 70e0bd3a: Merge "Rename the tzdata update tool, and add HTTP support."
* commit '9f10e6a96afbe85239d18c1cffb560c4f6ae9b4d':
  Rename the tzdata update tool, and add HTTP support.
2013-04-22 11:36:51 -07:00
Elliott Hughes
9f10e6a96a am 70e0bd3a: Merge "Rename the tzdata update tool, and add HTTP support."
* commit '70e0bd3a448fc345d75d16caf40babf36463f0ec':
  Rename the tzdata update tool, and add HTTP support.
2013-04-22 11:34:48 -07:00
Elliott Hughes
2379088a90 Upgrade to tzdata2013c.
From the release notes:

  Changes affecting current and future time stamps:

    Palestine observed DST starting March 29, 2013.  (Thanks to
    Steffen Thorsen.)  From 2013 on, Gaza and Hebron both observe DST,
    with the predicted rules being the last Thursday in March at 24:00
    to the first Friday on or after September 21 at 01:00.

    Assume that the recent change to Paraguay's DST rules is permanent,
    by moving the end of DST to the 4th Sunday in March every year.
    (Thanks to Carlos Raúl Perasso.)

  Changes affecting past time stamps:

    Fix some historical data for Palestine to agree with that of
    timeanddate.com, as follows:

          The spring 2008 change in Gaza and Hebron was on 00:00 Mar 28, not
          00:00 Apr 1.

          The fall 2009 change in Gaza and Hebron on Sep 4 was at 01:00, not
          02:00.

          The spring 2010 change in Hebron was 00:00 Mar 26, not 00:01 Mar 27.

          The spring 2011 change in Gaza was 00:01 Apr 1, not 12:01 Apr 2.

          The spring 2011 change in Hebron on Apr 1 was at 00:01, not 12:01.

          The fall 2011 change in Hebron on Sep 30 was at 00:00, not 03:00.

    Fix times of habitation for Macquarie to agree with the Tasmania
    Parks & Wildlife Service history, which indicates that permanent
    habitation was 1899-1919 and 1948 on.

  Changing affecting metadata only:

    Macquarie Island is politically part of Australia, not Antarctica.
    (Thanks to Tobias Conradi.)

    Sort Macquarie more-consistently with other parts of Australia.
    (Thanks to Tim Parenti.)

Change-Id: I3df146d046eda26dbc6ce2a0a26ad9214ec4eaca
2013-04-22 11:33:14 -07:00
Elliott Hughes
70e0bd3a44 Merge "Rename the tzdata update tool, and add HTTP support." 2013-04-22 18:28:49 +00:00
Elliott Hughes
f8dff7d449 Rename the tzdata update tool, and add HTTP support.
The FTP server is currently unavailable, but the HTTP server is working
fine.

Change-Id: If7f2f396e89aca022a60af531f3604523b7bf95c
2013-04-22 11:11:43 -07:00
The Android Automerger
c689ed1ef7 merge in master-release history after reset to master 2013-04-16 07:49:11 -07:00
Elliott Hughes
9a41d425ea am d23a87d3: am 8c181aa8: Merge "Use hidden visibility for internal-use-only functions"
* commit 'd23a87d3b1c7269a4b55f082555790a3003ba228':
  Use hidden visibility for internal-use-only functions
2013-04-15 11:26:47 -07:00
Elliott Hughes
d23a87d3b1 am 8c181aa8: Merge "Use hidden visibility for internal-use-only functions"
* commit '8c181aa8fe421c62a8e30f4c10e322aca968c27c':
  Use hidden visibility for internal-use-only functions
2013-04-15 11:24:14 -07:00
Elliott Hughes
8c181aa8fe Merge "Use hidden visibility for internal-use-only functions" 2013-04-15 17:51:24 +00:00
The Android Automerger
94dcdb0352 merge in master-release history after reset to master 2013-04-15 07:49:20 -07:00
Christopher Ferris
5274339979 am 39e4ed96: am 516a8970: Merge "Rewrite memset for cortexa15 to use strd."
* commit '39e4ed969948fd738d7b670b099c0b2c25351d95':
  Rewrite memset for cortexa15 to use strd.
2013-04-12 12:33:57 -07:00
Elliott Hughes
35a2a61d49 am cf4a5302: am b3c8c4d8: Merge "Switch to current FreeBSD qsort."
* commit 'cf4a53020d85b0017799c31dc41823f9e775a1c5':
  Switch to current FreeBSD qsort.
2013-04-12 12:33:56 -07:00
Christopher Ferris
39e4ed9699 am 516a8970: Merge "Rewrite memset for cortexa15 to use strd."
* commit '516a89705378f43646678e75924529404e52b613':
  Rewrite memset for cortexa15 to use strd.
2013-04-12 12:30:22 -07:00
Elliott Hughes
cf4a53020d am b3c8c4d8: Merge "Switch to current FreeBSD qsort."
* commit 'b3c8c4d8654894cdc72d32bde84a520ccda4d8f3':
  Switch to current FreeBSD qsort.
2013-04-12 12:30:22 -07:00
Christopher Ferris
516a897053 Merge "Rewrite memset for cortexa15 to use strd." 2013-04-12 19:16:44 +00:00
Elliott Hughes
b3c8c4d865 Merge "Switch to current FreeBSD qsort." 2013-04-12 19:12:29 +00:00
Christopher Ferris
796cbe249b Rewrite memset for cortexa15 to use strd.
Merge from internal master.

(cherry-picked from commit 7ffad9c120)

Change-Id: Ia67f2a545399f4fa37b63d5634a3565e4f5482f9
2013-04-12 10:58:25 -07:00
The Android Automerger
5703eb8007 merge in master-release history after reset to master 2013-04-12 07:49:26 -07:00
Kito Cheng
ea489745dc Use hidden visibility for internal-use-only functions
- malloc_debug_init and malloc_debug_fini

Change-Id: I4261ff428a50d8f0371415cda71bcc0a9487ce67
2013-04-12 16:34:38 +08:00
Elliott Hughes
0b25f633a2 Switch to current FreeBSD qsort.
Change-Id: Ic46cd0b663dc5fa78c99dd38db0bfe849a25e789
2013-04-11 18:08:34 -07:00
Elliott Hughes
a1826f6e59 am 5fe62e50: am ed36d95f: Merge "Start moving to current FreeBSD stdio."
* commit '5fe62e50f61b353657e1cd9cc6b1b1fc02870c9b':
  Start moving to current FreeBSD stdio.
2013-04-11 14:58:37 -07:00
Elliott Hughes
5fe62e50f6 am ed36d95f: Merge "Start moving to current FreeBSD stdio."
* commit 'ed36d95fac5881f78a601e2932f51edfd27c6ba6':
  Start moving to current FreeBSD stdio.
2013-04-11 14:24:37 -07:00
Elliott Hughes
ed36d95fac Merge "Start moving to current FreeBSD stdio." 2013-04-11 21:18:14 +00:00
Elliott Hughes
6b05c8e280 Start moving to current FreeBSD stdio.
This only touches the easy stuff.

Change-Id: Iecee57f1681dba5c56bff59f0e9a89811a71f0ca
2013-04-11 13:55:01 -07:00
The Android Automerger
651b3e1f9e merge in master-release history after reset to master 2013-04-11 09:22:10 -07:00
The Android Open Source Project
6c48aca345 am ab911a02: Reconcile with jb-mr2-release - do not merge
* commit 'ab911a02af2a5c3977b55cb0994f74635edc7c3a':
2013-04-11 07:47:08 -07:00
The Android Open Source Project
ab911a02af Reconcile with jb-mr2-release - do not merge
Change-Id: I15e9944781325d7a44f0d40ab078aec7723ce9ac
2013-04-11 07:44:55 -07:00
Elliott Hughes
980d21745c am 76db50dd: am b632857a: Merge "Add missing include and function prototype for sched_getaffinity."
* commit '76db50ddc948541d39bfc351666ba910bd8e6bab':
  Add missing include and function prototype for sched_getaffinity.
2013-04-10 18:22:50 -07:00
Christopher Ferris
b9cfe21c6e am 101dadf6: am fc76c7d3: Merge "Add missing branch in memcpy.S dst aligned case."
* commit '101dadf6a6a689b53f6db809578627448a14bff8':
  Add missing branch in memcpy.S dst aligned case.
2013-04-10 18:22:48 -07:00
Elliott Hughes
76db50ddc9 am b632857a: Merge "Add missing include and function prototype for sched_getaffinity."
* commit 'b632857a50a1fd2b759316d07ace6c36f6f418cf':
  Add missing include and function prototype for sched_getaffinity.
2013-04-10 17:56:22 -07:00
Christopher Ferris
dbc23ea51c resolved conflicts for merge of 3fe5b109 to master
Change-Id: Ifeecc0f8b0935ee1df057e944fc135d5047e248d
2013-04-10 17:54:53 -07:00
Elliott Hughes
b632857a50 Merge "Add missing include and function prototype for sched_getaffinity." 2013-04-11 00:45:33 +00:00
Kito Cheng
4ca685e36e Add missing include and function prototype for sched_getaffinity.
Change-Id: I649633c8d074def5d05bd0c8b92fb680d9d11d51
2013-04-10 17:44:29 -07:00
Christopher Ferris
101dadf6a6 am fc76c7d3: Merge "Add missing branch in memcpy.S dst aligned case."
* commit 'fc76c7d394ebe0e585777955efadf7cc8ed86636':
  Add missing branch in memcpy.S dst aligned case.
2013-04-10 17:37:49 -07:00
Christopher Ferris
3fe5b10948 am 68fd78ef: Merge "Update to latest cortexa15 memcpy code."
* commit '68fd78efa05fc61adfbdeadeb757caa45663570c':
  Update to latest cortexa15 memcpy code.
2013-04-10 17:37:49 -07:00
Christopher Ferris
fc76c7d394 Merge "Add missing branch in memcpy.S dst aligned case." 2013-04-11 00:23:46 +00:00
Christopher Ferris
bf0d1ad72b Add missing branch in memcpy.S dst aligned case.
Merge from internal master.

(cherry-picked from commit 6ffaa931c3)

Change-Id: Ifdcf01fd122866cf0d4c5b5f7a997803561d7889
2013-04-10 17:21:29 -07:00
Christopher Ferris
68fd78efa0 Merge "Update to latest cortexa15 memcpy code." 2013-04-11 00:18:04 +00:00
Eric Laurent
61735a9069 am 55c015cd: am ccaa0fa6: sound: Add ALSA compressed API headers
* commit '55c015cddd4d8d14e58e7134ae077d637ff5388e':
  sound: Add ALSA compressed API headers
2013-04-10 11:34:31 -07:00
Eric Laurent
55c015cddd am ccaa0fa6: sound: Add ALSA compressed API headers
* commit 'ccaa0fa6e90421831fa589e60f4e7ef6df39bd04':
  sound: Add ALSA compressed API headers
2013-04-10 11:31:08 -07:00
The Android Automerger
7b1d164a4e merge in master-release history after reset to master 2013-04-10 07:49:16 -07:00
Christopher Ferris
e27483c788 Merge "Rewrite memset for cortexa15 to use strd." 2013-04-09 22:58:26 +00:00
Christopher Ferris
7ffad9c120 Rewrite memset for cortexa15 to use strd.
Change-Id: Iac3af55f7813bd2b40a41bd19403f2b4dca5224b
2013-04-08 18:48:46 -07:00
Christopher Ferris
185ce72d00 Update to latest cortexa15 memcpy code.
This uses the new code original submitted as memcpy.a15.S as
the base. However, the old code handled unaligned src/dst better
so that was spliced in. I optimized the original unaligned code by
removing a few unnecessary instructions. I optimized the a15 code by
rewriting the pre and post code. I also modified the main loop to add
a pld so that larger copies would not stall waiting for memory.

Test cases for the new memcpy:

- Copy all sized values from 0 to 1024 bytes, using whatever alignment
  is returned by malloc.
For each alignment case described below, the test copied from 0 to 128
bytes.
- Src and dst pointers are both aligned to the same value, starting
  at one going through every power of two up to and including 128.
- Src aligned to double word boundary, dst aligned to word boundary.
- Src aligned to word boundary, dst aligned to double word boundary.
- Src aligned to 16 bit boundary, dst aligned to word boundary.
- Src aligned to word boundary, dst aligned to 16 byte boundary.
- Src aligned to word boundary, dst aligned to 1 byte from a word
  boundary.
- Src aligned to word boundary, dst aligned to 2 bytes from a word
  boundary.
- Src aligned to word boundary, dst aligned to 3 bytes from a word
  boundary.
- Src aligned to 1 byte from a word boundary, dst aligned to a word
  boundary.
- Src aligned to 2 bytes from a word boundary, dst aligned to a word
  boundary.
- Src aligned to 3 bytes from a word boundary, dst aligned to a word
  boundary.

Cases to verify the unaligned source code properly aligns to a 16 bit
boundary.
- Src aligned to 1 byte from a 128 bit boundary, dst aligned to
  4 + 128 bit boundary.
- Src aligned to 1 byte from a 128 bit boundary, dst aligned to
  8 + 128 bit boundary.
- Src aligned to 1 byte from a 128 bit boundary, dst aligned to
  12 + 128 bit boundary.
- Src aligned to 1 byte from a 128 bit boundary, dst aligned to
  16 + 128 bit boundary.

In all cases, a two byte fencepost was placed at the end of the
destination to verify that only the requested number of bytes were copied.

Bug: 8005082

Merge from internal master.

(cherry-picked from commit 21ede92d79)

Change-Id: Ief70c9e6dc8c6473ae245b6570b2c266fed9618c
2013-04-08 18:13:35 -07:00
The Android Open Source Project
bc37bf00f8 am bb9842b6: Reconcile with jb-mr2-release - do not merge
* commit 'bb9842b61e188ed70cf9bfb0415f2ba8fb406937':
2013-04-08 13:40:28 -07:00
The Android Open Source Project
bb9842b61e Reconcile with jb-mr2-release - do not merge
Change-Id: I562a47cb4eb8222c26aff7652826752825b9a091
2013-04-08 13:35:31 -07:00
The Android Automerger
cad988dafb merge in master-release history after reset to master 2013-04-08 07:49:30 -07:00
Elliott Hughes
8bed98c3ce am fe7f46c0: am 7b4d77e4: Make abort messages available to debuggerd.
* commit 'fe7f46c088f303ea2cb9f6b218cc0f46f5385d43':
  Make abort messages available to debuggerd.
2013-04-05 16:07:15 -07:00
Elliott Hughes
fe7f46c088 am 7b4d77e4: Make abort messages available to debuggerd.
* commit '7b4d77e400d321ccc7cdadd1cd225ebb1a69d358':
  Make abort messages available to debuggerd.
2013-04-05 16:04:13 -07:00
Elliott Hughes
f89ce5b518 am 9c7b510a: am 240fb862: Merge "Make abort messages available to debuggerd."
* commit '9c7b510a408740b5b53f8d14b8f43bf2f2d36ae6':
  Make abort messages available to debuggerd.
2013-04-05 11:47:00 -07:00
Elliott Hughes
9c7b510a40 am 240fb862: Merge "Make abort messages available to debuggerd."
* commit '240fb8623b1fe027d0d33a9d4c41d99ceb385b58':
  Make abort messages available to debuggerd.
2013-04-05 11:43:37 -07:00
Elliott Hughes
240fb8623b Merge "Make abort messages available to debuggerd." 2013-04-05 18:25:21 +00:00
Elliott Hughes
0d787c1fa1 Make abort messages available to debuggerd.
This adds __libc_fatal, cleans up the internal logging code a bit more,
and switches suitable callers over to __libc_fatal. In addition to logging,
__libc_fatal stashes the message somewhere that the debuggerd signal handler
can find it before calling abort.

In the debuggerd signal handler, we pass this address to debuggerd so that
it can come back with ptrace to read the message and present it to the user.

Bug: 8531731
Change-Id: I416ec1da38a8a1b0d0a582ccd7c8aaa681ed4a29
2013-04-05 11:24:19 -07:00
The Android Automerger
291f5c1e4b merge in master-release history after reset to master 2013-04-04 07:49:14 -07:00
The Android Open Source Project
9207e5aed8 am cd6f4804: Reconcile with jb-mr2-release - do not merge
* commit 'cd6f4804d22a119c1aaf915d70a53924b1666777':
2013-04-03 18:05:26 -07:00
The Android Open Source Project
cd6f4804d2 Reconcile with jb-mr2-release - do not merge
Change-Id: I716c266ad98beb8523f0e4a4a04bbc326388fe93
2013-04-03 16:43:02 -07:00
Elliott Hughes
fbfedc7a7c am 13ab5591: am 014c75c7: Merge "Prevent name conflict for eventfd.cpp and eventfd.s when building libc.a"
* commit '13ab55918a0a114ce1d5c67eeca9c94ce08803ee':
  Prevent name conflict for eventfd.cpp and eventfd.s when building libc.a
2013-04-03 12:40:33 -07:00
Elliott Hughes
acec23561e am f5dc9086: am 14c840df: Merge "Fix the SYSCALLS.TXT documentation and remove a dead script."
* commit 'f5dc908695ad4e513504e1a29613d797b95adbf0':
  Fix the SYSCALLS.TXT documentation and remove a dead script.
2013-04-03 12:40:33 -07:00
Kito Cheng
98ac1d64bd am 4bc54686: am 9b84824d: Prevent name conflict for eventfd.cpp and eventfd.s when building libc.a
* commit '4bc546860ec36f7ed86ee1a6a7e2bf6db028f02a':
  Prevent name conflict for eventfd.cpp and eventfd.s when building libc.a
2013-04-03 12:40:32 -07:00
Elliott Hughes
f3810dbb0a am 57148994: am a69103ff: Fix the SYSCALLS.TXT documentation and remove a dead script.
* commit '57148994df6c3ca0d3c60abe2e1e891e7e12b39c':
  Fix the SYSCALLS.TXT documentation and remove a dead script.
2013-04-03 12:40:31 -07:00
Elliott Hughes
13ab55918a am 014c75c7: Merge "Prevent name conflict for eventfd.cpp and eventfd.s when building libc.a"
* commit '014c75c78bdcad8acde8d0abb2450aa1f78e1a1f':
  Prevent name conflict for eventfd.cpp and eventfd.s when building libc.a
2013-04-03 12:37:52 -07:00
Elliott Hughes
f5dc908695 am 14c840df: Merge "Fix the SYSCALLS.TXT documentation and remove a dead script."
* commit '14c840df90bb4fc9935f7e24350e3269b6bd7f17':
  Fix the SYSCALLS.TXT documentation and remove a dead script.
2013-04-03 12:37:51 -07:00
Kito Cheng
4bc546860e am 9b84824d: Prevent name conflict for eventfd.cpp and eventfd.s when building libc.a
* commit '9b84824dfd597d8137137fa33295faa26cc70ae0':
  Prevent name conflict for eventfd.cpp and eventfd.s when building libc.a
2013-04-03 12:35:49 -07:00
Elliott Hughes
57148994df am a69103ff: Fix the SYSCALLS.TXT documentation and remove a dead script.
* commit 'a69103ffe4b3d55f5bab7e7bfba36ccecddfa4da':
  Fix the SYSCALLS.TXT documentation and remove a dead script.
2013-04-03 12:35:49 -07:00
Elliott Hughes
014c75c78b Merge "Prevent name conflict for eventfd.cpp and eventfd.s when building libc.a" 2013-04-03 18:11:30 +00:00
Kito Cheng
8baa929d5d Prevent name conflict for eventfd.cpp and eventfd.s when building libc.a
- eventfd.cpp and eventfd.s will output to the same file when building libc.a
   out/target/product/*/obj/STATIC_LIBRARIES/libc_intermediates/WHOLE/libc_common_objs/eventfd.o
 - And then `eventfd` will undefined when statically linked to libc.

Also add a unit test.

Change-Id: Ib310ade3256712ca617a90539e8eb07459c98505
2013-04-03 11:10:37 -07:00
Elliott Hughes
14c840df90 Merge "Fix the SYSCALLS.TXT documentation and remove a dead script." 2013-04-03 17:22:18 +00:00
Elliott Hughes
a51916b58b Fix the SYSCALLS.TXT documentation and remove a dead script.
We use the system call constants from the kernel header files now,
so there's no need to check that they've been correctly transcribed
into SYSCALLS.TXT.

This is a work in progress. I've added TODOs to SYSCALLS.TXT explaining
what's left to do.

Change-Id: I3b86acfe7f84b4da1c802ee5a4ef13a2e83e7939
2013-04-03 10:08:09 -07:00
The Android Automerger
c099884c7c merge in master-release history after reset to master 2013-04-03 07:49:14 -07:00
Elliott Hughes
168486f073 am fe51d25e: am 162b4411: Merge "Stop using unreasonable numbers of map entries."
* commit 'fe51d25e83a8487386c653493e587aa1686503aa':
  Stop using unreasonable numbers of map entries.
2013-04-02 19:25:21 -07:00
Elliott Hughes
a0340cf139 am 40147728: am 1fe11375: Stop using unreasonable numbers of map entries.
* commit '40147728d24a5a85b0ae0ee366b0a3cadb1ea65a':
  Stop using unreasonable numbers of map entries.
2013-04-02 19:25:19 -07:00
Elliott Hughes
fe51d25e83 am 162b4411: Merge "Stop using unreasonable numbers of map entries."
* commit '162b4411fc79fe906020ebdf9e85883237fac8c3':
  Stop using unreasonable numbers of map entries.
2013-04-02 18:05:25 -07:00
Elliott Hughes
40147728d2 am 1fe11375: Stop using unreasonable numbers of map entries.
* commit '1fe1137576a1b7faf2d9bede121cc6faeceb50ff':
  Stop using unreasonable numbers of map entries.
2013-04-02 17:52:20 -07:00
Elliott Hughes
162b4411fc Merge "Stop using unreasonable numbers of map entries." 2013-04-03 00:48:07 +00:00
Elliott Hughes
4ace92c62a Stop using unreasonable numbers of map entries.
Bug: 8460659
Change-Id: Ib0ee71e3cf61e122d0449c9d8a4e4670a7d7129a
2013-04-02 17:41:14 -07:00
Kenny Root
4ea3580749 Merge branch 'master' of https://googleplex-android.googlesource.com/_direct/platform/bionic 2013-04-02 11:06:24 -07:00
Christopher Ferris
5014f417ea Merge "Add missing branch in memcpy.S dst aligned case." 2013-04-02 18:05:54 +00:00
The Android Open Source Project
6517d138fd am cc91c517: Reconcile with jb-mr2-release - do not merge
* commit 'cc91c517bf00431f098b7ca371113dc108071a45':
2013-04-02 11:04:15 -07:00
Lorenzo Colitti
5a3cc2018c am 9ef66e84: am 309e107f: Merge "Update getaddrinfo to RFC6724" into jb-mr2-dev
* commit '9ef66e842f28f58abfbc8458973a2511a055db0c':
  Update getaddrinfo to RFC6724
2013-04-02 11:04:09 -07:00
Christopher Ferris
6ffaa931c3 Add missing branch in memcpy.S dst aligned case.
Change-Id: I0651e46dc5d9b49a997c0c6d099b75097eedb504
2013-04-02 09:19:00 -07:00
The Android Automerger
02dc65183b merge in master-release history after reset to master 2013-04-02 09:17:13 -07:00
The Android Open Source Project
cc91c517bf Reconcile with jb-mr2-release - do not merge
Change-Id: Id1d2ab018ca9bc14b36395ae84eb73a120b2befc
2013-04-02 08:39:18 -07:00
Lorenzo Colitti
9ef66e842f am 309e107f: Merge "Update getaddrinfo to RFC6724" into jb-mr2-dev
* commit '309e107f01e13bbe90ba31f2eee5d526ff676222':
  Update getaddrinfo to RFC6724
2013-04-02 08:24:30 -07:00
Christopher Ferris
50bc9395e4 Merge "Update to latest cortexa15 memcpy code." 2013-04-02 02:04:47 +00:00
Elliott Hughes
7506673f63 am 8dd195c5: am 7a29f404: Merge "Update getaddrinfo to RFC6724"
* commit '8dd195c509eed45d1e4b5ab91ddc2ef56fcb0737':
  Update getaddrinfo to RFC6724
2013-04-01 18:21:58 -07:00
Elliott Hughes
8dd195c509 am 7a29f404: Merge "Update getaddrinfo to RFC6724"
* commit '7a29f404e11d3346e79154b8e8d72a3215febced':
  Update getaddrinfo to RFC6724
2013-04-01 18:20:10 -07:00
Elliott Hughes
7a29f404e1 Merge "Update getaddrinfo to RFC6724" 2013-04-02 01:05:23 +00:00
Lorenzo Colitti
378b0e1ea2 Update getaddrinfo to RFC6724
Currently, our getaddrinfo implementation does not conform to
any IETF standard. It follows draft-ietf-6man-rfc3484-revise-01,
but that draft has expired. Update the policy table to RFC6724.

(cherry-pick of e919b116d35aa7deb24ddece69c491e24c3b0d6f.)

Bug: 8276725
Change-Id: I2d17122defd966ac6c2c13d04887fb110f2598a0
2013-04-01 18:04:25 -07:00
The Android Automerger
1ec2cf5ba8 merge in master-release history after reset to master 2013-04-01 11:31:26 -07:00
Christopher Ferris
21ede92d79 Update to latest cortexa15 memcpy code.
This uses the new code original submitted as memcpy.a15.S as
the base. However, the old code handled unaligned src/dst better
so that was spliced in. I optimized the original unaligned code by
removing a few unnecessary instructions. I optimized the a15 code by
rewriting the pre and post code. I also modified the main loop to add
a pld so that larger copies would not stall waiting for memory.

Test cases for the new memcpy:

- Copy all sized values from 0 to 1024 bytes, using whatever alignment
  is returned by malloc.
For each alignment case described below, the test copied from 0 to 128
bytes.
- Src and dst pointers are both aligned to the same value, starting
  at one going through every power of two up to and including 128.
- Src aligned to double word boundary, dst aligned to word boundary.
- Src aligned to word boundary, dst aligned to double word boundary.
- Src aligned to 16 bit boundary, dst aligned to word boundary.
- Src aligned to word boundary, dst aligned to 16 byte boundary.
- Src aligned to word boundary, dst aligned to 1 byte from a word
  boundary.
- Src aligned to word boundary, dst aligned to 2 bytes from a word
  boundary.
- Src aligned to word boundary, dst aligned to 3 bytes from a word
  boundary.
- Src aligned to 1 byte from a word boundary, dst aligned to a word
  boundary.
- Src aligned to 2 bytes from a word boundary, dst aligned to a word
  boundary.
- Src aligned to 3 bytes from a word boundary, dst aligned to a word
  boundary.

Cases to verify the unaligned source code properly aligns to a 16 bit
boundary.
- Src aligned to 1 byte from a 128 bit boundary, dst aligned to
  4 + 128 bit boundary.
- Src aligned to 1 byte from a 128 bit boundary, dst aligned to
  8 + 128 bit boundary.
- Src aligned to 1 byte from a 128 bit boundary, dst aligned to
  12 + 128 bit boundary.
- Src aligned to 1 byte from a 128 bit boundary, dst aligned to
  16 + 128 bit boundary.

In all cases, a two byte fencepost was placed at the end of the
destination to verify that only the requested number of bytes were copied.

Bug: 8005082
Change-Id: I700b2fab81941959d301ab1934c18fbd8ee3eee4
2013-03-30 14:32:49 -07:00
Elliott Hughes
c099b270c6 am e2bce303: am 96449b3d: Extra logging in pthread_create.
* commit 'e2bce30360a46fa3a235d1e9874d35891673826f':
  Extra logging in pthread_create.
2013-03-29 17:58:38 -07:00
Nick Kralevich
62bb090f8e resolved conflicts for merge of 5b661481 to master
Change-Id: Ifc68a87a95187b61f7f42a0217af43e14db6d4f8
2013-03-29 17:36:52 -07:00
Elliott Hughes
e2bce30360 am 96449b3d: Extra logging in pthread_create.
* commit '96449b3dc16d64ea91df83c9d7942f3e22e76b52':
  Extra logging in pthread_create.
2013-03-29 17:00:51 -07:00
Elliott Hughes
113054c4eb am e59ecd32: am 6bb17dfa: Merge "Extra logging in pthread_create."
* commit 'e59ecd32798b08e59b4813b3ed8859e5dac5297c':
  Extra logging in pthread_create.
2013-03-29 16:58:02 -07:00
Nick Kralevich
5b661481a8 am b24b6e14: Merge "resolv_cache: hide some libc private functions" into jb-mr2-dev
* commit 'b24b6e1419382146f85571cdda27d48fb348141d':
  resolv_cache: hide some libc private functions
2013-03-29 16:55:20 -07:00
Elliott Hughes
e59ecd3279 am 6bb17dfa: Merge "Extra logging in pthread_create."
* commit '6bb17dfad36edda68da46c2bf68c4297a160ab8a':
  Extra logging in pthread_create.
2013-03-29 16:53:02 -07:00
Elliott Hughes
6bb17dfad3 Merge "Extra logging in pthread_create." 2013-03-29 23:47:24 +00:00
Elliott Hughes
cfa089df23 Extra logging in pthread_create.
pthread_create returns EAGAIN when it can't allocate a pthread_internal_t,
when it can't allocate a stack for the new thread, or when clone(2) fails
because there are too many threads. It's useful to be able to know why your
pthread_create just failed, so add some logging.

Bug: 8470684
Change-Id: I1bb4497d4f7528eacce0db35c2014771cba64569
2013-03-29 16:35:00 -07:00
The Android Open Source Project
2903a0bac3 am f9e4a6e9: (-s ours) Reconcile with jb-mr2-release - do not merge
* commit 'f9e4a6e93b2d0ca6f2fd01547a04b63a94257a29':
2013-03-29 09:50:35 -07:00
The Android Open Source Project
f9e4a6e93b Reconcile with jb-mr2-release - do not merge
Change-Id: Ie2c8eed6e2ee90bc1d1a59184a503f9dd0dcdc80
2013-03-29 09:48:32 -07:00
The Android Automerger
0f7607f372 merge in master-release history after reset to master 2013-03-28 11:32:29 -07:00
Jean-Baptiste Queru
a3ce0bb1ad am a3de6b47: am d02dd19d: am 267290b3: am 74b324ac: Merge "Update processed linux/fs.h header file"
* commit 'a3de6b47bf444c6efbf386e01e70bc61f9c559de':
  Update processed linux/fs.h header file
2013-03-28 09:02:06 -07:00
Jean-Baptiste Queru
a3de6b47bf am d02dd19d: am 267290b3: am 74b324ac: Merge "Update processed linux/fs.h header file"
* commit 'd02dd19d51fd78c4cfea8be4eaba3df1668910c4':
  Update processed linux/fs.h header file
2013-03-28 09:01:01 -07:00
Ken Sumrall
6ed55e06fd am 024f418a: am 887049e4: Merge "Update processed linux/fs.h header file" into jb-mr2-dev
* commit '024f418af284d79e2d307489f33d67b6c564a112':
  Update processed linux/fs.h header file
2013-03-27 14:18:37 -07:00
Ken Sumrall
024f418af2 am 887049e4: Merge "Update processed linux/fs.h header file" into jb-mr2-dev
* commit '887049e46bdd5c14cc00837f959a0195780118a9':
  Update processed linux/fs.h header file
2013-03-27 14:16:47 -07:00
The Android Open Source Project
416d231f97 am fd59d4d3: (-s ours) Reconcile with jb-mr2-release - do not merge
* commit 'fd59d4d3eaccb9b181f8a2b9c88ffe5060f1e528':
2013-03-26 12:17:40 -07:00
The Android Open Source Project
fd59d4d3ea Reconcile with jb-mr2-release - do not merge
Change-Id: Icad78517674982f0ed6f87a7cc72a4d5b74a519f
2013-03-26 10:49:00 -07:00
The Android Automerger
47a46646f0 merge in master-release history after reset to master 2013-03-26 07:49:18 -07:00
Elliott Hughes
d74b3bb1cb am c813182d: am da2c1586: am 8a6abe38: am bd014c2e: Merge "Remove some dead script code and fix a script comment."
* commit 'c813182d20fa853d944cb9b4dc5c3f1a4d1c7728':
  Remove some dead script code and fix a script comment.
2013-03-25 21:40:33 +00:00
Elliott Hughes
c813182d20 am da2c1586: am 8a6abe38: am bd014c2e: Merge "Remove some dead script code and fix a script comment."
* commit 'da2c158645e10671de990bb71b307d90035320a4':
  Remove some dead script code and fix a script comment.
2013-03-25 21:38:40 +00:00
Elliott Hughes
69684aa312 am 94510371: am 999dff0e: am a850ad4c: am e51d75a9: Merge "Clarify the dlmalloc USAGE_ERROR."
* commit '94510371951bc28f97cdb55df74be26fcebdc1e4':
  Clarify the dlmalloc USAGE_ERROR.
2013-03-25 21:12:59 +00:00
Elliott Hughes
9451037195 am 999dff0e: am a850ad4c: am e51d75a9: Merge "Clarify the dlmalloc USAGE_ERROR."
* commit '999dff0ef3d92c1e84d12d3b8d8324c5ef441b85':
  Clarify the dlmalloc USAGE_ERROR.
2013-03-25 21:10:49 +00:00
Dima Zavin
e24ec2ad4c am bb06498d: am 369f9234: Merge "libc/arm: add cortex-a7 cpu variant" into jb-mr2-dev
* commit 'bb06498d89dd002a17bad6666276580c94da1749':
  libc/arm: add cortex-a7 cpu variant
2013-03-25 19:44:54 +00:00
Dima Zavin
bb06498d89 am 369f9234: Merge "libc/arm: add cortex-a7 cpu variant" into jb-mr2-dev
* commit '369f92349fc784f6c14ad30f5806f708a8f2c7f7':
  libc/arm: add cortex-a7 cpu variant
2013-03-25 19:43:41 +00:00
Elliott Hughes
7a7d39c3f0 am c538edc1: am c82b339a: am 3c1504d9: am 48f25cef: Merge "Stop generating <sys/linux-syscalls.h>."
* commit 'c538edc1e85b7df35852cf9fbc472b29683fc4a3':
  Stop generating <sys/linux-syscalls.h>.
2013-03-25 17:31:28 +00:00
Elliott Hughes
263be8b1a0 am 053ceea1: am 9386a33e: am 93f3811b: am a4075118: Merge "Unhide __set_errno for backwards compatibility."
* commit '053ceea1172a399b9fddf0ab010cff535c65be0e':
  Unhide __set_errno for backwards compatibility.
2013-03-25 17:31:27 +00:00
Elliott Hughes
c538edc1e8 am c82b339a: am 3c1504d9: am 48f25cef: Merge "Stop generating <sys/linux-syscalls.h>."
* commit 'c82b339a7da4dc36e644f5037c3868155fe454e4':
  Stop generating <sys/linux-syscalls.h>.
2013-03-25 17:29:11 +00:00
Elliott Hughes
053ceea117 am 9386a33e: am 93f3811b: am a4075118: Merge "Unhide __set_errno for backwards compatibility."
* commit '9386a33ea005fc008ff7ce0558d24e5ac68a6430':
  Unhide __set_errno for backwards compatibility.
2013-03-25 17:29:10 +00:00
The Android Automerger
a500fdb18e merge in master-release history after reset to master 2013-03-25 07:49:24 -07:00
Elliott Hughes
4584721b5a am 9792b2d1: am ba61bb55: am a3fe475c: am c019345a: Merge "Use the correct names for the __ARM_NR_* syscalls."
* commit '9792b2d16062c3fa334a47501a1cde9bfbedb5c2':
  Use the correct names for the __ARM_NR_* syscalls.
2013-03-22 22:13:44 +00:00
Elliott Hughes
9792b2d160 am ba61bb55: am a3fe475c: am c019345a: Merge "Use the correct names for the __ARM_NR_* syscalls."
* commit 'ba61bb55c4f3d468dd93bedc3deb24a0ef28a948':
  Use the correct names for the __ARM_NR_* syscalls.
2013-03-22 22:12:16 +00:00
Elliott Hughes
cf3fc45376 am dce1b3e2: am e0e5b2f6: am 65163750: am c37dd599: Merge "Fix builds where _FORTIFY_SOURCE is off."
* commit 'dce1b3e26a9f85fcc9a768cc69919299fcb2b5a5':
  Fix builds where _FORTIFY_SOURCE is off.
2013-03-22 18:26:45 +00:00
Elliott Hughes
dce1b3e26a am e0e5b2f6: am 65163750: am c37dd599: Merge "Fix builds where _FORTIFY_SOURCE is off."
* commit 'e0e5b2f6e731c639107e29abec17db2e6eb498e8':
  Fix builds where _FORTIFY_SOURCE is off.
2013-03-22 18:24:53 +00:00
Elliott Hughes
749a9e022c am fbb41988: am b826ebf4: am 85598626: am 34895c1b: Merge "Replace unnecessary ARM uses of <sys/linux-syscalls.h> with <asm/unistd.h>."
* commit 'fbb4198857374b816a6c444a52cb3209101e02c9':
  Replace unnecessary ARM uses of <sys/linux-syscalls.h> with <asm/unistd.h>.
2013-03-22 18:17:51 +00:00
Elliott Hughes
fbb4198857 am b826ebf4: am 85598626: am 34895c1b: Merge "Replace unnecessary ARM uses of <sys/linux-syscalls.h> with <asm/unistd.h>."
* commit 'b826ebf41e701d0d73be2897cecd560606193bd2':
  Replace unnecessary ARM uses of <sys/linux-syscalls.h> with <asm/unistd.h>.
2013-03-22 18:15:47 +00:00
Elliott Hughes
74c7d3ff03 am f30ff61e: am b44f9600: am b80a05fa: am 5c5f303e: Merge "Replace unnecessary MIPS uses of <sys/linux-syscalls.h> with <asm/unistd.h>."
* commit 'f30ff61ef61f3d8b73257e89e4635fc1436f4bbc':
  Replace unnecessary MIPS uses of <sys/linux-syscalls.h> with <asm/unistd.h>.
2013-03-22 16:47:49 +00:00
Elliott Hughes
90763e0aee am f0fc7b9b: am a0dcecc5: am bc0d7f73: am e7cb795c: Merge "Replace unnecessary x86 uses of <sys/linux-syscalls.h> with <asm/unistd.h>."
* commit 'f0fc7b9bf93029e2e0e2a21ac037d14c7f4db7a2':
  Replace unnecessary x86 uses of <sys/linux-syscalls.h> with <asm/unistd.h>.
2013-03-22 16:47:48 +00:00
Elliott Hughes
f30ff61ef6 am b44f9600: am b80a05fa: am 5c5f303e: Merge "Replace unnecessary MIPS uses of <sys/linux-syscalls.h> with <asm/unistd.h>."
* commit 'b44f9600a38988749d9f893fc5d2e3b3a07e6938':
  Replace unnecessary MIPS uses of <sys/linux-syscalls.h> with <asm/unistd.h>.
2013-03-22 16:45:18 +00:00
Elliott Hughes
f0fc7b9bf9 am a0dcecc5: am bc0d7f73: am e7cb795c: Merge "Replace unnecessary x86 uses of <sys/linux-syscalls.h> with <asm/unistd.h>."
* commit 'a0dcecc53e2f45939fdcb0f1ec1d592d91cf41c7':
  Replace unnecessary x86 uses of <sys/linux-syscalls.h> with <asm/unistd.h>.
2013-03-22 16:45:18 +00:00
The Android Automerger
847a62270f merge in master-release history after reset to master 2013-03-22 07:49:16 -07:00
Elliott Hughes
1d509cc043 am 472d7115: am ddda044a: am 5686bb30: am 3323628d: Merge "The SYS_ constants should cover all __NR_ values."
* commit '472d7115f1ec8968b645d72d18222687d39f189e':
  The SYS_ constants should cover all __NR_ values.
2013-03-22 05:57:05 +00:00
Elliott Hughes
472d7115f1 am ddda044a: am 5686bb30: am 3323628d: Merge "The SYS_ constants should cover all __NR_ values."
* commit 'ddda044a81b6be2ccdf351ad5c9a2b9800a60f5f':
  The SYS_ constants should cover all __NR_ values.
2013-03-22 05:55:47 +00:00
Elliott Hughes
731381ad5f am dfde829f: am c8ded7c6: am a3167257: am babb72dc: Merge "Fix pthread_setname_np\'s behavior on invalid pthread_ts."
* commit 'dfde829fc1c97fe3fbdaf244d2444562b7c2fbfe':
  Fix pthread_setname_np's behavior on invalid pthread_ts.
2013-03-22 05:25:17 +00:00
Elliott Hughes
dfde829fc1 am c8ded7c6: am a3167257: am babb72dc: Merge "Fix pthread_setname_np\'s behavior on invalid pthread_ts."
* commit 'c8ded7c6b1b95ca530383b9698719892d13a4f9e':
  Fix pthread_setname_np's behavior on invalid pthread_ts.
2013-03-22 05:24:12 +00:00
Elliott Hughes
bd43b613b8 am 3a6178f8: am 1e40ace4: am a596aa6a: am 26c815c4: Merge "Drop magic number in strrchr and strchr"
* commit '3a6178f8b9498ece5383fac9feb692e8ed2d4ce0':
  Drop magic number in strrchr and strchr
2013-03-22 03:03:15 +00:00
Elliott Hughes
06a06d5091 am 71afd315: am 17a0d191: am 01c0e19e: am 612333f6: Merge "Don\'t #define SYS_ constants unless they make sense for the current architecture."
* commit '71afd3153544a2795fcb74c86fd895df59aa5feb':
  Don't #define SYS_ constants unless they make sense for the current architecture.
2013-03-22 03:03:15 +00:00
Elliott Hughes
3a6178f8b9 am 1e40ace4: am a596aa6a: am 26c815c4: Merge "Drop magic number in strrchr and strchr"
* commit '1e40ace49e25ee4c469ed4613fe09656d3c0a5d7':
  Drop magic number in strrchr and strchr
2013-03-22 03:00:36 +00:00
Elliott Hughes
71afd31535 am 17a0d191: am 01c0e19e: am 612333f6: Merge "Don\'t #define SYS_ constants unless they make sense for the current architecture."
* commit '17a0d1915f871ad67608a582a4fb3352000cf719':
  Don't #define SYS_ constants unless they make sense for the current architecture.
2013-03-22 03:00:35 +00:00
Elliott Hughes
2810ec5464 am 5bed5501: am 3077d883: am c48968d2: am 4453c51c: Merge "Drop unnecessary execution permission for .cpp/.c/.h"
* commit '5bed5501d7048acc77f5365e87fd8487b21ef1f6':
  Drop unnecessary execution permission for .cpp/.c/.h
2013-03-22 02:43:23 +00:00
Elliott Hughes
5bed5501d7 am 3077d883: am c48968d2: am 4453c51c: Merge "Drop unnecessary execution permission for .cpp/.c/.h"
* commit '3077d88347f4b120ee93e73efdbfb017e0e968ec':
  Drop unnecessary execution permission for .cpp/.c/.h
2013-03-22 02:42:02 +00:00
Elliott Hughes
b11037a42a am 455637f2: am 5c9a25cc: am f977d2dc: am 800ad824: Merge "Provide glibc-compatible SYS_* aliases for the __NR_* constants."
* commit '455637f25180709f7baf261715873f4a0109583c':
  Provide glibc-compatible SYS_* aliases for the __NR_* constants.
2013-03-22 01:55:26 +00:00
Elliott Hughes
455637f251 am 5c9a25cc: am f977d2dc: am 800ad824: Merge "Provide glibc-compatible SYS_* aliases for the __NR_* constants."
* commit '5c9a25cc2369846f7cf7f4fe1bdb32cf3dc8a469':
  Provide glibc-compatible SYS_* aliases for the __NR_* constants.
2013-03-22 01:54:20 +00:00
Elliott Hughes
a2e42c3798 am 6d460efe: am c9edc079: am 39e2a408: am 6eb978c9: Merge "Expose wait4 as wait4 rather than __wait4."
* commit '6d460efed94e3d5825b5c842c112aa6b26357d93':
  Expose wait4 as wait4 rather than __wait4.
2013-03-21 23:25:38 +00:00
Elliott Hughes
6d460efed9 am c9edc079: am 39e2a408: am 6eb978c9: Merge "Expose wait4 as wait4 rather than __wait4."
* commit 'c9edc0797779187ad1b429e956820928051047ae':
  Expose wait4 as wait4 rather than __wait4.
2013-03-21 23:23:46 +00:00
Christopher Ferris
e269711a1b am 774266bf: am f46e1454: am 9088af19: am 86c31849: Merge "Create arch specific versions of strcmp."
* commit '774266bfa281880e16c2447555177c037575cdaf':
  Create arch specific versions of strcmp.
2013-03-20 22:40:13 +00:00
Christopher Ferris
774266bfa2 am f46e1454: am 9088af19: am 86c31849: Merge "Create arch specific versions of strcmp."
* commit 'f46e14544b446e6dbc241aabb8090cd8e62c158d':
  Create arch specific versions of strcmp.
2013-03-20 22:37:58 +00:00
The Android Open Source Project
fd56f2a3cc am bad0c4d8: (-s ours) Reconcile with jb-mr2-release - do not merge
* commit 'bad0c4d8bb85d91affb7274022f671b40b0a9305':
  am 2e7b8d63: am f861bc5c: Merge "Don\'t search off the end of the index for bad Olson ids."
2013-03-20 16:42:00 +00:00
The Android Open Source Project
bad0c4d8bb Reconcile with jb-mr2-release - do not merge
Change-Id: I9358f7d5fb867340fa18195fbbd6394c4ad53fce
2013-03-20 09:32:10 -07:00
The Android Automerger
1565771b2a merge in master-release history after reset to master 2013-03-18 07:49:11 -07:00
Elliott Hughes
6380d21a05 am 92a197f3: am d7dc414a: am 987fc5a3: am adeec096: Merge "Hide various symbols that shouldn\'t be exposed."
* commit '92a197f3051c5befd5e40ec7f23c0643999da259':
  Hide various symbols that shouldn't be exposed.
2013-03-16 00:11:52 +00:00
Elliott Hughes
92a197f305 am d7dc414a: am 987fc5a3: am adeec096: Merge "Hide various symbols that shouldn\'t be exposed."
* commit 'd7dc414afd1847e76ae317880bcedc9678953f9e':
  Hide various symbols that shouldn't be exposed.
2013-03-16 00:10:24 +00:00
Elliott Hughes
90f7546c68 am cf23cbb1: am 12ea8005: am 5f829205: am c1416647: Merge "Clean up internal libc logging."
* commit 'cf23cbb1d4826ac579fae28e4fe796a6e4e1ddfd':
  Clean up internal libc logging.
2013-03-15 23:43:01 +00:00
Elliott Hughes
cf23cbb1d4 am 12ea8005: am 5f829205: am c1416647: Merge "Clean up internal libc logging."
* commit '12ea8005665085ae82c1b233ae93d12855e04b8b':
  Clean up internal libc logging.
2013-03-15 23:40:15 +00:00
Elliott Hughes
cc71361ed6 am 270595f4: am e1b0db13: am 50d42294: am e23ed8c6: Merge "Remove useless workaround for HTC RIL bugs."
* commit '270595f4c976a86033ac099a283299c2ec53f24a':
  Remove useless workaround for HTC RIL bugs.
2013-03-15 18:49:50 +00:00
Elliott Hughes
270595f4c9 am e1b0db13: am 50d42294: am e23ed8c6: Merge "Remove useless workaround for HTC RIL bugs."
* commit 'e1b0db1392050900e1f38b16ec2c8e213308e267':
  Remove useless workaround for HTC RIL bugs.
2013-03-15 18:47:48 +00:00
The Android Automerger
9d6a2c28a5 merge in master-release history after reset to master 2013-03-15 07:49:25 -07:00
Elliott Hughes
045e01caed am c204b501: am 9ede4549: am f8d689bc: am 4d696eb4: Merge "Fix a bug in ZoneCompactor that meant the zonetab offset was wrong."
* commit 'c204b501f44d7b08e2be06693322d5426b3f85ef':
  Fix a bug in ZoneCompactor that meant the zonetab offset was wrong.
2013-03-15 00:45:09 +00:00
Elliott Hughes
c204b501f4 am 9ede4549: am f8d689bc: am 4d696eb4: Merge "Fix a bug in ZoneCompactor that meant the zonetab offset was wrong."
* commit '9ede4549fe083e54cdf2f34b177fc32777f61fac':
  Fix a bug in ZoneCompactor that meant the zonetab offset was wrong.
2013-03-15 00:44:05 +00:00
Christopher Ferris
18fcfa79d3 am 8dcbb90d: am f85fc022: am f694ed1c: am d30b9f09: Merge "Remove unused arm defines."
* commit '8dcbb90dea22a876d9cc517f382bb82c98d87450':
  Remove unused arm defines.
2013-03-14 23:43:26 +00:00
Christopher Ferris
8dcbb90dea am f85fc022: am f694ed1c: am d30b9f09: Merge "Remove unused arm defines."
* commit 'f85fc022f5ad405a7e43ecb6f48bcc6e061e01b5':
  Remove unused arm defines.
2013-03-14 23:40:36 +00:00
Elliott Hughes
4982e345cf am 2d48d0ea: am c9358706: am 2e7b8d63: am f861bc5c: Merge "Don\'t search off the end of the index for bad Olson ids."
* commit '2d48d0ea36395da9af4537195483b006900bf7bd':
  Don't search off the end of the index for bad Olson ids.
2013-03-14 22:35:28 +00:00
Elliott Hughes
2d48d0ea36 am c9358706: am 2e7b8d63: am f861bc5c: Merge "Don\'t search off the end of the index for bad Olson ids."
* commit 'c9358706c6f48eb27f785f3bf15b2ab0d50ff7bc':
  Don't search off the end of the index for bad Olson ids.
2013-03-14 22:33:35 +00:00
Christopher Ferris
65461bbe25 Merge "Create arch specific versions of strcmp." 2013-03-14 21:18:20 +00:00
The Android Automerger
e450d655ba merge in master-release history after reset to master 2013-03-13 07:49:07 -07:00
Elliott Hughes
a00988312b am 76ade2ed: am f557e90b: am 2f44c05b: am ec706c24: Merge "Use the kernel\'s MAX_ERRNO in the syscall stubs."
* commit '76ade2ed6077fec0a4978ef7e7e2a99578512c39':
  Use the kernel's MAX_ERRNO in the syscall stubs.
2013-03-13 01:00:12 +00:00
Elliott Hughes
76ade2ed60 am f557e90b: am 2f44c05b: am ec706c24: Merge "Use the kernel\'s MAX_ERRNO in the syscall stubs."
* commit 'f557e90b348d9a3294391076bcd6604a13c803b6':
  Use the kernel's MAX_ERRNO in the syscall stubs.
2013-03-13 00:58:27 +00:00
Christopher Ferris
f0cd52305a am 8cca0154: am b0b974c1: am 2a66ccf1: am 980508b0: Merge "Break bionic implementations into arch versions."
* commit '8cca015403f2f021d557fc81a0423a04a551448a':
  Break bionic implementations into arch versions.
2013-03-12 22:45:21 +00:00
Christopher Ferris
8cca015403 am b0b974c1: am 2a66ccf1: am 980508b0: Merge "Break bionic implementations into arch versions."
* commit 'b0b974c10ce3494fe58be1a3f419656f95c54331':
  Break bionic implementations into arch versions.
2013-03-12 22:43:05 +00:00
Elliott Hughes
4f73423c68 am 0052a618: am b4d6f28c: am a3214c65: am 94a34010: Merge "Support large errno values on ARM."
* commit '0052a6188ba20c3a9ea99f974bce0c143bd379cb':
  Support large errno values on ARM.
2013-03-12 19:24:10 +00:00
Elliott Hughes
0052a6188b am b4d6f28c: am a3214c65: am 94a34010: Merge "Support large errno values on ARM."
* commit 'b4d6f28cc33f438f9859d6ab5f91e7f2ee1d6d33':
  Support large errno values on ARM.
2013-03-12 19:22:50 +00:00
Elliott Hughes
6734451334 am 60414ba1: am 746f1286: am 5d998b4a: am f21aa3b6: Merge "Use more types than just \'unsigned\' in the linker."
* commit '60414ba165da87e427aef45b651ec7d4f26b084f':
  Use more types than just 'unsigned' in the linker.
2013-03-12 19:07:18 +00:00
Elliott Hughes
60414ba165 am 746f1286: am 5d998b4a: am f21aa3b6: Merge "Use more types than just \'unsigned\' in the linker."
* commit '746f128602772997b57e24fc8546473d01d6f955':
  Use more types than just 'unsigned' in the linker.
2013-03-12 19:05:53 +00:00
Elliott Hughes
947695bd9b am 5487ecb5: am e9cdce33: am 3c9afb5e: am 6b4c77f8: Merge "Use Elf32_Addr instead of unsigned in linker"
* commit '5487ecb52a328906b81635f8c8018f48031c19a1':
  Use Elf32_Addr instead of unsigned in linker
2013-03-12 17:43:55 +00:00
Elliott Hughes
5487ecb52a am e9cdce33: am 3c9afb5e: am 6b4c77f8: Merge "Use Elf32_Addr instead of unsigned in linker"
* commit 'e9cdce33f398e43952d11ef38027e2d255f16531':
  Use Elf32_Addr instead of unsigned in linker
2013-03-12 17:42:37 +00:00
Christopher Ferris
a9a5870d16 Create arch specific versions of strcmp.
This uses the new strcmp.a15.S code as the basis for new versions
of strcmp.S.

The cortex-a15 code is the performance optimized version of strcmp.a15.S
taken with only the addition of a few pld instructions.
The cortex-a9 code is the same as the cortex-a15 code except that the
unaligned strcmp code was taken from the original strcmp.S.
The krait code is the same as the cortex-a15 code except that one path
in the unaligned strcmp code was taken from the original strcmp.S code
(the 2 byte overlap case).
The generic code is the original unmodified strmp.S from the bionic
subdirectory.

All three new versions underwent these test cases:

Strings the same, all same size:
- Both pointers double word aligned.
- One pointer double word aligned, one pointer word aligned.
- Both pointers word aligned.
- One pointer double word aligned, one pointer 1 off a word alignment.
- One pointer double word aligned, one pointer 2 off a word alignment.
- One pointer double word aligned, one pointer 3 off a word alignment.
- One pointer word aligned, one pointer 1 off a word alignment.
- One pointer word aligned, one pointer 2 off a word alignment.
- One pointer word aligned, one pointer 3 off a word alignment.
For all cases where it made sense, the two pointers were also tested
swapped.

Different strings, all same size:
- Single difference at double word boundary.
- Single difference at word boudary.
- Single difference at 1 off a word alignment.
- Single difference at 2 off a word alignment.
- Single difference at 3 off a word alignment.

Different sized strings, strings the same until the end:
- Shorter string ends on a double word boundary.
- Shorter string ends on word boundary.
- Shorter string ends at 1 off a word boundary.
- Shorter string ends at 2 off a word boundary.
- Shorter string ends at 3 off a word boundary.

For all different cases, run them through the same pointer alignment
cases when the strings are the same size.
For all cases the two pointers were also tested swapped.

Bug: 8005082
Change-Id: I5f3dc02b48afba2cb9c13332ab45c828ff171a1c
2013-03-12 10:25:11 -07:00
The Android Automerger
1a6e73d0ac merge in master-release history after reset to master 2013-03-12 07:49:24 -07:00
The Android Open Source Project
70d97ae3d0 am 7c8af225: (-s ours) Reconcile with jb-mr2-release - do not merge
* commit '7c8af2252a5814a34f30922ac7d5d63bd891e525':
2013-03-12 14:16:36 +00:00
The Android Open Source Project
7c8af2252a Reconcile with jb-mr2-release - do not merge
Change-Id: Ia0c7d98294053c4dfab78608959f2f3f53c8e2a0
2013-03-12 07:14:11 -07:00
Elliott Hughes
3284773891 am 03e71235: am 8c73f69c: am 36cb88b7: am 53630c0e: Merge "Cache the most-recently used timezone for mktime_tz and localtime_tz."
* commit '03e712357d1f4de204ac9ad5cbef53acba48db9d':
  Cache the most-recently used timezone for mktime_tz and localtime_tz.
2013-03-12 01:50:53 +00:00
Elliott Hughes
03e712357d am 8c73f69c: am 36cb88b7: am 53630c0e: Merge "Cache the most-recently used timezone for mktime_tz and localtime_tz."
* commit '8c73f69cf42d78f37b9b82bf0cc62d2cd1985fcc':
  Cache the most-recently used timezone for mktime_tz and localtime_tz.
2013-03-12 01:48:34 +00:00
Jean-Baptiste Queru
23167e7556 am 1467dfa5: (-s ours) am a60f3818: am b2525ba8: am 7915b22e: am a4b20d71: am b8e1033c: (-s ours) am e5412a9a: (-s ours) Reconcile with jb-mr1-release - do not merge
* commit '1467dfa5cd28b8b4e07cfe86b020a07bd0d0da24':
2013-03-11 19:51:51 +00:00
Jean-Baptiste Queru
1467dfa5cd am a60f3818: am b2525ba8: am 7915b22e: am a4b20d71: am b8e1033c: (-s ours) am e5412a9a: (-s ours) Reconcile with jb-mr1-release - do not merge
* commit 'a60f38181465d5f5a37ea8f9ad34326ea2e21ef0':
2013-03-11 19:41:34 +00:00
Elliott Hughes
3d0bf2b30c am 9969b48d: am 60ac09bd: am 6d6f5e61: am 4b032ee9: Merge "Let bionic use the correct definition of ssize_t."
* commit '9969b48d235e71f87be67549fdd274c8e82f3f6f':
  Let bionic use the correct definition of ssize_t.
2013-03-11 19:41:19 +00:00
Elliott Hughes
9969b48d23 am 60ac09bd: am 6d6f5e61: am 4b032ee9: Merge "Let bionic use the correct definition of ssize_t."
* commit '60ac09bdb2ddc4076f78a91f260cd5a1e179c82b':
  Let bionic use the correct definition of ssize_t.
2013-03-11 19:34:11 +00:00
Elliott Hughes
cd9c4cfae3 am 022d7c50: am bf32ffcf: am 0b765862: am 62c5cd07: Merge "Upgrade to tzdata2013b."
* commit '022d7c50db28fbf90e197f0c88b23b7e3a74a07b':
  Upgrade to tzdata2013b.
2013-03-11 18:39:13 +00:00
Elliott Hughes
022d7c50db am bf32ffcf: am 0b765862: am 62c5cd07: Merge "Upgrade to tzdata2013b."
* commit 'bf32ffcf027d0089e84fafb0114f6b40825f84ac':
  Upgrade to tzdata2013b.
2013-03-11 18:33:57 +00:00
The Android Automerger
568eb7bd76 merge in master-release history after reset to master 2013-03-08 07:49:16 -08:00
Elliott Hughes
5bb64976a0 am 7a9749ec: am 8a015722: resolved conflicts for merge of 4706606c to jb-mr2-dev
* commit '7a9749eca06816ba3b63e55660bc1c2b7285dc52':
  Regenerate NOTICE files.
2013-03-07 21:25:35 +00:00
Elliott Hughes
7a9749eca0 am 8a015722: resolved conflicts for merge of 4706606c to jb-mr2-dev
* commit '8a0157227242eeb7917f064e0d81014bcda6d8f7':
  Regenerate NOTICE files.
2013-03-07 21:23:22 +00:00
The Android Automerger
a7a3bcef75 merge in master-release history after reset to master 2013-03-07 07:49:10 -08:00
Elliott Hughes
30be06bc7a am 0f644ccf: am 0a2ee475: am ad7c275e: am c9f80814: Merge "Upgrade to current NetBSD popen/pclose."
* commit '0f644ccf6dfb4f00473fc90f369d842e09ab13df':
  Upgrade to current NetBSD popen/pclose.
2013-03-07 01:09:36 +00:00
Elliott Hughes
0f644ccf6d am 0a2ee475: am ad7c275e: am c9f80814: Merge "Upgrade to current NetBSD popen/pclose."
* commit '0a2ee4750ac4e9e5949dbf97fbad68065e83b632':
  Upgrade to current NetBSD popen/pclose.
2013-03-07 01:07:08 +00:00
Brian Carlstrom
4bf33991b2 am 6b89c634: am c7b9f954: am 91392116: am 33031fed: Merge "Fix typo of DT_NEEDED for DT_NULL"
* commit '6b89c6341f2d805b7d9913d69ef6038b60b2af7b':
  Fix typo of DT_NEEDED for DT_NULL
2013-03-07 00:18:45 +00:00
Brian Carlstrom
6b89c6341f am c7b9f954: am 91392116: am 33031fed: Merge "Fix typo of DT_NEEDED for DT_NULL"
* commit 'c7b9f954a5278115333516a40c0d2839648a6877':
  Fix typo of DT_NEEDED for DT_NULL
2013-03-07 00:15:48 +00:00
Elliott Hughes
85598b9668 am 165825e3: am 9c0c056b: am 6b1aa1b1: am db794197: Merge "Fix debug malloc."
* commit '165825e3e83fb2ae43b60b1b5ef44cbc55f7979f':
  Fix debug malloc.
2013-03-06 23:29:12 +00:00
Elliott Hughes
165825e3e8 am 9c0c056b: am 6b1aa1b1: am db794197: Merge "Fix debug malloc."
* commit '9c0c056beddf8c4100769ad01404311a6d70efae':
  Fix debug malloc.
2013-03-06 23:27:40 +00:00
Elliott Hughes
6646adeac0 am bbef1f57: am bac72aba: am 50a2cd86: am 0b4a85bf: Merge "Fix TIMING/STATS/COUNT_PAGES dynamic linker build"
* commit 'bbef1f57509504ca11f26968beafd4aa0cfd4643':
  Fix TIMING/STATS/COUNT_PAGES dynamic linker build
2013-03-06 17:52:39 +00:00
Elliott Hughes
bbef1f5750 am bac72aba: am 50a2cd86: am 0b4a85bf: Merge "Fix TIMING/STATS/COUNT_PAGES dynamic linker build"
* commit 'bac72abae4578bf2df9227a9c3d2c7233c83a06b':
  Fix TIMING/STATS/COUNT_PAGES dynamic linker build
2013-03-06 17:47:07 +00:00
Brian Carlstrom
01b5c0f126 am 8f4880e2: am 2527a8b5: am 9043202b: am 20958207: Merge "Fix MIPS linker build"
* commit '8f4880e2c66d60283d443f6c9b5ef4136d2c6621':
  Fix MIPS linker build
2013-03-06 16:53:22 +00:00
Elliott Hughes
0864ade9de am 5673f9f7: am c1a5d20d: am 9a0b658c: am c41dcad0: Merge "More linker cleanup."
* commit '5673f9f73b545c8b4801c1494600ff2220bf8dca':
  More linker cleanup.
2013-03-06 16:53:22 +00:00
Brian Carlstrom
8f4880e2c6 am 2527a8b5: am 9043202b: am 20958207: Merge "Fix MIPS linker build"
* commit '2527a8b5a652d7f88b662fe3788e29b6bc2bbe78':
  Fix MIPS linker build
2013-03-06 16:48:18 +00:00
Elliott Hughes
5673f9f73b am c1a5d20d: am 9a0b658c: am c41dcad0: Merge "More linker cleanup."
* commit 'c1a5d20d08118bb778f99b14ca74d6654e4f4eba':
  More linker cleanup.
2013-03-06 16:48:05 +00:00
The Android Automerger
bc08713ba4 merge in master-release history after reset to master 2013-03-06 07:49:13 -08:00
Brian Carlstrom
d18e5bb412 am a2cfd1a2: am 8c65a1e4: am a2517de3: am 036f9097: Merge "Minor linker cleanup, primarily to use Elf32_Dyn"
* commit 'a2cfd1a27fe552a42d668c708d98ca3f8bee90b9':
  Minor linker cleanup, primarily to use Elf32_Dyn
2013-03-06 01:27:56 +00:00
Brian Carlstrom
a2cfd1a27f am 8c65a1e4: am a2517de3: am 036f9097: Merge "Minor linker cleanup, primarily to use Elf32_Dyn"
* commit '8c65a1e466dae62217700065256921ba86290faa':
  Minor linker cleanup, primarily to use Elf32_Dyn
2013-03-06 01:25:09 +00:00
Elliott Hughes
074a94c01e am b3b00378: am 97a8217a: am 3f7b1cd3: am be21fe7a: Merge "Upgrade to tzdata2013a."
* commit 'b3b0037884e9b0bcba787e84448815f2a4b4dccd':
  Upgrade to tzdata2013a.
2013-03-05 22:29:17 +00:00
Elliott Hughes
b3b0037884 am 97a8217a: am 3f7b1cd3: am be21fe7a: Merge "Upgrade to tzdata2013a."
* commit '97a8217ae1a23a808f7bb3af2f492040e7080549':
  Upgrade to tzdata2013a.
2013-03-05 22:25:39 +00:00
Ben Cheng
fbb281b15d am 7eaed030: am 6ad68558: am e5e6e17c: am 133d97e4: Merge "Add stack unwinding directives to memcpy."
* commit '7eaed030deacb14a6fe628e229af6c9a3a620f3c':
  Add stack unwinding directives to memcpy.
2013-03-05 21:24:43 +00:00
Ben Cheng
7eaed030de am 6ad68558: am e5e6e17c: am 133d97e4: Merge "Add stack unwinding directives to memcpy."
* commit '6ad68558ed4429f7ab0dbad9a5bbf18aacde8362':
  Add stack unwinding directives to memcpy.
2013-03-05 21:22:49 +00:00
Elliott Hughes
c6ef78e83e am 136e00d6: am c96ad9bc: am 7b69ac53: am cf9a9604: Merge "Switch to upstream-freebsd for the unmolested wchar code."
* commit '136e00d6e9bc19617e49a6b7bf81f749ff8a48e3':
  Switch to upstream-freebsd for the unmolested wchar code.
2013-03-05 21:14:04 +00:00
Elliott Hughes
136e00d6e9 am c96ad9bc: am 7b69ac53: am cf9a9604: Merge "Switch to upstream-freebsd for the unmolested wchar code."
* commit 'c96ad9bcd28fcd2b34040a2a696262057a11470b':
  Switch to upstream-freebsd for the unmolested wchar code.
2013-03-05 21:05:24 +00:00
The Android Open Source Project
69a278f679 am adff4e86: (-s ours) Reconcile with jb-mr2-release - do not merge
* commit 'adff4e8630e8d468253255b521caecfbb161dbbe':
2013-03-05 15:58:51 +00:00
The Android Open Source Project
adff4e8630 Reconcile with jb-mr2-release - do not merge
Change-Id: I2635d0c79d4adc135c7f0b6345547ed5e3114158
2013-03-05 07:53:05 -08:00
The Android Automerger
ee84789761 merge in master-release history after reset to master 2013-03-05 07:49:15 -08:00
Elliott Hughes
3f794facd3 am 7ef3ccb7: am 81e0f35a: am 2125c155: am d392e044: Merge "Move realpath.c to upstream-freebsd."
* commit '7ef3ccb7bb5f334e4ca8911a5d0eca7dd0da6b92':
  Move realpath.c to upstream-freebsd.
2013-03-04 23:59:47 +00:00
Elliott Hughes
7ef3ccb7bb am 81e0f35a: am 2125c155: am d392e044: Merge "Move realpath.c to upstream-freebsd."
* commit '81e0f35acc41cfafccc6d28a9122f115ca6e4a16':
  Move realpath.c to upstream-freebsd.
2013-03-04 23:58:16 +00:00
The Android Open Source Project
781c4b19f4 am 98650e04: (-s ours) Reconcile with jb-mr2-release - do not merge
* commit '98650e04e6d87e0b2c82151eacbe483ac15949d9':
  Avoid changing the C++ ABI with ssize_t.
2013-03-04 19:10:07 +00:00
The Android Open Source Project
98650e04e6 Reconcile with jb-mr2-release - do not merge
Change-Id: I92fd2ef799f358dd022234bc5fa7e6693f0619f0
2013-03-04 11:06:25 -08:00
The Android Automerger
e290a7e348 merge in master-release history after reset to master 2013-03-04 07:49:05 -08:00
Christopher Ferris
0a1ab287ff am 29cc4946: (-s ours) Merge "Remove unused arm defines. DO NOT MERGE" into jb-mr2-dev
* commit '29cc4946ac8ac89fa0c49e5da8b5b328065d4b2c':
  Remove unused arm defines. DO NOT MERGE
2013-03-02 01:19:47 +00:00
Ben Cheng
f85e173616 am b9ef7f4e: am 52b3aed7: am c5c6cb3f: am 66273ac2: Merge "Adding strcmp tuned for Cortex-A15."
* commit 'b9ef7f4e122bee55110ac703f391ab961484f3d8':
  Adding strcmp tuned for Cortex-A15.
2013-03-01 18:34:45 +00:00
Ben Cheng
89d7f5e482 am ae280bcd: am 55fc93a9: am 8f149da0: am b3b1ab62: Merge "Adding memcpy tuned for Cortex-A15."
* commit 'ae280bcdbee8d31096c1b332b20fa32f941ef12f':
  Adding memcpy tuned for Cortex-A15.
2013-03-01 18:34:45 +00:00
Nick Kralevich
1f415124ec am 04190c53: am cc646773: am 305a9995: am 8fa924e5: Merge "unistd.h: don\'t include sys/capability.h"
* commit '04190c53e3ac2958322a603d7bfb9b07b92d595e':
  unistd.h: don't include sys/capability.h
2013-03-01 18:34:44 +00:00
The Android Automerger
424f21b6a7 merge in master-release history after reset to master 2013-03-01 07:49:10 -08:00
Christopher Ferris
c7f9669226 am 7c83a1ed: (-s ours) Break bionic implementations into arch versions. DO NOT MERGE
* commit '7c83a1ed81a15f3e75836c1ac7d500a952f02e10':
  Break bionic implementations into arch versions. DO NOT MERGE
2013-03-01 02:36:41 +00:00
Elliott Hughes
bfc25aa33c am 04766565: am 9c102ccf: am 7fe8229b: am 9c1912c4: Merge "Avoid changing the C++ ABI with ssize_t."
* commit '04766565d3743d70f679ca180d7fcc35321143b8':
  Avoid changing the C++ ABI with ssize_t.
2013-02-28 22:38:45 +00:00
Sasha Levitskiy
fbae9f3c30 Bionic: Libc: Resolv: Stricter function signatures, unitialized return bug fix.
Stricter input parameters help avoid ugly casting when passing
	pointers to immutable protobuf data.
	While at it: an int return was dropped from 2 functions whose users
	never used the result; one of the return paths was returning an
	uninitialized value.
	Size_t for portablity and warning supression, misc warnings addressed.

Change-Id: I2d5cbdaf0c9b6c4621a7d397772da13da5dc0943
2013-02-28 18:46:54 +00:00
The Android Automerger
de8481bcf7 merge in master-release history after reset to master 2013-02-28 07:49:07 -08:00
Christopher Ferris
6e1a5cf31b Remove unused arm defines.
The defines HAVE_32_BYTE_CACHE_LINES and ARCH_ARM_USE_NON_NEON_MEMCPY
are not used by any code. The previous memcpy code that used these
has been split into different architecture versions to avoid the need
for them.

Bug: 8005082
Change-Id: I14e0368c5bb4c3a80e72520f7cfd97e359918cce
2013-02-27 16:26:41 -08:00
The Android Automerger
e9ca2d80ed merge in master-release history after reset to master 2013-02-27 07:49:09 -08:00
Christopher Ferris
acdde8c1cf Break bionic implementations into arch versions.
Move arch specific code for arm, mips, x86 into separate
makefiles.
In addition, add different arm cpu versions of memcpy/memset.

Bug: 8005082
Change-Id: I04f3d0715104fab618e1abf7cf8f7eec9bec79df
2013-02-26 16:04:34 -08:00
The Android Automerger
c453d42e20 merge in master-release history after reset to master 2013-02-26 07:49:08 -08:00
The Android Automerger
a6cef2de96 merge in master-release history after reset to master 2013-02-25 07:49:15 -08:00
The Android Automerger
d2a3e69c26 merge in master-release history after reset to master 2013-02-22 07:49:20 -08:00
The Android Automerger
8f8bc0664a merge in master-release history after reset to master 2013-02-21 08:30:27 -08:00
The Android Automerger
27b8421a15 merge in master-release history after reset to master 2013-01-16 07:49:04 -08:00
The Android Automerger
e7cc7957ac merge in master-release history after reset to master 2013-01-15 07:49:22 -08:00
Cédric Cabessa
beb349348e syslog needs a valid socket path for _PATH_LOG
/dev/kmsg is a character device already used for different purposes.
Most distribution use /dev/log for _PATH_LOG but this path is already used
by logcat.
I suggest using /dev/syslog.
This change was tested with busybox's syslogd.

Change-Id: I75b428123c7a0b3ca4bea656ce06860f6f727dde
2012-05-13 17:16:06 +02:00
319 changed files with 27965 additions and 4932 deletions

View File

@@ -6,67 +6,33 @@ include $(LOCAL_PATH)/arch-$(TARGET_ARCH)/syscalls.mk
# =========================================================
libc_common_src_files := \
$(syscall_src) \
unistd/abort.c \
unistd/alarm.c \
unistd/exec.c \
unistd/fnmatch.c \
unistd/getopt_long.c \
unistd/syslog.c \
unistd/system.c \
unistd/time.c \
stdio/asprintf.c \
stdio/clrerr.c \
stdio/fclose.c \
stdio/fdopen.c \
stdio/feof.c \
stdio/ferror.c \
stdio/fflush.c \
stdio/fgetc.c \
stdio/fgetln.c \
stdio/fgetpos.c \
stdio/fgets.c \
stdio/fileno.c \
stdio/findfp.c \
stdio/flags.c \
stdio/fopen.c \
stdio/fprintf.c \
stdio/fpurge.c \
stdio/fputc.c \
stdio/fputs.c \
stdio/fread.c \
stdio/freopen.c \
stdio/fscanf.c \
stdio/fseek.c \
stdio/fsetpos.c \
stdio/ftell.c \
stdio/funopen.c \
stdio/fvwrite.c \
stdio/fwalk.c \
stdio/fwrite.c \
stdio/getc.c \
stdio/getchar.c \
stdio/gets.c \
stdio/makebuf.c \
stdio/mktemp.c \
stdio/printf.c \
stdio/putc.c \
stdio/putchar.c \
stdio/puts.c \
stdio/putw.c \
stdio/refill.c \
stdio/remove.c \
stdio/rewind.c \
stdio/rget.c \
stdio/scanf.c \
stdio/setbuf.c \
stdio/setbuffer.c \
stdio/setvbuf.c \
stdio/snprintf.c\
stdio/sprintf.c \
stdio/sscanf.c \
stdio/stdio.c \
stdio/tempnam.c \
stdio/tmpnam.c \
stdio/ungetc.c \
stdio/vasprintf.c \
stdio/vfprintf.c \
@@ -77,13 +43,11 @@ libc_common_src_files := \
stdio/vscanf.c \
stdio/vsscanf.c \
stdio/wbuf.c \
stdio/wsetup.c \
stdlib/atexit.c \
stdlib/ctype_.c \
stdlib/exit.c \
stdlib/getenv.c \
stdlib/putenv.c \
stdlib/qsort.c \
stdlib/setenv.c \
stdlib/strtod.c \
stdlib/strtoimax.c \
@@ -94,29 +58,16 @@ libc_common_src_files := \
stdlib/strtoumax.c \
stdlib/tolower_.c \
stdlib/toupper_.c \
string/index.c \
string/strcasecmp.c \
string/strcat.c \
string/strchr.c \
string/strcspn.c \
string/strdup.c \
string/strlcat.c \
string/strlcpy.c \
string/strncat.c \
string/strncpy.c \
string/strpbrk.c \
string/strrchr.c \
string/strsep.c \
string/strspn.c \
string/strstr.c \
string/strtok.c \
wchar/wcswidth.c \
wchar/wcsxfrm.c \
tzcode/asctime.c \
tzcode/difftime.c \
tzcode/localtime.c \
tzcode/strftime.c \
tzcode/strptime.c \
bionic/arc4random.c \
bionic/atoi.c \
bionic/atol.c \
@@ -151,11 +102,9 @@ libc_common_src_files := \
bionic/ldexp.c \
bionic/lseek64.c \
bionic/md5.c \
bionic/memchr.c \
bionic/memmem.c \
bionic/memrchr.c \
bionic/memswap.c \
bionic/mmap.c \
bionic/name_mem.c \
bionic/openat.c \
bionic/open.c \
bionic/pathconf.c \
@@ -170,7 +119,6 @@ libc_common_src_files := \
bionic/recv.c \
bionic/sched_cpualloc.c \
bionic/sched_cpucount.c \
bionic/sched_getaffinity.c \
bionic/sched_getcpu.c \
bionic/semaphore.c \
bionic/send.c \
@@ -190,11 +138,11 @@ libc_common_src_files := \
bionic/sleep.c \
bionic/statfs.c \
bionic/strndup.c \
bionic/strnlen.c \
bionic/strntoimax.c \
bionic/strntoumax.c \
bionic/strtotimeval.c \
bionic/system_properties.c \
bionic/system_properties_compat.c \
bionic/tcgetpgrp.c \
bionic/tcsetpgrp.c \
bionic/thread_atexit.c \
@@ -233,22 +181,40 @@ libc_common_src_files := \
netbsd/nameser/ns_print.c \
netbsd/nameser/ns_samedomain.c \
# Fortify implementations of libc functions.
libc_common_src_files += \
bionic/__fgets_chk.cpp \
bionic/__memcpy_chk.cpp \
bionic/__memmove_chk.cpp \
bionic/__memset_chk.cpp \
bionic/__strcat_chk.cpp \
bionic/__strchr_chk.cpp \
bionic/__strcpy_chk.cpp \
bionic/__strlcat_chk.cpp \
bionic/__strlcpy_chk.cpp \
bionic/__strlen_chk.cpp \
bionic/__strncat_chk.cpp \
bionic/__strncpy_chk.cpp \
bionic/__strrchr_chk.cpp \
bionic/__umask_chk.cpp \
bionic/__vsnprintf_chk.cpp \
bionic/__vsprintf_chk.cpp \
libc_bionic_src_files := \
bionic/abort.cpp \
bionic/assert.cpp \
bionic/brk.cpp \
bionic/dirent.cpp \
bionic/__errno.c \
bionic/eventfd_read.cpp \
bionic/eventfd_write.cpp \
bionic/__fgets_chk.cpp \
bionic/futimens.cpp \
bionic/getauxval.cpp \
bionic/getcwd.cpp \
bionic/libc_init_common.cpp \
bionic/libc_logging.cpp \
bionic/libgen.cpp \
bionic/__memcpy_chk.cpp \
bionic/__memmove_chk.cpp \
bionic/__memset_chk.cpp \
bionic/mmap.cpp \
bionic/pthread_attr.cpp \
bionic/pthread_detach.cpp \
bionic/pthread_equal.cpp \
@@ -264,56 +230,88 @@ libc_bionic_src_files := \
bionic/raise.cpp \
bionic/sbrk.cpp \
bionic/scandir.cpp \
bionic/sched_getaffinity.cpp \
bionic/__set_errno.cpp \
bionic/setlocale.cpp \
bionic/signalfd.cpp \
bionic/sigwait.cpp \
bionic/__strcat_chk.cpp \
bionic/__strcpy_chk.cpp \
bionic/statvfs.cpp \
bionic/strerror.cpp \
bionic/strerror_r.cpp \
bionic/__strlcat_chk.cpp \
bionic/__strlcpy_chk.cpp \
bionic/__strlen_chk.cpp \
bionic/__strncat_chk.cpp \
bionic/__strncpy_chk.cpp \
bionic/strsignal.cpp \
bionic/stubs.cpp \
bionic/sysconf.cpp \
bionic/tdestroy.cpp \
bionic/tmpfile.cpp \
bionic/__umask_chk.cpp \
bionic/__vsnprintf_chk.cpp \
bionic/__vsprintf_chk.cpp \
bionic/wait.cpp \
bionic/wchar.cpp \
libc_tzcode_src_files := \
tzcode/asctime.c \
tzcode/difftime.c \
tzcode/localtime.c \
tzcode/strftime.c \
tzcode/strptime.c \
libc_upstream_freebsd_src_files := \
upstream-freebsd/lib/libc/stdio/clrerr.c \
upstream-freebsd/lib/libc/stdio/fclose.c \
upstream-freebsd/lib/libc/stdio/fdopen.c \
upstream-freebsd/lib/libc/stdio/feof.c \
upstream-freebsd/lib/libc/stdio/ferror.c \
upstream-freebsd/lib/libc/stdio/fgetln.c \
upstream-freebsd/lib/libc/stdio/fgetpos.c \
upstream-freebsd/lib/libc/stdio/fgets.c \
upstream-freebsd/lib/libc/stdio/fileno.c \
upstream-freebsd/lib/libc/stdio/flags.c \
upstream-freebsd/lib/libc/stdio/fopen.c \
upstream-freebsd/lib/libc/stdio/fpurge.c \
upstream-freebsd/lib/libc/stdio/fputs.c \
upstream-freebsd/lib/libc/stdio/fsetpos.c \
upstream-freebsd/lib/libc/stdio/funopen.c \
upstream-freebsd/lib/libc/stdio/fwalk.c \
upstream-freebsd/lib/libc/stdio/fwrite.c \
upstream-freebsd/lib/libc/stdio/getc.c \
upstream-freebsd/lib/libc/stdio/getchar.c \
upstream-freebsd/lib/libc/stdio/makebuf.c \
upstream-freebsd/lib/libc/stdio/mktemp.c \
upstream-freebsd/lib/libc/stdio/putc.c \
upstream-freebsd/lib/libc/stdio/putchar.c \
upstream-freebsd/lib/libc/stdio/puts.c \
upstream-freebsd/lib/libc/stdio/putw.c \
upstream-freebsd/lib/libc/stdio/remove.c \
upstream-freebsd/lib/libc/stdio/rget.c \
upstream-freebsd/lib/libc/stdio/setbuf.c \
upstream-freebsd/lib/libc/stdio/setbuffer.c \
upstream-freebsd/lib/libc/stdio/setvbuf.c \
upstream-freebsd/lib/libc/stdio/tempnam.c \
upstream-freebsd/lib/libc/stdio/tmpnam.c \
upstream-freebsd/lib/libc/stdio/wsetup.c \
upstream-freebsd/lib/libc/stdlib/abs.c \
upstream-freebsd/lib/libc/stdlib/getopt_long.c \
upstream-freebsd/lib/libc/stdlib/imaxabs.c \
upstream-freebsd/lib/libc/stdlib/imaxdiv.c \
upstream-freebsd/lib/libc/stdlib/labs.c \
upstream-freebsd/lib/libc/stdlib/llabs.c \
upstream-freebsd/lib/libc/stdlib/qsort.c \
upstream-freebsd/lib/libc/stdlib/realpath.c \
upstream-freebsd/lib/libc/string/wcpcpy.c \
upstream-freebsd/lib/libc/string/wcpncpy.c \
upstream-freebsd/lib/libc/string/wcscasecmp.c \
upstream-freebsd/lib/libc/string/wcscat.c \
upstream-freebsd/lib/libc/string/wcschr.c \
upstream-freebsd/lib/libc/string/wcscmp.c \
upstream-freebsd/lib/libc/string/wcscpy.c \
upstream-freebsd/lib/libc/string/wcscspn.c \
upstream-freebsd/lib/libc/string/wcsdup.c \
upstream-freebsd/lib/libc/string/wcslcat.c \
upstream-freebsd/lib/libc/string/wcslcpy.c \
upstream-freebsd/lib/libc/string/wcslen.c \
upstream-freebsd/lib/libc/string/wcsncasecmp.c \
upstream-freebsd/lib/libc/string/wcsncat.c \
upstream-freebsd/lib/libc/string/wcsncmp.c \
upstream-freebsd/lib/libc/string/wcsncpy.c \
upstream-freebsd/lib/libc/string/wcsnlen.c \
upstream-freebsd/lib/libc/string/wcspbrk.c \
upstream-freebsd/lib/libc/string/wcsrchr.c \
upstream-freebsd/lib/libc/string/wcsspn.c \
upstream-freebsd/lib/libc/string/wcsstr.c \
upstream-freebsd/lib/libc/string/wcstok.c \
upstream-freebsd/lib/libc/string/wmemchr.c \
upstream-freebsd/lib/libc/string/wmemcmp.c \
upstream-freebsd/lib/libc/string/wmemcpy.c \
upstream-freebsd/lib/libc/string/wmemmove.c \
upstream-freebsd/lib/libc/string/wmemset.c \
@@ -369,6 +367,23 @@ libc_common_src_files += \
bionic/memmove.c.arm \
string/bcopy.c \
string/strncmp.c \
string/strncat.c \
string/strncpy.c \
bionic/strchr.cpp \
string/strrchr.c \
bionic/memchr.c \
bionic/memrchr.c \
string/index.c \
bionic/strnlen.c \
string/strlcat.c \
string/strlcpy.c \
upstream-freebsd/lib/libc/string/wcschr.c \
upstream-freebsd/lib/libc/string/wcsrchr.c \
upstream-freebsd/lib/libc/string/wcscmp.c \
upstream-freebsd/lib/libc/string/wcscpy.c \
upstream-freebsd/lib/libc/string/wmemcmp.c \
upstream-freebsd/lib/libc/string/wcslen.c \
upstream-freebsd/lib/libc/string/wcscat.c
# These files need to be arm so that gdbserver
# can set breakpoints in them without messing
@@ -392,7 +407,6 @@ libc_common_src_files += \
bionic/pthread-rwlocks.c \
bionic/pthread-timers.c \
bionic/ptrace.c \
string/strcpy.c \
libc_static_common_src_files += \
bionic/pthread.c \
@@ -407,7 +421,25 @@ libc_common_src_files += \
string/bcopy.c \
string/strcmp.c \
string/strcpy.c \
string/strncmp.c
string/strncmp.c \
string/strcat.c \
string/strncat.c \
string/strncpy.c \
bionic/strchr.cpp \
string/strrchr.c \
bionic/memchr.c \
bionic/memrchr.c \
string/index.c \
bionic/strnlen.c \
string/strlcat.c \
string/strlcpy.c \
upstream-freebsd/lib/libc/string/wcschr.c \
upstream-freebsd/lib/libc/string/wcsrchr.c \
upstream-freebsd/lib/libc/string/wcscmp.c \
upstream-freebsd/lib/libc/string/wcscpy.c \
upstream-freebsd/lib/libc/string/wmemcmp.c \
upstream-freebsd/lib/libc/string/wcslen.c \
upstream-freebsd/lib/libc/string/wcscat.c
libc_common_src_files += \
bionic/pthread-atfork.c \
@@ -469,14 +501,6 @@ libc_common_cflags := \
-DLOG_ON_HEAP_ERROR \
-Wall -Wextra
# these macro definitions are required to implement the
# 'timezone' and 'daylight' global variables, as well as
# properly update the 'tm_gmtoff' field in 'struct tm'.
#
libc_common_cflags += \
-DTM_GMTOFF=tm_gmtoff \
-DUSG_COMPAT=1
ifeq ($(strip $(DEBUG_BIONIC_LIBC)),true)
libc_common_cflags += -DDEBUG
endif
@@ -554,23 +578,17 @@ libc_crt_target_cflags += \
# static C++ destructors are properly called on dlclose().
#
ifeq ($(TARGET_ARCH),arm)
libc_crtbegin_extension := c
libc_crt_target_so_cflags :=
endif
ifeq ($(TARGET_ARCH),mips)
libc_crtbegin_extension := S
libc_crt_target_so_cflags := -fPIC
endif
ifeq ($(TARGET_ARCH),x86)
libc_crtbegin_extension := c
libc_crt_target_so_cflags := -fPIC
endif
ifeq ($(libc_crtbegin_extension),)
$(error $(TARGET_ARCH) not supported)
endif
libc_crt_target_so_cflags += $(libc_crt_target_cflags)
libc_crt_target_crtbegin_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin.$(libc_crtbegin_extension)
libc_crt_target_crtbegin_so_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.$(libc_crtbegin_extension)
libc_crt_target_crtbegin_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin.c
libc_crt_target_crtbegin_so_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.c
# See the comment in crtbrand.c for the reason why we need to generate
# crtbrand.s before generating crtbrand.o.
@@ -686,6 +704,28 @@ LOCAL_SYSTEM_SHARED_LIBRARIES :=
include $(BUILD_STATIC_LIBRARY)
# ========================================================
# libc_tzcode.a - upstream 'tzcode' code
# ========================================================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(libc_tzcode_src_files)
LOCAL_CFLAGS := \
$(libc_common_cflags) \
-std=gnu99 \
-DSTD_INSPIRED=1 \
-DTZDIR=\"/system/usr/share/zoneinfo\" \
-DTM_GMTOFF=tm_gmtoff \
-DUSG_COMPAT=1
LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_MODULE := libc_tzcode
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_SYSTEM_SHARED_LIBRARIES :=
include $(BUILD_STATIC_LIBRARY)
# ========================================================
# libc_freebsd.a - upstream FreeBSD C library code
# ========================================================
@@ -761,7 +801,12 @@ LOCAL_CFLAGS := $(libc_common_cflags) \
LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_MODULE := libc_common
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_WHOLE_STATIC_LIBRARIES := libbionic_ssp libc_bionic libc_freebsd libc_netbsd
LOCAL_WHOLE_STATIC_LIBRARIES := \
libbionic_ssp \
libc_bionic \
libc_freebsd \
libc_netbsd \
libc_tzcode
LOCAL_SYSTEM_SHARED_LIBRARIES :=
# TODO: split out the asflags.

View File

@@ -1673,38 +1673,6 @@ SUCH DAMAGE.
-------------------------------------------------------------------
Copyright (c) 1990, 1993
The Regents of the University of California. All rights reserved.
This code is derived from software contributed to Berkeley by
Chris Torek.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
4. Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
-------------------------------------------------------------------
Copyright (c) 1990, 1993
The Regents of the University of California. All rights reserved.
@@ -2852,7 +2820,7 @@ are met:
2. Redistributions in binary form must reproduce the above copyright
notices, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
4. Neither the name of the University nor the names of its contributors
3. Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
@@ -3092,13 +3060,6 @@ are met:
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by the NetBSD
Foundation, Inc. and its contributors.
4. Neither the name of The NetBSD Foundation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
@@ -3916,6 +3877,36 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------
Copyright (c) 2010, 2011 Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------
Copyright (c) 2010, Intel Corporation
All rights reserved.
@@ -3946,6 +3937,36 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------
Copyright (c) 2011 Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------
Copyright (c) 2011 The Android Open Source Project
Copyright (c) 2008 ARM Ltd
All rights reserved.
@@ -3975,6 +3996,36 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------
Copyright (c) 2011, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------
Copyright (c) 2011, VMware, Inc.
All rights reserved.
@@ -4058,6 +4109,38 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------
Copyright (c) 2013, Linaro Limited
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Neither the name of Linaro Limited nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------
Copyright (c)1999 Citrus Project,
All rights reserved.

View File

@@ -201,6 +201,8 @@ int removexattr(const char *, const char *) 1
int lremovexattr(const char *, const char *) 1
int __statfs64:statfs64(const char *, size_t, struct statfs *) 1
long unshare(unsigned long) 1
int swapon(const char *, int) 1
int swapoff(const char *) 1
# time
int pause () 1
@@ -221,6 +223,9 @@ int __timer_getoverrun:timer_getoverrun(timer_t)
int __timer_delete:timer_delete(timer_t) 1
int utimes(const char*, const struct timeval tvp[2]) 1
int utimensat(int, const char *, const struct timespec times[2], int) 1
int timerfd_create(clockid_t, int) 1
int timerfd_settime(int, int, const struct itimerspec *, struct itimerspec *) 1
int timerfd_gettime(int, struct itimerspec *) 1
# signals
int sigaction(int, const struct sigaction *, struct sigaction *) 1

View File

@@ -14,8 +14,6 @@ _LIBC_ARCH_COMMON_SRC_FILES := \
arch-arm/bionic/_setjmp.S \
arch-arm/bionic/setjmp.S \
arch-arm/bionic/sigsetjmp.S \
arch-arm/bionic/strcpy.S \
arch-arm/bionic/strlen.c.arm \
arch-arm/bionic/syscall.S \
arch-arm/bionic/tgkill.S \
arch-arm/bionic/tkill.S \
@@ -28,8 +26,19 @@ _LIBC_ARCH_STATIC_SRC_FILES := \
_LIBC_ARCH_DYNAMIC_SRC_FILES := \
arch-arm/bionic/exidx_dynamic.c
# Remove the C++ fortify function implementations for which there is an
# arm assembler version.
_LIBC_FORTIFY_FILES_TO_REMOVE := \
bionic/__memcpy_chk.cpp \
bionic/__memset_chk.cpp \
bionic/__strcpy_chk.cpp \
bionic/__strcat_chk.cpp \
libc_common_src_files := \
$(filter-out $(_LIBC_FORTIFY_FILES_TO_REMOVE),$(libc_common_src_files))
ifeq ($(strip $(wildcard bionic/libc/arch-arm/$(TARGET_CPU_VARIANT)/$(TARGET_CPU_VARIANT).mk)),)
$(error "TARGET_CPU_VARIANT not set or set to an unknown value. Possible values are cortex-a9, cortex-a15, krait. Use generic for devices that do not have a CPU similar to any of the supported cpu variants.")
$(error "TARGET_CPU_VARIANT not set or set to an unknown value. Possible values are cortex-a7, cortex-a8, cortex-a9, cortex-a15, krait. Use generic for devices that do not have a CPU similar to any of the supported cpu variants.")
endif
include bionic/libc/arch-arm/$(TARGET_CPU_VARIANT)/$(TARGET_CPU_VARIANT).mk

View File

@@ -38,5 +38,5 @@
ENTRY(abort)
.save {r3, r14}
stmfd sp!, {r3, r14}
blx PIC_SYM(_C_LABEL(__libc_android_abort), PLT)
bl PIC_SYM(_C_LABEL(__libc_android_abort), PLT)
END(abort)

View File

@@ -32,33 +32,33 @@
// int __pthread_clone(void* (*fn)(void*), void* child_stack, int flags, void* arg);
ENTRY(__pthread_clone)
# Copy the args onto the new stack.
# Push 'fn' and 'arg' onto 'child_stack'.
stmdb r1!, {r0, r3}
# The sys_clone system call only takes two arguments: 'flags' and 'child_stack'.
# 'child_stack' is already in r1, but we need to move 'flags' into position.
mov r0, r2
stmfd sp!, {r4, r7}
# System call.
mov ip, r7
ldr r7, =__NR_clone
swi #0
# Child?
movs r0, r0
beq 1f
# In parent, reload saved registers then either return or set errno.
ldmfd sp!, {r4, r7}
# Parent.
mov r7, ip
cmn r0, #(MAX_ERRNO + 1)
bxls lr
neg r0, r0
b __set_errno
1: # The child.
# pick the function arg and call address off the stack and jump
# to the C __thread_entry function which does some setup and then
# calls the thread's start function
1: # Child.
# Pop 'fn' and 'arg' back off the stack and call __thread_entry.
pop {r0, r1}
# __thread_entry needs the TLS pointer
# __thread_entry also needs our stack pointer.
mov r2, sp
b __thread_entry
END(__pthread_clone)

View File

@@ -34,11 +34,10 @@
// __futex_syscall3(*ftx, op, val)
ENTRY(__futex_syscall3)
stmdb sp!, {r4, r7}
.save {r4, r7}
mov ip, r7
ldr r7, =__NR_futex
swi #0
ldmia sp!, {r4, r7}
mov r7, ip
bx lr
END(__futex_syscall3)
@@ -49,25 +48,23 @@ END(__futex_syscall4)
// __futex_wait(*ftx, val, *timespec)
ENTRY(__futex_wait)
stmdb sp!, {r4, r7}
.save {r4, r7}
mov ip, r7
mov r3, r2
mov r2, r1
mov r1, #FUTEX_WAIT
ldr r7, =__NR_futex
swi #0
ldmia sp!, {r4, r7}
mov r7, ip
bx lr
END(__futex_wait)
// __futex_wake(*ftx, counter)
ENTRY(__futex_wake)
.save {r4, r7}
stmdb sp!, {r4, r7}
mov ip, r7
mov r2, r1
mov r1, #FUTEX_WAKE
ldr r7, =__NR_futex
swi #0
ldmia sp!, {r4, r7}
mov r7, ip
bx lr
END(__futex_wake)

View File

@@ -30,8 +30,8 @@
* dynamic linker to copy their definition into the final libc.so binary.
*
* They are required to ensure backwards binary compatibility with
* Android 1.5, 1.6 and even 3.0 system images. Some applications built
* using the NDK require them to be here.
* libc.so provided by the platform and binaries built with the NDK or
* different versions/configurations of toolchains.
*
* Now, for a more elaborate description of the issue:
*
@@ -48,7 +48,9 @@
* gcc <options> -o libfoo.so foo.a libgcc.a -lc -lm
*
* This ensures that any helper function needed by the code in foo.a is copied
* into the final libfoo.so. Unfortunately, the Android build system has been
* into the final libfoo.so. However, doing so will link a bunch of other __cxa
* functions from libgcc.a into each .so and executable, causing 4k+ increase
* in every binary. Therefore the Android platform build system has been
* using this instead:
*
* gcc <options> -o libfoo.so foo.a -lc -lm libgcc.a
@@ -58,9 +60,10 @@
* into libfoo.so. Instead, a symbol import definition will be added to it
* so libfoo.so can directly call the one in libc.so at runtime.
*
* When changing toolchains for 2.0, the set of helper functions copied to
* libc.so changed, which resulted in some native shared libraries generated
* with the NDK to fail to load properly.
* When refreshing toolchains for new versions or using different architecture
* flags, the set of helper functions copied to libc.so may change, which
* resulted in some native shared libraries generated with the NDK or prebuilts
* from vendors to fail to load properly.
*
* The NDK has been fixed after 1.6_r1 to use the correct link command, so
* any native shared library generated with it should now be safe from that
@@ -73,6 +76,11 @@
* but it is easier to add a single function here than asking several app
* developers to fix their build.
*
* The __aeabi_idiv function is added to the list since cortex-a15 supports
* HW idiv instructions so the system libc.so doesn't pull in the reference to
* __aeabi_idiv but legacy libraries built against cortex-a9 targets still need
* it.
*
* Final note: some of the functions below should really be in libm.so to
* completely reflect the state of 1.5/1.6 system images. However,
* since libm.so depends on libc.so, it's easier to put all of
@@ -113,6 +121,7 @@
XX(__aeabi_idiv) \
XX(__aeabi_l2d) \
XX(__aeabi_l2f) \
XX(__aeabi_lasr) \
XX(__aeabi_lmul) \
XX(__aeabi_llsl) \
XX(__aeabi_llsr) \
@@ -123,7 +132,7 @@
XX(__cmpdf2) \
XX(__divdf3) \
XX(__divsf3) \
XX(__eqdf2) \
XX(__eqdf2) \
XX(__extendsfdf2) \
XX(__fixdfsi) \
XX(__fixsfsi) \

View File

@@ -0,0 +1,614 @@
/* Copyright (c) 2013, Linaro Limited
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Linaro Limited nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
This memcpy routine is optimised for Cortex-A15 cores and takes advantage
of VFP or NEON when built with the appropriate flags.
Assumptions:
ARMv6 (ARMv7-a if using Neon)
ARM state
Unaligned accesses
LDRD/STRD support unaligned word accesses
*/
#include <machine/cpu-features.h>
#include <machine/asm.h>
.syntax unified
/* This implementation requires ARM state. */
.arm
#ifdef __ARM_NEON__
.fpu neon
.arch armv7-a
# define FRAME_SIZE 4
# define USE_VFP
# define USE_NEON
#elif !defined (__SOFTFP__)
.arch armv6
.fpu vfpv2
# define FRAME_SIZE 32
# define USE_VFP
#else
.arch armv6
# define FRAME_SIZE 32
#endif
/* Old versions of GAS incorrectly implement the NEON align semantics. */
#ifdef BROKEN_ASM_NEON_ALIGN
#define ALIGN(addr, align) addr,:align
#else
#define ALIGN(addr, align) addr:align
#endif
#define PC_OFFSET 8 /* PC pipeline compensation. */
#define INSN_SIZE 4
/* Call parameters. */
#define dstin r0
#define src r1
#define count r2
/* Locals. */
#define tmp1 r3
#define dst ip
#define tmp2 r10
#ifndef USE_NEON
/* For bulk copies using GP registers. */
#define A_l r2 /* Call-clobbered. */
#define A_h r3 /* Call-clobbered. */
#define B_l r4
#define B_h r5
#define C_l r6
#define C_h r7
#define D_l r8
#define D_h r9
#endif
/* Number of lines ahead to pre-fetch data. If you change this the code
below will need adjustment to compensate. */
#define prefetch_lines 5
#ifdef USE_VFP
.macro cpy_line_vfp vreg, base
vstr \vreg, [dst, #\base]
vldr \vreg, [src, #\base]
vstr d0, [dst, #\base + 8]
vldr d0, [src, #\base + 8]
vstr d1, [dst, #\base + 16]
vldr d1, [src, #\base + 16]
vstr d2, [dst, #\base + 24]
vldr d2, [src, #\base + 24]
vstr \vreg, [dst, #\base + 32]
vldr \vreg, [src, #\base + prefetch_lines * 64 - 32]
vstr d0, [dst, #\base + 40]
vldr d0, [src, #\base + 40]
vstr d1, [dst, #\base + 48]
vldr d1, [src, #\base + 48]
vstr d2, [dst, #\base + 56]
vldr d2, [src, #\base + 56]
.endm
.macro cpy_tail_vfp vreg, base
vstr \vreg, [dst, #\base]
vldr \vreg, [src, #\base]
vstr d0, [dst, #\base + 8]
vldr d0, [src, #\base + 8]
vstr d1, [dst, #\base + 16]
vldr d1, [src, #\base + 16]
vstr d2, [dst, #\base + 24]
vldr d2, [src, #\base + 24]
vstr \vreg, [dst, #\base + 32]
vstr d0, [dst, #\base + 40]
vldr d0, [src, #\base + 40]
vstr d1, [dst, #\base + 48]
vldr d1, [src, #\base + 48]
vstr d2, [dst, #\base + 56]
vldr d2, [src, #\base + 56]
.endm
#endif
.p2align 6
ENTRY(memcpy)
mov dst, dstin /* Preserve dstin, we need to return it. */
cmp count, #64
bge .Lcpy_not_short
/* Deal with small copies quickly by dropping straight into the
exit block. */
.Ltail63unaligned:
#ifdef USE_NEON
and tmp1, count, #0x38
rsb tmp1, tmp1, #(56 - PC_OFFSET + INSN_SIZE)
add pc, pc, tmp1
vld1.8 {d0}, [src]! /* 14 words to go. */
vst1.8 {d0}, [dst]!
vld1.8 {d0}, [src]! /* 12 words to go. */
vst1.8 {d0}, [dst]!
vld1.8 {d0}, [src]! /* 10 words to go. */
vst1.8 {d0}, [dst]!
vld1.8 {d0}, [src]! /* 8 words to go. */
vst1.8 {d0}, [dst]!
vld1.8 {d0}, [src]! /* 6 words to go. */
vst1.8 {d0}, [dst]!
vld1.8 {d0}, [src]! /* 4 words to go. */
vst1.8 {d0}, [dst]!
vld1.8 {d0}, [src]! /* 2 words to go. */
vst1.8 {d0}, [dst]!
tst count, #4
ldrne tmp1, [src], #4
strne tmp1, [dst], #4
#else
/* Copy up to 15 full words of data. May not be aligned. */
/* Cannot use VFP for unaligned data. */
and tmp1, count, #0x3c
add dst, dst, tmp1
add src, src, tmp1
rsb tmp1, tmp1, #(60 - PC_OFFSET/2 + INSN_SIZE/2)
/* Jump directly into the sequence below at the correct offset. */
add pc, pc, tmp1, lsl #1
ldr tmp1, [src, #-60] /* 15 words to go. */
str tmp1, [dst, #-60]
ldr tmp1, [src, #-56] /* 14 words to go. */
str tmp1, [dst, #-56]
ldr tmp1, [src, #-52]
str tmp1, [dst, #-52]
ldr tmp1, [src, #-48] /* 12 words to go. */
str tmp1, [dst, #-48]
ldr tmp1, [src, #-44]
str tmp1, [dst, #-44]
ldr tmp1, [src, #-40] /* 10 words to go. */
str tmp1, [dst, #-40]
ldr tmp1, [src, #-36]
str tmp1, [dst, #-36]
ldr tmp1, [src, #-32] /* 8 words to go. */
str tmp1, [dst, #-32]
ldr tmp1, [src, #-28]
str tmp1, [dst, #-28]
ldr tmp1, [src, #-24] /* 6 words to go. */
str tmp1, [dst, #-24]
ldr tmp1, [src, #-20]
str tmp1, [dst, #-20]
ldr tmp1, [src, #-16] /* 4 words to go. */
str tmp1, [dst, #-16]
ldr tmp1, [src, #-12]
str tmp1, [dst, #-12]
ldr tmp1, [src, #-8] /* 2 words to go. */
str tmp1, [dst, #-8]
ldr tmp1, [src, #-4]
str tmp1, [dst, #-4]
#endif
lsls count, count, #31
ldrhcs tmp1, [src], #2
ldrbne src, [src] /* Src is dead, use as a scratch. */
strhcs tmp1, [dst], #2
strbne src, [dst]
bx lr
.Lcpy_not_short:
/* At least 64 bytes to copy, but don't know the alignment yet. */
str tmp2, [sp, #-FRAME_SIZE]!
and tmp2, src, #7
and tmp1, dst, #7
cmp tmp1, tmp2
bne .Lcpy_notaligned
#ifdef USE_VFP
/* Magic dust alert! Force VFP on Cortex-A9. Experiments show
that the FP pipeline is much better at streaming loads and
stores. This is outside the critical loop. */
vmov.f32 s0, s0
#endif
/* SRC and DST have the same mutual 32-bit alignment, but we may
still need to pre-copy some bytes to get to natural alignment.
We bring DST into full 64-bit alignment. */
lsls tmp2, dst, #29
beq 1f
rsbs tmp2, tmp2, #0
sub count, count, tmp2, lsr #29
ldrmi tmp1, [src], #4
strmi tmp1, [dst], #4
lsls tmp2, tmp2, #2
ldrhcs tmp1, [src], #2
ldrbne tmp2, [src], #1
strhcs tmp1, [dst], #2
strbne tmp2, [dst], #1
1:
subs tmp2, count, #64 /* Use tmp2 for count. */
blt .Ltail63aligned
cmp tmp2, #512
bge .Lcpy_body_long
.Lcpy_body_medium: /* Count in tmp2. */
#ifdef USE_VFP
1:
vldr d0, [src, #0]
subs tmp2, tmp2, #64
vldr d1, [src, #8]
vstr d0, [dst, #0]
vldr d0, [src, #16]
vstr d1, [dst, #8]
vldr d1, [src, #24]
vstr d0, [dst, #16]
vldr d0, [src, #32]
vstr d1, [dst, #24]
vldr d1, [src, #40]
vstr d0, [dst, #32]
vldr d0, [src, #48]
vstr d1, [dst, #40]
vldr d1, [src, #56]
vstr d0, [dst, #48]
add src, src, #64
vstr d1, [dst, #56]
add dst, dst, #64
bge 1b
tst tmp2, #0x3f
beq .Ldone
.Ltail63aligned: /* Count in tmp2. */
and tmp1, tmp2, #0x38
add dst, dst, tmp1
add src, src, tmp1
rsb tmp1, tmp1, #(56 - PC_OFFSET + INSN_SIZE)
add pc, pc, tmp1
vldr d0, [src, #-56] /* 14 words to go. */
vstr d0, [dst, #-56]
vldr d0, [src, #-48] /* 12 words to go. */
vstr d0, [dst, #-48]
vldr d0, [src, #-40] /* 10 words to go. */
vstr d0, [dst, #-40]
vldr d0, [src, #-32] /* 8 words to go. */
vstr d0, [dst, #-32]
vldr d0, [src, #-24] /* 6 words to go. */
vstr d0, [dst, #-24]
vldr d0, [src, #-16] /* 4 words to go. */
vstr d0, [dst, #-16]
vldr d0, [src, #-8] /* 2 words to go. */
vstr d0, [dst, #-8]
#else
sub src, src, #8
sub dst, dst, #8
1:
ldrd A_l, A_h, [src, #8]
strd A_l, A_h, [dst, #8]
ldrd A_l, A_h, [src, #16]
strd A_l, A_h, [dst, #16]
ldrd A_l, A_h, [src, #24]
strd A_l, A_h, [dst, #24]
ldrd A_l, A_h, [src, #32]
strd A_l, A_h, [dst, #32]
ldrd A_l, A_h, [src, #40]
strd A_l, A_h, [dst, #40]
ldrd A_l, A_h, [src, #48]
strd A_l, A_h, [dst, #48]
ldrd A_l, A_h, [src, #56]
strd A_l, A_h, [dst, #56]
ldrd A_l, A_h, [src, #64]!
strd A_l, A_h, [dst, #64]!
subs tmp2, tmp2, #64
bge 1b
tst tmp2, #0x3f
bne 1f
ldr tmp2,[sp], #FRAME_SIZE
bx lr
1:
add src, src, #8
add dst, dst, #8
.Ltail63aligned: /* Count in tmp2. */
/* Copy up to 7 d-words of data. Similar to Ltail63unaligned, but
we know that the src and dest are 32-bit aligned so we can use
LDRD/STRD to improve efficiency. */
/* TMP2 is now negative, but we don't care about that. The bottom
six bits still tell us how many bytes are left to copy. */
and tmp1, tmp2, #0x38
add dst, dst, tmp1
add src, src, tmp1
rsb tmp1, tmp1, #(56 - PC_OFFSET + INSN_SIZE)
add pc, pc, tmp1
ldrd A_l, A_h, [src, #-56] /* 14 words to go. */
strd A_l, A_h, [dst, #-56]
ldrd A_l, A_h, [src, #-48] /* 12 words to go. */
strd A_l, A_h, [dst, #-48]
ldrd A_l, A_h, [src, #-40] /* 10 words to go. */
strd A_l, A_h, [dst, #-40]
ldrd A_l, A_h, [src, #-32] /* 8 words to go. */
strd A_l, A_h, [dst, #-32]
ldrd A_l, A_h, [src, #-24] /* 6 words to go. */
strd A_l, A_h, [dst, #-24]
ldrd A_l, A_h, [src, #-16] /* 4 words to go. */
strd A_l, A_h, [dst, #-16]
ldrd A_l, A_h, [src, #-8] /* 2 words to go. */
strd A_l, A_h, [dst, #-8]
#endif
tst tmp2, #4
ldrne tmp1, [src], #4
strne tmp1, [dst], #4
lsls tmp2, tmp2, #31 /* Count (tmp2) now dead. */
ldrhcs tmp1, [src], #2
ldrbne tmp2, [src]
strhcs tmp1, [dst], #2
strbne tmp2, [dst]
.Ldone:
ldr tmp2, [sp], #FRAME_SIZE
bx lr
.Lcpy_body_long: /* Count in tmp2. */
/* Long copy. We know that there's at least (prefetch_lines * 64)
bytes to go. */
#ifdef USE_VFP
/* Don't use PLD. Instead, read some data in advance of the current
copy position into a register. This should act like a PLD
operation but we won't have to repeat the transfer. */
vldr d3, [src, #0]
vldr d4, [src, #64]
vldr d5, [src, #128]
vldr d6, [src, #192]
vldr d7, [src, #256]
vldr d0, [src, #8]
vldr d1, [src, #16]
vldr d2, [src, #24]
add src, src, #32
subs tmp2, tmp2, #prefetch_lines * 64 * 2
blt 2f
1:
cpy_line_vfp d3, 0
cpy_line_vfp d4, 64
cpy_line_vfp d5, 128
add dst, dst, #3 * 64
add src, src, #3 * 64
cpy_line_vfp d6, 0
cpy_line_vfp d7, 64
add dst, dst, #2 * 64
add src, src, #2 * 64
subs tmp2, tmp2, #prefetch_lines * 64
bge 1b
2:
cpy_tail_vfp d3, 0
cpy_tail_vfp d4, 64
cpy_tail_vfp d5, 128
add src, src, #3 * 64
add dst, dst, #3 * 64
cpy_tail_vfp d6, 0
vstr d7, [dst, #64]
vldr d7, [src, #64]
vstr d0, [dst, #64 + 8]
vldr d0, [src, #64 + 8]
vstr d1, [dst, #64 + 16]
vldr d1, [src, #64 + 16]
vstr d2, [dst, #64 + 24]
vldr d2, [src, #64 + 24]
vstr d7, [dst, #64 + 32]
add src, src, #96
vstr d0, [dst, #64 + 40]
vstr d1, [dst, #64 + 48]
vstr d2, [dst, #64 + 56]
add dst, dst, #128
add tmp2, tmp2, #prefetch_lines * 64
b .Lcpy_body_medium
#else
/* Long copy. Use an SMS style loop to maximize the I/O
bandwidth of the core. We don't have enough spare registers
to synthesise prefetching, so use PLD operations. */
/* Pre-bias src and dst. */
sub src, src, #8
sub dst, dst, #8
pld [src, #8]
pld [src, #72]
subs tmp2, tmp2, #64
pld [src, #136]
ldrd A_l, A_h, [src, #8]
strd B_l, B_h, [sp, #8]
ldrd B_l, B_h, [src, #16]
strd C_l, C_h, [sp, #16]
ldrd C_l, C_h, [src, #24]
strd D_l, D_h, [sp, #24]
pld [src, #200]
ldrd D_l, D_h, [src, #32]!
b 1f
.p2align 6
2:
pld [src, #232]
strd A_l, A_h, [dst, #40]
ldrd A_l, A_h, [src, #40]
strd B_l, B_h, [dst, #48]
ldrd B_l, B_h, [src, #48]
strd C_l, C_h, [dst, #56]
ldrd C_l, C_h, [src, #56]
strd D_l, D_h, [dst, #64]!
ldrd D_l, D_h, [src, #64]!
subs tmp2, tmp2, #64
1:
strd A_l, A_h, [dst, #8]
ldrd A_l, A_h, [src, #8]
strd B_l, B_h, [dst, #16]
ldrd B_l, B_h, [src, #16]
strd C_l, C_h, [dst, #24]
ldrd C_l, C_h, [src, #24]
strd D_l, D_h, [dst, #32]
ldrd D_l, D_h, [src, #32]
bcs 2b
/* Save the remaining bytes and restore the callee-saved regs. */
strd A_l, A_h, [dst, #40]
add src, src, #40
strd B_l, B_h, [dst, #48]
ldrd B_l, B_h, [sp, #8]
strd C_l, C_h, [dst, #56]
ldrd C_l, C_h, [sp, #16]
strd D_l, D_h, [dst, #64]
ldrd D_l, D_h, [sp, #24]
add dst, dst, #72
tst tmp2, #0x3f
bne .Ltail63aligned
ldr tmp2, [sp], #FRAME_SIZE
bx lr
#endif
.Lcpy_notaligned:
pld [src]
pld [src, #64]
/* There's at least 64 bytes to copy, but there is no mutual
alignment. */
/* Bring DST to 64-bit alignment. */
lsls tmp2, dst, #29
pld [src, #(2 * 64)]
beq 1f
rsbs tmp2, tmp2, #0
sub count, count, tmp2, lsr #29
ldrmi tmp1, [src], #4
strmi tmp1, [dst], #4
lsls tmp2, tmp2, #2
ldrbne tmp1, [src], #1
ldrhcs tmp2, [src], #2
strbne tmp1, [dst], #1
strhcs tmp2, [dst], #2
1:
pld [src, #(3 * 64)]
subs count, count, #64
ldrmi tmp2, [sp], #FRAME_SIZE
bmi .Ltail63unaligned
pld [src, #(4 * 64)]
#ifdef USE_NEON
vld1.8 {d0-d3}, [src]!
vld1.8 {d4-d7}, [src]!
subs count, count, #64
bmi 2f
1:
pld [src, #(4 * 64)]
vst1.8 {d0-d3}, [ALIGN (dst, 64)]!
vld1.8 {d0-d3}, [src]!
vst1.8 {d4-d7}, [ALIGN (dst, 64)]!
vld1.8 {d4-d7}, [src]!
subs count, count, #64
bpl 1b
2:
vst1.8 {d0-d3}, [ALIGN (dst, 64)]!
vst1.8 {d4-d7}, [ALIGN (dst, 64)]!
ands count, count, #0x3f
#else
/* Use an SMS style loop to maximize the I/O bandwidth. */
sub src, src, #4
sub dst, dst, #8
subs tmp2, count, #64 /* Use tmp2 for count. */
ldr A_l, [src, #4]
ldr A_h, [src, #8]
strd B_l, B_h, [sp, #8]
ldr B_l, [src, #12]
ldr B_h, [src, #16]
strd C_l, C_h, [sp, #16]
ldr C_l, [src, #20]
ldr C_h, [src, #24]
strd D_l, D_h, [sp, #24]
ldr D_l, [src, #28]
ldr D_h, [src, #32]!
b 1f
.p2align 6
2:
pld [src, #(5 * 64) - (32 - 4)]
strd A_l, A_h, [dst, #40]
ldr A_l, [src, #36]
ldr A_h, [src, #40]
strd B_l, B_h, [dst, #48]
ldr B_l, [src, #44]
ldr B_h, [src, #48]
strd C_l, C_h, [dst, #56]
ldr C_l, [src, #52]
ldr C_h, [src, #56]
strd D_l, D_h, [dst, #64]!
ldr D_l, [src, #60]
ldr D_h, [src, #64]!
subs tmp2, tmp2, #64
1:
strd A_l, A_h, [dst, #8]
ldr A_l, [src, #4]
ldr A_h, [src, #8]
strd B_l, B_h, [dst, #16]
ldr B_l, [src, #12]
ldr B_h, [src, #16]
strd C_l, C_h, [dst, #24]
ldr C_l, [src, #20]
ldr C_h, [src, #24]
strd D_l, D_h, [dst, #32]
ldr D_l, [src, #28]
ldr D_h, [src, #32]
bcs 2b
/* Save the remaining bytes and restore the callee-saved regs. */
strd A_l, A_h, [dst, #40]
add src, src, #36
strd B_l, B_h, [dst, #48]
ldrd B_l, B_h, [sp, #8]
strd C_l, C_h, [dst, #56]
ldrd C_l, C_h, [sp, #16]
strd D_l, D_h, [dst, #64]
ldrd D_l, D_h, [sp, #24]
add dst, dst, #72
ands count, tmp2, #0x3f
#endif
ldr tmp2, [sp], #FRAME_SIZE
bne .Ltail63unaligned
bx lr
END(memcpy)

View File

@@ -39,6 +39,7 @@
*/
ENTRY(tgkill)
.save {r4-r7, ip, lr}
stmfd sp!, {r4-r7, ip, lr}
ldr r7, =__NR_tgkill
swi #0

View File

@@ -0,0 +1,227 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#include "libc_events.h"
.syntax unified
.thumb
.thumb_func
// Get the length of src string, then get the source of the dst string.
// Check that the two lengths together don't exceed the threshold, then
// do a memcpy of the data.
ENTRY(__strcat_chk)
.cfi_startproc
pld [r0, #0]
push {r0, lr}
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
push {r4, r5}
.save {r4, r5}
.cfi_adjust_cfa_offset 8
.cfi_rel_offset r4, 0
.cfi_rel_offset r5, 4
mov lr, r2
// Save the dst register to r5
mov r5, r0
// Zero out r4
eor r4, r4, r4
// r1 contains the address of the string to count.
.L_strlen_start:
mov r0, r1
ands r3, r1, #7
beq .L_mainloop
// Align to a double word (64 bits).
rsb r3, r3, #8
lsls ip, r3, #31
beq .L_align_to_32
ldrb r2, [r1], #1
cbz r2, .L_update_count_and_finish
.L_align_to_32:
bcc .L_align_to_64
ands ip, r3, #2
beq .L_align_to_64
ldrb r2, [r1], #1
cbz r2, .L_update_count_and_finish
ldrb r2, [r1], #1
cbz r2, .L_update_count_and_finish
.L_align_to_64:
tst r3, #4
beq .L_mainloop
ldr r3, [r1], #4
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne .L_zero_in_second_register
.p2align 2
.L_mainloop:
ldrd r2, r3, [r1], #8
pld [r1, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne .L_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne .L_zero_in_second_register
b .L_mainloop
.L_update_count_and_finish:
sub r3, r1, r0
sub r3, r3, #1
b .L_finish
.L_zero_in_first_register:
sub r3, r1, r0
lsls r2, ip, #17
bne .L_sub8_and_finish
bcs .L_sub7_and_finish
lsls ip, ip, #1
bne .L_sub6_and_finish
sub r3, r3, #5
b .L_finish
.L_sub8_and_finish:
sub r3, r3, #8
b .L_finish
.L_sub7_and_finish:
sub r3, r3, #7
b .L_finish
.L_sub6_and_finish:
sub r3, r3, #6
b .L_finish
.L_zero_in_second_register:
sub r3, r1, r0
lsls r2, ip, #17
bne .L_sub4_and_finish
bcs .L_sub3_and_finish
lsls ip, ip, #1
bne .L_sub2_and_finish
sub r3, r3, #1
b .L_finish
.L_sub4_and_finish:
sub r3, r3, #4
b .L_finish
.L_sub3_and_finish:
sub r3, r3, #3
b .L_finish
.L_sub2_and_finish:
sub r3, r3, #2
.L_finish:
cmp r4, #0
bne .L_strlen_done
// Time to get the dst string length.
mov r1, r5
// Save the original source address to r5.
mov r5, r0
// Save the current length (adding 1 for the terminator).
add r4, r3, #1
b .L_strlen_start
// r0 holds the pointer to the dst string.
// r3 holds the dst string length.
// r4 holds the src string length + 1.
.L_strlen_done:
add r2, r3, r4
cmp r2, lr
bhi __strcat_chk_failed
// Set up the registers for the memcpy code.
mov r1, r5
pld [r1, #64]
mov r2, r4
add r0, r0, r3
pop {r4, r5}
.cfi_endproc
END(__strcat_chk)
#define MEMCPY_BASE __strcat_chk_memcpy_base
#define MEMCPY_BASE_ALIGNED __strcat_chk_memcpy_base_aligned
#include "memcpy_base.S"
ENTRY(__strcat_chk_failed)
.cfi_startproc
.save {r0, lr}
.save {r4, r5}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
.cfi_adjust_cfa_offset 8
.cfi_rel_offset r4, 0
.cfi_rel_offset r5, 4
ldr r0, error_message
ldr r1, error_code
1:
add r0, pc
bl __fortify_chk_fail
error_code:
.word BIONIC_EVENT_STRCAT_BUFFER_OVERFLOW
error_message:
.word error_string-(1b+4)
.cfi_endproc
END(__strcat_chk_failed)
.data
error_string:
.string "strcat buffer overflow"

View File

@@ -0,0 +1,188 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#include "libc_events.h"
.syntax unified
.thumb
.thumb_func
// Get the length of the source string first, then do a memcpy of the data
// instead of a strcpy.
ENTRY(__strcpy_chk)
.cfi_startproc
pld [r0, #0]
push {r0, lr}
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
mov lr, r2
mov r0, r1
ands r3, r1, #7
beq .L_mainloop
// Align to a double word (64 bits).
rsb r3, r3, #8
lsls ip, r3, #31
beq .L_align_to_32
ldrb r2, [r0], #1
cbz r2, .L_update_count_and_finish
.L_align_to_32:
bcc .L_align_to_64
ands ip, r3, #2
beq .L_align_to_64
ldrb r2, [r0], #1
cbz r2, .L_update_count_and_finish
ldrb r2, [r0], #1
cbz r2, .L_update_count_and_finish
.L_align_to_64:
tst r3, #4
beq .L_mainloop
ldr r3, [r0], #4
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne .L_zero_in_second_register
.p2align 2
.L_mainloop:
ldrd r2, r3, [r0], #8
pld [r0, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne .L_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne .L_zero_in_second_register
b .L_mainloop
.L_update_count_and_finish:
sub r3, r0, r1
sub r3, r3, #1
b .L_check_size
.L_zero_in_first_register:
sub r3, r0, r1
lsls r2, ip, #17
bne .L_sub8_and_finish
bcs .L_sub7_and_finish
lsls ip, ip, #1
bne .L_sub6_and_finish
sub r3, r3, #5
b .L_check_size
.L_sub8_and_finish:
sub r3, r3, #8
b .L_check_size
.L_sub7_and_finish:
sub r3, r3, #7
b .L_check_size
.L_sub6_and_finish:
sub r3, r3, #6
b .L_check_size
.L_zero_in_second_register:
sub r3, r0, r1
lsls r2, ip, #17
bne .L_sub4_and_finish
bcs .L_sub3_and_finish
lsls ip, ip, #1
bne .L_sub2_and_finish
sub r3, r3, #1
b .L_check_size
.L_sub4_and_finish:
sub r3, r3, #4
b .L_check_size
.L_sub3_and_finish:
sub r3, r3, #3
b .L_check_size
.L_sub2_and_finish:
sub r3, r3, #2
.L_check_size:
pld [r1, #0]
pld [r1, #64]
ldr r0, [sp]
cmp r3, lr
bhs __strcpy_chk_failed
// Add 1 for copy length to get the string terminator.
add r2, r3, #1
.cfi_endproc
END(__strcpy_chk)
#define MEMCPY_BASE __strcpy_chk_memcpy_base
#define MEMCPY_BASE_ALIGNED __strcpy_chk_memcpy_base_aligned
#include "memcpy_base.S"
ENTRY(__strcpy_chk_failed)
.cfi_startproc
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
ldr r0, error_message
ldr r1, error_code
1:
add r0, pc
bl __fortify_chk_fail
error_code:
.word BIONIC_EVENT_STRCPY_BUFFER_OVERFLOW
error_message:
.word error_string-(1b+4)
.cfi_endproc
END(__strcpy_chk_failed)
.data
error_string:
.string "strcpy buffer overflow"

View File

@@ -25,122 +25,88 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* Assumes neon instructions and a cache line size of 64 bytes. */
#include <machine/cpu-features.h>
#include <machine/asm.h>
/*
* This code assumes it is running on a processor that supports all arm v7
* instructions, that supports neon instructions, and that has a 64 byte
* cache line.
* Copyright (c) 2013 ARM Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the company may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// Prototype: void *memcpy (void *dst, const void *src, size_t count).
#include <machine/asm.h>
#include "libc_events.h"
.text
.syntax unified
.fpu neon
#define CACHE_LINE_SIZE 64
ENTRY(__memcpy_chk)
.cfi_startproc
cmp r2, r3
bhi __memcpy_chk_fail
// Fall through to memcpy...
.cfi_endproc
END(__memcpy_chk)
ENTRY(memcpy)
.save {r0, lr}
/* start preloading as early as possible */
pld [r1, #(CACHE_LINE_SIZE*0)]
stmfd sp!, {r0, lr}
pld [r1, #(CACHE_LINE_SIZE*1)]
.cfi_startproc
pld [r1, #64]
push {r0, lr}
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
/* do we have at least 16-bytes to copy (needed for alignment below) */
cmp r2, #16
blo 5f
/* align destination to cache-line for the write-buffer */
rsb r3, r0, #0
ands r3, r3, #0xF
beq 0f
/* copy up to 15-bytes (count in r3) */
sub r2, r2, r3
movs ip, r3, lsl #31
ldrmib lr, [r1], #1
strmib lr, [r0], #1
ldrcsb ip, [r1], #1
ldrcsb lr, [r1], #1
strcsb ip, [r0], #1
strcsb lr, [r0], #1
movs ip, r3, lsl #29
bge 1f
// copies 4 bytes, destination 32-bits aligned
vld4.8 {d0[0], d1[0], d2[0], d3[0]}, [r1]!
vst4.8 {d0[0], d1[0], d2[0], d3[0]}, [r0, :32]!
1: bcc 2f
// copies 8 bytes, destination 64-bits aligned
vld1.8 {d0}, [r1]!
vst1.8 {d0}, [r0, :64]!
2:
0: /* preload immediately the next cache line, which we may need */
pld [r1, #(CACHE_LINE_SIZE*0)]
pld [r1, #(CACHE_LINE_SIZE*1)]
/* make sure we have at least 64 bytes to copy */
subs r2, r2, #64
blo 2f
/* Preload all the cache lines we need.
* NOTE: The number of pld below depends on CACHE_LINE_SIZE,
* ideally we would increase the distance in the main loop to
* avoid the goofy code below. In practice this doesn't seem to make
* a big difference.
* NOTE: The value CACHE_LINE_SIZE * 4 was chosen through
* experimentation.
*/
pld [r1, #(CACHE_LINE_SIZE*2)]
pld [r1, #(CACHE_LINE_SIZE*3)]
pld [r1, #(CACHE_LINE_SIZE*4)]
1: /* The main loop copies 64 bytes at a time */
vld1.8 {d0 - d3}, [r1]!
vld1.8 {d4 - d7}, [r1]!
pld [r1, #(CACHE_LINE_SIZE*4)]
subs r2, r2, #64
vst1.8 {d0 - d3}, [r0, :128]!
vst1.8 {d4 - d7}, [r0, :128]!
bhs 1b
2: /* fix-up the remaining count and make sure we have >= 32 bytes left */
add r2, r2, #64
subs r2, r2, #32
blo 4f
3: /* 32 bytes at a time. These cache lines were already preloaded */
vld1.8 {d0 - d3}, [r1]!
subs r2, r2, #32
vst1.8 {d0 - d3}, [r0, :128]!
bhs 3b
4: /* less than 32 left */
add r2, r2, #32
tst r2, #0x10
beq 5f
// copies 16 bytes, 128-bits aligned
vld1.8 {d0, d1}, [r1]!
vst1.8 {d0, d1}, [r0, :128]!
5: /* copy up to 15-bytes (count in r2) */
movs ip, r2, lsl #29
bcc 1f
vld1.8 {d0}, [r1]!
vst1.8 {d0}, [r0]!
1: bge 2f
vld4.8 {d0[0], d1[0], d2[0], d3[0]}, [r1]!
vst4.8 {d0[0], d1[0], d2[0], d3[0]}, [r0]!
2: movs ip, r2, lsl #31
ldrmib r3, [r1], #1
ldrcsb ip, [r1], #1
ldrcsb lr, [r1], #1
strmib r3, [r0], #1
strcsb ip, [r0], #1
strcsb lr, [r0], #1
ldmfd sp!, {r0, lr}
bx lr
.cfi_endproc
END(memcpy)
#define MEMCPY_BASE __memcpy_base
#define MEMCPY_BASE_ALIGNED __memcpy_base_aligned
#include "memcpy_base.S"
ENTRY(__memcpy_chk_fail)
.cfi_startproc
// Preserve lr for backtrace.
push {lr}
.save {lr}
.cfi_def_cfa_offset 4
.cfi_rel_offset lr, 0
ldr r0, error_message
ldr r1, error_code
1:
add r0, pc
bl __fortify_chk_fail
error_code:
.word BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW
error_message:
.word error_string-(1b+8)
.cfi_endproc
END(__memcpy_chk_fail)
.data
error_string:
.string "memcpy buffer overflow"

View File

@@ -0,0 +1,327 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Copyright (c) 2013 ARM Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the company may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
ENTRY(MEMCPY_BASE)
.cfi_startproc
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
// Assumes that n >= 0, and dst, src are valid pointers.
// For any sizes less than 832 use the neon code that doesn't
// care about the src alignment. This avoids any checks
// for src alignment, and offers the best improvement since
// smaller sized copies are dominated by the overhead of
// the pre and post main loop.
// For larger copies, if src and dst cannot both be aligned to
// word boundaries, use the neon code.
// For all other copies, align dst to a double word boundary
// and copy using LDRD/STRD instructions.
cmp r2, #16
blo .L_copy_less_than_16_unknown_align
cmp r2, #832
bge .L_check_alignment
.L_copy_unknown_alignment:
// Unknown alignment of src and dst.
// Assumes that the first few bytes have already been prefetched.
// Align destination to 128 bits. The mainloop store instructions
// require this alignment or they will throw an exception.
rsb r3, r0, #0
ands r3, r3, #0xF
beq 2f
// Copy up to 15 bytes (count in r3).
sub r2, r2, r3
movs ip, r3, lsl #31
itt mi
ldrbmi lr, [r1], #1
strbmi lr, [r0], #1
itttt cs
ldrbcs ip, [r1], #1
ldrbcs lr, [r1], #1
strbcs ip, [r0], #1
strbcs lr, [r0], #1
movs ip, r3, lsl #29
bge 1f
// Copies 4 bytes, dst 32 bits aligned before, at least 64 bits after.
vld4.8 {d0[0], d1[0], d2[0], d3[0]}, [r1]!
vst4.8 {d0[0], d1[0], d2[0], d3[0]}, [r0, :32]!
1: bcc 2f
// Copies 8 bytes, dst 64 bits aligned before, at least 128 bits after.
vld1.8 {d0}, [r1]!
vst1.8 {d0}, [r0, :64]!
2: // Make sure we have at least 64 bytes to copy.
subs r2, r2, #64
blo 2f
1: // The main loop copies 64 bytes at a time.
vld1.8 {d0 - d3}, [r1]!
vld1.8 {d4 - d7}, [r1]!
pld [r1, #(64*4)]
subs r2, r2, #64
vst1.8 {d0 - d3}, [r0, :128]!
vst1.8 {d4 - d7}, [r0, :128]!
bhs 1b
2: // Fix-up the remaining count and make sure we have >= 32 bytes left.
adds r2, r2, #32
blo 3f
// 32 bytes. These cache lines were already preloaded.
vld1.8 {d0 - d3}, [r1]!
sub r2, r2, #32
vst1.8 {d0 - d3}, [r0, :128]!
3: // Less than 32 left.
add r2, r2, #32
tst r2, #0x10
beq .L_copy_less_than_16_unknown_align
// Copies 16 bytes, destination 128 bits aligned.
vld1.8 {d0, d1}, [r1]!
vst1.8 {d0, d1}, [r0, :128]!
.L_copy_less_than_16_unknown_align:
// Copy up to 15 bytes (count in r2).
movs ip, r2, lsl #29
bcc 1f
vld1.8 {d0}, [r1]!
vst1.8 {d0}, [r0]!
1: bge 2f
vld4.8 {d0[0], d1[0], d2[0], d3[0]}, [r1]!
vst4.8 {d0[0], d1[0], d2[0], d3[0]}, [r0]!
2: // Copy 0 to 4 bytes.
lsls r2, r2, #31
itt ne
ldrbne lr, [r1], #1
strbne lr, [r0], #1
itttt cs
ldrbcs ip, [r1], #1
ldrbcs lr, [r1]
strbcs ip, [r0], #1
strbcs lr, [r0]
pop {r0, pc}
.L_check_alignment:
// If src and dst cannot both be aligned to a word boundary,
// use the unaligned copy version.
eor r3, r0, r1
ands r3, r3, #0x3
bne .L_copy_unknown_alignment
.cfi_endproc
END(MEMCPY_BASE)
ENTRY(MEMCPY_BASE_ALIGNED)
.cfi_startproc
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
// To try and improve performance, stack layout changed,
// i.e., not keeping the stack looking like users expect
// (highest numbered register at highest address).
strd r4, r5, [sp, #-8]!
.save {r4, r5}
.cfi_adjust_cfa_offset 8
.cfi_rel_offset r4, 0
.cfi_rel_offset r5, 4
strd r6, r7, [sp, #-8]!
.save {r6, r7}
.cfi_adjust_cfa_offset 8
.cfi_rel_offset r6, 0
.cfi_rel_offset r7, 0
strd r8, r9, [sp, #-8]!
.save {r8, r9}
.cfi_adjust_cfa_offset 8
.cfi_rel_offset r8, 0
.cfi_rel_offset r9, 4
// Optimized for already aligned dst code.
ands ip, r0, #3
bne .L_dst_not_word_aligned
.L_word_aligned:
// Align the destination buffer to 8 bytes, to make sure double
// loads and stores don't cross a cache line boundary,
// as they are then more expensive even if the data is in the cache
// (require two load/store issue cycles instead of one).
// If only one of the buffers is not 8 bytes aligned,
// then it's more important to align dst than src,
// because there is more penalty for stores
// than loads that cross a cacheline boundary.
// This check and realignment are only done if there is >= 832
// bytes to copy.
// Dst is word aligned, but check if it is already double word aligned.
ands r3, r0, #4
beq 1f
ldr r3, [r1], #4
str r3, [r0], #4
sub r2, #4
1: // Can only get here if > 64 bytes to copy, so don't do check r2.
sub r2, #64
2: // Every loop iteration copies 64 bytes.
.irp offset, #0, #8, #16, #24, #32
ldrd r4, r5, [r1, \offset]
strd r4, r5, [r0, \offset]
.endr
ldrd r4, r5, [r1, #40]
ldrd r6, r7, [r1, #48]
ldrd r8, r9, [r1, #56]
// Keep the pld as far from the next load as possible.
// The amount to prefetch was determined experimentally using
// large sizes, and verifying the prefetch size does not affect
// the smaller copies too much.
// WARNING: If the ldrd and strd instructions get too far away
// from each other, performance suffers. Three loads
// in a row is the best tradeoff.
pld [r1, #(64*16)]
strd r4, r5, [r0, #40]
strd r6, r7, [r0, #48]
strd r8, r9, [r0, #56]
add r0, r0, #64
add r1, r1, #64
subs r2, r2, #64
bge 2b
// Fix-up the remaining count and make sure we have >= 32 bytes left.
adds r2, r2, #32
blo 4f
// Copy 32 bytes. These cache lines were already preloaded.
.irp offset, #0, #8, #16, #24
ldrd r4, r5, [r1, \offset]
strd r4, r5, [r0, \offset]
.endr
add r1, r1, #32
add r0, r0, #32
sub r2, r2, #32
4: // Less than 32 left.
add r2, r2, #32
tst r2, #0x10
beq 5f
// Copy 16 bytes.
.irp offset, #0, #8
ldrd r4, r5, [r1, \offset]
strd r4, r5, [r0, \offset]
.endr
add r1, r1, #16
add r0, r0, #16
5: // Copy up to 15 bytes (count in r2).
movs ip, r2, lsl #29
bcc 1f
// Copy 8 bytes.
ldrd r4, r5, [r1], #8
strd r4, r5, [r0], #8
1: bge 2f
// Copy 4 bytes.
ldr r4, [r1], #4
str r4, [r0], #4
2: // Copy 0 to 4 bytes.
lsls r2, r2, #31
itt ne
ldrbne lr, [r1], #1
strbne lr, [r0], #1
itttt cs
ldrbcs ip, [r1], #1
ldrbcs lr, [r1]
strbcs ip, [r0], #1
strbcs lr, [r0]
// Restore registers: optimized pop {r0, pc}
ldrd r8, r9, [sp], #8
ldrd r6, r7, [sp], #8
ldrd r4, r5, [sp], #8
pop {r0, pc}
.L_dst_not_word_aligned:
// Align dst to word.
rsb ip, ip, #4
cmp ip, #2
itt gt
ldrbgt lr, [r1], #1
strbgt lr, [r0], #1
itt ge
ldrbge lr, [r1], #1
strbge lr, [r0], #1
ldrb lr, [r1], #1
strb lr, [r0], #1
sub r2, r2, ip
// Src is guaranteed to be at least word aligned by this point.
b .L_word_aligned
.cfi_endproc
END(MEMCPY_BASE_ALIGNED)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -28,79 +28,173 @@
#include <machine/cpu-features.h>
#include <machine/asm.h>
#include "libc_events.h"
/*
* Optimized memset() for ARM.
/*
* Optimized memset() for ARM.
*
* memset() returns its first argument.
*/
*/
.fpu neon
.fpu neon
.syntax unified
ENTRY(__memset_chk)
.cfi_startproc
cmp r2, r3
bls .L_done
// Preserve lr for backtrace.
.save {lr}
push {lr}
.cfi_def_cfa_offset 4
.cfi_rel_offset lr, 0
ldr r0, error_message
ldr r1, error_code
1:
add r0, pc
bl __fortify_chk_fail
error_code:
.word BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW
error_message:
.word error_string-(1b+8)
.cfi_endproc
END(__memset_chk)
ENTRY(bzero)
mov r2, r1
mov r1, #0
.cfi_startproc
mov r2, r1
mov r1, #0
.L_done:
// Fall through to memset...
.cfi_endproc
END(bzero)
ENTRY(memset)
.cfi_startproc
.save {r0}
stmfd sp!, {r0}
.cfi_def_cfa_offset 4
.cfi_rel_offset r0, 0
vdup.8 q0, r1
/* do we have at least 16-bytes to write (needed for alignment below) */
// The new algorithm is slower for copies < 16 so use the old
// neon code in that case.
cmp r2, #16
blo 3f
blo .L_set_less_than_16_unknown_align
/* align destination to 16 bytes for the write-buffer */
rsb r3, r0, #0
ands r3, r3, #0xF
beq 2f
// Use strd which requires an even and odd register so move the
// values so that:
// r0 and r1 contain the memset value
// r2 is the number of bytes to set
// r3 is the destination pointer
mov r3, r0
/* write up to 15-bytes (count in r3) */
sub r2, r2, r3
movs ip, r3, lsl #31
strmib r1, [r0], #1
strcsb r1, [r0], #1
strcsb r1, [r0], #1
movs ip, r3, lsl #29
bge 1f
// Copy the byte value in every byte of r1.
mov r1, r1, lsl #24
orr r1, r1, r1, lsr #8
orr r1, r1, r1, lsr #16
// writes 4 bytes, 32-bits aligned
vst1.32 {d0[0]}, [r0, :32]!
1: bcc 2f
.L_check_alignment:
// Align destination to a double word to avoid the strd crossing
// a cache line boundary.
ands ip, r3, #7
bne .L_do_double_word_align
// writes 8 bytes, 64-bits aligned
vst1.8 {d0}, [r0, :64]!
2:
/* make sure we have at least 32 bytes to write */
subs r2, r2, #32
blo 2f
vmov q1, q0
.L_double_word_aligned:
mov r0, r1
1: /* The main loop writes 32 bytes at a time */
subs r2, r2, #32
vst1.8 {d0 - d3}, [r0, :128]!
bhs 1b
subs r2, #64
blo .L_set_less_than_64
2: /* less than 32 left */
add r2, r2, #32
tst r2, #0x10
beq 3f
1: // Main loop sets 64 bytes at a time.
.irp offset, #0, #8, #16, #24, #32, #40, #48, #56
strd r0, r1, [r3, \offset]
.endr
// writes 16 bytes, 128-bits aligned
vst1.8 {d0, d1}, [r0, :128]!
3: /* write up to 15-bytes (count in r2) */
add r3, #64
subs r2, #64
bge 1b
.L_set_less_than_64:
// Restore r2 to the count of bytes left to set.
add r2, #64
lsls ip, r2, #27
bcc .L_set_less_than_32
// Set 32 bytes.
.irp offset, #0, #8, #16, #24
strd r0, r1, [r3, \offset]
.endr
add r3, #32
.L_set_less_than_32:
bpl .L_set_less_than_16
// Set 16 bytes.
.irp offset, #0, #8
strd r0, r1, [r3, \offset]
.endr
add r3, #16
.L_set_less_than_16:
// Less than 16 bytes to set.
lsls ip, r2, #29
bcc .L_set_less_than_8
// Set 8 bytes.
strd r0, r1, [r3], #8
.L_set_less_than_8:
bpl .L_set_less_than_4
// Set 4 bytes
str r1, [r3], #4
.L_set_less_than_4:
lsls ip, r2, #31
it ne
strbne r1, [r3], #1
itt cs
strbcs r1, [r3], #1
strbcs r1, [r3]
ldmfd sp!, {r0}
bx lr
.L_do_double_word_align:
rsb ip, ip, #8
sub r2, r2, ip
movs r0, ip, lsl #31
it mi
strbmi r1, [r3], #1
itt cs
strbcs r1, [r3], #1
strbcs r1, [r3], #1
// Dst is at least word aligned by this point.
cmp ip, #4
blo .L_double_word_aligned
str r1, [r3], #4
b .L_double_word_aligned
.L_set_less_than_16_unknown_align:
// Set up to 15 bytes.
vdup.8 d0, r1
movs ip, r2, lsl #29
bcc 1f
vst1.8 {d0}, [r0]!
1: bge 2f
vst1.32 {d0[0]}, [r0]!
2: movs ip, r2, lsl #31
strmib r1, [r0], #1
strcsb r1, [r0], #1
strcsb r1, [r0], #1
it mi
strbmi r1, [r0], #1
itt cs
strbcs r1, [r0], #1
strbcs r1, [r0], #1
ldmfd sp!, {r0}
bx lr
.cfi_endproc
END(memset)
.data
error_string:
.string "memset buffer overflow"

View File

@@ -0,0 +1,568 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Copyright (c) 2013 ARM Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the company may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
.syntax unified
.thumb
.thumb_func
.macro m_push
push {r0, r4, r5, lr}
.endm // m_push
.macro m_pop
pop {r0, r4, r5, pc}
.endm // m_pop
.macro m_scan_byte
ldrb r3, [r0]
cbz r3, strcat_r0_scan_done
add r0, #1
.endm // m_scan_byte
.macro m_copy_byte reg, cmd, label
ldrb \reg, [r1], #1
strb \reg, [r0], #1
\cmd \reg, \label
.endm // m_copy_byte
ENTRY(strcat)
// Quick check to see if src is empty.
ldrb r2, [r1]
pld [r1, #0]
cbnz r2, strcat_continue
bx lr
strcat_continue:
// To speed up really small dst strings, unroll checking the first 4 bytes.
m_push
m_scan_byte
m_scan_byte
m_scan_byte
m_scan_byte
ands r3, r0, #7
beq strcat_mainloop
// Align to a double word (64 bits).
rsb r3, r3, #8
lsls ip, r3, #31
beq strcat_align_to_32
ldrb r5, [r0]
cbz r5, strcat_r0_scan_done
add r0, r0, #1
strcat_align_to_32:
bcc strcat_align_to_64
ldrb r2, [r0]
cbz r2, strcat_r0_scan_done
add r0, r0, #1
ldrb r4, [r0]
cbz r4, strcat_r0_scan_done
add r0, r0, #1
strcat_align_to_64:
tst r3, #4
beq strcat_mainloop
ldr r3, [r0], #4
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcat_zero_in_second_register
b strcat_mainloop
strcat_r0_scan_done:
// For short copies, hard-code checking the first 8 bytes since this
// new code doesn't win until after about 8 bytes.
m_copy_byte reg=r2, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r3, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r4, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r5, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r2, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r3, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r4, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r5, cmd=cbnz, label=strcpy_continue
strcpy_finish:
m_pop
strcpy_continue:
ands r3, r0, #7
beq strcpy_check_src_align
// Align to a double word (64 bits).
rsb r3, r3, #8
lsls ip, r3, #31
beq strcpy_align_to_32
ldrb r2, [r1], #1
strb r2, [r0], #1
cbz r2, strcpy_complete
strcpy_align_to_32:
bcc strcpy_align_to_64
ldrb r2, [r1], #1
strb r2, [r0], #1
cbz r2, strcpy_complete
ldrb r2, [r1], #1
strb r2, [r0], #1
cbz r2, strcpy_complete
strcpy_align_to_64:
tst r3, #4
beq strcpy_check_src_align
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
str r2, [r0], #4
strcpy_check_src_align:
// At this point dst is aligned to a double word, check if src
// is also aligned to a double word.
ands r3, r1, #7
bne strcpy_unaligned_copy
.p2align 2
strcpy_mainloop:
ldrd r2, r3, [r1], #8
pld [r1, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
strd r2, r3, [r0], #8
b strcpy_mainloop
strcpy_complete:
m_pop
strcpy_zero_in_first_register:
lsls lr, ip, #17
bne strcpy_copy1byte
bcs strcpy_copy2bytes
lsls ip, ip, #1
bne strcpy_copy3bytes
strcpy_copy4bytes:
// Copy 4 bytes to the destiniation.
str r2, [r0]
m_pop
strcpy_copy1byte:
strb r2, [r0]
m_pop
strcpy_copy2bytes:
strh r2, [r0]
m_pop
strcpy_copy3bytes:
strh r2, [r0], #2
lsr r2, #16
strb r2, [r0]
m_pop
strcpy_zero_in_second_register:
lsls lr, ip, #17
bne strcpy_copy5bytes
bcs strcpy_copy6bytes
lsls ip, ip, #1
bne strcpy_copy7bytes
// Copy 8 bytes to the destination.
strd r2, r3, [r0]
m_pop
strcpy_copy5bytes:
str r2, [r0], #4
strb r3, [r0]
m_pop
strcpy_copy6bytes:
str r2, [r0], #4
strh r3, [r0]
m_pop
strcpy_copy7bytes:
str r2, [r0], #4
strh r3, [r0], #2
lsr r3, #16
strb r3, [r0]
m_pop
strcpy_unaligned_copy:
// Dst is aligned to a double word, while src is at an unknown alignment.
// There are 7 different versions of the unaligned copy code
// to prevent overreading the src. The mainloop of every single version
// will store 64 bits per loop. The difference is how much of src can
// be read without potentially crossing a page boundary.
tbb [pc, r3]
strcpy_unaligned_branchtable:
.byte 0
.byte ((strcpy_unalign7 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign6 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign5 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign4 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign3 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign2 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign1 - strcpy_unaligned_branchtable)/2)
.p2align 2
// Can read 7 bytes before possibly crossing a page.
strcpy_unalign7:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldrb r3, [r1]
cbz r3, strcpy_unalign7_copy5bytes
ldrb r4, [r1, #1]
cbz r4, strcpy_unalign7_copy6bytes
ldrb r5, [r1, #2]
cbz r5, strcpy_unalign7_copy7bytes
ldr r3, [r1], #4
pld [r1, #64]
lsrs ip, r3, #24
strd r2, r3, [r0], #8
beq strcpy_unalign_return
b strcpy_unalign7
strcpy_unalign7_copy5bytes:
str r2, [r0], #4
strb r3, [r0]
strcpy_unalign_return:
m_pop
strcpy_unalign7_copy6bytes:
str r2, [r0], #4
strb r3, [r0], #1
strb r4, [r0], #1
m_pop
strcpy_unalign7_copy7bytes:
str r2, [r0], #4
strb r3, [r0], #1
strb r4, [r0], #1
strb r5, [r0], #1
m_pop
.p2align 2
// Can read 6 bytes before possibly crossing a page.
strcpy_unalign6:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldrb r4, [r1]
cbz r4, strcpy_unalign_copy5bytes
ldrb r5, [r1, #1]
cbz r5, strcpy_unalign_copy6bytes
ldr r3, [r1], #4
pld [r1, #64]
tst r3, #0xff0000
beq strcpy_copy7bytes
lsrs ip, r3, #24
strd r2, r3, [r0], #8
beq strcpy_unalign_return
b strcpy_unalign6
.p2align 2
// Can read 5 bytes before possibly crossing a page.
strcpy_unalign5:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldrb r4, [r1]
cbz r4, strcpy_unalign_copy5bytes
ldr r3, [r1], #4
pld [r1, #64]
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
strd r2, r3, [r0], #8
b strcpy_unalign5
strcpy_unalign_copy5bytes:
str r2, [r0], #4
strb r4, [r0]
m_pop
strcpy_unalign_copy6bytes:
str r2, [r0], #4
strb r4, [r0], #1
strb r5, [r0]
m_pop
.p2align 2
// Can read 4 bytes before possibly crossing a page.
strcpy_unalign4:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldr r3, [r1], #4
pld [r1, #64]
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
strd r2, r3, [r0], #8
b strcpy_unalign4
.p2align 2
// Can read 3 bytes before possibly crossing a page.
strcpy_unalign3:
ldrb r2, [r1]
cbz r2, strcpy_unalign3_copy1byte
ldrb r3, [r1, #1]
cbz r3, strcpy_unalign3_copy2bytes
ldrb r4, [r1, #2]
cbz r4, strcpy_unalign3_copy3bytes
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
lsrs lr, r2, #24
beq strcpy_copy4bytes
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
strd r2, r3, [r0], #8
b strcpy_unalign3
strcpy_unalign3_copy1byte:
strb r2, [r0]
m_pop
strcpy_unalign3_copy2bytes:
strb r2, [r0], #1
strb r3, [r0]
m_pop
strcpy_unalign3_copy3bytes:
strb r2, [r0], #1
strb r3, [r0], #1
strb r4, [r0]
m_pop
.p2align 2
// Can read 2 bytes before possibly crossing a page.
strcpy_unalign2:
ldrb r2, [r1]
cbz r2, strcpy_unalign_copy1byte
ldrb r4, [r1, #1]
cbz r4, strcpy_unalign_copy2bytes
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
tst r2, #0xff0000
beq strcpy_copy3bytes
lsrs ip, r2, #24
beq strcpy_copy4bytes
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
strd r2, r3, [r0], #8
b strcpy_unalign2
.p2align 2
// Can read 1 byte before possibly crossing a page.
strcpy_unalign1:
ldrb r2, [r1]
cbz r2, strcpy_unalign_copy1byte
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
strd r2, r3, [r0], #8
b strcpy_unalign1
strcpy_unalign_copy1byte:
strb r2, [r0]
m_pop
strcpy_unalign_copy2bytes:
strb r2, [r0], #1
strb r4, [r0]
m_pop
.p2align 2
strcat_mainloop:
ldrd r2, r3, [r0], #8
pld [r0, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcat_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcat_zero_in_second_register
b strcat_mainloop
strcat_zero_in_first_register:
// Prefetch the src now, it's going to be used soon.
pld [r1, #0]
lsls lr, ip, #17
bne strcat_sub8
bcs strcat_sub7
lsls ip, ip, #1
bne strcat_sub6
sub r0, r0, #5
b strcat_r0_scan_done
strcat_sub8:
sub r0, r0, #8
b strcat_r0_scan_done
strcat_sub7:
sub r0, r0, #7
b strcat_r0_scan_done
strcat_sub6:
sub r0, r0, #6
b strcat_r0_scan_done
strcat_zero_in_second_register:
// Prefetch the src now, it's going to be used soon.
pld [r1, #0]
lsls lr, ip, #17
bne strcat_sub4
bcs strcat_sub3
lsls ip, ip, #1
bne strcat_sub2
sub r0, r0, #1
b strcat_r0_scan_done
strcat_sub4:
sub r0, r0, #4
b strcat_r0_scan_done
strcat_sub3:
sub r0, r0, #3
b strcat_r0_scan_done
strcat_sub2:
sub r0, r0, #2
b strcat_r0_scan_done
END(strcat)

View File

@@ -123,8 +123,13 @@ ENTRY(strcmp)
.macro init
/* Macro to save temporary registers and prepare magic values. */
subs sp, sp, #16
.cfi_def_cfa_offset 16
strd r4, r5, [sp, #8]
.cfi_rel_offset r4, 0
.cfi_rel_offset r5, 4
strd r6, r7, [sp]
.cfi_rel_offset r6, 8
.cfi_rel_offset r7, 12
mvn r6, #0 /* all F */
mov r7, #0 /* all 0 */
.endm /* init */
@@ -165,18 +170,20 @@ ENTRY(strcmp)
#endif /* not __ARMEB__ */
.endm /* setup_return */
.cfi_startproc
pld [r0, #0]
pld [r1, #0]
/* Are both strings double-word aligned? */
orr ip, r0, r1
tst ip, #7
bne do_align
bne .L_do_align
/* Fast path. */
.save {r4-r7}
init
doubleword_aligned:
.L_doubleword_aligned:
/* Get here when the strings to compare are double-word aligned. */
/* Compare two words in every iteration. */
@@ -189,14 +196,14 @@ doubleword_aligned:
ldrd r2, r3, [r0], #8
ldrd r4, r5, [r1], #8
magic_compare_and_branch w1=r2, w2=r4, label=return_24
magic_compare_and_branch w1=r3, w2=r5, label=return_35
magic_compare_and_branch w1=r2, w2=r4, label=.L_return_24
magic_compare_and_branch w1=r3, w2=r5, label=.L_return_35
b 2b
do_align:
.L_do_align:
/* Is the first string word-aligned? */
ands ip, r0, #3
beq word_aligned_r0
beq .L_word_aligned_r0
/* Fast compare byte by byte until the first string is word-aligned. */
/* The offset of r0 from a word boundary is in ip. Thus, the number of bytes
@@ -204,58 +211,58 @@ do_align:
bic r0, r0, #3
ldr r2, [r0], #4
lsls ip, ip, #31
beq byte2
bcs byte3
beq .L_byte2
bcs .L_byte3
byte1:
.L_byte1:
ldrb ip, [r1], #1
uxtb r3, r2, ror #BYTE1_OFFSET
subs ip, r3, ip
bne fast_return
m_cbz reg=r3, label=fast_return
bne .L_fast_return
m_cbz reg=r3, label=.L_fast_return
byte2:
.L_byte2:
ldrb ip, [r1], #1
uxtb r3, r2, ror #BYTE2_OFFSET
subs ip, r3, ip
bne fast_return
m_cbz reg=r3, label=fast_return
bne .L_fast_return
m_cbz reg=r3, label=.L_fast_return
byte3:
.L_byte3:
ldrb ip, [r1], #1
uxtb r3, r2, ror #BYTE3_OFFSET
subs ip, r3, ip
bne fast_return
m_cbnz reg=r3, label=word_aligned_r0
bne .L_fast_return
m_cbnz reg=r3, label=.L_word_aligned_r0
fast_return:
.L_fast_return:
mov r0, ip
bx lr
word_aligned_r0:
.L_word_aligned_r0:
init
/* The first string is word-aligned. */
/* Is the second string word-aligned? */
ands ip, r1, #3
bne strcmp_unaligned
bne .L_strcmp_unaligned
word_aligned:
.L_word_aligned:
/* The strings are word-aligned. */
/* Is the first string double-word aligned? */
tst r0, #4
beq doubleword_aligned_r0
beq .L_doubleword_aligned_r0
/* If r0 is not double-word aligned yet, align it by loading
and comparing the next word from each string. */
ldr r2, [r0], #4
ldr r4, [r1], #4
magic_compare_and_branch w1=r2 w2=r4 label=return_24
magic_compare_and_branch w1=r2 w2=r4 label=.L_return_24
doubleword_aligned_r0:
.L_doubleword_aligned_r0:
/* Get here when r0 is double-word aligned. */
/* Is r1 doubleword_aligned? */
tst r1, #4
beq doubleword_aligned
beq .L_doubleword_aligned
/* Get here when the strings to compare are word-aligned,
r0 is double-word aligned, but r1 is not double-word aligned. */
@@ -271,9 +278,9 @@ doubleword_aligned_r0:
/* Load the next double-word from each string and compare. */
ldrd r2, r3, [r0], #8
magic_compare_and_branch w1=r2 w2=r5 label=return_25
magic_compare_and_branch w1=r2 w2=r5 label=.L_return_25
ldrd r4, r5, [r1], #8
magic_compare_and_branch w1=r3 w2=r4 label=return_34
magic_compare_and_branch w1=r3 w2=r4 label=.L_return_34
b 3b
.macro miscmp_word offsetlo offsethi
@@ -297,47 +304,47 @@ doubleword_aligned_r0:
and r2, r3, r6, S2LOMEM #\offsetlo
it eq
cmpeq r2, r5
bne return_25
bne .L_return_25
ldr r5, [r1], #4
cmp ip, #0
eor r3, r2, r3
S2HIMEM r2, r5, #\offsethi
it eq
cmpeq r3, r2
bne return_32
bne .L_return_32
b 7b
.endm /* miscmp_word */
strcmp_unaligned:
.L_strcmp_unaligned:
/* r0 is word-aligned, r1 is at offset ip from a word. */
/* Align r1 to the (previous) word-boundary. */
bic r1, r1, #3
/* Unaligned comparison word by word using LDRs. */
cmp ip, #2
beq miscmp_word_16 /* If ip == 2. */
bge miscmp_word_24 /* If ip == 3. */
beq .L_miscmp_word_16 /* If ip == 2. */
bge .L_miscmp_word_24 /* If ip == 3. */
miscmp_word offsetlo=8 offsethi=24 /* If ip == 1. */
miscmp_word_16: miscmp_word offsetlo=16 offsethi=16
miscmp_word_24: miscmp_word offsetlo=24 offsethi=8
.L_miscmp_word_16: miscmp_word offsetlo=16 offsethi=16
.L_miscmp_word_24: miscmp_word offsetlo=24 offsethi=8
return_32:
.L_return_32:
setup_return w1=r3, w2=r2
b do_return
return_34:
b .L_do_return
.L_return_34:
setup_return w1=r3, w2=r4
b do_return
return_25:
b .L_do_return
.L_return_25:
setup_return w1=r2, w2=r5
b do_return
return_35:
b .L_do_return
.L_return_35:
setup_return w1=r3, w2=r5
b do_return
return_24:
b .L_do_return
.L_return_24:
setup_return w1=r2, w2=r4
do_return:
.L_do_return:
#ifdef __ARMEB__
mov r0, ip
@@ -349,11 +356,16 @@ do_return:
ldrd r6, r7, [sp]
ldrd r4, r5, [sp, #8]
adds sp, sp, #16
.cfi_def_cfa_offset 0
.cfi_restore r4
.cfi_restore r5
.cfi_restore r6
.cfi_restore r7
/* There is a zero or a different byte between r1 and r2. */
/* r0 contains a mask of all-zero bytes in r1. */
/* Using r0 and not ip here because cbz requires low register. */
m_cbz reg=r0, label=compute_return_value
m_cbz reg=r0, label=.L_compute_return_value
clz r0, r0
/* r0 contains the number of bits on the left of the first all-zero byte in r1. */
rsb r0, r0, #24
@@ -361,7 +373,7 @@ do_return:
lsr r1, r1, r0
lsr r2, r2, r0
compute_return_value:
.L_compute_return_value:
movs r0, #1
cmp r1, r2
/* The return value is computed as follows.
@@ -374,4 +386,5 @@ compute_return_value:
it ls
sbcls r0, r0, r0
bx lr
.cfi_endproc
END(strcmp)

View File

@@ -0,0 +1,451 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Copyright (c) 2013 ARM Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the company may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
.syntax unified
.thumb
.thumb_func
.macro m_push
push {r0, r4, r5, lr}
.endm // m_push
.macro m_pop
pop {r0, r4, r5, pc}
.endm // m_pop
.macro m_copy_byte reg, cmd, label
ldrb \reg, [r1], #1
strb \reg, [r0], #1
\cmd \reg, \label
.endm // m_copy_byte
ENTRY(strcpy)
// For short copies, hard-code checking the first 8 bytes since this
// new code doesn't win until after about 8 bytes.
m_push
m_copy_byte reg=r2, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r3, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r4, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r5, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r2, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r3, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r4, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r5, cmd=cbnz, label=strcpy_continue
strcpy_finish:
m_pop
strcpy_continue:
pld [r1, #0]
ands r3, r0, #7
beq strcpy_check_src_align
// Align to a double word (64 bits).
rsb r3, r3, #8
lsls ip, r3, #31
beq strcpy_align_to_32
ldrb r2, [r1], #1
strb r2, [r0], #1
cbz r2, strcpy_complete
strcpy_align_to_32:
bcc strcpy_align_to_64
ldrb r2, [r1], #1
strb r2, [r0], #1
cbz r2, strcpy_complete
ldrb r2, [r1], #1
strb r2, [r0], #1
cbz r2, strcpy_complete
strcpy_align_to_64:
tst r3, #4
beq strcpy_check_src_align
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
str r2, [r0], #4
strcpy_check_src_align:
// At this point dst is aligned to a double word, check if src
// is also aligned to a double word.
ands r3, r1, #7
bne strcpy_unaligned_copy
.p2align 2
strcpy_mainloop:
ldrd r2, r3, [r1], #8
pld [r1, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
strd r2, r3, [r0], #8
b strcpy_mainloop
strcpy_complete:
m_pop
strcpy_zero_in_first_register:
lsls lr, ip, #17
bne strcpy_copy1byte
bcs strcpy_copy2bytes
lsls ip, ip, #1
bne strcpy_copy3bytes
strcpy_copy4bytes:
// Copy 4 bytes to the destiniation.
str r2, [r0]
m_pop
strcpy_copy1byte:
strb r2, [r0]
m_pop
strcpy_copy2bytes:
strh r2, [r0]
m_pop
strcpy_copy3bytes:
strh r2, [r0], #2
lsr r2, #16
strb r2, [r0]
m_pop
strcpy_zero_in_second_register:
lsls lr, ip, #17
bne strcpy_copy5bytes
bcs strcpy_copy6bytes
lsls ip, ip, #1
bne strcpy_copy7bytes
// Copy 8 bytes to the destination.
strd r2, r3, [r0]
m_pop
strcpy_copy5bytes:
str r2, [r0], #4
strb r3, [r0]
m_pop
strcpy_copy6bytes:
str r2, [r0], #4
strh r3, [r0]
m_pop
strcpy_copy7bytes:
str r2, [r0], #4
strh r3, [r0], #2
lsr r3, #16
strb r3, [r0]
m_pop
strcpy_unaligned_copy:
// Dst is aligned to a double word, while src is at an unknown alignment.
// There are 7 different versions of the unaligned copy code
// to prevent overreading the src. The mainloop of every single version
// will store 64 bits per loop. The difference is how much of src can
// be read without potentially crossing a page boundary.
tbb [pc, r3]
strcpy_unaligned_branchtable:
.byte 0
.byte ((strcpy_unalign7 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign6 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign5 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign4 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign3 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign2 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign1 - strcpy_unaligned_branchtable)/2)
.p2align 2
// Can read 7 bytes before possibly crossing a page.
strcpy_unalign7:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldrb r3, [r1]
cbz r3, strcpy_unalign7_copy5bytes
ldrb r4, [r1, #1]
cbz r4, strcpy_unalign7_copy6bytes
ldrb r5, [r1, #2]
cbz r5, strcpy_unalign7_copy7bytes
ldr r3, [r1], #4
pld [r1, #64]
lsrs ip, r3, #24
strd r2, r3, [r0], #8
beq strcpy_unalign_return
b strcpy_unalign7
strcpy_unalign7_copy5bytes:
str r2, [r0], #4
strb r3, [r0]
strcpy_unalign_return:
m_pop
strcpy_unalign7_copy6bytes:
str r2, [r0], #4
strb r3, [r0], #1
strb r4, [r0], #1
m_pop
strcpy_unalign7_copy7bytes:
str r2, [r0], #4
strb r3, [r0], #1
strb r4, [r0], #1
strb r5, [r0], #1
m_pop
.p2align 2
// Can read 6 bytes before possibly crossing a page.
strcpy_unalign6:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldrb r4, [r1]
cbz r4, strcpy_unalign_copy5bytes
ldrb r5, [r1, #1]
cbz r5, strcpy_unalign_copy6bytes
ldr r3, [r1], #4
pld [r1, #64]
tst r3, #0xff0000
beq strcpy_copy7bytes
lsrs ip, r3, #24
strd r2, r3, [r0], #8
beq strcpy_unalign_return
b strcpy_unalign6
.p2align 2
// Can read 5 bytes before possibly crossing a page.
strcpy_unalign5:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldrb r4, [r1]
cbz r4, strcpy_unalign_copy5bytes
ldr r3, [r1], #4
pld [r1, #64]
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
strd r2, r3, [r0], #8
b strcpy_unalign5
strcpy_unalign_copy5bytes:
str r2, [r0], #4
strb r4, [r0]
m_pop
strcpy_unalign_copy6bytes:
str r2, [r0], #4
strb r4, [r0], #1
strb r5, [r0]
m_pop
.p2align 2
// Can read 4 bytes before possibly crossing a page.
strcpy_unalign4:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldr r3, [r1], #4
pld [r1, #64]
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
strd r2, r3, [r0], #8
b strcpy_unalign4
.p2align 2
// Can read 3 bytes before possibly crossing a page.
strcpy_unalign3:
ldrb r2, [r1]
cbz r2, strcpy_unalign3_copy1byte
ldrb r3, [r1, #1]
cbz r3, strcpy_unalign3_copy2bytes
ldrb r4, [r1, #2]
cbz r4, strcpy_unalign3_copy3bytes
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
lsrs lr, r2, #24
beq strcpy_copy4bytes
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
strd r2, r3, [r0], #8
b strcpy_unalign3
strcpy_unalign3_copy1byte:
strb r2, [r0]
m_pop
strcpy_unalign3_copy2bytes:
strb r2, [r0], #1
strb r3, [r0]
m_pop
strcpy_unalign3_copy3bytes:
strb r2, [r0], #1
strb r3, [r0], #1
strb r4, [r0]
m_pop
.p2align 2
// Can read 2 bytes before possibly crossing a page.
strcpy_unalign2:
ldrb r2, [r1]
cbz r2, strcpy_unalign_copy1byte
ldrb r4, [r1, #1]
cbz r4, strcpy_unalign_copy2bytes
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
tst r2, #0xff0000
beq strcpy_copy3bytes
lsrs ip, r2, #24
beq strcpy_copy4bytes
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
strd r2, r3, [r0], #8
b strcpy_unalign2
.p2align 2
// Can read 1 byte before possibly crossing a page.
strcpy_unalign1:
ldrb r2, [r1]
cbz r2, strcpy_unalign_copy1byte
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
strd r2, r3, [r0], #8
b strcpy_unalign1
strcpy_unalign_copy1byte:
strb r2, [r0]
m_pop
strcpy_unalign_copy2bytes:
strb r2, [r0], #1
strb r4, [r0]
m_pop
END(strcpy)

View File

@@ -0,0 +1,165 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Copyright (c) 2013 ARM Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the company may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
.syntax unified
.thumb
.thumb_func
ENTRY(strlen)
pld [r0, #0]
mov r1, r0
ands r3, r0, #7
beq mainloop
// Align to a double word (64 bits).
rsb r3, r3, #8
lsls ip, r3, #31
beq align_to_32
ldrb r2, [r1], #1
cbz r2, update_count_and_return
align_to_32:
bcc align_to_64
ands ip, r3, #2
beq align_to_64
ldrb r2, [r1], #1
cbz r2, update_count_and_return
ldrb r2, [r1], #1
cbz r2, update_count_and_return
align_to_64:
tst r3, #4
beq mainloop
ldr r3, [r1], #4
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne zero_in_second_register
.p2align 2
mainloop:
ldrd r2, r3, [r1], #8
pld [r1, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne zero_in_second_register
b mainloop
update_count_and_return:
sub r0, r1, r0
sub r0, r0, #1
bx lr
zero_in_first_register:
sub r0, r1, r0
lsls r3, ip, #17
bne sub8_and_return
bcs sub7_and_return
lsls ip, ip, #1
bne sub6_and_return
sub r0, r0, #5
bx lr
sub8_and_return:
sub r0, r0, #8
bx lr
sub7_and_return:
sub r0, r0, #7
bx lr
sub6_and_return:
sub r0, r0, #6
bx lr
zero_in_second_register:
sub r0, r1, r0
lsls r3, ip, #17
bne sub4_and_return
bcs sub3_and_return
lsls ip, ip, #1
bne sub2_and_return
sub r0, r0, #1
bx lr
sub4_and_return:
sub r0, r0, #4
bx lr
sub3_and_return:
sub r0, r0, #3
bx lr
sub2_and_return:
sub r0, r0, #2
bx lr
END(strlen)

View File

@@ -1,5 +1,10 @@
$(call libc-add-cpu-variant-src,MEMCPY,arch-arm/cortex-a15/bionic/memcpy.S)
$(call libc-add-cpu-variant-src,MEMSET,arch-arm/cortex-a15/bionic/memset.S)
$(call libc-add-cpu-variant-src,STRCAT,arch-arm/cortex-a15/bionic/strcat.S)
$(call libc-add-cpu-variant-src,STRCMP,arch-arm/cortex-a15/bionic/strcmp.S)
$(call libc-add-cpu-variant-src,STRCPY,arch-arm/cortex-a15/bionic/strcpy.S)
$(call libc-add-cpu-variant-src,STRLEN,arch-arm/cortex-a15/bionic/strlen.S)
$(call libc-add-cpu-variant-src,__STRCAT_CHK,arch-arm/cortex-a15/bionic/__strcat_chk.S)
$(call libc-add-cpu-variant-src,__STRCPY_CHK,arch-arm/cortex-a15/bionic/__strcpy_chk.S)
include bionic/libc/arch-arm/generic/generic.mk

View File

@@ -0,0 +1 @@
include bionic/libc/arch-arm/cortex-a15/cortex-a15.mk

View File

@@ -0,0 +1,230 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#include "libc_events.h"
.syntax unified
.fpu neon
.thumb
.thumb_func
// Get the length of src string, then get the source of the dst string.
// Check that the two lengths together don't exceed the threshold, then
// do a memcpy of the data.
ENTRY(__strcat_chk)
.cfi_startproc
pld [r0, #0]
push {r0, lr}
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
push {r4, r5}
.save {r4, r5}
.cfi_adjust_cfa_offset 8
.cfi_rel_offset r4, 0
.cfi_rel_offset r5, 4
mov lr, r2
// Save the dst register to r5
mov r5, r0
// Zero out r4
eor r4, r4, r4
// r1 contains the address of the string to count.
.L_strlen_start:
mov r0, r1
ands r3, r0, #7
bne .L_align_src
.p2align 2
.L_mainloop:
ldmia r1!, {r2, r3}
pld [r1, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne .L_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne .L_zero_in_second_register
b .L_mainloop
.L_zero_in_first_register:
sub r3, r1, r0
// Check for zero in byte 0.
lsls r2, ip, #17
beq .L_check_byte1_reg1
sub r3, r3, #8
b .L_finish
.L_check_byte1_reg1:
bcc .L_check_byte2_reg1
sub r3, r3, #7
b .L_finish
.L_check_byte2_reg1:
// Check for zero in byte 2.
tst ip, #0x800000
it ne
subne r3, r3, #6
bne .L_finish
sub r3, r3, #5
b .L_finish
.L_zero_in_second_register:
sub r3, r1, r0
// Check for zero in byte 0.
lsls r2, ip, #17
beq .L_check_byte1_reg2
sub r3, r3, #4
b .L_finish
.L_check_byte1_reg2:
bcc .L_check_byte2_reg2
sub r3, r3, #3
b .L_finish
.L_check_byte2_reg2:
// Check for zero in byte 2.
tst ip, #0x800000
it ne
subne r3, r3, #2
bne .L_finish
sub r3, r3, #1
b .L_finish
.L_align_src:
// Align to a double word (64 bits).
rsb r3, r3, #8
lsls ip, r3, #31
beq .L_align_to_32
ldrb r2, [r1], #1
cbz r2, .L_done
.L_align_to_32:
bcc .L_align_to_64
ldrb r2, [r1], #1
cbz r2, .L_done
ldrb r2, [r1], #1
cbz r2, .L_done
.L_align_to_64:
tst r3, #4
beq .L_mainloop
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne .L_zero_in_second_register
b .L_mainloop
.L_done:
sub r3, r1, r0
sub r3, r3, #1
.L_finish:
cmp r4, #0
bne .L_strlen_done
// Time to get the dst string length.
mov r1, r5
// Save the original source address to r5.
mov r5, r0
// Save the current length (adding 1 for the terminator).
add r4, r3, #1
b .L_strlen_start
// r0 holds the pointer to the dst string.
// r3 holds the dst string length.
// r4 holds the src string length + 1.
.L_strlen_done:
add r2, r3, r4
cmp r2, lr
bhi __strcat_chk_fail
// Set up the registers for the memcpy code.
mov r1, r5
pld [r1, #64]
mov r2, r4
add r0, r0, r3
pop {r4, r5}
// Fall through into the memcpy_base function.
.cfi_endproc
END(__strcat_chk)
#define MEMCPY_BASE __strcat_chk_memcpy_base
#define MEMCPY_BASE_ALIGNED __strcat_chk_memcpy_base_aligned
#include "memcpy_base.S"
ENTRY(__strcat_chk_fail)
.cfi_startproc
.save {r0, lr}
.save {r4, r5}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
.cfi_adjust_cfa_offset 8
.cfi_rel_offset r4, 0
.cfi_rel_offset r5, 4
ldr r0, error_message
ldr r1, error_code
1:
add r0, pc
bl __fortify_chk_fail
error_code:
.word BIONIC_EVENT_STRCAT_BUFFER_OVERFLOW
error_message:
.word error_string-(1b+4)
.cfi_endproc
END(__strcat_chk_fail)
.data
error_string:
.string "strcat buffer overflow"

View File

@@ -0,0 +1,194 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#include "libc_events.h"
.syntax unified
.fpu neon
.thumb
.thumb_func
// Get the length of the source string first, then do a memcpy of the data
// instead of a strcpy.
ENTRY(__strcpy_chk)
.cfi_startproc
pld [r0, #0]
push {r0, lr}
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
mov lr, r2
mov r0, r1
ands r3, r0, #7
bne .L_align_src
.p2align 2
.L_mainloop:
ldmia r0!, {r2, r3}
pld [r0, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne .L_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne .L_zero_in_second_register
b .L_mainloop
.L_zero_in_first_register:
sub r3, r0, r1
// Check for zero in byte 0.
lsls r2, ip, #17
beq .L_check_byte1_reg1
sub r3, r3, #8
b .L_check_size
.L_check_byte1_reg1:
bcc .L_check_byte2_reg1
sub r3, r3, #7
b .L_check_size
.L_check_byte2_reg1:
// Check for zero in byte 2.
tst ip, #0x800000
it ne
subne r3, r3, #6
bne .L_check_size
sub r3, r3, #5
b .L_check_size
.L_zero_in_second_register:
sub r3, r0, r1
// Check for zero in byte 0.
lsls r2, ip, #17
beq .L_check_byte1_reg2
sub r3, r3, #4
b .L_check_size
.L_check_byte1_reg2:
bcc .L_check_byte2_reg2
sub r3, r3, #3
b .L_check_size
.L_check_byte2_reg2:
// Check for zero in byte 2.
tst ip, #0x800000
it ne
subne r3, r3, #2
bne .L_check_size
sub r3, r3, #1
b .L_check_size
.L_align_src:
// Align to a double word (64 bits).
rsb r3, r3, #8
lsls ip, r3, #31
beq .L_align_to_32
ldrb r2, [r0], #1
cbz r2, .L_done
.L_align_to_32:
bcc .L_align_to_64
ldrb r2, [r0], #1
cbz r2, .L_done
ldrb r2, [r0], #1
cbz r2, .L_done
.L_align_to_64:
tst r3, #4
beq .L_mainloop
ldr r2, [r0], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne .L_zero_in_second_register
b .L_mainloop
.L_done:
sub r3, r0, r1
sub r3, r3, #1
.L_check_size:
pld [r1, #0]
pld [r1, #64]
ldr r0, [sp]
cmp r3, lr
bhs __strcpy_chk_fail
// Add 1 for copy length to get the string terminator.
add r2, r3, #1
.cfi_endproc
// Fall through into the memcpy_base function.
END(__strcpy_chk)
#define MEMCPY_BASE __strcpy_chk_memcpy_base
#define MEMCPY_BASE_ALIGNED __strcpy_chk_memcpy_base_aligned
#include "memcpy_base.S"
ENTRY(__strcpy_chk_fail)
.cfi_startproc
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
ldr r0, error_message
ldr r1, error_code
1:
add r0, pc
bl __fortify_chk_fail
error_code:
.word BIONIC_EVENT_STRCPY_BUFFER_OVERFLOW
error_message:
.word error_string-(1b+4)
.cfi_endproc
END(__strcpy_chk_fail)
.data
error_string:
.string "strcpy buffer overflow"

View File

@@ -26,8 +26,8 @@
* SUCH DAMAGE.
*/
#include <machine/cpu-features.h>
#include <machine/asm.h>
#include "libc_events.h"
/*
* This code assumes it is running on a processor that supports all arm v7
@@ -35,177 +35,58 @@
* cache line.
*/
.text
.syntax unified
.fpu neon
.thumb
.thumb_func
#define CACHE_LINE_SIZE 32
ENTRY(__memcpy_chk)
.cfi_startproc
cmp r2, r3
bhi __memcpy_chk_fail
// Fall through to memcpy...
.cfi_endproc
END(__memcpy_chk)
ENTRY(memcpy)
.save {r0, lr}
/* start preloading as early as possible */
pld [r1, #(CACHE_LINE_SIZE * 0)]
stmfd sp!, {r0, lr}
pld [r1, #(CACHE_LINE_SIZE * 2)]
.cfi_startproc
// Check so divider is at least 16 bytes, needed for alignment code.
cmp r2, #16
blo 5f
pld [r1, #0]
stmfd sp!, {r0, lr}
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
pld [r1, #64]
/* check if buffers are aligned. If so, run arm-only version */
eor r3, r0, r1
ands r3, r3, #0x3
beq 11f
/* Check the upper size limit for Neon unaligned memory access in memcpy */
cmp r2, #224
blo 3f
/* align destination to 16 bytes for the write-buffer */
rsb r3, r0, #0
ands r3, r3, #0xF
beq 3f
/* copy up to 15-bytes (count in r3) */
sub r2, r2, r3
movs ip, r3, lsl #31
ldrmib lr, [r1], #1
strmib lr, [r0], #1
ldrcsb ip, [r1], #1
ldrcsb lr, [r1], #1
strcsb ip, [r0], #1
strcsb lr, [r0], #1
movs ip, r3, lsl #29
bge 1f
// copies 4 bytes, destination 32-bits aligned
vld1.32 {d0[0]}, [r1]!
vst1.32 {d0[0]}, [r0, :32]!
1: bcc 2f
// copies 8 bytes, destination 64-bits aligned
vld1.8 {d0}, [r1]!
vst1.8 {d0}, [r0, :64]!
2:
/* preload immediately the next cache line, which we may need */
pld [r1, #(CACHE_LINE_SIZE * 0)]
pld [r1, #(CACHE_LINE_SIZE * 2)]
3:
/* make sure we have at least 64 bytes to copy */
subs r2, r2, #64
blo 2f
/* preload all the cache lines we need */
pld [r1, #(CACHE_LINE_SIZE * 4)]
pld [r1, #(CACHE_LINE_SIZE * 6)]
1: /* The main loop copies 64 bytes at a time */
vld1.8 {d0 - d3}, [r1]!
vld1.8 {d4 - d7}, [r1]!
pld [r1, #(CACHE_LINE_SIZE * 6)]
subs r2, r2, #64
vst1.8 {d0 - d3}, [r0]!
vst1.8 {d4 - d7}, [r0]!
bhs 1b
2: /* fix-up the remaining count and make sure we have >= 32 bytes left */
add r2, r2, #64
subs r2, r2, #32
blo 4f
3: /* 32 bytes at a time. These cache lines were already preloaded */
vld1.8 {d0 - d3}, [r1]!
subs r2, r2, #32
vst1.8 {d0 - d3}, [r0]!
bhs 3b
4: /* less than 32 left */
add r2, r2, #32
tst r2, #0x10
beq 5f
// copies 16 bytes, 128-bits aligned
vld1.8 {d0, d1}, [r1]!
vst1.8 {d0, d1}, [r0]!
5: /* copy up to 15-bytes (count in r2) */
movs ip, r2, lsl #29
bcc 1f
vld1.8 {d0}, [r1]!
vst1.8 {d0}, [r0]!
1: bge 2f
vld1.32 {d0[0]}, [r1]!
vst1.32 {d0[0]}, [r0]!
2: movs ip, r2, lsl #31
ldrmib r3, [r1], #1
ldrcsb ip, [r1], #1
ldrcsb lr, [r1], #1
strmib r3, [r0], #1
strcsb ip, [r0], #1
strcsb lr, [r0], #1
ldmfd sp!, {r0, lr}
bx lr
11:
/* Simple arm-only copy loop to handle aligned copy operations */
stmfd sp!, {r4, r5, r6, r7, r8}
pld [r1, #(CACHE_LINE_SIZE * 4)]
/* Check alignment */
rsb r3, r1, #0
ands r3, #3
beq 2f
/* align source to 32 bits. We need to insert 2 instructions between
* a ldr[b|h] and str[b|h] because byte and half-word instructions
* stall 2 cycles.
*/
movs r12, r3, lsl #31
sub r2, r2, r3 /* we know that r3 <= r2 because r2 >= 4 */
ldrmib r3, [r1], #1
ldrcsb r4, [r1], #1
ldrcsb r5, [r1], #1
strmib r3, [r0], #1
strcsb r4, [r0], #1
strcsb r5, [r0], #1
2:
subs r2, r2, #64
blt 4f
3: /* Main copy loop, copying 64 bytes at a time */
pld [r1, #(CACHE_LINE_SIZE * 8)]
ldmia r1!, {r3, r4, r5, r6, r7, r8, r12, lr}
stmia r0!, {r3, r4, r5, r6, r7, r8, r12, lr}
ldmia r1!, {r3, r4, r5, r6, r7, r8, r12, lr}
stmia r0!, {r3, r4, r5, r6, r7, r8, r12, lr}
subs r2, r2, #64
bge 3b
4: /* Check if there are > 32 bytes left */
adds r2, r2, #64
subs r2, r2, #32
blt 5f
/* Copy 32 bytes */
ldmia r1!, {r3, r4, r5, r6, r7, r8, r12, lr}
stmia r0!, {r3, r4, r5, r6, r7, r8, r12, lr}
subs r2, #32
5: /* Handle any remaining bytes */
adds r2, #32
beq 6f
movs r12, r2, lsl #28
ldmcsia r1!, {r3, r4, r5, r6} /* 16 bytes */
ldmmiia r1!, {r7, r8} /* 8 bytes */
stmcsia r0!, {r3, r4, r5, r6}
stmmiia r0!, {r7, r8}
movs r12, r2, lsl #30
ldrcs r3, [r1], #4 /* 4 bytes */
ldrmih r4, [r1], #2 /* 2 bytes */
strcs r3, [r0], #4
strmih r4, [r0], #2
tst r2, #0x1
ldrneb r3, [r1] /* last byte */
strneb r3, [r0]
6:
ldmfd sp!, {r4, r5, r6, r7, r8}
ldmfd sp!, {r0, pc}
.cfi_endproc
END(memcpy)
#define MEMCPY_BASE __memcpy_base
#define MEMCPY_BASE_ALIGNED __memcpy_base_aligned
#include "memcpy_base.S"
ENTRY(__memcpy_chk_fail)
.cfi_startproc
// Preserve lr for backtrace.
push {lr}
.save {lr}
.cfi_def_cfa_offset 4
.cfi_rel_offset lr, 0
ldr r0, error_message
ldr r1, error_code
1:
add r0, pc
bl __fortify_chk_fail
error_code:
.word BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW
error_message:
.word error_string-(1b+4)
.cfi_endproc
END(__memcpy_chk_fail)
.data
error_string:
.string "memcpy buffer overflow"

View File

@@ -0,0 +1,233 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* This code assumes it is running on a processor that supports all arm v7
* instructions, that supports neon instructions, and that has a 32 byte
* cache line.
*/
ENTRY(MEMCPY_BASE)
.cfi_startproc
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
// Check so divider is at least 16 bytes, needed for alignment code.
cmp r2, #16
blo 5f
/* check if buffers are aligned. If so, run arm-only version */
eor r3, r0, r1
ands r3, r3, #0x3
beq __memcpy_base_aligned
/* Check the upper size limit for Neon unaligned memory access in memcpy */
cmp r2, #224
blo 3f
/* align destination to 16 bytes for the write-buffer */
rsb r3, r0, #0
ands r3, r3, #0xF
beq 3f
/* copy up to 15-bytes (count in r3) */
sub r2, r2, r3
movs ip, r3, lsl #31
itt mi
ldrbmi lr, [r1], #1
strbmi lr, [r0], #1
itttt cs
ldrbcs ip, [r1], #1
ldrbcs lr, [r1], #1
strbcs ip, [r0], #1
strbcs lr, [r0], #1
movs ip, r3, lsl #29
bge 1f
// copies 4 bytes, destination 32-bits aligned
vld1.32 {d0[0]}, [r1]!
vst1.32 {d0[0]}, [r0, :32]!
1: bcc 2f
// copies 8 bytes, destination 64-bits aligned
vld1.8 {d0}, [r1]!
vst1.8 {d0}, [r0, :64]!
2:
/* preload immediately the next cache line, which we may need */
pld [r1, #0]
pld [r1, #(32 * 2)]
3:
/* make sure we have at least 64 bytes to copy */
subs r2, r2, #64
blo 2f
/* preload all the cache lines we need */
pld [r1, #(32 * 4)]
pld [r1, #(32 * 6)]
1: /* The main loop copies 64 bytes at a time */
vld1.8 {d0 - d3}, [r1]!
vld1.8 {d4 - d7}, [r1]!
pld [r1, #(32 * 6)]
subs r2, r2, #64
vst1.8 {d0 - d3}, [r0]!
vst1.8 {d4 - d7}, [r0]!
bhs 1b
2: /* fix-up the remaining count and make sure we have >= 32 bytes left */
add r2, r2, #64
subs r2, r2, #32
blo 4f
3: /* 32 bytes at a time. These cache lines were already preloaded */
vld1.8 {d0 - d3}, [r1]!
subs r2, r2, #32
vst1.8 {d0 - d3}, [r0]!
bhs 3b
4: /* less than 32 left */
add r2, r2, #32
tst r2, #0x10
beq 5f
// copies 16 bytes, 128-bits aligned
vld1.8 {d0, d1}, [r1]!
vst1.8 {d0, d1}, [r0]!
5: /* copy up to 15-bytes (count in r2) */
movs ip, r2, lsl #29
bcc 1f
vld1.8 {d0}, [r1]!
vst1.8 {d0}, [r0]!
1: bge 2f
vld1.32 {d0[0]}, [r1]!
vst1.32 {d0[0]}, [r0]!
2: movs ip, r2, lsl #31
itt mi
ldrbmi r3, [r1], #1
strbmi r3, [r0], #1
itttt cs
ldrbcs ip, [r1], #1
ldrbcs lr, [r1], #1
strbcs ip, [r0], #1
strbcs lr, [r0], #1
ldmfd sp!, {r0, lr}
bx lr
.cfi_endproc
END(MEMCPY_BASE)
ENTRY(MEMCPY_BASE_ALIGNED)
.cfi_startproc
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
/* Simple arm-only copy loop to handle aligned copy operations */
stmfd sp!, {r4-r8}
.save {r4-r8}
.cfi_adjust_cfa_offset 20
.cfi_rel_offset r4, 0
.cfi_rel_offset r5, 4
.cfi_rel_offset r6, 8
.cfi_rel_offset r7, 12
.cfi_rel_offset r8, 16
pld [r1, #(32 * 4)]
/* Check alignment */
rsb r3, r1, #0
ands r3, #3
beq 2f
/* align source to 32 bits. We need to insert 2 instructions between
* a ldr[b|h] and str[b|h] because byte and half-word instructions
* stall 2 cycles.
*/
movs r12, r3, lsl #31
sub r2, r2, r3 /* we know that r3 <= r2 because r2 >= 4 */
itt mi
ldrbmi r3, [r1], #1
strbmi r3, [r0], #1
itttt cs
ldrbcs r4, [r1], #1
ldrbcs r5, [r1], #1
strbcs r4, [r0], #1
strbcs r5, [r0], #1
2:
subs r2, r2, #64
blt 4f
3: /* Main copy loop, copying 64 bytes at a time */
pld [r1, #(32 * 8)]
ldmia r1!, {r3, r4, r5, r6, r7, r8, r12, lr}
stmia r0!, {r3, r4, r5, r6, r7, r8, r12, lr}
ldmia r1!, {r3, r4, r5, r6, r7, r8, r12, lr}
stmia r0!, {r3, r4, r5, r6, r7, r8, r12, lr}
subs r2, r2, #64
bge 3b
4: /* Check if there are > 32 bytes left */
adds r2, r2, #64
subs r2, r2, #32
blt 5f
/* Copy 32 bytes */
ldmia r1!, {r3, r4, r5, r6, r7, r8, r12, lr}
stmia r0!, {r3, r4, r5, r6, r7, r8, r12, lr}
subs r2, #32
5: /* Handle any remaining bytes */
adds r2, #32
beq 6f
movs r12, r2, lsl #28
itt cs
ldmiacs r1!, {r3, r4, r5, r6} /* 16 bytes */
stmiacs r0!, {r3, r4, r5, r6}
itt mi
ldmiami r1!, {r7, r8} /* 8 bytes */
stmiami r0!, {r7, r8}
movs r12, r2, lsl #30
itt cs
ldrcs r3, [r1], #4 /* 4 bytes */
strcs r3, [r0], #4
itt mi
ldrhmi r4, [r1], #2 /* 2 bytes */
strhmi r4, [r0], #2
tst r2, #0x1
itt ne
ldrbne r3, [r1] /* last byte */
strbne r3, [r0]
6:
ldmfd sp!, {r4-r8}
ldmfd sp!, {r0, pc}
.cfi_endproc
END(MEMCPY_BASE_ALIGNED)

View File

@@ -28,6 +28,7 @@
#include <machine/cpu-features.h>
#include <machine/asm.h>
#include "libc_events.h"
/*
* This code assumes it is running on a processor that supports all arm v7
@@ -36,19 +37,52 @@
.fpu neon
ENTRY(__memset_chk)
.cfi_startproc
cmp r2, r3
bls .L_done
// Preserve lr for backtrace.
push {lr}
.save {lr}
.cfi_def_cfa_offset 4
.cfi_rel_offset lr, 0
ldr r0, error_message
ldr r1, error_code
1:
add r0, pc
bl __fortify_chk_fail
error_code:
.word BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW
error_message:
.word error_string-(1b+8)
.cfi_endproc
END(__memset_chk)
ENTRY(bzero)
.cfi_startproc
mov r2, r1
mov r1, #0
.L_done:
// Fall through to memset...
.cfi_endproc
END(bzero)
/* memset() returns its first argument. */
ENTRY(memset)
.cfi_startproc
# The neon memset only wins for less than 132.
cmp r2, #132
bhi 11f
bhi __memset_large_copy
.save {r0}
stmfd sp!, {r0}
.save {r0}
.cfi_def_cfa_offset 4
.cfi_rel_offset r0, 0
vdup.8 q0, r1
@@ -81,13 +115,26 @@ ENTRY(memset)
strcsb r1, [r0], #1
ldmfd sp!, {r0}
bx lr
11:
.cfi_endproc
END(memset)
ENTRY(__memset_large_copy)
.cfi_startproc
/* compute the offset to align the destination
* offset = (4-(src&3))&3 = -src & 3
*/
.save {r0, r4-r7, lr}
stmfd sp!, {r0, r4-r7, lr}
.save {r0, r4-r7, lr}
.cfi_def_cfa_offset 24
.cfi_rel_offset r0, 0
.cfi_rel_offset r4, 4
.cfi_rel_offset r5, 8
.cfi_rel_offset r6, 12
.cfi_rel_offset r7, 16
.cfi_rel_offset lr, 20
rsb r3, r0, #0
ands r3, r3, #3
cmp r3, r2
@@ -149,4 +196,9 @@ ENTRY(memset)
strcsb r1, [r0]
ldmfd sp!, {r0, r4-r7, lr}
bx lr
END(memset)
.cfi_endproc
END(__memset_large_copy)
.data
error_string:
.string "memset buffer overflow"

View File

@@ -0,0 +1,548 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Copyright (c) 2013 ARM Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the company may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
.syntax unified
.thumb
.thumb_func
.macro m_push
push {r0, r4, r5, lr}
.endm // m_push
.macro m_ret inst
\inst {r0, r4, r5, pc}
.endm // m_ret
.macro m_scan_byte
ldrb r3, [r0]
cbz r3, strcat_r0_scan_done
add r0, #1
.endm // m_scan_byte
.macro m_copy_byte reg, cmd, label
ldrb \reg, [r1], #1
strb \reg, [r0], #1
\cmd \reg, \label
.endm // m_copy_byte
ENTRY(strcat)
// Quick check to see if src is empty.
ldrb r2, [r1]
pld [r1, #0]
cbnz r2, strcat_continue
bx lr
strcat_continue:
// To speed up really small dst strings, unroll checking the first 4 bytes.
m_push
m_scan_byte
m_scan_byte
m_scan_byte
m_scan_byte
ands r3, r0, #7
bne strcat_align_src
.p2align 2
strcat_mainloop:
ldmia r0!, {r2, r3}
pld [r0, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcat_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcat_zero_in_second_register
b strcat_mainloop
strcat_zero_in_first_register:
sub r0, r0, #4
strcat_zero_in_second_register:
// Check for zero in byte 0.
tst ip, #0x80
it ne
subne r0, r0, #4
bne strcat_r0_scan_done
// Check for zero in byte 1.
tst ip, #0x8000
it ne
subne r0, r0, #3
bne strcat_r0_scan_done
// Check for zero in byte 2.
tst ip, #0x800000
it ne
subne r0, r0, #2
it eq
// Zero is in byte 3.
subeq r0, r0, #1
strcat_r0_scan_done:
// Unroll the first 8 bytes that will be copied.
m_copy_byte reg=r2, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r3, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r4, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r5, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r2, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r3, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r4, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r5, cmd=cbnz, label=strcpy_continue
strcpy_finish:
m_ret inst=pop
strcpy_continue:
pld [r1, #0]
ands r3, r0, #7
bne strcpy_align_dst
strcpy_check_src_align:
// At this point dst is aligned to a double word, check if src
// is also aligned to a double word.
ands r3, r1, #7
bne strcpy_unaligned_copy
.p2align 2
strcpy_mainloop:
ldmia r1!, {r2, r3}
pld [r1, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
stmia r0!, {r2, r3}
b strcpy_mainloop
strcpy_zero_in_first_register:
lsls lr, ip, #17
itt ne
strbne r2, [r0]
m_ret inst=popne
itt cs
strhcs r2, [r0]
m_ret inst=popcs
lsls ip, ip, #1
itt eq
streq r2, [r0]
m_ret inst=popeq
strh r2, [r0], #2
lsr r3, r2, #16
strb r3, [r0]
m_ret inst=pop
strcpy_zero_in_second_register:
lsls lr, ip, #17
ittt ne
stmiane r0!, {r2}
strbne r3, [r0]
m_ret inst=popne
ittt cs
strcs r2, [r0], #4
strhcs r3, [r0]
m_ret inst=popcs
lsls ip, ip, #1
itt eq
stmiaeq r0, {r2, r3}
m_ret inst=popeq
stmia r0!, {r2}
strh r3, [r0], #2
lsr r4, r3, #16
strb r4, [r0]
m_ret inst=pop
strcpy_align_dst:
// Align to a double word (64 bits).
rsb r3, r3, #8
lsls ip, r3, #31
beq strcpy_align_to_32
ldrb r2, [r1], #1
strb r2, [r0], #1
cbz r2, strcpy_complete
strcpy_align_to_32:
bcc strcpy_align_to_64
ldrb r4, [r1], #1
strb r4, [r0], #1
cmp r4, #0
it eq
m_ret inst=popeq
ldrb r5, [r1], #1
strb r5, [r0], #1
cmp r5, #0
it eq
m_ret inst=popeq
strcpy_align_to_64:
tst r3, #4
beq strcpy_check_src_align
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
stmia r0!, {r2}
b strcpy_check_src_align
strcpy_complete:
m_ret inst=pop
strcpy_unaligned_copy:
// Dst is aligned to a double word, while src is at an unknown alignment.
// There are 7 different versions of the unaligned copy code
// to prevent overreading the src. The mainloop of every single version
// will store 64 bits per loop. The difference is how much of src can
// be read without potentially crossing a page boundary.
tbb [pc, r3]
strcpy_unaligned_branchtable:
.byte 0
.byte ((strcpy_unalign7 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign6 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign5 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign4 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign3 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign2 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign1 - strcpy_unaligned_branchtable)/2)
.p2align 2
// Can read 7 bytes before possibly crossing a page.
strcpy_unalign7:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldrb r3, [r1]
cbz r3, strcpy_unalign7_copy5bytes
ldrb r4, [r1, #1]
cbz r4, strcpy_unalign7_copy6bytes
ldrb r5, [r1, #2]
cbz r5, strcpy_unalign7_copy7bytes
ldr r3, [r1], #4
pld [r1, #64]
lsrs ip, r3, #24
stmia r0!, {r2, r3}
beq strcpy_unalign_return
b strcpy_unalign7
strcpy_unalign7_copy5bytes:
stmia r0!, {r2}
strb r3, [r0]
strcpy_unalign_return:
m_ret inst=pop
strcpy_unalign7_copy6bytes:
stmia r0!, {r2}
strb r3, [r0], #1
strb r4, [r0], #1
m_ret inst=pop
strcpy_unalign7_copy7bytes:
stmia r0!, {r2}
strb r3, [r0], #1
strb r4, [r0], #1
strb r5, [r0], #1
m_ret inst=pop
.p2align 2
// Can read 6 bytes before possibly crossing a page.
strcpy_unalign6:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldrb r4, [r1]
cbz r4, strcpy_unalign_copy5bytes
ldrb r5, [r1, #1]
cbz r5, strcpy_unalign_copy6bytes
ldr r3, [r1], #4
pld [r1, #64]
tst r3, #0xff0000
beq strcpy_unalign6_copy7bytes
lsrs ip, r3, #24
stmia r0!, {r2, r3}
beq strcpy_unalign_return
b strcpy_unalign6
strcpy_unalign6_copy7bytes:
stmia r0!, {r2}
strh r3, [r0], #2
lsr r3, #16
strb r3, [r0]
m_ret inst=pop
.p2align 2
// Can read 5 bytes before possibly crossing a page.
strcpy_unalign5:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldrb r4, [r1]
cbz r4, strcpy_unalign_copy5bytes
ldr r3, [r1], #4
pld [r1, #64]
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
stmia r0!, {r2, r3}
b strcpy_unalign5
strcpy_unalign_copy5bytes:
stmia r0!, {r2}
strb r4, [r0]
m_ret inst=pop
strcpy_unalign_copy6bytes:
stmia r0!, {r2}
strb r4, [r0], #1
strb r5, [r0]
m_ret inst=pop
.p2align 2
// Can read 4 bytes before possibly crossing a page.
strcpy_unalign4:
ldmia r1!, {r2}
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldmia r1!, {r3}
pld [r1, #64]
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
stmia r0!, {r2, r3}
b strcpy_unalign4
.p2align 2
// Can read 3 bytes before possibly crossing a page.
strcpy_unalign3:
ldrb r2, [r1]
cbz r2, strcpy_unalign3_copy1byte
ldrb r3, [r1, #1]
cbz r3, strcpy_unalign3_copy2bytes
ldrb r4, [r1, #2]
cbz r4, strcpy_unalign3_copy3bytes
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
lsrs lr, r2, #24
beq strcpy_unalign_copy4bytes
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
stmia r0!, {r2, r3}
b strcpy_unalign3
strcpy_unalign3_copy1byte:
strb r2, [r0]
m_ret inst=pop
strcpy_unalign3_copy2bytes:
strb r2, [r0], #1
strb r3, [r0]
m_ret inst=pop
strcpy_unalign3_copy3bytes:
strb r2, [r0], #1
strb r3, [r0], #1
strb r4, [r0]
m_ret inst=pop
.p2align 2
// Can read 2 bytes before possibly crossing a page.
strcpy_unalign2:
ldrb r2, [r1]
cbz r2, strcpy_unalign_copy1byte
ldrb r3, [r1, #1]
cbz r3, strcpy_unalign_copy2bytes
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
tst r2, #0xff0000
beq strcpy_unalign_copy3bytes
lsrs ip, r2, #24
beq strcpy_unalign_copy4bytes
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
stmia r0!, {r2, r3}
b strcpy_unalign2
.p2align 2
// Can read 1 byte before possibly crossing a page.
strcpy_unalign1:
ldrb r2, [r1]
cbz r2, strcpy_unalign_copy1byte
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
stmia r0!, {r2, r3}
b strcpy_unalign1
strcpy_unalign_copy1byte:
strb r2, [r0]
m_ret inst=pop
strcpy_unalign_copy2bytes:
strb r2, [r0], #1
strb r3, [r0]
m_ret inst=pop
strcpy_unalign_copy3bytes:
strh r2, [r0], #2
lsr r2, #16
strb r2, [r0]
m_ret inst=pop
strcpy_unalign_copy4bytes:
stmia r0, {r2}
m_ret inst=pop
strcat_align_src:
// Align to a double word (64 bits).
rsb r3, r3, #8
lsls ip, r3, #31
beq strcat_align_to_32
ldrb r2, [r0], #1
cbz r2, strcat_r0_update
strcat_align_to_32:
bcc strcat_align_to_64
ldrb r2, [r0], #1
cbz r2, strcat_r0_update
ldrb r2, [r0], #1
cbz r2, strcat_r0_update
strcat_align_to_64:
tst r3, #4
beq strcat_mainloop
ldr r3, [r0], #4
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcat_zero_in_second_register
b strcat_mainloop
strcat_r0_update:
sub r0, r0, #1
b strcat_r0_scan_done
END(strcat)

View File

@@ -123,8 +123,13 @@ ENTRY(strcmp)
.macro init
/* Macro to save temporary registers and prepare magic values. */
subs sp, sp, #16
.cfi_def_cfa_offset 16
strd r4, r5, [sp, #8]
.cfi_rel_offset r4, 0
.cfi_rel_offset r5, 4
strd r6, r7, [sp]
.cfi_rel_offset r6, 8
.cfi_rel_offset r7, 12
mvn r6, #0 /* all F */
mov r7, #0 /* all 0 */
.endm /* init */
@@ -165,18 +170,20 @@ ENTRY(strcmp)
#endif /* not __ARMEB__ */
.endm /* setup_return */
.cfi_startproc
pld [r0, #0]
pld [r1, #0]
/* Are both strings double-word aligned? */
orr ip, r0, r1
tst ip, #7
bne do_align
bne .L_do_align
/* Fast path. */
.save {r4-r7}
init
doubleword_aligned:
.L_doubleword_aligned:
/* Get here when the strings to compare are double-word aligned. */
/* Compare two words in every iteration. */
@@ -189,14 +196,14 @@ doubleword_aligned:
ldrd r2, r3, [r0], #8
ldrd r4, r5, [r1], #8
magic_compare_and_branch w1=r2, w2=r4, label=return_24
magic_compare_and_branch w1=r3, w2=r5, label=return_35
magic_compare_and_branch w1=r2, w2=r4, label=.L_return_24
magic_compare_and_branch w1=r3, w2=r5, label=.L_return_35
b 2b
do_align:
.L_do_align:
/* Is the first string word-aligned? */
ands ip, r0, #3
beq word_aligned_r0
beq .L_word_aligned_r0
/* Fast compare byte by byte until the first string is word-aligned. */
/* The offset of r0 from a word boundary is in ip. Thus, the number of bytes
@@ -204,58 +211,58 @@ do_align:
bic r0, r0, #3
ldr r2, [r0], #4
lsls ip, ip, #31
beq byte2
bcs byte3
beq .L_byte2
bcs .L_byte3
byte1:
.L_byte1:
ldrb ip, [r1], #1
uxtb r3, r2, ror #BYTE1_OFFSET
subs ip, r3, ip
bne fast_return
m_cbz reg=r3, label=fast_return
bne .L_fast_return
m_cbz reg=r3, label=.L_fast_return
byte2:
.L_byte2:
ldrb ip, [r1], #1
uxtb r3, r2, ror #BYTE2_OFFSET
subs ip, r3, ip
bne fast_return
m_cbz reg=r3, label=fast_return
bne .L_fast_return
m_cbz reg=r3, label=.L_fast_return
byte3:
.L_byte3:
ldrb ip, [r1], #1
uxtb r3, r2, ror #BYTE3_OFFSET
subs ip, r3, ip
bne fast_return
m_cbnz reg=r3, label=word_aligned_r0
bne .L_fast_return
m_cbnz reg=r3, label=.L_word_aligned_r0
fast_return:
.L_fast_return:
mov r0, ip
bx lr
word_aligned_r0:
.L_word_aligned_r0:
init
/* The first string is word-aligned. */
/* Is the second string word-aligned? */
ands ip, r1, #3
bne strcmp_unaligned
bne .L_strcmp_unaligned
word_aligned:
.L_word_aligned:
/* The strings are word-aligned. */
/* Is the first string double-word aligned? */
tst r0, #4
beq doubleword_aligned_r0
beq .L_doubleword_aligned_r0
/* If r0 is not double-word aligned yet, align it by loading
and comparing the next word from each string. */
ldr r2, [r0], #4
ldr r4, [r1], #4
magic_compare_and_branch w1=r2 w2=r4 label=return_24
magic_compare_and_branch w1=r2 w2=r4 label=.L_return_24
doubleword_aligned_r0:
.L_doubleword_aligned_r0:
/* Get here when r0 is double-word aligned. */
/* Is r1 doubleword_aligned? */
tst r1, #4
beq doubleword_aligned
beq .L_doubleword_aligned
/* Get here when the strings to compare are word-aligned,
r0 is double-word aligned, but r1 is not double-word aligned. */
@@ -271,9 +278,9 @@ doubleword_aligned_r0:
/* Load the next double-word from each string and compare. */
ldrd r2, r3, [r0], #8
magic_compare_and_branch w1=r2 w2=r5 label=return_25
magic_compare_and_branch w1=r2 w2=r5 label=.L_return_25
ldrd r4, r5, [r1], #8
magic_compare_and_branch w1=r3 w2=r4 label=return_34
magic_compare_and_branch w1=r3 w2=r4 label=.L_return_34
b 3b
.macro miscmp_word offsetlo offsethi
@@ -297,33 +304,33 @@ doubleword_aligned_r0:
and r2, r3, r6, S2LOMEM #\offsetlo
it eq
cmpeq r2, r5
bne return_25
bne .L_return_25
ldr r5, [r1], #4
cmp ip, #0
eor r3, r2, r3
S2HIMEM r2, r5, #\offsethi
it eq
cmpeq r3, r2
bne return_32
bne .L_return_32
b 7b
.endm /* miscmp_word */
return_32:
.L_return_32:
setup_return w1=r3, w2=r2
b do_return
return_34:
b .L_do_return
.L_return_34:
setup_return w1=r3, w2=r4
b do_return
return_25:
b .L_do_return
.L_return_25:
setup_return w1=r2, w2=r5
b do_return
return_35:
b .L_do_return
.L_return_35:
setup_return w1=r3, w2=r5
b do_return
return_24:
b .L_do_return
.L_return_24:
setup_return w1=r2, w2=r4
do_return:
.L_do_return:
#ifdef __ARMEB__
mov r0, ip
@@ -335,11 +342,16 @@ do_return:
ldrd r6, r7, [sp]
ldrd r4, r5, [sp, #8]
adds sp, sp, #16
.cfi_def_cfa_offset 0
.cfi_restore r4
.cfi_restore r5
.cfi_restore r6
.cfi_restore r7
/* There is a zero or a different byte between r1 and r2. */
/* r0 contains a mask of all-zero bytes in r1. */
/* Using r0 and not ip here because cbz requires low register. */
m_cbz reg=r0, label=compute_return_value
m_cbz reg=r0, label=.L_compute_return_value
clz r0, r0
/* r0 contains the number of bits on the left of the first all-zero byte in r1. */
rsb r0, r0, #24
@@ -347,7 +359,7 @@ do_return:
lsr r1, r1, r0
lsr r2, r2, r0
compute_return_value:
.L_compute_return_value:
movs r0, #1
cmp r1, r2
/* The return value is computed as follows.
@@ -367,7 +379,7 @@ compute_return_value:
* bionic/libc/arch-arm/cortex-a15/bionic/strcmp.S for the unedited
* version of the code.
*/
strcmp_unaligned:
.L_strcmp_unaligned:
wp1 .req r0
wp2 .req r1
b1 .req r2
@@ -520,6 +532,11 @@ strcmp_unaligned:
ldrd r6, r7, [sp]
ldrd r4, r5, [sp, #8]
adds sp, sp, #16
.cfi_def_cfa_offset 0
.cfi_restore r4
.cfi_restore r5
.cfi_restore r6
.cfi_restore r7
bx lr
@@ -541,4 +558,5 @@ strcmp_unaligned:
adds sp, sp, #16
bx lr
.cfi_endproc
END(strcmp)

View File

@@ -0,0 +1,456 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Copyright (c) 2013 ARM Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the company may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
.syntax unified
.thumb
.thumb_func
.macro m_push
push {r0, r4, r5, lr}
.endm // m_push
.macro m_ret inst
\inst {r0, r4, r5, pc}
.endm // m_ret
.macro m_copy_byte reg, cmd, label
ldrb \reg, [r1], #1
strb \reg, [r0], #1
\cmd \reg, \label
.endm // m_copy_byte
ENTRY(strcpy)
// Unroll the first 8 bytes that will be copied.
m_push
m_copy_byte reg=r2, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r3, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r4, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r5, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r2, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r3, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r4, cmd=cbz, label=strcpy_finish
m_copy_byte reg=r5, cmd=cbnz, label=strcpy_continue
strcpy_finish:
m_ret inst=pop
strcpy_continue:
pld [r1, #0]
ands r3, r0, #7
bne strcpy_align_dst
strcpy_check_src_align:
// At this point dst is aligned to a double word, check if src
// is also aligned to a double word.
ands r3, r1, #7
bne strcpy_unaligned_copy
.p2align 2
strcpy_mainloop:
ldmia r1!, {r2, r3}
pld [r1, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
stmia r0!, {r2, r3}
b strcpy_mainloop
strcpy_zero_in_first_register:
lsls lr, ip, #17
itt ne
strbne r2, [r0]
m_ret inst=popne
itt cs
strhcs r2, [r0]
m_ret inst=popcs
lsls ip, ip, #1
itt eq
streq r2, [r0]
m_ret inst=popeq
strh r2, [r0], #2
lsr r3, r2, #16
strb r3, [r0]
m_ret inst=pop
strcpy_zero_in_second_register:
lsls lr, ip, #17
ittt ne
stmiane r0!, {r2}
strbne r3, [r0]
m_ret inst=popne
ittt cs
strcs r2, [r0], #4
strhcs r3, [r0]
m_ret inst=popcs
lsls ip, ip, #1
itt eq
stmiaeq r0, {r2, r3}
m_ret inst=popeq
stmia r0!, {r2}
strh r3, [r0], #2
lsr r4, r3, #16
strb r4, [r0]
m_ret inst=pop
strcpy_align_dst:
// Align to a double word (64 bits).
rsb r3, r3, #8
lsls ip, r3, #31
beq strcpy_align_to_32
ldrb r2, [r1], #1
strb r2, [r0], #1
cbz r2, strcpy_complete
strcpy_align_to_32:
bcc strcpy_align_to_64
ldrb r4, [r1], #1
strb r4, [r0], #1
cmp r4, #0
it eq
m_ret inst=popeq
ldrb r5, [r1], #1
strb r5, [r0], #1
cmp r5, #0
it eq
m_ret inst=popeq
strcpy_align_to_64:
tst r3, #4
beq strcpy_check_src_align
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
stmia r0!, {r2}
b strcpy_check_src_align
strcpy_complete:
m_ret inst=pop
strcpy_unaligned_copy:
// Dst is aligned to a double word, while src is at an unknown alignment.
// There are 7 different versions of the unaligned copy code
// to prevent overreading the src. The mainloop of every single version
// will store 64 bits per loop. The difference is how much of src can
// be read without potentially crossing a page boundary.
tbb [pc, r3]
strcpy_unaligned_branchtable:
.byte 0
.byte ((strcpy_unalign7 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign6 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign5 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign4 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign3 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign2 - strcpy_unaligned_branchtable)/2)
.byte ((strcpy_unalign1 - strcpy_unaligned_branchtable)/2)
.p2align 2
// Can read 7 bytes before possibly crossing a page.
strcpy_unalign7:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldrb r3, [r1]
cbz r3, strcpy_unalign7_copy5bytes
ldrb r4, [r1, #1]
cbz r4, strcpy_unalign7_copy6bytes
ldrb r5, [r1, #2]
cbz r5, strcpy_unalign7_copy7bytes
ldr r3, [r1], #4
pld [r1, #64]
lsrs ip, r3, #24
stmia r0!, {r2, r3}
beq strcpy_unalign_return
b strcpy_unalign7
strcpy_unalign7_copy5bytes:
stmia r0!, {r2}
strb r3, [r0]
strcpy_unalign_return:
m_ret inst=pop
strcpy_unalign7_copy6bytes:
stmia r0!, {r2}
strb r3, [r0], #1
strb r4, [r0], #1
m_ret inst=pop
strcpy_unalign7_copy7bytes:
stmia r0!, {r2}
strb r3, [r0], #1
strb r4, [r0], #1
strb r5, [r0], #1
m_ret inst=pop
.p2align 2
// Can read 6 bytes before possibly crossing a page.
strcpy_unalign6:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldrb r4, [r1]
cbz r4, strcpy_unalign_copy5bytes
ldrb r5, [r1, #1]
cbz r5, strcpy_unalign_copy6bytes
ldr r3, [r1], #4
pld [r1, #64]
tst r3, #0xff0000
beq strcpy_unalign6_copy7bytes
lsrs ip, r3, #24
stmia r0!, {r2, r3}
beq strcpy_unalign_return
b strcpy_unalign6
strcpy_unalign6_copy7bytes:
stmia r0!, {r2}
strh r3, [r0], #2
lsr r3, #16
strb r3, [r0]
m_ret inst=pop
.p2align 2
// Can read 5 bytes before possibly crossing a page.
strcpy_unalign5:
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldrb r4, [r1]
cbz r4, strcpy_unalign_copy5bytes
ldr r3, [r1], #4
pld [r1, #64]
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
stmia r0!, {r2, r3}
b strcpy_unalign5
strcpy_unalign_copy5bytes:
stmia r0!, {r2}
strb r4, [r0]
m_ret inst=pop
strcpy_unalign_copy6bytes:
stmia r0!, {r2}
strb r4, [r0], #1
strb r5, [r0]
m_ret inst=pop
.p2align 2
// Can read 4 bytes before possibly crossing a page.
strcpy_unalign4:
ldmia r1!, {r2}
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
ldmia r1!, {r3}
pld [r1, #64]
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
stmia r0!, {r2, r3}
b strcpy_unalign4
.p2align 2
// Can read 3 bytes before possibly crossing a page.
strcpy_unalign3:
ldrb r2, [r1]
cbz r2, strcpy_unalign3_copy1byte
ldrb r3, [r1, #1]
cbz r3, strcpy_unalign3_copy2bytes
ldrb r4, [r1, #2]
cbz r4, strcpy_unalign3_copy3bytes
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
lsrs lr, r2, #24
beq strcpy_unalign_copy4bytes
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
stmia r0!, {r2, r3}
b strcpy_unalign3
strcpy_unalign3_copy1byte:
strb r2, [r0]
m_ret inst=pop
strcpy_unalign3_copy2bytes:
strb r2, [r0], #1
strb r3, [r0]
m_ret inst=pop
strcpy_unalign3_copy3bytes:
strb r2, [r0], #1
strb r3, [r0], #1
strb r4, [r0]
m_ret inst=pop
.p2align 2
// Can read 2 bytes before possibly crossing a page.
strcpy_unalign2:
ldrb r2, [r1]
cbz r2, strcpy_unalign_copy1byte
ldrb r3, [r1, #1]
cbz r3, strcpy_unalign_copy2bytes
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
tst r2, #0xff0000
beq strcpy_unalign_copy3bytes
lsrs ip, r2, #24
beq strcpy_unalign_copy4bytes
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
stmia r0!, {r2, r3}
b strcpy_unalign2
.p2align 2
// Can read 1 byte before possibly crossing a page.
strcpy_unalign1:
ldrb r2, [r1]
cbz r2, strcpy_unalign_copy1byte
ldr r2, [r1], #4
ldr r3, [r1], #4
pld [r1, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne strcpy_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne strcpy_zero_in_second_register
stmia r0!, {r2, r3}
b strcpy_unalign1
strcpy_unalign_copy1byte:
strb r2, [r0]
m_ret inst=pop
strcpy_unalign_copy2bytes:
strb r2, [r0], #1
strb r3, [r0]
m_ret inst=pop
strcpy_unalign_copy3bytes:
strh r2, [r0], #2
lsr r2, #16
strb r2, [r0]
m_ret inst=pop
strcpy_unalign_copy4bytes:
stmia r0, {r2}
m_ret inst=pop
END(strcpy)

View File

@@ -0,0 +1,167 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Copyright (c) 2013 ARM Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the company may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
.syntax unified
.thumb
.thumb_func
ENTRY(strlen)
pld [r0, #0]
mov r1, r0
ands r3, r0, #7
bne align_src
.p2align 2
mainloop:
ldmia r1!, {r2, r3}
pld [r1, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne zero_in_second_register
b mainloop
zero_in_first_register:
sub r0, r1, r0
// Check for zero in byte 0.
lsls r2, ip, #17
beq check_byte1_reg1
sub r0, r0, #8
bx lr
check_byte1_reg1:
bcc check_byte2_reg1
sub r0, r0, #7
bx lr
check_byte2_reg1:
// Check for zero in byte 2.
tst ip, #0x800000
itt ne
subne r0, r0, #6
bxne lr
sub r0, r0, #5
bx lr
zero_in_second_register:
sub r0, r1, r0
// Check for zero in byte 0.
lsls r2, ip, #17
beq check_byte1_reg2
sub r0, r0, #4
bx lr
check_byte1_reg2:
bcc check_byte2_reg2
sub r0, r0, #3
bx lr
check_byte2_reg2:
// Check for zero in byte 2.
tst ip, #0x800000
itt ne
subne r0, r0, #2
bxne lr
sub r0, r0, #1
bx lr
align_src:
// Align to a double word (64 bits).
rsb r3, r3, #8
lsls ip, r3, #31
beq align_to_32
ldrb r2, [r1], #1
cbz r2, done
align_to_32:
bcc align_to_64
ldrb r2, [r1], #1
cbz r2, done
ldrb r2, [r1], #1
cbz r2, done
align_to_64:
tst r3, #4
beq mainloop
ldr r2, [r1], #4
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne zero_in_second_register
b mainloop
done:
sub r0, r1, r0
sub r0, r0, #1
bx lr
END(strlen)

View File

@@ -1,5 +1,10 @@
$(call libc-add-cpu-variant-src,MEMCPY,arch-arm/cortex-a9/bionic/memcpy.S)
$(call libc-add-cpu-variant-src,MEMSET,arch-arm/cortex-a9/bionic/memset.S)
$(call libc-add-cpu-variant-src,STRCAT,arch-arm/cortex-a9/bionic/strcat.S)
$(call libc-add-cpu-variant-src,STRCMP,arch-arm/cortex-a9/bionic/strcmp.S)
$(call libc-add-cpu-variant-src,STRCPY,arch-arm/cortex-a9/bionic/strcpy.S)
$(call libc-add-cpu-variant-src,STRLEN,arch-arm/cortex-a9/bionic/strlen.S)
$(call libc-add-cpu-variant-src,__STRCAT_CHK,arch-arm/cortex-a9/bionic/__strcat_chk.S)
$(call libc-add-cpu-variant-src,__STRCPY_CHK,arch-arm/cortex-a9/bionic/__strcpy_chk.S)
include bionic/libc/arch-arm/generic/generic.mk

View File

@@ -28,6 +28,7 @@
#include <machine/cpu-features.h>
#include <machine/asm.h>
#include "libc_events.h"
/*
* Optimized memcpy() for ARM.
@@ -36,6 +37,13 @@
* so we have to preserve R0.
*/
ENTRY(__memcpy_chk)
cmp r2, r3
bgt fortify_check_failed
// Fall through to memcpy...
END(__memcpy_chk)
ENTRY(memcpy)
/* The stack must always be 64-bits aligned to be compliant with the
* ARM ABI. Since we have to save R0, we might as well save R4
@@ -377,4 +385,20 @@ copy_last_3_and_return:
add sp, sp, #28
ldmfd sp!, {r0, r4, lr}
bx lr
// Only reached when the __memcpy_chk check fails.
fortify_check_failed:
ldr r0, error_message
ldr r1, error_code
1:
add r0, pc
bl __fortify_chk_fail
error_code:
.word BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW
error_message:
.word error_string-(1b+8)
END(memcpy)
.data
error_string:
.string "memcpy buffer overflow"

View File

@@ -27,6 +27,7 @@
*/
#include <machine/asm.h>
#include "libc_events.h"
/*
* Optimized memset() for ARM.
@@ -34,9 +35,28 @@
* memset() returns its first argument.
*/
ENTRY(__memset_chk)
cmp r2, r3
bls done
ldr r0, error_message
ldr r1, error_code
1:
add r0, pc
bl __fortify_chk_fail
error_code:
.word BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW
error_message:
.word error_string-(1b+8)
END(__memset_chk)
ENTRY(bzero)
mov r2, r1
mov r1, #0
done:
// Fall through to memset...
END(bzero)
ENTRY(memset)
@@ -107,3 +127,7 @@ ENTRY(memset)
ldmfd sp!, {r0, r4-r7, lr}
bx lr
END(memset)
.data
error_string:
.string "memset buffer overflow"

View File

@@ -33,16 +33,16 @@ size_t strlen(const char *s)
{
__builtin_prefetch(s);
__builtin_prefetch(s+32);
union {
const char *b;
const uint32_t *w;
uintptr_t i;
} u;
// these are some scratch variables for the asm code below
uint32_t v, t;
// initialize the string length to zero
size_t l = 0;
@@ -60,52 +60,60 @@ size_t strlen(const char *s)
// We need to process 32 bytes per loop to schedule PLD properly
// and achieve the maximum bus speed.
asm(
"ldr %[v], [ %[s] ], #4 \n"
"ldr %[v], [%[s]], #4 \n"
"sub %[l], %[l], %[s] \n"
"0: \n"
#if __ARM_HAVE_PLD
"pld [ %[s], #64 ] \n"
"pld [%[s], #64] \n"
#endif
"sub %[t], %[v], %[mask], lsr #7\n"
"and %[t], %[t], %[mask] \n"
"bics %[t], %[t], %[v] \n"
"ldreq %[v], [ %[s] ], #4 \n"
"it eq \n"
"ldreq %[v], [%[s]], #4 \n"
#if !defined(__OPTIMIZE_SIZE__)
"bne 1f \n"
"sub %[t], %[v], %[mask], lsr #7\n"
"and %[t], %[t], %[mask] \n"
"bics %[t], %[t], %[v] \n"
"ldreq %[v], [ %[s] ], #4 \n"
"it eq \n"
"ldreq %[v], [%[s]], #4 \n"
"bne 1f \n"
"sub %[t], %[v], %[mask], lsr #7\n"
"and %[t], %[t], %[mask] \n"
"bics %[t], %[t], %[v] \n"
"ldreq %[v], [ %[s] ], #4 \n"
"it eq \n"
"ldreq %[v], [%[s]], #4 \n"
"bne 1f \n"
"sub %[t], %[v], %[mask], lsr #7\n"
"and %[t], %[t], %[mask] \n"
"bics %[t], %[t], %[v] \n"
"ldreq %[v], [ %[s] ], #4 \n"
"it eq \n"
"ldreq %[v], [%[s]], #4 \n"
"bne 1f \n"
"sub %[t], %[v], %[mask], lsr #7\n"
"and %[t], %[t], %[mask] \n"
"bics %[t], %[t], %[v] \n"
"ldreq %[v], [ %[s] ], #4 \n"
"it eq \n"
"ldreq %[v], [%[s]], #4 \n"
"bne 1f \n"
"sub %[t], %[v], %[mask], lsr #7\n"
"and %[t], %[t], %[mask] \n"
"bics %[t], %[t], %[v] \n"
"ldreq %[v], [ %[s] ], #4 \n"
"it eq \n"
"ldreq %[v], [%[s]], #4 \n"
"bne 1f \n"
"sub %[t], %[v], %[mask], lsr #7\n"
"and %[t], %[t], %[mask] \n"
"bics %[t], %[t], %[v] \n"
"ldreq %[v], [ %[s] ], #4 \n"
"it eq \n"
"ldreq %[v], [%[s]], #4 \n"
"bne 1f \n"
"sub %[t], %[v], %[mask], lsr #7\n"
"and %[t], %[t], %[mask] \n"
"bics %[t], %[t], %[v] \n"
"ldreq %[v], [ %[s] ], #4 \n"
"it eq \n"
"ldreq %[v], [%[s]], #4 \n"
#endif
"beq 0b \n"
"1: \n"
@@ -117,13 +125,14 @@ size_t strlen(const char *s)
"beq 2f \n"
"add %[l], %[l], #1 \n"
"tst %[v], #0xFF0000 \n"
"it ne \n"
"addne %[l], %[l], #1 \n"
"2: \n"
: [l]"=&r"(l), [v]"=&r"(v), [t]"=&r"(t), [s]"=&r"(u.b)
: "%[l]"(l), "%[s]"(u.b), [mask]"r"(0x80808080UL)
: "cc"
);
done:
return l;
}

View File

@@ -1,3 +1,8 @@
$(call libc-add-cpu-variant-src,MEMCPY,arch-arm/generic/bionic/memcpy.S)
$(call libc-add-cpu-variant-src,MEMSET,arch-arm/generic/bionic/memset.S)
$(call libc-add-cpu-variant-src,STRCAT,string/strcat.c)
$(call libc-add-cpu-variant-src,STRCMP,arch-arm/generic/bionic/strcmp.S)
$(call libc-add-cpu-variant-src,STRCPY,arch-arm/generic/bionic/strcpy.S)
$(call libc-add-cpu-variant-src,STRLEN,arch-arm/generic/bionic/strlen.c)
$(call libc-add-cpu-variant-src,__STRCAT_CHK,bionic/__strcat_chk.cpp)
$(call libc-add-cpu-variant-src,__STRCPY_CHK,bionic/__strcpy_chk.cpp)

View File

@@ -0,0 +1,225 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#include "libc_events.h"
.syntax unified
.thumb
.thumb_func
// Get the length of src string, then get the source of the dst string.
// Check that the two lengths together don't exceed the threshold, then
// do a memcpy of the data.
ENTRY(__strcat_chk)
.cfi_startproc
pld [r0, #0]
push {r0, lr}
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
push {r4, r5}
.save {r4, r5}
.cfi_adjust_cfa_offset 8
.cfi_rel_offset r4, 0
.cfi_rel_offset r5, 4
mov lr, r2
// Save the dst register to r5
mov r5, r0
// Zero out r4
eor r4, r4, r4
// r1 contains the address of the string to count.
.L_strlen_start:
mov r0, r1
ands r3, r1, #7
beq .L_mainloop
// Align to a double word (64 bits).
rsb r3, r3, #8
lsls ip, r3, #31
beq .L_align_to_32
ldrb r2, [r1], #1
cbz r2, .L_update_count_and_finish
.L_align_to_32:
bcc .L_align_to_64
ands ip, r3, #2
beq .L_align_to_64
ldrb r2, [r1], #1
cbz r2, .L_update_count_and_finish
ldrb r2, [r1], #1
cbz r2, .L_update_count_and_finish
.L_align_to_64:
tst r3, #4
beq .L_mainloop
ldr r3, [r1], #4
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne .L_zero_in_second_register
.p2align 2
.L_mainloop:
ldrd r2, r3, [r1], #8
pld [r1, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne .L_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne .L_zero_in_second_register
b .L_mainloop
.L_update_count_and_finish:
sub r3, r1, r0
sub r3, r3, #1
b .L_finish
.L_zero_in_first_register:
sub r3, r1, r0
lsls r2, ip, #17
bne .L_sub8_and_finish
bcs .L_sub7_and_finish
lsls ip, ip, #1
bne .L_sub6_and_finish
sub r3, r3, #5
b .L_finish
.L_sub8_and_finish:
sub r3, r3, #8
b .L_finish
.L_sub7_and_finish:
sub r3, r3, #7
b .L_finish
.L_sub6_and_finish:
sub r3, r3, #6
b .L_finish
.L_zero_in_second_register:
sub r3, r1, r0
lsls r2, ip, #17
bne .L_sub4_and_finish
bcs .L_sub3_and_finish
lsls ip, ip, #1
bne .L_sub2_and_finish
sub r3, r3, #1
b .L_finish
.L_sub4_and_finish:
sub r3, r3, #4
b .L_finish
.L_sub3_and_finish:
sub r3, r3, #3
b .L_finish
.L_sub2_and_finish:
sub r3, r3, #2
.L_finish:
cmp r4, #0
bne .L_strlen_done
// Time to get the dst string length.
mov r1, r5
// Save the original source address to r5.
mov r5, r0
// Save the current length (adding 1 for the terminator).
add r4, r3, #1
b .L_strlen_start
// r0 holds the pointer to the dst string.
// r3 holds the dst string length.
// r4 holds the src string length + 1.
.L_strlen_done:
add r2, r3, r4
cmp r2, lr
bhi __strcat_chk_failed
// Set up the registers for the memcpy code.
mov r1, r5
pld [r1, #64]
mov r2, r4
add r0, r0, r3
pop {r4, r5}
.cfi_endproc
END(__strcat_chk)
#define MEMCPY_BASE __strcat_chk_memcpy_base
#define MEMCPY_BASE_ALIGNED __strcat_chk_memcpy_base_aligned
#include "memcpy_base.S"
ENTRY(__strcat_chk_failed)
.cfi_startproc
.save {r0, lr}
.save {r4, r5}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
.cfi_adjust_cfa_offset 8
.cfi_rel_offset r4, 0
.cfi_rel_offset r5, 4
ldr r0, error_message
ldr r1, error_code
1:
add r0, pc
bl __fortify_chk_fail
error_code:
.word BIONIC_EVENT_STRCAT_BUFFER_OVERFLOW
error_message:
.word error_string-(1b+4)
.cfi_endproc
END(__strcat_chk_failed)
.data
error_string:
.string "strcat buffer overflow"

View File

@@ -0,0 +1,187 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#include "libc_events.h"
.syntax unified
.thumb
.thumb_func
// Get the length of the source string first, then do a memcpy of the data
// instead of a strcpy.
ENTRY(__strcpy_chk)
.cfi_startproc
pld [r0, #0]
push {r0, lr}
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
mov lr, r2
mov r0, r1
ands r3, r1, #7
beq .L_mainloop
// Align to a double word (64 bits).
rsb r3, r3, #8
lsls ip, r3, #31
beq .L_align_to_32
ldrb r2, [r0], #1
cbz r2, .L_update_count_and_finish
.L_align_to_32:
bcc .L_align_to_64
ands ip, r3, #2
beq .L_align_to_64
ldrb r2, [r0], #1
cbz r2, .L_update_count_and_finish
ldrb r2, [r0], #1
cbz r2, .L_update_count_and_finish
.L_align_to_64:
tst r3, #4
beq .L_mainloop
ldr r3, [r0], #4
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne .L_zero_in_second_register
.p2align 2
.L_mainloop:
ldrd r2, r3, [r0], #8
pld [r0, #64]
sub ip, r2, #0x01010101
bic ip, ip, r2
ands ip, ip, #0x80808080
bne .L_zero_in_first_register
sub ip, r3, #0x01010101
bic ip, ip, r3
ands ip, ip, #0x80808080
bne .L_zero_in_second_register
b .L_mainloop
.L_update_count_and_finish:
sub r3, r0, r1
sub r3, r3, #1
b .L_check_size
.L_zero_in_first_register:
sub r3, r0, r1
lsls r2, ip, #17
bne .L_sub8_and_finish
bcs .L_sub7_and_finish
lsls ip, ip, #1
bne .L_sub6_and_finish
sub r3, r3, #5
b .L_check_size
.L_sub8_and_finish:
sub r3, r3, #8
b .L_check_size
.L_sub7_and_finish:
sub r3, r3, #7
b .L_check_size
.L_sub6_and_finish:
sub r3, r3, #6
b .L_check_size
.L_zero_in_second_register:
sub r3, r0, r1
lsls r2, ip, #17
bne .L_sub4_and_finish
bcs .L_sub3_and_finish
lsls ip, ip, #1
bne .L_sub2_and_finish
sub r3, r3, #1
b .L_check_size
.L_sub4_and_finish:
sub r3, r3, #4
b .L_check_size
.L_sub3_and_finish:
sub r3, r3, #3
b .L_check_size
.L_sub2_and_finish:
sub r3, r3, #2
.L_check_size:
pld [r1, #0]
pld [r1, #64]
ldr r0, [sp]
cmp r3, lr
bhs __strcpy_chk_failed
// Add 1 for copy length to get the string terminator.
add r2, r3, #1
.cfi_endproc
END(__strcpy_chk)
#define MEMCPY_BASE __strcpy_chk_memcpy_base
#define MEMCPY_BASE_ALIGNED __strcpy_chk_memcpy_base_aligned
#include "memcpy_base.S"
ENTRY(__strcpy_chk_failed)
.cfi_startproc
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
ldr r0, error_message
ldr r1, error_code
1:
add r0, pc
bl __fortify_chk_fail
error_code:
.word BIONIC_EVENT_STRCPY_BUFFER_OVERFLOW
error_message:
.word error_string-(1b+4)
.cfi_endproc
END(__strcpy_chk_failed)
.data
error_string:
.string "strcpy buffer overflow"

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -28,8 +28,8 @@
/* Assumes neon instructions and a cache line size of 32 bytes. */
#include <machine/cpu-features.h>
#include <machine/asm.h>
#include "libc_events.h"
/*
* This code assumes it is running on a processor that supports all arm v7
@@ -38,109 +38,55 @@
*/
.text
.syntax unified
.fpu neon
.thumb
.thumb_func
#define CACHE_LINE_SIZE 32
ENTRY(__memcpy_chk)
.cfi_startproc
cmp r2, r3
bhi __memcpy_chk_fail
// Fall through to memcpy...
.cfi_endproc
END(__memcpy_chk)
ENTRY(memcpy)
.save {r0, lr}
/* start preloading as early as possible */
pld [r1, #(CACHE_LINE_SIZE*0)]
stmfd sp!, {r0, lr}
pld [r1, #(CACHE_LINE_SIZE*2)]
/* do we have at least 16-bytes to copy (needed for alignment below) */
cmp r2, #16
blo 5f
/* align destination to cache-line for the write-buffer */
rsb r3, r0, #0
ands r3, r3, #0xF
beq 0f
/* copy up to 15-bytes (count in r3) */
sub r2, r2, r3
movs ip, r3, lsl #31
ldrmib lr, [r1], #1
strmib lr, [r0], #1
ldrcsb ip, [r1], #1
ldrcsb lr, [r1], #1
strcsb ip, [r0], #1
strcsb lr, [r0], #1
movs ip, r3, lsl #29
bge 1f
// copies 4 bytes, destination 32-bits aligned
vld4.8 {d0[0], d1[0], d2[0], d3[0]}, [r1]!
vst4.8 {d0[0], d1[0], d2[0], d3[0]}, [r0, :32]!
1: bcc 2f
// copies 8 bytes, destination 64-bits aligned
vld1.8 {d0}, [r1]!
vst1.8 {d0}, [r0, :64]!
2:
0: /* preload immediately the next cache line, which we may need */
pld [r1, #(CACHE_LINE_SIZE*0)]
pld [r1, #(CACHE_LINE_SIZE*2)]
/* make sure we have at least 64 bytes to copy */
subs r2, r2, #64
blo 2f
/* Preload all the cache lines we need.
* NOTE: The number of pld below depends on CACHE_LINE_SIZE,
* ideally we would increase the distance in the main loop to
* avoid the goofy code below. In practice this doesn't seem to make
* a big difference.
* NOTE: The value CACHE_LINE_SIZE * 8 was chosen through
* experimentation.
*/
pld [r1, #(CACHE_LINE_SIZE*4)]
pld [r1, #(CACHE_LINE_SIZE*6)]
pld [r1, #(CACHE_LINE_SIZE*8)]
1: /* The main loop copies 64 bytes at a time */
vld1.8 {d0 - d3}, [r1]!
vld1.8 {d4 - d7}, [r1]!
pld [r1, #(CACHE_LINE_SIZE*8)]
subs r2, r2, #64
vst1.8 {d0 - d3}, [r0, :128]!
vst1.8 {d4 - d7}, [r0, :128]!
bhs 1b
2: /* fix-up the remaining count and make sure we have >= 32 bytes left */
add r2, r2, #64
subs r2, r2, #32
blo 4f
3: /* 32 bytes at a time. These cache lines were already preloaded */
vld1.8 {d0 - d3}, [r1]!
subs r2, r2, #32
vst1.8 {d0 - d3}, [r0, :128]!
bhs 3b
4: /* less than 32 left */
add r2, r2, #32
tst r2, #0x10
beq 5f
// copies 16 bytes, 128-bits aligned
vld1.8 {d0, d1}, [r1]!
vst1.8 {d0, d1}, [r0, :128]!
5: /* copy up to 15-bytes (count in r2) */
movs ip, r2, lsl #29
bcc 1f
vld1.8 {d0}, [r1]!
vst1.8 {d0}, [r0]!
1: bge 2f
vld4.8 {d0[0], d1[0], d2[0], d3[0]}, [r1]!
vst4.8 {d0[0], d1[0], d2[0], d3[0]}, [r0]!
2: movs ip, r2, lsl #31
ldrmib r3, [r1], #1
ldrcsb ip, [r1], #1
ldrcsb lr, [r1], #1
strmib r3, [r0], #1
strcsb ip, [r0], #1
strcsb lr, [r0], #1
ldmfd sp!, {r0, lr}
bx lr
.cfi_startproc
pld [r1, #64]
stmfd sp!, {r0, lr}
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
.cfi_endproc
END(memcpy)
#define MEMCPY_BASE __memcpy_base
#define MEMCPY_BASE_ALIGNED __memcpy_base_aligned
#include "memcpy_base.S"
ENTRY(__memcpy_chk_fail)
.cfi_startproc
// Preserve lr for backtrace.
push {lr}
.save {lr}
.cfi_def_cfa_offset 4
.cfi_rel_offset lr, 0
ldr r0, error_message
ldr r1, error_code
1:
add r0, pc
bl __fortify_chk_fail
error_code:
.word BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW
error_message:
.word error_string-(1b+4)
.cfi_endproc
END(__memcpy_chk_fail)
.data
error_string:
.string "memcpy buffer overflow"

View File

@@ -0,0 +1,127 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* This code assumes it is running on a processor that supports all arm v7
* instructions, that supports neon instructions, and that has a 32 byte
* cache line.
*/
// Assumes neon instructions and a cache line size of 32 bytes.
ENTRY(MEMCPY_BASE)
.cfi_startproc
.save {r0, lr}
.cfi_def_cfa_offset 8
.cfi_rel_offset r0, 0
.cfi_rel_offset lr, 4
/* do we have at least 16-bytes to copy (needed for alignment below) */
cmp r2, #16
blo 5f
/* align destination to cache-line for the write-buffer */
rsb r3, r0, #0
ands r3, r3, #0xF
beq 2f
/* copy up to 15-bytes (count in r3) */
sub r2, r2, r3
movs ip, r3, lsl #31
itt mi
ldrbmi lr, [r1], #1
strbmi lr, [r0], #1
itttt cs
ldrbcs ip, [r1], #1
ldrbcs lr, [r1], #1
strbcs ip, [r0], #1
strbcs lr, [r0], #1
movs ip, r3, lsl #29
bge 1f
// copies 4 bytes, destination 32-bits aligned
vld4.8 {d0[0], d1[0], d2[0], d3[0]}, [r1]!
vst4.8 {d0[0], d1[0], d2[0], d3[0]}, [r0, :32]!
1: bcc 2f
// copies 8 bytes, destination 64-bits aligned
vld1.8 {d0}, [r1]!
vst1.8 {d0}, [r0, :64]!
2: /* make sure we have at least 64 bytes to copy */
subs r2, r2, #64
blo 2f
1: /* The main loop copies 64 bytes at a time */
vld1.8 {d0 - d3}, [r1]!
vld1.8 {d4 - d7}, [r1]!
pld [r1, #(32*2)]
subs r2, r2, #64
vst1.8 {d0 - d3}, [r0, :128]!
vst1.8 {d4 - d7}, [r0, :128]!
bhs 1b
2: /* fix-up the remaining count and make sure we have >= 32 bytes left */
adds r2, r2, #32
blo 4f
/* Copy 32 bytes. These cache lines were already preloaded */
vld1.8 {d0 - d3}, [r1]!
sub r2, r2, #32
vst1.8 {d0 - d3}, [r0, :128]!
4: /* less than 32 left */
add r2, r2, #32
tst r2, #0x10
beq 5f
// copies 16 bytes, 128-bits aligned
vld1.8 {d0, d1}, [r1]!
vst1.8 {d0, d1}, [r0, :128]!
5: /* copy up to 15-bytes (count in r2) */
movs ip, r2, lsl #29
bcc 1f
vld1.8 {d0}, [r1]!
vst1.8 {d0}, [r0]!
1: bge 2f
vld4.8 {d0[0], d1[0], d2[0], d3[0]}, [r1]!
vst4.8 {d0[0], d1[0], d2[0], d3[0]}, [r0]!
2: movs ip, r2, lsl #31
itt mi
ldrbmi r3, [r1], #1
strbmi r3, [r0], #1
itttt cs
ldrbcs ip, [r1], #1
ldrbcs lr, [r1], #1
strbcs ip, [r0], #1
strbcs lr, [r0], #1
ldmfd sp!, {r0, lr}
bx lr
.cfi_endproc
END(MEMCPY_BASE)

View File

@@ -28,6 +28,7 @@
#include <machine/cpu-features.h>
#include <machine/asm.h>
#include "libc_events.h"
/*
* This code assumes it is running on a processor that supports all arm v7
@@ -37,15 +38,47 @@
.fpu neon
ENTRY(__memset_chk)
.cfi_startproc
cmp r2, r3
bls .L_done
// Preserve lr for backtrace.
.save {lr}
push {lr}
.cfi_def_cfa_offset 4
.cfi_rel_offset lr, 0
ldr r0, error_message
ldr r1, error_code
1:
add r0, pc
bl __fortify_chk_fail
error_code:
.word BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW
error_message:
.word error_string-(1b+8)
.cfi_endproc
END(__memset_chk)
ENTRY(bzero)
.cfi_startproc
mov r2, r1
mov r1, #0
.L_done:
// Fall through to memset...
.cfi_endproc
END(bzero)
/* memset() returns its first argument. */
ENTRY(memset)
.cfi_startproc
.save {r0}
stmfd sp!, {r0}
.cfi_def_cfa_offset 4
.cfi_rel_offset r0, 0
vdup.8 q0, r1
@@ -78,4 +111,9 @@ ENTRY(memset)
strcsb r1, [r0], #1
ldmfd sp!, {r0}
bx lr
.cfi_endproc
END(memset)
.data
error_string:
.string "memset buffer overflow"

View File

@@ -123,8 +123,13 @@ ENTRY(strcmp)
.macro init
/* Macro to save temporary registers and prepare magic values. */
subs sp, sp, #16
.cfi_def_cfa_offset 16
strd r4, r5, [sp, #8]
.cfi_rel_offset r4, 0
.cfi_rel_offset r5, 4
strd r6, r7, [sp]
.cfi_rel_offset r6, 8
.cfi_rel_offset r7, 12
mvn r6, #0 /* all F */
mov r7, #0 /* all 0 */
.endm /* init */
@@ -165,18 +170,20 @@ ENTRY(strcmp)
#endif /* not __ARMEB__ */
.endm /* setup_return */
.cfi_startproc
pld [r0, #0]
pld [r1, #0]
/* Are both strings double-word aligned? */
orr ip, r0, r1
tst ip, #7
bne do_align
bne .L_do_align
/* Fast path. */
.save {r4-r7}
init
doubleword_aligned:
.L_doubleword_aligned:
/* Get here when the strings to compare are double-word aligned. */
/* Compare two words in every iteration. */
@@ -189,14 +196,14 @@ doubleword_aligned:
ldrd r2, r3, [r0], #8
ldrd r4, r5, [r1], #8
magic_compare_and_branch w1=r2, w2=r4, label=return_24
magic_compare_and_branch w1=r3, w2=r5, label=return_35
magic_compare_and_branch w1=r2, w2=r4, label=.L_return_24
magic_compare_and_branch w1=r3, w2=r5, label=.L_return_35
b 2b
do_align:
.L_do_align:
/* Is the first string word-aligned? */
ands ip, r0, #3
beq word_aligned_r0
beq .L_word_aligned_r0
/* Fast compare byte by byte until the first string is word-aligned. */
/* The offset of r0 from a word boundary is in ip. Thus, the number of bytes
@@ -204,58 +211,58 @@ do_align:
bic r0, r0, #3
ldr r2, [r0], #4
lsls ip, ip, #31
beq byte2
bcs byte3
beq .L_byte2
bcs .L_byte3
byte1:
.L_byte1:
ldrb ip, [r1], #1
uxtb r3, r2, ror #BYTE1_OFFSET
subs ip, r3, ip
bne fast_return
m_cbz reg=r3, label=fast_return
bne .L_fast_return
m_cbz reg=r3, label=.L_fast_return
byte2:
.L_byte2:
ldrb ip, [r1], #1
uxtb r3, r2, ror #BYTE2_OFFSET
subs ip, r3, ip
bne fast_return
m_cbz reg=r3, label=fast_return
bne .L_fast_return
m_cbz reg=r3, label=.L_fast_return
byte3:
.L_byte3:
ldrb ip, [r1], #1
uxtb r3, r2, ror #BYTE3_OFFSET
subs ip, r3, ip
bne fast_return
m_cbnz reg=r3, label=word_aligned_r0
bne .L_fast_return
m_cbnz reg=r3, label=.L_word_aligned_r0
fast_return:
.L_fast_return:
mov r0, ip
bx lr
word_aligned_r0:
.L_word_aligned_r0:
init
/* The first string is word-aligned. */
/* Is the second string word-aligned? */
ands ip, r1, #3
bne strcmp_unaligned
bne .L_strcmp_unaligned
word_aligned:
.L_word_aligned:
/* The strings are word-aligned. */
/* Is the first string double-word aligned? */
tst r0, #4
beq doubleword_aligned_r0
beq .L_doubleword_aligned_r0
/* If r0 is not double-word aligned yet, align it by loading
and comparing the next word from each string. */
ldr r2, [r0], #4
ldr r4, [r1], #4
magic_compare_and_branch w1=r2 w2=r4 label=return_24
magic_compare_and_branch w1=r2 w2=r4 label=.L_return_24
doubleword_aligned_r0:
.L_doubleword_aligned_r0:
/* Get here when r0 is double-word aligned. */
/* Is r1 doubleword_aligned? */
tst r1, #4
beq doubleword_aligned
beq .L_doubleword_aligned
/* Get here when the strings to compare are word-aligned,
r0 is double-word aligned, but r1 is not double-word aligned. */
@@ -271,9 +278,9 @@ doubleword_aligned_r0:
/* Load the next double-word from each string and compare. */
ldrd r2, r3, [r0], #8
magic_compare_and_branch w1=r2 w2=r5 label=return_25
magic_compare_and_branch w1=r2 w2=r5 label=.L_return_25
ldrd r4, r5, [r1], #8
magic_compare_and_branch w1=r3 w2=r4 label=return_34
magic_compare_and_branch w1=r3 w2=r4 label=.L_return_34
b 3b
.macro miscmp_word offsetlo offsethi
@@ -297,46 +304,46 @@ doubleword_aligned_r0:
and r2, r3, r6, S2LOMEM #\offsetlo
it eq
cmpeq r2, r5
bne return_25
bne .L_return_25
ldr r5, [r1], #4
cmp ip, #0
eor r3, r2, r3
S2HIMEM r2, r5, #\offsethi
it eq
cmpeq r3, r2
bne return_32
bne .L_return_32
b 7b
.endm /* miscmp_word */
strcmp_unaligned:
.L_strcmp_unaligned:
/* r0 is word-aligned, r1 is at offset ip from a word. */
/* Align r1 to the (previous) word-boundary. */
bic r1, r1, #3
/* Unaligned comparison word by word using LDRs. */
cmp ip, #2
beq miscmp_word_16 /* If ip == 2. */
bge miscmp_word_24 /* If ip == 3. */
beq .L_miscmp_word_16 /* If ip == 2. */
bge .L_miscmp_word_24 /* If ip == 3. */
miscmp_word offsetlo=8 offsethi=24 /* If ip == 1. */
miscmp_word_24: miscmp_word offsetlo=24 offsethi=8
.L_miscmp_word_24: miscmp_word offsetlo=24 offsethi=8
return_32:
.L_return_32:
setup_return w1=r3, w2=r2
b do_return
return_34:
b .L_do_return
.L_return_34:
setup_return w1=r3, w2=r4
b do_return
return_25:
b .L_do_return
.L_return_25:
setup_return w1=r2, w2=r5
b do_return
return_35:
b .L_do_return
.L_return_35:
setup_return w1=r3, w2=r5
b do_return
return_24:
b .L_do_return
.L_return_24:
setup_return w1=r2, w2=r4
do_return:
.L_do_return:
#ifdef __ARMEB__
mov r0, ip
@@ -348,11 +355,16 @@ do_return:
ldrd r6, r7, [sp]
ldrd r4, r5, [sp, #8]
adds sp, sp, #16
.cfi_def_cfa_offset 0
.cfi_restore r4
.cfi_restore r5
.cfi_restore r6
.cfi_restore r7
/* There is a zero or a different byte between r1 and r2. */
/* r0 contains a mask of all-zero bytes in r1. */
/* Using r0 and not ip here because cbz requires low register. */
m_cbz reg=r0, label=compute_return_value
m_cbz reg=r0, label=.L_compute_return_value
clz r0, r0
/* r0 contains the number of bits on the left of the first all-zero byte in r1. */
rsb r0, r0, #24
@@ -360,7 +372,7 @@ do_return:
lsr r1, r1, r0
lsr r2, r2, r0
compute_return_value:
.L_compute_return_value:
movs r0, #1
cmp r1, r2
/* The return value is computed as follows.
@@ -380,7 +392,7 @@ compute_return_value:
* previous version. See bionic/libc/arch-arm/cortex-a15/bionic/strcmp.S
* for the unedited version of this code.
*/
miscmp_word_16:
.L_miscmp_word_16:
wp1 .req r0
wp2 .req r1
b1 .req r2
@@ -453,6 +465,11 @@ miscmp_word_16:
ldrd r6, r7, [sp]
ldrd r4, r5, [sp, #8]
adds sp, sp, #16
.cfi_def_cfa_offset 0
.cfi_restore r4
.cfi_restore r5
.cfi_restore r6
.cfi_restore r7
bx lr
@@ -472,6 +489,12 @@ miscmp_word_16:
ldrd r6, r7, [sp]
ldrd r4, r5, [sp, #8]
adds sp, sp, #16
.cfi_def_cfa_offset 0
.cfi_restore r4
.cfi_restore r5
.cfi_restore r6
.cfi_restore r7
bx lr
.cfi_endproc
END(strcmp)

View File

@@ -1,5 +1,11 @@
$(call libc-add-cpu-variant-src,MEMCPY,arch-arm/krait/bionic/memcpy.S)
$(call libc-add-cpu-variant-src,MEMSET,arch-arm/krait/bionic/memset.S)
$(call libc-add-cpu-variant-src,STRCMP,arch-arm/krait/bionic/strcmp.S)
$(call libc-add-cpu-variant-src,__STRCAT_CHK,arch-arm/krait/bionic/__strcat_chk.S)
$(call libc-add-cpu-variant-src,__STRCPY_CHK,arch-arm/krait/bionic/__strcpy_chk.S)
# Use cortex-a15 versions of strcat/strcpy/strlen.
$(call libc-add-cpu-variant-src,STRCAT,arch-arm/cortex-a15/bionic/strcat.S)
$(call libc-add-cpu-variant-src,STRCPY,arch-arm/cortex-a15/bionic/strcpy.S)
$(call libc-add-cpu-variant-src,STRLEN,arch-arm/cortex-a15/bionic/strlen.S)
include bionic/libc/arch-arm/generic/generic.mk

View File

@@ -126,6 +126,8 @@ syscall_src += arch-arm/syscalls/removexattr.S
syscall_src += arch-arm/syscalls/lremovexattr.S
syscall_src += arch-arm/syscalls/__statfs64.S
syscall_src += arch-arm/syscalls/unshare.S
syscall_src += arch-arm/syscalls/swapon.S
syscall_src += arch-arm/syscalls/swapoff.S
syscall_src += arch-arm/syscalls/pause.S
syscall_src += arch-arm/syscalls/gettimeofday.S
syscall_src += arch-arm/syscalls/settimeofday.S
@@ -144,6 +146,9 @@ syscall_src += arch-arm/syscalls/__timer_getoverrun.S
syscall_src += arch-arm/syscalls/__timer_delete.S
syscall_src += arch-arm/syscalls/utimes.S
syscall_src += arch-arm/syscalls/utimensat.S
syscall_src += arch-arm/syscalls/timerfd_create.S
syscall_src += arch-arm/syscalls/timerfd_settime.S
syscall_src += arch-arm/syscalls/timerfd_gettime.S
syscall_src += arch-arm/syscalls/sigaction.S
syscall_src += arch-arm/syscalls/sigprocmask.S
syscall_src += arch-arm/syscalls/__sigsuspend.S

View File

@@ -0,0 +1,15 @@
/* autogenerated by gensyscalls.py */
#include <asm/unistd.h>
#include <linux/err.h>
#include <machine/asm.h>
ENTRY(swapoff)
mov ip, r7
ldr r7, =__NR_swapoff
swi #0
mov r7, ip
cmn r0, #(MAX_ERRNO + 1)
bxls lr
neg r0, r0
b __set_errno
END(swapoff)

View File

@@ -0,0 +1,15 @@
/* autogenerated by gensyscalls.py */
#include <asm/unistd.h>
#include <linux/err.h>
#include <machine/asm.h>
ENTRY(swapon)
mov ip, r7
ldr r7, =__NR_swapon
swi #0
mov r7, ip
cmn r0, #(MAX_ERRNO + 1)
bxls lr
neg r0, r0
b __set_errno
END(swapon)

View File

@@ -0,0 +1,15 @@
/* autogenerated by gensyscalls.py */
#include <asm/unistd.h>
#include <linux/err.h>
#include <machine/asm.h>
ENTRY(timerfd_create)
mov ip, r7
ldr r7, =__NR_timerfd_create
swi #0
mov r7, ip
cmn r0, #(MAX_ERRNO + 1)
bxls lr
neg r0, r0
b __set_errno
END(timerfd_create)

View File

@@ -0,0 +1,15 @@
/* autogenerated by gensyscalls.py */
#include <asm/unistd.h>
#include <linux/err.h>
#include <machine/asm.h>
ENTRY(timerfd_gettime)
mov ip, r7
ldr r7, =__NR_timerfd_gettime
swi #0
mov r7, ip
cmn r0, #(MAX_ERRNO + 1)
bxls lr
neg r0, r0
b __set_errno
END(timerfd_gettime)

View File

@@ -0,0 +1,15 @@
/* autogenerated by gensyscalls.py */
#include <asm/unistd.h>
#include <linux/err.h>
#include <machine/asm.h>
ENTRY(timerfd_settime)
mov ip, r7
ldr r7, =__NR_timerfd_settime
swi #0
mov r7, ip
cmn r0, #(MAX_ERRNO + 1)
bxls lr
neg r0, r0
b __set_errno
END(timerfd_settime)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010 The Android Open Source Project
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,13 +26,11 @@
* SUCH DAMAGE.
*/
# The __dso_handle global variable is used by static
# C++ constructors and destructors in the binary.
# See http://www.codesourcery.com/public/cxx-abi/abi.html#dso-dtor
#
.data
.align 4
.hidden __dso_handle
.globl __dso_handle
__dso_handle:
.long __dso_handle
extern void *__dso_handle;
extern int __cxa_atexit(void (*func)(void *), void *arg, void *dso);
__attribute__ ((visibility ("hidden")))
int atexit(void (*func)(void))
{
return (__cxa_atexit((void (*)(void *))func, (void *)0, &__dso_handle));
}

View File

@@ -1,146 +0,0 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
.text
.align 4
.type __start,@function
.globl __start
.globl _start
# this is the small startup code that is first run when
# any executable that is statically-linked with Bionic
# runs.
#
# it's purpose is to call __libc_init with appropriate
# arguments, which are:
#
# - the address of the raw data block setup by the Linux
# kernel ELF loader
#
# - address of an "onexit" function, not used on any
# platform supported by Bionic
#
# - address of the "main" function of the program.
#
# - address of the constructor list
#
.ent __start
__start:
_start:
bal 1f
1:
.set noreorder
.cpload $ra
.set reorder
move $a0, $sp
move $a1, $0
la $a2, main
la $a3, 1f
subu $sp, 32
la $t9, __libc_init
j $t9
.end __start
1: .long __PREINIT_ARRAY__
.long __INIT_ARRAY__
.long __FINI_ARRAY__
.section .preinit_array, "aw"
.type __PREINIT_ARRAY__, @object
.globl __PREINIT_ARRAY__
__PREINIT_ARRAY__:
.long -1
.section .init_array, "aw"
.type __INIT_ARRAY__, @object
.globl __INIT_ARRAY__
__INIT_ARRAY__:
.long -1
.section .fini_array, "aw"
.type __FINI_ARRAY__, @object
.globl __FINI_ARRAY__
__FINI_ARRAY__:
.long -1
.long __do_global_dtors_aux
.abicalls
.text
.align 2
.set nomips16
.ent __do_global_dtors_aux
.type __do_global_dtors_aux, @function
__do_global_dtors_aux:
.frame $sp,32,$31 # vars= 0, regs= 1/0, args= 16, gp= 8
.mask 0x80000000,-4
.fmask 0x00000000,0
.set noreorder
.cpload $25
.set nomacro
addiu $sp,$sp,-32
sw $31,28($sp)
.cprestore 16
lw $2,%got(completed.1269)($28)
lbu $2,%lo(completed.1269)($2)
bne $2,$0,$L8
nop
$L4:
lw $2,%got(__cxa_finalize)($28)
beq $2,$0,$L6
nop
lw $2,%got(__dso_handle)($28)
lw $4,0($2)
lw $25,%call16(__cxa_finalize)($28)
.reloc 1f,R_MIPS_JALR,__cxa_finalize
1: jalr $25
nop
lw $28,16($sp)
$L6:
lw $2,%got(completed.1269)($28)
li $3,1 # 0x1
sb $3,%lo(completed.1269)($2)
$L8:
lw $31,28($sp)
addiu $sp,$sp,32
j $31
nop
.set macro
.set reorder
.end __do_global_dtors_aux
.size __do_global_dtors_aux, .-__do_global_dtors_aux
.local completed.1269
.comm completed.1269,1,1
.weak __cxa_finalize
#include "__dso_handle.S"
#include "atexit.S"

View File

@@ -0,0 +1,94 @@
/*
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "../../bionic/libc_init_common.h"
#include <stddef.h>
#include <stdint.h>
__attribute__ ((section (".preinit_array")))
void (*__PREINIT_ARRAY__)(void) = (void (*)(void)) -1;
__attribute__ ((section (".init_array")))
void (*__INIT_ARRAY__)(void) = (void (*)(void)) -1;
__attribute__ ((section (".fini_array")))
void (*__FINI_ARRAY__)(void) = (void (*)(void)) -1;
__LIBC_HIDDEN__ void do_mips_start(void *raw_args) {
structors_array_t array;
array.preinit_array = &__PREINIT_ARRAY__;
array.init_array = &__INIT_ARRAY__;
array.fini_array = &__FINI_ARRAY__;
__libc_init(raw_args, NULL, &main, &array);
}
/*
* This function prepares the return address with a branch-and-link
* instruction (bal) and then uses a .cpload to compute the Global
* Offset Table (GOT) pointer ($gp). The $gp is then used to load
* the address of _do_start() into $t9 just before calling it.
* Terminating the stack with a NULL return address.
*/
__asm__ (
" .set push \n"
" \n"
" .text \n"
" .align 4 \n"
" .type __start,@function \n"
" .globl __start \n"
" .globl _start \n"
" \n"
" .ent __start \n"
"__start: \n"
" _start: \n"
" .frame $sp,32,$ra \n"
" .mask 0x80000000,-4 \n"
" \n"
" .set noreorder \n"
" bal 1f \n"
" nop \n"
"1: \n"
" .cpload $ra \n"
" .set reorder \n"
" \n"
" move $a0, $sp \n"
" addiu $sp, $sp, (-32) \n"
" sw $0, 28($sp) \n"
" la $t9, do_mips_start \n"
" jalr $t9 \n"
" \n"
"2: b 2b \n"
" .end __start \n"
" \n"
" .set pop \n"
);
#include "__dso_handle.h"
#include "atexit.h"

View File

@@ -1,94 +0,0 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
.section .init_array, "aw"
.type __INIT_ARRAY__, @object
.globl __INIT_ARRAY__
__INIT_ARRAY__:
.long -1
.section .fini_array, "aw"
.type __FINI_ARRAY__, @object
.globl __FINI_ARRAY__
__FINI_ARRAY__:
.long -1
.long __do_global_dtors_aux
.abicalls
.text
.align 2
.set nomips16
.ent __do_global_dtors_aux
.type __do_global_dtors_aux, @function
__do_global_dtors_aux:
.frame $sp,32,$31 # vars= 0, regs= 1/0, args= 16, gp= 8
.mask 0x80000000,-4
.fmask 0x00000000,0
.set noreorder
.cpload $25
.set nomacro
addiu $sp,$sp,-32
sw $31,28($sp)
.cprestore 16
lw $2,%got(completed.1269)($28)
lbu $2,%lo(completed.1269)($2)
bne $2,$0,$L8
nop
$L4:
lw $2,%got(__cxa_finalize)($28)
beq $2,$0,$L6
nop
lw $2,%got(__dso_handle)($28)
lw $4,0($2)
lw $25,%call16(__cxa_finalize)($28)
.reloc 1f,R_MIPS_JALR,__cxa_finalize
1: jalr $25
nop
lw $28,16($sp)
$L6:
lw $2,%got(completed.1269)($28)
li $3,1 # 0x1
sb $3,%lo(completed.1269)($2)
$L8:
lw $31,28($sp)
addiu $sp,$sp,32
j $31
nop
.set macro
.set reorder
.end __do_global_dtors_aux
.size __do_global_dtors_aux, .-__do_global_dtors_aux
.local completed.1269
.comm completed.1269,1,1
.weak __cxa_finalize
#include "__dso_handle_so.S"
#include "atexit.S"

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* Copyright (C) 2013 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,19 +25,14 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
.text
.globl atexit
.hidden atexit
.type atexit, @function
.align 4
.ent atexit
atexit:
.set noreorder
.cpload $t9
.set reorder
la $t9, __cxa_atexit
move $a1, $0
la $a2, __dso_handle
j $t9
.size atexit, .-atexit
.end atexit
extern void __cxa_finalize(void *);
extern void *__dso_handle;
__attribute__((visibility("hidden"),destructor))
void __on_dlclose() {
__cxa_finalize(&__dso_handle);
}
#include "__dso_handle_so.h"
#include "atexit.h"

View File

@@ -129,6 +129,8 @@ syscall_src += arch-mips/syscalls/removexattr.S
syscall_src += arch-mips/syscalls/lremovexattr.S
syscall_src += arch-mips/syscalls/__statfs64.S
syscall_src += arch-mips/syscalls/unshare.S
syscall_src += arch-mips/syscalls/swapon.S
syscall_src += arch-mips/syscalls/swapoff.S
syscall_src += arch-mips/syscalls/pause.S
syscall_src += arch-mips/syscalls/gettimeofday.S
syscall_src += arch-mips/syscalls/settimeofday.S
@@ -147,6 +149,9 @@ syscall_src += arch-mips/syscalls/__timer_getoverrun.S
syscall_src += arch-mips/syscalls/__timer_delete.S
syscall_src += arch-mips/syscalls/utimes.S
syscall_src += arch-mips/syscalls/utimensat.S
syscall_src += arch-mips/syscalls/timerfd_create.S
syscall_src += arch-mips/syscalls/timerfd_settime.S
syscall_src += arch-mips/syscalls/timerfd_gettime.S
syscall_src += arch-mips/syscalls/sigaction.S
syscall_src += arch-mips/syscalls/sigprocmask.S
syscall_src += arch-mips/syscalls/__sigsuspend.S

View File

@@ -0,0 +1,22 @@
/* autogenerated by gensyscalls.py */
#include <asm/unistd.h>
.text
.globl swapoff
.align 4
.ent swapoff
swapoff:
.set noreorder
.cpload $t9
li $v0, __NR_swapoff
syscall
bnez $a3, 1f
move $a0, $v0
j $ra
nop
1:
la $t9,__set_errno
j $t9
nop
.set reorder
.end swapoff

View File

@@ -0,0 +1,22 @@
/* autogenerated by gensyscalls.py */
#include <asm/unistd.h>
.text
.globl swapon
.align 4
.ent swapon
swapon:
.set noreorder
.cpload $t9
li $v0, __NR_swapon
syscall
bnez $a3, 1f
move $a0, $v0
j $ra
nop
1:
la $t9,__set_errno
j $t9
nop
.set reorder
.end swapon

View File

@@ -0,0 +1,22 @@
/* autogenerated by gensyscalls.py */
#include <asm/unistd.h>
.text
.globl timerfd_create
.align 4
.ent timerfd_create
timerfd_create:
.set noreorder
.cpload $t9
li $v0, __NR_timerfd_create
syscall
bnez $a3, 1f
move $a0, $v0
j $ra
nop
1:
la $t9,__set_errno
j $t9
nop
.set reorder
.end timerfd_create

View File

@@ -0,0 +1,22 @@
/* autogenerated by gensyscalls.py */
#include <asm/unistd.h>
.text
.globl timerfd_gettime
.align 4
.ent timerfd_gettime
timerfd_gettime:
.set noreorder
.cpload $t9
li $v0, __NR_timerfd_gettime
syscall
bnez $a3, 1f
move $a0, $v0
j $ra
nop
1:
la $t9,__set_errno
j $t9
nop
.set reorder
.end timerfd_gettime

View File

@@ -0,0 +1,22 @@
/* autogenerated by gensyscalls.py */
#include <asm/unistd.h>
.text
.globl timerfd_settime
.align 4
.ent timerfd_settime
timerfd_settime:
.set noreorder
.cpload $t9
li $v0, __NR_timerfd_settime
syscall
bnez $a3, 1f
move $a0, $v0
j $ra
nop
1:
la $t9,__set_errno
j $t9
nop
.set reorder
.end timerfd_settime

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: endian.h,v 1.14 2005/12/13 00:35:23 millert Exp $ */
/* $OpenBSD: endian.h,v 1.17 2011/03/12 04:03:04 guenther Exp $ */
/*-
* Copyright (c) 1997 Niklas Hallqvist. All rights reserved.
@@ -24,38 +24,28 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _I386_ENDIAN_H_
#define _I386_ENDIAN_H_
#ifndef _MACHINE_ENDIAN_H_
#define _MACHINE_ENDIAN_H_
#ifdef __GNUC__
#if defined(_KERNEL) && !defined(I386_CPU)
#define __swap32md(x) ({ \
#define __swap32md(x) __statement({ \
uint32_t __swap32md_x = (x); \
\
__asm ("bswap %1" : "+r" (__swap32md_x)); \
__asm ("bswap %0" : "+r" (__swap32md_x)); \
__swap32md_x; \
})
#else
#define __swap32md(x) ({ \
uint32_t __swap32md_x = (x); \
\
__asm ("rorw $8, %w1; rorl $16, %1; rorw $8, %w1" : \
"+r" (__swap32md_x)); \
__swap32md_x; \
})
#endif /* _KERNEL && !I386_CPU */
#define __swap64md(x) ({ \
#define __swap64md(x) __statement({ \
uint64_t __swap64md_x = (x); \
\
(uint64_t)__swap32md(__swap64md_x >> 32) | \
(uint64_t)__swap32md(__swap64md_x & 0xffffffff) << 32; \
})
#define __swap16md(x) ({ \
#define __swap16md(x) __statement({ \
uint16_t __swap16md_x = (x); \
\
__asm ("rorw $8, %w1" : "+r" (__swap16md_x)); \
__asm ("rorw $8, %w0" : "+r" (__swap16md_x)); \
__swap16md_x; \
})
@@ -68,4 +58,4 @@
#include <sys/types.h>
#include <sys/endian.h>
#endif /* _I386_ENDIAN_H_ */
#endif /* _MACHINE_ENDIAN_H_ */

View File

@@ -1,26 +0,0 @@
/* $OpenBSD: index.S,v 1.4 2005/08/07 11:30:38 espie Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <machine/asm.h>
#ifdef STRCHR
ENTRY(strchr)
#else
ENTRY(index)
#endif
movl 4(%esp),%eax
movb 8(%esp),%cl
.align 2,0x90
L1:
movb (%eax),%dl
cmpb %dl,%cl /* found char??? */
je L2
incl %eax
testb %dl,%dl /* null terminator??? */
jnz L1
xorl %eax,%eax
L2:
ret

View File

@@ -1,27 +0,0 @@
/* $OpenBSD: memchr.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <machine/asm.h>
ENTRY(memchr)
pushl %edi
movl 8(%esp),%edi /* string address */
movl 12(%esp),%eax /* set character to search for */
movl 16(%esp),%ecx /* set length of search */
testl %ecx,%ecx /* test for len == 0 */
jz L1
cld /* set search forward */
repne /* search! */
scasb
jne L1 /* scan failed, return null */
leal -1(%edi),%eax /* adjust result of scan */
popl %edi
ret
.align 2,0x90
L1: xorl %eax,%eax
popl %edi
ret
END(memchr)

View File

@@ -1,43 +0,0 @@
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(USE_SSSE3)
# include "cache_wrapper.S"
# undef __i686
# define MEMCPY memmove
# define USE_AS_MEMMOVE
# include "ssse3-memcpy5.S"
#else
# include "memmove.S"
#endif

View File

@@ -1,42 +0,0 @@
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(USE_SSE2)
# include "cache_wrapper.S"
# undef __i686
# define sse2_memset5_atom memset
# include "sse2-memset5-atom.S"
#else
# include "memset.S"
#endif

View File

@@ -28,15 +28,6 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(USE_SSSE3)
# define USE_AS_STRNCMP
# define ssse3_strcmp_latest strncmp
# include "ssse3-strcmp-latest.S"
#else
# include "strncmp.S"
#endif
#define USE_AS_BZERO
#define MEMSET bzero
#include "sse2-memset-atom.S"

View File

@@ -0,0 +1,32 @@
/*
Copyright (c) 2011, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define strchr index
#include "sse2-strchr-atom.S"

View File

@@ -0,0 +1,556 @@
/*
Copyright (c) 2011, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef L
# define L(label) .L##label
#endif
#ifndef cfi_startproc
# define cfi_startproc .cfi_startproc
#endif
#ifndef cfi_endproc
# define cfi_endproc .cfi_endproc
#endif
#ifndef cfi_rel_offset
# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
#endif
#ifndef cfi_restore
# define cfi_restore(reg) .cfi_restore reg
#endif
#ifndef cfi_adjust_cfa_offset
# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
#endif
#ifndef ENTRY
# define ENTRY(name) \
.type name, @function; \
.globl name; \
.p2align 4; \
name: \
cfi_startproc
#endif
#ifndef END
# define END(name) \
cfi_endproc; \
.size name, .-name
#endif
#define CFI_PUSH(REG) \
cfi_adjust_cfa_offset (4); \
cfi_rel_offset (REG, 0)
#define CFI_POP(REG) \
cfi_adjust_cfa_offset (-4); \
cfi_restore (REG)
#define PUSH(REG) pushl REG; CFI_PUSH (REG)
#define POP(REG) popl REG; CFI_POP (REG)
#define ENTRANCE PUSH (%edi);
#define PARMS 8
#define RETURN POP (%edi); ret; CFI_PUSH (%edi);
#define STR1 PARMS
#define STR2 STR1+4
#define LEN STR2+4
.text
ENTRY (memchr)
ENTRANCE
mov STR1(%esp), %ecx
movd STR2(%esp), %xmm1
mov LEN(%esp), %edx
test %edx, %edx
jz L(return_null)
punpcklbw %xmm1, %xmm1
mov %ecx, %edi
punpcklbw %xmm1, %xmm1
and $63, %ecx
pshufd $0, %xmm1, %xmm1
cmp $48, %ecx
ja L(crosscache)
movdqu (%edi), %xmm0
pcmpeqb %xmm1, %xmm0
pmovmskb %xmm0, %eax
test %eax, %eax
jnz L(match_case2_prolog)
sub $16, %edx
jbe L(return_null)
lea 16(%edi), %edi
and $15, %ecx
and $-16, %edi
add %ecx, %edx
sub $64, %edx
jbe L(exit_loop)
jmp L(loop_prolog)
.p2align 4
L(crosscache):
and $15, %ecx
and $-16, %edi
movdqa (%edi), %xmm0
pcmpeqb %xmm1, %xmm0
pmovmskb %xmm0, %eax
sar %cl, %eax
test %eax, %eax
jnz L(match_case2_prolog1)
lea -16(%edx), %edx
add %ecx, %edx
jle L(return_null)
lea 16(%edi), %edi
sub $64, %edx
jbe L(exit_loop)
.p2align 4
L(loop_prolog):
movdqa (%edi), %xmm0
pcmpeqb %xmm1, %xmm0
xor %ecx, %ecx
pmovmskb %xmm0, %eax
test %eax, %eax
jnz L(match_case1)
movdqa 16(%edi), %xmm2
pcmpeqb %xmm1, %xmm2
lea 16(%ecx), %ecx
pmovmskb %xmm2, %eax
test %eax, %eax
jnz L(match_case1)
movdqa 32(%edi), %xmm3
pcmpeqb %xmm1, %xmm3
lea 16(%ecx), %ecx
pmovmskb %xmm3, %eax
test %eax, %eax
jnz L(match_case1)
movdqa 48(%edi), %xmm4
pcmpeqb %xmm1, %xmm4
lea 16(%ecx), %ecx
pmovmskb %xmm4, %eax
test %eax, %eax
jnz L(match_case1)
lea 64(%edi), %edi
sub $64, %edx
jbe L(exit_loop)
movdqa (%edi), %xmm0
pcmpeqb %xmm1, %xmm0
xor %ecx, %ecx
pmovmskb %xmm0, %eax
test %eax, %eax
jnz L(match_case1)
movdqa 16(%edi), %xmm2
pcmpeqb %xmm1, %xmm2
lea 16(%ecx), %ecx
pmovmskb %xmm2, %eax
test %eax, %eax
jnz L(match_case1)
movdqa 32(%edi), %xmm3
pcmpeqb %xmm1, %xmm3
lea 16(%ecx), %ecx
pmovmskb %xmm3, %eax
test %eax, %eax
jnz L(match_case1)
movdqa 48(%edi), %xmm4
pcmpeqb %xmm1, %xmm4
lea 16(%ecx), %ecx
pmovmskb %xmm4, %eax
test %eax, %eax
jnz L(match_case1)
lea 64(%edi), %edi
mov %edi, %ecx
and $-64, %edi
and $63, %ecx
add %ecx, %edx
.p2align 4
L(align64_loop):
sub $64, %edx
jbe L(exit_loop)
movdqa (%edi), %xmm0
movdqa 16(%edi), %xmm2
movdqa 32(%edi), %xmm3
movdqa 48(%edi), %xmm4
pcmpeqb %xmm1, %xmm0
pcmpeqb %xmm1, %xmm2
pcmpeqb %xmm1, %xmm3
pcmpeqb %xmm1, %xmm4
pmaxub %xmm0, %xmm3
pmaxub %xmm2, %xmm4
pmaxub %xmm3, %xmm4
add $64, %edi
pmovmskb %xmm4, %eax
test %eax, %eax
jz L(align64_loop)
sub $64, %edi
pmovmskb %xmm0, %eax
xor %ecx, %ecx
test %eax, %eax
jnz L(match_case1)
pmovmskb %xmm2, %eax
lea 16(%ecx), %ecx
test %eax, %eax
jnz L(match_case1)
movdqa 32(%edi), %xmm3
pcmpeqb %xmm1, %xmm3
pmovmskb %xmm3, %eax
lea 16(%ecx), %ecx
test %eax, %eax
jnz L(match_case1)
pcmpeqb 48(%edi), %xmm1
pmovmskb %xmm1, %eax
lea 16(%ecx), %ecx
.p2align 4
L(match_case1):
add %ecx, %edi
test %al, %al
jz L(match_case1_high)
mov %al, %cl
and $15, %cl
jz L(match_case1_8)
test $0x01, %al
jnz L(exit_case1_1)
test $0x02, %al
jnz L(exit_case1_2)
test $0x04, %al
jnz L(exit_case1_3)
lea 3(%edi), %eax
RETURN
.p2align 4
L(match_case1_8):
test $0x10, %al
jnz L(exit_case1_5)
test $0x20, %al
jnz L(exit_case1_6)
test $0x40, %al
jnz L(exit_case1_7)
lea 7(%edi), %eax
RETURN
.p2align 4
L(match_case1_high):
mov %ah, %ch
and $15, %ch
jz L(match_case1_high_8)
test $0x01, %ah
jnz L(exit_case1_9)
test $0x02, %ah
jnz L(exit_case1_10)
test $0x04, %ah
jnz L(exit_case1_11)
lea 11(%edi), %eax
RETURN
.p2align 4
L(match_case1_high_8):
test $0x10, %ah
jnz L(exit_case1_13)
test $0x20, %ah
jnz L(exit_case1_14)
test $0x40, %ah
jnz L(exit_case1_15)
lea 15(%edi), %eax
RETURN
.p2align 4
L(exit_loop):
add $64, %edx
movdqa (%edi), %xmm0
pcmpeqb %xmm1, %xmm0
xor %ecx, %ecx
pmovmskb %xmm0, %eax
test %eax, %eax
jnz L(match_case2)
cmp $16, %edx
jbe L(return_null)
movdqa 16(%edi), %xmm2
pcmpeqb %xmm1, %xmm2
lea 16(%ecx), %ecx
pmovmskb %xmm2, %eax
test %eax, %eax
jnz L(match_case2)
cmp $32, %edx
jbe L(return_null)
movdqa 32(%edi), %xmm3
pcmpeqb %xmm1, %xmm3
lea 16(%ecx), %ecx
pmovmskb %xmm3, %eax
test %eax, %eax
jnz L(match_case2)
cmp $48, %edx
jbe L(return_null)
pcmpeqb 48(%edi), %xmm1
lea 16(%ecx), %ecx
pmovmskb %xmm1, %eax
test %eax, %eax
jnz L(match_case2)
xor %eax, %eax
RETURN
.p2align 4
L(exit_case1_1):
mov %edi, %eax
RETURN
.p2align 4
L(exit_case1_2):
lea 1(%edi), %eax
RETURN
.p2align 4
L(exit_case1_3):
lea 2(%edi), %eax
RETURN
.p2align 4
L(exit_case1_5):
lea 4(%edi), %eax
RETURN
.p2align 4
L(exit_case1_6):
lea 5(%edi), %eax
RETURN
.p2align 4
L(exit_case1_7):
lea 6(%edi), %eax
RETURN
.p2align 4
L(exit_case1_9):
lea 8(%edi), %eax
RETURN
.p2align 4
L(exit_case1_10):
lea 9(%edi), %eax
RETURN
.p2align 4
L(exit_case1_11):
lea 10(%edi), %eax
RETURN
.p2align 4
L(exit_case1_13):
lea 12(%edi), %eax
RETURN
.p2align 4
L(exit_case1_14):
lea 13(%edi), %eax
RETURN
.p2align 4
L(exit_case1_15):
lea 14(%edi), %eax
RETURN
.p2align 4
L(match_case2):
sub %ecx, %edx
L(match_case2_prolog1):
add %ecx, %edi
L(match_case2_prolog):
test %al, %al
jz L(match_case2_high)
mov %al, %cl
and $15, %cl
jz L(match_case2_8)
test $0x01, %al
jnz L(exit_case2_1)
test $0x02, %al
jnz L(exit_case2_2)
test $0x04, %al
jnz L(exit_case2_3)
sub $4, %edx
jb L(return_null)
lea 3(%edi), %eax
RETURN
.p2align 4
L(match_case2_8):
test $0x10, %al
jnz L(exit_case2_5)
test $0x20, %al
jnz L(exit_case2_6)
test $0x40, %al
jnz L(exit_case2_7)
sub $8, %edx
jb L(return_null)
lea 7(%edi), %eax
RETURN
.p2align 4
L(match_case2_high):
mov %ah, %ch
and $15, %ch
jz L(match_case2_high_8)
test $0x01, %ah
jnz L(exit_case2_9)
test $0x02, %ah
jnz L(exit_case2_10)
test $0x04, %ah
jnz L(exit_case2_11)
sub $12, %edx
jb L(return_null)
lea 11(%edi), %eax
RETURN
.p2align 4
L(match_case2_high_8):
test $0x10, %ah
jnz L(exit_case2_13)
test $0x20, %ah
jnz L(exit_case2_14)
test $0x40, %ah
jnz L(exit_case2_15)
sub $16, %edx
jb L(return_null)
lea 15(%edi), %eax
RETURN
.p2align 4
L(exit_case2_1):
mov %edi, %eax
RETURN
.p2align 4
L(exit_case2_2):
sub $2, %edx
jb L(return_null)
lea 1(%edi), %eax
RETURN
.p2align 4
L(exit_case2_3):
sub $3, %edx
jb L(return_null)
lea 2(%edi), %eax
RETURN
.p2align 4
L(exit_case2_5):
sub $5, %edx
jb L(return_null)
lea 4(%edi), %eax
RETURN
.p2align 4
L(exit_case2_6):
sub $6, %edx
jb L(return_null)
lea 5(%edi), %eax
RETURN
.p2align 4
L(exit_case2_7):
sub $7, %edx
jb L(return_null)
lea 6(%edi), %eax
RETURN
.p2align 4
L(exit_case2_9):
sub $9, %edx
jb L(return_null)
lea 8(%edi), %eax
RETURN
.p2align 4
L(exit_case2_10):
sub $10, %edx
jb L(return_null)
lea 9(%edi), %eax
RETURN
.p2align 4
L(exit_case2_11):
sub $11, %edx
jb L(return_null)
lea 10(%edi), %eax
RETURN
.p2align 4
L(exit_case2_13):
sub $13, %edx
jb L(return_null)
lea 12(%edi), %eax
RETURN
.p2align 4
L(exit_case2_14):
sub $14, %edx
jb L(return_null)
lea 13(%edi), %eax
RETURN
.p2align 4
L(exit_case2_15):
sub $15, %edx
jb L(return_null)
lea 14(%edi), %eax
RETURN
.p2align 4
L(return_null):
xor %eax, %eax
RETURN
END (memchr)

View File

@@ -0,0 +1,778 @@
/*
Copyright (c) 2011, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef L
# define L(label) .L##label
#endif
#ifndef cfi_startproc
# define cfi_startproc .cfi_startproc
#endif
#ifndef cfi_endproc
# define cfi_endproc .cfi_endproc
#endif
#ifndef cfi_rel_offset
# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
#endif
#ifndef cfi_restore
# define cfi_restore(reg) .cfi_restore reg
#endif
#ifndef cfi_adjust_cfa_offset
# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
#endif
#ifndef ENTRY
# define ENTRY(name) \
.type name, @function; \
.globl name; \
.p2align 4; \
name: \
cfi_startproc
#endif
#ifndef END
# define END(name) \
cfi_endproc; \
.size name, .-name
#endif
#define CFI_PUSH(REG) \
cfi_adjust_cfa_offset (4); \
cfi_rel_offset (REG, 0)
#define CFI_POP(REG) \
cfi_adjust_cfa_offset (-4); \
cfi_restore (REG)
#define PUSH(REG) pushl REG; CFI_PUSH (REG)
#define POP(REG) popl REG; CFI_POP (REG)
#define PARMS 4
#define STR1 PARMS
#define STR2 STR1+4
#define LEN STR2+4
.text
ENTRY (memrchr)
mov STR1(%esp), %ecx
movd STR2(%esp), %xmm1
mov LEN(%esp), %edx
test %edx, %edx
jz L(return_null)
sub $16, %edx
jbe L(length_less16)
punpcklbw %xmm1, %xmm1
add %edx, %ecx
punpcklbw %xmm1, %xmm1
movdqu (%ecx), %xmm0
pshufd $0, %xmm1, %xmm1
pcmpeqb %xmm1, %xmm0
pmovmskb %xmm0, %eax
test %eax, %eax
jnz L(exit_dispatch)
sub $64, %ecx
mov %ecx, %eax
and $15, %eax
jz L(loop_prolog)
add $16, %ecx
add $16, %edx
and $-16, %ecx
sub %eax, %edx
.p2align 4
/* Loop start on aligned string. */
L(loop_prolog):
sub $64, %edx
jbe L(exit_loop)
movdqa 48(%ecx), %xmm0
pcmpeqb %xmm1, %xmm0
pmovmskb %xmm0, %eax
test %eax, %eax
jnz L(matches48)
movdqa 32(%ecx), %xmm2
pcmpeqb %xmm1, %xmm2
pmovmskb %xmm2, %eax
test %eax, %eax
jnz L(matches32)
movdqa 16(%ecx), %xmm3
pcmpeqb %xmm1, %xmm3
pmovmskb %xmm3, %eax
test %eax, %eax
jnz L(matches16)
movdqa (%ecx), %xmm4
pcmpeqb %xmm1, %xmm4
pmovmskb %xmm4, %eax
test %eax, %eax
jnz L(exit_dispatch)
sub $64, %ecx
sub $64, %edx
jbe L(exit_loop)
movdqa 48(%ecx), %xmm0
pcmpeqb %xmm1, %xmm0
pmovmskb %xmm0, %eax
test %eax, %eax
jnz L(matches48)
movdqa 32(%ecx), %xmm2
pcmpeqb %xmm1, %xmm2
pmovmskb %xmm2, %eax
test %eax, %eax
jnz L(matches32)
movdqa 16(%ecx), %xmm3
pcmpeqb %xmm1, %xmm3
pmovmskb %xmm3, %eax
test %eax, %eax
jnz L(matches16)
movdqa (%ecx), %xmm3
pcmpeqb %xmm1, %xmm3
pmovmskb %xmm3, %eax
test %eax, %eax
jnz L(exit_dispatch)
mov %ecx, %eax
and $63, %eax
test %eax, %eax
jz L(align64_loop)
add $64, %ecx
add $64, %edx
and $-64, %ecx
sub %eax, %edx
.p2align 4
L(align64_loop):
sub $64, %ecx
sub $64, %edx
jbe L(exit_loop)
movdqa (%ecx), %xmm0
movdqa 16(%ecx), %xmm2
movdqa 32(%ecx), %xmm3
movdqa 48(%ecx), %xmm4
pcmpeqb %xmm1, %xmm0
pcmpeqb %xmm1, %xmm2
pcmpeqb %xmm1, %xmm3
pcmpeqb %xmm1, %xmm4
pmaxub %xmm3, %xmm0
pmaxub %xmm4, %xmm2
pmaxub %xmm0, %xmm2
pmovmskb %xmm2, %eax
test %eax, %eax
jz L(align64_loop)
pmovmskb %xmm4, %eax
test %eax, %eax
jnz L(matches48)
pmovmskb %xmm3, %eax
test %eax, %eax
jnz L(matches32)
movdqa 16(%ecx), %xmm2
pcmpeqb %xmm1, %xmm2
pcmpeqb (%ecx), %xmm1
pmovmskb %xmm2, %eax
test %eax, %eax
jnz L(matches16)
pmovmskb %xmm1, %eax
test %ah, %ah
jnz L(exit_dispatch_high)
mov %al, %dl
and $15 << 4, %dl
jnz L(exit_dispatch_8)
test $0x08, %al
jnz L(exit_4)
test $0x04, %al
jnz L(exit_3)
test $0x02, %al
jnz L(exit_2)
mov %ecx, %eax
ret
.p2align 4
L(exit_loop):
add $64, %edx
cmp $32, %edx
jbe L(exit_loop_32)
movdqa 48(%ecx), %xmm0
pcmpeqb %xmm1, %xmm0
pmovmskb %xmm0, %eax
test %eax, %eax
jnz L(matches48)
movdqa 32(%ecx), %xmm2
pcmpeqb %xmm1, %xmm2
pmovmskb %xmm2, %eax
test %eax, %eax
jnz L(matches32)
movdqa 16(%ecx), %xmm3
pcmpeqb %xmm1, %xmm3
pmovmskb %xmm3, %eax
test %eax, %eax
jnz L(matches16_1)
cmp $48, %edx
jbe L(return_null)
pcmpeqb (%ecx), %xmm1
pmovmskb %xmm1, %eax
test %eax, %eax
jnz L(matches0_1)
xor %eax, %eax
ret
.p2align 4
L(exit_loop_32):
movdqa 48(%ecx), %xmm0
pcmpeqb %xmm1, %xmm0
pmovmskb %xmm0, %eax
test %eax, %eax
jnz L(matches48_1)
cmp $16, %edx
jbe L(return_null)
pcmpeqb 32(%ecx), %xmm1
pmovmskb %xmm1, %eax
test %eax, %eax
jnz L(matches32_1)
xor %eax, %eax
ret
.p2align 4
L(matches16):
lea 16(%ecx), %ecx
test %ah, %ah
jnz L(exit_dispatch_high)
mov %al, %dl
and $15 << 4, %dl
jnz L(exit_dispatch_8)
test $0x08, %al
jnz L(exit_4)
test $0x04, %al
jnz L(exit_3)
test $0x02, %al
jnz L(exit_2)
mov %ecx, %eax
ret
.p2align 4
L(matches32):
lea 32(%ecx), %ecx
test %ah, %ah
jnz L(exit_dispatch_high)
mov %al, %dl
and $15 << 4, %dl
jnz L(exit_dispatch_8)
test $0x08, %al
jnz L(exit_4)
test $0x04, %al
jnz L(exit_3)
test $0x02, %al
jnz L(exit_2)
mov %ecx, %eax
ret
.p2align 4
L(matches48):
lea 48(%ecx), %ecx
.p2align 4
L(exit_dispatch):
test %ah, %ah
jnz L(exit_dispatch_high)
mov %al, %dl
and $15 << 4, %dl
jnz L(exit_dispatch_8)
test $0x08, %al
jnz L(exit_4)
test $0x04, %al
jnz L(exit_3)
test $0x02, %al
jnz L(exit_2)
mov %ecx, %eax
ret
.p2align 4
L(exit_dispatch_8):
test $0x80, %al
jnz L(exit_8)
test $0x40, %al
jnz L(exit_7)
test $0x20, %al
jnz L(exit_6)
lea 4(%ecx), %eax
ret
.p2align 4
L(exit_dispatch_high):
mov %ah, %dh
and $15 << 4, %dh
jnz L(exit_dispatch_high_8)
test $0x08, %ah
jnz L(exit_12)
test $0x04, %ah
jnz L(exit_11)
test $0x02, %ah
jnz L(exit_10)
lea 8(%ecx), %eax
ret
.p2align 4
L(exit_dispatch_high_8):
test $0x80, %ah
jnz L(exit_16)
test $0x40, %ah
jnz L(exit_15)
test $0x20, %ah
jnz L(exit_14)
lea 12(%ecx), %eax
ret
.p2align 4
L(exit_2):
lea 1(%ecx), %eax
ret
.p2align 4
L(exit_3):
lea 2(%ecx), %eax
ret
.p2align 4
L(exit_4):
lea 3(%ecx), %eax
ret
.p2align 4
L(exit_6):
lea 5(%ecx), %eax
ret
.p2align 4
L(exit_7):
lea 6(%ecx), %eax
ret
.p2align 4
L(exit_8):
lea 7(%ecx), %eax
ret
.p2align 4
L(exit_10):
lea 9(%ecx), %eax
ret
.p2align 4
L(exit_11):
lea 10(%ecx), %eax
ret
.p2align 4
L(exit_12):
lea 11(%ecx), %eax
ret
.p2align 4
L(exit_14):
lea 13(%ecx), %eax
ret
.p2align 4
L(exit_15):
lea 14(%ecx), %eax
ret
.p2align 4
L(exit_16):
lea 15(%ecx), %eax
ret
.p2align 4
L(matches0_1):
lea -64(%edx), %edx
test %ah, %ah
jnz L(exit_dispatch_1_high)
mov %al, %ah
and $15 << 4, %ah
jnz L(exit_dispatch_1_8)
test $0x08, %al
jnz L(exit_1_4)
test $0x04, %al
jnz L(exit_1_3)
test $0x02, %al
jnz L(exit_1_2)
add $0, %edx
jl L(return_null)
mov %ecx, %eax
ret
.p2align 4
L(matches16_1):
lea -48(%edx), %edx
lea 16(%ecx), %ecx
test %ah, %ah
jnz L(exit_dispatch_1_high)
mov %al, %ah
and $15 << 4, %ah
jnz L(exit_dispatch_1_8)
test $0x08, %al
jnz L(exit_1_4)
test $0x04, %al
jnz L(exit_1_3)
test $0x02, %al
jnz L(exit_1_2)
add $0, %edx
jl L(return_null)
mov %ecx, %eax
ret
.p2align 4
L(matches32_1):
lea -32(%edx), %edx
lea 32(%ecx), %ecx
test %ah, %ah
jnz L(exit_dispatch_1_high)
mov %al, %ah
and $15 << 4, %ah
jnz L(exit_dispatch_1_8)
test $0x08, %al
jnz L(exit_1_4)
test $0x04, %al
jnz L(exit_1_3)
test $0x02, %al
jnz L(exit_1_2)
add $0, %edx
jl L(return_null)
mov %ecx, %eax
ret
.p2align 4
L(matches48_1):
lea -16(%edx), %edx
lea 48(%ecx), %ecx
.p2align 4
L(exit_dispatch_1):
test %ah, %ah
jnz L(exit_dispatch_1_high)
mov %al, %ah
and $15 << 4, %ah
jnz L(exit_dispatch_1_8)
test $0x08, %al
jnz L(exit_1_4)
test $0x04, %al
jnz L(exit_1_3)
test $0x02, %al
jnz L(exit_1_2)
add $0, %edx
jl L(return_null)
mov %ecx, %eax
ret
.p2align 4
L(exit_dispatch_1_8):
test $0x80, %al
jnz L(exit_1_8)
test $0x40, %al
jnz L(exit_1_7)
test $0x20, %al
jnz L(exit_1_6)
add $4, %edx
jl L(return_null)
lea 4(%ecx), %eax
ret
.p2align 4
L(exit_dispatch_1_high):
mov %ah, %al
and $15 << 4, %al
jnz L(exit_dispatch_1_high_8)
test $0x08, %ah
jnz L(exit_1_12)
test $0x04, %ah
jnz L(exit_1_11)
test $0x02, %ah
jnz L(exit_1_10)
add $8, %edx
jl L(return_null)
lea 8(%ecx), %eax
ret
.p2align 4
L(exit_dispatch_1_high_8):
test $0x80, %ah
jnz L(exit_1_16)
test $0x40, %ah
jnz L(exit_1_15)
test $0x20, %ah
jnz L(exit_1_14)
add $12, %edx
jl L(return_null)
lea 12(%ecx), %eax
ret
.p2align 4
L(exit_1_2):
add $1, %edx
jl L(return_null)
lea 1(%ecx), %eax
ret
.p2align 4
L(exit_1_3):
add $2, %edx
jl L(return_null)
lea 2(%ecx), %eax
ret
.p2align 4
L(exit_1_4):
add $3, %edx
jl L(return_null)
lea 3(%ecx), %eax
ret
.p2align 4
L(exit_1_6):
add $5, %edx
jl L(return_null)
lea 5(%ecx), %eax
ret
.p2align 4
L(exit_1_7):
add $6, %edx
jl L(return_null)
lea 6(%ecx), %eax
ret
.p2align 4
L(exit_1_8):
add $7, %edx
jl L(return_null)
lea 7(%ecx), %eax
ret
.p2align 4
L(exit_1_10):
add $9, %edx
jl L(return_null)
lea 9(%ecx), %eax
ret
.p2align 4
L(exit_1_11):
add $10, %edx
jl L(return_null)
lea 10(%ecx), %eax
ret
.p2align 4
L(exit_1_12):
add $11, %edx
jl L(return_null)
lea 11(%ecx), %eax
ret
.p2align 4
L(exit_1_14):
add $13, %edx
jl L(return_null)
lea 13(%ecx), %eax
ret
.p2align 4
L(exit_1_15):
add $14, %edx
jl L(return_null)
lea 14(%ecx), %eax
ret
.p2align 4
L(exit_1_16):
add $15, %edx
jl L(return_null)
lea 15(%ecx), %eax
ret
.p2align 4
L(return_null):
xor %eax, %eax
ret
.p2align 4
L(length_less16_offset0):
mov %dl, %cl
pcmpeqb (%eax), %xmm1
mov $1, %edx
sal %cl, %edx
sub $1, %edx
mov %eax, %ecx
pmovmskb %xmm1, %eax
and %edx, %eax
test %eax, %eax
jnz L(exit_dispatch)
xor %eax, %eax
ret
.p2align 4
L(length_less16):
punpcklbw %xmm1, %xmm1
add $16, %edx
punpcklbw %xmm1, %xmm1
mov %ecx, %eax
pshufd $0, %xmm1, %xmm1
and $15, %ecx
jz L(length_less16_offset0)
PUSH (%edi)
mov %cl, %dh
add %dl, %dh
and $-16, %eax
sub $16, %dh
ja L(length_less16_part2)
pcmpeqb (%eax), %xmm1
pmovmskb %xmm1, %edi
sar %cl, %edi
add %ecx, %eax
mov %dl, %cl
mov $1, %edx
sal %cl, %edx
sub $1, %edx
and %edx, %edi
test %edi, %edi
jz L(ret_null)
bsr %edi, %edi
add %edi, %eax
POP (%edi)
ret
CFI_PUSH (%edi)
.p2align 4
L(length_less16_part2):
movdqa 16(%eax), %xmm2
pcmpeqb %xmm1, %xmm2
pmovmskb %xmm2, %edi
mov %cl, %ch
mov %dh, %cl
mov $1, %edx
sal %cl, %edx
sub $1, %edx
and %edx, %edi
test %edi, %edi
jnz L(length_less16_part2_return)
pcmpeqb (%eax), %xmm1
pmovmskb %xmm1, %edi
mov %ch, %cl
sar %cl, %edi
test %edi, %edi
jz L(ret_null)
bsr %edi, %edi
add %edi, %eax
xor %ch, %ch
add %ecx, %eax
POP (%edi)
ret
CFI_PUSH (%edi)
.p2align 4
L(length_less16_part2_return):
bsr %edi, %edi
lea 16(%eax, %edi), %eax
POP (%edi)
ret
CFI_PUSH (%edi)
.p2align 4
L(ret_null):
xor %eax, %eax
POP (%edi)
ret
END (memrchr)

View File

@@ -28,6 +28,9 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "cache.h"
#undef __i686
#ifndef L
# define L(label) .L##label
#endif
@@ -136,9 +139,13 @@ __i686.get_pc_thunk.bx:
jmp *TABLE(,%ecx,4)
#endif
#ifndef MEMSET
# define MEMSET memset
#endif
.section .text.sse2,"ax",@progbits
ALIGN (4)
ENTRY (sse2_memset5_atom)
ENTRY (MEMSET)
ENTRANCE
movl LEN(%esp), %ecx
@@ -911,4 +918,4 @@ L(aligned_16_15bytes):
SETRTNVAL
RETURN_END
END (sse2_memset5_atom)
END (MEMSET)

View File

@@ -0,0 +1,391 @@
/*
Copyright (c) 2011, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef L
# define L(label) .L##label
#endif
#ifndef cfi_startproc
# define cfi_startproc .cfi_startproc
#endif
#ifndef cfi_endproc
# define cfi_endproc .cfi_endproc
#endif
#ifndef cfi_rel_offset
# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
#endif
#ifndef cfi_restore
# define cfi_restore(reg) .cfi_restore reg
#endif
#ifndef cfi_adjust_cfa_offset
# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
#endif
#ifndef ENTRY
# define ENTRY(name) \
.type name, @function; \
.globl name; \
.p2align 4; \
name: \
cfi_startproc
#endif
#ifndef END
# define END(name) \
cfi_endproc; \
.size name, .-name
#endif
#define CFI_PUSH(REG) \
cfi_adjust_cfa_offset (4); \
cfi_rel_offset (REG, 0)
#define CFI_POP(REG) \
cfi_adjust_cfa_offset (-4); \
cfi_restore (REG)
#define PUSH(REG) pushl REG; CFI_PUSH (REG)
#define POP(REG) popl REG; CFI_POP (REG)
#define PARMS 8
#define ENTRANCE PUSH(%edi)
#define RETURN POP (%edi); ret; CFI_PUSH (%edi);
#define STR1 PARMS
#define STR2 STR1+4
.text
ENTRY (strchr)
ENTRANCE
mov STR1(%esp), %ecx
movd STR2(%esp), %xmm1
pxor %xmm2, %xmm2
mov %ecx, %edi
punpcklbw %xmm1, %xmm1
punpcklbw %xmm1, %xmm1
/* ECX has OFFSET. */
and $15, %ecx
pshufd $0, %xmm1, %xmm1
je L(loop)
/* Handle unaligned string. */
and $-16, %edi
movdqa (%edi), %xmm0
pcmpeqb %xmm0, %xmm2
pcmpeqb %xmm1, %xmm0
/* Find where NULL is. */
pmovmskb %xmm2, %edx
/* Check if there is a match. */
pmovmskb %xmm0, %eax
/* Remove the leading bytes. */
sarl %cl, %edx
sarl %cl, %eax
test %eax, %eax
jz L(unaligned_no_match)
add %ecx, %edi
test %edx, %edx
jz L(match_case1)
jmp L(match_case2)
.p2align 4
L(unaligned_no_match):
test %edx, %edx
jne L(return_null)
pxor %xmm2, %xmm2
add $16, %edi
.p2align 4
/* Loop start on aligned string. */
L(loop):
movdqa (%edi), %xmm0
pcmpeqb %xmm0, %xmm2
pcmpeqb %xmm1, %xmm0
pmovmskb %xmm2, %edx
pmovmskb %xmm0, %eax
test %eax, %eax
jnz L(matches)
test %edx, %edx
jnz L(return_null)
add $16, %edi
movdqa (%edi), %xmm0
pcmpeqb %xmm0, %xmm2
pcmpeqb %xmm1, %xmm0
pmovmskb %xmm2, %edx
pmovmskb %xmm0, %eax
test %eax, %eax
jnz L(matches)
test %edx, %edx
jnz L(return_null)
add $16, %edi
movdqa (%edi), %xmm0
pcmpeqb %xmm0, %xmm2
pcmpeqb %xmm1, %xmm0
pmovmskb %xmm2, %edx
pmovmskb %xmm0, %eax
test %eax, %eax
jnz L(matches)
test %edx, %edx
jnz L(return_null)
add $16, %edi
movdqa (%edi), %xmm0
pcmpeqb %xmm0, %xmm2
pcmpeqb %xmm1, %xmm0
pmovmskb %xmm2, %edx
pmovmskb %xmm0, %eax
test %eax, %eax
jnz L(matches)
test %edx, %edx
jnz L(return_null)
add $16, %edi
jmp L(loop)
L(matches):
/* There is a match. First find where NULL is. */
test %edx, %edx
jz L(match_case1)
.p2align 4
L(match_case2):
test %al, %al
jz L(match_higth_case2)
mov %al, %cl
and $15, %cl
jnz L(match_case2_4)
mov %dl, %ch
and $15, %ch
jnz L(return_null)
test $0x10, %al
jnz L(Exit5)
test $0x10, %dl
jnz L(return_null)
test $0x20, %al
jnz L(Exit6)
test $0x20, %dl
jnz L(return_null)
test $0x40, %al
jnz L(Exit7)
test $0x40, %dl
jnz L(return_null)
lea 7(%edi), %eax
RETURN
.p2align 4
L(match_case2_4):
test $0x01, %al
jnz L(Exit1)
test $0x01, %dl
jnz L(return_null)
test $0x02, %al
jnz L(Exit2)
test $0x02, %dl
jnz L(return_null)
test $0x04, %al
jnz L(Exit3)
test $0x04, %dl
jnz L(return_null)
lea 3(%edi), %eax
RETURN
.p2align 4
L(match_higth_case2):
test %dl, %dl
jnz L(return_null)
mov %ah, %cl
and $15, %cl
jnz L(match_case2_12)
mov %dh, %ch
and $15, %ch
jnz L(return_null)
test $0x10, %ah
jnz L(Exit13)
test $0x10, %dh
jnz L(return_null)
test $0x20, %ah
jnz L(Exit14)
test $0x20, %dh
jnz L(return_null)
test $0x40, %ah
jnz L(Exit15)
test $0x40, %dh
jnz L(return_null)
lea 15(%edi), %eax
RETURN
.p2align 4
L(match_case2_12):
test $0x01, %ah
jnz L(Exit9)
test $0x01, %dh
jnz L(return_null)
test $0x02, %ah
jnz L(Exit10)
test $0x02, %dh
jnz L(return_null)
test $0x04, %ah
jnz L(Exit11)
test $0x04, %dh
jnz L(return_null)
lea 11(%edi), %eax
RETURN
.p2align 4
L(match_case1):
test %al, %al
jz L(match_higth_case1)
test $0x01, %al
jnz L(Exit1)
test $0x02, %al
jnz L(Exit2)
test $0x04, %al
jnz L(Exit3)
test $0x08, %al
jnz L(Exit4)
test $0x10, %al
jnz L(Exit5)
test $0x20, %al
jnz L(Exit6)
test $0x40, %al
jnz L(Exit7)
lea 7(%edi), %eax
RETURN
.p2align 4
L(match_higth_case1):
test $0x01, %ah
jnz L(Exit9)
test $0x02, %ah
jnz L(Exit10)
test $0x04, %ah
jnz L(Exit11)
test $0x08, %ah
jnz L(Exit12)
test $0x10, %ah
jnz L(Exit13)
test $0x20, %ah
jnz L(Exit14)
test $0x40, %ah
jnz L(Exit15)
lea 15(%edi), %eax
RETURN
.p2align 4
L(Exit1):
lea (%edi), %eax
RETURN
.p2align 4
L(Exit2):
lea 1(%edi), %eax
RETURN
.p2align 4
L(Exit3):
lea 2(%edi), %eax
RETURN
.p2align 4
L(Exit4):
lea 3(%edi), %eax
RETURN
.p2align 4
L(Exit5):
lea 4(%edi), %eax
RETURN
.p2align 4
L(Exit6):
lea 5(%edi), %eax
RETURN
.p2align 4
L(Exit7):
lea 6(%edi), %eax
RETURN
.p2align 4
L(Exit9):
lea 8(%edi), %eax
RETURN
.p2align 4
L(Exit10):
lea 9(%edi), %eax
RETURN
.p2align 4
L(Exit11):
lea 10(%edi), %eax
RETURN
.p2align 4
L(Exit12):
lea 11(%edi), %eax
RETURN
.p2align 4
L(Exit13):
lea 12(%edi), %eax
RETURN
.p2align 4
L(Exit14):
lea 13(%edi), %eax
RETURN
.p2align 4
L(Exit15):
lea 14(%edi), %eax
RETURN
.p2align 4
L(return_null):
xor %eax, %eax
RETURN
END (strchr)

View File

@@ -1,71 +1,112 @@
#define STRLEN sse2_strlen_atom
/*
Copyright (c) 2011, Intel Corporation
All rights reserved.
#ifndef L
# define L(label) .L##label
#endif
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
#ifndef cfi_startproc
# define cfi_startproc .cfi_startproc
#endif
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
#ifndef cfi_endproc
# define cfi_endproc .cfi_endproc
#endif
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
#ifndef cfi_rel_offset
# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
#endif
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
#ifndef cfi_restore
# define cfi_restore(reg) .cfi_restore reg
#endif
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef cfi_adjust_cfa_offset
# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
#endif
#ifndef USE_AS_STRCAT
#ifndef cfi_remember_state
# define cfi_remember_state .cfi_remember_state
#endif
# ifndef STRLEN
# define STRLEN strlen
# endif
#ifndef cfi_restore_state
# define cfi_restore_state .cfi_restore_state
#endif
# ifndef L
# define L(label) .L##label
# endif
#ifndef ENTRY
# define ENTRY(name) \
.type name, @function; \
.globl name; \
.p2align 4; \
name: \
# ifndef cfi_startproc
# define cfi_startproc .cfi_startproc
# endif
# ifndef cfi_endproc
# define cfi_endproc .cfi_endproc
# endif
/* calee safe register only for strnlen is required */
# ifdef USE_AS_STRNLEN
# ifndef cfi_rel_offset
# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
# endif
# ifndef cfi_restore
# define cfi_restore(reg) .cfi_restore reg
# endif
# ifndef cfi_adjust_cfa_offset
# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
# endif
# endif
# ifndef ENTRY
# define ENTRY(name) \
.type name, @function; \
.globl name; \
.p2align 4; \
name: \
cfi_startproc
#endif
# endif
#ifndef END
# define END(name) \
cfi_endproc; \
# ifndef END
# define END(name) \
cfi_endproc; \
.size name, .-name
#endif
# endif
#define CFI_PUSH(REG) \
cfi_adjust_cfa_offset (4); \
cfi_rel_offset (REG, 0)
# define PARMS 4
# define STR PARMS
# define RETURN ret
#define CFI_POP(REG) \
cfi_adjust_cfa_offset (-4); \
cfi_restore (REG)
# ifdef USE_AS_STRNLEN
# define LEN PARMS + 8
# define CFI_PUSH(REG) \
cfi_adjust_cfa_offset (4); \
cfi_rel_offset (REG, 0)
#define PUSH(REG) pushl REG; CFI_PUSH (REG)
#define POP(REG) popl REG; CFI_POP (REG)
#define PARMS 4
#define STR PARMS
#define ENTRANCE
#define RETURN ret
# define CFI_POP(REG) \
cfi_adjust_cfa_offset (-4); \
cfi_restore (REG)
# define PUSH(REG) pushl REG; CFI_PUSH (REG)
# define POP(REG) popl REG; CFI_POP (REG)
# undef RETURN
# define RETURN POP (%edi); ret; CFI_PUSH(%edi);
# endif
.text
ENTRY (STRLEN)
ENTRANCE
mov STR(%esp), %edx
# ifdef USE_AS_STRNLEN
PUSH (%edi)
movl LEN(%esp), %edi
sub $4, %edi
jbe L(len_less4_prolog)
# endif
#endif
xor %eax, %eax
cmpb $0, (%edx)
jz L(exit_tail0)
@@ -75,6 +116,12 @@ ENTRY (STRLEN)
jz L(exit_tail2)
cmpb $0, 3(%edx)
jz L(exit_tail3)
#ifdef USE_AS_STRNLEN
sub $4, %edi
jbe L(len_less8_prolog)
#endif
cmpb $0, 4(%edx)
jz L(exit_tail4)
cmpb $0, 5(%edx)
@@ -83,6 +130,12 @@ ENTRY (STRLEN)
jz L(exit_tail6)
cmpb $0, 7(%edx)
jz L(exit_tail7)
#ifdef USE_AS_STRNLEN
sub $4, %edi
jbe L(len_less12_prolog)
#endif
cmpb $0, 8(%edx)
jz L(exit_tail8)
cmpb $0, 9(%edx)
@@ -91,6 +144,12 @@ ENTRY (STRLEN)
jz L(exit_tail10)
cmpb $0, 11(%edx)
jz L(exit_tail11)
#ifdef USE_AS_STRNLEN
sub $4, %edi
jbe L(len_less16_prolog)
#endif
cmpb $0, 12(%edx)
jz L(exit_tail12)
cmpb $0, 13(%edx)
@@ -99,211 +158,531 @@ ENTRY (STRLEN)
jz L(exit_tail14)
cmpb $0, 15(%edx)
jz L(exit_tail15)
pxor %xmm0, %xmm0
mov %edx, %eax
mov %edx, %ecx
lea 16(%edx), %eax
mov %eax, %ecx
and $-16, %eax
add $16, %ecx
add $16, %eax
#ifdef USE_AS_STRNLEN
and $15, %edx
add %edx, %edi
sub $64, %edi
jbe L(len_less64)
#endif
pcmpeqb (%eax), %xmm0
pmovmskb %xmm0, %edx
pxor %xmm1, %xmm1
test %edx, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqb (%eax), %xmm1
pmovmskb %xmm1, %edx
pxor %xmm2, %xmm2
test %edx, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqb (%eax), %xmm2
pmovmskb %xmm2, %edx
pxor %xmm3, %xmm3
test %edx, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqb (%eax), %xmm3
pmovmskb %xmm3, %edx
test %edx, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
#ifdef USE_AS_STRNLEN
sub $64, %edi
jbe L(len_less64)
#endif
pcmpeqb (%eax), %xmm0
pmovmskb %xmm0, %edx
test %edx, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqb (%eax), %xmm1
pmovmskb %xmm1, %edx
test %edx, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqb (%eax), %xmm2
pmovmskb %xmm2, %edx
test %edx, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqb (%eax), %xmm3
pmovmskb %xmm3, %edx
test %edx, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
#ifdef USE_AS_STRNLEN
sub $64, %edi
jbe L(len_less64)
#endif
pcmpeqb (%eax), %xmm0
pmovmskb %xmm0, %edx
test %edx, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqb (%eax), %xmm1
pmovmskb %xmm1, %edx
test %edx, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqb (%eax), %xmm2
pmovmskb %xmm2, %edx
test %edx, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqb (%eax), %xmm3
pmovmskb %xmm3, %edx
test %edx, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
#ifdef USE_AS_STRNLEN
sub $64, %edi
jbe L(len_less64)
#endif
pcmpeqb (%eax), %xmm0
pmovmskb %xmm0, %edx
test %edx, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqb (%eax), %xmm1
pmovmskb %xmm1, %edx
test %edx, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqb (%eax), %xmm2
pmovmskb %xmm2, %edx
test %edx, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqb (%eax), %xmm3
pmovmskb %xmm3, %edx
test %edx, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
#ifdef USE_AS_STRNLEN
mov %eax, %edx
and $63, %edx
add %edx, %edi
#endif
and $-0x40, %eax
PUSH (%esi)
PUSH (%edi)
PUSH (%ebx)
PUSH (%ebp)
xor %ebp, %ebp
L(aligned_64):
pcmpeqb (%eax), %xmm0
pcmpeqb 16(%eax), %xmm1
pcmpeqb 32(%eax), %xmm2
pcmpeqb 48(%eax), %xmm3
pmovmskb %xmm0, %edx
pmovmskb %xmm1, %esi
pmovmskb %xmm2, %edi
pmovmskb %xmm3, %ebx
or %edx, %ebp
or %esi, %ebp
or %edi, %ebp
or %ebx, %ebp
.p2align 4
L(aligned_64_loop):
#ifdef USE_AS_STRNLEN
sub $64, %edi
jbe L(len_less64)
#endif
movaps (%eax), %xmm0
movaps 16(%eax), %xmm1
movaps 32(%eax), %xmm2
movaps 48(%eax), %xmm6
pminub %xmm1, %xmm0
pminub %xmm6, %xmm2
pminub %xmm0, %xmm2
pcmpeqb %xmm3, %xmm2
pmovmskb %xmm2, %edx
lea 64(%eax), %eax
jz L(aligned_64)
L(48leave):
test %edx, %edx
jnz L(aligned_64_exit_16)
test %esi, %esi
jnz L(aligned_64_exit_32)
test %edi, %edi
jnz L(aligned_64_exit_48)
mov %ebx, %edx
lea (%eax), %eax
jmp L(aligned_64_exit)
L(aligned_64_exit_48):
lea -16(%eax), %eax
mov %edi, %edx
jmp L(aligned_64_exit)
L(aligned_64_exit_32):
lea -32(%eax), %eax
mov %esi, %edx
jmp L(aligned_64_exit)
L(aligned_64_exit_16):
lea -48(%eax), %eax
L(aligned_64_exit):
POP (%ebp)
POP (%ebx)
POP (%edi)
POP (%esi)
jz L(aligned_64_loop)
pcmpeqb -64(%eax), %xmm3
pmovmskb %xmm3, %edx
lea 48(%ecx), %ecx
test %edx, %edx
jnz L(exit)
pcmpeqb %xmm1, %xmm3
pmovmskb %xmm3, %edx
lea -16(%ecx), %ecx
test %edx, %edx
jnz L(exit)
pcmpeqb -32(%eax), %xmm3
pmovmskb %xmm3, %edx
lea -16(%ecx), %ecx
test %edx, %edx
jnz L(exit)
pcmpeqb %xmm6, %xmm3
pmovmskb %xmm3, %edx
lea -16(%ecx), %ecx
L(exit):
sub %ecx, %eax
test %dl, %dl
jz L(exit_high)
mov %dl, %cl
and $15, %cl
jz L(exit_8)
test $0x01, %dl
jnz L(exit_tail0)
test $0x02, %dl
jnz L(exit_tail1)
test $0x04, %dl
jnz L(exit_tail2)
add $3, %eax
RETURN
test $0x08, %dl
jnz L(exit_tail3)
.p2align 4
L(exit_8):
test $0x10, %dl
jnz L(exit_tail4)
test $0x20, %dl
jnz L(exit_tail5)
test $0x40, %dl
jnz L(exit_tail6)
add $7, %eax
RETURN
.p2align 4
L(exit_high):
mov %dh, %ch
and $15, %ch
jz L(exit_high_8)
test $0x01, %dh
jnz L(exit_tail8)
test $0x02, %dh
jnz L(exit_tail9)
test $0x04, %dh
jnz L(exit_tail10)
add $11, %eax
RETURN
.p2align 4
L(exit_high_8):
test $0x10, %dh
jnz L(exit_tail12)
test $0x20, %dh
jnz L(exit_tail13)
test $0x40, %dh
jnz L(exit_tail14)
add $15, %eax
L(exit_tail0):
RETURN
L(exit_high):
add $8, %eax
test $0x01, %dh
jnz L(exit_tail0)
#ifdef USE_AS_STRNLEN
test $0x02, %dh
jnz L(exit_tail1)
.p2align 4
L(len_less64):
pxor %xmm0, %xmm0
add $64, %edi
test $0x04, %dh
jnz L(exit_tail2)
pcmpeqb (%eax), %xmm0
pmovmskb %xmm0, %edx
pxor %xmm1, %xmm1
lea 16(%eax), %eax
test %edx, %edx
jnz L(strnlen_exit)
test $0x08, %dh
jnz L(exit_tail3)
sub $16, %edi
jbe L(return_start_len)
test $0x10, %dh
jnz L(exit_tail4)
pcmpeqb (%eax), %xmm1
pmovmskb %xmm1, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(strnlen_exit)
test $0x20, %dh
jnz L(exit_tail5)
sub $16, %edi
jbe L(return_start_len)
test $0x40, %dh
jnz L(exit_tail6)
add $7, %eax
pcmpeqb (%eax), %xmm0
pmovmskb %xmm0, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(strnlen_exit)
sub $16, %edi
jbe L(return_start_len)
pcmpeqb (%eax), %xmm1
pmovmskb %xmm1, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(strnlen_exit)
#ifndef USE_AS_STRLCAT
movl LEN(%esp), %eax
RETURN
#else
jmp L(return_start_len)
#endif
.p2align 4
L(strnlen_exit):
sub %ecx, %eax
test %dl, %dl
jz L(strnlen_exit_high)
mov %dl, %cl
and $15, %cl
jz L(strnlen_exit_8)
test $0x01, %dl
jnz L(exit_tail0)
test $0x02, %dl
jnz L(strnlen_exit_tail1)
test $0x04, %dl
jnz L(strnlen_exit_tail2)
sub $4, %edi
jb L(return_start_len)
lea 3(%eax), %eax
RETURN
.p2align 4
L(strnlen_exit_8):
test $0x10, %dl
jnz L(strnlen_exit_tail4)
test $0x20, %dl
jnz L(strnlen_exit_tail5)
test $0x40, %dl
jnz L(strnlen_exit_tail6)
sub $8, %edi
jb L(return_start_len)
lea 7(%eax), %eax
RETURN
.p2align 4
L(strnlen_exit_high):
mov %dh, %ch
and $15, %ch
jz L(strnlen_exit_high_8)
test $0x01, %dh
jnz L(strnlen_exit_tail8)
test $0x02, %dh
jnz L(strnlen_exit_tail9)
test $0x04, %dh
jnz L(strnlen_exit_tail10)
sub $12, %edi
jb L(return_start_len)
lea 11(%eax), %eax
RETURN
.p2align 4
L(strnlen_exit_high_8):
test $0x10, %dh
jnz L(strnlen_exit_tail12)
test $0x20, %dh
jnz L(strnlen_exit_tail13)
test $0x40, %dh
jnz L(strnlen_exit_tail14)
sub $16, %edi
jb L(return_start_len)
lea 15(%eax), %eax
RETURN
.p2align 4
L(strnlen_exit_tail1):
sub $2, %edi
jb L(return_start_len)
lea 1(%eax), %eax
RETURN
.p2align 4
L(strnlen_exit_tail2):
sub $3, %edi
jb L(return_start_len)
lea 2(%eax), %eax
RETURN
.p2align 4
L(strnlen_exit_tail4):
sub $5, %edi
jb L(return_start_len)
lea 4(%eax), %eax
RETURN
.p2align 4
L(strnlen_exit_tail5):
sub $6, %edi
jb L(return_start_len)
lea 5(%eax), %eax
RETURN
.p2align 4
L(strnlen_exit_tail6):
sub $7, %edi
jb L(return_start_len)
lea 6(%eax), %eax
RETURN
.p2align 4
L(strnlen_exit_tail8):
sub $9, %edi
jb L(return_start_len)
lea 8(%eax), %eax
RETURN
.p2align 4
L(strnlen_exit_tail9):
sub $10, %edi
jb L(return_start_len)
lea 9(%eax), %eax
RETURN
.p2align 4
L(strnlen_exit_tail10):
sub $11, %edi
jb L(return_start_len)
lea 10(%eax), %eax
RETURN
.p2align 4
L(strnlen_exit_tail12):
sub $13, %edi
jb L(return_start_len)
lea 12(%eax), %eax
RETURN
.p2align 4
L(strnlen_exit_tail13):
sub $14, %edi
jb L(return_start_len)
lea 13(%eax), %eax
RETURN
.p2align 4
L(strnlen_exit_tail14):
sub $15, %edi
jb L(return_start_len)
lea 14(%eax), %eax
RETURN
#ifndef USE_AS_STRLCAT
.p2align 4
L(return_start_len):
movl LEN(%esp), %eax
RETURN
#endif
/* for prolog only */
.p2align 4
L(len_less4_prolog):
xor %eax, %eax
add $4, %edi
jz L(exit_tail0)
cmpb $0, (%edx)
jz L(exit_tail0)
cmp $1, %edi
je L(exit_tail1)
cmpb $0, 1(%edx)
jz L(exit_tail1)
cmp $2, %edi
je L(exit_tail2)
cmpb $0, 2(%edx)
jz L(exit_tail2)
cmp $3, %edi
je L(exit_tail3)
cmpb $0, 3(%edx)
jz L(exit_tail3)
mov %edi, %eax
RETURN
.p2align 4
L(len_less8_prolog):
add $4, %edi
cmpb $0, 4(%edx)
jz L(exit_tail4)
cmp $1, %edi
je L(exit_tail5)
cmpb $0, 5(%edx)
jz L(exit_tail5)
cmp $2, %edi
je L(exit_tail6)
cmpb $0, 6(%edx)
jz L(exit_tail6)
cmp $3, %edi
je L(exit_tail7)
cmpb $0, 7(%edx)
jz L(exit_tail7)
mov $8, %eax
RETURN
.p2align 4
L(len_less12_prolog):
add $4, %edi
cmpb $0, 8(%edx)
jz L(exit_tail8)
cmp $1, %edi
je L(exit_tail9)
cmpb $0, 9(%edx)
jz L(exit_tail9)
cmp $2, %edi
je L(exit_tail10)
cmpb $0, 10(%edx)
jz L(exit_tail10)
cmp $3, %edi
je L(exit_tail11)
cmpb $0, 11(%edx)
jz L(exit_tail11)
mov $12, %eax
RETURN
.p2align 4
L(len_less16_prolog):
add $4, %edi
cmpb $0, 12(%edx)
jz L(exit_tail12)
cmp $1, %edi
je L(exit_tail13)
cmpb $0, 13(%edx)
jz L(exit_tail13)
cmp $2, %edi
je L(exit_tail14)
cmpb $0, 14(%edx)
jz L(exit_tail14)
cmp $3, %edi
je L(exit_tail15)
cmpb $0, 15(%edx)
jz L(exit_tail15)
mov $16, %eax
RETURN
#endif
.p2align 4
L(exit_tail1):
@@ -364,6 +743,7 @@ L(exit_tail14):
L(exit_tail15):
add $15, %eax
ret
#ifndef USE_AS_STRCAT
RETURN
END (STRLEN)
#endif

View File

@@ -0,0 +1,33 @@
/*
Copyright (c) 2011, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define USE_AS_STRNLEN 1
#define STRLEN strnlen
#include "sse2-strlen-atom.S"

View File

@@ -0,0 +1,753 @@
/*
Copyright (c) 2011, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef L
# define L(label) .L##label
#endif
#ifndef cfi_startproc
# define cfi_startproc .cfi_startproc
#endif
#ifndef cfi_endproc
# define cfi_endproc .cfi_endproc
#endif
#ifndef cfi_rel_offset
# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
#endif
#ifndef cfi_restore
# define cfi_restore(reg) .cfi_restore reg
#endif
#ifndef cfi_adjust_cfa_offset
# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
#endif
#ifndef ENTRY
# define ENTRY(name) \
.type name, @function; \
.globl name; \
.p2align 4; \
name: \
cfi_startproc
#endif
#ifndef END
# define END(name) \
cfi_endproc; \
.size name, .-name
#endif
#define CFI_PUSH(REG) \
cfi_adjust_cfa_offset (4); \
cfi_rel_offset (REG, 0)
#define CFI_POP(REG) \
cfi_adjust_cfa_offset (-4); \
cfi_restore (REG)
#define PUSH(REG) pushl REG; CFI_PUSH (REG)
#define POP(REG) popl REG; CFI_POP (REG)
#define PARMS 8
#define ENTRANCE PUSH(%edi);
#define RETURN POP (%edi); ret; CFI_PUSH (%edi);
#define STR1 PARMS
#define STR2 STR1+4
.text
ENTRY (strrchr)
ENTRANCE
mov STR1(%esp), %ecx
movd STR2(%esp), %xmm1
pxor %xmm2, %xmm2
mov %ecx, %edi
punpcklbw %xmm1, %xmm1
punpcklbw %xmm1, %xmm1
/* ECX has OFFSET. */
and $63, %ecx
pshufd $0, %xmm1, %xmm1
cmp $48, %ecx
ja L(crosscache)
/* unaligned string. */
movdqu (%edi), %xmm0
pcmpeqb %xmm0, %xmm2
pcmpeqb %xmm1, %xmm0
/* Find where NULL is. */
pmovmskb %xmm2, %ecx
/* Check if there is a match. */
pmovmskb %xmm0, %eax
add $16, %edi
test %eax, %eax
jnz L(unaligned_match1)
test %ecx, %ecx
jnz L(return_null)
and $-16, %edi
PUSH (%esi)
PUSH (%ebx)
xor %ebx, %ebx
jmp L(loop)
CFI_POP (%esi)
CFI_POP (%ebx)
.p2align 4
L(unaligned_match1):
test %ecx, %ecx
jnz L(prolog_find_zero_1)
PUSH (%esi)
PUSH (%ebx)
mov %eax, %ebx
mov %edi, %esi
and $-16, %edi
jmp L(loop)
CFI_POP (%esi)
CFI_POP (%ebx)
.p2align 4
L(crosscache):
/* Hancle unaligned string. */
and $15, %ecx
and $-16, %edi
pxor %xmm3, %xmm3
movdqa (%edi), %xmm0
pcmpeqb %xmm0, %xmm3
pcmpeqb %xmm1, %xmm0
/* Find where NULL is. */
pmovmskb %xmm3, %edx
/* Check if there is a match. */
pmovmskb %xmm0, %eax
/* Remove the leading bytes. */
shr %cl, %edx
shr %cl, %eax
add $16, %edi
test %eax, %eax
jnz L(unaligned_match)
test %edx, %edx
jnz L(return_null)
PUSH (%esi)
PUSH (%ebx)
xor %ebx, %ebx
jmp L(loop)
CFI_POP (%esi)
CFI_POP (%ebx)
.p2align 4
L(unaligned_match):
test %edx, %edx
jnz L(prolog_find_zero)
PUSH (%esi)
PUSH (%ebx)
mov %eax, %ebx
lea (%edi, %ecx), %esi
/* Loop start on aligned string. */
.p2align 4
L(loop):
movdqa (%edi), %xmm0
pcmpeqb %xmm0, %xmm2
add $16, %edi
pcmpeqb %xmm1, %xmm0
pmovmskb %xmm2, %ecx
pmovmskb %xmm0, %eax
or %eax, %ecx
jnz L(matches)
movdqa (%edi), %xmm0
pcmpeqb %xmm0, %xmm2
add $16, %edi
pcmpeqb %xmm1, %xmm0
pmovmskb %xmm2, %ecx
pmovmskb %xmm0, %eax
or %eax, %ecx
jnz L(matches)
movdqa (%edi), %xmm0
pcmpeqb %xmm0, %xmm2
add $16, %edi
pcmpeqb %xmm1, %xmm0
pmovmskb %xmm2, %ecx
pmovmskb %xmm0, %eax
or %eax, %ecx
jnz L(matches)
movdqa (%edi), %xmm0
pcmpeqb %xmm0, %xmm2
add $16, %edi
pcmpeqb %xmm1, %xmm0
pmovmskb %xmm2, %ecx
pmovmskb %xmm0, %eax
or %eax, %ecx
jz L(loop)
L(matches):
test %eax, %eax
jnz L(match)
L(return_value):
test %ebx, %ebx
jz L(return_null_1)
mov %ebx, %eax
mov %esi, %edi
POP (%ebx)
POP (%esi)
jmp L(match_case1)
CFI_PUSH (%ebx)
CFI_PUSH (%esi)
.p2align 4
L(return_null_1):
POP (%ebx)
POP (%esi)
xor %eax, %eax
RETURN
CFI_PUSH (%ebx)
CFI_PUSH (%esi)
.p2align 4
L(match):
pmovmskb %xmm2, %ecx
test %ecx, %ecx
jnz L(find_zero)
mov %eax, %ebx
mov %edi, %esi
jmp L(loop)
.p2align 4
L(find_zero):
test %cl, %cl
jz L(find_zero_high)
mov %cl, %dl
and $15, %dl
jz L(find_zero_8)
test $0x01, %cl
jnz L(FindZeroExit1)
test $0x02, %cl
jnz L(FindZeroExit2)
test $0x04, %cl
jnz L(FindZeroExit3)
and $1 << 4 - 1, %eax
jz L(return_value)
POP (%ebx)
POP (%esi)
jmp L(match_case1)
CFI_PUSH (%ebx)
CFI_PUSH (%esi)
.p2align 4
L(find_zero_8):
test $0x10, %cl
jnz L(FindZeroExit5)
test $0x20, %cl
jnz L(FindZeroExit6)
test $0x40, %cl
jnz L(FindZeroExit7)
and $1 << 8 - 1, %eax
jz L(return_value)
POP (%ebx)
POP (%esi)
jmp L(match_case1)
CFI_PUSH (%ebx)
CFI_PUSH (%esi)
.p2align 4
L(find_zero_high):
mov %ch, %dh
and $15, %dh
jz L(find_zero_high_8)
test $0x01, %ch
jnz L(FindZeroExit9)
test $0x02, %ch
jnz L(FindZeroExit10)
test $0x04, %ch
jnz L(FindZeroExit11)
and $1 << 12 - 1, %eax
jz L(return_value)
POP (%ebx)
POP (%esi)
jmp L(match_case1)
CFI_PUSH (%ebx)
CFI_PUSH (%esi)
.p2align 4
L(find_zero_high_8):
test $0x10, %ch
jnz L(FindZeroExit13)
test $0x20, %ch
jnz L(FindZeroExit14)
test $0x40, %ch
jnz L(FindZeroExit15)
and $1 << 16 - 1, %eax
jz L(return_value)
POP (%ebx)
POP (%esi)
jmp L(match_case1)
CFI_PUSH (%ebx)
CFI_PUSH (%esi)
.p2align 4
L(FindZeroExit1):
and $1, %eax
jz L(return_value)
POP (%ebx)
POP (%esi)
jmp L(match_case1)
CFI_PUSH (%ebx)
CFI_PUSH (%esi)
.p2align 4
L(FindZeroExit2):
and $1 << 2 - 1, %eax
jz L(return_value)
POP (%ebx)
POP (%esi)
jmp L(match_case1)
CFI_PUSH (%ebx)
CFI_PUSH (%esi)
.p2align 4
L(FindZeroExit3):
and $1 << 3 - 1, %eax
jz L(return_value)
POP (%ebx)
POP (%esi)
jmp L(match_case1)
CFI_PUSH (%ebx)
CFI_PUSH (%esi)
.p2align 4
L(FindZeroExit5):
and $1 << 5 - 1, %eax
jz L(return_value)
POP (%ebx)
POP (%esi)
jmp L(match_case1)
CFI_PUSH (%ebx)
CFI_PUSH (%esi)
.p2align 4
L(FindZeroExit6):
and $1 << 6 - 1, %eax
jz L(return_value)
POP (%ebx)
POP (%esi)
jmp L(match_case1)
CFI_PUSH (%ebx)
CFI_PUSH (%esi)
.p2align 4
L(FindZeroExit7):
and $1 << 7 - 1, %eax
jz L(return_value)
POP (%ebx)
POP (%esi)
jmp L(match_case1)
CFI_PUSH (%ebx)
CFI_PUSH (%esi)
.p2align 4
L(FindZeroExit9):
and $1 << 9 - 1, %eax
jz L(return_value)
POP (%ebx)
POP (%esi)
jmp L(match_case1)
CFI_PUSH (%ebx)
CFI_PUSH (%esi)
.p2align 4
L(FindZeroExit10):
and $1 << 10 - 1, %eax
jz L(return_value)
POP (%ebx)
POP (%esi)
jmp L(match_case1)
CFI_PUSH (%ebx)
CFI_PUSH (%esi)
.p2align 4
L(FindZeroExit11):
and $1 << 11 - 1, %eax
jz L(return_value)
POP (%ebx)
POP (%esi)
jmp L(match_case1)
CFI_PUSH (%ebx)
CFI_PUSH (%esi)
.p2align 4
L(FindZeroExit13):
and $1 << 13 - 1, %eax
jz L(return_value)
POP (%ebx)
POP (%esi)
jmp L(match_case1)
CFI_PUSH (%ebx)
CFI_PUSH (%esi)
.p2align 4
L(FindZeroExit14):
and $1 << 14 - 1, %eax
jz L(return_value)
POP (%ebx)
POP (%esi)
jmp L(match_case1)
CFI_PUSH (%ebx)
CFI_PUSH (%esi)
.p2align 4
L(FindZeroExit15):
and $1 << 15 - 1, %eax
jz L(return_value)
POP (%ebx)
POP (%esi)
.p2align 4
L(match_case1):
test %ah, %ah
jnz L(match_case1_high)
mov %al, %dl
and $15 << 4, %dl
jnz L(match_case1_8)
test $0x08, %al
jnz L(Exit4)
test $0x04, %al
jnz L(Exit3)
test $0x02, %al
jnz L(Exit2)
lea -16(%edi), %eax
RETURN
.p2align 4
L(match_case1_8):
test $0x80, %al
jnz L(Exit8)
test $0x40, %al
jnz L(Exit7)
test $0x20, %al
jnz L(Exit6)
lea -12(%edi), %eax
RETURN
.p2align 4
L(match_case1_high):
mov %ah, %dh
and $15 << 4, %dh
jnz L(match_case1_high_8)
test $0x08, %ah
jnz L(Exit12)
test $0x04, %ah
jnz L(Exit11)
test $0x02, %ah
jnz L(Exit10)
lea -8(%edi), %eax
RETURN
.p2align 4
L(match_case1_high_8):
test $0x80, %ah
jnz L(Exit16)
test $0x40, %ah
jnz L(Exit15)
test $0x20, %ah
jnz L(Exit14)
lea -4(%edi), %eax
RETURN
.p2align 4
L(Exit2):
lea -15(%edi), %eax
RETURN
.p2align 4
L(Exit3):
lea -14(%edi), %eax
RETURN
.p2align 4
L(Exit4):
lea -13(%edi), %eax
RETURN
.p2align 4
L(Exit6):
lea -11(%edi), %eax
RETURN
.p2align 4
L(Exit7):
lea -10(%edi), %eax
RETURN
.p2align 4
L(Exit8):
lea -9(%edi), %eax
RETURN
.p2align 4
L(Exit10):
lea -7(%edi), %eax
RETURN
.p2align 4
L(Exit11):
lea -6(%edi), %eax
RETURN
.p2align 4
L(Exit12):
lea -5(%edi), %eax
RETURN
.p2align 4
L(Exit14):
lea -3(%edi), %eax
RETURN
.p2align 4
L(Exit15):
lea -2(%edi), %eax
RETURN
.p2align 4
L(Exit16):
lea -1(%edi), %eax
RETURN
/* Return NULL. */
.p2align 4
L(return_null):
xor %eax, %eax
RETURN
.p2align 4
L(prolog_find_zero):
add %ecx, %edi
mov %edx, %ecx
L(prolog_find_zero_1):
test %cl, %cl
jz L(prolog_find_zero_high)
mov %cl, %dl
and $15, %dl
jz L(prolog_find_zero_8)
test $0x01, %cl
jnz L(PrologFindZeroExit1)
test $0x02, %cl
jnz L(PrologFindZeroExit2)
test $0x04, %cl
jnz L(PrologFindZeroExit3)
and $1 << 4 - 1, %eax
jnz L(match_case1)
xor %eax, %eax
RETURN
.p2align 4
L(prolog_find_zero_8):
test $0x10, %cl
jnz L(PrologFindZeroExit5)
test $0x20, %cl
jnz L(PrologFindZeroExit6)
test $0x40, %cl
jnz L(PrologFindZeroExit7)
and $1 << 8 - 1, %eax
jnz L(match_case1)
xor %eax, %eax
RETURN
.p2align 4
L(prolog_find_zero_high):
mov %ch, %dh
and $15, %dh
jz L(prolog_find_zero_high_8)
test $0x01, %ch
jnz L(PrologFindZeroExit9)
test $0x02, %ch
jnz L(PrologFindZeroExit10)
test $0x04, %ch
jnz L(PrologFindZeroExit11)
and $1 << 12 - 1, %eax
jnz L(match_case1)
xor %eax, %eax
RETURN
.p2align 4
L(prolog_find_zero_high_8):
test $0x10, %ch
jnz L(PrologFindZeroExit13)
test $0x20, %ch
jnz L(PrologFindZeroExit14)
test $0x40, %ch
jnz L(PrologFindZeroExit15)
and $1 << 16 - 1, %eax
jnz L(match_case1)
xor %eax, %eax
RETURN
.p2align 4
L(PrologFindZeroExit1):
and $1, %eax
jnz L(match_case1)
xor %eax, %eax
RETURN
.p2align 4
L(PrologFindZeroExit2):
and $1 << 2 - 1, %eax
jnz L(match_case1)
xor %eax, %eax
RETURN
.p2align 4
L(PrologFindZeroExit3):
and $1 << 3 - 1, %eax
jnz L(match_case1)
xor %eax, %eax
RETURN
.p2align 4
L(PrologFindZeroExit5):
and $1 << 5 - 1, %eax
jnz L(match_case1)
xor %eax, %eax
RETURN
.p2align 4
L(PrologFindZeroExit6):
and $1 << 6 - 1, %eax
jnz L(match_case1)
xor %eax, %eax
RETURN
.p2align 4
L(PrologFindZeroExit7):
and $1 << 7 - 1, %eax
jnz L(match_case1)
xor %eax, %eax
RETURN
.p2align 4
L(PrologFindZeroExit9):
and $1 << 9 - 1, %eax
jnz L(match_case1)
xor %eax, %eax
RETURN
.p2align 4
L(PrologFindZeroExit10):
and $1 << 10 - 1, %eax
jnz L(match_case1)
xor %eax, %eax
RETURN
.p2align 4
L(PrologFindZeroExit11):
and $1 << 11 - 1, %eax
jnz L(match_case1)
xor %eax, %eax
RETURN
.p2align 4
L(PrologFindZeroExit13):
and $1 << 13 - 1, %eax
jnz L(match_case1)
xor %eax, %eax
RETURN
.p2align 4
L(PrologFindZeroExit14):
and $1 << 14 - 1, %eax
jnz L(match_case1)
xor %eax, %eax
RETURN
.p2align 4
L(PrologFindZeroExit15):
and $1 << 15 - 1, %eax
jnz L(match_case1)
xor %eax, %eax
RETURN
END (strrchr)

View File

@@ -0,0 +1,267 @@
/*
Copyright (c) 2011 Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef L
# define L(label) .L##label
#endif
#ifndef cfi_startproc
# define cfi_startproc .cfi_startproc
#endif
#ifndef cfi_endproc
# define cfi_endproc .cfi_endproc
#endif
#ifndef cfi_rel_offset
# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
#endif
#ifndef cfi_restore
# define cfi_restore(reg) .cfi_restore reg
#endif
#ifndef cfi_adjust_cfa_offset
# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
#endif
#ifndef ENTRY
# define ENTRY(name) \
.type name, @function; \
.globl name; \
.p2align 4; \
name: \
cfi_startproc
#endif
#ifndef END
# define END(name) \
cfi_endproc; \
.size name, .-name
#endif
#define CFI_PUSH(REG) \
cfi_adjust_cfa_offset (4); \
cfi_rel_offset (REG, 0)
#define CFI_POP(REG) \
cfi_adjust_cfa_offset (-4); \
cfi_restore (REG)
#define PUSH(REG) pushl REG; CFI_PUSH (REG)
#define POP(REG) popl REG; CFI_POP (REG)
#define PARMS 4
#define STR1 PARMS
#define STR2 STR1+4
.text
ENTRY (wcschr)
mov STR1(%esp), %ecx
movd STR2(%esp), %xmm1
mov %ecx, %eax
punpckldq %xmm1, %xmm1
pxor %xmm2, %xmm2
punpckldq %xmm1, %xmm1
and $63, %eax
cmp $48, %eax
ja L(cross_cache)
movdqu (%ecx), %xmm0
pcmpeqd %xmm0, %xmm2
pcmpeqd %xmm1, %xmm0
pmovmskb %xmm2, %edx
pmovmskb %xmm0, %eax
or %eax, %edx
jnz L(matches)
and $-16, %ecx
jmp L(loop)
.p2align 4
L(cross_cache):
PUSH (%edi)
mov %ecx, %edi
mov %eax, %ecx
and $-16, %edi
and $15, %ecx
movdqa (%edi), %xmm0
pcmpeqd %xmm0, %xmm2
pcmpeqd %xmm1, %xmm0
pmovmskb %xmm2, %edx
pmovmskb %xmm0, %eax
sarl %cl, %edx
sarl %cl, %eax
test %eax, %eax
jz L(unaligned_no_match)
add %edi, %ecx
POP (%edi)
test %edx, %edx
jz L(match_case1)
test %al, %al
jz L(match_higth_case2)
test $15, %al
jnz L(match_case2_4)
test $15, %dl
jnz L(return_null)
lea 4(%ecx), %eax
ret
CFI_PUSH (%edi)
.p2align 4
L(unaligned_no_match):
mov %edi, %ecx
POP (%edi)
test %edx, %edx
jnz L(return_null)
pxor %xmm2, %xmm2
/* Loop start on aligned string. */
.p2align 4
L(loop):
add $16, %ecx
movdqa (%ecx), %xmm0
pcmpeqd %xmm0, %xmm2
pcmpeqd %xmm1, %xmm0
pmovmskb %xmm2, %edx
pmovmskb %xmm0, %eax
or %eax, %edx
jnz L(matches)
add $16, %ecx
movdqa (%ecx), %xmm0
pcmpeqd %xmm0, %xmm2
pcmpeqd %xmm1, %xmm0
pmovmskb %xmm2, %edx
pmovmskb %xmm0, %eax
or %eax, %edx
jnz L(matches)
add $16, %ecx
movdqa (%ecx), %xmm0
pcmpeqd %xmm0, %xmm2
pcmpeqd %xmm1, %xmm0
pmovmskb %xmm2, %edx
pmovmskb %xmm0, %eax
or %eax, %edx
jnz L(matches)
add $16, %ecx
movdqa (%ecx), %xmm0
pcmpeqd %xmm0, %xmm2
pcmpeqd %xmm1, %xmm0
pmovmskb %xmm2, %edx
pmovmskb %xmm0, %eax
or %eax, %edx
jz L(loop)
.p2align 4
L(matches):
pmovmskb %xmm2, %edx
test %eax, %eax
jz L(return_null)
test %edx, %edx
jz L(match_case1)
.p2align 4
L(match_case2):
test %al, %al
jz L(match_higth_case2)
test $15, %al
jnz L(match_case2_4)
test $15, %dl
jnz L(return_null)
lea 4(%ecx), %eax
ret
.p2align 4
L(match_case2_4):
mov %ecx, %eax
ret
.p2align 4
L(match_higth_case2):
test %dl, %dl
jnz L(return_null)
test $15, %ah
jnz L(match_case2_12)
test $15, %dh
jnz L(return_null)
lea 12(%ecx), %eax
ret
.p2align 4
L(match_case2_12):
lea 8(%ecx), %eax
ret
.p2align 4
L(match_case1):
test %al, %al
jz L(match_higth_case1)
test $0x01, %al
jnz L(exit0)
lea 4(%ecx), %eax
ret
.p2align 4
L(match_higth_case1):
test $0x01, %ah
jnz L(exit3)
lea 12(%ecx), %eax
ret
.p2align 4
L(exit0):
mov %ecx, %eax
ret
.p2align 4
L(exit3):
lea 8(%ecx), %eax
ret
.p2align 4
L(return_null):
xor %eax, %eax
ret
END (wcschr)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,306 @@
/*
Copyright (c) 2011 Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef USE_AS_WCSCAT
# ifndef L
# define L(label) .L##label
# endif
# ifndef cfi_startproc
# define cfi_startproc .cfi_startproc
# endif
# ifndef cfi_endproc
# define cfi_endproc .cfi_endproc
# endif
# ifndef ENTRY
# define ENTRY(name) \
.type name, @function; \
.globl name; \
.p2align 4; \
name: \
cfi_startproc
# endif
# ifndef END
# define END(name) \
cfi_endproc; \
.size name, .-name
# endif
# define PARMS 4
# define STR PARMS
# define RETURN ret
.text
ENTRY (wcslen)
mov STR(%esp), %edx
#endif
cmp $0, (%edx)
jz L(exit_tail0)
cmp $0, 4(%edx)
jz L(exit_tail1)
cmp $0, 8(%edx)
jz L(exit_tail2)
cmp $0, 12(%edx)
jz L(exit_tail3)
cmp $0, 16(%edx)
jz L(exit_tail4)
cmp $0, 20(%edx)
jz L(exit_tail5)
cmp $0, 24(%edx)
jz L(exit_tail6)
cmp $0, 28(%edx)
jz L(exit_tail7)
pxor %xmm0, %xmm0
lea 32(%edx), %eax
lea -16(%eax), %ecx
and $-16, %eax
pcmpeqd (%eax), %xmm0
pmovmskb %xmm0, %edx
pxor %xmm1, %xmm1
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqd (%eax), %xmm1
pmovmskb %xmm1, %edx
pxor %xmm2, %xmm2
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqd (%eax), %xmm2
pmovmskb %xmm2, %edx
pxor %xmm3, %xmm3
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqd (%eax), %xmm3
pmovmskb %xmm3, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqd (%eax), %xmm0
pmovmskb %xmm0, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqd (%eax), %xmm1
pmovmskb %xmm1, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqd (%eax), %xmm2
pmovmskb %xmm2, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqd (%eax), %xmm3
pmovmskb %xmm3, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqd (%eax), %xmm0
pmovmskb %xmm0, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqd (%eax), %xmm1
pmovmskb %xmm1, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqd (%eax), %xmm2
pmovmskb %xmm2, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqd (%eax), %xmm3
pmovmskb %xmm3, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqd (%eax), %xmm0
pmovmskb %xmm0, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqd (%eax), %xmm1
pmovmskb %xmm1, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqd (%eax), %xmm2
pmovmskb %xmm2, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
pcmpeqd (%eax), %xmm3
pmovmskb %xmm3, %edx
lea 16(%eax), %eax
test %edx, %edx
jnz L(exit)
and $-0x40, %eax
.p2align 4
L(aligned_64_loop):
movaps (%eax), %xmm0
movaps 16(%eax), %xmm1
movaps 32(%eax), %xmm2
movaps 48(%eax), %xmm6
pminub %xmm1, %xmm0
pminub %xmm6, %xmm2
pminub %xmm0, %xmm2
pcmpeqd %xmm3, %xmm2
pmovmskb %xmm2, %edx
lea 64(%eax), %eax
test %edx, %edx
jz L(aligned_64_loop)
pcmpeqd -64(%eax), %xmm3
pmovmskb %xmm3, %edx
lea 48(%ecx), %ecx
test %edx, %edx
jnz L(exit)
pcmpeqd %xmm1, %xmm3
pmovmskb %xmm3, %edx
lea -16(%ecx), %ecx
test %edx, %edx
jnz L(exit)
pcmpeqd -32(%eax), %xmm3
pmovmskb %xmm3, %edx
lea -16(%ecx), %ecx
test %edx, %edx
jnz L(exit)
pcmpeqd %xmm6, %xmm3
pmovmskb %xmm3, %edx
lea -16(%ecx), %ecx
test %edx, %edx
jnz L(exit)
jmp L(aligned_64_loop)
.p2align 4
L(exit):
sub %ecx, %eax
shr $2, %eax
test %dl, %dl
jz L(exit_high)
mov %dl, %cl
and $15, %cl
jz L(exit_1)
RETURN
.p2align 4
L(exit_high):
mov %dh, %ch
and $15, %ch
jz L(exit_3)
add $2, %eax
RETURN
.p2align 4
L(exit_1):
add $1, %eax
RETURN
.p2align 4
L(exit_3):
add $3, %eax
RETURN
.p2align 4
L(exit_tail0):
xor %eax, %eax
RETURN
.p2align 4
L(exit_tail1):
mov $1, %eax
RETURN
.p2align 4
L(exit_tail2):
mov $2, %eax
RETURN
.p2align 4
L(exit_tail3):
mov $3, %eax
RETURN
.p2align 4
L(exit_tail4):
mov $4, %eax
RETURN
.p2align 4
L(exit_tail5):
mov $5, %eax
RETURN
.p2align 4
L(exit_tail6):
mov $6, %eax
RETURN
.p2align 4
L(exit_tail7):
mov $7, %eax
#ifndef USE_AS_WCSCAT
RETURN
END (wcslen)
#endif

View File

@@ -0,0 +1,402 @@
/*
Copyright (c) 2011 Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef L
# define L(label) .L##label
#endif
#ifndef cfi_startproc
# define cfi_startproc .cfi_startproc
#endif
#ifndef cfi_endproc
# define cfi_endproc .cfi_endproc
#endif
#ifndef cfi_rel_offset
# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
#endif
#ifndef cfi_restore
# define cfi_restore(reg) .cfi_restore reg
#endif
#ifndef cfi_adjust_cfa_offset
# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
#endif
#ifndef ENTRY
# define ENTRY(name) \
.type name, @function; \
.globl name; \
.p2align 4; \
name: \
cfi_startproc
#endif
#ifndef END
# define END(name) \
cfi_endproc; \
.size name, .-name
#endif
#define CFI_PUSH(REG) \
cfi_adjust_cfa_offset (4); \
cfi_rel_offset (REG, 0)
#define CFI_POP(REG) \
cfi_adjust_cfa_offset (-4); \
cfi_restore (REG)
#define PUSH(REG) pushl REG; CFI_PUSH (REG)
#define POP(REG) popl REG; CFI_POP (REG)
#define PARMS 8
#define ENTRANCE PUSH(%edi);
#define RETURN POP(%edi); ret; CFI_PUSH(%edi);
#define STR1 PARMS
#define STR2 STR1+4
.text
ENTRY (wcsrchr)
ENTRANCE
mov STR1(%esp), %ecx
movd STR2(%esp), %xmm1
mov %ecx, %edi
punpckldq %xmm1, %xmm1
pxor %xmm2, %xmm2
punpckldq %xmm1, %xmm1
/* ECX has OFFSET. */
and $63, %ecx
cmp $48, %ecx
ja L(crosscache)
/* unaligned string. */
movdqu (%edi), %xmm0
pcmpeqd %xmm0, %xmm2
pcmpeqd %xmm1, %xmm0
/* Find where NULL is. */
pmovmskb %xmm2, %ecx
/* Check if there is a match. */
pmovmskb %xmm0, %eax
add $16, %edi
test %eax, %eax
jnz L(unaligned_match1)
test %ecx, %ecx
jnz L(return_null)
and $-16, %edi
PUSH (%esi)
xor %edx, %edx
jmp L(loop)
CFI_POP (%esi)
.p2align 4
L(unaligned_match1):
test %ecx, %ecx
jnz L(prolog_find_zero_1)
PUSH (%esi)
/* Save current match */
mov %eax, %edx
mov %edi, %esi
and $-16, %edi
jmp L(loop)
CFI_POP (%esi)
.p2align 4
L(crosscache):
/* Hancle unaligned string. */
and $15, %ecx
and $-16, %edi
pxor %xmm3, %xmm3
movdqa (%edi), %xmm0
pcmpeqd %xmm0, %xmm3
pcmpeqd %xmm1, %xmm0
/* Find where NULL is. */
pmovmskb %xmm3, %edx
/* Check if there is a match. */
pmovmskb %xmm0, %eax
/* Remove the leading bytes. */
shr %cl, %edx
shr %cl, %eax
add $16, %edi
test %eax, %eax
jnz L(unaligned_match)
test %edx, %edx
jnz L(return_null)
PUSH (%esi)
xor %edx, %edx
jmp L(loop)
CFI_POP (%esi)
.p2align 4
L(unaligned_match):
test %edx, %edx
jnz L(prolog_find_zero)
PUSH (%esi)
mov %eax, %edx
lea (%edi, %ecx), %esi
/* Loop start on aligned string. */
.p2align 4
L(loop):
movdqa (%edi), %xmm0
pcmpeqd %xmm0, %xmm2
add $16, %edi
pcmpeqd %xmm1, %xmm0
pmovmskb %xmm2, %ecx
pmovmskb %xmm0, %eax
or %eax, %ecx
jnz L(matches)
movdqa (%edi), %xmm3
pcmpeqd %xmm3, %xmm2
add $16, %edi
pcmpeqd %xmm1, %xmm3
pmovmskb %xmm2, %ecx
pmovmskb %xmm3, %eax
or %eax, %ecx
jnz L(matches)
movdqa (%edi), %xmm4
pcmpeqd %xmm4, %xmm2
add $16, %edi
pcmpeqd %xmm1, %xmm4
pmovmskb %xmm2, %ecx
pmovmskb %xmm4, %eax
or %eax, %ecx
jnz L(matches)
movdqa (%edi), %xmm5
pcmpeqd %xmm5, %xmm2
add $16, %edi
pcmpeqd %xmm1, %xmm5
pmovmskb %xmm2, %ecx
pmovmskb %xmm5, %eax
or %eax, %ecx
jz L(loop)
.p2align 4
L(matches):
test %eax, %eax
jnz L(match)
L(return_value):
test %edx, %edx
jz L(return_null_1)
mov %edx, %eax
mov %esi, %edi
POP (%esi)
test %ah, %ah
jnz L(match_third_or_fourth_wchar)
test $15 << 4, %al
jnz L(match_second_wchar)
lea -16(%edi), %eax
RETURN
CFI_PUSH (%esi)
.p2align 4
L(return_null_1):
POP (%esi)
xor %eax, %eax
RETURN
CFI_PUSH (%esi)
.p2align 4
L(match):
pmovmskb %xmm2, %ecx
test %ecx, %ecx
jnz L(find_zero)
/* save match info */
mov %eax, %edx
mov %edi, %esi
jmp L(loop)
.p2align 4
L(find_zero):
test %cl, %cl
jz L(find_zero_in_third_or_fourth_wchar)
test $15, %cl
jz L(find_zero_in_second_wchar)
and $1, %eax
jz L(return_value)
POP (%esi)
lea -16(%edi), %eax
RETURN
CFI_PUSH (%esi)
.p2align 4
L(find_zero_in_second_wchar):
and $1 << 5 - 1, %eax
jz L(return_value)
POP (%esi)
test $15 << 4, %al
jnz L(match_second_wchar)
lea -16(%edi), %eax
RETURN
CFI_PUSH (%esi)
.p2align 4
L(find_zero_in_third_or_fourth_wchar):
test $15, %ch
jz L(find_zero_in_fourth_wchar)
and $1 << 9 - 1, %eax
jz L(return_value)
POP (%esi)
test %ah, %ah
jnz L(match_third_wchar)
test $15 << 4, %al
jnz L(match_second_wchar)
lea -16(%edi), %eax
RETURN
CFI_PUSH (%esi)
.p2align 4
L(find_zero_in_fourth_wchar):
POP (%esi)
test %ah, %ah
jnz L(match_third_or_fourth_wchar)
test $15 << 4, %al
jnz L(match_second_wchar)
lea -16(%edi), %eax
RETURN
CFI_PUSH (%esi)
.p2align 4
L(match_second_wchar):
lea -12(%edi), %eax
RETURN
.p2align 4
L(match_third_or_fourth_wchar):
test $15 << 4, %ah
jnz L(match_fourth_wchar)
lea -8(%edi), %eax
RETURN
.p2align 4
L(match_third_wchar):
lea -8(%edi), %eax
RETURN
.p2align 4
L(match_fourth_wchar):
lea -4(%edi), %eax
RETURN
.p2align 4
L(return_null):
xor %eax, %eax
RETURN
.p2align 4
L(prolog_find_zero):
add %ecx, %edi
mov %edx, %ecx
L(prolog_find_zero_1):
test %cl, %cl
jz L(prolog_find_zero_in_third_or_fourth_wchar)
test $15, %cl
jz L(prolog_find_zero_in_second_wchar)
and $1, %eax
jz L(return_null)
lea -16(%edi), %eax
RETURN
.p2align 4
L(prolog_find_zero_in_second_wchar):
and $1 << 5 - 1, %eax
jz L(return_null)
test $15 << 4, %al
jnz L(match_second_wchar)
lea -16(%edi), %eax
RETURN
.p2align 4
L(prolog_find_zero_in_third_or_fourth_wchar):
test $15, %ch
jz L(prolog_find_zero_in_fourth_wchar)
and $1 << 9 - 1, %eax
jz L(return_null)
test %ah, %ah
jnz L(match_third_wchar)
test $15 << 4, %al
jnz L(match_second_wchar)
lea -16(%edi), %eax
RETURN
.p2align 4
L(prolog_find_zero_in_fourth_wchar):
test %ah, %ah
jnz L(match_third_or_fourth_wchar)
test $15 << 4, %al
jnz L(match_second_wchar)
lea -16(%edi), %eax
RETURN
END (wcsrchr)

View File

@@ -28,13 +28,8 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(USE_SSE2)
# define sse2_strlen_atom strlen
# include "sse2-strlen-atom.S"
#else
# include "strlen.S"
#endif
#define MEMCPY bcopy
#define USE_AS_MEMMOVE
#define USE_AS_BCOPY
#include "ssse3-memcpy-atom.S"

View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2010, Intel Corporation
Copyright (c) 2013, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -28,16 +28,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(USE_SSE2)
#define MEMCMP __memcmp16
# include "cache_wrapper.S"
# undef __i686
# define USE_AS_BZERO
# define sse2_memset5_atom bzero
# include "sse2-memset5-atom.S"
/* int __memcmp16(const unsigned short *ptr1, const unsigned short *ptr2, size_t n); */
#else
# include "bzero.S"
#endif
#define USE_UTF16
#define USE_AS_MEMCMP16 1
#include "ssse3-memcmp-atom.S"

View File

@@ -28,8 +28,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "cache.h"
#undef __i686
#ifndef MEMCPY
# define MEMCPY ssse3_memcpy5
# define MEMCPY memcpy
#endif
#ifndef L

View File

@@ -28,13 +28,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(USE_SSSE3)
# define ssse3_strcmp_latest strcmp
# include "ssse3-strcmp-latest.S"
#else
# include "strcmp.S"
#endif
#define MEMCPY memmove
#define USE_AS_MEMMOVE
#include "ssse3-memcpy-atom.S"

View File

@@ -0,0 +1,620 @@
/*
Copyright (c) 2011, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef L
# define L(label) .L##label
#endif
#ifndef cfi_startproc
# define cfi_startproc .cfi_startproc
#endif
#ifndef cfi_endproc
# define cfi_endproc .cfi_endproc
#endif
#ifndef cfi_rel_offset
# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
#endif
#ifndef cfi_restore
# define cfi_restore(reg) .cfi_restore reg
#endif
#ifndef cfi_adjust_cfa_offset
# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
#endif
#ifndef cfi_remember_state
# define cfi_remember_state .cfi_remember_state
#endif
#ifndef cfi_restore_state
# define cfi_restore_state .cfi_restore_state
#endif
#ifndef ENTRY
# define ENTRY(name) \
.type name, @function; \
.globl name; \
.p2align 4; \
name: \
cfi_startproc
#endif
#ifndef END
# define END(name) \
cfi_endproc; \
.size name, .-name
#endif
#define CFI_PUSH(REG) \
cfi_adjust_cfa_offset (4); \
cfi_rel_offset (REG, 0)
#define CFI_POP(REG) \
cfi_adjust_cfa_offset (-4); \
cfi_restore (REG)
#define PUSH(REG) pushl REG; CFI_PUSH (REG)
#define POP(REG) popl REG; CFI_POP (REG)
#ifndef STRCAT
# define STRCAT strcat
#endif
#define PARMS 4
#define STR1 PARMS+4
#define STR2 STR1+4
#ifdef USE_AS_STRNCAT
# define LEN STR2+8
#endif
#define USE_AS_STRCAT
.section .text.ssse3,"ax",@progbits
ENTRY (STRCAT)
PUSH (%edi)
mov STR1(%esp), %edi
mov %edi, %edx
#define RETURN jmp L(StrcpyAtom)
#include "sse2-strlen-atom.S"
L(StrcpyAtom):
mov STR2(%esp), %ecx
lea (%edi, %eax), %edx
#ifdef USE_AS_STRNCAT
PUSH (%ebx)
mov LEN(%esp), %ebx
test %ebx, %ebx
jz L(StrncatExit0)
cmp $8, %ebx
jbe L(StrncpyExit8Bytes)
#endif
cmpb $0, (%ecx)
jz L(Exit1)
cmpb $0, 1(%ecx)
jz L(Exit2)
cmpb $0, 2(%ecx)
jz L(Exit3)
cmpb $0, 3(%ecx)
jz L(Exit4)
cmpb $0, 4(%ecx)
jz L(Exit5)
cmpb $0, 5(%ecx)
jz L(Exit6)
cmpb $0, 6(%ecx)
jz L(Exit7)
cmpb $0, 7(%ecx)
jz L(Exit8)
cmpb $0, 8(%ecx)
jz L(Exit9)
#ifdef USE_AS_STRNCAT
cmp $16, %ebx
jb L(StrncpyExit15Bytes)
#endif
cmpb $0, 9(%ecx)
jz L(Exit10)
cmpb $0, 10(%ecx)
jz L(Exit11)
cmpb $0, 11(%ecx)
jz L(Exit12)
cmpb $0, 12(%ecx)
jz L(Exit13)
cmpb $0, 13(%ecx)
jz L(Exit14)
cmpb $0, 14(%ecx)
jz L(Exit15)
cmpb $0, 15(%ecx)
jz L(Exit16)
#ifdef USE_AS_STRNCAT
cmp $16, %ebx
je L(StrncatExit16)
# define RETURN1 POP (%ebx); POP (%edi); ret; \
CFI_PUSH (%ebx); CFI_PUSH (%edi)
# define USE_AS_STRNCPY
#else
# define RETURN1 POP(%edi); ret; CFI_PUSH(%edi)
#endif
#include "ssse3-strcpy-atom.S"
.p2align 4
L(CopyFrom1To16Bytes):
add %esi, %edx
add %esi, %ecx
POP (%esi)
test %al, %al
jz L(ExitHigh)
test $0x01, %al
jnz L(Exit1)
test $0x02, %al
jnz L(Exit2)
test $0x04, %al
jnz L(Exit3)
test $0x08, %al
jnz L(Exit4)
test $0x10, %al
jnz L(Exit5)
test $0x20, %al
jnz L(Exit6)
test $0x40, %al
jnz L(Exit7)
movlpd (%ecx), %xmm0
movlpd %xmm0, (%edx)
movl %edi, %eax
RETURN1
.p2align 4
L(ExitHigh):
test $0x01, %ah
jnz L(Exit9)
test $0x02, %ah
jnz L(Exit10)
test $0x04, %ah
jnz L(Exit11)
test $0x08, %ah
jnz L(Exit12)
test $0x10, %ah
jnz L(Exit13)
test $0x20, %ah
jnz L(Exit14)
test $0x40, %ah
jnz L(Exit15)
movlpd (%ecx), %xmm0
movlpd 8(%ecx), %xmm1
movlpd %xmm0, (%edx)
movlpd %xmm1, 8(%edx)
movl %edi, %eax
RETURN1
.p2align 4
L(StrncatExit1):
movb %bh, 1(%edx)
L(Exit1):
movb (%ecx), %al
movb %al, (%edx)
movl %edi, %eax
RETURN1
.p2align 4
L(StrncatExit2):
movb %bh, 2(%edx)
L(Exit2):
movw (%ecx), %ax
movw %ax, (%edx)
movl %edi, %eax
RETURN1
.p2align 4
L(StrncatExit3):
movb %bh, 3(%edx)
L(Exit3):
movw (%ecx), %ax
movw %ax, (%edx)
movb 2(%ecx), %al
movb %al, 2(%edx)
movl %edi, %eax
RETURN1
.p2align 4
L(StrncatExit4):
movb %bh, 4(%edx)
L(Exit4):
movl (%ecx), %eax
movl %eax, (%edx)
movl %edi, %eax
RETURN1
.p2align 4
L(StrncatExit5):
movb %bh, 5(%edx)
L(Exit5):
movl (%ecx), %eax
movl %eax, (%edx)
movb 4(%ecx), %al
movb %al, 4(%edx)
movl %edi, %eax
RETURN1
.p2align 4
L(StrncatExit6):
movb %bh, 6(%edx)
L(Exit6):
movl (%ecx), %eax
movl %eax, (%edx)
movw 4(%ecx), %ax
movw %ax, 4(%edx)
movl %edi, %eax
RETURN1
.p2align 4
L(StrncatExit7):
movb %bh, 7(%edx)
L(Exit7):
movl (%ecx), %eax
movl %eax, (%edx)
movl 3(%ecx), %eax
movl %eax, 3(%edx)
movl %edi, %eax
RETURN1
.p2align 4
L(StrncatExit8):
movb %bh, 8(%edx)
L(Exit8):
movlpd (%ecx), %xmm0
movlpd %xmm0, (%edx)
movl %edi, %eax
RETURN1
.p2align 4
L(StrncatExit9):
movb %bh, 9(%edx)
L(Exit9):
movlpd (%ecx), %xmm0
movlpd %xmm0, (%edx)
movb 8(%ecx), %al
movb %al, 8(%edx)
movl %edi, %eax
RETURN1
.p2align 4
L(StrncatExit10):
movb %bh, 10(%edx)
L(Exit10):
movlpd (%ecx), %xmm0
movlpd %xmm0, (%edx)
movw 8(%ecx), %ax
movw %ax, 8(%edx)
movl %edi, %eax
RETURN1
.p2align 4
L(StrncatExit11):
movb %bh, 11(%edx)
L(Exit11):
movlpd (%ecx), %xmm0
movlpd %xmm0, (%edx)
movl 7(%ecx), %eax
movl %eax, 7(%edx)
movl %edi, %eax
RETURN1
.p2align 4
L(StrncatExit12):
movb %bh, 12(%edx)
L(Exit12):
movlpd (%ecx), %xmm0
movlpd %xmm0, (%edx)
movl 8(%ecx), %eax
movl %eax, 8(%edx)
movl %edi, %eax
RETURN1
.p2align 4
L(StrncatExit13):
movb %bh, 13(%edx)
L(Exit13):
movlpd (%ecx), %xmm0
movlpd %xmm0, (%edx)
movlpd 5(%ecx), %xmm0
movlpd %xmm0, 5(%edx)
movl %edi, %eax
RETURN1
.p2align 4
L(StrncatExit14):
movb %bh, 14(%edx)
L(Exit14):
movlpd (%ecx), %xmm0
movlpd %xmm0, (%edx)
movlpd 6(%ecx), %xmm0
movlpd %xmm0, 6(%edx)
movl %edi, %eax
RETURN1
.p2align 4
L(StrncatExit15):
movb %bh, 15(%edx)
L(Exit15):
movlpd (%ecx), %xmm0
movlpd %xmm0, (%edx)
movlpd 7(%ecx), %xmm0
movlpd %xmm0, 7(%edx)
movl %edi, %eax
RETURN1
.p2align 4
L(StrncatExit16):
movb %bh, 16(%edx)
L(Exit16):
movlpd (%ecx), %xmm0
movlpd 8(%ecx), %xmm1
movlpd %xmm0, (%edx)
movlpd %xmm1, 8(%edx)
movl %edi, %eax
RETURN1
#ifdef USE_AS_STRNCPY
CFI_PUSH(%esi)
.p2align 4
L(CopyFrom1To16BytesCase2):
add $16, %ebx
add %esi, %ecx
lea (%esi, %edx), %esi
lea -9(%ebx), %edx
and $1<<7, %dh
or %al, %dh
lea (%esi), %edx
POP (%esi)
jz L(ExitHighCase2)
test $0x01, %al
jnz L(Exit1)
cmp $1, %ebx
je L(StrncatExit1)
test $0x02, %al
jnz L(Exit2)
cmp $2, %ebx
je L(StrncatExit2)
test $0x04, %al
jnz L(Exit3)
cmp $3, %ebx
je L(StrncatExit3)
test $0x08, %al
jnz L(Exit4)
cmp $4, %ebx
je L(StrncatExit4)
test $0x10, %al
jnz L(Exit5)
cmp $5, %ebx
je L(StrncatExit5)
test $0x20, %al
jnz L(Exit6)
cmp $6, %ebx
je L(StrncatExit6)
test $0x40, %al
jnz L(Exit7)
cmp $7, %ebx
je L(StrncatExit7)
movlpd (%ecx), %xmm0
movlpd %xmm0, (%edx)
lea 7(%edx), %eax
cmpb $1, (%eax)
sbb $-1, %eax
xor %cl, %cl
movb %cl, (%eax)
movl %edi, %eax
RETURN1
.p2align 4
L(ExitHighCase2):
test $0x01, %ah
jnz L(Exit9)
cmp $9, %ebx
je L(StrncatExit9)
test $0x02, %ah
jnz L(Exit10)
cmp $10, %ebx
je L(StrncatExit10)
test $0x04, %ah
jnz L(Exit11)
cmp $11, %ebx
je L(StrncatExit11)
test $0x8, %ah
jnz L(Exit12)
cmp $12, %ebx
je L(StrncatExit12)
test $0x10, %ah
jnz L(Exit13)
cmp $13, %ebx
je L(StrncatExit13)
test $0x20, %ah
jnz L(Exit14)
cmp $14, %ebx
je L(StrncatExit14)
test $0x40, %ah
jnz L(Exit15)
cmp $15, %ebx
je L(StrncatExit15)
movlpd (%ecx), %xmm0
movlpd %xmm0, (%edx)
movlpd 8(%ecx), %xmm1
movlpd %xmm1, 8(%edx)
movl %edi, %eax
RETURN1
CFI_PUSH(%esi)
L(CopyFrom1To16BytesCase2OrCase3):
test %eax, %eax
jnz L(CopyFrom1To16BytesCase2)
.p2align 4
L(CopyFrom1To16BytesCase3):
add $16, %ebx
add %esi, %edx
add %esi, %ecx
POP (%esi)
cmp $8, %ebx
ja L(ExitHighCase3)
cmp $1, %ebx
je L(StrncatExit1)
cmp $2, %ebx
je L(StrncatExit2)
cmp $3, %ebx
je L(StrncatExit3)
cmp $4, %ebx
je L(StrncatExit4)
cmp $5, %ebx
je L(StrncatExit5)
cmp $6, %ebx
je L(StrncatExit6)
cmp $7, %ebx
je L(StrncatExit7)
movlpd (%ecx), %xmm0
movlpd %xmm0, (%edx)
movb %bh, 8(%edx)
movl %edi, %eax
RETURN1
.p2align 4
L(ExitHighCase3):
cmp $9, %ebx
je L(StrncatExit9)
cmp $10, %ebx
je L(StrncatExit10)
cmp $11, %ebx
je L(StrncatExit11)
cmp $12, %ebx
je L(StrncatExit12)
cmp $13, %ebx
je L(StrncatExit13)
cmp $14, %ebx
je L(StrncatExit14)
cmp $15, %ebx
je L(StrncatExit15)
movlpd (%ecx), %xmm0
movlpd %xmm0, (%edx)
movlpd 8(%ecx), %xmm1
movlpd %xmm1, 8(%edx)
movb %bh, 16(%edx)
movl %edi, %eax
RETURN1
.p2align 4
L(StrncatExit0):
movl %edi, %eax
RETURN1
.p2align 4
L(StrncpyExit15Bytes):
cmp $9, %ebx
je L(StrncatExit9)
cmpb $0, 9(%ecx)
jz L(Exit10)
cmp $10, %ebx
je L(StrncatExit10)
cmpb $0, 10(%ecx)
jz L(Exit11)
cmp $11, %ebx
je L(StrncatExit11)
cmpb $0, 11(%ecx)
jz L(Exit12)
cmp $12, %ebx
je L(StrncatExit12)
cmpb $0, 12(%ecx)
jz L(Exit13)
cmp $13, %ebx
je L(StrncatExit13)
cmpb $0, 13(%ecx)
jz L(Exit14)
cmp $14, %ebx
je L(StrncatExit14)
movlpd (%ecx), %xmm0
movlpd %xmm0, (%edx)
movlpd 7(%ecx), %xmm0
movlpd %xmm0, 7(%edx)
lea 14(%edx), %eax
cmpb $1, (%eax)
sbb $-1, %eax
movb %bh, (%eax)
movl %edi, %eax
RETURN1
.p2align 4
L(StrncpyExit8Bytes):
cmpb $0, (%ecx)
jz L(Exit1)
cmp $1, %ebx
je L(StrncatExit1)
cmpb $0, 1(%ecx)
jz L(Exit2)
cmp $2, %ebx
je L(StrncatExit2)
cmpb $0, 2(%ecx)
jz L(Exit3)
cmp $3, %ebx
je L(StrncatExit3)
cmpb $0, 3(%ecx)
jz L(Exit4)
cmp $4, %ebx
je L(StrncatExit4)
cmpb $0, 4(%ecx)
jz L(Exit5)
cmp $5, %ebx
je L(StrncatExit5)
cmpb $0, 5(%ecx)
jz L(Exit6)
cmp $6, %ebx
je L(StrncatExit6)
cmpb $0, 6(%ecx)
jz L(Exit7)
cmp $7, %ebx
je L(StrncatExit7)
movlpd (%ecx), %xmm0
movlpd %xmm0, (%edx)
lea 7(%edx), %eax
cmpb $1, (%eax)
sbb $-1, %eax
movb %bh, (%eax)
movl %edi, %eax
RETURN1
#endif
END (STRCAT)

View File

@@ -107,8 +107,12 @@ name: \
sub %esi, %ebp
#endif
#ifndef STRCMP
# define STRCMP strcmp
#endif
.section .text.ssse3,"ax",@progbits
ENTRY (ssse3_strcmp_latest)
ENTRY (STRCMP)
#ifdef USE_AS_STRNCMP
PUSH (%ebp)
#endif
@@ -2271,4 +2275,4 @@ L(less16bytes_sncmp):
ret
#endif
END (ssse3_strcmp_latest)
END (STRCMP)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,34 @@
/*
Copyright (c) 2011, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define STRCAT strncat
#define USE_AS_STRNCAT
#include "ssse3-strcat-atom.S"

View File

@@ -28,13 +28,8 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(USE_SSSE3)
# define MEMCMP memcmp
# include "ssse3-memcmp3-new.S"
#define USE_AS_STRNCMP
#define STRCMP strncmp
#include "ssse3-strcmp-atom.S"
#else
# include "memcmp.S"
#endif

View File

@@ -0,0 +1,33 @@
/*
Copyright (c) 2011, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define USE_AS_STRNCPY
#define STRCPY strncpy
#include "ssse3-strcpy-atom.S"

View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2010, Intel Corporation
Copyright (c) 2011 Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -28,16 +28,87 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(USE_SSSE3)
# include "cache_wrapper.S"
# undef __i686
# define MEMCPY memcpy
# define USE_AS_MEMMOVE
# include "ssse3-memcpy5.S"
#else
# include "memcpy.S"
#ifndef L
# define L(label) .L##label
#endif
#ifndef cfi_startproc
# define cfi_startproc .cfi_startproc
#endif
#ifndef cfi_endproc
# define cfi_endproc .cfi_endproc
#endif
#ifndef cfi_rel_offset
# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
#endif
#ifndef cfi_restore
# define cfi_restore(reg) .cfi_restore reg
#endif
#ifndef cfi_adjust_cfa_offset
# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
#endif
#ifndef ENTRY
# define ENTRY(name) \
.type name, @function; \
.globl name; \
.p2align 4; \
name: \
cfi_startproc
#endif
#ifndef END
# define END(name) \
cfi_endproc; \
.size name, .-name
#endif
#define CFI_PUSH(REG) \
cfi_adjust_cfa_offset (4); \
cfi_rel_offset (REG, 0)
#define CFI_POP(REG) \
cfi_adjust_cfa_offset (-4); \
cfi_restore (REG)
#define PUSH(REG) pushl REG; CFI_PUSH (REG)
#define POP(REG) popl REG; CFI_POP (REG)
#define PARMS 4
#define STR1 PARMS+4
#define STR2 STR1+4
#define USE_AS_WCSCAT
.text
ENTRY (wcscat)
PUSH (%edi)
mov STR1(%esp), %edi
mov %edi, %edx
#define RETURN jmp L(WcscpyAtom)
#include "sse2-wcslen-atom.S"
L(WcscpyAtom):
shl $2, %eax
mov STR2(%esp), %ecx
lea (%edi, %eax), %edx
cmp $0, (%ecx)
jz L(Exit4)
cmp $0, 4(%ecx)
jz L(Exit8)
cmp $0, 8(%ecx)
jz L(Exit12)
cmp $0, 12(%ecx)
jz L(Exit16)
#undef RETURN
#define RETURN POP(%edi); ret; CFI_PUSH(%edi)
#include "ssse3-wcscpy-atom.S"
END (wcscat)

View File

@@ -0,0 +1,652 @@
/*
Copyright (c) 2011, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef USE_AS_WCSCAT
# ifndef L
# define L(label) .L##label
# endif
# ifndef cfi_startproc
# define cfi_startproc .cfi_startproc
# endif
# ifndef cfi_endproc
# define cfi_endproc .cfi_endproc
# endif
# ifndef cfi_rel_offset
# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
# endif
# ifndef cfi_restore
# define cfi_restore(reg) .cfi_restore reg
# endif
# ifndef cfi_adjust_cfa_offset
# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
# endif
# ifndef ENTRY
# define ENTRY(name) \
.type name, @function; \
.globl name; \
.p2align 4; \
name: \
cfi_startproc
# endif
# ifndef END
# define END(name) \
cfi_endproc; \
.size name, .-name
# endif
# define CFI_PUSH(REG) \
cfi_adjust_cfa_offset (4); \
cfi_rel_offset (REG, 0)
# define CFI_POP(REG) \
cfi_adjust_cfa_offset (-4); \
cfi_restore (REG)
# define PUSH(REG) pushl REG; CFI_PUSH (REG)
# define POP(REG) popl REG; CFI_POP (REG)
# define PARMS 4
# define RETURN POP (%edi); ret; CFI_PUSH (%edi)
# define STR1 PARMS
# define STR2 STR1+4
# define LEN STR2+4
.text
ENTRY (wcscpy)
mov STR1(%esp), %edx
mov STR2(%esp), %ecx
cmp $0, (%ecx)
jz L(ExitTail4)
cmp $0, 4(%ecx)
jz L(ExitTail8)
cmp $0, 8(%ecx)
jz L(ExitTail12)
cmp $0, 12(%ecx)
jz L(ExitTail16)
PUSH (%edi)
mov %edx, %edi
#endif
PUSH (%esi)
lea 16(%ecx), %esi
and $-16, %esi
pxor %xmm0, %xmm0
pcmpeqd (%esi), %xmm0
movdqu (%ecx), %xmm1
movdqu %xmm1, (%edx)
pmovmskb %xmm0, %eax
sub %ecx, %esi
test %eax, %eax
jnz L(CopyFrom1To16Bytes)
mov %edx, %eax
lea 16(%edx), %edx
and $-16, %edx
sub %edx, %eax
sub %eax, %ecx
mov %ecx, %eax
and $0xf, %eax
mov $0, %esi
jz L(Align16Both)
cmp $4, %eax
je L(Shl4)
cmp $8, %eax
je L(Shl8)
jmp L(Shl12)
L(Align16Both):
movaps (%ecx), %xmm1
movaps 16(%ecx), %xmm2
movaps %xmm1, (%edx)
pcmpeqd %xmm2, %xmm0
pmovmskb %xmm0, %eax
lea 16(%esi), %esi
test %eax, %eax
jnz L(CopyFrom1To16Bytes)
movaps 16(%ecx, %esi), %xmm3
movaps %xmm2, (%edx, %esi)
pcmpeqd %xmm3, %xmm0
pmovmskb %xmm0, %eax
lea 16(%esi), %esi
test %eax, %eax
jnz L(CopyFrom1To16Bytes)
movaps 16(%ecx, %esi), %xmm4
movaps %xmm3, (%edx, %esi)
pcmpeqd %xmm4, %xmm0
pmovmskb %xmm0, %eax
lea 16(%esi), %esi
test %eax, %eax
jnz L(CopyFrom1To16Bytes)
movaps 16(%ecx, %esi), %xmm1
movaps %xmm4, (%edx, %esi)
pcmpeqd %xmm1, %xmm0
pmovmskb %xmm0, %eax
lea 16(%esi), %esi
test %eax, %eax
jnz L(CopyFrom1To16Bytes)
movaps 16(%ecx, %esi), %xmm2
movaps %xmm1, (%edx, %esi)
pcmpeqd %xmm2, %xmm0
pmovmskb %xmm0, %eax
lea 16(%esi), %esi
test %eax, %eax
jnz L(CopyFrom1To16Bytes)
movaps 16(%ecx, %esi), %xmm3
movaps %xmm2, (%edx, %esi)
pcmpeqd %xmm3, %xmm0
pmovmskb %xmm0, %eax
lea 16(%esi), %esi
test %eax, %eax
jnz L(CopyFrom1To16Bytes)
movaps %xmm3, (%edx, %esi)
mov %ecx, %eax
lea 16(%ecx, %esi), %ecx
and $-0x40, %ecx
sub %ecx, %eax
sub %eax, %edx
mov $-0x40, %esi
L(Aligned64Loop):
movaps (%ecx), %xmm2
movaps 32(%ecx), %xmm3
movaps %xmm2, %xmm4
movaps 16(%ecx), %xmm5
movaps %xmm3, %xmm6
movaps 48(%ecx), %xmm7
pminub %xmm5, %xmm2
pminub %xmm7, %xmm3
pminub %xmm2, %xmm3
lea 64(%edx), %edx
pcmpeqd %xmm0, %xmm3
lea 64(%ecx), %ecx
pmovmskb %xmm3, %eax
test %eax, %eax
jnz L(Aligned64Leave)
movaps %xmm4, -64(%edx)
movaps %xmm5, -48(%edx)
movaps %xmm6, -32(%edx)
movaps %xmm7, -16(%edx)
jmp L(Aligned64Loop)
L(Aligned64Leave):
pcmpeqd %xmm4, %xmm0
pmovmskb %xmm0, %eax
test %eax, %eax
jnz L(CopyFrom1To16Bytes)
pcmpeqd %xmm5, %xmm0
pmovmskb %xmm0, %eax
movaps %xmm4, -64(%edx)
lea 16(%esi), %esi
test %eax, %eax
jnz L(CopyFrom1To16Bytes)
pcmpeqd %xmm6, %xmm0
pmovmskb %xmm0, %eax
movaps %xmm5, -48(%edx)
lea 16(%esi), %esi
test %eax, %eax
jnz L(CopyFrom1To16Bytes)
movaps %xmm6, -32(%edx)
pcmpeqd %xmm7, %xmm0
pmovmskb %xmm0, %eax
lea 16(%esi), %esi
test %eax, %eax
jnz L(CopyFrom1To16Bytes)
mov $-0x40, %esi
movaps %xmm7, -16(%edx)
jmp L(Aligned64Loop)
.p2align 4
L(Shl4):
movaps -4(%ecx), %xmm1
movaps 12(%ecx), %xmm2
L(Shl4Start):
pcmpeqd %xmm2, %xmm0
pmovmskb %xmm0, %eax
movaps %xmm2, %xmm3
test %eax, %eax
jnz L(Shl4LoopExit)
palignr $4, %xmm1, %xmm2
movaps %xmm2, (%edx)
movaps 28(%ecx), %xmm2
pcmpeqd %xmm2, %xmm0
lea 16(%edx), %edx
pmovmskb %xmm0, %eax
lea 16(%ecx), %ecx
movaps %xmm2, %xmm1
test %eax, %eax
jnz L(Shl4LoopExit)
palignr $4, %xmm3, %xmm2
movaps %xmm2, (%edx)
movaps 28(%ecx), %xmm2
pcmpeqd %xmm2, %xmm0
lea 16(%edx), %edx
pmovmskb %xmm0, %eax
lea 16(%ecx), %ecx
movaps %xmm2, %xmm3
test %eax, %eax
jnz L(Shl4LoopExit)
palignr $4, %xmm1, %xmm2
movaps %xmm2, (%edx)
movaps 28(%ecx), %xmm2
pcmpeqd %xmm2, %xmm0
lea 16(%edx), %edx
pmovmskb %xmm0, %eax
lea 16(%ecx), %ecx
test %eax, %eax
jnz L(Shl4LoopExit)
palignr $4, %xmm3, %xmm2
movaps %xmm2, (%edx)
lea 28(%ecx), %ecx
lea 16(%edx), %edx
mov %ecx, %eax
and $-0x40, %ecx
sub %ecx, %eax
lea -12(%ecx), %ecx
sub %eax, %edx
movaps -4(%ecx), %xmm1
L(Shl4LoopStart):
movaps 12(%ecx), %xmm2
movaps 28(%ecx), %xmm3
movaps %xmm3, %xmm6
movaps 44(%ecx), %xmm4
movaps %xmm4, %xmm7
movaps 60(%ecx), %xmm5
pminub %xmm2, %xmm6
pminub %xmm5, %xmm7
pminub %xmm6, %xmm7
pcmpeqd %xmm0, %xmm7
pmovmskb %xmm7, %eax
movaps %xmm5, %xmm7
palignr $4, %xmm4, %xmm5
palignr $4, %xmm3, %xmm4
test %eax, %eax
jnz L(Shl4Start)
palignr $4, %xmm2, %xmm3
lea 64(%ecx), %ecx
palignr $4, %xmm1, %xmm2
movaps %xmm7, %xmm1
movaps %xmm5, 48(%edx)
movaps %xmm4, 32(%edx)
movaps %xmm3, 16(%edx)
movaps %xmm2, (%edx)
lea 64(%edx), %edx
jmp L(Shl4LoopStart)
L(Shl4LoopExit):
movlpd (%ecx), %xmm0
movl 8(%ecx), %esi
movlpd %xmm0, (%edx)
movl %esi, 8(%edx)
POP (%esi)
add $12, %edx
add $12, %ecx
test %al, %al
jz L(ExitHigh)
test $0x01, %al
jnz L(Exit4)
movlpd (%ecx), %xmm0
movlpd %xmm0, (%edx)
movl %edi, %eax
RETURN
CFI_PUSH (%esi)
.p2align 4
L(Shl8):
movaps -8(%ecx), %xmm1
movaps 8(%ecx), %xmm2
L(Shl8Start):
pcmpeqd %xmm2, %xmm0
pmovmskb %xmm0, %eax
movaps %xmm2, %xmm3
test %eax, %eax
jnz L(Shl8LoopExit)
palignr $8, %xmm1, %xmm2
movaps %xmm2, (%edx)
movaps 24(%ecx), %xmm2
pcmpeqd %xmm2, %xmm0
lea 16(%edx), %edx
pmovmskb %xmm0, %eax
lea 16(%ecx), %ecx
movaps %xmm2, %xmm1
test %eax, %eax
jnz L(Shl8LoopExit)
palignr $8, %xmm3, %xmm2
movaps %xmm2, (%edx)
movaps 24(%ecx), %xmm2
pcmpeqd %xmm2, %xmm0
lea 16(%edx), %edx
pmovmskb %xmm0, %eax
lea 16(%ecx), %ecx
movaps %xmm2, %xmm3
test %eax, %eax
jnz L(Shl8LoopExit)
palignr $8, %xmm1, %xmm2
movaps %xmm2, (%edx)
movaps 24(%ecx), %xmm2
pcmpeqd %xmm2, %xmm0
lea 16(%edx), %edx
pmovmskb %xmm0, %eax
lea 16(%ecx), %ecx
test %eax, %eax
jnz L(Shl8LoopExit)
palignr $8, %xmm3, %xmm2
movaps %xmm2, (%edx)
lea 24(%ecx), %ecx
lea 16(%edx), %edx
mov %ecx, %eax
and $-0x40, %ecx
sub %ecx, %eax
lea -8(%ecx), %ecx
sub %eax, %edx
movaps -8(%ecx), %xmm1
L(Shl8LoopStart):
movaps 8(%ecx), %xmm2
movaps 24(%ecx), %xmm3
movaps %xmm3, %xmm6
movaps 40(%ecx), %xmm4
movaps %xmm4, %xmm7
movaps 56(%ecx), %xmm5
pminub %xmm2, %xmm6
pminub %xmm5, %xmm7
pminub %xmm6, %xmm7
pcmpeqd %xmm0, %xmm7
pmovmskb %xmm7, %eax
movaps %xmm5, %xmm7
palignr $8, %xmm4, %xmm5
palignr $8, %xmm3, %xmm4
test %eax, %eax
jnz L(Shl8Start)
palignr $8, %xmm2, %xmm3
lea 64(%ecx), %ecx
palignr $8, %xmm1, %xmm2
movaps %xmm7, %xmm1
movaps %xmm5, 48(%edx)
movaps %xmm4, 32(%edx)
movaps %xmm3, 16(%edx)
movaps %xmm2, (%edx)
lea 64(%edx), %edx
jmp L(Shl8LoopStart)
L(Shl8LoopExit):
movlpd (%ecx), %xmm0
movlpd %xmm0, (%edx)
POP (%esi)
add $8, %edx
add $8, %ecx
test %al, %al
jz L(ExitHigh)
test $0x01, %al
jnz L(Exit4)
movlpd (%ecx), %xmm0
movlpd %xmm0, (%edx)
movl %edi, %eax
RETURN
CFI_PUSH (%esi)
.p2align 4
L(Shl12):
movaps -12(%ecx), %xmm1
movaps 4(%ecx), %xmm2
L(Shl12Start):
pcmpeqd %xmm2, %xmm0
pmovmskb %xmm0, %eax
movaps %xmm2, %xmm3
test %eax, %eax
jnz L(Shl12LoopExit)
palignr $12, %xmm1, %xmm2
movaps %xmm2, (%edx)
movaps 20(%ecx), %xmm2
pcmpeqd %xmm2, %xmm0
lea 16(%edx), %edx
pmovmskb %xmm0, %eax
lea 16(%ecx), %ecx
movaps %xmm2, %xmm1
test %eax, %eax
jnz L(Shl12LoopExit)
palignr $12, %xmm3, %xmm2
movaps %xmm2, (%edx)
movaps 20(%ecx), %xmm2
pcmpeqd %xmm2, %xmm0
lea 16(%edx), %edx
pmovmskb %xmm0, %eax
lea 16(%ecx), %ecx
movaps %xmm2, %xmm3
test %eax, %eax
jnz L(Shl12LoopExit)
palignr $12, %xmm1, %xmm2
movaps %xmm2, (%edx)
movaps 20(%ecx), %xmm2
pcmpeqd %xmm2, %xmm0
lea 16(%edx), %edx
pmovmskb %xmm0, %eax
lea 16(%ecx), %ecx
test %eax, %eax
jnz L(Shl12LoopExit)
palignr $12, %xmm3, %xmm2
movaps %xmm2, (%edx)
lea 20(%ecx), %ecx
lea 16(%edx), %edx
mov %ecx, %eax
and $-0x40, %ecx
sub %ecx, %eax
lea -4(%ecx), %ecx
sub %eax, %edx
movaps -12(%ecx), %xmm1
L(Shl12LoopStart):
movaps 4(%ecx), %xmm2
movaps 20(%ecx), %xmm3
movaps %xmm3, %xmm6
movaps 36(%ecx), %xmm4
movaps %xmm4, %xmm7
movaps 52(%ecx), %xmm5
pminub %xmm2, %xmm6
pminub %xmm5, %xmm7
pminub %xmm6, %xmm7
pcmpeqd %xmm0, %xmm7
pmovmskb %xmm7, %eax
movaps %xmm5, %xmm7
palignr $12, %xmm4, %xmm5
palignr $12, %xmm3, %xmm4
test %eax, %eax
jnz L(Shl12Start)
palignr $12, %xmm2, %xmm3
lea 64(%ecx), %ecx
palignr $12, %xmm1, %xmm2
movaps %xmm7, %xmm1
movaps %xmm5, 48(%edx)
movaps %xmm4, 32(%edx)
movaps %xmm3, 16(%edx)
movaps %xmm2, (%edx)
lea 64(%edx), %edx
jmp L(Shl12LoopStart)
L(Shl12LoopExit):
movl (%ecx), %esi
movl %esi, (%edx)
mov $4, %esi
.p2align 4
L(CopyFrom1To16Bytes):
add %esi, %edx
add %esi, %ecx
POP (%esi)
test %al, %al
jz L(ExitHigh)
test $0x01, %al
jnz L(Exit4)
L(Exit8):
movlpd (%ecx), %xmm0
movlpd %xmm0, (%edx)
movl %edi, %eax
RETURN
.p2align 4
L(ExitHigh):
test $0x01, %ah
jnz L(Exit12)
L(Exit16):
movdqu (%ecx), %xmm0
movdqu %xmm0, (%edx)
movl %edi, %eax
RETURN
.p2align 4
L(Exit4):
movl (%ecx), %eax
movl %eax, (%edx)
movl %edi, %eax
RETURN
.p2align 4
L(Exit12):
movlpd (%ecx), %xmm0
movlpd %xmm0, (%edx)
movl 8(%ecx), %eax
movl %eax, 8(%edx)
movl %edi, %eax
RETURN
CFI_POP (%edi)
.p2align 4
L(ExitTail4):
movl (%ecx), %eax
movl %eax, (%edx)
movl %edx, %eax
ret
.p2align 4
L(ExitTail8):
movlpd (%ecx), %xmm0
movlpd %xmm0, (%edx)
movl %edx, %eax
ret
.p2align 4
L(ExitTail12):
movlpd (%ecx), %xmm0
movlpd %xmm0, (%edx)
movl 8(%ecx), %eax
movl %eax, 8(%edx)
movl %edx, %eax
ret
.p2align 4
L(ExitTail16):
movdqu (%ecx), %xmm0
movdqu %xmm0, (%edx)
movl %edx, %eax
ret
#ifndef USE_AS_WCSCAT
END (wcscpy)
#endif

View File

@@ -0,0 +1,35 @@
/*
Copyright (c) 2011, 2012, 2013 Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define MEMCMP wmemcmp
#define USE_WCHAR
#define USE_AS_WMEMCMP 1
#include "ssse3-memcmp-atom.S"

View File

@@ -1,3 +0,0 @@
/* $OpenBSD: strchr.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */
#define STRCHR
#include "index.S"

View File

@@ -1,64 +0,0 @@
/* $OpenBSD: strcpy.S,v 1.8 2005/08/07 11:30:38 espie Exp $ */
/*
* Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
#include <machine/asm.h>
#if defined(APIWARN)
#APP
.section .gnu.warning.strcpy
.ascii "warning: strcpy() is almost always misused, please use strlcpy()"
#NO_APP
#endif
/*
* NOTE: I've unrolled the loop eight times: large enough to make a
* significant difference, and small enough not to totally trash the
* cache.
*/
ENTRY(strcpy)
movl 4(%esp),%ecx /* dst address */
movl 8(%esp),%edx /* src address */
pushl %ecx /* push dst address */
.align 2,0x90
L1: movb (%edx),%al /* unroll loop, but not too much */
movb %al,(%ecx)
testb %al,%al
jz L2
movb 1(%edx),%al
movb %al,1(%ecx)
testb %al,%al
jz L2
movb 2(%edx),%al
movb %al,2(%ecx)
testb %al,%al
jz L2
movb 3(%edx),%al
movb %al,3(%ecx)
testb %al,%al
jz L2
movb 4(%edx),%al
movb %al,4(%ecx)
testb %al,%al
jz L2
movb 5(%edx),%al
movb %al,5(%ecx)
testb %al,%al
jz L2
movb 6(%edx),%al
movb %al,6(%ecx)
testb %al,%al
jz L2
movb 7(%edx),%al
movb %al,7(%ecx)
addl $8,%edx
addl $8,%ecx
testb %al,%al
jnz L1
L2: popl %eax /* pop dst address */
ret
END(strcpy)

View File

@@ -130,6 +130,8 @@ syscall_src += arch-x86/syscalls/removexattr.S
syscall_src += arch-x86/syscalls/lremovexattr.S
syscall_src += arch-x86/syscalls/__statfs64.S
syscall_src += arch-x86/syscalls/unshare.S
syscall_src += arch-x86/syscalls/swapon.S
syscall_src += arch-x86/syscalls/swapoff.S
syscall_src += arch-x86/syscalls/pause.S
syscall_src += arch-x86/syscalls/gettimeofday.S
syscall_src += arch-x86/syscalls/settimeofday.S
@@ -148,6 +150,9 @@ syscall_src += arch-x86/syscalls/__timer_getoverrun.S
syscall_src += arch-x86/syscalls/__timer_delete.S
syscall_src += arch-x86/syscalls/utimes.S
syscall_src += arch-x86/syscalls/utimensat.S
syscall_src += arch-x86/syscalls/timerfd_create.S
syscall_src += arch-x86/syscalls/timerfd_settime.S
syscall_src += arch-x86/syscalls/timerfd_gettime.S
syscall_src += arch-x86/syscalls/sigaction.S
syscall_src += arch-x86/syscalls/sigprocmask.S
syscall_src += arch-x86/syscalls/__sigsuspend.S

View File

@@ -0,0 +1,21 @@
/* autogenerated by gensyscalls.py */
#include <linux/err.h>
#include <machine/asm.h>
#include <asm/unistd.h>
ENTRY(swapoff)
pushl %ebx
mov 8(%esp), %ebx
movl $__NR_swapoff, %eax
int $0x80
cmpl $-MAX_ERRNO, %eax
jb 1f
negl %eax
pushl %eax
call __set_errno
addl $4, %esp
orl $-1, %eax
1:
popl %ebx
ret
END(swapoff)

View File

@@ -0,0 +1,24 @@
/* autogenerated by gensyscalls.py */
#include <linux/err.h>
#include <machine/asm.h>
#include <asm/unistd.h>
ENTRY(swapon)
pushl %ebx
pushl %ecx
mov 12(%esp), %ebx
mov 16(%esp), %ecx
movl $__NR_swapon, %eax
int $0x80
cmpl $-MAX_ERRNO, %eax
jb 1f
negl %eax
pushl %eax
call __set_errno
addl $4, %esp
orl $-1, %eax
1:
popl %ecx
popl %ebx
ret
END(swapon)

Some files were not shown because too many files have changed in this diff Show More