Commit graph

1616 commits

Author SHA1 Message Date
Elliott Hughes
dff08ced56 Add pthread_setschedprio.
Bug: http://b/26204555
Test: ran tests
Change-Id: Ic34062b9b6036a1ce2642a069514bab48a893338
2017-10-17 09:14:05 -07:00
Elliott Hughes
5033918092 Complete <netdb.h>.
Add all the missing <netdb.h> functions.

Also fix getservbyport to handle a null protocol correctly.

Also fix getservbyname/getservbyport to not interfere with getservent.

Also fix endservent to reset getservent iteration.

Also reduce unnecessary differences from upstream NetBSD sethostent.c.

The servent implementation is still horrific, and we should
probably support protoent too so that debugging tools can use
getprotobyname/getprotobynumber.

Bug: N/A
Test: ran tests
Change-Id: I639108c46df0a768af297cf3bbce857cb1bef9d9
2017-10-15 10:37:51 -07:00
Elliott Hughes
ddd6436df2 Merge "Unified sysroot: kill arch-specific include dirs." 2017-10-12 22:23:58 +00:00
Elliott Hughes
01bb7bf6fb Merge "Implement <spawn.h>." 2017-10-12 21:02:54 +00:00
Elliott Hughes
d4ca231ae2 Unified sysroot: kill arch-specific include dirs.
<machine/asm.h> was internal use only.

<machine/fenv.h> is quite large, but can live in <bits/...>.

<machine/regdef.h> is trivially replaced by saying $x instead of x in
our assembler.

<machine/setjmp.h> is trivially inlined into <setjmp.h>.

<sgidefs.h> is unused.

Bug: N/A
Test: builds
Change-Id: Id05dbab43a2f9537486efb8f27a5ef167b055815
2017-10-12 13:19:51 -07:00
Elliott Hughes
14e3ff9f09 Implement <spawn.h>.
As described here:

  http://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn.html

And here:

  http://man7.org/linux/man-pages/man3/posix_spawn.3.html

Bug: N/A (but mentioned in my inbox since 2013)
Test: ran tests
Change-Id: I0b27b2919b660779e3bd8a25fb429527c16dc621
2017-10-11 14:57:49 -07:00
Dan Albert
8c2323c697 Fix "Add a legacy inline for mmap64".
Autosubmit fired before the CL was actually ready (forgot to hit "y"
on the repo upload).

Test: make checkbuild
Test: copied into the NDK and ran mmap64_fob64 test.
Bug: lots
Change-Id: I8c0400a703f319e8e230f7ba9178009ed7c88be0
2017-10-06 16:01:36 -07:00
Treehugger Robot
3dacc47642 Merge "Add a legacy inline for mmap64." 2017-10-06 22:20:54 +00:00
Dan Albert
a613d0df5c Add a legacy inline for mmap64.
While this was never an inline, this function alone has caused most of
the bug reports related to _FILE_OFFSET_BITS=64. Providing an inline
for it should allow a lot more code to build with _FILE_OFFSET_BITS=64
when targeting pre-L.

Test: make checkbuild
Test: built trivial cc_binary for LP32 against API 14 with
      _FILE_OFFSET_BITS=64 set
Bug: lots
Change-Id: I8479d34af4da358c11423bee43d45b59e9d4143e
2017-10-05 23:41:47 -07:00
Elliott Hughes
aaf83e8051 More POSIX limits cleanup.
http://man7.org/linux/man-pages/man7/posixoptions.7.html is a very useful
quick reference to what these are supposed to mean.

Bug: http://b/32776472
Test: ran tests
Change-Id: Icea6812d6075e663885844d7424aa6cf73d6284a
2017-10-05 16:18:10 -07:00
Elliott Hughes
3a8f75d8b0 POSIX clock cleanup.
The newest of these clocks was added in Linux 2.6.12, so no need for runtime
checks.

Add CTS tests that we can actually use the various clocks.

Bug: http://b/67458266
Test: ran tests
Change-Id: I3cfd7982043d6f8d4ebdc2b29e8722334f443ce5
2017-10-05 10:33:18 -07:00
John Reck
a0c7ec8080 Add O MR1 define
Bug: 64394076
Test: none
Change-Id: Ice3991c626dd2cce93c9a571ba529fa5b0129492
2017-10-02 08:14:56 -07:00
Elliott Hughes
b3639adf9c Merge changes I76dde1e3,I54fec461
* changes:
  Add <sys/random.h>.
  Run other maintenance scripts as part of the preupload hooks.
2017-09-29 15:39:29 +00:00
Elliott Hughes
8465e968a8 Add <sys/random.h>.
iOS 10 has <sys/random.h> with getentropy, glibc >= 2.25 has
<sys/random.h> with getentropy and getrandom. (glibc also pollutes
<unistd.h>, but that seems like a bad idea.)

Also, all supported devices now have kernels with the getrandom system
call.

We've had these available internally for a while, but it seems like the
time is ripe to expose them.

Bug: http://b/67014255
Test: ran tests
Change-Id: I76dde1e3a2d0bc82777eea437ac193f96964f138
2017-09-29 05:31:35 +00:00
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
0d9301e156 Merge "Rename _Exit in a way that works with libandroid_support." 2017-09-19 18:34:52 +00:00
Elliott Hughes
2f94a29d9c Rename _Exit in a way that works with libandroid_support.
Bug: N/A
Test: builds
Change-Id: I2aeaf9bafe7d51e91b67f22d68f4e52191df062b
2017-09-19 18:34:40 +00:00
Elliott Hughes
d6541c2a97 Make <math.h> renames compatible with GCC.
GCC is fussy about the order in which attributes and renames occur.

Bug: N/A
Test: builds
Change-Id: Icee5ec00aa4626ddad0d89d2d7cee5ec6891c368
2017-09-18 16:22:32 -07:00
Elliott Hughes
50cda38f1d Use __RENAME for long double functions.
We can cut a lot of stuff out of the NDK's libandroid_support with this,
and reduce unnecessary relocations for all LP32 code. LP64 code should
be unaffected.

Bug: https://issuetracker.google.com/64450768
Bug: https://github.com/android-ndk/ndk/issues/507
Test: ran tests, plus manual readelf on the _test.o files
Change-Id: I3de6015921195304ea9c829ef31665cd34664066
2017-09-14 16:10:43 -07:00
Elliott Hughes
40756d61ac Merge "Cast __builtin_swap64 to uint64_t." 2017-09-11 20:43:36 +00:00
Elliott Hughes
4c0803d165 Cast __builtin_swap64 to uint64_t.
strace 4.19 causes clang to emit a questionable warning:

  external/strace/nlattr.c:254:35: error: format specifies type 'unsigned long' but the argument has type 'unsigned long long' [-Werror,-Wformat]
                tprintf("htobe64(%" PRIu64 ")", be64toh(num));
                                 ~~~            ^~~~~~~~~~~~
  bionic/libc/include/sys/endian.h💯20: note: expanded from macro 'be64toh'
  #define be64toh(x) htobe64(x)
                     ^~~~~~~~~~
  bionic/libc/include/sys/endian.h:80:17: note: expanded from macro 'htobe64'
  #define htobe64 __swap64
                  ^
  bionic/libc/include/sys/endian.h:48:18: note: expanded from macro '__swap64'
  #define __swap64 __builtin_bswap64
                   ^

What's happened here is:

* be64toh is __builtin_bswap64

* PRIu64 is "lu"

* __builtin_bswap64 is internally declared a "ULLiULLi"

All of which leads to the `unsigned long` != `unsigned long long` complaint.

It seems like __builtin_bswap64 should be ULiULi on 64-bit architectures,
where `long` rather than `long long` is the natural way to refer to 64-bit
types, as evidenced by the "lu" for PRIu64.

As long as clang behaves like this, though, we can work around it with a cast.

Also clean up the other casts in the file, be more consistent about whether
these function-like macros are defined with an argument, and remove an
incorrect comment.

Bug: http://b/65495954
Test: ran tests, built strace 4.19 without warnings
Change-Id: I8e06d4bf71e95d62f556eab8661033e04d487e0d
2017-09-11 13:21:35 -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
Treehugger Robot
8468a1be01 Merge "Pretend the <fts.h> functions didn't appear until 21." 2017-08-26 00:02:50 +00:00
Elliott Hughes
f11aa95ee7 Pretend the <fts.h> functions didn't appear until 21.
Because there was an accidental ABI breakage in 21, and we can't fix
the past. It seems more useful to refuse to build code that won't work
on any current or future device.

Bug: https://issuetracker.google.com/37051826
Test: builds
Change-Id: I4b5c30f899e2c7307642e2fb20e43a3ca14ae7fe
2017-08-25 15:18:33 -07:00
Elliott Hughes
bda6f3b6af Improve names for function arguments in <unistd.h> for Studio.
Spotted while adding syncfs(2). I'd previously seen that this file already
had names, but apparently not inspected them. A couple were missing, a
couple (pipe/pipe2) could usefully have a more specific type, and many
hadruntogethercstylenames.

Bug: http://b/64613623
Test: builds
Change-Id: I6b4a131bf51bf04825317ec481bc55e87c88c2b3
2017-08-25 15:07:05 -07:00
Elliott Hughes
a648733cb7 Implement <iconv.h>.
Bug: http://b/32978596
Test: ran tests
Change-Id: I56b6ae3d9c5a3a56d2b4afba33fb8f9e964bf7b9
2017-08-25 08:47:41 -07:00
Elliott Hughes
896362eb0e Add syncfs(2).
GMM calls this system call directly at the moment. That's silly.

Bug: http://b/36405699
Test: ran tests
Change-Id: I1e14c0e5ce0bc2aa888d884845ac30dc20f13cd5
2017-08-24 16:31:49 -07:00
Elliott Hughes
df9a489b2b Add more const-correct C++ overloads.
libc++ actually provides overloads for all the standard C library stuff,
so we just need to handle the POSIX and GNU extensions, of which there
are just two more: memrchr and strcasestr.

Bug: http://b/22768375
Test: builds
Change-Id: Ie9ed1fbcc794e14a0c9bba13b5307ad677949613
2017-08-23 14:34:40 -07:00
Sandeep Patil
9b1ca569db libc: Add support to allow library calls to find appropriate shell executable for a process
Library calls like system() and popen() invoke the shell executable
pointed to by '_PATH_BSHELL' in order to run the command passed into the
function. The _PATH_BSHELL points to /system/bin/sh by default and thus
breaks any vendor process trying to use system() / popen(), as they are
denied access to system shell by selinux.

This CL make necessary changes, so the implmentations of system() and popen()
can use the appropriate shell (e.g. /vendor/bin/sh for processes running
out of /vendor partition). Also, changes the implementation of system()
and popen().

Bug: 64832610
Test: Manual, Using a test program running from /system/bin and
      /vendor/bin to ensure correct shell is being used.

Change-Id: Ie7168d69decb1ae98284446ae7db34dec930dc33
Merged-In: Ie7168d69decb1ae98284446ae7db34dec930dc33
Signed-off-by: Sandeep Patil <sspatil@google.com>
(cherry picked from commit aa3e32422c)
2017-08-22 10:17:28 -07:00
Elliott Hughes
611d0de62f Merge "Name function arguments in libc headers for Studio." 2017-08-22 16:14:26 +00:00
Elliott Hughes
ffde533ed9 Name function arguments in libc headers for Studio.
Final batch of headers...

Bug: http://b/64613623
Test: builds

Change-Id: I86578c7c2df446b210fa1bdda3391b21f340e947
2017-08-21 14:51:59 -07:00
Elliott Hughes
f3b92f1485 Merge "Name function arguments in libc headers for Studio." 2017-08-19 16:42:07 +00:00
Treehugger Robot
7ac99d3ff6 Merge "Disable FORTIFY on ASAN builds" 2017-08-18 22:52:27 +00:00
Elliott Hughes
684c31a267 Name function arguments in libc headers for Studio.
Third batch of headers...

Bug: http://b/64613623
Test: builds
Change-Id: I32d8467a0bd22ba94d76476397f4f7dc51003886
2017-08-18 15:07:41 -07:00
George Burgess IV
d9551db089 Disable FORTIFY on ASAN builds
FORTIFY's *_chk functions mess with ASAN's library function
interceptors, which can apparently result in false-positives.

Since adding even more complexity to every run-time check condition in
FORTIFY doesn't seem like a great idea, and the majority of our builds
will still use FORTIFY anyway, turning FORTIFY off here seems
reasonable.

Bug: 63104159
Test: checkbuild on internal master + CtsBionicTestCases. No new
failures.

Change-Id: Id32e551e28ee70a9815ad140c3253b86f03de63f
2017-08-18 13:33:45 -07:00
Elliott Hughes
ff26a16c1d Re-submit "Name function arguments in libc headers for Studio."
This reverts commit 9af9120091 (a revert
of 079bff4fa5), now the versioner bug is
fixed.

Bug: http://b/64613623 # header bug
Bug: http://b/64802958 # versioner bug
Change-Id: I1cb9d7832d4b3aecdc57a9285e2291443e59d02d
2017-08-18 00:00:38 +00:00
Colin Cross
9af9120091 Revert "Name function arguments in libc headers for Studio."
This reverts commit 079bff4fa5.

Broke builds with SANITIZE_HOST=address with an asan failure in versioner.

Change-Id: I22b113fd5405589d1a25e5e137c450aaba1ade5f
2017-08-17 18:29:54 +00:00
Elliott Hughes
079bff4fa5 Name function arguments in libc headers for Studio.
Second batch of headers...

Bug: http://b/64613623
Test: builds
Change-Id: I8eef043dbf32afee8ff814e9d005f46aee8fa21f
2017-08-16 16:30:54 -07:00
Treehugger Robot
67e7bf137e Merge "Enable FORTIFY in unoptimized builds" 2017-08-16 20:43:54 +00:00
George Burgess IV
1de2e358ca Enable FORTIFY in unoptimized builds
GCC's FORTIFY required optimizations to be enabled in order to function
properly. Clang's FORTIFY doesn't have this limitation, so it seems
pointless to keep it disabled due to a GCC-specific limitation.

Bug: 12231437
Test: Checkbuild on bullhead internal master + CtsBionicTestCases. No
new failures.

Change-Id: I74aa35f9d3f3d2a6b11a7adfe72a787e3d7f7f36
2017-08-15 21:20:09 -07:00
Dan Albert
3f7e65e66e Add guards for things the versioner can't catch.
The versioner doesn't handle C++ blocks yet, so these guards won't be
added and it will appear as though the functions are always available
in C++, but based on API level in C.

Test: make checkbuild
Bug: https://github.com/android-ndk/ndk/issues/440
Change-Id: I31a20fa1596d836b280ffc6d7feb863afccca6c7
2017-08-15 14:42:31 -07:00
Elliott Hughes
3ce8834e53 Merge "Name function arguments in libc headers for Studio." 2017-08-15 20:30:28 +00:00
George Burgess IV
95bd4884b5 libc fortify: error on realpath(NULL, foo)
I've half a mind to make this a warning instead, since this sort of
call isn't UB. That said:
- if the user really wants this (I can't imagine why they would), they
  can just put NULL in a non-const variable,
- we're slowly moving to -Werror ~everywhere anyway, and
- it's presumably easier to change this from an error to a warning than
  the other way around

Bug: 12231437
Test: m checkbuild on bullhead internal master. No new
CtsBionicTestCases failures.

Change-Id: Ie8bf5a3455f663686fda4a7450fb35d147fa745e
2017-08-14 14:48:55 -07:00
Elliott Hughes
faa74342e3 Name function arguments in libc headers for Studio.
First batch of headers...

Bug: http://b/64613623
Test: builds
Change-Id: I6bc3ad79daa635456b61d03b1f43f06c433ec596
2017-08-11 17:45:59 -07:00
dimitry
daebd05739 Fix pattern to account for '_' prefix in syscalls
Bug: http://b/64549471
Test: make
Change-Id: I7ba856a2cad29adbb028f150aeaabb9894e84d6e
2017-08-10 11:11:00 +02:00
Treehugger Robot
0cd32c1aba Merge "Put back the _Exit rename for pre-L." 2017-08-09 23:44:41 +00:00
Elliott Hughes
8aa387fbee Merge "Remove reference to non-existent __LP32__." 2017-08-07 23:09:42 +00:00
Dan Albert
cd8828c346 Put back the _Exit rename for pre-L.
Somehow I accidentally removed this in
https://android-review.googlesource.com/c/445150.

Test: make checkbuild
Bug: None
Change-Id: Ia6744af6c7b6dc2f149e9eab6e1f39863f96f6ca
2017-08-07 14:47:00 -07:00
Elliott Hughes
0138c46794 Remove reference to non-existent __LP32__.
Since there is no 64-bit before 21, there's no need for us to talk about
bitness at all.

Bug: https://github.com/android-ndk/ndk/issues/481
Test: builds
Change-Id: I307466997df35d7f1d0eef7dc7cb35ac3033d25d
2017-08-07 09:04:08 -07:00
Elliott Hughes
2fdefadcee Merge "With O_TMPFILE, open(2) takes a mode argument." 2017-08-04 20:12:18 +00:00