Commit graph

484 commits

Author SHA1 Message Date
Russell Webb
ac3fc00ca2 Remove SIZE_MAX definition in limits.h
the POSIX standard is that SIZE_MAX is defined
in stdint.h, not limits.h.

Change-Id: Iafd8ec71d1840541feaca4f53b2926b398293fac
Signed-off-by: Webb, Russell <russell.webb@intel.com>
Signed-off-by: Fengwei Yin <fengwei.yin@intel.com>
Reviewed-by: Ross, Andrew J <andrew.j.ross@intel.com>
Reviewed-by: Boie, Andrew P <andrew.p.boie@intel.com>
Reviewed-by: Gumbel, Matthew K <matthew.k.gumbel@intel.com>
Tested-by: Gumbel, Matthew K <matthew.k.gumbel@intel.com>
2014-03-31 22:38:14 +08:00
Christopher Ferris
d8fe15fdb6 Merge "add 32-bit bionic implementation for denver arch" 2014-03-31 03:30:13 +00:00
Andrei Emeltchenko
8f2a30a92a Add accept4() syscall
Add accept4() using SYSCALLS.TXT and gensyscall

Change-Id: I6f19f29144186d15d46423e10f2cc4b4223719c6
2014-03-26 15:50:01 +02:00
Shu Zhang
5b5d6e7045 add 32-bit bionic implementation for denver arch
Add 32-bit bionic implementation for denver. Use denver version of memcpy/
memset. Use Cortex-A15 version of strlen/strcat/strcpy/strcmp.

Change-Id: I4c6b675f20cf41a29cadf70a11d1635d7df5b30a
2014-03-26 13:57:01 +08:00
Guillaume Ranquet
6ff0c75c83 Add recvmmsg and sendmmsg syscalls.
Also add the corresponding constant, struct, and function declarations
to <sys/socket.h>, and perfunctory tests so we know that the symbols
actually exist.

Signed-off-by: Guillaume Ranquet <guillaumex.ranquet@intel.com>
Change-Id: Ib0d854239d3716be90ad70973c579aff4895a4f7
2014-02-27 14:29:01 -08:00
Elliott Hughes
53e43292aa More OpenBSD cleanup (primarily string).
This patch removes the string/ and wchar/ directories.

Change-Id: Ia489904bc67047e4bc79acb1f3eec21aa3fe5f0d
2014-02-24 18:02:05 -08:00
Elliott Hughes
b8dc9bbd90 Stop asking GCC to cause trouble.
Why do we see so many bogus strict-aliasing warnings? Because we asked GCC to
cause trouble on arm and mips.

Change-Id: I25d7fd036b6afff7ccfa799abe0dc1579ead2847
2014-02-20 14:35:20 -08:00
Elliott Hughes
851e68a240 Unify our assembler macros.
Our <machine/asm.h> files were modified from upstream, to the extent
that no architecture was actually using the upstream ENTRY or END macros,
assuming that architecture even had such a macro upstream. This patch moves
everyone to the same macros, with just a few tweaks remaining in the
<machine/asm.h> files, which no one should now use directly.

I've removed most of the unused cruft from the <machine/asm.h> files, though
there's still rather a lot in the mips/mips64 ones.

Bug: 12229603
Change-Id: I2fff287dc571ac1087abe9070362fb9420d85d6d
2014-02-20 13:51:26 -08:00
Elliott Hughes
09289d92f9 Remove useless _C_LABEL from our assembler source.
Change-Id: I41a9181537c70ecc69ef8035132c9a83811a40d0
2014-02-20 11:51:11 -08:00
Elliott Hughes
bfa2b6fc6a Merge "Stop advertising an arm32-specific hack like it's a build system feature." 2014-02-20 19:41:15 +00:00
Elliott Hughes
6e39ba73bf Stop advertising an arm32-specific hack like it's a build system feature.
Change-Id: I3a830b4a3516b6eb8e4f8e6e6b122a22a2e341df
2014-02-20 11:36:55 -08:00
Dmitriy Ivanov
adab51aefd Added script generating additions to libgcc_compat.c from linker errors
bug: 12234455
Change-Id: Icac35237f06e75745da5a91d9c4c941d7df4f84d
2014-02-20 11:34:08 -08:00
Elliott Hughes
986f906710 Fix build by avoiding the _C_LABEL macro.
Change-Id: Ide367c2b65071388bd95fbc81a4ed6ae94aec4e4
2014-02-18 16:42:36 -08:00
Elliott Hughes
db1ea34748 Implement some of the missing LFS64 support.
This gives us:

* <dirent.h>
  struct dirent64
  readdir64, readdir64_r, alphasort64, scandir64

* <fcntl.h>
  creat64, openat64, open64.

* <sys/stat.h>
  struct stat64
  fstat64, fstatat64, lstat64, stat64.

* <sys/statvfs.h>
  struct statvfs64
  statvfs64, fstatvfs64.

* <sys/vfs.h>
  struct statfs64
  statfs64, fstatfs64.

This also removes some of the incorrect #define hacks we've had in the
past (for stat64, for example, which we promised to clean up way back
in bug 8472078).

Bug: 11865851
Bug: 8472078
Change-Id: Ia46443521918519f2dfa64d4621027dfd13ac566
2014-02-18 15:39:24 -08:00
Ying Wang
f25d677147 Reconfig libc's Android.mk to build for multilib
1. Moved arch-specific setup to their own files:
    - <arch>/<arch>.mk, arch-specific configs. Variables in those config
      end with the arch name.
    - removed the extra complexity introduced by function libc-add-cpu-variant-src,
      which seems to be not very useful these days.
2. Separated out the crt object files generation rules and set up the
   rules for both TARGET_ARCH and TARGET_2ND_ARCH.
3. Build all the libraries for both TARGET_ARCH and TARGET_2ND_ARCH,
  with the arch-specific LOCAL_ variables.

Bug: 11654773
Change-Id: I9c2d85db0affa49199d182236d2210060a321421
2014-02-12 13:58:34 -08:00
Elliott Hughes
b3a23bd017 Build syscall stubs in their own library.
This lets us lose the auto-generated makefiles.

Change-Id: I2de0c71b3b9c08f9cce8f4ff7fd7254dda008c86
2014-02-11 13:52:02 -08:00
Elliott Hughes
0266ae5f88 Switch <elf.h> over to linux uapi under the covers.
Remove the linker's reliance on BSD cruft and use the glibc-style
ElfW macro. (Other code too, but the linker contains the majority
of the code that needs to work for Elf32 and Elf64.)

All platforms need dl_iterate_phdr_static, so it doesn't make sense
to have that part of the per-architecture configuration.

Bug: 12476126
Change-Id: I1d7f918f1303a392794a6cd8b3512ff56bd6e487
2014-02-10 18:22:24 -08:00
Elliott Hughes
9afe2884c7 Kill <machine/_types.h>.
Most of <machine/_types.h> was either unused, wrong, or identical across
all 32-/64-bit architectures.

I'm not a huge fan of <sys/_types.h> either, but moving the bits we need
up into there is a step forward.

Bug: 12213562
Change-Id: Id13551c78966e324beee2dd90c5575e37d2a71e6
2014-02-04 19:26:31 -08:00
Elliott Hughes
f64b8ea09d Add fallocate/fallocate64/posix_fallocate/posix_fallocate64.
Bug: 5287571
Bug: 12612860
Change-Id: I4501b9c6cdf9a830336ce0b3afc4ea716b6a0f6f
2014-02-03 16:20:46 -08:00
Ben Cheng
62ffe14a7e Add all implicitly loaded symbols from libgcc.a into libgcc_compat.c.
Change-Id: I0e66a73e849a01817d016a688d7291c2fb604e48
2014-01-24 15:20:11 -08:00
Bernhard Rosenkränzer
f38fb19d9d Re-export libgcc's __aeabi_uidivmod and __popcount_tab
This is required to make the Nexus 10 graphics driver work on a system
compiled with gcc 4.9.

Change-Id: If3f3d488652a736d9ea3e583548d74fae3ffa902
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
2014-01-24 12:57:13 +01:00
Elliott Hughes
0f461e35f6 Fix <sys/resource.h>.
The situation here is a bit confusing. On 64-bit, rlimit and rlimit64 are
the same, and so getrlimit/getrlimit64, setrlimit/setrlimit64,
and prlimit/prlimit64 are all the same. On 32-bit, rlimit and rlimit64 are
different. 32-bit architectures other than MIPS go one step further by having
an even more limited getrlimit system call, so arm and x86 need to use
ugetrlimit instead of getrlimit. Worse, the 32-bit architectures don't have
64-bit getrlimit- and setrlimit-equivalent system calls, and you have to use
prlimit64 instead. There's no 32-bit prlimit system call, so there's no
easy implementation of that --- what should we do if the result of prlimit64
won't fit in a struct rlimit? Since 32-bit survived without prlimit/prlimit64
for this long, I'm not going to bother implementing prlimit for 32-bit.

We need the rlimit64 functions to be able to build strace 4.8 out of the box.

Change-Id: I1903d913b23016a2fc3b9f452885ac730d71e001
2014-01-09 11:00:04 -08:00
Elliott Hughes
54a7494f17 Regenerate the NOTICE files.
Also standardize the orthography in a few places to reduce near-duplicates
in the NOTICE files.

Change-Id: I347c75e817be61ec1b9c5b4b96226feedc8d09ab
2014-01-07 13:46:11 -08:00
Elliott Hughes
887e1140fe Clean up <sched.h>.
This patch switches to using the uapi constants. It also adds the missing
setns system call, fixes sched_getcpu's error behavior, and fixes the
gensyscalls script now ARM is uapi-only too.

Change-Id: I8e16b1693d6d32cd9b8499e46b5d8b0a50bc4f1d
2014-01-02 12:05:50 -08:00
Elliott Hughes
2aace21a19 Remove the bogus exit status from _exit_with_stack_teardown.
It should always be 0, and there's no reason to pass a constant in as
an argument.

Change-Id: I92ac59b718a18e298bd7c52821af447f9181ca2a
2013-12-21 15:30:49 -08:00
Elliott Hughes
5eccb9646d Fix aarch64 futex assembly routines.
Also make the other architectures more similar to one another,
use NULL instead of 0 in calling code, and remove an unused #define.

Change-Id: I52b874afb6a351c802f201a0625e484df6d093bb
2013-12-20 16:58:06 -08:00
Ben Cheng
e3fb66dd01 Add __popcountsi2 to the function compat list.
This is needed if we use Clang to compile Bionic, which won't include
__popcountsi2 anymore as Clang generates inline instructions. However
prebuilt binary blobs still depend on libc.so to resolve __popcountsi2.

Change-Id: I9001a3884c4be250c0ceebcd79922783fae1a0b7
2013-12-19 16:26:40 -08:00
Elliott Hughes
2b333ea31e Remove <machine/kernel.h>.
Bug: 12175484
Change-Id: I127f7f91f36bd879109d653e0c56ec56e2529d4d
2013-12-18 11:21:55 -08:00
Elliott Hughes
c13fb75cea Move bionic over to GCC's 'warning' attribute.
This is a better solution than the old __warn_references because it's
a compile-time rather than link-time warning, it doesn't rely on something
that doesn't appear to be supported by gold (which is why you only used
to see these warnings on mips builds), and the errors refer to the exact
call site(s) rather than just telling you which object file contains a
reference to the bad function.

This is primarily so we can build bionic for aarch64; building libc.so
caused these warnings to fire (because link time is the wrong time) and
warnings are errors.

Change-Id: I5df9281b2a9d98b164a9b11807ea9472c6faa9e3
2013-12-17 20:43:30 -08:00
Elliott Hughes
c54ca40aef Clean up some ARMv4/ARMv5 cruft.
Change-Id: I29e836fea4b53901e29f96c6888869c35f6726be
2013-12-13 14:02:30 -08:00
Christopher Ferris
ed45970ac5 Add cfi directives to all arm assembly.
Since the ENTRY/END macros now have .cfi_startproc/.cfi_endproc, most of the
custom arm assembly has no unwind information. Adding the proper cfi directives
for these and removing the arm directives.

Update the gensyscalls.py script to add these cfi directives for the generated
assembly. Also fix the references to non-uapi headers to the proper uapi
header.

In addition, remove the kill.S, tkill.S, tgkill.S for arm since they are not
needed at all. The unwinder (libunwind) is able to properly unwind using the
normal abort.

After this change, I can unwind through the system calls again.

Bug: 11559337
Bug: 11825869
Bug: 11321283

Change-Id: I18b48089ef2d000a67913ce6febc6544bbe934a3
2013-12-02 19:13:12 -08:00
The Android Open Source Project
f00c938c7f Merge commit '811b0cdb2d6e4a697dbc63a678712759dd0db242' into HEAD
Change-Id: I786944f80fb1a2d502fed51dc2c391ed5db66761
2013-11-22 13:38:33 -08:00
Christopher Ferris
507cfe2e10 Add .cfi_startproc/.cfi_endproc to ENTRY/END.
Bug: 10414953
Change-Id: I711718098b9f3cc0ba8277778df64557e9c7b2a0
2013-11-19 16:31:24 -08:00
Elliott Hughes
36d6188f8c Clean up forking and cloning.
The kernel now maintains the pthread_internal_t::tid field for us,
and __clone was only used in one place so let's inline it so we don't
have to leave such a dangerous function lying around. Also rename
files to match their content and remove some useless #includes.

Change-Id: I24299fb4a940e394de75f864ee36fdabbd9438f9
2013-11-19 14:08:54 -08:00
Elliott Hughes
877ec6d904 Fix pthread_join.
Let the kernel keep pthread_internal_t::tid updated, including
across forks and for the main thread. This then lets us fix
pthread_join to only return after the thread has really exited.

Also fix the thread attributes of the main thread so we don't
unmap the main thread's stack (which is really owned by the
dynamic linker and contains things like environment variables),
which fixes crashes when joining with an exited main thread
and also fixes problems reported publicly with accessing environment
variables after the main thread exits (for which I've added a new
unit test).

In passing I also fixed a bug where if the clone(2) inside
pthread_create(3) fails, we'd unmap the child's stack and TLS (which
contains the mutex) and then try to unlock the mutex. Boom! It wasn't
until after I'd uploaded the fix for this that I came across a new
public bug reporting this exact failure.

Bug: 8206355
Bug: 11693195
Bug: https://code.google.com/p/android/issues/detail?id=57421
Bug: https://code.google.com/p/android/issues/detail?id=62392
Change-Id: I2af9cf6e8ae510a67256ad93cad891794ed0580b
2013-11-18 19:48:11 -08:00
Elliott Hughes
70b24b1cc2 Switch pthread_create over to __bionic_clone.
Bug: 8206355
Bug: 11693195
Change-Id: I04aadbc36c87e1b7e33324b9a930a1e441fbfed6
2013-11-15 14:41:19 -08:00
Elliott Hughes
ed74484dcb Stop using the non-uapi <linux/err.h> header file.
We only need it for MAX_ERRNO, and it's time we had somewhere to put
the little assembler utility macros we've been putting off writing.

Change-Id: I9354d2e0dc47c689296a34b5b229fc9ba75f1a83
2013-11-07 10:31:05 -08:00
Elliott Hughes
062092543f Clean up the 32-bit kernel support, fix LP64 fcntl declaration.
In practice, thanks to all the registers the stubs don't actually change,
but it's confusing to have an incorrect declaration.

I suspect that fcntl remains broken for aarch64; it happens to work for
x86_64 because the first vararg argument gets placed in the right register
anyway, but I have no reason to believe that's true for aarch64.

This patch adds a unit test, though, so we'll be able to tell when we get
as far as running the unit tests.

Change-Id: I58dd0054fe99d7d51d04c22781d8965dff1afbf3
2013-11-06 16:33:39 -08:00
Elliott Hughes
6b53c2349a Fix the exit syscall stub's name.
I've left the exit_group syscall as _exit because otherwise we'd have to
convince the compiler that our _exit (which just calls __exit_group) is
actually "noreturn", and it seems like that would be less clean than just
cutting out the middleman.

We'll just have to trust ourselves not to add anything to SYSCALLS.TXT
that ought to be private but that only has a single leading underscore.
Hopefully we can manage that.

Change-Id: Iac47faea9f516186e1774381846c54cafabc4354
2013-10-24 22:41:50 -07:00
Elliott Hughes
bf425680e4 Let the compiler worry about implementing ffs(3).
It does at least as good a job as our old hand-written assembly anyway.

Change-Id: If7c4a1ac508bace0b71ee7b67808caa6eabf11d2
2013-10-24 16:29:40 -07:00
Elliott Hughes
11952073af Remove dependencies on obsolete __ARCH_WANT_SYSCALL_DEPRECATED system calls.
(aarch64 kernels don't have these system calls.)

Change-Id: I6f64075aa412f71520f2df71c3d69b647f91c1ca
2013-10-24 15:48:32 -07:00
Elliott Hughes
cac7b9d6ec Remove dependencies on obsolete __ARCH_WANT_SYSCALL_NO_FLAGS syscalls.
(aarch64 kernels only have the newer system calls.)

Also expose the new functionality that's exposed by glibc in our header files.

Change-Id: I45d2d168a03f88723d1f7fbf634701006a4843c5
2013-10-23 09:48:29 -07:00
Elliott Hughes
f8fcfbc85a Move away from the __ARCH_WANT_SYSCALL_NO_AT system calls.
Modern architectures only get the *at(2) system calls. For example,
aarch64 doesn't have open(2), and expects userspace to use openat(2)
instead.

Change-Id: I87b4ed79790cb8a80844f5544ac1a13fda26c7b5
2013-10-22 16:31:01 -07:00
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