Commit graph

541 commits

Author SHA1 Message Date
Serban Constantinescu
7f70c9b64e AArch64: Fix uses of stack size for 32/64bit libc builds
This patch fixes stack size uses to size_t.

Change-Id: I0671c85ddb1c1aceaf9440a7c73c21fe528653fa
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
2013-10-22 12:01:29 -07:00
Elliott Hughes
c7e9b23317 Fix sigaction(3) for 64-bit.
Also clean up <signal.h> and revert the hacks that were necessary
for 64-bit in linker/debugger.cpp until now.

Change-Id: I3b0554ca8a49ee1c97cda086ce2c1954ebc11892
2013-10-17 11:36:55 -07:00
Elliott Hughes
b2386fed55 am 4346bd9f: am bffe261a: Merge "Sort the syscalls.mk files, give all generated files the same header."
* commit '4346bd9fbcfe4144df7ac0e920bdda274d523fc4':
  Sort the syscalls.mk files, give all generated files the same header.
2013-10-16 16:33:50 -07:00
Elliott Hughes
6b9321b858 am d6e117b6: am 1f29c2f5: Merge "Switch sigpending over to rt_sigpending."
* commit 'd6e117b64bdfbf8d793eb59ea9604b806608ec75':
  Switch sigpending over to rt_sigpending.
2013-10-16 16:09:42 -07:00
Elliott Hughes
103ccde8fe Sort the syscalls.mk files, give all generated files the same header.
No non-comment changes to the .S files.

Change-Id: Iafcfd004c3ea92b64268f80ab16df615b97cefac
2013-10-16 14:27:59 -07:00
Elliott Hughes
40d105ccb3 Switch sigpending over to rt_sigpending.
Change-Id: I7b28984796b5fb343cfbcc47e0afc3a84293d417
2013-10-16 14:07:01 -07:00
Elliott Hughes
afaebc3fef am 87fc78de: am 608c65f6: Merge "Fix sigsuspend to use rt_sigsuspend on all platforms."
* commit '87fc78de6c869d0403ccdd2e756ec1f5d456f3d3':
  Fix sigsuspend to use rt_sigsuspend on all platforms.
2013-10-15 18:20:32 -07:00
Elliott Hughes
1f5af926fa Fix sigsuspend to use rt_sigsuspend on all platforms.
Change-Id: I981c1a66d35480d4457a0a08a1b042dac94daa5b
2013-10-15 18:15:19 -07:00
Elliott Hughes
f2a760dca7 am a85606e1: am c100a100: Merge "\'Avoid confusing "read prevented write" log messages\' 2."
* commit 'a85606e1563c2153bea3c73dfe4ca1588e778f22':
  'Avoid confusing "read prevented write" log messages' 2.
2013-10-15 17:38:17 -07:00
Elliott Hughes
68b67113a4 'Avoid confusing "read prevented write" log messages' 2.
This time it's assembler.

Change-Id: Iae6369833b8046b8eda70238bb4ed0cae64269ea
2013-10-15 17:17:05 -07:00
Christopher Ferris
289c460c55 am ac6bc319: Remove new aligned memcpy path for cortex-a15.
* commit 'ac6bc31942e58c8893c0695d9766d0f3e39335fe':
  Remove new aligned memcpy path for cortex-a15.
2013-10-15 16:17:14 -07:00
Christopher Ferris
ac6bc31942 Remove new aligned memcpy path for cortex-a15.
For some reason the new cortex-a15 memcpy code from ARM is really bad
for really large copies. This change forces us to go down the old path
for all copies.

All of my benchmarks show the new version is faster for large copies, but
something is going on that I don't understand.

Bug: 10838353
Change-Id: I01c16d4a2575e76f4c69862c6f78fd9024eb3fb8
2013-10-15 14:54:02 -07:00
Christopher Ferris
d77ff4f423 am 76d78dc0: am dc9d8d05: Merge "Modify prefetch for krait memcpy."
* commit '76d78dc0441ba982438ef613a8d6f2f65c6834e0':
  Modify prefetch for krait memcpy.
2013-10-15 14:19:27 -07:00
Elliott Hughes
4681f8244e am 5b3f1d8b: am 22b83da4: Merge "Clean up the sigprocmask/pthread_sigmask implementation."
* commit '5b3f1d8b3a6a1caf059dc376e4967a27ddd57dac':
  Clean up the sigprocmask/pthread_sigmask implementation.
2013-10-15 14:16:02 -07:00
Christopher Ferris
dc9d8d050a Merge "Modify prefetch for krait memcpy." 2013-10-15 21:12:31 +00:00
Christopher Ferris
c3c58fb560 Modify prefetch for krait memcpy.
I originally modified the krait mainloop prefetch from cacheline * 8 to * 2.
This causes a perf degradation for copies bigger than will fit in the cache.
Fixing this back to the original * 8. I tried other multiples, but * 8 is th
sweet spot on krait.

Bug: 11221806

Change-Id: I1f75fad6440f7417e664795a6e7b5616f6a29c45
2013-10-15 12:10:06 -07:00
Elliott Hughes
19e62325c2 Clean up the sigprocmask/pthread_sigmask implementation.
Let's have both use rt_sigprocmask, like in glibc. The 64-bit ABIs
can share the same code as the 32-bit ABIs.

Also, let's test the return side of these calls, not just the
setting.

Bug: 11069919
Change-Id: I11da99f85b5b481870943c520d05ec929b15eddb
2013-10-15 11:23:57 -07:00
Elliott Hughes
2d38f0c1c7 am 21d70d5f: am 39385aa7: Merge "Clean up the cpuacct cruft."
* commit '21d70d5fd8ff2823a6879d59c7d5a8d6c3e0ce8b':
  Clean up the cpuacct cruft.
2013-10-09 21:28:51 -07:00
Elliott Hughes
232163cf70 Clean up the cpuacct cruft.
Change-Id: I6ed63af8dfc2368e211420389fa8af4d5dc0908f
2013-10-09 17:35:36 -07:00
Elliott Hughes
1cdc9fe6d5 am 8826ba8a: am bc545e8a: Merge "Fix x86_64 build, clean up intermediate libraries."
* commit '8826ba8ab6922927bdac2466d2903916d5806a06':
  Fix x86_64 build, clean up intermediate libraries.
2013-10-09 16:35:46 -07:00
Elliott Hughes
eb847bc866 Fix x86_64 build, clean up intermediate libraries.
The x86_64 build was failing because clone.S had a call to __thread_entry which
was being added to a different intermediate .a on the way to making libc.so,
and the linker couldn't guarantee statically that such a relocation would be
possible.

  ld: error: out/target/product/generic_x86_64/obj/STATIC_LIBRARIES/libc_common_intermediates/libc_common.a(clone.o): requires dynamic R_X86_64_PC32 reloc against '__thread_entry' which may overflow at runtime; recompile with -fPIC

This patch addresses that by ensuring that the caller and callee end up in the
same intermediate .a. While I'm here, I've tried to clean up some of the mess
that led to this situation too. In particular, this removes libc/private/ from
the default include path (except for the DNS code), and splits out the DNS
code into its own library (since it's a weird special case of upstream NetBSD
code that's diverged so heavily it's unlikely ever to get back in sync).

There's more cleanup of the DNS situation possible, but this is definitely a
step in the right direction, and it's more than enough to get x86_64 building
cleanly.

Change-Id: I00425a7245b7a2573df16cc38798187d0729e7c4
2013-10-09 16:00:17 -07:00
Elliott Hughes
42b618cffe am 58b8f225: am 5cf1f229: Merge "pthread_exit should call __NR_exit with status 0."
* commit '58b8f2256637c5b1e24b568b699fb3aa6cf0ca96':
  pthread_exit should call __NR_exit with status 0.
2013-10-08 15:06:49 -07:00
Elliott Hughes
c4c6e192ac pthread_exit should call __NR_exit with status 0.
We shouldn't have been passing the bottom 32 bits of the address used
for pthread_join to the kernel.

Change-Id: I487e5002d60c27adba51173719213abbee0f183f
2013-10-08 14:48:05 -07:00
Elliott Hughes
9258c7b23e am b7d77a9e: am 56777421: Merge "Add arch-x86_64/include/machine."
* commit 'b7d77a9eb1effd5f0472dff14a8fe77d9da2c7a2':
  Add arch-x86_64/include/machine.
2013-10-04 16:21:25 -07:00
Elliott Hughes
72645164b6 Add arch-x86_64/include/machine.
This is basically the other half of I5de76f6c46ac87779f207d568a86bb453e2414de
from Pavel Chupin <pavel.v.chupin@intel.com>, but taking the exact upstream
_types.h instead of the modified version. (I was confused when I suggested
otherwise.)

I've also cleaned up the internal_types.h situation; we weren't gaining
anything from these empty files, and there is no upstream internal_types.h
for x86_64.

Change-Id: I802a9a6a8df1c979e820659212c75a47c2ef392e
2013-10-04 16:10:13 -07:00
Nick Kralevich
7909bd19ab am 9da8b682: am c417d0a5: Merge "Make error messages even better!"
* commit '9da8b6829cb8febb70af46761b7f2ca19e6498ce':
  Make error messages even better!
2013-10-04 12:02:57 -07:00
Nick Kralevich
6861c6f85e Make error messages even better!
Change-Id: I72bd1eb1d526dc59833e5bc3c636171f7f9545af
2013-10-04 11:43:30 -07:00
Elliott Hughes
be7b6408b3 am 6d923d49: am 14102932: Merge "Move common arch-* code to arch-common directory"
* commit '6d923d497373c160f6fdddd42f5ed56e7bf0923a':
  Move common arch-* code to arch-common directory
2013-10-04 09:58:23 -07:00
Elliott Hughes
141029327c Merge "Move common arch-* code to arch-common directory" 2013-10-03 23:17:58 +00:00
Christopher Ferris
1a086a52d3 am 270c52da: am 1fe477fc: Merge "Add dependencies on included makefiles."
* commit '270c52da0db68c6961eb576b67adc0c41c418763':
  Add dependencies on included makefiles.
2013-10-03 14:57:21 -07:00
Christopher Ferris
d7a632948d Add dependencies on included makefiles.
Bug: 11050594

Merge from internal master.

(cherry-picked from f389284e86)

Change-Id: I2b3e38329a09d26c16870906f9ed1257e2a9dbc8
2013-10-03 14:17:14 -07:00
Christopher Ferris
bdc610aba5 am dc7f8ddc: am 6088047a: Merge "Remove dead files."
* commit 'dc7f8ddc227e833b889eb1eedc16b9b5827fc127':
  Remove dead files.
2013-10-03 13:26:38 -07:00
Christopher Ferris
fc4d70fe54 Remove dead files.
memcpy.a15.S/strcmp.a15.S files were submitted by ARM for use as the basis
for the memcpy/strcmp implementations in cortex-a15.

memset.S was moved in to the generic directory.

NOTE: memcpy.a9.S was submitted by Linaro to be the basis for the memcpy
for cortex-a9/cortex-a15 but has not been incorporated yet.

Bug: 10971279

Merge from internal master.

(cherry-picked from 48fc3e8b9f)

Change-Id: I8f9297578990d517f004e4e8840e2b2cbd5a47d8
2013-10-03 12:35:56 -07:00
Pavel Chupin
b49c17c2bf Move common arch-* code to arch-common directory
Will be helpful on adding x86_64

Change-Id: I96cf6fc7912c02f289c75f07ae0079c32d69173f
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2013-10-03 11:14:33 +04:00
Christopher Ferris
de7ed18df0 am 0292c1c8: am 3901b1bd: Merge "Remove the __ARM_FEATURE_DSP check."
* commit '0292c1c81dfed23a32d46fb0b089b7eccb87e21e':
  Remove the __ARM_FEATURE_DSP check.
2013-10-02 23:27:06 -07:00
Christopher Ferris
aec1b3540a Remove the __ARM_FEATURE_DSP check.
The check for __ARM_FEATURE_DSP being defined is pointless since it
is always defined.

Bug: 10971279

Merge from internal master.

(cherry-picked from d2642fa70c)

Change-Id: If23ab3271f4da0c38cd531ffdc9a7e5eed6ec5dc
2013-10-02 23:14:01 -07:00
Nick Kralevich
670f372470 am b6201932: am 2c701a1b: Merge "libc: don\'t export unnecessary symbols"
* commit 'b6201932838c46a567e3411047719fd5c2797e96':
  libc: don't export unnecessary symbols
2013-10-02 17:03:42 -07:00
Nick Kralevich
32bbf8a63b libc: don't export unnecessary symbols
Symbols associated with the internal implementation of memcpy
like routines should be private.

Change-Id: I2b1d1f59006395c29d518c153928437b08f93d16
2013-10-02 16:54:58 -07:00
Elliott Hughes
5825f979b7 am 88f29444: am 7b538021: Merge "Make it easier to add syscalls for another architecture."
* commit '88f2944421839b725e02e97c62d119c9e608ec58':
  Make it easier to add syscalls for another architecture.
2013-09-26 09:02:46 -07:00
Elliott Hughes
d612165c67 Make it easier to add syscalls for another architecture.
Much of the per-architecture duplication can be removed, so let's do so
before we add the 64-bit architectures.

Change-Id: Ieb796503c8e5353ea38c3bab768bb9a690c9a767
2013-09-26 08:57:17 -07:00
Christopher Ferris
16e185c908 __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

Merge from internal master.

(cherry-picked from 883ef2499c)

Change-Id: Id9a96b549435f5d9b61dc132cf1082e0e30889f5
2013-09-20 20:12:09 -07:00
Christopher Ferris
a57c9c084b 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

Merge from internal master.

(cherry-picked from 05332f2ce7)

Change-Id: Ibc919b117cfe72b9ae97e35bd48185477177c5ca
2013-09-20 18:59:58 -07:00
Christopher Ferris
bd7fe1d3c4 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

Merge from internal master.

(cherry-picked from 5f7ccea3ff)

Change-Id: If48a216203216a643807f5d61906015984987189
2013-09-20 13:49:38 -07:00
Elliott Hughes
e74f77f92d am 48a909c9: am aad3c52e: Merge "Ensure we have the off64_t variant of every function that takes an off_t."
* commit '48a909c9fd6dbe9be5655ad172d1083fa69c4107':
  Ensure we have the off64_t variant of every function that takes an off_t.
2013-09-19 17:43:01 -07:00
Elliott Hughes
b4f7616fd6 Ensure we have the off64_t variant of every function that takes an off_t.
Change-Id: Ib2eee0cf13162be3b62559b84e90c6dcf5aab1c3
2013-09-19 16:27:24 -07:00
Christopher Ferris
2e7a8b44c2 resolved conflicts for merge of 883ef249 to klp-dev-plus-aosp
Change-Id: I1e2bd03a0cb5a0ab191c525d1574377bc7fd90ab
2013-09-10 19:49:04 -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
Christopher Ferris
5cb0436930 am 1a88ca08: am 98c726ec: Merge "Add the dl_iterate_phdr function to libdl for arm."
* commit '1a88ca08046ea510bfc8d3de6875537f124b3ce3':
  Add the dl_iterate_phdr function to libdl for arm.
2013-09-06 10:57:40 -07:00
Christopher Ferris
24053a461e Add the dl_iterate_phdr function to libdl for arm.
Bug: 8410085

Merge from internal master.

(cherry-picked from cb491bc66d)

Change-Id: I94ed51bc5d4c626df7552c0e85c31ccee2d6568f
2013-09-06 09:53:54 -07:00
Christopher Ferris
153ec2a76f am 49c0d471: Merge "Fix all debug directives." into klp-dev
* commit '49c0d471a8ba9ed32e7fdadb7e4ea6118b4b4af4':
  Fix all debug directives.
2013-08-29 14:23:06 -07: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
Nick Kralevich
f6186e9592 am 1278ae38: am 22f5ef6b: Merge "Delete CAVEATS / fix spelling."
* commit '1278ae38366102369b5a35152f2213426a148512':
  Delete CAVEATS / fix spelling.
2013-08-27 17:11:06 -07:00
Nick Kralevich
bdbdbb8319 Delete CAVEATS / fix spelling.
Change-Id: I0ed504271b7c2e4434d0d5f53bc10335c8cf7b5b
2013-08-27 17:05:19 -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
Christopher Ferris
5f45d583b0 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

(cherry-picked from 2be91915dc)

Change-Id: Ia407b74d3287d0b6af0139a90b6eb3bfaebf2155
2013-08-15 11:13:39 -07:00
Christopher Ferris
59a13c122e Optimize __memset_chk, __memcpy_chk. DO NOT MERGE.
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

Merge from internal master.

(cherry-picked from 7c860db074)

Change-Id: I916ad305e4001269460ca6ebd38aaa0be8ac7f52
2013-08-14 18:14:43 -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
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
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
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
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
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
Ben Cheng
772b797b7b Update the comments to reflect the current status.
Change-Id: I3a6348b568230fe8b21d121e5b8d30561a9703c2
2013-08-02 15:53:18 -07: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
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
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
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
62d6b7526a am 2a18ea14: am f152e386: Merge "EABI syscall cleanup."
* commit '2a18ea1462cf65cc51bfcb1a1c46972ee5af1d01':
  EABI syscall cleanup.
2013-07-16 15:36:11 -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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
9e1905794b Use bl instead of blx to support interworking properly.
BUG: 9227177
Change-Id: I742c2f2ecbe332f9c9743e3f4bde8de791a1d289
2013-05-31 14:25:48 -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
Rom Lemarchand
22bda4bd67 libc/arm: add cortex-a8 cpu variant
Change-Id: I30e8dd6d4b2e7889aea8f5ed21182a5941bfb489
2013-05-15 20:13:28 -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
Todd Poynor
4200e6203a libc: add timerfd calls
(cherry-pick of 04c0ac14a49e0969333008a9522b64046d58fbdc.)

Change-Id: I06d0b6c2a8781602362b81f48faf1cca76b9ec05
2013-05-14 14:45:02 -07:00
Todd Poynor
04c0ac14a4 libc: add timerfd calls
Change-Id: Id63b907266d5b87c7422a51d393a1430551ca33d
2013-05-13 12:06:15 -07: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
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
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
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
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
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
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
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
Dima Zavin
369f92349f Merge "libc/arm: add cortex-a7 cpu variant" into jb-mr2-dev 2013-03-25 19:42:28 +00:00
Dima Zavin
0c973d7049 libc/arm: add cortex-a7 cpu variant
Change-Id: I541d665805ea69ca96bb6a5f4d50e56287f8c08c
Signed-off-by: Dima Zavin <dima@android.com>
2013-03-23 01:38:22 -07:00
Elliott Hughes
cda62094ef Use the correct names for the __ARM_NR_* syscalls.
This lets us move all the ARM syscall stubs over to the kernel <asm/unistd.h>.
Our generated <sys/linux-syscalls.h> is now unused, but I'll remove that in a
later change.

Change-Id: Ie5ff2cc4abce1938576af7cbaef615a79c7f310d
2013-03-22 13:53:43 -07:00
Elliott Hughes
8794ece296 Replace unnecessary ARM uses of <sys/linux-syscalls.h> with <asm/unistd.h>.
For some reason, socketcalls.c was only being compiled for ARM, where
it makes no sense. For x86 we generate stubs for the socket functions
that use __NR_socketcall directly.

Change-Id: I84181e6183fae2314ae3ed862276eba82ad21e8e
2013-03-21 23:07:11 -07:00
Elliott Hughes
5c2772f59d The SYS_ constants should cover all __NR_ values.
<sys/linux-syscalls.h> only contains constants for the syscalls
we're generating stubs for. We want all the syscalls available
on the architecture in question.

Keep using <sys/linux-syscalls.h> on ARM for now because the
__NR_ARM_set_tls and __NR_ARM_cacheflush values aren't in <asm/unistd.h>.

Change-Id: I66683950d87d9b18d6107d0acc0ed238a4496f44
2013-03-21 22:26:20 -07:00
Elliott Hughes
17a8b0db63 Expose wait4 as wait4 rather than __wait4.
This helps strace(1) compile with one fewer hack.

Change-Id: I5296d0cfec5546709cda990abd705ad33d7c4626
2013-03-21 16:14:06 -07:00
Christopher Ferris
31dea25b8b 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

Merge from internal master.

(cherry-picked from commit a9a5870d16)

Change-Id: I4c2b98f8a50804fb98ab67f75e9d660f1315a144
2013-03-20 14:33:54 -07:00
Elliott Hughes
8f2a5a0b40 Clean up internal libc logging.
We only need one logging API, and I prefer the one that does no
allocation and is thus safe to use in any context.

Also use O_CLOEXEC when opening the /dev/log files.

Move everything logging-related into one header file.

Change-Id: Ic1e3ea8e9b910dc29df351bff6c0aa4db26fbb58
2013-03-15 16:12:58 -07:00
Elliott Hughes
ec706c24ac Merge "Use the kernel's MAX_ERRNO in the syscall stubs." 2013-03-13 00:44:33 +00:00
Elliott Hughes
9aceab5015 Use the kernel's MAX_ERRNO in the syscall stubs.
Bug: http://code.google.com/p/android/issues/detail?id=53104
Change-Id: Iaabf7025b153e96dc5eca231a33a32d4cb7d8116
2013-03-12 17:43:58 -07:00
Christopher Ferris
04954a43b3 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

Merge from internal master (acdde8c1cf).

Change-Id: I04f3d0715104fab618e1abf7cf8f7eec9bec79df
2013-03-12 14:06:08 -07:00
Ben Cheng
14283004f5 Add stack unwinding directives to memcpy.
Also include some Android specific header files.

Change-Id: Idbcbd43458ba945ca8c61bfbc04ea15fc0ae4e00
2013-03-01 14:56:04 -08:00
Greta Yorsh
eb149e954e Adding strcmp tuned for Cortex-A15.
The attached patch provides a new implementation of strcmp for ARM,
using LDRD instead of LDR whenever possible.

For older architectures that do not support LDRD, this implementation
uses the same algorithm as before.

Testing and benchmarking:
* Validation: successfully passes a test that compares different strings
of length 1-128 and offsets 0-8 from a word boundary. Checked on
qemu/A15/A9, ARM/Thumb mode, Big/Little Endian.
* Integration with gcc: no regression on qemu for arm-none-eabi --with-cpu
a15/a9 --with-mode arm/thumb.

Change-Id: I9e230e1b99dbdc9119b69ee858a89038c516a4ea
Signed-off-by: Vassilis Laganakos <vasileios.laganakos@arm.com>
2013-03-01 10:41:01 +00:00
Greta Yorsh
5b349fc22e Adding memcpy tuned for Cortex-A15.
The strategy for large block sizes is LDRD and STRD with offset addressing,
where the main loop copies 64 bytes in every iteration, (i.e., 8 calls to
LDRD and STRD pairs), interleaving load and stores (i.e., the pairs of LDRD
and STRD of the same data are consecutive instructions), and the writeback
of an updated address is a separate instruction, which allows us to write
back the accumulated update once per iteration.

This strategy is implemented in memcpy.S. In some configurations, a plain
version of memcpy (included from memcpy-stub.c) is used instead of the
optimized one.

Validation:
* Correctness: checked memcpy using a test harness for block sizes
ranging between 1 to 128, and source and destination buffers alignment
ranging in { 0,1,2,3,4,8,12 } bytes each.
* Performance: benchmarking on Cortex-A15 FPGA indicates that this strategy
is better for A15 than the strategy used by glibc and even slightly better
than using NEON. Benchmarking on Cortex-A9 bare metal and Linux shows
that the proposed strategy is reasonable: not as fast as the version of
memcpy from glibc (which is the best open source strategy for A9), but
comparable with csl and bionic.
* Integration with GCC: no regression for arm-none-eabi --with-cpu
cortex-a15 and cortex-a9.

Change-Id: Ied56354d8992c62ae3e02d582a2bd55585d814b9
Signed-off-by: Vassilis Laganakos <vasileios.laganakos@arm.com>
2013-03-01 10:40:50 +00:00
Elliott Hughes
40eabe24e4 Fix the pthread_setname_np test.
Fix the pthread_setname_np test to take into account that emulator kernels are
so old that they don't support setting the name of other threads.

The CLONE_DETACHED thread is obsolete since 2.5 kernels.

Rename kernel_id to tid.

Fix the signature of __pthread_clone.

Clean up the clone and pthread_setname_np implementations slightly.

Change-Id: I16c2ff8845b67530544bbda9aa6618058603066d
2013-02-15 12:08:59 -08:00
Elliott Hughes
6719500dbd Add a bunch more missing ENDs to assembler routines.
This isn't everything; I've missed out those x86 files that are

Change-Id: Idb7bb1a68796d6c0b70ea2b5c3300e49da6c62d2
2013-02-13 15:12:32 -08:00
Elliott Hughes
73964c592c Everyone has CLZ.
Even armv5 had CLZ.

Change-Id: I51bc8d1166d09940fd0d3f4c7717edf26977082c
2013-02-13 14:40:48 -08:00
Elliott Hughes
9f878c2fca Really set errno if __pthread_clone fails.
If r0 == 0, we're the child. If r0 > 0, we're the parent.
Otherwise set errno.

The __bionic_clone code I copy & pasted was wrong. This patch
fixes both.

Bug: 3461078
Change-Id: Ibb7d6cc7e54e666841f2f0dc59a141a0b31982e4
2013-02-12 16:07:06 -08:00
Elliott Hughes
d7a3a403c1 Use ENTRY/END in ARM __get_sp.
Change-Id: If2f159b266f5fa4ad9d188a17d4cd318b605e446
2013-02-11 16:58:34 -08:00
Elliott Hughes
5e3fc43dde Fix __pthread_clone on ARM to set errno on failure.
MIPS and x86 appear to have been correct already.

(Also fix unit tests that ASSERT_EQ with errno so that the
arguments are in the retarded junit order.)

Bug: 3461078
Change-Id: I2418ea98927b56e15b4ba9cfec97f5e7094c6291
2013-02-11 16:39:10 -08:00
Elliott Hughes
f94fd3ccc6 Clean up ARM assembler files to use ENTRY/END.
We also don't need legacy syscall support (non-"swi 0").

Change-Id: Id1012e8ca18bf13f3f4e42200f39ba0e2e632cbf
2013-02-11 15:36:59 -08:00
Elliott Hughes
646e058136 Fix x86 build, remove void* arithmetic.
Change-Id: Idc7f14af2e094ac33de315e808176237af063bb8
2013-02-07 12:16:10 -08:00
Elliott Hughes
42b2c6a5ee Clean up the argc/argv/envp/auxv handling.
There's now only one place where we deal with this stuff, it only needs to
be parsed once by the dynamic linker (rather than by each recipient), and it's
now easier for us to get hold of auxv data early on.

Change-Id: I6314224257c736547aac2e2a650e66f2ea53bef5
2013-02-07 11:44:21 -08:00
Elliott Hughes
a0ee07829a Upgrade libm.
This brings us up to date with FreeBSD HEAD, fixes various bugs, unifies
the set of functions we support on ARM, MIPS, and x86, fixes "long double",
adds ISO C99 support, and adds basic unit tests.

It turns out that our "long double" functions have always been broken
for non-normal numbers. This patch fixes that by not using the upstream
implementations and just forwarding to the regular "double" implementation
instead (since "long double" on Android is just "double" anyway, which is
what BSD doesn't support).

All the tests pass on ARM, MIPS, and x86, plus glibc on x86-64.

Bug: 3169850
Bug: 8012787
Bug: https://code.google.com/p/android/issues/detail?id=6697
Change-Id: If0c343030959c24bfc50d4d21c9530052c581837
2013-02-01 14:51:19 -08:00
Elliott Hughes
a6a3ac5924 Use the NetBSD <sys/exec_elf.h>.
Replace a kernel header file dependency with files from NetBSD.
They're more complete, and ELF is ELF, whether you're on Linux or a BSD.

Bug: 7973611
Change-Id: I83ee719e7efdf432ec2ddbe8be271d05b2f558d7
2013-01-29 15:02:50 -08:00
Elliott Hughes
6a94cb748b Merge "arm syscall : for eabi call_default don't use stack" 2013-01-25 21:57:58 +00:00
Elliott Hughes
1e980b6bc8 Fix the duplication in the debugging code.
We had two copies of the backtrace code, and two copies of the
libcorkscrew /proc/pid/maps code. This patch gets us down to one.

We also had hacks so we could log in the malloc debugging code.
This patch pulls the non-allocating "printf" code out of the
dynamic linker so everyone can share.

This patch also makes the leak diagnostics easier to read, and
makes it possible to paste them directly into the 'stack' tool (by
using relative PCs).

This patch also fixes the stdio standard stream leak that was
causing a leak warning every time tf_daemon ran.

Bug: 7291287
Change-Id: I66e4083ac2c5606c8d2737cb45c8ac8a32c7cfe8
2013-01-18 22:20:06 -08:00
Matthieu Castet
faa0fdb119 arm syscall : for eabi call_default don't use stack
In the default case, we don't need to use the stack, we can save r7 with
ip register (that what does eglibc).

This allow to fix vfork data corruption
(see 3884bfe966), because vfork now don't
use the stack.
2013-01-16 14:53:37 +01:00
Ben Cheng
35f5385aa5 Add __aeabi_idiv to the dummy reference list.
If the platform code is compiled with -mcpu=cortex-a15, then without this
change prebuilt libraries built against -march=armv7 cannot resolve the
dependency on __aeabi_idiv (provided by libgcc.a).

Bug: 7961327

cherry-picked from internal master.

Change-Id: I8fe59a98eb53d641518b882523c1d6a724fb7e55
2013-01-14 15:33:40 -08:00
Rom Lemarchand
a4b2dc016f Add signalfd call to bionic
Add signalfd() call to bionic.

Adding the signalfd call was done in 3 steps:
- add signalfd4 system call (function name and syscall
  number) to libc/SYSCALLS.TXT
- generate all necessary headers by calling
  libc/tools/gensyscalls.py. This patch is adding
  the generated files since the build system
  does not call gensyscalls.py.
- create the signalfd wrapper in signalfd.cpp and add
  the function prototype to sys/signalfd.h

(cherry-pick of 0c11611c11, modified to
work with older versions of GCC still in use on some branches.)

Change-Id: I4c6c3f12199559af8be63f93a5336851b7e63355
2013-01-10 13:14:46 -08:00
Elliott Hughes
4fa35d8ae8 Fix <endian.h> and <sys/endian.h>.
Previously we'd been relying on getting the machine-specific <endian.h>
instead of the top-level <endian.h>, and <sys/endian.h> was basically broken.
Now, with this patch and the previous patch we should have <endian.h>
and <sys/endian.h> behaving the same. This is basically how NetBSD's endian.h
works, and was probably how ours was originally intended to work.

Bug: http://code.google.com/p/android/issues/detail?id=39824
Change-Id: I71de5a507e633de166013a658b5764df9e1aa09c
2012-12-11 16:17:33 -08:00
Elliott Hughes
3975cec694 Remove (near-)duplicate definitions of size_t and ssize_t.
The near duplicates upset fussier compilers that insist that
typedefs be exactly the same, but the fix isn't to make all
copies identical...

Change-Id: Icfdace41726f36ec33c9ae919dbb5a54d3529cc9
2012-11-29 17:25:23 -08:00
Elliott Hughes
b15c58bb0f Clean up _BYTE_ORDER definitions for better x86 portability.
We'd manually hacked _BYTE_ORDER into the arm and mips "_types.h" headers,
but not into the x86 one. Judging by upstream, _BYTE_ORDER should be in
the "endian.h" headers instead, so let's uniformly do that.

I've also ironed out some of the other differences between the different
architectures' header files too.

Bug: http://code.google.com/p/android/issues/detail?id=39824
Change-Id: I19d3af7ffd74e1c02b1b6886aec0f0d11f44ab8d
2012-11-27 14:18:04 -08:00
Henrik Smiding
884e4f839b Add optimized version of memset for Cortex A9
Adds new code to function memset, optimized for Cortex A9.

Copyright (C) ST-Ericsson SA 2010

Added neon implementation

Author: Henrik Smiding henrik.smiding@stericsson.com for ST-Ericsson.

Change-Id: Id3c87767953439269040e15bd30a27aba709aef6
Signed-off-by: Christian Bejram <christian.bejram@stericsson.com>
2012-11-09 15:05:32 -08:00
Henrik Smiding
6d0bcdc832 Add optimized version of memcpy for Cortex A9
Adds new code to memcpy function, optimized for Cortex A9.
Adds new ARM-only loop, for operations where source and
destination are aligned.

Copyright (C) ST-Ericsson SA 2010

Modified neon implementation to fit Cortex A9 cache line size,
for those running 32 bytes L2 cache line size.
Also split the implementation in aligned and unaligned access,
for those that allows unaligned memory access with Neon.
For totally aligned operations, arm-only code is used.

Change-Id: I95ebf6164cd6486b12a7e3e98e369db21e7e18d2
Author: Henrik Smiding henrik.smiding@stericsson.com for ST-Ericsson.
Signed-off-by: Christian Bejram <christian.bejram@stericsson.com>
2012-11-08 18:02:14 -08:00
Elliott Hughes
c213291515 Merge "Add optimized version of memcmp for Cortex A9" 2012-11-08 17:48:19 -08:00
David 'Digit' Turner
c1b44ecc53 Revert "libc: Provide ucontext_t/mcontext_t/<sys/ucontext.h>"
This creates build issues in the internal Android tree.
Will investigate later.

Original patch: https://android-review.googlesource.com/#/c/38875/

Change-Id: I12c5995ebf172890051af42a5d3b31014c9c5117
2012-10-17 19:10:11 +02:00
David 'Digit' Turner
c124baaf29 libc: Provide ucontext_t/mcontext_t/<sys/ucontext.h>
This patch updates the C library headers to provide ucontext_t
definitions for three architectures.

+ Fix <signal.h> to always define 'struct sigcontext'.

The new declarations are announced with new macros defined in
<sys/cdefs.h> in order to make it easier to adapt client code
that already defines its own, incompatible, versions of the
structures seen here.

http://code.google.com/p/android/issues/detail?id=34784

Change-Id: Ie78c48690a4ce61c50593f6c39639be7fead3596
2012-10-17 15:59:23 +02:00
Elliott Hughes
d10309c36b Merge "Rename __dso_handle_so.c to __dso_handle_so.h" 2012-09-07 10:59:20 -07:00
Andrew Hsieh
048569be54 Rename __dso_handle_so.c to __dso_handle_so.h
Also chang libc/arch-arm/bionic/crtbegin_so.c to include it
as a header.

Change-Id: Ib91b0b8caf5c8b936425aa8a4fc1a229b2b27929
2012-09-07 12:49:41 +08:00
Elliott Hughes
1ad05db9ce Add mlockall and munlockall for Google TV.
Change-Id: I10e961d701e74aab07211ec7975f61167e387853
2012-09-06 11:24:45 -07:00
Elliott Hughes
b2c5bd543d Merge "ARM: warn about atexit() calls from legacy shared libraries" 2012-09-05 10:18:43 -07:00
Elliott Hughes
26f2e4a163 Merge "ARM: make CRT_LEGACY_WORKAROUND work as intended" 2012-09-05 09:43:35 -07:00
Irina Tirdea
1ad10a566e Add getsid system call to bionic
Add getsid() system call to bionic for
all architectures. This is needed for various tools
(e.g. perf).

Adding the getsid system call was done in 3 steps:
() add getsid system call (function name and syscall
number) to libc/SYSCALLS.TXT
() generate all necessary headers by calling
libc/tools/gensyscalls.py. This patch is adding
the generated files since the build system
does not call gensyscalls.py.
() add the system call signature to libc/include/unistd.h

Change-Id: Id69a257e13ec02e1a44085a6b217a3f19ab025b1
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
2012-09-03 01:38:34 +03:00
Nick Kralevich
069c64cdf2 Merge "ARM: make sure __on_dlclose() actually gets called" 2012-08-28 13:04:22 -07:00
Nick Kralevich
e026b1d89a Merge "ARM: remove dummy entries from .so init_array/fini_array" 2012-08-28 12:49:46 -07:00
Ard Biesheuvel
144c291866 ARM: warn about atexit() calls from legacy shared libraries
Legacy ARM shared libraries use this generic version of atexit(),
which queues exit functions for invocation at program exit, at
which time the library may have been dlclose()'d, causing the
program to crash.

Change-Id: I41ae153c23268daa65ede7fb8966fc3e9caec369
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@gmail.com>
2012-08-28 11:23:06 +02:00
Ard Biesheuvel
f3cfcd869d ARM: make CRT_LEGACY_WORKAROUND work as intended
To properly support legacy ARM shared libraries, libc.so needs
to export the symbols __dso_handle and atexit, even though
these are now supplied by the crt startup code.

This patch reshuffles the existing CRT_LEGACY_WORKAROUND
conditionally compiled code slightly so it works as the
original author likely intended.

Change-Id: Id6c0e94dc65b7928324a5f0bad7eba6eb2f464b9
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@gmail.com>
2012-08-28 10:27:02 +02:00
Ard Biesheuvel
c23092887f ARM: remove dummy entries from .so init_array/fini_array
The runtime linker parses the ELF section headers to
discover the size of the init_array and fini_array, so
there is no point in putting NULL terminators at the end.

Change-Id: I3246cd585efce9314155600277dd829e9f37d04f
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@gmail.com>
2012-08-28 09:55:51 +02:00
Ard Biesheuvel
0a150ead18 libc: remove ctors/dtors sections
None of the supported ARCHs actually populate these sections,
so there is no point in keeping them in the binaries.

Change-Id: I21a364f510118ac1114e1b49c53ec8c895c6bc6b
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@gmail.com>
2012-08-22 20:45:26 +02:00
Ard Biesheuvel
404e28ff8c hardening: remove pointless ARM __get_pc() function
Useful if you're trying to defeat ASLR, otherwise not
so much ...

Change-Id: I17ebb50bb490a3967db9c3038f049adafe2b8ea7
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@gmail.com>
2012-08-22 20:38:54 +02:00
Ard Biesheuvel
5ed48a4d7f ARM: make sure __on_dlclose() actually gets called
Change-Id: I280e5428b0543cccf17ca36baee4865395928cdb
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@gmail.com>
2012-08-21 12:56:05 +02:00
Pavel Chupin
b7beb69075 Add link.h for all platforms with dl_phdr_info
This header is used on bionic build and should be propagated into
sysroot on toolchain rebuild. Discussion re. this header is here:
http://gcc.gnu.org/ml/gcc-patches/2012-08/msg00936.html

It is available already in mips NDK platforms:
development/ndk/platforms/android-9/arch-mips/include/link.h

Change-Id: I39ff467cdac9f448e31c11ee3e14a6200e82ab57
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2012-08-17 12:44:23 -07:00
Nick Kralevich
6eee1fc68f crtend*: Add GNU_STACK note
Add a GNU_STACK marker to crtend* files. This tells the linker
that these files do not require an executable stack.

When linking, a missing GNU_STACK marker in any .o file can prevent
the compiler from automatically marking the final executable as NX
safe (executable stack not required).  In Android, we normally work
around this by adding -Wa,--noexecstack / -Wl,-z,noexecstack.
For files like crtend.S / crtend_so.S, which are included in every
executable / shared library, it's better to add the GNU_STACK note
directly to the assembly file.  This allows the compiler to
automatically mark the final executable as NX safe without any
special command line options.

References: http://www.gentoo.org/proj/en/hardened/gnu-stack.xml

Change-Id: I07bd058f9f60ddd8b146e0fb36ba26ff84c0357d
2012-08-10 14:12:00 -07:00
Jeff Sharkey
e36c826f7a Add unshare() syscall.
(cherry-pick of 5467f25f82934d611c60f8bc57a05114f3c1bea0.)

Bug: 6925012
Change-Id: Ic5ea2fbd606311087de05d7a3594df2fa9b2fef9
2012-08-10 12:57:43 -07:00
Peter Enderborg
3460db9490 bionic: Stack pointer/signal race condition.
Move the stackpointer so a captured signal does not corrupt
stack variables needed for __thread_entry.

Change-Id: I3e1e7b94a6d7cd3a07081f849043262743aa8064
2012-07-27 15:11:01 +02:00
Nick Kralevich
9d40326830 arm: rewrite crtbegin* as C files.
Rewrite
 crtbegin.S     -> crtbegin.c
 crtbegin_so.S  -> crtbegin_so.c

This change allows us to generate PIC code without relying
on text relocations.

As a consequence of this rewrite, also rewrite
  __dso_handle.S    -> __dso_handle.c
  __dso_handle_so.S -> __dso_handle_so.c
  atexit.S          -> atexit.c

In crtbegin.c _start, place the __PREINIT_ARRAY__, __INIT_ARRAY__,
__FINI_ARRAY__, and __CTOR_LIST__ variables onto the stack, instead of
passing a pointer to the text section of the binary.

This change appears sorta wonky, as I attempted to preserve,
as much as possible, the structure of the original assembly.
As a result, you have C files including other C files, and other
programming uglyness.

Result: This change reduces the number of files with text-relocations
from 315 to 19 on my Android build.

Before:
  $ scanelf -aR $OUT/system | grep TEXTREL | wc -l
  315

After:
  $ scanelf -aR $OUT/system | grep TEXTREL | wc -l
  19

Change-Id: Ib9f98107c0eeabcb606e1ddc7ed7fc4eba01c9c4
2012-06-01 14:41:27 -07:00
Nick Kralevich
83a73d1afe crtbegin: eliminate duplicate code
crtbegin_dynamic and crtbegin_static are essentially identical,
minus a few trivial differences (comments and whitespace).

Eliminate duplicates.

Change-Id: Ic9fae6bc9695004974493b53bfc07cd3bb904480
2012-05-30 11:45:12 -07:00
Henrik Smiding
3ebd31c0a1 Add optimized version of memcmp for Cortex A9
Adds new code to function memcmp, optimized for Cortex A9.

Copyright (C) ST-Ericsson SA 2010

Added neon optimization

Change-Id: I8864d277042db40778b33232feddd90a02a27fb0
Author: Henrik Smiding henrik.smiding@stericsson.com for ST-Ericsson.
Signed-off-by: Christian Bejram <christian.bejram@stericsson.com>
2012-05-19 14:04:59 +02:00
Nick Kralevich
6cdefd06c0 Add linker support for PIE
Modify the dynamic linker so that executables can be loaded
at locations other than 0x00000000.

Modify crtbegin* so that non-PIC compilant "thumb interwork
veneers" are not created by the linker.

Bug: 5323301
Change-Id: Iece0272e2b708c79034f302c20160e1fe9029588
2012-05-15 09:56:32 -07:00
Iliyan Malchev
8034415ddd resolved conflicts for merge of 08e72d01 to jb-dev-plus-aosp
Change-Id: If00e354a5953ed54b31963d4f8ea77e1603c321e
2012-05-10 09:19:59 -07:00
Prajakta Gudadhe
08e72d0161 bionic: add support for non-NEON memcpy() on NEON SoCs
Some SoCs that support NEON nevertheless perform better with a non-NEON than a
NEON memcpy().  This patch adds build variable ARCH_ARM_USE_NON_NEON_MEMCPY,
which can be set in BoardConfig.mk.  When ARCH_ARM_USE_NON_NEON_MEMCPY is
defined, we compile in the non-NEON optimized memcpy() even if the SoC supports
NEON.

Change-Id: Ia0e5bee6bad5880ffc5ff8f34a1382d567546cf9
2012-05-09 13:34:31 -07:00
Ben Cheng
da0d8534f1 am 08b51e2c: Implement the "abort" stub in assembly for ARM.
* commit '08b51e2c091d036c124259ae59eb7be6bbe346af':
  Implement the "abort" stub in assembly for ARM.
2012-05-09 01:48:40 -07:00
Ben Cheng
eda7be454d Implement the "abort" stub in assembly for ARM.
So that we can always get the full stack trace regardless of gcc's handling
of the "noreturn" attribute associated with abort().

(Cherry pick of Id264a5167e7cabbf11515fbc48f5469c527e34d4.)

Bug: 6455193

Conflicts:

	libc/Android.mk

Change-Id: I568fc5303fd1d747075ca933355f914122f94dac
2012-05-08 14:47:20 -07:00
Ben Cheng
08b51e2c09 Implement the "abort" stub in assembly for ARM.
So that we can always get the full stack trace regardless of gcc's handling
of the "noreturn" attribute associated with abort().

[cherry-picked from master]

BUG:6455193
Change-Id: I0102355f5bf20e636d3feab9d1424495f38e39e2
2012-05-08 14:39:35 -07:00
Elliott Hughes
e636e1f2c1 am 8657eafc: Merge "Adjust memcpy for ARM Cortex A9 cache line size"
* commit '8657eafc3552f36c176667c1591beab255308da6':
  Adjust memcpy for ARM Cortex A9 cache line size
2012-05-07 13:59:58 -07:00
Henrik Smiding
fe6338da91 Adjust memcpy for ARM Cortex A9 cache line size
ARM Cortex A8 use 64 bytes and ARM Cortex A9 use 32 bytes cache line
size.

The following patch:
  Adds code to adjust memcpy cache line size to match A9 cache line
  size.
  Adds a flag to select between 32 bytes and 64 bytes cache line
  size.

  Copyright (C) ST-Ericsson SA 2010
    Modified neon implementation to fit Cortex A9 cache line size
    Author: Henrik Smiding henrik.smiding@stericsson.com for
            ST-Ericsson.

Change-Id: I8a55946bfb074e6ec0a14805ed65f73fcd0984a3
Signed-off-by: Christian Bejram <christian.bejram@stericsson.com>
2012-05-07 14:18:02 +02:00
Evgeniy Stepanov
4a9d6e50bb Fix segv when unwinding stack past __libc_init.
This change mirrors cd15bac for statically-linked binaries.

Change-Id: Id870832a50b37f0ef3e79e1ed03ed31390bfc9ef
2012-04-18 12:59:38 +04:00
Kenny Root
f0ec06ba60 Add faccessat to syscall list
Change-Id: I427a18811089cb280769ac8da3ed8adc00a65a10
2012-04-13 15:45:42 -07:00
Elliott Hughes
d5099016f7 Merge "Fix segv when unwinding stack past __libc_init." 2012-04-12 11:52:44 -07:00
Kenny Root
470835b215 Move end of __on_dlclose up
The END macro was put too far down which made the linker complain about
it. Move up to the end of the code.

Change-Id: Ica71a9c6083b437d2213c7cefe34b0083c78f16b
2012-04-11 14:24:28 -07:00
Kenny Root
03273f8fc0 __on_dlclose should be aligned
Marking segments read-only was pushing the alignment of __on_dlclose by
2 bytes making it unaligned. This change makes sure the ARM code is
aligned to the 4 byte boundary.

Bug: 6313309
Change-Id: Ic2bf475e120dd61225ec19e5d8a9a8b1d0b7f081
2012-04-10 17:53:11 -07:00
Evgeniy Stepanov
cd15bacf33 Fix segv when unwinding stack past __libc_init.
This change fixes a segmentation fault in the libc unwinder when it goes
past __libc_init.

Unwind instructions for __libc_init direct it to grab the return address from
the stack frame. Without this change, the unwinder gets a wild address and
looks up further unwind instructions for the routine at that address. If it's
unlucky enough to hit an existing function, it will try to unwind it. Bad
things happen then.

With this change, the return address always points to the _start function,
which does not have unwind instructions associated with it. This stop the
unwind process.

__libc_init never returns, so this does not affect program execution, other
than adding 4 bytes on the main thread stack.

Change-Id: Id58612172e8825c8729cccd081541a13bff96bd0
2012-04-10 16:45:54 +04:00
Ben Cheng
1a823691a2 Update kernel headers and add syscall "perf_event_open"
Change-Id: I43f12b727881df002a8524f2738586c043833bae
2012-03-13 12:28:40 -07:00
Kenny Root
be101bf39a Revert "Reference __dso_handle in PIC way"
This reverts commit 93cb308137
2012-03-05 10:45:31 -08:00
Kenny Root
93cb308137 Reference __dso_handle in PIC way
Use the same pattern in atexit.S to reference __dso_handle in a way that
doesn't require a TEXTREL flag to be set.

Change-Id: Id69d20863ee203d2b2f7ef0db230f9b548657741
2012-03-02 13:09:36 -08:00
Andrew Hsieh
4fc1273459 Merge "Trivial fix in comment" 2012-02-29 09:40:49 -08:00
Dima Zavin
f1a17e762b libc: Add __aeabi_llsl and __aeabi_llsr to libgcc_compat
Some platform libraries built for ICS do not work with master
because of some refactoring in frameworks/base.

Make sure that these libgcc symbols are always present in our libc

Change-Id: Ib8d345878be0ba711f051082a778f5cc1f1b3a19
Signed-off-by: Dima Zavin <dima@android.com>
2012-02-22 15:18:56 -08:00
Andrew Hsieh
58b2c1616b Trivial fix in comment
Very, very trivial fix for minor typo in comment about how it works

Change-Id: Ia08d332366837dec8f7e91b9728732c5edea223e
2012-02-21 15:09:32 -08:00
Jean-Baptiste Queru
d6b58b03b8 am 09049311: am cfff36df: am a60ff6c5: Merge "libc: Define new symbol visibility macros"
* commit '09049311a229c427f73e3e0ac873bf344b45aaf2':
  libc: Define new symbol visibility macros
2012-02-13 14:42:48 -08:00
Jean-Baptiste Queru
cfff36df2b am a60ff6c5: Merge "libc: Define new symbol visibility macros"
* commit 'a60ff6c5b2ca76181b387d8c10aee22a2cbcf840':
  libc: Define new symbol visibility macros
2012-02-13 14:25:53 -08:00
David 'Digit' Turner
5fbf2e0992 libc: Define new symbol visibility macros
This patch defines a few new macros that can be used to control the
visibility of symbols exported by the C library:

- ENTRY_PRIVATE() can be used in assembly sources to indicate
  that an assembler function should have "hidden" visibility, i.e.
  will never be exported by the C library's shared library.

  This is the equivalent of using __LIBC_HIDDEN__ for a C function,
  but ENTRY_PRIVATE() works like ENTRY(), and must be used with
  END() to tag the end of the function.

- __LIBC_ABI_PUBLIC__ can be used to tag a C functions as being
  part of the C library's public ABI. This is important for a
  few functions that must be exposed by the NDK to maintain
  binary compatibility.

  Once a symbol has been tagged with this macro, it shall
  *never* be removed from the library, even if it becomes
  directly unused due to implementation changes
  (e.g. __is_threaded).

- __LIBC_ABI_PRIVATE__ can be used for C functions that should
  always be exported by the C library because they are used by
  other libraries in the platform, but should not be exposed
  by the NDK. It is possible to remove such symbols from the
  implementation if all callers are also modified.

+ Add missing END() assembly macro for x86

Change-Id: Ia96236ea0dbec41d57bea634b39d246b30e5e234
2012-01-31 22:19:09 +01:00
Jean-Baptiste Queru
73fa5fdaf9 Merge 2f80f07d
Change-Id: Iff51b8530dbee01499ba4af0ecd6ab837c8c94fb
2012-01-20 16:47:01 -08:00
Jean-Baptiste Queru
2f80f07d81 am 23f56bbb: Merge "Add extended attribute (xattr) system call wrappers to bionic."
* commit '23f56bbb6ae053996dd821f29379aea0c7166055':
  Add extended attribute (xattr) system call wrappers to bionic.
2012-01-20 11:54:47 -08:00
Stephen Smalley
5eb686d105 Add extended attribute (xattr) system call wrappers to bionic.
The xattr system calls are required for the SE Android userspace in
order to get and set file security contexts.  In particular, libselinux
requires these calls.

Change-Id: I78f5eb3d8f3384aed0a5e7c6a6f001781d982017
2012-01-18 08:02:23 -05:00
Nick Kralevich
023e5409df am 06f51ba1: am f44de270: add personality() system call.
* commit '06f51ba1af2fafeec7fdfcba5d635bd001a31b3e':
  add personality() system call.
2012-01-17 13:09:53 -08:00
Nick Kralevich
06f51ba1af am f44de270: add personality() system call.
* commit 'f44de270bba32c9b1b5eff8a34be07b10ddff238':
  add personality() system call.
2012-01-17 11:45:25 -08:00
Nick Kralevich
f44de270bb add personality() system call.
Change-Id: Ie899def8ea1d705930ed83adae1343c1353e7c57
2012-01-13 15:50:40 -08:00
Bruce Beare
6519c8124e am e30e9093: sreadahead: adding readahead system call into bionic libc
* commit 'e30e909363c5c706f394050d9cd00ce222caadbf':
  sreadahead: adding readahead system call into bionic libc
2012-01-03 18:37:28 -08:00
Bruce Beare
e30e909363 sreadahead: adding readahead system call into bionic libc
Add bionic libc to support readahead system call.
This is needed to enable sreadahead to work.

Change-Id: I3856e1a3833db82e6cf42fd34af7631bd40cc723
Author: Winson Yung <winson.w.yung@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
2012-01-03 15:18:04 -08:00
David 'Digit' Turner
f1a39dce60 libc: Fix typo that broke NDK compatibility.
The function must be named __atomic_cmpxchg, not __android_cmpxchg.
This typo broke existing prebuilt binaries (they couldn't be loaded
at runtime anymore).

Change-Id: I25ca7d18329817f0056e616a0409113269ad7b1f
2011-11-23 14:38:36 +01:00
David 'Digit' Turner
de44d0b2bd Merge "libc: provide atomic operations will full barriers for NDK apps." 2011-11-22 02:10:06 -08:00
Jeff Brown
10c8ce59a4 Add tgkill syscall.
Use tgkill instead of tkill to implement pthread_kill.
This is safer in the event that the thread has already terminated
and its id has been reused by a different process.

Change-Id: Ied715e11d7eadeceead79f33db5e2b5722954ac9
2011-11-18 16:40:48 -08:00
David 'Digit' Turner
0fec6b9d88 libc: provide atomic operations will full barriers for NDK apps.
__atomic_cmpxchg and other related atomic operations did not
provide memory barriers, which can be a problem for non-platform
code that links against them when it runs on multi-core devices.

This patch does two things to fix this:

- It modifies the existing implementation of the functions
  that are exported by the C library to always provide
  full memory barriers. We need to keep them exported by
  the C library to prevent breaking existing application
  machine code.

- It also modifies <sys/atomics.h> to only export
  always-inlined versions of the functions, to ensure that
  any application code compiled against the new header will
  not rely on the platform version of the functions.

  This ensure that said machine code will run properly on
  all multi-core devices.

This is based on the GCC built-in sync primitives.

The end result should be only slightly slower than the
previous implementation.

Note that the platform code does not use these functions
at all. A previous patch completely removed their usage in
the pthread and libstdc++ code.

+ rename arch-arm/bionic/atomics_arm.S to futex_arm.S
+ rename arch-x86/bionic/atomics_x86.S to futex_x86.S
+ remove arch-x86/include/sys/atomics.h which already
  provided inlined functions to the x86 platform.

Change-Id: I752a594475090cf37fa926bb38209c2175dda539
2011-11-16 17:37:15 +01:00
Nick Kralevich
d9ad62343c Add linker support for PIE
Modify the dynamic linker so that executables can be loaded
at locations other than 0x00000000.

Modify crtbegin* so that non-PIC compilant "thumb interwork
veneers" are not created by the linker.

Bug: 5323301
Change-Id: Iece0272e2b708c79034f302c20160e1fe9029588
2011-10-22 13:19:23 -07:00
Evgeniy Stepanov
487b613e57 Use ENTRY and EXIT macros for strcmp, memcpy, atexit.
Without this change strcmp size is zero (not set), and it gets
ignored by Valgrind. Changes to memcpy and atexit don't affect the
generated binary in any way.

Change-Id: I05818cb5951f75901dc8c0eef02807a2e83a9231
2011-10-11 12:12:05 +04:00
David 'Digit' Turner
58246b7067 libc: Add __aeabi_f2uiz to libgcc_compat.c
This patch ensure that __aeabi_f2uiz is embedded in our C library.
This is needed to avoid breaking certain applications when they are
loaded in ICS. It is likely that the issue is due to mis-linked
binaries generated with the stand-alone toolchain (the problem
should not exist if you use ndk-build), but this fix is easier
than asking all app developers to fix their custom build system.

If you want more technical details, read the comments inside
libgcc_compat.c

Change-Id: I59ac1fc781ecb70b90b5573c5a3c67560ca8f270
2011-08-22 19:53:10 +02:00
David Turner
b489666086 am 1c0a0381: Merge "Enable functional DSO object destruction"
* commit '1c0a0381dfb3648ffadef9537ec9383d63d62473':
  Enable functional DSO object destruction
2011-06-23 05:28:13 -07:00
Bruce Beare
3964084282 Enable functional DSO object destruction
Unfortunately, legacy .so files for ARM don't have a correct crtbegin file.
Consequently, we have to grandfather the old __dso_handle behaviour.
Add some ifdefs for ARM to allow it to use the old code until we can work
out a transition.

Change-Id: I6a28f368267d792c94e1d985d8344023bc632f6f
Author: H.J. Lu <hongjiu.lu@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
2011-06-20 14:44:44 -07:00
David Turner
a9e409a035 am a7a9dddb: Merge "bionic: Add ARM optimized strcmp()"
* commit 'a7a9dddb5dfe783d65fec4d3b0dee9f734345a29':
  bionic: Add ARM optimized strcmp()
2011-05-17 04:47:09 -07:00
Jim Huang
f50e9be593 bionic: Add ARM optimized strcmp()
Reference results of the experiments on TI OMAP3430 at 600 MHz

$ bench_strcmp -N "strcmp_1k" -s 1k -I 200

[original C code]
             prc thr   usecs/call      samples   errors cnt/samp     size
strcmp_1k      1   1     10.38000          102        0    15000     1024

[ARM optimized code]
             prc thr   usecs/call      samples   errors cnt/samp     size
strcmp_1k      1   1      3.08840           88        0    15000     1024

The work was derived from ARM Ltd, contributed to newlib, and reworked
for Android by Linaro.

Change-Id: Ib0d5755e1eb9adb07d80ef0252f57a5c4c57a425
Signed-off-by: Jim Huang <jserv@0xlab.org>
2011-04-20 15:39:43 +08:00
Ken Sumrall
ae2d5ba314 Add support for the utimensat(2) syscall to bionic.
The kernel has supported this syscall for quite some time now,
but bionic did not.  Now that there is a need for it, let's
add it to bionic.

Change-Id: Ifcef3e46f1438d79435b600c4e6063857ab16903
2011-03-24 18:18:48 -07:00
David Turner
3224c08bd7 Merge changes I8c481c89,I791406f8,I5f09cef8
* changes:
  libc: ARM: update syscalls with new script
  libc: ARM: add size info to gensyscalls
  Add function marks and size indications
2011-02-18 15:22:27 -08:00
Kenny Root
fb723c8749 libc: ARM: update syscalls with new script
Used the new gensyscalls.py script to update the ARM syscalls with the
BEGIN(x) and END(x) macros to give size information for the code of the
syscall. Useful for valgrind.

Change-Id: I8c481c8928401ac110fd19b087f7d67e4db39326
2011-02-17 10:47:47 -08:00
Kenny Root
420878c690 Add function marks and size indications
Add a macro to annotate function end and start using both ENTRY and END
for each function. This allows valgrind (and presumably other debugging
tools) to use the debug symbols to trace the functions.

Change-Id: I5f09cef8e22fb356eb6f5cee952b031e567599b6
2011-02-17 09:07:25 -08:00
Kenny Root
0233509c16 Amend previous commit with needed include
Change-Id: Idae8daaf095d90513820e05f423144ffed4ba913
2011-02-17 07:50:36 -08:00
Kenny Root
3a3c1853ac Use CLZ on ARMv5 and newer
Change-Id: Ia5aa6974c0343ae43fbcb91304501213048e9ec0
2011-02-16 16:40:08 -08:00
David 'Digit' Turner
95d751feac libc: Add ftruncate64 and improve 64-bit parameter syscall handling.
This patch improves the handling of 64-bit parameters in syscalls on ARM.
The ARM EABI mandates that 64-bit quantities be passed in even/odd register
pairs, which requires special treatment.

This allows us to simplify our implementations of pread() and pwrite()
and remove the C stubs for pread64() and pwrite64().

Also add ftruncate64() to <unistd.h>

Change-Id: I407e2fd223ba0093dd2d0b04c6152fadfc9ce3ef

Bug 3107933
2010-12-16 17:04:41 +01:00
David 'Digit' Turner
72e6fd4242 <sched.h>: Add sched_getcpu() and cpu_set_t
This adds the cpu_set_t type definition and related functions
and macros used to handle CPU thread affinity.

  sched_getcpu()
  sched_setaffinity()
  sched_getaffinity()

Change-Id: If382ecafde8926341a88478062b275553645065b
2010-12-06 13:42:54 +01:00
Jean-Baptiste Queru
9c8ea7fa3f am 24dc9363: resolved conflicts for merge of 1bc98ccb to gingerbread-plus-aosp
* commit '24dc936346b4a31005ac28c4bd464320cca9320a':
  bionic: Add ARM optimized strcpy()
2010-11-22 13:38:44 -08:00
Jean-Baptiste Queru
24dc936346 resolved conflicts for merge of 1bc98ccb to gingerbread-plus-aosp
Change-Id: Ief9ec3d0472660e26864e082e03c26e09a043b9d
2010-11-22 13:34:59 -08:00
Jim Huang
73c04b3269 bionic: Add ARM optimized strcpy()
Reference results of the experiments on Qualcomm MSM7x25 (524MHz):

[original C code]
             prc thr   usecs/call      samples   errors cnt/samp
size
strcpy_1k      1   1     14.56159           99        0     1000
1024

[ARM optimized code]
             prc thr   usecs/call      samples   errors cnt/samp
size
strcpy_1k      1   1      3.46653           99        0     1000
1024

The work was derived from ARM Ltd.

Change-Id: I906ac53bb7a7285e14693c77d3ce8d4ed6f98bfd
2010-11-22 13:01:32 -08:00
Jean-Baptiste Queru
482358fda7 am d29b8a51: am 5109146f: Merge "Reconcile assembly-only macros in <machine/cpu-features.h>"
Merge commit 'd29b8a51a5f95a3f38e5fb812231e12e5a66a865'

* commit 'd29b8a51a5f95a3f38e5fb812231e12e5a66a865':
  Reconcile assembly-only macros in <machine/cpu-features.h>
2010-10-21 09:54:30 -07:00
Jean-Baptiste Queru
d29b8a51a5 am 5109146f: Merge "Reconcile assembly-only macros in <machine/cpu-features.h>"
Merge commit '5109146f954d8cca39d34689bff2762e15bc6933' into gingerbread-plus-aosp

* commit '5109146f954d8cca39d34689bff2762e15bc6933':
  Reconcile assembly-only macros in <machine/cpu-features.h>
2010-10-19 15:21:57 -07:00
Ying Wang
76a34d6628 Remove duplicate item
This elimates the makefile warning at the beginning of each build:
libc_common_intermediates/arch-arm/syscalls/eventfd.o' given more than once in the same rule.

Change-Id: I25cc0c373d55b5036dd17811a595c097fd6ca69a
2010-10-08 17:09:55 -07:00
Jim Huang
94e5c5ef37 Reconcile assembly-only macros in <machine/cpu-features.h>
The change explicitly isolates the assembly-only macros in header
<machine/cpu-features.h> in order to prevent mis-inclusion in C/C++
source files.

Change-Id: I0258e87c5ac3fd24944fb227290ac3b9cac4bfba
2010-10-01 17:00:46 +08:00
repo sync
686af0b3a5 resolved conflicts for merge of defd1622 to gingerbread-plus-aosp
Conflicts:
	libc/arch-arm/syscalls/eventfd.S
	libc/include/sys/eventfd.h
	libc/include/sys/linux-syscalls.h

Change-Id: I02f6e9536aa5478322240c199ff4c2f4367922d0
2010-09-28 12:23:55 +02:00
David 'Digit' Turner
a511f24561 am 9973a564: libc: Add missing waitid() implementation.
Merge commit '9973a564222b842eb7497fd6e659fe8c8c49e2b3' into gingerbread-plus-aosp

* commit '9973a564222b842eb7497fd6e659fe8c8c49e2b3':
  libc: Add missing waitid() implementation.
2010-09-28 00:22:25 -07:00
David 'Digit' Turner
defd162212 libc: add <sys/eventfd.h> and corresponding implementations.
Change-Id: Ide040884c456190226e580513099fdb8377e015b
2010-09-28 09:20:37 +02:00
David 'Digit' Turner
052fbd8808 am a3ae60d3: libc: Add missing fdatasync() implementation
Merge commit 'a3ae60d343661784e3f6f4566b276d8e6b8a06a7' into gingerbread-plus-aosp

* commit 'a3ae60d343661784e3f6f4566b276d8e6b8a06a7':
  libc: Add missing fdatasync() implementation
2010-09-28 00:19:31 -07:00
David 'Digit' Turner
9973a56422 libc: Add missing waitid() implementation.
Change-Id: I312ee608dbf9249e4886a10d45d13e3cda8a9042
2010-09-28 09:18:26 +02:00
David 'Digit' Turner
a3ae60d343 libc: Add missing fdatasync() implementation
Change-Id: I04bb655d77e414021e1f2a973329167ad76ca1c4
2010-09-28 09:17:17 +02:00
David 'Digit' Turner
914528cdc9 am 223ddfcf: Merge "libc: Add missing pipe2() declaration and implementation." into gingerbread
Merge commit '223ddfcfc4cb354641e70da31a60556248db5036' into gingerbread-plus-aosp

* commit '223ddfcfc4cb354641e70da31a60556248db5036':
  libc: Add missing pipe2() declaration and implementation.
2010-09-28 00:13:48 -07:00
David 'Digit' Turner
9aac38249b am bd8d987b: libc: remove C++ comments from public headers.
Merge commit 'bd8d987b3c3aa6d9d00cede2cb091f00bdb42204' into gingerbread-plus-aosp

* commit 'bd8d987b3c3aa6d9d00cede2cb091f00bdb42204':
  libc: remove C++ comments from public headers.
2010-09-28 00:13:43 -07:00
David 'Digit' Turner
223ddfcfc4 Merge "libc: Add missing pipe2() declaration and implementation." into gingerbread 2010-09-28 00:12:08 -07:00
Elliott Hughes
8120a8df84 am 3cf53d1a: Fixes for the ARM-specific bswap_16, bswap_32, and bswap_64.
Merge commit '3cf53d1a7814e1520df09d24b009c16f4f27db0d' into gingerbread-plus-aosp

* commit '3cf53d1a7814e1520df09d24b009c16f4f27db0d':
  Fixes for the ARM-specific bswap_16, bswap_32, and bswap_64.
2010-09-27 11:39:39 -07:00
David 'Digit' Turner
bd8d987b3c libc: remove C++ comments from public headers.
Change-Id: I4af84f912062cd2ff34711c25122fb323f20c032
2010-09-27 17:35:26 +02:00
David 'Digit' Turner
275cd48511 libc: Add missing pipe2() declaration and implementation.
Change-Id: Iacb914bd6ac5adc60c5671e6fef680ede21f9b0c
2010-09-27 17:33:08 +02:00
Elliott Hughes
3cf53d1a78 Fixes for the ARM-specific bswap_16, bswap_32, and bswap_64.
1. Make the feature test work by excluding known-deficient processors, so
we don't have to maintain a complete list of all the processors that support
REV and REV16.

2. Don't abuse 'register' to get an effect similar to GCC's +l constraint,
but which was unnecessarily restrictive.

3. Fix __swap64md so _x isn't clobbered, breaking 64-bit swaps.

4. Make <byteswap.h> (which declars bswap_16 and friends) use <endian.h>
rather than <sys/endian.h>, so we get the machine-dependent implementations.

Change-Id: I6a38fad7a9fbe394aff141489617eb3883e1e944
2010-09-26 11:26:53 -07:00
Jean-Baptiste Queru
ef3644d110 am 312be567: Merge "Use ARMv6 instruction for handling byte order"
Merge commit '312be567a03aaf851707a268807ee666b12f8c74' into gingerbread-plus-aosp

* commit '312be567a03aaf851707a268807ee666b12f8c74':
  Use ARMv6 instruction for handling byte order
2010-09-10 16:37:38 -07:00
Jean-Baptiste Queru
312be567a0 Merge "Use ARMv6 instruction for handling byte order" 2010-09-10 16:02:59 -07:00
Keith Deacon
d7b156d2a3 am 3a1bbee3: Add eventfd system call support
Merge commit '3a1bbee36b773862e88c6f1895b607c0cd81b499' into gingerbread-plus-aosp

* commit '3a1bbee36b773862e88c6f1895b607c0cd81b499':
  Add eventfd system call support
2010-09-08 03:06:26 -07:00
Keith Deacon
3a1bbee36b Add eventfd system call support 2010-08-31 16:16:01 -05:00
Jim Huang
aa35095517 Use ARMv6 instruction for handling byte order
ARMv6 ISA has several instructions to handle data in different byte order.
For endian conversion (byte swapping) of single data words, it might be a
good idea to use the REV/REV16 instruction simply.

Change-Id: Ic4a5ed6254e082763e54aa70d428f59a0088636e
2010-08-31 14:51:44 +08:00
Jim Huang
a172709259 bionic: Rename _ARM_HAVE_LDREX_STREX to __ARM_HAVE_LDREX_STREX for consistency
The patch follows the naming manner in existing macros with prefix
__ARM_HAVE.

Change-Id: I6763ce2bf3ee85fd1da112c719543061d8d19bf4
2010-08-09 05:35:11 +08:00
Dima Zavin
18c5bcc66a Revert "Set SA_RESTORER in sigaction()"
This reverts commit e4fa46e75c.
2010-07-29 19:12:04 -07:00
David 'Digit' Turner
ab8b54101e libc: fix fstatfs() implementation.
The syscall expects the size of the buffer as the second argument.

Change-Id: I99ede2fec7fcd385ca03ff022c2cffa4297bea8d
2010-07-08 16:52:27 -07:00
David 'Digit' Turner
3b43f87d29 Allow dlclose() to properly call static C++ destructors.
With this patch _and_ an upcoming build/ patch, the destruction
of static C++ objects contained in shared libraries will happen
properly when dlclose() is called.

Note that this change introduces crtbegin_so.S and crtend_so.S which
are currently ignored by the build system.

+ move definition of __dso_handle to the right place
(before that, all shared libraries used the __dso_handle
global variable from the C library).

Note that we keep a 'weak' __dso_handle in aeabi.c to avoid
breaking the build until the next patch to build/core/combo/
appears. We will be able to remove that later.

+ move bionic/aeabi.c to arch-arm/bionic/ (its proper location)

NOTE: The NDK will need to be modified to enable this feature in
         the shared libraries that are generated through it.

Change-Id: I99cd801375bbaef0581175893d1aa0943211b9bc
2010-07-01 23:09:28 -07:00
David 'Digit' Turner
6a9b888d7c Allow static C++ destructors to be properly called on dlclose().
With this patch, _and_ an upcoming build/ patch, the destruction
of static C++ objects contained in shared libraries will happen
properly when dlclose() is called.

Note that this change introduces crtbegin_so.S and crtend_so.S which
are currently ignored by the build system.

+ move definition of __dso_handle to the right place
  (before that, all shared libraries used the __dso_handle
   global variable from the C library).

  Note that we keep a 'weak' __dso_handle in aeabi.c to avoid
  breaking the build until the next patch to build/core/combo/
  appears. We will be able to remove that later.

+ move bionic/aeabi.c to arch-arm/bionic/ (its proper location)

Change-Id: Ie771aa204e3acbdf02fd30ebd4150373a1398f39
NOTE: The NDK will need to be modified to enable this feature in
      the shared libraries that are generated through it.
2010-06-18 16:07:10 -07:00
David 'Digit' Turner
b8e6c50cfa Fix setjmp()/longjmp() to save FP registers on ARMv7. - DO NOT MERGE
Change-Id: I3a0c2c05e295ac05ed51a531dabda668be204ca0
2010-06-09 13:18:29 -07:00
David 'Digit' Turner
aa4b1d0429 Add missing sysinfo() implementation (already declared in <sys/sysinfo.h>) - DO NOT MERGE
Change-Id: Iac4eb5911ffe4a7ab72b84df44e907685ac816af
2010-06-09 13:12:15 -07:00
Andy McFadden
fcd00ebbdf Atomic/SMP update, part 3.
Update ARM atomic ops to use LDREX/STREX.  Stripped out #if 0 chunk.

Insert explicit memory barriers in pthread and semaphore code.

For bug 2721865.

Change-Id: I0f153b797753a655702d8be41679273d1d5d6ae7
2010-05-28 16:12:01 -07:00
Andy McFadden
4fdbadde92 Atomic/SMP update.
Added an underscore to _ARM_HAVE_LDREX_STREX to make it match the others.

Added __ARM_HAVE_DMB and __ARM_HAVE_LDREXD when appropriate.

Fixed some typos.

Change-Id: I2f55febcff4aeb7de572a514fb2cd2f820dca27c
2010-05-20 15:59:32 -07:00
The Android Open Source Project
4aef0ae660 merge from open-source master
Change-Id: I2be62bce462ee53fe9519f433523bd7a44a73d40
2010-05-13 14:31:02 -07:00
Matt Fischer
e4fa46e75c Set SA_RESTORER in sigaction()
GDB looks for specific opcode sequences when trying to recognize a stack
frame as a signal trampoline.  The sequences it looks for happen to be those
created when SA_RESTORER is set, since glibc always sets a restorer.  This
patch does the same here, so that the trampolines can be correctly identified.

Change-Id: I0ac574a68818cb24d939c3527f3aaeb04b853d04
2010-05-12 14:18:36 -05:00
David 'Digit' Turner
88f06cd84a Use private futexes for pthread_mutex_t.
This does not change the implementation of conditional variables
since we're waiting for other system components to properly use
pthread_condattr_init/setpshared before that.

Also remove an obsolete x86 source file.

Change-Id: Ia3e3fbac35b87a534fb04d4381c3c66b975bc8f7
2010-03-18 17:13:41 -07:00
Fabrice Di Meglio
8641833b62 Revert "bionic: pthread: use private futexes by default for mutexes and condvars"
This reverts commit ba9c6f0989.
2010-03-11 14:47:47 -08:00
David 'Digit' Turner
ba9c6f0989 bionic: pthread: use private futexes by default for mutexes and condvars
Private futexes are a recent kernel addition: faster futexes that cannot be
shared between processes. This patch uses them by default, unless the PROCESS_SHARED
attribute flag is used when creating a mutex and/or conditional variable.

Also introduces pthread_condattr_init/destroy/setpshared/getpshared.

Change-Id: I3a0e2116f467072b046524cb5babc00e41057a53
2010-03-11 11:48:38 -08:00
Colin Cross
ecede40222 Only use NEON memcpy if __ARM_NEON__ is defined
Change-Id: I32e6b9385d46efeec15dee8e395a82eef24ba3ea
2010-03-09 16:23:51 -08:00
Mike Chan
9f6915631b bonic: libc: cpuacct support for setuid functions
Any of the setuid functions now updates /acct/uid/ with its own tid
before changing users. This is so we can properly account for cpu time
per uid.

Change-Id: I34186cf4d5228cac8439e582a9e26c01ef3011e4
Signed-off-by: Mike Chan <mike@android.com>
2010-03-02 18:18:04 -08:00
Andrei Popescu
eb9d5ed347 add sigaltstack syscall 2010-03-02 11:43:24 +00:00
San Mehat
75c5e25ae3 bionic: syscalls: Add ioprio_set/ioprio_get syscall wrappers
Signed-off-by: San Mehat <san@google.com>
2010-02-23 15:55:29 -08:00
David 'Digit' Turner
97cf7f3394 Implement clone() C library function properly.
Only provide an implementation for ARM at the moment, since
it requires specific assembly fragments (the standard syscall
stubs cannot be used because the child returns in a different
stack).
2010-01-25 11:18:30 -08:00
Doug Kwan
d548a265ca Add missing symbol type directives. 2009-12-03 16:26:04 -08:00
Mathias Agopian
ecac54db21 am 3ba822cc: am 199f9d92: Improve memcpy performance from 290 MiB/s to 340 MiB/s (17% improvment)
Merge commit '3ba822cc3f0a252db73cf63cb8390e46fc0ceb0a' into eclair-mr2-plus-aosp

* commit '3ba822cc3f0a252db73cf63cb8390e46fc0ceb0a':
  Improve memcpy performance from 290 MiB/s to 340 MiB/s (17% improvment)
2009-10-29 19:53:39 -07:00
Mathias Agopian
47c5e30b61 am 199f9d92: Improve memcpy performance from 290 MiB/s to 340 MiB/s (17% improvment)
Merge commit '199f9d923804d74e021dd80e48ec75c0a96dba77' into eclair-plus-aosp

* commit '199f9d923804d74e021dd80e48ec75c0a96dba77':
  Improve memcpy performance from 290 MiB/s to 340 MiB/s (17% improvment)
2009-10-29 02:44:15 -07:00
Mathias Agopian
199f9d9238 Improve memcpy performance from 290 MiB/s to 340 MiB/s (17% improvment)
use 64 bytes cache lines, reduce the main loop to 64-bytes instead of
128 bytes and adjust the prefetch distance to the optimal value.
2009-10-28 03:17:02 -07:00
Mathias Agopian
581f43056b am 76ef331c: am 7e7d6c48: use local symbols in memset so it doesn\'t screw up profiling
Merge commit '76ef331cd6967ca8f5af779d25c8b634f8cdd2b6' into eclair-mr2-plus-aosp

* commit '76ef331cd6967ca8f5af779d25c8b634f8cdd2b6':
  use local symbols in memset so it doesn't screw up profiling
2009-10-19 17:19:37 -07:00
Mathias Agopian
214dec2811 am 7e7d6c48: use local symbols in memset so it doesn\'t screw up profiling
Merge commit '7e7d6c48a064af82f0ec39f47b9eb803a6e1df4c' into eclair-plus-aosp

* commit '7e7d6c48a064af82f0ec39f47b9eb803a6e1df4c':
  use local symbols in memset so it doesn't screw up profiling
2009-10-19 17:09:51 -07:00
Mathias Agopian
7e7d6c48a0 use local symbols in memset so it doesn't screw up profiling 2009-10-19 16:34:38 -07:00
David 'Digit' Turner
1f2a381e84 am fdc5c1f5: Re-enable ARMv7 memcpy implementation.
Merge commit 'fdc5c1f56f9d21034badb8e4b092c47098f19613' into eclair-plus-aosp

* commit 'fdc5c1f56f9d21034badb8e4b092c47098f19613':
  Re-enable ARMv7 memcpy implementation.
2009-10-07 11:48:11 -07:00
David 'Digit' Turner
5be45ce0cf am 1e40783d: Fix armv7-user builds by disabling the ARMv7-optimized memcpy.
Merge commit '1e40783d9ad29c88a4d547774e05080fc4327a2e' into eclair-plus-aosp

* commit '1e40783d9ad29c88a4d547774e05080fc4327a2e':
  Fix armv7-user builds by disabling the ARMv7-optimized memcpy.
2009-10-07 11:42:33 -07:00
David 'Digit' Turner
fdc5c1f56f Re-enable ARMv7 memcpy implementation.
Do not submit this patch before the one that modifies the Android emulator to
work-around a weird ARMv7 emulation issue. This is done to temporarily re-allow
the -user builds needed for QA.
2009-10-05 14:25:10 -07:00
David 'Digit' Turner
1e40783d9a Fix armv7-user builds by disabling the ARMv7-optimized memcpy.
This is required to work-around some corny bugs in ARMv7 emulation.

The emulation itself is required to run the dex pre-optimization pass
for -user builds.
2009-10-02 19:13:27 -07:00
David 'Digit' Turner
0893d49187 am 7a9e06fa: Merge change I2a7ad975 into eclair
Merge commit '7a9e06fa7e4e533074cde314f25dff3024f34a5d' into eclair-plus-aosp

* commit '7a9e06fa7e4e533074cde314f25dff3024f34a5d':
  Fix ABI breakage in libc.so and libm.so between 1.6 and Eclair.
2009-09-29 15:13:15 -07:00
Android (Google) Code Review
7a9e06fa7e Merge change I2a7ad975 into eclair
* changes:
  Fix ABI breakage in libc.so and libm.so between 1.6 and Eclair.
2009-09-29 18:04:51 -04:00
David 'Digit' Turner
2a7ad97539 Fix ABI breakage in libc.so and libm.so between 1.6 and Eclair.
For a detailed description of the problem and why this fix is
needed, plrease read the comments in libgcc_compat.c
2009-09-29 14:43:38 -07:00
Mathias Agopian
2d77d4dbd6 am ee223d02: NEON optimized memcpy.
Merge commit 'ee223d02d96815c989b62043ff1237b1cd4e14b0' into eclair-plus-aosp

* commit 'ee223d02d96815c989b62043ff1237b1cd4e14b0':
  NEON optimized memcpy.
2009-09-29 13:31:57 -07:00
Mathias Agopian
ee223d02d9 NEON optimized memcpy.
372 MB/s for large transfers, 440 MB/s for smaller ones down to 1KB. 130 MB/s for very small transfers ( < 32 bytes )
Performance is similar with non-congruent buffers.
2009-09-28 19:08:18 -07:00
David 'Digit' Turner
dfa87a200f am f355096a: Remove NEON optimizations for memcpy
Merge commit 'f355096a64b74c8e869527de55f7e908873e3128' into eclair-plus-aosp

* commit 'f355096a64b74c8e869527de55f7e908873e3128':
  Remove NEON optimizations for memcpy
2009-09-27 07:19:59 -07:00
David 'Digit' Turner
f355096a64 Remove NEON optimizations for memcpy 2009-09-27 07:08:46 -07:00
David 'Digit' Turner
4a05d12cf5 Fix TLS access for ARMv6 and beyond.
For performance reasons, we don't call the kernel helper. Instead, we directly
access the TLS register on ARMv6 and higher. For ARMv5TE, keep using the hard-coded
address populated by the kernel on each task switch.

NOTE: Since we don't call the kernel helper, this must precisely match your
      kernel configuration. This is controlled by setting the ARCH_ARM_HAVE_TLS_REGISTER
      variable to 'true' in your board configuration file.
2009-09-22 10:03:59 -07:00
Ben Cheng
b8a18d059b am bd192b47: Add stack unwinding directives to assembly leaf functions.
Merge commit 'bd192b470b69e00e9313680b70c5572a609e535d' into eclair-plus-aosp

* commit 'bd192b470b69e00e9313680b70c5572a609e535d':
  Add stack unwinding directives to assembly leaf functions.
2009-09-15 14:51:10 -07:00
Ben Cheng
bd192b470b Add stack unwinding directives to assembly leaf functions.
So that the real culprit of native crashes can surface in the stack trace.
2009-09-15 13:41:14 -07:00
Jean-Baptiste Queru
cdeb4c8afa merge from open-source master 2009-09-15 07:51:39 -07:00
vinay harugop
76ec6891e2 ARM architecture reference manuals for ARMv6 & ARMv7 state that the use of 'swp' instruction is deprecated
ARMv6 onwards. These architectures provide the load-linked, store-conditional pair of ldrex/strex whose use
is recommended in place of 'swp'. Also, the description of the 'swp' instruction in the ARMv6 reference
manual states that the swap operation does not include any memory barrier guarantees.This fix attempts to
address these issues by providing an atomic swap implementation using ldrex/strex under _ARM_HAVE_LDREX_STREX
macro.  This Fix is verified on ST Ericsson's U8500 platform and Submitted on behalf of a third-party:
Surinder-pal SINGH from STMicroelectronics.
2009-09-09 21:01:46 +05:30
David 'Digit' Turner
1bbc56cd22 Neon-optimized versions of memcpy.
This optimization come from the external 0xdroid repository.
Original patch can be found here:

ebafe41c2c
2009-09-02 23:21:52 +02:00
David 'Digit' Turner
3a654b1e04 Revert "Fix the C library initialization to avoid calling static C++ constructors twice."
This reverts commit 03eabfe65e.
2009-06-03 19:32:37 +02:00
David 'Digit' Turner
03eabfe65e Fix the C library initialization to avoid calling static C++ constructors twice.
The problem was due to the fact that, in the case of dynamic executables,
the dynamic linker calls the DT_PREINIT_ARRAY, DT_INIT and DT_INIT_ARRAY
constructors when loading shared libraries and dynamic executables,
*before* calling the executable's entry point (i.e. arch-$ARCH/bionic/crtbegin_dynamic.c)
which in turns call __libc_init() in libc.so, as defined by bionic/libc_init_dynamic.c

The latter did call these constructors array again, mistakenly.

The patch also updates the documentation of many related functions.

Also adds a new section to linker/README.TXT explaining restrictions on
C library usage.

The patch has been tested on a Dream for stability issues with
proprietary blobs:

- H264 decoding works
- Camera + Video recording works
- GPS works
- Sensors work

The tests in system/extra/tests/bionic/libc/common/test_static_cpp_mutex.cpp has been
run and shows the static C++ constructor being called only once.
2009-06-02 23:27:44 +02:00
The Android Open Source Project
1dc9e472e1 auto import from //depot/cupcake/@135843 2009-03-03 19:28:35 -08:00
The Android Open Source Project
1767f908af auto import from //depot/cupcake/@135843 2009-03-03 18:28:13 -08:00
The Android Open Source Project
6f04a0f4c7 auto import from //branches/cupcake/...@132276 2009-02-19 10:57:29 -08:00
The Android Open Source Project
6d6c82c7a0 auto import from //branches/cupcake/...@125939 2009-01-09 17:50:54 -08:00
The Android Open Source Project
4e468ed2eb Code drop from //branches/cupcake/...@124589 2008-12-17 18:03:48 -08:00
The Android Open Source Project
a27d2baa0c Initial Contribution 2008-10-21 07:00:00 -07:00