Commit graph

1699 commits

Author SHA1 Message Date
Elliott Hughes
70a8f2272e Fix various ftw/nftw "shall fail"s from POSIX.
POSIX says ftw/nftw "shall fail" in various cases where BSD's fts_open
doesn't. Since our ftw/nftw are written in terms of fts_open, add a back
door so we can hint to ourselves when we should have the POSIX semantics.

Also pull several O_CLOEXEC and don't-null-check-before-free cleanups
from upstream, and add a couple of tests.

Bug: http://b/31152735
Test: ran bionic tests and LTP "nftw01" test
Change-Id: Ib05facacc1da4c8b2ab48e9ecce88f11a5406630
2018-05-08 15:20:07 -07:00
Dan Albert
e219cefc17 Fix posix_memalign introduced tag.
Apparently this didn't make it to all android-16 devices. As far as
we know it did make it for all android-17 devices.

Test: make checkbuild
Bug: https://github.com/android-ndk/ndk/issues/647
Change-Id: I2f07cfb1254e2a203c1c10b91b0be46bf37ea853
2018-04-20 10:46:16 -07:00
Treehugger Robot
af0ad77af5 Merge "Bionic: Always use fortified versions of FD_X macros" 2018-04-16 15:34:14 +00:00
Treehugger Robot
9ee88bdbc7 Merge "Type of second __sched_cpucount should be "const cpu_set_t*"." 2018-04-14 01:27:28 +00:00
Andreas Gampe
00a6d5fe0a Bionic: Always use fortified versions of FD_X macros
When compiling on/for at least Lollipop, always use the fortified
versions of FD_X macros. This works around side-effect issues (which
are explicitly called out in the specification) and generally
increases robustness of code.

Bug: 77986327
Test: mmma bionic
Test: m
Test: bionic_unit_tests
Change-Id: I9096c6872770e46ba5ab64e7375ff83fc0518e07
2018-04-13 17:57:21 -07:00
Tong Shen
37793a1892 Type of second __sched_cpucount should be "const cpu_set_t*".
Test: none

Bug: 77341596
Change-Id: Ib4f1a75d2cfe147855b4d5f0203f4a64c22c116a
2018-04-13 16:07:21 -07:00
Dan Albert
da1994ced6 Add dlext.h to the libdl doc group.
Test: https://irina-dot-devsite.googleplex.com/ndk/reference/group/libdl
Bug: http://b/77236573
Change-Id: Ie09351ee961554488e34c79511712b07c345b8ad
2018-04-13 14:32:37 -07:00
Ben Schwartz
27dd915147 Pad queries when EDNS0 is enabled.
Behavior is compliant with
https://tools.ietf.org/html/draft-ietf-dprive-padding-policy-04

EDNS0 is only enabled when the netcontext requests it, i.e. in DNS-over-TLS
mode.

Bug: 69623036
Bug: 64133961
Test: Wireshark verified. Integration tests echo padding and pass.
Change-Id: I5ef600e02a572d281441e890cc981614f150629b
2018-04-02 05:28:16 +00:00
Tom Cherry
60fd72e8a3 Merge "Create PTHREAD_COND_INITIALIZER_MONOTONIC_NP" 2018-03-26 23:15:11 +00:00
Tom Cherry
f0f3d2f002 Create PTHREAD_COND_INITIALIZER_MONOTONIC_NP
Needed for std::condition_variable to wait on CLOCK_MONOTONIC.

Test: boot bullhead
Change-Id: I32a30817f0ec2190393fcc6faec45b40822cba32
2018-03-26 09:00:51 -07:00
Elliott Hughes
9724e93c19 Reject .so files using ELF TLS.
Bug: http://b/74361956
Test: ran tests
Change-Id: I53e71252eb08c607c2c436dcba433374c8c53887
2018-03-23 18:46:07 -07:00
Elliott Hughes
90234e5748 Merge "Fortify ppoll64." 2018-03-22 23:49:40 +00:00
Elliott Hughes
b83bf14a35 Fortify ppoll64.
I've deliberately not bothered with the GCC implementation because we'll
have removed GCC from the NDK before anyone gets to use this.

Bug: http://b/72493232
Test: ran tests
Change-Id: Icfc2a3b214739ab53aa41bacacc11b5c67498fb4
2018-03-22 13:59:02 -07:00
Treehugger Robot
1315e3ef85 Merge "libc: silence unsigned->signed warnings with ioctl" 2018-03-22 02:06:34 +00:00
Tom Cherry
c6b5bcd182 Add _monotonic_np versions of timed wait functions
As a follow up to Ibba98f5d88be1c306d14e9b9366302ecbef6d534, where we
added a work around to convert the CLOCK_REALTIME timeouts to
CLOCK_MONOTONIC for pthread and semaphore timed wait functions, we're
introducing a set of _monotonic_np versions of each of these functions
that wait on CLOCK_MONOTONIC directly.

The primary motivation here is that while the above work around helps
for 3rd party code, it creates a dilemma when implementing new code
that would use these functions: either one implements code with these
functions knowing there is a race condition possible or one avoids
these functions and reinvent their own waiting/signaling mechanisms.
Neither are satisfactory, so we create a third option to use these
Android specific _monotonic_np functions that completely remove the
race condition while keeping the rest of the interface.

Specifically this adds the below functions:
pthread_mutex_timedlock_monotonic_np()
pthread_cond_timedwait_monotonic_np()
pthread_rwlock_timedrdlock_monotonic_np()
pthread_rwlock_timedwrlock_monotonic_np()
sem_timedwait_monotonic_np()

Note that pthread_cond_timedwait_monotonic_np() previously existed and
was removed since it's possible to initialize a condition variable to
use CLOCK_MONOTONIC.  It is added back for a mix of reasons,
1) Symmetry with the rest of the functions we're adding
2) libc++ cannot easily take advantage of the new initializer, but
   will be able to use this function in order to wait on
   std::steady_clock
3) Frankly, it's a better API to specify the clock in the waiter function
   than to specify the clock when the condition variable is
   initialized.

Bug: 73951740
Test: new unit tests
Change-Id: I23aa5c204e36a194237d41e064c5c8ccaa4204e3
2018-03-20 18:41:22 -07:00
George Burgess IV
de45dcbbab libc: silence unsigned->signed warnings with ioctl
This also tweaks cdefs to make __overloadable usable outside of
FORTIFY. It had to be FORTIFY-only before we had unmarked overload
support in clang+Bionic.

Bug: https://github.com/android-ndk/ndk/issues/402
Test: Internal master builds + `mma`. `mma` in Bionic fails if the
change to ioctl is undone.

Change-Id: Ib386b1786e1dca625e6d5a18682005adc734d9c1
2018-03-20 15:59:46 -07:00
Treehugger Robot
d5172fced0 Merge "Add __fseterr." 2018-02-15 02:36:38 +00:00
Elliott Hughes
665ce210fa Merge "Add remaining _l function stubs." 2018-02-15 01:26:17 +00:00
Elliott Hughes
457852666c Add __fseterr.
Trivial, obvious counterpart to the standard ferror(3) and clearerr(3),
and lets us build bison out of the box.

Bug: http://b/64273806
Test: ran tests
Change-Id: I20affabddb71210051165c41e86adfe5ae04f77f
2018-02-14 15:25:21 -08:00
Elliott Hughes
38a78728c3 Merge "Add uc_sigmask64." 2018-02-14 21:24:11 +00:00
Elliott Hughes
3376c23dac Add remaining _l function stubs.
Bug: http://b/65595804
Test: ran tests
Change-Id: I3bea3af20b354d1f0d3e05fd35421a9045f29020
2018-02-13 23:14:12 -08:00
Elliott Hughes
23415fc60d Add uc_sigmask64.
Added to each ucontext_t for source compatibility between platforms where
sigset_t and sigset64_t differ (arm, x86) and where they're the same
(all the rest).

Bug: http://b/72493232
Test: ran tests
Change-Id: I65a37bfa177933701bbe6c2350448885fd0f9c43
2018-02-13 19:09:04 -08:00
Christopher Ferris
db478a6274 Implement malloc hooks.
Use the malloc debug framework to implement the malloc debug hooks
since it can introduce a performance issue.

Also, modify the bionic/tests/utils.h slightly to dump an error message
when the exe failed.

Bug: 30561479

Test: Ran malloc hook unit tests.
Test: Ran malloc debug unit tests.
Test: Enabled malloc hooks and ran bionic unit tests and verified no
Test: unexpected failures.
Test: Enabled malloc debug and malloc hooks and verified malloc debug wins.
Test: Enabled malloc debug using env, property, and property with name
Test: still works.

Change-Id: Ib50046a0493c5c2050cf831befb812310bdcc249
(cherry picked from commit d6a1dc2379)
2018-02-13 13:37:30 -08:00
Elliott Hughes
25f17e48df Better backwards compatibility for stat64.
Caused problems for some Google source switching to unified headers
because the legacy headers just used #define instead.

Bug: http://b/73210428
Test: builds
Change-Id: If8a36f284031e57af419903610029a8c34a23d91
2018-02-12 15:48:01 -08:00
Goran Jakovljevic
379666996d MIPS32: Make sigset64_t equal to sigset_t
sigset_t is already large enough on mips so use the same principle
as on LP64 architectures: typedef sigset_t sigset64_t

Also prevent accessing sa_restorer field for architectures which
don't define SA_RESTORER in signal_test.

This allows compilation of signal_test.

Test: bionic-unit-tests in QEMU (MIPS32)
Change-Id: I965e202c9a7f7d109e4ec25ad87172dc7c1b8806
2018-02-12 09:03:10 +01:00
Treehugger Robot
4362da8076 Merge "Remove __overloadable/__RENAME_CLANG" 2018-02-10 02:30:37 +00:00
Treehugger Robot
13dec2354d Merge "Add a few more legacy inlines for strto*_l." 2018-02-07 19:55:43 +00:00
Christopher Ferris
cae21a9b53 Add aligned_alloc to libc.
Bug: 72969374

Test: Bionic unit tests pass.
Test: Malloc debug unit tests pass.
Change-Id: I235985bbc638855d94249c97c98f14ab2924bda0
(cherry picked from commit d69ee59594)
2018-02-07 06:57:14 -08:00
Dan Albert
4d4a7832ad Add a few more legacy inlines for strto*_l.
These three functions are the only reason we need libandroid_support
post-L. Add these so we can remove it entirely for LP64 or users
targeting L+.

Test: make checkbuild
Test: build/soong/scripts/build-ndk-prebuilts.sh
Test: Imported the prebuilts generated from the above to the NDK,
      `./checkbuild.py && ./run_tests.py` with a handful of patches
      to remove libandroid_support for L+.
Bug: None

Change-Id: I39f8ee686bd76ebdb2fc3745b013d56175ba8ff0
2018-02-06 13:45:29 -08:00
George Burgess IV
9024235005 Remove __overloadable/__RENAME_CLANG
Now that we have a clang that supports transparent overloads, we can
kill all of this cruft, and restore our upstream sources to their
untouched glory. Woohoo!

Bug: 12231437
Test: Built aosp_marlin; no obvious patch-related aosp_mips issues.
Change-Id: I520a19d014f12137f80e43f973dccd6711c571cd
2018-02-06 13:35:56 -08:00
Elliott Hughes
3e235911c9 Add struct sigaction64 and sigaction64.
Bug: http://b/72493232
Test: ran tests
Change-Id: I47b0560a30aa33a9b1f1978dfb7f84d2e3d389b8
2018-02-01 14:45:15 -08:00
Elliott Hughes
5905d6f879 Add sigset64_t and accompanying functions.
This doesn't address `struct sigaction` and `sigaction`. That will
come later.

Bug: http://b/72493232
Test: ran tests
Change-Id: I4134346757ce3a4dac6feae413361cec16223386
2018-01-30 18:47:16 -08:00
Elliott Hughes
cc0fe6e8c0 The future is now (2018 edition).
Bug: N/A
Test: builds
Change-Id: Ic638e5b1f4e5901885fe7bc60b2a265817636b21
2018-01-30 08:54:12 -08:00
Treehugger Robot
2e2a8930e5 Merge "linker: simpler encoding for SHT_RELR sections." 2018-01-27 00:00:17 +00:00
Rahul Chaudhry
f16b65932b linker: simpler encoding for SHT_RELR sections.
This change modifies the encoding used in SHT_RELR sections to a simpler
version that gives better results. This encoding was suggested by Andrew
Grieve and is described in this post on generic-abi@googlegroups.com:
    https://groups.google.com/d/msg/generic-abi/bX460iggiKg/Pi9aSwwABgAJ

Bug: None
Test: Built image for marlin, flashed on device, ran arm and
      aarch64 binaries containing '.relr.dyn' sections using
      the new encoding.

Change-Id: I266affe0fbad91dc375995985a221cb02499447b
2018-01-26 11:46:47 -08:00
Chih-hung Hsieh
c6ea39d33b Merge "Use __BIONIC_FORTIFY_VARIADIC for variadic functions." 2018-01-26 17:08:26 +00:00
Elliott Hughes
4debf20829 Merge "Make the <android/dlext.h> docs show up on the web." 2018-01-26 16:06:54 +00:00
Elliott Hughes
c9cd4eb163 Merge "<sys/ioctl.h> shouldn't pollute the namespace as much." 2018-01-26 16:05:24 +00:00
Elliott Hughes
5f6d1a59a8 <sys/ioctl.h> shouldn't pollute the namespace as much.
The history has no motivation for <asm/termbits.h>, and other C libraries
don't seem to include any of the extra types and constants that gains us.

This caused problems building FFMPEG, which defines its own B0.

Bug: https://github.com/android-ndk/ndk/issues/630
Test: builds
Change-Id: If032b9fa7860777c13f7bd8e68fb78ff606dcd94
2018-01-25 22:21:25 -08:00
Chih-Hung Hsieh
f81abef148 Use __BIONIC_FORTIFY_VARIADIC for variadic functions.
* Variadic functions usually cannot be inlined.
* Do not use misleading __always_inline attribute,
  and also avoid early clang 7.0 compiler bug.

Bug: 72412382
Test: build and boot aosp*-eng in emulator
Change-Id: I7490976166581abc626f397ad408581ada0ed308
2018-01-25 17:54:50 -08:00
Elliott Hughes
5046e5fe87 Make the <android/dlext.h> docs show up on the web.
Just enough doxygen so that
https://developer.android.com/ndk/reference/dlext_8h.html won't be completely
devoid of all this.

Bug: N/A
Test: ran doxygen manually
Change-Id: I1e0667feae93227e32c1bd671065359f5be85d9d
2018-01-25 15:48:32 -08:00
Yabin Cui
6b9c85b36d Support priority inheritance mutex in 64bit programs.
Bug: http://b/29177606
Test: run bionic-unit-tests on walleye.
Test: run bionic-unit-tests-glibc on host.
Change-Id: Iac349284aa73515f384e7509445f87434757f59e
2018-01-24 16:11:07 -08:00
Elliott Hughes
73871ad09b Merge "Deprecate readdir_r." 2018-01-23 21:51:22 +00:00
Elliott Hughes
f19af37b5e Deprecate readdir_r.
I've been campaigning against readdir_r for years:

  http://elliotth.blogspot.com/2012/10/how-not-to-use-readdirr3.html

and glibc deprecated it in 2.24, so we should join the club.

Bug: http://b/32678321
Test: builds
Change-Id: Ie3887ed75989aced9324266aa3b93e85c11bdbc9
2018-01-22 17:15:25 -08:00
Elliott Hughes
d00d38b36b Merge "linker: add experimental support for SHT_RELR sections." 2018-01-23 00:24:26 +00:00
Rahul Chaudhry
b7feec7454 linker: add experimental support for SHT_RELR sections.
This change adds experimental support for SHT_RELR sections, proposed
here: https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg

Definitions for the new ELF section type and dynamic array tags, as well
as the encoding used in the new section are all under discussion and are
subject to change. Use with caution!

Bug: None
Test: Built image for marlin, flashed on device, ran arm and
      aarch64 binaries containing '.relr.dyn' sections.

Change-Id: I2953ae932d3c42ae394e71f8fa058013758a1778
2018-01-22 12:41:27 -08:00
Dan Albert
989d804859 Reland "Cleanup transitive includes in the legacy inlines."
This reverts commit 54c71521b5.

Bug: None
Test: make checkbuild
Change-Id: Ica6a4f7ecadfcc854160a60a5db1b44ae3b6c821
2018-01-18 23:39:48 +00:00
Joachim Sauer
54c71521b5 Revert "Revert "Revert "Revert "Revert "Cleanup transitive includes in the legacy inlines."""""
This reverts commit a074ac79d7.

Reason for revert: Broke several builds.

Change-Id: I406f0b0aa0c37961ad031d2f6c5ea4241f3f1111
2018-01-18 11:37:34 +00:00
Dan Albert
a074ac79d7 Revert "Revert "Revert "Revert "Cleanup transitive includes in the legacy inlines.""""
This reverts commit b37e9aa9a6.

Reason for revert: trying again
Test: make native
Change-Id: Ide23f0a752fd6ca88e44449e996eb5809db6712d
2018-01-11 09:43:23 -08:00
Ryan Prichard
51a7fe8fbd Mark abs/labs/llabs as 19+ rather than 21+
The libc.map.txt file already defines these three functions as having
been introduced in API 19, but these header files had declared them as
21 and up.

See https://android-review.googlesource.com/c/platform/development/+/233407

imaxabs is already declared as 19 and up.

Test: build-ndk-prebuilts.sh && ./update_platform.py &&
  checkbuild.py && run_tests.py
Test: manually build app against 18 and 19

Change-Id: Iaeed48d7e6c438d816635a0433a056e557e8ebc2
2018-01-08 17:46:27 -08:00