Compare commits

..

574 Commits

Author SHA1 Message Date
Dmitriy Ivanov
dec4de456c Merge "Correct way to specify additional dependencies" 2014-10-17 20:19:18 +00:00
Dmitriy Ivanov
4a9e1937c5 Correct way to specify additional dependencies
Previous one was not covering all the targets

Bug: 17548097
Change-Id: I425e0f8d6e5a43feabd29dcb327049b82754d249
2014-10-17 11:47:18 -07:00
Dmitriy Ivanov
5281e1fb15 Merge "Fix misleading comment." 2014-10-16 17:54:02 +00:00
Dan Albert
90aa7e374f Merge "Only use <atomic> for C++11 and newer." 2014-10-16 16:19:44 +00:00
Dan Albert
8bb12127e6 Merge "Don't use an STL for libm." 2014-10-16 15:56:32 +00:00
Dan Albert
3ce0769aa5 Only use <atomic> for C++11 and newer.
Any pre-C++11 clients of stdatomic.h that use libc++ are being forced
over to <atomic>, which they don't have the language support to use.

Change-Id: I62445c1f2541410a1569498c09433c7196635537
2014-10-16 07:52:51 -07:00
Dan Albert
e91d9cd4ad Don't use an STL for libm.
The default is none right now, but this will be needed when the
default becomes libc++.

Change-Id: Ib022adac2b9dc08fbfae830908128043cfffb91e
2014-10-16 07:44:47 -07:00
Dmitriy Ivanov
f5e0258268 Merge "Ignore DT_BIND_NOW (0x18)" 2014-10-15 23:46:26 +00:00
Dmitriy Ivanov
ea6eae182a Ignore DT_BIND_NOW (0x18)
Bug: 17552334
Change-Id: Ibe93fd3d6580f369f9a6ef8d235bf0df00fe7607
2014-10-15 22:57:14 +00:00
Robert Grosse
4544d9f9bf Fix misleading comment.
Change-Id: I9e2aa6c2ba938c8f8d7c74eba32d313c866c77b2
2014-10-15 14:32:19 -07:00
Dan Albert
71cbcdcf94 Merge "We don't actually need all of libc++ here." 2014-10-15 19:59:09 +00:00
Dan Albert
a7c2e0bad6 We don't actually need all of libc++ here.
All we're actually interested in is the unwinder. Since that's now a
separate library, just use that.

Change-Id: If86071a0d850da961336a58147b70369ace7bd12
2014-10-14 14:19:34 -07:00
Elliott Hughes
97df16ba5c Merge "Add clock_settime and clock_nanosleep." 2014-10-14 03:07:43 +00:00
Haruki Hasegawa
1816025684 Add clock_settime and clock_nanosleep.
Add the missing prototypes, fix the existing prototypes to use clockid_t
rather than int, fix clock_nanosleep's failure behavior, and add simple
tests.

Bug: 17644443
Bug: https://code.google.com/p/android/issues/detail?id=77372
Change-Id: I03fba369939403918abcabae9551a7123953d780
Signed-off-by: Haruki Hasegawa <h6a.h4i.0@gmail.com>
2014-10-13 17:04:10 -07:00
Dmitriy Ivanov
c229705051 Merge "Add glibc alias for NT_PRFPREG" 2014-10-13 22:08:52 +00:00
Dmitriy Ivanov
a6bee4df4c Add glibc alias for NT_PRFPREG
Also fix comment style for DF_1_ constants

Change-Id: I7c3ed1d834f0a2b85ee8cc8016c79020955084f8
2014-10-13 15:03:27 -07:00
Christopher Ferris
083769a3df Merge "Return total footprint, not high water mark." 2014-10-13 19:48:35 +00:00
Christopher Ferris
fee09e556f Return total footprint, not high water mark.
The mallinfo usmblks value returned by dlmalloc is a little misleading.
It's not the current max, it's the historical high water mark. This
leads to dumpsys meminfo producing native memory numbers that don't add up.
Change this to the real total footprint, not this high water mark.

Bug: 17265653

(cherry pick from commit f4ada9c9ce)

Change-Id: I2fba10285859dccfe8331063c9be14cc169f2d91
2014-10-13 12:45:35 -07:00
Dan Albert
94571f9ade Merge "Use LOCAL_CXX_STL to select libc++_static." 2014-10-13 19:09:00 +00:00
Dan Albert
90a29db0f4 Use LOCAL_CXX_STL to select libc++_static.
Directly adding the library to LOCAL_STATIC_LIBRARIES thwarts a few
build system checks.

Change-Id: Ib23c43badfa85de21c691f79ccdcc2cbe2a89b33
2014-10-13 11:20:29 -07:00
Dan Albert
4c0862474e Merge "Fix some formatting so GitHub displays it nicely." 2014-10-11 00:48:33 +00:00
Dan Albert
472cce5c98 Fix some formatting so GitHub displays it nicely.
Change-Id: Id6ce9a61bebd98544c85e5780147715c73d0e78b
2014-10-10 17:14:37 -07:00
Dan Albert
8c3901b299 Merge "Improve documentation for testing and coverage." 2014-10-10 18:59:03 +00:00
Dan Albert
efee1ce46a Improve documentation for testing and coverage.
Also rename HACKING.txt to README.md so it will display on the GitHub
mirror.

Change-Id: I70157a4ad262700212bf9afd87253d195c7013a9
2014-10-10 11:45:19 -07:00
Elliott Hughes
2698f9ef84 Merge "Catch up on upstream's round/roundf/roundl." 2014-10-10 17:29:52 +00:00
Elliott Hughes
14538ca75e Catch up on upstream's round/roundf/roundl.
Not sure how we missed these, but better late than never...

Change-Id: Ib08d1bb6e340a1907cbeb1cbe220e33f70642bdc
2014-10-10 10:21:43 -07:00
Christopher Ferris
62a665a605 Merge "Add back symbols to fix Greed for Glory franchise." 2014-10-10 05:25:26 +00:00
Christopher Ferris
78ba823033 Add back symbols to fix Greed for Glory franchise.
Bug: 17813018

(cherry picked from commit c891e24073)

Change-Id: I4e891c2dbad9ea00d2377c5175317d9ae3840153
2014-10-09 22:23:50 -07:00
Elliott Hughes
8dd3b65f2d Merge "Sync libm with upstream." 2014-10-10 01:26:18 +00:00
Elliott Hughes
488268b134 Sync libm with upstream.
Change-Id: I3b4e2c9c6ce6c5934f270a51ce5eb9154c5805d5
2014-10-09 16:20:37 -07:00
Elliott Hughes
e9c216fca5 Merge "Fix pthread_attr_getstack under valgrind." 2014-10-09 21:17:41 +00:00
Elliott Hughes
9afb2f2106 Fix pthread_attr_getstack under valgrind.
valgrind seems to mess with the stack enough that the kernel will
report "[stack:pid]" rather than "[stack]" in /proc/self/maps, so
switch to the task-specific file instead to force "[stack]". (There
are two conditions in the kernel code that decides which form to
output.)

Bug: 17897476
Change-Id: Iff85ceb6d52e8716251fab4e45d95a27184c5529
2014-10-09 14:01:47 -07:00
Christopher Ferris
d0944d9ed3 Merge "Re-add dlmalloc for 32 bit." 2014-10-09 18:50:32 +00:00
Christopher Ferris
f183f95946 Re-add dlmalloc for 32 bit.
It turns out that appportable has a version that calls dlmalloc directly.
Re-add the dlmalloc symbol for 32 bit only as a compatibility shim that
calls malloc.

Bug: 17881362

(cherry pick commit from c9734d24d9)

Change-Id: Iee9a777f66a1edb407d7563a60792b767ac4f83a
2014-10-09 11:47:01 -07:00
Dan Albert
8a7f8387b3 Merge "Use snprintf(3) instead of sprintf(3)." 2014-10-09 00:32:11 +00:00
Dan Albert
ca75f9cdeb Use snprintf(3) instead of sprintf(3).
This change should probably be made upstream as well, but they have a
note about not using it because it isn't available on all systems.

Change-Id: I6d8404c031bd2f486532ced55d94bbb4a4cd2e71
2014-10-08 17:10:26 -07:00
Dan Albert
72d72d9126 Merge "Replace uses of sprintf(3) with snprintf(3)." 2014-10-08 23:44:48 +00:00
Ying Wang
0c0e728bd8 Merge "Build dlext_testzip as custom module." 2014-10-08 23:43:50 +00:00
Ying Wang
667853d477 Build dlext_testzip as custom module.
Use $(BUILD_SYSTEM)/base_rules to build it as custom module, so that
it's exposed to utilities like mm/mmma etc.

Bug: 17887283
Change-Id: Idd7b62d08e4d56331a3ff15da6aa46eae8c41898
2014-10-08 16:38:58 -07:00
Dan Albert
cfd8c45725 Replace uses of sprintf(3) with snprintf(3).
At -00, the compiler warns about sprintf(3), and it is promoted to an
error by -Werror.

Change-Id: Ibb380d27d7eb09dda8ac785be2478d656b379190
2014-10-08 16:12:27 -07:00
Dmitriy Ivanov
ac3c94d031 Merge "Fix mma build: 'cd bionic && mma' case" 2014-10-08 22:39:21 +00:00
Dmitriy Ivanov
51166d3aa2 Fix mma build: 'cd bionic && mma' case
Bug: 17887283
Change-Id: If2015f2361348eac8c53aed3f8715077b79ce2f5
2014-10-08 15:36:56 -07:00
Elliott Hughes
0511534dcb Merge "Don't silently return EINVAL for a NULL sem_t*." 2014-10-08 22:21:13 +00:00
Elliott Hughes
bfeef2d3a9 Merge "Use ln(1) rather than cp(1) to set up host /system for testing." 2014-10-08 22:17:19 +00:00
Elliott Hughes
75129ae9f3 Don't silently return EINVAL for a NULL sem_t*.
Bug: 17571197
Change-Id: Ied31d8de87fc10d20dc338be0457e9a4ddb9a0a5
2014-10-08 15:11:44 -07:00
Elliott Hughes
3ea4d56ed4 Use ln(1) rather than cp(1) to set up host /system for testing.
The trouble with cp is that if you're running a command directly (because
you're using gdb, say), you need to make sure you've copied the linker
and shell again if you've done a rebuild that caused a change there.

Change-Id: I312da30c0f92b515967e854e0faba272c961ecc7
2014-10-08 14:56:27 -07:00
Elliott Hughes
1364101067 Merge "Fix compile-time tests for LP64." 2014-10-08 20:31:10 +00:00
Elliott Hughes
b4b15c63a1 Fix compile-time tests for LP64.
Change-Id: Ib9bec5c6c77c55679d64c2bc15ab70979c40e66c
2014-10-08 13:21:29 -07:00
Dan Albert
5cc5c5ea0b Merge "Add basic compile time tests for sn?printf." 2014-10-08 20:04:27 +00:00
Dan Albert
2fbb1b653e Add basic compile time tests for sn?printf.
Bug: 17782583
Change-Id: I6443537c643d1cc6b4a8f2dab5c364f2fbc1faa3
2014-10-08 13:02:53 -07:00
Elliott Hughes
5a3ca37458 Merge "Revert "Work around a bug in Immersion's libImmEmulatorJ.so."" 2014-10-08 16:40:58 +00:00
Dan Albert
c9e4f2de0a Merge "Inline helpers need to be exported unmangled." 2014-10-08 00:01:08 +00:00
Dan Albert
658727e111 Inline helpers need to be exported unmangled.
__open_2() is used by the fortify implementation of open(2) in
fcntl.h, and as such needs an unmangled C name. For some reason
(inlining?), this doesn't cause problems at the default optimization
level, but does for -O0.

The rest of these didn't cause build failures, but they look suspect
and probably will, we just haven't caught them yet.

Bug: 17784968
Change-Id: I7391a7a8999ee204eaf6abd14a3d5373ea419d5b
2014-10-07 16:46:47 -07:00
Elliott Hughes
3d773274ad Revert "Work around a bug in Immersion's libImmEmulatorJ.so."
This reverts commit 7d3f553f98.

Change-Id: I8909b6aa1d97e9a61dbe95a2d91b9fbe336b58f0
2014-10-07 23:31:06 +00:00
Elliott Hughes
e8d9057e30 Merge "Work around a bug in Immersion's libImmEmulatorJ.so." 2014-10-07 23:08:12 +00:00
Elliott Hughes
7d3f553f98 Work around a bug in Immersion's libImmEmulatorJ.so.
This library calls pthread_mutex_lock and pthread_mutex_unlock with a NULL
pthread_mutex_t*. This gives them (and their users) one release to fix things.

Bug: 17443936
Change-Id: I3b63c9a3dd63db0833f21073e323b3236a13b47a
2014-10-07 16:02:11 -07:00
Dan Albert
eeb9aa02b7 Merge "Use snprintf instead of sprintf." 2014-10-07 18:38:11 +00:00
Dan Albert
b0fd55608e Use snprintf instead of sprintf.
At -O0, the attribute warning on sprintf is actually triggered (why
doesn't this happen with -Os?!) and promoted to an error by -Werror.
asctime64_r() is a non-standard function, but the IBM docs state that
the buffer is assumed to be at least 26 characters wide, and the
format string does limit to that (assuming a 4 digit year, also
defined by the IBM docs).

http://www-01.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.bpxbd00/asctimer.htm

Change-Id: I1c884474a769aa16c53e985c3d8d694c478c1189
2014-10-07 11:28:47 -07:00
Dmitriy Ivanov
6d2dd6a740 Merge "Fix 2nd arch prefix application" 2014-10-07 17:04:24 +00:00
Dmitriy Ivanov
75d66dd9a7 Fix 2nd arch prefix application
Bug: 17887283
Change-Id: I7b3b2332212fe416d6b5f5c2e5c1e07605ba09aa
2014-10-07 09:46:46 -07:00
Christopher Ferris
81fca35672 Merge "Force export symbols on all x86 variants in libc." 2014-10-06 23:45:03 +00:00
Christopher Ferris
6869d26ad9 Force export symbols on all x86 variants in libc.
For silvermont, the __popcountsi2 symbol does not get exported by libc.
But for atom, this symbol is exported. Since we already exported this symbol
for previous releases, it's better to just follow through and force
the export, but only for 32 bit. x86 64 bit will not export this symbol.

Bug: 17681440

(cherry picked from commit d11eac3455)

Change-Id: I93704c721d98d569922f606f214069bda24872ba
2014-10-06 16:41:46 -07:00
Nick Kralevich
b5cba6081b Merge "cdefs.h: add artificial attribute to FORTIFY_SOURCE functions" 2014-10-06 23:21:04 +00:00
Nick Kralevich
1aaa17802c cdefs.h: add artificial attribute to FORTIFY_SOURCE functions
Otherwise the gcc compiler warning doesn't show up.

Add -Wno-error to fortify related tests. Fortify related tests
are expected to be examples of bad programs, and in many
cases shouldn't compile cleanly. Rewriting them to compile
cleanly isn't feasible nor desirable.

Bug: 17784968
Change-Id: I93bececa7444d965f18c7c27d46e7abce5c49a02
2014-10-06 15:11:52 -07:00
Dan Albert
9969fecad2 Merge "Add compile time test infrastructure for bionic." 2014-10-06 19:45:32 +00:00
Dmitriy Ivanov
f4320e867c Merge "Resolve "unused DT entry" warnings for x86_64" 2014-10-06 19:07:58 +00:00
Dan Albert
f04a8bc226 Add compile time test infrastructure for bionic.
Actual tests to follow...

Bug: 17782583
Change-Id: I22857f19899c3b39dbc2e5473ad3be1a8a291139
2014-10-06 11:38:01 -07:00
Dmitriy Ivanov
513e29e16f Resolve "unused DT entry" warnings for x86_64
Change-Id: I3a2c87bf6e6259313cd9203389623f13b7405ef3
2014-10-06 11:32:19 -07:00
Dmitriy Ivanov
6d569b9201 Merge "Add file_offset parameter to android_extinfo" 2014-10-06 17:19:39 +00:00
Dmitriy Ivanov
07e5bc152d Add file_offset parameter to android_extinfo
Bug: 17762003
Change-Id: I8fb267a3155acef3dba534038cf5d1ef00d7154b
2014-10-06 10:02:34 -07:00
Nick Kralevich
a6eef3be10 Merge "Revert "cdefs.h: add artificial attribute to FORTIFY_SOURCE functions"" 2014-10-06 00:40:07 +00:00
Nick Kralevich
884a3de60f Revert "cdefs.h: add artificial attribute to FORTIFY_SOURCE functions"
Broke the build.

In file included from frameworks/rs/cpu_ref/rsCpuCore.cpp:36:
system/core/include/cutils/properties.h:118:1: error: unknown attribute '__artificial__' ignored [-Werror,-Wunknown-attributes]
__BIONIC_FORTIFY_INLINE
^
bionic/libc/include/sys/cdefs.h:537:110: note: expanded from macro '__BIONIC_FORTIFY_INLINE'
#define __BIONIC_FORTIFY_INLINE extern __inline__ __always_inline __attribute__((gnu_inline)) __attribute__((__artificial__))
                                                                                                             ^
1 error generated.
make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libRSCpuRef_intermediates/rsCpuCore.o] Error 1
This reverts commit 9b543ffeac.

Change-Id: I6a1198747505dcb402b722887c1bfbc3a628a8b8
2014-10-06 00:39:47 +00:00
Nick Kralevich
558ec8103b Merge "cdefs.h: add artificial attribute to FORTIFY_SOURCE functions" 2014-10-06 00:10:48 +00:00
Nick Kralevich
db6fea86a5 Merge "further cleanup memcpy fortify implementation" 2014-10-05 16:43:24 +00:00
Nick Kralevich
b84f667e93 further cleanup memcpy fortify implementation
Change-Id: I0380f3c8ca8f9bb8a206accd839c32c9daf13c56
2014-10-05 06:52:24 -07:00
Nick Kralevich
9b543ffeac cdefs.h: add artificial attribute to FORTIFY_SOURCE functions
Otherwise the gcc compiler warning doesn't show up.

Delete some unittests. These unittests no longer compile cleanly
using -Wall -Werror, and rewriting them to compile cleanly
isn't feasible.

Bug: 17784968
Change-Id: I9bbdc7b6a1c2ac75754f5d0f90782e0dfae66721
2014-10-04 22:01:41 -07:00
Nick Kralevich
ae97a776ea Merge "string.h: remove unused variable" 2014-10-04 22:38:09 +00:00
Nick Kralevich
48be71d02b string.h: remove unused variable
Change-Id: I08b7dab1b374ad427fcbee4183f2c7d93d0199a9
2014-10-04 15:20:00 -07:00
Elliott Hughes
4ef0e59f33 Merge "Reimplement clock(3) using clock_gettime(3)" 2014-10-04 01:57:42 +00:00
Alex Van Brunt
8d0b2dbf21 Reimplement clock(3) using clock_gettime(3)
Unlike times(), clock_gettime() is implemented as a vDSO on many architectures.
So, using clock_gettime() will return a more accurate time and do so with less
overhead because it does have the overhead of calling into the kernel.

It is also significantly more accurate because it measures the actual time in
nanoseconds rather than the number of ticks (typically 1 millisecond or more).

Bug: 17814435
Change-Id: Id4945d9f387330518f78669809639952e9227ed9
2014-10-03 18:54:28 -07:00
Dmitriy Ivanov
d5df4124bb Merge "Add RTLD_NODELETE flag support" 2014-10-02 21:47:29 +00:00
Hans Boehm
2d111d9eb1 Merge "Make memory_order_acquire visible in global namespace" 2014-10-01 19:16:50 +00:00
Christopher Ferris
b19bd93f8b Merge "Add stpcpy assembler version." 2014-10-01 18:16:14 +00:00
Dmitriy Ivanov
1b20dafdbe Add RTLD_NODELETE flag support
Bug: https://code.google.com/p/android/issues/detail?id=64069
Change-Id: Ie5f90482feae86391172be4b32d6cb7d76f446fb
2014-10-01 11:09:37 -07:00
Elliott Hughes
cadccfd708 Merge "Update bionic to tzdata 2014h." 2014-10-01 17:20:34 +00:00
Elliott Hughes
89fd32362b Merge "Fix update-tzdata.py to rebuild icu4c .dat file." 2014-10-01 17:00:23 +00:00
Christopher Ferris
7d849ac378 Add stpcpy assembler version.
For generic, continue to use the C version of the code.

Bug: 13746695
Change-Id: I77426a70b06131f2373bb51265bea1240bb3f101
2014-09-30 19:23:26 -07:00
Hans Boehm
76ac4d0853 Make memory_order_acquire visible in global namespace
We were missing that using directive when including <atomic>.

Bug:17736764
Change-Id: Ie8ca92a952749415567bcd5fa21d56629a364660
2014-09-30 18:35:04 -07:00
Dan Albert
81156d93c5 Merge "Add coverage flag for libm." 2014-10-01 01:28:25 +00:00
Elliott Hughes
0c8fb51e6b Update bionic to tzdata 2014h.
From the release notes:

  Changes affecting past time stamps

    America/Jamaica's 1974 spring-forward transition was Jan. 6, not Apr. 28.

    Shanks says Asia/Novokuznetsk switched from LMT (not "NMT") on 1924-05-01,
    not 1920-01-06.  The old entry was based on a misinterpretation of Shanks.

    Some more zones have been turned into links, when they differed
    from existing zones only for older time stamps.  As usual,
    these changes affect UTC offsets in pre-1970 time stamps only.
    Their old contents have been moved to the 'backzone' file.
    The affected zones are: Africa/Blantyre, Africa/Bujumbura,
    Africa/Gaborone, Africa/Harare, Africa/Kigali, Africa/Lubumbashi,
    Africa/Lusaka, Africa/Maseru, and Africa/Mbabane.

Bug: 17731498
Change-Id: If65b740d4e3a67075cca770655a1df17952c3da0
2014-09-30 17:35:38 -07:00
Elliott Hughes
f8896c6c93 Fix update-tzdata.py to rebuild icu4c .dat file.
Bug: 17731498
Change-Id: I4c810507c0ca9883dde1bece14530db80485b8f6
2014-09-30 17:30:01 -07:00
Dan Albert
12e3f22c7c Add coverage flag for libm.
Change-Id: I195d38c5e1f50d1cc6d4353dc8857f11b803b7a3
2014-09-30 16:56:43 -07:00
Elliott Hughes
252c1ac973 Merge "Update our FreeBSD realpath(3) to upstream head." 2014-09-30 23:55:57 +00:00
Dmitriy Ivanov
701cf9419b Merge "Fix mips build" 2014-09-30 23:42:24 +00:00
Dan Albert
e04aa450c2 Merge "Clean up the pthread key tests." 2014-09-30 23:41:06 +00:00
Elliott Hughes
31e072fc9b Update our FreeBSD realpath(3) to upstream head.
Change-Id: I8c89728184ecd2c1a28a05cefa84a5037d28b552
2014-09-30 16:40:41 -07:00
Dmitriy Ivanov
ecf532fa1c Fix mips build
Change-Id: I4454e69a982f239b168678c5a681d1078b4bd4f1
2014-09-30 16:30:22 -07:00
Dan Albert
c4bcc75f09 Clean up the pthread key tests.
The previous pthread_key_create_many test was really
pthread_key_create_all, which has proven very difficult to test
correctly (because it is affected by any other parts of the system using
pthread keys, and that can vary with test ordering). It also tested
expected values of PTHREAD_KEYS_MAX and the associated sysconf() value,
rather than those being in their own test.

Instead, split this test into a few distinct tests:

 * pthread.pthread_keys_max
 * pthread._SC_THREAD_KEYS_MAX_big_enough_for_POSIX
 * pthread.pthread_key_many_distinct
     * We actually didn't have a test to ensure that the keys we were
       creating were distinct.
 * pthread.pthread_key_EAGAIN
     * Make sure pthread_key_create() will _eventually_ fail with
       EAGAIN, not at a (sometimes incorrectly) predetermined maximum.

Change-Id: Iff1e4fdcc02404094bde0418122c64c227cf1702
2014-09-30 15:40:14 -07:00
Dmitriy Ivanov
1f7d5ac538 Merge "Fix unused DT entry warnings." 2014-09-30 22:14:33 +00:00
Dmitriy Ivanov
6cdeb5234d Fix unused DT entry warnings.
DT_STRSZ Implement strtab boundary checks
 DT_FLAGS_1 Warn if flags other than DF_1_NOW|DF_1_GLOBAL are set

Bug: 17552334
Change-Id: Iaad29cd52f5b2d7d2f785fb351697906dc1617d9
2014-09-30 14:41:29 -07:00
Dan Albert
0481471b1b Merge "Switch benchmarks and tests to libc++." 2014-09-30 17:30:57 +00:00
Dan Albert
e49491ada4 Merge "Ignore multiple symbol definition errors." 2014-09-30 17:30:52 +00:00
Dan Albert
3a5aeba4bd Switch benchmarks and tests to libc++.
Change-Id: I3b9c8f8c14a1e227e67ae1977cc29b0e8fccef5d
2014-09-30 10:28:30 -07:00
Dan Albert
d9898c5b82 Ignore multiple symbol definition errors.
libc and libc++ both define std::nothrow. libc's is a private symbol,
but this still causes issues when linking libc.a and libc++.a, since
private isn't effective until it has been linked. To fix this, just
allow multiple symbol definitions for the static tests.

Change-Id: Idbf19fefda47298c39360e3f5b6242b0b1a52fcc
2014-09-30 10:28:30 -07:00
Dmitriy Ivanov
9997daa0ff Merge "Return has_DT_SYMBOLIC flag." 2014-09-30 16:40:27 +00:00
Andrew Hsieh
b104be321f Merge "Remove arch-mips64/bionic/__get_sp.S" 2014-09-30 00:01:02 +00:00
Andrew Hsieh
b0c0037370 Remove arch-mips64/bionic/__get_sp.S
__get_sp.S doesn't exist

Change-Id: Id84f8904c8022c683263a317a18fabeb50fed992
2014-09-30 07:55:32 +08:00
Christopher Ferris
85a932c0c9 Merge "Cleanup arm assembly." 2014-09-29 23:12:39 +00:00
Christopher Ferris
c8bd2abab2 Cleanup arm assembly.
Remove the old arm directives.
Change the non-local labels to .L labels.
Add cfi directives to strcpy.S.

Change-Id: I9bafee1ffe5d85c92d07cfa8a85338cef9759562
2014-09-29 15:53:10 -07:00
Dmitriy Ivanov
96bc37f2e1 Return has_DT_SYMBOLIC flag.
This reverts commit 8f61d99183

 Despite the fact that static linker does all the work while linking
 -Bsymbolic executables, according to the SCO doc following DT_SYMBOLIC
 and DF_SYMBOLIC flags is still a requirement for the dynamic linker
 as well.

 (see http://www.sco.com/developers/gabi/2012-12-31/ch5.dynamic.html)

Change-Id: I23f6a5e9b662e40cdbc462b64feff912431e800c
2014-09-29 12:10:36 -07:00
Dan Albert
73e6c9b393 Merge "Static libc++ is being renamed libc++_static." 2014-09-29 16:08:35 +00:00
Dan Albert
188d093993 Static libc++ is being renamed libc++_static.
Change-Id: I1596110e4ed7e8f9ab9e2605dfcd9fd0489ca0d1
2014-09-27 09:22:07 -07:00
Dan Albert
7ca5c4b99b Merge "Make __aeabi_*() symbols weak." 2014-09-27 00:19:14 +00:00
Dan Albert
98ab0c52f5 Merge "Add a dummy libdl.a." 2014-09-27 00:19:05 +00:00
Elliott Hughes
d644fecc8e Merge "Fix gdb could not get shared library list issue" 2014-09-26 23:01:00 +00:00
Ningsheng Jian
e93be99da0 Fix gdb could not get shared library list issue
Get dynamic flags from phdr table's correct entry rather the first
entry, so that the following DT_DEBUG entry can be set.

Also fix the undefined reference to LoadTask::deleter issue under gcc
-O0 option.

Bug: 17524778
Change-Id: I9c679af197b034761fb739d6c980e628ff2ab84c
2014-09-26 22:58:57 +00:00
Dan Albert
690211fcf8 Make __aeabi_*() symbols weak.
This is needed to avoid multiple symbol definitions when linking with
libstdc++ or with compiler-rt.

Change-Id: I2f713bcff113222f0d2538e49691e715d8a8475d
2014-09-26 15:36:14 -07:00
Dan Albert
a4ed64d4c3 Add a dummy libdl.a.
Change-Id: I4b30b8875f14352bae2948ab8cf544ae818795ab
2014-09-26 15:23:07 -07:00
Christopher Ferris
aa66e88280 Merge "Add __memcpy_chk assembly for 64 bit." 2014-09-26 20:39:21 +00:00
Christopher Ferris
8cf61dab5f Add __memcpy_chk assembly for 64 bit.
Bug: 17623887
Change-Id: I443723bc941b40f84884b330d222baabee01f868
2014-09-26 12:47:04 -07:00
Dan Albert
852d4fbbe9 Merge "Prevent benchmarks from being optimized away." 2014-09-25 22:52:53 +00:00
Dan Albert
055a59c3ed Prevent benchmarks from being optimized away.
Change-Id: I2d27b39ecdfc50e78098314567c295a2f113f8d3
2014-09-25 15:43:48 -07:00
Elliott Hughes
17e7d3208c Merge "Re-expose more stdio implementation details for LP32." 2014-09-25 03:08:23 +00:00
Elliott Hughes
abefc93ff3 Re-expose more stdio implementation details for LP32.
Keeps a variety of apps running.

(cherry-pick of 5def2f5aecd968e4022b0afbe4441fa7ba3e7c7e.)

Bug: 17047819
Change-Id: I55882ec95f2b59a5df76e5a89c23aa315609e01d
2014-09-24 20:07:10 -07:00
Christopher Ferris
a864e72b56 Merge "Fix sys_stat.mkfifo when not run as root." 2014-09-24 23:56:06 +00:00
Christopher Ferris
528ad742c6 Fix sys_stat.mkfifo when not run as root.
It's not allowed for a shell user to create a fifo in /data/local/tmp.
Make the test do nothing if not run as root.

Bug: 17646702

(cherry picked from commit 6c69afdb6d)

Change-Id: Ia3a862ed4586413b7bb393557ab57e0a7141d888
2014-09-24 16:50:30 -07:00
Elliott Hughes
567d3fcb7e Merge "Switch to OpenBSD fopen/fclose." 2014-09-24 20:24:48 +00:00
Elliott Hughes
4fcfd3a474 Merge "Sync with current upstream getopt_long.c." 2014-09-24 20:24:19 +00:00
Elliott Hughes
af12924f67 Sync with current upstream getopt_long.c.
Change-Id: I269195aa581a688fd3eb99552d506b8f5f6a8395
2014-09-24 12:39:34 -07:00
Elliott Hughes
5a69da8d7a Switch to OpenBSD fopen/fclose.
This means all our stdio implementation is now the OpenBSD implementation.
The only thing we lose is the STDIO_THREAD_LOCK calls but they were no-ops
anyway.

We should probably talk to upstream about this. Either fix the locking or,
preferably, encourage them to move away from this pooling (especially since
there's no eviction policy).

Bug: 17154680
Change-Id: Ie2523e444a7d0965b8d141d57e3e11f6432d5b9a
2014-09-24 11:14:36 -07:00
Elliott Hughes
f05410edc6 Merge "Sync with upstream findfp.c." 2014-09-24 17:48:59 +00:00
Elliott Hughes
c08c25b4c9 Sync with upstream findfp.c.
Change-Id: Ib298f46de0c4d0fd4ce0a9b456c163e8b8b06342
2014-09-24 10:32:30 -07:00
Dan Albert
21db6ff108 Merge "Coverage configs for bionic." 2014-09-24 17:28:04 +00:00
Dan Albert
4a6e71100e Merge "Add a dummy atexit(3) to the linker." 2014-09-24 17:27:38 +00:00
Dan Albert
c2d39088d8 Coverage configs for bionic.
Bug: 17553780
Change-Id: Iee7d0c210e2379e71e0c1e4e7058bce23f61e8cd
2014-09-24 10:26:41 -07:00
Dan Albert
9a05e3818a Add a dummy atexit(3) to the linker.
This is needed when building the linker against a libc that was built
with coverage information.

Bug: 17553780
Change-Id: If131002e067dd7768fc657c30e62c42a45c05ace
2014-09-24 10:26:41 -07:00
Dan Albert
fc5a93f7a2 Merge "Fix incorrect parameter types for locale funcs." 2014-09-24 16:00:07 +00:00
Elliott Hughes
ebf37e3886 Merge "Switch to OpenBSD flags.c." 2014-09-24 04:50:45 +00:00
Christopher Ferris
04643c181c Merge "Remove the unnecessary generic-neon code." 2014-09-24 04:01:23 +00:00
Elliott Hughes
a71b4c3f14 Switch to OpenBSD flags.c.
Change-Id: I0a35e5bd9f8edba27e0c73e5c8150636346d6a81
2014-09-23 20:02:42 -07:00
Elliott Hughes
c57e5c8289 Merge "CLOEXEC support in fdopen, freopen, and mkostemp/mkostemps." 2014-09-24 01:49:06 +00:00
Christopher Ferris
2169e17482 Remove the unnecessary generic-neon code.
Change-Id: Ib75c33caafd76750ec1aca3a74dec5e4b881e965
2014-09-23 18:31:45 -07:00
Elliott Hughes
31165edf57 CLOEXEC support in fdopen, freopen, and mkostemp/mkostemps.
Change-Id: I74ea88e0d4973d6ab3c57da7d8bb643c31592b14
2014-09-23 18:21:52 -07:00
Dan Albert
3c5037f1b3 Fix incorrect parameter types for locale funcs.
strtoll(3), strtoull(3), wcstoll(3), and wcstoull(3) all take an _int_
as a base, not a size_t. This is an ABI compatibility issue.

Bug: 17628622
Change-Id: I17f8eead34ce2112005899fc30162067573023ec
2014-09-23 15:32:24 -07:00
Elliott Hughes
87b6906f6e Merge "Pull in upstream fixes to reject invalid bases." 2014-09-23 21:59:15 +00: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
8642165344 Merge "Sync with some upstream OpenBSD #include cleanup." 2014-09-23 21:27:29 +00:00
Elliott Hughes
0ab5fd9a5a Merge "Switch to OpenBSD insque/remque/killpg." 2014-09-23 21:26:27 +00:00
Elliott Hughes
49eed7db79 Switch to OpenBSD insque/remque/killpg.
Change-Id: Ie02290ad3187b1c1596dd776fd1c8a743a55f7ef
2014-09-23 14:06:56 -07:00
Elliott Hughes
08dc9d83a2 Sync with some upstream OpenBSD #include cleanup.
Change-Id: Ibcd7adb19e9a6b9ad8c24d77e23935f19f56a144
2014-09-23 13:55:15 -07:00
Elliott Hughes
93951cfa96 Merge "Fix a couple more cases of missing CLOEXEC." 2014-09-23 01:19:52 +00:00
Elliott Hughes
0dc39f9952 Fix a couple more cases of missing CLOEXEC.
The debuggerd case can probably never happen, because you're crashing at this
point anyway. The system property one seems possible though.

Change-Id: Idba6a4f1d68587ec5b320d1e25f0b6a987ea32a0
2014-09-22 17:43:09 -07:00
Elliott Hughes
e8a95624b6 Merge "Test pthread_cleanup_push(3)/pthread_cleanup_pop(3)." 2014-09-22 23:28:32 +00: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
b2da456253 Merge "Clean up fpathconf(3)/pathconf(3)." 2014-09-22 22:50:11 +00:00
Elliott Hughes
a186b2e0ca Clean up fpathconf(3)/pathconf(3).
fpathconf(3) and pathconf(3) can share code. There's no such
header file as <pathconf.h>. glibc/POSIX and BSD disagree about where
the _POSIX_* definitions should go.

Change-Id: I4a67f1595c9f5fbb26700a131178eedebd6bf712
2014-09-22 22:49:40 +00: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
9f423c554a Merge "Use the uapi fs magic in <sys/vfs.h>." 2014-09-22 16:51:07 +00:00
Elliott Hughes
c296e4f151 Use the uapi fs magic in <sys/vfs.h>.
Change-Id: I712b856a6d786bba400c9a8d08f596b826403731
2014-09-22 09:47:21 -07:00
Elliott Hughes
413de5b0d4 Merge "Add semaphore tests, fix sem_destroy." 2014-09-20 01:34:11 +00: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
Christopher Ferris
e716044918 Merge "Remove references to MALLOC_LEAK_CHECK." 2014-09-20 00:29:09 +00:00
Christopher Ferris
6fe376d392 Remove references to MALLOC_LEAK_CHECK.
This define isn't really used any more.

Bug: 17378595
Change-Id: I39722b83cd98955a3a2514577de34a239524617f
2014-09-19 17:15:12 -07:00
Elliott Hughes
adc01348ee Merge "Add greg_t for arm64." 2014-09-19 18:01:23 +00:00
Elliott Hughes
8e4d371091 Add greg_t for arm64.
This was already present for the other architectures. I think we skipped
this because glibc seems to have an incorrect definition (int rather than
long), but the kernel has the sane definition (just not in a uapi header).

Change-Id: I0d47a424b505804389853dd8632693dad55a3907
2014-09-19 10:31:49 -07:00
Dan Albert
13d6023aac Merge "Exclude libstdc++ from linked libraries." 2014-09-18 23:43:24 +00:00
Christopher Ferris
d5e1c583a6 Merge "Move to v3.16.3 kernel headers." 2014-09-18 21:34:43 +00:00
Elliott Hughes
fb8d60f743 Merge "Fix lgamma_r/lgammaf_r/lgammal_r for -0." 2014-09-18 21:28:35 +00:00
Christopher Ferris
653676dde8 Move to v3.16.3 kernel headers.
Change-Id: Ife491bd7630b853a78532dd74e4644438256a3a1
2014-09-18 13:14:58 -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
6ced005123 Merge "Stack unwinding unit tests." 2014-09-18 15:49:30 +00:00
Elliott Hughes
bee1993a14 Stack unwinding unit tests.
Bug: 17436734
Change-Id: I1e98da7eaeab646b448fb3f2b683973dddc319b0
2014-09-17 19:52:14 -07:00
Christopher Ferris
0bd28a43da Merge "Update kernel uapi headers to v3.16.1." 2014-09-18 00:18:46 +00:00
Christopher Ferris
ba8d4f460b Update kernel uapi headers to v3.16.1.
Other changes to support the new headers:

- Remove the flock64 structure it is defined in the new headers.
- Update the syscalls to correspond with the headers.

Change-Id: I49a6b07e8b2bfffb67be71b07b58e4e6848fcc09
2014-09-17 17:05:17 -07:00
Dmitriy Ivanov
6a310f4ad6 Merge "Temporary disable DL_WARNs for unused DT_*" 2014-09-17 23:56:45 +00:00
Dmitriy Ivanov
1b77423eff Temporary disable DL_WARNs for unused DT_*
Bug: 17552334
Change-Id: I2f7b5e4b4d1db96e812a7f86adc929e113d4c11a
2014-09-17 16:46:40 -07:00
Dmitriy Ivanov
77784cb9b7 Merge "Add Android*.mk files to additional dependencies" 2014-09-17 23:01:49 +00:00
Dmitriy Ivanov
bf50e2645d Add Android*.mk files to additional dependencies
Bug: 17548097
Change-Id: Ie0d9c8f33459320008f561217c54eba42d283b47
2014-09-17 15:55:01 -07:00
Elliott Hughes
03fef1f511 Merge "Fix some 32-bit-isms in <stdio.h>." 2014-09-17 22:22:32 +00:00
Elliott Hughes
2ad11a96a1 Fix some 32-bit-isms in <stdio.h>.
(cherry-pick of 2d80400a9e8454038a3ec29959436184be0c4c65.)

Bug: 17157793
Change-Id: I8290e240b92e5617f4c12c0eacad6e622e677b6a
2014-09-17 15:21:10 -07:00
Elliott Hughes
2f5cf100a8 Merge "Pull input.h from v3.16.1 kernel headers." 2014-09-17 22:18:48 +00:00
Christopher Ferris
e2d86feb7b Pull input.h from v3.16.1 kernel headers.
(cherry-pick of 027d2717d067c3706f22bf84dc1226ede7c1566d.)

Bug: 17407564
Change-Id: Idcfc40a7254605280e3d5474c61ae1ab7b2b7b51
2014-09-17 15:18:21 -07:00
Dan Albert
3ec67de051 Exclude libstdc++ from linked libraries.
Also explicitly add libstdc++ includes for necessary targets.

Change-Id: If712ba0ae7908d8147a69e29da5c453a183d6540
2014-09-17 14:22:36 -07:00
Elliott Hughes
36a5aa057c Merge "Use the kernel's sa_restorer for aarch64." 2014-09-17 17:04:40 +00:00
Elliott Hughes
56433ee2a2 Merge "Clean up the architecture-specific makefiles." 2014-09-17 16:36:47 +00:00
Dmitriy Ivanov
e7c9a387fa Merge "Fix 64bit build" 2014-09-17 06:36:19 +00:00
Dmitriy Ivanov
f240aa8089 Fix 64bit build
Change-Id: I6ef55b5951270c46ee5e9a11385bd09e33a9f969
2014-09-16 23:34:20 -07:00
Dmitriy Ivanov
34ac60ca16 Merge "Fix some unused DT_ warnings" 2014-09-17 05:28:30 +00:00
Elliott Hughes
7c02d9428c Clean up the architecture-specific makefiles.
Group things appropriately and name each group.

Change-Id: I0da45eb0ccde19c31d5e984d0e6eb3dad26630dc
2014-09-16 19:06:31 -07:00
Dmitriy Ivanov
4a6e9a835a Fix some unused DT_ warnings
* DT_PLTGOT - ignored for non-mips
 * DT_RELCOUNT/RELACOUNT - ignored
 * DT_RELENT/RELAENT - sanity checks
 * DT_SYMENT - sanity check
 * DT_SONAME - ignore for now.

Change-Id: Ied90748d12f733a84f6c38a1250567a2f77608b7
2014-09-16 18:19:36 -07:00
Elliott Hughes
17cc8e539a Merge "No arm source refers to SOFTFLOAT." 2014-09-16 23:45:40 +00:00
Elliott Hughes
b1a6c319c4 No arm source refers to SOFTFLOAT.
So why bother #defining it?

Change-Id: I539e91916cee082cacac594ddf628419b737fa9d
2014-09-16 16:27:35 -07:00
Elliott Hughes
1cff9a8964 Use the kernel's sa_restorer for aarch64.
gdb was happy with what we had, but libgcc and libunwind weren't.
libgcc is happy with the kernel's restorer (because of the extra nop),
though libunwind looks like it's going to need code changes regardless.

We could make our restorer more like the kernel's one, but why bother
when we can just let the kernel supply the canonical one?

Bug: 17436734
Change-Id: I330fa5e68f23b1cf8133aa552896657b0b873ed3
2014-09-16 15:49:50 -07:00
Dmitriy Ivanov
aea393c096 Merge "Remove has_DT_SYMBOLIC flag" 2014-09-16 22:37:37 +00:00
Dmitriy Ivanov
8f61d99183 Remove has_DT_SYMBOLIC flag
From the elf-spec: "Symbolically bound shared objects are
  identified by the .dynamic entry DT_SYMBOLIC. This tag is
  informational only; the runtime linker processes symbol
  lookups from these objects in the same manner as any
  other object."

Change-Id: I4aae0e502ed9fac096fbf076f4d6b2e055d784f6
2014-09-16 15:26:47 -07:00
Elliott Hughes
380a3be757 Merge "Fix 32-bit arm unwinding through signal frames." 2014-09-16 21:17:20 +00:00
Elliott Hughes
148dff3ec6 Fix 32-bit arm unwinding through signal frames.
gdb was already okay; libgcc and libunwind need a little extra help.

Bug: 17436734
Change-Id: I1f5108f9877373be078554a1ea4938aa4436204e
2014-09-16 14:10:53 -07:00
Calin Juravle
370704d69d Merge "Add benchmarks for pthread_rw_locks" 2014-09-16 17:31:39 +00:00
Calin Juravle
837a962bf5 Add benchmarks for pthread_rw_locks
Benchmarks for the following sequences:
1) pthread_rwlock_rdlock -> pthread_rwlock_unlock
2) pthread_rwlock_wrlock -> pthread_rwlock_unlock

Change-Id: I8d87d4d8afab8637ea7ff5d23a0b3a81d6d40835
2014-09-16 18:02:30 +01:00
Elliott Hughes
5cba3c6f8e Merge "Fix signal trampolines." 2014-09-16 15:19:06 +00:00
Dmitriy Ivanov
2997ae83d5 Merge "Fix dlsym() to take into account RTLD_GLOBAL/LOCAL" 2014-09-16 01:27:56 +00: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
0b8f6d592a Merge "Add dlfcn_test to glibc test suite." 2014-09-15 22:12:06 +00:00
Elliott Hughes
36f451a6d9 Fix signal trampolines.
* LP32 should use sa_restorer too. gdb expects this, and future (>= 3.15) x86
  kernels will apparently stop supporting the case where SA_RESTORER isn't
  set.

* gdb and libunwind care about the exact instruction sequences, so we need to
  modify the code slightly in a few cases to match what they're looking for.

* gdb also cares about the exact function names (for some architectures),
  so we need to use __restore and __restore_rt rather than __sigreturn and
  __rt_sigreturn.

* It's possible that we don't have a VDSO; dl_iterate_phdr shouldn't assume
  that getauxval(AT_SYSINFO_EHDR) will return a non-null pointer.

This fixes unwinding through a signal handler in gdb for all architectures.
It doesn't fix libunwind for arm and arm64. I'll keep investigating that...

Bug: 17436734
Change-Id: Ic1ea1184db6655c5d96180dc07bcc09628e647cb
2014-09-15 15:04:14 -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
95b0c6a940 Merge "POSIX says <signal.h> gets you ucontext_t." 2014-09-15 17:17:37 +00:00
Dan Albert
2c58104718 Merge "Fix filename in comment in cmath" 2014-09-14 19:33:44 +00:00
m4tx
2214a1ce17 Fix filename in comment in cmath
It looks like the file comment was copy-pasted from ctime. Fixed filename in comment to "math.h".

Change-Id: I27b0c2a7827076a91fc7b63913fad6eee4d6a79e
Signed-off-by: m4tx <m4tx@m4tx.pl>
2014-09-14 16:41:31 +02:00
Elliott Hughes
85ef3b5b80 Merge "Update NOTICE files." 2014-09-13 17:01:08 +00:00
Elliott Hughes
ae51accf22 Merge "Remove an unused file." 2014-09-13 17:00:27 +00:00
Elliott Hughes
5c2264a136 Update NOTICE files.
Change-Id: I37a2c297b318b8e1b1ce8b29a7ccc58ba214708a
2014-09-13 09:42:41 -07:00
Elliott Hughes
5681fe8eae Remove an unused file.
Also remove a reference to it and two other files that have already
been removed in a script --- these files were problematic because they
weren't UTF-8.

Change-Id: Ibf597bac1903c34d8d0fe0a09615c42f24d4f23d
2014-09-13 09:24:28 -07:00
Elliott Hughes
26a8eb50a8 POSIX says <signal.h> gets you ucontext_t.
POSIX also says that ucontext_t's uc_sigmask has type sigset_t.

MIPS64 strace needs this.

The #define is to keep chromium off our lawn; otherwise it tries to redefine
all this stuff itself. We should probably clean that up and remove the #define.

Change-Id: I765d6a765a33dca7db33cd8c40f408dc98e5c95b
2014-09-12 20:47:35 -07:00
Elliott Hughes
73d2059f9b Merge "Explain why clock(3) isn't broken." 2014-09-12 23:52:13 +00:00
Elliott Hughes
f83c208b82 Explain why clock(3) isn't broken.
Bug: 17441123
Change-Id: I6ee9b7f54bab55b1a8760ce9bcaaa6eab1dcc492
2014-09-12 16:33:37 -07:00
Elliott Hughes
21451f5bf6 Merge "Get new coshl, sinhl, and tanhl implementations from upstream." 2014-09-12 23:13:43 +00:00
Elliott Hughes
c729d4f237 Get new coshl, sinhl, and tanhl implementations from upstream.
Change-Id: I92f9cd53d12efb2e0f4f8a9590b9fe42398233f6
2014-09-12 16:09:40 -07:00
Elliott Hughes
a40a16eab1 Merge "Add a test for pthread_gettid_np." 2014-09-12 22:52:38 +00:00
Elliott Hughes
8fb639ca91 Add a test for pthread_gettid_np.
Bug: 17475191
Change-Id: I8c6a2f4ceba2d24a77ae9a21269edce523aea421
2014-09-12 14:43:07 -07:00
Elliott Hughes
69c2d7dc64 Merge "Sync libm with upstream." 2014-09-12 21:07:48 +00:00
Elliott Hughes
460ad7454a Sync libm with upstream.
Change-Id: I8ac8ee52122ee19a2e423c3211092023cb4896eb
2014-09-12 14:00:02 -07:00
Elliott Hughes
e39e47c6b3 Merge "Remove "private/bionic_pthread.h"." 2014-09-12 18:43:05 +00:00
Elliott Hughes
0f001b67fe Remove "private/bionic_pthread.h".
Bug: 17476168
Change-Id: Id642987e641de81e914a28daea4ffe9d11e090ed
2014-09-12 11:35:05 -07:00
Dmitriy Ivanov
d74aa58035 Merge "Fix unload of recursively linked library" 2014-09-12 16:55:42 +00:00
Dmitriy Ivanov
aad92067bf Merge "Reformatting" 2014-09-12 16:50:29 +00:00
Dmitriy Ivanov
66bbf1595c Merge "Refactoring: C++11 style DISABLE_ bionic marcos" 2014-09-12 16:50:05 +00:00
Dmitriy Ivanov
6abf624d12 Reformatting
No functional changes.

Change-Id: If71775e5fc207e91ebd31ba3c5f9d2c13dc8dada
2014-09-12 09:43:13 -07: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
Elliott Hughes
8d8a789c49 Merge "Expose __swsetup for LP32 binary compatibility." 2014-09-12 01:27:45 +00:00
Elliott Hughes
5f35710fad Expose __swsetup for LP32 binary compatibility.
(cherry-pick of 7e00b44e80d6e38b8ab86d0ebc86b666c0ac2ef6.)

Bug: 17476127
Change-Id: I0ef1355ac913d782c268a638f88642d6cfc236c2
2014-09-11 18:23:46 -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
5920a9ad5f Merge "Add pthread_gettid_np and re-expose __get_thread for LP32." 2014-09-11 23:25:46 +00:00
Elliott Hughes
a4831cb4a3 Add pthread_gettid_np and re-expose __get_thread for LP32.
A lot of third-party code calls the private __get_thread symbol,
often as part of a backport of bionic's pthread_rwlock implementation.
Hopefully this will go away for LP64 (since you're guaranteed the
real implementation there), but there are still APIs that take a tid
and no way to convert between a pthread_t and a tid. pthread_gettid_np
is a public API for that. To aid the transition, make __get_thread
available again for LP32.

(cherry-pick of 27efc48814b8153c55cbcd0af5d9add824816e69.)

Bug: 14079438
Change-Id: I43fabc7f1918250d31d4665ffa4ca352d0dbeac1
2014-09-11 16:22:50 -07:00
Elliott Hughes
ea66004c4a Merge "Fix mips __fadvise64.S build failure." 2014-09-11 17:12:49 +00:00
Elliott Hughes
9990b3973b Fix mips __fadvise64.S build failure.
Bug: 12449798
Change-Id: I0663b741108ba2f1d286904d6414b3ff4d475551
2014-09-11 10:10:08 -07:00
Elliott Hughes
33df10f284 Merge "Add posix_fadvise(3)." 2014-09-11 15:46:44 +00: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
Lorenzo Colitti
c71483c0b3 Merge "When comparing DNS server configs, also compare number of servers" 2014-09-09 10:22:18 +00:00
Lorenzo Colitti
bce18c9163 When comparing DNS server configs, also compare number of servers
Bug: 16070602
Change-Id: I605f1cca50b08479ebcad290b3bd179f59be8a96
2014-09-09 19:20:26 +09: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
671f96cd44 Merge "Ensure __set_errno is still visible on LP32." 2014-09-08 23:47:53 +00:00
Elliott Hughes
011e111d29 Ensure __set_errno is still visible on LP32.
The use of the .hidden directive to avoid going via the PLT for
__set_errno had the side-effect of actually making __set_errno
hidden (which is odd because assembler directives don't usually
affect symbols defined in a different file --- you can't even
create a weak reference to a symbol that's defined in a different
file).

This change switches the system call stubs over to a new always-hidden
__set_errno_internal and has a visible __set_errno on LP32 just for
binary compatibility with old NDK apps.

(cherry-pick of 7efad83d430f4d824f2aaa75edea5106f6ff8aae.)

Bug: 17423135
Change-Id: I6b6d7a05dda85f923d22e5ffd169a91e23499b7b
2014-09-08 16:46:50 -07:00
Elliott Hughes
201f36d23b Merge "Don't expose non-standard basename_r and dirname_r in LP64." 2014-09-08 23:46:04 +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
Elliott Hughes
d3d89f0d28 Merge "Add arc4random_addrandom binary compatibility." 2014-09-08 17:53:04 +00:00
Elliott Hughes
fc829736e1 Add arc4random_addrandom binary compatibility.
This was in <stdlib.h> in older releases. It's no longer used, but we can
preserve backwards compatibility by making it a no-op.

(cherry-pick of 51c8355d5cf4b83ccd2ad250ca4c61a616356c2b.)

Bug: 16205834
Change-Id: Idde7b46df4f253e39675600bcf82352879a716e7
2014-09-08 10:52:28 -07:00
Christopher Ferris
b4673c4102 Merge "Add dlmalloc_usable_size for 32 bit arches." 2014-09-06 20:17:02 +00:00
Christopher Ferris
f903558446 Add dlmalloc_usable_size for 32 bit arches.
Bug: 17337831

(cherry picked from commit 1c365cb494)

Change-Id: Ice100e42eeac4b9c3b77737a546ec33174adcb2f
2014-09-06 13:06:57 -07:00
Ying Wang
e07b4da53d Merge "Use LOCAL_POST_LINK_CMD to insert the objcopy command for linker." 2014-09-05 23:41:25 +00:00
Dmitriy Ivanov
320a01d516 Merge "Revert "Load libraries in breadth-first order"" 2014-09-05 23:36:22 +00: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
Ying Wang
f9e147b0bf Use LOCAL_POST_LINK_CMD to insert the objcopy command for linker.
Previously we duplicated code in build/core/executable.mk and it's hard
to maintain. LOCAL_POST_LINK_CMD is a clean solution for this.

Bug: 17403674
Change-Id: I8c054bf782af68cf1f88b8d787a78ca74a7968b5
2014-09-05 16:16:35 -07:00
Dmitriy Ivanov
b3ebfecdae Merge "Fix order of soinfo links (repairs libcxx tests)." 2014-09-05 23:11:19 +00:00
Dmitriy Ivanov
b2a30ee8d2 Fix order of soinfo links (repairs libcxx tests).
Change-Id: Iee9de09657351cd6a7512784ca797e4b84cdd98b
2014-09-05 16:01:47 -07:00
Chih-Hung Hsieh
8adace5f2c Merge "Enable clang compilation with libc but not linker." 2014-09-05 18:54:48 +00:00
Chih-Hung Hsieh
b58db8b083 Enable clang compilation with libc but not linker.
Clang is still disabled for x86 and x86_64 long double code,
for x86_64 special assembly instruction, and the linker module.

BUG: 17163651
BUG: 17302991
BUG: 17403674
Change-Id: I43c5f5f0ddc0c2a31918f00b57150dadd8f3f26b
2014-09-05 11:18:35 -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
aca9cae309 Merge "Fix pthread_attr_getstack__main_thread." 2014-09-04 23:20:53 +00: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
c74a7680a4 Merge "Fix mips signed/unsigned signal_test.cpp build breakage." 2014-09-04 22:48:16 +00:00
Elliott Hughes
aa13e839f0 Fix mips signed/unsigned signal_test.cpp build breakage.
Change-Id: I045ce017c0c51e1843193759a2eb6fc5b93e3867
2014-09-04 15:43:10 -07:00
Dmitriy Ivanov
44352f5f7f Merge "Revert "Register __libc_fini as early as possible."" 2014-09-04 21:55:59 +00:00
Dmitriy Ivanov
c0cd9ce5df Merge "Revert "Fix arm64 build"" 2014-09-04 21:55:55 +00:00
Dmitriy Ivanov
4b41555ba5 Revert "Register __libc_fini as early as possible."
This reverts commit e880c736d6.

Change-Id: Ide83e442eb5dbfef5298a15bc602c3fe1dda1862
2014-09-04 21:54:34 +00:00
Dmitriy Ivanov
f0d8970435 Revert "Fix arm64 build"
This reverts commit 5c1a7fdbd5.

Change-Id: Ia5fea0d6a8f59700edce0742e2271b5f02a5d87c
2014-09-04 21:53:14 +00:00
Elliott Hughes
05f0bfd6c5 Merge "Don't mask out SA_RESTORER from sa_flags." 2014-09-04 21:03:34 +00: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
Chih-Hung Hsieh
4ee7c325df Merge "Disable Clang, due to x86 LDBL_MANT_DIG errors." 2014-09-04 20:44:34 +00:00
Chih-Hung Hsieh
356a6249d8 Disable Clang, due to x86 LDBL_MANT_DIG errors.
Clang -m32 has incorrect sizeof(long double) = 12.
With -m64, LDBL_MANT_DIG is incorrect 64.

BUG: 17163651
Change-Id: I4b157aa1a8572c3a10aece6070e119a292ab8e83
2014-09-04 12:35:19 -07:00
Elliott Hughes
071bed8091 Merge "_GNU_SOURCE implies _BSD_SOURCE and the latest _POSIX_C_SOURCE." 2014-09-04 17:02:10 +00:00
Elliott Hughes
fc8974b7aa _GNU_SOURCE implies _BSD_SOURCE and the latest _POSIX_C_SOURCE.
This showed up as open_memstream not being visible in <stdio.h>
if only _GNU_SOURCE was defined.

Bug: 17361504
Change-Id: I38f9843f4e6ee770a6325ad50f779bda5495ffca
2014-09-04 08:53:16 -07:00
Dmitriy Ivanov
1737b15937 Merge "Load libraries in breadth-first order" 2014-09-04 00:59:23 +00:00
Dmitriy Ivanov
8f3b8f523e Merge "Fix arm64 build" 2014-09-03 23:36:35 +00:00
Elliott Hughes
58bb54c38b Merge "Add back a dummy arc4random_stir for compatibility." 2014-09-03 23:34:05 +00:00
Dmitriy Ivanov
5c1a7fdbd5 Fix arm64 build
Bug: 14611536
Change-Id: I4f7f4d1f5c0a37ef38fa0956778393f8d7668512
2014-09-03 16:33:08 -07:00
Elliott Hughes
5dea47221a Add back a dummy arc4random_stir for compatibility.
The current arc4random implementation stirs itself as needed, but we
need to keep an arc4random_stir symbol around for binary compatibility.

(cherry-pick of 1e010d60397db706cd3d1c4d5701a2bced441aa8.)

Bug: 17291075
Change-Id: Iaf6171c3ec65c39c1868364d5b35ea280e29a363
2014-09-03 16:30:22 -07:00
Dmitriy Ivanov
450aaa018d Merge "Register __libc_fini as early as possible." 2014-09-03 22:29:59 +00:00
Dmitriy Ivanov
e880c736d6 Register __libc_fini as early as possible.
We want __libc_fini to be called after all the destructors.

Bug: 14611536
Change-Id: Ibb83a94436795ec178fd605fa531ac29608f4a3e
2014-09-03 15:27:29 -07: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
28f1770101 Merge "Don't fail a test just because we aren't root." 2014-09-03 18:37:11 +00: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
c7de919129 Merge "Start math tests with a clean fenv." 2014-09-02 23:11:42 +00: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
847e52b9b7 Merge "Prevent a few test pthread keys from leaking." 2014-09-02 22:43:18 +00: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
Elliott Hughes
ec95a9cf11 Merge "MIPS64 syscall() arguments" 2014-09-02 20:53:31 +00:00
Chris Dearman
296895f1a9 MIPS64 syscall() arguments
The seventh argument for syscall is passed in a register, not on the stack

Change-Id: Idb69fac77d1f710cff5a3ab4ae1259feb61ae69d
2014-09-02 12:41:01 -07:00
Dmitriy Ivanov
86f594b19b Merge "Encapsulate soinfo_link_image and soinfo_relocate" 2014-09-02 19:25:09 +00:00
Dmitriy Ivanov
29bbc9dd4c Encapsulate soinfo_link_image and soinfo_relocate
Also get rid of needed[] array for these functions

Change-Id: I8d12887dbec0724309bb171e6bbd9b9ceb32cc70
2014-09-02 11:47:23 -07:00
Elliott Hughes
4625dd751e Merge "Upgrade bionic to tzdata2014g." 2014-09-02 17:57:10 +00:00
Dmitriy Ivanov
e057b9fc82 Merge "Introduce size-based r/w allocators" 2014-09-02 17:21:51 +00:00
Dmitriy Ivanov
4cafa3ce80 Merge "Implement LinkedList::visit()" 2014-09-02 16:54:14 +00:00
Elliott Hughes
9685c30a23 Upgrade bionic to tzdata2014g.
From the release notes:

  Changes affecting future time stamps

    Turks & Caicos is switching from US eastern time to UTC-4 year-round,
    modeled as a switch from EST/EDT to AST on 2014-11-02 at 02:00.

  Changes affecting past time stamps

    Time in Russia or the USSR before 1926 or so has been corrected by
    a few seconds in the following zones: Asia/Irkutsk,
    Asia/Krasnoyarsk, Asia/Omsk, Asia/Samarkand, Asia/Tbilisi,
    Asia/Vladivostok, Asia/Yakutsk, Europe/Riga, Europe/Samara.  For
    Asia/Yekaterinburg the correction is a few minutes.  (Thanks to
    Vladimir Karpinsky.)

    The Portuguese decree of 1911-05-26 took effect on 1912-01-01.
    This affects 1911 time stamps in Africa/Bissau, Africa/Luanda,
    Atlantic/Azores, and Atlantic/Madeira.  Also, Lisbon's pre-1912
    GMT offset was -0:36:45 (rounded from -0:36:44.68), not -0:36:32.
    (Thanks to Stephen Colebourne for pointing to the decree.)

    Asia/Dhaka ended DST on 2009-12-31 at 24:00, not 23:59.

    A new file 'backzone' contains data which may appeal to
    connoisseurs of old time stamps, although it is out of scope for
    the tz database, is often poorly sourced, and contains some data
    that is known to be incorrect.  The new file is not recommended
    for ordinary use and its entries are not installed by default.
    (Thanks to Lester Caine for the high-quality Jersey, Guernsey, and
    Isle of Man entries.)

    Some more zones have been turned into links, when they differed
    from existing zones only for older time stamps.  As usual,
    these changes affect UTC offsets in pre-1970 time stamps only.
    Their old contents have been moved to the 'backzone' file.
    The affected zones are: Africa/Bangui, Africa/Brazzaville,
    Africa/Douala, Africa/Kinshasa, Africa/Libreville, Africa/Luanda,
    Africa/Malabo, Africa/Niamey, and Africa/Porto-Novo.

Bug: 17277574
Change-Id: Idff4a68e927d49bef1e787af534e1b23b5b8a7fb
2014-09-02 09:51:04 -07:00
Dmitriy Ivanov
a492605849 Implement LinkedList::visit()
Change-Id: Ibd9d133dddf1f2e6e65660e3cd2dacafcc0c84d9
2014-09-02 09:45:40 -07:00
Dmitriy Ivanov
0cd83ebb0e Introduce size-based r/w allocators
Change-Id: I75165fc392e5380124039e6db49b0f559c8a518e
2014-09-01 16:17:05 -07:00
Dmitriy Ivanov
5120bcf9f1 Merge "Look into ld_preloads before current library" 2014-09-01 21:16:42 +00:00
Dmitriy Ivanov
c2048944ff Look into ld_preloads before current library
Change lookup order during relocation so that
 ld_preloads always precede caller (unless caller
 is main executable).

 Asan needs this change in order to intercept libc->libc
 calls.

Bug: 15432753
(cherry picked from commit 05e190c093)

Change-Id: I5bfb58e18015b1ec5b77842dbb37fb122fa1fd1a
2014-09-01 14:14:09 -07:00
Dmitriy Ivanov
11387985d2 Merge "Erase elements in LinkedList::remove_if" 2014-09-01 21:06:32 +00:00
Hans Boehm
e505cc66a6 Merge "Make stdatomic.h work with gcc4.6 host compiler" 2014-08-30 00:49:51 +00:00
Dmitriy Ivanov
4bea498544 Erase elements in LinkedList::remove_if
Change-Id: I5119a78c73ffe780a81c53ab5ff0266d5c82d319
2014-08-29 17:09:24 -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
bbe06e0da1 Merge "Use __GNUC_PREREQ rather than __GNUC_PREREQ__ to match glibc." 2014-08-29 23:08:01 +00:00
Elliott Hughes
e0c56efddf Use __GNUC_PREREQ rather than __GNUC_PREREQ__ to match glibc.
Bug: 16874785
Change-Id: I8512f8be3fd149d8720c5c3b4657bedd5ce2b1d1
2014-08-29 15:54:11 -07:00
Dmitriy Ivanov
83b637fa28 Merge "Replace NULL with nullptr" 2014-08-29 22:30:07 +00:00
Dmitriy Ivanov
851135bf99 Replace NULL with nullptr
Change-Id: Iad50be617d318ca98883b843229c960ad5b9afa9
2014-08-29 14:13:48 -07:00
Elliott Hughes
1f39afc8d4 Merge "The host prebuilt glibc is 2.11, so remove workarounds for 2.9." 2014-08-29 18:12:36 +00:00
Chih-Hung Hsieh
cc4259ed92 Merge "Ignore all __weak_alias in OpenBSD libC." 2014-08-29 03:10:44 +00: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
29f06943a1 Merge "Add GNU-compatible strerror_r." 2014-08-29 02:26:34 +00: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
Chih-Hung Hsieh
b6b5cb5389 Ignore all __weak_alias in OpenBSD libC.
GCC assembler allows xyz to be redeclared as weak,
by __weak_alias(xyz, _xyz), while _xyz is undefined.
Clang does not like that but silently generates no code.
It will reject its own .s file if the assembly code is saved first.
Since we have no reason to define xyz or _xyz as weak symbol now,
and _xyz is a macro to xyz, we simplify libC to have only
xyz defined as global.

BUG: 17186746
Change-Id: I24b154425838683cae69248cc750c59e26fd5467
2014-08-28 15:10:01 -07:00
Elliott Hughes
f4e721dd51 Merge "Have pthread_attr_getstack for the main thread report RLIMIT_STACK..." 2014-08-27 23:43:27 +00:00
Christopher Ferris
af9da4a343 Merge "Replace snprintf calls in linker." 2014-08-27 23:29:18 +00:00
Chih-Hung Hsieh
fbe9d3dfeb Merge "Fix strlen function type for mips." 2014-08-27 23:09:30 +00:00
Christopher Ferris
052fa3a34c Replace snprintf calls in linker.
When enabling debug malloc, the snprintf calls in the linker fails to
update the buffer.

The problem is that snprintf makes a call to pthread_getspecific that
returns a valid pointer, but the data it points to is zero. This should
never happen and causes the snprintf to stop and do nothing.

Temporarily replace snprintf with a different implementation to work
around this issue.

Bug: 16874447
Bug: 17302493

(cherry pick from commit 172955a4e3)

Change-Id: Idca9d417978403d61debfd0434aaa82fd770f33b
2014-08-27 16:01:57 -07:00
Chih-Hung Hsieh
15b914c8f3 Fix strlen function type for mips.
Clang complains about incompatible-library-redeclaration.

BUG: 17302369
Change-Id: I3ae36f24846408c6464b84b5bddb1747e1e4a971
2014-08-27 16:00:46 -07:00
Chih-Hung Hsieh
4f8268e38f Merge "Replace ambiguous cmp instruction with cmpl." 2014-08-27 22:46:07 +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
857fa6b2a3 Replace ambiguous cmp instruction with cmpl.
Clang assembler rejects ambiguous cmp instruction.

BUG: 17302482
Change-Id: I74f49de87464541f9fe6fa288e4093a9fbf37120
2014-08-27 15:04:23 -07:00
Chih-Hung Hsieh
34da32e7dd Merge "Add missing type casts before comparison." 2014-08-27 21:44:12 +00:00
Christopher Ferris
6ecd1cd195 Merge "Use the default unwind code." 2014-08-27 21:21:28 +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
Christopher Ferris
b78e60e7b7 Use the default unwind code.
This speeds up the debug malloc code by using the original unwinding code.
The only catch is that it has to link in the libc++ arm unwind code or
there will be crashes when attempting to unwind through libc++ compiled
code.

Bug: 16874447

(cherry picked from commit 3f7635f490)

Change-Id: If8a3821cdd95ed481bb496bf2daab449d13790f8
2014-08-27 13:13:21 -07:00
Elliott Hughes
cb322a1168 Merge "call uselocale() before freelocale() to make sure that g_local_key has a valid locale." 2014-08-27 17:27:46 +00: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
Elliott Hughes
64ae11ab76 Merge "Switch to OpenBSD <err.h> implementation." 2014-08-27 17:26:03 +00:00
Elliott Hughes
cc7e5f489f Switch to OpenBSD <err.h> implementation.
Change-Id: Ia950d88871a30f68e74f9ac7dbd87788e128e02f
2014-08-26 17:00:37 -07:00
Hans Boehm
6bfcefe02f Merge "Undefine _Atomic before redefining" 2014-08-26 23:34:49 +00:00
Elliott Hughes
07401c7136 Merge "Switch to OpenBSD daemon(3)." 2014-08-26 23:33:43 +00:00
Elliott Hughes
e5055179fd Switch to OpenBSD daemon(3).
Change-Id: I1fd0be09fdb24aa6f1d945410eba5987f8a949b4
2014-08-26 16:25:19 -07:00
Elliott Hughes
f1e64b5c17 Merge "More cases where libc should use O_CLOEXEC." 2014-08-26 23:23:59 +00:00
Elliott Hughes
f73183f1a3 More cases where libc should use O_CLOEXEC.
Change-Id: Idfa111aeebc5deca2399dae919e8b72eb54c23c0
2014-08-26 16:20:59 -07:00
Elliott Hughes
7b87d441b0 Merge "Switch to OpenBSD res_random." 2014-08-26 23:18:04 +00:00
Elliott Hughes
59de803af9 Merge "libc should use O_CLOEXEC when opening files for its own use." 2014-08-26 23:11:46 +00:00
Dmitriy Ivanov
9f5dee55aa Merge "Remove unnecessary calls to LinkedList::clear()" 2014-08-26 23:00:44 +00:00
Hans Boehm
3e4a0099a1 Undefine _Atomic before redefining
Stdatomic.h was potentially redefining _Atomic, in spite of a
prior definition by <atomic>.  This could cause g++ builds that
included <stdatomic.h> with an available <atomic> header to break.

Change-Id: I562c7115118c0587d594d4d5b62d25101e47bfd8
2014-08-26 15:58:15 -07:00
Elliott Hughes
c674edbf27 libc should use O_CLOEXEC when opening files for its own use.
Change-Id: I159f1d57e0ca090d837f57854fcef5879b8b8248
2014-08-26 15:56:54 -07:00
Dmitriy Ivanov
608217e167 Remove unnecessary calls to LinkedList::clear()
Change-Id: I981d2700cb17322c634b751715543fd33ee49b7c
2014-08-26 15:56:31 -07:00
Dmitriy Ivanov
d2bd3c4717 Merge "Enable __cxa_atexit && __cxa_finalize for linker" 2014-08-26 22:53:16 +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
c764fb24cc Merge "Fix pthread_getattr_np for the main thread." 2014-08-26 19:53:40 +00: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
Chih-Hung Hsieh
9e307af982 Merge "Add standard throw() spec to delete operators." 2014-08-25 22:08:33 +00:00
Chih-Hung Hsieh
ae558d6b4b Add standard throw() spec to delete operators.
Without these specs, clang will reports mismatch between standard definitions and these declarations/definitions. These specs are ignored when compiled with -fno-exceptions.

BUG: 17136236
Change-Id: I386c712a61dc4fc74dfde45f9ec2d3d037f2e9f1
2014-08-25 21:16:14 +00: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
Dmitriy Ivanov
9d34f6a909 Merge "Bump soinfo version" 2014-08-22 20:44:56 +00:00
Dmitriy Ivanov
0d15094287 Bump soinfo version
This includes:
 1. Placing has_ifunc after fields with version = 0
 2. Switch to has_min_version(v) function.
 3. Minor soinfo initialization refactoring (placement new + ctor)

Change-Id: I1bf5fde4d930914012ce5f3ad5acb48217da9b2d
2014-08-22 13:29:18 -07:00
Dan Albert
0b9fa4c9bf Merge "Fix dlmalloc build." 2014-08-22 18:06:36 +00:00
Dan Albert
ef619cc083 Fix dlmalloc build.
Change-Id: Ied542c40867ab443cdd2076bd2e535b00c4854e4
2014-08-22 11:05:48 -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
538db6d2e6 Merge "Fix unistd.getpid_caching_and_clone." 2014-08-22 16:28:02 +00: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
Dan Albert
2e6c5fc4e9 Merge "Remove _flush_cache(2) for mips64." 2014-08-21 21:51:42 +00:00
Dmitriy Ivanov
2bd88d450e Merge "Run constructors before resolving ifunc functions" 2014-08-21 21:27:52 +00:00
Dmitriy Ivanov
9598b8c415 Run constructors before resolving ifunc functions
Bug: 17177284
Change-Id: I5714b9bc2d1ca8f8711806bfb68da3d524213e99
2014-08-21 14:24:13 -07:00
Dan Albert
47793d6a29 Remove _flush_cache(2) for mips64.
Also remove declaration.

The only user is compiler-rt, and they can replace that call with one to
syscall(2). compiler-rt doesn't currently build on mips64 anyway.

Bug: 11156955
Change-Id: Ieae0ba49c8e7aa50253401fc1d7c2d17bc867d39
2014-08-21 13:32:37 -07:00
Dan Albert
3157211849 Merge "__gnu_basename(3) is accounted for." 2014-08-21 19:14:44 +00:00
Dan Albert
2320b02c7d __gnu_basename(3) is accounted for.
Change-Id: I3836b14a797c4a8d121c6d29d95791ac768257da
2014-08-21 11:36:07 -07:00
Elliott Hughes
d5fbc37119 Merge "Add POSIX-2008 fmemopen, open_memstream, and open_wmemstream." 2014-08-21 00:17:56 +00: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
Elliott Hughes
b6ed54076a Merge "Simplify _ALIGN_TEXT." 2014-08-20 20:25:32 +00:00
Elliott Hughes
0e7f8a9e52 Simplify _ALIGN_TEXT.
Bug: 16872067
Change-Id: I2b622f252c21ce1b344c040f828ab3f4bf9b6c0a
2014-08-20 13:11:58 -07:00
Elliott Hughes
7134fc3089 Merge "Regenerate "services.h" from /etc/services." 2014-08-16 04:28:29 +00:00
Elliott Hughes
c4a1de1ae2 Regenerate "services.h" from /etc/services.
Change-Id: Iec118f9a342b5c1f6ce6d48965798b12a7159ad3
2014-08-20 12:11:31 -07:00
Elliott Hughes
3bcd414b78 Merge "Clean up some of our python scripts." 2014-08-16 04:28:29 +00:00
Elliott Hughes
dc1fb7000a Clean up some of our python scripts.
Change-Id: Ifa75345db43434298cfb6113fbe2f7a33b88c79d
2014-08-20 11:16:11 -07:00
Elliott Hughes
55244a9bdb Merge "Add <stdio_ext.h> for elfutils." 2014-08-19 02:44:29 +00:00
Elliott Hughes
2b021e1066 Add <stdio_ext.h> for elfutils.
Bug: 17139679
Change-Id: I1605ac382dbb6f23b2d874dbb9769f3cde4a6a99
2014-08-20 10:23:52 -07:00
Hans Boehm
b61c50647b Merge "Work around atomic_load(const T*) issues." 2014-08-19 22:32:42 +00:00
Hans Boehm
1e8587a479 Work around atomic_load(const T*) issues.
Bug:17067219
Change-Id: I78e753bcf03464f5f05c3f37e394f2727d282589
2014-08-19 14:50:54 -07:00
Elliott Hughes
c5d6df6f2f Merge "Add in_port_t and move it and in_addr_t to the correct header file." 2014-08-19 15:49:56 +00:00
Elliott Hughes
35d226e05d Add in_port_t and move it and in_addr_t to the correct header file.
No one's reported this, but I saw it in an Android port of fuser(1).

We still have lots of problems in our network headers because we
get most of the structs direct from the kernel, and it doesn't use
types like this (which is why we've got away without this one for
so long). One day we should probably look at cleaning that up, but
doing so can wait.

Change-Id: If15edf0cfc32716fa312d7ed97c48321b760d979
2014-08-19 12:43:50 -07:00
Elliott Hughes
b9d674c8ad Merge "Implement the GNU basename(3) in addition to the POSIX one." 2014-08-19 02:44:29 +00: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
6f4220c49e Merge "Move the meat of <features.h> into <sys/cdefs.h>." 2014-08-19 02:44:29 +00: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
Elliott Hughes
17f83c93cb Merge "Remove unused defines from <features.h>." 2014-08-19 02:44:29 +00:00
Elliott Hughes
f800969d35 Remove unused defines from <features.h>.
Bug: 14659579
Change-Id: I2ab02b13cafe3faad31248b843d39ab2cdbfeb91
2014-08-19 10:07:00 -07:00
Elliott Hughes
e4fcc3ad2b Merge "Fix _BSD_SOURCE/__USE_BSD." 2014-08-19 02:44:29 +00:00
Elliott Hughes
b810462028 Fix _BSD_SOURCE/__USE_BSD.
Bug: 14659579
Change-Id: I80ec9584f054c02d1078828f6bca759c42bc1d4c
2014-08-19 09:18:03 -07:00
Dmitriy Ivanov
8a76ee821e Merge "Revert "Add support for protected local symbol lookup."" 2014-08-19 02:44:29 +00: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
Dan Albert
2222eae61e Merge "Missing #include <sys/cdefs.h>." 2014-08-16 04:28:29 +00:00
Dan Albert
3a25ab952b Missing #include <sys/cdefs.h>.
Needed for __BEGIN_DECLS/__END_DECLS. Currently fine because it's being
included after other files that do this.

Change-Id: I1f12368fc461f6ef5ca90992cf19f317f0b5d7af
2014-08-19 11:08:02 -07:00
Dan Albert
934c8015d5 Merge "Expose android_set_abort_message()." 2014-08-16 04:20:19 +00:00
Dan Albert
ce6b1abbb1 Expose android_set_abort_message().
Removes the leading underscores from __android_set_abort_message() and
moves its declaration into a public header file.

Bug: 17059126
Change-Id: I470c79db47ec783ea7a54b800f8b78ecbe7479ab
2014-08-18 14:37:42 -07:00
Christopher Ferris
54d24e099c Merge "Fix leak_realloc, copy entire allocation." 2014-08-16 04:08:14 +00:00
Christopher Ferris
6d40d34908 Fix leak_realloc, copy entire allocation.
Bug: 16874447

(cherry picked from commit 5df0839cea)

Change-Id: I9280505c0c1c3b5da24ba590448dcd6e7a230406
2014-08-18 13:10:47 -07:00
Christopher Ferris
5d9e145c62 malloc_usable_size returns the original size.
Bug: 16874447

(cherry picked from commit 59c1ee44d0)

Change-Id: I70839632974367c8b9893fb1f9c5ee4364608470
2014-08-18 13:10:16 -07:00
Christopher Ferris
3c7c9a8d3f Merge "malloc_usable_size returns the original size." 2014-08-16 04:09:33 +00:00
Dan Albert
db2e0247ed Merge "Hide C++ stuff in libc. Put it back in libstdc++." 2014-08-16 04:08:14 +00:00
Dan Albert
fd5ee9aebc Hide C++ stuff in libc. Put it back in libstdc++.
Bug: 17062445
Change-Id: I027b186719654c2865b08c3fa83f90fa00c1e838
2014-08-18 12:01:01 -07:00
Elliott Hughes
0baf2ca34c Merge "Fix <features.h> (_BSD_SOURCE and _GNU_SOURCE)." 2014-08-16 04:03:35 +00: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
Elliott Hughes
205cc41556 Merge "Improve <sys/cdefs.h>." 2014-08-18 21:31:43 +00:00
Elliott Hughes
2cfb4e8e2e Improve <sys/cdefs.h>.
Fix and use __RENAME (and lose ___RENAME --- two underscores should be
enough for anybody). This was the point of this change, because I want
to use __RENAME to support the two basename variants and the two
strerror_r variants.

Lose a bunch of macros that weren't being used.

Lose three dead files from the DNS code.

Change-Id: I3ef645c566b16a52217bc2e68c7d54b37c7c9522
2014-08-18 14:45:42 -07:00
Dmitriy Ivanov
2b6cdb5e45 Merge "Add atexit test for attributed c-tor/d-tor" 2014-08-15 21:23:56 +00: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
Hans Boehm
7d05f741e7 Merge "Have stdatomic.h punt to C++ atomic when possible" 2014-08-15 05:01:31 +00:00
Hans Boehm
019d395811 Have stdatomic.h punt to C++ atomic when possible
This is an alternate, somewhat simpler, fix that makes it safe to
include both <atomic> and <stdatomic.h> from C++ code in either order.
It means that C code consistently uses one implementation of atomics
and C++ another.  We still have to make sure that those two
implementations interoperate correctly at runtime; in particular,
any flavor of atomic object needs to be represented exactly like the
underlying type, with the proper alignment constraint.

Bug:17007799
Change-Id: Iffcfc5220d8fa150f89dd083a121b24d23f268fc
2014-08-15 10:38:20 -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
Dan Albert
d0cce14364 Merge "Move mtctxres.c to libc_dns.a." 2014-08-12 19:23:43 +00:00
Dan Albert
891ec7a6e4 Move mtctxres.c to libc_dns.a.
Has the effect of making ___mtctxres hidden.

Bug: 17007799
Change-Id: I5aa5f49344ad5ecb33f48737430561b329bcbb0d
2014-08-14 22:50:45 +00:00
Dmitriy Ivanov
8457779b34 Merge "Keep symbols for linker" 2014-08-14 19:49:27 +00:00
Dmitriy Ivanov
ad5e8b5073 Keep symbols for linker
Bug: 17011146
Change-Id: I314e72a1ac9325bf5ea84d52e3d5bc51d8ea00cf
2014-08-14 15:46:36 -07:00
Dan Albert
0d4ccee351 Merge "Change name of MB_CUR_MAX implementation function." 2014-08-14 19:41:13 +00:00
Dan Albert
224ff048ef Change name of MB_CUR_MAX implementation function.
Glibc calls theirs __ctype_get_mb_cur_max. Make ours match to cut down
on differences between bionic and glibc.

Bug: 11156955
Change-Id: Ib7231f01aa9676dff30aea0af25d597bfe07bc73
2014-08-14 13:56:51 -07:00
Dan Albert
104a472958 Merge "Add more functionality to glibc symbol checker." 2014-08-14 19:41:13 +00:00
Dan Albert
76212eeb53 Add more functionality to glibc symbol checker.
Also scan NDK's unwanted symbols list (to show the things that we're
exporting but the NDK isn't. Symbols hidden in the NDK will be marked
with a *.

Add a -u (--unwanted) flag to disable the first two printed groups
(all symbols in bionic, all symbols in glibc). This is helpful when
wanting to grep in the list of unwanted symbols.

Finally, update the list of known differences between us and glibc.

Change-Id: I6fdb4126823098430454763c391bd8cd369a75bb
2014-08-14 14:02:34 -07:00
Dan Albert
9a74e4c15c Merge "Hide __libc_init_vdso()." 2014-08-12 23:11:16 +00:00
Dan Albert
b3aaf398e1 Hide __libc_init_vdso().
Bug: 11156955
Change-Id: I7ee31e1ee2ce479c5746b374a239637d582815fe
2014-08-13 13:11:58 -07:00
Hans Boehm
4f85c6ffd3 Merge "Add memory ordering constraint, convert to C11 atomics" 2014-08-12 19:23:43 +00:00
Dan Albert
1f4c536fd5 Merge "Hide ScopedTrace." 2014-08-12 19:23:43 +00:00
Dan Albert
f2c1e7ee78 Hide ScopedTrace.
Bug: 11156955
Change-Id: I6cddc868d1c6503e30f1ffcf460f45670631d64a
2014-08-13 11:25:01 -07:00
Dmitriy Ivanov
db0785cbf9 Merge "Optimize symbol lookup" 2014-08-13 01:32:01 +00:00
Dmitriy Ivanov
042426ba63 Optimize symbol lookup
Do not run symbol lookup on already visited soinfos
 Not taking into account already visited libraries
 dramatically slows down dlsym in cases when there
 are multiple occurrences of a large library in
 dependency tree.

Bug: 16977077
Change-Id: I1379f30ed8b06758dd1cc76b80833ac8589afa50
2014-08-13 09:21:57 -07:00
Dan Albert
6e3823d37e Merge "Hide __libc_malloc_dispatch." 2014-08-12 19:23:43 +00:00
Dan Albert
edd81faff0 Hide __libc_malloc_dispatch.
Now that -Bsymbolic is fixed, we can hide __libc_malloc_dispatch without
breaking ASAN.

Bug: 11156955
Change-Id: Ia2fc9b046a74e666b33aa6c6c5435f70a63b8021
2014-08-12 16:53:14 -07:00
Dmitriy Ivanov
e942b3ed81 Merge "Added test for ifunc support in dynamic linker." 2014-08-12 19:23:43 +00:00
Dmitriy Ivanov
00c16c1b92 Merge "Label pages mapped by linker_allocator" 2014-08-09 00:45:41 +00:00
Dmitriy Ivanov
51a22a12ab Label pages mapped by linker_allocator
Change-Id: I7e0bf29bc1a480e9be0d1ae573ca1063d90d82ff
2014-08-11 09:22:48 -07:00
Elliott Hughes
4d0f742afe Merge "Fix our x86 PIC_PROLOGUE." 2014-08-09 00:52:40 +00:00
Elliott Hughes
ca5b6a74a7 Fix our x86 PIC_PROLOGUE.
The old definition only worked for functions that didn't use numbered
local labels. Upstream uses '666' not only as some kind of BSD in-joke,
but also because there's little likelihood of any function having
labels that high.

There's a wider question about whether we actually want to go via the
PLT at all in this code, but that's a question for another day.

(cherry-pick of 72d7e667c7e926cb120c4edb53cbf74c652ab915.)

Bug: 16906712
Change-Id: I3cd8ecc448b33f942bb6e783931808ef39091489
2014-08-09 22:18:33 -07:00
Hans Boehm
30214b901e Add memory ordering constraint, convert to C11 atomics
Add an ordering constraint/fence to __system_property_serial.
This slows down a read on a Nexus 5 from about 50 to about 70 ns,
but avoids the possibility of seeing an inconsistent property value.
Use C11 atomic operations where easy and appropriate.
This code remains not fully C++11 memory model conformant, but
I would now expect the generated code to now be correct with current compilers.

Bug:14970171
Change-Id: I0891ff1d0f914ae5c3857e3d76b6a7c8a4a07d83
2014-08-08 11:34:25 -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
Dan Albert
a0db464187 Merge "Make __set_errno hidden in asm." 2014-08-08 18:16:13 +00:00
Dan Albert
bc9f9f25bf Make __set_errno hidden in asm.
This fixes the build after the -Bsymbolic change.

Bug: 16853291
Change-Id: I989c9fec3c32e0289ea257a3bd2b7fd2709b6ce2
2014-08-08 15:35:47 -07:00
Dan Albert
3788a1ee8e Merge "Revert "Fix incorrect relocations for x86."" 2014-08-07 18:51:06 +00:00
Dan Albert
3726f9c38b Revert "Fix incorrect relocations for x86."
Bug: 16853291
This reverts commit 512bc52326.
2014-08-08 22:26:47 +00:00
Christopher Ferris
1c5e415f8c Merge "Add a way to disable backtracing in malloc debug." 2014-08-07 17:53:11 +00:00
Christopher Ferris
88a1f520d2 Add a way to disable backtracing in malloc debug.
The property libc.debug.malloc.nobacktrace set to non-zero disables
getting backtracing when using mode 1 or mode 10.

Bug: 16874447

(cherry picked from 49de01a5be)

Change-Id: I6bbefe5420b14991fe84c2f849222dcd7cb592bf
2014-08-08 09:40:17 -07:00
Elliott Hughes
f2d8c357ee Merge "Remove misleading arm/arm64 PIC_SYM." 2014-08-06 23:49:29 +00:00
Elliott Hughes
651a0683ca Remove misleading arm/arm64 PIC_SYM.
Bug: 16823325
Change-Id: Ic8ff3a628bb4cd71361e3a1c2cfde4b3d39c50b1
2014-08-07 11:52:38 -07:00
Christopher Ferris
92f0c91b82 Merge "Create a distinct temp directory for each run." 2014-08-07 15:46:11 +00:00
Christopher Ferris
01bd32e0e4 Create a distinct temp directory for each run.
Modify make__NR_name so that only __ARM_NR_ is exempted from the
__NR_ being prepended. This avoids a case where using a name starting
with __ but is not a valid syscall name in SYSCALLS.TXT does not generate
code that will compile but references the function itself and causes
link errors.

Fix all of the directory references from dir_part1 + dir_part2 to
use os.path.join() instead.

Change-Id: Ib9527eba6f25f26a30c5cb0ad431f3f88a7683cf
2014-08-07 19:33:22 -07:00
Elliott Hughes
d994622ebf Merge "Android is all-PIC/PIE." 2014-08-07 14:59:23 +00:00
Elliott Hughes
6b6364a7fc Android is all-PIC/PIE.
Clean up the x86/x86_64 assembler. The motivator (other than reducing
confusion) was that asm.h incorrectly checked PIC rather than __PIC__.

Bug: 16823325
Change-Id: Iaa9d45009e93a4b31b719021c93ac221e336479b
2014-08-07 10:54:54 -07:00
Dan Albert
cdd2f072af Merge "Fix incorrect relocations for x86." 2014-08-07 14:59:23 +00:00
Dan Albert
512bc52326 Fix incorrect relocations for x86.
These calls were not going through the PLT like they should have been.

Bug: 16853291
Change-Id: Id70488b077256a70137c4417f21be2c2d1d4341c
2014-08-07 16:21:47 -07:00
Christopher Ferris
85ebcfceb6 Merge "Do a second key cleanup in pthread_exit." 2014-08-06 23:49:29 +00: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
Elliott Hughes
f3868fa735 Merge "Upgrade bionic to tzdata2014f." 2014-08-07 00:00:55 +00:00
Elliott Hughes
51fde5b865 Upgrade bionic to tzdata2014f.
From the release notes:

  Changes affecting future time stamps

    Russia will subtract an hour from most of its time zones on
    2014-10-26 at 02:00 local time.  (Thanks to Alexander Krivenyshev.)
    There are a few exceptions: Magadan Oblast (Asia/Magadan) and
    Zabaykalsky Krai are subtracting two hours; conversely, Chukotka
    Autonomous Okrug (Asia/Anadyr), Kamchatka Krai (Asia/Kamchatka),
    Kemerovo Oblast (Asia/Novokuznetsk), and the Samara Oblast and the
    Udmurt Republic (Europe/Samara) are not changing their clocks.  The
    changed zones are Europe/Kaliningrad, Europe/Moscow,
    Europe/Simferopol, Europe/Volgograd, Asia/Yekaterinburg, Asia/Omsk,
    Asia/Novosibirsk, Asia/Krasnoyarsk, Asia/Irkutsk, Asia/Yakutsk,
    Asia/Vladivostok, Asia/Khandyga, Asia/Sakhalin, and Asia/Ust-Nera;
    Asia/Magadan will have two hours subtracted; and Asia/Novokuznetsk's
    time zone abbreviation is affected, but not its UTC offset.  Two
    zones are added: Asia/Chita (split from Asia/Yakutsk, and also with
    two hours subtracted) and Asia/Srednekolymsk (split from
    Asia/Magadan, but with only one hour subtracted).  (Thanks to Tim
    Parenti for much of the above.)

  Changes affecting past time stamps

    China's five zones have been simplified to two, since the post-1970
    differences in the other three seem to have been imaginary.  The
    zones Asia/Harbin, Asia/Chongqing, and Asia/Kashgar have been
    removed; backwards-compatibility links still work, albeit with
    different behaviors for time stamps before May 1980.  Asia/Urumqi's
    1980 transition to UTC+8 has been removed, so that it is now at
    UTC+6 and not UTC+8.  (Thanks to Luther Ma and to Alois Treindl;
    Treindl sent helpful translations of two papers by Guo Qingsheng.)

    Some zones have been turned into links, when they differed from
    existing zones only for older UTC offsets where the data were likely
    invented.  These changes affect UTC offsets in pre-1970 time stamps
    only.  This is similar to the change in release 2013e, except this
    time for western Africa.  The affected zones are: Africa/Bamako,
    Africa/Banjul, Africa/Conakry, Africa/Dakar, Africa/Freetown,
    Africa/Lome, Africa/Nouakchott, Africa/Ouagadougou, Africa/Sao_Tome,
    and Atlantic/St_Helena.  This also affects the
    backwards-compatibility link Africa/Timbuktu.  (Thanks to Alan
    Barrett, Stephen Colebourne, Tim Parenti, and David Patte for
    reporting problems in earlier versions of this change.)

    Asia/Shanghai's pre-standard-time UT offset has been changed from
    8:05:57 to 8:05:43, the location of Xujiahui Observatory.  Its
    transition to standard time has been changed from 1928 to 1901.

    Asia/Taipei switched to JWST on 1896-01-01, then to JST on
    1937-10-01, then to CST on 1945-09-21 at 01:00, and did not observe
    DST in 1945.  In 1946 it observed DST from 05-15 through 09-30; in
    1947 from 04-15 through 10-31; and in 1979 from 07-01 through 09-30.
    (Thanks to Yu-Cheng Chuang.)

    Asia/Riyadh's transition to standard time is now 1947-03-14, not
    1950.

    Europe/Helsinki's 1942 fall-back transition was 10-04 at 01:00, not
    10-03 at 00:00.  (Thanks to Konstantin Hyppönen.)

    Pacific/Pago_Pago has been changed from UTC-11:30 to UTC-11 for the
    period from 1911 to 1950.

    Pacific/Chatham has been changed to New Zealand standard time plus
    45 minutes for the period before 1957, reflecting a 1956 remark in
    the New Zealand parliament.

    Europe/Budapest has several pre-1946 corrections: in 1918 the
    transition out of DST was on 09-16, not 09-29; in 1919 it was on
    11-24, not 09-15; in 1945 it was on 11-01, not 11-03; in 1941 the
    transition to DST was 04-08 not 04-06 at 02:00; and there was no DST
    in 1920.

    Africa/Accra is now assumed to have observed DST from 1920 through
    1935.

    Time in Russia before 1927 or so has been corrected by a few seconds
    in the following zones: Europe/Moscow, Asia/Irkutsk, Asia/Tbilisi,
    Asia/Tashkent, Asia/Vladivostok, Asia/Yekaterinburg,
    Europe/Helsinki, and Europe/Riga.  Also, Moscow's location has been
    changed to its Kilometer 0 point.  (Thanks to Vladimir Karpinsky for
    the Moscow changes.)

(cherry-pick of 0dc2c1db6fc84b4526f2a5f8d73e1187500f2300.)

Bug: 16168653
Change-Id: I23827254bcf50dd07a2192ed34b02224d73e07a0
2014-08-06 17:38:01 -07:00
Elliott Hughes
b4b7e0547d Merge "Fix the tzdata update tools." 2014-08-06 23:55:49 +00:00
Elliott Hughes
13bab43337 Fix the tzdata update tools.
The recent libcore ZoneInfo changes mean that we can no longer
compile libcore's ZoneInfo against the RI. Luckily, the field in
our data file that we needed ZoneInfo for isn't actually used.
This change removes our dependence on libcore.

I've left the field in to avoid a file format change. We can remove
the field if/when we next have a real need to bump the file format.

(cherry-pick of 90cb5ffb85a9bc2e725824b3ca8db932d02c45db.)

Bug: 16168653
Change-Id: Iedad2252c2b49f4d8bb2c7d9078b39b622444ca7
2014-08-06 17:31:48 -07:00
Elliott Hughes
3a238ae762 Merge "Revert "Add a hack to <stdlib.h> until we can fix libvpx."" 2014-08-06 17:15:22 +00:00
Elliott Hughes
9d2a05a6dd Revert "Add a hack to <stdlib.h> until we can fix libvpx."
This reverts commit 3fb5097a7e.
libvpx is now fixed.

(cherry-pick of 2be1be47aa9b63568fe6ce1e0a4029b37d90764d.)

Bug: 15598056
Change-Id: Icca974e667f92206505f484bd291726eb0150f68
2014-08-06 13:20:41 -07:00
Elliott Hughes
bb91a1b845 Merge "Workaround b/16818336 which fails build under aggressive inlining." 2014-08-05 00:30:25 +00:00
Dehao Chen
28285f85a1 Workaround b/16818336 which fails build under aggressive inlining.
(cherry-pick of 7aa27e1c1a53afe28f6180fd1fc50d096cabea7b.)

Change-Id: Ifcd596714c427a2ec39502b9c0af9082ded91884
2014-08-06 11:43:38 -07:00
Elliott Hughes
8b91980e4c Merge "Explain how wcswcs ended up in ndk_cruft.cpp." 2014-08-06 17:20:04 +00:00
Elliott Hughes
1628eb1d43 Explain how wcswcs ended up in ndk_cruft.cpp.
Change-Id: Ie45148095b2d5c3896c0df623d5d06a700c33c70
2014-08-06 10:47:33 -07:00
Elliott Hughes
afc8672387 Merge "Add an obvious comment to <stdio.h> for fixincludes." 2014-08-05 17:41:26 +00:00
Elliott Hughes
df85f50b82 Add an obvious comment to <stdio.h> for fixincludes.
We don't want GCC's fixincludes to touch our <stdio.h> because we
want to support multiple platform versions with one toolchain. Give
them a nice easy unambiguous string to look for.

Bug: http://code.google.com/p/android/issues/detail?id=73728
Change-Id: I15cb9a2c9eb0a44b0965dc2139f224f2b6e68ea1
2014-08-06 09:03:52 -07:00
Dan Albert
de69069fcf Merge "Fixes build." 2014-08-05 17:41:26 +00:00
Dan Albert
9eae8405e8 Fixes build.
This change somehow went missing from the vfork change.

Change-Id: I807a2072080eac20601c694e85ba5723220289d8
2014-08-05 14:46:03 -07:00
Dan Albert
a7ef8188e2 Merge "Revert "Replaces vfork() implementation with fork()"" 2014-08-05 17:41:26 +00:00
Dan Albert
6a918870ba Revert "Replaces vfork() implementation with fork()"
We're getting cold feet on this one... let's put it back.

This reverts commit 210331d976.

Change-Id: I6b0d3c2b1dbf7f1dc9566979a91b7504c2189269
2014-08-05 14:11:38 -07:00
Dan Albert
447fe1c23b Merge "Fix mbsrtowcs(3) src param for finished string." 2014-07-30 11:26:00 +00: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
36bacd237d Merge "Proper MB_CUR_MAX." 2014-07-31 00:14:55 +00: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
Christopher Ferris
4ad5066e1d Merge "Use libunwindbacktrace for debug malloc code." 2014-07-28 22:45:44 +00:00
Christopher Ferris
861c0ef37b Use libunwindbacktrace for debug malloc code.
Create a method of disabling the debug allocation code paths so that
it's possible to use the libunwindbacktrace library without any
modifications.

Use this path to create and destroy the maps for the process. It's not
stricly necessary in the init code since the symbols are not modified
until after the initialize calls.

Also, remove the debug_XXX source files that doesn't need to be in libc.so.

Fix the maps reading code since it was completely broken for 64 bit.

Bug: 16408686

Change-Id: I6b02ef6ce26fdb7a59ad1029e7cbba9accceb704
2014-07-29 18:10:00 -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
Elliott Hughes
17886971ff Merge "Remove declarations for things that don't exist." 2014-07-25 21:16:27 +00:00
Elliott Hughes
f4c1a36a45 Remove declarations for things that don't exist.
The <grp.h> ones prevent gdb from building out of the box.

Change-Id: I0efbffad2215cfcd75b4d442dfc972444b51d97c
2014-07-29 16:57:47 -07:00
Dmitriy Ivanov
2b591b3742 Merge "Fix dlsym(3) to do breadth first search." 2014-07-29 21:36:05 +00: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
52f8271fa9 Merge "Added a bionic systrace class and tracing to pthread_mutex.cpp." 2014-07-25 21:16:27 +00:00
Brigid Smith
a406ee6d5f Added a bionic systrace class and tracing to pthread_mutex.cpp.
bionic_systrace.h contains an implementation of tracing that
can be used with systrace.py and its associated viewer.  pthread_mutex
now uses this tracing to track pthread_mutex contention, which can be
enabled by using the "bionic" command line option to systrace.

Bug: 15116468
Change-Id: I30ed5b377c91ca4c36568a0e647ddf95d4e4a61a
2014-07-28 19:38:08 -07:00
Dmitriy Ivanov
24dcda0f4f Merge "Fix mips/mips64 build" 2014-07-25 21:16:27 +00:00
Dmitriy Ivanov
ed48534718 Fix mips/mips64 build
Add _start entry label to mips/mips64 linker begin.S

Change-Id: Idcdfc3391427b53880650798be0583a7ac022bcc
2014-07-28 21:03:17 -07:00
Elliott Hughes
50a9630cc2 Merge "Start hiding "private/bionic_time.h"." 2014-07-24 20:55:36 +00:00
Elliott Hughes
905e6d58aa Start hiding "private/bionic_time.h".
Bug: 15765976
Change-Id: Ibd9cf07067ec8dffe9fda6c3d498d4ab90708220
2014-07-25 12:03:51 -07:00
Dan Albert
a4c14fda91 Merge "en_US.UTF-8 is also supported." 2014-07-24 20:55:36 +00:00
Dan Albert
1abb8bd21d en_US.UTF-8 is also supported.
Change-Id: Ic35fad3596dc5e24ee8ae35543a274a471f27bb2
2014-07-25 11:24:03 -07:00
Elliott Hughes
83b9826e68 Merge "Implement <sys/fsuid.h>." 2014-07-23 22:55:49 +00:00
Elliott Hughes
79310994d2 Implement <sys/fsuid.h>.
Change-Id: I1e5e50444a1b5a430ba5b5d9b8b1d91219af5e92
2014-07-30 15:19:29 -07:00
Elliott Hughes
c7706a02ad Merge "[MIPSR6] Use C-coded string ops on mips32r6/mips64r6" 2014-07-29 21:36:05 +00:00
Elliott Hughes
18a1bbe6e1 Merge "Only wipe TLS for user-supplied stacks." 2014-07-30 19:31:16 +00:00
Elliott Hughes
40a5217448 Only wipe TLS for user-supplied stacks.
Bug: 16667988
Change-Id: Id180ab2bc6713e1612386120a306db5bbf1d6046
2014-07-30 14:49:40 -07:00
Elliott Hughes
123172ae37 Merge "[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." 2014-07-23 22:55:49 +00: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
Dmitriy Ivanov
dbf52ec37b Merge "Fix global variable initialization for linker" 2014-07-24 20:55:36 +00:00
Dmitriy Ivanov
4151ea73b7 Fix global variable initialization for linker
Linker now calls init functions for itself.

Change-Id: Ibd099812493041ac70f591e3f379ee742b4683b8
2014-07-24 15:33:25 -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
Duane Sand
bc5a3ec6df [MIPSR6] Use C-coded string ops on mips32r6/mips64r6
The existing assembler code uses deprecated lwl/lwr/swl/swr ops.
Replacing those with misalignment-forgiving lw/sw ops may
involve careful performance tuning.

Change-Id: I47a042f7b22b87d7d52e46c29c44b1db1ba8b693
2014-07-23 14:00:21 -07:00
Elliott Hughes
7d22a45196 Merge "[MIPSR6] setjmp supports mips32r6 and FP64A/FPXX reg models" 2014-07-23 18:45:08 +00:00
Duane Sand
dd37251c47 [MIPSR6] setjmp supports mips32r6 and FP64A/FPXX reg models
Save and restore floating point registers via 64-bit
load/stores when possible.  Use assembler's builtin macro
ops to generate pairs of 32-bit load/stores on Mips I cpus.

Some cpus or FR modes have only 16 even-numbered dp fp regs.
This is exposed by _MIPS_FPSET, defined by existing compilers.

Change-Id: I7f617a3ffea8da41c402ef3a68ab32c91d3d7622
2014-07-23 13:57:30 -07:00
Nick Kralevich
f965075749 Merge "debuggerd: if PR_GET_DUMPABLE=0, don't ask for dumping" 2014-07-23 18:51:55 +00: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
f9bfc2ff8e Merge "Fix belated review comments on syslog change." 2014-07-23 18:45:08 +00:00
Elliott Hughes
afe6360627 Fix belated review comments on syslog change.
Bug: 14292866
Change-Id: I3cd92084cb55b5673f6ba62d51952941b79deb51
2014-07-23 11:38:38 -07:00
Dmitriy Ivanov
337c0cefdc Merge "Fix 'adb shell /system/bin/linker' crash" 2014-07-23 17:53:27 +00:00
Dmitriy Ivanov
efe13832dc Fix 'adb shell /system/bin/linker' crash
Bug: https://code.google.com/p/android/issues/detail?id=63174
Change-Id: I072290ea11109c07f277ad3dec7f44fcb7bf6aa6
2014-07-28 16:29:52 -07:00
Elliott Hughes
8a2ecf868f Merge "syscall(3)'s return type should be long." 2014-07-24 20:55:36 +00: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
1a918d9be8 Merge "Remove localtime_tz and strftime_tz." 2014-07-24 20:55:36 +00:00
Elliott Hughes
39d903aea9 Remove localtime_tz and strftime_tz.
This also brings our copy of strftime.c much closer to upstream, though
we still have several GNU extensions and hacks to deal with Android32's
broken time_t.

Bug: 15765976
Change-Id: Ic9ef36e8acd3619504ecc4d73feec2b61fd4dfa1
2014-07-25 15:50:31 -07:00
Elliott Hughes
8c66fd798e Merge "Use vsnprintf(3) in syslog(3)." 2014-07-24 20:55:36 +00: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
Elliott Hughes
8dbe3f0f51 Merge "[MIPS] Drop soft-fp targets" 2014-07-23 17:53:27 +00:00
Duane Sand
ba23bd0a40 [MIPS] Drop soft-fp targets
Change-Id: I583bf8242d3034ebfc48548499cdb3316094c8e3
2014-07-24 18:04:21 +00:00
Elliott Hughes
467e49be70 Merge "Fix generate-NOTICE to cope better with BSD __COPYRIGHT macros." 2014-07-22 16:35:00 +00:00
Elliott Hughes
5d2f86f363 Fix generate-NOTICE to cope better with BSD __COPYRIGHT macros.
Change-Id: I99f9d2e0a28342663cec6aed483e1a23c12e5e87
2014-07-23 11:10:48 -07:00
Elliott Hughes
ea42a6caea Merge "Fix a couple of bugs in generate-NOTICE and regenerate the NOTICE files." 2014-07-22 16:25:43 +00:00
Elliott Hughes
3758a244cf Fix a couple of bugs in generate-NOTICE and regenerate the NOTICE files.
Change-Id: Id6fcb74292e661504d0758bfce24abdc18cb8d32
2014-07-22 21:29:00 -07:00
Elliott Hughes
e26ac7f776 Merge "Remove the unused swab.S." 2014-07-22 21:56:40 +00:00
Elliott Hughes
ca70453e84 Remove the unused swab.S.
Change-Id: Id30eac5a21b649d6a039a0d7ca0496177fbfb571
2014-07-22 20:21:31 -07:00
Elliott Hughes
79b5a39617 Merge "[MIPS] Allow united mipsel and mips64el gcc toolchain" 2014-07-22 16:35:00 +00:00
Duane Sand
f541650828 [MIPS] Allow united mipsel and mips64el gcc toolchain
Explicitly tell 32-bit links that they are doing 32-bit links.
This is needed when using united 32-bit and 64-bit toolchains.
This is harmless when using older separate 32-only toolchains.

Change-Id: I70cbd3f5867e59b1f6f829793444242fb0894aa6
2014-07-22 14:27:48 -07:00
Elliott Hughes
0f7d882bb7 Switch to OpenBSD res_random.
Change-Id: Ia971d647832893e9bb4601697132a105524d2f96
2014-07-21 15:31:53 -07:00
Elliott Hughes
4d421901e5 Merge "Use upstream OpenBSD's arc4random." 2014-07-21 15:45:37 +00:00
Elliott Hughes
2b67d7dee0 Use upstream OpenBSD's arc4random.
The getentropy_linux.c is lightly modified to build on Android, but we're now
completely in sync with upstream OpenBSD's arc4random implementation.

Change-Id: If32229fc28aba908035fb38703190d41ddcabc95
2014-07-21 14:38:16 -07:00
Elliott Hughes
925d388e24 Merge "Rewrite syslog(3) to use Android logging." 2014-07-19 23:20:08 +00: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
b828eaeb45 Merge "There is no _MIN for unsigned types." 2014-07-21 15:45:37 +00:00
Dan Albert
ee7f1b5946 There is no _MIN for unsigned types.
Change-Id: I49c38e51197b750210bdbf28c9cf6db30452a206
2014-07-21 17:16:30 -07:00
Dan Albert
1fb90a8aa0 Merge "Fix mbsrtowcs(3)'s handling of len parameter." 2014-07-17 22:34:19 +00: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
Dan Albert
e9731387f4 Merge "__libc_fatal should print a newline to stderr." 2014-07-18 22:17:02 +00:00
Dan Albert
97e31dedf0 __libc_fatal should print a newline to stderr.
Change-Id: I088dc880d7488a65beac8cda95f530f3db41f112
2014-07-21 11:10:00 -07:00
Elliott Hughes
7dd126a38c Merge "Clean up some misinformation around prctl." 2014-07-17 22:33:54 +00:00
Elliott Hughes
9c07aee83b Clean up some misinformation around prctl.
prctl shouldn't be in <unistd.h>.

Change-Id: I29609fc91c033e1ad143b75d9b4eb17aefbd63d6
2014-07-18 16:15:32 -07:00
Christopher Ferris
3c2b71ad56 Merge "Use the mmap/munmap for allocation routines." 2014-07-17 22:33:54 +00:00
Christopher Ferris
6425327c32 Use the mmap/munmap for allocation routines.
To avoid any issues calling malloc related routines, use mmap/munmap.
Specifically, this avoids any problems when this is compiled into a
malloc debug shared library.

Change-Id: Iae2d197145da43dc103ad6024357d8cc2374378f
2014-07-18 14:16:51 -07:00
Elliott Hughes
d18b87f38d Merge "Remove SIOCKILLADDR from <sys/socket.h>." 2014-07-17 22:33:42 +00:00
Elliott Hughes
8a3d1ca183 Remove SIOCKILLADDR from <sys/socket.h>.
Change-Id: I6b64a9abe01c786a9ec26aee1517cb981a4860fb
2014-07-17 17:10:02 -07:00
Elliott Hughes
76282482db Merge "Remove PR_SET_TIMERSLACK_PID from <sys/prctl.h>." 2014-07-17 22:33:42 +00:00
Elliott Hughes
9f165d24f0 Remove PR_SET_TIMERSLACK_PID from <sys/prctl.h>.
Change-Id: Ie70f23c80e8473ac9617b74967d7c84709f5b00d
2014-07-17 17:12:35 -07:00
Elliott Hughes
6bf42ddc79 Merge "Fix private/bionic_name_mem.h build breakage." 2014-07-17 21:58:34 +00:00
Elliott Hughes
2f9c6e38b8 Fix private/bionic_name_mem.h build breakage.
Change-Id: I8fe9c63dbbb5911721ca56791c0bff4bdf403314
2014-07-17 15:09:17 -07:00
Elliott Hughes
169e2bf6bd Merge "Remove non-standard prctl constants from <sys/prctl.h>." 2014-07-17 17:59:29 +00:00
Elliott Hughes
d7453860a6 Remove non-standard prctl constants from <sys/prctl.h>.
Also remove __bionic_name_mem which has exactly one caller, and is only
ever expected to be used in this one place.

Change-Id: I833744f91e887639f5b2d1269f966ee9032af207
2014-07-17 14:26:33 -07:00
Hans Boehm
43363ab720 Merge "Define atomic_charN_t only if charN_t is supported." 2014-07-16 23:31:38 +00:00
Hans Boehm
8b002362d9 Define atomic_charN_t only if charN_t is supported.
Some platform code is apparently compiled with switches that do
not support char16_t and char32_t.  This caused stdatomic.h to fail
to compile.  This CL makes stdatomic.h usable in those environments.

Change-Id: Ie5a17f20b8b545c97128d00605b4eabd2a6bfe3e
2014-07-16 17:31:05 -07:00
Elliott Hughes
94f84d36a9 Merge "ptrace(3) should be varargs." 2014-07-16 21:56:17 +00:00
Elliott Hughes
98b088dce7 ptrace(3) should be varargs.
Bug: 16352070
Change-Id: Ied72e6e79eaf912fc93fc49ae7637af321a31a59
2014-07-16 16:07:10 -07:00
Elliott Hughes
f13aa6fc5b Merge "Use VDSO for clock_gettime(2) and gettimeofday(2)." 2014-07-16 19:02:19 +00: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
Christopher Ferris
770d0f6177 Merge "Make sure not to construct illegal property names." 2014-07-15 20:47:30 +00:00
Christopher Ferris
53531ccebb Make sure not to construct illegal property names.
Change-Id: I37624e69aec51efd4291f076fb87af3f35d33025
2014-07-15 19:26:28 -07:00
Christopher Ferris
64035c4a4b Merge "Add gen syscalls step to instructions." 2014-07-15 20:47:30 +00:00
Christopher Ferris
ea271fdf26 Add gen syscalls step to instructions.
Also, fix incorrect path to some tools.

Change-Id: I409fc02d7077f0d2811d90be19550e70f5d73c0e
2014-07-15 19:02:33 -07:00
Elliott Hughes
52023cb725 Merge "Regenerate the syscalls list after the uapi update." 2014-07-15 20:36:09 +00:00
Elliott Hughes
3fa60e10bc Regenerate the syscalls list after the uapi update.
Change-Id: I117c5b18f735376dd3ab5061018dc7db9c046202
2014-07-15 18:39:27 -07:00
Christopher Ferris
51c914b7fd Merge "Fix BIONIC_ROUND_UP_POWER_OF_2 for 64 bit." 2014-07-15 00:42:07 +00:00
Christopher Ferris
27047faf28 Fix BIONIC_ROUND_UP_POWER_OF_2 for 64 bit.
There were two bugs here:

- For 64 bit values, this did not properly round up.
- The macro rounded to the power of 2 less than value, not to the power
  of 2 greater than value.

Change-Id: If8cb41536a9d2f5c1bc213676f1e67a7903a36b0
2014-07-15 12:33:48 -07:00
Dan Albert
5656a0c494 Merge "Remove isascii_l(3)." 2014-07-14 23:04:02 +00:00
Dan Albert
e612add051 Remove isascii_l(3).
Had intended to remove this one before submitting the locale changes,
but forgot. It isn't a standard ctype function, so we don't need it.

Change-Id: Ie9c09fa6c61b1101b5992fa06da30e373a0c6bf7
2014-07-14 15:48:02 -07:00
Elliott Hughes
ee3608f9d3 Merge "Fix visibility for a bunch more symbols." 2014-07-14 17:01:21 +00:00
Elliott Hughes
a167eef548 Fix visibility for a bunch more symbols.
Bug: 11156955
Bug: 15291317
Change-Id: I664f25cce7c17085a101d6593d8e01525a1f6a90
2014-07-14 15:13:30 -07:00
Elliott Hughes
673bff01ae Merge "Implement rand/srand in terms of random/srandom." 2014-07-14 17:20:33 +00: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
Elliott Hughes
4ae938698c Merge "Sync upstream-openbsd." 2014-07-14 17:15:23 +00:00
Elliott Hughes
4f0b67a8db Sync upstream-openbsd.
Change-Id: I5b9961a57e2ff05f63bd218c130bf8347850b9be
2014-07-14 11:22:59 -07:00
Dmitriy Ivanov
91f2074e5f Merge "Upstream atexit" 2014-07-14 17:20:33 +00:00
Dmitriy Ivanov
53c3c271dc Upstream atexit
Change-Id: Ia454a2181b5058ed9783dc02b6b1805d0e4d2715
2014-07-14 12:05:16 -07:00
388 changed files with 12418 additions and 7259 deletions

View File

@@ -4,40 +4,52 @@ Working on bionic
What are the big pieces of bionic?
----------------------------------
libc/ --- libc.so, libc.a
The C library. Stuff like fopen(3) and kill(2).
libm/ --- libm.so, libm.a
The math library. Traditionally Unix systems kept stuff like sin(3) and
cos(3) in a separate library to save space in the days before shared
libraries.
libdl/ --- libdl.so
The dynamic linker interface library. This is actually just a bunch of
stubs that the dynamic linker replaces with pointers to its own
implementation at runtime. This is where stuff like dlopen(3) lives.
libstdc++/ --- libstdc++.so
The C++ ABI support functions. The C++ compiler doesn't know how to
implement thread-safe static initialization and the like, so it just calls
functions that are supplied by the system. Stuff like __cxa_guard_acquire
and __cxa_pure_virtual live here.
#### libc/ --- libc.so, libc.a
linker/ --- /system/bin/linker and /system/bin/linker64
The dynamic linker. When you run a dynamically-linked executable, its ELF
file has a DT_INTERP entry that says "use the following program to start me".
On Android, that's either linker or linker64 (depending on whether it's a
32-bit or 64-bit executable). It's responsible for loading the ELF executable
into memory and resolving references to symbols (so that when your code tries
to jump to fopen(3), say, it lands in the right place).
The C library. Stuff like `fopen(3)` and `kill(2)`.
tests/ --- unit tests
The tests/ directory contains unit tests. Roughly arranged as one file per
publicly-exported header file.
benchmarks/ --- benchmarks
The benchmarks/ directory contains benchmarks.
#### libm/ --- libm.so, libm.a
The math library. Traditionally Unix systems kept stuff like `sin(3)` and
`cos(3)` in a separate library to save space in the days before shared
libraries.
#### libdl/ --- libdl.so
The dynamic linker interface library. This is actually just a bunch of stubs
that the dynamic linker replaces with pointers to its own implementation at
runtime. This is where stuff like `dlopen(3)` lives.
#### libstdc++/ --- libstdc++.so
The C++ ABI support functions. The C++ compiler doesn't know how to implement
thread-safe static initialization and the like, so it just calls functions that
are supplied by the system. Stuff like `__cxa_guard_acquire` and
`__cxa_pure_virtual` live here.
#### linker/ --- /system/bin/linker and /system/bin/linker64
The dynamic linker. When you run a dynamically-linked executable, its ELF file
has a `DT_INTERP` entry that says "use the following program to start me". On
Android, that's either `linker` or `linker64` (depending on whether it's a
32-bit or 64-bit executable). It's responsible for loading the ELF executable
into memory and resolving references to symbols (so that when your code tries to
jump to `fopen(3)`, say, it lands in the right place).
#### tests/ --- unit tests
The `tests/` directory contains unit tests. Roughly arranged as one file per
publicly-exported header file.
#### benchmarks/ --- benchmarks
The `benchmarks/` directory contains benchmarks.
What's in libc/?
----------------
<pre>
libc/
arch-arm/
arch-arm64/
@@ -121,6 +133,7 @@ libc/
zoneinfo/
# Android-format time zone data.
# See 'Updating tzdata' later.
</pre>
Adding system calls
@@ -160,3 +173,74 @@ This is fully automated:
1. Run update-tzdata.py.
Running the tests
-----------------
The tests are all built from the tests/ directory.
### Device tests
$ mma
$ adb sync
$ adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests32
$ adb shell \
/data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static32
# Only for 64-bit targets
$ adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests64
$ adb shell \
/data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static64
### Host tests
The host tests require that you have `lunch`ed either an x86 or x86_64 target.
$ mma
# 64-bit tests for 64-bit targets, 32-bit otherwise.
$ mm bionic-unit-tests-run-on-host
# Only exists for 64-bit targets.
$ mm bionic-unit-tests-run-on-host32
### Against glibc
As a way to check that our tests do in fact test the correct behavior (and not
just the behavior we think is correct), it is possible to run the tests against
the host's glibc.
$ mma
$ bionic-unit-tests-glibc32 # already in your path
$ bionic-unit-tests-glibc64
Gathering test coverage
-----------------------
For either host or target coverage, you must first:
* `$ export NATIVE_COVERAGE=true`
* Note that the build system is ignorant to this flag being toggled, i.e. if
you change this flag, you will have to manually rebuild bionic.
* Set `bionic_coverage=true` in `libc/Android.mk` and `libm/Android.mk`.
### Coverage from device tests
$ mma
$ adb sync
$ adb shell \
GCOV_PREFIX=/data/local/tmp/gcov \
GCOV_PREFIX_STRIP=`echo $ANDROID_BUILD_TOP | grep -o / | wc -l` \
/data/nativetest/bionic-unit-tests/bionic-unit-tests32
$ acov
`acov` will pull all coverage information from the device, push it to the right
directories, run `lcov`, and open the coverage report in your browser.
### Coverage from host tests
First, build and run the host tests as usual (see above).
$ croot
$ lcov -c -d $ANDROID_PRODUCT_OUT -o coverage.info
$ genhtml -o covreport coverage.info # or lcov --list coverage.info
The coverage report is now available at `covreport/index.html`.

View File

@@ -49,9 +49,8 @@ LOCAL_MODULE_STEM_64 := bionic-benchmarks64
LOCAL_MULTILIB := both
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_CFLAGS += $(benchmark_c_flags)
LOCAL_C_INCLUDES += external/stlport/stlport bionic/ bionic/libstdc++/include
LOCAL_SHARED_LIBRARIES += libstlport
LOCAL_SRC_FILES := $(benchmark_src_files)
LOCAL_CXX_STL := libc++
include $(BUILD_EXECUTABLE)
ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64))

View File

@@ -20,8 +20,8 @@
#include <math.h>
// Avoid optimization.
double d;
double v;
volatile double d;
volatile double v;
static void BM_math_sqrt(int iters) {
StartBenchmarkTiming();

View File

@@ -105,3 +105,35 @@ static void BM_pthread_mutex_lock_RECURSIVE(int iters) {
StopBenchmarkTiming();
}
BENCHMARK(BM_pthread_mutex_lock_RECURSIVE);
static void BM_pthread_rw_lock_read(int iters) {
StopBenchmarkTiming();
pthread_rwlock_t lock;
pthread_rwlock_init(&lock, NULL);
StartBenchmarkTiming();
for (int i = 0; i < iters; ++i) {
pthread_rwlock_rdlock(&lock);
pthread_rwlock_unlock(&lock);
}
StopBenchmarkTiming();
pthread_rwlock_destroy(&lock);
}
BENCHMARK(BM_pthread_rw_lock_read);
static void BM_pthread_rw_lock_write(int iters) {
StopBenchmarkTiming();
pthread_rwlock_t lock;
pthread_rwlock_init(&lock, NULL);
StartBenchmarkTiming();
for (int i = 0; i < iters; ++i) {
pthread_rwlock_wrlock(&lock);
pthread_rwlock_unlock(&lock);
}
StopBenchmarkTiming();
pthread_rwlock_destroy(&lock);
}
BENCHMARK(BM_pthread_rw_lock_write);

View File

@@ -1,5 +1,7 @@
LOCAL_PATH := $(call my-dir)
bionic_coverage := false
# Make everything depend on any changes to included makefiles.
libc_common_additional_dependencies := $(LOCAL_PATH)/Android.mk
@@ -38,8 +40,6 @@ endif
# =========================================================
libc_common_src_files := \
bionic/bindresvport.c \
bionic/daemon.c \
bionic/err.c \
bionic/ether_aton.c \
bionic/ether_ntoa.c \
bionic/fts.c \
@@ -51,19 +51,16 @@ libc_common_src_files := \
bionic/ioctl.c \
bionic/isatty.c \
bionic/memmem.c \
bionic/pathconf.c \
bionic/pututline.c \
bionic/sched_cpualloc.c \
bionic/sched_cpucount.c \
bionic/semaphore.c \
bionic/sigblock.c \
bionic/siginterrupt.c \
bionic/sigsetmask.c \
bionic/system_properties_compat.c \
stdio/findfp.c \
stdio/fread.c \
stdio/snprintf.c\
stdio/sprintf.c \
stdio/stdio_ext.cpp \
# Fortify implementations of libc functions.
libc_common_src_files += \
@@ -92,6 +89,7 @@ libc_bionic_src_files := \
bionic/access.cpp \
bionic/assert.cpp \
bionic/atof.cpp \
bionic/bionic_systrace.cpp \
bionic/bionic_time_conversions.cpp \
bionic/brk.cpp \
bionic/c16rtomb.cpp \
@@ -100,6 +98,7 @@ libc_bionic_src_files := \
bionic/chown.cpp \
bionic/clearenv.cpp \
bionic/clock.cpp \
bionic/clock_nanosleep.cpp \
bionic/clone.cpp \
bionic/__cmsg_nxthdr.cpp \
bionic/connect.cpp \
@@ -123,6 +122,7 @@ libc_bionic_src_files := \
bionic/getpgrp.cpp \
bionic/getpid.cpp \
bionic/gettid.cpp \
bionic/__gnu_basename.cpp \
bionic/inotify_init.cpp \
bionic/lchown.cpp \
bionic/lfs64_support.cpp \
@@ -134,6 +134,7 @@ libc_bionic_src_files := \
bionic/link.cpp \
bionic/locale.cpp \
bionic/lstat.cpp \
bionic/malloc_info.cpp \
bionic/mbrtoc16.cpp \
bionic/mbrtoc32.cpp \
bionic/mbstate.cpp \
@@ -143,6 +144,7 @@ libc_bionic_src_files := \
bionic/mntent.cpp \
bionic/NetdClientDispatch.cpp \
bionic/open.cpp \
bionic/pathconf.cpp \
bionic/pause.cpp \
bionic/pipe.cpp \
bionic/poll.cpp \
@@ -182,6 +184,7 @@ libc_bionic_src_files := \
bionic/scandir.cpp \
bionic/sched_getaffinity.cpp \
bionic/sched_getcpu.cpp \
bionic/semaphore.cpp \
bionic/send.cpp \
bionic/setegid.cpp \
bionic/__set_errno.cpp \
@@ -240,9 +243,6 @@ libc_upstream_freebsd_src_files := \
upstream-freebsd/lib/libc/gen/ldexp.c \
upstream-freebsd/lib/libc/gen/sleep.c \
upstream-freebsd/lib/libc/gen/usleep.c \
upstream-freebsd/lib/libc/stdio/fclose.c \
upstream-freebsd/lib/libc/stdio/flags.c \
upstream-freebsd/lib/libc/stdio/fopen.c \
upstream-freebsd/lib/libc/stdlib/abs.c \
upstream-freebsd/lib/libc/stdlib/getopt_long.c \
upstream-freebsd/lib/libc/stdlib/imaxabs.c \
@@ -288,7 +288,6 @@ libc_upstream_netbsd_src_files := \
upstream-netbsd/lib/libc/stdlib/div.c \
upstream-netbsd/lib/libc/stdlib/drand48.c \
upstream-netbsd/lib/libc/stdlib/erand48.c \
upstream-netbsd/lib/libc/stdlib/insque.c \
upstream-netbsd/lib/libc/stdlib/jrand48.c \
upstream-netbsd/lib/libc/stdlib/ldiv.c \
upstream-netbsd/lib/libc/stdlib/lldiv.c \
@@ -297,14 +296,12 @@ libc_upstream_netbsd_src_files := \
upstream-netbsd/lib/libc/stdlib/nrand48.c \
upstream-netbsd/lib/libc/stdlib/_rand48.c \
upstream-netbsd/lib/libc/stdlib/rand_r.c \
upstream-netbsd/lib/libc/stdlib/remque.c \
upstream-netbsd/lib/libc/stdlib/seed48.c \
upstream-netbsd/lib/libc/stdlib/srand48.c \
upstream-netbsd/lib/libc/string/memccpy.c \
upstream-netbsd/lib/libc/string/strcasestr.c \
upstream-netbsd/lib/libc/string/strcoll.c \
upstream-netbsd/lib/libc/string/strxfrm.c \
upstream-netbsd/lib/libc/unistd/killpg.c \
libc_upstream_openbsd_gdtoa_src_files := \
upstream-openbsd/android/gdtoa_support.cpp \
@@ -334,10 +331,14 @@ libc_upstream_openbsd_gdtoa_src_files_64 := \
upstream-openbsd/lib/libc/gdtoa/strtorQ.c \
libc_upstream_openbsd_src_files := \
upstream-openbsd/lib/libc/compat-43/killpg.c \
upstream-openbsd/lib/libc/crypt/arc4random.c \
upstream-openbsd/lib/libc/crypt/arc4random_uniform.c \
upstream-openbsd/lib/libc/gen/alarm.c \
upstream-openbsd/lib/libc/gen/ctype_.c \
upstream-openbsd/lib/libc/gen/daemon.c \
upstream-openbsd/lib/libc/gen/err.c \
upstream-openbsd/lib/libc/gen/errx.c \
upstream-openbsd/lib/libc/gen/exec.c \
upstream-openbsd/lib/libc/gen/fnmatch.c \
upstream-openbsd/lib/libc/gen/ftok.c \
@@ -347,6 +348,12 @@ libc_upstream_openbsd_src_files := \
upstream-openbsd/lib/libc/gen/time.c \
upstream-openbsd/lib/libc/gen/tolower_.c \
upstream-openbsd/lib/libc/gen/toupper_.c \
upstream-openbsd/lib/libc/gen/verr.c \
upstream-openbsd/lib/libc/gen/verrx.c \
upstream-openbsd/lib/libc/gen/vwarn.c \
upstream-openbsd/lib/libc/gen/vwarnx.c \
upstream-openbsd/lib/libc/gen/warn.c \
upstream-openbsd/lib/libc/gen/warnx.c \
upstream-openbsd/lib/libc/locale/btowc.c \
upstream-openbsd/lib/libc/locale/mbrlen.c \
upstream-openbsd/lib/libc/locale/mbstowcs.c \
@@ -380,6 +387,7 @@ libc_upstream_openbsd_src_files := \
upstream-openbsd/lib/libc/stdio/asprintf.c \
upstream-openbsd/lib/libc/stdio/clrerr.c \
upstream-openbsd/lib/libc/stdio/dprintf.c \
upstream-openbsd/lib/libc/stdio/fclose.c \
upstream-openbsd/lib/libc/stdio/fdopen.c \
upstream-openbsd/lib/libc/stdio/feof.c \
upstream-openbsd/lib/libc/stdio/ferror.c \
@@ -391,12 +399,17 @@ libc_upstream_openbsd_src_files := \
upstream-openbsd/lib/libc/stdio/fgetwc.c \
upstream-openbsd/lib/libc/stdio/fgetws.c \
upstream-openbsd/lib/libc/stdio/fileno.c \
upstream-openbsd/lib/libc/stdio/findfp.c \
upstream-openbsd/lib/libc/stdio/flags.c \
upstream-openbsd/lib/libc/stdio/fmemopen.c \
upstream-openbsd/lib/libc/stdio/fopen.c \
upstream-openbsd/lib/libc/stdio/fprintf.c \
upstream-openbsd/lib/libc/stdio/fpurge.c \
upstream-openbsd/lib/libc/stdio/fputc.c \
upstream-openbsd/lib/libc/stdio/fputs.c \
upstream-openbsd/lib/libc/stdio/fputwc.c \
upstream-openbsd/lib/libc/stdio/fputws.c \
upstream-openbsd/lib/libc/stdio/fread.c \
upstream-openbsd/lib/libc/stdio/freopen.c \
upstream-openbsd/lib/libc/stdio/fscanf.c \
upstream-openbsd/lib/libc/stdio/fseek.c \
@@ -418,6 +431,8 @@ libc_upstream_openbsd_src_files := \
upstream-openbsd/lib/libc/stdio/getwchar.c \
upstream-openbsd/lib/libc/stdio/makebuf.c \
upstream-openbsd/lib/libc/stdio/mktemp.c \
upstream-openbsd/lib/libc/stdio/open_memstream.c \
upstream-openbsd/lib/libc/stdio/open_wmemstream.c \
upstream-openbsd/lib/libc/stdio/perror.c \
upstream-openbsd/lib/libc/stdio/printf.c \
upstream-openbsd/lib/libc/stdio/putc.c \
@@ -466,7 +481,9 @@ libc_upstream_openbsd_src_files := \
upstream-openbsd/lib/libc/stdlib/atoll.c \
upstream-openbsd/lib/libc/stdlib/exit.c \
upstream-openbsd/lib/libc/stdlib/getenv.c \
upstream-openbsd/lib/libc/stdlib/insque.c \
upstream-openbsd/lib/libc/stdlib/lsearch.c \
upstream-openbsd/lib/libc/stdlib/remque.c \
upstream-openbsd/lib/libc/stdlib/setenv.c \
upstream-openbsd/lib/libc/stdlib/strtoimax.c \
upstream-openbsd/lib/libc/stdlib/strtol.c \
@@ -586,7 +603,9 @@ LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_MODULE := libc_stack_protector
LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
include $(BUILD_STATIC_LIBRARY)
@@ -624,7 +643,9 @@ LOCAL_C_INCLUDES := $(libc_common_c_includes) $(LOCAL_PATH)/tzcode/
LOCAL_MODULE := libc_tzcode
LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
include $(BUILD_STATIC_LIBRARY)
@@ -642,7 +663,13 @@ LOCAL_SRC_FILES := \
upstream-netbsd/lib/libc/isc/ev_timers.c \
upstream-netbsd/lib/libc/resolv/mtctxres.c \
LOCAL_CFLAGS := \
# We use the OpenBSD res_random.
LOCAL_CFLAGS += \
-Dres_randomid=__res_randomid
LOCAL_SRC_FILES += \
upstream-openbsd/lib/libc/net/res_random.c \
LOCAL_CFLAGS += \
$(libc_common_cflags) \
-DANDROID_CHANGES \
-DINET6 \
@@ -660,7 +687,9 @@ LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_MODULE := libc_dns
LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
include $(BUILD_STATIC_LIBRARY)
@@ -689,7 +718,9 @@ LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_MODULE := libc_freebsd
LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_freebsd_src_files))
@@ -720,7 +751,9 @@ LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_MODULE := libc_netbsd
LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_netbsd_src_files))
@@ -746,7 +779,10 @@ endif
LOCAL_CFLAGS := \
$(libc_common_cflags) \
-Wno-sign-compare -Wno-uninitialized -Wno-unused-parameter \
-Wno-missing-field-initializers \
-Wno-sign-compare \
-Wno-uninitialized \
-Wno-unused-parameter \
-I$(LOCAL_PATH)/private \
-I$(LOCAL_PATH)/upstream-openbsd/android/include \
-I$(LOCAL_PATH)/upstream-openbsd/lib/libc/include \
@@ -758,7 +794,9 @@ LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_MODULE := libc_openbsd
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_openbsd_src_files))
@@ -797,7 +835,9 @@ LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_MODULE := libc_gdtoa
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
include $(BUILD_STATIC_LIBRARY)
@@ -820,11 +860,13 @@ endif
LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_C_INCLUDES := $(libc_common_c_includes) bionic/libstdc++/include
LOCAL_MODULE := libc_bionic
LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_bionic_src_files))
@@ -843,12 +885,13 @@ LOCAL_CFLAGS := $(libc_common_cflags) \
LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_C_INCLUDES := $(libc_common_c_includes) bionic/libstdc++/include
LOCAL_MODULE := libc_cxa
# GCC refuses to hide new/delete
LOCAL_CLANG := true
LOCAL_CLANG := true # GCC refuses to hide new/delete
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
include $(BUILD_STATIC_LIBRARY)
@@ -866,7 +909,9 @@ endif
LOCAL_MODULE := libc_syscalls
LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
include $(BUILD_STATIC_LIBRARY)
@@ -885,7 +930,9 @@ LOCAL_MODULE := libc_aeabi
LOCAL_CLANG := $(use_clang)
LOCAL_CFLAGS := $(libc_common_cflags) -fno-builtin
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
include $(BUILD_STATIC_LIBRARY)
@@ -922,10 +969,12 @@ ifneq ($(MALLOC_IMPL),dlmalloc)
LOCAL_WHOLE_STATIC_LIBRARIES += libjemalloc
endif
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES :=
# TODO: split out the asflags.
LOCAL_ASFLAGS := $(LOCAL_CFLAGS)
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_common_src_files))
@@ -961,7 +1010,9 @@ LOCAL_MODULE := libc_nomalloc
LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_arch_static_src_files))
@@ -982,6 +1033,8 @@ LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_MODULE := libc_malloc
LOCAL_CLANG := $(use_clang)
LOCAL_CXX_STL := none
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
include $(BUILD_STATIC_LIBRARY)
@@ -1007,7 +1060,9 @@ LOCAL_MODULE := libc
LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
$(eval $(call patch-up-arch-specific-flags,LOCAL_SRC_FILES,libc_arch_static_src_files))
@@ -1049,6 +1104,7 @@ LOCAL_STRIP_MODULE := keep_symbols
LOCAL_SHARED_LIBRARIES := libdl
LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES :=
# We'd really like to do this for all architectures, but since this wasn't done
@@ -1068,6 +1124,7 @@ LOCAL_SRC_FILES_arm += \
arch-common/bionic/crtbegin_so.c \
arch-arm/bionic/atexit_legacy.c \
arch-common/bionic/crtend_so.S
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
include $(BUILD_SHARED_LIBRARY)
@@ -1085,10 +1142,7 @@ ifneq ($(TARGET_BUILD_VARIANT),user)
# ========================================================
include $(CLEAR_VARS)
LOCAL_CFLAGS := \
$(libc_common_cflags) \
-DMALLOC_LEAK_CHECK \
LOCAL_CFLAGS := $(libc_common_cflags)
LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags)
@@ -1108,14 +1162,16 @@ LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_SHARED_LIBRARIES := libc libdl
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES :=
# Only need this for arm since libc++ uses its own unwind code that
# doesn't mix with the other default unwind code.
LOCAL_STATIC_LIBRARIES_arm := libc++
LOCAL_STATIC_LIBRARIES_arm := libunwind_llvm
LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
# Don't install on release build
LOCAL_MODULE_TAGS := eng debug
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
include $(BUILD_SHARED_LIBRARY)
@@ -1144,10 +1200,12 @@ LOCAL_CLANG := $(use_clang)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libc_common_additional_dependencies)
LOCAL_SHARED_LIBRARIES := libc libdl
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES :=
# Don't install on release build
LOCAL_MODULE_TAGS := eng debug
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
$(eval $(call patch-up-arch-specific-flags,LOCAL_CFLAGS,libc_common_cflags))
include $(BUILD_SHARED_LIBRARY)
@@ -1164,26 +1222,30 @@ libstdcxx_common_src_files := \
bionic/libc_logging.cpp \
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_C_INCLUDES := $(libc_common_c_includes) bionic/libstdc++/include
LOCAL_CFLAGS := $(libc_common_cflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_SRC_FILES := $(libstdcxx_common_src_files)
LOCAL_MODULE:= libstdc++
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES := libc
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
include $(BUILD_SHARED_LIBRARY)
# ========================================================
# libstdc++.a
# ========================================================
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_C_INCLUDES := $(libc_common_c_includes) bionic/libstdc++/include
LOCAL_CFLAGS := $(libc_common_cflags)
LOCAL_CPPFLAGS := $(libc_common_cppflags)
LOCAL_SRC_FILES := $(libstdcxx_common_src_files)
LOCAL_MODULE:= libstdc++
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_CXX_STL := none
LOCAL_SYSTEM_SHARED_LIBRARIES := libc
LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
include $(BUILD_STATIC_LIBRARY)

View File

@@ -2510,35 +2510,6 @@ SUCH DAMAGE.
-------------------------------------------------------------------
Copyright (c) 1993
The Regents of the University of California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
-------------------------------------------------------------------
Copyright (c) 1993
The Regents of the University of California. All rights reserved.
@@ -3131,38 +3102,6 @@ SUCH DAMAGE.
-------------------------------------------------------------------
Copyright (c) 1999 Kungliga Tekniska Högskolan
(Royal Institute of Technology, Stockholm, Sweden).
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of KTH nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY KTH AND ITS CONTRIBUTORS ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KTH OR ITS CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-------------------------------------------------------------------
Copyright (c) 2000 Ben Harris.
Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
All rights reserved.
@@ -4422,6 +4361,39 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------
Copyright (c) 2011 Martin Pieuchot <mpi@openbsd.org>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-------------------------------------------------------------------
Copyright (c) 2011 Martin Pieuchot <mpi@openbsd.org>
Copyright (c) 2009 Ted Unangst
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-------------------------------------------------------------------
Copyright (c) 2011 The Android Open Source Project
Copyright (c) 2008 ARM Ltd
All rights reserved.
@@ -4853,6 +4825,42 @@ SUCH DAMAGE.
-------------------------------------------------------------------
Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
Copyright 2008 Damien Miller <djm@openbsd.org>
All rights reserved.
Theo de Raadt <deraadt@openbsd.org> came up with the idea of using
such a mathematical system to generate more random (yet non-repeating)
ids to solve the resolver/named problem. But Niels designed the
actual system based on the constraints.
Later modified by Damien Miller to wrap the LCG output in a 15-bit
permutation generator based on a Luby-Rackoff block cipher. This
ensures the output is non-repeating and preserves the MSB twiddle
trick, but makes it more resistant to LCG prediction.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------
Copyright 2000 David E. O'Brien, John D. Polstra.
All rights reserved.

View File

@@ -202,9 +202,9 @@ int swapoff(const char*) all
int settimeofday(const struct timeval*, const struct timezone*) all
clock_t times(struct tms*) all
int nanosleep(const struct timespec*, struct timespec*) all
int clock_settime(clockid_t clk_id, const struct timespec* tp) all
int clock_getres(clockid_t clk_id, struct timespec* res) all
int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec* req, struct timespec* rem) all
int clock_settime(clockid_t, const struct timespec*) all
int clock_getres(clockid_t, struct timespec*) all
int __clock_nanosleep:clock_nanosleep(clockid_t, int, const struct timespec*, struct timespec*) all
int getitimer(int, const struct itimerval*) all
int setitimer(int, const struct itimerval*, struct itimerval*) all
int __timer_create:timer_create(clockid_t clockid, struct sigevent* evp, __kernel_timer_t* timerid) all
@@ -321,7 +321,7 @@ int __set_tls:__ARM_NR_set_tls(void*) arm
int cacheflush:__ARM_NR_cacheflush(long start, long end, long flags) arm
# MIPS-specific
int _flush_cache:cacheflush(char* addr, const int nbytes, const int op) mips,mips64
int _flush_cache:cacheflush(char* addr, const int nbytes, const int op) mips
int __set_tls:set_thread_area(void*) mips,mips64
# x86-specific

View File

@@ -39,6 +39,9 @@
extern int __cxa_atexit(void (*)(void*), void*, void*);
// All of these are weak symbols to avoid multiple definition errors when
// linking with libstdc++-v3 or compiler-rt.
/* The "C++ ABI for ARM" document states that static C++ constructors,
* which are called from the .init_array, should manually call
* __aeabi_atexit() to register static destructors explicitly.
@@ -47,35 +50,35 @@ extern int __cxa_atexit(void (*)(void*), void*, void*);
* variable from the shared object that contains the constructor/destructor
*/
// Make this a weak symbol to avoid a multiple definition error when linking with libstdc++-v3.
int __attribute__((weak))
__aeabi_atexit(void *object, void (*destructor) (void *), void *dso_handle) {
return __cxa_atexit(destructor, object, dso_handle);
}
void __aeabi_memcpy8(void *dest, const void *src, size_t n) {
void __attribute__((weak))
__aeabi_memcpy8(void *dest, const void *src, size_t n) {
memcpy(dest, src, n);
}
void __aeabi_memcpy4(void *dest, const void *src, size_t n) {
void __attribute__((weak)) __aeabi_memcpy4(void *dest, const void *src, size_t n) {
memcpy(dest, src, n);
}
void __aeabi_memcpy(void *dest, const void *src, size_t n) {
void __attribute__((weak)) __aeabi_memcpy(void *dest, const void *src, size_t n) {
memcpy(dest, src, n);
}
void __aeabi_memmove8(void *dest, const void *src, size_t n) {
void __attribute__((weak)) __aeabi_memmove8(void *dest, const void *src, size_t n) {
memmove(dest, src, n);
}
void __aeabi_memmove4(void *dest, const void *src, size_t n) {
void __attribute__((weak)) __aeabi_memmove4(void *dest, const void *src, size_t n) {
memmove(dest, src, n);
}
void __aeabi_memmove(void *dest, const void *src, size_t n) {
void __attribute__((weak)) __aeabi_memmove(void *dest, const void *src, size_t n) {
memmove(dest, src, n);
}
@@ -84,27 +87,27 @@ void __aeabi_memmove(void *dest, const void *src, size_t n) {
* This allows __aeabi_memclr to tail-call __aeabi_memset
*/
void __aeabi_memset8(void *dest, size_t n, int c) {
void __attribute__((weak)) __aeabi_memset8(void *dest, size_t n, int c) {
memset(dest, c, n);
}
void __aeabi_memset4(void *dest, size_t n, int c) {
void __attribute__((weak)) __aeabi_memset4(void *dest, size_t n, int c) {
memset(dest, c, n);
}
void __aeabi_memset(void *dest, size_t n, int c) {
void __attribute__((weak)) __aeabi_memset(void *dest, size_t n, int c) {
memset(dest, c, n);
}
void __aeabi_memclr8(void *dest, size_t n) {
void __attribute__((weak)) __aeabi_memclr8(void *dest, size_t n) {
__aeabi_memset8(dest, n, 0);
}
void __aeabi_memclr4(void *dest, size_t n) {
void __attribute__((weak)) __aeabi_memclr4(void *dest, size_t n) {
__aeabi_memset4(dest, n, 0);
}
void __aeabi_memclr(void *dest, size_t n) {
void __attribute__((weak)) __aeabi_memclr(void *dest, size_t n) {
__aeabi_memset(dest, n, 0);
}

View File

@@ -107,7 +107,7 @@ ENTRY(_longjmp)
/* validation failed, die die die. */
botch:
bl PIC_SYM(longjmperror, PLT)
bl PIC_SYM(abort, PLT)
bl longjmperror
bl abort
b . - 8 /* Cannot get here */
END(_longjmp)

View File

@@ -40,5 +40,5 @@ ENTRY(abort)
.cfi_def_cfa_offset 8
.cfi_rel_offset r3, 0
.cfi_rel_offset r14, 4
bl PIC_SYM(__libc_android_abort, PLT)
bl __libc_android_abort
END(abort)

View File

@@ -56,7 +56,7 @@ ENTRY(setjmp)
.cfi_rel_offset r14, 4
mov r0, #0x00000000
bl PIC_SYM(sigblock, PLT)
bl sigblock
mov r1, r0
ldmfd sp!, {r0, r14}
@@ -108,7 +108,7 @@ ENTRY(longjmp)
.cfi_adjust_cfa_offset 4
mov r0, r2
bl PIC_SYM(sigsetmask, PLT)
bl sigsetmask
add sp, sp, #4 /* unalign the stack */
.cfi_adjust_cfa_offset -4
@@ -147,7 +147,7 @@ ENTRY(longjmp)
/* validation failed, die die die. */
botch:
bl PIC_SYM(longjmperror, PLT)
bl PIC_SYM(abort, PLT)
bl longjmperror
bl abort
b . - 8 /* Cannot get here */
END(longjmp)

View File

@@ -33,8 +33,6 @@
* SUCH DAMAGE.
*/
#define _ALIGN_TEXT .align 0
#include <private/bionic_asm.h>
#include <machine/setjmp.h>
@@ -50,8 +48,8 @@
ENTRY(sigsetjmp)
teq r1, #0
beq PIC_SYM(_setjmp, PLT)
b PIC_SYM(setjmp, PLT)
beq _setjmp
b setjmp
END(sigsetjmp)
.L_setjmp_magic:
@@ -61,6 +59,6 @@ ENTRY(siglongjmp)
ldr r2, .L_setjmp_magic
ldr r3, [r0]
teq r2, r3
beq PIC_SYM(_longjmp, PLT)
b PIC_SYM(longjmp, PLT)
beq _longjmp
b longjmp
END(siglongjmp)

View File

@@ -39,7 +39,7 @@
ENTRY(__memcpy_chk)
cmp r2, r3
bhi __memcpy_chk_fail
bgt fortify_check_failed
// Fall through to memcpy...
END(__memcpy_chk)
@@ -49,14 +49,11 @@ ENTRY(memcpy)
* ARM ABI. Since we have to save R0, we might as well save R4
* which we can use for better pipelining of the reads below
*/
.save {r0, r4, lr}
stmfd sp!, {r0, r4, lr}
.cfi_def_cfa_offset 12
.cfi_rel_offset r0, 0
.cfi_rel_offset r4, 4
.cfi_rel_offset lr, 8
/* Making room for r5-r11 which will be spilled later */
.pad #28
sub sp, sp, #28
.cfi_adjust_cfa_offset 28
// preload the destination because we'll align it to a cache line
// with small writes. Also start the source "pump".
@@ -66,14 +63,14 @@ ENTRY(memcpy)
/* it simplifies things to take care of len<4 early */
cmp r2, #4
blo .Lcopy_last_3_and_return
blo copy_last_3_and_return
/* compute the offset to align the source
* offset = (4-(src&3))&3 = -src & 3
*/
rsb r3, r1, #0
ands r3, r3, #3
beq .Lsrc_aligned
beq src_aligned
/* align source to 32 bits. We need to insert 2 instructions between
* a ldr[b|h] and str[b|h] because byte and half-word instructions
@@ -88,12 +85,12 @@ ENTRY(memcpy)
strcsb r4, [r0], #1
strcsb r12,[r0], #1
.Lsrc_aligned:
src_aligned:
/* see if src and dst are aligned together (congruent) */
eor r12, r0, r1
tst r12, #3
bne .Lnon_congruent
bne non_congruent
/* Use post-incriment mode for stm to spill r5-r11 to reserved stack
* frame. Don't update sp.
@@ -103,7 +100,7 @@ ENTRY(memcpy)
/* align the destination to a cache-line */
rsb r3, r0, #0
ands r3, r3, #0x1C
beq .Lcongruent_aligned32
beq congruent_aligned32
cmp r3, r2
andhi r3, r2, #0x1C
@@ -118,14 +115,14 @@ ENTRY(memcpy)
strne r10,[r0], #4
sub r2, r2, r3
.Lcongruent_aligned32:
congruent_aligned32:
/*
* here source is aligned to 32 bytes.
*/
.Lcached_aligned32:
cached_aligned32:
subs r2, r2, #32
blo .Lless_than_32_left
blo less_than_32_left
/*
* We preload a cache-line up to 64 bytes ahead. On the 926, this will
@@ -163,7 +160,10 @@ ENTRY(memcpy)
add r2, r2, #32
.Lless_than_32_left:
less_than_32_left:
/*
* less than 32 bytes left at this point (length in r2)
*/
@@ -197,7 +197,7 @@ ENTRY(memcpy)
/********************************************************************/
.Lnon_congruent:
non_congruent:
/*
* here source is aligned to 4 bytes
* but destination is not.
@@ -207,9 +207,9 @@ ENTRY(memcpy)
* partial words in the shift queue)
*/
cmp r2, #4
blo .Lcopy_last_3_and_return
blo copy_last_3_and_return
/* Use post-increment mode for stm to spill r5-r11 to reserved stack
/* Use post-incriment mode for stm to spill r5-r11 to reserved stack
* frame. Don't update sp.
*/
stmea sp, {r5-r11}
@@ -236,7 +236,7 @@ ENTRY(memcpy)
movcs r3, r3, lsr #8
cmp r2, #4
blo .Lpartial_word_tail
blo partial_word_tail
/* Align destination to 32 bytes (cache line boundary) */
1: tst r0, #0x1c
@@ -248,11 +248,11 @@ ENTRY(memcpy)
str r4, [r0], #4
cmp r2, #4
bhs 1b
blo .Lpartial_word_tail
blo partial_word_tail
/* copy 32 bytes at a time */
2: subs r2, r2, #32
blo .Lless_than_thirtytwo
blo less_than_thirtytwo
/* Use immediate mode for the shifts, because there is an extra cycle
* for register shifts, which could account for up to 50% of
@@ -260,11 +260,11 @@ ENTRY(memcpy)
*/
cmp r12, #24
beq .Lloop24
beq loop24
cmp r12, #8
beq .Lloop8
beq loop8
.Lloop16:
loop16:
ldr r12, [r1], #4
1: mov r4, r12
ldmia r1!, { r5,r6,r7, r8,r9,r10,r11}
@@ -289,9 +289,9 @@ ENTRY(memcpy)
stmia r0!, {r3,r4,r5,r6, r7,r8,r9,r10}
mov r3, r11, lsr #16
bhs 1b
b .Lless_than_thirtytwo
b less_than_thirtytwo
.Lloop8:
loop8:
ldr r12, [r1], #4
1: mov r4, r12
ldmia r1!, { r5,r6,r7, r8,r9,r10,r11}
@@ -316,9 +316,9 @@ ENTRY(memcpy)
stmia r0!, {r3,r4,r5,r6, r7,r8,r9,r10}
mov r3, r11, lsr #8
bhs 1b
b .Lless_than_thirtytwo
b less_than_thirtytwo
.Lloop24:
loop24:
ldr r12, [r1], #4
1: mov r4, r12
ldmia r1!, { r5,r6,r7, r8,r9,r10,r11}
@@ -345,12 +345,12 @@ ENTRY(memcpy)
bhs 1b
.Lless_than_thirtytwo:
less_than_thirtytwo:
/* copy the last 0 to 31 bytes of the source */
rsb r12, lr, #32 /* we corrupted r12, recompute it */
add r2, r2, #32
cmp r2, #4
blo .Lpartial_word_tail
blo partial_word_tail
1: ldr r5, [r1], #4
sub r2, r2, #4
@@ -360,7 +360,7 @@ ENTRY(memcpy)
cmp r2, #4
bhs 1b
.Lpartial_word_tail:
partial_word_tail:
/* we have a partial word in the input buffer */
movs r5, lr, lsl #(31-3)
strmib r3, [r0], #1
@@ -372,7 +372,7 @@ ENTRY(memcpy)
/* Refill spilled registers from the stack. Don't update sp. */
ldmfd sp, {r5-r11}
.Lcopy_last_3_and_return:
copy_last_3_and_return:
movs r2, r2, lsl #31 /* copy remaining 0, 1, 2 or 3 bytes */
ldrmib r2, [r1], #1
ldrcsb r3, [r1], #1
@@ -385,15 +385,9 @@ ENTRY(memcpy)
add sp, sp, #28
ldmfd sp!, {r0, r4, lr}
bx lr
END(memcpy)
// Only reached when the __memcpy_chk check fails.
ENTRY_PRIVATE(__memcpy_chk_fail)
// Preserve lr for backtrace.
push {lr}
.cfi_def_cfa_offset 4
.cfi_rel_offset lr, 0
fortify_check_failed:
ldr r0, error_message
ldr r1, error_code
1:
@@ -403,7 +397,7 @@ error_code:
.word BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW
error_message:
.word error_string-(1b+8)
END(__memcpy_chk_fail)
END(memcpy)
.data
error_string:

View File

@@ -38,9 +38,7 @@
#ifndef _ARM32_ASM_H_
#define _ARM32_ASM_H_
#ifndef _ALIGN_TEXT
# define _ALIGN_TEXT .align 0
#endif
#define __bionic_asm_align 0
#undef __bionic_asm_custom_entry
#undef __bionic_asm_custom_end
@@ -50,10 +48,4 @@
#undef __bionic_asm_function_type
#define __bionic_asm_function_type #function
#if defined(__ELF__) && defined(PIC)
#define PIC_SYM(x,y) x ## ( ## y ## )
#else
#define PIC_SYM(x,y) x
#endif
#endif /* !_ARM_ASM_H_ */

View File

@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
ENTRY(clock_nanosleep)
ENTRY(__clock_nanosleep)
mov ip, r7
ldr r7, =__NR_clock_nanosleep
swi #0
@@ -11,4 +11,4 @@ ENTRY(clock_nanosleep)
bxls lr
neg r0, r0
b __set_errno_internal
END(clock_nanosleep)
END(__clock_nanosleep)

View File

@@ -105,7 +105,7 @@ ENTRY(_longjmp)
/* validation failed, die die die */
.L_fail:
bl PIC_SYM(longjmperror, PLT)
bl PIC_SYM(abort, PLT)
bl longjmperror
bl abort
b . - 8 /* Cannot get here */
END(_longjmp)

View File

@@ -45,7 +45,7 @@ ENTRY(setjmp)
stp x0, x30, [sp, #-16]!
mov x0, xzr
bl PIC_SYM(sigblock, PLT)
bl sigblock
mov w1, w0
ldp x0, x30, [sp], #16
@@ -117,7 +117,7 @@ ENTRY(longjmp)
/* validation failed, die die die */
.L_fail:
bl PIC_SYM(longjmperror, PLT)
bl PIC_SYM(abort, PLT)
bl longjmperror
bl abort
b . - 8 /* Cannot get here */
END(longjmp)

View File

@@ -35,8 +35,8 @@
*/
ENTRY(sigsetjmp)
cbz w1, PIC_SYM(_setjmp, PLT)
b PIC_SYM(setjmp, PLT)
cbz w1, _setjmp
b setjmp
END(sigsetjmp)
.L_setjmp_magic:
@@ -46,6 +46,6 @@ ENTRY(siglongjmp)
ldr w2, .L_setjmp_magic
ldr w3, [x0]
cmp w2, w3
b.eq PIC_SYM(_longjmp, PLT)
b PIC_SYM(longjmp, PLT)
b.eq _longjmp
b longjmp
END(siglongjmp)

View File

@@ -38,17 +38,9 @@
#ifndef _AARCH64_ASM_H_
#define _AARCH64_ASM_H_
#ifndef _ALIGN_TEXT
# define _ALIGN_TEXT .align 0
#endif
#define __bionic_asm_align 0
#undef __bionic_asm_function_type
#define __bionic_asm_function_type %function
#if defined(__ELF__) && defined(PIC)
#define PIC_SYM(x,y) x ## ( ## y ## )
#else
#define PIC_SYM(x,y) x
#endif
#endif /* _AARCH64_ASM_H_ */

View File

@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
ENTRY(clock_nanosleep)
ENTRY(__clock_nanosleep)
mov x8, __NR_clock_nanosleep
svc #0
@@ -11,4 +11,5 @@ ENTRY(clock_nanosleep)
b.hi __set_errno_internal
ret
END(clock_nanosleep)
END(__clock_nanosleep)
.hidden __clock_nanosleep

View File

@@ -28,9 +28,7 @@
#ifndef _MIPS64_ASM_H
#define _MIPS64_ASM_H
#ifndef _ALIGN_TEXT
# define _ALIGN_TEXT .align 4
#endif
#define __bionic_asm_align 4
#undef __bionic_asm_custom_entry
#undef __bionic_asm_custom_end

View File

@@ -30,6 +30,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <string.h>
#include "mips-string-ops.h"
#define do_strlen_word(__av) {\
@@ -47,8 +48,8 @@
#define strlen my_strlen
#endif
int
strlen (const void *_a)
size_t
strlen (const char *_a)
{
int cnt = 0;
unsigned x;

View File

@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
ENTRY(clock_nanosleep)
ENTRY(__clock_nanosleep)
.set noreorder
.cpload t9
li v0, __NR_clock_nanosleep
@@ -16,4 +16,4 @@ ENTRY(clock_nanosleep)
j t9
nop
.set reorder
END(clock_nanosleep)
END(__clock_nanosleep)

View File

@@ -52,7 +52,7 @@ LEAF(syscall,FRAMESZ)
#else
move a3, a4
move a4, a5
REG_L a5, FRAMESZ(sp)
move a5, a6
#endif
syscall
move a0, v0

View File

@@ -28,9 +28,7 @@
#ifndef _MIPS64_ASM_H
#define _MIPS64_ASM_H
#ifndef _ALIGN_TEXT
# define _ALIGN_TEXT .align 4
#endif
#define __bionic_asm_align 4
#undef __bionic_asm_custom_entry
#undef __bionic_asm_custom_end

View File

@@ -49,7 +49,6 @@ libc_openbsd_src_files_mips64 += \
libc_bionic_src_files_mips64 += \
arch-mips64/bionic/__bionic_clone.S \
arch-mips64/bionic/_exit_with_stack_teardown.S \
arch-mips64/bionic/__get_sp.S \
arch-mips64/bionic/_setjmp.S \
arch-mips64/bionic/setjmp.S \
arch-mips64/bionic/sigsetjmp.S \

View File

@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
ENTRY(clock_nanosleep)
ENTRY(__clock_nanosleep)
.set push
.set noreorder
li v0, __NR_clock_nanosleep
@@ -22,4 +22,5 @@ ENTRY(clock_nanosleep)
j t9
move ra, t0
.set pop
END(clock_nanosleep)
END(__clock_nanosleep)
.hidden __clock_nanosleep

View File

@@ -1,25 +0,0 @@
/* Generated by gensyscalls.py. Do not edit. */
#include <private/bionic_asm.h>
ENTRY(_flush_cache)
.set push
.set noreorder
li v0, __NR_cacheflush
syscall
bnez a3, 1f
move a0, v0
j ra
nop
1:
move t0, ra
bal 2f
nop
2:
.cpsetup ra, t1, 2b
LA t9,__set_errno_internal
.cpreturn
j t9
move ra, t0
.set pop
END(_flush_cache)

View File

@@ -65,21 +65,21 @@ name: \
ENTRY (wcslen)
mov STR(%esp), %edx
#endif
cmp $0, (%edx)
cmpl $0, (%edx)
jz L(exit_tail0)
cmp $0, 4(%edx)
cmpl $0, 4(%edx)
jz L(exit_tail1)
cmp $0, 8(%edx)
cmpl $0, 8(%edx)
jz L(exit_tail2)
cmp $0, 12(%edx)
cmpl $0, 12(%edx)
jz L(exit_tail3)
cmp $0, 16(%edx)
cmpl $0, 16(%edx)
jz L(exit_tail4)
cmp $0, 20(%edx)
cmpl $0, 20(%edx)
jz L(exit_tail5)
cmp $0, 24(%edx)
cmpl $0, 24(%edx)
jz L(exit_tail6)
cmp $0, 28(%edx)
cmpl $0, 28(%edx)
jz L(exit_tail7)
pxor %xmm0, %xmm0

View File

@@ -28,108 +28,10 @@
#include <private/bionic_asm.h>
// DWARF constants.
#define DW_CFA_def_cfa_expression 0x0f
#define DW_CFA_expression 0x10
#define DW_EH_PE_pcrel 0x10
#define DW_EH_PE_sdata4 0x0b
#define DW_OP_breg4 0x74
#define DW_OP_deref 0x06
// Offsets into struct sigcontext.
#define OFFSET_EDI 16
#define OFFSET_ESI 20
#define OFFSET_EBP 24
#define OFFSET_ESP 28
#define OFFSET_EBX 32
#define OFFSET_EDX 36
#define OFFSET_ECX 40
#define OFFSET_EAX 44
#define OFFSET_EIP 56
// Non-standard DWARF constants for the x86 registers.
#define DW_x86_REG_EAX 0
#define DW_x86_REG_ECX 1
#define DW_x86_REG_EDX 2
#define DW_x86_REG_EBX 3
#define DW_x86_REG_EBP 5
#define DW_x86_REG_ESI 6
#define DW_x86_REG_EDI 7
#define DW_x86_REG_EIP 8
#define cfi_signal_frame_start(f) \
.section .eh_frame,"a",@progbits; \
.L ## f ## _START_EH_FRAME: \
.long 2f - 1f; /* CIE length. */ \
1:.long 0; /* CIE ID. */ \
.byte 1; /* Version. */ \
.string "zRS"; /* Augmentation string. */ \
.uleb128 1; /* Code alignment factor. */ \
.sleb128 -4; /* Data alignment factor. */ \
.uleb128 DW_x86_REG_EIP; /* Return address register. */ \
.uleb128 1; /* 1 byte of augmentation data. */ \
.byte (DW_EH_PE_pcrel|DW_EH_PE_sdata4); /* FDE encoding. */ \
.align 8; \
2: \
.long .L ## f ## _END_FDE - .L ## f ## _START_FDE; /* FDE length. */ \
.L ## f ## _START_FDE: \
.long .L ## f ## _START_FDE - .L ## f ## _START_EH_FRAME; /* CIE location. */ \
.long (.L ## f ## _START - 1) - .; /* pcrel start address (see FDE encoding above). */ \
.long .L ## f ## _END - (.L ## f ## _START - 1); /* Function this FDE applies to. */ \
.uleb128 0; /* FDE augmentation length. */ \
#define cfi_signal_frame_end(f) \
.L ## f ## _END_FDE: \
#define cfi_def_cfa(offset) \
.byte DW_CFA_def_cfa_expression; \
.uleb128 2f-1f; \
1:.byte DW_OP_breg4; \
.sleb128 offset; \
.byte DW_OP_deref; \
2: \
#define cfi_offset(reg_number,offset) \
.byte DW_CFA_expression; \
.uleb128 reg_number; \
.uleb128 2f-1f; \
1:.byte DW_OP_breg4; \
.sleb128 offset; \
2: \
ENTRY_PRIVATE(__restore)
.L__restore_START:
// This function must have exactly this instruction sequence for gdb and libunwind.
// This function must have exactly this name for gdb.
ENTRY(__restore)
popl %eax
movl $__NR_sigreturn, %eax
int $0x80
.L__restore_END:
END(__restore)
cfi_signal_frame_start(__restore)
cfi_def_cfa(OFFSET_ESP + 4)
cfi_offset(DW_x86_REG_EDI, OFFSET_EDI + 4)
cfi_offset(DW_x86_REG_ESI, OFFSET_ESI + 4)
cfi_offset(DW_x86_REG_EBP, OFFSET_EBP + 4)
cfi_offset(DW_x86_REG_EBX, OFFSET_EBX + 4)
cfi_offset(DW_x86_REG_EDX, OFFSET_EDX + 4)
cfi_offset(DW_x86_REG_ECX, OFFSET_ECX + 4)
cfi_offset(DW_x86_REG_EAX, OFFSET_EAX + 4)
cfi_offset(DW_x86_REG_EIP, OFFSET_EIP + 4)
cfi_signal_frame_end(__restore)
ENTRY_PRIVATE(__restore_rt)
.L__restore_rt_START:
movl $__NR_rt_sigreturn, %eax
int $0x80
.L__restore_rt_END:
END(__restore_rt)
cfi_signal_frame_start(__restore_rt)
cfi_def_cfa(OFFSET_ESP + 160)
cfi_offset(DW_x86_REG_EDI, OFFSET_EDI + 160)
cfi_offset(DW_x86_REG_ESI, OFFSET_ESI + 160)
cfi_offset(DW_x86_REG_EBP, OFFSET_EBP + 160)
cfi_offset(DW_x86_REG_EBX, OFFSET_EBX + 160)
cfi_offset(DW_x86_REG_EDX, OFFSET_EDX + 160)
cfi_offset(DW_x86_REG_ECX, OFFSET_ECX + 160)
cfi_offset(DW_x86_REG_EAX, OFFSET_EAX + 160)
cfi_offset(DW_x86_REG_EIP, OFFSET_EIP + 160)
cfi_signal_frame_end(__restore_rt)

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2014 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <private/bionic_asm.h>
// This function must have exactly this instruction sequence for gdb and libunwind.
// This function must have exactly this name for gdb.
ENTRY(__restore_rt)
movl $__NR_rt_sigreturn, %eax
int $0x80
END(__restore_rt)

View File

@@ -49,15 +49,6 @@
#define PIC_GOT(x) x@GOT(%ebx)
#define PIC_GOTOFF(x) x@GOTOFF(%ebx)
/* let kernels and others override entrypoint alignment */
#if !defined(_ALIGN_TEXT) && !defined(_KERNEL)
# ifdef _STANDALONE
# define _ALIGN_TEXT .align 1
# elif defined __ELF__
# define _ALIGN_TEXT .align 16
# else
# define _ALIGN_TEXT .align 4
# endif
#endif
#define __bionic_asm_align 16
#endif /* !_I386_ASM_H_ */

View File

@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
ENTRY(clock_nanosleep)
ENTRY(__clock_nanosleep)
pushl %ebx
.cfi_def_cfa_offset 8
.cfi_rel_offset ebx, 0
@@ -33,4 +33,4 @@ ENTRY(clock_nanosleep)
popl %ecx
popl %ebx
ret
END(clock_nanosleep)
END(__clock_nanosleep)

View File

@@ -39,6 +39,7 @@ libc_bionic_src_files_x86 += \
arch-x86/bionic/__bionic_clone.S \
arch-x86/bionic/_exit_with_stack_teardown.S \
arch-x86/bionic/libgcc_compat.c \
arch-x86/bionic/__restore_rt.S \
arch-x86/bionic/__restore.S \
arch-x86/bionic/_setjmp.S \
arch-x86/bionic/setjmp.S \

View File

@@ -28,116 +28,9 @@
#include <private/bionic_asm.h>
// DWARF constants.
#define DW_CFA_def_cfa_expression 0x0f
#define DW_CFA_expression 0x10
#define DW_EH_PE_pcrel 0x10
#define DW_EH_PE_sdata4 0x0b
#define DW_OP_breg4 0x74
#define DW_OP_breg7 0x77
#define DW_OP_deref 0x06
// Offsets into struct ucontext_t of uc_mcontext.gregs[x].
#define OFFSET_R8 40
#define OFFSET_R9 48
#define OFFSET_R10 56
#define OFFSET_R11 64
#define OFFSET_R12 72
#define OFFSET_R13 80
#define OFFSET_R14 88
#define OFFSET_R15 96
#define OFFSET_RDI 104
#define OFFSET_RSI 112
#define OFFSET_RBP 120
#define OFFSET_RSP 160
#define OFFSET_RBX 128
#define OFFSET_RDX 136
#define OFFSET_RAX 144
#define OFFSET_RCX 152
#define OFFSET_RIP 168
// Non-standard DWARF constants for the x86-64 registers.
#define DW_x86_64_RAX 0
#define DW_x86_64_RDX 1
#define DW_x86_64_RCX 2
#define DW_x86_64_RBX 3
#define DW_x86_64_RSI 4
#define DW_x86_64_RDI 5
#define DW_x86_64_RBP 6
#define DW_x86_64_RSP 7
#define DW_x86_64_R8 8
#define DW_x86_64_R9 9
#define DW_x86_64_R10 10
#define DW_x86_64_R11 11
#define DW_x86_64_R12 12
#define DW_x86_64_R13 13
#define DW_x86_64_R14 14
#define DW_x86_64_R15 15
#define DW_x86_64_RIP 16
#define cfi_signal_frame_start(f) \
.section .eh_frame,"a",@progbits; \
.L ## f ## _START_EH_FRAME: \
.long 2f - 1f; /* CIE length. */ \
1:.long 0; /* CIE ID. */ \
.byte 1; /* Version. */ \
.string "zRS"; /* Augmentation string. */ \
.uleb128 1; /* Code alignment factor. */ \
.sleb128 -8; /* Data alignment factor. */ \
.uleb128 DW_x86_64_RIP; /* Return address register. */ \
.uleb128 1; /* 1 byte of augmentation data. */ \
.byte (DW_EH_PE_pcrel | DW_EH_PE_sdata4); /* FDE encoding. */ \
.align 8; \
2: \
.long .L ## f ## _END_FDE - .L ## f ## _START_FDE; /* FDE length. */ \
.L ## f ## _START_FDE: \
.long .L ## f ## _START_FDE - .L ## f ## _START_EH_FRAME; /* CIE location. */ \
.long (.L ## f ## _START - 1) - .; /* pcrel start address (see FDE encoding above). */ \
.long .L ## f ## _END - (.L ## f ## _START - 1); /* Function this FDE applies to. */ \
.uleb128 0; /* FDE augmentation length. */ \
#define cfi_signal_frame_end(f) \
.L ## f ## _END_FDE: \
#define cfi_def_cfa(offset) \
.byte DW_CFA_def_cfa_expression; \
.uleb128 2f-1f; \
1:.byte DW_OP_breg7; \
.sleb128 offset; \
.byte DW_OP_deref; \
2: \
#define cfi_offset(reg_number,offset) \
.byte DW_CFA_expression; \
.uleb128 reg_number; \
.uleb128 2f-1f; \
1:.byte DW_OP_breg7; \
.sleb128 offset; \
2: \
ENTRY_PRIVATE(__restore_rt)
.L__restore_rt_START:
// This function must have exactly this instruction sequence for gdb and libunwind.
// This function must have exactly this name for gdb.
ENTRY(__restore_rt)
mov $__NR_rt_sigreturn, %rax
syscall
.L__restore_rt_END:
END(__restore_rt)
cfi_signal_frame_start(__restore_rt)
cfi_def_cfa(OFFSET_RSP)
cfi_offset(DW_x86_64_R8, OFFSET_R8)
cfi_offset(DW_x86_64_R9, OFFSET_R9)
cfi_offset(DW_x86_64_R10, OFFSET_R10)
cfi_offset(DW_x86_64_R11, OFFSET_R11)
cfi_offset(DW_x86_64_R12, OFFSET_R12)
cfi_offset(DW_x86_64_R13, OFFSET_R13)
cfi_offset(DW_x86_64_R14, OFFSET_R14)
cfi_offset(DW_x86_64_R15, OFFSET_R15)
cfi_offset(DW_x86_64_RDI, OFFSET_RDI)
cfi_offset(DW_x86_64_RSI, OFFSET_RSI)
cfi_offset(DW_x86_64_RBP, OFFSET_RBP)
cfi_offset(DW_x86_64_RSP, OFFSET_RSP)
cfi_offset(DW_x86_64_RBX, OFFSET_RBX)
cfi_offset(DW_x86_64_RDX, OFFSET_RDX)
cfi_offset(DW_x86_64_RAX, OFFSET_RAX)
cfi_offset(DW_x86_64_RCX, OFFSET_RCX)
cfi_offset(DW_x86_64_RIP, OFFSET_RIP)
cfi_signal_frame_end(__restore_rt)

View File

@@ -40,13 +40,6 @@
#define PIC_PLT(x) x@PLT
#define PIC_GOT(x) x@GOTPCREL(%rip)
/* let kernels and others override entrypoint alignment */
#ifndef _ALIGN_TEXT
# ifdef _STANDALONE
# define _ALIGN_TEXT .align 4
# else
# define _ALIGN_TEXT .align 16
# endif
#endif
#define __bionic_asm_align 16
#endif /* !_AMD64_ASM_H_ */

View File

@@ -2,7 +2,7 @@
#include <private/bionic_asm.h>
ENTRY(clock_nanosleep)
ENTRY(__clock_nanosleep)
movq %rcx, %r10
movl $__NR_clock_nanosleep, %eax
syscall
@@ -13,4 +13,5 @@ ENTRY(clock_nanosleep)
call __set_errno_internal
1:
ret
END(clock_nanosleep)
END(__clock_nanosleep)
.hidden __clock_nanosleep

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011 The Android Open Source Project
* Copyright (C) 2014 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,16 +26,10 @@
* SUCH DAMAGE.
*/
#ifndef _BIONIC_PTHREAD_H
#define _BIONIC_PTHREAD_H
#define _GNU_SOURCE 1
#include <string.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
/* Internal, not an NDK API */
extern pid_t __pthread_gettid(pthread_t thid);
__END_DECLS
#endif /* _BIONIC_PTHREAD_H */
extern "C" const char* __gnu_basename(const char* path) {
const char* last_slash = strrchr(path, '/');
return (last_slash != NULL) ? last_slash + 1 : path;
}

View File

@@ -0,0 +1,107 @@
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cutils/trace.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include "private/bionic_systrace.h"
#include "private/libc_logging.h"
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <sys/_system_properties.h>
#define WRITE_OFFSET 32
static const prop_info* g_pinfo = NULL;
static uint32_t g_serial = -1;
static uint64_t g_tags = 0;
static int g_trace_marker_fd = -1;
static bool should_trace() {
// If g_pinfo is null, this means that systrace hasn't been run and it's safe to
// assume that no trace writing will need to take place. However, to avoid running
// this costly find check each time, we set it to a non-tracing value so that next
// time, it will just check the serial to see if the value has been changed.
// this function also deals with the bootup case, during which the call to property
// set will fail if the property server hasn't yet started.
if (g_pinfo == NULL) {
g_pinfo = __system_property_find("debug.atrace.tags.enableflags");
if (g_pinfo == NULL) {
__system_property_set("debug.atrace.tags.enableflags", "0");
g_pinfo = __system_property_find("debug.atrace.tags.enableflags");
if (g_pinfo == NULL) {
return false;
}
}
}
// Find out which tags have been enabled on the command line and set
// the value of tags accordingly. If the value of the property changes,
// the serial will also change, so the costly system_property_read function
// can be avoided by calling the much cheaper system_property_serial
// first. The values within pinfo may change, but its location is guaranteed
// not to move.
const uint32_t cur_serial = __system_property_serial(g_pinfo);
if (cur_serial != g_serial) {
g_serial = cur_serial;
char value[PROP_VALUE_MAX];
__system_property_read(g_pinfo, 0, value);
g_tags = strtoull(value, NULL, 0);
}
// Finally, verify that this tag value enables bionic tracing.
return ((g_tags & ATRACE_TAG_BIONIC) != 0);
}
ScopedTrace::ScopedTrace(const char* message) {
if (!should_trace()) {
return;
}
if (g_trace_marker_fd == -1) {
g_trace_marker_fd = open("/sys/kernel/debug/tracing/trace_marker", O_CLOEXEC | O_WRONLY);
if (g_trace_marker_fd == -1) {
__libc_fatal("Could not open kernel trace file: %s\n", strerror(errno));
}
}
// If bionic tracing has been enabled, then write the message to the
// kernel trace_marker.
int length = strlen(message);
char buf[length + WRITE_OFFSET];
size_t len = snprintf(buf, length + WRITE_OFFSET, "B|%d|%s", getpid(), message);
ssize_t wbytes = TEMP_FAILURE_RETRY(write(g_trace_marker_fd, buf, len));
// Error while writing
if (static_cast<size_t>(wbytes) != len) {
__libc_fatal("Could not write to kernel trace file: %s\n", strerror(errno));
}
}
ScopedTrace::~ScopedTrace() {
if (!should_trace()) {
return;
}
ssize_t wbytes = TEMP_FAILURE_RETRY(write(g_trace_marker_fd, "E", 1));
// Error while writing
if (static_cast<size_t>(wbytes) != 1) {
__libc_fatal("Could not write to kernel trace file: %s\n", strerror(errno));
}
}

View File

@@ -28,6 +28,8 @@
#include "private/bionic_time_conversions.h"
#include "private/bionic_constants.h"
bool timespec_from_timeval(timespec& ts, const timeval& tv) {
// Whole seconds can just be copied.
ts.tv_sec = tv.tv_sec;
@@ -49,3 +51,19 @@ void timeval_from_timespec(timeval& tv, const timespec& ts) {
tv.tv_sec = ts.tv_sec;
tv.tv_usec = ts.tv_nsec / 1000;
}
// Initializes 'ts' with the difference between 'abs_ts' and the current time
// according to 'clock'. Returns false if abstime already expired, true otherwise.
bool timespec_from_absolute_timespec(timespec& ts, const timespec& abs_ts, clockid_t clock) {
clock_gettime(clock, &ts);
ts.tv_sec = abs_ts.tv_sec - ts.tv_sec;
ts.tv_nsec = abs_ts.tv_nsec - ts.tv_nsec;
if (ts.tv_nsec < 0) {
ts.tv_sec--;
ts.tv_nsec += NS_PER_S;
}
if (ts.tv_nsec < 0 || ts.tv_sec < 0) {
return false;
}
return true;
}

View File

@@ -30,7 +30,7 @@
#include <sys/sysconf.h>
#include <sys/times.h>
#define NS_PER_S 1000000000 // No "private/bionic_constants.h" in lmp-dev.
#include "private/bionic_constants.h"
// http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock.html
clock_t clock() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* Copyright (C) 2014 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,40 +25,14 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _PATHCONF_H_
#define _PATHCONF_H_
#include <sys/cdefs.h>
#include <time.h>
__BEGIN_DECLS
#include "private/ErrnoRestorer.h"
/* constants to be used for the 'name' paremeter of pathconf/fpathconf */
#define _PC_FILESIZEBITS 0x0000
#define _PC_LINK_MAX 0x0001
#define _PC_MAX_CANON 0x0002
#define _PC_MAX_INPUT 0x0003
#define _PC_NAME_MAX 0x0004
#define _PC_PATH_MAX 0x0005
#define _PC_PIPE_BUF 0x0006
#define _PC_2_SYMLINKS 0x0007
#define _PC_ALLOC_SIZE_MIN 0x0008
#define _PC_REC_INCR_XFER_SIZE 0x0009
#define _PC_REC_MAX_XFER_SIZE 0x000a
#define _PC_REC_MIN_XFER_SIZE 0x000b
#define _PC_REC_XFER_ALIGN 0x000c
#define _PC_SYMLINK_MAX 0x000d
#define _PC_CHOWN_RESTRICTED 0x000e
#define _PC_NO_TRUNC 0x000f
#define _PC_VDISABLE 0x0010
#define _PC_ASYNC_IO 0x0011
#define _PC_PRIO_IO 0x0012
#define _PC_SYNC_IO 0x0013
extern long fpathconf(int fildes, int name);
extern long pathconf(const char *path, int name);
__END_DECLS
#endif /* _PATHCONF_H_ */
extern "C" int __clock_nanosleep(clockid_t, int, const timespec*, timespec*);
int clock_nanosleep(clockid_t clock_id, int flags, const timespec* in, timespec* out) {
ErrnoRestorer errno_restorer;
return (__clock_nanosleep(clock_id, flags, in, out) == 0) ? 0 : errno;
}

View File

@@ -26,7 +26,7 @@
* SUCH DAMAGE.
*/
#define __GNU_SOURCE 1
#define _GNU_SOURCE 1
#include <sched.h>
#include <stdlib.h>
#include <stdarg.h>

View File

@@ -71,7 +71,7 @@ __LIBC_HIDDEN__ mapinfo_t* mapinfo_create(pid_t pid) {
struct mapinfo_t* milist = NULL;
char data[1024]; // Used to read lines as well as to construct the filename.
snprintf(data, sizeof(data), "/proc/%d/maps", pid);
FILE* fp = fopen(data, "r");
FILE* fp = fopen(data, "re");
if (fp != NULL) {
while (fgets(data, sizeof(data), fp) != NULL) {
mapinfo_t* mi = parse_maps_line(data);

View File

@@ -78,7 +78,7 @@ DIR* fdopendir(int fd) {
}
DIR* opendir(const char* path) {
int fd = open(path, O_RDONLY | O_DIRECTORY);
int fd = open(path, O_CLOEXEC | O_DIRECTORY | O_RDONLY);
return (fd != -1) ? __allocate_DIR(fd) : NULL;
}

View File

@@ -16,6 +16,7 @@
#include "dlmalloc.h"
#include "malloc.h"
#include "private/bionic_prctl.h"
#include "private/libc_logging.h"
@@ -54,3 +55,25 @@ static void* named_anonymous_mmap(size_t length) {
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, map, length, "libc_malloc");
return map;
}
// Since dlmalloc isn't the default, we'll leave this unimplemented for now. If
// we decide we need it later, we can fill it in.
size_t __mallinfo_narenas() {
return 0;
}
size_t __mallinfo_nbins() {
return 0;
}
struct mallinfo __mallinfo_arena_info(size_t aidx __unused) {
struct mallinfo mi;
memset(&mi, 0, sizeof(mi));
return mi;
}
struct mallinfo __mallinfo_bin_info(size_t aidx __unused, size_t bidx __unused) {
struct mallinfo mi;
memset(&mi, 0, sizeof(mi));
return mi;
}

View File

@@ -36,20 +36,12 @@
// struct __sfileext (see fileext.h).
void flockfile(FILE* fp) {
if (!__sdidinit) {
__sinit();
}
if (fp != NULL) {
pthread_mutex_lock(&_FLOCK(fp));
}
}
int ftrylockfile(FILE* fp) {
if (!__sdidinit) {
__sinit();
}
// The specification for ftrylockfile() says it returns 0 on success,
// or non-zero on error. So return an errno code directly on error.
if (fp == NULL) {
@@ -60,10 +52,6 @@ int ftrylockfile(FILE* fp) {
}
void funlockfile(FILE* fp) {
if (!__sdidinit) {
__sinit();
}
if (fp != NULL) {
pthread_mutex_unlock(&_FLOCK(fp));
}

View File

@@ -1,68 +0,0 @@
/*
* Copyright (c) 1999 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of KTH nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY KTH AND ITS CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KTH OR ITS CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
/* $Heimdal: hash.h,v 1.1 1999/03/22 19:16:25 joda Exp $
$NetBSD: hash.h,v 1.1.1.3 2002/09/12 12:41:42 joda Exp $ */
/* stuff in common between md4, md5, and sha1 */
#ifndef __hash_h__
#define __hash_h__
#include <stdlib.h>
#include <string.h>
#ifndef min
#define min(a,b) (((a)>(b))?(b):(a))
#endif
/* Vector Crays doesn't have a good 32-bit type, or more precisely,
int32_t as defined by <bind/bitypes.h> isn't 32 bits, and we don't
want to depend in being able to redefine this type. To cope with
this we have to clamp the result in some places to [0,2^32); no
need to do this on other machines. Did I say this was a mess?
*/
#ifdef _CRAY
#define CRAYFIX(X) ((X) & 0xffffffff)
#else
#define CRAYFIX(X) (X)
#endif
static inline u_int32_t
cshift (u_int32_t x, unsigned int n)
{
x = CRAYFIX(x);
return CRAYFIX((x << n) | (x >> (32 - n)));
}
#endif /* __hash_h__ */

View File

@@ -17,11 +17,20 @@
#include <ftw.h>
#include <stdlib.h>
int mkstemp64(char* filename) {
// Delegation will work in this case because all the transitive dependencies
// are already 64-bit ready. In particular, we don't have non-O_LARGEFILE
// open (our open is actually open64) and stat and stat64 are the same.
return mkstemp(filename);
// Delegation will work in these cases because all the transitive dependencies
// are already 64-bit ready. In particular, we don't have non-O_LARGEFILE
// open (our open is actually open64) and stat and stat64 are the same.
int mkstemp64(char* path) {
return mkstemp(path);
}
int mkostemp64(char* path, int flags) {
return mkostemp(path, flags);
}
int mkstemps64(char* path, int suffix_length) {
return mkstemps(path, suffix_length);
}
int mkostemps64(char* path, int suffix_length, int flags) {
return mkostemps(path, suffix_length, flags);
}
typedef int (*ftw_fn)(const char*, const struct stat*, int);

View File

@@ -49,7 +49,7 @@ extern "C" int __system_properties_init(void);
extern "C" int __set_tls(void* ptr);
extern "C" int __set_tid_address(int* tid_address);
void __libc_init_vdso();
__LIBC_HIDDEN__ void __libc_init_vdso();
// Not public, but well-known in the BSDs.
const char* __progname;

View File

@@ -75,10 +75,12 @@ struct BufferOutputStream {
len = strlen(data);
}
total += len;
while (len > 0) {
int avail = end_ - pos_;
if (avail == 0) {
break;
return;
}
if (avail > len) {
avail = len;
@@ -87,11 +89,10 @@ struct BufferOutputStream {
pos_ += avail;
pos_[0] = '\0';
len -= avail;
total += avail;
}
}
int total;
size_t total;
private:
char* buffer_;
@@ -109,18 +110,19 @@ struct FdOutputStream {
len = strlen(data);
}
total += len;
while (len > 0) {
int rc = TEMP_FAILURE_RETRY(write(fd_, data, len));
if (rc == -1) {
break;
return;
}
data += rc;
len -= rc;
total += rc;
}
}
int total;
size_t total;
private:
int fd_;

View File

@@ -29,14 +29,13 @@
// Contains definition of structures, global variables, and implementation of
// routines that are used by malloc leak detection code and other components in
// the system. The trick is that some components expect these data and
// routines to be defined / implemented in libc.so library, regardless
// whether or not MALLOC_LEAK_CHECK macro is defined. To make things even
// more tricky, malloc leak detection code, implemented in
// libc_malloc_debug.so also requires access to these variables and routines
// (to fill allocation entry hash table, for example). So, all relevant
// variables and routines are defined / implemented here and exported
// to all, leak detection code and other components via dynamic (libc.so),
// or static (libc.a) linking.
// routines to be defined / implemented in libc.so, regardless whether or not
// malloc leak detection code is going to run. To make things even more tricky,
// malloc leak detection code, implemented in libc_malloc_debug.so also
// requires access to these variables and routines (to fill allocation entry
// hash table, for example). So, all relevant variables and routines are
// defined / implemented here and exported to all, leak detection code and
// other components via dynamic (libc.so), or static (libc.a) linking.
#include "malloc_debug_common.h"

View File

@@ -55,13 +55,6 @@
#include "private/libc_logging.h"
#include "private/ScopedPthreadMutexLocker.h"
// This file should be included into the build only when
// MALLOC_LEAK_CHECK, or MALLOC_QEMU_INSTRUMENT, or both
// macros are defined.
#ifndef MALLOC_LEAK_CHECK
#error MALLOC_LEAK_CHECK is not defined.
#endif // !MALLOC_LEAK_CHECK
extern int gMallocLeakZygoteChild;
extern HashTable* g_hash_table;
extern const MallocDebug* g_malloc_dispatch;

View File

@@ -606,7 +606,7 @@ extern "C" bool malloc_debug_initialize(HashTable*, const MallocDebug* malloc_di
* the memory mapped spaces into writes to an I/O port that emulator
* "listens to" on the other end. Note that until we open and map that
* device, logging to emulator's stdout will not be available. */
int fd = open("/dev/qemu_trace", O_RDWR);
int fd = open("/dev/qemu_trace", O_CLOEXEC | O_RDWR);
if (fd < 0) {
error_log("Unable to open /dev/qemu_trace");
return false;

View File

@@ -0,0 +1,94 @@
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "malloc_info.h"
#include <errno.h>
#include "private/bionic_macros.h"
class __LIBC_HIDDEN__ Elem {
public:
// name must be valid throughout lifetime of the object.
explicit Elem(FILE* fp, const char* name,
const char* attr_fmt = nullptr, ...) {
this->fp = fp;
this->name = name;
fprintf(fp, "<%s", name);
if (attr_fmt != nullptr) {
va_list args;
va_start(args, attr_fmt);
fputc(' ', fp);
vfprintf(fp, attr_fmt, args);
va_end(args);
}
fputc('>', fp);
}
~Elem() noexcept {
fprintf(fp, "</%s>", name);
}
void contents(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
vfprintf(fp, fmt, args);
va_end(args);
}
private:
FILE* fp;
const char* name;
DISALLOW_COPY_AND_ASSIGN(Elem);
};
int malloc_info(int options, FILE* fp) {
if (options != 0) {
errno = EINVAL;
return -1;
}
Elem root(fp, "malloc", "version=\"jemalloc-1\"");
// Dump all of the large allocations in the arenas.
for (size_t i = 0; i < __mallinfo_narenas(); i++) {
struct mallinfo mi = __mallinfo_arena_info(i);
if (mi.hblkhd != 0) {
Elem arena_elem(fp, "heap", "nr=\"%d\"", i);
{
Elem(fp, "allocated-large").contents("%zu", mi.ordblks);
Elem(fp, "allocated-huge").contents("%zu", mi.uordblks);
Elem(fp, "allocated-bins").contents("%zu", mi.fsmblks);
size_t total = 0;
for (size_t j = 0; j < __mallinfo_nbins(); j++) {
struct mallinfo mi = __mallinfo_bin_info(i, j);
if (mi.ordblks != 0) {
Elem bin_elem(fp, "bin", "nr=\"%d\"", j);
Elem(fp, "allocated").contents("%zu", mi.ordblks);
Elem(fp, "nmalloc").contents("%zu", mi.uordblks);
Elem(fp, "ndalloc").contents("%zu", mi.fordblks);
total += mi.ordblks;
}
}
Elem(fp, "bins-total").contents("%zu", total);
}
}
}
return 0;
}

32
libc/bionic/malloc_info.h Normal file
View File

@@ -0,0 +1,32 @@
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef LIBC_BIONIC_MALLOC_INFO_H_
#define LIBC_BIONIC_MALLOC_INFO_H_
#include <malloc.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
__LIBC_HIDDEN__ size_t __mallinfo_narenas();
__LIBC_HIDDEN__ size_t __mallinfo_nbins();
__LIBC_HIDDEN__ struct mallinfo __mallinfo_arena_info(size_t);
__LIBC_HIDDEN__ struct mallinfo __mallinfo_bin_info(size_t, size_t);
__END_DECLS
#endif // LIBC_BIONIC_MALLOC_INFO_H_

View File

@@ -320,6 +320,11 @@ extern "C" size_t dlmalloc_usable_size(void* ptr) {
return malloc_usable_size(ptr);
}
// In L we added a public pthread_gettid_np, but some apps were using the private API.
extern "C" pid_t __pthread_gettid(pthread_t t) {
return pthread_gettid_np(t);
}
// Older versions of appportable used dlmalloc directly instead of malloc,
// so export this compatibility shim that simply calls malloc.
extern "C" void* dlmalloc(size_t size) {

View File

@@ -38,11 +38,11 @@ void* operator new[](std::size_t size) {
return p;
}
void operator delete(void* ptr) {
void operator delete(void* ptr) throw() {
free(ptr);
}
void operator delete[](void* ptr) {
void operator delete[](void* ptr) throw() {
free(ptr);
}
@@ -54,10 +54,10 @@ void* operator new[](std::size_t size, const std::nothrow_t&) {
return malloc(size);
}
void operator delete(void* ptr, const std::nothrow_t&) {
void operator delete(void* ptr, const std::nothrow_t&) throw() {
free(ptr);
}
void operator delete[](void* ptr, const std::nothrow_t&) {
void operator delete[](void* ptr, const std::nothrow_t&) throw() {
free(ptr);
}

View File

@@ -1,267 +0,0 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <pathconf.h>
#include <sys/vfs.h>
#include <sys/limits.h>
#include <errno.h>
/* these may not be defined yet by our headers */
#ifndef _POSIX_VDISABLE
#define _POSIX_VDISABLE -1
#endif
#ifndef _POSIX_SYNC_IO
#define _POSIX_SYNC_IO -1
#endif
#ifndef _POSIX_PRIO_IO
#define _POSIX_PRIO_IO -1
#endif
#ifndef _POSIX_ASYNC_IO
#define _POSIX_ASYNC_IO -1
#endif
static long
__filesizebits( struct statfs* s )
{
#define EOL_MAGIC 0x0000U
/* list of known 64-bit aware filesystems */
static const uint32_t known64[] = {
EXT2_SUPER_MAGIC,
UFS_MAGIC,
REISERFS_SUPER_MAGIC,
XFS_SUPER_MAGIC,
SMB_SUPER_MAGIC,
UDF_SUPER_MAGIC,
JFS_SUPER_MAGIC,
NTFS_SB_MAGIC,
VXFS_SUPER_MAGIC,
EOL_MAGIC
};
int nn = 0;
for (; known64[nn] != EOL_MAGIC; ++nn) {
if (known64[nn] == s->f_type) {
return 64;
}
}
return 32;
}
static long
__link_max( struct statfs* s )
{
// These constant values were taken from kernel headers.
// They're not available in uapi headers.
static const struct { uint32_t type; int max; } knownMax[] =
{
{ EXT2_SUPER_MAGIC, 32000 },
{ EXT3_SUPER_MAGIC, 32000 },
{ MINIX_SUPER_MAGIC, 250 },
{ MINIX2_SUPER_MAGIC, 65530 },
{ REISERFS_SUPER_MAGIC, 0xffff - 1000 },
{ UFS_MAGIC, 32000 },
{ EOL_MAGIC, 0 }
};
int nn = 0;
for (; knownMax[nn].type != EOL_MAGIC; ++nn) {
if (knownMax[nn].type == s->f_type) {
return knownMax[nn].max;
}
}
return LINK_MAX;
}
static long
__2_symlinks( struct statfs* s )
{
/* list of know filesystems that don't support symlinks */
static const uint32_t knownNoSymlinks[] = {
ADFS_SUPER_MAGIC, BFS_MAGIC, CRAMFS_MAGIC,
EFS_SUPER_MAGIC, MSDOS_SUPER_MAGIC, NTFS_SB_MAGIC,
QNX4_SUPER_MAGIC,
EOL_MAGIC
};
int nn = 0;
for (; knownNoSymlinks[nn] != EOL_MAGIC; ++nn) {
if (knownNoSymlinks[nn] == s->f_type) {
return 0;
}
}
return 1;
}
static long
__name_max( struct statfs* s )
{
return s->f_namelen;
}
long
pathconf(const char *path, int name)
{
struct statfs buf;
int ret = statfs( path, &buf );
if (ret < 0)
return -1;
switch (name) {
case _PC_FILESIZEBITS:
return __filesizebits(&buf);
case _PC_LINK_MAX:
return __link_max(&buf);
case _PC_MAX_CANON:
return MAX_CANON;
case _PC_MAX_INPUT:
return MAX_INPUT;
case _PC_NAME_MAX:
return __name_max(&buf);
case _PC_PATH_MAX:
return PATH_MAX;
case _PC_PIPE_BUF:
return PIPE_BUF;
case _PC_2_SYMLINKS:
return __2_symlinks(&buf);
#if 0 /* don't know what to do there, the specs are really weird */
case _PC_ALLOC_SIZE_MIN:
case _PC_REC_INCR_XFER_SIZE:
case _PC_REC_MAX_XFER_SIZE:
case _PC_REC_MIN_XFER_SIZE:
case _PC_REC_XFER_ALIGN:
#endif
case _PC_SYMLINK_MAX:
return -1; /* no limit */
case _PC_CHOWN_RESTRICTED:
return _POSIX_CHOWN_RESTRICTED;
case _PC_NO_TRUNC:
return _POSIX_NO_TRUNC;
case _PC_VDISABLE:
return _POSIX_VDISABLE;
case _PC_ASYNC_IO:
return _POSIX_ASYNC_IO;
case _PC_PRIO_IO:
return _POSIX_PRIO_IO;
case _PC_SYNC_IO:
return _POSIX_SYNC_IO;
default:
errno = EINVAL;
return -1;
}
}
long fpathconf(int fildes, int name)
{
struct statfs buf;
int ret = fstatfs(fildes, &buf);
if (ret < 0)
return -1;
switch (name) {
case _PC_FILESIZEBITS:
return __filesizebits(&buf);
case _PC_LINK_MAX:
return __link_max(&buf);
case _PC_MAX_CANON:
return MAX_CANON;
case _PC_MAX_INPUT:
return MAX_INPUT;
case _PC_NAME_MAX:
return __name_max(&buf);
case _PC_PATH_MAX:
return PATH_MAX;
case _PC_PIPE_BUF:
return PIPE_BUF;
case _PC_2_SYMLINKS:
return __2_symlinks(&buf);
#if 0 /* don't know what to do there, the specs are really weird */
case _PC_ALLOC_SIZE_MIN:
case _PC_REC_INCR_XFER_SIZE:
case _PC_REC_MAX_XFER_SIZE:
case _PC_REC_MIN_XFER_SIZE:
case _PC_REC_XFER_ALIGN:
#endif
case _PC_SYMLINK_MAX:
return -1; /* no limit */
case _PC_CHOWN_RESTRICTED:
return _POSIX_CHOWN_RESTRICTED;
case _PC_NO_TRUNC:
return _POSIX_NO_TRUNC;
case _PC_VDISABLE:
return _POSIX_VDISABLE;
case _PC_ASYNC_IO:
return _POSIX_ASYNC_IO;
case _PC_PRIO_IO:
return _POSIX_PRIO_IO;
case _PC_SYNC_IO:
return _POSIX_SYNC_IO;
default:
errno = EINVAL;
return -1;
}
}

152
libc/bionic/pathconf.cpp Normal file
View File

@@ -0,0 +1,152 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <unistd.h>
#include <errno.h>
#include <sys/limits.h>
#include <sys/vfs.h>
static long __filesizebits(const struct statfs& s) {
switch (s.f_type) {
case JFFS2_SUPER_MAGIC:
case MSDOS_SUPER_MAGIC:
case NCP_SUPER_MAGIC:
return 32;
}
// There won't be any new 32-bit file systems.
return 64;
}
static long __link_max(const struct statfs& s) {
// These constant values were taken from kernel headers.
// They're not available in uapi headers.
switch (s.f_type) {
case EXT2_SUPER_MAGIC:
return 32000;
case MINIX_SUPER_MAGIC:
return 250;
case MINIX2_SUPER_MAGIC:
return 65530;
case REISERFS_SUPER_MAGIC:
return 0xffff - 1000;
case UFS_MAGIC:
return 32000;
}
return LINK_MAX;
}
static long __2_symlinks(const struct statfs& s) {
switch (s.f_type) {
case ADFS_SUPER_MAGIC:
case BFS_MAGIC:
case CRAMFS_MAGIC:
case EFS_SUPER_MAGIC:
case MSDOS_SUPER_MAGIC:
case QNX4_SUPER_MAGIC:
return 0;
}
return 1;
}
static long __pathconf(const struct statfs& s, int name) {
switch (name) {
case _PC_FILESIZEBITS:
return __filesizebits(s);
case _PC_LINK_MAX:
return __link_max(s);
case _PC_MAX_CANON:
return MAX_CANON;
case _PC_MAX_INPUT:
return MAX_INPUT;
case _PC_NAME_MAX:
return s.f_namelen;
case _PC_PATH_MAX:
return PATH_MAX;
case _PC_PIPE_BUF:
return PIPE_BUF;
case _PC_2_SYMLINKS:
return __2_symlinks(s);
#if 0
case _PC_ALLOC_SIZE_MIN:
case _PC_REC_INCR_XFER_SIZE:
case _PC_REC_MAX_XFER_SIZE:
case _PC_REC_MIN_XFER_SIZE:
case _PC_REC_XFER_ALIGN:
#endif
case _PC_SYMLINK_MAX:
return -1; /* no limit */
case _PC_CHOWN_RESTRICTED:
return _POSIX_CHOWN_RESTRICTED;
case _PC_NO_TRUNC:
return _POSIX_NO_TRUNC;
case _PC_VDISABLE:
return _POSIX_VDISABLE;
case _PC_ASYNC_IO:
return -1;
case _PC_PRIO_IO:
return -1;
case _PC_SYNC_IO:
return -1;
default:
errno = EINVAL;
return -1;
}
}
long pathconf(const char* path, int name) {
struct statfs sb;
if (statfs(path, &sb) == -1) {
return -1;
}
return __pathconf(sb, name);
}
long fpathconf(int fd, int name) {
struct statfs sb;
if (fstatfs(fd, &sb) == -1) {
return -1;
}
return __pathconf(sb, name);
}

View File

@@ -62,7 +62,6 @@ struct PosixTimer {
pthread_t callback_thread;
void (*callback)(sigval_t);
sigval_t callback_argument;
volatile bool armed;
};
static __kernel_timer_t to_kernel_timer_id(timer_t timer) {
@@ -84,7 +83,7 @@ static void* __timer_thread_start(void* arg) {
continue;
}
if (si.si_code == SI_TIMER && timer->armed) {
if (si.si_code == SI_TIMER) {
// This signal was sent because a timer fired, so call the callback.
timer->callback(timer->callback_argument);
} else if (si.si_code == SI_TKILL) {
@@ -96,9 +95,6 @@ static void* __timer_thread_start(void* arg) {
}
static void __timer_thread_stop(PosixTimer* timer) {
// Immediately mark the timer as disarmed so even if some events
// continue to happen, the callback won't be called.
timer->armed = false;
pthread_kill(timer->callback_thread, TIMER_SIGNAL);
}
@@ -125,7 +121,6 @@ int timer_create(clockid_t clock_id, sigevent* evp, timer_t* timer_id) {
// Otherwise, this must be SIGEV_THREAD timer...
timer->callback = evp->sigev_notify_function;
timer->callback_argument = evp->sigev_value;
timer->armed = false;
// Check arguments that the kernel doesn't care about but we do.
if (timer->callback == NULL) {
@@ -205,18 +200,7 @@ int timer_gettime(timer_t id, itimerspec* ts) {
// http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_getoverrun.html
int timer_settime(timer_t id, int flags, const itimerspec* ts, itimerspec* ots) {
PosixTimer* timer= reinterpret_cast<PosixTimer*>(id);
int rc = __timer_settime(timer->kernel_timer_id, flags, ts, ots);
if (rc == 0) {
// Mark the timer as either being armed or disarmed. This avoids the
// callback being called after the disarm for SIGEV_THREAD timers only.
if (ts->it_value.tv_sec != 0 || ts->it_value.tv_nsec != 0) {
timer->armed = true;
} else {
timer->armed = false;
}
}
return rc;
return __timer_settime(to_kernel_timer_id(id), flags, ts, ots);
}
// http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_getoverrun.html

View File

@@ -163,12 +163,12 @@ int __pthread_cond_timedwait_relative(pthread_cond_t* cond, pthread_mutex_t* mut
}
__LIBC_HIDDEN__
int __pthread_cond_timedwait(pthread_cond_t* cond, pthread_mutex_t* mutex, const timespec* abstime, clockid_t clock) {
int __pthread_cond_timedwait(pthread_cond_t* cond, pthread_mutex_t* mutex, const timespec* abs_ts, clockid_t clock) {
timespec ts;
timespec* tsp;
if (abstime != NULL) {
if (__timespec_from_absolute(&ts, abstime, clock) < 0) {
if (abs_ts != NULL) {
if (!timespec_from_absolute_timespec(ts, *abs_ts, clock)) {
return ETIMEDOUT;
}
tsp = &ts;

View File

@@ -27,13 +27,7 @@
*/
#include "pthread_internal.h"
#include "private/bionic_pthread.h"
pid_t pthread_gettid_np(pthread_t t) {
return reinterpret_cast<pthread_internal_t*>(t)->tid;
}
// TODO: move callers over to pthread_gettid_np and remove this.
pid_t __pthread_gettid(pthread_t t) {
return pthread_gettid_np(t);
}

View File

@@ -117,8 +117,6 @@ __LIBC_HIDDEN__ void _pthread_internal_remove_locked(pthread_internal_t* thread)
__LIBC_HIDDEN__ extern pthread_internal_t* g_thread_list;
__LIBC_HIDDEN__ extern pthread_mutex_t g_thread_list_lock;
__LIBC_HIDDEN__ int __timespec_from_absolute(timespec*, const timespec*, clockid_t);
/* Needed by fork. */
__LIBC_HIDDEN__ extern void __bionic_atfork_run_prepare();
__LIBC_HIDDEN__ extern void __bionic_atfork_run_child();

View File

@@ -67,19 +67,3 @@ void _pthread_internal_add(pthread_internal_t* thread) {
pthread_internal_t* __get_thread(void) {
return reinterpret_cast<pthread_internal_t*>(__get_tls()[TLS_SLOT_THREAD_ID]);
}
// Initialize 'ts' with the difference between 'abstime' and the current time
// according to 'clock'. Returns -1 if abstime already expired, or 0 otherwise.
int __timespec_from_absolute(timespec* ts, const timespec* abstime, clockid_t clock) {
clock_gettime(clock, ts);
ts->tv_sec = abstime->tv_sec - ts->tv_sec;
ts->tv_nsec = abstime->tv_nsec - ts->tv_nsec;
if (ts->tv_nsec < 0) {
ts->tv_sec--;
ts->tv_nsec += 1000000000;
}
if ((ts->tv_nsec < 0) || (ts->tv_sec < 0)) {
return -1;
}
return 0;
}

View File

@@ -36,9 +36,13 @@
#include "pthread_internal.h"
#include "private/bionic_atomic_inline.h"
#include "private/bionic_constants.h"
#include "private/bionic_futex.h"
#include "private/bionic_time_conversions.h"
#include "private/bionic_tls.h"
#include "private/bionic_systrace.h"
extern void pthread_debug_mutex_lock_check(pthread_mutex_t *mutex);
extern void pthread_debug_mutex_unlock_check(pthread_mutex_t *mutex);
@@ -333,6 +337,10 @@ static inline void _normal_lock(pthread_mutex_t* mutex, int shared) {
* that the mutex is in state 2 when we go to sleep on it, which
* guarantees a wake-up call.
*/
ScopedTrace trace("Contending for pthread mutex");
while (__bionic_swap(locked_contended, &mutex->value) != unlocked) {
__futex_wait_ex(&mutex->value, shared, locked_contended, NULL);
}
@@ -440,12 +448,6 @@ static inline __always_inline int _recursive_increment(pthread_mutex_t* mutex, i
}
int pthread_mutex_lock(pthread_mutex_t* mutex) {
#if !defined(__LP64__)
if (mutex == NULL) {
return EINVAL;
}
#endif
int mvalue, mtype, tid, shared;
mvalue = mutex->value;
@@ -479,6 +481,8 @@ int pthread_mutex_lock(pthread_mutex_t* mutex) {
mvalue = mutex->value;
}
ScopedTrace trace("Contending for pthread mutex");
for (;;) {
int newval;
@@ -522,12 +526,6 @@ int pthread_mutex_lock(pthread_mutex_t* mutex) {
}
int pthread_mutex_unlock(pthread_mutex_t* mutex) {
#if !defined(__LP64__)
if (mutex == NULL) {
return EINVAL;
}
#endif
int mvalue, mtype, tid, shared;
mvalue = mutex->value;
@@ -619,7 +617,7 @@ int pthread_mutex_trylock(pthread_mutex_t* mutex) {
return EBUSY;
}
static int __pthread_mutex_timedlock(pthread_mutex_t* mutex, const timespec* abs_timeout, clockid_t clock) {
static int __pthread_mutex_timedlock(pthread_mutex_t* mutex, const timespec* abs_ts, clockid_t clock) {
timespec ts;
int mvalue = mutex->value;
@@ -638,9 +636,11 @@ static int __pthread_mutex_timedlock(pthread_mutex_t* mutex, const timespec* abs
return 0;
}
ScopedTrace trace("Contending for timed pthread mutex");
// Loop while needed.
while (__bionic_swap(locked_contended, &mutex->value) != unlocked) {
if (__timespec_from_absolute(&ts, abs_timeout, clock) < 0) {
if (!timespec_from_absolute_timespec(ts, *abs_ts, clock)) {
return ETIMEDOUT;
}
__futex_wait_ex(&mutex->value, shared, locked_contended, &ts);
@@ -670,6 +670,8 @@ static int __pthread_mutex_timedlock(pthread_mutex_t* mutex, const timespec* abs
mvalue = mutex->value;
}
ScopedTrace trace("Contending for timed pthread mutex");
while (true) {
// If the value is 'unlocked', try to acquire it directly.
// NOTE: put state to 2 since we know there is contention.
@@ -681,7 +683,7 @@ static int __pthread_mutex_timedlock(pthread_mutex_t* mutex, const timespec* abs
}
// The value changed before we could lock it. We need to check
// the time to avoid livelocks, reload the value, then loop again.
if (__timespec_from_absolute(&ts, abs_timeout, clock) < 0) {
if (!timespec_from_absolute_timespec(ts, *abs_ts, clock)) {
return ETIMEDOUT;
}
@@ -703,7 +705,7 @@ static int __pthread_mutex_timedlock(pthread_mutex_t* mutex, const timespec* abs
}
// Check time and update 'ts'.
if (__timespec_from_absolute(&ts, abs_timeout, clock) < 0) {
if (timespec_from_absolute_timespec(ts, *abs_ts, clock)) {
return ETIMEDOUT;
}
@@ -726,9 +728,9 @@ extern "C" int pthread_mutex_lock_timeout_np(pthread_mutex_t* mutex, unsigned ms
clock_gettime(CLOCK_MONOTONIC, &abs_timeout);
abs_timeout.tv_sec += ms / 1000;
abs_timeout.tv_nsec += (ms % 1000) * 1000000;
if (abs_timeout.tv_nsec >= 1000000000) {
if (abs_timeout.tv_nsec >= NS_PER_S) {
abs_timeout.tv_sec++;
abs_timeout.tv_nsec -= 1000000000;
abs_timeout.tv_nsec -= NS_PER_S;
}
int error = __pthread_mutex_timedlock(mutex, &abs_timeout, CLOCK_MONOTONIC);

View File

@@ -30,6 +30,7 @@
#include "pthread_internal.h"
#include "private/bionic_futex.h"
#include "private/bionic_time_conversions.h"
/* Technical note:
*
@@ -71,7 +72,7 @@ static inline bool rwlock_is_shared(const pthread_rwlock_t* rwlock) {
static bool timespec_from_absolute(timespec* rel_timeout, const timespec* abs_timeout) {
if (abs_timeout != NULL) {
if (__timespec_from_absolute(rel_timeout, abs_timeout, CLOCK_REALTIME) < 0) {
if (!timespec_from_absolute_timespec(*rel_timeout, *abs_timeout, CLOCK_REALTIME)) {
return false;
}
}

View File

@@ -67,7 +67,7 @@ int pthread_setname_np(pthread_t t, const char* thread_name) {
}
char comm_name[sizeof(TASK_COMM_FMT) + 8];
snprintf(comm_name, sizeof(comm_name), TASK_COMM_FMT, tid);
int fd = open(comm_name, O_WRONLY);
int fd = open(comm_name, O_CLOEXEC | O_WRONLY);
if (fd == -1) {
return errno;
}

View File

@@ -36,7 +36,7 @@ void pututline(struct utmp* utmp)
struct utmp u;
long i;
if (!(f = fopen(_PATH_UTMP, "w+")))
if (!(f = fopen(_PATH_UTMP, "w+e")))
return;
while (fread(&u, sizeof(struct utmp), 1, f) == 1)
@@ -55,7 +55,7 @@ void pututline(struct utmp* utmp)
fclose(f);
if (!(f = fopen(_PATH_UTMP, "w+")))
if (!(f = fopen(_PATH_UTMP, "w+e")))
return;
fwrite(utmp, sizeof(struct utmp), 1, f);

View File

@@ -1,398 +0,0 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <semaphore.h>
#include <errno.h>
#include <sys/time.h>
#include <time.h>
#include <limits.h>
#include "private/bionic_atomic_inline.h"
#include "private/bionic_futex.h"
/* In this implementation, a semaphore contains a
* 31-bit signed value and a 1-bit 'shared' flag
* (for process-sharing purpose).
*
* We use the value -1 to indicate contention on the
* semaphore, 0 or more to indicate uncontended state,
* any value lower than -2 is invalid at runtime.
*
* State diagram:
*
* post(1) ==> 2
* post(0) ==> 1
* post(-1) ==> 1, then wake all waiters
*
* wait(2) ==> 1
* wait(1) ==> 0
* wait(0) ==> -1 then wait for a wake up + loop
* wait(-1) ==> -1 then wait for a wake up + loop
*
*/
/* Use the upper 31-bits for the counter, and the lower one
* for the shared flag.
*/
#define SEMCOUNT_SHARED_MASK 0x00000001
#define SEMCOUNT_VALUE_MASK 0xfffffffe
#define SEMCOUNT_VALUE_SHIFT 1
/* Maximum unsigned value that can be stored in the semaphore.
* One bit is used for the shared flag, another one for the
* sign bit, leaving us with only 30 bits.
*/
#define SEM_MAX_VALUE 0x3fffffff
/* convert a value into the corresponding sem->count bit pattern */
#define SEMCOUNT_FROM_VALUE(val) (((val) << SEMCOUNT_VALUE_SHIFT) & SEMCOUNT_VALUE_MASK)
/* convert a sem->count bit pattern into the corresponding signed value */
#define SEMCOUNT_TO_VALUE(sval) ((int)(sval) >> SEMCOUNT_VALUE_SHIFT)
/* the value +1 as a sem->count bit-pattern. */
#define SEMCOUNT_ONE SEMCOUNT_FROM_VALUE(1)
/* the value -1 as a sem->count bit-pattern. */
#define SEMCOUNT_MINUS_ONE SEMCOUNT_FROM_VALUE(-1)
#define SEMCOUNT_DECREMENT(sval) (((sval) - (1U << SEMCOUNT_VALUE_SHIFT)) & SEMCOUNT_VALUE_MASK)
#define SEMCOUNT_INCREMENT(sval) (((sval) + (1U << SEMCOUNT_VALUE_SHIFT)) & SEMCOUNT_VALUE_MASK)
/* return the shared bitflag from a semaphore */
#define SEM_GET_SHARED(sem) ((sem)->count & SEMCOUNT_SHARED_MASK)
int sem_init(sem_t *sem, int pshared, unsigned int value)
{
if (sem == NULL) {
errno = EINVAL;
return -1;
}
/* ensure that 'value' can be stored in the semaphore */
if (value > SEM_MAX_VALUE) {
errno = EINVAL;
return -1;
}
sem->count = SEMCOUNT_FROM_VALUE(value);
if (pshared != 0)
sem->count |= SEMCOUNT_SHARED_MASK;
return 0;
}
int sem_destroy(sem_t *sem)
{
int count;
if (sem == NULL) {
errno = EINVAL;
return -1;
}
count = SEMCOUNT_TO_VALUE(sem->count);
if (count < 0) {
errno = EBUSY;
return -1;
}
sem->count = 0;
return 0;
}
sem_t *sem_open(const char *name __unused, int oflag __unused, ...)
{
errno = ENOSYS;
return SEM_FAILED;
}
int sem_close(sem_t *sem)
{
if (sem == NULL) {
errno = EINVAL;
return -1;
}
errno = ENOSYS;
return -1;
}
int sem_unlink(const char* name __unused)
{
errno = ENOSYS;
return -1;
}
/* Decrement a semaphore's value atomically,
* and return the old one. As a special case,
* this returns immediately if the value is
* negative (i.e. -1)
*/
static int
__sem_dec(volatile unsigned int *pvalue)
{
unsigned int shared = (*pvalue & SEMCOUNT_SHARED_MASK);
unsigned int old, new;
int ret;
do {
old = (*pvalue & SEMCOUNT_VALUE_MASK);
ret = SEMCOUNT_TO_VALUE(old);
if (ret < 0)
break;
new = SEMCOUNT_DECREMENT(old);
}
while (__bionic_cmpxchg((int)(old|shared),
(int)(new|shared),
(volatile int *)pvalue) != 0);
return ret;
}
/* Same as __sem_dec, but will not touch anything if the
* value is already negative *or* 0. Returns the old value.
*/
static int
__sem_trydec(volatile unsigned int *pvalue)
{
unsigned int shared = (*pvalue & SEMCOUNT_SHARED_MASK);
unsigned int old, new;
int ret;
do {
old = (*pvalue & SEMCOUNT_VALUE_MASK);
ret = SEMCOUNT_TO_VALUE(old);
if (ret <= 0)
break;
new = SEMCOUNT_DECREMENT(old);
}
while (__bionic_cmpxchg((int)(old|shared),
(int)(new|shared),
(volatile int *)pvalue) != 0);
return ret;
}
/* "Increment" the value of a semaphore atomically and
* return its old value. Note that this implements
* the special case of "incrementing" any negative
* value to +1 directly.
*
* NOTE: The value will _not_ wrap above SEM_VALUE_MAX
*/
static int
__sem_inc(volatile unsigned int *pvalue)
{
unsigned int shared = (*pvalue & SEMCOUNT_SHARED_MASK);
unsigned int old, new;
int ret;
do {
old = (*pvalue & SEMCOUNT_VALUE_MASK);
ret = SEMCOUNT_TO_VALUE(old);
/* Can't go higher than SEM_MAX_VALUE */
if (ret == SEM_MAX_VALUE)
break;
/* If the counter is negative, go directly to +1,
* otherwise just increment */
if (ret < 0)
new = SEMCOUNT_ONE;
else
new = SEMCOUNT_INCREMENT(old);
}
while ( __bionic_cmpxchg((int)(old|shared),
(int)(new|shared),
(volatile int*)pvalue) != 0);
return ret;
}
/* lock a semaphore */
int sem_wait(sem_t *sem)
{
unsigned shared;
if (sem == NULL) {
errno = EINVAL;
return -1;
}
shared = SEM_GET_SHARED(sem);
for (;;) {
if (__sem_dec(&sem->count) > 0)
break;
__futex_wait_ex(&sem->count, shared, shared|SEMCOUNT_MINUS_ONE, NULL);
}
ANDROID_MEMBAR_FULL();
return 0;
}
int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout)
{
unsigned int shared;
if (sem == NULL) {
errno = EINVAL;
return -1;
}
/* POSIX says we need to try to decrement the semaphore
* before checking the timeout value. Note that if the
* value is currently 0, __sem_trydec() does nothing.
*/
if (__sem_trydec(&sem->count) > 0) {
ANDROID_MEMBAR_FULL();
return 0;
}
/* Check it as per Posix */
if (abs_timeout == NULL ||
abs_timeout->tv_sec < 0 ||
abs_timeout->tv_nsec < 0 ||
abs_timeout->tv_nsec >= 1000000000)
{
errno = EINVAL;
return -1;
}
shared = SEM_GET_SHARED(sem);
for (;;) {
struct timespec ts;
int ret;
/* Posix mandates CLOCK_REALTIME here */
clock_gettime( CLOCK_REALTIME, &ts );
ts.tv_sec = abs_timeout->tv_sec - ts.tv_sec;
ts.tv_nsec = abs_timeout->tv_nsec - ts.tv_nsec;
if (ts.tv_nsec < 0) {
ts.tv_nsec += 1000000000;
ts.tv_sec -= 1;
}
if (ts.tv_sec < 0 || ts.tv_nsec < 0) {
errno = ETIMEDOUT;
return -1;
}
/* Try to grab the semaphore. If the value was 0, this
* will also change it to -1 */
if (__sem_dec(&sem->count) > 0) {
ANDROID_MEMBAR_FULL();
break;
}
/* Contention detected. wait for a wakeup event */
ret = __futex_wait_ex(&sem->count, shared, shared|SEMCOUNT_MINUS_ONE, &ts);
/* return in case of timeout or interrupt */
if (ret == -ETIMEDOUT || ret == -EINTR) {
errno = -ret;
return -1;
}
}
return 0;
}
/* Unlock a semaphore */
int sem_post(sem_t *sem)
{
unsigned int shared;
int old;
if (sem == NULL)
return EINVAL;
shared = SEM_GET_SHARED(sem);
ANDROID_MEMBAR_FULL();
old = __sem_inc(&sem->count);
if (old < 0) {
/* contention on the semaphore, wake up all waiters */
__futex_wake_ex(&sem->count, shared, INT_MAX);
}
else if (old == SEM_MAX_VALUE) {
/* overflow detected */
errno = EOVERFLOW;
return -1;
}
return 0;
}
int sem_trywait(sem_t *sem)
{
if (sem == NULL) {
errno = EINVAL;
return -1;
}
if (__sem_trydec(&sem->count) > 0) {
ANDROID_MEMBAR_FULL();
return 0;
} else {
errno = EAGAIN;
return -1;
}
}
/* Note that Posix requires that sem_getvalue() returns, in
* case of contention, the negative of the number of waiting
* threads.
*
* However, code that depends on this negative value to be
* meaningful is most probably racy. The GLibc sem_getvalue()
* only returns the semaphore value, which is 0, in case of
* contention, so we will mimick this behaviour here instead
* for better compatibility.
*/
int sem_getvalue(sem_t *sem, int *sval)
{
int val;
if (sem == NULL || sval == NULL) {
errno = EINVAL;
return -1;
}
val = SEMCOUNT_TO_VALUE(sem->count);
if (val < 0)
val = 0;
*sval = val;
return 0;
}

289
libc/bionic/semaphore.cpp Normal file
View File

@@ -0,0 +1,289 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <semaphore.h>
#include <errno.h>
#include <limits.h>
#include <sys/time.h>
#include <time.h>
#include "private/bionic_atomic_inline.h"
#include "private/bionic_constants.h"
#include "private/bionic_futex.h"
#include "private/bionic_time_conversions.h"
// In this implementation, a semaphore contains a
// 31-bit signed value and a 1-bit 'shared' flag
// (for process-sharing purpose).
//
// We use the value -1 to indicate contention on the
// semaphore, 0 or more to indicate uncontended state,
// any value lower than -2 is invalid at runtime.
//
// State diagram:
//
// post(1) ==> 2
// post(0) ==> 1
// post(-1) ==> 1, then wake all waiters
//
// wait(2) ==> 1
// wait(1) ==> 0
// wait(0) ==> -1 then wait for a wake up + loop
// wait(-1) ==> -1 then wait for a wake up + loop
// Use the upper 31-bits for the counter, and the lower one
// for the shared flag.
#define SEMCOUNT_SHARED_MASK 0x00000001
#define SEMCOUNT_VALUE_MASK 0xfffffffe
#define SEMCOUNT_VALUE_SHIFT 1
// Convert a value into the corresponding sem->count bit pattern.
#define SEMCOUNT_FROM_VALUE(val) (((val) << SEMCOUNT_VALUE_SHIFT) & SEMCOUNT_VALUE_MASK)
// Convert a sem->count bit pattern into the corresponding signed value.
static inline int SEMCOUNT_TO_VALUE(uint32_t sval) {
return (static_cast<int>(sval) >> SEMCOUNT_VALUE_SHIFT);
}
// The value +1 as a sem->count bit-pattern.
#define SEMCOUNT_ONE SEMCOUNT_FROM_VALUE(1)
// The value -1 as a sem->count bit-pattern.
#define SEMCOUNT_MINUS_ONE SEMCOUNT_FROM_VALUE(-1)
#define SEMCOUNT_DECREMENT(sval) (((sval) - (1U << SEMCOUNT_VALUE_SHIFT)) & SEMCOUNT_VALUE_MASK)
#define SEMCOUNT_INCREMENT(sval) (((sval) + (1U << SEMCOUNT_VALUE_SHIFT)) & SEMCOUNT_VALUE_MASK)
// Return the shared bitflag from a semaphore.
static inline uint32_t SEM_GET_SHARED(sem_t* sem) {
return (sem->count & SEMCOUNT_SHARED_MASK);
}
int sem_init(sem_t* sem, int pshared, unsigned int value) {
// Ensure that 'value' can be stored in the semaphore.
if (value > SEM_VALUE_MAX) {
errno = EINVAL;
return -1;
}
sem->count = SEMCOUNT_FROM_VALUE(value);
if (pshared != 0) {
sem->count |= SEMCOUNT_SHARED_MASK;
}
return 0;
}
int sem_destroy(sem_t*) {
return 0;
}
sem_t* sem_open(const char*, int, ...) {
errno = ENOSYS;
return SEM_FAILED;
}
int sem_close(sem_t*) {
errno = ENOSYS;
return -1;
}
int sem_unlink(const char*) {
errno = ENOSYS;
return -1;
}
// Decrement a semaphore's value atomically,
// and return the old one. As a special case,
// this returns immediately if the value is
// negative (i.e. -1)
static int __sem_dec(volatile uint32_t* sem) {
volatile int32_t* ptr = reinterpret_cast<volatile int32_t*>(sem);
uint32_t shared = (*sem & SEMCOUNT_SHARED_MASK);
uint32_t old_value, new_value;
int ret;
do {
old_value = (*sem & SEMCOUNT_VALUE_MASK);
ret = SEMCOUNT_TO_VALUE(old_value);
if (ret < 0) {
break;
}
new_value = SEMCOUNT_DECREMENT(old_value);
} while (__bionic_cmpxchg((old_value|shared), (new_value|shared), ptr) != 0);
return ret;
}
// Same as __sem_dec, but will not touch anything if the
// value is already negative *or* 0. Returns the old value.
static int __sem_trydec(volatile uint32_t* sem) {
volatile int32_t* ptr = reinterpret_cast<volatile int32_t*>(sem);
uint32_t shared = (*sem & SEMCOUNT_SHARED_MASK);
uint32_t old_value, new_value;
int ret;
do {
old_value = (*sem & SEMCOUNT_VALUE_MASK);
ret = SEMCOUNT_TO_VALUE(old_value);
if (ret <= 0) {
break;
}
new_value = SEMCOUNT_DECREMENT(old_value);
} while (__bionic_cmpxchg((old_value|shared), (new_value|shared), ptr) != 0);
return ret;
}
// "Increment" the value of a semaphore atomically and
// return its old value. Note that this implements
// the special case of "incrementing" any negative
// value to +1 directly.
//
// NOTE: The value will _not_ wrap above SEM_VALUE_MAX
static int __sem_inc(volatile uint32_t* sem) {
volatile int32_t* ptr = reinterpret_cast<volatile int32_t*>(sem);
uint32_t shared = (*sem & SEMCOUNT_SHARED_MASK);
uint32_t old_value, new_value;
int ret;
do {
old_value = (*sem & SEMCOUNT_VALUE_MASK);
ret = SEMCOUNT_TO_VALUE(old_value);
// Can't go higher than SEM_VALUE_MAX.
if (ret == SEM_VALUE_MAX) {
break;
}
// If the counter is negative, go directly to +1, otherwise just increment.
if (ret < 0) {
new_value = SEMCOUNT_ONE;
} else {
new_value = SEMCOUNT_INCREMENT(old_value);
}
} while (__bionic_cmpxchg((old_value|shared), (new_value|shared), ptr) != 0);
return ret;
}
int sem_wait(sem_t* sem) {
uint32_t shared = SEM_GET_SHARED(sem);
while (true) {
if (__sem_dec(&sem->count) > 0) {
ANDROID_MEMBAR_FULL();
return 0;
}
__futex_wait_ex(&sem->count, shared, shared|SEMCOUNT_MINUS_ONE, NULL);
}
}
int sem_timedwait(sem_t* sem, const timespec* abs_timeout) {
// POSIX says we need to try to decrement the semaphore
// before checking the timeout value. Note that if the
// value is currently 0, __sem_trydec() does nothing.
if (__sem_trydec(&sem->count) > 0) {
ANDROID_MEMBAR_FULL();
return 0;
}
// Check it as per POSIX.
if (abs_timeout == NULL || abs_timeout->tv_sec < 0 || abs_timeout->tv_nsec < 0 || abs_timeout->tv_nsec >= NS_PER_S) {
errno = EINVAL;
return -1;
}
uint32_t shared = SEM_GET_SHARED(sem);
while (true) {
// POSIX mandates CLOCK_REALTIME here.
timespec ts;
if (!timespec_from_absolute_timespec(ts, *abs_timeout, CLOCK_REALTIME)) {
errno = ETIMEDOUT;
return -1;
}
// Try to grab the semaphore. If the value was 0, this will also change it to -1.
if (__sem_dec(&sem->count) > 0) {
ANDROID_MEMBAR_FULL();
break;
}
// Contention detected. Wait for a wakeup event.
int ret = __futex_wait_ex(&sem->count, shared, shared|SEMCOUNT_MINUS_ONE, &ts);
// Return in case of timeout or interrupt.
if (ret == -ETIMEDOUT || ret == -EINTR) {
errno = -ret;
return -1;
}
}
return 0;
}
int sem_post(sem_t* sem) {
uint32_t shared = SEM_GET_SHARED(sem);
ANDROID_MEMBAR_FULL();
int old_value = __sem_inc(&sem->count);
if (old_value < 0) {
// Contention on the semaphore. Wake up all waiters.
__futex_wake_ex(&sem->count, shared, INT_MAX);
} else if (old_value == SEM_VALUE_MAX) {
// Overflow detected.
errno = EOVERFLOW;
return -1;
}
return 0;
}
int sem_trywait(sem_t* sem) {
if (__sem_trydec(&sem->count) > 0) {
ANDROID_MEMBAR_FULL();
return 0;
} else {
errno = EAGAIN;
return -1;
}
}
int sem_getvalue(sem_t* sem, int* sval) {
int val = SEMCOUNT_TO_VALUE(sem->count);
if (val < 0) {
val = 0;
}
*sval = val;
return 0;
}

View File

@@ -1,11 +1,16 @@
/* $OpenBSD: strerror_r.c,v 1.6 2005/08/08 08:05:37 espie Exp $ */
/* Public Domain <marc@snafu.org> */
// G++ automatically defines _GNU_SOURCE, which then means that <string.h>
// gives us the GNU variant.
#undef _GNU_SOURCE
#include <string.h>
#include <errno.h>
#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include "private/ErrnoRestorer.h"
#include "private/libc_logging.h"
@@ -62,6 +67,12 @@ int strerror_r(int error_number, char* buf, size_t buf_len) {
return 0;
}
extern "C" char* __gnu_strerror_r(int error_number, char* buf, size_t buf_len) {
ErrnoRestorer errno_restorer; // The glibc strerror_r doesn't set errno if it truncates...
strerror_r(error_number, buf, buf_len);
return buf; // ...and just returns whatever fit.
}
extern "C" __LIBC_HIDDEN__ const char* __strsignal(int signal_number, char* buf, size_t buf_len) {
const char* signal_name = __strsignal_lookup(signal_number);
if (signal_name != NULL) {

View File

@@ -49,7 +49,6 @@
#define SYSTEM_MQ_OPEN_MAX 8
#define SYSTEM_MQ_PRIO_MAX 32768
#define SYSTEM_SEM_NSEMS_MAX 256
#define SYSTEM_SEM_VALUE_MAX 0x3fffffff /* see bionic/semaphore.c */
#define SYSTEM_SIGQUEUE_MAX 32
#define SYSTEM_TIMER_MAX 32
#define SYSTEM_LOGIN_NAME_MAX 256
@@ -95,7 +94,7 @@ static int __sysconf_nprocessors_conf() {
}
static int __sysconf_nprocessors_onln() {
FILE* fp = fopen("/proc/stat", "r");
FILE* fp = fopen("/proc/stat", "re");
if (fp == NULL) {
return 1;
}
@@ -118,7 +117,7 @@ static int __sysconf_nprocessors_onln() {
}
static int __get_meminfo(const char* pattern) {
FILE* fp = fopen("/proc/meminfo", "r");
FILE* fp = fopen("/proc/meminfo", "re");
if (fp == NULL) {
return -1;
}
@@ -150,37 +149,15 @@ static int __sysconf_monotonic_clock() {
return (rc == -1) ? -1 : _POSIX_VERSION;
}
long sysconf(int name) {
switch (name) {
#ifdef _POSIX_ARG_MAX
int sysconf(int name) {
switch (name) {
case _SC_ARG_MAX: return _POSIX_ARG_MAX;
#endif
#ifdef _POSIX2_BC_BASE_MAX
case _SC_BC_BASE_MAX: return _POSIX2_BC_BASE_MAX;
#endif
#ifdef _POSIX2_BC_DIM_MAX
case _SC_BC_DIM_MAX: return _POSIX2_BC_DIM_MAX;
#endif
#ifdef _POSIX2_BC_SCALE_MAX
case _SC_BC_SCALE_MAX: return _POSIX2_BC_SCALE_MAX;
#endif
#ifdef _POSIX2_BC_STRING_MAX
case _SC_BC_STRING_MAX: return _POSIX2_BC_STRING_MAX;
#endif
case _SC_CHILD_MAX: return CHILD_MAX;
case _SC_CLK_TCK: return SYSTEM_CLK_TCK;
#ifdef _POSIX2_COLL_WEIGHTS_MASK
case _SC_COLL_WEIGHTS_MAX: return _POSIX2_COLL_WEIGHTS_MASK;
#endif
#ifdef _POSIX2_EXPR_NEST_MAX
case _SC_EXPR_NEST_MAX: return _POSIX2_EXPR_NEST_MAX;
#endif
#ifdef _POSIX2_LINE_MAX
case _SC_LINE_MAX: return _POSIX2_LINE_MAX;
#endif
case _SC_NGROUPS_MAX: return NGROUPS_MAX;
case _SC_OPEN_MAX: return OPEN_MAX;
//case _SC_PASS_MAX: return PASS_MAX;
case _SC_PASS_MAX: return PASS_MAX;
case _SC_2_C_BIND: return SYSTEM_2_C_BIND;
case _SC_2_C_DEV: return SYSTEM_2_C_DEV;
case _SC_2_C_VERSION: return SYSTEM_2_C_VER;
@@ -191,42 +168,20 @@ long sysconf(int name) {
case _SC_2_SW_DEV: return SYSTEM_2_SW_DEV;
case _SC_2_UPE: return SYSTEM_2_UPE;
case _SC_2_VERSION: return SYSTEM_2_VERSION;
#ifdef _POSIX_JOB_CONTROL
case _SC_JOB_CONTROL: return _POSIX_JOB_CONTROL;
#endif
#ifdef _POSIX_SAVED_IDS
case _SC_SAVED_IDS: return _POSIX_SAVED_IDS;
#endif
#ifdef _POSIX_VERSION
case _SC_VERSION: return _POSIX_VERSION;
#endif
//case _SC_RE_DUP_<AX: return ;
case _SC_RE_DUP_MAX: return _POSIX_RE_DUP_MAX;
case _SC_STREAM_MAX: return FOPEN_MAX;
//case _SC_TZNAME_MAX: return ;
#if _XOPEN_CRYPT
case _SC_TZNAME_MAX: return _POSIX_TZNAME_MAX;
case _SC_XOPEN_CRYPT: return _XOPEN_CRYPT;
#endif
#ifdef _XOPEN_ENH_I18N
case _SC_XOPEN_ENH_I18N: return _XOPEN_ENH_I18N;
#endif
#ifdef _XOPEN_SHM
case _SC_XOPEN_SHM: return _XOPEN_SHM;
#endif
#ifdef _XOPEN_VERSION
//case _SC_XOPEN_SHM: return _XOPEN_SHM;
case _SC_XOPEN_VERSION: return _XOPEN_VERSION;
#endif
#ifdef _XOPEN_XCU_VERSION
case _SC_XOPEN_XCU_VERSION: return _XOPEN_XCU_VERSION;
#endif
#ifdef _XOPEN_REALTIME
case _SC_XOPEN_REALTIME: return _XOPEN_REALTIME;
#endif
#ifdef _XOPEN_REALTIME_THREADS
case _SC_XOPEN_REALTIME_THREADS: return _XOPEN_REALTIME_THREADS;
#endif
#ifdef _XOPEN_LEGACY
case _SC_XOPEN_LEGACY: return _XOPEN_LEGACY;
#endif
case _SC_ATEXIT_MAX: return SYSTEM_ATEXIT_MAX;
case _SC_IOV_MAX: return SYSTEM_IOV_MAX;
@@ -234,71 +189,35 @@ long sysconf(int name) {
case _SC_PAGE_SIZE:
return PAGE_SIZE;
#ifdef _XOPEN_UNIX
case _SC_XOPEN_UNIX: return _XOPEN_UNIX;
#endif
// XXX: TODO: XBS5 nonsense
#ifdef AIO_LISTIO_MAX
case _SC_AIO_LISTIO_MAX: return AIO_LISTIO_MAX;
#endif
#ifdef AIO_MAX
case _SC_AIO_MAX: return AIO_MAX;
#endif
#ifdef AIO_PRIO_DELTA_MAX
case _SC_AIO_PRIO_DELTA_MAX: return AIO_PRIO_DELTA_MAX;
#endif
//case _SC_AIO_LISTIO_MAX: return AIO_LISTIO_MAX;
//case _SC_AIO_MAX: return AIO_MAX;
//case _SC_AIO_PRIO_DELTA_MAX: return AIO_PRIO_DELTA_MAX;
case _SC_DELAYTIMER_MAX: return SYSTEM_DELAYTIMER_MAX;
case _SC_MQ_OPEN_MAX: return SYSTEM_MQ_OPEN_MAX;
case _SC_MQ_PRIO_MAX: return SYSTEM_MQ_PRIO_MAX;
case _SC_RTSIG_MAX: return RTSIG_MAX;
case _SC_SEM_NSEMS_MAX: return SYSTEM_SEM_NSEMS_MAX;
case _SC_SEM_VALUE_MAX: return SYSTEM_SEM_VALUE_MAX;
case _SC_SEM_VALUE_MAX: return SEM_VALUE_MAX;
case _SC_SIGQUEUE_MAX: return SYSTEM_SIGQUEUE_MAX;
case _SC_TIMER_MAX: return SYSTEM_TIMER_MAX;
#ifdef _POSIX_ASYNCHRONOUS_IO
case _SC_ASYNCHRONOUS_IO: return _POSIX_ASYNCHRONOUS_IO;
#endif
#ifdef _POSIX_FSYNC
//case _SC_ASYNCHRONOUS_IO: return _POSIX_ASYNCHRONOUS_IO;
case _SC_FSYNC: return _POSIX_FSYNC;
#endif
#ifdef _POSIX_MAPPED_FILES
case _SC_MAPPED_FILES: return _POSIX_MAPPED_FILES;
#endif
#ifdef _POSIX_MEMLOCK
case _SC_MEMLOCK: return _POSIX_MEMLOCK;
#endif
#ifdef _POSIX_MEMLOCK_RANGE
case _SC_MEMLOCK_RANGE: return _POSIX_MEMLOCK_RANGE
#endif
#ifdef _POSIX_MEMORY_PROTECTION
case _SC_MEMORY_PROTECTION: return _POSIX_MEMORY_PROTECTION;
#endif
#ifdef _POSIX_MESSAGE_PASSING
case _SC_MESSAGE_PASSING: return _POSIX_MESSAGE_PASSING;
#endif
#ifdef _POSIX_PRIORITIZED_IO
case _SC_PRIORITIZED_IO: return _POSIX_PRIORITIZED_IO;
#endif
#ifdef _POSIX_PRIORITY_SCHEDULING
//case _SC_MEMLOCK: return _POSIX_MEMLOCK;
//case _SC_MEMLOCK_RANGE: return _POSIX_MEMLOCK_RANGE;
//case _SC_MEMORY_PROTECTION: return _POSIX_MEMORY_PROTECTION;
//case _SC_MESSAGE_PASSING: return _POSIX_MESSAGE_PASSING;
//case _SC_PRIORITIZED_IO: return _POSIX_PRIORITIZED_IO;
case _SC_PRIORITY_SCHEDULING: return _POSIX_PRIORITY_SCHEDULING;
#endif
#ifdef _POSIX_REALTIME_SIGNALS
case _SC_REALTIME_SIGNALS: return _POSIX_REALTIME_SIGNALS;
#endif
#ifdef _POSIX_SEMAPHORES
case _SC_SEMAPHORES: return _POSIX_SEMAPHORES;
#endif
#ifdef _POSIX_SHARED_MEMORY_OBJECTS
case _SC_SHARED_MEMORY_OBJECTS: return _POSIX_SHARED_MEMORY_OBJECTS;
#endif
#ifdef _POSIX_SYNCHRONIZED_IO
//case _SC_SHARED_MEMORY_OBJECTS: return _POSIX_SHARED_MEMORY_OBJECTS;
case _SC_SYNCHRONIZED_IO: return _POSIX_SYNCHRONIZED_IO;
#endif
#ifdef _POSIX_TIMERS
case _SC_TIMERS: return _POSIX_TIMERS;
#endif
case _SC_GETGR_R_SIZE_MAX: return 1024;
case _SC_GETPW_R_SIZE_MAX: return 1024;
@@ -314,25 +233,15 @@ long sysconf(int name) {
case _SC_THREAD_STACK_MIN: return PTHREAD_STACK_MIN;
case _SC_THREAD_THREADS_MAX: return SYSTEM_THREAD_THREADS_MAX;
case _SC_TTY_NAME_MAX: return SYSTEM_TTY_NAME_MAX;
#ifdef _POSIX_THREADS
case _SC_THREADS: return _POSIX_THREADS;
#endif
case _SC_THREAD_ATTR_STACKADDR: return -1; // Removed in POSIX 2008
case _SC_THREAD_ATTR_STACKSIZE: return -1; // Removed in POSIX 2008
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
case _SC_THREAD_PRIORITY_SCHEDULING: return _POSIX_THREAD_PRIORITY_SCHEDULING;
#endif
#ifdef _POSIX_THREAD_PRIO_INHERIT
//case _SC_THREAD_PRIORITY_SCHEDULING: return _POSIX_THREAD_PRIORITY_SCHEDULING;
case _SC_THREAD_PRIO_INHERIT: return _POSIX_THREAD_PRIO_INHERIT;
#endif
#ifdef _POSIX_THREAD_PRIO_PROTECT
case _SC_THREAD_PRIO_PROTECT: return _POSIX_THREAD_PRIO_PROTECT;
#endif
#ifdef _POSIX_THREAD_SAFE_FUNCTIONS
case _SC_THREAD_SAFE_FUNCTIONS: return _POSIX_THREAD_SAFE_FUNCTIONS
#endif
//case _SC_THREAD_SAFE_FUNCTIONS: return _POSIX_THREAD_SAFE_FUNCTIONS
case _SC_MONOTONIC_CLOCK: return __sysconf_monotonic_clock();
case _SC_NPROCESSORS_CONF: return __sysconf_nprocessors_conf();
@@ -341,9 +250,9 @@ long sysconf(int name) {
case _SC_AVPHYS_PAGES: return __sysconf_avphys_pages();
default:
/* Posix says EINVAL is the only error that shall be returned,
* but GLibc uses ENOSYS */
errno = ENOSYS;
return -1;
}
// Posix says EINVAL is the only error that shall be returned,
// but glibc uses ENOSYS.
errno = ENOSYS;
return -1;
}
}

View File

@@ -26,6 +26,7 @@
* SUCH DAMAGE.
*/
#include <new>
#include <stdatomic.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@@ -45,7 +46,6 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <unistd.h>
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <sys/_system_properties.h>
@@ -80,6 +80,16 @@ struct prop_bt {
uint8_t namelen;
uint8_t reserved[3];
// TODO: The following fields should be declared as atomic_uint32_t.
// They should be assigned to with release semantics, instead of using
// explicit fences. Unfortunately, the read accesses are generally
// followed by more dependent read accesses, and the dependence
// is assumed to enforce memory ordering. Which it does on supported
// hardware. This technically should use memory_order_consume, if
// that worked as intended.
// We should also avoid rereading these fields redundantly, since not
// all processor implementations ensure that multiple loads from the
// same field are carried out in the right order.
volatile uint32_t prop;
volatile uint32_t left;
@@ -93,7 +103,8 @@ struct prop_bt {
this->namelen = name_length;
memcpy(this->name, name, name_length);
this->name[name_length] = '\0';
ANDROID_MEMBAR_FULL();
ANDROID_MEMBAR_FULL(); // TODO: Instead use a release store
// for subsequent pointer assignment.
}
private:
@@ -102,14 +113,15 @@ private:
struct prop_area {
uint32_t bytes_used;
volatile uint32_t serial;
atomic_uint_least32_t serial;
uint32_t magic;
uint32_t version;
uint32_t reserved[28];
char data[0];
prop_area(const uint32_t magic, const uint32_t version) :
serial(0), magic(magic), version(version) {
magic(magic), version(version) {
atomic_init(&serial, 0);
memset(reserved, 0, sizeof(reserved));
// Allocate enough space for the root node.
bytes_used = sizeof(prop_bt);
@@ -120,7 +132,7 @@ private:
};
struct prop_info {
volatile uint32_t serial;
atomic_uint_least32_t serial;
char value[PROP_VALUE_MAX];
char name[0];
@@ -128,10 +140,11 @@ struct prop_info {
const uint8_t valuelen) {
memcpy(this->name, name, namelen);
this->name[namelen] = '\0';
this->serial = (valuelen << 24);
atomic_init(&this->serial, valuelen << 24);
memcpy(this->value, value, valuelen);
this->value[valuelen] = '\0';
ANDROID_MEMBAR_FULL();
ANDROID_MEMBAR_FULL(); // TODO: Instead use a release store
// for subsequent point assignment.
}
private:
DISALLOW_COPY_AND_ASSIGN(prop_info);
@@ -188,14 +201,6 @@ static int map_prop_area_rw()
return -1;
}
// TODO: Is this really required ? Does android run on any kernels that
// don't support O_CLOEXEC ?
const int ret = fcntl(fd, F_SETFD, FD_CLOEXEC);
if (ret < 0) {
close(fd);
return -1;
}
if (ftruncate(fd, PA_SIZE) < 0) {
close(fd);
return -1;
@@ -258,18 +263,9 @@ static int map_fd_ro(const int fd) {
static int map_prop_area()
{
int fd(open(property_filename, O_RDONLY | O_NOFOLLOW | O_CLOEXEC));
if (fd >= 0) {
/* For old kernels that don't support O_CLOEXEC */
const int ret = fcntl(fd, F_SETFD, FD_CLOEXEC);
if (ret < 0) {
close(fd);
return -1;
}
}
int fd = open(property_filename, O_CLOEXEC | O_NOFOLLOW | O_RDONLY);
bool close_fd = true;
if ((fd < 0) && (errno == ENOENT)) {
if (fd == -1 && errno == ENOENT) {
/*
* For backwards compatibility, if the file doesn't
* exist, we use the environment to get the file descriptor.
@@ -598,6 +594,14 @@ const prop_info *__system_property_find(const char *name)
return find_property(root_node(), name, strlen(name), NULL, 0, false);
}
// The C11 standard doesn't allow atomic loads from const fields,
// though C++11 does. Fudge it until standards get straightened out.
static inline uint_least32_t load_const_atomic(const atomic_uint_least32_t* s,
memory_order mo) {
atomic_uint_least32_t* non_const_s = const_cast<atomic_uint_least32_t*>(s);
return atomic_load_explicit(non_const_s, mo);
}
int __system_property_read(const prop_info *pi, char *name, char *value)
{
if (__predict_false(compat_mode)) {
@@ -605,11 +609,20 @@ int __system_property_read(const prop_info *pi, char *name, char *value)
}
while (true) {
uint32_t serial = __system_property_serial(pi);
uint32_t serial = __system_property_serial(pi); // acquire semantics
size_t len = SERIAL_VALUE_LEN(serial);
memcpy(value, pi->value, len + 1);
ANDROID_MEMBAR_FULL();
if (serial == pi->serial) {
// TODO: Fix the synchronization scheme here.
// There is no fully supported way to implement this kind
// of synchronization in C++11, since the memcpy races with
// updates to pi, and the data being accessed is not atomic.
// The following fence is unintuitive, but would be the
// correct one if memcpy used memory_order_relaxed atomic accesses.
// In practice it seems unlikely that the generated code would
// would be any different, so this should be OK.
atomic_thread_fence(memory_order_acquire);
if (serial ==
load_const_atomic(&(pi->serial), memory_order_relaxed)) {
if (name != 0) {
strcpy(name, pi->name);
}
@@ -658,14 +671,24 @@ int __system_property_update(prop_info *pi, const char *value, unsigned int len)
if (len >= PROP_VALUE_MAX)
return -1;
pi->serial = pi->serial | 1;
ANDROID_MEMBAR_FULL();
uint32_t serial = atomic_load_explicit(&pi->serial, memory_order_relaxed);
serial |= 1;
atomic_store_explicit(&pi->serial, serial, memory_order_relaxed);
// The memcpy call here also races. Again pretend it
// used memory_order_relaxed atomics, and use the analogous
// counterintuitive fence.
atomic_thread_fence(memory_order_release);
memcpy(pi->value, value, len + 1);
ANDROID_MEMBAR_FULL();
pi->serial = (len << 24) | ((pi->serial + 1) & 0xffffff);
atomic_store_explicit(
&pi->serial,
(len << 24) | ((serial + 1) & 0xffffff),
memory_order_release);
__futex_wake(&pi->serial, INT32_MAX);
pa->serial++;
atomic_store_explicit(
&pa->serial,
atomic_load_explicit(&pa->serial, memory_order_relaxed) + 1,
memory_order_release);
__futex_wake(&pa->serial, INT32_MAX);
return 0;
@@ -688,17 +711,25 @@ int __system_property_add(const char *name, unsigned int namelen,
if (!pi)
return -1;
pa->serial++;
// There is only a single mutator, but we want to make sure that
// updates are visible to a reader waiting for the update.
atomic_store_explicit(
&pa->serial,
atomic_load_explicit(&pa->serial, memory_order_relaxed) + 1,
memory_order_release);
__futex_wake(&pa->serial, INT32_MAX);
return 0;
}
// Wait for non-locked serial, and retrieve it with acquire semantics.
unsigned int __system_property_serial(const prop_info *pi)
{
uint32_t serial = pi->serial;
uint32_t serial = load_const_atomic(&pi->serial, memory_order_acquire);
while (SERIAL_DIRTY(serial)) {
__futex_wait(const_cast<volatile uint32_t*>(&pi->serial), serial, NULL);
serial = pi->serial;
__futex_wait(const_cast<volatile void *>(
reinterpret_cast<const void *>(&pi->serial)),
serial, NULL);
serial = load_const_atomic(&pi->serial, memory_order_acquire);
}
return serial;
}
@@ -706,12 +737,14 @@ unsigned int __system_property_serial(const prop_info *pi)
unsigned int __system_property_wait_any(unsigned int serial)
{
prop_area *pa = __system_property_area__;
uint32_t my_serial;
do {
__futex_wait(&pa->serial, serial, NULL);
} while (pa->serial == serial);
my_serial = atomic_load_explicit(&pa->serial, memory_order_acquire);
} while (my_serial == serial);
return pa->serial;
return my_serial;
}
const prop_info *__system_property_find_nth(unsigned n)

View File

@@ -748,10 +748,24 @@ static int valid_tm_mon( const struct TM* date ) {
char *asctime64_r( const struct TM* date, char *result ) {
/* I figure everything else can be displayed, even hour 25, but if
these are out of range we walk off the name arrays */
if( !valid_tm_wday(date) || !valid_tm_mon(date) )
if (!valid_tm_wday(date) || !valid_tm_mon(date)) {
return NULL;
}
sprintf(result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
/* Docs state this function does not support years beyond 9999. */
if (1900 + date->tm_year > 9999) {
return NULL;
}
/*
* The IBM docs for this function state that the result buffer can be
* assumed to be at least 26 bytes wide. The docs also state that this is
* only valid for years <= 9999, so we know this format string will not
* print more than that many characters.
*
* http://www-01.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.bpxbd00/asctimer.htm
*/
snprintf(result, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
wday_name[date->tm_wday],
mon_name[date->tm_mon],
date->tm_mday, date->tm_hour,

View File

@@ -565,7 +565,7 @@ android_read_hostent(FILE* proxy)
char buf[4];
if (fread(buf, 1, sizeof(buf), proxy) != sizeof(buf)) return NULL;
/* This is reading serialized data from system/netd/server/DnsProxyListener.cpp
/* This is reading serialized data from system/netd/DnsProxyListener.cpp
* and changes here need to be matched there */
int result_code = strtol(buf, NULL, 10);
if (result_code != DnsProxyQueryResult) {
@@ -763,7 +763,7 @@ gethostbyname_internal(const char *name, int af, res_state res, unsigned netid,
netid = __netdClientDispatch.netIdForResolv(netid);
/* This is writing to system/netd/server/DnsProxyListener.cpp and changes
/* This is writing to system/netd/DnsProxyListener.cpp and changes
* here need to be matched there */
if (fprintf(proxy, "gethostbyname %u %s %d",
netid,
@@ -899,7 +899,7 @@ _sethtent(int f)
res_static rs = __res_get_static();
if (rs == NULL) return;
if (!rs->hostf)
rs->hostf = fopen(_PATH_HOSTS, "r" );
rs->hostf = fopen(_PATH_HOSTS, "re" );
else
rewind(rs->hostf);
rs->stayopen = f;
@@ -925,7 +925,7 @@ _gethtent(void)
int af, len;
res_static rs = __res_get_static();
if (!rs->hostf && !(rs->hostf = fopen(_PATH_HOSTS, "r" ))) {
if (!rs->hostf && !(rs->hostf = fopen(_PATH_HOSTS, "re" ))) {
h_errno = NETDB_INTERNAL;
return NULL;
}

View File

@@ -32,6 +32,11 @@
#include <sys/cdefs.h>
struct __res_state;
struct resolv_cache; /* forward */
/* Gets the cache for a network. Returned cache might be NULL. */
__LIBC_HIDDEN__
extern struct resolv_cache* __get_res_cache(unsigned netid);
/* sets the name server addresses to the provided res_state structure. The
* name servers are retrieved from the cache which is associated
@@ -48,7 +53,7 @@ typedef enum {
__LIBC_HIDDEN__
extern ResolvCacheStatus
_resolv_cache_lookup( unsigned netid,
_resolv_cache_lookup( struct resolv_cache* cache,
const void* query,
int querylen,
void* answer,
@@ -60,7 +65,7 @@ _resolv_cache_lookup( unsigned netid,
*/
__LIBC_HIDDEN__
extern void
_resolv_cache_add( unsigned netid,
_resolv_cache_add( struct resolv_cache* cache,
const void* query,
int querylen,
const void* answer,
@@ -69,7 +74,7 @@ _resolv_cache_add( unsigned netid,
/* Notify the cache a request failed */
__LIBC_HIDDEN__
extern void
_resolv_cache_query_failed( unsigned netid,
_resolv_cache_query_failed( struct resolv_cache* cache,
const void* query,
int querylen);

View File

@@ -36,7 +36,7 @@
#include <netinet/in.h>
/*
* Passing NETID_UNSET as the netId causes system/netd/server/DnsProxyListener.cpp to
* Passing NETID_UNSET as the netId causes system/netd/DnsProxyListener.cpp to
* fill in the appropriate default netId for the query.
*/
#define NETID_UNSET 0u
@@ -72,9 +72,6 @@ struct hostent *android_gethostbyaddrfornet_proxy(const void *, socklen_t, int ,
int android_getnameinfofornet(const struct sockaddr *, socklen_t, char *, size_t, char *, size_t,
int, unsigned, unsigned);
/* delete the cache associated with a certain network */
extern void _resolv_delete_cache_for_net(unsigned netid);
__END_DECLS
#endif /* _RESOLV_NETID_H */

View File

@@ -426,7 +426,7 @@ int b64_ntop(u_char const *, size_t, char *, size_t);
int b64_pton(char const *, u_char *, size_t);
#endif
int loc_aton(const char *, u_char *);
const char * loc_ntoa(const u_char *, char *);
const char * loc_ntoa(const u_char *, char *, size_t);
int dn_skipname(const u_char *, const u_char *);
void putlong(uint32_t, u_char *);
void putshort(uint16_t, u_char *);
@@ -498,16 +498,6 @@ __LIBC_HIDDEN__ void res_setnetid(res_state, unsigned);
__LIBC_HIDDEN__ void res_setmark(res_state, unsigned);
u_int res_randomid(void);
#ifdef __i386__
# define __socketcall extern __attribute__((__cdecl__))
#else
# define __socketcall extern
#endif
__socketcall int __connect(int, const struct sockaddr*, socklen_t);
#undef __socketcall
__END_DECLS
#pragma GCC visibility pop

View File

@@ -43,12 +43,6 @@ __RCSID("$NetBSD: ns_name.c,v 1.9 2012/03/13 21:13:39 christos Exp $");
#include <stdlib.h>
#include <limits.h>
#ifdef SPRINTF_CHAR
# define SPRINTF(x) ((int)strlen(sprintf/**/x))
#else
# define SPRINTF(x) (sprintf x)
#endif
#define NS_TYPE_ELT 0x40 /* EDNS0 extended label type */
#define DNS_LABELTYPE_BITSTRING 0x41
@@ -1012,31 +1006,31 @@ decode_bitstring(const unsigned char **cpp, char *dn, const char *eom)
return(-1);
cp++;
i = SPRINTF((dn, "\\[x"));
i = snprintf(dn, eom - dn, "\\[x");
if (i < 0)
return (-1);
dn += i;
for (b = blen; b > 7; b -= 8, cp++) {
i = SPRINTF((dn, "%02x", *cp & 0xff));
i = snprintf(dn, eom - dn, "%02x", *cp & 0xff);
if (i < 0)
return (-1);
dn += i;
}
if (b > 4) {
tc = *cp++;
i = SPRINTF((dn, "%02x", tc & (0xff << (8 - b))));
i = snprintf(dn, eom - dn, "%02x", tc & (0xff << (8 - b)));
if (i < 0)
return (-1);
dn += i;
} else if (b > 0) {
tc = *cp++;
i = SPRINTF((dn, "%1x",
(((u_int32_t)tc >> 4) & 0x0f) & (0x0f << (4 - b))));
i = snprintf(dn, eom - dn, "%1x",
(((u_int32_t)tc >> 4) & 0x0f) & (0x0f << (4 - b)));
if (i < 0)
return (-1);
dn += i;
}
i = SPRINTF((dn, "/%d]", blen));
i = snprintf(dn, eom - dn, "/%d]", blen);
if (i < 0)
return (-1);
dn += i;

View File

@@ -48,12 +48,6 @@ __RCSID("$NetBSD: ns_print.c,v 1.11 2012/03/13 21:13:39 christos Exp $");
#include <string.h>
#include <ctype.h>
#ifdef SPRINTF_CHAR
# define SPRINTF(x) ((int)strlen(sprintf/**/x))
#else
# define SPRINTF(x) (sprintf x)
#endif
#ifndef MIN
#define MIN(x,y) ((x)<(y)?(x):(y))
#endif
@@ -155,7 +149,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
*/
T(x = ns_format_ttl(ttl, buf, buflen));
addlen((size_t)x, &buf, &buflen);
len = SPRINTF((tmp, " %s %s", p_class(class), p_type(type)));
len = snprintf(tmp, sizeof(tmp), " %s %s", p_class(class), p_type(type));
T(addstr(tmp, (size_t)len, &buf, &buflen));
T(spaced = addtab((size_t)(x + len), (size_t)16, spaced, &buf, &buflen));
@@ -218,7 +212,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
/* Serial number. */
t = ns_get32(rdata); rdata += NS_INT32SZ;
T(addstr("\t\t\t\t\t", (size_t)5, &buf, &buflen));
len = SPRINTF((tmp, "%lu", t));
len = snprintf(tmp, sizeof(tmp), "%lu", t);
T(addstr(tmp, (size_t)len, &buf, &buflen));
T(spaced = addtab((size_t)len, (size_t)16, spaced, &buf, &buflen));
T(addstr("; serial\n", (size_t)9, &buf, &buflen));
@@ -275,7 +269,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
/* Priority. */
t = ns_get16(rdata);
rdata += NS_INT16SZ;
len = SPRINTF((tmp, "%u ", t));
len = snprintf(tmp, sizeof(tmp), "%u ", t);
T(addstr(tmp, (size_t)len, &buf, &buflen));
/* Target. */
@@ -293,7 +287,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
/* Priority. */
t = ns_get16(rdata);
rdata += NS_INT16SZ;
len = SPRINTF((tmp, "%u ", t));
len = snprintf(tmp, sizeof(tmp), "%u ", t);
T(addstr(tmp, (size_t)len, &buf, &buflen));
/* Name1. */
@@ -344,7 +338,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
char t[255];
/* XXX protocol format checking? */
(void) loc_ntoa(rdata, t);
(void) loc_ntoa(rdata, t, sizeof(t));
T(addstr(t, strlen(t), &buf, &buflen));
break;
}
@@ -359,7 +353,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
/* Order, Precedence. */
order = ns_get16(rdata); rdata += NS_INT16SZ;
preference = ns_get16(rdata); rdata += NS_INT16SZ;
len = SPRINTF((t, "%u %u ", order, preference));
len = snprintf(t, sizeof(t), "%u %u ", order, preference);
T(addstr(t, (size_t)len, &buf, &buflen));
/* Flags. */
@@ -401,7 +395,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
priority = ns_get16(rdata); rdata += NS_INT16SZ;
weight = ns_get16(rdata); rdata += NS_INT16SZ;
port = ns_get16(rdata); rdata += NS_INT16SZ;
len = SPRINTF((t, "%u %u %u ", priority, weight, port));
len = snprintf(t, sizeof(t), "%u %u %u ", priority, weight, port);
T(addstr(t, (size_t)len, &buf, &buflen));
/* Server. */
@@ -432,7 +426,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
rdata += NS_INADDRSZ;
/* Protocol. */
len = SPRINTF((tmp, " %u ( ", *rdata));
len = snprintf(tmp, sizeof(tmp), " %u ( ", *rdata);
T(addstr(tmp, (size_t)len, &buf, &buflen));
rdata += NS_INT8SZ;
@@ -449,7 +443,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
lcnt = 10;
spaced = 0;
}
len = SPRINTF((tmp, "%d ", n));
len = snprintf(tmp, sizeof(tmp), "%d ", n);
T(addstr(tmp, (size_t)len, &buf, &buflen));
lcnt--;
}
@@ -480,8 +474,8 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
keyflags = ns_get16(rdata); rdata += NS_INT16SZ;
protocol = *rdata++;
algorithm = *rdata++;
len = SPRINTF((tmp, "0x%04x %u %u",
keyflags, protocol, algorithm));
len = snprintf(tmp, sizeof(tmp), "0x%04x %u %u",
keyflags, protocol, algorithm);
T(addstr(tmp, (size_t)len, &buf, &buflen));
/* Public key data. */
@@ -502,7 +496,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
}
if (len > 15)
T(addstr(" )", (size_t)2, &buf, &buflen));
n = SPRINTF((tmp, " ; key_tag= %u", key_id));
n = snprintf(tmp, sizeof(tmp), " ; key_tag= %u", key_id);
T(addstr(tmp, (size_t)n, &buf, &buflen));
break;
@@ -524,25 +518,25 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
algorithm = *rdata++;
labels = *rdata++;
t = ns_get32(rdata); rdata += NS_INT32SZ;
len = SPRINTF((tmp, "%s %d %d %lu ",
p_type((int)typ), algorithm, labels, t));
len = snprintf(tmp, sizeof(tmp), "%s %d %d %lu ",
p_type((int)typ), algorithm, labels, t);
T(addstr(tmp, (size_t)len, &buf, &buflen));
if (labels > (u_int)dn_count_labels(name))
goto formerr;
/* Signature expiry. */
t = ns_get32(rdata); rdata += NS_INT32SZ;
len = SPRINTF((tmp, "%s ", p_secstodate(t)));
len = snprintf(tmp, sizeof(tmp), "%s ", p_secstodate(t));
T(addstr(tmp, (size_t)len, &buf, &buflen));
/* Time signed. */
t = ns_get32(rdata); rdata += NS_INT32SZ;
len = SPRINTF((tmp, "%s ", p_secstodate(t)));
len = snprintf(tmp, sizeof(tmp), "%s ", p_secstodate(t));
T(addstr(tmp, (size_t)len, &buf, &buflen));
/* Signature Footprint. */
footprint = ns_get16(rdata); rdata += NS_INT16SZ;
len = SPRINTF((tmp, "%u ", footprint));
len = snprintf(tmp, sizeof(tmp), "%u ", footprint);
T(addstr(tmp, (size_t)len, &buf, &buflen));
/* Signer's name. */
@@ -579,7 +573,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
n = edata - rdata;
for (c = 0; c < n*8; c++)
if (NS_NXT_BIT_ISSET(c, rdata)) {
len = SPRINTF((tmp, " %s", p_type((int)c)));
len = snprintf(tmp, sizeof(tmp), " %s", p_type((int)c));
T(addstr(tmp, (size_t)len, &buf, &buflen));
}
break;
@@ -596,7 +590,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
key_tag = ns_get16(rdata); rdata += NS_INT16SZ;
alg = (u_int) *rdata++;
len = SPRINTF((tmp1, "%d %d %d ", c_type, key_tag, alg));
len = snprintf(tmp1, sizeof(tmp1), "%d %d %d ", c_type, key_tag, alg);
T(addstr(tmp1, (size_t)len, &buf, &buflen));
siz = (edata-rdata)*4/3 + 4; /* "+4" accounts for trailing \0 */
if (siz > sizeof(base64_cert) * 3/4) {
@@ -640,12 +634,12 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
/* Inception. */
t = ns_get32(rdata); rdata += NS_INT32SZ;
len = SPRINTF((tmp, "%s ", p_secstodate(t)));
len = snprintf(tmp, sizeof(tmp), "%s ", p_secstodate(t));
T(addstr(tmp, (size_t)len, &buf, &buflen));
/* Experation. */
t = ns_get32(rdata); rdata += NS_INT32SZ;
len = SPRINTF((tmp, "%s ", p_secstodate(t)));
len = snprintf(tmp, sizeof(tmp), "%s ", p_secstodate(t));
T(addstr(tmp, (size_t)len, &buf, &buflen));
/* Mode , Error, Key Size. */
@@ -653,7 +647,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
mode = ns_get16(rdata); rdata += NS_INT16SZ;
err = ns_get16(rdata); rdata += NS_INT16SZ;
keysize = ns_get16(rdata); rdata += NS_INT16SZ;
len = SPRINTF((tmp, "%u %u %u ", mode, err, keysize));
len = snprintf(tmp, sizeof(tmp), "%u %u %u ", mode, err, keysize);
T(addstr(tmp, (size_t)len, &buf, &buflen));
/* XXX need to dump key, print otherdata length & other data */
@@ -670,7 +664,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
n = ns_get16(rdata); rdata += INT16SZ;
rdata += n; /* sig */
n = ns_get16(rdata); rdata += INT16SZ; /* original id */
sprintf(buf, "%d", ns_get16(rdata));
snprintf(buf, buflen, "%d", ns_get16(rdata));
rdata += INT16SZ;
addlen(strlen(buf), &buf, &buflen);
break;
@@ -682,7 +676,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
/* prefix length */
if (rdlen == 0U) goto formerr;
len = SPRINTF((tmp, "%d ", *rdata));
len = snprintf(tmp, sizeof(tmp), "%d ", *rdata);
T(addstr(tmp, (size_t)len, &buf, &buflen));
pbit = *rdata;
if (pbit > 128) goto formerr;
@@ -710,7 +704,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
}
case ns_t_opt: {
len = SPRINTF((tmp, "%u bytes", class));
len = snprintf(tmp, sizeof(tmp), "%u bytes", class);
T(addstr(tmp, (size_t)len, &buf, &buflen));
break;
}
@@ -724,21 +718,21 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
if (rdlen < 4U) goto formerr;
t = ns_get16(rdata);
rdata += NS_INT16SZ;
len = SPRINTF((tmp, "%u ", t));
len = snprintf(tmp, sizeof(tmp), "%u ", t);
T(addstr(tmp, (size_t)len, &buf, &buflen));
} else
if (rdlen < 2U) goto formerr;
len = SPRINTF((tmp, "%u ", *rdata));
len = snprintf(tmp, sizeof(tmp), "%u ", *rdata);
T(addstr(tmp, (size_t)len, &buf, &buflen));
rdata++;
len = SPRINTF((tmp, "%u ", *rdata));
len = snprintf(tmp, sizeof(tmp), "%u ", *rdata);
T(addstr(tmp, (size_t)len, &buf, &buflen));
rdata++;
while (rdata < edata) {
len = SPRINTF((tmp, "%02X", *rdata));
len = snprintf(tmp, sizeof(tmp), "%02X", *rdata);
T(addstr(tmp, (size_t)len, &buf, &buflen));
rdata++;
}
@@ -749,17 +743,17 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
case ns_t_nsec3param: {
u_int t, w, l, j, k, c;
len = SPRINTF((tmp, "%u ", *rdata));
len = snprintf(tmp, sizeof(tmp), "%u ", *rdata);
T(addstr(tmp, (size_t)len, &buf, &buflen));
rdata++;
len = SPRINTF((tmp, "%u ", *rdata));
len = snprintf(tmp, sizeof(tmp), "%u ", *rdata);
T(addstr(tmp, (size_t)len, &buf, &buflen));
rdata++;
t = ns_get16(rdata);
rdata += NS_INT16SZ;
len = SPRINTF((tmp, "%u ", t));
len = snprintf(tmp, sizeof(tmp), "%u ", t);
T(addstr(tmp, (size_t)len, &buf, &buflen));
t = *rdata++;
@@ -767,7 +761,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
T(addstr("-", 1, &buf, &buflen));
} else {
while (t-- > 0) {
len = SPRINTF((tmp, "%02X", *rdata));
len = snprintf(tmp, sizeof(tmp), "%02X", *rdata);
T(addstr(tmp, (size_t)len, &buf, &buflen));
rdata++;
}
@@ -851,7 +845,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
if ((rdata[j] & (0x80 >> k)) == 0)
continue;
c = w * 256 + j * 8 + k;
len = SPRINTF((tmp, " %s", p_type((ns_type)c)));
len = snprintf(tmp, sizeof(tmp), " %s", p_type((ns_type)c));
T(addstr(tmp, (size_t)len, &buf, &buflen));
}
}
@@ -875,7 +869,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
if ((rdata[j] & (0x80 >> k)) == 0)
continue;
c = w * 256 + j * 8 + k;
len = SPRINTF((tmp, " %s", p_type((ns_type)c)));
len = snprintf(tmp, sizeof(tmp), " %s", p_type((ns_type)c));
T(addstr(tmp, (size_t)len, &buf, &buflen));
}
}
@@ -949,15 +943,15 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
goto hexify;
}
len = SPRINTF((tmp, "%u ", *rdata));
len = snprintf(tmp, sizeof(tmp), "%u ", *rdata);
T(addstr(tmp, (size_t)len, &buf, &buflen));
rdata++;
len = SPRINTF((tmp, "%u ", *rdata));
len = snprintf(tmp, sizeof(tmp), "%u ", *rdata);
T(addstr(tmp, (size_t)len, &buf, &buflen));
rdata++;
len = SPRINTF((tmp, "%u ", *rdata));
len = snprintf(tmp, sizeof(tmp), "%u ", *rdata);
T(addstr(tmp, (size_t)len, &buf, &buflen));
rdata++;
@@ -1030,11 +1024,11 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
const char *str = "record too long to print";
T(addstr(str, strlen(str), &buf, &buflen));
} else {
len = sprintf(tmp, "( %u ", algorithm);
len = snprintf(tmp, sizeof(tmp), "( %u ", algorithm);
T(addstr(tmp, (size_t)len, &buf, &buflen));
for (i = 0; i < hip_len; i++) {
len = sprintf(tmp, "%02X", *rdata);
len = snprintf(tmp, sizeof(tmp), "%02X", *rdata);
T(addstr(tmp, (size_t)len, &buf, &buflen));
rdata++;
}
@@ -1069,23 +1063,23 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
int n, m;
char *p;
len = SPRINTF((tmp, "\\# %u%s\t; %s", (unsigned)(edata - rdata),
rdlen != 0U ? " (" : "", comment));
len = snprintf(tmp, sizeof(tmp), "\\# %u%s\t; %s", (unsigned)(edata - rdata),
rdlen != 0U ? " (" : "", comment);
T(addstr(tmp, (size_t)len, &buf, &buflen));
while (rdata < edata) {
p = tmp;
p += SPRINTF((p, "\n\t"));
p += snprintf(p, sizeof(tmp), "\n\t");
spaced = 0;
n = MIN(16, (int)(edata - rdata));
for (m = 0; m < n; m++)
p += SPRINTF((p, "%02x ", rdata[m]));
p += snprintf(p, sizeof(tmp) - (p - tmp), "%02x ", rdata[m]);
T(addstr(tmp, (size_t)(p - tmp), &buf, &buflen));
if (n < 16) {
T(addstr(")", (size_t)1, &buf, &buflen));
T(addtab((size_t)(p - tmp + 1), (size_t)48, spaced, &buf, &buflen));
}
p = tmp;
p += SPRINTF((p, "; "));
p += snprintf(p, sizeof(tmp), "; ");
for (m = 0; m < n; m++)
*p++ = (isascii(rdata[m]) && isprint(rdata[m]))
? rdata[m]

View File

@@ -36,12 +36,6 @@ __RCSID("$NetBSD: ns_ttl.c,v 1.8 2012/03/13 21:13:39 christos Exp $");
#include <stdio.h>
#include <string.h>
#ifdef SPRINTF_CHAR
# define SPRINTF(x) strlen(sprintf/**/x)
#else
# define SPRINTF(x) ((size_t)sprintf x)
#endif
/* Forward. */
static int fmt1(int t, char s, char **buf, size_t *buflen);
@@ -157,8 +151,8 @@ fmt1(int t, char s, char **buf, size_t *buflen) {
char tmp[50];
size_t len;
len = SPRINTF((tmp, "%d%c", t, s));
if (len + 1 > *buflen)
len = (size_t)snprintf(tmp, sizeof(tmp), "%d%c", t, s);
if ((int)len < 0 || len + 1 > *buflen)
return (-1);
strcpy(*buf, tmp);
*buf += len;

View File

@@ -369,7 +369,7 @@ _test_connect(int pf, struct sockaddr *addr, size_t addrlen, unsigned mark) {
return 0;
int ret;
do {
ret = __connect(s, addr, addrlen);
ret = connect(s, addr, addrlen);
} while (ret < 0 && errno == EINTR);
int success = (ret == 0);
do {
@@ -1803,7 +1803,7 @@ _find_src_addr(const struct sockaddr *addr, struct sockaddr *src_addr, unsigned
if (mark != MARK_UNSET && setsockopt(sock, SOL_SOCKET, SO_MARK, &mark, sizeof(mark)) < 0)
return 0;
do {
ret = __connect(sock, addr, len);
ret = connect(sock, addr, len);
} while (ret == -1 && errno == EINTR);
if (ret == -1) {
@@ -2017,7 +2017,7 @@ _sethtent(FILE **hostf)
{
if (!*hostf)
*hostf = fopen(_PATH_HOSTS, "r" );
*hostf = fopen(_PATH_HOSTS, "re");
else
rewind(*hostf);
}
@@ -2046,7 +2046,7 @@ _gethtent(FILE **hostf, const char *name, const struct addrinfo *pai)
assert(name != NULL);
assert(pai != NULL);
if (!*hostf && !(*hostf = fopen(_PATH_HOSTS, "r" )))
if (!*hostf && !(*hostf = fopen(_PATH_HOSTS, "re")))
return (NULL);
again:
if (!(p = fgets(hostbuf, sizeof hostbuf, *hostf)))

View File

@@ -30,8 +30,8 @@ static const char _services[] = "\
\6tacacs\0\61u\0\
\12re-mail-ck\0\62t\0\
\12re-mail-ck\0\62u\0\
\6domain\0\65t\1\12nameserver\
\6domain\0\65u\1\12nameserver\
\6domain\0\65t\0\
\6domain\0\65u\0\
\3mtp\0\71t\0\
\11tacacs-ds\0\101t\0\
\11tacacs-ds\0\101u\0\
@@ -44,8 +44,8 @@ static const char _services[] = "\
\6gopher\0\106u\0\
\3rje\0\115t\1\6netrjs\
\6finger\0\117t\0\
\3www\0\120t\1\4http\
\3www\0\120u\0\
\4http\0\120t\1\3www\
\4http\0\120u\0\
\4link\0\127t\1\7ttylink\
\10kerberos\0\130t\3\11kerberos5\4krb5\14kerberos-sec\
\10kerberos\0\130u\3\11kerberos5\4krb5\14kerberos-sec\
@@ -138,12 +138,16 @@ static const char _services[] = "\
\4ldap\1\205u\0\
\4imsp\1\226t\0\
\4imsp\1\226u\0\
\6svrloc\1\253t\0\
\6svrloc\1\253u\0\
\5https\1\273t\0\
\5https\1\273u\0\
\4snpp\1\274t\0\
\4snpp\1\274u\0\
\14microsoft-ds\1\275t\0\
\14microsoft-ds\1\275u\0\
\7kpasswd\1\320t\0\
\7kpasswd\1\320u\0\
\4saft\1\347t\0\
\4saft\1\347u\0\
\6isakmp\1\364t\0\
@@ -158,6 +162,8 @@ static const char _services[] = "\
\10npmp-gui\2\143u\1\14dqs313_execd\
\10hmmp-ind\2\144t\1\20dqs313_intercell\
\10hmmp-ind\2\144u\1\20dqs313_intercell\
\4qmqp\2\164t\0\
\4qmqp\2\164u\0\
\3ipp\2\167t\0\
\3ipp\2\167u\0\
\4exec\2\0t\0\
@@ -181,8 +187,14 @@ static const char _services[] = "\
\4uucp\2\34t\1\5uucpd\
\6klogin\2\37t\0\
\6kshell\2\40t\1\5krcmd\
\15dhcpv6-client\2\42t\0\
\15dhcpv6-client\2\42u\0\
\15dhcpv6-server\2\43t\0\
\15dhcpv6-server\2\43u\0\
\12afpovertcp\2\44t\0\
\12afpovertcp\2\44u\0\
\4idfp\2\45t\0\
\4idfp\2\45u\0\
\10remotefs\2\54t\2\12rfs_server\3rfs\
\5nntps\2\63t\1\5snntp\
\5nntps\2\63u\1\5snntp\
@@ -239,19 +251,33 @@ static const char _services[] = "\
\13sa-msg-port\6\156u\1\13old-radacct\
\6kermit\6\161t\0\
\6kermit\6\161u\0\
\11groupwise\6\215t\0\
\11groupwise\6\215u\0\
\3l2f\6\245t\1\4l2tp\
\3l2f\6\245u\1\4l2tp\
\6radius\7\24t\0\
\6radius\7\24u\0\
\13radius-acct\7\25t\1\7radacct\
\13radius-acct\7\25u\1\7radacct\
\4msnp\7\107t\0\
\4msnp\7\107u\0\
\13unix-status\7\245t\0\
\12log-server\7\246t\0\
\12remoteping\7\247t\0\
\12cisco-sccp\7\320t\0\
\12cisco-sccp\7\320u\0\
\6search\7\332t\1\4ndtp\
\13pipe-server\7\332t\1\13pipe_server\
\3nfs\10\1t\0\
\3nfs\10\1u\0\
\6gnunet\10\46t\0\
\6gnunet\10\46u\0\
\12rtcm-sc104\10\65t\0\
\12rtcm-sc104\10\65u\0\
\15gsigatekeeper\10\107t\0\
\15gsigatekeeper\10\107u\0\
\4gris\10\127t\0\
\4gris\10\127u\0\
\12cvspserver\11\141t\0\
\12cvspserver\11\141u\0\
\5venus\11\176t\0\
@@ -266,10 +292,14 @@ static const char _services[] = "\
\3mon\12\27u\0\
\4dict\12\104t\0\
\4dict\12\104u\0\
\15f5-globalsite\12\350t\0\
\15f5-globalsite\12\350u\0\
\6gsiftp\12\373t\0\
\6gsiftp\12\373u\0\
\4gpsd\13\203t\0\
\4gpsd\13\203u\0\
\6gds_db\13\352t\0\
\6gds_db\13\352u\0\
\6gds-db\13\352t\1\6gds_db\
\6gds-db\13\352u\1\6gds_db\
\5icpv2\14\72t\1\3icp\
\5icpv2\14\72u\1\3icp\
\5mysql\14\352t\0\
@@ -282,24 +312,49 @@ static const char _services[] = "\
\4daap\16\151u\0\
\3svn\16\152t\1\12subversion\
\3svn\16\152u\1\12subversion\
\5suucp\17\277t\0\
\5suucp\17\277u\0\
\6sysrqd\17\376t\0\
\6sysrqd\17\376u\0\
\5sieve\20\136t\0\
\4epmd\21\21t\0\
\4epmd\21\21u\0\
\6remctl\21\25t\0\
\6remctl\21\25u\0\
\11f5-iquery\21\1t\0\
\11f5-iquery\21\1u\0\
\3iax\21\331t\0\
\3iax\21\331u\0\
\3mtn\22\123t\0\
\3mtn\22\123u\0\
\13radmin-port\23\43t\0\
\13radmin-port\23\43u\0\
\3rfe\23\212u\0\
\3rfe\23\212t\0\
\4mmcc\23\272t\0\
\4mmcc\23\272u\0\
\3sip\23\304t\0\
\3sip\23\304u\0\
\7sip-tls\23\305t\0\
\7sip-tls\23\305u\0\
\3aol\24\106t\0\
\3aol\24\106u\0\
\13xmpp-client\24\146t\1\15jabber-client\
\13xmpp-client\24\146u\1\15jabber-client\
\13xmpp-server\24\225t\1\15jabber-server\
\13xmpp-server\24\225u\1\15jabber-server\
\10cfengine\24\274t\0\
\10cfengine\24\274u\0\
\4mdns\24\351t\0\
\4mdns\24\351u\0\
\12postgresql\25\70t\1\10postgres\
\12postgresql\25\70u\1\10postgres\
\7freeciv\25\264t\1\4rptp\
\7freeciv\25\264u\0\
\4amqp\26\50t\0\
\4amqp\26\50u\0\
\3ggz\26\70t\0\
\3ggz\26\70u\0\
\3x11\27\160t\1\5x11-0\
\3x11\27\160u\1\5x11-0\
\5x11-1\27\161t\0\
@@ -320,6 +375,12 @@ static const char _services[] = "\
\14gnutella-svc\30\312u\0\
\14gnutella-rtr\30\313t\0\
\14gnutella-rtr\30\313u\0\
\13sge-qmaster\31\54t\1\13sge_qmaster\
\13sge-qmaster\31\54u\1\13sge_qmaster\
\11sge-execd\31\55t\1\11sge_execd\
\11sge-execd\31\55u\1\11sge_execd\
\13mysql-proxy\31\56t\0\
\13mysql-proxy\31\56u\0\
\17afs3-fileserver\33\130t\1\3bbs\
\17afs3-fileserver\33\130u\1\3bbs\
\15afs3-callback\33\131t\0\
@@ -342,12 +403,21 @@ static const char _services[] = "\
\13afs3-rmtsys\33\141u\0\
\14font-service\33\274t\1\3xfs\
\14font-service\33\274u\1\3xfs\
\10http-alt\37\220t\1\10webcache\
\10http-alt\37\220u\0\
\12bacula-dir\43\215t\0\
\12bacula-dir\43\215u\0\
\11bacula-fd\43\216t\0\
\11bacula-fd\43\216u\0\
\11bacula-sd\43\217t\0\
\11bacula-sd\43\217u\0\
\5xmms2\45\303t\0\
\5xmms2\45\303u\0\
\3nbd\52\71t\0\
\14zabbix-agent\47\102t\0\
\14zabbix-agent\47\102u\0\
\16zabbix-trapper\47\103t\0\
\16zabbix-trapper\47\103u\0\
\6amanda\47\140t\0\
\6amanda\47\140u\0\
\3hkp\54\153t\0\
@@ -364,16 +434,17 @@ static const char _services[] = "\
\4bpcd\65\326u\0\
\6vopied\65\327t\0\
\6vopied\65\327u\0\
\4dcap\126\155t\0\
\7gsidcap\126\160t\0\
\4wnn6\127\1t\0\
\4wnn6\127\1u\0\
\11kerberos4\2\356u\2\13kerberos-iv\3kdc\
\11kerberos4\2\356t\2\13kerberos-iv\3kdc\
\17kerberos_master\2\357u\0\
\17kerberos_master\2\357t\0\
\15passwd_server\2\360u\0\
\10krb_prop\2\362t\2\11krb5_prop\5hprop\
\17kerberos-master\2\357u\1\17kerberos_master\
\17kerberos-master\2\357t\0\
\15passwd-server\2\360u\1\15passwd_server\
\10krb-prop\2\362t\3\10krb_prop\11krb5_prop\5hprop\
\11krbupdate\2\370t\1\4kreg\
\7kpasswd\2\371t\1\4kpwd\
\4swat\3\205t\0\
\4kpop\4\125t\0\
\5knetd\10\5t\0\
@@ -389,9 +460,9 @@ static const char _services[] = "\
\10poppassd\0\152t\0\
\10poppassd\0\152u\0\
\5ssmtp\1\321t\1\5smtps\
\10moira_db\3\7t\0\
\14moira_update\3\11t\0\
\12moira_ureg\3\13u\0\
\10moira-db\3\7t\1\10moira_db\
\14moira-update\3\11t\1\14moira_update\
\12moira-ureg\3\13u\1\12moira_ureg\
\5spamd\3\17t\0\
\5omirr\3\50t\1\6omirrd\
\5omirr\3\50u\1\6omirrd\
@@ -404,9 +475,7 @@ static const char _services[] = "\
\4xtel\5\41t\0\
\5xtelw\5\42t\0\
\7support\5\371t\0\
\5sieve\7\320t\0\
\7cfinger\7\323t\0\
\4ndtp\7\332t\0\
\4frox\10\111t\0\
\10ninstall\10\146t\0\
\10ninstall\10\146u\0\
@@ -436,9 +505,7 @@ static const char _services[] = "\
\7hostmon\24\353t\0\
\7hostmon\24\353u\0\
\5rplay\25\263u\0\
\5rplay\25\263t\0\
\4rptp\25\264u\0\
\4rptp\25\264t\0\
\4nrpe\26\42t\0\
\4nsca\26\43t\0\
\4mrtd\26\52t\0\
\6bgpsim\26\53t\0\
@@ -446,14 +513,15 @@ static const char _services[] = "\
\11sane-port\31\246t\2\4sane\5saned\
\4ircd\32\13t\0\
\10zope-ftp\37\125t\0\
\10webcache\37\220t\0\
\6tproxy\37\221t\0\
\7omniorb\37\230t\0\
\7omniorb\37\230u\0\
\20clc-build-daemon\43\36t\0\
\6xinetd\43\212t\0\
\13mandelspawn\44\217u\1\12mandelbrot\
\3git\44\312t\0\
\4zope\45\311t\0\
\6webmin\47\20t\0\
\7kamanda\47\141t\0\
\7kamanda\47\141u\0\
\11amandaidx\47\142t\0\
@@ -473,6 +541,7 @@ static const char _services[] = "\
\5binkp\137\352t\0\
\3asp\152\356t\0\
\3asp\152\356u\0\
\6csync2\170\221t\0\
\11dircproxy\336\250t\0\
\5tfido\353\21t\0\
\4fido\353\23t\0\

View File

@@ -1218,6 +1218,7 @@ typedef struct resolv_cache {
int max_entries;
int num_entries;
Entry mru_list;
pthread_mutex_t lock;
int last_id;
Entry* entries;
PendingReqInfo pending_requests;
@@ -1235,15 +1236,6 @@ struct resolv_cache_info {
#define HTABLE_VALID(x) ((x) != NULL && (x) != HTABLE_DELETED)
static pthread_once_t _res_cache_once = PTHREAD_ONCE_INIT;
static void _res_cache_init(void);
// lock protecting everything in the _resolve_cache_info structs (next ptr, etc)
static pthread_mutex_t _res_cache_list_lock;
/* gets cache associated with a network, or NULL if none exists */
static struct resolv_cache* _find_named_cache_locked(unsigned netid);
static void
_cache_flush_pending_requests_locked( struct resolv_cache* cache )
{
@@ -1264,18 +1256,18 @@ _cache_flush_pending_requests_locked( struct resolv_cache* cache )
}
}
/* Return 0 if no pending request is found matching the key.
* If a matching request is found the calling thread will wait until
* the matching request completes, then update *cache and return 1. */
/* return 0 if no pending request is found matching the key
* if a matching request is found the calling thread will wait
* and return 1 when released */
static int
_cache_check_pending_request_locked( struct resolv_cache** cache, Entry* key, unsigned netid )
_cache_check_pending_request_locked( struct resolv_cache* cache, Entry* key )
{
struct pending_req_info *ri, *prev;
int exist = 0;
if (*cache && key) {
ri = (*cache)->pending_requests.next;
prev = &(*cache)->pending_requests;
if (cache && key) {
ri = cache->pending_requests.next;
prev = &cache->pending_requests;
while (ri) {
if (ri->hash == key->hash) {
exist = 1;
@@ -1296,9 +1288,7 @@ _cache_check_pending_request_locked( struct resolv_cache** cache, Entry* key, un
struct timespec ts = {0,0};
XLOG("Waiting for previous request");
ts.tv_sec = _time_now() + PENDING_REQUEST_TIMEOUT;
pthread_cond_timedwait(&ri->cond, &_res_cache_list_lock, &ts);
/* Must update *cache as it could have been deleted. */
*cache = _find_named_cache_locked(netid);
pthread_cond_timedwait(&ri->cond, &cache->lock, &ts);
}
}
@@ -1335,25 +1325,17 @@ _cache_notify_waiting_tid_locked( struct resolv_cache* cache, Entry* key )
/* notify the cache that the query failed */
void
_resolv_cache_query_failed( unsigned netid,
_resolv_cache_query_failed( struct resolv_cache* cache,
const void* query,
int querylen)
{
Entry key[1];
Cache* cache;
if (!entry_init_key(key, query, querylen))
return;
pthread_mutex_lock(&_res_cache_list_lock);
cache = _find_named_cache_locked(netid);
if (cache) {
if (cache && entry_init_key(key, query, querylen)) {
pthread_mutex_lock(&cache->lock);
_cache_notify_waiting_tid_locked(cache, key);
pthread_mutex_unlock(&cache->lock);
}
pthread_mutex_unlock(&_res_cache_list_lock);
}
static void
@@ -1409,6 +1391,7 @@ _resolv_cache_create( void )
cache->max_entries = _res_cache_get_max_entries();
cache->entries = calloc(sizeof(*cache->entries), cache->max_entries);
if (cache->entries) {
pthread_mutex_init( &cache->lock, NULL );
cache->mru_list.mru_prev = cache->mru_list.mru_next = &cache->mru_list;
XLOG("%s: cache created\n", __FUNCTION__);
} else {
@@ -1453,7 +1436,7 @@ _dump_answer(const void* answer, int answerlen)
char* buf;
int fileLen;
fp = fopen("/data/reslog.txt", "w+");
fp = fopen("/data/reslog.txt", "w+e");
if (fp != NULL) {
statep = __res_get_state();
@@ -1603,7 +1586,7 @@ static void _cache_remove_expired(Cache* cache) {
}
ResolvCacheStatus
_resolv_cache_lookup( unsigned netid,
_resolv_cache_lookup( struct resolv_cache* cache,
const void* query,
int querylen,
void* answer,
@@ -1614,7 +1597,6 @@ _resolv_cache_lookup( unsigned netid,
Entry** lookup;
Entry* e;
time_t now;
Cache* cache;
ResolvCacheStatus result = RESOLV_CACHE_NOTFOUND;
@@ -1627,14 +1609,7 @@ _resolv_cache_lookup( unsigned netid,
return RESOLV_CACHE_UNSUPPORTED;
}
/* lookup cache */
pthread_once(&_res_cache_once, _res_cache_init);
pthread_mutex_lock(&_res_cache_list_lock);
cache = _find_named_cache_locked(netid);
if (cache == NULL) {
result = RESOLV_CACHE_UNSUPPORTED;
goto Exit;
}
pthread_mutex_lock( &cache->lock );
/* see the description of _lookup_p to understand this.
* the function always return a non-NULL pointer.
@@ -1646,7 +1621,7 @@ _resolv_cache_lookup( unsigned netid,
XLOG( "NOT IN CACHE");
// calling thread will wait if an outstanding request is found
// that matching this query
if (!_cache_check_pending_request_locked(&cache, key, netid) || cache == NULL) {
if (!_cache_check_pending_request_locked(cache, key)) {
goto Exit;
} else {
lookup = _cache_lookup_p(cache, key);
@@ -1687,13 +1662,13 @@ _resolv_cache_lookup( unsigned netid,
result = RESOLV_CACHE_FOUND;
Exit:
pthread_mutex_unlock(&_res_cache_list_lock);
pthread_mutex_unlock( &cache->lock );
return result;
}
void
_resolv_cache_add( unsigned netid,
_resolv_cache_add( struct resolv_cache* cache,
const void* query,
int querylen,
const void* answer,
@@ -1703,7 +1678,6 @@ _resolv_cache_add( unsigned netid,
Entry* e;
Entry** lookup;
u_long ttl;
Cache* cache = NULL;
/* don't assume that the query has already been cached
*/
@@ -1712,12 +1686,7 @@ _resolv_cache_add( unsigned netid,
return;
}
pthread_mutex_lock(&_res_cache_list_lock);
cache = _find_named_cache_locked(netid);
if (cache == NULL) {
goto Exit;
}
pthread_mutex_lock( &cache->lock );
XLOG( "%s: query:", __FUNCTION__ );
XLOG_QUERY(query,querylen);
@@ -1763,10 +1732,8 @@ _resolv_cache_add( unsigned netid,
_cache_dump_mru(cache);
#endif
Exit:
if (cache != NULL) {
_cache_notify_waiting_tid_locked(cache, key);
}
pthread_mutex_unlock(&_res_cache_list_lock);
_cache_notify_waiting_tid_locked(cache, key);
pthread_mutex_unlock( &cache->lock );
}
/****************************************************************************/
@@ -1777,13 +1744,20 @@ Exit:
/****************************************************************************/
/****************************************************************************/
static pthread_once_t _res_cache_once = PTHREAD_ONCE_INIT;
// Head of the list of caches. Protected by _res_cache_list_lock.
static struct resolv_cache_info _res_cache_list;
// lock protecting everything in the _resolve_cache_info structs (next ptr, etc)
static pthread_mutex_t _res_cache_list_lock;
/* insert resolv_cache_info into the list of resolv_cache_infos */
static void _insert_cache_info_locked(struct resolv_cache_info* cache_info);
/* creates a resolv_cache_info */
static struct resolv_cache_info* _create_cache_info( void );
/* gets cache associated with a network, or NULL if none exists */
static struct resolv_cache* _find_named_cache_locked(unsigned netid);
/* gets a resolv_cache_info associated with a network, or NULL if not found */
static struct resolv_cache_info* _find_cache_info_locked(unsigned netid);
/* look up the named cache, and creates one if needed */
@@ -1811,6 +1785,22 @@ _res_cache_init(void)
pthread_mutex_init(&_res_cache_list_lock, NULL);
}
struct resolv_cache*
__get_res_cache(unsigned netid)
{
struct resolv_cache *cache;
pthread_once(&_res_cache_once, _res_cache_init);
pthread_mutex_lock(&_res_cache_list_lock);
/* Does NOT create a cache if it does not exist. */
cache = _find_named_cache_locked(netid);
pthread_mutex_unlock(&_res_cache_list_lock);
XLOG("%s: netid=%u, cache=%p\n", __FUNCTION__, netid, cache);
return cache;
}
static struct resolv_cache*
_get_res_cache_for_net_locked(unsigned netid)
{
@@ -1847,36 +1837,12 @@ _flush_cache_for_net_locked(unsigned netid)
{
struct resolv_cache* cache = _find_named_cache_locked(netid);
if (cache) {
pthread_mutex_lock(&cache->lock);
_cache_flush_locked(cache);
pthread_mutex_unlock(&cache->lock);
}
}
void _resolv_delete_cache_for_net(unsigned netid)
{
pthread_once(&_res_cache_once, _res_cache_init);
pthread_mutex_lock(&_res_cache_list_lock);
struct resolv_cache_info* prev_cache_info = &_res_cache_list;
while (prev_cache_info->next) {
struct resolv_cache_info* cache_info = prev_cache_info->next;
if (cache_info->netid == netid) {
prev_cache_info->next = cache_info->next;
_cache_flush_locked(cache_info->cache);
free(cache_info->cache->entries);
free(cache_info->cache);
_free_nameservers_locked(cache_info);
free(cache_info);
break;
}
prev_cache_info = prev_cache_info->next;
}
pthread_mutex_unlock(&_res_cache_list_lock);
}
static struct resolv_cache_info*
_create_cache_info(void)
{
@@ -1949,7 +1915,7 @@ _resolv_set_nameservers_for_net(unsigned netid, const char** servers, int numser
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM; /*dummy*/
hints.ai_flags = AI_NUMERICHOST;
sprintf(sbuf, "%u", NAMESERVER_PORT);
snprintf(sbuf, sizeof(sbuf), "%u", NAMESERVER_PORT);
index = 0;
for (i = 0; i < numservers && i < MAXNS; i++) {

View File

@@ -126,14 +126,6 @@ __RCSID("$NetBSD: res_debug.c,v 1.13 2012/06/25 22:32:45 abs Exp $");
#include <strings.h>
#include <time.h>
#ifdef SPRINTF_CHAR
# define SPRINTF(x) strlen(sprintf/**/x)
#else
# define SPRINTF(x) sprintf x
#endif
extern const char * const _res_opcodes[];
extern const char * const _res_sectioncodes[];
@@ -588,7 +580,7 @@ sym_ntos(const struct res_sym *syms, int number, int *success) {
}
}
sprintf(unname, "%d", number); /* XXX nonreentrant */
snprintf(unname, sizeof(unname), "%d", number); /* XXX nonreentrant */
if (success)
*success = 0;
return (unname);
@@ -605,7 +597,7 @@ sym_ntop(const struct res_sym *syms, int number, int *success) {
return (syms->humanname);
}
}
sprintf(unname, "%d", number); /* XXX nonreentrant */
snprintf(unname, sizeof(unname), "%d", number); /* XXX nonreentrant */
if (success)
*success = 0;
return (unname);
@@ -625,7 +617,7 @@ p_type(int type) {
return (result);
if (type < 0 || type > 0xffff)
return ("BADTYPE");
sprintf(typebuf, "TYPE%d", type);
snprintf(typebuf, sizeof(typebuf), "TYPE%d", type);
return (typebuf);
}
@@ -661,7 +653,7 @@ p_class(int class) {
return (result);
if (class < 0 || class > 0xffff)
return ("BADCLASS");
sprintf(classbuf, "CLASS%d", class);
snprintf(classbuf, sizeof(classbuf), "CLASS%d", class);
return (classbuf);
}
@@ -703,7 +695,7 @@ p_option(u_long option) {
case RES_NO_NIBBLE2: return "no-nibble2";
#endif
/* XXX nonreentrant */
default: sprintf(nbuf, "?0x%lx?", (u_long)option);
default: snprintf(nbuf, sizeof(nbuf), "?0x%lx?", (u_long)option);
return (nbuf);
}
}
@@ -716,7 +708,7 @@ p_time(u_int32_t value) {
static char nbuf[40]; /* XXX nonreentrant */
if (ns_format_ttl((u_long)value, nbuf, sizeof nbuf) < 0)
sprintf(nbuf, "%u", value);
snprintf(nbuf, sizeof(nbuf), "%u", value);
return (nbuf);
}
@@ -745,7 +737,7 @@ p_sockun(union res_sockaddr_union u, char *buf, size_t size) {
break;
#endif
default:
sprintf(ret, "[af%d]", u.sin.sin_family);
snprintf(ret, sizeof(ret), "[af%d]", u.sin.sin_family);
break;
}
if (size > 0U) {
@@ -777,7 +769,7 @@ precsize_ntoa(u_int32_t prec)
val = mantissa * poweroften[exponent];
(void) sprintf(retbuf, "%lu.%.2lu", val/100, val%100);
(void) snprintf(retbuf, sizeof(retbuf), "%lu.%.2lu", val/100, val%100);
return (retbuf);
}
@@ -1028,7 +1020,7 @@ loc_aton(const char *ascii, u_char *binary)
/* takes an on-the-wire LOC RR and formats it in a human readable format. */
const char *
loc_ntoa(const u_char *binary, char *ascii)
loc_ntoa(const u_char *binary, char *ascii, size_t bufsiz)
{
static const char *error = "?";
static char tmpbuf[sizeof
@@ -1055,7 +1047,7 @@ loc_ntoa(const u_char *binary, char *ascii)
ascii = tmpbuf;
if (versionval) {
(void) sprintf(ascii, "; error: unknown LOC RR version");
(void) snprintf(ascii, bufsiz, "; error: unknown LOC RR version");
return (ascii);
}
@@ -1114,7 +1106,7 @@ loc_ntoa(const u_char *binary, char *ascii)
hpstr = strdup(precsize_ntoa((u_int32_t)hpval));
vpstr = strdup(precsize_ntoa((u_int32_t)vpval));
sprintf(ascii,
snprintf(ascii, bufsiz,
"%d %.2d %.2d.%.3d %c %d %.2d %.2d.%.3d %c %s%d.%.2dm %sm %sm %sm",
latdeg, latmin, latsec, latsecfrac, northsouth,
longdeg, longmin, longsec, longsecfrac, eastwest,
@@ -1180,7 +1172,7 @@ p_secstodate (u_long secs) {
#endif
mytime->tm_year += 1900;
mytime->tm_mon += 1;
sprintf(output, "%04d%02d%02d%02d%02d%02d",
snprintf(output, sizeof(output), "%04d%02d%02d%02d%02d%02d",
mytime->tm_year, mytime->tm_mon, mytime->tm_mday,
mytime->tm_hour, mytime->tm_min, mytime->tm_sec);
return (output);

View File

@@ -289,7 +289,7 @@ __res_vinit(res_state statp, int preinit) {
line[sizeof(name) - 1] == '\t'))
nserv = 0;
if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
if ((fp = fopen(_PATH_RESCONF, "re")) != NULL) {
/* read the config file */
while (fgets(buf, sizeof(buf), fp) != NULL) {
/* skip comments */
@@ -616,47 +616,6 @@ net_mask(struct in_addr in) /*!< XXX - should really use system's version of thi
}
#endif
#ifdef ANDROID_CHANGES
static int
real_randomid(u_int *random_value) {
/* open the nonblocking random device, returning -1 on failure */
int random_device = open("/dev/urandom", O_RDONLY | O_CLOEXEC);
if (random_device < 0) {
return -1;
}
/* read from the random device, returning -1 on failure (or too many retries)*/
for (u_int retry = 5; retry > 0; retry--) {
int retval = read(random_device, random_value, sizeof(u_int));
if (retval == sizeof(u_int)) {
*random_value &= 0xffff;
close(random_device);
return 0;
} else if ((retval < 0) && (errno != EINTR)) {
break;
}
}
close(random_device);
return -1;
}
#endif /* ANDROID_CHANGES */
u_int
res_randomid(void) {
#ifdef ANDROID_CHANGES
int status = 0;
u_int output = 0;
status = real_randomid(&output);
if (status != -1) {
return output;
}
#endif /* ANDROID_CHANGES */
struct timeval now;
gettimeofday(&now, NULL);
return (0xffff & (now.tv_sec ^ now.tv_usec ^ getpid()));
}
/*%
* This routine is for closing the socket if a virtual circuit is used and
* the program wants to close it. This provides support for endhostent()

View File

@@ -414,7 +414,7 @@ res_nquerydomain(res_state statp,
RES_SET_H_ERRNO(statp, NO_RECOVERY);
return (-1);
}
sprintf(nbuf, "%s.%s", name, domain);
snprintf(nbuf, sizeof(nbuf), "%s.%s", name, domain);
}
return (res_nquery(statp, longname, class, type, answer, anslen));
}

View File

@@ -367,6 +367,7 @@ res_nsend(res_state statp,
int gotsomewhere, terrno, try, v_circuit, resplen, ns, n;
char abuf[NI_MAXHOST];
#if USE_RESOLV_CACHE
struct resolv_cache* cache;
ResolvCacheStatus cache_status = RESOLV_CACHE_UNSUPPORTED;
#endif
@@ -388,24 +389,24 @@ res_nsend(res_state statp,
terrno = ETIMEDOUT;
#if USE_RESOLV_CACHE
int anslen = 0;
cache_status = _resolv_cache_lookup(
statp->netid, buf, buflen,
ans, anssiz, &anslen);
// get the cache associated with the network
cache = __get_res_cache(statp->netid);
if (cache != NULL) {
int anslen = 0;
cache_status = _resolv_cache_lookup(
cache, buf, buflen,
ans, anssiz, &anslen);
if (cache_status == RESOLV_CACHE_FOUND) {
return anslen;
} else if (cache_status != RESOLV_CACHE_UNSUPPORTED) {
// had a cache miss for a known network, so populate the thread private
// data so the normal resolve path can do its thing
_resolv_populate_res_for_net(statp);
if (cache_status == RESOLV_CACHE_FOUND) {
return anslen;
} else {
// had a cache miss for a known network, so populate the thread private
// data so the normal resolve path can do its thing
_resolv_populate_res_for_net(statp);
}
}
if (statp->nscount == 0) {
// We have no nameservers configured, so there's no point trying.
// Tell the cache the query failed, or any retries and anyone else asking the same
// question will block for PENDING_REQUEST_TIMEOUT seconds instead of failing fast.
_resolv_cache_query_failed(statp->netid, buf, buflen);
errno = ESRCH;
return (-1);
}
@@ -601,7 +602,7 @@ res_nsend(res_state statp,
#if USE_RESOLV_CACHE
if (cache_status == RESOLV_CACHE_NOTFOUND) {
_resolv_cache_add(statp->netid, buf, buflen,
_resolv_cache_add(cache, buf, buflen,
ans, resplen);
}
#endif
@@ -657,13 +658,13 @@ res_nsend(res_state statp,
errno = terrno;
#if USE_RESOLV_CACHE
_resolv_cache_query_failed(statp->netid, buf, buflen);
_resolv_cache_query_failed(cache, buf, buflen);
#endif
return (-1);
fail:
#if USE_RESOLV_CACHE
_resolv_cache_query_failed(statp->netid, buf, buflen);
_resolv_cache_query_failed(cache, buf, buflen);
#endif
res_nclose(statp);
return (-1);
@@ -950,7 +951,7 @@ connect_with_timeout(int sock, const struct sockaddr *nsap, socklen_t salen, int
origflags = fcntl(sock, F_GETFL, 0);
fcntl(sock, F_SETFL, origflags | O_NONBLOCK);
res = __connect(sock, nsap, salen);
res = connect(sock, nsap, salen);
if (res < 0 && errno != EINPROGRESS) {
res = -1;
goto done;
@@ -1107,7 +1108,7 @@ send_dg(res_state statp,
res_nclose(statp);
return (0);
}
if (__connect(EXT(statp).nssocks[ns], nsap, (socklen_t)nsaplen) < 0) {
if (connect(EXT(statp).nssocks[ns], nsap, (socklen_t)nsaplen) < 0) {
Aerror(statp, stderr, "connect(dg)", errno, nsap,
nsaplen);
res_nclose(statp);

View File

@@ -54,11 +54,11 @@ enum {
*/
ANDROID_DLEXT_USE_LIBRARY_FD = 0x10,
/* If opening a library using library_fd read it starting at library_fd_offset.
/* When opening library using library_fd read it starting with library_offset
* This flag is only valid when ANDROID_DLEXT_USE_LIBRARY_FD is set.
*/
ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET = 0x20,
ANDROID_DLEXT_USE_LIBRARY_OFFSET = 0x20,
/* Mask of valid bits */
ANDROID_DLEXT_VALID_FLAG_BITS = ANDROID_DLEXT_RESERVED_ADDRESS |
@@ -66,7 +66,7 @@ enum {
ANDROID_DLEXT_WRITE_RELRO |
ANDROID_DLEXT_USE_RELRO |
ANDROID_DLEXT_USE_LIBRARY_FD |
ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET,
ANDROID_DLEXT_USE_LIBRARY_OFFSET,
};
typedef struct {
@@ -75,7 +75,7 @@ typedef struct {
size_t reserved_size;
int relro_fd;
int library_fd;
off64_t library_fd_offset;
off64_t library_offset;
} android_dlextinfo;
extern void* android_dlopen_ext(const char* filename, int flag, const android_dlextinfo* extinfo);

View File

@@ -518,8 +518,9 @@ typedef enum __ns_cert_types {
(cp) += NS_INT32SZ; \
} while (/*CONSTCOND*/0)
#if !defined(__LP64__)
/* Annoyingly, LP32 shipped with __ names. */
/*
* ANSI C identifier hiding for bind's lib/nameser.
*/
#define ns_msg_getflag __ns_msg_getflag
#define ns_get16 __ns_get16
#define ns_get32 __ns_get32
@@ -563,73 +564,101 @@ typedef enum __ns_cert_types {
#define ns_subdomain __ns_subdomain
#define ns_makecanon __ns_makecanon
#define ns_samename __ns_samename
#endif
#define ns_newmsg_init __ns_newmsg_init
#define ns_newmsg_copy __ns_newmsg_copy
#define ns_newmsg_id __ns_newmsg_id
#define ns_newmsg_flag __ns_newmsg_flag
#define ns_newmsg_q __ns_newmsg_q
#define ns_newmsg_rr __ns_newmsg_rr
#define ns_newmsg_done __ns_newmsg_done
#define ns_rdata_unpack __ns_rdata_unpack
#define ns_rdata_equal __ns_rdata_equal
#define ns_rdata_refers __ns_rdata_refers
__BEGIN_DECLS
int ns_msg_getflag(ns_msg, int) __LIBC_ABI_PUBLIC__;
uint16_t ns_get16(const u_char *) __LIBC_ABI_PUBLIC__;
uint32_t ns_get32(const u_char *) __LIBC_ABI_PUBLIC__;
void ns_put16(uint16_t, u_char *) __LIBC_ABI_PUBLIC__;
void ns_put32(uint32_t, u_char *) __LIBC_ABI_PUBLIC__;
int ns_initparse(const u_char *, int, ns_msg *) __LIBC_ABI_PUBLIC__;
int ns_skiprr(const u_char *, const u_char *, ns_sect, int) __LIBC_ABI_PUBLIC__;
int ns_parserr(ns_msg *, ns_sect, int, ns_rr *) __LIBC_ABI_PUBLIC__;
int ns_parserr2(ns_msg *, ns_sect, int, ns_rr2 *) __LIBC_HIDDEN__;
int ns_msg_getflag(ns_msg, int);
uint16_t ns_get16(const u_char *);
uint32_t ns_get32(const u_char *);
void ns_put16(uint16_t, u_char *);
void ns_put32(uint32_t, u_char *);
int ns_initparse(const u_char *, int, ns_msg *);
int ns_skiprr(const u_char *, const u_char *, ns_sect, int);
int ns_parserr(ns_msg *, ns_sect, int, ns_rr *);
int ns_parserr2(ns_msg *, ns_sect, int, ns_rr2 *);
int ns_sprintrr(const ns_msg *, const ns_rr *,
const char *, const char *, char *, size_t) __LIBC_ABI_PUBLIC__;
const char *, const char *, char *, size_t);
int ns_sprintrrf(const u_char *, size_t, const char *,
ns_class, ns_type, u_long, const u_char *,
size_t, const char *, const char *,
char *, size_t) __LIBC_ABI_PUBLIC__;
int ns_format_ttl(u_long, char *, size_t) __LIBC_ABI_PUBLIC__;
int ns_parse_ttl(const char *, u_long *) __LIBC_ABI_PUBLIC__;
uint32_t ns_datetosecs(const char *cp, int *errp) __LIBC_ABI_PUBLIC__;
int ns_name_ntol(const u_char *, u_char *, size_t) __LIBC_ABI_PUBLIC__;
int ns_name_ntop(const u_char *, char *, size_t) __LIBC_ABI_PUBLIC__;
int ns_name_pton(const char *, u_char *, size_t) __LIBC_ABI_PUBLIC__;
int ns_name_pton2(const char *, u_char *, size_t, size_t *) __LIBC_HIDDEN__;
char *, size_t);
int ns_format_ttl(u_long, char *, size_t);
int ns_parse_ttl(const char *, u_long *);
uint32_t ns_datetosecs(const char *cp, int *errp);
int ns_name_ntol(const u_char *, u_char *, size_t);
int ns_name_ntop(const u_char *, char *, size_t);
int ns_name_pton(const char *, u_char *, size_t);
int ns_name_pton2(const char *, u_char *, size_t, size_t *);
int ns_name_unpack(const u_char *, const u_char *,
const u_char *, u_char *, size_t) __LIBC_ABI_PUBLIC__;
const u_char *, u_char *, size_t);
int ns_name_unpack2(const u_char *, const u_char *,
const u_char *, u_char *, size_t,
size_t *) __LIBC_HIDDEN__;
size_t *);
int ns_name_pack(const u_char *, u_char *, int,
const u_char **, const u_char **) __LIBC_ABI_PUBLIC__;
const u_char **, const u_char **);
int ns_name_uncompress(const u_char *, const u_char *,
const u_char *, char *, size_t) __LIBC_ABI_PUBLIC__;
const u_char *, char *, size_t);
int ns_name_compress(const char *, u_char *, size_t,
const u_char **, const u_char **) __LIBC_ABI_PUBLIC__;
int ns_name_skip(const u_char **, const u_char *) __LIBC_ABI_PUBLIC__;
const u_char **, const u_char **);
int ns_name_skip(const u_char **, const u_char *);
void ns_name_rollback(const u_char *, const u_char **,
const u_char **) __LIBC_ABI_PUBLIC__;
const u_char **);
int ns_sign(u_char *, int *, int, int, void *,
const u_char *, int, u_char *, int *, time_t) __LIBC_ABI_PUBLIC__;
const u_char *, int, u_char *, int *, time_t);
int ns_sign2(u_char *, int *, int, int, void *,
const u_char *, int, u_char *, int *, time_t,
u_char **, u_char **) __LIBC_ABI_PUBLIC__;
ssize_t ns_name_length(ns_nname_ct, size_t) __LIBC_HIDDEN__;
int ns_name_eq(ns_nname_ct, size_t, ns_nname_ct, size_t) __LIBC_HIDDEN__;
int ns_name_owned(ns_namemap_ct, int, ns_namemap_ct, int) __LIBC_HIDDEN__;
int ns_name_map(ns_nname_ct, size_t, ns_namemap_t, int) __LIBC_HIDDEN__;
int ns_name_labels(ns_nname_ct, size_t) __LIBC_HIDDEN__;
u_char **, u_char **);
ssize_t ns_name_length(ns_nname_ct, size_t);
int ns_name_eq(ns_nname_ct, size_t, ns_nname_ct, size_t);
int ns_name_owned(ns_namemap_ct, int, ns_namemap_ct, int);
int ns_name_map(ns_nname_ct, size_t, ns_namemap_t, int);
int ns_name_labels(ns_nname_ct, size_t);
int ns_sign_tcp(u_char *, int *, int, int,
ns_tcp_tsig_state *, int) __LIBC_ABI_PUBLIC__;
ns_tcp_tsig_state *, int);
int ns_sign_tcp2(u_char *, int *, int, int,
ns_tcp_tsig_state *, int,
u_char **, u_char **) __LIBC_ABI_PUBLIC__;
u_char **, u_char **);
int ns_sign_tcp_init(void *, const u_char *, int,
ns_tcp_tsig_state *) __LIBC_ABI_PUBLIC__;
u_char *ns_find_tsig(u_char *, u_char *) __LIBC_ABI_PUBLIC__;
ns_tcp_tsig_state *);
u_char *ns_find_tsig(u_char *, u_char *);
int ns_verify(u_char *, int *, void *,
const u_char *, int, u_char *, int *,
time_t *, int) __LIBC_ABI_PUBLIC__;
time_t *, int);
int ns_verify_tcp(u_char *, int *, ns_tcp_tsig_state *, int);
int ns_verify_tcp_init(void *, const u_char *, int,
ns_tcp_tsig_state *) __LIBC_ABI_PUBLIC__;
int ns_samedomain(const char *, const char *) __LIBC_ABI_PUBLIC__;
int ns_subdomain(const char *, const char *) __LIBC_ABI_PUBLIC__;
int ns_makecanon(const char *, char *, size_t) __LIBC_ABI_PUBLIC__;
int ns_samename(const char *, const char *) __LIBC_ABI_PUBLIC__;
ns_tcp_tsig_state *);
int ns_samedomain(const char *, const char *);
int ns_subdomain(const char *, const char *);
int ns_makecanon(const char *, char *, size_t);
int ns_samename(const char *, const char *);
int ns_newmsg_init(u_char *buffer, size_t bufsiz, ns_newmsg *);
int ns_newmsg_copy(ns_newmsg *, ns_msg *);
void ns_newmsg_id(ns_newmsg *handle, uint16_t id);
void ns_newmsg_flag(ns_newmsg *handle, ns_flag flag, u_int value);
int ns_newmsg_q(ns_newmsg *handle, ns_nname_ct qname,
ns_type qtype, ns_class qclass);
int ns_newmsg_rr(ns_newmsg *handle, ns_sect sect,
ns_nname_ct name, ns_type type,
ns_class rr_class, uint32_t ttl,
uint16_t rdlen, const u_char *rdata);
size_t ns_newmsg_done(ns_newmsg *handle);
ssize_t ns_rdata_unpack(const u_char *, const u_char *, ns_type,
const u_char *, size_t, u_char *, size_t);
int ns_rdata_equal(ns_type,
const u_char *, size_t,
const u_char *, size_t);
int ns_rdata_refers(ns_type,
const u_char *, size_t,
const u_char *);
__END_DECLS
#ifdef BIND_4_COMPAT

View File

@@ -64,6 +64,7 @@ enum {
RTLD_GLOBAL = 2,
#endif
RTLD_NOLOAD = 4,
RTLD_NODELETE = 0x01000,
};
#if defined (__LP64__)

View File

@@ -54,29 +54,29 @@ typedef struct {
#define DF_BIND_NOW 0x00000008
#define DF_STATIC_TLS 0x00000010
#define DF_1_NOW 0x00000001 // Perform complete relocation processing.
#define DF_1_GLOBAL 0x00000002 // implies RTLD_GLOBAL
#define DF_1_NOW 0x00000001 /* Perform complete relocation processing. */
#define DF_1_GLOBAL 0x00000002 /* implies RTLD_GLOBAL */
#define DF_1_GROUP 0x00000004
#define DF_1_NODELETE 0x00000008 // implies RTLD_NODELETE
#define DF_1_NODELETE 0x00000008 /* implies RTLD_NODELETE */
#define DF_1_LOADFLTR 0x00000010
#define DF_1_INITFIRST 0x00000020
#define DF_1_NOOPEN 0x00000040 // Object can not be used with dlopen(3)
#define DF_1_NOOPEN 0x00000040 /* Object can not be used with dlopen(3) */
#define DF_1_ORIGIN 0x00000080
#define DF_1_DIRECT 0x00000100
#define DF_1_TRANS 0x00000200
#define DF_1_INTERPOSE 0x00000400
#define DF_1_NODEFLIB 0x00000800
#define DF_1_NODUMP 0x00001000 // Object cannot be dumped with dldump(3)
#define DF_1_NODUMP 0x00001000 /* Object cannot be dumped with dldump(3) */
#define DF_1_CONFALT 0x00002000
#define DF_1_ENDFILTEE 0x00004000
#define DF_1_DISPRELDNE 0x00008000
#define DF_1_DISPRELPND 0x00010000
#define DF_1_NODIRECT 0x00020000
#define DF_1_IGNMULDEF 0x00040000 // Internal use
#define DF_1_NOKSYMS 0x00080000 // Internal use
#define DF_1_NOHDR 0x00100000 // Internal use
#define DF_1_IGNMULDEF 0x00040000 /* Internal use */
#define DF_1_NOKSYMS 0x00080000 /* Internal use */
#define DF_1_NOHDR 0x00100000 /* Internal use */
#define DF_1_EDITED 0x00200000
#define DF_1_NORELOC 0x00400000 // Internal use
#define DF_1_NORELOC 0x00400000 /* Internal use */
#define DF_1_SYMINTPOSE 0x00800000
#define DF_1_GLOBAUDIT 0x01000000
#define DF_1_SINGLETON 0x02000000
@@ -109,4 +109,7 @@ typedef struct {
#define STT_LOPROC 13
#define STT_HIPROC 15
/* The kernel uses NT_PRFPREG but glibc also offers NT_FPREGSET */
#define NT_FPREGSET NT_PRFPREG
#endif /* _ELF_H */

View File

@@ -39,20 +39,14 @@
__BEGIN_DECLS
#ifdef __LP64__
/* LP64 kernels don't have flock64 because their flock is 64-bit. */
struct flock64 {
short l_type;
short l_whence;
off64_t l_start;
off64_t l_len;
pid_t l_pid;
};
/* LP64 kernels don't have F_*64 defines because their flock is 64-bit. */
#define F_GETLK64 F_GETLK
#define F_SETLK64 F_SETLK
#define F_SETLKW64 F_SETLKW
#endif
#define O_ASYNC FASYNC
#define O_RSYNC O_SYNC
#define SPLICE_F_MOVE 1
#define SPLICE_F_NONBLOCK 2

View File

@@ -25,34 +25,11 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _FEATURES_H_
#define _FEATURES_H_
/* certain Linux-specific programs expect a <features.h> header file
* that defines various features macros
*/
/* we do include a number of BSD extensions */
#define _BSD_SOURCE 1
/* we do include a number of GNU extensions */
#define _GNU_SOURCE 1
/* C95 support */
#undef __USE_ISOC95
#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199409L
# define __USE_ISOC95 1
#endif
/* C99 support */
#undef __USE_ISOC99
#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
# define __USE_ISOC99 1
#endif
/* Posix support */
#define __USE_POSIX 1
#define __USE_POSIX2 1
#define __USE_XPG 1
/* Our <features.h> macro fun is all in <sys/cdefs.h>. */
#include <sys/cdefs.h>
#endif /* _FEATURES_H_ */

View File

@@ -25,6 +25,7 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _LIBGEN_H
#define _LIBGEN_H
@@ -33,8 +34,18 @@
__BEGIN_DECLS
/* On Android these don't modify their input, and use thread-local storage for their results. */
#if !defined(__bionic_using_gnu_basename)
/*
* <string.h> gets you the GNU basename.
* <libgen.h> the POSIX one.
* Note that our "POSIX" one has the wrong argument cv-qualifiers, but doesn't
* modify its input and uses thread-local storage for the result if necessary.
*/
extern char* basename(const char*);
#define __bionic_using_posix_basename
#endif
/* This has the wrong argument cv-qualifiers, but doesn't modify its input and uses thread-local storage for the result if necessary. */
extern char* dirname(const char*);
#if !defined(__LP64__)

View File

@@ -37,39 +37,6 @@
#include <sys/cdefs.h>
#if __POSIX_VISIBLE
#define _POSIX_ARG_MAX 4096
#define _POSIX_CHILD_MAX 25
#define _POSIX_LINK_MAX 8
#define _POSIX_MAX_CANON 255
#define _POSIX_MAX_INPUT 255
#define _POSIX_NAME_MAX 14
#define _POSIX_NGROUPS_MAX 0
#define _POSIX_OPEN_MAX 16
#define _POSIX_PATH_MAX 256
#define _POSIX_PIPE_BUF 512
#define _POSIX_RE_DUP_MAX 255
#define _POSIX_SSIZE_MAX 32767
#define _POSIX_STREAM_MAX 8
#define _POSIX_SYMLINK_MAX 255
#define _POSIX_SYMLOOP_MAX 8
#define _POSIX_TZNAME_MAX 3
#define _POSIX2_BC_BASE_MAX 99
#define _POSIX2_BC_DIM_MAX 2048
#define _POSIX2_BC_SCALE_MAX 99
#define _POSIX2_BC_STRING_MAX 1000
#define _POSIX2_COLL_WEIGHTS_MAX 2
#define _POSIX2_EXPR_NEST_MAX 32
#define _POSIX2_LINE_MAX 2048
#define _POSIX2_RE_DUP_MAX _POSIX_RE_DUP_MAX
#if __POSIX_VISIBLE >= 200112
#define _POSIX_TTY_NAME_MAX 9 /* includes trailing NUL */
#define _POSIX_LOGIN_NAME_MAX 9 /* includes trailing NUL */
#endif /* __POSIX_VISIBLE >= 200112 */
#endif /* __POSIX_VISIBLE */
#if __XPG_VISIBLE
#define PASS_MAX 128 /* _PASSWORD_LEN from <pwd.h> */
@@ -125,4 +92,9 @@
/* glibc's PAGE_MASK is the bitwise negation of BSD's! TODO: remove? */
#define PAGE_MASK (~(PAGE_SIZE - 1))
#define SEM_VALUE_MAX 0x3fffffff
/* POSIX says these belong in <unistd.h> but BSD has some in <limits.h>. */
#include <machine/posix_limits.h>
#endif /* !_LIMITS_H_ */

View File

@@ -0,0 +1,73 @@
/*
* Copyright (C) 2014 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _POSIX_LIMITS_H_
#define _POSIX_LIMITS_H_
/* TODO: complete and check these. */
#define _POSIX2_LINE_MAX 2048
#define _POSIX2_RE_DUP_MAX _POSIX_RE_DUP_MAX
#define _POSIX_ARG_MAX 4096
#define _POSIX_CHILD_MAX 25
#define _POSIX_CHOWN_RESTRICTED 1 /* yes, chown requires appropriate privileges */
#define _POSIX_FSYNC 1 /* fdatasync() supported */
#define _POSIX_JOB_CONTROL 1 /* job control is a Linux feature */
#define _POSIX_LINK_MAX 8
#define _POSIX_LOGIN_NAME_MAX 9 /* includes trailing NUL */
#define _POSIX_MAPPED_FILES 1 /* mmap-ed files supported */
#define _POSIX_MAX_CANON 255
#define _POSIX_MAX_INPUT 255
#define _POSIX_MONOTONIC_CLOCK 0 /* the monotonic clock may be available; ask sysconf */
#define _POSIX_NAME_MAX 14
#define _POSIX_NGROUPS_MAX 0
#define _POSIX_NO_TRUNC 1 /* very long pathnames generate an error */
#define _POSIX_OPEN_MAX 16
#define _POSIX_PATH_MAX 256
#define _POSIX_PIPE_BUF 512
#define _POSIX_PRIORITY_SCHEDULING 1 /* priority scheduling is a Linux feature */
#define _POSIX_REALTIME_SIGNALS -1 /* for now, this is not supported */
#define _POSIX_RE_DUP_MAX 255
#define _POSIX_SAVED_IDS 1 /* saved user ids is a Linux feature */
#define _POSIX_SEMAPHORES 200809L
#define _POSIX_SEM_VALUE_MAX 32767
#define _POSIX_SSIZE_MAX 32767
#define _POSIX_STREAM_MAX 8
#define _POSIX_SYMLINK_MAX 255
#define _POSIX_SYMLOOP_MAX 8
#define _POSIX_SYNCHRONIZED_IO 1 /* synchronized i/o supported */
#define _POSIX_THREAD_PRIO_INHERIT 200112L /* linux feature */
#define _POSIX_THREAD_PRIO_PROTECT 200112L /* linux feature */
#define _POSIX_THREADS 1 /* we support threads */
#define _POSIX_THREAD_STACKADDR 1 /* we support thread stack address */
#define _POSIX_THREAD_STACKSIZE 1 /* we support thread stack size */
#define _POSIX_TIMERS 1 /* Posix timers are supported */
#define _POSIX_TTY_NAME_MAX 9 /* includes trailing NUL */
#define _POSIX_TZNAME_MAX 3
#define _POSIX_VDISABLE '\0'
#endif /* _POSIX_LIMITS_H_ */

View File

@@ -24,6 +24,7 @@
*/
#include <sys/cdefs.h>
#include <stddef.h>
#include <stdio.h>
__BEGIN_DECLS
@@ -53,6 +54,27 @@ struct mallinfo {
extern struct mallinfo mallinfo(void);
/*
* XML structure for malloc_info(3) is in the following format:
*
* <malloc version="jemalloc-1">
* <heap nr="INT">
* <allocated-large>INT</allocated-large>
* <allocated-huge>INT</allocated-huge>
* <allocated-bins>INT</allocated-bins>
* <bins-total>INT</bins-total>
* <bin nr="INT">
* <allocated>INT</allocated>
* <nmalloc>INT</nmalloc>
* <ndalloc>INT</ndalloc>
* </bin>
* <!-- more bins -->
* </heap>
* <!-- more heaps -->
* </malloc>
*/
extern int malloc_info(int, FILE *);
__END_DECLS
#endif /* LIBC_INCLUDE_MALLOC_H_ */

View File

@@ -206,10 +206,10 @@ int pthread_mutexattr_settype(pthread_mutexattr_t*, int) __nonnull((1));
int pthread_mutex_destroy(pthread_mutex_t*) __nonnull((1));
int pthread_mutex_init(pthread_mutex_t*, const pthread_mutexattr_t*) __nonnull((1));
int pthread_mutex_lock(pthread_mutex_t*) /* __nonnull((1)) */;
int pthread_mutex_lock(pthread_mutex_t*) __nonnull((1));
int pthread_mutex_timedlock(pthread_mutex_t*, const struct timespec*) __nonnull((1, 2));
int pthread_mutex_trylock(pthread_mutex_t*) __nonnull((1));
int pthread_mutex_unlock(pthread_mutex_t*) /* __nonnull((1)) */;
int pthread_mutex_unlock(pthread_mutex_t*) __nonnull((1));
int pthread_once(pthread_once_t*, void (*)(void)) __nonnull((1, 2));

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