Commit graph

53 commits

Author SHA1 Message Date
Elliott Hughes
40360b379c Remove bogus transitive includes.
<signal.h> shouldn't get you the contents of <errno.h>, and <fcntl.h>
shouldn't get you the contents of <unistd.h>.

Change-Id: I347499cd8671bfee98e6b8e875a97cab3a3655d3
2014-12-29 13:29:50 -08:00
Elliott Hughes
274afe8f0e Add POSIX lcong48.
Change-Id: I821046816661d77275cb02c8c99d526bb41afb9c
2014-11-06 14:14:37 -08:00
Elliott Hughes
49eed7db79 Switch to OpenBSD insque/remque/killpg.
Change-Id: Ie02290ad3187b1c1596dd776fd1c8a743a55f7ef
2014-09-23 14:06:56 -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
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
a167eef548 Fix visibility for a bunch more symbols.
Bug: 11156955
Bug: 15291317
Change-Id: I664f25cce7c17085a101d6593d8e01525a1f6a90
2014-07-14 15:13:30 -07:00
Elliott Hughes
673bff01ae Merge "Implement rand/srand in terms of random/srandom." 2014-07-14 17:20:33 +00:00
Elliott Hughes
76c241b091 Implement rand/srand in terms of random/srandom.
Code developed for glibc or older versions of bionic might expect more
randomness than the BSD implementation provides.

Bug: 15829381
Change-Id: Ia5a908a816e0a5f0639f514107a6384a51ec157e
2014-07-14 12:02:22 -07:00
Elliott Hughes
4f0b67a8db Sync upstream-openbsd.
Change-Id: I5b9961a57e2ff05f63bd218c130bf8347850b9be
2014-07-14 11:22:59 -07: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
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
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
Elliott Hughes
809093bc21 Hide rand48 implementation details.
Bug: 11156955
Change-Id: I130272286989487dc22e246fb4ffbee5230225c4
2014-06-09 18:10:20 -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
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
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
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
d39f3f2c2e Clean up and document our hacks for building BSD source.
Change-Id: Ic591e22fa5b363bb68376b9f25814c0e5bd83fbf
2014-04-21 17:13:46 -07:00
Elliott Hughes
7f3a272ae3 Add lsearch(3) for ltrace.
Bug: 13746936
Change-Id: I833c6ba70a1752c04dab7de389f5bebb741662b3
2014-04-01 12:40:00 -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
ad41e9a4eb More stdio cleanup.
Change-Id: Idc909cd3dc7b072f1edd2ae4980932d6550e8568
2014-03-11 15:05:50 -07:00
Elliott Hughes
19f58efa22 Switch to NetBSD utmp.c.
Change-Id: Ibe94888aa48b5b28fea97fd5719a1ed7a23ddeb3
2014-03-10 16:32:35 -07:00
Calin Juravle
569fb9887d Moved nameser.h and namser_compat.h to public include dir
This is part of the upstream sync (Net/Open/Free BSDs expose the
nameser.h in their public headers).

Change-Id: Ib063d4e50586748cc70201a8296cd90d2e48bbcf
2014-03-04 15:07:07 +00: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
677b6e605b 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
2014-02-20 14:16:58 -08:00
Elliott Hughes
db1ea34748 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
2014-02-18 15:39:24 -08:00
Elliott Hughes
a38cb08861 Clean up various warnings in bionic.
Change-Id: Ic57541d0a567fd4ae79f0ad59b2ffde1130eb7d2
2014-02-18 12:04:54 -08:00
Pawit Pornkitprasan
652289942d bionic: call stdio cleanup on exit
As of 61e699a133, 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
2013-11-19 09:49:17 +07:00
Elliott Hughes
9be07fa527 Fix a TODO; we've had SOCK_CLOEXEC for a while now.
Change-Id: I4bc39b57f3c33441ead74127f576bf5a4e311566
2013-11-06 17:04:56 -08:00
Elliott Hughes
60fd3450bf Fix the *rand48 functions on LP64.
I reported the mrand48 bug upstream, and 'matt' fixed the whole family
of functions!

Change-Id: I07fbc034e86499ce89599c3026a741738fd0cfc0
2013-10-28 15:24:26 -07:00
Elliott Hughes
eb847bc866 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
2013-10-09 16:00:17 -07:00
Elliott Hughes
d04c183979 Add more __restricts, clean up __format__ attributes.
Change-Id: I7e2d270cc722d339d221eaea92747eaff3b51403
2013-05-14 16:08:43 -07:00
Elliott Hughes
6b3f49a537 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
2013-03-06 16:20:55 -08:00
Elliott Hughes
2b47307012 Our strcoll(3) is no different from NetBSD's, so take exactly theirs.
Change-Id: I45251047202a229f9175735ecc23c0ebcda71e8d
2013-01-22 15:10:19 -08:00
Elliott Hughes
c51cd764a2 Avoid overflow in memccpy.
Just take the upstream NetBSD code.

Bug: http://code.google.com/p/android/issues/detail?id=43078
Change-Id: Ibbbde9d00e8bc6a09c9503aab2b04b4e3d1f98b0
2013-01-22 14:41:23 -08:00
David 'Digit' Turner
c30396f5f2 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
2012-10-29 07:44:27 -07:00
Elliott Hughes
063cfb2084 Clean up the implementation of the <dirent.h> functions.
Change-Id: I3c647cc9588525afc41fee90ee468d58cd13503a
2012-10-26 16:42:06 -07:00
Elliott Hughes
ab44f52202 More upstream NetBSD upgrades.
Change-Id: Idb781d37de3b05585271d7d258ecffd5ba87d0b8
2012-10-23 16:05:09 -07:00
Elliott Hughes
e8bcca3a2c Upgrade more functions to the current upstream NetBSD copy.
Change-Id: Ie0b3f8b3fccef28609eb210434413ebd51d6ef45
2012-10-23 12:29:53 -07:00
Elliott Hughes
31a1060a5a Upgrade seed48 too.
Missed this in 774c7f54ff.

Change-Id: Ic24fd67f003d0e2d192cfb08f96f63024ca817eb
2012-10-01 14:14:21 -07:00
Elliott Hughes
774c7f54ff Upgrade to the current NetBSD rand implementation.
Also add basic unit tests.

Change-Id: I7fc7ef61d47c1e8fdf8b8eff67a635220c3afd56
2012-10-01 13:53:41 -07:00
Irina Tirdea
eac9eb462e 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>
2012-09-27 11:38:57 -07:00
Elliott Hughes
ac184b2142 Fix several compiler warnings.
Change-Id: I55caa50a5937442734f4fcbdb4edf1c70f335bf8
2012-09-26 14:20:22 -07:00
Nick Kralevich
5e58ea07d4 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
2012-09-13 16:54:57 -07:00
Irina Tirdea
b5f053b5a7 Make strerror(3) and strsignal(3) thread-safe, and add psignal(3) and psiginfo(3).
Change-Id: I426109db25e907980d6cb3a7a695796e45783b78
2012-09-13 15:18:21 -07:00
Elliott Hughes
cc213f871b Switch to the current NetBSD regex implementation.
Change-Id: If32b28dd85d6a7ab8957ab81d19fa4c0de9499d5
2012-08-15 15:39:11 -07:00
Elliott Hughes
409302f0f9 Switch to upstream NetBSD tdelete/tfind/tsearch.
tdestroy is a GNU extension, so that stays.

Change-Id: Iedebaff25ea7e92b1ab1dd4440da12b67b99aa40
2012-08-13 17:41:49 -07:00
Elliott Hughes
3d2d448af1 Fix nice...
...by switching to the NetBSD implementation.

Change-Id: I562b27b237a24ded95804035cc322c7bff12ff59
2012-08-13 16:38:29 -07:00