History log of /bionic/tests/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
6c69afdb6ddd56e011b59e3060f12a5bdffb5f5c 25-Sep-2014 Christopher Ferris <cferris@google.com> Fix sys_stat.mkfifo when not run as root.

It's not allowed for a shell user to create a fifo in /data/local/tmp.
Make the test do nothing if not run as root.

Bug: 17646702
Change-Id: I932262fa233eae8b5dd607a2398a47c50a208701
00008263782e484020420c606f7d145fe7d0a4d8 11-Sep-2014 Elliott Hughes <enh@google.com> Add posix_fadvise(3).

Bug: 12449798
Change-Id: I07cbf3f670a0d1304b68148325a774f266b5c433
f0e9458ea596227720fa745df15f5357f6c0c8f6 06-Sep-2014 Elliott Hughes <enh@google.com> Don't expose non-standard basename_r and dirname_r in LP64.

Bug: 17407423
Change-Id: I47fe499a4c396bf09d7b78fd828728d04777398b
5beddb7d642524ecb6655ab2823caf2add679917 05-Sep-2014 Elliott Hughes <enh@google.com> Fix pthread_attr_getstack__main_thread.

There were two problems here:

* This would fail when run with unlimited stack, because it didn't know
that bionic reports unlimited stacks as 8MiB.

* This would leave RLIMIT_STACK small, causing failures to exec (so the
popen and system tests would fail).

(cherry-pick of 27a9aed81978af792cb06035a1619c8141a5fb5b plus the
new ScopeGuard.h from a3ad450a2e3fb6b3fe359683b247eba20896f646.)

Bug: 17394276
Change-Id: I5b92dc64ca089400223b2d9a3743e9b9d57c1bc2
9ac60bf82b1f0e316666b862e9924f90caa60342 29-Aug-2014 Hans Boehm <hboehm@google.com> Make stdatomic.h work with gcc4.6 host compiler

This is needed to make L work correctly, and bionic tests pass
again, after applying the equivalent of
commit 00aaea364501b3b0abe58dae461136159df1e356 there.

It makes the preexisting code that uses __sync implementations
much more useful, although we should no longer be exercising that
code in AOSP.

Specifically fixes:

We were invoking __has_extension and __has_builtin for GCC compilations.
They're clang specific. Restructured the tests.

The __sync implementation was not defining the LOCK_FREE macros.

ATOMIC_VAR_INIT was using named field initializations. These are a
C, not C++, feature, that is not supported by g++ 4.6.

The stdatomic bionic test still failed with 4.6 and glibc with our
questionable LOCK_FREE macro implementation. Don't run that piece
with 4.6.

In L, this is a prerequisite for fixing:


Change-Id: I9b61e42307f96a114dce7552b6ead4ad1c544eab
(cherry picked from commit 32429606bf696d3b2ca555f132a0d60c566d0bd0)
c8cf3513ecb265ba3aadc846aa2113290a504c44 20-Aug-2014 Hans Boehm <hboehm@google.com> Fix, generalize stdatomic.h; improve test.

We seem to use this stdatomic.h sometimes, and slightly different prebuilts
at other times, making them all difficult to test, and making it unclear
which one we're testing. This generalizes the bionic header so that it
can be used directly as the prebuilt header as well. So long as they
don't diverge again, that should somewhat improve test coverage.

Use the correct builtin for atomic_is_lock_free.

Fix atomic_flag_init.

Turn on atomic tests even with __GLIBC__, since they now appear to pass.

Include uchar.h in stdatomic.h where needed.

Add a basic memory ordering test.

Fix bit-rotted comments in bionic tests makefile.

Prerequisite for fixing b/16880454 and


Change-Id: If6a14c1075b379395ba5d93357d56025c0ffab68
(cherry picked from commit 00aaea364501b3b0abe58dae461136159df1e356)
67f1f3b171ecd5f68f51465bbe4b8c8440bb6b2e 28-Aug-2014 Elliott Hughes <enh@google.com> Have pthread_attr_getstack for the main thread report RLIMIT_STACK...

...rather than just what's already mapped in. This seems somewhat
contrary to POSIX's "All pages within the stack described by stackaddr
and stacksize shall be both readable and writable by the thread", but
it's what glibc does.

Bug: 17111575

(cherry picked from commit 9e4ffa7032eaab308876b8e3da86b05c3c613878)

Change-Id: I73f219a569917b2e4546c09436d7ef5231facc07
a0eeb0b69fb3840125329026f2172d3fbe177e99 28-Aug-2014 Elliott Hughes <enh@google.com> Merge "Fix pthread_getattr_np for the main thread." into lmp-dev
8a46cf0fcf82b8c76e05be7e066ec854f974603a 26-Aug-2014 Wally Yau <wyau@google.com> call uselocale() before freelocale() to make sure that g_local_key has a valid locale.

For tests that call uselocale(), the locale is stored in the
g_userlocale_key thread-specific key. If freelocale() is called later,
then g_uselocal_key points to a deleted pointer. CTS eventually calls
vfprintf to print the result, which calls MB_CUR_MAX and MB_CUR_MAX
accesses the deleted locale stored in g_uselocale_key, causing unpredictable

Fixed the tests by calling uselocale() with the old locale before
calling freelocale.

Bug: 17299565
Change-Id: I87efa2a9b16999a11d587f68d3aeedcbe6ac8a2c
642182341018b282148280a7bdb771493e15bd7d 26-Aug-2014 Elliott Hughes <enh@google.com> Fix pthread_getattr_np for the main thread.

On most architectures the kernel subtracts a random offset to the stack
pointer in create_elf_tables by calling arch_align_stack before writing
the auxval table and so on. On all but x86 this doesn't cause a problem
because the random offset is less than a page, but on x86 it's up to two
pages. This means that our old technique of rounding the stack pointer
doesn't work. (Our old implementation of that technique was wrong too.)

It's also incorrect to assume that the main thread's stack base and size
are constant. Likewise to assume that the main thread has a guard page.
The main thread is not like other threads.

This patch switches to reading /proc/self/maps (and checking RLIMIT_STACK)
whenever we're asked.

Bug: 17111575
Signed-off-by: Fengwei Yin <fengwei.yin@intel.com>

(cherry picked from commit 57b7a6110e7e8b446fc23cce4765ff625ee0a105)

Change-Id: I87e679ee1c0db8092f2d1221c8e7c1461545c5a4
84d0683a824fa02dbaa6d1b56a79223804b54e80 22-Aug-2014 Elliott Hughes <enh@google.com> Fix unistd.getpid_caching_and_clone.

This test only works if you're root (strictly: if you have permission to
CLONE_NEWNS), so it's useful to us when we're doing ad hoc testing (since
that's usually done as root), but it's not useful as part of CTS or when
running the tests on the host.

Bug: 16705621
Bug: 17170200
Change-Id: Ia92c871b15f7e45fc174bb59bc95540fd00ae745
9419420919ea846bbad5510850c7aaec95021648 19-Aug-2014 Dmitriy Ivanov <dimitry@google.com> Revert "Add support for protected local symbol lookup."

This reverts commit d97e9f546ea195686a78e539315b273393609b9e.

Bug: 17107521
Change-Id: I2b81ce2b5a4a2d166133a2626e49d81b6aef3672
3e7b8e2a8bd16a37cecdae1135a5e7fc6e64c762 07-Aug-2014 Christopher Ferris <cferris@google.com> Merge "Do a second key cleanup in pthread_exit." into lmp-dev
18d93f2793fad393b6aa6eae6afe1054958339d5 06-Aug-2014 Christopher Ferris <cferris@google.com> Do a second key cleanup in pthread_exit.

During pthread_exit, the keys are cleaned. Unfortunately, a call to
free occurs after the cleanup and the memory for some of the keys
is recreated when using jemalloc. The solution is to do the key
cleanup twice.

Also, modify the pthread_detach__leak test to be less flaky
when run on a jemalloc system.

Bug: 16513133
Change-Id: Ic17e8344bdc1ba053c4f5b6d827a4c19c57860c1
bc0d65c114f3ead6d89f8e92622bc941d731b01c 06-Aug-2014 Dan Albert <danalbert@google.com> Merge "Proper MB_CUR_MAX." into lmp-dev
6035e6cc8317600c3100fdf1070890c3e42715a7 30-Jul-2014 Dan Albert <danalbert@google.com> Proper MB_CUR_MAX.

Previously this was hard coded to 4. This is only the case for UTF-8

As a side effect, this properly reports C.UTF-8 as the default locale
instead of C.

Change-Id: I7c73cc8fe6ffac61d211cd5f75287e36de06f4fc
(cherry picked from commit 1aec7c1a35b2d03038b194967d5ebdc8e2c24b80)
938a8008a61ecb6e975aa974dbf30ea7e1f298e2 31-Jul-2014 Dan Albert <danalbert@google.com> Fix mbsrtowcs(3) src param for finished string.

A mistake I made while cleaning this up the first time through.
mbstrtowcs(3) sets the src param to null if it finishes the string.

Change-Id: I6263646e25d9537043b7025fd1dd6ae195f365e2
(cherry picked from commit b6cc8e00cd562bd0f81fe44a6bc646540a862f32)
db7a17d4ff56a05af01ee2fee1f3c55245bfc630 05-Aug-2014 Dmitriy Ivanov <dimitry@google.com> Revert "Revert "Fix dlsym(3) to do breadth first search.""

This reverts commit 1b1966d9448e979d1503a3d8843708bfa8880dc6.

Change-Id: I05d6d3481aaf8f3e260d2e5e950248519a1d347f
1b1966d9448e979d1503a3d8843708bfa8880dc6 04-Aug-2014 Dmitriy Ivanov <dimitry@google.com> Revert "Fix dlsym(3) to do breadth first search."

This reverts commit 422106a24d620af4be58e8d92a2e9b7b6167b72d.

Change-Id: I9e26a6933d10eb30438b521450f2010997ca5aee
61833de613990f2fdaf357bb3d854d72a4980890 31-Jul-2014 Christopher Ferris <cferris@google.com> Fix memchr with a zero length.

The memchr implementation for 64 bit fails if these conditions occur:

- The buffer is 32 byte aligned.
- The buffer contains the character in the first byte.
- The count sent in is zero.

The function should return NULL, but it's not.

Bug: 16676625

(cherry picked from commit e03e1eac0b7682884b6628df1305d34299680cb4)

Change-Id: Ie4cca2c445127a0936ee2b96651a8e7204fbaffd
11bf8a3025a7b5aee891c521255a7db1860e5b12 30-Jul-2014 Elliott Hughes <enh@google.com> Only wipe TLS for user-supplied stacks.

Bug: 16667988

(cherry picked from commit 40a521744825b6060960c296d5fb3da4c6593d94)

Change-Id: I7550fa47b76e643323aa3e2a53529e393c829e47
a1a813da8184153606bfcf8ffcce557eda09a5ba 30-Jul-2014 Dan Albert <danalbert@google.com> Merge "Fix mbsrtowcs(3)'s handling of len parameter." into lmp-dev
4e5860958767ecc7bc455d2a5e1d2a2096a1c79f 20-Jul-2014 Dan Albert <danalbert@google.com> Fix mbsrtowcs(3)'s handling of len parameter.

The len parameter is a _maximum_ length. The previous code was treating
it as an exact length, causing the following typical call to fail:

mbsrtowcs(out, &in, sizeof(out), state); // sizeof(out) > strlen(in)

Change-Id: I48e474fd54ea5f122bc168a4d74bfe08704f28cc
(cherry picked from commit 6b55ba54eff4657cffe053b71e1c9cce2944a8a9)
2ea0a58e01c1ed6db1da9dd0314ee053f5a32026 26-Jul-2014 Elliott Hughes <enh@google.com> Fix linkage of grantpt(3).

Also clean up the implementation of all the pty functions, add tests,
and fix the stub implementations of ttyname(3) and ttyname_r(3).

Bug: https://code.google.com/p/android/issues/detail?id=58888

(cherry picked from commit 4916706cfe590eb06c9b5bd4bd402ce056034d51)

Change-Id: I5cb7a1c17b156456e4c4818e65f256eb8d045424
78e4f8fed2c162f8ada55180e48487ef2180cf93 28-Jul-2014 Elliott Hughes <enh@google.com> syscall(3)'s return type should be long.

This doesn't require us to change any of the syscall implementations
because (a) the LP32 ones have sizeof(int) == sizeof(long) anyway,
which is how we never noticed this bug before and (b) the LP64 ones
all use a 64-bit register for the result (and for the syscall number

Bug: https://code.google.com/p/android/issues/detail?id=73952
Bug: 16568314

(cherry picked from commit 21972b61ec0572395c5684eebc6cc7b3a4c9e3be)

Change-Id: Ifbc424be29e5650ec72a24df25dd35f24fdd5b3c
b1b60c30bf321c0fc02264b953b5c16c49d34457 26-Jul-2014 Elliott Hughes <enh@google.com> Use vsnprintf(3) in syslog(3).

It seemed like a clever trick to use the internal log message formatting
code in syslog(3), but on reflection that means you can't (for example)
format floating point numbers. This patch switches us over to using good
old vsnprintf(3), even though that requires us to jump through a few hoops.

There's no obvious way to unit test this, so I wrote a little program and
ran that.

Bug: 14292866
Change-Id: I9c83500ba9cbb209b6f496067a91bf69434eeef5
708c11205443cda14cfb21138d441106aa77a5f9 25-Jul-2014 Elliott Hughes <enh@google.com> Start hiding "private/bionic_time.h".

Bug: 15765976

(cherry picked from commit 905e6d58aaf515bf237e62078f8a321920fe4c6b)

Change-Id: Ic7435308e8b521886f42ac7bf59531924921ea67
422106a24d620af4be58e8d92a2e9b7b6167b72d 29-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Fix dlsym(3) to do breadth first search.

dlsym(3) with handle != RTLD_DEFAULT|RTLD_NEXT performs
breadth first search through the dependency tree.

Bug: 16653281

(cherry picked from commit aa0f2bdbc22d4b7aec5d3f8f5f01eaeaa13414c2)

Change-Id: I0ba8c2034ab341f8a279cdb4e2e7e47f1aef7897
34b258dd692951ab2236e134e5520367cda60125 25-Jul-2014 Raghu Gandham <raghu.gandham@imgtec.com> [MIPS] Fix atomic_is_lock_free test for mips32.
On 32-bit MIPS, 64-bit atomic ops are achieved through locks.
So allow the test to fail for atomic_intmax_t on 32-bit MIPS.

(cherry picked from commit f1837377d215a6eda294b6ac7552b226deee91ce)

Change-Id: I973d999c31c9ab89b5a7b709beff6486b93408f2
b902641d7303d2ea24c10f6d6e7ff49e7ee75611 24-Jul-2014 Elliott Hughes <enh@google.com> Implement twalk(3), add unit tests.

I've also added insque(3) and remque(3) (from NetBSD because the OpenBSD
ones are currently broken for non-circular lists).

I've not added the three hash table functions that should be in this header
because they operate on a single global hash table and thus aren't likely
to be useful.

Bug: https://code.google.com/p/android/issues/detail?id=73719

(cherry picked from commit 3e424d0a241f8ae5194514dabc4ad899f5a5416d)

Change-Id: I5882a6b48c80fea8ac6b9c27e7b9de10b202b4ff
92d8b2320a4c3911452227f560ae4a39e83b0abf 23-Jul-2014 Nick Kralevich <nnk@google.com> debuggerd: if PR_GET_DUMPABLE=0, don't ask for dumping

PR_GET_DUMPABLE is used by an application to indicate whether or
not core dumps / PTRACE_ATTACH should work.

Security sensitive applications often set PR_SET_DUMPABLE to 0 to
disable core dumps, to avoid leaking sensitive memory to persistent
storage. Similarly, they also set PR_SET_DUMPABLE to zero to prevent
PTRACE_ATTACH from working, again to avoid leaking the contents
of sensitive memory.

Honor PR_GET_DUMPABLE when connecting to debuggerd. If an application
has said it doesn't want its memory dumped, then we shouldn't
ask debuggerd to dump memory on its behalf.

FORTIFY_SOURCE tests: Modify the fortify_source tests to set
PR_SET_DUMPABLE=0. This reduces the total runtime of
/data/nativetest/bionic-unit-tests/bionic-unit-tests32 from approx
53 seconds to 25 seconds. There's no need to connect to debuggerd
when running these tests.

Bug: 16513137

(cherry picked from commit be0e43b77676338fd5e6a82c9cc2b6302d579de2)

Change-Id: I6e1a9bce564e94fc19893d639b15f38c549cabfa
b76613627d045acd3bdb7294f424f14c21584872 22-Jul-2014 Elliott Hughes <enh@google.com> Rewrite syslog(3) to use Android logging.

Since we don't have syslogd on Android and you can't run one on a non-rooted
device, it's more useful if syslog output just goes to the regular Android
logging system.

Bug: 14292866

(cherry picked from commit 3ad8ecb64e9dd5614169232b84a93eb3b8aa32d7)

Change-Id: I3038855ca4f22532bf6d2c45d3f8028b866975f9
3002131da33401cf1b45abbdbec58b7c751fc43a 16-Jul-2014 Elliott Hughes <enh@google.com> Use VDSO for clock_gettime(2) and gettimeofday(2).

Bug: 15387103

(cherry picked from commit 625993dfbb085a3cde7492eda8ec1cdc1ee39a78)

Change-Id: I0e156d7049ba1495902259071a96936592e74025
99ae0983c0fd22e34e4d2aa61942b04e347447ee 14-Jul-2014 Elliott Hughes <enh@google.com> Implement rand/srand in terms of random/srandom.

Code developed for glibc or older versions of bionic might expect more
randomness than the BSD implementation provides.

Bug: 15829381

(cherry picked from commit 76c241b091b4d9d9a9237d40e814e52ce2917f47)

Change-Id: If721b3f16efdb21cb67df5ec5034c0ba905bd029
8e32b7b3543eadbb58a92443fb57d60aac92ef88 11-Jul-2014 Christopher Ferris <cferris@google.com> Make jemalloc the default choice.

Change-Id: I5ff0cf0c396b7ae6278e6fcd5a0d50f8b966fb54
6cdd0cfd2f279dfb20b9f7cccc963eb9ee91c666 09-Jul-2014 Ying Wang <wangying@google.com> Merge "TARGET_OUT_DATA_NATIVE_TESTS now points to $(TARGET_OUT_DATA)/nativetest64 in 64-bit target"
dc42e20d54f17cbcabb2e8584398566eb66c47c3 09-Jul-2014 Ying Wang <wangying@google.com> TARGET_OUT_DATA_NATIVE_TESTS now points to $(TARGET_OUT_DATA)/nativetest64 in 64-bit target

Change-Id: I9a562e79de7ec0f065c90de9ae1b72cbcd7d8c6b
f8846a45878faa9eb51fab3a2b347e9a36ecd250 09-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Add test for constructor function.

Change-Id: I0ad26d617f00cdd6c2241d613be39a1d16918612
950a435fc0dffc22a816194af175420176b86908 03-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Merge "Load library using file handle."
04dc91ae763adc403a14c88b4c46f77b3d2d71a3 01-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Load library using file handle.

* This patch enables dlopen by file descriptor
instead of path/name.

Bug: 15984217
Change-Id: Ib39051e00567fb97070bf96d8ce63993877c0a01
d06ee1d6db6165126161044fb662301bf9f04b3a 02-Jul-2014 Elliott Hughes <enh@google.com> Build all bionic test files -Werror and fix our one warning.

Change-Id: I62bb0528fd1bcb9aa4c61e44c78158a592690fc7
ce0ba3c70634d5fe64b9a298d8a305d85bd1e6ac 02-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Disable local/protected symbol test for lp64

* Static linker optimizes protected local symbol
out of existence, which leads to test failure.
Disabling it for now.

Change-Id: I8de327e5073f98b64639f7a0bba3a273aa419884
fcac81ef04ade6f31eddb71bfc9a30a1ecf47840 02-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Native tests are now multilib=both by default

Change-Id: I788ac0b871703c137727a65e017c4466127c0190
d97e9f546ea195686a78e539315b273393609b9e 29-Jun-2014 Dmitriy Ivanov <dimitry@google.com> Add support for protected local symbol lookup.

Bug: http://code.google.com/p/android/issues/detail?id=66048
Change-Id: Ib334223df27adad9477fb241ab099c5e26df4a7d
3a657d01eca1529ba7002cbee44e149988834c9d 27-Jun-2014 Christopher Ferris <cferris@google.com> Add extra strchr testing.

Change-Id: Idd0a779eb3388e402cfcb4e0df40872320f8e155
ebb770f90d9a8d7f75a9d8b0e6a96ded96c617af 25-Jun-2014 Elliott Hughes <enh@google.com> Add a new pthread_key_delete test.

Bug: https://code.google.com/p/android/issues/detail?id=66813
Change-Id: Ida87bc1fb15a73a08c223a7099456d9f049cd3c5
3f525d41c2acde2ae3309cf839d83d7f41ab2fe6 25-Jun-2014 Elliott Hughes <enh@google.com> Add splice, tee, and vmsplice.

Change-Id: I5f43380b88d776a8bb607b47dbbc5db5a2fe6163
fa9e16efaf0e885f6044e725eb759ef6de10f7ef 24-Jun-2014 Elliott Hughes <enh@google.com> Fix getpid caching across a clone.

If you make clone, fork, or vfork system calls directly, you're still
on your own, but we now do the right thing for the clone wrapper.
With this implementation, children lose the getpid caching, but we've
no reason to think that that covers any significant use cases.

Bug: 15387103
Change-Id: Icfab6b63c708fea830960742ec92aeba8ce7680d
7086ad6919feb2415c6027163f5c63323bcca27c 20-Jun-2014 Elliott Hughes <enh@google.com> Cache getpid.

In practice, with this implementation we never need to make a system call.
We get the main thread's tid (which is the same as our pid) back from
the set_tid_address system call we have to make during initialization.
A new pthread will have the same pid as its parent, and a fork child's
main (and only) thread will have a pid equal to its tid, which we get for
free from the kernel before clone returns.

The only time we'd actually have to make a getpid system call now is if
we take a signal during fork and the signal handler calls getpid. (That,
or we call getpid in the dynamic linker while it's still dealing with its
own relocations and hasn't even set up the main thread yet.)

Bug: 15387103
Change-Id: I6d4718ed0a5c912fc75b5f738c49a023dbed5189
ce44166c737b6737c3a0820bef10b074a5e36cf8 18-Jun-2014 Dmitriy Ivanov <dimitry@google.com> Fix weak function lookups

* Linker now correctly resolves function defined
with __attribute__((weak)).

Bug: https://code.google.com/p/android/issues/detail?id=70206
Change-Id: I82efb905676c25fefb1b11a13f5fecb0f1384657
1f5e1a3cbc564c593fe1090894ecdb070f36e20c 03-Jun-2014 Dmitriy Ivanov <dimitry@google.com> Move libraries for unit-tests to separate folder

Change-Id: I1653f3f2fd63ba25525369bc725c8f7438ecf021
636196438180fd37027bf7b7119a436169b6923e 17-Jun-2014 Christopher Ferris <cferris@google.com> Use a separate config.h for config like defines.

This allows an easier way to share config parameters between unit tests
and the bionic code.

It also fixes a problem where the 32 bit bionic tests based on glibc, or
the cts list executable did not have the pvalloc,valloc tests.

Change-Id: Ib47942cb8a278252faa7498a6ef23e9578db544f
e5fdaa4f9d102461a4d8a865e6ca84666893b9e7 14-Jun-2014 Dan Albert <danalbert@google.com> Revert "Backing this one out since the counterpart needs to be sent upstream."

This reverts commit a04d2bc28e7d7fcaf34ad71e4a6608a13cf84197.

Change-Id: I1b49165ca5d4bafdba7948818256a6167a363aca
a04d2bc28e7d7fcaf34ad71e4a6608a13cf84197 14-Jun-2014 Dan Albert <danalbert@google.com> Backing this one out since the counterpart needs to be sent upstream.

This reverts commit 5ee320dd35fafc11eaf90c62198e08c6670e35b4.

Change-Id: I1a9c6b06c3aca595f01c629f7649be743dc48e77
5ee320dd35fafc11eaf90c62198e08c6670e35b4 12-Jun-2014 Dan Albert <danalbert@google.com> Hides valloc(3)/pvalloc(3) on LP64.

These were removed from POSIX 2004. Hides the header declarations for all
targets, and hides the symbols for LP64.

Bug: 13935372
Change-Id: Id592f67e9b7051517a05f536e1373b30162e669c
5d25d5480ab1e02d8f1e39f5936a3180e84a842c 13-Jun-2014 Elliott Hughes <enh@google.com> Merge "Remove __memcmp16 from bionic."
24614b4729a4c8665193f5793b93019b37f779b1 13-Jun-2014 Elliott Hughes <enh@google.com> Remove __memcmp16 from bionic.

Change-Id: I2486d667d96c8900dd368d855f37c1327161efb7
29ddd78c21b15117bc7d4fc196f3a503f3aab3e2 13-Jun-2014 Christopher Ferris <cferris@google.com> Merge "Put all allocation functions into dispatch table."
a403780538ac9d1a260e064df6599663f8cc4166 10-Jun-2014 Christopher Ferris <cferris@google.com> Put all allocation functions into dispatch table.

Implement these new functions for all of the debug malloc types.

Fix a number of bugs in the debug malloc functions related to overflow
Fix a bug in dlpvalloc due to an overflow condition.

Fix various other bugs in the debug malloc functions.

Add new tests for malloc functions.

Bug: 11225066

Change-Id: Idf50f389603e2157645565bc15cd9365eec2e9dd
346fa721ca20e481a624930425d823d452e11dfe 12-Jun-2014 Elliott Hughes <enh@google.com> Merge "Get the full set of PRNG functions in <stdlib.h>"
a0beeeabbc8735bc830544cbbb1d920122b8d958 12-Jun-2014 Elliott Hughes <enh@google.com> Get the full set of PRNG functions in <stdlib.h>

Bug: https://code.google.com/p/android/issues/detail?id=58888
Change-Id: I435250bdae302e8bd7e29977d0fde7b9afbfca5e
3d5e0b2045f899e27a071dc228dafc9378e90798 12-Jun-2014 Christopher Ferris <cferris@google.com> Merge "Add/Remove mmap tests."
eda26bc1ffc60dc722a375095b9de4fd86959a1d 12-Jun-2014 Christopher Ferris <cferris@google.com> Add/Remove mmap tests.

Remove the incorrect tests that use a negative offset for mmap without
a fd.

Add a small set of tests for mmap.

Bug: 15436969

Change-Id: Id537d33cd4cdc26dee6cdfa9bf9cf35754bce335
37b845f9e410e326f24fa8c820774d92eafa4dd3 12-Jun-2014 Dan Albert <danalbert@google.com> Merge "Remove declaration for putw(3)/getw(3)."
8e613cf342b369f7985135dbe11ebdbf8c736157 11-Jun-2014 Dan Albert <danalbert@google.com> Remove declaration for putw(3)/getw(3).

These were both removed from POSIX 2004, and we don't define an
implementation for getw(3). Keep the definition of put(3) on LP32 for
binary compatibility.

Bug: 13935372
Change-Id: Iba384b45093ac6d2d7c2d81f7980cd7701dd6f56
e9f7a9c340a3af11de720042fdc5061b65dc9b78 11-Jun-2014 Christopher Ferris <cferris@google.com> Allow bionic-unit-tests-glibc to be built again.

When we switched to 64 bit host build be default, we no longer build
the glibc unit tests. Fix that, and also set all host targets to build

This change also changes the name of bionic-unit-tests-glibc to add
the suffix of 32 or 64 depending on the host type built.

Change-Id: Ife13f9d80f351750ff02825b086d44bb0c2df828
68b01665b35849859f26f58f3044618b626abc2b 11-Jun-2014 Alexander Ivchenko <alexander.ivchenko@intel.com> Fix mbrtoc32 test from tests/uchar_test.cpp for x86.

Without that fix the test fails with:
"error: comparison between signed and unsigned integer expressions" on x86,
due to the fact that char is signed on x86.

Change-Id: I44462d67c15c7e9b730ad5da52eb9c05e207d34b
Signed-off-by: Alexander Ivchenko <alexander.ivchenko@intel.com>
2aca7fe8214d9b4f421499a6f07579c888313649 10-Jun-2014 Serban Constantinescu <serban.constantinescu@arm.com> AArch64: Fix memcmp16() test

__memcmp16() should return an integer less than, equal to, or greater than
zero. However the tests looks for a specific value.

Change-Id: I06052f58f9ccc67146a3df9abb349c4bc19f090e
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
199e8638df12eb6373771ebb59a1f5a83c6de1cc 10-Jun-2014 Ying Wang <wangying@google.com> Merge "Use PRIVATE_POST_INSTALL_CMD to create symlink."
7f722b366aad52000465818ffbdc880676be9aae 10-Jun-2014 Ying Wang <wangying@google.com> Use PRIVATE_POST_INSTALL_CMD to create symlink.

Bug: 15520908
Change-Id: Ib3349f7adb6def81abf07bfb9d37093e4a599d09
18b17e97757a59718a23f8128dfc91c016df08b1 07-Jun-2014 Elliott Hughes <enh@google.com> Add a regression test for two libm bugs we didn't have.

Reported on the OpenBSD list, but we already had the fix for one from FreeBSD,
and I think the other only affected ld80 anyway. Worth having tests thuogh.

Change-Id: Ic4bbeb2384fd578a3ef13e4907be83deda50815f
c3bdc792be78d788663ff9b5e019b4af852dc6f7 06-Jun-2014 Elliott Hughes <enh@google.com> Merge "Fix the printf family for non-ASCII."
69f05d291d848de654c72e5278de8ca06fbf5d2f 06-Jun-2014 Elliott Hughes <enh@google.com> Fix the printf family for non-ASCII.

The bug here turned out to be that we hadn't increased the constant
corresponding to the maximum number of bytes in a character to match
our new implementation, so any character requiring more than a byte
in UTF-8 would break our printf family.

Bug: 15439554
Change-Id: I693e5e6eb11c640b5886e848502908ec5fff53b1
fce861498c8c4720c6ad2475a73bb4c3e55d6948 26-May-2014 Varvara Rainchik <varvara.rainchik@intel.com> Fix for slm-tuned memmove (both 32- and 64-bit).

Introduce a test for memmove that catches a fault.
Fix both 32- and 64-bit versions of slm-tuned memmove.

Change-Id: Ib416def2610a0972e32c3b9b6055b54967643dc3
Signed-off-by: Varvara Rainchik <varvara.rainchik@intel.com>
001f8f041bf21c53d4a0b919ef2c859b047bac0a 04-Jun-2014 Dan Albert <danalbert@google.com> Removes wcswcs from bionic for LP64.

Bug: 13935372
Change-Id: I0deb15e769da4fa81bb65a87f3c86db5163a5796
452e09130010b641904e7411e0c539590a654022 04-Jun-2014 Dan Albert <danalbert@google.com> Merge "Adds functionality specified by uchar.h"
7a7f9952c12b216fbf91fc4cdbb97045e8861115 02-Jun-2014 Dan Albert <danalbert@google.com> Adds functionality specified by uchar.h

mbrtoc32 and c32rtomb get their implementations from mbrtowc and wcrtomb. The
wc functions now simply call the c32 functions.

Bug: 14646575
Change-Id: I49d4b95fed0f9d790260c996c4d0f8bfd1686324
d286796fce1e6fff407b719a53eb2afbeb96c327 04-Jun-2014 Elliott Hughes <enh@google.com> Turn on -Wunused and fix the mistakes it uncovers.

Change-Id: I023d2d8b547fbc21d4124bb7510d42b06a0dc501
214e64135ee22e8aa7f71e56e0f5662dc6746ad0 31-May-2014 Dmitriy Ivanov <dimitry@google.com> Make atexit.dlclose work for glibc

* build libtest_atexit.so
* remove atexit(NULL) - glibc segfaults on it

Bug: 15350494
Change-Id: I27d79130c32c5691b0e8790a57d92f9710f5bf4a
39036f655aee275f307b9557270e1364b0c6ef36 30-May-2014 Christopher Ferris <cferris@google.com> Do not run dlclose test on glibc.

The support library for this test is not built for host by default.
Even if the support library is built, the test segfaults on glibc.

Change-Id: I9cb7a364c59b55d4bf5d8634293037cd9bae020b
d178c83d45ef5ff5caa6f8e92d461ada72c37bd2 30-May-2014 Christopher Ferris <cferris@google.com> Fix unwinding_through_signal_frame test.

I accidentally removed the compilcation of the test implementation file
with special flags needed for the test to work. This change creates the
impl as a library with those flags back.

Bug: 14819262
Change-Id: Ib84fd26a7f4d40a0267d3ed686185b0abc5a3706
8bf50d5b72193d342f2c784ecbc5068d6baee114 30-May-2014 Christopher Ferris <cferris@google.com> Fix wmemmove test.

I accidentally copied over the nul terminator with the test.

Change-Id: I24a9aa05d4fba4f383fa38a3041bb6a6b179130c
9e01ea63a7517fe0c811ced3b822cf6e855ee62b 29-May-2014 Christopher Ferris <cferris@google.com> Fix dprintf test.

Change-Id: Ied783d545b6a35a70a158249f3957a9d00971627
1a57de713adfb81842cb2ebdfc051ecb9afa55f1 29-May-2014 Christopher Ferris <cferris@google.com> Merge "Fix overflow testing in sbrk."
738b0cc5e95a9a650e9621603f4dd8dd16b07568 22-May-2014 Christopher Ferris <cferris@google.com> Fix overflow testing in sbrk.

Modify the overflow testing for sbrk.

Bug: 15188366

Change-Id: Ia83f85f7c1789454d872279bd41f38f1ce6b8a34
6b3beb23d666b722deeb81672166766ad28e7340 29-May-2014 Dan Albert <danalbert@google.com> Fixes stdatomic.h test to match C11 spec

C11 defines the expected value to atomic_compare_exchange_* as being non-atomic
types. Using an atomic type is a syntax error in clang.


Change-Id: I74de1061fa1fc50d835451792d902000f368200e
8a405b027a9c8b3a614016f4824a03fa252e9e1e 28-May-2014 Christopher Ferris <cferris@google.com> Merge "Add optimized AArch64 versions of bcopy and wmemmove based on memmove"
e6c57fcb05b0dcbfa8129bb6f7d99093f4819370 24-May-2014 Elliott Hughes <enh@google.com> Add C11 <stdatomic.h>.

Bug: 14903517
Change-Id: I631dbfdaa698cf7fea8e3b5e18a32586383e62a5
6f2bde344123d8503cd60f3ecd3420f39aa24eb9 23-May-2014 Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org> Add optimized AArch64 versions of bcopy and wmemmove based on memmove

Add optimized versions of bcopy and wmemmove for AArch64 based on the
memmove implementation

Change-Id: I82fbe8a7221ce224c567ffcfed7a94a53640fca8
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
fd0ce866ce46ed62aa17dc2959a085cb3bf5755d 24-May-2014 Christopher Ferris <cferris@google.com> Revert "Add optimized AArch64 versions of bcopy and wmemmove based on memmove"

This reverts commit 8167dd7cb98e87ffe9b40e4993c330b244ca2234.

For some reason I thought the bcopy change was bzero. The bcopy code doesn't pass our tests, so reverting until I can figure out what's wrong.

Change-Id: Id89fe959ea5105cd58dff6bba8d91a30cc4bcb07
8167dd7cb98e87ffe9b40e4993c330b244ca2234 23-May-2014 Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org> Add optimized AArch64 versions of bcopy and wmemmove based on memmove

Add optimized versions of bcopy and wmemmove for AArch64 based on the
memmove implementation

Change-Id: Ie43d0ff4f8ec4edba5b4fb5ccacd941f81ac6557
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
92687e41bcf108957944dafa80a9bfda219bfb0f 22-May-2014 Calin Juravle <calin@google.com> Cleaned up pthread rwlocks implementation.

- used underscore_style_for_vars
- extracted time related functionality into a function
- cleaned up style
- removed unused fields from pthread_rwlock_t on LP64
- changed reservation in pthread_rwlock_t so that the size of the
structure equals glibc version

Bug: 8133149

Change-Id: I84ad3918678dc7f5e6b3db9b7e9b0899d3abe9cd
44adf93b8eddb3a7965a3e9abc189408a1f5a7ea 22-May-2014 Dmitriy Ivanov <dimitry@google.com> Fix dlsym_failure NULL handle test

* RTLD_DEFAULT != (void*)0 only for bionic32

Change-Id: I3b3758835cf4085b0f899e2b62861591411aec13
eea59ea21e04806fff48fdf4ad5ba117dcb0babb 22-May-2014 Calin Juravle <calin@google.com> Merge "Add dprintf test"
3eb9f1f6bade8085520d9b0ec35d84d69563ebe1 22-May-2014 Dmitriy Ivanov <dimitry@google.com> Merge "Removed dlsym handle != NULL check for lp64"
6afb2a9a9729bbfd70ace602342b0173f3bad328 22-May-2014 Calin Juravle <calin@google.com> Add dprintf test

Change-Id: I0fe1b4d45c1312cf01deed6ce5db032d5513e908
172167163af5412c316a8be2f29ca8622984df32 22-May-2014 Calin Juravle <calin@google.com> Merge "Mutex-free implementation of pthread_rwlock"
76f352eec12d8938101e5ae33429c72797c3aa23 19-May-2014 Calin Juravle <calin@google.com> Mutex-free implementation of pthread_rwlock

Bug: 8133149
Change-Id: Id6775010d95f2634b173daa55d87a59a3cf4131b
ca1c80220e9b16fde7a761ca1c2c63dbe8071e0f 22-May-2014 Dmitriy Ivanov <dimitry@google.com> Removed dlsym handle != NULL check for lp64

* Removed unnecessary NULL check in dlsym
* Fixed dlsym_failure test to account for
correct RTLD_DEFAULT value
* Added temporary check for legacy RTLD_DEFAULT
value for non-yet-recompiled binaries

Bug: 15146875
Change-Id: I089fa673762629f5724b6e4fbca019d9cfc39905
72bbd423579bb971dc06cdd3c06201faf3fe95e6 08-May-2014 Christopher Ferris <cferris@google.com> Support for jemalloc to replace dlmalloc.

To use jemalloc, add MALLOC_IMPL = jemalloc in a board config file
and you get the new version automatically.

Update the pthread_create_key tests since jemalloc uses a few keys.
Add a new test to verify memalign works as expected.

Bug: 981363

Change-Id: I16eb152b291a95bd2499e90492fc6b4bd7053836
afb89c2a01089bb247456634a15a58f111bb55a6 20-May-2014 Christopher Ferris <cferris@google.com> Merge "denver: optimize memmove"
6c80ccdeed9d9b30e961f68229fe8171d79c5d14 12-May-2014 Shu Zhang <chazhang@nvidia.com> denver: optimize memmove

Optimize 32-bit denver memmove with reversal memcpy.

Change-Id: Iaad0a9475248cdd7e4f50d58bea9db1b767abc88
b648a8a57ee42533a5bf127225a252f73ca2cbbc 20-May-2014 Dmitriy Ivanov <dimitry@google.com> Add RTLD_NOLOAD support and some related changes.

* Aligned RTLD_ values with glibc for lp64
* dlopen supports RTLD_NOLOAD flag
* soinfo_unload calls find_library(.., RTLD_NOLOAD)
instead of naive find_loaded_library_by_name()
* dlopen changed to add child to caller soinfo instead
of somain.

Bug: https://code.google.com/p/android/issues/detail?id=64069
Change-Id: I1a65f2c34f3e0edc6d2c41a2e408b58195feb640
de9ac710534626e6796ea885f8480fc4cfd64158 20-May-2014 Elliott Hughes <enh@google.com> Use -fvisibility=hidden to build libm.

Bug: 11156955
Change-Id: I77b7772a44313a1eb3970f5d2c8e2af63690efa4
77338a2969c4b5d6de5200c326ef67d6a82e95b2 20-May-2014 Ben Cheng <bccheng@google.com> Merge "Address additional warnings found by GCC 4.9."
caff5f2e1a1c23f70ecf529a84d4d75d2445a44a 19-May-2014 Ben Cheng <bccheng@google.com> Address additional warnings found by GCC 4.9.

Change-Id: If668a6eb98a6ce7b2872f528b8e3527638814f68
568d64dc6213b137e43d65e007cc2c60adc16071 14-May-2014 Jingwei Zhang <jingwei.zhang@intel.com> Accuracy tests for libm

This patch adds tests for 14 math functions to address coverage
issue of math functions discussed in:

Change-Id: Ia7200b93d4f5c7928a3fb827ca6932226384a116
Signed-off-by: Jingwei Zhang <jingwei.zhang@intel.com>
Signed-off-by: Yong Yao <yong.yao@intel.com>
86bc436e20621656cd76b653ae3396c6584259e5 15-May-2014 Dmitriy Ivanov <dimitry@google.com> Merge "Improve detection of already loaded libraries"
9b95ea936a72532c3124963312d348c6ee453d78 14-May-2014 Calin Juravle <calin@google.com> Document a known test issue in stdio_test.cpp.

Bug: 13077905
Change-Id: Iab7fc7be0737c732e26cc07ecd7884b3087b51bb
d59e50063ad708509f3ad83350be33f5612c4f54 09-May-2014 Dmitriy Ivanov <dimitry@google.com> Improve detection of already loaded libraries

Linker is now able to resolve symlinked libraries correctly.

soinfo is extended to save the graph of dependencies during
load/unload. Dependencies are used only in CallConstructor.

Bug: 9741592
Change-Id: Id9c48a74c46aa89bcdf3d54ec2f8ba3d398130b1
c9244bdac1ae254bdbb9687da9cdbb4c3f4cb432 14-May-2014 Elliott Hughes <enh@google.com> Add tests for fprintf behavior when the underlying fd is bad.

Bug: 7229520
Change-Id: Ie878e0c13fdcda7b9131fa56208b84ed88125be7
e77f38f14a01be7d0e1f2ca055047579ec42ffb7 14-May-2014 Elliott Hughes <enh@google.com> Add a unit test for already-fixed printf -0.0 formatting.

This was fixed by the upgrade to upstream head.

Bug: 5084292
Change-Id: Ia3bda1c0bbe38f428e22213b8bdbdf1a16caccf2
3694ec6c4b644064f7e00b898cd11e138e4f6c09 14-May-2014 Elliott Hughes <enh@google.com> Add a regression test for a long-fixed pthread_once bug.

Bug: 1934122
Change-Id: Iae09baedc2c6ed4036521e51718fe9d015bc56b9
1728b2396591853345507a063ed6075dfd251706 14-May-2014 Elliott Hughes <enh@google.com> Switch to g_ for globals.

That's what the Google style guide recommends, and we're starting
to get a mix.

Change-Id: Ib0c53a890bb5deed5c679e887541a715faea91fc
5c8c88dd8d0a371d30096aa107297ebc23e96a45 14-May-2014 Elliott Hughes <enh@google.com> Use the NetBSD inet_ntop until the OpenBSD bug is fixed.

Stupidly I found this bug by accident when writing the existing
tests, but I didn't think any real code would hit it. It turns
out that libcore always uses an INET6_ADDRSTRLEN-sized buffer
even when working with AF_INET addresses.

Change-Id: Ieffc8e4bbe9b66b49b033e3e7101c896e097e6f8
6a41b0fb0e589c4afc4ecbcf7c425f0aa40eaea4 14-May-2014 Elliott Hughes <enh@google.com> Flesh out <arpa/inet.h>.

Use the upstream OpenBSD implementations of these functions.

Also ensure we have symbols for htonl, htons, ntohl, and ntohs.
gtest doesn't like us using the macro versions in ASSERT_EQ.

Bug: 14840760
Change-Id: I68720e9aca14838df457d2bb27b999d5818ac2b5
063525c61d24776094d76971f33920e2a2079530 13-May-2014 Elliott Hughes <enh@google.com> Consistently use #if defined(__BIONIC__) in tests.

I've also switched some tests to be positive rather than negative,
because !defined is slightly harder to reason about and there are
only two cases: bionic and glibc.

Change-Id: I8d3ac40420ca5aead3e88c69cf293f267273c8ef
eb664e24c074b88539b743668109d8b4eaa925bd 13-May-2014 Elliott Hughes <enh@google.com> Add getmntent_r to our collection of <mntent.h> compatibility stubs.

This helps build 'external/flo' out of the box.

Bug: 14841211
Change-Id: I30dde77239cceaf1f5743163744eb3604d27a266
03e4ebee8d1579fbbc6157c1e9be4537bcad0c62 08-May-2014 Calin Juravle <calin@google.com> Add fpos_t tests.

Bug: 13077905

Change-Id: I86bb0ee95660f69f9971231c6f828a3a067d1ac8
15a6310e4b745add324b07a5d3d297aa95a56f59 08-May-2014 Calin Juravle <calin@google.com> Support mb sequences across calls to mb*to*wcs* functions

Bug: 13077905
Change-Id: I5abdc7cc3c27c109b7900c94b112f18a95c35763
20f8aec8976b17ad4d9da6be265594d924f368e1 13-May-2014 Elliott Hughes <enh@google.com> Fix use-after-free errors in stdio_test.

fclose(3) frees the passed-in FILE*. We should close(2) the underlying fd,
not fclose(3) the stream, if we want to test what happens with a stream
we can't read from.

Bug: 14466691
Change-Id: I99fed5904b0266b9c6ae05d0b9cf2e926446c064
4d695bf5606f2cf4029a7ff4e6dd61073407d3b0 12-May-2014 Calin Juravle <calin@google.com> Merge "Align struct passwd definition with other variations of libc"
c768874c667794bee278b9fbf207b5ca5df4e7a6 09-May-2014 Calin Juravle <calin@google.com> Align struct passwd definition with other variations of libc

Add pg_gecos ("real name") field to struct passwd.

Bug: 14679430
Bug: 12875898
Change-Id: I833ec2c46f6a6259b7232a8e3f7942968ef0b50d
55b4c8a4a15723f7c5f68b9ab167fbdea0c4e610 09-May-2014 Elliott Hughes <enh@google.com> Merge "Hide the __bionic_clone and __bionic_clone_entry implementation details."
954cf0d4e2669f91194b45f484152e47efa4f6c7 09-May-2014 Elliott Hughes <enh@google.com> Hide the __bionic_clone and __bionic_clone_entry implementation details.

clone(2) is the public symbol.

Also switch a test from __bionic_clone to clone; testing public API
means the test now works on glibc too.

Change-Id: If59def26a00c3afadb8a6cf9442094c35a59ffde
29d10e3de8f5258fec25174eb5f55eb19577859e 09-May-2014 Dmitriy Ivanov <dimitry@google.com> Merge "Test dlopen with symlinked .so files"
170daa042cb0ef3e5d7839f79d052a683b3c670f 09-May-2014 Elliott Hughes <enh@google.com> Merge "wchar_test.cpp: fix error between comparison signed and unsigned integer"
7db180919c335287b201e859faa8ee0dbe281cde 08-May-2014 Dmitriy Ivanov <dimitry@google.com> Test dlopen with symlinked .so files

Bug: 9741592
Change-Id: I68c59d6f4e690136395c3dc3de13f99ce38de528
a5c6b2ecb55afd75630cbe38dd2b88172cfa304d 08-May-2014 Yongqin Liu <yongqin.liu@linaro.org> wchar_test.cpp: fix error between comparison signed and unsigned integer

when compile the cts package with aarch64 gcc4.9, will get following error:
bionic/tests/wchar_test.cpp:253:3: required from here
error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]

this change fix it by using static_cast<wchar_t> as suggested by Calin Juravle

Change-Id: I7fb9506e7b84b8a12b9d003458d4f0e78554c3cd
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
3b968032848426c12185fe1c0f20e5bc882ed388 08-May-2014 Elliott Hughes <enh@google.com> Merge "Add basic tests for fsync/fdatasync."
a62a28d1d9c8df7cb77e4bca19814922729b5291 07-May-2014 Elliott Hughes <enh@google.com> Add basic tests for fsync/fdatasync.

Bug: 14613980
Change-Id: Ie8002c2a1abae07295b7bdb33772764767c03d37
f837cbdc27a0f024bdc9898177a8ac05817441a7 07-May-2014 Dmitriy Ivanov <dimitry@google.com> Merge "Add missing test for atexit test suite."
6396da98cb3313048ae9a8147523ed61f675fd50 06-May-2014 Dmitriy Ivanov <dimitry@google.com> Add missing test for atexit test suite.

Change-Id: I3d14d7df1da53ccef534c106633593551ab6a7cb
837abf04667c29db178fd28f500537429a18be30 07-May-2014 Calin Juravle <calin@google.com> Merge "Fix bionic-unit-tests-glibc-run target"
0e9d7fccb9c3b688992f2ef9ac1cfd1f456b1ed7 07-May-2014 Calin Juravle <calin@google.com> Fix bionic-unit-tests-glibc-run target

Configure multilib for bionic-unit-tests-glibc-run target (the path to
the host executable was already patched to support multilib build but
the multilib itself wasn't configured).

Change-Id: If533fbdb19bc737e543cf85a0787505458f24579
35cff760dfc5d9d1432955503ffff02286ac20ef 07-May-2014 Torne (Richard Coles) <torne@google.com> Merge "Test that relro sharing actually saves memory."
100168abff75f41c0179a77777f0aef622f7ed9f 06-May-2014 Elliott Hughes <enh@google.com> Merge "Fix <math.h> to quieten most of our warnings."
26052616915fe2324755687c7db73d69c521b34d 02-May-2014 Torne (Richard Coles) <torne@google.com> Test that relro sharing actually saves memory.

Spawn 20 child processes, have them all load the library, and compare
the total PSS used in the case where we use dlopen() and the case where
we use android_dlopen_ext() with relro sharing. We assume we will save
at least 10% of the memory; in practise this example saves 40% or more
so this should be a reasonable threshold.

Bug: 14299541
Change-Id: Idccf6b8b0eb137abae2200f1ce68fb76b3cbdd75
9b5ee4aa85cf55467eb9a749b6602f6f2ba1cfc6 06-May-2014 Torne (Richard Coles) <torne@google.com> Merge "Handle empty relro segment or incorrectly sized file."
9a5a3e8e74e2c6d7850ab29711189acf0f7378a2 06-May-2014 Elliott Hughes <enh@google.com> Fix <math.h> to quieten most of our warnings.

I've reported the wcsftime bug upstream, but we really just want to use -D
to ensure the buggy code isn't built. (I've also brought our strftime a bit
closer to upstream now we have the right define.)

I don't think upstream is likely to fix all their sign-compare and
uninitialized warnings, so let's just silence them.

As for libm, again upstream isn't likely to fix all their warnings, and
silencing those made the ones that were our fault stand out. I've fixed
our <math.h> to fix the warnings caused by our lack of definitions for
the non-imprecise long-double functions. I checked the C99 standard, and
all these functions are there.

Change-Id: Iee8e1182c1db375058fb2c451eceb212bab47a37
9ded07cff6c73bd3ea1bbc874180139d3a5d6f0c 25-Feb-2014 Philip Hatcher <philip.hatcher@intel.com> bionic: make epoll_event structure packed

Description: In the kernel the epoll_event structure is packed
in 64 bit kernel builds to allow the structure to be more easily
compatible with 32 bit user space. As a result, when user space
is 64-bit the structure must be packed as well.

Add unit test to show the ptr alignment issue.

Change-Id: I2c4848d5e38a357219091f350f9b6e3da05090da
Signed-off-by: Philip Hatcher <philip.hatcher@intel.com>
Signed-off-by: Fengwei Yin <fengwei.yin@intel.com>
Reviewed-by: Hazarika, Prodyut <prodyut.hazarika@intel.com>
Tested-by: Hazarika, Prodyut <prodyut.hazarika@intel.com>
ad534985ec3e01d37d46c50caa562f6482f48347 05-May-2014 Elliott Hughes <enh@google.com> Merge "Disable %n in printf and vfwprintf."
e2341d08fa4a4e0c22056c410fd34d3f93e06017 03-May-2014 Elliott Hughes <enh@google.com> Disable %n in printf and vfwprintf.

Bug: 14492135
Change-Id: If190bede29e5f68a65043ddbe8e878c660933d03
8ec21d9ded4c05744b3f9388bf824a508d7c95c2 05-May-2014 Elliott Hughes <enh@google.com> Merge "Switch to current upstream OpenBSD wsetup.c."
53b24382f5299931af5d08c933a765334a092c56 03-May-2014 Elliott Hughes <enh@google.com> Switch to current upstream OpenBSD wsetup.c.

Change-Id: I2c1123f3e1d3c4af7fd7bf354e763934a39b78c0
580b246917d58fafc757daaf097b6bd20b17970a 05-May-2014 Dmitriy Ivanov <dimitry@google.com> Merge "Fixes for __cxa_finalize"
6b56691a678420477595a531b2d2829980eb51c0 29-Apr-2014 Dmitriy Ivanov <dimitry@google.com> Fixes for __cxa_finalize

* Ability to register atexit handler from atexit handler
* Correct way to handle both forms of atexit handler

Bug: https://code.google.com/p/android/issues/detail?id=66595
Bug: 4998315
Change-Id: I39529afaef97b6e1469c21389d54c0d7d175da28
efaa461bd67cfdfcbc2b4c6b69805bc5b929ae05 03-May-2014 Elliott Hughes <enh@google.com> Use the OpenBSD wcsftime.

Change-Id: I81929355d245ba1e58b4a464ca6cf45915e0238e
26ec9679ff01fb155ae21015f31cc95bed24f670 30-Apr-2014 Torne (Richard Coles) <torne@google.com> Handle empty relro segment or incorrectly sized file.

If the file has no relro segment, the generated relro file will have
length 0, which caused mmap to fail. If the relro file has nonzero size,
but is too short (e.g. because it's for the wrong version of the
library), the linker would segfault while comparing the data. Fix both
these issues: don't try to map a zero length file, and don't try to
compare data that would be beyond the end of the file.

Improve test to explicitly generate two versions of the library: one
with -z relro, and one with -z norelro, so we can test both cases; also
explicitly test the case where the relro file has length 0.

Bug: 14299541
Change-Id: Id8b95585edda90e8bb5de452a35b70ed2d224934
f83e644e2c8ea041d5864c25d0aa40cff579d2f7 02-May-2014 Elliott Hughes <enh@google.com> Fix wchar.cpp MIPS narrowing conversion build failure.

Change-Id: Id9103c78958d60337dbdb807b11256c1b31c632a
5a0aa3dee247a313f04252cf45608097695d5953 01-May-2014 Elliott Hughes <enh@google.com> Switch to a working UTF-8 mb/wc implementation.

Although glibc gets by with an 8-byte mbstate_t, OpenBSD uses 12 bytes (of
the 128 bytes it reserves!).

We can actually implement UTF-8 encoding/decoding with a 0-byte mbstate_t
which means we can make things work on LP32 too, as long as we accept the
limitation that the caller needs to present us with a complete sequence
before we'll process it.

Our behavior is fine when going from characters to bytes; we just
update the source wchar_t** to say how far through the input we got.

I'll come back and use the 4 bytes we do have to cope with byte sequences
split across multiple input buffers. The fact that we don't support
UTF-8 sequences longer than 4 bytes plus the fact that the first byte of
a UTF-8 sequence encodes the length means we shouldn't need the other
fields OpenBSD used (at the cost of some recomputation in cases where a
sequence is split across buffers).

This patch also makes the minimal changes necessary to setlocale(3) to
make us behave like glibc when an app requests UTF-8. (The difference
being that our "C" locale is the same as our "C.UTF-8" locale.)

Change-Id: Ied327a8c4643744b3611bf6bb005a9b389ba4c2f
9fb53dd4dbaa7633c234d9da8417827fa3d3c32f 30-Apr-2014 Elliott Hughes <enh@google.com> Merge "Make SIGRTMIN hide the real-time signals we use internally."
2d36750c3ad8fd91cf52cb0ed8f38ecfd88b0f13 30-Apr-2014 Elliott Hughes <enh@google.com> Fix the CPU_*_S tests.

Change-Id: Id67c48b9c12a20b01309490670438bfcd9163465
0990d4fda898ada86e557f872f5cb7d16b138e3c 30-Apr-2014 Elliott Hughes <enh@google.com> Make SIGRTMIN hide the real-time signals we use internally.

__SIGRTMIN will continue to tell the truth. This matches glibc's
behavior (as evidenced by the fact that we don't need a special case
in the strsignal test now).

Change-Id: I1abe1681d516577afa8cd39c837ef12467f68dd2
77473e408504a7e298816b4071cd6902065b03d8 30-Apr-2014 Calin Juravle <calin@google.com> Merge "Fix cpu_set_t"
b743790ccabd9b0b93355ff693066478d10dae0d 29-Apr-2014 Calin Juravle <calin@google.com> Fix cpu_set_t

- extend CPU_SETSIZE for LP64
- fix CPU_(AND|OR|XOR) macros
- fix CPU_OP_S macro
- fix __sched_cpucount
- tidy up the code

Change-Id: I741afff4d0c473e8a1ee6b4141981dc24467e0d4
b8425c549a0bfe08b01b5906b95603d8523c1b16 30-Apr-2014 Dan Albert <danalbert@google.com> Adds quick_exit(3) and at_quick_exit(3) from freebsd

Change-Id: I4fe88abd8f7b8aa45e58aeb2529d59a8d555d338
01ae00f3170ad0e36c1657f6ff8c89dfa730fd37 30-Apr-2014 Elliott Hughes <enh@google.com> Switch to the OpenBSD implementations of the wide scanf functions.

This also gets us the C99 wcstoimax and wcstoumax, and a working fgetwc and
ungetwc, all of which are needed in the implementation.

This also brings several other files closer to upstream.

Change-Id: I23b025a8237a6dbb9aa50d2a96765ea729a85579
55cd82762f3173247dc7e0eae2826aa24d22213a 30-Apr-2014 Elliott Hughes <enh@google.com> Merge "Switch to the OpenBSD wcsto* functions."
3d7a0d9b08ecab054b2dff8332507644de3690b0 29-Apr-2014 Elliott Hughes <enh@google.com> Switch to the OpenBSD wcsto* functions.

This replaces a partial set of non-functional functions with a complete
set of functions, all of which actually work.

This requires us to implement mbsnrtowcs and wcsnrtombs which completes
the set of what we need for libc++.

The mbsnrtowcs is basically a copy & paste of wcsnrtombs, but I'm going
to go straight to looking at using the OpenBSD UTF-8 implementation rather
than keep polishing our home-grown turd.

(This patch also opportunistically switches us over to upstream btowc,
mbrlen, and wctob, since they're all trivially expressed in terms of
other functions.)

Change-Id: I0f81443840de0f1aa73b96f0b51988976793a323
7fdab460a9790959ce6c4201476a3ea982eb148e 29-Apr-2014 Christopher Ferris <cferris@google.com> Merge "Fix potential makefile bug."
5090964da02c956f099a49b5a3eb732c0085c58b 29-Apr-2014 Christopher Ferris <cferris@google.com> Fix potential makefile bug.

Since multilib is not set every time, it needs to be per module or
there is a change that another target will use the multilib value set

Change-Id: I5c30e18d5111705cb3f6e3d4cd9ef8a28c9b746c
0a5e26da1eae6b75a89695faf2e057c5c4717721 29-Apr-2014 Elliott Hughes <enh@google.com> Add mbtowc and fix mbrtowc.

Change-Id: I48786cd82587e61188d40f6fd6e11ac05e857ae9
d299bcfdad959a3a0adf1683605b15a1c3b3ab66 29-Apr-2014 Elliott Hughes <enh@google.com> Replace our broken wcswcs with the working upstream one.

Change-Id: I2952684df5674d10f0564d92c2cd42597725c0e3
329103d3e2f42d3e35a060c3e0d326d6476eb2ef 26-Apr-2014 Elliott Hughes <enh@google.com> Don't use so much stack in tzcode.

Bug: 14313703
Bug: https://code.google.com/p/android/issues/detail?id=61130
Change-Id: Id9b240fce20d4a6f2660792070e02b2b5f287655
533dde4dbf87d6615952be3654fc74e5ff2e1003 26-Apr-2014 Elliott Hughes <enh@google.com> Fix brk/sbrk error checking.

Note that the kernel returns the current break on error or if the requested
break is smaller than the minimum break, or the new break. I don't know where
we got the idea that the kernel could return -1.

Also optimizes the query case.

Also hides an accidentally-exported symbol for LP64.

Change-Id: I0fd6b8b14ddf1ae82935c0c3fc610da5cc74932e
ae77f74bcf51cb4199c9f7e87ec9c751fdd1842b 24-Apr-2014 Calin Juravle <calin@google.com> Merge "Clean-up _fpmath and fake_long_doubles"
409588cdae447a0e58bf136a9ea3a9b8d321fbf3 24-Apr-2014 Elliott Hughes <enh@google.com> Fix fallout from host GCC upgrade.

I'll raise a bug for the FD_ISSET fortification; we should do better too.

Change-Id: Id2bf277890ad06b010dc952e270d746714c2bea7
1abc9ff6a5b5f8a9925f1b8d9d333bc5bc7d407f 17-Apr-2014 Calin Juravle <calin@google.com> Clean-up _fpmath and fake_long_doubles

- promoted IEEEld2bits to fpmath since most of the where the same for
diffrent archs
- removed _fpmath
- reinstated weak_references
- moved isfinite and isnormal to libc
- clean up fake_long_doubles
- clean up some useless ifdefs
- added missing nexttoward* tests

Bug: 14134235
Change-Id: I95639c4885653fe47fd7dc0570ee5bb3389bbc6b
0c567f1e6cfceada98ba10deb4bac6030c9d20f7 23-Apr-2014 Elliott Hughes <enh@google.com> Fix the glibc tests again.

The glibc tests are just a regular host binary; they don't require
that you're targeting x86 or x86_64. They do seem to pick up the
suffix of the target though, even though they're always 32-bit.

Change-Id: I689ca2a4f8d7b397afa4df722b95b0d7ec904bf6
cbf6df0459f05e180d1c50b3f5b36cdd483193c6 17-Sep-2013 Grigoriy Kraynov <grigoriy.kraynov@intel.com> Tests for environment variables utility functions

This is the first patch from the new set of tests for Bionic standard functions.

Change-Id: Ie568788a24832394e597ad33f44a5c71cb33b51f
Signed-off-by: Grigoriy Kraynov <grigoriy.kraynov@intel.com>
53c884e28166678b2fa40cb3763d1549074628ad 23-Apr-2014 Dmitriy Ivanov <dimitry@google.com> Get ANDROID_DATA dir from enviroment

Change-Id: Ie3675bd27bbc779fc2140f95b930eadd14838753
156c3afcf178b8a6c29b9edc7e8d13999a58d857 23-Apr-2014 Dmitriy Ivanov <dimitry@google.com> Follow up on building tests for both platforms

this makes run-on-host work properly

Change-Id: Iaed93ca9d96359b64bbeff995280ecd70fc9cc60
345b49a7c07fde18e9397ffba9079ff81a4c3d74 22-Apr-2014 Christopher Ferris <cferris@google.com> Build 32/64 bit versions of tests/benchmarks.

Change-Id: I4d146377aac6573a214dfaa5cab5cce8b10538b4
c5eea6d386c23bde6f0400a8959ed21081d8365b 22-Apr-2014 Elliott Hughes <enh@google.com> Merge "Fix WCHAR_MAX, WCHAR_MIN, WINT_MAX, and WINT_MIN."
b1bfa7956c56c28b8c914e6606df191e094e7b42 22-Apr-2014 Torne (Richard Coles) <torne@google.com> Merge "Allow sharing the RELRO section via a file."
c363e5dd0a15aac9036b453f655a3a0ae5cd32cd 22-Apr-2014 Torne (Richard Coles) <torne@google.com> Merge "Support loading libraries to a reserved address."
83c07b5e50207458445262ed10b79aa6b2d2d0ce 22-Apr-2014 Elliott Hughes <enh@google.com> Fix WCHAR_MAX, WCHAR_MIN, WINT_MAX, and WINT_MIN.

GCC tells us everything we need to know. clang does its usual half-assed job.

Change-Id: Id4d664529b10345274602768cd564d3df717e931
1b836ee6f8e5c0f61d67c1f014819a066366ab6f 18-Apr-2014 Elliott Hughes <enh@google.com> Fix a wchar.wcstombs_wcrtombs test failure.

Looks like I screwed up a last-minute refactor and didn't re-run the tests.

Change-Id: I90a710ae66a313a9812859650aa0b4e8c6bc57f9
b88da06580a22d9a1ee5a1c573c49e89207bc71b 18-Apr-2014 Elliott Hughes <enh@google.com> Merge "Upgrade to current vfprintf."
f3c73901cb5ca4de2651151cf2c65b31a729466e 18-Apr-2014 Elliott Hughes <enh@google.com> Upgrade our <ctype.h> implementation to OpenBSD head.

Adding the perfunctory <ctype.h> tests showed that we'd accidentally
dropped several symbols. This puts everything back in its proper place
and switches us to upstream head at the same time.

Change-Id: Ib527ad280c9baded81e667fa598698526d93e66f
0549371bd74ba7c7a5a16c2a7d6cc17dbe0e6f97 18-Apr-2014 Elliott Hughes <enh@google.com> Upgrade to current vfprintf.

This gets us various bug fixes and missing C99 functionality.

Bug: https://code.google.com/p/android/issues/detail?id=64886
Change-Id: Ie9f8ac569e9b5eec1e4a1faacfe2c21662eaf895
183ad9df536ab04ef35a397a1f4724e4e401d11f 27-Feb-2014 Torne (Richard Coles) <torne@google.com> Allow sharing the RELRO section via a file.

Add flags and a file descriptor to android_dlopen_ext() to allow writing
the RELRO section of the loaded library to a file after relocation
processing, and to allow mapping identical pages from the file over the
top of relocated memory in another process. Explicitly comparing the
pages is required in case a page contains a reference to a symbol
defined in another library loaded at a random base address.

Bug: 13005501
Change-Id: Ibb5b2d384edfaa5acf3e97a5f8b6115c10497a1e
12bbb9164578b6512b8b07a3fb093858244b7c7b 06-Feb-2014 Torne (Richard Coles) <torne@google.com> Support loading libraries to a reserved address.

Add flags and parameters to android_dlopen_ext() to allow loading a
library at an already-reserved fixed address. If the library to be
loaded will not fit within the space reserved, then the linker will
either fail, or allocate its own address space as usual, according to
which flag has been specified. This behaviour only applies to the
specific library requested; any other libraries loaded as dependencies
will be loaded in the normal fashion.

There is a new gtest included to cover the functionality added.

Bug: 13005501
Change-Id: I5d1810375b20fc51ba6a9b3191a25f9792c687f1
4bd97cee28dd815fff54fc97560be60d566c1fa5 11-Apr-2014 Elliott Hughes <enh@google.com> Switch to gdtoa.

This gives us a real strtold for LP64 and fixes various LP64

Bug: 13563801
Change-Id: I277858d718ee746e136b6b6308a495ba50dfa488
26c2bb84dd5cbd9ab43a5f0ebc2635bc3b64be3d 16-Apr-2014 Ben Cheng <bccheng@google.com> Merge "Fix signed vs unsigned comparison."
b760164dd67929789a4732ed3f5df56a4b66c3ae 16-Apr-2014 Ben Cheng <bccheng@google.com> Fix signed vs unsigned comparison.

Otherwise GCC 4.9 complains.

Change-Id: I7cd3c5e8c78fda709130ca88a85fa1512e6fc024
02c78a386739a8a2b3007efeb00a9ca04132100a 12-Apr-2014 Elliott Hughes <enh@google.com> Reimplement isinf/isnan/fpclassify.

Also move isinf and isnan into libc like everyone else.

Also move fpclassify to libc like the BSDs (but unlike glibc). We need
this to be able to upgrade our float/double/long double parsing to gdtoa.

Also add some missing aliases. We now have all of:

isnan, __isnan, isnanf, __isnanf, isnanl, __isnanl,
isinf, __isinf, isinff, __isinff, isinfl, __isinfl,
__fpclassify, __fpclassifyd, __fpclassifyf, __fpclassifyl.

Bug: 13469877
Change-Id: I407ffbac06c765a6c5fffda8106c37d7db04f27d
7823f320b144bc95a34389e7ab709c9e4d3073e1 14-Apr-2014 Elliott Hughes <enh@google.com> Extra tests for printf of NaN and Inf.

Change-Id: I61fc655d9777a03aabf38f6ebd047fe275386f05
6455ac73da3f8b4ff6aae2acb0442429c8921788 11-Apr-2014 Elliott Hughes <enh@google.com> Improve the <sstream> test.

It looks like libcxx's testing is crap too, and this turned up
another bug in stlport.

Change-Id: I98c93dceaa8225c3cc280166d4bb74adaf94a324
8c42606ae10b59318c9a4ea83854049bab5b9328 10-Apr-2014 Elliott Hughes <enh@google.com> Add a test for external/stlport a6df82320fcb8f26af0d067c7768fedbaeb9ad88.

Change-Id: If4df9f5df41ae5453a3dff6bb032b419819f8703
b52a4ab4e281c7adae35b3d7ae8d99b5753b870d 09-Apr-2014 Elliott Hughes <enh@google.com> Merge "Flesh out <locale.h>."
764a99361130dceda62bbc4f8780bbf395dbc424 09-Apr-2014 Elliott Hughes <enh@google.com> Fix build: include what you use.

Change-Id: I12b2d5e434ad3ed38d4451bd470673781e6ca8fe
c4936e20a3a8772cc393423037be36091e68acc2 09-Apr-2014 Elliott Hughes <enh@google.com> Flesh out <locale.h>.

This is a trivial implementation that only supports the C/POSIX locale.

Change-Id: Ib11cea4249e1862aca96a8b94d58ea9a418cbe75
9f525644df99cb2f7f81a23ca23840f0a8f82275 09-Apr-2014 Elliott Hughes <enh@google.com> Implement _Exit(3).

Change-Id: Ida6ac844cc87d38c9645b197dd8188bb73e27dbe
5363a45f2b6d4eeb054710d0886bbadea8a15273 08-Apr-2014 Elliott Hughes <enh@google.com> Clean up localeconv(3).

The OpenBSD doesn't support C99, and the extent to which we support
locales is trivial, so just do it ourselves.

Change-Id: If0a06e627ecc593f7b8ea3e9389365782e49b00e
48501af98f3cdf0115a469ee8d773cf74c42958d 14-Mar-2014 Serban Constantinescu <serban.constantinescu@arm.com> AArch64: Fix flock64 for LP64.

On LP64 systems F_GETLK64, F_SETLK64 and F_SETLKW64 definitions should
map onto the F_GETLK, F_SETLK and F_SETLKW definitions, respectively.
LP64 also doesn't have a struct flock64.

Change-Id: Ibdfed9645d9e946999acd6efa8b96ea6238ed5bf
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
41059d764f347baa28b8da653a88c772daa9b738 08-Apr-2014 Christopher Ferris <cferris@google.com> Merge "Add stpcpy/stpncpy."
b9bb48bf289eec9053c6d7cc77ebbde2b4356c4b 08-Apr-2014 Elliott Hughes <enh@google.com> Merge "Fix the printf issue for 64 bits. The following case:"
950a58e24d1019eb9d814dbb16f111a6b61e3f23 04-Apr-2014 Christopher Ferris <cferris@google.com> Add stpcpy/stpncpy.

Add tests for the above.

Add the fortify implementations of __stpcpy_chk and __stpncpy_chk.

Modify the strncpy test to cover more cases and use this template for

Add all of the fortify test cases.

Bug: 13746695
Change-Id: I8c0f0d4991a878b8e8734fff12c8b73b07fdd344
efbdb53f84f4e1faf38f3c1a4cb60a83b9885ef4 08-Apr-2014 Elliott Hughes <enh@google.com> Remove a non-standard turd: strtotimeval.

Change-Id: I1b1e40746cb573e3fb73a5276969b40c5da36d15
77e944fd46728075fe632bcb5211da9daf5b7e68 05-Apr-2014 Elliott Hughes <enh@google.com> Implement wctomb(3) for ltrace.

This is an implementation in the style of the rest: char == byte.

We might want to come back and implement UTF-8, but this is enough for ltrace.

Bug: 13747066
Change-Id: Ib2b63609c9014fdef9a8491e067467c4fc5ae3cc
eb554998d774c670a169bde1792619789f2f7058 03-Apr-2014 Calin Juravle <calin@google.com> Merge "Fix modf* tests"
d8d6feed3add3965f481dcdd6e1bb259a46f21c2 01-Apr-2014 Calin Juravle <calin@google.com> Fix modf* tests

Use a value that can be exactly represented.

Change-Id: Idf3b1db5e6042fb49c1f591f25f9eee656659ece
edd7c2ec256548702d275b3023f54bd91b4dcfc4 01-Apr-2014 Alexander Ivchenko <alexander.ivchenko@intel.com> Fix the printf issue for 64 bits. The following case:

printf("%1$s %1$s\n", "test");

would print garbage instead of the second "test". The problem is __find_arguments
and the patch is a backport of two patches from OpenBSD that fix the issue:

Author: tedu <tedu@cvs.openbsd.org>
Date: Sat Apr 29 23:00:24 2006 +0000

check mmap for failure. the helper functions using it return -1, but
callers do not yet check since printf() for example is not documented
to return an error.
some formatting cleanups.
mostly ok deraadt millert

Author: millert <millert@cvs.openbsd.org>
Date: Fri May 16 14:28:54 2008 +0000

C99 says that for each va_copy() there must be a matching va_end().
Replace the non-portable hackery in __find_arguments() with a union.
From FreeBSD.

Change-Id: I6ea392ce6fcf4a319ae6a67ec58cc52fe7cbe534
Signed-off-by: Alexander Ivchenko <alexander.ivchenko@intel.com>
9c9ef0db91c816ca81a22a94c3ddd896a0f0f1bc 02-Apr-2014 Calin Juravle <calin@google.com> Merge "Changed long double literal suffix from 'l' to 'L'."
1021c05f1bef70d78cddff41b151787b8195cac9 02-Apr-2014 Brian Carlstrom <bdc@google.com> Include sys/types.h and sys/wait.h for waitpid

(cherry picked from commit 8b2c6d44cac206b61dffd965863336e6f803fc66)

Change-Id: Ice1f6d956c11aaefd3d846c12121f08613a94446
e3bb025b3d963e4aa412ab3eee35ca2187eb0eca 01-Apr-2014 Christopher Ferris <cferris@google.com> Fix transient failure in select_smoke test.

Make sure there is a delay before the file descriptor is written so that
the select/pselect calls do not return immediately.

Change-Id: If9e481b0e2cfae7ef7abd9cba8fff84078e203d3
b7afa9df2552c6a6889a43c6a1722e1ce46f1969 01-Apr-2014 Calin Juravle <calin@google.com> Changed long double literal suffix from 'l' to 'L'.

Change-Id: Id569f2d335b0930704d12ad7f388cb98b65f3ab7
108f6dc3168fa492a7ba906466ac65749f5fbda5 31-Mar-2014 Christopher Ferris <cferris@google.com> Move accept4 tests into sys_socket_test.cpp.

In addition, create basic recvmmsg, sendmmsg tests.

Change-Id: Ie9f4954446d98b5eb5e553d3c616c1ee67c3cb66
9cea3775056d0a8d04d49c3983440b89d82a462b 31-Mar-2014 Christopher Ferris <cferris@google.com> Small accept4 fixes.

Put the accept4 test in the sorted order, and put the accept4 define in
sorted order.

Also add the missing SYS_RECVMMSG and SYS_SENDMMSG defines.

Change-Id: Iba55354975e0d5027dbee53f6de752c2df719493
557942ac58f08675473460b1802b43473c467172 31-Mar-2014 Calin Juravle <calin@google.com> Merge "Fix math tests."
50282f72bb9be6b49212a3978faec70786e9f97f 25-Mar-2014 Pavel Chupin <pavel.v.chupin@intel.com> Add lconv declaration and localeconv(3)

lconv is taken from ndk/sources/android/support/include/locale.h and
bsd/glibc upstream.
Keep old declaration for 32-bits for compatibility.
localeconv.c and deps are taken from openbsd upstream.
Changed strtod.c accordingly.

Change-Id: I9fcc4d15f5674d192950d80edf26f36006cd31b4
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
c8564f2df2a85a753e25bf48b4eefbf8379fe31a 27-Mar-2014 Calin Juravle <calin@google.com> Fix math tests.

Bug: 13657654
Change-Id: I39b2f13b5b3d3e6897618ac3aed49a0a08458dd0
a58b3f78e14500e7b10fc845ef0a6a8309664663 27-Mar-2014 Christopher Ferris <cferris@google.com> Merge "Add accept4 unit test to bionic."
2f3ba8844ab8ed6be02485c79c1e974a6513b492 18-Feb-2014 Andrei Emeltchenko <andrei.emeltchenko@intel.com> Add accept4 unit test to bionic.

Change-Id: I1cce5fb8dab16f03164fdd288f35a814d7c49c6a
4bfaf462f0c864473faaca63cc4ba9e1a1b103a8 26-Mar-2014 Calin Juravle <calin@google.com> Added strtotimeval tests.

Change-Id: I3dfd3647a8494490a2d549bdb915968063a7fb99
133bd09334cb28b45cca1ca0e5b4e22a9e5b68e5 25-Mar-2014 Brian Carlstrom <bdc@google.com> Add include of float.h for LDBL_MIN_EXP and LDBL_MANT_DIG

(cherry picked from commit 1711c6ea3a0d891da665325c75738a68bd7d501f)

Change-Id: Ia64676b2b904f042fec678003e3f2cd5bd82b510
989a80b75014eff71600a6a4e1445e710c2f94b4 24-Mar-2014 Calin Juravle <calin@google.com> Merge "Fix LP64 libm for 128-bit long doubles"
4d77c1151c40010d137e4a2fa8629bff4bea72b0 14-Mar-2014 Calin Juravle <calin@google.com> Fix LP64 libm for 128-bit long doubles

* reworked amd64/_fpmath.h and arm64/_fpmath.h to support 128-bit long
* improved tests to cover long double cases
* made modfl an alias for LP32

Tests pass on x86, x86_64, arm, arm64 and mips.

Bug: 12921273

Change-Id: Ibe39acde57972447a8950fa45b1e702acc68ebeb
753ad778bc1c3aecc4cd82b8387a7dc8a9b44d34 21-Mar-2014 Christopher Ferris <cferris@google.com> Fix deadlock in timer_delete.

If the callback function for a timer did a timer_delete, the function
would never return. The problem was that the timer_delete function would try
to wait until the timer thread has finished. Waiting for yourself to finish
doesn't work very well.

Bug: 13397340
Change-Id: Ica123a5bafbc8660c8a4a909e5c2dead55ca429d
722706672617d009279a8485b895bd3389de0396 19-Mar-2014 Calin Juravle <calin@google.com> Added a test flag to bionic run-test targets.

It makes it much easier to pass arguments to the tests.

Change-Id: Ia91eba4868627a3cea3f8d2c26ba01af4e860b12
f171b34cf045115b82ccb89b57feb56d3cad472b 18-Mar-2014 Christopher Ferris <cferris@google.com> Use the float/double assert macros.

The normal ASSERT_EQ macros don't work quite right for float/double values,
and result in false failures. Use the correct macros instead.

Bug: 13511379
Change-Id: Ic2feee7f3d3569f57b6453b8fa95222846c625cd
603332fc4c2d073f0e197f9ce4517710e9b3a6d0 13-Mar-2014 Elliott Hughes <enh@google.com> Upgrade to current upstream scanf implementation.

Also add a basic test.

Change-Id: Icc0e68a5716b9579244f6eb8bac1ab5a24eda85a
5a8173860d65182af022be88fed0c5d8d5dcb69d 13-Mar-2014 Elliott Hughes <enh@google.com> Ensure we always have symbols for atof, strtof, strtold.

We'll need a better implementation of strtold for LP64, but all our
long double functions are currently broken for LP64 anyway so this
isn't a regression.

Change-Id: I2bdebac11245d31521d5fa09a16331c03dc4339c
40488560c17e41c0980b3a08ef54ec38bb572a41 12-Mar-2014 Elliott Hughes <enh@google.com> Include what you use.

Don't rely on transitive includes. (Even though that works fine in AOSP.)

Change-Id: Ifc06575e4aea383cfff24d6c5c14fc0a7aabdf2b
3cdf5739cd34757943a5fff9d26efeb8da04cb09 11-Mar-2014 Elliott Hughes <enh@google.com> Add a basic unit test for system(3).

Change-Id: Ibc5ac21f3663685d89ce261b58d6ea386fc1ff88
3e3409af0faa8843078a9e6e7110e69a88210da4 11-Mar-2014 Elliott Hughes <enh@google.com> Add system/extras strftime and strptime tests.

Change-Id: I889c58f6e2e27b99cf6328a8671858d2e5feaa4e
be1d91dedcfb346ced5ac496cd454f5b2e9bc4a9 09-Mar-2014 Brian Carlstrom <bdc@google.com> Add includes for waitpid

(cherry picked from commit f07c5dd9ab63f2e8ba736107bd4b69bbd8829c9f)

Change-Id: I7a765fd7a3a5f8f29a703f6a591c4fd8df4ebf1c
04620a3cd7bdea0d1b421c8772ba3f06839bbe9c 08-Mar-2014 Elliott Hughes <enh@google.com> Fix pthread_detach for already-exited threads.

Change-Id: I2bf7f41234d93b226132a4c51705f4186f4961c3
Reported-by: Paresh Nakhe <pnakhe@codeaurora.org>
4b558f50a42c97d461f1dede5aaaae490ea99e2e 05-Mar-2014 Elliott Hughes <enh@google.com> Rewrite the POSIX timer functions.

This is a much simpler implementation that lets the kernel
do as much as possible.

Co-authored-by: Jörgen Strand <jorgen.strand@sonymobile.com>
Co-authored-by: Snild Dolkow <snild.dolkow@sonymobile.com>
Change-Id: Iad19f155de977667aea09410266d54e63e8a26bf
0e714a5b41451e84c5ded93a42c9a4b0a9440691 04-Mar-2014 Elliott Hughes <enh@google.com> Implement POSIX pthread_mutex_timedlock.

This replaces the non-standard pthread_mutex_lock_timeout_np, which we have
to keep around on LP32 for binary compatibility.

Change-Id: I098dc7cd38369f0c1bec1fac35687fbd27392e00
51e6cb33e3d7c2f44864d356a2a8e66317688f55 03-Mar-2014 Narayan Kamath <narayan@google.com> Implement pthread_condattr_{get,set}clock.

We only support CLOCK_REALTIME and CLOCK_MONOTONIC for now,
so we us a single bit from pthread_cond_t->value to denote
the clock type. Note that this reduces the width of the counter
to 30 bits, but this should be large enough for all practical

bug: 13232338

Change-Id: I857e7da64b3ecbb23eeac7c9f3fbd460f60231bd
aedb00d04eb7f0b20b6abde702ba94a46577ca68 03-Mar-2014 Elliott Hughes <enh@google.com> Switch to upstream alarm(3).

The only way the setitimer call can fail is if the unsigned number of seconds is
too large to fit in the kernel's signed number of seconds. If you schedule a
68-year alarm, glibc will fail by returning 0 and BSD will fail by returning -1.

Change-Id: Ic3721b01428f5402d99f31fd7f2ba2cc58805607
6ff0c75c838e73d2aeccc0102ab58a7b865172ca 10-Feb-2014 Guillaume Ranquet <guillaumex.ranquet@intel.com> 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
a92b57c7f8230661d911f2fd6dd67a81e9a90cef 25-Feb-2014 Calin Juravle <calin@google.com> Merge "Added ftw64, nftw64"
7c1efffc249283b47309846abba8795f3fb91555 25-Feb-2014 Calin Juravle <calin@google.com> Merge "Added mkstemp64"
0e44bc3baeb1677e5fbdda87a737b9c508c95132 25-Feb-2014 Elliott Hughes <enh@google.com> Remove <asm/page.h>.

If we have PAGE_SIZE/PAGESIZE, POSIX says they should be in <limits.h>.

Change-Id: I3c2d574ea2aea81f524874a156361411a4ffa18e
d4934a70e69365c97b1378820152e134a0089b5e 24-Feb-2014 Calin Juravle <calin@google.com> Added ftw64, nftw64

Bug: 13076637
Change-Id: I5b926526f935b00bba14c2807b61d85f95089c33
fe317a3775e16d466bb884a8e054fd77f7087bb3 21-Feb-2014 Calin Juravle <calin@google.com> Added mkstemp64

Bug: 13076637
Change-Id: I41bf28ab3e6c7325470781e9323eeec023483df5
90b0157679a984f1829a72f8c642d17030aa7644 21-Feb-2014 Calin Juravle <calin@google.com> Merge "Fixed int fast types for LP64"
da030de702b756077fec536ed139e7ea38b51022 20-Feb-2014 Calin Juravle <calin@google.com> Fixed int fast types for LP64

Bug: 13110474
Change-Id: Id5591603ad4ba7e149c0852f4abb25e4e5a5d065
5f6f4a956cd630f873fe41058e96262f897f4bc9 19-Feb-2014 Narayan Kamath <narayan@google.com> Fix signbit / infinite / isinf / isnan unit tests.

Turns out stlport isn't broken. <cmath> (included
transitively via gtest in our case) is not required
to make C99 math macros (like signbit) available, nor is
it required to preserve them if they're already defined.
It is only required to make the equivalent functions in
namespace std available.

I couldn't find any documentation of required behaviour for
programs that include both <math.h> and <cmath>.

I've verified experimentally that llvm's libc++ and gnu
stl behave the same as stlport.

bug: 12935307

Change-Id: I9dc5cc0fd9f4f259abc8eefb280177cdd092a94b
1d18e9cc0ab8b2f6d860c4f7d85c33eb5cde4179 19-Feb-2014 Elliott Hughes <enh@google.com> Add missing file from previous change.

Change-Id: Id25000162a9ed76ce756842bdc09fe9afff9528f
db1ea3474899ebbd783aba872d3005f95a816d0f 18-Jan-2014 Elliott Hughes <enh@google.com> 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
915fefb62e1beed3da26fe299a8141645733a925 18-Feb-2014 Elliott Hughes <enh@google.com> Fix x86 build.

Change-Id: Iee6e5884288f7da6c955694cfe32fecfd9c9e263
3d19a8319b9c27af8aa5cfbf495da0fe7fa62d3e 15-Feb-2014 Colin Cross <ccross@android.com> bionic: fix __set_errno for arm64 syscalls that return a 64-bit value

bionic/libc/arch-arm64/syscalls/read.S ends with:
b.hi __set_errno

If __set_errno returns int, it will set w0 to 0xFFFFFFFF, which means
x0 is 0x00000000FFFFFFFF. When interpreted as a ssize_t that is
INT_MAX, not -1.

Change __set_errno to return long, which will cause x0 to be set instead
of w0.

Change-Id: I9f9ea0f2995928d2ea240eb2ff7758ecdf0ff412
671e236d5fd2cae169c2a31d0a35e66c4fcc5556 13-Feb-2014 Elliott Hughes <enh@google.com> Restore sys_signame for LP64.

mksh is using this, and we probably build as much BSD source as glibc source.

Change-Id: I400d255a67f9614ca9e57090e3a2e49d2b10cba4
aa0ebdafc71e1ceac78e0929b94f3bb117d0c8e9 12-Feb-2014 Elliott Hughes <enh@google.com> Clean up sys_signame and sys_siglist a little.

We don't need quite so much duplication because we already have a way
to get the signal number from its name, and that already copes with the
fact that the mips/mips64 numbers are different from everyone else's.

Also remove sys_signame from LP64. glibc doesn't have this BSD-ism.

Change-Id: I6dc411a3d73589383c85d3b07d9d648311492a10
f04935c85e0b466f0d30d2cd4c0fa2fff62e7d6d 21-Dec-2013 Christopher Ferris <cferris@google.com> Make sure that the same tests are on all platforms.

In order to be able to generate a list of tests for cts, the same set of
tests must exist across all platforms. This CL adds empty tests where a
test was conditionally compiled out.

This CL creates a single library libBionicTests that includes all of
the tests found in bionic-unit-tests-static.

Also fix a few missing include files in some test files.

Tested by running and compiling the tests for every platform and
verifying the same number of tests are on each platform.

Change-Id: I9989d4bfebb0f9c409a0ce7e87169299eac605a2
f64b8ea09db3bdd84eed59f7721301743332b3fe 04-Feb-2014 Elliott Hughes <enh@google.com> Add fallocate/fallocate64/posix_fallocate/posix_fallocate64.

Bug: 5287571
Bug: 12612860
Change-Id: I4501b9c6cdf9a830336ce0b3afc4ea716b6a0f6f
718a5b5495ae7726aabd2f8a748da9f391d12b98 29-Jan-2014 Elliott Hughes <enh@google.com> Fix pthread_test to work with gtest 1.7.0.

Now we're building it correctly configured, gtest takes a couple of
TLS slots for itself.

Change-Id: I1c2c4e9e5f9c6e2e2e6ecd1214cfc16a5af5afed
431166d99519f6794f10c48694913d2fe864b841 28-Jan-2014 Elliott Hughes <enh@google.com> Fix 32-bit mmap/mmap64 handling of negative offsets.

We don't actually need to worry about sign extension if we reject
negative values ourselves. Previously it was possible to come up
with negative but aligned values that we would pass to the kernel;
in the case of mmap (as opposed to mmap64) we'd incorrectly turn
those into large positive offsets.

Change-Id: I2aa583e0f892d59bb77429aea8730b72db32dcb0
e2a292d278b94fec3d078b1f1b27c1f89942c276 25-Jan-2014 Elliott Hughes <enh@google.com> Remove __STDC_FORMAT_MACROS and __STDC_LIMIT_MACROS guards (and fix SIZE_MAX for LP64).

The various committees decided that everyone should get all these macros,
all the time.

Bug: 12708004
Change-Id: Ib56010dcba9b0656e5701546fefb7f78dc0bf916
d1973ca51325393f304e82a4d79874f33e54ac16 22-Jan-2014 Colin Cross <ccross@android.com> bionic: rename aarch64 target to arm64

Rename aarch64 build targets to arm64. The gcc toolchain is still

Change-Id: Ia92d8a50824e5329cf00fd6f4f92eae112b7f3a3
0f461e35f63200641fc53bba222845a84589c024 09-Jan-2014 Elliott Hughes <enh@google.com> 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
5f1322cecf5af4bedfb2d3cf857d18e73a233b9d 07-Jan-2014 Elliott Hughes <enh@google.com> Merge "Pass a valid stack pointer to __bionic_clone in pthread.__bionic_clone"
dd00364807020a244aa8be4f3481f7ec0fefcc79 04-Jan-2014 Chris Dearman <chris.dearman@imgtec.com> Pass a valid stack pointer to __bionic_clone in pthread.__bionic_clone

__bionic_clone modifies the child stack before cloning so the stack
pointer should be valid. The test is expecting an EINVAL error to be
generated from the incorrect flags: CLONE_THREAD set without

Change-Id: Ic02192081f6f52df6f03d9810efa82d923247a11
894f8cb1395d3409bb995d18abc1b3409c557d01 03-Jan-2014 Elliott Hughes <enh@google.com> Fix dev_t (for LP64).

32-bit Android's dev_t was wrong too. We can't fix that without ABI breakage,
but we can at least fix 64-bit Android. And add tests.

Bug: https://code.google.com/p/android/issues/detail?id=54966
Change-Id: Ie2e42cc042b78b669a1a44e55f959dbd9c52c5c9
6ad8f76f1f1cbee484c30d723d9d6d1fcf5dc85c 19-Dec-2013 Elliott Hughes <enh@google.com> Don't abort in stdio.getdelim_invalid and stdio.getline_invalid.

Change-Id: Ie1aefed732f4bea77887bddd1be9a0578e247aa3
e7c59f9e2041812c597ff1c8689d47d1bfd32883 18-Dec-2013 Elliott Hughes <enh@google.com> Fix compilation of crtbegin.c and pthread_debug.cpp.

Because there was no default := for the aarch64 libc_crt_target_cflags,
the += was causing libc_crt_target_cflags to be recursively-defined
variable, which meant that when we were compiling crtbegin.c LOCAL_PATH
would be bionic/tests/ and we'd have -Ibionic/tests/include/ and find
none of our include files.

Also fix linking of pthread_debug.cpp, at least in the disabled mode.
The enabled mode was already broken for all architectures, and continues
to be broken after this change. It's been broken for long enough that
we might want to just remove it...

(aarch64 is using the FSF linker where arm uses the gold linker.)

Change-Id: I7db2e386694f6933db043138e6e97e5ae54d4174
e365f9d6543bc6607864ef61257505239dde15d1 10-Oct-2013 Marcus Oakland <marcus.oakland@arm.com> AArch64: Linker64 support for AArch64

Addition of support for AArch64 in the linker64 target.

Change-Id: I8dfd9711278f6706063e91f626b6007ea7a3dd6e
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
282e232e2a32cca8a288e81edddfd95f450cfc79 22-Oct-2013 Serban Constantinescu <serban.constantinescu@arm.com> AArch64: Add fixes to bionic/tests

This patch adds minor fixes to the bionic unit tests.

Change-Id: Ie10f33c631ed6c10987923d678711d22931ddb05
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
1887621de8a48eece8a05f2400ddd783b9833147 12-Dec-2013 Elliott Hughes <enh@google.com> PTHREAD_KEYS_MAX cleanup.

I fixed this bug a while back, but didn't remove it from the list,
could have added a better test, and could have written clearer code
that didn't require a comment.

Change-Id: Iebdf0f9a54537a7d5cbca254a5967b1543061f3d
a84f88f0989e9446686ae76a53dc087ff5788fe6 11-Dec-2013 Colin Cross <ccross@android.com> Merge "bionic: move benchmarks out of tests directory"
bd3efbc9b585e0c9801b0b35f282347cb8692ca8 16-Nov-2013 Colin Cross <ccross@android.com> bionic: move benchmarks out of tests directory

Change-Id: I4d054965198af22c9a9c821d1bc53f4e9ea01248
e5bbb6b6ab662503f06ceb20fa841d2e558d596d 04-Dec-2013 Christopher Ferris <cferris@google.com> Add strcmp/memcmp testing.

Bug: 9797008
Change-Id: I11b1da060d29f7dacbb53f20a3e2082395b5bd8a
f00c938c7f5887981d724bf2dd9989ee0af08332 22-Nov-2013 The Android Open Source Project <initial-contribution@android.com> Merge commit '811b0cdb2d6e4a697dbc63a678712759dd0db242' into HEAD

Change-Id: I786944f80fb1a2d502fed51dc2c391ed5db66761
9d70ddc466ed0bdb36908d69b1fe849904150eb7 19-Nov-2013 Narayan Kamath <narayan@google.com> Merge "Add test case for 1^NaN"
303fe0cb38def66aa438b9caac32e5af298f840a 19-Nov-2013 Elliott Hughes <enh@google.com> Merge "Fix pthread_join."
877ec6d90418ff1d6597147d355a2229fdffae7e 16-Nov-2013 Elliott Hughes <enh@google.com> 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
af64dad4796ab4f077e2f2ba1e90cc56b6575d63 18-Nov-2013 Narayan Kamath <narayan@google.com> Add test case for 1^NaN

Should be 1.

Change-Id: I6cf723a419f51d3bda58286a538774b71276c7b5
cbd85b9cc1c5dd0bb1a5691143cd5adcbecdba77 16-Nov-2013 Christopher Ferris <cferris@google.com> Modify tests for another glibc difference.

It turns out that when passing a closed file to getdelim or getline, the
functions in glibc will properly return a failure, but errno might not be
set. Skip the errno check except on bionic.

Change-Id: I8d625f15303d4c2d42e8d28491ea8a368aea4d32
e39e3a77d6e8cf681718a572bc754fd64dfc87ff 15-Nov-2013 Christopher Ferris <cferris@google.com> Merge "Add new tests for memory/string routines."
70b24b1cc2a1a4436b1fea3f8b76616fdcb27224 15-Nov-2013 Elliott Hughes <enh@google.com> Switch pthread_create over to __bionic_clone.

Bug: 8206355
Bug: 11693195
Change-Id: I04aadbc36c87e1b7e33324b9a930a1e441fbfed6
b687ad3c3491fffe22507cafc9347e10cbf6bd31 07-Nov-2013 Christopher Ferris <cferris@google.com> Add new tests for memory/string routines.

Create a few generic testing functions to allow any memory/string tests
to be created.

Add alignment tests for memcpy/memset/strcat/strcpy/strlen.

Add an overread test for memcpy/strcat/strcpy/strlen. This test attempts
to verify that the functions do not read past the end of their buffers
(src buffer in the case of src/dst functions).

Bug: 9797008

Change-Id: Ib3223ca1b99e729ae8229adc2d03f4dc3103d97c
6a8f00d49c30107903f2449ae563cfee51b48468 13-Nov-2013 Elliott Hughes <enh@google.com> Add unit tests for pow's behavior with NaNs.

Bug: 11669804
Change-Id: Idfa6527640c8d0c2cf3e5343bf7afe013e237545
e61dc71efca544f4066a93706b639a29b3600229 13-Nov-2013 Elliott Hughes <enh@google.com> Add a unit test for syscall(2).

Change-Id: Ic7d9735d46711af93c3a1747de7b2eb8cebea094
2ed710976cb0ace31aab565c95a42d4e75623894 12-Nov-2013 Elliott Hughes <enh@google.com> Add extra regression tests for an already-fixed dynamic linker bug.

Bug: https://code.google.com/p/android/issues/detail?id=61799
Change-Id: I84af68f8430a06e999297c2e57e06ecb45adf81e
062092543fdbd6fa2676e4f5b37a15f7bba94332 07-Nov-2013 Elliott Hughes <enh@google.com> 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
ebd506c69e12b6dcaf5be94cc8ed1b53af299f9f 31-Oct-2013 Sergey Melnikov <sergey.melnikov@intel.com> Fix linker crashes during unknown symbol lookup

Integration of kernel VDSO into internal bionic data structures using
common functions.
Fix for dl_iterate_phdr function: the function provides incorrect
address of object in case of nonzero virtual and base addresses.
Location in address space of a particular program header should be
calculated using the formula: addr = base_addr + virtual_addr.

Signed-off-by: Sergey Melnikov <sergey.melnikov@intel.com>
Change-Id: Ie2ab4257fd456242aab8afed0bd5bd6b29e81d6d
c3f114037dbf028896310609fd28cf2b3da99c4d 30-Oct-2013 Elliott Hughes <enh@google.com> <pthread.h> fixes and pthread cleanup.

<pthread.h> was missing nonnull attributes, noreturn on pthread_exit,
and had incorrect cv qualifiers for several standard functions.

I've also marked the non-standard stuff (where I count glibc rather
than POSIX as "standard") so we can revisit this cruft for LP64 and
try to ensure we're compatible with glibc.

I've also broken out the pthread_cond* functions into a new file.

I've made the remaining pthread files (plus ptrace) part of the bionic code
and fixed all the warnings.

I've added a few more smoke tests for chunks of untested pthread functionality.

We no longer need the libc_static_common_src_files hack for any of the
pthread implementation because we long since stripped out the rest of
the armv5 support, and this hack was just to ensure that __get_tls in libc.a
went via the kernel if necessary.

This patch also finishes the job of breaking up the pthread.c monolith, and
adds a handful of new tests.

Change-Id: Idc0ae7f5d8aa65989598acd4c01a874fe21582c7
13613137bc4266656bffce464e525eb9ae6371f0 28-Oct-2013 Christopher Ferris <cferris@google.com> Fix up failing glibc tests.

There is a known bug running clone with the CLONE_VM flag, so for host
create an empty test.

Change the expected output of the stdio test for a glibc difference.

Change the pause test to use ScopedSignalHandler to setup/restore the SIGALRM

After this, running bionic-unit-tests-glibc passes for all tests.

Bug: 11389824

Change-Id: Ib304eae4164115835a54991dfdca5821ecc3db5e
27586ebe1a7f2f45651b855a26b3203d63d015d6 28-Oct-2013 Elliott Hughes <enh@google.com> Fix utime/utimes when passed a NULL pointer.

Bug: 11383777
Change-Id: If944a42f3adfa8a6ce91c167c249e009ed63300a
b38e4d536f6592cf22b984c143ee6790d6df2351 25-Oct-2013 Christopher Ferris <cferris@google.com> Update running bionic unit tests on host.

Add a bionic-unit-tests-glibc-run target to run the glibc bionic unit tests.

Modify the bionic-unit-tests-run-on-host to make sure that the /system/bin
directory is created properly.

Also remove the EXTERNAL_STORAGE variable which isn't used any more.

Bug: 11234772
Change-Id: I9aea501d05700b29e938f672474d550b1872a78b
11952073af22568bba0b661f7a9d4402c443a888 25-Oct-2013 Elliott Hughes <enh@google.com> Remove dependencies on obsolete __ARCH_WANT_SYSCALL_DEPRECATED system calls.

(aarch64 kernels don't have these system calls.)

Change-Id: I6f64075aa412f71520f2df71c3d69b647f91c1ca
f8fcfbc85a3ce3e195626b90736d3a484331494b 22-Oct-2013 Elliott Hughes <enh@google.com> 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)

Change-Id: I87b4ed79790cb8a80844f5544ac1a13fda26c7b5
594b1a4af204aa9de2b4913182f4556e38d71648 22-Oct-2013 Elliott Hughes <enh@google.com> Make sure we have a mkfifo symbol.

Bug: https://code.google.com/p/android/issues/detail?id=58888
Change-Id: Ic0a883a5f30beb82cb7be3c4e81b6d693d5fbb4d
3d305f1d62107d5261bad1c45a0a441d98dc4d41 22-Oct-2013 Elliott Hughes <enh@google.com> Fix statvfs tests for the host.

Using /proc seems like a better idea because it's more similar across devices.
I've switched to ensuring we check the initial and final elements in the struct
too, so we have more reason to believe the whole struct is converted correctly.

Change-Id: Ia23403369485747c1452292f6c9df2bb233c04fb
e4375196d650f68ad486e2202699c98f9342d616 22-Oct-2013 Elliott Hughes <enh@google.com> Fix the system property tests to use $ANDROID_DATA.

This lets them work on the host.

Change-Id: I771ccc67652ae37451b45859c7831116cd830086
53bfdae4ffdbd43d0c019d1a35af1f8477a272c9 19-Oct-2013 Elliott Hughes <enh@google.com> Fix the x86_64 clone implementation.

Change-Id: Ia75f46dcb4d3222049e9a6a6fabc2b17223b47f7
0c40152767188dc718a46e5b4e7e32e937c85bd8 19-Oct-2013 Elliott Hughes <enh@google.com> Fix the time unit tests for systems with 64-bit time_t.

Change-Id: I29df50b25d022c1c00906e71b612defa58e46e81
17558dec7fc60775c940be0e494b42829f35e0b1 17-Oct-2013 Pavel Chupin <pavel.v.chupin@intel.com> x86_64: Fix bionic tests build-and-run

Change-Id: Iab48362893a212afbcbc362fdfaff5bfa5b55259
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
925753aa1175ae58b24bbfe2d9e38eb4fe3f579d 18-Oct-2013 Elliott Hughes <enh@google.com> Fix some test assumptions that are wrong for __LP64__.

Change-Id: Ic79cd5858ceb611640a76bd03f3da4925d3150d9
c7e9b2331771e5e87c34a8ee3dc6cc41d35b02fe 17-Oct-2013 Elliott Hughes <enh@google.com> 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
6b9321b85875dd8938d0a5064ea3e9fdebe5c623 17-Oct-2013 Elliott Hughes <enh@google.com> am d6e117b6: am 1f29c2f5: Merge "Switch sigpending over to rt_sigpending."

* commit 'd6e117b64bdfbf8d793eb59ea9604b806608ec75':
Switch sigpending over to rt_sigpending.
40d105ccb3e6283566ce54b693b3088f31aa4f26 16-Oct-2013 Elliott Hughes <enh@google.com> Switch sigpending over to rt_sigpending.

Change-Id: I7b28984796b5fb343cfbcc47e0afc3a84293d417
afaebc3fefe93cbfbaead60212dab7b99bae9d7a 16-Oct-2013 Elliott Hughes <enh@google.com> 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.
1f5af926fa626734981d6b4dcc0ab54e520032a9 16-Oct-2013 Elliott Hughes <enh@google.com> Fix sigsuspend to use rt_sigsuspend on all platforms.

Change-Id: I981c1a66d35480d4457a0a08a1b042dac94daa5b
4681f8244ee6fd3aec5a5c62e604e2a429d0d00f 15-Oct-2013 Elliott Hughes <enh@google.com> am 5b3f1d8b: am 22b83da4: Merge "Clean up the sigprocmask/pthread_sigmask implementation."

* commit '5b3f1d8b3a6a1caf059dc376e4967a27ddd57dac':
Clean up the sigprocmask/pthread_sigmask implementation.
19e62325c268a668692e2b65fde2284079f369aa 15-Oct-2013 Elliott Hughes <enh@google.com> 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

Bug: 11069919
Change-Id: I11da99f85b5b481870943c520d05ec929b15eddb
8161b236891de223b0ebe9b76db57147d50a20f5 12-Oct-2013 Stephen Hines <srhines@google.com> am 4691325d: am abeafbd6: Merge "Wrap sprintf()/snprintf() macros to prevent expansion errors."

* commit '4691325d48406033632fe84a944ac9c3bd2e5097':
Wrap sprintf()/snprintf() macros to prevent expansion errors.
78f6db64fe90e45f1cdb649543feb2d92696802a 12-Oct-2013 Stephen Hines <srhines@google.com> am 36959302: am 8704ada3: Merge "Fix clang warnings in bionic."

* commit '36959302a334499c7d2ddf4a090e2ab7e3a8ae1d':
Fix clang warnings in bionic.
abeafbd6d5e11044dd305e48134bc3d84319a3da 12-Oct-2013 Stephen Hines <srhines@google.com> Merge "Wrap sprintf()/snprintf() macros to prevent expansion errors."
6c7b3cb056509fd8756bc012878a499f6f102114 12-Oct-2013 Stephen Hines <srhines@google.com> Fix clang warnings in bionic.

This fixes a few diverse issues that clang warns on in bionic. First,
it specifies the appropriate converted types for format specifiers.
The "h" and "hh" modifiers specify that the user is passing a short or
char respectively. We were passing int deliberately in both cases and
relying on the compiler to implicitly downcast to the smaller type.
We also remove the non-standard "d" suffix from our double-precision
floating point constant. This is an extension for gcc that clang does
not implement. The third fix is to mark the c1 variable as unused,
since it truly is neither read nor written.

Change-Id: I4793352b9d3e58f1f4cac9e7581ef4b2a70b43c7
6e38072addd556e3894284b5bd040ac64fffa72e 11-Oct-2013 Stephen Hines <srhines@google.com> Wrap sprintf()/snprintf() macros to prevent expansion errors.

Previously, FORTIFY_SOURCE used single macros to define these standard
functions for use with clang. This can cause conflicts with other macros used
to call these functions, particularly when those macros expand the number of
arguments to the function. This change wraps our macro definitions, so that
expansion properly takes place for programmer arguments first.

Change-Id: I55929b1fd2a643b9d14a17631c4bcab3b0b712cf
49bb53c8e20ff37a1965ba4af645464ea4b8f8fa 10-Oct-2013 Nick Kralevich <nnk@google.com> am 95de0df8: am eda2679e: Merge "FORTIFY_SOURCE: fortify read()"

* commit '95de0df8c2daeefca358010f2d15c3346a5284f1':
FORTIFY_SOURCE: fortify read()
b036b5ca36c1e12b075909b3eca6eab73ee611cf 10-Oct-2013 Nick Kralevich <nnk@google.com> FORTIFY_SOURCE: fortify read()

Change-Id: Ic7de163fe121db13e00560adb257331bc709814d
b8771d9fd844fd28b6e5e6fe429ef40c097b32a6 10-Oct-2013 Nick Kralevich <nnk@google.com> am b35ebe3d: am 848efa9d: Merge "Revert "FORTIFY_SOURCE: fortify read()""

* commit 'b35ebe3d7097899fd4498ebb2b93e48fd836ebcf':
Revert "FORTIFY_SOURCE: fortify read()"
8d2532763981d132b02df157e4cc363c39330090 10-Oct-2013 Nick Kralevich <nnk@google.com> Revert "FORTIFY_SOURCE: fortify read()"

This change reverts
* fb3f956d075676c0438f2ee2bf3a5be659dfc04b.
* 65c99de2cb7a569ea17ca35e2f8f1e033421864b

Change-Id: Id5774eeede41130579115cf67a72ee914f2b47d5
45e3076cdc03efe7d37178fbd4366d5632d50cba 10-Oct-2013 Nick Kralevich <nnk@google.com> am 731ced6b: am c147478c: Merge "FORTIFY_SOURCE: fortify read()"

* commit '731ced6b289629a552b5841561fdcccf08d8c43a':
FORTIFY_SOURCE: fortify read()
65c99de2cb7a569ea17ca35e2f8f1e033421864b 09-Oct-2013 Nick Kralevich <nnk@google.com> FORTIFY_SOURCE: fortify read()

Change-Id: I3d7b4ec86d04efb865117ce7629a2e26917f3331
6f103689268a8f6c6177b9c17d72436776a27b22 04-Oct-2013 Nick Kralevich <nnk@google.com> am 2e819c58: am 2ff3c746: Merge "Check memory size on FD_* functions"

* commit '2e819c58c9396eec3e4311ef2c9bdcadd107f001':
Check memory size on FD_* functions
7943df62f70f686b0c77532f6617b47255d75763 03-Oct-2013 Nick Kralevich <nnk@google.com> Check memory size on FD_* functions

Make sure the buffer we're dealing with has enough room.
Might as well check for memory issues while we're here,
even though I don't imagine they'll happen in practice.

Change-Id: I0ae1f0f06aca9ceb91e58c70183bb14e275b92b5
fa9fb5cb01986ac77ea4f7c54b2f419ac47989d3 03-Oct-2013 Elliott Hughes <enh@google.com> am 2a3d760e: am 00a816e5: Merge "Fix 32-bit issues in tests, and add a trivial test for the FD_* macros."

* commit '2a3d760e0fc0cbd2cac03754949457c062ced5f5':
Fix 32-bit issues in tests, and add a trivial test for the FD_* macros.
5b9310e502003e584bcb3a028ca3db7aa4d3f01b 03-Oct-2013 Elliott Hughes <enh@google.com> Fix 32-bit issues in tests, and add a trivial test for the FD_* macros.

Change-Id: Ia3f21ce1f0ed9236527fe44d36ccb7de6bf63113
5634373320d7dac30fa68feeb4d3b883566461ac 03-Oct-2013 Nick Kralevich <nnk@google.com> am 8598cd68: am f741e1c2: Merge "FORTIFY_SOURCE: Add __FD_* checks"

* commit '8598cd6888366008033286113bd633b44c70b7dd':
FORTIFY_SOURCE: Add __FD_* checks
90201d5eca050414d50a433866ccb580415bb0d4 03-Oct-2013 Nick Kralevich <nnk@google.com> FORTIFY_SOURCE: Add __FD_* checks

Add FORTIFY_SOURCE checks for the following macros:


Bug: 11047121
Change-Id: I3c5952136aec9eff3288b91b1318677ff971525c
944ce989f8d9c4fa1c8211ac5aa46693346e1fe0 02-Oct-2013 Nick Kralevich <nnk@google.com> am f7da611b: am 00d51c9f: Merge "Use alloc_size attribute on *alloc functions"

* commit 'f7da611b3dedaf9951e08b0296daf67eda8228c0':
Use alloc_size attribute on *alloc functions
b91791d71c58d14309cd4d842d222f5d36b3a5a8 02-Oct-2013 Nick Kralevich <nnk@google.com> Use alloc_size attribute on *alloc functions

malloc and family were not declared with __attribute__((alloc_size)).
This was (sometimes) preventing FORTIFY_SOURCE related functions
from knowing the size of the buffer it's dealing with, inhibiting
FORTIFY_SOURCE protections.

Add __attribute__((alloc_size))

Information about the alloc_size attribute can be found
at http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html

Change-Id: Ia2f0a445f0170a7325f69259b5e7fb35a9f14921
a59e16bac971db7bb8e65e63d90e895bf4731747 30-Sep-2013 Christopher Ferris <cferris@google.com> am 34c2a9fc: Move stack unwinding test into library.

* commit '34c2a9fc37848d446bf91ce61783884232fffeb1':
Move stack unwinding test into library.
427e8cf90248f7da0a789fb3b4fb9a859c19aacd 27-Sep-2013 Christopher Ferris <cferris@google.com> Fix line that got removed by merge.

(cherry picked from commit f14d71fcf74e755ece4f8ca2ca2b7483424aa432)

Change-Id: Id3dd54d9efd87ef2bbb2c90adae2ce3911695027
e83a780600eda88d351fda590079265bcc0d1f56 27-Sep-2013 Conley Owens <cco3@android.com> resolved conflicts for merge of f4af9110 to klp-dev-plus-aosp

Change-Id: I9e499e552b758392dd0c7b8d888944c0150dd22a
9a622f874ceb90431623af140ca9a78eadc96dcb 27-Sep-2013 Nick Kralevich <nnk@google.com> am cc362291: am 8427b745: Merge "libc: fortify recvfrom()"

* commit 'cc362291362f8183431eccb19267c8a625f36006':
libc: fortify recvfrom()
8427b7450fe068db6484d161f7004661c4698858 27-Sep-2013 Nick Kralevich <nnk@google.com> Merge "libc: fortify recvfrom()"
fcdb47d7f5f859e04e9f4d88006e5595a9acf647 26-Sep-2013 Elliott Hughes <enh@google.com> am dbd4dbc0: am a1c1a334: Merge "Add a unit test for %n."

* commit 'dbd4dbc02c969531ff4891c06e66c63ec7a6d75d':
Add a unit test for %n.
7248a2d4d03122efc55637ec77692fbc260b6e4f 25-Sep-2013 Elliott Hughes <enh@google.com> Add a unit test for %n.

Change-Id: I9335e089d66c98d34577f5e1d1a54b8f507b94f6
60f4f9a5b99a0a66817f50edfc2194a49f8b5146 25-Sep-2013 Nick Kralevich <nnk@google.com> libc: fortify recvfrom()

Fortify calls to recv() and recvfrom().

We use __bos0 to match glibc's behavior, and because I haven't
tested using __bos.

Change-Id: Iad6ae96551a89af17a9c347b80cdefcf2020c505
a663ebd468b99981b07c1b0dca9aaa5da2cd8d50 24-Sep-2013 Elliott Hughes <enh@google.com> am f8222078: am 43e5badd: Merge "Fix %hhd formats in the printf family."

* commit 'f82220785d20385fa02aa78b02f3fdb98e5aa553':
Fix %hhd formats in the printf family.
1d13c64d781a87dfa3f01e5c179bfa36748786af 24-Sep-2013 Elliott Hughes <enh@google.com> Fix %hhd formats in the printf family.

Found by adapting the simple unit tests for libc logging to test
snprintf too. Fix taken from upstream OpenBSD without updating
the rest of stdio.

Change-Id: Ie339a8e9393a36080147aae4d6665118e5d93647
34c2a9fc37848d446bf91ce61783884232fffeb1 29-Aug-2013 Christopher Ferris <cferris@google.com> Move stack unwinding test into library.

Bug: 8291716

(cherry picked from commit 8240bed918722944c9985bc0cca89eb44c4f6c91)

Change-Id: I1da2d0757ed304c352229f9818c052925d4e976a
f4af911065b1b392085b857b891e5496bc75f478 27-Aug-2013 Christopher Ferris <cferris@google.com> Create bionic unit test library for use with CTS.

Bug: 8291716

(cherry picked from commit 153d92765bb693541abf49a2a1d31335e2c90348)

Change-Id: Ia53b85b95621b7000034e4c6259d6586d0987dee
7bfef355b1590cb8ac68d8caa97eaf0018191db8 28-Aug-2013 Christopher Ferris <cferris@google.com> Change hard-coded directory.

The tests are using /data/data which is not accessible to a non-root
user. Change this to /data/local/tmp which is accessible to all users.

Bug: 8291716

(cherry picked from commit 5227bb363dfdd0a4570cfa3d0735744daf7d83c2)

Change-Id: I83bf70aa8edd21b00321363d7ddcb65a5f048ba5
6d1f85dcdcf32117332b48563357d311a2886c30 15-Aug-2013 Christopher Ferris <cferris@google.com> Change hard-coded temporary directory.

The properties tests creates a temporary directory in /data/nativetest,
but this directory might not exist in all circumstances.
Change this to create the temporary directory in /data/local/tmp.

(cherry picked from commit bd6dc6a8864a1997eb8608030ac816740169c463)

Change-Id: I15144ece7ffb5c29eded9a1ef399db630f6af5ab
16e185c9081530859c17270fbaf5798f0ea871f8 11-Sep-2013 Christopher Ferris <cferris@google.com> __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 883ef2499c2ff76605f73b1240f719ca6282e554)

Change-Id: Id9a96b549435f5d9b61dc132cf1082e0e30889f5
e74f77f92d80f11616da699ac908fd5d1913e996 20-Sep-2013 Elliott Hughes <enh@google.com> 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.
b4f7616fd618875768b8fffc122b58bdb84a9969 20-Sep-2013 Elliott Hughes <enh@google.com> Ensure we have the off64_t variant of every function that takes an off_t.

Change-Id: Ib2eee0cf13162be3b62559b84e90c6dcf5aab1c3
1b75f3e07a8d20f45aa8a78578f294ac499529d0 19-Sep-2013 Elliott Hughes <enh@google.com> am fd5f6f19: am d5ddf40e: Merge "Fix host tests that need the shell."

* commit 'fd5f6f192ab6dcc01091b0e36af822dd3480f9b4':
Fix host tests that need the shell.
e60c4f0a6cb5836caa8d0de299cc83fe4b13744c 19-Sep-2013 Elliott Hughes <enh@google.com> Fix host tests that need the shell.

By making the /system/bin/sh available.

Change-Id: I99200c1ddc922a2f6b5cea8ff2da98aedbe70e7b
ca0f0662f42a5debe8469e1a9b06ebffb6e492aa 19-Sep-2013 Elliott Hughes <enh@google.com> am 2443358b: am 4a509d89: Merge "Add bionic-unit-tests-run-on-host special target"

* commit '2443358b3717bdce932303bbcbe625f59e1ae380':
Add bionic-unit-tests-run-on-host special target
f22fb68751c4040f3335cb0bd2d47f87c3ee1aac 06-Sep-2013 Pavel Chupin <pavel.v.chupin@intel.com> Add bionic-unit-tests-run-on-host special target

Allows running the tests linked with bionic .so on the host if host and
target are compatible. See more comments and usage limitation inlined.

make bionic-unit-tests-run-on-host should do build and run.

Change-Id: I5946fa72e009d324baa9da18f460294b3c1a615e
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2e7a8b44c2691770e917efcca80bc2650d93efaa 11-Sep-2013 Christopher Ferris <cferris@google.com> resolved conflicts for merge of 883ef249 to klp-dev-plus-aosp

Change-Id: I1e2bd03a0cb5a0ab191c525d1574377bc7fd90ab
883ef2499c2ff76605f73b1240f719ca6282e554 11-Sep-2013 Christopher Ferris <cferris@google.com> __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
7a809829136457bb884e54cce6d1ec29223970c2 29-Aug-2013 Christopher Ferris <cferris@google.com> am fc24bc25: am 99b859cf: Merge "Move stack unwinding test into library."

* commit 'fc24bc2544edad03798a1c69d6a76259e6f1e7dd':
Move stack unwinding test into library.
8240bed918722944c9985bc0cca89eb44c4f6c91 29-Aug-2013 Christopher Ferris <cferris@google.com> Move stack unwinding test into library.

Bug: 8291716
Change-Id: Ia270f074b574a8fe86b5ad435bdef80999c64295
2c87c3ff021571e82684a865609a1146830338fb 28-Aug-2013 Nick Kralevich <nnk@google.com> am cfd0d72d: am eb8f3622: Merge "FORTIFY_SOURCE: introduce __strncpy_chk2"

* commit 'cfd0d72da8641087f9c4015ee586614da9f7320a':
FORTIFY_SOURCE: introduce __strncpy_chk2
93501d3ab81156bcef251bb817a49e9ca46a6ec1 28-Aug-2013 Nick Kralevich <nnk@google.com> FORTIFY_SOURCE: introduce __strncpy_chk2

This change detects programs reading beyond the end of "src" when
calling strncpy.

Change-Id: Ie1b42de923385d62552b22c27b2d4713ab77ee03
7c8ebaf6c17c11854ae394ac7fa45c51489de75a 28-Aug-2013 Christopher Ferris <cferris@google.com> am d923b307: am 2557433d: Merge "Change hard-coded directory."

* commit 'd923b3075c9cf9e0749cee7373cabb9afba9420c':
Change hard-coded directory.
3825da5c0734215d179ce613681322fb5be3bfbe 28-Aug-2013 Christopher Ferris <cferris@google.com> am 7a2c2784: am 1f216e30: Merge "Create bionic unit test library for use with CTS."

* commit '7a2c2784a656adfae613b6b53d388988d6f2efa6':
Create bionic unit test library for use with CTS.
5227bb363dfdd0a4570cfa3d0735744daf7d83c2 28-Aug-2013 Christopher Ferris <cferris@google.com> Change hard-coded directory.

The tests are using /data/data which is not accessible to a non-root
user. Change this to /data/local/tmp which is accessible to all users.

Bug: 8291716

Change-Id: I66476bbbaf5d1dc0c103863abf9219405f06a85b
153d92765bb693541abf49a2a1d31335e2c90348 27-Aug-2013 Christopher Ferris <cferris@google.com> Create bionic unit test library for use with CTS.

Bug: 8291716

Change-Id: I46b749348456fae7892eecca6b44aef51a0e4747
e9e10c13ff3fdb7104aafd0707b2c851851c9d1f 15-Aug-2013 Jeff Hao <jeffhao@google.com> Fix pthread_getcpuclockid.

clock_gettime was returning EINVAL for the values
produced by pthread_getcpuclockid.

Bug: 10346183

(cherry picked from commit 9b06cc3c1b2c4e2b08582f3fc9393a05aa589766)

Change-Id: Ib81a7024c218a4502f256c3002b9030e2aaa278d
6b5eb3134adb3d08c0803228ce79d3a5b14d4fac 22-Aug-2013 Elliott Hughes <enh@google.com> am e5ac43e1: am c44205cf: Merge "Work around tzcode\'s reliance on signed overflow."

* commit 'e5ac43e19afe270c2a70e4fb5d02b4cf056d50d7':
Work around tzcode's reliance on signed overflow.
f0c10a4a16c74f5099cf6b272c0a2f11f454e63c 22-Aug-2013 Elliott Hughes <enh@google.com> Work around tzcode's reliance on signed overflow.

I've mailed the tz list about this, and will switch to whatever upstream
fix comes along as soon as it's available.

Bug: 10310929

(cherry picked from commit 7843d44a594270bcb56e98b130603c054f8a9d38)

Change-Id: I205e2440703444c50cecd91d3458d33613ddbc59
7843d44a594270bcb56e98b130603c054f8a9d38 22-Aug-2013 Elliott Hughes <enh@google.com> Work around tzcode's reliance on signed overflow.

I've mailed the tz list about this, and will switch to whatever upstream
fix comes along as soon as it's available.

Bug: 10310929
Change-Id: I36bf3fcf11f5ac9b88137597bac3487a7bb81b0f
2389a26705a600e69c8c0b24a02bc05522bc68d1 16-Aug-2013 Christopher Ferris <cferris@google.com> am c058154b: am c8039337: Merge "Change hard-coded temporary directory."

* commit 'c058154b747f295c98ad771d3dec4065749ee1a9':
Change hard-coded temporary directory.
e714eb157ea92f3166b6292ed54138f3e092d5da 16-Aug-2013 Elliott Hughes <enh@google.com> am 6b6aaec8: am 4eacb341: Merge "Fix pthread_getcpuclockid."

* commit '6b6aaec892b1f256787fbbf106449f7d7e5888a2':
Fix pthread_getcpuclockid.
c8039337e3ee608e23f8ca6e5ea123d938b08029 16-Aug-2013 Christopher Ferris <cferris@google.com> Merge "Change hard-coded temporary directory."
9b06cc3c1b2c4e2b08582f3fc9393a05aa589766 15-Aug-2013 Jeff Hao <jeffhao@google.com> Fix pthread_getcpuclockid.

clock_gettime was returning EINVAL for the values
produced by pthread_getcpuclockid.

Bug: 10346183
Change-Id: Iabe643d7d46110bb311a0367aa0fc737f653208e
bd6dc6a8864a1997eb8608030ac816740169c463 15-Aug-2013 Christopher Ferris <cferris@google.com> Change hard-coded temporary directory.

The properties tests creates a temporary directory in /data/nativetest,
but this directory might not exist in all circumstances.
Change this to create the temporary directory in /data/local/tmp.

Change-Id: I812d3e24fcd084c5d74055c9faa95b1656f255bc
840a114eb12773c5af39c0c97675b27aa6dee78c 09-Aug-2013 Elliott Hughes <enh@google.com> Add futimens.

(cherry picked from commit d0be7c8f9a06b3ca8ea7647ea35c8f9dc63f0fe1)

Bug: 10239370
Change-Id: I0087e85a94d83b6ce68ec6a0768c44cbe4bd0132
d0be7c8f9a06b3ca8ea7647ea35c8f9dc63f0fe1 09-Aug-2013 Elliott Hughes <enh@google.com> Add futimens.

Bug: 10239370
Change-Id: I518340084103dc339ef8a065d4837d6258a1381d
49b24b4efbc95cbff6dc73007583a880f7c01e7e 03-Aug-2013 Elliott Hughes <enh@google.com> am 3287dccf: Merge "Add ssse3 implementation of __memcmp16."

* commit '3287dccf2ecced89bb39b857abc8eba997bc3f51':
Add ssse3 implementation of __memcmp16.
baa91f4f8974b6e9a81fa3aa49f051b3bf823653 26-Jun-2013 Alexander Ivchenko <alexander.ivchenko@intel.com> Add ssse3 implementation of __memcmp16.

__memcmp16 was missing in x86. Also added C-version for backward
compatibility. Added bionic test for __memcmp16 and for wmemcmp.

Change-Id: I33718441e7ee343cdb021d91dbeaf9ce2d4d7eb4
Signed-off-by: Alexander Ivchenko <alexander.ivchenko@intel.com>
993ea1061b99607df0613be609ada257df3f9266 16-Jul-2013 Elliott Hughes <enh@google.com> am 5148661f: am 67750c85: Merge "Fix pthread_getattr_np, pthread_attr_setguardsize, and pthread_attr_setstacksize."

* commit '5148661f8d2be514d0e3c191bc1e489157ae1154':
Fix pthread_getattr_np, pthread_attr_setguardsize, and pthread_attr_setstacksize.
b95cf0d23a1db3b7c37bd98b0c86196796c9b029 15-Jul-2013 Elliott Hughes <enh@google.com> Fix pthread_getattr_np, pthread_attr_setguardsize, and pthread_attr_setstacksize.

pthread_getattr_np was reporting the values supplied to us, not the values we
actually used, which is kinda the whole point of pthread_getattr_np.

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

Also improve the error reporting for pthread_create failures.

Change-Id: I7ebc518628a8a1161ec72e111def911d500bba71
d3522051ce506963c5900f4ecbabfaaa62a5fb5d 12-Jul-2013 Elliott Hughes <enh@google.com> am 7e56f462: am 3db1f359: Merge "Add a trivial gmtime(3) test."

* commit '7e56f462ad19791d7b270e297fc994d18df43252':
Add a trivial gmtime(3) test.
ee178bfb794d16d6c5a35f424b28c8ebb83e1581 12-Jul-2013 Elliott Hughes <enh@google.com> Add a trivial gmtime(3) test.

Change-Id: I849f200a455cd6971646fa45766ab22ba19fb866
1087e0df4f542a7640db7709b068751be4752443 11-Jul-2013 Elliott Hughes <enh@google.com> am 731f7c2d: am 9d476716: Merge "Add <sys/statvfs.h>."

* commit '731f7c2d0e531d5e0ecdd771d743053f8d093e16':
Add <sys/statvfs.h>.
06040fd75c1edff9e5ffb2b3d3e2a6e66d57c11d 09-Jul-2013 Elliott Hughes <enh@google.com> Add <sys/statvfs.h>.

Bug: 2512019
Change-Id: I6e7fd3fa281977cc4bc270481a95416b5b2dc351
742aad35845b156a34db1d06a50a63f4b7f6d47d 03-Jul-2013 Elliott Hughes <enh@google.com> am 7c808b29: am feec97a7: Merge "Fix inttypes.h PRI?PTR and SCN?PTR macros."

* commit '7c808b29d5cea61e5bda90a1b0f2f0e669ee135e':
Fix inttypes.h PRI?PTR and SCN?PTR macros.
74f0833df6d04d51eb4e554845862ed7279f78b0 03-Jul-2013 Elliott Hughes <enh@google.com> Fix inttypes.h PRI?PTR and SCN?PTR macros.

Our intptr_t and uintptr_t aren't "long". Add a compilation test so we remember
to fix this to cope with 32- and 64-bit later.

Bug: http://code.google.com/p/android/issues/detail?id=57218
Change-Id: I2f816d339edb4f7d57e4418b818fb4c602093f38
4b17283c9839ddd8c692eb57f657abf3facb73d8 01-Jul-2013 Nick Kralevich <nnk@google.com> am 28d298a6: am 413eef71: Merge "More FORTIFY_SOURCE functions under clang"

* commit '28d298a673da4367f27f428db5e12d7dad3d8e83':
More FORTIFY_SOURCE functions under clang
a6cde392765eb955cb4be5faa6ee62dcf77e8aa5 29-Jun-2013 Nick Kralevich <nnk@google.com> More FORTIFY_SOURCE functions under clang

* bzero
* umask
* strlcat

Change-Id: I65065208e0b8b37e10f6a266d5305de8fa9e59fc
fda0c066050c26cbb5bb130b5f2c25ccddde2945 28-Jun-2013 Nick Kralevich <nnk@google.com> am 2018cfa8: am 394df35e: Merge "Reorganize FORTIFY_SOURCE tests."

* commit '2018cfa85d4c7f36316376f5b090be5f0d3d13dc':
Reorganize FORTIFY_SOURCE tests.
5bcf39842e8c4b02ae557a2765a84e724f762469 28-Jun-2013 Nick Kralevich <nnk@google.com> Reorganize FORTIFY_SOURCE tests.

Get rid of a lot of the duplication in the various FORTIFY_SOURCE
tests. Instead, we build 4 separate static libraries, with
4 different compile time options, and link them into the final test

Change-Id: Idb0b7cccc8dd837adb037bf4ddfe8942ae138230
9a268a10bb5ceb564aea42f1658d0e83004f3b48 27-Jun-2013 Nick Kralevich <nnk@google.com> am f9ef0106: am 78a7bf99: Merge "stdio.h: enable vs?printf clang FORTIFY_SOURCE"

* commit 'f9ef0106da43d21e6cb68d87b86d806f63b215fd':
stdio.h: enable vs?printf clang FORTIFY_SOURCE
c8ae8bd9418b79f4da85dc12a61ebd82146b7e51 27-Jun-2013 Nick Kralevich <nnk@google.com> stdio.h: enable vs?printf clang FORTIFY_SOURCE

Enable FORTIFY_SOURCE protections under clang for the following

* vsprintf
* vsnprintf

and add unittests.

Change-Id: I90f8a27f7b202c78b5dd8ebf53050bf9e33496f7
d9643a3119264da152b4c9577bfee8b542c8454b 26-Jun-2013 Elliott Hughes <enh@google.com> am d31287d6: am 7d624e9a: Merge "Kernel dso support for \'dl_iterate_phdr\' function"

* commit 'd31287d6017475209cfee2fea0532bdc8c0f4aac':
Kernel dso support for 'dl_iterate_phdr' function
caad18c7d19a7371b1b8514c0f2777ebd00ba043 26-Jun-2013 Nick Kralevich <nnk@google.com> am 71802135: am bfacb603: Merge "libc: enable FORTIFY_SOURCE snprintf under clang"

* commit '7180213557f3120b391053b4f5861037eda6ebb6':
libc: enable FORTIFY_SOURCE snprintf under clang
be30c7a78a1cf4adc8ec9bbdf17e85186fdb05b2 19-Jun-2013 Greg Hackmann <ghackmann@google.com> bionic: revert to a single (larger) property area

d329697 is too complicated. Change the multiple property pages back to
a single 128K property area that's mapped in entirely at initialization
(the memory will not get allocated until the pages are touched).

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

Change-Id: Icd137669a4f8bc248e9dd2c1e8cc54e9193c9a6d
Signed-off-by: Greg Hackmann <ghackmann@google.com>
d5276422ca9f1f4d45e91c189a1655521e91962d 17-Jun-2013 Greg Hackmann <ghackmann@google.com> bionic: add hierarchical properties test

Deliberately put items several levels deep in the trie hierarchy to test
the trie traversal

Change-Id: I995a1cdd3b5e74162fb5d25bc0f65140bdf2f719
Signed-off-by: Greg Hackmann <ghackmann@google.com>
c45087bffa528c0809f0df2e0a3708eba7018b33 25-Jan-2013 Sergey Melnikov <sergey.melnikov@intel.com> Kernel dso support for 'dl_iterate_phdr' function

Kernel provides virtual DSO for stack unwinding/exception handlind info for
signal usage case. Stack unwinding routines use 'dl_iterate_phdr' function
for additional DWARF info gathering from DSOs. Patch enables virtual DSO
enumeration via dl_iterate_phdr function.

Signed-off-by: Sergey Melnikov <sergey.melnikov@intel.com>
Change-Id: Ic2882b28f40b456a088bc1e63c50cbfda7e4a102
621b19dddbfba1cd98c01cb95ce312baa20e0e7c 25-Jun-2013 Nick Kralevich <nnk@google.com> libc: enable FORTIFY_SOURCE snprintf under clang

Change-Id: I8b8059782a720104722b0841994b38f873ed02aa
5f7f7fca278c45debe7e2fa80edd859277141f17 25-Jun-2013 Nick Kralevich <nnk@google.com> am 95448039: am 0ea1d5c0: Merge "libc: enable sprintf FORTIFY_SOURCE under clang"

* commit '954480393f4539f62cdc3f6cb83c562050ea4f51':
libc: enable sprintf FORTIFY_SOURCE under clang
890aa0d937ae72473c84cc773e77d45e9288b0bc 25-Jun-2013 Greg Hackmann <ghackmann@google.com> Revert "bionic: add hierarchical properties test"

This reverts commit 0f76e2340ca53ce458a01f91627651dfe0112969.
fa8cc0629f6227b507434245d237d44d7e119b16 25-Jun-2013 Greg Hackmann <ghackmann@google.com> Revert "bionic: revert to a single (larger) property area"

This reverts commit 5f05348c18286a2cea46eae8acf94ed5b7932fac.
1540f601be32bdd4af8e8c13bdf2bc06bdaa76f1 19-Jun-2013 Greg Hackmann <ghackmann@google.com> bionic: revert to a single (larger) property area

d329697 is too complicated. Change the multiple property pages back to
a single 128K property area that's mapped in entirely at initialization
(the memory will not get allocated until the pages are touched).

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

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

(cherry picked from commit 5f05348c18286a2cea46eae8acf94ed5b7932fac)

Change-Id: I690704552afc07a4dd410277893ca9c40bc13e5f
cb215a7e9ecec9feb5aae9d9a5b1c89f392208e7 13-Feb-2013 Greg Hackmann <ghackmann@google.com> bionic: make property area expandable

The property area is initially one 4K region, automatically expanding as
needed up to 64 regions.

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

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

(cherry picked from commit d32969701be070c0161c2643ee3c3df16066bbb8)

Change-Id: I038d451fe8849b0c4863663eec6f57f6521bf4a7
5f05348c18286a2cea46eae8acf94ed5b7932fac 19-Jun-2013 Greg Hackmann <ghackmann@google.com> bionic: revert to a single (larger) property area

d329697 is too complicated. Change the multiple property pages back to
a single 128K property area that's mapped in entirely at initialization
(the memory will not get allocated until the pages are touched).

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

Change-Id: I0ecb27843404f93af5489f15bfe657d65175e4f0
Signed-off-by: Greg Hackmann <ghackmann@google.com>
c6eb9854542c115fd9aa87731adcb1b5da57e8ac 24-Jun-2013 Nick Kralevich <nnk@google.com> libc: enable sprintf FORTIFY_SOURCE under clang

clang doesn't support __builtin_va_arg_pack(), so we have
to use #define instead.

Change-Id: I2ee75e6267d60cdf997fee6b9b0547bf68f062a1
0f76e2340ca53ce458a01f91627651dfe0112969 17-Jun-2013 Greg Hackmann <ghackmann@google.com> bionic: add hierarchical properties test

Deliberately put items several levels deep in the trie hierarchy to test
the trie traversal

Change-Id: Id3cbd2e7d3500216b1ac8025eac70c0939622903
Signed-off-by: Greg Hackmann <ghackmann@google.com>
33ae76abf32b8f78799e9ebb1de2343dfa10c91a 20-Jun-2013 Nick Kralevich <nnk@google.com> am 5fed0eea: am 0ce28d20: Merge "libc: enable FORTIFY_SOURCE clang strlcpy"

* commit '5fed0eeabd88bfe241c416f2c2f44a14b6e447fa':
libc: enable FORTIFY_SOURCE clang strlcpy
8bafa7452ec0892572b0b49f86022ce945c5e908 20-Jun-2013 Nick Kralevich <nnk@google.com> libc: enable FORTIFY_SOURCE clang strlcpy

Change-Id: Idcfe08f5afc3dde592416df9eba83f64e130c7c2
d32969701be070c0161c2643ee3c3df16066bbb8 13-Feb-2013 Greg Hackmann <ghackmann@google.com> bionic: make property area expandable

The property area is initially one 4K region, automatically expanding as
needed up to 64 regions.

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

Change-Id: Ibe00ef52464bfa590953c4699a6d98383b0142b1
Signed-off-by: Greg Hackmann <ghackmann@google.com>
02ca0e314219a4c7205a180a414c509651043f13 19-Jun-2013 Nick Kralevich <nnk@google.com> Merge "Fix FORTIFY_SOURCE unittests."
3cd4cac2cedd960e76bb55ce899f8d42bf4dfbfc 19-Jun-2013 Nick Kralevich <nnk@google.com> Fix FORTIFY_SOURCE unittests.

The compiler is too damn smart.

Change-Id: Ibef3ef41ec99f8cd9c06f1dbca535819f9a08197
c6ff844d75dddfb19fc804b8add2d6a79947b101 13-Feb-2013 Greg Hackmann <ghackmann@google.com> bionic: add __system_property_foreach

find_nth() will be inefficient on a trie. Since find_nth() is only used
internally and only for enumerating properties, we can add a foreach()
function to do this directly.

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

(cherry picked from commit 577418403d68e663fb33c7b0c8a90d862d9c00cf)

Change-Id: Iaca97d1182ce2c28863ba85241cbb5cf6185eb2f
dd0880fec3bb8c998680e78aff9e2ddc2bcf6d7a 18-Jun-2013 Nick Kralevich <nnk@google.com> Merge "libc: add limited FORTIFY_SOURCE support for clang"
7d06813d93b3b3745d438c000f596a38cb0efeb4 18-Jun-2013 Colin Cross <ccross@android.com> bionic: fix deleting property arrays in property benchmark

Use delete[] to delete arrays allocated with new []

Change-Id: Icc2a6b23df09049c008f7f1f50ed93a277174308
7d90cfa6b5b49abb2123b069b81e0b9f4eba6432 18-Jun-2013 Colin Cross <ccross@android.com> bionic: change properties benchmarks to read a single property

The properties benchmarks were reading n properties from a property
area with n properties in it, which was making it hard to compare
the time between runs of different sizes. Change the benchmark
to read a random property per iteration so the numbers between
runs are comparable.

Change-Id: Ib1648ce0948d9038fce76d209608427376cfb8da
16d1af167f8e36a9aa4a07ae77034ad519b00463 17-Jun-2013 Nick Kralevich <nnk@google.com> libc: add limited FORTIFY_SOURCE support for clang

In 829c089f83ddee37203b52bcb294867a9ae7bdbc, we disabled all
FORTIFY_SOURCE support when compiling under clang. At the time,
we didn't have proper test cases, and couldn't easily create targeted
clang tests.

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

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

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

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

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

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

Change-Id: If12a15089bb0ffe93824b485290d05b14355fcaa
b27e200ad6170ba3163f5ae6ba581bdaabb2e696 29-Jan-2013 Colin Cross <ccross@android.com> bionic: add tests for properties

(cherry picked from commit 37d9f75dde881a0ba1c1b3253b1be19d4096963d)

Change-Id: Iac00ce10a4272032a1cbdbc4204277d6876e3365
0f020d18b138e24b1fe34074808e07ac412f35a4 06-Jun-2013 msg555 <msg555@gmail.com> Handles spurious wake-ups in pthread_join()

Removed 'join_count' from pthread_internal_t and switched to using the flag
PTHREAD_ATTR_FLAG_JOINED to indicate if a thread is being joined. Combined with
a switch to a while loop in pthread_join, this fixes spurious wake-ups but
prevents a thread from being joined multiple times. This is fine for
two reasons:

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

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

Bug: https://code.google.com/p/android/issues/detail?id=52255
Change-Id: I8b6784d47620ffdcdbfb14524e7402e21d46c5f7
fd0325bd98764afaca1dc258960dde060b3c77de 12-Jun-2013 Nick Kralevich <nnk@google.com> fix unittests.

7e6ce1a3c52d8533fed92c143419fedb0c93988a fixed abort() to raise
SIGABRT rather than causing SIGSEGV. However, the unittests were
not updated.

Fix unittests.

Change-Id: I73db194127b9b9e9440358aa94273863765a736b
885f3b9cad01b8158aadc55c159c17dbf34f622c 22-May-2013 Christopher Ferris <cferris@google.com> Implement malloc_usable_size for debug impls.

- Implemented chk_memalign.
- Fixed a few bugs in leak_memalign.
- Implemented {leak,fill,check,qemu}_malloc_usable_size.
- Make malloc_usable_size update at run time.
- Add malloc_test.cpp as a small set of tests for the
malloc debug routines.
- Fix the qemu routines since it's been broken since it moved to C++.
- Add support for the %u format to the out_vformat in libc_logging.cpp.
This is used by the emulator code.

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

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

Bug: 6143477

Merge change from internal master.

(cherry-picked from commit 3d594c258045783fc9e1956ce7a4d91e302f011e)

Change-Id: I4ae00fffba82315a8c283f35893fd554460722fb
13476deec46d7ba101c1f76b8ddcaab9d0b96b84 03-Jun-2013 Nick Kralevich <nnk@google.com> Add tests for __strcpy_chk()

Change-Id: I5675d04fcd471732c1b87b83879a54fbcd27762e
cf870199d576bdfc339b7fb016c9f6fe7f2c87ed 31-May-2013 Nick Kralevich <nnk@google.com> FORTIFY_SOURCE: strcat / strncat optimize

__strcat_chk and __strncat_chk are slightly inefficient,
because they end up traversing over the same memory region
two times.

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

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

Change-Id: Id2c70dff55a276b47c59db27a03734d659f84b74
8cc145edf42ff8f0c10d5f2fd82ec99c6752e5ab 30-May-2013 Nick Kralevich <nnk@google.com> Add strncpy FORTIFY_SOURCE tests.

Change-Id: Id108b1d72b44d7e5fb911268e80bbdf896808f60
4f40e511b0612ea099ab5b0843977fe7a49372fd 20-Apr-2013 Nick Kralevich <nnk@google.com> libc: cleanup strchr

Move strchr to a .cpp file, and change to bionic directory.

Change-Id: I64ade7df326c0a9a714aca4caf5647b6833b1c97
277226bf43e01b25e9c573a37ee55ae052e85eb4 02-May-2013 Nick Kralevich <nnk@google.com> keep test names consistent with other tests.

Change-Id: I23dc4d963af40406b270af83cd17f6c8c95f1de3
80541922e34f2879806caf1bfbd53ebd311f2f87 01-May-2013 Nick Kralevich <nnk@google.com> add strrchr -D_FORTIFY_SOURCE=2 test.

Change-Id: I1b95bb0086ae9f2f506f3cc90cee834c0ce3b1d8
78d6d9888c24c50f65d694dc8283afdcb58db84c 30-Apr-2013 Nick Kralevich <nnk@google.com> libc: upgrade sprintf to _FORTIFY_SOURCE=2

Upgrade sprintf to fortify_source level 2, to catch
additional security bugs.

Change-Id: Ibc957d65e4cb96152de84b3745a04e00fa22659e
1aae9bd170883805f2e7975cd3dbd2502b083cc1 29-Apr-2013 Nick Kralevich <nnk@google.com> strncpy: implement _FORTIFY_SOURCE=2

Add support for fortify source level 2 to strncpy.
This will enable detection of more areas where strncpy
is used inappropriately. For example, this would have detected
bug 8727221.

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

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

Change-Id: Ica0fba531cc7d0609e4f23b8176739b13f7f7a83
0b25f633a23e575c8a1f9547d1af5dc5b0157a1c 12-Apr-2013 Elliott Hughes <enh@google.com> Switch to current FreeBSD qsort.

Change-Id: Ic46cd0b663dc5fa78c99dd38db0bfe849a25e789
6b05c8e28017518fae04a3a601d0d245916561d2 11-Apr-2013 Elliott Hughes <enh@google.com> Start moving to current FreeBSD stdio.

This only touches the easy stuff.

Change-Id: Iecee57f1681dba5c56bff59f0e9a89811a71f0ca
8baa929d5d3bcf63381cf78ba76168c80c303f5e 03-Apr-2013 Kito Cheng <kito@0xlab.org> Prevent name conflict for eventfd.cpp and eventfd.s when building libc.a

- eventfd.cpp and eventfd.s will output to the same file when building libc.a
- And then `eventfd` will undefined when statically linked to libc.

Also add a unit test.

Change-Id: Ib310ade3256712ca617a90539e8eb07459c98505
a41ba2f0bfc4fce1ce8f06a9c289102c440c929d 22-Mar-2013 Elliott Hughes <enh@google.com> Fix pthread_setname_np's behavior on invalid pthread_ts.

Change-Id: I0a154beaab4d164ac812f2564d12e4d79b80a8e8
8f2a5a0b40fc82126c691d5c30131d908772aab7 15-Mar-2013 Elliott Hughes <enh@google.com> 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
e0175ca7e440a87e9d03f249fc8f210063df7908 14-Mar-2013 Elliott Hughes <enh@google.com> Don't search off the end of the index for bad Olson ids.

In the old code, the index was a file to itself, so it made sense to
read until you hit the end of the file. In the new code, the index is
followed by hundreds of KiB of data, so we need to just search the

Bug: 8368791
Change-Id: Icf5f8b5516cf3a93679fa849c9f6cd1cb100e0f1
53630c0e5bb6f845ba633e8dedc08b827f7b5d0c 12-Mar-2013 Elliott Hughes <enh@google.com> Merge "Cache the most-recently used timezone for mktime_tz and localtime_tz."
4a05bef4c06dac05f1c9aa8cfc5b7e7dd6642385 12-Mar-2013 Elliott Hughes <enh@google.com> Cache the most-recently used timezone for mktime_tz and localtime_tz.

Normally, the C library implicitly caches your timezone by virtue
of the fact that the prehistoric API assumes a single timezone for
the entire process.

The unfortunate mktime_tz and localtime_tz extensions work around
this, but represent timezones as strings to their callers, so code
that makes heavy use of these needs a cache to be able to perform
acceptably until it can hopefully one day be rewritten to use
java.util.Calendar or icu4c.

Bug: 8270865
Change-Id: I92e3964e86dc33ceac925f819cc5e26ff4203f50
b6e22482d4fbf62c23707a9096eecd2082a63ef1 09-Mar-2013 Elliott Hughes <enh@google.com> Let bionic use the correct definition of ssize_t.

Bug: 8253769
Change-Id: I50c7cc20828fc089b83580e039ce9153a6c5a8cc
6b3f49a5374305ce9690c3c5ca2aadc90f54c521 07-Mar-2013 Elliott Hughes <enh@google.com> Upgrade to current NetBSD popen/pclose.

This gets us back to using vfork now our ARM vfork assembler stub is
fixed, and adds the missing thread safety for the 'pidlist'.

Bug: 5335385
Change-Id: Ib08bfa65b2cb9fa695717aae629ea14816bf988d
f0777843c03deb26b1f78c8edd17c557041696e9 02-Mar-2013 Elliott Hughes <enh@google.com> Move realpath.c to upstream-freebsd.

This is actually a slightly newer upstream version than the one I
originally pulled. Hopefully now it's in upstream-freebsd it will
be easier to track upstream, though I still need to sit down and
write the necessary scripts at some point.

Bug: 5110679
Change-Id: I87e563f0f95aa8e68b45578e2a8f448bbf827a33
e255642dc1178663860104d9da2590056fae8d0b 28-Feb-2013 Elliott Hughes <enh@google.com> Avoid changing the C++ ABI with ssize_t.

Bug: 8253769
Change-Id: Ia325003ed6e59da553e2bdde7c43515bc191b8ba
fae89fc4042ee4c360842234dfda7831c313bd44 21-Feb-2013 Elliott Hughes <enh@google.com> Fix raise(3) so it works in signal handlers.

We could special-case raise(3) in non-threaded programs, but the more
conservative course is to make pthread_kill(3) work in signal handlers
at the cost of a race shared by other C libraries.

Change-Id: I59fb23d03bdabf403435e731704b33acdf3e0234
c641cafbc387849510d7f408e85f72fa3608916d 17-Feb-2013 Thorsten Glaser <tg@mirbsd.org> use architecture-specific ssize_t definition

after change 32822 was rejected, this is the more light-weight
version of the fix: libc/include/sys/types.h already - via
libc/kernel/common/linux/posix_types.h - includes a definition
of __kernel_ssize_t from libc/kernel/arch-*/asm/posix_types.h
which is architecture-specific, toolchain-agnostic and also
gets rid of the gcc -Wformat warning (which it issues correctly,
since this i̲s̲ indeed a bug in bionic)

Change-Id: Ie4503ab16628bc25815a836d07556f665e9795c7
9d23e04c43dbb8480bea8be28b8a2f37423bec49 16-Feb-2013 Elliott Hughes <enh@google.com> Fix pthreads functions that should return ESRCH.

imgtec pointed out that pthread_kill(3) was broken, but most of the
other functions that ought to return ESRCH for invalid/exited threads
were equally broken.

Change-Id: I96347f6195549aee0c72dc39063e6c5d06d2e01f
40eabe24e4e3ae8ebe437f1f4e43cf39cbba2e9e 15-Feb-2013 Elliott Hughes <enh@google.com> 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
7fd803cdfa873c01138dcbd614ec92418169b1c2 15-Feb-2013 Elliott Hughes <enh@google.com> Fix the stack protector death test.

Now __stack_chk_fail calls abort(3) directly, we terminate with
SIGSEGV rather than SIGABRT. (Because of the workaround for the
debuggerd lossage in the abort(3) implementation, which was the
motivation for switching __stack_chk_fail over to abort(3).)

Also clarify the comment on the weird pthread death test, so it
doesn't get copied and pasted onto real death tests.

Change-Id: Ie832eaded61359c99e7a10db65e28f35e8f63eed
fb7eb5e07f43587c2bedf2aaa53b21fa002417bb 14-Feb-2013 Elliott Hughes <enh@google.com> Simplify __stack_chk_fail, and fix it so we get debuggerd stack traces.

Bug: 2487269
Change-Id: Iec5e470fc22cd9108404f634a9d4baa2c7b7f58f
26a13bcfb894b19ea4c53e4456b07bedd233dda4 14-Feb-2013 Elliott Hughes <enh@google.com> Stop using the local gcc.

Some build servers are still out of date, so we're better off having
the known quanitity of the consistently out-of-date prebuilt host gcc.

Change-Id: Ib6308ae926ffa1ac5d95efbbf32052344c17a6b8
73964c592c8d23901e9479893dfbd3d0f25bab04 13-Feb-2013 Elliott Hughes <enh@google.com> Everyone has CLZ.

Even armv5 had CLZ.

Change-Id: I51bc8d1166d09940fd0d3f4c7717edf26977082c
d8213bb5738ac778fcb5d696d1294b0f8ddae7f3 13-Feb-2013 Elliott Hughes <enh@google.com> Update getnameinfo.c, remove dead code, and fix error reporting.

Also add a unit test for the salen size checking.

Bug: 1889275
Change-Id: I8ec4107df9e2e9a8571e8915525249c6e44b98ad
d3b9d11369ee15dc0ce512014284c3c5432f2813 13-Feb-2013 Elliott Hughes <enh@google.com> Add a test that getaddrinfo works when hints are NULL.

Bug: 1827911
Change-Id: I9e1b774c44c10a8c5391bcf3baf1607f50eaf214
5227663d2ffd70dc32f03a7a5b103ef0d3fc0584 13-Feb-2013 Elliott Hughes <enh@google.com> Put the right number of Ls after 64-bit constants.

Change-Id: I9f96259f21e42a84b9ebe20655fe0edb31f41892
9701d4b7018ea50f57601eaec5f8f6731a7c6510 13-Feb-2013 Elliott Hughes <enh@google.com> Give up trying to build the pthread_setname_np tests for glibc.

Looks like using /usr/bin/g++ isn't enough on some of our older
build servers.

Change-Id: Id7681fb164eb6324b10050f6bb237393e95b41e9
3e898476c7230b60a0f76968e64ff25f475b48c0 12-Feb-2013 Elliott Hughes <enh@google.com> Revert "Revert "More pthreads cleanup.""

This reverts commit 6f94de3ca49e4ea147b1c59e5818fa175846518f

(Doesn't try to increase the number of TLS slots; that leads to
an inability to boot. Adds more tests.)

Change-Id: Ia7d25ba3995219ed6e686463dbba80c95cc831ca
fcaf4e9f9b735e053469c7ecbf63584e10fd67a7 12-Feb-2013 Elliott Hughes <enh@google.com> Merge "Revert "More pthreads cleanup.""
6f94de3ca49e4ea147b1c59e5818fa175846518f 12-Feb-2013 Elliott Hughes <enh@google.com> Revert "More pthreads cleanup."

This reverts commit 2a1bb4e64677b9abbc17173c79768ed494565047

Change-Id: Ia443d0748015c8e9fc3121e40e68258616767b51
85f491f96da3b79d0d7cc5368bc1f649e1a82340 12-Feb-2013 Elliott Hughes <enh@google.com> Merge "More pthreads cleanup."
5e3fc43ddeada547a155c6f561a12ff0b16e02d3 12-Feb-2013 Elliott Hughes <enh@google.com> 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
2a1bb4e64677b9abbc17173c79768ed494565047 11-Feb-2013 Elliott Hughes <enh@google.com> More pthreads cleanup.

POSIX says pthread_create returns EAGAIN, not ENOMEM.

Also pull pthread_attr_t functions into their own file.

Also pull pthread_setname_np into its own file.

Also remove unnecessary #includes from pthread_key.cpp.

Also account for those pthread keys used internally by bionic,
so they don't count against the number of keys available to user
code. (They do with glibc, but glibc's limit is the much more
generous 1024.)

Also factor out the common errno-restoring idiom to reduce gotos.

Bug: 6702535
Change-Id: I555e66efffcf2c1b5a2873569e91489156efca42
44b53ad6818de344e0b499ad8fdbb21fcb0ff2b6 11-Feb-2013 Elliott Hughes <enh@google.com> Revert "Revert "Pull the pthread_key_t functions out of pthread.c.""

This reverts commit 6260553d48f6fd87ca220270bea8bafdde5726ec

(Removing the accidental libm/Android.mk change.)

Change-Id: I6cddd9857c31facc05636e8221505b3d2344cb75
6260553d48f6fd87ca220270bea8bafdde5726ec 11-Feb-2013 Elliott Hughes <enh@google.com> Revert "Pull the pthread_key_t functions out of pthread.c."

This reverts commit ad59322ae432d11ff36dcf046016af8cfe45fbe4

somehow my unfinished libm/Android.mk change got into here.

Change-Id: I46be626c5269d60fb1ced9862f2ebaa380b4e0af
ad59322ae432d11ff36dcf046016af8cfe45fbe4 09-Feb-2013 Elliott Hughes <enh@google.com> Pull the pthread_key_t functions out of pthread.c.

This was originally motivated by noticing that we were setting the
wrong bits for the well-known tls entries. That was a harmless bug
because none of the well-known tls entries has a destructor, but
it's best not to leave land mines lying around.

Also add some missing POSIX constants, a new test, and fix
pthread_key_create's return value when we hit the limit.

Change-Id: Ife26ea2f4b40865308e8410ec803b20bcc3e0ed1
d3920b3a996b358e48232f417aa0a1e44a60f155 08-Feb-2013 Elliott Hughes <enh@google.com> Switch to using AT_RANDOM for the stack guards.

Bug: 7959813
Change-Id: I8db4b8912ba649bfe668c6f22aa44690ddd401a2
9edb3e004b487e08cbbb54f2af18b15241550513 07-Feb-2013 Elliott Hughes <enh@google.com> Improve benchmarking tool, add a few math benchmarks.

Change-Id: I641305dd0e4ac0705381e735ed1604c5be7aa536
428f5567be25b8090e3dd72e2d3d337c305b514e 06-Feb-2013 Elliott Hughes <enh@google.com> Remove bogus extra alignment from sbrk.

Bug: https://code.google.com/p/android/issues/detail?id=37349
Change-Id: I970c7b6be7bb7fbe6bbbe2c332f05816aeb0e09f
b16b72248bd109b6073df6a45aeffaa69e38cfc6 04-Feb-2013 Elliott Hughes <enh@google.com> Add basic tests for posix_memalign.

Change-Id: Ie34fcc87aa9e8bfc715e25161752024b11e2032a
a0ee07829a9ba7e99ef68e8c12551301cc797f0f 31-Jan-2013 Elliott Hughes <enh@google.com> 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
41b3179c9ef03ebb447cac7f5e8405dce399cb17 28-Jan-2013 Elliott Hughes <enh@google.com> Unit tests for formatting code, fix %%.

Also fix <signal.h> and <stdio.h> so they don't cause compiler warnings.

Change-Id: Ib1a746bf01de22d47dbd964de0e6af80a7c96303
a44e9afdd16105d6f36319cb538666d9cc78435a 18-Jan-2013 Nick Kralevich <nnk@google.com> FORTIFY_SOURCE: optimize

Don't do the fortify_source checks if we can determine, at
compile time, that the provided operation is safe.

This avoids silliness like calling fortify source on things like:

size_t len = strlen("asdf");
printf("%d\n", len);

and allows the compiler to optimize this code to:

printf("%d\n", 4);

Defer to gcc's builtin functions instead of pointing our code
to the libc implementation.

Change-Id: I5e1dcb61946461c4afaaaa983e39f07c7a0df0ae
36bd371e26c716cbc18e11801b13eff0352d91b0 16-Jan-2013 Nick Kralevich <nnk@google.com> Revert "stack protector: use AT_RANDOM"

The AT_RANDOM changes broke setuid / setgid executables
such as "ping". When the linker executes a setuid program,
it cleans the environment, removing any invalid environment
entries, and adding "NULL"s to the end of the environment
array for each removed variable. Later on, we try to determine
the location of the aux environment variable, and get tripped
up by these extra NULLs.

Reverting this patch will get setuid executables working again,
but getauxval() is still broken for setuid programs because of
this bug.

This reverts commit e3a49a8661125f24aec8a1453e54b3b78005e21e.

Change-Id: I05c58a896b1fe32cfb5d95d43b096045cda0aa4a
e3a49a8661125f24aec8a1453e54b3b78005e21e 14-Jan-2013 Nick Kralevich <nnk@google.com> stack protector: use AT_RANDOM

Populate the stack canaries from the kernel supplied
AT_RANDOM value, which doesn't involve any system calls.
This is slightly faster (6 fewer syscalls) and avoids
unnecessarily reading /dev/urandom, which depletes entropy.

Bug: 7959813

Change-Id: If2b43100a2a9929666df3de56b6139fed969e0f1
606058933c5129cb1026960ea67624b9426c610f 15-Jan-2013 Nick Kralevich <nnk@google.com> fix strerror_r test

e6e60065ff093ff8c859ab146cf543531cb1967c modified strerror_r to
treat errno as signed. However, the change to the test code
modified the "strerror" test, not the "strerror_r" test.

Make the same change for the strerror_r code.

Change-Id: Ia236a53df5745935e229a4446a74da8bed0cfd7b
2c5153b043b44e9935a334ae9b2d5a4bc5258b40 11-Jan-2013 Nick Kralevich <nnk@google.com> libc: add getauxval()

Add support for getauxval(). This method allows a program an easy way
to retrieve information from the kernel auxiliary vector, and will
hopefully replace other clumsy ways of accessing this same information.

This particular function was also added to glibc in glibc 2.16.
See the following URLs for more details.

* http://lwn.net/Articles/519085/
* http://www.gnu.org/software/libc/manual/html_node/Auxiliary-Vector.html

This change is a prerequisite for bug 7959813.

Bug: http://code.google.com/p/android/issues/detail?id=38441
Change-Id: Iba19d899df334bddc6f4899077ece2fc87564ea8
dcab1b2c76a498c56bc00024613386de8b4b2aae 11-Jan-2013 Nick Kralevich <nnk@google.com> Add stack canaries / strcpy tests.

Add a test to ensure that stack canaries are working
correctly. Since stack canaries aren't normally generated
on non-string functions, we have to enable stack-protector-all.

Add a test to ensure that an out of bounds strcpy generates
a runtime failure.

Change-Id: Id0d3e59fc4b9602da019e4d35c5c653e1a57fae4
e6e60065ff093ff8c859ab146cf543531cb1967c 11-Jan-2013 Elliott Hughes <enh@google.com> glibc 2.15 treats errno as signed in strerror(3).

And the only reason I hadn't done that in bionic is because I wanted to behave
the same as glibc.

Change-Id: I2cf1bf0aac82a748cd6305a2cabbac0790058570
c5d028fc913de84a781bd61084bf7ae2182fd48e 10-Jan-2013 Elliott Hughes <enh@google.com> Only have one copy of the kernel_sigset_t hack, and add more tests.

Change-Id: I377522fcba6fb4b5fd2754ab15b091014bd7c16f
a43e906221a3e9c70a66118a8692cd46f77e144e 07-Jan-2013 Elliott Hughes <enh@google.com> Don't test GNU-style ELF hashes on MIPS.

The MIPS toolchain can't generate them because they're incompatible
with the MIPS ABI (which requires .dynsym match the GOT, while GNU-style
requires .dynsym to be sorted by hash code), so there's nothing to test.

Change-Id: I2220f452fe6fe595ec1312544cc741dd390a36a5
fb5e5cbdd4e1d75594c37ebb544c0f46482a027b 07-Jan-2013 Elliott Hughes <enh@google.com> Fix an off-by-one error in the sigset_t function error handling.

Spotted while running the tests on MIPS, where sigset_t is
actually large enough. The bits in sigset_t are used such that
signal 1 is represented by bit 0, so the range of signals is
actually [1, 8*sizeof(sigset_t)]; it seems clearer to reword
the code in terms of valid bit offsets [0, 8*sizeof(sigset_t)),
which leads to the usual bounds checking idiom.

Change-Id: Id899c288e15ff71c85dd2fd33c47f8e97aa1956f
a55f63083fb16b2595f517a3260083e5f8cddd02 02-Jan-2013 Elliott Hughes <enh@google.com> Define _POSIX_MONOTONIC_CLOCK and implement sysconf(_SC_MONOTONIC_CLOCK).

Bug: http://code.google.com/p/android/issues/detail?id=39680
Change-Id: I11cf10a66f9d305868a725f04f581099fb88bbfc
e66190d2a97a713ae4b4786e60ca3d67ab8aa192 19-Dec-2012 Elliott Hughes <enh@google.com> Check for unknown flags passed to dlopen(3).

Change-Id: I56f4aab0e5a1487bc32d2c4d231e8bd15c4ac8da
d8a5a6f513c6fa99229e9c82c5c308c7cd6b3d54 08-Dec-2012 Chris Dearman <chris@mips.com> Use pthread_kill() in raise()

raise() should use pthread_kill() in a pthreads environment.
For bionic this means it should always be used.

Change-Id: Ic679272b664d2b8a7068b628fb83a9f7395c441f
da73f655fcbac6e1a8bfd35303cef6f41187d12b 01-Dec-2012 Elliott Hughes <enh@google.com> Add argument checking to sigemptyset(3) and friends.

You could argue that this is hurting people smart enough to have manually
allocated a large-enough sigset_t, but those people are smart enough to
implement their own sigset functions too.

I wonder whether our least unpleasant way out of our self-inflicted 32-bit
cesspool is to have equivalents of _FILE_OFFSET_BITS such as _SIGSET_T_BITS,
so calling code could opt in? You'd have to be careful passing sigset_t
arguments between code compiled with different options.

Bug: 5828899
Change-Id: I0ae60ee8544835b069a2b20568f38ec142e0737b
fbe44ec0436a8ce735f4dbe06c5109e3c0d4a8ae 09-Nov-2012 Elliott Hughes <enh@google.com> Add a memmove(3) benchmark.

Change-Id: I9c0ffae0b5aae29521b7e68e5ce2318b5a401cba
7be369d4c60e9df2316fdb6c73181a40020abef2 09-Nov-2012 Elliott Hughes <enh@google.com> Simple google3-compatible benchmarking.

Based on our open-source RE2 benchmarking code.

Includes benchmarks for a handful of <string.h> functions.

Change-Id: I30eb70d25dbf4ad5f2ca44976a8ce3b1ff7dad01
d460f3f1af80af40d8c3fab12a68459d8d1ec4c5 08-Nov-2012 Elliott Hughes <enh@google.com> Merge "Tests for string routines."
6e33b0296d23c75bdefa53f0bf0b08c0d877a652 08-Nov-2012 Elliott Hughes <enh@google.com> Fix dlopen_library_with_only_gnu_hash_Test.

Change-Id: Id3395f155587cfa74061f97a2cb4c6a6e59c13dc
036154b0c2d64d618aded8674f2e13cbbb2867e2 05-Oct-2012 Anna Tikhonova <anna.tikhonova@intel.com> Tests for string routines.

Change-Id: I24068a228f59df1c3b758c5b2026a09720490616
Signed-off-by: Anna Tikhonova <anna.tikhonova@intel.com>
90e10d41c4271a5d517f60f4ff1d2891b8ccc034 03-Nov-2012 Elliott Hughes <enh@google.com> Rewrite <fenv.h> for ARM.

The old code was one big no-op.

Bug: http://code.google.com/p/android/issues/detail?id=38196
Change-Id: I201a6ffa477385b2629f45e8c948bdfbd47b5bf1
4f251bee5d51228217c1bf4dfc9219f3058bd3ed 02-Nov-2012 Elliott Hughes <enh@google.com> Don't corrupt the thread list if the main thread exits.

...and don't pass a non-heap pointer to free(3), either.

This patch replaces the "node** prev" with the clearer "node* prev"
style and fixes the null pointer dereference in the old code. That's
not sufficient to fix the reporter's bug, though. The pthread_internal_t*
for the main thread isn't heap-allocated --- __libc_init_tls causes a
pointer to a statically-allocated pthread_internal_t to be added to
the thread list.

Bug: http://code.google.com/p/android/issues/detail?id=37410
Change-Id: I112b7f22782fc789d58f9c783f7b323bda8fb8b7
1a6961650c82168864afe040dbdc05977db701df 01-Nov-2012 Elliott Hughes <enh@google.com> Stop defining our own PAGE_SIZE and PAGE_MASK, and test dlclose(3) too.

Also remove an unnecessary #include and a now-obsolete TODO.

Change-Id: I36d923721e349a286934b9534090a67ce0786e7b
124fae9eabd7a25d80dfa8c3b56bed0f0fba16f1 31-Oct-2012 Elliott Hughes <enh@google.com> Reject .so files with no sysv hash table.

Also ensure that dlopen(3) errors always include the name of the library we
failed to open.

Also fix a bug where we'd fall back to searching LD_LIBRARY_PATH and the
built-in paths for names that include slashes.

Bug: http://code.google.com/p/android/issues/detail?id=38479
Change-Id: Ib2c009ed083344a7a012749d58f8679db2f26c78
06b596104a9ed3ac089abd00186a5698d7e8544f 30-Oct-2012 Elliott Hughes <enh@google.com> Merge "Fix bug in pthread_join, pthread_exit, pthread_detach"
58b575485c446f9d76ee00f67516ed42cf017769 29-Oct-2012 Elliott Hughes <enh@google.com> Clean up the <libgen.h> implementation a little, bring in tests.

Most of these tests were in system/extras, but I've added more to cover other
cases explicitly mentioned by POSIX.

Change-Id: I5e8d77e4179028d77306935cceadbb505515dcde
10ce96944eaea4c459392952652fdb24742c9c29 26-Oct-2012 Sergey Melnikov <sergey.melnikov@intel.com> Fix bug in pthread_join, pthread_exit, pthread_detach

pthread_no_op_detach_after_join test from bionic-unit-tests hangs
on x86 emulator. There is a race in the pthread_join, pthread_exit,
pthread_detach functions:
- pthread_join waits for the non-detached thread
- pthread_detach sets the detached flag on that thread
- the thread executes pthread_exit which just kills the now-detached
thread, without sending the join notification.

This patch improves the test so it fails on ARM too, and modifies
pthread_detach to behave more like glibc, not setting the detach state if
called on a thread that's already being joined (but not returning an error).

Change-Id: I87dc688221ce979ef5178753dd63d01ac0b108e6
Signed-off-by: Sergey Melnikov <sergey.melnikov@intel.com>
14f19592ae7c819855052bcebc79de87069c2954 29-Oct-2012 Elliott Hughes <enh@google.com> Fix the pthread_join on self error case.

We should return EDEADLK, not deadlock the calling thread.

Change-Id: I1243483f709c11b2a60e41142725c54c7dbfcbc9
c30396f5f225e0b5a83a35432e2d82a7063cfdb9 29-Oct-2012 David 'Digit' Turner <digit@android.com> libc: Fix alphasort() signature (and implementation).

The declaration for alphasort() in <dirent.h> used the deprecated:

int alphasort(const void*, const void*);

while both Posix and GLibc use instead:

int alphasort(const struct dirent** a, const struct dirent** b);

See: http://pubs.opengroup.org/onlinepubs/9699919799/functions/alphasort.html

This patch does the following:

- Update the declaration to match Posix/GLibc
- Get rid of the upstream BSD code which isn't compatible with the new
- Implement a new trivial alphasort() with the right signature, and
ensure that it uses strcoll() instead of strcmp().
- Remove Bionic-specific #ifdef .. #else .. #endif block in
dirent_test.cpp which uses alphasort().

Even through strcoll() currently uses strcmp(), this does the right
thing in the case where we decide to update strcoll() to properly
implement locale-specific ordered comparison.

Change-Id: I4fd45604d8a940aaf2eb0ecd7d73e2f11c9bca96
063cfb2084ea4b12d3c85b2d2c44e888f0857eb4 26-Oct-2012 Elliott Hughes <enh@google.com> Clean up the implementation of the <dirent.h> functions.

Change-Id: I3c647cc9588525afc41fee90ee468d58cd13503a
ad88a0863110798cef5169dcf917e18b967a7cf6 25-Oct-2012 Elliott Hughes <enh@google.com> Per-thread -fstack-protector guards for x86.

Based on a pair of patches from Intel:


For x86, this patch supports _both_ the global that ARM/MIPS use
and the per-thread TLS entry (%gs:20) that GCC uses by default. This
lets us support binaries built with any x86 toolchain (right now,
the NDK is emitting x86 code that uses the global).

I've also extended the original tests to cover ARM/MIPS too, and
be a little more thorough for x86.

Change-Id: I02f279a80c6b626aecad449771dec91df235ad01
5419b9474753d25dff947c7740532f86d130c0be 17-Oct-2012 Elliott Hughes <enh@google.com> Make dlerror(3) thread-safe.

I gave up trying to use the usual thread-local buffer idiom; calls to
calloc(3) and free(3) from any of the "dl" functions -- which live in
the dynamic linker -- end up resolving to the dynamic linker's stubs.
I tried to work around that, but was just making things more complicated.
This alternative costs us a well-known TLS slot (instead of the
dynamically-allocated TLS slot we'd have used otherwise, so no difference
there), plus an extra buffer inside every pthread_internal_t.

Bug: 5404023
Change-Id: Ie9614edd05b6d1eeaf7bf9172792d616c6361767
3b297c40794b23d50cb5240f9b03f6ef25fd98db 12-Oct-2012 Elliott Hughes <enh@google.com> Fix dlerror(3).

Add unit tests for dlerror(3) in various situations. I think We're at least
as good as glibc now.

Also factor out the ScopedPthreadMutexLock and use it here too.

Bug: http://code.google.com/p/android/issues/detail?id=38398
Change-Id: I040938b4366ab836e3df46d1d8055b92f4ea6ed8
156da966214957c5616a0b83cc84686eedfc4e31 10-Oct-2012 Elliott Hughes <enh@google.com> Fix a getcwd(3) bug and make our tests run correctly under valgrind.

The getcwd(3) bug was found by valgrind.

Bug: 7291287
Change-Id: I59f3bff1c1392a408b905934eebcd5d894d37492
774c7f54ff375d71106283d42779b0cc5f238f87 01-Oct-2012 Elliott Hughes <enh@google.com> Upgrade to the current NetBSD rand implementation.

Also add basic unit tests.

Change-Id: I7fc7ef61d47c1e8fdf8b8eff67a635220c3afd56
eac9eb462ed6f7fcfb791e7a08b4011fcca47829 08-Sep-2012 Irina Tirdea <irina.tirdea@intel.com> Add getdelim(3) and getline(3) to bionic

Some userspace programs (e.g. perf) need getline.

() add getdelim.c, getline.c from NetBSD (http://netbsd.org/) under the
NetBSD Foundation's (TNF) license ("2 clause" Berkeley-style license).
() add stub for reentrant.h header that is needed by getdelim.c
() add tests for getdelim(3) and getline(3).
() update NOTICE file.

Change-Id: I22ed82dd5904b9d7a3695535c04f502be3c27c5d
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
ac184b21425a0681c51ef152f0567168b575da49 26-Sep-2012 Elliott Hughes <enh@google.com> Fix several compiler warnings.

Change-Id: I55caa50a5937442734f4fcbdb4edf1c70f335bf8
8e630dacf61307e4681f04fc6b5ee593f30d91d0 26-Sep-2012 Elliott Hughes <enh@google.com> Merge "Simple tests for dladdr(3)."
91875dcd6e17b7f3b251efe9b236b905ef414dde 25-Sep-2012 Elliott Hughes <enh@google.com> Fix tmpfile(3).

This could be better, but at least now it works.

Change-Id: I88b7cf3f7ce8e5fa0b3fe678b7d1679a68ffffc9
8e15b08ae22a5230c1fea4779410de0420fa939c 26-Sep-2012 Elliott Hughes <enh@google.com> Simple tests for dladdr(3).

Change-Id: I22160b7fc9b950ea19adb6da42af2f893f4fe5d5
8a05a01de75d78a45d646115b20b2a3e3c12ba9e 13-Sep-2012 Kenny Root <kroot@google.com> Print out shared app gids correctly

For applications that share resources across users such as
forward-locked applications, print out their group name correctly.

Change-Id: I06ee0b67e4325cfa415ffd7a03e301700399a66d
2a54e5ecd0a96398e8d7d9b1629ecf8fb1633a2b 13-Sep-2012 Kenny Root <kroot@google.com> Add tests for Android-specific stubs

Also fix problem with multi-user IDs that the home directory was
returned as "/data" instead of "/" unlike all the other uids.

Change-Id: I914d22052e5a86552989f8969b85aadbc748c65d
fa36875df423af968d053c584c0de18a2448516b 14-Sep-2012 Elliott Hughes <enh@google.com> Merge "Make strerror(3) and strsignal(3) thread-safe, and add psignal(3) and psiginfo(3)."
b5f053b5a7deb084e7a052d527e0aa41339ae05c 08-Sep-2012 Irina Tirdea <irina.tirdea@intel.com> Make strerror(3) and strsignal(3) thread-safe, and add psignal(3) and psiginfo(3).

Change-Id: I426109db25e907980d6cb3a7a695796e45783b78
38bfa21695b19c21784d2074de30d5d102f08972 13-Sep-2012 Elliott Hughes <enh@google.com> Fix Mac build.

Change-Id: Id625806fab0f2f7f90f9508c5fce649afe970414
acf5aa76a56f101607aeb8e6d1fbea24d0d4f68c 13-Sep-2012 jeffhao <jeffhao@google.com> Added new test for dlopen which is failing for MIPS.

Change-Id: I2240faefb387a11647f49b1a15699907a40f98c1
4d014e15b44d3e8d1b0189bc9bb7b0d0685e5af8 08-Sep-2012 Elliott Hughes <enh@google.com> Add more pthreads tests.

Someone reported a bug if pthread_detach is called while a pthread_join is
already in progress, but I'm unable to reproduce it. Keep the tests I wrote,

Change-Id: I3d71450bbbb5345f2cb213dc56310ec020d528cc
bfeab1bbe7e8d0c08b7e3f46aedab64e3b2bf706 06-Sep-2012 Elliott Hughes <enh@google.com> Don't corrupt the thread list in static executables.

Several previous changes conspired to make a mess of the thread list
in static binaries. This was most obvious when trying to call
pthread_key_delete(3) on the main thread.

Bug: http://code.google.com/p/android/issues/detail?id=36893
Change-Id: I2a2f553114d8fb40533c481252b410c10656da2e
2e8f4345dfe16e64d7a3c26f688f17f2b48b2dd1 05-Sep-2012 Elliott Hughes <enh@google.com> Add missing dependencies.

Change-Id: I53c1cfb59ac7a89952a8d6b906b2b9e16a66624f
5ac9eee1d3291a0d203a125849b4636a11c0d124 01-Sep-2012 Benoit Goby <benoit@android.com> bionic: Fix TINY_ANDROID build

(cherry-pick of 545d5dbbcb0dc9e44323c4f2e687a3aace75a483.)

Change-Id: Ifc91e84ffed5a3a287accabd7f08b02752688db6
7b841f3b4ad121dd64f639c1858b42defffd60bd 16-Aug-2012 Joe Onorato <joeo@google.com> Don't over-generalize makefiles. Host modules always build. This isn't needed on eng builds.

Change-Id: I5821ced7a8a9042fd2094204e07470d8002263ca
04a83a48ed89f433c78e31106ed50059764797a0 17-Aug-2012 Elliott Hughes <enh@google.com> Enhance getcwd(3) to handle NULL like glibc.

Bug: http://code.google.com/p/android/issues/detail?id=36085
Change-Id: I960a1b585887eb66176c61d29c5c61c239a4003f
cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8 15-Aug-2012 Elliott Hughes <enh@google.com> Switch to the current NetBSD regex implementation.

Change-Id: If32b28dd85d6a7ab8957ab81d19fa4c0de9499d5