Commit graph

1502 commits

Author SHA1 Message Date
Elliott Hughes
00fedf5879 Undo recent _FILE_OFFSET_BITS=64 changes.
We had several bugs filed saying "if I set _FILE_OFFSET_BITS=64 when
targeting an API < L, various functions are missing". Instead of
saying "yes, they are", we quietly just modified the header files to
expose the non-64-bit variants. This makes no sense. We can't just say
"oh, yeah, we don't have a version of this function that agrees with
your calling code about how large off_t is, but here's a version that
doesn't: I'm sure it'll be fine".

_FILE_OFFSET_BITS=64 on Android LP32 has always been a game of chance,
but that game should be "are all the functions my code needs available
at compile time?", not "will my code actually work at run time?".

Bug: https://github.com/android-ndk/ndk/issues/449
Bug: https://github.com/android-ndk/ndk/issues/442
Bug: https://github.com/android-ndk/ndk/issues/333
Bug: https://github.com/android-ndk/ndk/issues/332
Bug: https://github.com/android-ndk/ndk/issues/324
Test: builds
Change-Id: Ib095251d3e21e77ed50cc3575388107fecec4ecd
2017-07-10 19:52:18 +00:00
Elliott Hughes
f45bc14d54 Merge "Work around missing _Exit in old API levels." 2017-07-01 15:48:58 +00:00
Elliott Hughes
79dd9889d1 Work around missing _Exit in old API levels.
Rather than do this in libandroid_support, we may as well just stick it with
the other historical stdlib workarounds in bionic itself...

Bug: N/A
Test: built new NDK test
Change-Id: Ia5cf4010581eb79d4adf924e87d0bc050b9e2839
2017-06-30 16:39:25 -07:00
Treehugger Robot
d09f3b67a3 Merge "Add version info for C++ versions of basename, strchrnul." 2017-06-30 22:33:27 +00:00
Josh Gao
16d9ba808b Add version info for C++ versions of basename, strchrnul.
These still won't get guards added by the preprocessor, because it
compiles with C-only.

Bug: https://github.com/android-ndk/ndk/issues/440
Test: treehugger
Change-Id: I893b345e528ed1b761e0db00700037411bbb8b78
2017-06-30 13:21:25 -07:00
Dan Albert
c2ce12046c Put back more legacy pthread APIs.
Test: make checkbuild
Bug: https://github.com/android-ndk/ndk/issues/423
Bug: https://stackoverflow.com/q/44580542/632035
Change-Id: Ibf52a969afffbfcdf6793a0bf8b0e10bbdd1f32c
2017-06-22 12:52:17 -07:00
Treehugger Robot
42edca036e Merge "Add sys/stat.h compatibility macros for old NDKs." 2017-06-16 22:52:01 +00:00
Elliott Hughes
8ad4093659 Add #defines for some key enums.
Building ruby actually trips over both of these:

* if the RTLD_ constants aren't #defined, it uses its own incorrect values.

* if the REG_ constants aren't #defined, it confuses x86 with x86-64.

In all other places where we have enums in our headers, we already match
existing glibc practice.

Bug: http://b/62531921
Test: builds
Change-Id: I5b3aab25a1a24611bdc58f2eda4104a78e9f841c
2017-06-15 15:12:29 -07:00
Elliott Hughes
e2d4663b27 Move a <wchar.h> implementation detail into the implementation.
No other C library expose these, and I couldn't find any callers.

Bug: http://b/62531921
Test: builds
Change-Id: I4a3505bc0897286a4036c48066b98d16665b573a
2017-06-15 10:37:26 -07:00
Treehugger Robot
a09953e1a8 Merge "Expose pthread_mutex_lock_timeout_np to the NDK." 2017-06-15 16:15:24 +00:00
Elliott Hughes
112581a5e0 Merge "Don't use the overloadable attribute if we're not fortified." 2017-06-15 15:06:36 +00:00
Elliott Hughes
af0c781cf4 Add <sys/mtio.h>.
In a similar style to some of our other "not really, but enough" headers
like <sys/vt.h>.

Bug: N/A
Test: build GNU dd or BSD dd with a standalone toolchain
Change-Id: I8fbd1aac1d97e24b05e7aae8a55666300b5bf1ed
2017-06-14 17:16:05 -07:00
Elliott Hughes
6fa8df9d3c Don't use the overloadable attribute if we're not fortified.
See code comment.

Bug: N/A
Test: building bash and binutils with a standalone toolchain
Change-Id: I73b5d55716072ca1b03b1b0157d65cb1ceb22841
2017-06-14 16:54:32 -07:00
Dan Albert
a4e774c2bb Add sys/stat.h compatibility macros for old NDKs.
Test: make checkbuild
Bug: https://github.com/android-ndk/ndk/issues/417
Change-Id: I04fdb2f31131e87907adab9f3264b783917de542
2017-06-14 14:03:14 -07:00
Treehugger Robot
7f6bcc4780 Merge "Remove volatile from the __errno declaration." 2017-06-14 00:44:33 +00:00
Treehugger Robot
87d1df9f70 Merge "The bsd_signal declaration shouldn't be visible if API > 21." 2017-06-13 23:20:40 +00:00
Elliott Hughes
e452cb1ff3 Remove volatile from the __errno declaration.
This breaks code that declares `errno` itself for whatever crazy reason:

  b.c:22:12: error: conflicting types for '__errno'
  extern int errno;
             ^
  /usr/local/google/ndkports/toolchain/bin/../sysroot/usr/include/errno.h:47:20: note: expanded from macro 'errno'
  #define  errno   (*__errno())
                     ^
  /usr/local/google/ndkports/toolchain/bin/../sysroot/usr/include/errno.h:44:15: note: previous declaration is here
  volatile int* __errno(void) __attribute_const__;
                ^

Bug: N/A
Test: built various bits of GNU source
Change-Id: I27c03bf3bde419a001f98f1ea6c267c847f31271
2017-06-13 16:02:07 -07:00
Elliott Hughes
583ef362c8 The bsd_signal declaration shouldn't be visible if API > 21.
This causes GNU make to fail to build:

  main.o:main.c:(.text+0x18c): more undefined references to `bsd_signal' follow

Bug: N/A
Test: built GNU make with a hacked standalone toolchain
Change-Id: Icdfb4cf674df8abed44f6671454bed9f8d68e74b
2017-06-13 14:29:15 -07:00
Dan Albert
8c67f1e617 Expose pthread_mutex_lock_timeout_np to the NDK.
The proper API for this isn't available until L, so expose this for
API levels earlier than that.

Test: make checkbuild
Bug: https://github.com/android-ndk/ndk/issues/420
Change-Id: I382b8f557be9530f3e13aaae353b4a6e7f9301ab
2017-06-12 16:46:01 -07:00
Elliott Hughes
2eab77e503 Fix boost build with unified headers.
boost (1.64.0 at least) assumes that if you have POSIX_MADV_NORMAL, you have
posix_madvise. With unified headers, this isn't true. Rather than make life
harder for projects that don't use configure, just make it so. We already
applied similar workarounds for epoll_create1 and inotify_init1.

Bug: https://github.com/android-ndk/ndk/issues/395
Test: built boost (long story!)
Change-Id: I5d2d8de7b30921dde913251d35dcd249a2876f94
2017-06-01 14:08:58 -07:00
Christopher Ferris
8f7a987cd0 Merge "Revert "Make mallopt available in the future."" 2017-05-31 18:15:11 +00:00
Christopher Ferris
7c08c7910d Revert "Make mallopt available in the future."
This reverts commit 083923d96a.

Reason for revert: No longer correct, this will be in API 26.

Change-Id: Iaf82d797405135fcd30455fd750b23fc57e9623a
2017-05-31 00:15:00 +00:00
Treehugger Robot
f58179cda5 Merge "Stop including <sys/sysmacros.h> from <sys/types.h>." 2017-05-25 01:43:07 +00:00
Treehugger Robot
1f66c6d078 Merge "Fix _POSIX_THREAD_PROCESS_SHARED." 2017-05-24 07:13:36 +00:00
Elliott Hughes
8543f923fe Stop including <sys/sysmacros.h> from <sys/types.h>.
<sys/types.h> unconditionally includes <sys/sysmacros.h>.

<sys/sysmacros.h> defines major, minor, and makedev. In the deprecated NDK
headers, these were inline functions. In the unified headers, they are
function-like macros.

The inline functions would only collide with another function called major,
minor, or makedev but the macros will replace anything with a function-like
form such as definitions of class methods called major, minor, or makedev.
This causes code which has such definitions to fail to compile when moving
from the deprecated headers to the unified headers.

Resolve this by removing the transitive dependency. Folks who want
<sys/sysmacros.h> can ask for it explicitly (it's been in both bionic and
glibc for years, though I don't think macOS has it [as usual]).

Bug: https://github.com/android-ndk/ndk/issues/398
Test: builds
Change-Id: If2921c7b5d979c3066f199f22c64d4d2f7bf6632
2017-05-23 15:53:36 -07:00
Treehugger Robot
7bbe7cb619 Merge changes Iefdc1662,I8ee9ce62
* changes:
  Don't define IN_CLOEXEC/IN_NONBLOCK for pre-L.
  Undef EPOLL_CLOEXEC for pre-L.
2017-05-23 00:48:01 +00:00
Dan Albert
5a215d7817 Don't define IN_CLOEXEC/IN_NONBLOCK for pre-L.
Some third-party code uses the existence of IN_CLOEXEC/IN_NONBLOCK to
detect the availability of inotify_init1. This is not correct, since
`syscall(__NR_inotify_init1, IN_CLOEXEC)` is still valid even if the C
library doesn't have that function, but for the time being we don't
want to harm adoption to the unified headers. We'll avoid defining
IN_CLOEXEC and IN_NONBLOCK if we don't have inotify_init1 for the time
being, and maybe revisit this later.

Test: make checkbuild
Bug: https://github.com/android-ndk/ndk/issues/394
Change-Id: Iefdc1662b21045de886c7ad1cbeba6241163d943
2017-05-22 12:58:18 -07:00
Dan Albert
cdfface662 Undef EPOLL_CLOEXEC for pre-L.
Some third-party code uses the existence of EPOLL_CLOEXEC to detect
the availability of epoll_create1. This is not correct, since having
up-to-date UAPI headers says nothing about the C library, but for the
time being we don't want to harm adoption to the unified headers.
We'll undef EPOLL_CLOEXEC if we don't have epoll_create1 for the time
being, and maybe revisit this later.

Test: make checkbuild
Bug: https://github.com/android-ndk/ndk/issues/302
Bug: https://github.com/android-ndk/ndk/issues/394
Change-Id: I8ee9ce62768fb174070ec51d114f477389befc4a
2017-05-22 12:52:00 -07:00
Elliott Hughes
468c8086e6 Fix _POSIX_THREAD_PROCESS_SHARED.
We've had pthread_*_setpshared for long enough that there are no
__INTRODUCED_IN guards.

Found because fio's configure script was confused by this.

Bug: N/A
Test: ran tests
Change-Id: I07b4d937741e4dcd7e615f2371b17c827341917a
2017-05-20 13:11:14 -07:00
Elliott Hughes
8fbd15a6d0 Merge "Make union semun usable." 2017-05-19 18:24:09 +00:00
Elliott Hughes
497ad30d7d Make union semun usable.
This is a bit bogus because it's been removed from glibc (though not
thoroughly) and is never useful on Android (because the system calls
in question are compiled out of Android kernels, and SELinux would
disallow them even if you weren't running an Android kernel). This
also means that on glibc you need to include <linux/sem.h> for this
and on bionic you need <sys/sem.h> (and for either if you #include
the other file, you won't get this union).

Bug: https://github.com/android-ndk/ndk/issues/400
Test: added new test
Change-Id: I47f721da77515531f616d6ad8479bfbc9b60ee47
2017-05-18 15:05:26 -07:00
Christopher Ferris
083923d96a Make mallopt available in the future.
I made this in 26 but it's really only available in the future.

Test: Built angler image.
Change-Id: I9e1179b350103bf1b8774459a9e210b377300d40
2017-05-17 14:48:59 -07:00
Christopher Ferris
a1c0d2fd4c Add support for modifying decay timer.
Add the mallopt function, and only a single option so far.

Bug: 36401135

Test: Built and booted bullhead.
Test: Ran jemalloc unit tests.
Test: Ran bionic unit tests.
Test: Ran a test that allocated and free'd a large piece of memory,
Test: and verified that after changing the parameter, the PSS
Test: sticks around (decay timer set to 1), the PSS is purged (decay
Test: timer set to 0).
Change-Id: I6927929b0c539c1023d34772d9e26bb6a8a45877
2017-05-15 16:59:16 -07:00
Elliott Hughes
d390df1dbc Restore ELF32_ST_INFO/ELF64_ST_INFO.
Mistakenly removed years ago, along with its genuinely duplicated companions.
This patch also redefines one of those rather than use the Linux uapi header
definition, which leads to signed/unsigned warnings in calling code.

Bug: https://github.com/android-ndk/ndk/issues/377
Test: ran tests
Change-Id: Ib25b17949f04969f12b945ca88ab87d080677cf9
2017-04-30 22:56:10 -07:00
Yi Kong
82f7208ac0 Merge "Update bionic after Clang rebase" 2017-04-26 23:00:41 +00:00
Elliott Hughes
7ba2bed0b2 Make unified headers' SIGRTMIN/SIGRTMAX usable before API 21.
Bug: https://github.com/android-ndk/ndk/issues/352
Test: built new NDK test
Change-Id: Iacebe574bbf693701949e038005a40ba6520d592
2017-04-26 14:34:36 -07:00
Yi Kong
06be3459ca Update bionic after Clang rebase
After the new rebase of Clang, we now supports alloc_size attribute, so
we can remove the warning about switching to alloc_size once Clang has
support.

Compiler.setInvocation has changed argument type from raw pointer to
shared pointer. Add version check here so that we can build under either
old rebase or the new rebase.

Test: build
Bug: 37423073
Change-Id: I4563eaf93bae6c59a4a19318f8caa92bd361b3ab
2017-04-26 10:44:12 -07:00
Elliott Hughes
e54e64bd60 Merge "Make the _Unwind_Ptr declaration match clang's." 2017-04-21 19:52:32 +00:00
Elliott Hughes
f2c6ad6338 Make the _Unwind_Ptr declaration match clang's.
Bug: https://issuetracker.google.com/37126620
Test: builds, boots angler
Change-Id: I7d4a9b998f2e5c4c7b0beed87807d7b76a564c5c
2017-04-21 19:52:21 +00:00
Josh Gao
2e8e5e60b6 DO NOT MERGE: The future is now.
__INTRODUCED_IN_FUTURE -> __INTRODUCED_IN(26)

Bug: http://b/37437368
Test: treehugger
Change-Id: I601a23da83b65a0cd582cc840ed3856a9031b673
(cherry picked from commit cb302f932a)
2017-04-20 16:57:25 -07:00
Treehugger Robot
64cdd0c886 Merge "Make all the ELF relocation constants available." 2017-04-19 22:29:42 +00:00
Treehugger Robot
237c3ee0f8 Merge "libc: fix typo in __RENAME macro" 2017-04-19 20:31:41 +00:00
Elliott Hughes
5109bb463d Make all the ELF relocation constants available.
BSD thinks you should only get the relocation constants for your target
architecture, but it's often useful to have them all available at once.
Rearrange the headers to enable that.

Also update the (modified) NetBSD files to CVS HEAD.

Also remove the unused BSDism R_TYPE.

Bug: N/A
Test: builds
Change-Id: Iad5ef29192a732696e2b36af35144a9ca116aa46
2017-04-19 13:28:32 -07:00
George Burgess IV
31e5a35f3d libc: fix typo in __RENAME macro
Apparently __strncpy_real redirects to strcpy instead of strncpy for GCC
builds. This is bad, and it confused a project compiled by GCC that uses
strcpy.

I audited all of the FORTIFY-related __RENAMEs both manually and with a
script I hacked together; they all look correct aside from this one.

FWIW, with the cleaned up clang FORTIFY, lots of the `void foo()
__RENAME(foo)` will just become `void foo()` if this last thing I'm
working on gets through review.

Bug: 35329524
Test: Previously broken project now seems to work. Bullhead and Ryu
both build + boot.

Change-Id: Ib18ee3535ae31eb7e8ae846dc012f9b64cac80bf
2017-04-19 18:46:44 +00:00
Elliott Hughes
0446c8c095 Add missing arch-specific AT_ cruft.
AP_FPUCW is referenced by valgrind.

Bug: https://bugs.kde.org/show_bug.cgi?id=339945
Test: valgrind builds with one less hack
Change-Id: I7146f3709286662108cc82ba3c55ce935375a1f1
2017-04-19 10:52:35 -07:00
Treehugger Robot
791989d250 Merge "Add PT_ARM_EXIDX." 2017-04-18 22:47:00 +00:00
Treehugger Robot
57e7a0d853 Merge "Un-deprecated __system_property_find_nth." 2017-04-17 23:45:57 +00:00
Dan Albert
3914b19bd4 Add PT_ARM_EXIDX.
The updated LLVM libunwind needs this to be defined.

Test: make checkbuild
Bug: None
Change-Id: Ia20016a9e3becb37ea6902f1959d1884c1263e51
2017-04-17 16:06:59 -07:00
Elliott Hughes
438e01940b Un-deprecated __system_property_find_nth.
Netflix was using this, and looking the header file, although
__system_property_find_nth has been available since the beginning of time,
__system_property_foreach only appeared in 16. So anyone who wants to run
on pre-JellyBean devices would want to use __system_property_find_nth.

It's pretty much a one-liner in terms of __system_property_foreach anyway,
so it doesn't cost us anything to keep it.

Also restore slightly better tests than we originally removed.

Bug: http://b/36566667
Test: ran tests
Change-Id: Id268c2c2e848da17bb0a5a5420af234d9dcb829a
2017-04-17 14:53:07 -07:00
Elliott Hughes
ef2b2fe99e Link to the public post about clang FORTIFY.
Bug: N/A
Test: builds
Change-Id: I1c2040fdd3c3bbe61a8adfc1f414fce50087a1b8
2017-04-16 08:50:58 -07:00