Commit graph

71 commits

Author SHA1 Message Date
Elliott Hughes
c08c25b4c9 Sync with upstream findfp.c.
Change-Id: Ib298f46de0c4d0fd4ce0a9b456c163e8b8b06342
2014-09-24 10:32:30 -07:00
Elliott Hughes
a71b4c3f14 Switch to OpenBSD flags.c.
Change-Id: I0a35e5bd9f8edba27e0c73e5c8150636346d6a81
2014-09-23 20:02:42 -07:00
Elliott Hughes
31165edf57 CLOEXEC support in fdopen, freopen, and mkostemp/mkostemps.
Change-Id: I74ea88e0d4973d6ab3c57da7d8bb643c31592b14
2014-09-23 18:21:52 -07:00
Elliott Hughes
b05ec5ae93 Pull in upstream fixes to reject invalid bases.
Also add tests to make sure the full set works correctly.

Change-Id: I3e7f237f12c9c93e1185a97c9717803e7e55a73c
2014-09-23 14:53:10 -07:00
Elliott Hughes
8642165344 Merge "Sync with some upstream OpenBSD #include cleanup." 2014-09-23 21:27:29 +00:00
Elliott Hughes
49eed7db79 Switch to OpenBSD insque/remque/killpg.
Change-Id: Ie02290ad3187b1c1596dd776fd1c8a743a55f7ef
2014-09-23 14:06:56 -07:00
Elliott Hughes
08dc9d83a2 Sync with some upstream OpenBSD #include cleanup.
Change-Id: Ibcd7adb19e9a6b9ad8c24d77e23935f19f56a144
2014-09-23 13:55:15 -07:00
Chih-Hung Hsieh
b6b5cb5389 Ignore all __weak_alias in OpenBSD libC.
GCC assembler allows xyz to be redeclared as weak,
by __weak_alias(xyz, _xyz), while _xyz is undefined.
Clang does not like that but silently generates no code.
It will reject its own .s file if the assembly code is saved first.
Since we have no reason to define xyz or _xyz as weak symbol now,
and _xyz is a macro to xyz, we simplify libC to have only
xyz defined as global.

BUG: 17186746
Change-Id: I24b154425838683cae69248cc750c59e26fd5467
2014-08-28 15:10:01 -07:00
Elliott Hughes
cc7e5f489f Switch to OpenBSD <err.h> implementation.
Change-Id: Ia950d88871a30f68e74f9ac7dbd87788e128e02f
2014-08-26 17:00:37 -07:00
Elliott Hughes
e5055179fd Switch to OpenBSD daemon(3).
Change-Id: I1fd0be09fdb24aa6f1d945410eba5987f8a949b4
2014-08-26 16:25:19 -07:00
Elliott Hughes
7b87d441b0 Merge "Switch to OpenBSD res_random." 2014-08-26 23:18:04 +00:00
Elliott Hughes
6b841db2ba Add POSIX-2008 fmemopen, open_memstream, and open_wmemstream.
Bug: 17164505
Change-Id: I59e28a08ff8b6ab632230b11a5807cfd5278aeb5
2014-08-20 17:03:46 -07:00
Elliott Hughes
b810462028 Fix _BSD_SOURCE/__USE_BSD.
Bug: 14659579
Change-Id: I80ec9584f054c02d1078828f6bca759c42bc1d4c
2014-08-19 09:18:03 -07:00
Elliott Hughes
3e424d0a24 Implement twalk(3), add unit tests.
I've also added insque(3) and remque(3) (from NetBSD because the OpenBSD
ones are currently broken for non-circular lists).

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

Bug: https://code.google.com/p/android/issues/detail?id=73719
Change-Id: I97397a7b921e2e860fd9c8032cafd9097380498a
2014-07-24 14:55:29 -07:00
Elliott Hughes
0f7d882bb7 Switch to OpenBSD res_random.
Change-Id: Ia971d647832893e9bb4601697132a105524d2f96
2014-07-21 15:31:53 -07:00
Elliott Hughes
2b67d7dee0 Use upstream OpenBSD's arc4random.
The getentropy_linux.c is lightly modified to build on Android, but we're now
completely in sync with upstream OpenBSD's arc4random implementation.

Change-Id: If32229fc28aba908035fb38703190d41ddcabc95
2014-07-21 14:38:16 -07:00
Elliott Hughes
a167eef548 Fix visibility for a bunch more symbols.
Bug: 11156955
Bug: 15291317
Change-Id: I664f25cce7c17085a101d6593d8e01525a1f6a90
2014-07-14 15:13:30 -07:00
Elliott Hughes
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
Dan Albert
2d94ee29f4 Merge "Revert "Revert "Hide _tolower_tab_ and _toupper_tab_ on LP64.""" 2014-07-02 20:51:20 +00: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
f79ee064b6 Revert "Revert "Hide _tolower_tab_ and _toupper_tab_ on LP64.""
This reverts commit 715242fd0f.

Change-Id: Ia9892fa3b03287129aa72a49974cef9fd94ae735
2014-07-01 22:41:50 +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
715242fd0f Revert "Hide _tolower_tab_ and _toupper_tab_ on LP64."
This reverts commit dd4ad5c463.

Change-Id: If3c9771825e460ce68604082f4feb0ca783e56c6
2014-06-19 03:57:05 +00:00
Dan Albert
dd4ad5c463 Hide _tolower_tab_ and _toupper_tab_ on LP64.
We can't hide them on LP32 because they appeared in NDK headers.

Bug: 11156955
Change-Id: I22bf5a0f4d330c04b49565bc598cd0568128d4fc
2014-06-18 13:11:07 -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
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
Elliott Hughes
b4e099c6f7 Remove issetugid.
Bug: 14569474
Change-Id: I752c77ed53c724f144f0b618443eb95e87f2929a
2014-05-29 16:43:01 -07:00
Elliott Hughes
fcac8ff97f Switch to POSIX dprintf/vdprintf.
Bug: 11156955
Change-Id: I734bd02db514367ab119a48304aae9767958e367
2014-05-22 11:27:06 +01: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
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
6a41b0fb0e Flesh out <arpa/inet.h>.
Use the upstream OpenBSD implementations of these functions.

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

Bug: 14840760
Change-Id: I68720e9aca14838df457d2bb27b999d5818ac2b5
2014-05-13 18:08:29 -07:00
Elliott Hughes
2716f3e805 Sync with upstream OpenBSD wcsftime.c.
They removed the code nobody wants rather than fix the ""/L"" mixup.
Even better!

Change-Id: Ib4333acf5e90d69586805a218d2894c5dffcb82f
2014-05-06 11:12:34 -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
e0a36f49a9 Sync with upstream OpenBSD.
These trivial differences are are only current differences from upstream
OpenBSD.

Change-Id: Iddbee2c803911915a25e1da8b246e8403fa72daf
2014-05-05 14:57:23 -07:00
Elliott Hughes
ad534985ec Merge "Disable %n in printf and vfwprintf." 2014-05-05 21:49:22 +00:00
Elliott Hughes
e2341d08fa Disable %n in printf and vfwprintf.
Bug: 14492135
Change-Id: If190bede29e5f68a65043ddbe8e878c660933d03
2014-05-05 14:43:17 -07:00
Elliott Hughes
8ec21d9ded Merge "Switch to current upstream OpenBSD wsetup.c." 2014-05-05 21:33:22 +00:00
Elliott Hughes
53b24382f5 Switch to current upstream OpenBSD wsetup.c.
Change-Id: I2c1123f3e1d3c4af7fd7bf354e763934a39b78c0
2014-05-05 14:31:20 -07:00
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
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