History log of /bionic/libc/Android.mk
Revision Date Author Comments
f36b5088a32775c44661fb6b348ed0b6b3b67e65 26-Apr-2014 Elliott Hughes <enh@google.com> Fix brk/sbrk error checking.

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

Also optimizes the query case.

Also hides an accidentally-exported symbol for LP64.

Bug: 28740702

(cherry picked from commit 533dde4dbf87d6615952be3654fc74e5ff2e1003)

Change-Id: Ied16987756a501acf292368a14e3727ad631efa5
66c25c360afb161be02fbdb8da21cd02c9d99447 13-Feb-2016 Elliott Hughes <enh@google.com> Fix regerror(..., nullptr, 0).

Found by passing a bad regular expression to the Google benchmark
code (https://github.com/google/benchmark).

(cherry picked from commit cac2908b08f517802e719ddafe39f45c85c96a33)

Change-Id: I317a7c2ea6535998c0853029023fcefc88cb3750
0c485dae707fac45f5d8baff7da1a469e25c2261 03-Feb-2016 Elliott Hughes <enh@google.com> Add in6addr_any and in6addr_loopback symbols.

Change-Id: I3a90fa448b6bd43321672ba74b84a4e9e8a67738
03e65eb03bf0bfaafa797daf91e80e8308968db3 26-Jan-2016 Elliott Hughes <enh@google.com> Implement funopen64.

Bug: http://b/24807045
Change-Id: I161920978161389be34b707cc6ce8e05f760d552
5704c423c81790195161c1757ae79da188590c51 26-Jan-2016 Elliott Hughes <enh@google.com> Implement POSIX lockf.

This has been requested a few times over the years. This is basically
a very late rebase of https://android-review.googlesource.com/45470
which was abandoned years ago. One addition is that this version has
_FILE_OFFSET_BITS=64 support.

POSIX puts this in <unistd.h>. glibc also has it in <fcntl.h>.

Bug: http://b/13077650
Change-Id: I5862b1dc326e326c01ad92438ecc1578d19ba739
63860cb8fd1adf3f679b9b4ad876323a8d65cd9d 17-Nov-2015 Christopher Ferris <cferris@google.com> Malloc debug rewrite.

The major components of the rewrite:

- Completely remove the qemu shared library code. Nobody was using it
and it appears to have broken at some point.
- Adds the ability to enable/disable different options independently.
- Adds a new option that can enable the backtrace on alloc/free when
a process gets a specific signal.
- Adds a new way to enable malloc debug. If a special property is
set, and the process has an environment variable set, then debug
malloc will be enabled. This allows something that might be
a derivative of app_process to be started with an environment variable
being enabled.
- get_malloc_leak_info() used to return one element for each pointer that
had the exact same backtrace. The new version returns information for
every one of the pointers with same backtrace. It turns out ddms already
automatically coalesces these, so the old method simply hid the fact
that there where multiple pointers with the same amount of backtrace.
- Moved all of the malloc debug specific code into the library.
Nothing related to the malloc debug data structures remains in libc.
- Removed the calls to the debug malloc cleanup routine. Instead, I
added an atexit call with the debug malloc cleanup routine. This gets
around most problems related to the timing of doing the cleanup.

The new properties and environment variables:

libc.debug.malloc.options
Set by option name (such as "backtrace"). Setting this to a bad value
will cause a usage statement to be printed to the log.

libc.debug.malloc.program
Same as before. If this is set, then only the program named will
be launched with malloc debug enabled. This is not a complete match,
but if any part of the property is in the program name, malloc debug is
enabled.

libc.debug.malloc.env_enabled
If set, then malloc debug is only enabled if the running process has the
environment variable LIBC_DEBUG_MALLOC_ENABLE set.

Bug: 19145921

Change-Id: I7b0e58cc85cc6d4118173fe1f8627a391b64c0d7
0ac0cee0d1ab60a92103a5021e76ec31da2e3234 07-Jan-2016 Josh Gao <jmgao@google.com> Remove dlmalloc.

Bug: http://b/17207577
Change-Id: Ie009badca6deb1f91b27a4340b70cdd6bedff893
023c3071a036d84bbd7973edef152c5a48679cb7 23-Jan-2016 Elliott Hughes <enh@google.com> Add _seek64 to FILE.

Move fdopen/fopen/freopen and change them to initialize _seek64 instead
of the legacy _seek. The in-memory streams can stick with _seek for now,
since you're not going to fit a > 4GiB in-memory stream on a 32-bit device
anyway.

Bug: http://b/24807045
Change-Id: I09dcb426817b571415ce24d4d15f364cdda395b3
2704bd13409a77237147f861c43796148326b2e3 21-Jan-2016 Elliott Hughes <enh@google.com> Simplify fseek/ftell.

Another step towards _FILE_OFFSET_BITS=64 support.

Bug: http://b/24807045
Change-Id: I00b83c81a7b108176c4d9437bc32611f73b7e967
021335ebdac3768be571ea2fd0cb776b29a7f2df 20-Jan-2016 Elliott Hughes <enh@google.com> Move stdio implementation details around a little.

Change-Id: I24594426d5479bdd55cbef0ab1b7d76c249dbd0c
923f165b29866cba1bd077117127f576763b384d 20-Jan-2016 Elliott Hughes <enh@google.com> Make FILE*s less usable after fclose(3).

BSD doesn't invalidate the fd stored in struct FILE, which can make
it possible (via fileno(3), for example), to perform operations on
an fd you didn't intend to (rather than just failing with EBADF).

Fixing this makes the code slightly simpler anyway, and might help
catch bad code before it ships.

Bug: http://stackoverflow.com/questions/10816837/fclose-works-differently-on-android-and-linux
Change-Id: I9db74584038229499197a2695c70b58ed0372a87
b43ee658bbb071cc45bbd8455d3a9b8ec0cbbd4c 19-Jan-2016 Chih-Hung Hsieh <chh@google.com> Switch libc default to clang.

* Default to clang when USE_CLANG_PLATFORM_BUILD is not set
and the target has no clang bug.

BUG: 26102335
Change-Id: Ied6c9dc5593bfbadbb8d8b38e66ea237d649bae5
ed57b98758176f0cccdec16cbed524e444039fe7 16-Jan-2016 Elliott Hughes <enh@google.com> Implement if_nameindex(3)/if_freenameindex(3).

This is just a subset of the recently-implemented getifaddrs(3), though if
we want to handle interfaces (such as "rmnet_*") that don't have an address,
we need to either expose ifaddrs_storage and keep track of which interfaces
we've already seen (which is pretty messy), or refactor the netlink code so
we can reuse it and just extract the information we need for if_nameindex(3).
This patch goes the latter route.

Also clean up if_nametoindex(3) and if_indextoname(3).

Change-Id: I5ffc5df0bab62286cdda2e7af06f032c767119a8
506c6deff726c8c052ff5abb0cef57e63707bd1c 16-Jan-2016 Elliott Hughes <enh@google.com> Sync with upstream OpenBSD.

Also some minor build cleanup.

Change-Id: Ibd20602d7ea45685f0c47fceb00ffd6c7ae35954
c23aeb8414176a0d8dd0cc36f9a5a1907e233a0c 11-Jan-2016 Colin Cross <ccross@android.com> Rearrange build files to support USE_SOONG=true

Building with USE_SOONG=true will build with an Android.bp file if it is
present in the directory, otherwise an Android.mk file. Only a few of
the bionic directories compile with soong, so include all of them from
the top level Android.mk file and remove the top level Android.bp file.
Individual subdirectories with Android.bp files will use soong with
USE_SOONG=true.

Change-Id: Idf8d7977ea4668fa646be25b543bf9d3773de615
42d949ff9d2956e25f84e537f43a8f93ecb37baf 07-Jan-2016 Elliott Hughes <enh@google.com> Defend against -fstack-protector in libc startup.

Exactly which functions get a stack protector is up to the compiler, so
let's separate the code that sets up the environment stack protection
requires and explicitly build it with -fno-stack-protector.

Bug: http://b/26276517
Change-Id: I8719e23ead1f1e81715c32c1335da868f68369b5
63a42070fca452da2d543d2c253d1844eb611ef9 06-Jan-2016 Josh Gao <jmgao@google.com> Kill BOARD_MALLOC_ALIGNMENT.

Bug: http://b/26403338
Change-Id: Iba4006277fdb7c7ca60542c517634ae86c847b4f
6b5cbea099e6663facc86b898b64291456442059 06-Jan-2016 Elliott Hughes <enh@google.com> Temporary hack to avoid stack protector crashes.

It'll take me a while to refactor things cleanly, but if we just want
something that boots for testing...

Bug: http://b/26276517
Change-Id: I24729d3dc546e36e0eff383f0d1d05c3aa1f2e0b
2489161ce5d65421030d09fac7fe09d217bb0981 06-Jan-2016 Elliott Hughes <enh@google.com> Temporary hack to avoid stack protector crashes.

It'll take me a while to refactor things cleanly, but if we just want
something that boots for testing...

Bug: http://b/26276517
Change-Id: I24729d3dc546e36e0eff383f0d1d05c3aa1f2e0b
09f4651c0ef1920e5f48d87308f6cdd1e5b74149 05-Jan-2016 Josh Gao <jmgao@google.com> Replace MALLOC_IMPL with MALLOC_SVELTE.

Bug: http://b/26390299
Change-Id: I665f64bff4d598607e1eb7c4078819fe1d400feb
9cddb482b498abd134f7ccfc9933747e8bcb9cc7 04-Jan-2016 Elliott Hughes <enh@google.com> Revert "Revert "Implement getifaddrs(3)/freeifaddrs(3).""

This reverts commit 76814a8250fd5e1502909ef5e10e4d166cc96c0e.

This differs from the original in fixing the GCC -Werror build:

bionic/libc/bionic/ifaddrs.cpp: In function 'void __handle_netlink_response(ifaddrs**, nlmsghdr*)':
bionic/libc/bionic/ifaddrs.cpp:113:62: error: use of old-style cast [-Werror=old-style-cast]
ifinfomsg* ifi = reinterpret_cast<ifinfomsg*>(NLMSG_DATA(hdr));

This appears to be a GCC bug; the GCC command-line correctly uses -isystem,
and manually adding #pragma GCC system_header doesn't help. So just turn the
warning off for GCC for now. We won't need to worry about building with GCC
soon anyway.

Bug: http://b/26238832
Change-Id: I01615bd335edf11baf487b1c83a9157cd780f4a1
76814a8250fd5e1502909ef5e10e4d166cc96c0e 22-Dec-2015 Yi Kong <yikong@google.com> Revert "Implement getifaddrs(3)/freeifaddrs(3)."

Werror build broken. Revert while working on a fix.

This reverts commit 0945ed5cc5921243724fed4465d20881f4891a8d.

Change-Id: I67edab7a7a3b9aa673ce9d14aa95380f947838a1
0945ed5cc5921243724fed4465d20881f4891a8d 19-Dec-2015 Elliott Hughes <enh@google.com> Implement getifaddrs(3)/freeifaddrs(3).

Time to dust off the old libcore implementation from gingerbread and add it
to bionic. Unlike the original, this actually looks at both RTM_NEWLINK and
RTM_NEWADDR.

Bug: http://b/26238832
Change-Id: I7bb4b432deb766065b66b9c9ff36ed68249aba82
bc2e88a85d5fd3e59c041a667283378c1503a16c 16-Dec-2015 Dimitry Ivanov <dimitry@google.com> Revert "Revert "Remove remaining ndk_cruft from LP64 platforms""

This reverts commit 23af25b747b5e7b0ca513a87b32f1f6a3cb99698.

Bug: http://b/26164862
Change-Id: I201bf49530f33f8ba6a1a35b79723afb9e84c7a5
23af25b747b5e7b0ca513a87b32f1f6a3cb99698 15-Dec-2015 Dimitry Ivanov <dimitry@google.com> Revert "Remove remaining ndk_cruft from LP64 platforms"

This reverts commit b1d0a2ae7790f882d8f1ab24d7ef15e2b90c8ca2.

Change-Id: I1da06be0b78a4f2a4cad7e4a19a3ee755f55a813
b1d0a2ae7790f882d8f1ab24d7ef15e2b90c8ca2 15-Dec-2015 Dimitry Ivanov <dimitry@google.com> Remove remaining ndk_cruft from LP64 platforms

This change removes endpwent, dlmalloc_inspect_all, dlmalloc_trim
from lp64 libc.so. It also removed necessety of having brillo
version scripts for lp64 platforms.

Bug: http://b/26164862
Change-Id: I4e9b38907bb1dc410f0eb6d2f5d5944fe713da51
585e9598493d3b4a0e545dad35c0f361d4ad2d3e 14-Dec-2015 Dimitry Ivanov <dimitry@google.com> Generate libc version-script for brillo

Brillo doesn't use the ndk cruft, so we need
separate set of version scripts. Added new "nobrillo"
tag to mark such symbols in *.map.txt files.

Bug: http://b/26164862
Change-Id: Iaee1b7119f75b68c2971679fc32817e6df29fd94
a3dd076126df616b75b4fc4484f4750e0e3e6a7f 14-Dec-2015 Dimitry Ivanov <dimitry@google.com> Revert "Don't verify version scripts on 32-bit Brillo"

This reverts commit 31951b7f0dc7ce577a21682e54362b0cf2913e11.

Bug: http://b/26164862
31951b7f0dc7ce577a21682e54362b0cf2913e11 12-Dec-2015 Dan Willemsen <dwillemsen@google.com> Don't verify version scripts on 32-bit Brillo

Brillo doesn't use the ndk cruft, so the same version scripts do not
apply. Until we have brillo-specific version scripts, just disable the
version script check.

Bug: 26164862
Change-Id: I682860ec1c5b36014c7a6cf24da43df553e9dc9f
6c54ddd20f663de9e383fcd7b4cff93471369d87 08-Dec-2015 Elliott Hughes <enh@google.com> Fix -fstack-protector-strong for x86.

We need to ensure %gs:20 is set up early enough for -fstack-protector-strong
on x86, and that __set_tls doesn't get stack protector checks because it's a
prerequisite for them. x86 devices/emulators won't boot without this.

Bug: http://b/26073874
Change-Id: Icf0d34294648cc0c8cb406a3617befe0d45c525a
b9055518fc0607344f1de803b80a5293c0f2f0ee 03-Dec-2015 Dan Willemsen <dwillemsen@google.com> Re-add putw for LP32

This was missed when switching to LOCAL_SRC_FILES_EXCLUDE

Change-Id: I6ea23c9eb31abe11e0ec4abfc2ee2f2a43c76ce2
9b687dc243c5cea56002947a5ae563ff6cf31968 30-Nov-2015 Yabin Cui <yabinc@google.com> Enable using clang to build __cxa_thread_atexit_impl.

Remove previous workaround as we no longer use
__thread in __cxa_thread_atexit_impl.cpp.

Change-Id: Ic1062995db488859b341acdda0b5f6635e10d7e8
83f314f060f10f9eb01e3754b25d28a92cb70720 25-Nov-2015 Nikola Veljkovic <Nikola.Veljkovic@imgtec.com> Consider $(use_clang) when building libc_thread_atexit_impl module

Change-Id: Ia369d94979f418198a2ee891385942d9bc5604d7
b4bc156c6cfe5603cc08480d069d7f1c61560db1 20-Nov-2015 Chih-Hung Hsieh <chh@google.com> Disable clang for mips/mips64 libc.

* Many processes, including adbd, failed to start in mips/mips64
emulator when libc.so was compiled by clang.

BUG: 25291096
Change-Id: If3434ebdca4a3a6bf6102b120ee838a7ab66cd74
fe3a83a9343f0e4ff654f09ef8ffc8a773c7c105 18-Nov-2015 Yabin Cui <yabinc@google.com> Implement pthread spin.

In order to run tsan unit tests, we need to support pthread spin APIs.

Bug: 18623621
Bug: 25392375
Change-Id: Icbb4a74e72e467824b3715982a01600031868e29
e7c2fffa16eccecfd43d99516751a43776f5f609 06-Nov-2015 Yabin Cui <yabinc@google.com> Implement pthread barrier.

Bug: 24341262
Change-Id: I5472549e5d7545c1c3f0bef78235f545557b9630
a9cac4c87a4ea3e6d1c0a1159909bf0e209a61a7 13-Nov-2015 Elliott Hughes <enh@google.com> Fix strftime if tm_zone is null.

Upstream tzcode said "On platforms with tm_zone, strftime.c now assumes it
is not NULL". Which is fine for any struct tm generated by tzcode, but not
necessarily true of a struct tm constructed by arbitrary code. In particular,
Netflix on Nexus Player was failing to start because they format "%Z" with
a struct tm whose tm_zone is null (the other fields are valid, but, yeah,
that's probably not intentional).

glibc takes a null tm_zone to mean "the current time zone", so let's do that
too. (Historically Android would use the empty string, and POSIX doesn't
clarify which of this is the appropriate behavior when tm_zone is null.)

Bug: http://b/25170306
Change-Id: Idbf68bfe90d143aca7dada8607742905188b1d33
c04647f8c2e3e825d4ed27ea649024b89d1b5aed 12-Nov-2015 Chih-Hung Hsieh <chh@google.com> Still cannot compile with clang on arm64.

When __cxa_thread_atexit_impl.cpp is compiled with clang on arm64,
Android cannot boot up.

BUG: 25662915
Change-Id: If997b544f43e956172ce605d86fe147d42fd39e0
5058a005b8dfb4bd5eefe0eb4420f1c37665b2b0 10-Nov-2015 Chih-Hung Hsieh <chh@google.com> Enable clang for modules failed with TLS.

New 3.8 clang/llvm can compile TLS code now.
* For x86_64, still disable clang due to f128 bug.
* For b/25643775, arm and arm64, disable clang in unit tests.
* Fix thread_local_test.cpp to compile with clang and
limit gcc workaround only to arm and aarch64.

BUG: 25643775

Change-Id: Iecd006bf1fc417dbcce2c63343a59c4bf1fa77ea
4200e260d266fd0c176e71fbd720d0bab04b02db 03-Nov-2015 Daniel Micay <danielmicay@gmail.com> fix the mremap signature

The mremap definition was incorrect (unsigned long instead of int) and
it was missing the optional new_address parameter.

Change-Id: Ib9d0675aaa098c21617cedc9b2b8cf267be3aec4
e85fb580c88d5423702272ecc93856ed86c1eef6 29-Oct-2015 Dmitriy Ivanov <dimitry@google.com> Fix LDFLAGS for arm and x86

Change-Id: I5366f4499cb4da3a51b8484ab3e4ff785f0888ab
284b4685246197890b4f75a9912096b8e13c62ba 28-Oct-2015 Dmitriy Ivanov <dimitry@google.com> Generate per-architecture version scripts.

Bug: http://b/24767418
Change-Id: I23e49d8d30c0def3215ffbd99d09f207d9483624
268a673bd1add941e331b2f53758242d939ca5b1 15-Oct-2015 Dan Willemsen <dwillemsen@google.com> Switch to LOCAL_SRC_FILES_EXCLUDE

This moves the generic arm/arm64/x86 settings into the main makefiles
and makes the rest of them derivatives. This better aligns with how
soong handles arch/cpu variants.

Also updates the Android.bp to make it consistent with the make
versions.

Change-Id: I5a0275d992bc657459eb6fe1697ad2336731d122
055a66c9b1017c01b82c12b65a571bf9efad8b19 15-Sep-2015 Elliott Hughes <enh@google.com> Sync with upstream NetBSD lib/libc/regex.

Bug: http://b/22850181
Change-Id: I11a51a2031e68a953ccd5691da98c699c7d01904

(cherry-picked from commit 71927a82379f7a72559ea96e6678d6215090937f)
beb6e08abf1393663151afde2742bb23eccab4e1 15-Sep-2015 Elliott Hughes <enh@google.com> Sync with upstream NetBSD lib/libc/regex.

Bug: http://b/22850181
(cherry-picked from commit 71927a82379f7a72559ea96e6678d6215090937f)

Change-Id: I11a51a2031e68a953ccd5691da98c699c7d01904
9a9572d577eacc5f1c83a92655fbbe5cd897236b 15-Sep-2015 Elliott Hughes <enh@google.com> Sync with upstream NetBSD lib/libc/regex.

Bug: http://b/22850181

(cherry picked from commit 71927a82379f7a72559ea96e6678d6215090937f)

Change-Id: I4a914f0594a66f38efb3026b7ba9d28a4887cb2d
8ab433df132aa59db08b4548155d72574ad06421 10-Oct-2015 Elliott Hughes <enh@google.com> Fix stdio read after EOF behavior.

Bug: https://code.google.com/p/android/issues/detail?id=184847
Change-Id: Ia20ce94007c2a09649f0763b1dc7ba959f2f618d
047866672c66e51b557721cf50ba101305c252d2 09-Oct-2015 Elliott Hughes <enh@google.com> Fix inet_addr/inet_aton/inet_network.

Rewrite inet_addr and inet_network in terms of inet_aton, and reimplement
that to include all the missing error checks.

Bug: http://b/24754503
Change-Id: I5dfa971c87201968985a0894df419f0fbf54768a
9fb22a3ec4ec5217fc29bb3ee3a0f1076098151f 08-Oct-2015 Elliott Hughes <enh@google.com> Sync with upstream tzcode (2015g).

This is quite a large patch because we haven't updated for some time,
but the good news is that upstream is now thread-safe so a lot of our
changes go away in this update and the remaining diff is a lot smaller.

(Note that our whitespace still doesn't match upstream. I use diff -wub
to compare. Upstream doesn't even really have a consistent style. New
code seems to be two spaces, old code tabs.)

From the intervening changelogs (eliding the changes that only affected
the tools, which we don't use):

2014a:
An uninitialized-storage bug in 'localtime' has been fixed.
(Thanks to Logan Chien.)

2014b:
'zic' and 'localtime' no longer reject locations needing four
transitions per year for the forseeable future. (Thanks to Andrew
Main (Zefram).)

2014c:
<None>

2014d:
<None>

2014e:
<None>

2014f:
'localtime', 'mktime', etc. now use much less stack space if
ALL_STATE is defined. (Thanks to Elliott Hughes for reporting the
problem.)

Some lint has been removed when using GCC_DEBUG_FLAGS with GCC
4.9.0.

2014g:
Unless NETBSD_INSPIRED is defined to 0, the tz library now
supplies functions for creating and using objects that represent
time zones. The new functions are tzalloc, tzfree, localtime_rz,
mktime_z, and (if STD_INSPIRED is also defined) posix2time_z and
time2posix_z. They are intended for performance: for example,
localtime_rz (unlike localtime_r) is trivially thread-safe without
locking. (Thanks to Christos Zoulas for proposing NetBSD-inspired
functions, and to Alan Barrett and Jonathan Lennox for helping to
debug the change.)

If THREAD_SAFE is defined to 1, the tz library is now thread-safe.
Although not needed for tz's own applications, which are single-threaded,
this supports POSIX better if the tz library is used in multithreaded apps.

Some crashes have been fixed when zdump or the tz library is given
invalid or outlandish input.

The tz library no longer mishandles leap seconds on platforms with
unsigned time_t in time zones that lack ordinary transitions after 1970.

The tz code now attempts to infer TM_GMTOFF and TM_ZONE if not
already defined, to make it easier to configure on common platforms.
Define NO_TM_GMTOFF and NO_TM_ZONE to suppress this.

Unless the new macro UNINIT_TRAP is defined to 1, the tz code now
assumes that reading uninitialized memory yields garbage values
but does not cause other problems such as traps.

If TM_GMTOFF is defined and UNINIT_TRAP is 0, mktime is now
more likely to guess right for ambiguous time stamps near
transitions where tm_isdst does not change.

If HAVE_STRFTIME_L is defined to 1, the tz library now defines
strftime_l for compatibility with recent versions of POSIX.
Only the C locale is supported, though. HAVE_STRFTIME_L defaults
to 1 on recent POSIX versions, and to 0 otherwise.

tzselect -c now uses a hybrid distance measure that works better
in Africa. (Thanks to Alan Barrett for noting the problem.)

The C source code now ports to NetBSD when GCC_DEBUG_FLAGS is used,
or when time_tz is defined.

When HAVE_UTMPX_H is set the 'date' command now builds on systems
whose <utmpx.h> file does not define WTMPX_FILE, and when setting
the date it updates the wtmpx file if _PATH_WTMPX is defined.
This affects GNU/Linux and similar systems.

For easier maintenance later, some C code has been simplified,
some lint has been removed, and the code has been tweaked so that
plain 'make' is more likely to work.

The C type 'bool' is now used for boolean values, instead of 'int'.

The long-obsolete LOCALE_HOME code has been removed.

The long-obsolete 'gtime' function has been removed.

2014h:
The tz library's localtime and mktime functions now set tzname to a value
appropriate for the requested time stamp, and zdump now uses this
on platforms not defining TM_ZONE, fixing a 2014g regression.
(Thanks to Tim Parenti for reporting the problem.)

The tz library no longer sets tzname if localtime or mktime fails.

An access to uninitalized data has been fixed.
(Thanks to Jörg Richter for reporting the problem.)

When THREAD_SAFE is defined, the code ports to the C11 memory model.
A memory leak has been fixed if ALL_STATE and THREAD_SAFE are defined
and two threads race to initialize data used by gmtime-like functions.
(Thanks to Andy Heninger for reporting the problems.)

2014i:
The time-related library functions now set errno on failure,
and some crashes in the new tzalloc-related library functions
have been fixed. (Thanks to Christos Zoulas for reporting
most of these problems and for suggesting fixes.)

If USG_COMPAT is defined and the requested time stamp is
standard time, the tz library's localtime and mktime functions
now set the extern variable timezone to a value appropriate
for that time stamp; and similarly for ALTZONE, daylight
saving time, and the altzone variable. This change is a
companion to the tzname change in 2014h, and is designed to
make timezone and altzone more compatible with tzname.

The tz library's functions now set errno to EOVERFLOW if they
fail because the result cannot be represented. ctime and
ctime_r now return NULL and set errno when a time stamp is out
of range, rather than having undefined behavior.

Some bugs associated with the new 2014g functions have been
fixed. This includes a bug that largely incapacitated the new
functions time2posix_z and posix2time_z. (Thanks to Christos
Zoulas.) It also includes some uses of uninitialized
variables after tzalloc. The new code uses the standard type
'ssize_t', which the Makefile now gives porting advice about.

2014j:
<None>

2015a:
tzalloc now scrubs time zone abbreviations compatibly with the way
that tzset always has, by replacing invalid bytes with '_' and by
shortening too-long abbreviations.

2015b:
Fix integer overflow bug in reference 'mktime' implementation.
(Problem reported by Jörg Richter.)

Allow -Dtime_tz=time_t compilations, and allow -Dtime_tz=... libraries
to be used in the same executable as standard-library time_t functions.
(Problems reported by Bradley White.)

2015c:
<None>

2015d:
<None>

2015e:
<None>

2015f:
<None>

2015g:
localtime no longer mishandles America/Anchorage after 2037.
(Thanks to Bradley White for reporting the bug.)

On hosts with signed 32-bit time_t, localtime no longer mishandles
Pacific/Fiji after 2038-01-16 14:00 UTC.

The localtime module allows the variables 'timezone', 'daylight',
and 'altzone' to be in common storage shared with other modules,
and declares them in case the system <time.h> does not.
(Problems reported by Kees Dekker.)

On platforms with tm_zone, strftime.c now assumes it is not NULL.
This simplifies the code and is consistent with zdump.c.
(Problem reported by Christos Zoulas.)

Change-Id: I9eb0a8323cb8bd9968fcfe612dc14f45aa3b59d2
697e261d4b157fed6042a12df217eab0b22cb759 08-Oct-2015 Dan Albert <danalbert@google.com> Fix bionic_coverage for kati.

Kati won't override something set with :=, only ?=.

Note that the actually reveals that our coverage build has been broken
for... some time. The issue is that we have static libraries built
with clang and others built with gcc linked into the same .so. If we
use both libclang_rt.profile and libgcov together, we get duplicate
symbol errors. If we only use one or the other, we don't have all the
symbols we need.

This will be fixed once chh's TLS stuff makes it into our clang and we
can start building libc_thread_atexit_impl with clang.

Change-Id: I45d0f2e558a881ad8be71088102320724ced8fe5
280d54680d8842df5b0e37ec50acde48957d8e7a 28-Sep-2015 Dmitriy Ivanov <dimitry@google.com> Fix bug number for linker related workarounds

Bug: 24425865
Change-Id: I2021674a9df0e768f312ca024d906302db1c494f
0aa96aedbe8db44148b7e41fd1a58ff8ad00964a 23-Sep-2015 Dan Albert <danalbert@google.com> Prevent the build system from hiding our ABI.

Unfortunately --exclude-libs (now passed globally) clobbers our
version script, so we have to prevent the build system from using this
flag.

Bug: http://b/24166967
Change-Id: I33c766d399c418fdc17983c8c0a56608d463201e
7fda8d2aa4d24ab400f6f0cb9f792488b634afae 11-Sep-2015 Josh Gao <jmgao@google.com> Implement setjmp cookies on ARM.

Reuse the top bits of _JB_SIGFLAG field previously used to store a
boolean to store a cookie that's validated by [sig]longjmp to make it
harder to use as a ROP gadget. Additionally, encrypt saved registers
with the cookie so that an attacker can't modify a register's value to
a specific value without knowing the cookie.

Bug: http://b/23942752
Change-Id: Id0eb8d06916e89d5d776bfcaa9458f8826717ba3
26a83229728c099f5572edb65dedce7163dbff71 15-Sep-2015 Elliott Hughes <enh@google.com> Move several FreeBSD functions to OpenBSD.

There's no difference between the two BSDs for these functions, so let's go
with the majority.

Change-Id: Ic296f23153a48bed5ad152f5b31989c4e00e60bd
71927a82379f7a72559ea96e6678d6215090937f 15-Sep-2015 Elliott Hughes <enh@google.com> Sync with upstream NetBSD lib/libc/regex.

Bug: http://b/22850181
Change-Id: I11a51a2031e68a953ccd5691da98c699c7d01904
32bf43f44a4c0ccf04c6a60094aff574d50ecfe7 02-Sep-2015 Elliott Hughes <enh@google.com> Rename debug_stacktrace to debug_backtrace.

All the functions say "backtrace", so it's weird that the filename
says "stacktrace".

Change-Id: I1c88a56c1f9adb1bae4615edc8af3e73db270a8c
7ac3c128bb5df83cb001cb50b6a5ee4da9a0b0e0 26-Aug-2015 Elliott Hughes <enh@google.com> Add strchrnul.

Bug: http://b/18374026
Change-Id: Iea923309c090a51a2d41c5a83320ab3789f40f1c
cc6461861e6f09e0e0dd98e9409a11ea2c356d88 26-Aug-2015 Dan Albert <danalbert@google.com> Don't re-export libunwind_llvm.

Change-Id: Ic16be4ada4cff374209d5eea89a7f81ed2fff398
3d0142227245250a28f138807d723b7a2e0dc244 24-Aug-2015 Nick Kralevich <nnk@google.com> Revert "fix incompatibility with -fstack-protector-strong"

Reports of devices not booting with a build range including
this patch. Reverting while I investigate.

This reverts commit 96dd2b6e85e03ca9ab2600c2031490c22d5626ad.

Bug: 23470962
Change-Id: I056f1d8668f52d31412868975f2143249fc7e8f0
afdd15456ad0c7223c690731f5eb0af54cdb0024 21-Jul-2015 Daniel Micay <danielmicay@gmail.com> add fortified implementations of write/pwrite{,64}

These are just based on the read/pread{,64} implementations with the
function calls and error messages adjusted as appropriate. The only
difference is that the buffer parameters are const.

Change-Id: Ida1597a903807f583f230d74bcedffdb7b24fcf6
5341691955e2fc2b271b722c37496d72a0e8c683 11-Aug-2015 Dan Albert <danalbert@google.com> Move up to C++14.

The default standard version is now ahead of us. Stop specifying C++11
so we get that too.

Change-Id: Ic96942cd7fd134118e29b744601b0119e49b6ac4
9101b00400cfb20b96112682169c5da67e065ff2 20-May-2015 Daniel Micay <danielmicay@gmail.com> add a fortified implementation of getcwd

Change-Id: Ice3e6d3e1ff07788305dc85f8ee4059baad5fac4
4c43aac9a5db6de1e34fdab652dab01b32141718 31-Jul-2015 Elliott Hughes <enh@google.com> Revert "add a fortified implementation of getcwd"

This reverts commit 89a121d43a274131cf9f84b0e685bebf1e70cc1b.

Change-Id: Ib6f6fd424acea68a063777e9f324405450e23316
89a121d43a274131cf9f84b0e685bebf1e70cc1b 20-May-2015 Daniel Micay <danielmicay@gmail.com> add a fortified implementation of getcwd

Change-Id: I95001ae4fe8f206db83e5c44d129ba11310695ce
667dc75ee1c7c922f8610ccc6b70002642141f08 28-Jul-2015 Mark Salyzyn <salyzyn@google.com> deprecate TARGET_USES_LOGD

This is not the kernel logger you are looking for

Bug: 22787659
Change-Id: I340d8bb5cdaa73be9565521681ee238b7033934b
fed2659869ec41a93f655be8058568ddab419e01 18-Jul-2015 Daniel Micay <danielmicay@gmail.com> add fortified implementations of fread/fwrite

A __size_mul_overflow utility is used to take advantage of the checked
overflow intrinsics in Clang and GCC (>= 5). The fallback for older
compilers is the optimized but less than ideal overflow checking pattern
used in OpenBSD.

Change-Id: Ibb0d4fd9b5acb67983e6a9f46844c2fd444f7e69
96dd2b6e85e03ca9ab2600c2031490c22d5626ad 04-Apr-2015 Daniel Micay <danielmicay@gmail.com> fix incompatibility with -fstack-protector-strong

The __libc_init_tls function in libc_init_common.cpp takes a reference
to a local variable so it ends up being protected. Since this happens
before TLS and the stack guard value are initialized, it breaks.

The libc_init_common code needs to be compiled with -fno-stack-protector
and can then be merged into libc_bionic.

Change-Id: Ie95ea2ff533d4af1cfad1c9bc59e49f20a8e119d
e79d06b0e852c5ae854bb27de9c9de7f29b4343d 23-Jun-2015 Chih-Hung Hsieh <chh@google.com> Use gcc to build and test x86_64 long double code.

Clang/llvm x86_64 configuration of long double is still
incompatible with gcc.
https://llvm.org/bugs/show_bug.cgi?id=23897

BUG: 21899249
Change-Id: I47fd6d0ce2daa84ae0035e7885a4d90e4c3056f7
11ea08c5cbc47db16f6c024338fbe9f6f456ce80 16-Jun-2015 Dan Albert <danalbert@google.com> Use new sanitizer option.

Change-Id: I21b04a1f3be3b10ee557bf9e0caa5db638686364
420574690cc7096c3f894d5d88a65e8fd13de25c 04-Jun-2015 Dmitriy Ivanov <dimitry@google.com> Add version to libc.so symbols

Bug: http://b/21617095
Bug: http://b/20139821
Change-Id: If3d42d2a0b4a0c49721fd9b9ecbb4f7bee5a1eff
(cherry picked from commit 665607a6b7a7a8f129c30ee73c6606f4a56cea0c)
665607a6b7a7a8f129c30ee73c6606f4a56cea0c 04-Jun-2015 Dmitriy Ivanov <dimitry@google.com> Add version to libc.so symbols

Bug: http://b/21617095
Bug: http://b/20139821
Change-Id: If3d42d2a0b4a0c49721fd9b9ecbb4f7bee5a1eff
7a799f2b02ee453a46ee368cd8c41477e0567852 05-Jun-2015 Christopher Ferris <cferris@google.com> Fix a few libc makefile mishaps.

These are the problems fixed in this CL:

- The ndk_cruft.cpp file was not compiled for 64 bit.
- Some files where not compiled for libc_bionic.a due to a missing
patch-up-arch-specific-flags call.
- The libc_bionic_ndk.a patch up call was using bionic src, not
the bionic_ndk_src_files.
- Move mmap.cpp to the ndk src list where it was before because of
the above errors.

Bug: 21640784
(cherry picked from commit 19fee2ca8beb4fae5b5c142de19757410171dc93)

Change-Id: Ib9a9cfd72720586d3400b11cd7189f021e9a06c6
e1d0810cd7e2aa045d5cc1e7d2b8697acd8467be 06-Jun-2015 Nick Kralevich <nnk@google.com> Add O_PATH support for flistxattr()

A continuation of commit 2825f10b7f61558c264231a536cf3affc0d84204.

Add O_PATH compatibility support for flistxattr(). This allows
a process to list out all the extended attributes associated with
O_PATH file descriptors.

Change-Id: Ie2285ac7ad2e4eac427ddba6c2d182d41b130f75
19fee2ca8beb4fae5b5c142de19757410171dc93 05-Jun-2015 Christopher Ferris <cferris@google.com> Fix a few libc makefile mishaps.

These are the problems fixed in this CL:

- The ndk_cruft.cpp file was not compiled for 64 bit.
- Some files where not compiled for libc_bionic.a due to a missing
patch-up-arch-specific-flags call.
- The libc_bionic_ndk.a patch up call was using bionic src, not
the bionic_ndk_src_files.
- Move mmap.cpp to the ndk src list where it was before because of
the above errors.

Bug: 21640784
Change-Id: I31e97bc8bf347c8e584cc17aa4b984a7d122b298
c92f9f8069f567ad2c2557e2ef56e13de4bf8713 31-May-2015 Nick Kralevich <nnk@google.com> libc: Add O_PATH support for fgetxattr / fsetxattr

Support O_PATH file descriptors when handling fgetxattr and fsetxattr.
This avoids requiring file read access to pull extended attributes.

This is needed to support O_PATH file descriptors when calling
SELinux's fgetfilecon() call. In particular, this allows the querying
and setting of SELinux file context by using something like the following
code:

int dirfd = open("/path/to/dir", O_DIRECTORY);
int fd = openat(dirfd, "file", O_PATH | O_NOFOLLOW);
char *context;
fgetfilecon(fd, &context);

This change was motivated by a comment in
https://android-review.googlesource.com/#/c/152680/1/toys/posix/ls.c

(cherrypicked from commit 2825f10b7f61558c264231a536cf3affc0d84204)

Change-Id: Ic0cdf9f9dd0e35a63b44a4c4a08400020041eddf
2825f10b7f61558c264231a536cf3affc0d84204 31-May-2015 Nick Kralevich <nnk@google.com> libc: Add O_PATH support for fgetxattr / fsetxattr

Support O_PATH file descriptors when handling fgetxattr and fsetxattr.
This avoids requiring file read access to pull extended attributes.

This is needed to support O_PATH file descriptors when calling
SELinux's fgetfilecon() call. In particular, this allows the querying
and setting of SELinux file context by using something like the following
code:

int dirfd = open("/path/to/dir", O_DIRECTORY);
int fd = openat(dirfd, "file", O_PATH | O_NOFOLLOW);
char *context;
fgetfilecon(fd, &context);

This change was motivated by a comment in
https://android-review.googlesource.com/#/c/152680/1/toys/posix/ls.c

Change-Id: Ic0cdf9f9dd0e35a63b44a4c4a08400020041eddf
5f3e19dbbeb851fff5cf7f9869d344feca479413 20-May-2015 Dan Albert <danalbert@google.com> Fix error handling for negative size in ftruncate.

Bug: 21309901
Change-Id: I54692ab8105dd09db6af7a2c0894a17bdd118aa0
(cherry picked from commit c05554ec5c9aff5e0f1e83de9bb62c3569eecca2)
c05554ec5c9aff5e0f1e83de9bb62c3569eecca2 20-May-2015 Dan Albert <danalbert@google.com> Fix error handling for negative size in ftruncate.

Bug: 21309901
Change-Id: I54692ab8105dd09db6af7a2c0894a17bdd118aa0
9185e04f72c16d2a66d92ac89b38ee926d7f706b 16-May-2015 Dmitriy Ivanov <dimitry@google.com> Apply work around b/19059885 to x86

Bug: http://b/19059885
Bug: http://b/21203348
Change-Id: Ic375e9f877d68de8f866d17362879a7dde638465
(cherry picked from commit 69a5fb951d69689dedd83cb033ae3dcd0ef05b65)
69a5fb951d69689dedd83cb033ae3dcd0ef05b65 16-May-2015 Dmitriy Ivanov <dimitry@google.com> Apply work around b/19059885 to x86

Bug: http://b/19059885
Bug: http://b/21203348
Change-Id: Ic375e9f877d68de8f866d17362879a7dde638465
43850d19f422d4850bebf765607e4f4d4b99df2e 11-May-2015 Chih-Hung Hsieh <chh@google.com> Use unified syntax to compile with both llvm and gcc.

All arch-arm and arch-arm64 .S files were compiled
by gcc with and without this patch. The output object files
were identical. When compiled with llvm and this patch,
the output files were also identical to gcc's output.

BUG: 18061004
Change-Id: I458914d512ddf5496e4eb3d288bf032cd526d32b
(cherry picked from commit 33f33515b503b634d9fbc57dda7123ea9cf23fc6)
22c21c6b4e789b9013ac472c77f43c91127cf9fa 23-Apr-2015 Chih-Hung Hsieh <chh@google.com> Fix opcode to compile with both gcc and llvm.

BUG: 17302991

Change-Id: I31febd9ad24312388068803ce247b295bd73b607
(cherry picked from commit 0a93df369cf3f44d40ca1f0cb4a58aeab42fb39c)
33f33515b503b634d9fbc57dda7123ea9cf23fc6 11-May-2015 Chih-Hung Hsieh <chh@google.com> Use unified syntax to compile with both llvm and gcc.

All arch-arm and arch-arm64 .S files were compiled
by gcc with and without this patch. The output object files
were identical. When compiled with llvm and this patch,
the output files were also identical to gcc's output.

BUG: 18061004
Change-Id: I458914d512ddf5496e4eb3d288bf032cd526d32b
f7009f450e596dc76352da7ceefc8caeeb74ff14 08-May-2015 Dmitriy Ivanov <dimitry@google.com> Switch libc/libcstdc++/libm to hash-style=both

Bug: http://b/19059885
Change-Id: Ie42703d91f291fd689a1cf9c35bcab5c487b9a84
(cherry picked from commit 88e777d6f46709abebab88421e8c4ea7a9e3d9c4)
88e777d6f46709abebab88421e8c4ea7a9e3d9c4 08-May-2015 Dmitriy Ivanov <dimitry@google.com> Switch libc/libcstdc++/libm to hash-style=both

Bug: http://b/19059885
Change-Id: Ie42703d91f291fd689a1cf9c35bcab5c487b9a84
6b27e6e8e095fe288a450dbc9f42ea4ccec39ff0 08-May-2015 Dan Albert <danalbert@google.com> Revert "Fix volantis boot."

Bug: http://b/20065774
This reverts commit 76e1cbca75e9fdaf7a7943f2c58e65433b283f4a.

(cherry picked from commit 7c2c01d681d7f2faa256a263996a35ac3edc94b3)
7c2c01d681d7f2faa256a263996a35ac3edc94b3 08-May-2015 Dan Albert <danalbert@google.com> Revert "Fix volantis boot."

Bug: http://b/20065774
This reverts commit 76e1cbca75e9fdaf7a7943f2c58e65433b283f4a.
62d6533c1ac4b32568ffcbebb41d480a730eb8bb 28-Apr-2015 Dmitriy Ivanov <dimitry@google.com> Do not pack relocations for libc.so

Bug: http://b/20645321
Bug: http://b/20655855
(cherry picked from commit 452742d2bf4247106055696c11bc4e59ca630f11)

Change-Id: Ic9125cc1bc4c9ba9eb20d030de72e3ce1fb86fa6
452742d2bf4247106055696c11bc4e59ca630f11 28-Apr-2015 Dmitriy Ivanov <dimitry@google.com> Do not pack relocations for libc.so

Bug: http://b/20645321
Bug: http://b/20655855
Change-Id: Ia4470e0a6d388a7f8445c7f7f9a5639689c0fe32
ea295f68f1fae7c701baaa717f67296659d567ac 21-Nov-2014 Dmitriy Ivanov <dimitry@google.com> Unregister pthread_atfork handlers on dlclose()

Bug: http://b/20339788
Change-Id: I874c87faa377645fa9e0752f4fc166d81fd9ef7e
094f58fb2a57d1ed5736ae3588bf0355618f915b 24-Apr-2015 Dimitry Ivanov <dimitry@google.com> Revert "Unregister pthread_atfork handlers on dlclose()"

The visibility control in pthread_atfork.h is incorrect.
It breaks 64bit libc.so by hiding pthread_atfork.

This reverts commit 6df122f8528f9b9fcf7dfea14ae98b0ef66274e1.

Change-Id: I21e4b344d500c6f6de0ccb7420b916c4e233dd34
0a93df369cf3f44d40ca1f0cb4a58aeab42fb39c 23-Apr-2015 Chih-Hung Hsieh <chh@google.com> Fix opcode to compile with both gcc and llvm.

BUG: 17302991

Change-Id: I31febd9ad24312388068803ce247b295bd73b607
7280e507b61851bce9b18259368d65b9e950c330 23-Apr-2015 Dmitriy Ivanov <dimitry@google.com> Remove jemalloc.a from libc_nomalloc.a

Change-Id: I86edc1a6cf3a26c46e6daef2c859459c1b0f29af
3391a9ff139d57fe4f8a2ff2d81a5ddc230a6208 23-Apr-2015 Elliott Hughes <enh@google.com> Simplify close(2) EINTR handling.

This doesn't affect code like Chrome that correctly ignores EINTR on
close, makes code that tries TEMP_FAILURE_RETRY work (where before it might
have closed a different fd and appeared to succeed, or had a bogus EBADF),
and makes "goto fail" code work (instead of mistakenly assuming that EINTR
means that the close failed).

Who loses? Anyone actively trying to detect that they caught a signal while
in close(2). I don't think those people exist, and I think they have better
alternatives available.

Bug: https://code.google.com/p/chromium/issues/detail?id=269623
Bug: http://b/20501816
Change-Id: I11e2f66532fe5d1b0082b2433212e24bdda8219b
6df122f8528f9b9fcf7dfea14ae98b0ef66274e1 21-Nov-2014 Dmitriy Ivanov <dimitry@google.com> Unregister pthread_atfork handlers on dlclose()

Change-Id: I326fdf6bb06bed12743f08980b5c69d849c015b8
6fb8e96e5f6ff2dd3b3aa8eda0a6766d6b3a63f2 16-Mar-2015 Chih-Hung Hsieh <chh@google.com> Allow building libc long double code with clang/llvm.

This requires fix of clang's Android x86 long double size and format.
That bug has been fixed in https://android-review.git.corp.google.com/#/c/146254/

Change-Id: I182c6c493085212f88c694356659f72227c8b8c7
4ae773633aac9ceba5ec62bb8e1aa22c3c56ebde 18-Apr-2015 Daniel Micay <danielmicay@gmail.com> add fortified memchr/memrchr implementations

Change-Id: I38c473cc0c608b08f971409a95eb8b853cb2ba1c
42281880a8ac8614832ff918a14e4b950f35d05d 17-Apr-2015 Daniel Micay <danielmicay@gmail.com> add fortified readlink/readlinkat implementations

Change-Id: Ia4b1824d20cad3a072b9162047492dade8576779
e7e1c875b0f8eefb1d771f200a58f54e64c39d55 16-Apr-2015 Daniel Micay <danielmicay@gmail.com> add fortified implementations of pread/pread64

Change-Id: Iec39c3917e0bc94371bd81541619392f5abe29b9
163ab8ba86deb991c73152e6828f270cc71dc4c5 16-Apr-2015 Dmitriy Ivanov <dimitry@google.com> Call __cxa_thread_finalize for the main thread.

Bug: http://b/20231984
Bug: http://b/16696563
Change-Id: I71cfddd0d404d1d4a593ec8d3bca9741de8cb90f
66aa0b61f736678e97a0cfaf975052881a23651b 15-Apr-2015 Dmitriy Ivanov <dimitry@google.com> Hide emutls* symbols in libc.so

Also make thread_local in test static to avoid ld.bfd
warning for arm64.

Change-Id: I09a3f2aa9b73a4fafa3f3bbc64ddc2a128ad50ee
76e1cbca75e9fdaf7a7943f2c58e65433b283f4a 03-Apr-2015 Elliott Hughes <enh@google.com> Fix volantis boot.

NVIDIA binary blobs are assuming that __cache_clear, _Unwind_Backtrace,
and _Unwind_GetIP are all in some library that they link, but now we've
cleaned up this leakage, they're no longer getting it. Deliberately leak
the symbols from libc.so until we get new blobs.

Bug: http://b/20065774
Change-Id: I92ef07b2bce8d1ad719bf40dab41d745cd6904d4
d6bf3d5e19f192dc1949b573d931d487c42730fa 02-Apr-2015 Dan Albert <danalbert@google.com> Don't export new/delete from libc shared libraries.

This used to be handled by -fvisibility=hidden on libc_cxa, but that
was broken by the resolution of https://llvm.org/PR22419 (introduced
to Android in today's clang update).

Now we just use a version script that prevents these from being
re-exported from our shared libraries.

Change-Id: Ib290e1d0d7426e09ad17a91178162fff6dbdcfa9
402d19945092eee87cfb6c029c98ccb4fb40d2c6 27-Mar-2015 Dmitriy Ivanov <dimitry@google.com> Fix libstdc++.so hash-style.

Bug: 19059885
Bug: 19958712
Change-Id: I167457a54cc688d64912a50f5fb75e4e2f3e3937
df79c330d895af31f39ee301dee62731fa586168 26-Mar-2015 Dmitriy Ivanov <dimitry@google.com> Initial implementation of __cxa_thread_atexit_impl

This is initial implementations; does not yet handle
dlclose - undefined behavior, needs linker support to
handle it right.

Bug: 19800080
Bug: 16696563
Change-Id: I7a3e21ed7f7ec01e62ea1b7cb2ab253590ea0686
673b15e4ee2c6d99b150aedddc0f389e29f98e1b 19-Mar-2015 Yabin Cui <yabinc@google.com> Let g_thread_list_lock only protect g_thread_list.

As glibc/netbsd don't protect access to thread struct members by a global
lock, we don't want to do it either. This change reduces the
responsibility of g_thread_list_lock to only protect g_thread_list.

Bug: 19636317
Change-Id: I897890710653dac165d8fa4452c7ecf74abdbf2b
2e16d2cf1e477af1db92efde389a5ce0a8e6fbb3 13-Mar-2015 Dmitriy Ivanov <dimitry@google.com> Switch libc and libm to sysv-only hash style

Bug: 19059885
Change-Id: I60a23dc5f9c756994d566818332ca42b305b4a05
1156508265422f407c7072788ce6c32c35411941 10-Mar-2015 Goran Jakovljevic <goran.jakovljevic@imgtec.com> Generate gnu hash for arm only

Fixes build failure caused by:
https://android-review.googlesource.com/#/c/139660

As previously discussed [1], MIPS does not support GNU-style ELF hashes.

[1] https://android-review.googlesource.com/#/c/49282/2/tests/Android.mk

Change-Id: I9a7966eebfd1ef0a587a20b71faefde38e84ab62
4a55c46d308deae70d7d8669c50514d521813dc2 10-Mar-2015 Dmitriy Ivanov <dimitry@google.com> Generate sysv hash for libc, libstdc++ and libm

Bug: 19059885
Change-Id: I35e2a9cd0bb3914d9d0c82d163bfaf0fff844667
35778253a5ed71e87a608ca590b63729d9f88567 24-Feb-2015 Nick Kralevich <nnk@google.com> Fix "faccessat ignores flags"

The kernel system call faccessat() does not have any flags arguments,
so passing flags to the kernel is currently ignored.

Fix the kernel system call so that no flags argument is passed in.

Ensure that we don't support AT_SYMLINK_NOFOLLOW. This non-POSIX
(http://pubs.opengroup.org/onlinepubs/9699919799/functions/access.html)
flag is a glibc extension, and has non-intuitive, error prone behavior.

For example, consider the following code:

symlink("foo.is.dangling", "foo");
if (faccessat(AT_FDCWD, "foo", R_OK, AT_SYMLINK_NOFOLLOW) == 0) {
int fd = openat(AT_FDCWD, "foo", O_RDONLY | O_NOFOLLOW);
}

The faccessat() call in glibc will return true, but an attempt to
open the dangling symlink will end up failing. GLIBC documents this
as returning the access mode of the symlink itself, which will
always return true for any symlink on Linux.

Some further discussions of this are at:

* http://lists.landley.net/pipermail/toybox-landley.net/2014-September/003617.html
* http://permalink.gmane.org/gmane.linux.lib.musl.general/6952

AT_SYMLINK_NOFOLLOW seems broken by design. I suspect this is why this
function was never added to POSIX. (note that "access" is pretty much
broken by design too, since it introduces a race condition between
check and action). We shouldn't support this until it's clearly
documented by POSIX or we can have it produce intuitive results.

Don't support AT_EACCESS for now. Implementing it is complicated, and
pretty much useless on Android, since we don't have setuid binaries.
See http://git.musl-libc.org/cgit/musl/commit/?id=0a05eace163cee9b08571d2ff9d90f5e82d9c228
for how an implementation might look.

Bug: 18867827
Change-Id: I25b86c5020f3152ffa3ac3047f6c4152908d0e04
3cfb52aab2548df635e9672218cc433e14922fd3 19-Feb-2015 Elliott Hughes <enh@google.com> Add GNU extensions mempcpy and wmemcpy.

Used by elfutils. On the bright side, they stopped using __mempcpy.

Bug: 18374026
Change-Id: Id29bbe6ef1c5ed5a171bb6c32182f129d8332abb
2c678e6644a0ac7bfdfb8f199ac2cd0d4ea1153f 19-Feb-2015 Dan Albert <danalbert@google.com> Parameterize use of clang in libc_ndk.

We still have issues with clang coverage in static libraries, so we
need to make sure we follow suit with the rest of libc for now.

Bug: 17574078
Change-Id: I2ab58a84b1caa0d8d08415d240c35adec5b1e150
a6395e1fd0ccc818ed6424797690b12f8b690755 13-Feb-2015 Dan Albert <danalbert@google.com> Update NDK compatlib for 4.1.2.

The replacement new failures present in newer versions are present
here as well, with the following new issues:

XPASS std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp

This is from the -NaN formatting fix in bionic. We previously had this
wrong, and the upstream test is also wrong. There's currently an XFAIL
for Android in this test because I haven't fixed the upstream test
yet. After that is done, I'll need to teach the test runner how to
XFAIL older Android versions...

FAIL std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp
dtor.pass.cpp:39: int main(): assertion "globalMemCounter.checkDeleteArrayCalledEq(1)" failed

Haven't investigated this one yet. http://b/19412688

Note that this also needs the libgcc link ordering to be fixed in the
build system, as we'll otherwise depend on libgcc symbols from libc
that may or may not have been there.

The build fix can't be submitted because the proper link order causes
the libgcc unwinder to be used instead of the EHABI one:
http://b/18471342

Bug: 18471532
Change-Id: Icf560485a9b8f5ebbe01e4458703e62ec94df5e1
9a9ea3a28099602fe22e36638a44fa36df80fe8e 10-Feb-2015 Dan Albert <danalbert@google.com> Update the NDK compatlib for 4.4.4 and ToT.

Now passes all libc++ tests for these targets, with the exception of
the usual failing replacement new tests since libc uses new/delete for
things. I don't know if we can ever really fix these.

Bug: 18471532
Change-Id: Ibc0a15f26b0e4613249b5e15ecf3cf80e523467c
e09ab2cc2ff41ce7519c143d448371ddd62afc59 13-Feb-2015 Colin Cross <ccross@android.com> Make .note.android.ident section type SH_NOTE

The .note.android.ident section is only used by GDB, which doesn't
care what section type the section is, but it would be convenient
for readelf -n to be able to find the section too.

The old way of getting the .note.android.ident section to be of type
SH_NOTE involved compiling from .c to .s using gcc, running sed to
change progbits to note, and then compiling from .s to .o using gcc.
Since crtbrand.c only contains a section containing data, a
crtbrand.S can be checked in that will compile on all platforms,
avoiding the need for sed.

Also add crtbrand.o to crtbegin_so.o so that libraries also get
the note, and to the crt workaround in arm libc.so.

Change-Id: Ica71942a6af4553b56978ceaa288b3f4c15ebfa2
91b403cef62a5f1c727c3ed7395ea83852c4a2ab 06-Feb-2015 Colin Cross <ccross@android.com> Use LOCAL_C_INCLUDES instead of LOCAL_CFLAGS for include dirs

Change-Id: If61d6faae5d91c3bbe198e733e5922cd877ba353
6e54c3e519892ca13f15bdcea0d431befbadac25 05-Feb-2015 Elliott Hughes <enh@google.com> Use the libcxxabi __cxa_demangle.

Bug: 18930951
Change-Id: If2ea3633ac6dfd4ec975c0f16bdf3dd58e05c614
5b869c0bbf8a2924ab69d86a98e9a25558d33494 05-Feb-2015 Colin Cross <ccross@android.com> Use LOCAL_LDFLAGS_64 instead of enumerating 64-bit architectures

LOCAL_LDFLAGS_<arch> was being set for arm64, mips64, and x86_64.
Use LOCAL_LDFLAGS_64 instead.

Change-Id: Ib87855e8a7783f82461b707fffa7f1663e6be9c8
7dc502d01292f3303a5252ce20f80f621f4f15f5 05-Feb-2015 Colin Cross <ccross@android.com> Remove libc_static_common_src_files

libc_static_common_src_files is never set after
c3f114037dbf028896310609fd28cf2b3da99c4d, remove the remaining
references to it.

Change-Id: I66364a5c1b031ad69d608f6f44244049192944f6
1742a32aea4108a8a967e8da2131de30c8808658 05-Feb-2015 Colin Cross <ccross@android.com> Share LP32 makefile settings between arches

Add <var>_32 to patch-up-arch-specific-flags, and move the LP32
cruft varaibles from the 32-bit arch specific makefiles into the
top level Android.mk.

Change-Id: Id3fcf6805d4af048c2524c94b1295416ebe7d057
3cbc6c627fe57c9a9783c52d148078f8d52f7b96 01-Feb-2015 Nick Kralevich <nnk@google.com> Add fchmodat(AT_SYMLINK_NOFOLLOW) and fchmod O_PATH support

Many libc functions have an option to not follow symbolic
links. This is useful to avoid security sensitive code
from inadvertantly following attacker supplied symlinks
and taking inappropriate action on files it shouldn't.
For example, open() has O_NOFOLLOW, chown() has
lchown(), stat() has lstat(), etc.

There is no such equivalent function for chmod(), such as lchmod().
To address this, POSIX introduced fchmodat(AT_SYMLINK_NOFOLLOW),
which is intended to provide a way to perform a chmod operation
which doesn't follow symlinks.

Currently, the Linux kernel doesn't implement AT_SYMLINK_NOFOLLOW.
In GLIBC, attempting to use the AT_SYMLINK_NOFOLLOW flag causes
fchmodat to return ENOTSUP. Details are in "man fchmodat".

Bionic currently differs from GLIBC in that AT_SYMLINK_NOFOLLOW
is silently ignored and treated as if the flag wasn't present.

This patch provides a userspace implementation of
AT_SYMLINK_NOFOLLOW for bionic. Using open(O_PATH | O_NOFOLLOW),
we can provide a way to atomically change the permissions on
files without worrying about race conditions.

As part of this change, we add support for fchmod on O_PATH
file descriptors, because it's relatively straight forward
and could be useful in the future.

The basic idea behind this implementation comes from
https://sourceware.org/bugzilla/show_bug.cgi?id=14578 , specifically
comment #10.

Change-Id: I1eba0cdb2c509d9193ceecf28f13118188a3cfa7
4674e3899afcc6b3ac8a48cdb716695d5489d26b 02-Feb-2015 Elliott Hughes <enh@google.com> Fortify poll and ppoll.

And remove the test for FD_ZERO fortification, which never made much
sense anyway.

Change-Id: Id1009c5298d461fa4722189e8ecaf22f0c529536
76f8916b904db14facf811ae44e1265261349702 26-Jan-2015 Elliott Hughes <enh@google.com> Clean up <stdlib.h> slightly.

Interestingly, this mostly involves cleaning up our implementation of
various <string.h> functions.

Change-Id: Ifaef49b5cb997134f7bc0cc31bdac844bdb9e089
b8a8cf0d1a333401eae9c9e1d70b9c1b154ff9c9 25-Jan-2015 Elliott Hughes <enh@google.com> Add <error.h>.

Bug: https://code.google.com/p/android/issues/detail?id=79170
Change-Id: Id91765fac45124545e2674a5b2c814707c1a448b
6e9e6ad3bf831ed0b25ce2e6ce586a790044f8da 25-Jan-2015 Dan Albert <danalbert@google.com> Fix coverage build after adding clang coverage.

Static libraries are painful. Details are in the comment. I'll try to
get prebuilts in to the tree so I can fix this on Monday. Until then,
this isn't actually a regression because we've not had coverage
available for this library until now anyway.

Bug: 17574078
Change-Id: I7505c8a94007203e15a6cf192caa06004849d7d9
9c3fd59b00d6f477b1a7f8611cb4f829d64aa7ea 22-Jan-2015 Dan Albert <danalbert@google.com> Add a basic NDK compatibility library.

We know we can safely statically link `libm`, since it doesn't have
any dependencies on the OS or the layout of a data type that has
changed between releases (like `pthread_t`).

We can safely statically link `libc_syscalls` because the user can
check for and handle `ENOSYS`.

Update `ndk_missing_symbols.py` to account for symbols that are in the
compatibility library.

Improve `symbols.py` to be able to pull symbols from a static library.

Change-Id: Ifb0ede1e8b4a8f0f33865d9fed72fb8b4d443fbc
8b5df3920f2843c9cdf04160517c1e8b77c992f5 22-Jan-2015 Elliott Hughes <enh@google.com> Turn on -Wold-style-cast and fix the errors.

A couple of dodgy cases where we cast away const, but otherwise pretty boring.

Change-Id: Ibc39ebd525377792b5911464be842121c20f03b9
8885dcc779bceae5016d5ad96caa73465a7bab90 21-Jan-2015 Elliott Hughes <enh@google.com> Add TEMP_FAILURE_RETRY to stdio's low-level read/write functions.

This is correctness rather than performance, but found while investigating
performance.

Bug: 18593728
Change-Id: Idbdfed89d1931fcfae65db29d662108d4bbd9b65
3f61f89b559551164b13441ff4ff02ed0718530a 10-Dec-2014 Christopher Ferris <cferris@google.com> Fix missing symbol for debug malloc.

Bug: 18686270
Change-Id: I800a6f0940060218413df652d74aca91f6a339f8
634816055f51c536d24dea30dfe930b7fe2fa603 02-Dec-2014 Yabin Cui <yabinc@google.com> support _POSIX_REALTIME_SIGNALS

Bug: 18489947
Change-Id: I2e834d68bc10ca5fc7ebde047b517a3074179475
5afae64a1bac56638c6348f0c8f5e9d61b654029 26-Nov-2014 Yabin Cui <yabinc@google.com> implement posix_madvise

Bug: 18472477
Change-Id: I8183de6c281acf69ed5f7f88351b056b9827b162
27d276f3a6d81d29fab13de96496efb7bc072773 02-Dec-2014 Elliott Hughes <enh@google.com> Avoid pathological behavior in OpenBSD's fread.

(cherry picked from commit 20841a137beac5caa824e3586c7bd91d879ff92e)

Bug: https://code.google.com/p/android/issues/detail?id=81155
Bug: 18556607
Change-Id: Ibdfebc20dce4c34ad565014523c9b074e90ea665
20841a137beac5caa824e3586c7bd91d879ff92e 02-Dec-2014 Elliott Hughes <enh@google.com> Avoid pathological behavior in OpenBSD's fread.

Bug: https://code.google.com/p/android/issues/detail?id=81155
Bug: 18556607
Change-Id: Idc60976b79610e2202cc42dc393dcb4ca6c42e05
d5c652756bb1a52959cd5c62447b62462f90f983 26-Nov-2014 Yabin Cui <yabinc@google.com> support _POSIX_CPUTIME

Bug: 18490039
Change-Id: I01fa83b48e1b908de1f227b6e4f98e280bcd50ee
2818279ace22fb854b00e668c224492c4dd072a4 22-Nov-2014 Elliott Hughes <enh@google.com> Sync with upstream OpenBSD fts.c.

Change-Id: Ia7e26b603f6461095b5a8d7e8a6cdf4f8279fa84
bfbf7a4300ab5cd6334212f701e47ea449456048 17-Nov-2014 Elliott Hughes <enh@google.com> Remove remaining bionic support for TARGET_CPU_SMP being false.

Change-Id: I02a0a1c0ae55ccb5c45d17fb99a09c374d71def4
9d93986481b67a8135e57fc6400ca8c59f7375f6 15-Nov-2014 Yabin Cui <yabinc@google.com> Add functions in sysinfo.h.

Bug: 17703902

Change-Id: I699d12d76a8fc483c919be730c2ac63641b71a1d
2f954bab2d524f6afed8a443c2a7ee32876db0fa 30-Oct-2014 Yongqin Liu <yongqin.liu@linaro.org> gethostname.c: change to report ENAMETOOLONG error when buflen is less

change to behaviour the same as glibc for the check about buflen

Change-Id: I98265a8fe441df6fed2527686f89b087364ca53d
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
b20c24456e43df430ec5626a68e5dc0dc6929344 07-Nov-2014 Elliott Hughes <enh@google.com> Implement all the POSIX _l functions.

Strictly speaking, this only implements the _l variants of the functions
we actually have. We're still missing nl_langinfo_l, for example, but we
don't have nl_langinfo either.

Change-Id: Ie711c7b04e7b9100932a13f5a5d5b28847eb4c12
274afe8f0eab4139c94d5f8b1ee3d267f449ef42 06-Nov-2014 Elliott Hughes <enh@google.com> Add POSIX lcong48.

Change-Id: I821046816661d77275cb02c8c99d526bb41afb9c
dc6599e20f6a2a82c35533fba36d16fd43c53273 04-Nov-2014 Chih-Hung Hsieh <chh@google.com> Fix warning of missing field initializer.

BUG: 18241135
Change-Id: I91304eb608bc3336ce5fcd5744fbe080d64f1cc2
d18f4b25785761c022906b93b2123b3be90182e8 03-Nov-2014 Elliott Hughes <enh@google.com> Ensure we initialize stdin/stdout/stderr's recursive mutexes.

(cherry-pick of 6a03abcfd23f31d1df06eb0059830e22621282bb.)

Bug: 18208568
Change-Id: I9da16ce0f9375bc363d1d02be706d73fd3b1e150
6a03abcfd23f31d1df06eb0059830e22621282bb 03-Nov-2014 Elliott Hughes <enh@google.com> Ensure we initialize stdin/stdout/stderr's recursive mutexes.

Bug: 18208568
Change-Id: I9da16ce0f9375bc363d1d02be706d73fd3b1e150
86d16a053eeff3bd432695471d8942e99b2db598 17-Sep-2014 Elliott Hughes <enh@google.com> Clean up the architecture-specific makefiles.

Group things appropriately and name each group.

Bug: 18160821

(cherry picked from commit 7c02d9428ca18ac600f7ba7d51bb24ca71e733f6)

Change-Id: I863242515af44058154d03e2d8c34678e682d66a
5ba672ebcb0bbb77f22bbc6c98ec03867ac1711d 17-Oct-2014 Dan Albert <danalbert@google.com> Never use ASAN.

Unless we completely redo how we build bionic (so that the object
files for libc.so get built separately from libc.a), we can't enable
ASAN here, as libc.a gets linked into static executables.

Change-Id: I2ce4f51248bd51c4213a555ff481b6faabbf53f8
a371750681a84c8f0445fa041e817582e12c125f 18-Oct-2014 Chih-Hung Hsieh <chh@google.com> Add -no-integrated-as at local level.

Later we will enable integrated-as as default at the global level.

BUG: 17820427
BUG: 17302991
Change-Id: I233204ca04d7222b2cb1fbd0fa48a482f8b63f6f
a7c2e0bad678280b9d76eacdb50b1361ab0849ff 14-Oct-2014 Dan Albert <danalbert@google.com> 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
18160256840e9bb097f17422ea47d54fabbc9f3f 12-Oct-2014 Haruki Hasegawa <h6a.h4i.0@gmail.com> 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>
90a29db0f4a0893bdbd12f656d8869bb79ec3900 13-Oct-2014 Dan Albert <danalbert@google.com> 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
ef1306d77718cc74a8df5673a15649dea317571d 09-Sep-2014 Dmitriy Ivanov <dimitry@google.com> 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';

(cherry picked from commit d9ff7226613014056c9edd79a68dc5af939107a0)

Change-Id: If2573d080770e18b36b56106f2369f7bb682cd3c
81fe2b16dc3ac8f17719964d3d01e92e2dc3cc4c 05-Sep-2014 Chih-Hung Hsieh <chh@google.com> 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

(cherry picked from commit b58db8b083ce41798a5310616e4f20885cec611f)

Change-Id: I916c05056d37a9c287b0a5ae3b1a209d98c8f70e
188d093993b3330b3c22437af8f22352f72ce64b 27-Sep-2014 Dan Albert <danalbert@google.com> Static libc++ is being renamed libc++_static.

Change-Id: I1596110e4ed7e8f9ab9e2605dfcd9fd0489ca0d1
5a69da8d7af6a388a4ad5b3dd619017b0030031a 24-Sep-2014 Elliott Hughes <enh@google.com> 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
c08c25b4c9bdd95bfbda56a8c21f51b88c8a692e 24-Sep-2014 Elliott Hughes <enh@google.com> Sync with upstream findfp.c.

Change-Id: Ib298f46de0c4d0fd4ce0a9b456c163e8b8b06342
c2d39088d8c6f621dbde0410a1fc24b9f9e7f824 23-Sep-2014 Dan Albert <danalbert@google.com> Coverage configs for bionic.

Bug: 17553780
Change-Id: Iee7d0c210e2379e71e0c1e4e7058bce23f61e8cd
a71b4c3f144a516826e8ac5b262099b920c49ce0 24-Sep-2014 Elliott Hughes <enh@google.com> Switch to OpenBSD flags.c.

Change-Id: I0a35e5bd9f8edba27e0c73e5c8150636346d6a81
49eed7db79bd2664a2a13552ad81d445c93ba462 23-Sep-2014 Elliott Hughes <enh@google.com> Switch to OpenBSD insque/remque/killpg.

Change-Id: Ie02290ad3187b1c1596dd776fd1c8a743a55f7ef
a186b2e0ca19620a52b4a49c17835532d13eb30a 22-Sep-2014 Elliott Hughes <enh@google.com> 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
04303f5a8ab9a992f3671d46b6ee2171582cbd61 19-Sep-2014 Elliott Hughes <enh@google.com> Add semaphore tests, fix sem_destroy.

Bug: https://code.google.com/p/android/issues/detail?id=76088
Change-Id: I4a0561b23e90312384d40a1c804ca64ee98f4066
6fe376d3925a788f60fd44280b00008af60b9334 19-Sep-2014 Christopher Ferris <cferris@google.com> Remove references to MALLOC_LEAK_CHECK.

This define isn't really used any more.

Bug: 17378595
Change-Id: I39722b83cd98955a3a2514577de34a239524617f
9969481d5bf05954fff9c0f3d1c95bb99c36b9a8 18-Sep-2014 Elliott Hughes <enh@google.com> Fix an unintended difference between aosp/master and lmp-dev-plus-aosp.

Whitespace difference presumably introduced while fixing a merge conflict.

Bug: 17549448

(cherry picked from commit 8fa377eb6afdea4b03b6a0d112471f7ee988fb96)

Change-Id: I7e30f37da4430af19d09a661e489c8ff65e42297
d0be539e01424fa720840dfe702dedf8e54379fb 17-Sep-2014 Elliott Hughes <enh@google.com> Revert "Revert "Added a bionic systrace class and tracing to pthread_mutex.cpp.""

This reverts commit 26c1420fbb68916d66a8621b5efe8bb25cfdad7b.

(cherry picked from commit 9e87f2f876243225deef37645ddceaa5d225cb41)

Change-Id: I46a71a456952e3dd2c2bb0d9934820ffe8dc8469
8fa377eb6afdea4b03b6a0d112471f7ee988fb96 18-Sep-2014 Elliott Hughes <enh@google.com> Fix an unintended difference between aosp/master and lmp-dev-plus-aosp.

Whitespace difference presumably introduced while fixing a merge conflict.

Bug: 17549448
Change-Id: If688330bf1dbaed23ba687d843d9744d6261023b
9e87f2f876243225deef37645ddceaa5d225cb41 17-Sep-2014 Elliott Hughes <enh@google.com> Revert "Revert "Added a bionic systrace class and tracing to pthread_mutex.cpp.""

This reverts commit 26c1420fbb68916d66a8621b5efe8bb25cfdad7b.
3ec67de0513c1d7e5f41f7f17e8251122a0cc9d2 16-Sep-2014 Dan Albert <danalbert@google.com> Exclude libstdc++ from linked libraries.

Also explicitly add libstdc++ includes for necessary targets.

Change-Id: If712ba0ae7908d8147a69e29da5c453a183d6540
7c02d9428ca18ac600f7ba7d51bb24ca71e733f6 17-Sep-2014 Elliott Hughes <enh@google.com> Clean up the architecture-specific makefiles.

Group things appropriately and name each group.

Change-Id: I0da45eb0ccde19c31d5e984d0e6eb3dad26630dc
a4831cb4a3f44b93788488db8ff9ea76613f0355 12-Sep-2014 Elliott Hughes <enh@google.com> 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
27efc48814b8153c55cbcd0af5d9add824816e69 12-Sep-2014 Elliott Hughes <enh@google.com> 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.

Bug: 14079438
Change-Id: I43fabc7f1918250d31d4665ffa4ca352d0dbeac1
b587f339db269abf08a2c311a7263dd218cb23d3 11-Sep-2014 Elliott Hughes <enh@google.com> Add posix_fadvise(3).

(cherry-pick of 00008263782e484020420c606f7d145fe7d0a4d8.)

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

Bug: 12449798
Change-Id: I07cbf3f670a0d1304b68148325a774f266b5c433
d9ff7226613014056c9edd79a68dc5af939107a0 09-Sep-2014 Dmitriy Ivanov <dimitry@google.com> 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
b58db8b083ce41798a5310616e4f20885cec611f 05-Sep-2014 Chih-Hung Hsieh <chh@google.com> 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
b78e60e7b7de02fed474f170c5c7a8f78f5a0e5c 27-Aug-2014 Christopher Ferris <cferris@google.com> 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 3f7635f4906c53fa744731efc35235456b7d93bf)

Change-Id: If8a3821cdd95ed481bb496bf2daab449d13790f8
cc7e5f489f02ceee46e315af4f78559d3ad6c962 27-Aug-2014 Elliott Hughes <enh@google.com> Switch to OpenBSD <err.h> implementation.

Change-Id: Ia950d88871a30f68e74f9ac7dbd87788e128e02f
e5055179fd92ae243741d778426e1da03539165f 27-Aug-2014 Elliott Hughes <enh@google.com> Switch to OpenBSD daemon(3).

Change-Id: I1fd0be09fdb24aa6f1d945410eba5987f8a949b4
3f7635f4906c53fa744731efc35235456b7d93bf 27-Aug-2014 Christopher Ferris <cferris@google.com> 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
Change-Id: Ifdbbcbd4137d668b25cf3c2bd59535e06ebfa5a7
4caa1f09770ea3e5ca22afbe8aa0900810a0dbfe 20-Aug-2014 Dan Albert <danalbert@google.com> Implement malloc_info(3).

Expose jemalloc stats through the malloc_info(3) interface.

Bug: 16874689
Change-Id: I4358ac283002e60ff161107028d1a3fb1e9afb0a
6b841db2baa24ffcf2a4e5f975d1d07f1699b918 21-Aug-2014 Elliott Hughes <enh@google.com> Add POSIX-2008 fmemopen, open_memstream, and open_wmemstream.

Bug: 17164505
Change-Id: I59e28a08ff8b6ab632230b11a5807cfd5278aeb5
2b021e10664c3938249eb18b48eeac253cbb3e20 20-Aug-2014 Elliott Hughes <enh@google.com> Add <stdio_ext.h> for elfutils.

Bug: 17139679
Change-Id: I1605ac382dbb6f23b2d874dbb9769f3cde4a6a99
09c39d6df0e952620f8c1751377b559a04e023aa 19-Aug-2014 Elliott Hughes <enh@google.com> Implement the GNU basename(3) in addition to the POSIX one.

Code like perf(1) needs this.

Bug: 11860789
Change-Id: I907eb448052a7b165e4012d74303330d32328cb2
6df7b609984479c894be81140730578896dbdd8f 15-Aug-2014 Dan Albert <danalbert@google.com> Hide C++ stuff in libc. Put it back in libstdc++.

Bug: 17062445
Change-Id: I027b186719654c2865b08c3fa83f90fa00c1e838
(cherry picked from commit fd5ee9aebc0a43c7f36a0778c7f416b39ddb870e)
fd5ee9aebc0a43c7f36a0778c7f416b39ddb870e 15-Aug-2014 Dan Albert <danalbert@google.com> Hide C++ stuff in libc. Put it back in libstdc++.

Bug: 17062445
Change-Id: I027b186719654c2865b08c3fa83f90fa00c1e838
9f533972ae3be1a2faec74ddddbf136b20fd76d1 15-Aug-2014 Dan Albert <danalbert@google.com> Move mtctxres.c to libc_dns.a.

Has the effect of making ___mtctxres hidden.

Bug: 11156955
Change-Id: I5aa5f49344ad5ecb33f48737430561b329bcbb0d
(cherry picked from commit 891ec7a6e46e60d7dfa1cf229e14a8e8634e272b)
891ec7a6e46e60d7dfa1cf229e14a8e8634e272b 15-Aug-2014 Dan Albert <danalbert@google.com> Move mtctxres.c to libc_dns.a.

Has the effect of making ___mtctxres hidden.

Bug: 17007799
Change-Id: I5aa5f49344ad5ecb33f48737430561b329bcbb0d
40079b003168b39dab91e106c7a877b677e64ef1 05-Aug-2014 Dan Albert <danalbert@google.com> Fixes build.

This change somehow went missing from the vfork change.

Change-Id: I807a2072080eac20601c694e85ba5723220289d8
(cherry picked from commit 9eae8405e8f70e489f2fe350a0212ab8114cbd17)
62c69c25d29c42359c4383319d0080c204789a8d 06-Aug-2014 Ben Murdoch <benm@google.com> fix the build

Change-Id: I8a3b26014ced1ce95b9a0f675099c3fdfbe041f3
9eae8405e8f70e489f2fe350a0212ab8114cbd17 05-Aug-2014 Dan Albert <danalbert@google.com> Fixes build.

This change somehow went missing from the vfork change.

Change-Id: I807a2072080eac20601c694e85ba5723220289d8
c701e5b3357b6484572d46f29c5d1e51063dfcbb 25-Jul-2014 Christopher Ferris <cferris@google.com> 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

(cherry picked from commit 861c0ef37bcfcae56d88572cb01c18bcfe1faded)

Change-Id: I04445f0cf9a1e85172b64d57df92eb7939ce2332
26c1420fbb68916d66a8621b5efe8bb25cfdad7b 30-Jul-2014 Elliott Hughes <enh@google.com> Revert "Added a bionic systrace class and tracing to pthread_mutex.cpp."

This reverts commit a09fe118b1a5eb876ddaa2620965c4a8fb8b007c.

Change-Id: Ia2eb07b57a25dc2ac76fecc0925efb2bed998156
2ea0a58e01c1ed6db1da9dd0314ee053f5a32026 26-Jul-2014 Elliott Hughes <enh@google.com> Fix linkage of grantpt(3).

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

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

(cherry picked from commit 4916706cfe590eb06c9b5bd4bd402ce056034d51)

Change-Id: I5cb7a1c17b156456e4c4818e65f256eb8d045424
a09fe118b1a5eb876ddaa2620965c4a8fb8b007c 22-Jul-2014 Brigid Smith <brigidsmith@google.com> 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

(cherry picked from commit a406ee6d5f616192e9a13afad6ac6a9969814fc1)

Change-Id: Ic98fc303689fe9384974150d0d258c50806a55e4
861c0ef37bcfcae56d88572cb01c18bcfe1faded 25-Jul-2014 Christopher Ferris <cferris@google.com> 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
4916706cfe590eb06c9b5bd4bd402ce056034d51 26-Jul-2014 Elliott Hughes <enh@google.com> Fix linkage of grantpt(3).

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

Bug: https://code.google.com/p/android/issues/detail?id=58888
Change-Id: I0fb36438cd1abf8d4e87c29415f03db9ba13c3c2
a406ee6d5f616192e9a13afad6ac6a9969814fc1 22-Jul-2014 Brigid Smith <brigidsmith@google.com> 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
b902641d7303d2ea24c10f6d6e7ff49e7ee75611 24-Jul-2014 Elliott Hughes <enh@google.com> Implement twalk(3), add unit tests.

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

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

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

(cherry picked from commit 3e424d0a241f8ae5194514dabc4ad899f5a5416d)

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

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

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

Bug: https://code.google.com/p/android/issues/detail?id=73719
Change-Id: I97397a7b921e2e860fd9c8032cafd9097380498a
6209c81d40e2b4e129a28bda3259150d79d507e8 19-Jul-2014 Elliott Hughes <enh@google.com> 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.

(cherry picked from commit 2b67d7dee09852789d9ac7d8972ed6cdb2c18430)

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

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

Bug: 14292866

(cherry picked from commit 3ad8ecb64e9dd5614169232b84a93eb3b8aa32d7)

Change-Id: I3038855ca4f22532bf6d2c45d3f8028b866975f9
0f7d882bb7661f9601f3843b0e393b6155cd9571 22-Jul-2014 Elliott Hughes <enh@google.com> Switch to OpenBSD res_random.

Change-Id: Ia971d647832893e9bb4601697132a105524d2f96
2b67d7dee09852789d9ac7d8972ed6cdb2c18430 19-Jul-2014 Elliott Hughes <enh@google.com> 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
3ad8ecb64e9dd5614169232b84a93eb3b8aa32d7 22-Jul-2014 Elliott Hughes <enh@google.com> Rewrite syslog(3) to use Android logging.

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

Bug: 14292866
Change-Id: Icee7f088b97f88ccbdaf471b98cbac7f19f9210a
d648f557f116513263aa2f86bba552d2f72660f1 17-Jul-2014 Elliott Hughes <enh@google.com> 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.

(cherry picked from commit d7453860a6b06e7d4a960c20792ce6f0b6cc5f3a)

Change-Id: I26b7638609e9d4eaf4f21ae29721ea27d4176702
d7453860a6b06e7d4a960c20792ce6f0b6cc5f3a 17-Jul-2014 Elliott Hughes <enh@google.com> 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
3002131da33401cf1b45abbdbec58b7c751fc43a 16-Jul-2014 Elliott Hughes <enh@google.com> Use VDSO for clock_gettime(2) and gettimeofday(2).

Bug: 15387103

(cherry picked from commit 625993dfbb085a3cde7492eda8ec1cdc1ee39a78)

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

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

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

Bug: 15829381

(cherry picked from commit 76c241b091b4d9d9a9237d40e814e52ce2917f47)

Change-Id: If721b3f16efdb21cb67df5ec5034c0ba905bd029
caaf71ebb358f811fe7602bbadb90b897e93eaf7 14-Jul-2014 Elliott Hughes <enh@google.com> Sync upstream-openbsd.

(cherry picked from commit 4f0b67a8dbf0e1d8b1dae42358553fb8d14456d4)

Change-Id: I8753959853312ab978bc4eb1bbbcdc7d1b007b95
38778e3b6c89689bbdd01f4a52ac88f02bf59783 11-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Upstream atexit

Change-Id: Ia454a2181b5058ed9783dc02b6b1805d0e4d2715
(cherry picked from commit 53c3c271dc9927dd280981fc23409af60f460007)
76c241b091b4d9d9a9237d40e814e52ce2917f47 14-Jul-2014 Elliott Hughes <enh@google.com> Implement rand/srand in terms of random/srandom.

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

Bug: 15829381
Change-Id: Ia5a908a816e0a5f0639f514107a6384a51ec157e
53c3c271dc9927dd280981fc23409af60f460007 11-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Upstream atexit

Change-Id: Ia454a2181b5058ed9783dc02b6b1805d0e4d2715
4f0b67a8dbf0e1d8b1dae42358553fb8d14456d4 14-Jul-2014 Elliott Hughes <enh@google.com> Sync upstream-openbsd.

Change-Id: I5b9961a57e2ff05f63bd218c130bf8347850b9be
c999f76977d2389a3e2dcbdd98f20d93c3193727 11-Jul-2014 Elliott Hughes <enh@google.com> Enable building libc with clang.

Bug: 16218205
Change-Id: I024de2044fe016412c7bead22c264e96be4cb39c
dfb5ce42bcc5a275af49211c0bbe64c5ec3d2668 10-Jul-2014 Dan Albert <danalbert@google.com> Revert "Revert "Add locale aware APIs.""

This reverts commit 063e20c26943ec82ef1d53a544545e79054e93d3.

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

Change-Id: I5ff0cf0c396b7ae6278e6fcd5a0d50f8b966fb54
dda1c6c466c4f31de31d76c8be7e46c16b4b4209 10-Jul-2014 Christopher Ferris <cferris@google.com> Do not include libc_common in malloc debug code.

The inclusion of the static libc_common library in the malloc_debug_XXX.so
shared libraries causes constructors to be called twice. This doesn't seem
to have caused any issues when setting the libc.debug.malloc property.
However, jemalloc crashes because there are two jemalloc implementations,
one in the static libc_common library and one in the shared library. Each
implementation has created overlapping thread keys that are not the same.
The crash comes because one of the jemalloc keys is actually used by the
locale setting code. Thus if someone sets the locale, the jemalloc code
crashes trying to access the same key.

Change-Id: Iaac650a82d69064db148a6333e9403744f68b4a4
e087eac404b0e30de427392065e2750acf92bd4a 09-Jul-2014 Dan Albert <danalbert@google.com> Add locale aware APIs.

Since we only support the C locale, we can just forward all of these to
their non-locale equivalents for correct behavior.

Change-Id: Ib7be71b7f636309c0cc3be1096a4c1f693f04fbb
f8408c58fa61540d8b6b5afec4246284482d89c2 10-Jul-2014 Calin Juravle <calin@google.com> Move __cmsg_nxthdr to its proper file.

Change-Id: I095fb6bc5318f2d256baa97658bdfe679d235aec
063e20c26943ec82ef1d53a544545e79054e93d3 10-Jul-2014 Dan Albert <danalbert@google.com> Revert "Add locale aware APIs."

Accidentally verified against a dirty tree. Needs the companion change to libc++ to land upstream before I can submit this.

This reverts commit e087eac404b0e30de427392065e2750acf92bd4a.

Change-Id: I317ecd0923114f415eaad7603002f77feffb5e3f
37b1b5bbcd1cddf833c9ca18a5976efbbf88dabf 03-Jul-2014 Elliott Hughes <enh@google.com> Fix all resolv warnings and turn on -Werror.

The res_init.c changes bring us a bit closer to upstream too, though
there's still work to be done there. Some of the remaining differences
look like bugs we'd want to fix, so we should definitely try to come
back to that.

Change-Id: I50baa148e967c90d55d711e9904ad54c7d724d4d
65935979311373f2c7fa27cbfc189f49b188ca3a 02-Jul-2014 Elliott Hughes <enh@google.com> Switch to upstream OpenBSD mktemp.c.

Almost all of our stdio is actually OpenBSD, so although this isn't
really a core part of stdio (it doesn't touch struct FILE, for example)
it probably makes sense for it to come from the same upstream. My
actual motivation though is that it's the only FreeBSD file we have
compiler warnings from.

This patch moves us over to -Werror by default, with only the DNS code
having -Wno-error.

Change-Id: Id244a5b445cba41b0a1ca30298ca7b1ed177810c
a210cae724313604f8cbd49cc6deab1be5239083 30-Jun-2014 Elliott Hughes <enh@google.com> Switch to upstream NetBSD nsap_addr.c.

These symbols should be public (and Firefox uses them), and we'd also probably
rather have the upstream thread-safe implementation.

Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1030899
Change-Id: I2a5888fbb3198546848398f576fd2195ff3fe00c
0468feb28696751efcddada8de69a622afffdba8 21-Jun-2014 Elliott Hughes <enh@google.com> Sync to current upstream arc4random.

This is actually revision 1.33, which is no longer the latest, but it's
as close to head as we can currently reasonably get. I've also switched
to the OpenBSD getentropy_linux.c implementation of getentropy, lightly
modified to try to report an error on failure.

Bug: 14499627
Change-Id: Ia7c561184b1f366c9bf66f248aa60f0d53535fcb
71f9b34fbeef00f3bd34364dadad41bff60b6b1d 24-Jun-2014 Dan Albert <danalbert@google.com> Revert "Revert "Prevent symbols from libgcc from being reexported.""

This reverts commit 4e4e1a5d78ff6dd9394b9b116c012046da409e99.

Change-Id: I8e78c3a59598e052e02965dd37b3fba8f567eed9
4e4e1a5d78ff6dd9394b9b116c012046da409e99 23-Jun-2014 Dan Albert <danalbert@google.com> Revert "Prevent symbols from libgcc from being reexported."

This reverts commit 65e80cf62200085f72c1c081aea2d6e9b800cde2.

Change-Id: I5f94b123f73db8d0b03cd71a5cffa0662776a017
65e80cf62200085f72c1c081aea2d6e9b800cde2 19-Jun-2014 Dan Albert <danalbert@google.com> Prevent symbols from libgcc from being reexported.

Since this was not done earlier, there are binary compatibility concerns
that prevent us from being able to apply this to LP32.

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

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

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

Bug: 15387103
Change-Id: I6d4718ed0a5c912fc75b5f738c49a023dbed5189
d10db8261949e4d84b65f5c369153d0ca86ab22c 19-Jun-2014 Elliott Hughes <enh@google.com> Build tzcode with hidden visibility.

Bug: 11156955
Change-Id: Ib98d837b56cbbdfd01687cb3054fe3103eec0da9
5f564540a953a670925e058dabc521f68ffb997c 19-Jun-2014 Elliott Hughes <enh@google.com> Build tzcode with -Werror.

Parts of this are just getting us in sync with upstream, but the
'const' stuff is our own mess. We should kill the *_tz functions
and lose this difference from upstream.

Change-Id: I17d26534ed3f54667143d78147a8c53be56d7b33
c82c0b7e072491da4818e7de37411fbb2055fce1 17-Jun-2014 Dan Albert <danalbert@google.com> Remove SHA1 from LP64 in favor of libcrypto.

Keep the symbols around on LP32 for binary compatibility.

Bug: 11156955
Change-Id: I379a7e0fa3092e9a70daeafcbcb2aacfc314031a
ac6467587e864d199377f14281da4641f979a68a 05-Jun-2014 Dan Albert <danalbert@google.com> Revert "Revert "Remove ftime from bionic LP64""

This reverts commit 0921204660b9597de795065d0350a787035ad589.

Change-Id: I749af8d7d429cda9f9d09a75bd30df54e6b1dd65
462abab12b074c62c0999859e65d5a32ebb41951 14-Jun-2014 Dan Albert <danalbert@google.com> Removes getdtablesize(3) from LP64.

getdtablesize(3) was removed fro POSIX 2004. Keep the symbol around in LP32 for
binary compatibility, but remove the declaration from unistd.h.

Bug: 13935372
Change-Id: I1f96cd290bf9176f922dad58bd5a7ab2cae7ef0f
3a37576d4b9714989b0618f6d1a2d2b2df77ed2b 17-Jun-2014 Christopher Ferris <cferris@google.com> Move jemalloc due to whole_static_library bug.

Rename jemalloc.cpp to jemalloc_wrapper.cpp to avoid problems with
the libc library having two jemalloc.o files that clobber each other.

Change-Id: I9a2d966dbf414b1367ee0ef1f0d73fca6f25b518
8563802b04347951d8878747a830987e5ca145f5 16-May-2014 Elliott Hughes <enh@google.com> Use default hidden visibility to build libc_dns.

Bug: 11156955
Change-Id: Ia443705f5fbee0681039d4480abc89850968f475
a0beeeabbc8735bc830544cbbb1d920122b8d958 12-Jun-2014 Elliott Hughes <enh@google.com> Get the full set of PRNG functions in <stdlib.h>

Bug: https://code.google.com/p/android/issues/detail?id=58888
Change-Id: I435250bdae302e8bd7e29977d0fde7b9afbfca5e
8e613cf342b369f7985135dbe11ebdbf8c736157 11-Jun-2014 Dan Albert <danalbert@google.com> Remove declaration for putw(3)/getw(3).

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

Bug: 13935372
Change-Id: Iba384b45093ac6d2d7c2d81f7980cd7701dd6f56
210331d9762037afb9b5ed8413079c6f65872df9 06-Jun-2014 Dan Albert <danalbert@google.com> Replaces vfork() implementation with fork()

vfork() was removed from POSIX 2008, so this replaces its implementation
with a call to fork().

Bug: 13935372
Change-Id: I6d99ac9e52a2efc5ee9bda1cab908774b830cedc
67401638a92abd52e5896183e851b1b097da07ac 10-Jun-2014 Elliott Hughes <enh@google.com> Remove the MD5 implementation that was only used by toolbox.

I've already moved toolbox over to openssl.

Change-Id: Ia75fba5b5e3335a975b97787f653bf4df78e1b4e
47ba295b0679148970bbffc9b76a3651efea9502 07-Jun-2014 Elliott Hughes <enh@google.com> Rewrite and hide longjmperror.

This shouldn't be public API, isn't supported on x86/x86_64, and it's
unlikely anyone would have actually seen the message before anyway.
Using __libc_fatal makes it much more likely to be seen.

Bug: 11156955
Change-Id: Icf7f654b22a7dacd89668b60c11e5705c7215c08
0921204660b9597de795065d0350a787035ad589 05-Jun-2014 Dan Albert <danalbert@google.com> Revert "Remove ftime from bionic LP64"

Breaking some build... will look in to it later.

This reverts commit 26d6799bbe170b0955f564974b584c1471efdca1.

Change-Id: I35fa770221be3a181bd37c6c3dce1bf37a69a4a1
26d6799bbe170b0955f564974b584c1471efdca1 05-Jun-2014 Dan Albert <danalbert@google.com> Remove ftime from bionic LP64

Bug: 13935372
Change-Id: I5dd31147143b23a090a3b75b846dc5354e599121
001f8f041bf21c53d4a0b919ef2c859b047bac0a 04-Jun-2014 Dan Albert <danalbert@google.com> Removes wcswcs from bionic for LP64.

Bug: 13935372
Change-Id: I0deb15e769da4fa81bb65a87f3c86db5163a5796
be8df2e7445968d503a59a0a15c9612a8fb991df 04-Jun-2014 Elliott Hughes <enh@google.com> Cherrypick upstream OpenBSD's vfwprintf.c revision 1.11.

revision 1.11
date: 2014/06/04 07:45:25; author: stsp; state: Exp; lines: +1 -7; commitid:
zJPRH5RUO224FmQu;
Remove assigned but unused local variables and macro from vfwprintf().
Found by Elliott @ google
ok mpi@

Change-Id: I716edc0c4d736a484a5317942de8e87bd8c6fd26
7a7f9952c12b216fbf91fc4cdbb97045e8861115 02-Jun-2014 Dan Albert <danalbert@google.com> Adds functionality specified by uchar.h

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

Bug: 14646575
Change-Id: I49d4b95fed0f9d790260c996c4d0f8bfd1686324
9b5235d74e794d29fa912fe95ca3d5ec488dd371 04-Jun-2014 Elliott Hughes <enh@google.com> Hide dlmalloc symbols.

We need to leave dlmalloc_trim and dlmalloc_inspect_all exposed for
the VM, but if we're seriously looking at other malloc implementations,
that's something we're going to have to fix.

Bug: 11156955
Change-Id: If85156c280044f1616c09a3c50ba674aaf0e8d3a
b082645ccbac14e5c2ee2c55b22a0e635c3eae03 04-Jun-2014 Elliott Hughes <enh@google.com> Work around "error: variable 'uio' set but not used".

I've sent the real fix upstream, and will merge that when they commit it.

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

Change-Id: I023d2d8b547fbc21d4124bb7510d42b06a0dc501
5d9a7ba0dc9c24ed4e4efa9cac0e796fd524b308 31-May-2014 Elliott Hughes <enh@google.com> Avoid a system call in 'gettid'.

System calls can be pretty slow. This is mako, which has one of our
lowest latencies:

iterations ns/op
BM_unistd_getpid 10000000 209
BM_unistd_gettid 200000000 8

Bug: 15297299 (kernel panic from too many gettid calls)
Bug: 15315766 (excessive gettid overhead in liblogd)
Change-Id: I49656c0fc5b5d092390264a59e4f2c0d8a8b1aeb
b4e099c6f741835b11ecb6f8fd0861b1892ff182 30-May-2014 Elliott Hughes <enh@google.com> Remove issetugid.

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

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

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

This reverts commit 8167dd7cb98e87ffe9b40e4993c330b244ca2234.

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

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

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

Change-Id: Ie43d0ff4f8ec4edba5b4fb5ccacd941f81ac6557
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
fcac8ff97f6b6cced6546e0096cadc1039b68b5e 22-May-2014 Elliott Hughes <enh@google.com> Switch to POSIX dprintf/vdprintf.

Bug: 11156955
Change-Id: I734bd02db514367ab119a48304aae9767958e367
8d2410d33d2c4eba6319664c965a750d863c7e05 21-May-2014 Christopher Ferris <cferris@google.com> Fix build.

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

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

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

Bug: 981363

Change-Id: I16eb152b291a95bd2499e90492fc6b4bd7053836
f51d3e87671110c508f0f71d9bcb1bf54c22ca3b 20-May-2014 Elliott Hughes <enh@google.com> Switch back to OpenBSD inet_ntop now they're FORTIFY clean.

Change-Id: I04798a4966c352a8a12feebdff9646e3bad5933f
903b78873a744d3fba187e4bd22008ba21162e51 19-May-2014 Sreeram Ramachandran <sreeram@google.com> Mark sockets on creation (socket()) and accept4().

Remove the separate syscall for accept() and implement it as accept4(..., 0).

Change-Id: Ib0b8f5d7c5013b91eae6bbc3847852eb355c7714
48ee47ce25fa9c99df49855ebf77ae1758d58d47 19-May-2014 Dan Albert <danalbert@google.com> Removes RTTI support from libc

Our type_info stub implementation is incompatible with the libc++ headers. Since
we don't need this support internally and anyone that wants RTTI support will
have to use libc++ anyway, this can be safely removed.

Change-Id: Ied8b67a0d86a4eb0e31191a50cceba0e39a16a6d
4c2da039baa6c621c78afa47ead85ec9e028f56d 17-May-2014 Elliott Hughes <enh@google.com> Fix the newly-introduced warning and turn on -Werror.

I cleaned up most of our warnings last week but forgot to turn on -Werror,
so of course we're getting new warnings already. I've left -Werror commented
out in those places where we still have warnings to deal with before we can
turn on -Werror.

Change-Id: Ia58ff8b8c1ada4bf81eec6f19ec1d34e133cf4b1
9029d2f638160b37f65da176acd7ccb3aa0ba891 16-May-2014 Christopher Ferris <cferris@google.com> Fix comment typo.

Change-Id: I1909f724826b531daf14fec4853e40d578fc0f59
623b0d05bd924e7fa3c155492695123c87c3a2b1 15-May-2014 Dmitriy Ivanov <dimitry@google.com> Register _cleanup function with atexit

* Register cleanup function with atexit
instead of calling it explicitly on
exit()
* abort() no longer calls _cleanup:
Flushing stdio buffers on abort is no
longer required by POSIX.
* dlmalloc no longer need to reset cleanup
(see above)
* Upstream findfp.c makebuf.c setvbuf.cexit.c
to openbsd versions.

Bug: 14415367
Change-Id: I277058852485a9d3dbb13e5c232db5f9948d78ac
15b641a26731a7e42455c3ed22e1e9bdf31ea79c 15-May-2014 Elliott Hughes <enh@google.com> Move libstdc++ into libc.

The Android build system always links against libstdc++.so anyway. Having
operator new and operator delete in a separate library means we can't use
constructors and destructors on heap-allocated objects inside the C library,
which is quite an unfortunate limitation.

This will be cheaper too; on LP64 we can stop linking against the [now empty]
libstdc++.so giving the dynamic linker one less library to worry about for
every process.

There's precedent too --- we already have no libpthread or librt.

For now I'm leaving the include files where they are, and I'm generating a
dummy libstdc++.so and libstdc++.a. We can come back and clean that up later
if all goes well.

Bug: 13367666
Change-Id: I6f3e27ea7c30d03d6394965d0400c9dc87fa83db
07f1ded1399805fa9367f4db2936832b0c22b7a5 14-May-2014 Elliott Hughes <enh@google.com> Remove the broken pthread deadlock prediction.

This hasn't built in over one release cycle and no one even noticed.
art does this the right way and other projects should do the same.

Change-Id: I7d1fb84c4080e008f329ee73e209ce85a36e6d55
8f0cd8aa22906c3e678738eeba20fc1a5c399b6c 14-May-2014 Sreeram Ramachandran <sreeram@google.com> Mark sockets on accept().

(cherry picked from commit 58b1f3f6a30a660ad81637c2b50382c3d279243b)

Change-Id: I5d09be413cf720fbed905f96313b007997ada76c
dedf2922d5c67e8c1e457b542bd71bc53d460b53 14-May-2014 Sreeram Ramachandran <sreeram@google.com> Mark sockets on accept().

Conflicts:
libc/SYSCALLS.TXT

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

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

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

Use the upstream OpenBSD implementations of these functions.

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

Bug: 14840760
Change-Id: I68720e9aca14838df457d2bb27b999d5818ac2b5
47b93faa48170661583aecea0ad79b7d1aad8008 14-May-2014 Sreeram Ramachandran <sreeram@google.com> Fix build (take two).

Make sure __netdClientDispatch is defined in the same set of libraries that
refer to it (e.g.: with connect.cpp).

(cherry picked from commit 8205a61248973ac13716ae80e712c80e126b0541)

Change-Id: I86d7bf2df5bde09f75a35b204eac0e1361747e22
8205a61248973ac13716ae80e712c80e126b0541 14-May-2014 Sreeram Ramachandran <sreeram@google.com> Fix build (take two).

Make sure __netdClientDispatch is defined in the same set of libraries that
refer to it (e.g.: with connect.cpp).

Change-Id: I86d7bf2df5bde09f75a35b204eac0e1361747e22
2677d133dd7196cc3c7a4e5293f208c00b00b3af 14-May-2014 Sreeram Ramachandran <sreeram@google.com> Fix build.

(cherry picked from commit 06e8796ee95793435c194b0a55e26d7b568c7409)

Change-Id: I33293d8bc62cbb22e23a704c4242e7e9d3fce7c5
06e8796ee95793435c194b0a55e26d7b568c7409 14-May-2014 Sreeram Ramachandran <sreeram@google.com> Fix build.

Change-Id: I33293d8bc62cbb22e23a704c4242e7e9d3fce7c5
ceb5bd787c8ce281e5f4343c5d4f77b41c3e2919 12-May-2014 Sreeram Ramachandran <sreeram@google.com> Introduce netd_client, a dynamic library that talks to netd.

The library exists outside bionic. It is dynamically loaded, to replace selected
standard socket syscalls with versions that talk to netd.

Change connect() to use the library if available.

(cherry picked from commit 3a6b627a14df8111b03e452f2df4b5f4938e0e49)

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

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

Bug: 14841211
Change-Id: I30dde77239cceaf1f5743163744eb3604d27a266
b6943186ce78105155ba67ab261a970859b190df 13-May-2014 Elliott Hughes <enh@google.com> Reduce stack usage of tmpfile(3).

Also ensure that none of our home-grown code uses more than 2KiB per frame.

Change-Id: I8987a17d72f4b7f082bb7fa25e137c8433664c14
5a92284167ffba6d45210ef6889fa7d255c15d4f 24-Apr-2014 Varvara Rainchik <varvara.rainchik@intel.com> Add 32-bit Silvermont-optimized string/memory functions.

Add following functions:
bcopy, memcpy, memmove, memset, bzero, memcmp, wmemcmp, strlen,
strcpy, strncpy, stpcpy, stpncpy.
Create new directories inside arch-x86 to specify architecture: atom,
silvermont and generic (non atom or silvermont architectures are treated like generic).
Due to introducing optimized versions of stpcpy and stpncpy,
c-implementations of these functions are moved from
common for architectures makefile to arm and mips specific makefiles.

Change-Id: I990f8061c3e9bca1f154119303da9e781c5d086e
Signed-off-by: Varvara Rainchik <varvara.rainchik@intel.com>
9a5a3e8e74e2c6d7850ab29711189acf0f7378a2 06-May-2014 Elliott Hughes <enh@google.com> Fix <math.h> to quieten most of our warnings.

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

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

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

Change-Id: Iee8e1182c1db375058fb2c451eceb212bab47a37
53b24382f5299931af5d08c933a765334a092c56 03-May-2014 Elliott Hughes <enh@google.com> Switch to current upstream OpenBSD wsetup.c.

Change-Id: I2c1123f3e1d3c4af7fd7bf354e763934a39b78c0
792ae72e41923800ba8797d87a76346cb2de14b9 03-May-2014 Elliott Hughes <enh@google.com> Switch to current upstream OpenBSD fwrite.c.

Change-Id: Ife527aafc1e5438f477d711902efe6e6f59f3f8e
f1ada79a83f6ac42f5efd995bf04374005ac532b 03-May-2014 Elliott Hughes <enh@google.com> Sync with current OpenBSD stdio.

We'd fallen a little behind.

Bug: 14492135
Change-Id: Ic1137ef10bffccecebd5ce51086c23db006d0ea3
efaa461bd67cfdfcbc2b4c6b69805bc5b929ae05 03-May-2014 Elliott Hughes <enh@google.com> Use the OpenBSD wcsftime.

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

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

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

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

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

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

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

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

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

Change-Id: I4fe88abd8f7b8aa45e58aeb2529d59a8d555d338
94336d8ecf795cfdde874a1e15977d68cfc7afc1 30-Apr-2014 Elliott Hughes <enh@google.com> Switch to OpenBSD stdio wide printf functions.

Change-Id: Icf4f8685d021ec6b7482ca1cc021ce8184098e4a
c932225e1061dc57fc4bf2d6203d9737f4f989fa 30-Apr-2014 Elliott Hughes <enh@google.com> Switch to OpenBSD stdio wide get/put functions.

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

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

This also brings several other files closer to upstream.

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

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

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

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

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

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

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

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

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

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

Also optimizes the query case.

Also hides an accidentally-exported symbol for LP64.

Change-Id: I0fd6b8b14ddf1ae82935c0c3fc610da5cc74932e
fbb46a0c9a5edf318f95a4f643979a7a02dfd89c 24-Apr-2014 Calin Juravle <calin@google.com> Remove an unsed include dir

Change-Id: I05aa1e7e0639a5ec5576bf7646f35d2e5b157c09
4b7c4f886fae05a825009fce5aa624294356e373 24-Apr-2014 Calin Juravle <calin@google.com> Removed non-existing include dir

Change-Id: I3e00a8471e6d94f596a34bdfdb26a0caba23dd82
eae5902e73dc4381811e08fd2334bf4a9300a928 23-Apr-2014 Elliott Hughes <enh@google.com> Remove strntoimax and strntoumax from the future.

Where do these turds come from?

Change-Id: Id9ad2cc85c6128aa63b5d56ff2aa455bde39a5eb
58d9e280d459225aa8dc4533e883182b08215f7d 23-Apr-2014 Elliott Hughes <enh@google.com> Switch to the upstream OpenBSD getenv/putenv/setenv implementation.

This fixes all the bugs found by the new tests.

Change-Id: Id5a5f9f39a0620208bafa053f871a044725b4795
8d77bce185d04c531bd9bf34d38e5cbbe644d3a3 22-Apr-2014 Elliott Hughes <enh@google.com> LP64 shouldn't include the non-standard <time64.h> cruft.

This patch includes just enough to keep external/chromium_org building
until they switch 64-bit Android over to using the regular non-Android code.

Change-Id: Iecaf274efa46ae18a42d5e3439c5aa4f909177c1
cce36c187896fb0d4bd36519c4b2e90c502137dc 22-Apr-2014 Elliott Hughes <enh@google.com> Use -fvisibility=hidden to build libc_gdtoa.

Bug: 12177745
Change-Id: Ia4ac71e1a3a237e764c809cc591622f8952ed642
d39f3f2c2e7fc73ddb019695f0df3417deef5bf4 22-Apr-2014 Elliott Hughes <enh@google.com> Clean up and document our hacks for building BSD source.

Change-Id: Ic591e22fa5b363bb68376b9f25814c0e5bd83fbf
6a45fe98727f9ee39386d39fa18eea69c706bc9e 19-Apr-2014 Dmitriy Ivanov <dimitry@google.com> Fix for libgcc compat generation script.

Taking into account possibility that external symbol
could have been an OBJECT instead of function.

b/14090368

Change-Id: Iac173d2dd1309ed53024306578137c26b1dbbf15
9d3c2dd11f5e796cd814cddc5b907494f859058e 18-Apr-2014 Elliott Hughes <enh@google.com> Switch to upstream OpenBSD fread/fvwrite.

Change-Id: I3dc11083693bc8d99edc0cbcc6f70dc9e5dc6565
f3c73901cb5ca4de2651151cf2c65b31a729466e 18-Apr-2014 Elliott Hughes <enh@google.com> Upgrade our <ctype.h> implementation to OpenBSD head.

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

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

This gets us various bug fixes and missing C99 functionality.

Bug: https://code.google.com/p/android/issues/detail?id=64886
Change-Id: Ie9f8ac569e9b5eec1e4a1faacfe2c21662eaf895
4bd97cee28dd815fff54fc97560be60d566c1fa5 11-Apr-2014 Elliott Hughes <enh@google.com> Switch to gdtoa.

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

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

Also move isinf and isnan into libc like everyone else.

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

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

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

Bug: 13469877
Change-Id: I407ffbac06c765a6c5fffda8106c37d7db04f27d
ff64831b0965c16c95c9f81a148f30a6ef3a6c64 07-Apr-2014 Calin Juravle <calin@google.com> Use glibc structure for __cmsg_nxthdr.

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

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

Change-Id: If0a06e627ecc593f7b8ea3e9389365782e49b00e
950a58e24d1019eb9d814dbb16f111a6b61e3f23 04-Apr-2014 Christopher Ferris <cferris@google.com> Add stpcpy/stpncpy.

Add tests for the above.

Add the fortify implementations of __stpcpy_chk and __stpncpy_chk.

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

Add all of the fortify test cases.

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

Change-Id: I1b1e40746cb573e3fb73a5276969b40c5da36d15
7f3a272ae327c647db4caeaea2a3c7af50bd73b5 01-Apr-2014 Elliott Hughes <enh@google.com> Add lsearch(3) for ltrace.

Bug: 13746936
Change-Id: I833c6ba70a1752c04dab7de389f5bebb741662b3
0ae6445e9a85291b3a20da7f7a5b948cd18d3424 21-Mar-2014 Christopher Ferris <cferris@google.com> Keep the symbol table in the shared libc.

In order to allow the unwinder code to have meaningful names for
libc functions, leave the symbol table. This results in the libc.so
getting to be about ~130K larger on all arm platforms and about ~70K
larger on mips/x86 platforms.

Bug: 12958251
Change-Id: I6b3a97e4824142faf5de46aeabf7c1dfb98a8cc6
205c7887add8b8c85434c35158138f16265beb28 14-Mar-2014 Elliott Hughes <enh@google.com> Clean up reentrancy cruft.

The DNS copy of reentrant.h was unused, so remove it.

The strtod implementation can use the upstream-netbsd reentrant.h and
get a little closer to what was then upstream. (It's since been replaced
by gdtoa, and we'll have to follow at some point, but for now this doesn't
make anything any worse.)

ANDROID_CHANGES is (now) only used in the DNS code, so push the -D
down.

The <locale.h> change prevents an LP32 hack from leaking into LP64.

Change-Id: Idf30b98a59d7ca8f7c6cd6d07020b512057911ef
f2cea021ab2c6d7d7feeb40cca098aa132605876 13-Mar-2014 Elliott Hughes <enh@google.com> Clean up <stdio.h> macros.

Also neuter __isthreaded.

We should come back to try to hide struct FILE's internals for LP64.

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

Also add a basic test.

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

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

Change-Id: I2bdebac11245d31521d5fa09a16331c03dc4339c
c1005aaf8ea8f9eab515a5b06b80a706faba6e43 12-Mar-2014 Mark Salyzyn <salyzyn@google.com> logd: default user space logger

Change-Id: Id205b01537940051c72d79def28a3c1a8b169a21
8d4b5849f21dc4115ad66944dc11df838b3faa52 12-Mar-2014 Elliott Hughes <enh@google.com> Clean up our termios implementation.

It's safe to fix our constant definitions because we know we never
had symbols before, so can't be passing the bad old constants to the new
functions, or the correct new constants to the old inlines.

Change-Id: I858fc680df39bdd3ba471e867833bdfa71f6224e
ad41e9a4eb957ea318bbc93dd49dbe76b89df1e9 11-Mar-2014 Elliott Hughes <enh@google.com> More stdio cleanup.

Change-Id: Idc909cd3dc7b072f1edd2ae4980932d6550e8568
cccfe1e17c47799deee67fa23f48d8c860390ac8 11-Mar-2014 Elliott Hughes <enh@google.com> Reimplement clock(3) and switch to OpenBSD time(3).

The new implementation is a better approximation to the processor time used
by the process because it's actually based on resource usage rather than just
elapsed wall clock time.

Change-Id: I9e13b69c1d3048cadf0eb9dec1e3ebc78225596a
247dc91889ffc8b71fc3371edba9d834afab96ab 11-Mar-2014 Elliott Hughes <enh@google.com> Take ownership of various simple syscall wrappers.

None of these trivial functions is something we're going to get from BSD.

Change-Id: Iee1d1281b73db67da5ec303da7a49748121464bf
19f58efa22357bfaa6a63a0940928830e95c5123 11-Mar-2014 Elliott Hughes <enh@google.com> Switch to NetBSD utmp.c.

Change-Id: Ibe94888aa48b5b28fea97fd5719a1ed7a23ddeb3
57a883640f3b43bf5e332d64489b3eab67a5ac3f 11-Mar-2014 Elliott Hughes <enh@google.com> Switch to upstream FreeBSD ldexp.c.

(Yes, this should be in libm, but it isn't. For once, this mistake predates
bionic!)

Change-Id: I1340407acbcdc0151dee969a38ba490bdd5e6767
6380b51a8d775a3b572b2db15195f279cb5565f6 11-Mar-2014 Elliott Hughes <enh@google.com> Rename the stack protector intermediate library.

libbionic_ssp already confused at least one person, and characters
in filenames are cheap, so let's just call this library what it is.

Change-Id: I69ab950bf52fa4d267a6891efb49b5e177efc0c4
c8937eadf4a45afebe586dcea7a8ed882f3bec3b 11-Mar-2014 Elliott Hughes <enh@google.com> Switch to OpenBSD wcscoll.

Change-Id: I1050ef728e18124656e76f32b42ac9a4688f252d
152b9de19ade833ada124390ef153e53d3d3e2ed 10-Mar-2014 Elliott Hughes <enh@google.com> Remove non-standard memswap.

Change-Id: I06548dda339987b755ef7139c590ca3e1f9fe0a9
4b558f50a42c97d461f1dede5aaaae490ea99e2e 05-Mar-2014 Elliott Hughes <enh@google.com> Rewrite the POSIX timer functions.

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

Co-authored-by: Jörgen Strand <jorgen.strand@sonymobile.com>
Co-authored-by: Snild Dolkow <snild.dolkow@sonymobile.com>
Change-Id: Iad19f155de977667aea09410266d54e63e8a26bf
fcb502e3ec032497bba7f8634fb214e0c05394d8 05-Mar-2014 Calin Juravle <calin@google.com> Sync up nameser with upstream(2014.03.05)

Bug: 13219633

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

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

Change-Id: Ic3721b01428f5402d99f31fd7f2ba2cc58805607
cecc036970fba8b319cca302768865677f2be094 03-Mar-2014 Calin Juravle <calin@google.com> Moved private dns header to their own dir.

Bug: 13219633
Change-Id: I3435ef7564b9ad3c7b54188a0809440993b36c9e
f38292862b0a560f082ce1ccefc587dd2f58b893 03-Mar-2014 Mark Salyzyn <salyzyn@google.com> libc: Make calls to new user-space logger (revisit)

* TARGET_USES_LOGD is true or false, yes is not valid
* was supposed to be in the libc_bionic definition

Change-Id: I7f15d0fe61205641f7310ba9762df885e6c959d0
692207eb457f9b4bf6cb4301d710d19b6e85c902 01-Mar-2014 Elliott Hughes <enh@google.com> Add getprogname/setprogname for BSD compatibility.

This is one less change we have to make when porting BSD code.

Bug: https://code.google.com/p/android/issues/detail?id=34898
Change-Id: If9b1a8d16996c7a19abcce8d3a456afc3e105a41
bd33537fde8e1c68fcadfd6adf77b295ada9b45f 28-Feb-2014 Calin Juravle <calin@google.com> Renamed the misleading libc/netbsd directory to libc/dns.

Bug: 13219633
Change-Id: Ide43add0b90b3081cc709a22d1ff1f59d65f1104
0336e35368aa161f1fed04ccde39553db4740b97 08-Nov-2013 Mark Salyzyn <salyzyn@google.com> libc: Make calls to new user-space logger

* libc (fatal) logging now makes socket connection to the
user-space logging service.
* Add a TARGET_USES_LOGD make flag for BoardConfig.mk to manage
whether logd is enabled for use or not.

Change-Id: I96ab598c76d6eec86f9d0bc81094c1fb3fb0d9b4
1e4378ea06d06f57027a97714f076ad4f417a705 26-Feb-2014 Elliott Hughes <enh@google.com> Switch to current OpenBSD system.c.

Change-Id: Ie2df60f0d55dca69149ffe064f10183411407987
53e43292aac91bf62995788cd5ca2ceb7caea283 25-Feb-2014 Elliott Hughes <enh@google.com> More OpenBSD cleanup (primarily string).

This patch removes the string/ and wchar/ directories.

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

Bug: 13076637
Change-Id: I41bf28ab3e6c7325470781e9323eeec023483df5
c9ae21a5c3b2e1baafe50f752e2e07e343d39530 19-Feb-2014 Narayan Kamath <narayan@google.com> Move system_properties over to C++.

This change constitutes the minimum amount of
work required to move the code over to C++, address
compiler warnings, and to make it const correct and
idiomatic (within the constraints of being called
from C code).

bug: 13058886

Change-Id: Ic78cf91b7c8e8f07b4ab0781333a9e243763298c
0133944b09d1c0a35041f7a41eb6bfb660144f4f 21-Feb-2014 Elliott Hughes <enh@google.com> Clean up our OpenBSD usage.

Also undo some of the mess where we have OpenBSD <stdio.h> but a mix of
different BSD's implementations.

In this first pass, I've only moved easy OpenBSD stuff.

Change-Id: Iae67b02cde6dba9d8d06fedeb53efbfdac0a8cf6
677b6e605be95f434602f19a627ea0dea2927ccd 20-Feb-2014 Elliott Hughes <enh@google.com> Move the upstream-netbsd libc files into the correct directory.

I screwed up when I originally imported these files; they're in lib/libc/
in the upstream tree; there is no top-level libc/ (though there is a top-level
common/, so those files stay where they are).

Change-Id: I7c5e2224a4441ab0e33616a855a8c6aacfeac46f
d28b277952a5feceb5ab37a9dd76f8c86132f164 20-Feb-2014 Elliott Hughes <enh@google.com> Remove two DNS files that weren't being built.

And switch the makefile to just building everything in the relevant directory.

Change-Id: Ia7785c4dcabb51639c2230026f8a8a9eff919a36
1fbe6213cdd9fda7e7b816e608b887ad8a0ad265 20-Feb-2014 Elliott Hughes <enh@google.com> Don't explicitly list the tzcode files.

Change-Id: I3ac19899523ac1f5fd2fdd6c942aefce75a964a4
db1ea3474899ebbd783aba872d3005f95a816d0f 18-Jan-2014 Elliott Hughes <enh@google.com> Implement some of the missing LFS64 support.

This gives us:

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

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

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

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

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

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

Bug: 11865851
Bug: 8472078
Change-Id: Ia46443521918519f2dfa64d4621027dfd13ac566
a38cb088619d3e2f2194247038c10897d1c5036e 17-Feb-2014 Elliott Hughes <enh@google.com> Clean up various warnings in bionic.

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

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

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

Change-Id: I6dc411a3d73589383c85d3b07d9d648311492a10
76c8b882690dd9025caa625a023996c136377cb1 13-Feb-2014 Ying Wang <wangying@google.com> Fix missing args.

Change-Id: I89a366db984ea6b2553896a4351e59bb91f93040
f25d677147ae55a1f3b6ef7fa3ee27921792813f 24-Jan-2014 Ying Wang <wangying@google.com> Reconfig libc's Android.mk to build for multilib

1. Moved arch-specific setup to their own files:
- <arch>/<arch>.mk, arch-specific configs. Variables in those config
end with the arch name.
- removed the extra complexity introduced by function libc-add-cpu-variant-src,
which seems to be not very useful these days.
2. Separated out the crt object files generation rules and set up the
rules for both TARGET_ARCH and TARGET_2ND_ARCH.
3. Build all the libraries for both TARGET_ARCH and TARGET_2ND_ARCH,
with the arch-specific LOCAL_ variables.

Bug: 11654773
Change-Id: I9c2d85db0affa49199d182236d2210060a321421
9918665a45095ad135576f005c0e5307feb366a1 07-Feb-2014 Chris Dearman <chris.dearman@imgtec.com> [MIPS64] Dynamic linker

Change-Id: I937c7c776cae3d66e214798d5217a922cd106bfc
Signed-off-by: Chris Dearman <chris.dearman@imgtec.com>
Signed-off-by: Duane Sand <duane.sand@imgtec.com>
b3a23bd0178c8edbb34e310be08e6fb73ac6ba09 11-Feb-2014 Elliott Hughes <enh@google.com> Build syscall stubs in their own library.

This lets us lose the auto-generated makefiles.

Change-Id: I2de0c71b3b9c08f9cce8f4ff7fd7254dda008c86
0266ae5f884d72da58f33a072e865ba131234a5e 11-Feb-2014 Elliott Hughes <enh@google.com> Switch <elf.h> over to linux uapi under the covers.

Remove the linker's reliance on BSD cruft and use the glibc-style
ElfW macro. (Other code too, but the linker contains the majority
of the code that needs to work for Elf32 and Elf64.)

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

Bug: 12476126
Change-Id: I1d7f918f1303a392794a6cd8b3512ff56bd6e487
645d0312c2d6b6492cc4b3891bc1a91908dc24b7 06-Feb-2014 Chris Dearman <chris.dearman@imgtec.com> [MIPS64] libc/libm support

libc/libm support for MIPS64 targets

Change-Id: I8271941d418612a286be55495f0e95822f90004f
Signed-off-by: Chris Dearman <chris.dearman@imgtec.com>
Signed-off-by: Raghu Gandham <raghu.gandham@imgtec.com>
f64b8ea09db3bdd84eed59f7721301743332b3fe 04-Feb-2014 Elliott Hughes <enh@google.com> Add fallocate/fallocate64/posix_fallocate/posix_fallocate64.

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

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

Change-Id: Ia92d8a50824e5329cf00fd6f4f92eae112b7f3a3
887e1140fe7596fa1239a0bc802d2cdb51c57d3c 02-Jan-2014 Elliott Hughes <enh@google.com> Clean up <sched.h>.

This patch switches to using the uapi constants. It also adds the missing
setns system call, fixes sched_getcpu's error behavior, and fixes the
gensyscalls script now ARM is uapi-only too.

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

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

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

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

Change-Id: I7db2e386694f6933db043138e6e97e5ae54d4174
e210488e0d4082b9a0c55195c22191f29ed56bf8 26-Sep-2013 Serban Constantinescu <serban.constantinescu@arm.com> AArch64: Add initial support for AArch64

This is the first patch out of a series of patches that add support for
AArch64, the new 64bit execution state of the ARMv8 Architecture. The
patches add support for LP64 programming model.

The patch adds:
* "arch-aarch64" to the architecture directories.
* "arch-aarch64/include" - headers used by libc
* "arch-aarch64/bionic":
- crtbegin, crtend support;
- aarch64 specific syscall stubs;
- setjmp, clone, vfork assembly files.

Change-Id: If72b859f81928d03ad05d4ccfcb54c2f5dbf99a5
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
ab61eb366ac48addf2bca6093a34455193f5c8df 21-Nov-2013 Elliott Hughes <enh@google.com> Switch to upstream sleep(3) and usleep(3).

Also fix the signature of usleep, and the definition of useconds_t which
should be unsigned, as the 'u' in its name implies.

This patch also cleans up the existing FreeBSD hacks by moving the libm
stuff from <sys/cdefs.h> to a libm-private header, and adding comments
about the hacks we use to build FreeBSD source.

Change-Id: Ibe5067a380502df94a0a3a7901969b35411085b6
36d6188f8cd8b948fb797f11d9620d63d0c2215a 19-Nov-2013 Elliott Hughes <enh@google.com> Clean up forking and cloning.

The kernel now maintains the pthread_internal_t::tid field for us,
and __clone was only used in one place so let's inline it so we don't
have to leave such a dangerous function lying around. Also rename
files to match their content and remove some useless #includes.

Change-Id: I24299fb4a940e394de75f864ee36fdabbd9438f9
652289942d0d2543af90c8af9c04d80a2edb481a 14-Nov-2013 Pawit Pornkitprasan <p.pawit@gmail.com> bionic: call stdio cleanup on exit

As of 61e699a133a4807fe878a6cb0d7190d7c96e21f8, stdio clean up
functions are no longer registered in atexit and must be called
manually via __cleanup.

The issue this fixes is some static binaries linked against bionic
cannot output properly when piped or redirected because the buffer
is not flushed before closing.

This is done by pulling in exit.c (and other dependencies) from
netbsd.

Change-Id: I193e54a6d08900f291550029fe75ce76394d9e22
e48b68570d872ef7ece1d873c0ea298ea76393f3 15-Nov-2013 Elliott Hughes <enh@google.com> Clean up the pthread_create trampoline.

Bug: 8206355
Bug: 11693195
Change-Id: I35cc024d5b6ebd19d1d2e45610db185addaf45df
062092543fdbd6fa2676e4f5b37a15f7bba94332 07-Nov-2013 Elliott Hughes <enh@google.com> Clean up the 32-bit kernel support, fix LP64 fcntl declaration.

In practice, thanks to all the registers the stubs don't actually change,
but it's confusing to have an incorrect declaration.

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

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

Change-Id: I58dd0054fe99d7d51d04c22781d8965dff1afbf3
8fbf8deb34d0bd1efc22d2b67d660ad32ecc4c5c 06-Nov-2013 Elliott Hughes <enh@google.com> Fix pread/pwrite for LP64.

Unlike on 32-bit systems where off_t is 32-bit, we don't want to
throw away the top 32 bits of an LP64 system's 64-bit off_t.

Change-Id: Ib2e0daeb4fc0b8ab3d1b983d0b371d8f81033b50
66759d6041b33706c3a92dde48492ba4f2bbab2f 31-Oct-2013 Elliott Hughes <enh@google.com> Move the pthread debugging flags to the right place.

Change-Id: Ie805bd837d1f72cdf1818e056c0baeb0857e4e84
c3f114037dbf028896310609fd28cf2b3da99c4d 30-Oct-2013 Elliott Hughes <enh@google.com> <pthread.h> fixes and pthread cleanup.

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

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

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

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

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

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

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

Change-Id: Idc0ae7f5d8aa65989598acd4c01a874fe21582c7
b5b97f20a8225e6aad593b2d8f8eb6c0ac34cefe 30-Oct-2013 Elliott Hughes <enh@google.com> Remove an obsolete ARM gdb hack.

Experiment shows that the claim in the makefile was false: gdb works fine
setting breakpoints in these functions when compiled without special treatment.

Change-Id: Ibdf4dd5a14d171c954b8c2089daaf28e1c310be9
2f287bc72827525ad42ee43d532d267a388104c3 30-Oct-2013 Elliott Hughes <enh@google.com> Factor out some of the makefile cruft.

I really don't want to add yet another copy for aarch64.

Also sort arm, mips, and x86.

Also silence the "TARGET_ARCH_VARIANT" warning for non-ARM; Intel and MIPS
have both complained about it.

Change-Id: I32c592a90c0cf0cdae250d84035b3e4655543781
567a8de3ca5b4c4f033bfbcdd339a3fd59a76227 25-Oct-2013 Elliott Hughes <enh@google.com> Start moving 32-bit cruft somewhere it won't pollute 64-bit.

Change-Id: I03a6a50a5243f29e50fb58a3cf8b5e7198640baa
bf425680e484486803bf21e4c4cd1e3f36614a3c 25-Oct-2013 Elliott Hughes <enh@google.com> Let the compiler worry about implementing ffs(3).

It does at least as good a job as our old hand-written assembly anyway.

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

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

Change-Id: I6f64075aa412f71520f2df71c3d69b647f91c1ca
cac7b9d6ec1a09814bc028e2f768db732f018891 23-Oct-2013 Elliott Hughes <enh@google.com> Remove dependencies on obsolete __ARCH_WANT_SYSCALL_NO_FLAGS syscalls.

(aarch64 kernels only have the newer system calls.)

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

Change-Id: I45d2d168a03f88723d1f7fbf634701006a4843c5
f8fcfbc85a3ce3e195626b90736d3a484331494b 22-Oct-2013 Elliott Hughes <enh@google.com> Move away from the __ARCH_WANT_SYSCALL_NO_AT system calls.

Modern architectures only get the *at(2) system calls. For example,
aarch64 doesn't have open(2), and expects userspace to use openat(2)
instead.

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

Bug: https://code.google.com/p/android/issues/detail?id=58888
Change-Id: Ic0a883a5f30beb82cb7be3c4e81b6d693d5fbb4d
c7e9b2331771e5e87c34a8ee3dc6cc41d35b02fe 17-Oct-2013 Elliott Hughes <enh@google.com> Fix sigaction(3) for 64-bit.

Also clean up <signal.h> and revert the hacks that were necessary
for 64-bit in linker/debugger.cpp until now.

Change-Id: I3b0554ca8a49ee1c97cda086ce2c1954ebc11892
40d105ccb3e6283566ce54b693b3088f31aa4f26 16-Oct-2013 Elliott Hughes <enh@google.com> Switch sigpending over to rt_sigpending.

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

Change-Id: I981c1a66d35480d4457a0a08a1b042dac94daa5b
19e62325c268a668692e2b65fde2284079f369aa 15-Oct-2013 Elliott Hughes <enh@google.com> Clean up the sigprocmask/pthread_sigmask implementation.

Let's have both use rt_sigprocmask, like in glibc. The 64-bit ABIs
can share the same code as the 32-bit ABIs.

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

Bug: 11069919
Change-Id: I11da99f85b5b481870943c520d05ec929b15eddb
b036b5ca36c1e12b075909b3eca6eab73ee611cf 10-Oct-2013 Nick Kralevich <nnk@google.com> FORTIFY_SOURCE: fortify read()

Change-Id: Ic7de163fe121db13e00560adb257331bc709814d
232163cf70712fe00436b70dd495f4cf405e9eab 10-Oct-2013 Elliott Hughes <enh@google.com> Clean up the cpuacct cruft.

Change-Id: I6ed63af8dfc2368e211420389fa8af4d5dc0908f
8d2532763981d132b02df157e4cc363c39330090 10-Oct-2013 Nick Kralevich <nnk@google.com> Revert "FORTIFY_SOURCE: fortify read()"

This change reverts
* fb3f956d075676c0438f2ee2bf3a5be659dfc04b.
* 65c99de2cb7a569ea17ca35e2f8f1e033421864b

Change-Id: Id5774eeede41130579115cf67a72ee914f2b47d5
eb847bc8666842a3cfc9c06e8458ad1abebebaf0 10-Oct-2013 Elliott Hughes <enh@google.com> Fix x86_64 build, clean up intermediate libraries.

The x86_64 build was failing because clone.S had a call to __thread_entry which
was being added to a different intermediate .a on the way to making libc.so,
and the linker couldn't guarantee statically that such a relocation would be
possible.

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

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

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

Change-Id: I00425a7245b7a2573df16cc38798187d0729e7c4
65c99de2cb7a569ea17ca35e2f8f1e033421864b 09-Oct-2013 Nick Kralevich <nnk@google.com> FORTIFY_SOURCE: fortify read()

Change-Id: I3d7b4ec86d04efb865117ce7629a2e26917f3331
2a0b873065edb304fa2d1c54f8de663ea638b8ab 09-Oct-2013 Elliott Hughes <enh@google.com> Fix __errno for LP64 and clean up __get_tls.

If __get_tls has the right type, a lot of confusing casting can disappear.

It was probably a mistake that __get_tls was exposed as a function for mips
and x86 (but not arm), so let's (a) ensure that the __get_tls function
always matches the macro, (b) that we have the function for arm too, and
(c) that we don't have the function for any 64-bit architecture.

Change-Id: Ie9cb989b66e2006524ad7733eb6e1a65055463be
2ec400bfc7d1605b68ae3f5501add7bf2647b9dd 09-Oct-2013 Elliott Hughes <enh@google.com> Don't allow int<->pointer conversions.

Normally we don't have -Werror for upstream code, but for those warnings
that probably point to 32-bit assumptions about pointers, we want those
warnings to always be errors.

Change-Id: Ibece9caf09b2f7989ca600ef448d07868669a8fb
ee489f6ad2331592523b3cc6e4dc80a8e5ef80be 07-Oct-2013 Elliott Hughes <enh@google.com> Don't define the meaningless SOFTFLOAT for x86.

Change-Id: I9f932ad5d9f731a0de18efb881d02cedf9fcbede
9373bbb24b16fbee0f7d99a94651d614ec4d2318 20-Sep-2013 Pavel Chupin <pavel.v.chupin@intel.com> x86_64: Remove lseek64 for x86_64 for a while

Just to keep x86_64 libc buildable

Change-Id: I6e69abe2b699bc4ac12e41178ee080df5dac47b7
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
7e841ed688947855a3bd20d2b23a44599257038a 04-Oct-2013 Elliott Hughes <enh@google.com> Remove useless x86 fallbacks.

The NDK ABI requires that you support SSE2, and the build system won't let you
build with ARCH_X86_HAVE_SSE2 set to false. So let's stop pretending this
constant is actually a variable, and let's remove the corresponding dead code.

Also, the USE_SSE2 and USE_SSE3 macros are unused, so let's not bother
setting them.

Change-Id: I40b501d998530d22518ce1c4d14575513a8125bb
d7a632948d5b3128cc536a2c4db3124b4fa57a80 03-Oct-2013 Christopher Ferris <cferris@google.com> Add dependencies on included makefiles.

Bug: 11050594

Merge from internal master.

(cherry-picked from f389284e86bbcbdb257d7388a17fde007113b0d6)

Change-Id: I2b3e38329a09d26c16870906f9ed1257e2a9dbc8
f389284e86bbcbdb257d7388a17fde007113b0d6 03-Oct-2013 Christopher Ferris <cferris@google.com> Add dependencies on included makefiles.

Bug: 11050594
Change-Id: I5e6e1965f9c0c493921cf59c974b3bcbaea40c22
b49c17c2bf1232e29bc390e58d6fa43688929aa5 02-Oct-2013 Pavel Chupin <pavel.v.chupin@intel.com> Move common arch-* code to arch-common directory

Will be helpful on adding x86_64

Change-Id: I96cf6fc7912c02f289c75f07ae0079c32d69173f
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
90201d5eca050414d50a433866ccb580415bb0d4 03-Oct-2013 Nick Kralevich <nnk@google.com> FORTIFY_SOURCE: Add __FD_* checks

Add FORTIFY_SOURCE checks for the following macros:

* FD_CLR
* FD_ISSET
* FD_SET

Bug: 11047121
Change-Id: I3c5952136aec9eff3288b91b1318677ff971525c
762cea46f070e25b33de6f36a54fb7c293f0fee5 01-Oct-2013 Stephen Hines <srhines@google.com> Use gnu++11 and gnu99 explicitly for C++/C files.

Clang and gcc default to different standards, so we should be explicit
about the versions we want to compile for.

Change-Id: I65495a2392dd29f36373b94c616c2506173e6033
fa4d596abc5dd3a485cc0b5e38b80393abef4a44 02-Oct-2013 Chris Dearman <chris.dearman@imgtec.com> Add missing backslash in MIPS filelist

Change-Id: I993ea7038cd641ea167d974226e2350e49d41c88
a567a8e4bd9036bcb74a0a028235a48d8b2a115e 18-Dec-2012 Pavel Chupin <pavel.v.chupin@intel.com> x86_64: Update Makefiles for x86_64 targets and add symlinks

Use basic .c versions of all functions for x86_64 until they are
manually optimized and .s versions released.

Change-Id: I59bba08931e894822db485c8803c2665c226234a
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
60f4f9a5b99a0a66817f50edfc2194a49f8b5146 25-Sep-2013 Nick Kralevich <nnk@google.com> libc: fortify recvfrom()

Fortify calls to recv() and recvfrom().

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

Change-Id: Iad6ae96551a89af17a9c347b80cdefcf2020c505
1d13c64d781a87dfa3f01e5c179bfa36748786af 24-Sep-2013 Elliott Hughes <enh@google.com> Fix %hhd formats in the printf family.

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

Change-Id: Ie339a8e9393a36080147aae4d6665118e5d93647
3f33165acd0bd86044ba9c284e6586a8f2c48515 23-Sep-2013 Elliott Hughes <enh@google.com> Remove two -D flags for unused macros.

Change-Id: Ia95b0f0e2003cadd875e84437afa1853c8fe2598
e85c1834248916d7d13891e602461d9be91dda28 16-Aug-2013 Pavel Chupin <pavel.v.chupin@intel.com> Add explicit -m32/-melf_i386 for x86 target

Required for x86 build with multilib compiler.

Change-Id: Iac71cdc3461df6fb48cb2a7b713324ca368e6704
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
345eb225ae2e87e36354be5f1e62301179482804 22-Aug-2013 Elliott Hughes <enh@google.com> Apply upstream commit 943a6621866e9d6e654f5cfe1494378c1fb8957a.

Author: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu Aug 22 12:47:51 2013 -0700

* localtime.c: Fix another integer overflow bug in mktime.

(time2sub): Avoid undefined behavior on time_t overflow.
Reported by Elliott Hughes in
<http://mm.icann.org/pipermail/tz/2013-August/019580.html>.

Bug: 10310929

(cherry picked from commit 713fe6463e6ff8cb9689aa8ead88c885d25d03aa)

Change-Id: I9ec79fd8d825e6b9e8bb5af549dbfc2182346c05
713fe6463e6ff8cb9689aa8ead88c885d25d03aa 22-Aug-2013 Elliott Hughes <enh@google.com> Apply upstream commit 943a6621866e9d6e654f5cfe1494378c1fb8957a.

Author: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu Aug 22 12:47:51 2013 -0700

* localtime.c: Fix another integer overflow bug in mktime.

(time2sub): Avoid undefined behavior on time_t overflow.
Reported by Elliott Hughes in
<http://mm.icann.org/pipermail/tz/2013-August/019580.html>.

Bug: 10310929
Change-Id: I3bf26f1f91371552e0a3828457d27e22af55acb2
f0c10a4a16c74f5099cf6b272c0a2f11f454e63c 22-Aug-2013 Elliott Hughes <enh@google.com> Work around tzcode's reliance on signed overflow.

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

Bug: 10310929

(cherry picked from commit 7843d44a594270bcb56e98b130603c054f8a9d38)

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

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

Bug: 10310929
Change-Id: I36bf3fcf11f5ac9b88137597bac3487a7bb81b0f
59a13c122ebc4191583b67c846a95d690dcda5cf 01-Aug-2013 Christopher Ferris <cferris@google.com> Optimize __memset_chk, __memcpy_chk. DO NOT MERGE.

This change creates assembler versions of __memcpy_chk/__memset_chk
that is implemented in the memcpy/memset assembler code. This change
avoids an extra call to memcpy/memset, instead allowing a simple fall
through to occur from the chk code into the body of the real
implementation.

Testing:

- Ran the libc_test on __memcpy_chk/__memset_chk on all nexus devices.
- Wrote a small test executable that has three calls to __memcpy_chk and
three calls to __memset_chk. First call dest_len is length + 1. Second
call dest_len is length. Third call dest_len is length - 1.
Verified that the first two calls pass, and the third fails. Examined
the logcat output on all nexus devices to verify that the fortify
error message was sent properly.
- I benchmarked the new __memcpy_chk and __memset_chk on all systems. For
__memcpy_chk and large copies, the savings is relatively small (about 1%).
For small copies, the savings is large on cortex-a15/krait devices
(between 5% to 30%).
For cortex-a9 and small copies, the speed up is present, but relatively
small (about 3% to 5%).
For __memset_chk and large copies, the savings is also small (about 1%).
However, all processors show larger speed-ups on small copies (about 30% to
100%).

Bug: 9293744

Merge from internal master.

(cherry-picked from 7c860db0747f6276a6e43984d43f8fa5181ea936)

Change-Id: I916ad305e4001269460ca6ebd38aaa0be8ac7f52
5951e84646553cdcba0c619f1424f2d934eeabb2 12-Aug-2013 Elliott Hughes <enh@google.com> Fix our missing abs/labs/llabs/imaxabs (and imaxdiv) symbols.

(cherry picked from commit aec2ffbc5a7b45368ceab3663265fbb659968fe7)

Change-Id: Ib61b52dc37e63493094a0a7af23bf89d4a9f0ce5
aec2ffbc5a7b45368ceab3663265fbb659968fe7 12-Aug-2013 Elliott Hughes <enh@google.com> Fix our missing abs/labs/llabs/imaxabs (and imaxdiv) symbols.

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

(cherry picked from commit d0be7c8f9a06b3ca8ea7647ea35c8f9dc63f0fe1)

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

Bug: 10239370
Change-Id: I518340084103dc339ef8a065d4837d6258a1381d
4e24dcc8d869db7303650d8444c8796445fbbc07 15-Jul-2013 Christopher Ferris <cferris@google.com> Optimize strcat/strcpy, small tweaks to strlen. DO NOT MERGE

Create one version of strcat/strcpy/strlen for cortex-a15/krait and another
version for cortex-a9.

Tested with the libc_test strcat/strcpy/strlen tests.
Including new tests that verify that the src for strcat/strcpy do not
overread across page boundaries.

NOTE: The handling of unaligned strcpy (same code in strcat) could probably
be optimized further such that the src is read 64 bits at a time instead of
the partial reads occurring now.

strlen improves slightly since it was recently optimized.

Performance improvements for strcpy and strcat (using an empty dest string):

cortex-a9
- Small copies vary from about 5% to 20% as the size gets above 10 bytes.
- Copies >= 1024, about a 60% improvement.
- Unaligned copies, from about 40% improvement.

cortex-a15
- Most small copies exhibit a 100% improvement, a few copies only
improve by 20%.
- Copies >= 1024, about 150% improvement.
- Unaligned copies, about 100% improvement.

krait
- Most small copies vary widely, but on average 20% improvement, then
the performance gets better, hitting about a 100% improvement when
copies 64 bytes of data.
- Copies >= 1024, about 100% improvement.
- When coping MBs of data, about 50% improvement.
- Unaligned copies, about 90% improvement.

As strcat destination strings get larger in size:

cortex-a9
- about 40% improvement for small dst strings (>= 32).
- about 250% improvement for dst strings >= 1024.

cortex-a15
- about 200% improvement for small dst strings (>=32).
- about 250% improvement for dst strings >= 1024.

krait
- about 25% improvement for small dst strings (>=32).
- about 100% improvement for dst strings >=1024.

Merge from internal master.

(cherry-picked from d119b7b6f48fe507088cfb98bcafa99b320fd884)

Change-Id: I296463b251ef9fab004ee4dded2793feca5b547a
6771b9cef635f0da98932a1f0f877a07257ca088 07-Aug-2013 Colin Cross <ccross@android.com> bionic: add function to name memory

Only works on some kernels, and only on page-aligned regions of
anonymous memory. It will show up in /proc/pid/maps as
[anon:<name>] and in /proc/pid/smaps as Name: <name>

Change-Id: If31667cf45ff41cc2a79a140ff68707526def80e
7c860db0747f6276a6e43984d43f8fa5181ea936 01-Aug-2013 Christopher Ferris <cferris@google.com> Optimize __memset_chk, __memcpy_chk.

This change creates assembler versions of __memcpy_chk/__memset_chk
that is implemented in the memcpy/memset assembler code. This change
avoids an extra call to memcpy/memset, instead allowing a simple fall
through to occur from the chk code into the body of the real
implementation.

Testing:

- Ran the libc_test on __memcpy_chk/__memset_chk on all nexus devices.
- Wrote a small test executable that has three calls to __memcpy_chk and
three calls to __memset_chk. First call dest_len is length + 1. Second
call dest_len is length. Third call dest_len is length - 1.
Verified that the first two calls pass, and the third fails. Examined
the logcat output on all nexus devices to verify that the fortify
error message was sent properly.
- I benchmarked the new __memcpy_chk and __memset_chk on all systems. For
__memcpy_chk and large copies, the savings is relatively small (about 1%).
For small copies, the savings is large on cortex-a15/krait devices
(between 5% to 30%).
For cortex-a9 and small copies, the speed up is present, but relatively
small (about 3% to 5%).
For __memset_chk and large copies, the savings is also small (about 1%).
However, all processors show larger speed-ups on small copies (about 30% to
100%).

Bug: 9293744

Change-Id: I8926d59fe2673e36e8a27629e02a7b7059ebbc98
d119b7b6f48fe507088cfb98bcafa99b320fd884 15-Jul-2013 Christopher Ferris <cferris@google.com> Optimize strcat/strcpy, small tweaks to strlen.

Create one version of strcat/strcpy/strlen for cortex-a15/krait and another
version for cortex-a9.

Tested with the libc_test strcat/strcpy/strlen tests.
Including new tests that verify that the src for strcat/strcpy do not
overread across page boundaries.

NOTE: The handling of unaligned strcpy (same code in strcat) could probably
be optimized further such that the src is read 64 bits at a time instead of
the partial reads occurring now.

strlen improves slightly since it was recently optimized.

Performance improvements for strcpy and strcat (using an empty dest string):

cortex-a9
- Small copies vary from about 5% to 20% as the size gets above 10 bytes.
- Copies >= 1024, about a 60% improvement.
- Unaligned copies, from about 40% improvement.

cortex-a15
- Most small copies exhibit a 100% improvement, a few copies only
improve by 20%.
- Copies >= 1024, about 150% improvement.
- Unaligned copies, about 100% improvement.

krait
- Most small copies vary widely, but on average 20% improvement, then
the performance gets better, hitting about a 100% improvement when
copies 64 bytes of data.
- Copies >= 1024, about 100% improvement.
- When coping MBs of data, about 50% improvement.
- Unaligned copies, about 90% improvement.

As strcat destination strings get larger in size:

cortex-a9
- about 40% improvement for small dst strings (>= 32).
- about 250% improvement for dst strings >= 1024.

cortex-a15
- about 200% improvement for small dst strings (>=32).
- about 250% improvement for dst strings >= 1024.

krait
- about 25% improvement for small dst strings (>=32).
- about 100% improvement for dst strings >=1024.

Change-Id: Ifd091ebdbce70fe35a7c5d8f71d5914255f3af35
284f7880323d33356df682c3cfb6b7f0c665bfd4 20-Jul-2013 Elliott Hughes <enh@google.com> Upgrade mktemp.c to the current upstream version.

Yet another archaic relic containing bugs that had been fixed years before the
Android project even started...

Bug: 9935113
Change-Id: I3c9d019a216efd609ee568cf8c70bc360f357403
4c6b925bac0ebe2898acbcb4c4ba257463dbfc26 18-Jul-2013 Elliott Hughes <enh@google.com> Remove some non-unused makefile generality.

MIPS uses .c files like ARM and x86 now.

Change-Id: Ie580647e385121c380316c443ec199dabf657ff8
368860124c34e101f2e9fda71870b5562108357a 17-Jul-2013 Pete Delaney <piet.delaney@imgtec.com> [MIPS] Rewrite MIPS crtbegin* as C files.

This updates the MIPS arch to be much more in
sync with the commit Nick Kralevich made last
June; see 9d40326830c2bd407427889c554adeb915ee6b4a.

Rewrite
crtbegin.S -> crtbegin.c
crtbegin_so.S -> crtbegin_so.c
__dso_handle.S -> __dso_handle.c
__dso_handle_so.S -> __dso_handle_so.c
atexit.S -> atexit.c

Previously __do_global_dtors_aux was in the tasks
__FINI_ARRAY__ linked with crtbegin.S and it now being
removed as there is no need to call a destructor just
before terminating a process.

Shared libraries, on the other hand, are linked with
crtbegin_so.c and have a hidden destructor declared
to allow the bionic linker to call __on_dlclose().

Change-Id: Ieb4da5199b54573de05743990e309db381a11cb8
Signed-off-by: Pete Delaney <piet.delaney@imgtec.com>
Signed-off-by: Chao-Ying Fu <chao-ying.fu@imgtec.com>
Signed-off-by: Chris Dearman <chris.dearman@imgtec.com>
107cdd406b8e404af4d552498076cfe2dfe5efbf 17-Jul-2013 Elliott Hughes <enh@google.com> Prevent the madvise(MADV_MERGEABLE) mmap hack from affecting errno.

Bug: 9889616
Change-Id: I4a7323e0ae5aeb5cbe0da1b2bc7501d83b3a2aa4
ce4783ce76a4ef888466e02e4c6f3a0a3910bce8 13-Jul-2013 Elliott Hughes <enh@google.com> Upgrade to tzcode2013d.

Well, kinda... localtime.c still contains a bunch of Android-specific
hacks, as does strftime.c. But the other files are now exactly the same
as upstream.

This catches up with several years of bug fixes, and fixes most of the
compiler warnings that were in this code. (Just two remain.)

Bug: 1744909
Change-Id: I2ddfecb6fd408c847397c17afb0fff859e27feef
06040fd75c1edff9e5ffb2b3d3e2a6e66d57c11d 09-Jul-2013 Elliott Hughes <enh@google.com> Add <sys/statvfs.h>.

Bug: 2512019
Change-Id: I6e7fd3fa281977cc4bc270481a95416b5b2dc351
5e9a086145764d64c0f7fbce5489d820aa7fdcd4 25-Jun-2013 Colin Cross <ccross@android.com> bionic: add compatibility mode for properties

Allow a new bionic to work with an old init property area by supporting
the old format.

(cherry picked from commit ad76c85b9ca587084089d086f954158bc0eae905)

Change-Id: Ib496e818a62a5834d40c71eb4745783d998be893
d278b828fef47fb2d7098f8ec70867fbd3da09d6 25-Jun-2013 Elliott Hughes <enh@google.com> Switch to current upstream getopt_long.

Change-Id: I4c646dcb8be9e88dd54d069a03bbc5fbfd92de03
ad76c85b9ca587084089d086f954158bc0eae905 25-Jun-2013 Colin Cross <ccross@android.com> bionic: add compatibility mode for properties

Allow a new bionic to work with an old init property area by supporting
the old format.

Change-Id: I9268214b2f8930e75e3b5c26afe94fa92068bf0b
677ee5647721df22f13909375d5d0e770a1a80bf 13-Jun-2013 Elliott Hughes <enh@google.com> Switch to current upstream stdio makebuf.c and setvbuf.c.

Change-Id: I4761b5e94459815520f01062eef39abf62af621f
61e699a133a4807fe878a6cb0d7190d7c96e21f8 12-Jun-2013 Elliott Hughes <enh@google.com> Clean up abort.

* A dlmalloc usage error shouldn't call abort(3) because we want to
cause a SIGSEGV by writing the address dlmalloc didn't like to an
address the kernel won't like, so that debuggerd will dump the
memory around the address that upset dlmalloc.

* Switch to the simpler FreeBSD/NetBSD style of registering stdio
cleanup. Hopefully this will let us simplify more of the stdio
implementation.

* Clear the stdio cleanup handler before we abort because of a dlmalloc
corruption error. This fixes the reported bug, where we'd hang inside
dlmalloc because the stdio cleanup reentered dlmalloc.

Bug: 9301265
Change-Id: Ief31b389455d6876e5a68f0f5429567d37277dbc
0a490665a3a287cd3aee1e7327f2381222c387c4 16-Jan-2012 Liubov Dmitrieva <liubov.dmitrieva@intel.com> bionic/x86: Optimization for string routines

Optimized strcpy, strcat,
strncpy, strncat, strlcpy, strlcat,
memchr, memrchr, strchr, strrchr, index,
strnlen, strlen, wcslen, wmemcmp, wcscmp,
wcschr, wcsrchr, wcscpy, wcscat

Change-Id: I82b29132edf9a2e144e0bb3ee4ff5217df8d2a6d
Signed-off-by: Liubov Dmitrieva <liubov.dmitrieva@intel.com>
4f40e511b0612ea099ab5b0843977fe7a49372fd 20-Apr-2013 Nick Kralevich <nnk@google.com> libc: cleanup strchr

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

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

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

This only touches the easy stuff.

Change-Id: Iecee57f1681dba5c56bff59f0e9a89811a71f0ca
4ca685e36e9d7f53c135eba2b4b8ece152129dbe 09-Apr-2013 Kito Cheng <kito@0xlab.org> Add missing include and function prototype for sched_getaffinity.

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

- eventfd.cpp and eventfd.s will output to the same file when building libc.a
out/target/product/*/obj/STATIC_LIBRARIES/libc_intermediates/WHOLE/libc_common_objs/eventfd.o
- And then `eventfd` will undefined when statically linked to libc.

Also add a unit test.

(cherry-pick of 8baa929d5d3bcf63381cf78ba76168c80c303f5e.)

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

- eventfd.cpp and eventfd.s will output to the same file when building libc.a
out/target/product/*/obj/STATIC_LIBRARIES/libc_intermediates/WHOLE/libc_common_objs/eventfd.o
- And then `eventfd` will undefined when statically linked to libc.

Also add a unit test.

Change-Id: Ib310ade3256712ca617a90539e8eb07459c98505
8794ece296dd62cbeb3d00fe57c831c90a1bef77 22-Mar-2013 Elliott Hughes <enh@google.com> Replace unnecessary ARM uses of <sys/linux-syscalls.h> with <asm/unistd.h>.

For some reason, socketcalls.c was only being compiled for ARM, where
it makes no sense. For x86 we generate stubs for the socket functions
that use __NR_socketcall directly.

Change-Id: I84181e6183fae2314ae3ed862276eba82ad21e8e
17a8b0db63d54e9d79bf11112ace0c4fe9606289 21-Mar-2013 Elliott Hughes <enh@google.com> Expose wait4 as wait4 rather than __wait4.

This helps strace(1) compile with one fewer hack.

Change-Id: I5296d0cfec5546709cda990abd705ad33d7c4626
8f2a5a0b40fc82126c691d5c30131d908772aab7 15-Mar-2013 Elliott Hughes <enh@google.com> Clean up internal libc logging.

We only need one logging API, and I prefer the one that does no
allocation and is thus safe to use in any context.

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

Move everything logging-related into one header file.

Change-Id: Ic1e3ea8e9b910dc29df351bff6c0aa4db26fbb58
306a3538254ed8272ff3d04bcb724d87af7423d1 28-Feb-2013 Christopher Ferris <cferris@google.com> Remove unused arm defines.

The defines HAVE_32_BYTE_CACHE_LINES and ARCH_ARM_USE_NON_NEON_MEMCPY
are not used by any code. The previous memcpy code that used these
has been split into different architecture versions to avoid the need
for them.

Bug: 8005082

Merge from internal master.

(cherry-picked from commit 6e1a5cf31ba47508b08dba02a45b4ea6e1edd6d2)

Change-Id: Ib18fc3f4131b21cdbd19b9dde7697ac25d066fcf
04954a43b362b8c817cc5859513efad0c344f412 26-Feb-2013 Christopher Ferris <cferris@google.com> Break bionic implementations into arch versions.

Move arch specific code for arm, mips, x86 into separate
makefiles.
In addition, add different arm cpu versions of memcpy/memset.

Bug: 8005082

Merge from internal master (acdde8c1cf8e8beed98c052757d96695b820b50c).

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

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

Bug: 5335385
Change-Id: Ib08bfa65b2cb9fa695717aae629ea14816bf988d
642331b5dd5647e7d196ac4f44406fd435478a56 07-Mar-2013 Elliott Hughes <enh@google.com> Fix debug malloc.

This was broken by the change to use AT_RANDOM for the stack guards.

Bug: 7959813
Bug: 8330764
Change-Id: I791900092b72a9a900f16585237fa7ad82aaed9f
eb93ebffba21e2c9b8a12bb86db60d38c7750270 02-Mar-2013 Elliott Hughes <enh@google.com> Switch to upstream-freebsd for the unmolested wchar code.

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

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

Bug: 5110679
Change-Id: I87e563f0f95aa8e68b45578e2a8f448bbf827a33
947b3ab02b702717742499687190b4a87b63e46c 28-Feb-2013 Christopher Ferris <cferris@google.com> Remove unused arm defines. DO NOT MERGE

The defines HAVE_32_BYTE_CACHE_LINES and ARCH_ARM_USE_NON_NEON_MEMCPY
are not used by any code. The previous memcpy code that used these
has been split into different architecture versions to avoid the need
for them.

Bug: 8005082

(cherry picked from commit 6e1a5cf31ba47508b08dba02a45b4ea6e1edd6d2)

Change-Id: I69654d47db1458136782b5504290f620e924ee75
7c83a1ed81a15f3e75836c1ac7d500a952f02e10 26-Feb-2013 Christopher Ferris <cferris@google.com> Break bionic implementations into arch versions. DO NOT MERGE

Move arch specific code for arm, mips, x86 into separate
makefiles.
In addition, add different arm cpu versions of memcpy/memset.

Bug: 8005082

(cherry picked from commit acdde8c1cf8e8beed98c052757d96695b820b50c)

Change-Id: I0108d432af9f6283ae99adfc92a3399e5ab3e31d
6e1a5cf31ba47508b08dba02a45b4ea6e1edd6d2 28-Feb-2013 Christopher Ferris <cferris@google.com> Remove unused arm defines.

The defines HAVE_32_BYTE_CACHE_LINES and ARCH_ARM_USE_NON_NEON_MEMCPY
are not used by any code. The previous memcpy code that used these
has been split into different architecture versions to avoid the need
for them.

Bug: 8005082
Change-Id: I14e0368c5bb4c3a80e72520f7cfd97e359918cce
acdde8c1cf8e8beed98c052757d96695b820b50c 26-Feb-2013 Christopher Ferris <cferris@google.com> Break bionic implementations into arch versions.

Move arch specific code for arm, mips, x86 into separate
makefiles.
In addition, add different arm cpu versions of memcpy/memset.

Bug: 8005082
Change-Id: I04f3d0715104fab618e1abf7cf8f7eec9bec79df
701bec2af33feaa9dddf12ccf8e4c714441b7f2e 25-Feb-2013 Elliott Hughes <enh@google.com> Reimplement scandir(3).

The old scandir implementation didn't take into account the varying
size of directory entries, and didn't correctly clean up on its
error exits.

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

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

Change-Id: I96347f6195549aee0c72dc39063e6c5d06d2e01f
081318e3550b1a8d8384d98d7c94527681691120 15-Feb-2013 Elliott Hughes <enh@google.com> dalvik is big enough and ugly enough to handle System.arraycopy itself.

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

Bug: 2487269
Change-Id: Iec5e470fc22cd9108404f634a9d4baa2c7b7f58f
dc5ec07158079b39f758ed41eca5b937e52c3729 14-Feb-2013 Elliott Hughes <enh@google.com> Turn on -Werror for ssp.cpp.

libc_bionic.a is already compiled -Werror, but this one file gets
compiled into its own library because it needs to be compiled with
-fno-stack-protector.

Change-Id: I273c535ab5c73ccaccbcf793fda1f788a2589abe
d2547040a13fe1bce31a60df35d4953c596a3db0 14-Feb-2013 Elliott Hughes <enh@google.com> ffs was not being built for x86.

Change-Id: I53e92273664a4d0a13536c2fa1aeb87e1f3cf4e8
91a9925998f2b878f0245ce03aab22cc412a4d8b 13-Feb-2013 Elliott Hughes <enh@google.com> Everyone has a TLS register.

Change-Id: Id7cdf67087aa7d5074c9c59b7e595bc391d9f146
4b4a8824289c48c823cd38bc63289d121aae3d67 13-Feb-2013 Elliott Hughes <enh@google.com> Clean up pthread_create.

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

This reverts commit 6f94de3ca49e4ea147b1c59e5818fa175846518f

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

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

This reverts commit 2a1bb4e64677b9abbc17173c79768ed494565047

Change-Id: Ia443d0748015c8e9fc3121e40e68258616767b51
ba342c11adbe92aa918d50b0d2a36453510ebf02 12-Feb-2013 Elliott Hughes <enh@google.com> Fix MIPS build.

Change-Id: I4863f21f3c2fd597ea36cb7096fc72db808643a3
2a1bb4e64677b9abbc17173c79768ed494565047 11-Feb-2013 Elliott Hughes <enh@google.com> More pthreads cleanup.

POSIX says pthread_create returns EAGAIN, not ENOMEM.

Also pull pthread_attr_t functions into their own file.

Also pull pthread_setname_np into its own file.

Also remove unnecessary #includes from pthread_key.cpp.

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

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

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

This reverts commit 6260553d48f6fd87ca220270bea8bafdde5726ec

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

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

This reverts commit ad59322ae432d11ff36dcf046016af8cfe45fbe4

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

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

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

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

Change-Id: Ife26ea2f4b40865308e8410ec803b20bcc3e0ed1
42b2c6a5eed5e4ef35315b8cd32d1355f12a69b6 07-Feb-2013 Elliott Hughes <enh@google.com> Clean up the argc/argv/envp/auxv handling.

There's now only one place where we deal with this stuff, it only needs to
be parsed once by the dynamic linker (rather than by each recipient), and it's
now easier for us to get hold of auxv data early on.

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

Bug: https://code.google.com/p/android/issues/detail?id=37349
Change-Id: I970c7b6be7bb7fbe6bbbe2c332f05816aeb0e09f
2b473070126345e323d0694b87f88264cc9a77cc 23-Jan-2013 Elliott Hughes <enh@google.com> Our strcoll(3) is no different from NetBSD's, so take exactly theirs.

Change-Id: I45251047202a229f9175735ecc23c0ebcda71e8d
c51cd764a2d0897234762abd4dbd21420cb9f17d 22-Jan-2013 Elliott Hughes <enh@google.com> Avoid overflow in memccpy.

Just take the upstream NetBSD code.

Bug: http://code.google.com/p/android/issues/detail?id=43078
Change-Id: Ibbbde9d00e8bc6a09c9503aab2b04b4e3d1f98b0
1e980b6bc8315d00a07312b25486531247abd98c 18-Jan-2013 Elliott Hughes <enh@google.com> Fix the duplication in the debugging code.

We had two copies of the backtrace code, and two copies of the
libcorkscrew /proc/pid/maps code. This patch gets us down to one.

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

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

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

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

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

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

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

This change is a prerequisite for bug 7959813.

Bug: http://code.google.com/p/android/issues/detail?id=38441
Change-Id: Iba19d899df334bddc6f4899077ece2fc87564ea8
c5d028fc913de84a781bd61084bf7ae2182fd48e 10-Jan-2013 Elliott Hughes <enh@google.com> Only have one copy of the kernel_sigset_t hack, and add more tests.

Change-Id: I377522fcba6fb4b5fd2754ab15b091014bd7c16f
a4b2dc016fa62bd172a73c3f8971c805700ffb0f 10-Jan-2013 Rom Lemarchand <romlem@google.com> Add signalfd call to bionic

Add signalfd() call to bionic.

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

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

Change-Id: I4c6c3f12199559af8be63f93a5336851b7e63355
19dd1567a0aee5e2e46b22352569d37b4c3844c5 10-Jan-2013 Elliott Hughes <enh@google.com> Revert "Add signalfd call to bionic"

This reverts commit 0c11611c11f4dc1b6d43587b72c3ccbe8c51a51c

Change-Id: I1a2beae7ed66ec995fdf6c96c53c35598ac6cde0
0c11611c11f4dc1b6d43587b72c3ccbe8c51a51c 10-Jan-2013 Rom Lemarchand <romlem@google.com> Add signalfd call to bionic

Add signalfd() call to bionic.

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

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

Bug: http://code.google.com/p/android/issues/detail?id=39680
Change-Id: I11cf10a66f9d305868a725f04f581099fb88bbfc
d8a5a6f513c6fa99229e9c82c5c308c7cd6b3d54 08-Dec-2012 Chris Dearman <chris@mips.com> Use pthread_kill() in raise()

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

Change-Id: Ic679272b664d2b8a7068b628fb83a9f7395c441f
4a9e837840fda3aaea48aeba85c7c7a8782d2586 30-Nov-2012 Elliott Hughes <enh@google.com> Reduce the exposure of the __set_errno implementation detail.

Change-Id: I395e1b46a9491e34fc53e71853e932ea90b3d1cc
20c4a3a8eee5ca8c87ae377732f541baffce1fda 28-Nov-2012 Pavel Chupin <pavel.v.chupin@intel.com> Replace .S version of x86 crtfiles with .c version

This patch replaces .S versions of x86 crtfiles with .c which are much
easier to support. Some of the files are matching .c version of Arm
crtfiles. x86 files required some cleanup anyway and this cleanup actually
led to matching Arm files.

I didn't change anything to share the same crt*.c between x86 and Arm. I
prefer to keep them separate for a while in case any change is required
for one of the arch, but it's good thing to do in the following patches.

Change-Id: Ibcf033f8d15aa5b10c05c879fd4b79a64dfc70f3
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
58b575485c446f9d76ee00f67516ed42cf017769 29-Oct-2012 Elliott Hughes <enh@google.com> Clean up the <libgen.h> implementation a little, bring in tests.

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

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

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

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

while both Posix and GLibc use instead:

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

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

This patch does the following:

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

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

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

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

Based on a pair of patches from Intel:

https://android-review.googlesource.com/#/c/43909/
https://android-review.googlesource.com/#/c/44903/

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

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

Change-Id: I02f279a80c6b626aecad449771dec91df235ad01
ab44f52202878cdf2bf22457aeae33ec24089556 24-Oct-2012 Elliott Hughes <enh@google.com> More upstream NetBSD upgrades.

Change-Id: Idb781d37de3b05585271d7d258ecffd5ba87d0b8
e8bcca3a2ca4a70156c72239d62bb68eeb2929fd 23-Oct-2012 Elliott Hughes <enh@google.com> Upgrade more functions to the current upstream NetBSD copy.

Change-Id: Ie0b3f8b3fccef28609eb210434413ebd51d6ef45
29c7f0b4d18f812267c2194b85204e19e41d0387 23-Oct-2012 Elliott Hughes <enh@google.com> Move setlocale(3) and the wchar stubs over to .cpp.

Also separate out the C++ files so we can use -Werror on them. I'd
rather wait for LOCAL_CPPFLAGS to be in AOSP, but this also lets us
see which files still need to be sorted into one bucket or the other.

Change-Id: I6acc1f7c043935c70a3b089f705d218b9aaaba0a
4035b7a32155eac46f3f3782774deb5967ea2b54 23-Oct-2012 Elliott Hughes <enh@google.com> Move the FORTIFY_SOURCE helpers over to .cpp.

Change-Id: Ib5067d51b983cac7760c975becce7fe2408ead04
914d8d4cff10f023ccd382fb43b2c7833dd34f72 18-Oct-2012 Elliott Hughes <enh@google.com> Make bionic's dependency on the tzdata explicit.

Also stop building the obsolete three files, now bionic and libcore
both use the new single file.

Bug: 7012465
Change-Id: I1b9b49af7382c57b6cb8820c2275e6d4044b2bb6
857fed50cbf2d1a701a5a1a29e124f7e9fb945d5 02-Oct-2012 Elliott Hughes <enh@google.com> Fix MIPS build.

ARM and x86 have custom memcpy implementations, but MIPS relies on the generic
one, which I recently moved.

Change-Id: I9e49243f63b27a4123f2c6623d6286ec82d333c7
a89864a20b818621a1da10e88fda815334062f9f 02-Oct-2012 Elliott Hughes <enh@google.com> Move non-upstream code into the libc/bionic directory.

I'll need at least one more pass, because there's some upstream code
lurking in libc/bionic, but this is still a step in the right direction.

Change-Id: I55927315972da8327ae01c5240ed587db17e8462
31a1060a5a75d4f2aa3c3a5a7b948eb512d53387 01-Oct-2012 Elliott Hughes <enh@google.com> Upgrade seed48 too.

Missed this in 774c7f54ff375d71106283d42779b0cc5f238f87.

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

Also add basic unit tests.

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

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

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

Change-Id: I22ed82dd5904b9d7a3695535c04f502be3c27c5d
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
91875dcd6e17b7f3b251efe9b236b905ef414dde 25-Sep-2012 Elliott Hughes <enh@google.com> Fix tmpfile(3).

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

Change-Id: I88b7cf3f7ce8e5fa0b3fe678b7d1679a68ffffc9
cd587701c8590fb34bb69804b5d3b3c14d3d2508 26-Sep-2012 Nick Kralevich <nnk@google.com> FORTIFY_SOURCE: add umask check

Verify that the call to umask makes sense. While this wouldn't
have detected bug 7094213 (because the low order bits were all zero),
it might detect other similar bugs.

References: https://code.google.com/p/android-source-browsing/source/detail?r=acba45cc4b1f98f67fcdeda2f7c13ed57659b92a&repo=platform--libcore

Change-Id: I966a531d6b3cf8e1c5eacd69bd3cbec475b5fa58
5e58ea07d47c175abf8285ff67e3e9bc0b3a9e8e 12-Sep-2012 Nick Kralevich <nnk@google.com> libc: add ftw / nftw functions

Please see "man 3 ftw" for a description of the
ftw / nftw functions.

This code is taken directly from netbsd unmodified.

Change-Id: Ia4879ac57212b424adf5281b5e92858e216d0f14
b5f053b5a7deb084e7a052d527e0aa41339ae05c 08-Sep-2012 Irina Tirdea <irina.tirdea@intel.com> Make strerror(3) and strsignal(3) thread-safe, and add psignal(3) and psiginfo(3).

Change-Id: I426109db25e907980d6cb3a7a695796e45783b78
e007775f4b21f6b94078ed1d34b753435ba28fda 10-Sep-2012 Pavel Chupin <pavel.v.chupin@intel.com> Add libdl into libc_malloc_debug_leak build

Otherwise libc_malloc_debug_leak.so is failed to load runtime in x86
case

Change-Id: I8207ce06d1ec17b233f4e4fcfdd2b161673b4fa8
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
12949e5d3946cc5d5b53d52adf5a3b925bfca2c6 10-Sep-2012 Elliott Hughes <enh@google.com> Rename crtstart variables as crtbegin, to match reality.

No functional change, but it's confusing that the variable
names don't match the filenames.

Change-Id: I7109f917797be2f056e69fddb92e4a7306281813
cf464878efda7652b0a7eb636e45944eda6b6f2f 08-Sep-2012 Ying Wang <wangying@google.com> Generate header dependency makefiles for the crt*.o

Bug: 7127743
Change-Id: I606e5f7cd2b513f855a1fefd2b001abd365fc854
c4d1fecc105063e68a5090a6900b63d1b9a24287 28-Aug-2012 Elliott Hughes <enh@google.com> Clean up warnings in the malloc_debug_* files.

Also clean up cpplint.py-detected lint.

Change-Id: Ia18e89c4c6878764f8d7ed34b8247e7a8d8fe88b
2c344d3631eaad4bcfec821ea0e9f158c537a686 29-Aug-2012 Ian Rogers <irogers@google.com> Revert "Revert "Upgrade to dlmalloc 2.8.5.""

This reverts commit f72ee269274170cd46af2844a2fe88767fb6e43c.
f3cfcd869ded41d25c1f4f4e48e7c374a64f9583 21-Aug-2012 Ard Biesheuvel <ard.biesheuvel@gmail.com> ARM: make CRT_LEGACY_WORKAROUND work as intended

To properly support legacy ARM shared libraries, libc.so needs
to export the symbols __dso_handle and atexit, even though
these are now supplied by the crt startup code.

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

Change-Id: Id6c0e94dc65b7928324a5f0bad7eba6eb2f464b9
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@gmail.com>
561bf16be54de9a1387a2063a5609f925ccfb898 22-Aug-2012 Brian Carlstrom <bdc@google.com> Revert "Upgrade to dlmalloc 2.8.5."

This reverts commit 999089181ef60bb67e1a49f2cf6f4ec608a7caf8.
f72ee269274170cd46af2844a2fe88767fb6e43c 22-Aug-2012 Brian Carlstrom <bdc@google.com> Revert "Upgrade to dlmalloc 2.8.5."

This reverts commit 999089181ef60bb67e1a49f2cf6f4ec608a7caf8.
404e28ff8c3352a4fa290ae7769922db0172008e 22-Aug-2012 Ard Biesheuvel <ard.biesheuvel@gmail.com> hardening: remove pointless ARM __get_pc() function

Useful if you're trying to defeat ASLR, otherwise not
so much ...

Change-Id: I17ebb50bb490a3967db9c3038f049adafe2b8ea7
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@gmail.com>
999089181ef60bb67e1a49f2cf6f4ec608a7caf8 18-Aug-2012 Ian Rogers <irogers@google.com> Upgrade to dlmalloc 2.8.5.

Move dlmalloc code to upstream-dlmalloc to make pulling upstream changes
easier.
Declare pvalloc and malloc_usable_size routines present in malloc.h but with
missing implementations. Remove other functions from malloc.h that have
no implementation nor use in Android.

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

Bug: http://code.google.com/p/android/issues/detail?id=36085
Change-Id: I960a1b585887eb66176c61d29c5c61c239a4003f
22d366cc09383956dc264ed4641572e609392eee 08-Aug-2012 Jin Wei <wei.a.jin@intel.com> enable clone system call for x86

Add __bionic_clone function for x86, which will be
used for clone system call.

Change-Id: I889dc9bf4b7ebb4358476e17e6f3233e26491f4d
Signed-off-by: Jin Wei <wei.a.jin@intel.com>
Signed-off-by: Xiaokang Qin <xiaokang.qin@intel.com>
Signed-off-by: Beare, Bruce J <bruce.j.beare@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Author-tracking-BZ: 51414
cc213f871bf4c5329eb5eb7a80a0ce9d4a880af8 15-Aug-2012 Elliott Hughes <enh@google.com> Switch to the current NetBSD regex implementation.

Change-Id: If32b28dd85d6a7ab8957ab81d19fa4c0de9499d5
409302f0f9fce73ea4c82bbfd439041cd7923d34 14-Aug-2012 Elliott Hughes <enh@google.com> Switch to upstream NetBSD tdelete/tfind/tsearch.

tdestroy is a GNU extension, so that stays.

Change-Id: Iedebaff25ea7e92b1ab1dd4440da12b67b99aa40
3d2d448af1b16923f5a329b49bb8e658dbad8a06 14-Aug-2012 Elliott Hughes <enh@google.com> Fix nice...

...by switching to the NetBSD implementation.

Change-Id: I562b27b237a24ded95804035cc322c7bff12ff59
de727caee24df86c3052508aa213f7165168913a 14-Aug-2012 Elliott Hughes <enh@google.com> Clean up warnings in stubs.cpp.

Switch to C++ to get extra warnings, and format the code Google style.

Change-Id: Ifc0131bf297a6ee8a8a6b8d049a02518b0b1a4b7
ae5c64413bf72bc18d7fc81e1f5761824bc01f49 13-Aug-2012 Elliott Hughes <enh@google.com> Add dependencies on all the makefiles.

This should help prevent broken builds next time I'm messing with
assembler/compiler/linker flags...

Change-Id: I30f15a3ce3c3f3c60cad7bc59aaba9f42d792224
c97c5fc7880267fd835d22946a920bf370461cf2 11-Aug-2012 Ying Wang <wangying@google.com> Split out LOCAL_ASFLAGS.

Bug: 6967574
Change-Id: I5be50d582c1cb8075039b06292cf0745a996c3c4
a4c7933b49f1d43579f184167e79a5fb237bd206 07-Aug-2012 Raghu Gandham <raghu@mips.com> MIPS support to the libc Makefile

Change-Id: Ia1f3f545ca61a5abb235e99046cb3cdaf24d4205
f8b3a920a895a53b207017249080087d562bd0d2 10-Aug-2012 Elliott Hughes <enh@google.com> Revert "Revert "Switch to NetBSD's strxfrm(3).""

This reverts commit 8793e7c7d21a0434d1b5e63364c88b2b125a3d29,
and fixes the build by building upstream NetBSD source as a
separate library that's then swallowed whole into libc_common.

Change-Id: I6c9317d8c48b5ccaf85a7b185bc07fb31176ff97
8793e7c7d21a0434d1b5e63364c88b2b125a3d29 10-Aug-2012 Elliott Hughes <enh@google.com> Revert "Switch to NetBSD's strxfrm(3)."

This reverts commit be1d78b0dc899a732c0e9d7515d3023e8004e368

Change-Id: I11a95db474796f3da004f27652b081d5ba4ec9b4
be1d78b0dc899a732c0e9d7515d3023e8004e368 10-Aug-2012 Elliott Hughes <enh@google.com> Switch to NetBSD's strxfrm(3).

There were two bugs in our implementation. Intel found one, but another
remainined, and tracking upstream is the way forward for functions where
we add no value.

Change-Id: Ida9bac0293fb2c4cbc942b1e0515ee0477c6538b
76be660aae0911467c51dc3f86a4f8d7fed5b332 08-Aug-2012 Elliott Hughes <enh@google.com> Clean up libc/Android.mk a bit after the crtbrand changes.

Change-Id: Icfb95fffe70967418cd93da8cbeae22dcd68f8c9
405b8029a6888f386adf3512113a33546141d1c8 26-Jul-2012 Raghu Gandham <raghu@mips.com> MIPS support for libc.

Change-Id: I2864dea04b3faf2d919165dcaa600af5b16c41c8
Signed-off-by: Chris Dearman <chris@mips.com>
Signed-off-by: Raghu Gandham <raghu@mips.com>
ea8fad11d980d55ebd2bcf2302f3f1f742b6351c 31-Jul-2012 Michael Hope <michael.hope@linaro.org> Add a .note.android.ident section to Android ELF binaries.

This allows debugging tools to know they are working with Android
binaries and adapt accordingly.

Signed-off-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Signed-off-by: Michael Hope <michael.hope@linaro.org>

Change-Id: Ic906992fcad61c028bb765821637a3e1333bf52b
fc0725ec5cc51053c06bf2c67755a5a57a5da621 28-Jul-2012 Shih-wei Liao <sliao@google.com> Install crt(begin|end)_so.o to target library path.

BUG=6886348.

Change-Id: I176b2c4963d9731b06d10d4e0b92c010a0006b59
260bf8cfe00f83bc579dfe81c78b75bd9973f051 13-Jul-2012 Nick Kralevich <nnk@google.com> FORTIFY_SOURCE: strlen check.

This test is designed to detect code such as:

int main() {
char buf[10];
memcpy(buf, "1234567890", sizeof(buf));
size_t len = strlen(buf); // segfault here with _FORTIFY_SOURCE
printf("%d\n", len);
return 0;
}

or anytime strlen reads beyond an object boundary. This should
help address memory leakage vulnerabilities and make other
unrelated vulnerabilities harder to exploit.

Change-Id: I354b425be7bef4713c85f6bab0e9738445e00182
6334c662cae4cd9b61f5f3185048b0cd3633dad7 10-Jul-2012 Nick Kralevich <nnk@google.com> Don't use -fstack-protector on ssp.c

libc's stack protector initialization routine (__guard_setup)
is in bionic/ssp.c. This code deliberately modifies the stack
canary. This code should never be compiled with -fstack-protector-all
otherwise it will crash (mismatched canary value).

Force bionic/ssp.c to be compiled with -fno-stack-protector

Change-Id: Ib95a5736e4bafe1a460d6b4e522ca660b417d8d6
965dbc6405aa2c3170270cfc53a8d4416444fddb 03-Jul-2012 Nick Kralevich <nnk@google.com> FORTIFY_SOURCE: add fgets support.

Change-Id: I8c3410a90c71a3336c4ac8581618fa9330edf5e3
8df49ad2467ec2d48f94a925162185c34bf6e68b 14-Jun-2012 Nick Kralevich <nnk@google.com> FORTIFY_SOURCE: add strlcpy / strlcat support

Add strlcpy / strlcat support to FORTIFY_SOURCE. This allows
us to do consistency checks on to ensure we don't overflow buffers
when the compiler is able to tell us the size of the buffer we're
dealing with.

Unlike previous changes, this change DOES NOT use the compiler's
builtin support. Instead, we do everything the compiler would
normally do.

Change-Id: I47c099a911382452eafd711f8e9bfe7c2d0a0d22
9b549c39c938f54680f282c21e6885f53254bfb0 13-Jun-2012 Nick Kralevich <nnk@google.com> FORTIFY_SOURCE: add sprintf / vsprintf support

sprintf FORTIFY_SOURCE protections are not available
on clang.

Also add various __attribute__s to stdio functions.

Change-Id: I936d1f9e55fe53a68885c4524b7b59e68fed218d
cffdf6693ffb50d2a1258d955a162bca83038f25 12-Jun-2012 Nick Kralevich <nnk@google.com> FORTIFY_SOURCE: add snprintf, vsnprintf

Add _FORTIFY_SOURCE support for snprintf, vsnprintf

At this time, we opt out of these protections for clang, as clang
does not implement __builtin_va_arg_pack().

http://clang.llvm.org/docs/UsersManual.html#c_unimpl_gcc

Change-Id: I73ebe5ec8dad1dca8898a76d6afb693a25f75375
76656afc6dd069fcfda5768e6e54bb85e4e99942 08-Jun-2012 Nick Kralevich <nnk@google.com> _FORTIFY_SOURCE: check for integer overflows

Ensure that strcat / strncat check for integer overflows
when computing the length of the resulting string.

Change-Id: Ib806ad33a0d3b50876f384bc17787a28f0dddc37
71a18dd435e96564539b5af71b8ea5093a2109a1 07-Jun-2012 Nick Kralevich <nnk@google.com> _FORTIFY_SOURCE: add memset / bzero support

Add _FORTIFY_SOURCE support for the following functions:

* memset
* bzero

Move the __BIONIC_FORTIFY_INLINE definition to cdefs.h so it
can be used from multiple header files.

Change-Id: Iead4d5e35de6ec97786d58ee12573f9b11135bb7
470631ed79538ce912edb94505dee3e24af8db89 06-Jun-2012 Elliott Hughes <enh@google.com> Give the timer_create SIGEV_THREAD helper threads sensible names.

Bug: 6609676
Change-Id: I286b197c75beee4d9930b0973f2d7dd47c14e91c
0a2301598c207fd1b50015984942fee5e8511593 05-Jun-2012 Nick Kralevich <nnk@google.com> libc: implement some FORTIFY_SOURCE functions

Add initial support for -D_FORTIFY_SOURCE to bionic for the
following functions:

* memcpy
* memmove
* strcpy
* strcat
* strncpy
* strncat

This change adds a new version of the above functions which passes
the size of the destination buffer to __builtin___*_chk.

If the compiler can determine, at compile time, that the destination
buffer is large enough, or the destination buffer can point to an object
of unknown size, then the check call is bypassed.

If the compiler can't make a compile time decision, then it calls
the __*_chk() function, which does a runtime buffer size check

These options are only enabled if the code is compiled with
-D_FORTIFY_SOURCE=1 or 2, and only when optimizations are enabled.

Please see
* http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
* http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html

for additional details on FORTIFY_SOURCE.

Testing: Compiled the entire Android tree with -D_FORTIFY_SOURCE=1,
and verified that everything appears to be working properly.
Also created a test buffer overflow, and verified that it was
caught by this change.

Change-Id: I4fddb445bafe92b16845b22458d72e6dedd24fbc
e1dd3c287ba836281de0197670018bd9bbfbd62b 29-May-2012 Iliyan Malchev <malchev@google.com> bionic: import heaptracker as chk_malloc

This patch is a rewrite of libc.debug.malloc = 10 (chk_malloc). It provides
the same features as the original (poison freed memory, detect heap overruns
and underruns), except that it provides more debugging information whenever it
detects a problem.

In addition to the original features, the new chk_malloc() implementation
detects multiple frees within a given range of the last N allocations, N being
configurable via the system property libc.debug.malloc.backlog.

Finally, this patch keeps track of all outstanding memory allocations. On
program exit, we walk that list and report each outstanding allocation.

(There is support (not enabled) for a scanner thread periodically walks over
the list of outstanding allocations as well as the backlog of recently-freed
allocations, checking for heap-usage errors.)

Feature overview:

1) memory leaks
2) multiple frees
3) use after free
4) overrun

Implementation:

-- for each allocation, there is a:
1) stack trace at the time the allocation is made
2) if the memory is freed, there is also a stack trace at the point
3) a front and rear guard (fence)
4) the stack traces are kept together with the allocation

-- the following lists and maintained

1) all outstanding memory allocations
3) a backlog of allocations what are freed; when you call free(), instead of
actually freed, the allocation is moved to this backlog;
4) when the backlog of allocations gets full, the oldest entry gets evicted
from it; at that point, the allocation is checked for overruns or
use-after-free errors, and then actually freed.
5) when the program exits, the list of outstanding allocations and the
backlog are inspected for errors, then freed;

To use this, set the following system properties before running the process or
processes you want to inspect:

libc.malloc.debug.backlog # defaults to 100
libc.malloc.debug 10

When a problem is detected, you will see the following on logcat for a multiple
free:

E/libc ( 7233): +++ ALLOCATION 0x404b9278 SIZE 10 BYTES MULTIPLY FREED!
E/libc ( 7233): +++ ALLOCATION 0x404b9278 SIZE 10 ALLOCATED HERE:
E/libc ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc ( 7233): #00 pc 0000c35a /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #01 pc 0000c658 /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #02 pc 00016d80 /system/lib/libc.so
E/libc ( 7233): #03 pc 4009647c /system/bin/malloctest
E/libc ( 7233): #04 pc 00016f24 /system/lib/libc.so
E/libc ( 7233): +++ ALLOCATION 0x404b9278 SIZE 10 FIRST FREED HERE:
E/libc ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc ( 7233): #00 pc 0000c35a /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #01 pc 0000c7d2 /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #02 pc 00016d94 /system/lib/libc.so
E/libc ( 7233): #03 pc 40096490 /system/bin/malloctest
E/libc ( 7233): #04 pc 00016f24 /system/lib/libc.so
E/libc ( 7233): +++ ALLOCATION 0x404b9278 SIZE 10 NOW BEING FREED HERE:
E/libc ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc ( 7233): #00 pc 0000c35a /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #01 pc 0000c6ac /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #02 pc 00016d94 /system/lib/libc.so
E/libc ( 7233): #03 pc 400964a0 /system/bin/malloctest
E/libc ( 7233): #04 pc 00016f24 /system/lib/libc.so

The following for a heap overrun and underrun:

E/libc ( 7233): +++ REAR GUARD MISMATCH [10, 11)
E/libc ( 7233): +++ ALLOCATION 0x404b9198 SIZE 10 HAS A CORRUPTED REAR GUARD
E/libc ( 7233): +++ ALLOCATION 0x404b9198 SIZE 10 ALLOCATED HERE:
E/libc ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc ( 7233): #00 pc 0000c35a /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #01 pc 0000c658 /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #02 pc 00016d80 /system/lib/libc.so
E/libc ( 7233): #03 pc 40096438 /system/bin/malloctest
E/libc ( 7233): #04 pc 00016f24 /system/lib/libc.so
E/libc ( 7233): +++ ALLOCATION 0x404b9198 SIZE 10 FREED HERE:
E/libc ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc ( 7233): #00 pc 0000c35a /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #01 pc 0000c7d2 /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #02 pc 00016d94 /system/lib/libc.so
E/libc ( 7233): #03 pc 40096462 /system/bin/malloctest
E/libc ( 7233): #04 pc 00016f24 /system/lib/libc.so
E/libc ( 7233): +++ ALLOCATION 0x404b9358 SIZE 10 HAS A CORRUPTED FRONT GUARD
E/libc ( 7233): +++ ALLOCATION 0x404b9358 SIZE 10 ALLOCATED HERE:
E/libc ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc ( 7233): #00 pc 0000c35a /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #01 pc 0000c658 /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #02 pc 00016d80 /system/lib/libc.so
E/libc ( 7233): #03 pc 400964ba /system/bin/malloctest
E/libc ( 7233): #04 pc 00016f24 /system/lib/libc.so
E/libc ( 7233): +++ ALLOCATION 0x404b9358 SIZE 10 FREED HERE:
E/libc ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc ( 7233): #00 pc 0000c35a /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #01 pc 0000c7d2 /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #02 pc 00016d94 /system/lib/libc.so
E/libc ( 7233): #03 pc 400964e4 /system/bin/malloctest
E/libc ( 7233): #04 pc 00016f24 /system/lib/libc.so

The following for a memory leak:

E/libc ( 7233): +++ THERE ARE 1 LEAKED ALLOCATIONS
E/libc ( 7233): +++ DELETING 4096 BYTES OF LEAKED MEMORY AT 0x404b95e8 (1 REMAINING)
E/libc ( 7233): +++ ALLOCATION 0x404b95e8 SIZE 4096 ALLOCATED HERE:
E/libc ( 7233): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
E/libc ( 7233): #00 pc 0000c35a /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #01 pc 0000c658 /system/lib/libc_malloc_debug_leak.so
E/libc ( 7233): #02 pc 00016d80 /system/lib/libc.so
E/libc ( 7233): #03 pc 0001bc94 /system/lib/libc.so
E/libc ( 7233): #04 pc 0001edf6 /system/lib/libc.so
E/libc ( 7233): #05 pc 0001b80a /system/lib/libc.so
E/libc ( 7233): #06 pc 0001c086 /system/lib/libc.so
E/libc ( 7233): #07 pc 40096402 /system/bin/malloctest
E/libc ( 7233): #08 pc 00016f24 /system/lib/libc.so

Change-Id: Ic440e9d05a01e2ea86b25e8998714e88bc2d16e0
Signed-off-by: Iliyan Malchev <malchev@google.com>
9d40326830c2bd407427889c554adeb915ee6b4a 31-May-2012 Nick Kralevich <nnk@google.com> arm: rewrite crtbegin* as C files.

Rewrite
crtbegin.S -> crtbegin.c
crtbegin_so.S -> crtbegin_so.c

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

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

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

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

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

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

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

Change-Id: Ib9f98107c0eeabcb606e1ddc7ed7fc4eba01c9c4
83a73d1afe972014f6c8ff2520fe6d3357421f87 30-May-2012 Nick Kralevich <nnk@google.com> crtbegin: eliminate duplicate code

crtbegin_dynamic and crtbegin_static are essentially identical,
minus a few trivial differences (comments and whitespace).

Eliminate duplicates.

Change-Id: Ic9fae6bc9695004974493b53bfc07cd3bb904480
fc9e525fe07846c1efa23235a59575f8dad69c53 16-May-2012 Ying Wang <wangying@google.com> Rename the misleading var name TARGET_OUT_STATIC_LIBRARIES

TARGET_OUT_STATIC_LIBRARIES is actually the same as
TARGET_OUT_INTERMEDIATE_LIBRARIES.

Change-Id: I11ac35256031d461d20156cd4c19ed7eae781d22
08e72d0161e39e99ff1003bf1ce894f37d7b7eb4 07-May-2012 Prajakta Gudadhe <pgudadhe@nvidia.com> bionic: add support for non-NEON memcpy() on NEON SoCs

Some SoCs that support NEON nevertheless perform better with a non-NEON than a
NEON memcpy(). This patch adds build variable ARCH_ARM_USE_NON_NEON_MEMCPY,
which can be set in BoardConfig.mk. When ARCH_ARM_USE_NON_NEON_MEMCPY is
defined, we compile in the non-NEON optimized memcpy() even if the SoC supports
NEON.

Change-Id: Ia0e5bee6bad5880ffc5ff8f34a1382d567546cf9
2fd81ef71c10aecf6583facdd79f8f60f3eed678 19-Nov-2011 Jack Ren <jack.ren@intel.com> bionic: allow the board to customize MALLOC_ALIGNMENT

Currently the dlmalloc allocates the memory with 8-byte alignment.
According to the com.aurorasoftworks.quadrant.ui.professional benchmark data:
We can get much better memory performance if we change it to be 16-byte aligned.
For example, On Nexus-S:
8-byte aligned :
1378 1070 1142 1665 1765 1163 1179 1263 1404 avg: 1336.555555556
16-byte aligned:
1691 1731 1780 1691 1671 1678 1802 1758 1780 avg: 1731.333333333
gain: 29.53%

That patch provides flexibity to customize the MALLOC_ALIGNMENT from the
board config.The macro MALLOC_ALIGNMENT defaults to 8.
To change it, please define BOARD_MALLOC_ALIGNMENT in the BoardConfig.mk:
BOARD_MALLOC_ALIGNMENT := <whatever>

Change-Id: I8da0376944a0bbcef1d0fc026bfb6d9125db9739
Signed-off-by: Jin Wei <wei.a.jin@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Signed-off-by: Beare, Bruce J <bruce.j.beare@intel.com>
eda7be454d6ff8689392442223335c6558bea932 08-May-2012 Ben Cheng <bccheng@google.com> Implement the "abort" stub in assembly for ARM.

So that we can always get the full stack trace regardless of gcc's handling
of the "noreturn" attribute associated with abort().

(Cherry pick of Id264a5167e7cabbf11515fbc48f5469c527e34d4.)

Bug: 6455193

Conflicts:

libc/Android.mk

Change-Id: I568fc5303fd1d747075ca933355f914122f94dac
08b51e2c091d036c124259ae59eb7be6bbe346af 08-May-2012 Ben Cheng <bccheng@google.com> Implement the "abort" stub in assembly for ARM.

So that we can always get the full stack trace regardless of gcc's handling
of the "noreturn" attribute associated with abort().

[cherry-picked from master]

BUG:6455193
Change-Id: I0102355f5bf20e636d3feab9d1424495f38e39e2
017f438534068f48277fe6f7f7234e6f24ae5065 08-May-2012 Ben Cheng <bccheng@google.com> Implement the "abort" stub in assembly for ARM.

So that we can always get the full stack trace regardless of gcc's handling
of the "noreturn" attribute associated with abort().

BUG:6455193
Change-Id: Id264a5167e7cabbf11515fbc48f5469c527e34d4
a2758f19cee0a8daf3194d8c88eeb4d078000a08 07-May-2012 Nick Kralevich <nnk@google.com> libc: stop using the custom linker script

stop using the custom linker script. It prevents relro from
working on libc.

This reverts commit b091dd9bf27a9132c4ac9da55f2f4a87ffe3b59f.
fe6338da9168330d44b409b2ee36103e8bfe6697 15-Sep-2010 Henrik Smiding <henrik.smiding@stericsson.com> Adjust memcpy for ARM Cortex A9 cache line size

ARM Cortex A8 use 64 bytes and ARM Cortex A9 use 32 bytes cache line
size.

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

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

Change-Id: I8a55946bfb074e6ec0a14805ed65f73fcd0984a3
Signed-off-by: Christian Bejram <christian.bejram@stericsson.com>
b091dd9bf27a9132c4ac9da55f2f4a87ffe3b59f 26-Apr-2012 Nick Kralevich <nnk@google.com> libc: continue to use Android's custom linker script

By default, Android no longer compiles code using it's custom
linker script /build/core/armelf.xsc. However, this causes
problems for libc. Certain programs linked using older versions
of GOLD expect libc.so to export __exidx_start and __exidx_end.
Removing the custom linker script causes libc.so not to export
those symbols.

For now, continue using the old linker script, until we can
figure out a better solution.

Change-Id: Iaf002afd63a58b848818da24e5a4525620dc4d74
03273f8fc0a7ac2b54fa2c983d4a647580e34458 11-Apr-2012 Kenny Root <kroot@google.com> __on_dlclose should be aligned

Marking segments read-only was pushing the alignment of __on_dlclose by
2 bytes making it unaligned. This change makes sure the ARM code is
aligned to the 4 byte boundary.

Bug: 6313309
Change-Id: Ic2bf475e120dd61225ec19e5d8a9a8b1d0b7f081
21eab513e7eec280a7a8bcb9482a1a8b61e59442 14-Mar-2012 Ben Cheng <bccheng@google.com> New additions/bug fixes required/found when porting perf.

New functions:
tfind
tsearch
tdelete
twalk
tdestroy (GNU extension)

Bug fix: the current implementation for realpath would crash
if the second argument (resolved_path) is NULL.

New headers:
ar.h
search.h

Change-Id: Ib6c1e42fc186a6d597a6e5a9692b16acaa155804
70b1668a76d3b719ae690903ea790fda964a5458 30-Jan-2012 David 'Digit' Turner <digit@google.com> remove obsolete SuperH support

We don't have a toolchain anymore, we don't have working original
kernel headers, and nobody is maintaining this so there is really
no point in keeping this here. Details of the patch:

- removed code paths from Android.mk files related to the SuperH
architecture ("sh")

- removed libc/arch-sh, linker/arch-sh, libc/kernel/arch-sh

- simplified libc/SYSCALLS.TXT

- simplified the scripts in libc/tools/ and libc/kernel/tools

Change-Id: I26b0e1422bdc347489e4573e2fbec0e402f75560

Signed-off-by: David 'Digit' Turner <digit@android.com>
a5cb76bca00b1ce44a04687fb179809c12ea9cd3 14-Dec-2011 David 'Digit' Turner <digit@google.com> libc: x86: Use SSE2 or SSSE3 optimized routines when possible.

This patch uses the new hardware feature macros for x86 to define
various compile-time macros used to make the C library use
SSE2 and/or SSSE3 optimized memory functions for target CPUs
that support these features.

Note that previously, we relied on the macros being defined by
build/core/combo/TARGET_linux-x86.mk, but this is no longer the
case.

Change-Id: Ieae5ff5284c0c839bc920953fb6b91d2f2633afc
7c0c3793722aea293c45921ef50e4adcdf9645ce 06-Sep-2011 Mathias Agopian <mathias.agopian@gmail.com> implement pthread mutex deadlock detection

this works by building a directed graph of acquired
pthread mutexes and making sure there are no loops in
that graph.

this feature is enabled with:

setprop debug.libc.pthread 1

when a potential deadlock is detected, a large warning is
output to the log with appropriate back traces.

currently disabled at compile-time. set PTHREAD_DEBUG_ENABLED=1
to enable.

Change-Id: I916eed2319599e8aaf8f229d3f18a8ddbec3aa8a
af96d4dadc3f3d8466dbbeaf3a816e6871715fbc 09-Dec-2011 Bruce Beare <bruce.j.beare@intel.com> x86: libc may use the gcc flags from TARGET_linux-x86.mk

Change-Id: Iaf4d864d4b6fe388bd3c2d7c4d7d6e42aebb0d35
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
10c8ce59a40a1d8ae8f49145eca365b364aabe58 19-Nov-2011 Jeff Brown <jeffbrown@google.com> Add tgkill syscall.

Use tgkill instead of tkill to implement pthread_kill.
This is safer in the event that the thread has already terminated
and its id has been reused by a different process.

Change-Id: Ied715e11d7eadeceead79f33db5e2b5722954ac9
0fec6b9d88ee5a9e359b2208038f9806c0804538 16-Nov-2011 David 'Digit' Turner <digit@google.com> libc: provide atomic operations will full barriers for NDK apps.

__atomic_cmpxchg and other related atomic operations did not
provide memory barriers, which can be a problem for non-platform
code that links against them when it runs on multi-core devices.

This patch does two things to fix this:

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

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

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

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

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

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

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

Change-Id: I752a594475090cf37fa926bb38209c2175dda539
afb0167ad915f3f43c3194ed787199187f1bb56f 20-Jun-2011 Bruce Beare <bruce.j.beare@intel.com> Enable functional DSO object destruction

Unfortunately, legacy .so files for ARM don't have a correct crtbegin file.
Consequently, we have to grandfather the old __dso_handle behaviour.
Add some ifdefs for ARM to allow it to use the old code until we can work
out a transition.

Change-Id: I6a28f368267d792c94e1d985d8344023bc632f6f
Author: H.J. Lu <hongjiu.lu@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
a0aec0bd3083280dcba0c3aaba39602425228e2a 04-May-2011 Bruce Beare <bruce.j.beare@intel.com> x86: Enable -fstack-protector

Change-Id: Iff9e3a3ba0e2d0faa7c6d98154aa5be0cc8a6c50
Orig-Change-Id: Ib69514c3afcb4c1f5e5f3f8cd91acfd145a0866c
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
832a86eaba56dcf8066e4b96df12738a9dff7053 31-May-2011 Bruce Beare <bruce.j.beare@intel.com> Update ATOM string routines to latest

Orig-Change-Id: I22a600e7f172681cfd38ff73a64e3fd07b284959
Signed-off-by: Lu, Hongjiu <hongjiu.lu@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
88bb394c0d2cb96a85acb43e25cacfe8235ac1af 08-Jul-2010 Bruce Beare <brucex.j.beare@intel.com> Fix undefined reference to dl_iterate_phdr for x86

Orig-Change-Id: I22410b27939e8f54da932d7a1104102550c4685f
Signed-off-by: Bruce Beare <brucex.j.beare@intel.com>
c51871d4b22425b32ec40c060c39d6b6fa4406f6 06-Jul-2011 David 'Digit' Turner <digit@android.com> Really fix the build.

libcutils/mspace.c includes libc/bionic/dlmalloc.c, we need to
take care of the fact that any internal C library function cannot
be used from it.

Change-Id: I0bc81ae090b7ac2d464f26b97fc6b94a08cdad9c
2d2dbd30243f4ffd1e0a10ade989e25d29f7f45c 25-Jun-2011 David 'Digit' Turner <digit@google.com> x86: fix full_x86-eng build

The latest merge conflict resolution worked only for ARM, but not for x86
Both ARM and x86 builds have been tested with this fix.

Change-Id: I4ec1f1b0ea32fa86e7e2515b221133473d6550a3
NOTE: Care has been taken to not change the compiler flags for ARM builds.
In particular, when building crtbegin_so.so, the -fPIC flag is only
used for x86 (previous reports indicate that it breaks the ARM
build at runtime for obscure reasons).
39640842823ba4cd42bd11514c0da39aa939519f 20-Jun-2011 Bruce Beare <bruce.j.beare@intel.com> Enable functional DSO object destruction

Unfortunately, legacy .so files for ARM don't have a correct crtbegin file.
Consequently, we have to grandfather the old __dso_handle behaviour.
Add some ifdefs for ARM to allow it to use the old code until we can work
out a transition.

Change-Id: I6a28f368267d792c94e1d985d8344023bc632f6f
Author: H.J. Lu <hongjiu.lu@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
a903811819c06e4d6e9e27fcc9db3ab5459009bc 07-Jun-2011 Martijn Coenen <maco@google.com> Revert "x86: Enable -fstack-protector"

This reverts commit e0b4844a20ffd022a568abb4203b3f7c759c7ff5,
causes netd to crash.
e0b4844a20ffd022a568abb4203b3f7c759c7ff5 04-May-2011 Bruce Beare <bruce.j.beare@intel.com> x86: Enable -fstack-protector

Change-Id: Ib69514c3afcb4c1f5e5f3f8cd91acfd145a0866c
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
f50e9be5930a08fa825b0c23353c802e11369b14 20-Apr-2011 Jim Huang <jim.huang@linaro.org> bionic: Add ARM optimized strcmp()

Reference results of the experiments on TI OMAP3430 at 600 MHz

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

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

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

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

Change-Id: Ib0d5755e1eb9adb07d80ef0252f57a5c4c57a425
Signed-off-by: Jim Huang <jserv@0xlab.org>
368070454b1349d1fcf29a5d1eb51c869fb538f6 14-Mar-2011 Iliyan Malchev <malchev@google.com> bionic: remove LOCAL_PRELINK_MODULE

Change-Id: Iad65ae18446b20d2aace7b8fe19b1a032b616e9c
Signed-off-by: Iliyan Malchev <malchev@google.com>
81a844a0fc3c6850afc6cf8580e0d9c10267a879 04-Feb-2011 Andy McFadden <fadden@android.com> Added _memmove_words

Added a memmove() variant for Dalvik's System.arraycopy()
implementation. It guarantees 16-bit or 32-bit atomicity depending
on the alignment of the arguments.

Bug 3398352

(cherry-pick from master)

Change-Id: I5e64de1c76971ba234bf2dd05477ba390e0412a4
4ce737f5df6bda362b45ca2a9d72d0aad2d5a58f 04-Feb-2011 Andy McFadden <fadden@android.com> Added _memmove_words

Added a memmove() variant for Dalvik's System.arraycopy()
implementation. It guarantees 16-bit or 32-bit atomicity depending
on the alignment of the arguments.

Bug 3398352

Change-Id: Ie7bd246305ef0ff8290513663327c5b81680368d
18635d9c173120f6f97dd9b035b6f9a1ebfcd1a3 14-Dec-2010 Chih-Wei Huang <cwhuang@linux.org.tw> android-x86: add sigsetjmp.S

It adds two functions sigsetjmp and siglongjmp
that fix compiling errors in bluetooth and mksh.

Copy directly from sigsetjmp.S of OpenBSD.

Change-Id: I4696f82ee6f85d1c93cbdd3c9e40f4917d50f3a6
95d751feacdb58d3fbc36f3f21a895a3ec2f065b 16-Dec-2010 David 'Digit' Turner <digit@google.com> libc: Add ftruncate64 and improve 64-bit parameter syscall handling.

This patch improves the handling of 64-bit parameters in syscalls on ARM.
The ARM EABI mandates that 64-bit quantities be passed in even/odd register
pairs, which requires special treatment.

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

Also add ftruncate64() to <unistd.h>

Change-Id: I407e2fd223ba0093dd2d0b04c6152fadfc9ce3ef

Bug 3107933
72e6fd42421dca80fb2776a9185c186d4a04e5f7 03-Dec-2010 David 'Digit' Turner <digit@google.com> <sched.h>: Add sched_getcpu() and cpu_set_t

This adds the cpu_set_t type definition and related functions
and macros used to handle CPU thread affinity.

sched_getcpu()
sched_setaffinity()
sched_getaffinity()

Change-Id: If382ecafde8926341a88478062b275553645065b
72e64e08697cc2b3d66397c8b6d34965dd2a7338 24-Nov-2010 Kenny Root <kroot@google.com> Add support for pread64/pwrite64

64-bit pread() and pwrite() is needed for ZipFileRO to be able to read
ludicrously large ZIP files just in case someone is crazy enough to do
it.

Also fix a license header that was apparently mangled.

Change-Id: I6819ef8b36e46b63b40749c95717b1ecf9307033
73c04b32691cb344cb60289a646ded8fc551d09e 10-Aug-2010 Jim Huang <jserv@0xlab.org> bionic: Add ARM optimized strcpy()

Reference results of the experiments on Qualcomm MSM7x25 (524MHz):

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

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

The work was derived from ARM Ltd.

Change-Id: I906ac53bb7a7285e14693c77d3ce8d4ed6f98bfd
70478100d5967f528e6514a42f98a76bb85b7e28 27-Sep-2010 Jim Huang <jserv@0xlab.org> Remove duplicated _rand48 implementation. Use stdlib version instead

Originally, there are _rand48 (in libc/bionic/_rand48.c) and __rand48
(in libc/stdlib/_rand48.c) implemented in bionic. Besides the naming,
the functionality is identical. This patch removes the duplicated
_rand48. Also, drand48 and erand48 are modified accordingly.

Change-Id: Ie5761a0a97f45df8538222a77edacb7c3e0125d7
124a542aa4d78040176f65b28f4958540b5d89aa 11-Oct-2010 Bruce Beare <brucex.j.beare@intel.com> Update ATOM string routines to latest

Change-Id: I22a600e7f172681cfd38ff73a64e3fd07b284959
Signed-off-by: Lu, Hongjiu <hongjiu.lu@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
defd162212de3789d2268a1f3339c2a6097fa825 26-Sep-2010 David 'Digit' Turner <digit@google.com> libc: add <sys/eventfd.h> and corresponding implementations.

Change-Id: Ide040884c456190226e580513099fdb8377e015b
cb99ab98c99291a6c90043009ab8d64ec8058f9d 10-Sep-2010 Kenny Root <kroot@google.com> Add wmemcmp to Android.mk

Change-Id: I9dc96d72b2becdd31981b4d176a13358aef6dcb9
6a51defa034a1c033ed01f7de444c0a4fc615249 27-Aug-2010 David 'Digit' Turner <digit@google.com> Fix __get_tls() in static C library to use kernel helpers.

This is needed to fix gdbserver's handling of threaded programs,
among other things.

Change-Id: I823387c602cef9891532da946a01db14be780ab0
41e533af4a2720c1dc228ba40b6582ca53085c3a 09-Jun-2010 Szymon Jakubczak <szym@google.com> added missing ether_aton and ether_ntoa

Change-Id: I32ee448abde4d5693d393030ed77ddc6d2ad1dfc
3871d57ba581236142c9bf2f8be2d34cce7c5829 18-Aug-2010 Jean-Baptiste Queru <jbq@google.com> Revert "added missing ether_aton and ether_ntoa"

This reverts commit 4032c1e2dfcc99613fe3e509a8153191e35aec12.
18c5bcc66a9a7b2178dcdcf04a0716958798ab81 30-Jul-2010 Dima Zavin <dima@android.com> Revert "Set SA_RESTORER in sigaction()"

This reverts commit e4fa46e75cd0d433b5c6c064720ed7e195cba7c8.
26c15a8eb9a445527d679935b86960211bbb85a8 26-Jul-2010 Chih-Wei Huang <cwhuang@linux.org.tw> Move the atom optimization flags into TARGET_linux-x86.mk.

Setting libc_crt_target_cflags to be non-recursive is necessary.

Change-Id: I5310d86e705f23da126c21ecb33a97a074da584a
4f086aeb4aa06e13079b7fec71a8178ceeacf318 25-Jun-2010 Matt Fischer <matt.fischer@garmin.com> Implemented pthread_atfork()

Change-Id: Ie6c0bf593315d3507b3c4a6c8903a74a1fa053db
ab8b54101eed0a4b92ebf8fa6994cd1b4f22d8f4 09-Jul-2010 David 'Digit' Turner <digit@google.com> libc: fix fstatfs() implementation.

The syscall expects the size of the buffer as the second argument.

Change-Id: I99ede2fec7fcd385ca03ff022c2cffa4297bea8d
aa46fa24035f3ab020f9a7abd86c25ae2196bb32 08-Jul-2010 Bruce Beare <brucex.j.beare@intel.com> Fix undefined reference to dl_iterate_phdr for x86

Change-Id: I22410b27939e8f54da932d7a1104102550c4685f
Signed-off-by: Bruce Beare <brucex.j.beare@intel.com>
3b43f87d2949a340e2c19cb735af7727157d8274 02-Jul-2010 David 'Digit' Turner <digit@android.com> Allow dlclose() to properly call static C++ destructors.

With this patch _and_ an upcoming build/ patch, the destruction
of static C++ objects contained in shared libraries will happen
properly when dlclose() is called.

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

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

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

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

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

Change-Id: I99cd801375bbaef0581175893d1aa0943211b9bc
50ace4fec5e8cb5afcbc656a4556fa528adfd760 17-Jun-2010 David 'Digit' Turner <digit@google.com> Remove compiler warnings when building Bionic.

Also add missing declarations to misc. functions.
Fix clearerr() implementation (previous was broken).
Handle feature test macros like _POSIX_C_SOURCE properly.

Change-Id: Icdc973a6b9d550a166fc2545f727ea837fe800c4
6a9b888d7c4b246f6f66360789c72b754ff85021 18-Jun-2010 David 'Digit' Turner <digit@google.com> Allow static C++ destructors to be properly called on dlclose().

With this patch, _and_ an upcoming build/ patch, the destruction
of static C++ objects contained in shared libraries will happen
properly when dlclose() is called.

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

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

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

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

Change-Id: Ie771aa204e3acbdf02fd30ebd4150373a1398f39
NOTE: The NDK will need to be modified to enable this feature in
the shared libraries that are generated through it.
70465614e14a87f547cdd1b82b0b270b87d215c1 16-Jun-2010 Kristian Monsen <kristianm@google.com> Just link fixes for b 2763938.

Added wcsxfrm.c and wmemcmp.c to the src files in Android.mk and removed wcsxfrm from wchar.c

Change-Id: Iab9b45cf78c27880d2941c360340a7af6b8964fe
3527fd6f0df794207215790321824b7844cc712d 15-Jun-2010 David 'Digit' Turner <digit@google.com> wchar.h: improve wchar_t support in Bionic

Change-Id: Iffd41046fd0933c66542abf7627a1569522dfcb2
4032c1e2dfcc99613fe3e509a8153191e35aec12 09-Jun-2010 Szymon Jakubczak <szym@google.com> added missing ether_aton and ether_ntoa

Change-Id: I32ee448abde4d5693d393030ed77ddc6d2ad1dfc
7c99c1856fce65c0394cd578c2a8ed37da2f288d 28-May-2010 Andy McFadden <fadden@android.com> Atomic/SMP update, part 3. (manual merge)

Update ARM atomic ops to use LDREX/STREX. Stripped out #if 0 chunk.

Insert explicit memory barriers in pthread and semaphore code.

For bug 2721865.

Change-Id: I595cc8e5a8d1e4906b6641115e46208a7e9e755a
fcd00ebbdf3e7f4e1e7782a65ae10fb0fc03a1aa 28-May-2010 Andy McFadden <fadden@android.com> Atomic/SMP update, part 3.

Update ARM atomic ops to use LDREX/STREX. Stripped out #if 0 chunk.

Insert explicit memory barriers in pthread and semaphore code.

For bug 2721865.

Change-Id: I0f153b797753a655702d8be41679273d1d5d6ae7
8a1d2cf1422e35257c160ac5bb12dd3ee481c433 12-May-2010 David 'Digit' Turner <digit@google.com> Add pthread_rwlock_t implementation to the C library (DO NOT MERGE)

Change-Id: I756d8c26afc37cd7b71117ddbaa02a2cb40fdecb
a418c3b8370cae1c80fbe9a06e7e53025da5d6f0 12-May-2010 David 'Digit' Turner <digit@google.com> Add pthread_rwlock_t implementation to the C library

Change-Id: I14d0a112554756a7294a51fe88c1c408a16b5ff1
e4fa46e75cd0d433b5c6c064720ed7e195cba7c8 11-Jan-2010 Matt Fischer <matt.fischer@garmin.com> Set SA_RESTORER in sigaction()

GDB looks for specific opcode sequences when trying to recognize a stack
frame as a signal trampoline. The sequences it looks for happen to be those
created when SA_RESTORER is set, since glibc always sets a restorer. This
patch does the same here, so that the trampolines can be correctly identified.

Change-Id: I0ac574a68818cb24d939c3527f3aaeb04b853d04
8ff1a2759a6389bed30d7862d0beb76077032c99 04-Mar-2010 Bruce Beare <brucex.j.beare@intel.com> Atom optimized string and memory routines

Change-Id: I27b68bb28551c75c9ac84bb9730e2cd8254d8991
d7ed1ae98249af8a58ce97784a29f048d77789a9 05-Mar-2010 David 'Digit' Turner <digit@google.com> Fix timezone management in the C library

Define 'timezone' and 'daylight' global variables that are already
defined in <time.h>

Properly update the 'tm_gmtoff' field in 'struct tm' values.
3c543e1da9a2780a70b25299f39734bf0a18c4a0 04-Mar-2010 Bruce Beare <brucex.j.beare@intel.com> x86 syscall system call implementation
9f6915631b918a56e0e6be958fb14d274cbab322 02-Mar-2010 Mike Chan <mike@android.com> bonic: libc: cpuacct support for setuid functions

Any of the setuid functions now updates /acct/uid/ with its own tid
before changing users. This is so we can properly account for cpu time
per uid.

Change-Id: I34186cf4d5228cac8439e582a9e26c01ef3011e4
Signed-off-by: Mike Chan <mike@android.com>
97cf7f3394780d524038fc083e2c134031b54728 23-Jan-2010 David 'Digit' Turner <digit@google.com> Implement clone() C library function properly.

Only provide an implementation for ARM at the moment, since
it requires specific assembly fragments (the standard syscall
stubs cannot be used because the child returns in a different
stack).
fc10b24accd082fb33c8f92ff8b92481c22fe3dc 14-Jan-2010 Colin Cross <ccross@android.com> Add implementation of fdprintf, clearenv, and stubs for ttyname_r, *usershell

Change-Id: I5fe7e8b6ee5edbb49e707c3b6737a58563781fa3
8c59d96e243ba1a05d7d9ab7a14d1a00e20bad4a 14-Jan-2010 Colin Cross <ccross@android.com> Add killpg function

Change-Id: I9bc347d264fe38faf2d0f9935d2ebb43a353196e
64ceac3f493e3063a289aec4a12c74787be974e4 14-Jan-2010 Colin Cross <ccross@android.com> Add fts, err, and sys/queue for grep

Change-Id: Id47514a1812d828e95efa2fab0e9c15c5b682b58
4fa7b105644222d9b35347c9d226ca8e011072eb 13-Jan-2010 Colin Cross <ccross@android.com> Import regex from OpenBSD

Change-Id: I7ad7d907ef65e4e345f94777d730813b1270a612
5f53a18204ec991f5a77872806eeaa185936aa8c 04-Dec-2009 Mathias Agopian <mathias@google.com> Revert "Add qsort_r() implementation to the C library."

This reverts commit 754c178ae551aedcbbfd3bfd1c1c3b710d9ad989.

Turns out we don't need it afterall (needed a stable sort anyways).
So, we'll make that change in the dev branch instead.
754c178ae551aedcbbfd3bfd1c1c3b710d9ad989 03-Dec-2009 David 'Digit' Turner <digit@google.com> Add qsort_r() implementation to the C library.

NOTE: This replaces qsort.c with the FreeBSD version. While
the patch changes the source, it should not alter the
implementation that should use the exact same algorithm.
b74ceb25aae555570df64fa4d4076272733a9a20 17-Nov-2009 Vladimir Chtchetkine <vchtchetkine@google.com> Split libc_debug.so into two .so modules loaded on demand from libc.so

This change is intended to eliminate need to replace libc.so with libc_debug.so in order to enablememory allocation debugging.
This is also the first step towards implementing extended memoryallocation debugging using emulator's capabilities in monitoring memory access.
194d3fa048cf909ca592dd56fa538dc9cd3f5ddb 13-Nov-2009 Jean-Baptiste Queru <jbq@google.com> eclair snapshot
92b10af793da235659198cf38ff2e0237c181058 02-Oct-2009 Thorsten Glaser <tg@mirbsd.org> Add the BSD sys_signame array.

Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
2a7ad97539313c82e13d36c9c75cefb2982a87d8 29-Sep-2009 David 'Digit' Turner <digit@google.com> Fix ABI breakage in libc.so and libm.so between 1.6 and Eclair.

For a detailed description of the problem and why this fix is
needed, plrease read the comments in libgcc_compat.c
10093276e98d26428875480c502a278dffe550c7 28-Sep-2009 Shin-ichiro KAWASAKI <shinichiro.kawasaki.mg@hitachi.com> added and modified bionic code to support SuperH architecture

modified: libc/Android.mk
new files: libc/arch-sh/bionic/*
new files: libc/arch-sh/include/*
4a05d12cf52a9a40759f11f28543bd75715c8f00 18-Sep-2009 David 'Digit' Turner <digit@google.com> Fix TLS access for ARMv6 and beyond.

For performance reasons, we don't call the kernel helper. Instead, we directly
access the TLS register on ARMv6 and higher. For ARMv5TE, keep using the hard-coded
address populated by the kernel on each task switch.

NOTE: Since we don't call the kernel helper, this must precisely match your
kernel configuration. This is controlled by setting the ARCH_ARM_HAVE_TLS_REGISTER
variable to 'true' in your board configuration file.
49e55332784b82f7112ee7c1ea3c176c9dc32d7a 27-May-2009 Dima Zavin <dima@android.com> libc: Add an intermediate version of the static libc without malloc

For now, this will only used by the dynamic loader to ensure that
malloc and friends are never called.

Signed-off-by: Dima Zavin <dima@android.com>
ca122b0e34df0e8c485be0d3ab1b80f728b76276 27-May-2009 Dima Zavin <dima@android.com> libc: Cleanup the libc makefile.

Removes a lot of redundant code, and reorganizes the file. We first
setup all the comomn variables we may need, and then define the
actual libraries that need to be generated.

Signed-off-by: Dima Zavin <dima@android.com>
d2c9dcc9265e66f6432ec39dcc7378b944449e60 24-Apr-2009 Dave Bort <dbort@android.com> libc: Replace a reference to TARGET_BUILD_TYPE with DEBUG_BIONIC_LIBC

We're soon going to stop using TARGET_BUILD_TYPE==debug to debug
native modules.

Signed-off-by: Dave Bort <dbort@android.com>
1dc9e472e19acfe6dc7f41e429236e7eef7ceda1 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
1767f908af327fa388b1c66883760ad851267013 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
9f65adf2ba3bb15feb8b7a7b3eef788df3fd270e 11-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@130745
6d6c82c7a0a6b9a89f61b61c66f9b90d9c7177dc 10-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@125939
4e468ed2eb86a2406e14f1eca82072ee501d05fd 18-Dec-2008 The Android Open Source Project <initial-contribution@android.com> Code drop from //branches/cupcake/...@124589
a27d2baa0c1a2ec70f47ea9199b1dd6762c8a349 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution