Commit graph

44 commits

Author SHA1 Message Date
Elliott Hughes
f1c568d1ea Add <glob.h>.
This is the FreeBSD implementation, plus some tests. The FreeBSD
implementation includes the GNU extensions and seems to be what
iOS is using too, which should provide bug compatibility for app
developers.

The code unfortunately uses a lot of stack, and uses FreeBSD locale
implementation that we don't have, but it does seem better maintained
than the other BSDs.

Bug: http://b/29251134
Test: ran tests
Change-Id: Ie477b45e42a6df1319b25712098519d2b33adf67
2017-09-26 18:46:09 -07:00
Elliott Hughes
5702c6ff45 Finish <search.h>.
I'm unable to find a bug, but we've had requests for this internally
once or twice (though I pointed those folks at the STL), and there's
code we build for the host or in our bootloaders that would use this,
and there's reasonable-looking FreeBSD implementation ready and waiting.

Bug: N/A
Test: ran tests
Change-Id: I6ddee4b71bea4c22ed015debd31d3eaac4fcdd35
2017-08-31 17:38:51 -07:00
George Burgess IV
54f5d8331f libc fortify: make socket.h and stdlib.h use diagnose_if
Since realpath no longer needs to be overloaded, we can restore the
upstream source to purity. We'll be able to do this with most of the
other functions when we pull a newer clang in.

Bug: 12231437
Test: m checkbuild on bionic internal master; CtsBionicTestCases show
no new failures.

Change-Id: I484221bba0b291273fece23d2be2f5f9fd713d2c
2017-08-01 22:32:15 -07:00
Elliott Hughes
20f3399956 Switch to FreeBSD for wcsstr and wmemcpy.
Almost all of our w* functions come from FreeBSD already. The one downside is
that we can't take all our w* functions from FreeBSD because FreeBSD handles
locales very differently from us.

Bug: N/A
Test: ran tests
Change-Id: I177b4332499992babd5d5afe5b3f469f8c4345a5
2017-07-13 09:45:00 -07:00
Xin Li
4b1a3992de libc: Sync qsort(3) with FreeBSD revision r318515.
r279663: enhance to handle 32-bit aligned data on 64-bit systems

r279666: qsort(3): small style(9) cleanups.

r288030: Use ANSI C prototypes.  Eliminates -Wold-style-definition
warnings.

r318514: Use size_t.

r318515: Reduce the possible recursion level to log2(N) by always
recursing on the smaller partition instead.

Bug: 38450217
Test: builds, ./tests/run-on-host.sh 64
Change-Id: Ieb622e6f54f8f6d6f62e1bdb491d3b5c8e2f9965
2017-06-13 18:49:54 +00:00
George Burgess IV
7cc779f15c libc: add clang FORTIFY support
This patch adds clang-style FORTIFY to Bionic. For more information on
FORTIFY, please see https://goo.gl/8HS2dW . This implementation works
for versions of clang that don't support diagnose_if, so please see the
"without diagnose_if" sections. We plan to swap to a diagnose_if-based
FORTIFY later this year (since it doesn't really add any features; it
just simplifies the implementation a lot, and it gives us much prettier
diagnostics)

Bug: 32073964
Test: Builds on angler, bullhead, marlin, sailfish. Bionic CTS tests
pass on Angler and Bullhead.

Change-Id: I607aecbeee81529709b1eee7bef5b0836151eb2b
2017-02-09 15:49:32 -08:00
Elliott Hughes
da7a0b105d Move to .md files for even trivial documentation.
So it's automatically displayed for folks browsing the source.

Bug: N/A
Test: N/A
Change-Id: I80e823415f1fb12ad8ce5348e926519b6e29580f
2017-01-07 12:47:28 -08:00
Elliott Hughes
3d125175d7 Move <machine/endian.h> somewhere more private.
Bug: http://b/28519060
Change-Id: I1c7811f95f46c65d4152bcf509b6e048c45bc28b
2016-05-02 15:44:56 -07:00
Elliott Hughes
26a8322972 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
2015-09-14 19:01:58 -07:00
Elliott Hughes
76f8916b90 Clean up <stdlib.h> slightly.
Interestingly, this mostly involves cleaning up our implementation of
various <string.h> functions.

Change-Id: Ifaef49b5cb997134f7bc0cc31bdac844bdb9e089
2015-01-26 14:28:41 -08:00
Elliott Hughes
39cd0fa24a Remove an unused file.
We don't have any FreeBSD stdio left.

Bug: 17154680
Change-Id: I145627f564364ac8d4707d431d451cc3115c1c6a
2014-10-29 13:42:23 -07:00
Elliott Hughes
31e072fc9b Update our FreeBSD realpath(3) to upstream head.
Change-Id: I8c89728184ecd2c1a28a05cefa84a5037d28b552
2014-09-30 16:40:41 -07:00
Elliott Hughes
567d3fcb7e Merge "Switch to OpenBSD fopen/fclose." 2014-09-24 20:24:48 +00:00
Elliott Hughes
af12924f67 Sync with current upstream getopt_long.c.
Change-Id: I269195aa581a688fd3eb99552d506b8f5f6a8395
2014-09-24 12:39:34 -07:00
Elliott Hughes
5a69da8d7a Switch to OpenBSD fopen/fclose.
This means all our stdio implementation is now the OpenBSD implementation.
The only thing we lose is the STDIO_THREAD_LOCK calls but they were no-ops
anyway.

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

Bug: 17154680
Change-Id: Ie2523e444a7d0965b8d141d57e3e11f6432d5b9a
2014-09-24 11:14:36 -07:00
Elliott Hughes
a71b4c3f14 Switch to OpenBSD flags.c.
Change-Id: I0a35e5bd9f8edba27e0c73e5c8150636346d6a81
2014-09-23 20:02:42 -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
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
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
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
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
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
d299bcfdad Replace our broken wcswcs with the working upstream one.
Change-Id: I2952684df5674d10f0564d92c2cd42597725c0e3
2014-04-28 16:46:24 -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
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
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
53e43292aa More OpenBSD cleanup (primarily string).
This patch removes the string/ and wchar/ directories.

Change-Id: Ia489904bc67047e4bc79acb1f3eec21aa3fe5f0d
2014-02-24 18:02:05 -08:00
Elliott Hughes
0133944b09 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
2014-02-21 14:30:18 -08:00
Elliott Hughes
a38cb08861 Clean up various warnings in bionic.
Change-Id: Ic57541d0a567fd4ae79f0ad59b2ffde1130eb7d2
2014-02-18 12:04:54 -08:00
Elliott Hughes
ab61eb366a 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
2013-11-20 16:24:16 -08:00
Elliott Hughes
aec2ffbc5a Fix our missing abs/labs/llabs/imaxabs (and imaxdiv) symbols.
Change-Id: I94c411c22634e43184445c82e7388e51fc46a8cc
2013-08-12 12:07:05 -07:00
Elliott Hughes
284f788032 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
2013-07-19 15:20:31 -07:00
Elliott Hughes
d278b828fe Switch to current upstream getopt_long.
Change-Id: I4c646dcb8be9e88dd54d069a03bbc5fbfd92de03
2013-06-25 14:56:17 -07:00
Elliott Hughes
4eeec44e29 Fix the qsort copyright notice (fixed upstream this afternoon).
Change-Id: I786feb42719bceaa7da91565e350c1333b0d301f
2013-06-12 17:42:43 -07:00
Elliott Hughes
2815b1dd45 Take some fixed upstream copyright headers and regenerate NOTICE.
Change-Id: Ifff41d69c13322dbc6f928ce7d4c65f76fe36772
2013-06-12 16:00:41 -07:00
Elliott Hughes
677ee56477 Switch to current upstream stdio makebuf.c and setvbuf.c.
Change-Id: I4761b5e94459815520f01062eef39abf62af621f
2013-06-12 15:24:15 -07:00
Elliott Hughes
b2e1abda05 Pull upstream FreeBSD revision 249810.
Fix license clause numbering.

Convert libc/stdio from K&R to ANSI C.

And add '__restrict' where it appeared in the header prototypes.

Change-Id: I5fdb22f79d3effa2298d03f9aa8412b4b087da04
Upstream: http://svnweb.freebsd.org/base?view=revision&revision=249810
2013-05-14 15:02:16 -07:00
Elliott Hughes
0b25f633a2 Switch to current FreeBSD qsort.
Change-Id: Ic46cd0b663dc5fa78c99dd38db0bfe849a25e789
2013-04-11 18:08:34 -07:00
Elliott Hughes
6b05c8e280 Start moving to current FreeBSD stdio.
This only touches the easy stuff.

Change-Id: Iecee57f1681dba5c56bff59f0e9a89811a71f0ca
2013-04-11 13:55:01 -07:00
Elliott Hughes
0493a6f7be Regenerate NOTICE files.
Also clean up some obsolete cruft.

Change-Id: Iec3b36f6607f7a08b72de99294ed5b6cd910dd5f
2013-03-07 11:51:10 -08:00
Elliott Hughes
eb93ebffba Switch to upstream-freebsd for the unmolested wchar code.
Change-Id: I87b4d76ff8da04109ae53638eec4f11629798960
2013-03-01 18:35:56 -08:00
Elliott Hughes
f0777843c0 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
2013-03-01 17:11:39 -08:00