Commit graph

719 commits

Author SHA1 Message Date
Elliott Hughes
625993dfbb Use VDSO for clock_gettime(2) and gettimeofday(2).
Bug: 15387103
Change-Id: Ifc3608ea65060c1dc38120b10b6e79874f182a36
2014-07-16 14:27:43 -07:00
Elliott Hughes
673bff01ae Merge "Implement rand/srand in terms of random/srandom." 2014-07-14 17:20:33 +00:00
Elliott Hughes
76c241b091 Implement rand/srand in terms of random/srandom.
Code developed for glibc or older versions of bionic might expect more
randomness than the BSD implementation provides.

Bug: 15829381
Change-Id: Ia5a908a816e0a5f0639f514107a6384a51ec157e
2014-07-14 12:02:22 -07:00
Elliott Hughes
4ae938698c Merge "Sync upstream-openbsd." 2014-07-14 17:15:23 +00:00
Elliott Hughes
4f0b67a8db Sync upstream-openbsd.
Change-Id: I5b9961a57e2ff05f63bd218c130bf8347850b9be
2014-07-14 11:22:59 -07:00
Dmitriy Ivanov
53c3c271dc Upstream atexit
Change-Id: Ia454a2181b5058ed9783dc02b6b1805d0e4d2715
2014-07-14 12:05:16 -07:00
Christopher Ferris
8e32b7b354 Make jemalloc the default choice.
Change-Id: I5ff0cf0c396b7ae6278e6fcd5a0d50f8b966fb54
2014-07-11 11:01:30 -07:00
Elliott Hughes
040e11877d Merge "Enable building libc with clang." 2014-07-11 16:35:27 +00:00
Elliott Hughes
c999f76977 Enable building libc with clang.
Bug: 16218205
Change-Id: I024de2044fe016412c7bead22c264e96be4cb39c
2014-07-11 09:28:53 -07:00
Dan Albert
dfb5ce42bc Revert "Revert "Add locale aware APIs.""
This reverts commit 063e20c269.

Change-Id: Ib8c9004efefe75a5346b3af50dfe37952d91eb21
2014-07-11 16:21:31 +00:00
Calin Juravle
f8408c58fa Move __cmsg_nxthdr to its proper file.
Change-Id: I095fb6bc5318f2d256baa97658bdfe679d235aec
2014-07-10 12:47:13 +01:00
Christopher Ferris
dda1c6c466 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
2014-07-09 21:27:15 -07:00
Elliott Hughes
37b1b5bbcd 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
2014-07-02 16:27:20 -07:00
Elliott Hughes
6593597931 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
2014-07-02 11:22:26 -07:00
Dan Albert
42a5a177e9 Merge "Revert "Revert "Prevent symbols from libgcc from being reexported.""" 2014-07-01 14:58:20 +00:00
Elliott Hughes
a210cae724 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
2014-06-30 12:03:43 -07:00
Elliott Hughes
52f9b051c8 Merge "Sync to current upstream arc4random." 2014-06-24 18:00:13 +00:00
Elliott Hughes
0468feb286 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
2014-06-24 14:13:48 -07:00
Dan Albert
71f9b34fbe Revert "Revert "Prevent symbols from libgcc from being reexported.""
This reverts commit 4e4e1a5d78.

Change-Id: I8e78c3a59598e052e02965dd37b3fba8f567eed9
2014-06-24 04:31:08 +00:00
Dan Albert
4e4e1a5d78 Revert "Prevent symbols from libgcc from being reexported."
This reverts commit 65e80cf622.

Change-Id: I5f94b123f73db8d0b03cd71a5cffa0662776a017
2014-06-23 20:12:05 +00:00
Dan Albert
65e80cf622 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
2014-06-21 00:09:31 -07:00
Dan Albert
0d7415fb22 Merge "Remove SHA1 from LP64 in favor of libcrypto." 2014-06-20 20:43:43 +00:00
Elliott Hughes
7086ad6919 Cache getpid.
In practice, with this implementation we never need to make a system call.
We get the main thread's tid (which is the same as our pid) back from
the set_tid_address system call we have to make during initialization.
A new pthread will have the same pid as its parent, and a fork child's
main (and only) thread will have a pid equal to its tid, which we get for
free from the kernel before clone returns.

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

Bug: 15387103
Change-Id: I6d4718ed0a5c912fc75b5f738c49a023dbed5189
2014-06-20 09:06:57 -07:00
Elliott Hughes
d10db82619 Build tzcode with hidden visibility.
Bug: 11156955
Change-Id: Ib98d837b56cbbdfd01687cb3054fe3103eec0da9
2014-06-19 14:49:30 -07:00
Elliott Hughes
5f564540a9 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
2014-06-19 13:54:10 -07:00
Dan Albert
c82c0b7e07 Remove SHA1 from LP64 in favor of libcrypto.
Keep the symbols around on LP32 for binary compatibility.

Bug: 11156955
Change-Id: I379a7e0fa3092e9a70daeafcbcb2aacfc314031a
2014-06-16 16:52:27 -07:00
Christopher Ferris
3a37576d4b 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
2014-06-16 17:13:09 -07:00
Dan Albert
ac6467587e Revert "Revert "Remove ftime from bionic LP64""
This reverts commit 0921204660.

Change-Id: I749af8d7d429cda9f9d09a75bd30df54e6b1dd65
2014-06-16 12:32:38 -07:00
Dan Albert
462abab12b 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
2014-06-16 10:12:37 -07:00
Elliott Hughes
564222e338 Merge "Use default hidden visibility to build libc_dns." 2014-06-12 05:34:11 +00:00
Elliott Hughes
8563802b04 Use default hidden visibility to build libc_dns.
Bug: 11156955
Change-Id: Ia443705f5fbee0681039d4480abc89850968f475
2014-06-12 13:35:41 -07:00
Elliott Hughes
346fa721ca Merge "Get the full set of PRNG functions in <stdlib.h>" 2014-06-12 03:32:07 +00:00
Elliott Hughes
a0beeeabbc Get the full set of PRNG functions in <stdlib.h>
Bug: https://code.google.com/p/android/issues/detail?id=58888
Change-Id: I435250bdae302e8bd7e29977d0fde7b9afbfca5e
2014-06-12 14:37:31 -07:00
Dan Albert
8e613cf342 Remove declaration for putw(3)/getw(3).
These were both removed from POSIX 2004, and we don't define an
implementation for getw(3). Keep the definition of put(3) on LP32 for
binary compatibility.

Bug: 13935372
Change-Id: Iba384b45093ac6d2d7c2d81f7980cd7701dd6f56
2014-06-11 14:41:45 -07:00
Dan Albert
440bd6bcc3 Merge "Replaces vfork() implementation with fork()" 2014-06-10 22:08:45 +00:00
Dan Albert
210331d976 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
2014-06-10 21:38:52 -07:00
Elliott Hughes
67401638a9 Remove the MD5 implementation that was only used by toolbox.
I've already moved toolbox over to openssl.

Change-Id: Ia75fba5b5e3335a975b97787f653bf4df78e1b4e
2014-06-09 16:26:29 -07:00
Elliott Hughes
47ba295b06 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
2014-06-06 16:49:39 -07:00
Dan Albert
0921204660 Revert "Remove ftime from bionic LP64"
Breaking some build... will look in to it later.

This reverts commit 26d6799bbe.

Change-Id: I35fa770221be3a181bd37c6c3dce1bf37a69a4a1
2014-06-05 00:50:43 +00:00
Dan Albert
26d6799bbe Remove ftime from bionic LP64
Bug: 13935372
Change-Id: I5dd31147143b23a090a3b75b846dc5354e599121
2014-06-04 16:25:24 -07:00
Dan Albert
001f8f041b Removes wcswcs from bionic for LP64.
Bug: 13935372
Change-Id: I0deb15e769da4fa81bb65a87f3c86db5163a5796
2014-06-04 12:01:56 -07:00
Elliott Hughes
e120cba31d Merge "Cherrypick upstream OpenBSD's vfwprintf.c revision 1.11." 2014-06-04 16:17:10 +00:00
Dan Albert
452e091300 Merge "Adds functionality specified by uchar.h" 2014-06-04 16:10:50 +00:00
Elliott Hughes
be8df2e744 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
2014-06-04 09:00:25 -07:00
Dan Albert
7a7f9952c1 Adds functionality specified by uchar.h
mbrtoc32 and c32rtomb get their implementations from mbrtowc and wcrtomb. The
wc functions now simply call the c32 functions.

Bug: 14646575
Change-Id: I49d4b95fed0f9d790260c996c4d0f8bfd1686324
2014-06-04 08:39:24 -07:00
Elliott Hughes
9b5235d74e 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
2014-06-03 18:47:17 -07:00
Elliott Hughes
b082645ccb 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
2014-06-03 16:39:58 -07:00
Elliott Hughes
d286796fce Turn on -Wunused and fix the mistakes it uncovers.
Change-Id: I023d2d8b547fbc21d4124bb7510d42b06a0dc501
2014-06-03 15:22:34 -07:00
Elliott Hughes
5d9a7ba0dc 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
2014-06-02 10:32:55 -07:00
Elliott Hughes
b4e099c6f7 Remove issetugid.
Bug: 14569474
Change-Id: I752c77ed53c724f144f0b618443eb95e87f2929a
2014-05-29 16:43:01 -07:00
Bernhard Rosenkraenzer
6f2bde3441 Add optimized AArch64 versions of bcopy and wmemmove based on memmove
Add optimized versions of bcopy and wmemmove for AArch64 based on the
memmove implementation

Change-Id: I82fbe8a7221ce224c567ffcfed7a94a53640fca8
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
2014-05-23 18:49:57 -07:00
Christopher Ferris
fd0ce866ce Revert "Add optimized AArch64 versions of bcopy and wmemmove based on memmove"
This reverts commit 8167dd7cb9.

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

Change-Id: Id89fe959ea5105cd58dff6bba8d91a30cc4bcb07
2014-05-24 01:02:22 +00:00
Bernhard Rosenkraenzer
8167dd7cb9 Add optimized AArch64 versions of bcopy and wmemmove based on memmove
Add optimized versions of bcopy and wmemmove for AArch64 based on the
memmove implementation

Change-Id: Ie43d0ff4f8ec4edba5b4fb5ccacd941f81ac6557
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
2014-05-23 17:54:08 -07:00
Calin Juravle
254fa8857f Merge "Switch to POSIX dprintf/vdprintf." 2014-05-22 13:28:52 +00:00
Elliott Hughes
fcac8ff97f Switch to POSIX dprintf/vdprintf.
Bug: 11156955
Change-Id: I734bd02db514367ab119a48304aae9767958e367
2014-05-22 11:27:06 +01:00
Christopher Ferris
8d2410d33d Fix build.
Change-Id: I5a35eee4074e35f459c86c7f9b1d9b0754888940
2014-05-21 11:45:51 -07:00
Christopher Ferris
72bbd42357 Support for jemalloc to replace dlmalloc.
To use jemalloc, add MALLOC_IMPL = jemalloc in a board config file
and you get the new version automatically.

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

Bug: 981363

Change-Id: I16eb152b291a95bd2499e90492fc6b4bd7053836
2014-05-20 14:47:33 -07:00
Dan Albert
94a9ba2b4a Merge "Removes RTTI support from libc" 2014-05-19 23:21:46 +00:00
Elliott Hughes
948acf710e Merge "Switch back to OpenBSD inet_ntop now they're FORTIFY clean." 2014-05-19 23:19:32 +00:00
Elliott Hughes
f51d3e8767 Switch back to OpenBSD inet_ntop now they're FORTIFY clean.
Change-Id: I04798a4966c352a8a12feebdff9646e3bad5933f
2014-05-19 15:55:29 -07:00
Sreeram Ramachandran
903b78873a Mark sockets on creation (socket()) and accept4().
Remove the separate syscall for accept() and implement it as accept4(..., 0).

Change-Id: Ib0b8f5d7c5013b91eae6bbc3847852eb355c7714
2014-05-19 15:19:16 -07:00
Dan Albert
48ee47ce25 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
2014-05-19 10:32:42 -07:00
Elliott Hughes
4c2da039ba 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
2014-05-16 16:50:34 -07:00
Elliott Hughes
2a60227223 Merge "Move libstdc++ into libc." 2014-05-16 16:37:20 +00:00
Christopher Ferris
5265ad6273 Merge "Fix comment typo." 2014-05-16 02:14:07 +00:00
Christopher Ferris
9029d2f638 Fix comment typo.
Change-Id: I1909f724826b531daf14fec4853e40d578fc0f59
2014-05-15 19:11:58 -07:00
Dmitriy Ivanov
623b0d05bd 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
2014-05-15 13:05:21 -07:00
Elliott Hughes
15b641a267 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
2014-05-14 18:18:55 -07:00
Sreeram Ramachandran
49ec2a0cdc Merge "Mark sockets on accept()." 2014-05-14 19:40:50 +00:00
Elliott Hughes
07f1ded139 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
2014-05-14 11:38:22 -07:00
Sreeram Ramachandran
8f0cd8aa22 Mark sockets on accept().
(cherry picked from commit 58b1f3f6a30a660ad81637c2b50382c3d279243b)

Change-Id: I5d09be413cf720fbed905f96313b007997ada76c
2014-05-14 11:10:22 -07:00
Elliott Hughes
5c8c88dd8d Use the NetBSD inet_ntop until the OpenBSD bug is fixed.
Stupidly I found this bug by accident when writing the existing
tests, but I didn't think any real code would hit it. It turns
out that libcore always uses an INET6_ADDRSTRLEN-sized buffer
even when working with AF_INET addresses.

Change-Id: Ieffc8e4bbe9b66b49b033e3e7101c896e097e6f8
2014-05-13 19:17:46 -07:00
Elliott Hughes
17f8ef87b5 Merge "Flesh out <arpa/inet.h>." 2014-05-14 01:09:01 +00:00
Elliott Hughes
6a41b0fb0e Flesh out <arpa/inet.h>.
Use the upstream OpenBSD implementations of these functions.

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

Bug: 14840760
Change-Id: I68720e9aca14838df457d2bb27b999d5818ac2b5
2014-05-13 18:08:29 -07:00
Sreeram Ramachandran
8205a61248 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
2014-05-13 17:24:03 -07:00
Sreeram Ramachandran
06e8796ee9 Fix build.
Change-Id: I33293d8bc62cbb22e23a704c4242e7e9d3fce7c5
2014-05-13 16:30:12 -07:00
Sreeram Ramachandran
ceb5bd787c 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
2014-05-13 11:30:03 -07:00
Elliott Hughes
eb664e24c0 Add getmntent_r to our collection of <mntent.h> compatibility stubs.
This helps build 'external/flo' out of the box.

Bug: 14841211
Change-Id: I30dde77239cceaf1f5743163744eb3604d27a266
2014-05-13 10:44:07 -07:00
Elliott Hughes
dbcba8f5f9 Merge "Reduce stack usage of tmpfile(3)." 2014-05-13 17:32:48 +00:00
Elliott Hughes
b6943186ce Reduce stack usage of tmpfile(3).
Also ensure that none of our home-grown code uses more than 2KiB per frame.

Change-Id: I8987a17d72f4b7f082bb7fa25e137c8433664c14
2014-05-13 10:14:22 -07:00
Varvara Rainchik
5a92284167 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>
2014-05-12 13:56:59 -07:00
Elliott Hughes
9a5a3e8e74 Fix <math.h> to quieten most of our warnings.
I've reported the wcsftime bug upstream, but we really just want to use -D
to ensure the buggy code isn't built. (I've also brought our strftime a bit
closer to upstream now we have the right define.)

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

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

Change-Id: Iee8e1182c1db375058fb2c451eceb212bab47a37
2014-05-05 21:19:47 -07:00
Elliott Hughes
8ec21d9ded Merge "Switch to current upstream OpenBSD wsetup.c." 2014-05-05 21:33:22 +00:00
Elliott Hughes
53b24382f5 Switch to current upstream OpenBSD wsetup.c.
Change-Id: I2c1123f3e1d3c4af7fd7bf354e763934a39b78c0
2014-05-05 14:31:20 -07:00
Elliott Hughes
792ae72e41 Switch to current upstream OpenBSD fwrite.c.
Change-Id: Ife527aafc1e5438f477d711902efe6e6f59f3f8e
2014-05-02 18:22:23 -07:00
Elliott Hughes
f1ada79a83 Sync with current OpenBSD stdio.
We'd fallen a little behind.

Bug: 14492135
Change-Id: Ic1137ef10bffccecebd5ce51086c23db006d0ea3
2014-05-02 17:56:56 -07:00
Elliott Hughes
efaa461bd6 Use the OpenBSD wcsftime.
Change-Id: I81929355d245ba1e58b4a464ca6cf45915e0238e
2014-05-02 15:57:50 -07:00
Elliott Hughes
5a0aa3dee2 Switch to a working UTF-8 mb/wc implementation.
Although glibc gets by with an 8-byte mbstate_t, OpenBSD uses 12 bytes (of
the 128 bytes it reserves!).

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

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

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

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

Change-Id: Ied327a8c4643744b3611bf6bb005a9b389ba4c2f
2014-05-01 14:46:54 -07:00
Elliott Hughes
0990d4fda8 Make SIGRTMIN hide the real-time signals we use internally.
__SIGRTMIN will continue to tell the truth. This matches glibc's
behavior (as evidenced by the fact that we don't need a special case
in the strsignal test now).

Change-Id: I1abe1681d516577afa8cd39c837ef12467f68dd2
2014-04-30 10:06:09 -07:00
Dan Albert
4566731772 Merge "Adds quick_exit(3) and at_quick_exit(3) from freebsd" 2014-04-30 15:39:14 +00:00
Dan Albert
b8425c549a Adds quick_exit(3) and at_quick_exit(3) from freebsd
Change-Id: I4fe88abd8f7b8aa45e58aeb2529d59a8d555d338
2014-04-29 19:17:00 -07:00
Elliott Hughes
94336d8ecf Switch to OpenBSD stdio wide printf functions.
Change-Id: Icf4f8685d021ec6b7482ca1cc021ce8184098e4a
2014-04-29 17:39:29 -07:00
Elliott Hughes
c932225e10 Switch to OpenBSD stdio wide get/put functions.
Change-Id: I71f8769cdea874e55d397ca7682d9d4e659d3dcb
2014-04-29 17:08:03 -07:00
Elliott Hughes
01ae00f317 Switch to the OpenBSD implementations of the wide scanf functions.
This also gets us the C99 wcstoimax and wcstoumax, and a working fgetwc and
ungetwc, all of which are needed in the implementation.

This also brings several other files closer to upstream.

Change-Id: I23b025a8237a6dbb9aa50d2a96765ea729a85579
2014-04-29 16:28:56 -07:00
Elliott Hughes
3d7a0d9b08 Switch to the OpenBSD wcsto* functions.
This replaces a partial set of non-functional functions with a complete
set of functions, all of which actually work.

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

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

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

Change-Id: I0f81443840de0f1aa73b96f0b51988976793a323
2014-04-29 14:53:11 -07:00
Elliott Hughes
0a5e26da1e Add mbtowc and fix mbrtowc.
Change-Id: I48786cd82587e61188d40f6fd6e11ac05e857ae9
2014-04-28 17:51:13 -07:00
Elliott Hughes
d299bcfdad Replace our broken wcswcs with the working upstream one.
Change-Id: I2952684df5674d10f0564d92c2cd42597725c0e3
2014-04-28 16:46:24 -07:00
Elliott Hughes
329103d3e2 Don't use so much stack in tzcode.
Bug: 14313703
Bug: https://code.google.com/p/android/issues/detail?id=61130
Change-Id: Id9b240fce20d4a6f2660792070e02b2b5f287655
2014-04-25 21:51:26 -07:00
Elliott Hughes
533dde4dbf Fix brk/sbrk error checking.
Note that the kernel returns the current break on error or if the requested
break is smaller than the minimum break, or the new break. I don't know where
we got the idea that the kernel could return -1.

Also optimizes the query case.

Also hides an accidentally-exported symbol for LP64.

Change-Id: I0fd6b8b14ddf1ae82935c0c3fc610da5cc74932e
2014-04-25 19:38:33 -07:00
Calin Juravle
f2aeca505c Merge "Remove an unsed include dir" 2014-04-24 16:40:50 +00:00
Calin Juravle
fbb46a0c9a Remove an unsed include dir
Change-Id: I05aa1e7e0639a5ec5576bf7646f35d2e5b157c09
2014-04-24 17:40:06 +01:00
Calin Juravle
690401db7a Merge "Removed non-existing include dir" 2014-04-24 16:29:50 +00:00
Calin Juravle
4b7c4f886f Removed non-existing include dir
Change-Id: I3e00a8471e6d94f596a34bdfdb26a0caba23dd82
2014-04-24 17:17:02 +01:00
Elliott Hughes
532ad903d2 Merge "Switch to the upstream OpenBSD getenv/putenv/setenv implementation." 2014-04-23 01:52:06 +00:00
Elliott Hughes
eae5902e73 Remove strntoimax and strntoumax from the future.
Where do these turds come from?

Change-Id: Id9ad2cc85c6128aa63b5d56ff2aa455bde39a5eb
2014-04-22 17:56:42 -07:00
Elliott Hughes
58d9e280d4 Switch to the upstream OpenBSD getenv/putenv/setenv implementation.
This fixes all the bugs found by the new tests.

Change-Id: Id5a5f9f39a0620208bafa053f871a044725b4795
2014-04-22 17:41:00 -07:00
Elliott Hughes
8d77bce185 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
2014-04-22 13:55:58 -07:00
Elliott Hughes
cce36c1878 Use -fvisibility=hidden to build libc_gdtoa.
Bug: 12177745
Change-Id: Ia4ac71e1a3a237e764c809cc591622f8952ed642
2014-04-22 12:32:49 -07:00
Elliott Hughes
d39f3f2c2e Clean up and document our hacks for building BSD source.
Change-Id: Ic591e22fa5b363bb68376b9f25814c0e5bd83fbf
2014-04-21 17:13:46 -07:00
Dmitriy Ivanov
6d09ec3c2f Merge "Fix for libgcc compat generation script." 2014-04-19 01:12:58 +00:00
Dmitriy Ivanov
6a45fe9872 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
2014-04-18 17:34:20 -07:00
Elliott Hughes
9d3c2dd11f Switch to upstream OpenBSD fread/fvwrite.
Change-Id: I3dc11083693bc8d99edc0cbcc6f70dc9e5dc6565
2014-04-18 13:13:04 -07:00
Elliott Hughes
b88da06580 Merge "Upgrade to current vfprintf." 2014-04-18 18:19:23 +00:00
Elliott Hughes
f3c73901cb Upgrade our <ctype.h> implementation to OpenBSD head.
Adding the perfunctory <ctype.h> tests showed that we'd accidentally
dropped several symbols. This puts everything back in its proper place
and switches us to upstream head at the same time.

Change-Id: Ib527ad280c9baded81e667fa598698526d93e66f
2014-04-18 10:29:16 -07:00
Elliott Hughes
0549371bd7 Upgrade to current vfprintf.
This gets us various bug fixes and missing C99 functionality.

Bug: https://code.google.com/p/android/issues/detail?id=64886
Change-Id: Ie9f8ac569e9b5eec1e4a1faacfe2c21662eaf895
2014-04-17 17:30:03 -07:00
Elliott Hughes
4bd97cee28 Switch to gdtoa.
This gives us a real strtold for LP64 and fixes various LP64
bugs.

Bug: 13563801
Change-Id: I277858d718ee746e136b6b6308a495ba50dfa488
2014-04-16 15:15:52 -07:00
Elliott Hughes
02c78a3867 Reimplement isinf/isnan/fpclassify.
Also move isinf and isnan into libc like everyone else.

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

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

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

Bug: 13469877
Change-Id: I407ffbac06c765a6c5fffda8106c37d7db04f27d
2014-04-14 14:35:47 -07:00
Calin Juravle
a5d83312bd Merge "Use glibc structure for __cmsg_nxthdr." 2014-04-09 06:06:48 +00:00
Calin Juravle
ff64831b09 Use glibc structure for __cmsg_nxthdr.
Bug: 13418328
Change-Id: I7e656b373e53e80d708325321e48dcedacf5086d
2014-04-09 00:55:24 +03:00
Elliott Hughes
5363a45f2b Clean up localeconv(3).
The OpenBSD doesn't support C99, and the extent to which we support
locales is trivial, so just do it ourselves.

Change-Id: If0a06e627ecc593f7b8ea3e9389365782e49b00e
2014-04-08 14:34:12 -07:00
Christopher Ferris
41059d764f Merge "Add stpcpy/stpncpy." 2014-04-08 01:21:07 +00:00
Christopher Ferris
950a58e24d Add stpcpy/stpncpy.
Add tests for the above.

Add the fortify implementations of __stpcpy_chk and __stpncpy_chk.

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

Add all of the fortify test cases.

Bug: 13746695
Change-Id: I8c0f0d4991a878b8e8734fff12c8b73b07fdd344
2014-04-07 16:41:53 -07:00
Elliott Hughes
efbdb53f84 Remove a non-standard turd: strtotimeval.
Change-Id: I1b1e40746cb573e3fb73a5276969b40c5da36d15
2014-04-07 15:17:19 -07:00
Elliott Hughes
7f3a272ae3 Add lsearch(3) for ltrace.
Bug: 13746936
Change-Id: I833c6ba70a1752c04dab7de389f5bebb741662b3
2014-04-01 12:40:00 -07:00
Christopher Ferris
0ae6445e9a 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
2014-03-24 17:56:13 -07:00
Elliott Hughes
205c7887ad 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
2014-03-13 16:17:43 -07:00
Elliott Hughes
f2cea021ab 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
2014-03-13 14:54:53 -07:00
Elliott Hughes
603332fc4c Upgrade to current upstream scanf implementation.
Also add a basic test.

Change-Id: Icc0e68a5716b9579244f6eb8bac1ab5a24eda85a
2014-03-12 17:10:41 -07:00
Elliott Hughes
5a8173860d Ensure we always have symbols for atof, strtof, strtold.
We'll need a better implementation of strtold for LP64, but all our
long double functions are currently broken for LP64 anyway so this
isn't a regression.

Change-Id: I2bdebac11245d31521d5fa09a16331c03dc4339c
2014-03-12 16:12:57 -07:00
Mark Salyzyn
c1005aaf8e logd: default user space logger
Change-Id: Id205b01537940051c72d79def28a3c1a8b169a21
2014-03-12 13:17:38 -07:00
Elliott Hughes
8d4b5849f2 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
2014-03-11 19:13:25 -07:00
Elliott Hughes
ad41e9a4eb More stdio cleanup.
Change-Id: Idc909cd3dc7b072f1edd2ae4980932d6550e8568
2014-03-11 15:05:50 -07:00
Elliott Hughes
cccfe1e17c 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
2014-03-11 13:37:11 -07:00
Elliott Hughes
247dc91889 Take ownership of various simple syscall wrappers.
None of these trivial functions is something we're going to get from BSD.

Change-Id: Iee1d1281b73db67da5ec303da7a49748121464bf
2014-03-10 17:17:01 -07:00
Elliott Hughes
19f58efa22 Switch to NetBSD utmp.c.
Change-Id: Ibe94888aa48b5b28fea97fd5719a1ed7a23ddeb3
2014-03-10 16:32:35 -07:00
Elliott Hughes
ec674b4d06 Merge "Switch to upstream FreeBSD ldexp.c." 2014-03-10 23:25:39 +00:00
Elliott Hughes
21d9e58d01 Merge "Rename the stack protector intermediate library." 2014-03-10 23:25:05 +00:00
Elliott Hughes
57a883640f 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
2014-03-10 16:23:09 -07:00
Elliott Hughes
7aef27468e Merge "Switch to OpenBSD wcscoll." 2014-03-10 23:21:08 +00:00
Elliott Hughes
6380b51a8d 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
2014-03-10 16:15:11 -07:00
Elliott Hughes
c8937eadf4 Switch to OpenBSD wcscoll.
Change-Id: I1050ef728e18124656e76f32b42ac9a4688f252d
2014-03-10 16:11:59 -07:00
Elliott Hughes
152b9de19a Remove non-standard memswap.
Change-Id: I06548dda339987b755ef7139c590ca3e1f9fe0a9
2014-03-10 15:54:40 -07:00
Elliott Hughes
4d46c94031 Merge "Rewrite the POSIX timer functions." 2014-03-08 00:50:56 +00:00
Elliott Hughes
4b558f50a4 Rewrite the POSIX timer functions.
This is a much simpler implementation that lets the kernel
do as much as possible.

Co-authored-by: Jörgen Strand <jorgen.strand@sonymobile.com>
Co-authored-by: Snild Dolkow <snild.dolkow@sonymobile.com>
Change-Id: Iad19f155de977667aea09410266d54e63e8a26bf
2014-03-07 16:49:46 -08:00
Calin Juravle
fcb502e3ec Sync up nameser with upstream(2014.03.05)
Bug: 13219633

Change-Id: I8ee4ddf270710e9eea415fa3db984af7719a8dd4
2014-03-06 18:36:43 +00:00
Calin Juravle
4a46a68942 Merge "Moved private dns header to their own dir." 2014-03-04 14:25:51 +00:00
Calin Juravle
9f2d1bcd17 Merge "Renamed the misleading libc/netbsd directory to libc/dns." 2014-03-04 14:25:30 +00:00
Elliott Hughes
2c7c79e6e5 Merge "Switch to upstream alarm(3)." 2014-03-04 00:58:53 +00:00
Elliott Hughes
aedb00d04e Switch to upstream alarm(3).
The only way the setitimer call can fail is if the unsigned number of seconds is
too large to fit in the kernel's signed number of seconds. If you schedule a
68-year alarm, glibc will fail by returning 0 and BSD will fail by returning -1.

Change-Id: Ic3721b01428f5402d99f31fd7f2ba2cc58805607
2014-03-04 00:58:31 +00:00
Calin Juravle
cecc036970 Moved private dns header to their own dir.
Bug: 13219633
Change-Id: I3435ef7564b9ad3c7b54188a0809440993b36c9e
2014-03-03 20:40:41 +00:00