Commit graph

887 commits

Author SHA1 Message Date
Elliott Hughes
31165edf57 CLOEXEC support in fdopen, freopen, and mkostemp/mkostemps.
Change-Id: I74ea88e0d4973d6ab3c57da7d8bb643c31592b14
2014-09-23 18:21:52 -07:00
Elliott Hughes
b05ec5ae93 Pull in upstream fixes to reject invalid bases.
Also add tests to make sure the full set works correctly.

Change-Id: I3e7f237f12c9c93e1185a97c9717803e7e55a73c
2014-09-23 14:53:10 -07:00
Elliott Hughes
34c987a6dd Test pthread_cleanup_push(3)/pthread_cleanup_pop(3).
Change-Id: I5a623fa1e1da55f11d51f3a9bdfa0627698c486f
2014-09-22 16:27:19 -07:00
Elliott Hughes
d9cb0ed281 Merge "Unit test for abort(3)." 2014-09-22 21:46:56 +00:00
Elliott Hughes
60452a211c Unit test for abort(3).
Change-Id: I021604b977572801f228a193741624df26e76d72
2014-09-22 14:41:30 -07:00
Elliott Hughes
04303f5a8a Add semaphore tests, fix sem_destroy.
Bug: https://code.google.com/p/android/issues/detail?id=76088
Change-Id: I4a0561b23e90312384d40a1c804ca64ee98f4066
2014-09-19 17:37:06 -07:00
Elliott Hughes
755318548d Fix lgamma_r/lgammaf_r/lgammal_r for -0.
Upstream has implemented lgammal/lgammal_r for ld128, and fixed the
sign problem we reported with all the lgamma*_r functions and -0.

Bug: 17471883
Change-Id: Ibb175d9cab67efae75f1010796fd44c9ba6ce4fc
2014-09-18 11:23:58 -07:00
Elliott Hughes
82e71085c2 Merge "The nextafter functions use the wrong next representable value" 2014-09-18 15:51:46 +00:00
Jingwei Zhang
90be6c5fc5 The nextafter functions use the wrong next representable value
From C99 standard: “The nextafter functions determine the next representable value, in the type of the function,
after x in the direction of y, where x and y are first converted to the type of the function”.
The next representable value of 0.0 in direction of -1.0 is -4.9406564584124654e-324, not 0.0.

Similar thing holds for nextafterf, nextafterl, nexttowardf, nexttoward, and nexttowardl.
The tests pass either way, since the error is within the tolerance, but how it is written is wrong.

Change-Id: I1338eeffe3de8031a48f46e1b07146bc07dc2f0a
Signed-off-by: Jingwei Zhang <jingwei.zhang@intel.com>
Signed-off-by: Mingwei Shi <mingwei.shi@intel.com>
2014-09-19 00:50:00 +08:00
Elliott Hughes
bee1993a14 Stack unwinding unit tests.
Bug: 17436734
Change-Id: I1e98da7eaeab646b448fb3f2b683973dddc319b0
2014-09-17 19:52:14 -07:00
Dmitriy Ivanov
bf50e2645d Add Android*.mk files to additional dependencies
Bug: 17548097
Change-Id: Ie0d9c8f33459320008f561217c54eba42d283b47
2014-09-17 15:55:01 -07:00
Dmitriy Ivanov
e8ba50fe0d Fix dlsym() to take into account RTLD_GLOBAL/LOCAL
Symbols from libraries opened with RTLD_LOCAL (default)
  should not be visible via dlsym(RLTD_DEFAULT/RTLD_NEXT, .)

Bug: 17512583
Change-Id: I1758943081a67cf3d49ba5808e061b8251a91964
2014-09-15 17:39:48 -07:00
Dmitriy Ivanov
eb27bbae8f Add dlfcn_test to glibc test suite.
Change-Id: I955e4f7dfcc23ea5c767f967b3532dc31663b876
2014-09-15 15:03:15 -07:00
Elliott Hughes
8fb639ca91 Add a test for pthread_gettid_np.
Bug: 17475191
Change-Id: I8c6a2f4ceba2d24a77ae9a21269edce523aea421
2014-09-12 14:43:07 -07:00
Dmitriy Ivanov
d74aa58035 Merge "Fix unload of recursively linked library" 2014-09-12 16:55:42 +00:00
Dmitriy Ivanov
66bbf1595c Merge "Refactoring: C++11 style DISABLE_ bionic marcos" 2014-09-12 16:50:05 +00:00
Dmitriy Ivanov
a6ac54a215 Fix unload of recursively linked library
Expanded test for recursive libs. Fixed bug with unnecessary
  soinfo_free of already loaded library.

Change-Id: I2cc19f2650c8b12a35feeac127ef608ebba44d88
2014-09-11 22:40:48 -07:00
Dmitriy Ivanov
6487f0d834 Merge "Add IFUNC support for arm64 and IRELATIVE reloc" 2014-09-12 00:40:12 +00:00
Dmitriy Ivanov
9aea164457 Add IFUNC support for arm64 and IRELATIVE reloc
There are number of changes in the way IFUNC related relocations are done:
 1. IRELATIVE relocations are now supported for x86/x86_64 and arm64.
 2. IFUNC relocations are now relying on static linker to generate
    them in correct order - this removes necessety of additional
    relocation pass for ifuncs.
 3. Related to 2: rela?.dyn relocations are preformed before .plt ones.
 4. Ifunc are resolved on symbol lookup this approach allowed to avoid
    mprotect(PROT_WRITE) call on r-x program segments.

Bug: 17399706
Bug: 17177284
Change-Id: I414dd3e82bd47cc03442c5dfc7c279949aec51ed
2014-09-11 16:30:45 -07:00
Elliott Hughes
b587f339db Add posix_fadvise(3).
(cherry-pick of 00008263782e484020420c606f7d145fe7d0a4d8.)

Bug: 12449798
Change-Id: I07cbf3f670a0d1304b68148325a774f266b5c433
2014-09-11 08:45:46 -07:00
Elliott Hughes
0000826378 Add posix_fadvise(3).
Bug: 12449798
Change-Id: I07cbf3f670a0d1304b68148325a774f266b5c433
2014-09-10 20:30:23 -07:00
Dmitriy Ivanov
d9ff722661 Refactoring: C++11 style DISABLE_ bionic marcos
Enable the -std=gnu++11 flag for libstdc++ static and
  dynamic libs.

  ScopeGuard uses DISABLE_ macros instead of '= delete';

Change-Id: I07e21b306f95fffd49345f7fa136cfdac61e0225
2014-09-08 17:51:31 -07:00
Dmitriy Ivanov
3c3624f3df Merge "Load libraries in breadth-first order" 2014-09-09 00:49:38 +00:00
Elliott Hughes
cf5fc80c3e Don't expose non-standard basename_r and dirname_r in LP64.
(cherry-pick of f0e9458ea596227720fa745df15f5357f6c0c8f6.)

Bug: 17407423
Change-Id: I47fe499a4c396bf09d7b78fd828728d04777398b
2014-09-08 16:44:48 -07:00
Dmitriy Ivanov
14669a939d Load libraries in breadth-first order
This patch fixes the problem with symbol search order
  for dlsym(RTLD_DEFAULT/RTLD_NEXT, .) by loading libraries
  and ld_preloads in correct order.

Bug: https://code.google.com/p/android/issues/detail?id=74255
Change-Id: If1ba5c807322409faa914e27ecb675e2c4541f0d
Attempt: 2
2014-09-08 13:02:50 -07:00
Dmitriy Ivanov
498eb18b82 Revert "Load libraries in breadth-first order"
This reverts commit a3ad450a2e.

Change-Id: Ia2b838ad2159c643b80c514849582f4b4f4f40e5
2014-09-05 16:27:54 -07:00
Elliott Hughes
f0e9458ea5 Don't expose non-standard basename_r and dirname_r in LP64.
Bug: 17407423
Change-Id: I47fe499a4c396bf09d7b78fd828728d04777398b
2014-09-05 16:12:42 -07:00
Dmitriy Ivanov
b2a30ee8d2 Fix order of soinfo links (repairs libcxx tests).
Change-Id: Iee9de09657351cd6a7512784ca797e4b84cdd98b
2014-09-05 16:01:47 -07:00
Elliott Hughes
5beddb7d64 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 27a9aed819 plus the
new ScopeGuard.h from a3ad450a2e3fb6b3fe359683b247eba20896f646.)

Bug: 17394276
Change-Id: I5b92dc64ca089400223b2d9a3743e9b9d57c1bc2
2014-09-04 20:34:03 -07:00
Dmitriy Ivanov
001815ed19 Merge "Reset enviroment for math_tests" 2014-09-05 01:56:44 +00:00
Dmitriy Ivanov
7b956ede3f Reset enviroment for math_tests
Bug: 17390824
Change-Id: I42f4c8d9199a2efe7641f0b0e64580cacb5695da
2014-09-04 18:38:21 -07:00
Elliott Hughes
27a9aed819 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).

Change-Id: I5b92dc64ca089400223b2d9a3743e9b9d57c1bc2
2014-09-04 16:09:25 -07:00
Elliott Hughes
aa13e839f0 Fix mips signed/unsigned signal_test.cpp build breakage.
Change-Id: I045ce017c0c51e1843193759a2eb6fc5b93e3867
2014-09-04 15:43:10 -07:00
Elliott Hughes
afe58ad989 Don't mask out SA_RESTORER from sa_flags.
glibc doesn't do this, and we probably shouldn't either.

Bug: 16703540
Change-Id: Id5b93c3782e34024a9916463348e8f3caff191bf
2014-09-04 13:54:42 -07:00
Dmitriy Ivanov
1737b15937 Merge "Load libraries in breadth-first order" 2014-09-04 00:59:23 +00:00
Dmitriy Ivanov
8da304b997 Merge "Make string tests check all alignment combinations" 2014-09-03 22:08:57 +00:00
Dmitriy Ivanov
a3ad450a2e Load libraries in breadth-first order
This patch fixes the problem with symbol search order
  for dlsym(RTLD_DEFAULT/RTLD_NEXT, .) by loading libraries
  and ld_preloads in correct order.

Bug: https://code.google.com/p/android/issues/detail?id=74255
Change-Id: I4cf84c70dbaabe99310230dfda12385ae5401859
2014-09-03 15:06:14 -07:00
Dan Albert
69fb9f3f40 Don't fail a test just because we aren't root.
If the tests are not being run as root, emit a message and don't
continue with the test.

Change-Id: I352e1a4162caaeb18b81b8daf44797009756dcd9
2014-09-03 11:30:21 -07:00
Dmitriy Ivanov
3b10ba6f1b Merge "Add some missing dlclose(.)" 2014-09-03 00:36:22 +00:00
Dmitriy Ivanov
319356e39c Add some missing dlclose(.)
Bug: 17358010
Change-Id: I9e427b7681f1a8fe890b0b47812d9e65ab95c792
2014-09-02 17:31:44 -07:00
Dan Albert
6676a7d4ee Start math tests with a clean fenv.
We always want the default floating point environment when running these
tests.

Bug: 17358010
Change-Id: I6ca2552e9f2d3e07d7b9dcaf0aec66905401c466
2014-09-02 16:00:10 -07:00
Dan Albert
1d53ae2a01 Prevent a few test pthread keys from leaking.
Bug: 17358010
Change-Id: Ie718dc215ddfd431650295a1630c1b1716760c3d
2014-09-02 15:24:26 -07:00
Hans Boehm
9ac60bf82b 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 00aaea3645 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:

    Bug:16880454
    Bug:16513433

Change-Id: I9b61e42307f96a114dce7552b6ead4ad1c544eab
(cherry picked from commit 32429606bf)
2014-09-02 11:37:02 -07:00
Hans Boehm
c8cf3513ec 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

Bug:16513433

Change-Id: If6a14c1075b379395ba5d93357d56025c0ffab68
(cherry picked from commit 00aaea3645)
2014-09-02 10:32:33 -07:00
Hans Boehm
32429606bf 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 00aaea3645 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:

    Bug:16880454
    Bug:16513433

Change-Id: I9b61e42307f96a114dce7552b6ead4ad1c544eab
2014-08-29 17:03:26 -07:00
Elliott Hughes
f6824b26ae The host prebuilt glibc is 2.11, so remove workarounds for 2.9.
Change-Id: I1072fcebc8b3018580a9d069fe6eca9c4e74e865
2014-08-28 19:28:35 -07:00
Elliott Hughes
416d7ddaff Add GNU-compatible strerror_r.
We already had the POSIX strerror_r, but some third-party code defines
_GNU_SOURCE and expects to get the GNU strerror_r instead.

This exposed a bug in the libc internal logging functions where unlike
their standard brethren they wouldn't return the number of bytes they'd
have liked to have written.

Bug: 16243479
Change-Id: I1745752ccbdc569646d34f5071f6df2be066d5f4
2014-08-28 16:37:09 -07:00
Elliott Hughes
67f1f3b171 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 9e4ffa7032)

Change-Id: I73f219a569917b2e4546c09436d7ef5231facc07
2014-08-27 16:50:53 -07:00
Elliott Hughes
a0eeb0b69f Merge "Fix pthread_getattr_np for the main thread." into lmp-dev 2014-08-27 23:49:56 +00:00
Elliott Hughes
9e4ffa7032 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
Change-Id: If9e2dfad9a603c0d0615a8123aacda4946e95b2c
2014-08-27 15:32:01 -07:00
Chih-Hung Hsieh
34da32e7dd Merge "Add missing type casts before comparison." 2014-08-27 21:44:12 +00:00
Chih-Hung Hsieh
a2c6ae6f84 Add missing type casts before comparison.
BUG: 17300548
Change-Id: Ice9868f36c8fa8cd40bb13741b0e33c8f8d354fd
2014-08-27 13:45:37 -07:00
Wally Yau
a40fdbd565 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
errors.

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

(cherry-pick of 8a46cf0fcf82b8c76e05be7e066ec854f974603a.)

Bug: 17299565
Change-Id: I87efa2a9b16999a11d587f68d3aeedcbe6ac8a2c
2014-08-27 10:26:49 -07:00
Wally Yau
8a46cf0fcf 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
errors.

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

Bug: 17299565
Change-Id: I87efa2a9b16999a11d587f68d3aeedcbe6ac8a2c
2014-08-27 17:22:29 +00:00
Dmitriy Ivanov
14241402de Enable __cxa_atexit && __cxa_finalize for linker
This allows adding destructors to classes used
 for global variables.

Change-Id: I5e1cd63fe3bf8f66de88cc4f7437cafb350f49b5
2014-08-26 15:44:18 -07:00
Elliott Hughes
6421823410 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 57b7a6110e)

Change-Id: I87e679ee1c0db8092f2d1221c8e7c1461545c5a4
2014-08-26 12:55:01 -07:00
Elliott Hughes
57b7a6110e 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>
Change-Id: I1d4dbffe7bc7bda1d353c3a295dbf68d29f63158
2014-08-26 10:36:38 -07:00
Hans Boehm
a4a8c4feb8 Merge "Fix, generalize stdatomic.h; improve test." 2014-08-22 22:52:31 +00:00
Hans Boehm
00aaea3645 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.

Change-Id: If6a14c1075b379395ba5d93357d56025c0ffab68
2014-08-22 15:50:17 -07:00
Dan Albert
4756afe3d5 Merge "Implement malloc_info(3)." 2014-08-22 17:39:18 +00:00
Dan Albert
4caa1f0977 Implement malloc_info(3).
Expose jemalloc stats through the malloc_info(3) interface.

Bug: 16874689
Change-Id: I4358ac283002e60ff161107028d1a3fb1e9afb0a
2014-08-22 10:23:12 -07:00
Elliott Hughes
2b3b2ecee8 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.

(cherry-pick of 84d0683a824fa02dbaa6d1b56a79223804b54e80.)

Bug: 16705621
Bug: 17170200
Change-Id: Ia92c871b15f7e45fc174bb59bc95540fd00ae745
2014-08-22 09:26:50 -07:00
Elliott Hughes
84d0683a82 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
2014-08-21 19:23:53 -07:00
Dmitriy Ivanov
9598b8c415 Run constructors before resolving ifunc functions
Bug: 17177284
Change-Id: I5714b9bc2d1ca8f8711806bfb68da3d524213e99
2014-08-21 14:24:13 -07:00
Elliott Hughes
6b841db2ba Add POSIX-2008 fmemopen, open_memstream, and open_wmemstream.
Bug: 17164505
Change-Id: I59e28a08ff8b6ab632230b11a5807cfd5278aeb5
2014-08-20 17:03:46 -07:00
Dmitriy Ivanov
9419420919 Revert "Add support for protected local symbol lookup."
This reverts commit d97e9f546e.

Bug: 17107521
Change-Id: I2b81ce2b5a4a2d166133a2626e49d81b6aef3672
2014-08-18 15:11:50 -07:00
Elliott Hughes
2b021e1066 Add <stdio_ext.h> for elfutils.
Bug: 17139679
Change-Id: I1605ac382dbb6f23b2d874dbb9769f3cde4a6a99
2014-08-20 10:23:52 -07:00
Elliott Hughes
09c39d6df0 Implement the GNU basename(3) in addition to the POSIX one.
Code like perf(1) needs this.

Bug: 11860789
Change-Id: I907eb448052a7b165e4012d74303330d32328cb2
2014-08-19 14:30:30 -07:00
Elliott Hughes
f4c948a9e9 Move the meat of <features.h> into <sys/cdefs.h>.
This way it's a lot harder for us to screw up (since we should always
be including <sys/cdefs.h> anyway).

Bug: 14659579
Change-Id: I23070fff3296b0d1c683bb5e3a6e214146327d53
2014-08-19 11:18:20 -07:00
Dmitriy Ivanov
02aa70589d Revert "Add support for protected local symbol lookup."
This reverts commit d97e9f546e.

Bug: 17107521
(cherry picked from commit 9419420919)

Change-Id: I1a6df946ac8075699e77d68ffa6ac4a21b88e4bf
2014-08-19 05:19:53 -07:00
Elliott Hughes
5f5cc45cf0 Fix <features.h> (_BSD_SOURCE and _GNU_SOURCE).
<features.h> is supposed to take user-settable stuff like _GNU_SOURCE
and _BSD_SOURCE and turn them into __USE_GNU and __USE_BSD for use in
the C library headers. Instead, bionic used to unconditionally define
_BSD_SOURCE and _GNU_SOURCE, and then test _GNU_SOURCE in the header
files (which makes no sense whatsoever).

Bug: 14659579
Change-Id: Ice4cf21a364ea2e559071dc8329e995277d5b987
2014-08-18 16:04:03 -07:00
Dmitriy Ivanov
4571f31bd4 Add atexit test for attributed c-tor/d-tor
1. Add test for __attribute__((constructor/destructor))
    and static constructor

 2. Compile C++ testlibs with -std=gnu++11

Change-Id: I67f9308144a0c638a51f111fcba8e1933fe0ba41
2014-08-15 14:22:07 -07:00
Dmitriy Ivanov
1467dfe3e8 Make string tests check all alignment combinations
Reduce randomization of the test by (1) replacing random() & 255
 with hard-coded char and (2) by making State *Iteration function
 visit every possible alignment combination instead of 10 random ones.

Change-Id: I0ff0b4ca817ba9fbbcce53e09b25eb10a1a853c2
2014-08-14 15:05:20 -07:00
Brigid Smith
c5a13efa9b Added test for ifunc support in dynamic linker.
ifuncs now work in i386 and x86_64 when called in the same library as
well as in a different library.

Bug:6657325
Change-Id: Ic0c48b1b0a76cb90f36c20c79f68294cc3fd44a1
2014-08-08 11:29:35 -07:00
Christopher Ferris
3e7b8e2a8b Merge "Do a second key cleanup in pthread_exit." into lmp-dev 2014-08-06 23:54:36 +00:00
Christopher Ferris
18d93f2793 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
2014-08-06 17:12:30 -07:00
Christopher Ferris
e380960813 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

(cherry picked from commit 18d93f2793)

Change-Id: Idb32e7f9b09e2c088d256ed9eb881df80c81ff8e
2014-08-06 17:57:04 -07:00
Dan Albert
bc0d65c114 Merge "Proper MB_CUR_MAX." into lmp-dev 2014-08-06 17:14:55 +00:00
Dan Albert
6035e6cc83 Proper MB_CUR_MAX.
Previously this was hard coded to 4. This is only the case for UTF-8
locales.

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

Change-Id: I7c73cc8fe6ffac61d211cd5f75287e36de06f4fc
(cherry picked from commit 1aec7c1a35)
2014-08-06 13:17:43 -07:00
Dan Albert
938a8008a6 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 b6cc8e00cd)
2014-08-06 13:00:54 -07:00
Dmitriy Ivanov
db7a17d4ff Revert "Revert "Fix dlsym(3) to do breadth first search.""
This reverts commit 1b1966d944.

Change-Id: I05d6d3481aaf8f3e260d2e5e950248519a1d347f
2014-08-04 23:39:22 +00:00
Dmitriy Ivanov
1b1966d944 Revert "Fix dlsym(3) to do breadth first search."
This reverts commit 422106a24d.

Change-Id: I9e26a6933d10eb30438b521450f2010997ca5aee
2014-08-04 16:38:57 +00:00
Christopher Ferris
61833de613 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 e03e1eac0b)

Change-Id: Ie4cca2c445127a0936ee2b96651a8e7204fbaffd
2014-07-30 16:33:11 -07:00
Elliott Hughes
11bf8a3025 Only wipe TLS for user-supplied stacks.
Bug: 16667988

(cherry picked from commit 40a5217448)

Change-Id: I7550fa47b76e643323aa3e2a53529e393c829e47
2014-07-30 14:56:34 -07:00
Dan Albert
b6cc8e00cd 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
2014-07-31 11:31:03 -07:00
Dan Albert
1aec7c1a35 Proper MB_CUR_MAX.
Previously this was hard coded to 4. This is only the case for UTF-8
locales.

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

Change-Id: I7c73cc8fe6ffac61d211cd5f75287e36de06f4fc
2014-07-30 17:09:46 -07:00
Christopher Ferris
0f7ed163cf Merge "Fix memchr with a zero length." 2014-07-30 20:40:05 +00:00
Christopher Ferris
e03e1eac0b 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
Change-Id: Iab33cc7a8b79920350c72f054dff0e0a3cde69ce
2014-07-30 16:06:56 -07:00
Dmitriy Ivanov
aa0f2bdbc2 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
Change-Id: I017a6975d1a62abb0218a7eb59ae4deba458e324
2014-07-29 14:35:13 -07:00
Elliott Hughes
a7dc7600fe Merge "Fix linkage of grantpt(3)." 2014-07-28 22:45:44 +00:00
Elliott Hughes
4916706cfe 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
Change-Id: I0fb36438cd1abf8d4e87c29415f03db9ba13c3c2
2014-07-25 19:55:23 -07:00
Dan Albert
a1a813da81 Merge "Fix mbsrtowcs(3)'s handling of len parameter." into lmp-dev 2014-07-28 22:45:16 +00:00
Dan Albert
4e58609587 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 6b55ba54ef)
2014-07-29 14:20:31 -07:00
Elliott Hughes
2ea0a58e01 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 4916706cfe)

Change-Id: I5cb7a1c17b156456e4c4818e65f256eb8d045424
2014-07-29 10:48:34 -07:00
Elliott Hughes
78e4f8fed2 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
too).

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

(cherry picked from commit 21972b61ec)

Change-Id: Ifbc424be29e5650ec72a24df25dd35f24fdd5b3c
2014-07-28 15:39:24 -07:00
Elliott Hughes
b1b60c30bf 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
2014-07-28 09:33:00 -07:00
Elliott Hughes
708c112054 Start hiding "private/bionic_time.h".
Bug: 15765976

(cherry picked from commit 905e6d58aa)

Change-Id: Ic7435308e8b521886f42ac7bf59531924921ea67
2014-07-25 15:24:57 -07:00
Dmitriy Ivanov
422106a24d 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 aa0f2bdbc2)

Change-Id: I0ba8c2034ab341f8a279cdb4e2e7e47f1aef7897
2014-07-29 15:02:15 -07:00
Raghu Gandham
34b258dd69 [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 f1837377d2)

Change-Id: I973d999c31c9ab89b5a7b709beff6486b93408f2
2014-07-24 16:22:02 -07:00
Elliott Hughes
b902641d73 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 3e424d0a24)

Change-Id: I5882a6b48c80fea8ac6b9c27e7b9de10b202b4ff
2014-07-24 15:14:06 -07:00
Elliott Hughes
905e6d58aa Start hiding "private/bionic_time.h".
Bug: 15765976
Change-Id: Ibd9cf07067ec8dffe9fda6c3d498d4ab90708220
2014-07-25 12:03:51 -07:00
Nick Kralevich
92d8b2320a 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 be0e43b776)

Change-Id: I6e1a9bce564e94fc19893d639b15f38c549cabfa
2014-07-23 16:07:33 -07:00
Elliott Hughes
40a5217448 Only wipe TLS for user-supplied stacks.
Bug: 16667988
Change-Id: Id180ab2bc6713e1612386120a306db5bbf1d6046
2014-07-30 14:49:40 -07:00
Raghu Gandham
f1837377d2 [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.

Change-Id: I78e7807e50f899a0fea0d5b388d9ebb53228aaa0
2014-07-24 16:11:52 -07:00
Elliott Hughes
d6f614a4e1 Merge "Implement twalk(3), add unit tests." 2014-07-24 22:07:52 +00:00
Elliott Hughes
3e424d0a24 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
Change-Id: I97397a7b921e2e860fd9c8032cafd9097380498a
2014-07-24 14:55:29 -07:00
Elliott Hughes
21972b61ec 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
too).

Bug: https://code.google.com/p/android/issues/detail?id=73952
Change-Id: I9866c3579a7a94de27bfbe80ad7a822c3183c7fb
2014-07-28 12:33:07 -07:00
Elliott Hughes
f1e83cc34a 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.

(cherry-pick of b1b60c30bf321c0fc02264b953b5c16c49d34457.)

Bug: 14292866
Change-Id: I9c83500ba9cbb209b6f496067a91bf69434eeef5
2014-07-28 09:43:21 -07:00
Nick Kralevich
be0e43b776 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
Change-Id: Idc7857b089f3545758f4d9b436b783d580fb653f
2014-07-23 15:48:49 -07:00
Elliott Hughes
b76613627d 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 3ad8ecb64e)

Change-Id: I3038855ca4f22532bf6d2c45d3f8028b866975f9
2014-07-21 18:55:04 -07:00
Elliott Hughes
3ad8ecb64e 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
Change-Id: Icee7f088b97f88ccbdaf471b98cbac7f19f9210a
2014-07-21 16:56:48 -07:00
Dan Albert
6b55ba54ef 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
2014-07-21 11:45:48 -07:00
Elliott Hughes
3002131da3 Use VDSO for clock_gettime(2) and gettimeofday(2).
Bug: 15387103

(cherry picked from commit 625993dfbb)

Change-Id: I0e156d7049ba1495902259071a96936592e74025
2014-07-16 15:15:53 -07:00
Elliott Hughes
625993dfbb Use VDSO for clock_gettime(2) and gettimeofday(2).
Bug: 15387103
Change-Id: Ifc3608ea65060c1dc38120b10b6e79874f182a36
2014-07-16 14:27:43 -07:00
Elliott Hughes
99ae0983c0 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 76c241b091)

Change-Id: If721b3f16efdb21cb67df5ec5034c0ba905bd029
2014-07-14 14:06:11 -07:00
Elliott Hughes
76c241b091 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
Change-Id: Ia5a908a816e0a5f0639f514107a6384a51ec157e
2014-07-14 12:02:22 -07:00
Christopher Ferris
8e32b7b354 Make jemalloc the default choice.
Change-Id: I5ff0cf0c396b7ae6278e6fcd5a0d50f8b966fb54
2014-07-11 11:01:30 -07:00
Ying Wang
6cdd0cfd2f Merge "TARGET_OUT_DATA_NATIVE_TESTS now points to $(TARGET_OUT_DATA)/nativetest64 in 64-bit target" 2014-07-09 14:50:30 +00:00
Ying Wang
dc42e20d54 TARGET_OUT_DATA_NATIVE_TESTS now points to $(TARGET_OUT_DATA)/nativetest64 in 64-bit target
Change-Id: I9a562e79de7ec0f065c90de9ae1b72cbcd7d8c6b
2014-07-08 18:54:42 -07:00
Dmitriy Ivanov
f8846a4587 Add test for constructor function.
Change-Id: I0ad26d617f00cdd6c2241d613be39a1d16918612
2014-07-08 21:21:34 -07:00
Dmitriy Ivanov
950a435fc0 Merge "Load library using file handle." 2014-07-02 20:52:43 +00:00
Dmitriy Ivanov
04dc91ae76 Load library using file handle.
* This patch enables dlopen by file descriptor
   instead of path/name.

Bug: 15984217
Change-Id: Ib39051e00567fb97070bf96d8ce63993877c0a01
2014-07-02 13:20:47 -07:00
Elliott Hughes
d06ee1d6db Build all bionic test files -Werror and fix our one warning.
Change-Id: I62bb0528fd1bcb9aa4c61e44c78158a592690fc7
2014-07-01 17:17:46 -07:00
Dmitriy Ivanov
ce0ba3c706 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
2014-07-01 19:13:01 -07:00
Dmitriy Ivanov
fcac81ef04 Native tests are now multilib=both by default
Change-Id: I788ac0b871703c137727a65e017c4466127c0190
2014-07-01 15:38:22 -07:00
Dmitriy Ivanov
d97e9f546e Add support for protected local symbol lookup.
Bug: http://code.google.com/p/android/issues/detail?id=66048
Change-Id: Ib334223df27adad9477fb241ab099c5e26df4a7d
2014-07-01 10:25:54 -07:00
Christopher Ferris
3a657d01ec Add extra strchr testing.
Change-Id: Idd0a779eb3388e402cfcb4e0df40872320f8e155
2014-06-30 12:39:55 -07:00
Elliott Hughes
ebb770f90d Add a new pthread_key_delete test.
Bug: https://code.google.com/p/android/issues/detail?id=66813
Change-Id: Ida87bc1fb15a73a08c223a7099456d9f049cd3c5
2014-06-25 13:46:46 -07:00
Elliott Hughes
3f525d41c2 Add splice, tee, and vmsplice.
Change-Id: I5f43380b88d776a8bb607b47dbbc5db5a2fe6163
2014-06-24 19:03:31 -07:00
Elliott Hughes
fa9e16efaf 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
2014-06-23 17:49:45 -07:00
Elliott Hughes
7086ad6919 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
2014-06-20 09:06:57 -07:00
Dmitriy Ivanov
ce44166c73 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
2014-06-17 16:18:18 -07:00
Dmitriy Ivanov
1f5e1a3cbc Move libraries for unit-tests to separate folder
Change-Id: I1653f3f2fd63ba25525369bc725c8f7438ecf021
2014-06-17 15:08:53 -07:00
Christopher Ferris
6361964381 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
2014-06-16 23:35:53 -07:00
Dan Albert
e5fdaa4f9d Revert "Backing this one out since the counterpart needs to be sent upstream."
This reverts commit a04d2bc28e.

Change-Id: I1b49165ca5d4bafdba7948818256a6167a363aca
2014-06-14 01:04:31 +00:00
Dan Albert
a04d2bc28e Backing this one out since the counterpart needs to be sent upstream.
This reverts commit 5ee320dd35.

Change-Id: I1a9c6b06c3aca595f01c629f7649be743dc48e77
2014-06-14 00:51:14 +00:00
Dan Albert
5ee320dd35 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
2014-06-13 15:35:05 -07:00
Elliott Hughes
5d25d5480a Merge "Remove __memcmp16 from bionic." 2014-06-12 05:34:11 +00:00
Elliott Hughes
24614b4729 Remove __memcmp16 from bionic.
Change-Id: I2486d667d96c8900dd368d855f37c1327161efb7
2014-06-12 15:35:22 -07:00
Christopher Ferris
29ddd78c21 Merge "Put all allocation functions into dispatch table." 2014-06-12 21:07:49 +00:00
Christopher Ferris
a403780538 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
conditions.
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
2014-06-12 15:08:18 -07:00
Elliott Hughes
346fa721ca Merge "Get the full set of PRNG functions in <stdlib.h>" 2014-06-12 03:32:07 +00:00
Elliott Hughes
a0beeeabbc Get the full set of PRNG functions in <stdlib.h>
Bug: https://code.google.com/p/android/issues/detail?id=58888
Change-Id: I435250bdae302e8bd7e29977d0fde7b9afbfca5e
2014-06-12 14:37:31 -07:00
Christopher Ferris
3d5e0b2045 Merge "Add/Remove mmap tests." 2014-06-12 03:32:07 +00:00
Christopher Ferris
eda26bc1ff 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
2014-06-12 13:16:36 -07:00
Dan Albert
37b845f9e4 Merge "Remove declaration for putw(3)/getw(3)." 2014-06-12 05:34:11 +00:00
Dan Albert
8e613cf342 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
2014-06-11 14:41:45 -07:00
Christopher Ferris
e9f7a9c340 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
multilib.

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
2014-06-10 19:46:07 -07:00
Alexander Ivchenko
68b01665b3 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>
2014-06-11 15:57:57 -07:00
Serban Constantinescu
2aca7fe821 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>
2014-06-10 17:51:10 +01:00
Ying Wang
199e8638df Merge "Use PRIVATE_POST_INSTALL_CMD to create symlink." 2014-06-09 23:55:19 +00:00
Ying Wang
7f722b366a Use PRIVATE_POST_INSTALL_CMD to create symlink.
Bug: 15520908
Change-Id: Ib3349f7adb6def81abf07bfb9d37093e4a599d09
2014-06-09 16:32:51 -07:00
Elliott Hughes
18b17e9775 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
2014-06-06 21:55:27 -07:00
Elliott Hughes
c3bdc792be Merge "Fix the printf family for non-ASCII." 2014-06-06 18:06:44 +00:00
Elliott Hughes
69f05d291d 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
2014-06-05 23:19:15 -07:00
Varvara Rainchik
fce861498c 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>
2014-06-05 11:08:09 -07:00
Dan Albert
001f8f041b Removes wcswcs from bionic for LP64.
Bug: 13935372
Change-Id: I0deb15e769da4fa81bb65a87f3c86db5163a5796
2014-06-04 12:01:56 -07:00
Dan Albert
452e091300 Merge "Adds functionality specified by uchar.h" 2014-06-04 16:10:50 +00:00
Dan Albert
7a7f9952c1 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
2014-06-04 08:39:24 -07:00
Elliott Hughes
d286796fce Turn on -Wunused and fix the mistakes it uncovers.
Change-Id: I023d2d8b547fbc21d4124bb7510d42b06a0dc501
2014-06-03 15:22:34 -07:00
Dmitriy Ivanov
214e64135e Make atexit.dlclose work for glibc
* build libtest_atexit.so
 * remove atexit(NULL) - glibc segfaults on it

Bug: 15350494
Change-Id: I27d79130c32c5691b0e8790a57d92f9710f5bf4a
2014-05-30 18:16:09 -07:00
Christopher Ferris
39036f655a 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
2014-05-30 11:23:21 -07:00
Christopher Ferris
d178c83d45 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
2014-05-29 20:00:12 -07:00
Christopher Ferris
8bf50d5b72 Fix wmemmove test.
I accidentally copied over the nul terminator with the test.

Change-Id: I24a9aa05d4fba4f383fa38a3041bb6a6b179130c
2014-05-29 15:44:34 -07:00
Christopher Ferris
9e01ea63a7 Fix dprintf test.
Change-Id: Ied783d545b6a35a70a158249f3957a9d00971627
2014-05-29 13:17:40 -07:00
Christopher Ferris
1a57de713a Merge "Fix overflow testing in sbrk." 2014-05-29 18:03:28 +00:00
Christopher Ferris
738b0cc5e9 Fix overflow testing in sbrk.
Modify the overflow testing for sbrk.

Bug: 15188366

Change-Id: Ia83f85f7c1789454d872279bd41f38f1ce6b8a34
2014-05-29 10:51:22 -07:00
Dan Albert
6b3beb23d6 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.

http://en.cppreference.com/w/c/atomic/atomic_compare_exchange

Change-Id: I74de1061fa1fc50d835451792d902000f368200e
2014-05-28 16:53:08 -07:00
Christopher Ferris
8a405b027a Merge "Add optimized AArch64 versions of bcopy and wmemmove based on memmove" 2014-05-28 21:35:04 +00:00
Elliott Hughes
e6c57fcb05 Add C11 <stdatomic.h>.
Bug: 14903517
Change-Id: I631dbfdaa698cf7fea8e3b5e18a32586383e62a5
2014-05-23 20:06:03 -07:00
Bernhard Rosenkraenzer
6f2bde3441 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>
2014-05-23 18:49:57 -07:00
Christopher Ferris
fd0ce866ce Revert "Add optimized AArch64 versions of bcopy and wmemmove based on memmove"
This reverts commit 8167dd7cb9.

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
2014-05-24 01:02:22 +00:00
Bernhard Rosenkraenzer
8167dd7cb9 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>
2014-05-23 17:54:08 -07:00
Calin Juravle
92687e41bc 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
2014-05-23 00:22:58 +01:00
Dmitriy Ivanov
44adf93b8e Fix dlsym_failure NULL handle test
* RTLD_DEFAULT != (void*)0 only for bionic32

Change-Id: I3b3758835cf4085b0f899e2b62861591411aec13
2014-05-22 10:06:32 -07:00
Calin Juravle
eea59ea21e Merge "Add dprintf test" 2014-05-22 16:03:08 +00:00
Dmitriy Ivanov
3eb9f1f6ba Merge "Removed dlsym handle != NULL check for lp64" 2014-05-22 12:55:15 +00:00
Calin Juravle
6afb2a9a97 Add dprintf test
Change-Id: I0fe1b4d45c1312cf01deed6ce5db032d5513e908
2014-05-22 11:47:47 +01:00
Calin Juravle
172167163a Merge "Mutex-free implementation of pthread_rwlock" 2014-05-22 10:15:03 +00:00
Calin Juravle
76f352eec1 Mutex-free implementation of pthread_rwlock
Bug: 8133149
Change-Id: Id6775010d95f2634b173daa55d87a59a3cf4131b
2014-05-22 11:11:15 +01:00
Dmitriy Ivanov
ca1c80220e 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
2014-05-21 22:42:24 -07:00
Christopher Ferris
72bbd42357 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
2014-05-20 14:47:33 -07:00
Christopher Ferris
afb89c2a01 Merge "denver: optimize memmove" 2014-05-20 19:56:13 +00:00
Shu Zhang
6c80ccdeed denver: optimize memmove
Optimize 32-bit denver memmove with reversal memcpy.

Change-Id: Iaad0a9475248cdd7e4f50d58bea9db1b767abc88
2014-05-20 12:31:38 -07:00
Dmitriy Ivanov
b648a8a57e 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
2014-05-20 12:02:24 -07:00
Elliott Hughes
de9ac71053 Use -fvisibility=hidden to build libm.
Bug: 11156955
Change-Id: I77b7772a44313a1eb3970f5d2c8e2af63690efa4
2014-05-19 16:58:52 -07:00
Ben Cheng
77338a2969 Merge "Address additional warnings found by GCC 4.9." 2014-05-19 22:28:10 +00:00
Ben Cheng
caff5f2e1a Address additional warnings found by GCC 4.9.
Change-Id: If668a6eb98a6ce7b2872f528b8e3527638814f68
2014-05-19 14:27:31 -07:00
Jingwei Zhang
568d64dc62 Accuracy tests for libm
This patch adds tests for 14 math functions to address coverage
issue of math functions discussed in:
https://android-review.googlesource.com/#/c/49653/

Change-Id: Ia7200b93d4f5c7928a3fb827ca6932226384a116
Signed-off-by: Jingwei Zhang <jingwei.zhang@intel.com>
Signed-off-by: Yong Yao <yong.yao@intel.com>
2014-05-16 15:31:55 -07:00
Dmitriy Ivanov
86bc436e20 Merge "Improve detection of already loaded libraries" 2014-05-15 21:55:24 +00:00
Calin Juravle
9b95ea936a Document a known test issue in stdio_test.cpp.
Bug: 13077905
Change-Id: Iab7fc7be0737c732e26cc07ecd7884b3087b51bb
2014-05-15 10:34:06 +01:00
Dmitriy Ivanov
d59e50063a 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
2014-05-14 15:16:35 -07:00
Elliott Hughes
c9244bdac1 Add tests for fprintf behavior when the underlying fd is bad.
Bug: 7229520
Change-Id: Ie878e0c13fdcda7b9131fa56208b84ed88125be7
2014-05-14 13:31:35 -07:00
Elliott Hughes
e77f38f14a 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
2014-05-14 12:39:12 -07:00
Elliott Hughes
3694ec6c4b Add a regression test for a long-fixed pthread_once bug.
Bug: 1934122
Change-Id: Iae09baedc2c6ed4036521e51718fe9d015bc56b9
2014-05-14 11:46:08 -07:00
Elliott Hughes
1728b23965 Switch to g_ for globals.
That's what the Google style guide recommends, and we're starting
to get a mix.

Change-Id: Ib0c53a890bb5deed5c679e887541a715faea91fc
2014-05-14 10:02:03 -07:00
Elliott Hughes
5c8c88dd8d 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
2014-05-13 19:17:46 -07:00
Elliott Hughes
6a41b0fb0e 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
2014-05-13 18:08:29 -07:00
Elliott Hughes
063525c61d 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
2014-05-13 11:19:57 -07:00
Elliott Hughes
eb664e24c0 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
2014-05-13 10:44:07 -07:00
Calin Juravle
03e4ebee8d Add fpos_t tests.
Bug: 13077905

Change-Id: I86bb0ee95660f69f9971231c6f828a3a067d1ac8
2014-05-13 00:39:08 +01:00
Calin Juravle
15a6310e4b Support mb sequences across calls to mb*to*wcs* functions
Bug: 13077905
Change-Id: I5abdc7cc3c27c109b7900c94b112f18a95c35763
2014-05-13 00:24:25 +01:00
Elliott Hughes
20f8aec897 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
2014-05-12 15:15:37 -07:00
Calin Juravle
4d695bf560 Merge "Align struct passwd definition with other variations of libc" 2014-05-12 09:53:41 +00:00
Calin Juravle
c768874c66 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
2014-05-09 22:29:23 +01:00
Elliott Hughes
55b4c8a4a1 Merge "Hide the __bionic_clone and __bionic_clone_entry implementation details." 2014-05-09 16:13:52 +00:00
Elliott Hughes
954cf0d4e2 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
2014-05-08 19:00:23 -07:00
Dmitriy Ivanov
29d10e3de8 Merge "Test dlopen with symlinked .so files" 2014-05-09 00:52:08 +00:00
Elliott Hughes
170daa042c Merge "wchar_test.cpp: fix error between comparison signed and unsigned integer" 2014-05-08 23:52:59 +00:00
Dmitriy Ivanov
7db180919c Test dlopen with symlinked .so files
Bug: 9741592
Change-Id: I68c59d6f4e690136395c3dc3de13f99ce38de528
2014-05-08 14:28:34 -07:00
Yongqin Liu
a5c6b2ecb5 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
external/gtest/include/gtest/gtest.h:1448:16:
    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>
2014-05-09 00:57:47 +08:00
Elliott Hughes
3b96803284 Merge "Add basic tests for fsync/fdatasync." 2014-05-07 23:40:11 +00:00
Elliott Hughes
a62a28d1d9 Add basic tests for fsync/fdatasync.
Bug: 14613980
Change-Id: Ie8002c2a1abae07295b7bdb33772764767c03d37
2014-05-07 14:30:33 -07:00
Dmitriy Ivanov
f837cbdc27 Merge "Add missing test for atexit test suite." 2014-05-07 20:49:00 +00:00
Dmitriy Ivanov
6396da98cb Add missing test for atexit test suite.
Change-Id: I3d14d7df1da53ccef534c106633593551ab6a7cb
2014-05-07 12:29:54 -07:00
Calin Juravle
837abf0466 Merge "Fix bionic-unit-tests-glibc-run target" 2014-05-07 18:31:11 +00:00
Calin Juravle
0e9d7fccb9 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
2014-05-07 19:06:30 +01:00
Torne (Richard Coles)
35cff760df Merge "Test that relro sharing actually saves memory." 2014-05-07 15:25:44 +00:00
Elliott Hughes
100168abff Merge "Fix <math.h> to quieten most of our warnings." 2014-05-06 17:18:16 +00:00
Torne (Richard Coles)
2605261691 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
2014-05-06 11:38:53 +01:00
Torne (Richard Coles)
9b5ee4aa85 Merge "Handle empty relro segment or incorrectly sized file." 2014-05-06 10:16:18 +00:00
Elliott Hughes
9a5a3e8e74 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
2014-05-05 21:19:47 -07:00
Philip Hatcher
9ded07cff6 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>
2014-05-05 19:48:55 -07:00
Elliott Hughes
ad534985ec Merge "Disable %n in printf and vfwprintf." 2014-05-05 21:49:22 +00:00
Elliott Hughes
e2341d08fa Disable %n in printf and vfwprintf.
Bug: 14492135
Change-Id: If190bede29e5f68a65043ddbe8e878c660933d03
2014-05-05 14:43:17 -07:00
Elliott Hughes
8ec21d9ded Merge "Switch to current upstream OpenBSD wsetup.c." 2014-05-05 21:33:22 +00:00
Elliott Hughes
53b24382f5 Switch to current upstream OpenBSD wsetup.c.
Change-Id: I2c1123f3e1d3c4af7fd7bf354e763934a39b78c0
2014-05-05 14:31:20 -07:00
Dmitriy Ivanov
580b246917 Merge "Fixes for __cxa_finalize" 2014-05-05 21:04:33 +00:00
Dmitriy Ivanov
6b56691a67 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
2014-05-05 11:36:57 -07:00
Elliott Hughes
efaa461bd6 Use the OpenBSD wcsftime.
Change-Id: I81929355d245ba1e58b4a464ca6cf45915e0238e
2014-05-02 15:57:50 -07:00
Torne (Richard Coles)
26ec9679ff 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
2014-05-02 14:25:45 +01:00
Elliott Hughes
f83e644e2c Fix wchar.cpp MIPS narrowing conversion build failure.
Change-Id: Id9103c78958d60337dbdb807b11256c1b31c632a
2014-05-01 17:14:59 -07:00
Elliott Hughes
5a0aa3dee2 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
2014-05-01 14:46:54 -07:00
Elliott Hughes
9fb53dd4db Merge "Make SIGRTMIN hide the real-time signals we use internally." 2014-04-30 18:30:15 +00:00
Elliott Hughes
2d36750c3a Fix the CPU_*_S tests.
Change-Id: Id67c48b9c12a20b01309490670438bfcd9163465
2014-04-30 10:45:35 -07:00
Elliott Hughes
0990d4fda8 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
2014-04-30 10:06:09 -07:00
Calin Juravle
77473e4085 Merge "Fix cpu_set_t" 2014-04-30 16:09:08 +00:00
Calin Juravle
b743790cca 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
2014-04-30 14:30:15 +01:00
Dan Albert
b8425c549a Adds quick_exit(3) and at_quick_exit(3) from freebsd
Change-Id: I4fe88abd8f7b8aa45e58aeb2529d59a8d555d338
2014-04-29 19:17:00 -07:00
Elliott Hughes
01ae00f317 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
2014-04-29 16:28:56 -07:00
Elliott Hughes
55cd82762f Merge "Switch to the OpenBSD wcsto* functions." 2014-04-29 22:33:15 +00:00
Elliott Hughes
3d7a0d9b08 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
2014-04-29 14:53:11 -07:00
Christopher Ferris
7fdab460a9 Merge "Fix potential makefile bug." 2014-04-29 15:56:06 +00:00
Christopher Ferris
5090964da0 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
previously.

Change-Id: I5c30e18d5111705cb3f6e3d4cd9ef8a28c9b746c
2014-04-28 21:10:37 -07:00
Elliott Hughes
0a5e26da1e Add mbtowc and fix mbrtowc.
Change-Id: I48786cd82587e61188d40f6fd6e11ac05e857ae9
2014-04-28 17:51:13 -07:00
Elliott Hughes
d299bcfdad Replace our broken wcswcs with the working upstream one.
Change-Id: I2952684df5674d10f0564d92c2cd42597725c0e3
2014-04-28 16:46:24 -07:00
Elliott Hughes
329103d3e2 Don't use so much stack in tzcode.
Bug: 14313703
Bug: https://code.google.com/p/android/issues/detail?id=61130
Change-Id: Id9b240fce20d4a6f2660792070e02b2b5f287655
2014-04-25 21:51:26 -07:00
Elliott Hughes
533dde4dbf 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
2014-04-25 19:38:33 -07:00
Calin Juravle
ae77f74bcf Merge "Clean-up _fpmath and fake_long_doubles" 2014-04-24 10:12:58 +00:00
Elliott Hughes
409588cdae Fix fallout from host GCC upgrade.
I'll raise a bug for the FD_ISSET fortification; we should do better too.

Change-Id: Id2bf277890ad06b010dc952e270d746714c2bea7
2014-04-23 23:02:43 -07:00
Calin Juravle
1abc9ff6a5 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
2014-04-23 19:03:06 +01:00
Elliott Hughes
0c567f1e6c 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
2014-04-22 19:21:32 -07:00
Grigoriy Kraynov
cbf6df0459 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>
2014-04-22 19:09:45 -07:00
Dmitriy Ivanov
53c884e281 Get ANDROID_DATA dir from enviroment
Change-Id: Ie3675bd27bbc779fc2140f95b930eadd14838753
2014-04-22 18:44:55 -07:00
Dmitriy Ivanov
156c3afcf1 Follow up on building tests for both platforms
this makes run-on-host work properly

Change-Id: Iaed93ca9d96359b64bbeff995280ecd70fc9cc60
2014-04-22 15:22:25 -07:00
Christopher Ferris
345b49a7c0 Build 32/64 bit versions of tests/benchmarks.
Change-Id: I4d146377aac6573a214dfaa5cab5cce8b10538b4
2014-04-22 10:42:12 -07:00
Elliott Hughes
c5eea6d386 Merge "Fix WCHAR_MAX, WCHAR_MIN, WINT_MAX, and WINT_MIN." 2014-04-22 17:00:33 +00:00
Torne (Richard Coles)
b1bfa7956c Merge "Allow sharing the RELRO section via a file." 2014-04-22 10:39:49 +00:00
Torne (Richard Coles)
c363e5dd0a Merge "Support loading libraries to a reserved address." 2014-04-22 10:33:34 +00:00
Elliott Hughes
83c07b5e50 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
2014-04-21 18:09:46 -07:00
Elliott Hughes
1b836ee6f8 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
2014-04-18 13:32:33 -07:00
Elliott Hughes
b88da06580 Merge "Upgrade to current vfprintf." 2014-04-18 18:19:23 +00:00
Elliott Hughes
f3c73901cb 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
2014-04-18 10:29:16 -07:00
Elliott Hughes
0549371bd7 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
2014-04-17 17:30:03 -07:00
Torne (Richard Coles)
183ad9df53 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
2014-04-17 14:30:46 +01:00
Torne (Richard Coles)
12bbb91645 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
2014-04-17 14:22:17 +01:00
Elliott Hughes
4bd97cee28 Switch to gdtoa.
This gives us a real strtold for LP64 and fixes various LP64
bugs.

Bug: 13563801
Change-Id: I277858d718ee746e136b6b6308a495ba50dfa488
2014-04-16 15:15:52 -07:00
Ben Cheng
26c2bb84dd Merge "Fix signed vs unsigned comparison." 2014-04-15 22:37:29 +00:00
Ben Cheng
b760164dd6 Fix signed vs unsigned comparison.
Otherwise GCC 4.9 complains.

Change-Id: I7cd3c5e8c78fda709130ca88a85fa1512e6fc024
2014-04-15 15:29:32 -07:00
Elliott Hughes
02c78a3867 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
2014-04-14 14:35:47 -07:00
Elliott Hughes
7823f320b1 Extra tests for printf of NaN and Inf.
Change-Id: I61fc655d9777a03aabf38f6ebd047fe275386f05
2014-04-14 12:11:28 -07:00
Elliott Hughes
6455ac73da Improve the <sstream> test.
It looks like libcxx's testing is crap too, and this turned up
another bug in stlport.

Change-Id: I98c93dceaa8225c3cc280166d4bb74adaf94a324
2014-04-10 20:44:27 -07:00
Elliott Hughes
8c42606ae1 Add a test for external/stlport a6df82320fcb8f26af0d067c7768fedbaeb9ad88.
Change-Id: If4df9f5df41ae5453a3dff6bb032b419819f8703
2014-04-10 11:34:14 -07:00
Elliott Hughes
b52a4ab4e2 Merge "Flesh out <locale.h>." 2014-04-09 04:13:43 +00:00
Elliott Hughes
764a993611 Fix build: include what you use.
Change-Id: I12b2d5e434ad3ed38d4451bd470673781e6ca8fe
2014-04-08 19:44:36 -07:00
Elliott Hughes
c4936e20a3 Flesh out <locale.h>.
This is a trivial implementation that only supports the C/POSIX locale.

Change-Id: Ib11cea4249e1862aca96a8b94d58ea9a418cbe75
2014-04-08 19:37:38 -07:00
Elliott Hughes
9f525644df Implement _Exit(3).
Change-Id: Ida6ac844cc87d38c9645b197dd8188bb73e27dbe
2014-04-08 17:16:13 -07:00
Elliott Hughes
5363a45f2b 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
2014-04-08 14:34:12 -07:00
Serban Constantinescu
48501af98f 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>
2014-04-08 12:19:23 -07:00
Christopher Ferris
41059d764f Merge "Add stpcpy/stpncpy." 2014-04-08 01:21:07 +00:00
Elliott Hughes
b9bb48bf28 Merge "Fix the printf issue for 64 bits. The following case:" 2014-04-07 23:44:50 +00:00
Christopher Ferris
950a58e24d 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
stpncpy.

Add all of the fortify test cases.

Bug: 13746695
Change-Id: I8c0f0d4991a878b8e8734fff12c8b73b07fdd344
2014-04-07 16:41:53 -07:00
Elliott Hughes
efbdb53f84 Remove a non-standard turd: strtotimeval.
Change-Id: I1b1e40746cb573e3fb73a5276969b40c5da36d15
2014-04-07 15:17:19 -07:00
Elliott Hughes
77e944fd46 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
2014-04-07 14:29:28 -07:00
Calin Juravle
eb554998d7 Merge "Fix modf* tests" 2014-04-03 09:00:34 +00:00
Calin Juravle
d8d6feed3a Fix modf* tests
Use a value that can be exactly represented.

Change-Id: Idf3b1db5e6042fb49c1f591f25f9eee656659ece
2014-04-02 21:54:39 +01:00
Alexander Ivchenko
edd7c2ec25 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>
2014-04-02 18:30:55 +04:00
Calin Juravle
9c9ef0db91 Merge "Changed long double literal suffix from 'l' to 'L'." 2014-04-02 10:17:11 +00:00
Brian Carlstrom
1021c05f1b Include sys/types.h and sys/wait.h for waitpid
(cherry picked from commit 8b2c6d44cac206b61dffd965863336e6f803fc66)

Change-Id: Ice1f6d956c11aaefd3d846c12121f08613a94446
2014-04-01 17:42:31 -07:00
Christopher Ferris
e3bb025b3d 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
2014-04-01 14:46:09 -07:00
Calin Juravle
b7afa9df25 Changed long double literal suffix from 'l' to 'L'.
Change-Id: Id569f2d335b0930704d12ad7f388cb98b65f3ab7
2014-04-01 16:49:14 +01:00
Christopher Ferris
108f6dc316 Move accept4 tests into sys_socket_test.cpp.
In addition, create basic recvmmsg, sendmmsg tests.

Change-Id: Ie9f4954446d98b5eb5e553d3c616c1ee67c3cb66
2014-03-31 22:43:38 -07:00
Christopher Ferris
9cea377505 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
2014-03-31 11:23:39 -07:00
Calin Juravle
557942ac58 Merge "Fix math tests." 2014-03-31 10:54:15 +00:00
Pavel Chupin
50282f72bb Add lconv declaration and localeconv(3)
lconv is taken from ndk/sources/android/support/include/locale.h and
matches
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>
2014-03-28 11:15:03 +00:00
Calin Juravle
c8564f2df2 Fix math tests.
Bug: 13657654
Change-Id: I39b2f13b5b3d3e6897618ac3aed49a0a08458dd0
2014-03-28 11:10:01 +00:00
Christopher Ferris
a58b3f78e1 Merge "Add accept4 unit test to bionic." 2014-03-27 18:15:15 +00:00
Andrei Emeltchenko
2f3ba8844a Add accept4 unit test to bionic.
Change-Id: I1cce5fb8dab16f03164fdd288f35a814d7c49c6a
2014-03-27 11:08:49 -07:00
Calin Juravle
4bfaf462f0 Added strtotimeval tests.
Change-Id: I3dfd3647a8494490a2d549bdb915968063a7fb99
2014-03-26 17:57:48 +00:00
Brian Carlstrom
133bd09334 Add include of float.h for LDBL_MIN_EXP and LDBL_MANT_DIG
(cherry picked from commit 1711c6ea3a0d891da665325c75738a68bd7d501f)

Change-Id: Ia64676b2b904f042fec678003e3f2cd5bd82b510
2014-03-24 16:53:22 -07:00
Calin Juravle
989a80b750 Merge "Fix LP64 libm for 128-bit long doubles" 2014-03-24 12:13:24 +00:00
Calin Juravle
4d77c1151c Fix LP64 libm for 128-bit long doubles
* reworked amd64/_fpmath.h and arm64/_fpmath.h to support 128-bit long
doubles.
* 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
2014-03-24 11:48:42 +00:00
Christopher Ferris
753ad778bc 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
2014-03-20 20:47:45 -07:00
Calin Juravle
7227066726 Added a test flag to bionic run-test targets.
It makes it much easier to pass arguments to the tests.

Change-Id: Ia91eba4868627a3cea3f8d2c26ba01af4e860b12
2014-03-19 18:23:36 +00:00
Christopher Ferris
f171b34cf0 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
2014-03-17 16:40:26 -07:00
Elliott Hughes
603332fc4c Upgrade to current upstream scanf implementation.
Also add a basic test.

Change-Id: Icc0e68a5716b9579244f6eb8bac1ab5a24eda85a
2014-03-12 17:10:41 -07:00
Elliott Hughes
5a8173860d 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
2014-03-12 16:12:57 -07:00
Elliott Hughes
40488560c1 Include what you use.
Don't rely on transitive includes. (Even though that works fine in AOSP.)

Change-Id: Ifc06575e4aea383cfff24d6c5c14fc0a7aabdf2b
2014-03-12 13:50:38 -07:00
Elliott Hughes
3cdf5739cd Add a basic unit test for system(3).
Change-Id: Ibc5ac21f3663685d89ce261b58d6ea386fc1ff88
2014-03-11 12:54:44 -07:00
Elliott Hughes
3e3409af0f Add system/extras strftime and strptime tests.
Change-Id: I889c58f6e2e27b99cf6328a8671858d2e5feaa4e
2014-03-10 18:19:03 -07:00
Brian Carlstrom
be1d91dedc Add includes for waitpid
(cherry picked from commit f07c5dd9ab63f2e8ba736107bd4b69bbd8829c9f)

Change-Id: I7a765fd7a3a5f8f29a703f6a591c4fd8df4ebf1c
2014-03-08 15:09:43 -08:00
Elliott Hughes
04620a3cd7 Fix pthread_detach for already-exited threads.
Change-Id: I2bf7f41234d93b226132a4c51705f4186f4961c3
Reported-by: Paresh Nakhe <pnakhe@codeaurora.org>
2014-03-07 17:59:05 -08:00
Elliott Hughes
4b558f50a4 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
2014-03-07 16:49:46 -08:00
Elliott Hughes
0e714a5b41 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
2014-03-04 10:27:58 -08:00
Narayan Kamath
51e6cb33e3 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
purposes.

bug: 13232338

Change-Id: I857e7da64b3ecbb23eeac7c9f3fbd460f60231bd
2014-03-04 11:17:13 +00:00
Elliott Hughes
aedb00d04e 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
2014-03-04 00:58:31 +00:00
Guillaume Ranquet
6ff0c75c83 Add recvmmsg and sendmmsg syscalls.
Also add the corresponding constant, struct, and function declarations
to <sys/socket.h>, and perfunctory tests so we know that the symbols
actually exist.

Signed-off-by: Guillaume Ranquet <guillaumex.ranquet@intel.com>
Change-Id: Ib0d854239d3716be90ad70973c579aff4895a4f7
2014-02-27 14:29:01 -08:00
Calin Juravle
a92b57c7f8 Merge "Added ftw64, nftw64" 2014-02-25 10:44:26 +00:00
Calin Juravle
7c1efffc24 Merge "Added mkstemp64" 2014-02-25 10:43:31 +00:00
Elliott Hughes
0e44bc3bae Remove <asm/page.h>.
If we have PAGE_SIZE/PAGESIZE, POSIX says they should be in <limits.h>.

Change-Id: I3c2d574ea2aea81f524874a156361411a4ffa18e
2014-02-24 15:55:31 -08:00
Calin Juravle
d4934a70e6 Added ftw64, nftw64
Bug: 13076637
Change-Id: I5b926526f935b00bba14c2807b61d85f95089c33
2014-02-24 20:22:11 +00:00
Calin Juravle
fe317a3775 Added mkstemp64
Bug: 13076637
Change-Id: I41bf28ab3e6c7325470781e9323eeec023483df5
2014-02-24 20:19:19 +00:00
Calin Juravle
90b0157679 Merge "Fixed int fast types for LP64" 2014-02-21 17:09:13 +00:00
Calin Juravle
da030de702 Fixed int fast types for LP64
Bug: 13110474
Change-Id: Id5591603ad4ba7e149c0852f4abb25e4e5a5d065
2014-02-21 16:27:21 +00:00
Narayan Kamath
5f6f4a956c 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
2014-02-19 18:50:30 +00:00
Elliott Hughes
1d18e9cc0a Add missing file from previous change.
Change-Id: Id25000162a9ed76ce756842bdc09fe9afff9528f
2014-02-18 15:48:56 -08:00
Elliott Hughes
db1ea34748 Implement some of the missing LFS64 support.
This gives us:

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

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

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

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

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

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

Bug: 11865851
Bug: 8472078
Change-Id: Ia46443521918519f2dfa64d4621027dfd13ac566
2014-02-18 15:39:24 -08:00
Elliott Hughes
915fefb62e Fix x86 build.
Change-Id: Iee6e5884288f7da6c955694cfe32fecfd9c9e263
2014-02-18 12:34:51 -08:00
Colin Cross
3d19a8319b 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
    ret
END(read)

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
2014-02-18 12:11:38 -08:00
Elliott Hughes
671e236d5f Restore sys_signame for LP64.
mksh is using this, and we probably build as much BSD source as glibc source.

Change-Id: I400d255a67f9614ca9e57090e3a2e49d2b10cba4
2014-02-12 19:04:27 -08:00
Elliott Hughes
aa0ebdafc7 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
2014-02-12 17:09:25 -08:00
Christopher Ferris
f04935c85e 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
2014-02-06 20:12:21 -08:00
Elliott Hughes
f64b8ea09d Add fallocate/fallocate64/posix_fallocate/posix_fallocate64.
Bug: 5287571
Bug: 12612860
Change-Id: I4501b9c6cdf9a830336ce0b3afc4ea716b6a0f6f
2014-02-03 16:20:46 -08:00
Elliott Hughes
718a5b5495 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
2014-01-28 17:02:03 -08:00
Elliott Hughes
431166d995 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
2014-01-27 16:36:56 -08:00
Elliott Hughes
e2a292d278 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
2014-01-24 16:38:07 -08:00
Colin Cross
d1973ca513 bionic: rename aarch64 target to arm64
Rename aarch64 build targets to arm64.  The gcc toolchain is still
aarch64.

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

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

Change-Id: I1903d913b23016a2fc3b9f452885ac730d71e001
2014-01-09 11:00:04 -08:00
Elliott Hughes
5f1322cecf Merge "Pass a valid stack pointer to __bionic_clone in pthread.__bionic_clone" 2014-01-06 23:37:21 +00:00
Chris Dearman
dd00364807 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
CLONE_SIGHAND.

Change-Id: Ic02192081f6f52df6f03d9810efa82d923247a11
2014-01-04 13:14:35 +00:00
Elliott Hughes
894f8cb139 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
2014-01-03 14:49:37 -08:00
Elliott Hughes
6ad8f76f1f Don't abort in stdio.getdelim_invalid and stdio.getline_invalid.
Change-Id: Ie1aefed732f4bea77887bddd1be9a0578e247aa3
2013-12-19 14:56:17 -08:00
Elliott Hughes
e7c59f9e20 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
2013-12-18 09:47:44 -08:00
Marcus Oakland
e365f9d654 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>
2013-12-17 15:02:43 -08:00
Serban Constantinescu
282e232e2a 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>
2013-12-16 17:40:30 -08:00
Elliott Hughes
1887621de8 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
2013-12-12 12:51:08 -08:00
Colin Cross
a84f88f098 Merge "bionic: move benchmarks out of tests directory" 2013-12-11 19:05:25 +00:00
Colin Cross
bd3efbc9b5 bionic: move benchmarks out of tests directory
Change-Id: I4d054965198af22c9a9c821d1bc53f4e9ea01248
2013-12-10 18:24:30 -08:00
Christopher Ferris
e5bbb6b6ab Add strcmp/memcmp testing.
Bug: 9797008
Change-Id: I11b1da060d29f7dacbb53f20a3e2082395b5bd8a
2013-12-03 18:42:41 -08:00
The Android Open Source Project
f00c938c7f Merge commit '811b0cdb2d6e4a697dbc63a678712759dd0db242' into HEAD
Change-Id: I786944f80fb1a2d502fed51dc2c391ed5db66761
2013-11-22 13:38:33 -08:00