Commit graph

2219 commits

Author SHA1 Message Date
Zijun Zhao
6bda367899 Merge "Nullability check for dlfcn module" 2023-03-02 00:32:47 +00:00
zijunzhao
447c346475 Nullability check for dlfcn module
Bugs: b/245972273
Test: adb shell
Change-Id: I0ecde8a0f1f71b6ec2262ff637d33c518578d54d
2023-03-01 21:29:41 +00:00
zijunzhao
e7d41ab7c0 Nullability check for ifaddrs module
Bugs: b/245972273
Test: adb shell
Change-Id: Iccb419667282922d31e2c81b3d9dbac8b6009a76
2023-03-01 01:36:30 +00:00
Elliott Hughes
93398b1b14 Merge "Remove <pthread.h> cruft." 2023-02-28 16:27:57 +00:00
zijunzhao
6b6d51e9ea Nullability check for stdio_ext module
Bugs: b/245972273
Test: adb shell
Change-Id: I4175218f6fa7f4581a739bb0f12cf10b6bdb529e
2023-02-27 23:34:25 +00:00
Elliott Hughes
9108f258ad Remove <pthread.h> cruft.
The next NDK to take these headers only supports API 21 and later.

Note that this change leaves the _implementation_ of these functions
behind, so that any old apps calling these APIs should continue to work,
you just can't (without declaring the functions yourself) write new ones
that do (and declaring the functions yourself would only work on LP32
anyway, so that's not going to get you very far in 2023).

Test: treehugger
Change-Id: Ie03514e4215b40f6e9feaa6e4bf5df5b16dc8d59
2023-02-27 21:31:11 +00:00
Elliott Hughes
957d34a85c Merge "Remove libandroidsupport cruft." 2023-02-25 02:28:38 +00:00
Elliott Hughes
20cd43a66d Merge "Remove <stdlib.h> cruft." 2023-02-24 23:35:29 +00:00
Zijun Zhao
41a4aa3174 Merge "Nullability check for iconv module" 2023-02-24 23:14:16 +00:00
Zijun Zhao
67737cdf9f Merge "Nullability check for error module" 2023-02-24 23:08:57 +00:00
Zijun Zhao
2b26a1e22c Merge "Nullability check for ftw module" 2023-02-24 20:33:47 +00:00
Elliott Hughes
fbd79707c3 Remove <stdlib.h> cruft.
The next NDK to take these headers only supports API 21 and later.

Test: treehugger
Change-Id: Ib5962989c5c978996b04789c21c0822dd8792303
2023-02-24 19:48:50 +00:00
zijunzhao
377954fdc6 Nullability check for error module
Bugs: b/245972273
Test: adb shell
Change-Id: I9d1c20cf2a7e1e4201c3c54a321c9d9f896c92e2
2023-02-24 19:44:21 +00:00
Elliott Hughes
fa7c0dbf47 Remove libandroidsupport cruft.
The next NDK to take these headers only supports API 21 and later.

Test: treehugger
Change-Id: I084ec887158ce4e40d6927df49da748671bfd127
2023-02-24 19:33:33 +00:00
Elliott Hughes
f2ca0bc13d Merge "Remove <sys/socket.h> inlines for obsolete API levels." 2023-02-24 19:23:51 +00:00
Elliott Hughes
59d90262ed Merge "Remove <fenv.h> inlines for obsolete API levels." 2023-02-24 19:23:24 +00:00
Elliott Hughes
f5e899d84d Merge "Remove <sys/stat.h> inlines for obsolete API levels." 2023-02-24 19:23:15 +00:00
Elliott Hughes
af17562d0e Merge "Remove <time.h> cruft." 2023-02-24 19:23:06 +00:00
Elliott Hughes
7dfa18a49f Merge "Remove <signal.h> inlines for obsolete API levels." 2023-02-24 19:19:19 +00:00
Elliott Hughes
66734f0c35 Merge "Remove <sys/mman.h> inlines for obsolete API levels." 2023-02-24 19:19:13 +00:00
Elliott Hughes
d54d92c4fd Merge "Remove <errno.h> inlines for obsolete API levels." 2023-02-24 19:18:38 +00:00
zijunzhao
32b6d4371e Nullability check for iconv module
Bugs: b/245972273
Test: adb shell
Change-Id: I9b6223b039cffda1f665c01013900824b35a8e42
2023-02-24 02:32:35 +00:00
zijunzhao
d6af63b795 Nullability check for ftw module
Bugs: b/245972273
Test: adb shell
Change-Id: If132a01d3e07ddb92a81e3289aa7cd4f83b44b51
2023-02-24 01:44:26 +00:00
Elliott Hughes
b5ff68cf24 Remove a tautology from <bits/threads_inlines.h>.
The next NDK to take these headers only supports API 21 and later.

Test: treehugger
Change-Id: I31a07842a498e818ec8f16c217c365b100a5e05b
2023-02-24 01:02:24 +00:00
Elliott Hughes
f4105789fb Remove <time.h> cruft.
The next NDK to take these headers only supports API 21 and later, but
even if it didn't --- there is no inline!

Test: treehugger
Change-Id: Ibb194e1cbf0a8551bff863d940d92c35ed06a1e1
2023-02-24 00:56:25 +00:00
Elliott Hughes
82b0d52cb0 Remove <sys/socket.h> inlines for obsolete API levels.
The next NDK to take these headers only supports API 21 and later.

Test: treehugger
Change-Id: I445eb6ea2d42c3c8a4beb12ef88ba423cfb64f20
2023-02-24 00:46:48 +00:00
Elliott Hughes
19ed204031 Remove <sys/mman.h> inlines for obsolete API levels.
The next NDK to take these headers only supports API 21 and later.

Test: treehugger
Change-Id: I64baf933d3796f20dee5c1465ed58f8bb45394b5
2023-02-24 00:41:30 +00:00
Elliott Hughes
acaaab007c Remove <errno.h> inlines for obsolete API levels.
The next NDK to take these headers only supports API 21 and later.

Test: treehugger
Change-Id: Ie9e9bc82612a326d9e608b0d5974231f4acc5638
2023-02-24 00:32:47 +00:00
Elliott Hughes
432a4afb1e Remove <signal.h> inlines for obsolete API levels.
The next NDK to take these headers only supports API 21 and later.

Test: treehugger
Change-Id: I8fe617e6eb781629ddf0b98b0037a9b3e54c559c
2023-02-24 00:28:20 +00:00
Elliott Hughes
2f5829b55d Remove <fenv.h> inlines for obsolete API levels.
The next NDK to take these headers only supports API 21 and later, so
clean up some of the trivial cruft.

Test: treehugger
Change-Id: Ib735a776d244cc82858f2ed629dd63a54dbaf650
2023-02-24 00:16:41 +00:00
Elliott Hughes
3f3a8cd57e Remove <sys/stat.h> inlines for obsolete API levels.
The next NDK to take these headers only supports API 21 and later.

Test: treehugger
Change-Id: Ia2a4c04fdd144cfbe961bdf8d4f53bd4958befe8
2023-02-23 22:53:37 +00:00
Elliott Hughes
b890ff36d1 Merge "libc/include: remove easy __ANDROID_API__ tautologies." 2023-02-23 22:45:57 +00:00
Elliott Hughes
6ccb71ca0c Merge "Remove <sys/statvfs.h> inlines for API level 19." 2023-02-23 18:55:04 +00:00
Elliott Hughes
f4ace9d634 libc/include: remove easy __ANDROID_API__ tautologies.
The next NDK to take these headers only supports API 21 and later, so
clean up some of the trivial cruft.

This doesn't include the remaining "legacy inlines", since they're a bit
more complicated. I'll remove those in later changes.

Test: treehugger
Change-Id: I94c32f6393dd3ae831165917303ea591222baa0d
2023-02-23 17:38:37 +00:00
Elliott Hughes
3c3736e1bd Remove <sys/statvfs.h> inlines for API level 19.
API level 19 is no longer supported by the NDK.

While I'm here, let's remove the duplicated structure defintion (as
we've already done for `struct stat`).

Test: treehugger
Change-Id: I9d8286f9e7ba803f3131b6dcb0486ff1b0f9d5d1
2023-02-22 21:58:24 +00:00
Elliott Hughes
d3ebc2f7c4 Merge "Remove <stdlib.h> abs/labs/llabs inline for API level 19." 2023-02-21 21:14:49 +00:00
zijunzhao
3e39b3ac4a Nullability check for glob module
Bugs: b/245972273
Test: adb shell
Change-Id: Ic631bfe3c70080f140bb1be13e98ab751ab52252
2023-02-19 22:33:27 +00:00
Elliott Hughes
5fb10ce72d Merge "Remove <sys/wait.h> wait4() inline for API level 18." 2023-02-18 15:56:49 +00:00
Elliott Hughes
0572153fea Merge "Add documentation for a couple of pthread functions." 2023-02-18 02:12:08 +00:00
Elliott Hughes
527d01221e Remove <stdlib.h> abs/labs/llabs inline for API level 19.
API level 19 is no longer supported by the NDK.

Test: treehugger
Change-Id: I9fa1e9b3c492b3d3384e393994a7dddfdb35d805
2023-02-17 23:51:57 +00:00
Elliott Hughes
ed07723a34 Remove <sys/wait.h> wait4() inline for API level 18.
API level 18 is no longer supported by the NDK.

Test: treehugger
Change-Id: I526b628bf3aa9215c9832275f7eeaa15b52a107d
2023-02-17 23:41:55 +00:00
Elliott Hughes
8d8a911eab Add documentation for a couple of pthread functions.
These cause great confusion, so explicitly point out that apps can't use
one, and probably want the other.

Bug: https://github.com/android/ndk/issues/1255
Test: N/A
Change-Id: I287e820dc45a8446e3c72c9a2e4007db76828e3b
2023-02-17 23:31:17 +00:00
Treehugger Robot
c83efcab83 Merge "Nullability check for fenv module" 2023-02-16 18:57:36 +00:00
Zijun Zhao
fa2ac8440d Merge "Nullability check for swap module" 2023-02-16 17:49:28 +00:00
Treehugger Robot
f4fdf0a702 Merge "Nullability check for wctype module" 2023-02-16 03:26:23 +00:00
zijunzhao
37a136fc2c Nullability check for fenv module
Bugs: b/245972273
Test: adb shell
Change-Id: Id930d187169820cf15bc9e5b4907a0984ee277ca
2023-02-16 01:41:55 +00:00
zijunzhao
b0fba720ff Nullability check for swap module
Bugs: b/245972273
Test: adb shell
Change-Id: I75e7e50d9ca08b82551851f877af8b2d309137b4
2023-02-16 01:40:05 +00:00
zijunzhao
c0d5b4718e Nullability check for wctype module
Bugs: b/245972273
Test: adb shell
Change-Id: Ic60a1b77e3f16bc9c3808ab4f772d6f174116a75
2023-02-15 23:24:40 +00:00
zijunzhao
557d9a553c Nullability check for vfs module
Bugs: b/245972273
Test: adb shell
Change-Id: Icaaa69641f72a58326afbd6691c8df8f4e774363
2023-02-15 23:22:10 +00:00
zijunzhao
02c4ef4d78 Nullability check for string module
Bugs: b/245972273
Test: adb shell
Change-Id: I4c71bca1ff72553b27805722c3076ed105612a21
2023-02-14 20:47:10 +00:00
zijunzhao
d555a333c8 Nullability check for epoll module
Bugs: b/245972273
Test: adb shell
Change-Id: Ic09eb9c503992178b5f271f80208ea159ee040be
2023-02-14 02:27:20 +00:00
zijunzhao
38c5344446 Nullability check for signal module.
Bugs: b/245972273
Test: None
Change-Id: I958e7fd7836afd1e6ff9f2c808171faa602022c7
2023-02-10 02:16:41 +00:00
zijunzhao
195b90b83f Nullability check for math module
Bugs: b/245972273
Test: adb shell
Change-Id: I46bf02e1ed3d6e6143c780e30f95fa3af2745216
2023-02-09 00:25:29 +00:00
Treehugger Robot
bc516bf20a Merge "Nullability check for eventfd module" 2023-02-07 22:50:56 +00:00
zijunzhao
9729c193cb Nullability check for eventfd module
Bugs: b/245972273
Test: None
Change-Id: I5a74318850f3e49dd9d78180476e2a9d76853606
2023-02-07 20:47:11 +00:00
Treehugger Robot
f82ee4a37a Merge "Nullability check for klog module" 2023-02-07 16:35:27 +00:00
zijunzhao
1cda74daba Nullability check for stat module
Bugs: b/245972273
Test: None
Change-Id: I8611c7d7c22e2fb6b0cec4b5101dbcb3174ae706
2023-02-07 06:58:39 +00:00
Treehugger Robot
a3357c28f5 Merge "Nullability check for quota module" 2023-02-04 04:12:16 +00:00
zijunzhao
e716b1b3ee Nullability check for klog module
Bugs: b/245972273
Test: adb shell
Change-Id: I43634184ff8785fa8096d7e8034b22da452cfdd4
2023-02-03 21:56:56 +00:00
zijunzhao
4b8a126255 Nullability check for sysinfo module
Bugs: b/245972273
Test: None
Change-Id: Ie351c609136d1873d3969788246d8a4d8b77ac55
2023-02-03 20:05:05 +00:00
zijunzhao
7833a70000 Nullability check for quota module
Bugs: b/245972273
Test: adb shell
Change-Id: Ic300055163c852d1955d0dc419794b25395ce9a3
2023-02-03 20:03:34 +00:00
zijunzhao
3d59110f72 Nullability check for unistd module
Bugs: b/245972273
Test: None
Change-Id: I6037b1cd0bf233476a1cc0fbc8308a87de50c550
2023-02-01 20:40:35 +00:00
zijunzhao
93eb87007a Add BIONIC_COMPLICATED_NULLNESS as _Null_unspecified
In some cases, the nullability of the pointer argument is too
complicated. Developers have better check relevant manuals or
code before annotating.

Bugs: b/245972273
Test: None
Change-Id: I3589a5080b267d1766cc8ed99868129ac16e4012
2023-01-31 22:51:30 +00:00
zijunzhao
4aa1ea04d7 Nullability check for fcntl module
Bugs: b/245972273
Test: None
Change-Id: I48d23c7bc80863cd3a67ab424780308fe6929292
2023-01-30 19:48:44 +00:00
zijunzhao
64b1fe21b7 Nullability check for nl_types module
Bugs: b/245972273
Test: None
Change-Id: Idc05efd6613c99292bd3c095679ac20bb6e8bf8f
2023-01-26 06:48:13 +00:00
zijunzhao
d9755064a6 Nullability check for utmp module
Bugs: b/245972273
Test: None
Change-Id: Ie37781b87ad13119d1ebc4cd053e184d482d5b58
2023-01-25 19:22:27 +00:00
zijunzhao
4730fb6cc8 Nullability check for termios module
Bugs: b/245972273
Test: None
Change-Id: Ic91fa6ebc87bff513740c1b757a726505e4dae0e
2023-01-14 01:01:51 +00:00
zijunzhao
e951acd2ca Nullability check for execinfo module
Bugs: b/245972273
Test: None
Change-Id: I136926d5b82f62e11df716a26d0847a6bd83a419
2023-01-13 02:14:10 +00:00
zijunzhao
6daedb7c41 Nullability check for inttypes module
Bugs: b/245972273
Test: None
Change-Id: Ibc6edd389a9f7cb4d2d5f625ba67163eeda98979
2023-01-11 00:32:16 +00:00
Treehugger Robot
57c8646f59 Merge "Nullability check for malloc module." 2023-01-07 01:28:42 +00:00
zijunzhao
979d39cb82 Nullability check for syslog module.
Bugs: b/245972273
Test: None
Change-Id: I630597ac2101e16f5566208019a9a54e78fe5667
2023-01-06 20:22:58 +00:00
zijunzhao
e620266d1c Nullability check for time module.
Bugs: b/245972273
Test: None
Change-Id: I65adc146f88bbd948f61d2f22bdec344faba09ae
2023-01-05 00:18:18 +00:00
zijunzhao
f043619125 Nullability check for langinfo module.
Bugs: b/245972273
Test: None
Change-Id: I92df36179d25ec668647f15848e5164eeb5d4d70
2023-01-03 19:52:35 +00:00
zijunzhao
1a49058e66 Nullability check for malloc module.
Bugs: b/245972273
Test: None
Change-Id: I33e164c23d5b7d09af003f3d85e02e676b78aa55
2022-12-15 21:47:53 +00:00
Treehugger Robot
65584f3264 Merge "Nullability check for libgen module." 2022-12-15 01:04:20 +00:00
zijunzhao
ab17c07f1e Nullability check for libgen module.
Bugs: b/245972273
Test: None
Change-Id: I41c741701a5b4416a09c3c683a0817b219262c6d
2022-12-13 00:06:09 +00:00
Elie Kheirallah
056549795c Add rlim64_t to libc/include/sys/resource
crosvm is using rlim64_t. Adding for portability.

Bug: 255594691
Test: m libc && m bionic
Change-Id: I752bfdaa23d900278fe7224306d785b0c9f67d3f
2022-12-08 23:32:11 +00:00
zijunzhao
5a918d922b Nullability check for stdlib module.
Bugs: b/245972273
Test: None

Change-Id: Ib33a5359a924c21888f268158c4d7f824740dd55
2022-12-02 21:00:02 +00:00
Elliott Hughes
d4fd67ce69 Add some missing "Available since" documentation.
Also fix formatting of `errno` in one function.

Test: treehugger
Change-Id: Ibf362bcd36c901dab2a422afe09e0f78011315aa
2022-11-30 19:55:32 +00:00
zijunzhao
7ececf1140 Nullability check for regex module.
Bugs: b/245972273
Test: None
Change-Id: Ie2c0f3dcbbe1dcbe04d4a6acfac445d556f0c38d
2022-11-10 20:32:47 +00:00
Elliott Hughes
8e826775fb Use the same union in riscv64's ucontext.
We don't need this (any more than arm64 does), because riscv64 is too
new to have had a too-small sigset_t, but it's useful for source code
compatibility with code that needs to build on arm32/x86 too.

Test: treehugger
Change-Id: Ied5f64d9094bc7d31c059f82f9e4ffe9b8ca4061
2022-11-09 16:38:00 +00:00
Elliott Hughes
88e4e60a75 Sync with upstream NetBSD.
Test: treehugger
Change-Id: Ia82ba4a0c00a47377240e5d9a85dc30deb5ce3b7
2022-11-08 02:51:48 +00:00
Elliott Hughes
e1905ed629 riscv64 setjmp.
Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: m
Change-Id: I02cf117f67bda74516e4de8cd6f4c05efdb9a85b
2022-10-17 23:23:36 +00:00
Colin Cross
91529b75cf Add REG_S0 to ucontext.h for riscv64
REG_S0 is needed by Clang's sanitizer runtimes:
https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp#L2218

Test: clang build
Change-Id: Id9a82e977dcbdddf5505495b59057cf4564c9e35
2022-10-13 13:27:18 -07:00
Elliott Hughes
287f48e6e5 riscv64: more <sys/ucontext.h>.
Actually, we don't want to reuse the kernel struct ucontext because its
uc_mcontext has the wrong type, which means the fields within that end
up with the wrong names. Add the call site that made that evident, and
update <sys/ucontext.h> appropriately.

Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: treehugger
Change-Id: If1d079afef0d5953aa22d9b0e049cfb0119c7718
2022-10-11 00:01:35 +00:00
Elliott Hughes
4043e5ea96 Add riscv64 <ucontext.h>.
Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: treehugger
Change-Id: Ieb7cb71cd735b6629d507efb0a5e35ee653e4d20
2022-10-10 20:15:51 +00:00
Elliott Hughes
5b2552a030 Merge "riscv64 <sys/user.h>." 2022-10-10 16:36:10 +00:00
Elliott Hughes
4c6d66c472 riscv64 <fenv.h>.
Just the interface for now; implementation to come later.

Test: treehugger
Change-Id: Id1f0b158f708ff501b5e13fe92c6736e4507d7b6
2022-10-07 21:15:26 +00:00
Elliott Hughes
cf123811b7 riscv64 <sys/user.h>.
Empty, at least for now. The other libcs seem not to have invented types
here, so let's see whether there's really a call for them before we do.

Test: treehugger
Change-Id: Icbace2c02abc011388edc8e3e238bb64c640feb7
2022-10-07 20:49:07 +00:00
Elliott Hughes
0f19b10b5d Switch to FreeBSD's elf_common.h.
In particular, it contains all the riscv64 definitions we need, and lets
us clear up a lot of our existing ELF headers.

The other two BSDs seem to have errors and/or gaps in their riscv64
constants.

Test: treehugger
Change-Id: I92e48ef56c52c271ff6ed341b82169aa91f11d98
2022-10-07 00:04:44 +00:00
Elliott Hughes
5cc8a46419 riscv64's struct stat is the same as arm64's.
(And all other new architectures.)

Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: treehugger
Change-Id: Iceb2dd16c738302624980179788c4a2e68b797ed
2022-10-06 00:26:18 +00:00
Elliott Hughes
ee41a35cc1 Extend the process_madvise() docs.
In particular, explain why we don't have process_mremove(), and why
adding this was probably a mistake (lest it be used as precedent for
similar bad decisions in future).

Also add the missing __INTRODUCED_IN().

Test: treehugger
Change-Id: Ic2d7ef32f6e288353b5be2bffd000ad2f501bf39
2022-09-27 19:27:10 +00:00
Elliott Hughes
82be76b5a2 Add __freadahead.
At the time I added <stdio_ext.h>, I just added what was on the man
page (which matched glibc), not realizing that musl and glibc had
slightly different functionality in their headers.

The toybox maintainer came up with a legitimate use case for this, for
which there is no portable workaround, so I'm adding it here. I'm not
adding the other functions that are in musl but not glibc for lack of a
motivating use case.

Bug: http://lists.landley.net/htdig.cgi/toybox-landley.net/2022-April/020864.html
Test: treehugger
Change-Id: I073baa86ff0271064d4e2f20a584d38787ead6b0
2022-09-22 23:47:42 +00:00
Brian Duddie
5cfca6b832 Add fdsan owner type for native_handle_t
Bug: 244214188
Test: validated alongside sensor service change
Change-Id: Ia576b551012c50def8a8ebe82115ceac35070dcb
2022-08-29 21:29:45 +00:00
Elliott Hughes
963e24b93e setjmp.h: add the missing __returns_twice to sigsetjmp().
setjmp() and _setjmp() were already correct, but we'd missed
sigsetjmp(). Found while investigating a toybox timeout(1) failure on
macOS, which doesn't annotate _any_ of these functions.

Also add all the missing doc comments while I'm here.

Test: treehugger
Change-Id: I69dc2587d140916d172237173c2bd56547a4ed8a
2022-08-25 20:13:00 +00:00
Elliott Hughes
0d64243407 Add C23's memset_explicit().
https://open-std.org/jtc1/sc22/wg14/www/docs/n2897.htm

Test: treehugger
Change-Id: Ia0cfc72bdf3c22eda6a4fc9adaa4c0ca0ff9a7c8
2022-08-10 23:36:16 +00:00
Elliott Hughes
7b396aee5f Add the other known aliases for the recent Android releases.
Test: treehugger
Change-Id: Ic861cba14236a8e4cd60be340407a8c80cda6c8f
2022-07-15 17:04:50 -07:00
Michael Wright
8cd2ebf80e Add Android U API level to NDK headers
Test: Build
Change-Id: Ic1e0d8b7e5abf07045944d2f610764709b45c923
2022-06-25 00:56:08 +00:00
Christopher Ferris
10a76e674d Update to v5.18 kernel headers.
Kernel headers coming from:

Git: https://android.googlesource.com/kernel/common/
Branch: android-mainline
Tag: android-mainline-5.18

The file bionic/libc/kernel/uapi/linux/android/binder.h had a bug
in the original 5.18 kernel headers. This was fixed upstream, so
add a comment to the structure but leave the incorrect field the
same as the 5.17 kernel headers.

Bug: 234125620

Test: Builds.
Test: All bionic unit tests pass on a coral device.
Test: Able to log in to wembley system.
Change-Id: Ia72cafbe71fd894c599e15aa5334d7bbcbe74778
2022-06-08 13:31:52 -07:00
Elliott Hughes
900a9890e4 Mention O_CREAT and O_TMPFILE in both open(2) fortify messages.
Spotted while reading gbiv's forthcoming "how fortify works"
documentation.

Test: treehugger
Change-Id: I89827bc9afa8e445de8361e938075fabf73ac518
2022-06-06 23:50:34 +00:00
Greg Kaiser
55b5639cca Revert "Update to v5.18 kernel headers."
Revert "Update to v5.18 kernel headers."

Revert submission 2106847-kernel_update

Reason for revert: b/234125620
Reverted Changes:
I5844ca1fc:Update to v5.18 kernel headers.
I5700813ee:Update to v5.18 kernel headers.
Bug: 234125620

Change-Id: I07a39aa9c01939455b5a2a9da5fc04be497ca399
2022-05-27 20:41:14 +00:00
Christopher Ferris
5d3679612f Update to v5.18 kernel headers.
Kernel headers coming from:

Git: https://android.googlesource.com/kernel/common/
Branch: android-mainline
Tag: android-mainline-5.18

Test: Builds.
Test: All bionic unit tests pass on a coral device.
Change-Id: I5700813eec0fb0db55bee4d75b129400b7a239bd
2022-05-25 14:30:25 -07:00
zijunzhao
c2e412e086 Add copy_file_range(2) syscall stub to bionic.
Test: treehugger
Bug: https://buganizer.corp.google.com/issues/227784687
Change-Id: I543306cd2234189401bf7c9d80d405eeb6e4d41d
2022-05-12 16:53:41 +00:00
Treehugger Robot
c66cb5ba6a Merge "add new Linux close_range() system call to bionic" 2022-05-06 22:25:26 +00:00
Maciej Żenczykowski
b65e105047 add new Linux close_range() system call to bionic
See:
  https://man7.org/linux/man-pages/man2/close_range.2.html

Note: 'man close_range' documents 'flags' as unsigned int,
while glibc unistd.h as just 'int'.  Picking 'int' to match glibc,
though it probably doesn't matter.

BYPASS_INCLUSIVE_LANGUAGE_REASON=man is a cli command
Test: TreeHugger
Bug: 229913920
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1e2d1c8edc2ea28922d60f3ce3e534a784622cd1
2022-05-06 10:33:04 +00:00
Ryan Prichard
88134649ee legacy strtof inline: don't set errno for "inf"
Bug: https://github.com/android/ndk/issues/415
Test: libc++'s std/strings/string.conversions/stof.pass.cpp
Change-Id: I2c6bab9e31fb1c916be991f72b04735b5df279c2
2022-04-28 23:17:33 -07:00
Maciej Żenczykowski
262b873dea posix_spawn - implement support for POSIX_SPAWN_CLOEXEC_DEFAULT
This new posix_spawn attribute flag marks all file descriptors
(except stdin/out/err) as close-on-exec before executing any user
registered file actions (posix_spawn_file_actions_addopen/adddup2).

Test: TreeHugger
Bug: 229913920
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If458100d6a253a9b0348d4e93a9a610225f89615
2022-04-21 07:09:55 -07:00
Treehugger Robot
2b64e4000d Merge "Avoid usage of LONG_BIT in signal headers." 2022-03-24 21:10:41 +00:00
Peter Collingbourne
08b968b282 Avoid usage of LONG_BIT in signal headers.
Clang has its own limits.h which is ahead of ours on the inclusion
path. This header uses include_next to include our header, but only
in hosted mode. This means that in freestanding mode we don't get our
limits.h macro definitions, including LONG_BIT. This ends up causing
our signal.h to produce errors when included in freestanding mode on
32-bit platforms.

Fix the errors by replacing usage of LONG_BIT with (8 * sizeof(long))
in the signal headers.

Change-Id: I18ec7b6876d5f862beae09f0c011128eef97c869
2022-03-24 11:11:11 -07:00
Christopher Ferris
1ed5534657 Update to v5.17 kernel headers.
Kernel headers coming from:

Git: https://android.googlesource.com/kernel/common/
Branch: android-mainline
Tag: android-mainline-5.17

Test: Boots on a flame and all bionic unit tests pass.
Change-Id: I7057d7308241f3acfa600597d287994c39ababbc
2022-03-22 16:48:40 -07:00
Pirama Arumuga Nainar
07cdd57d53 Remove clang version check around diagnose_as_builtin
Bug: http://b/197147102

versioner in aosp/1997532 is built with clang-r445002 and understands
the new attribute.

Test: mmma bionic
Change-Id: Ia3e3c3840e6013446d2679587b72011aff8c50eb
2022-02-23 17:51:55 +00:00
Pirama Arumuga Nainar
db71defb66 Annotate fortify functions with diagnose_as_builtin
Bug: http://b/197147102
Bug: http://b/214080353

With https://reviews.llvm.org/D77491, clang got stricter when issuing
diagnostics regarding builtin functions.
https://reviews.llvm.org/D112024 adds a diagnose_as_builtin attribute
which lets it diagnose builtins even though their signature is slightly
different.  This patch adds diagnose_as_builtin attribute as needed.

Versioner is built with an older clang so it doesn't recognize this
attribute.  So this is added with a preprocessor check on clang
versions.  We can remove the version check once versioner gets updated
shortly after the compiler update.

Test: mmma bionic/tests with clang-r445002
Change-Id: I3d0d63ecdbea0cffe97eb5110e2d9f2a7595a38e
2022-02-03 11:53:52 -08:00
Treehugger Robot
5396787062 Merge "Fix copy pasta in guard macro for weak symbols." 2022-01-12 22:19:11 +00:00
Christopher Ferris
a479261feb Update to v5.16 kernel headers.
Kernel headers coming from:

Git: https://android.googlesource.com/kernel/common/
Branch: android-mainline
Tag: android-mainline-5.16

Test: Builds and bionic unit tests pass.
Change-Id: I2522c4f2a0efb9f8a193e1f2d65868e478217502
2022-01-10 13:51:15 -08:00
Dan Albert
e4106253e7 Fix copy pasta in guard macro for weak symbols.
This was pretty broken. I think anything using this was being given
always-available annotations for everything but 32-bit x86? Treehugger
should complain loudly if this was actually impacting anything though.
I suspect not since the only user of this mode is mainline which
doesn't target far back enough to have arch-specific introduction
guards.

Test: treehugger
Bug: None
Change-Id: I64e96a89d83e64512e661e88915c48a091198992
2022-01-07 16:06:54 -08:00
Dan Albert
952da92670 Remove availability definitions for mbs APIs.
Definitions for these are provided in libandroid_support for API
levels that do not expose this in the stubs. For the rare cases where
libandroid_support is not being used this will result in a lower
quality diagnostic (undefined reference instead of "not available
until API 21"), but other fixes would also have that behavior because
the libandroid_support headers are *always* available, even if
libandroid_support won't be linked.

Test: Reverted xfailed tests for #1108 and reran tests with this
Bug: https://github.com/android/ndk/issues/1108
Change-Id: I371f5b9d7caeef8dc7c80f2f6d11280ecba119c9
2022-01-07 14:38:29 -08:00
Elliott Hughes
31fbc1469f sched.h: add doc comments.
Test: treehugger
Change-Id: I9a6dd40bb26a5966dd32dbdf573cddc874bcb508
2021-12-15 13:56:39 -08:00
Christopher Ferris
8248e62fa9 Add mallinfo2 call.
Bug: 208293616

Test: New unit tests pass.
Change-Id: I619219b7322e2dd1c82b9c8a171dfbfe7eac6706
2021-12-13 14:26:17 -08:00
Zijun Zhao
02ed7ea425 Merge "Fix incorrect API level for wcstombs and mbstowcs." 2021-11-12 01:32:47 +00:00
ZijunZhao
57474c89fe Fix incorrect API level for wcstombs and mbstowcs.
Mbstowcs and wcstombs cannot get correct return value when called in the environment below api 21, and need to raise the API level to solve the problem.

Test: None
fix bug 1108 https://github.com/android/ndk/issues/1108

Change-Id: Iabcf1bff0be087288646687732ef68870630b48a
2021-11-09 23:29:33 +00:00
Christopher Ferris
2abfa9e4f8 Update to v5.15 kernel headers.
Kernel headers coming from:

Git: https://android.googlesource.com/kernel/common/
Branch: android-mainline
Tag: android-mainline-5.15

Test: Builds, and ran bionic unit tests on flame.
Change-Id: I86901ea6d89fb0f7384b90a47bef35d194083c24
2021-11-02 15:53:58 -07:00
Christopher Ferris
11526e2fc6 Add execinfo functionality.
Bug: 27877410

Test: Add new unit tests.
Change-Id: Id5d7eb27a23f50e99a04f5ee1ab64047ba269bab
2021-10-20 21:53:07 +00:00
Elliott Hughes
cf59e19e22 Add preadv2/pwritev2 wrappers.
They're in glibc, though not in musl.

Also add basic doc comments to the whole of <sys/uio.h>.

Bug: http://b/203002492
Test: treehugger
Change-Id: Ic607f7f349e5b7c9bf66c25b7bd68f827da530d6
2021-10-18 12:58:47 -07:00
Dan Albert
e791552fbb Add API level define for T.
Test: treehugger
Bug: None
Change-Id: I7a973bbd7e8d646f45f4d860d564f9f104aab134
2021-09-08 14:57:46 -07:00
Christopher Ferris
3a39c0bc43 Update to v5.14 kernel headers.
Kernel headers coming from:

Git: https://android.googlesource.com/kernel/common/
Branch: android-mainline
Tag: android-mainline-5.14

Test: Builds, bionic unit tests.
Change-Id: Iff3424da9fbf7ae89ebeb6daabb34c4aa650901f
2021-09-02 00:03:38 +00:00
Colin Cross
d27506716a Define sockaddr_storage in bionic
Bionic currently renames the kernel's __kernel_sockaddr_storage
to sockaddr_storage.  We would like to reuse the bionic kernel
headers for musl, but musl defines its own sockaddr_storage,
causing redefinition errors when the musl and kernel headers
are both included.

Give bionic its own definition of sockaddr_storage so the kernel
one can be left as __kernel_sockaddr_storage, avoiding the
conflict in musl.

Some of the structs in netinet/in.h contain sockaddr_storage members.
There are definitions in linux/in.h, but they now use the
__kernel_sockaddr_storage naming.  To avoid having to copy the structs
from linux/in.h into netinet/in.h, add some #define hackery to
rename __kernel_sockaddr_storage to sockaddr_storage when including
linux/in.h from netinet/in.h.

Bug: 190084016
Test: m checkbuild
Test: bionic-unit-tests
Change-Id: I8f654511722b3a4a8e0bb146e4418ebcd370305c
2021-07-14 14:20:36 -07:00
Christopher Ferris
fcc3b4f45d Update to v5.13 kernel headers.
Kernel headers coming from:

Git: https://android.googlesource.com/kernel/common/
Branch: android-mainline
Tag: android-mainline-5.13

Test: Builds, bionic unit tests.
Change-Id: Ia4360ca4a2808206f64187dcb234d73c5752624b
2021-07-01 01:30:21 +00:00
Evgenii Stepanov
d8d561c984 Add definition of M_MEMTAG_TUNING.
Bug: 191769584
Test: N/A
Change-Id: Ief77f95a04411528563787a9fc6d10738fc5688f
2021-06-24 01:21:00 +00:00
Elliott Hughes
c849ef1063 Improve the <sys/select.h> docs.
Test: treehugger
Change-Id: I00fc6aededc20e89fb46d8dc033bdcb0530a8052
2021-06-17 14:41:29 -07:00
Elliott Hughes
504d0488ad Mark abort(3) as nomerge.
Otherwise, since it's `noreturn`, clang will merge multiple call sites
in the same function, destroying information that helps you debug
_which_ call fired from a tombstone.

Bug: https://github.com/android/ndk/issues/1514
Test: treehugger
Change-Id: I7930318a813f6a2220266794f16c0e5e72d32869
2021-06-07 11:20:28 -07:00
Christopher Ferris
a9750eda0d Update to v5.12 kernel headers.
Kernel headers coming from:

Git: https://android.googlesource.com/kernel/common/
Branch: android-mainline
Tag: android-mainline-5.12

Test: Boots flame device and runs bionic unit tests.
Test: Boots acloud device and runs bionic unit tests.

Change-Id: I8ac107ce9d4978be3ef9517b90ad6ecafd06785a
2021-05-03 15:01:39 -07:00
Elliott Hughes
39899f592b Fix return type of process_madvise().
Noticed this from
https://man7.org/linux/man-pages/man2/process_madvise.2.html but
independently confirmed by checking the kernel source.

Also fix the documentation.

Test: treehugger
Change-Id: I6beeeeb2178a58a22a36532e634917b3ae8767ee
2021-04-06 16:38:37 -07:00
George Burgess IV
a1112fd880 fortify: mark all always_inline functions with no_stack_protector
FORTIFY'ed functions try to be as close to possible as 'invisible';
having stack protectors detracts from that.

Don't apply this to functions which clang has no chance of inlining
anyway (like variadic functions)

Bug: 182948263
Test: TreeHugger
Change-Id: I08cfec25464b8ea1e070942e3dc76fc84da73dd0
2021-03-29 15:39:50 -07:00
Josh Gao
3de19151e5 Add wrappers for pidfd_{open,getfd,send_signal}.
Bug: http://b/172518739
Test: `/data/nativetest64/bionic-unit-tests/bionic-unit-tests --gtest_filter="*pidfd*"` on blueline
Change-Id: Ibae32bbedbcf26535a80a5cbfb55ce180906b610
2021-02-25 13:55:12 -08:00
Christopher Ferris
05667cd66a Update to v5.11 kernel headers.
Kernel headers coming from:

Git: https://android.googlesource.com/kernel/common/
Branch: android-mainline
Tag: android-mainline-5.11

Test: Built cuttlefish and flame images. Ran bionic unit tests on both.
Change-Id: Ie60337aafad4bda55af99b6c8fe9f56bf2fa787f
2021-02-16 16:01:34 -08:00
Elliott Hughes
a37b18133d Rename __ANDROID_UNGUARDED_AVAILABILITY__ -> __ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__.
Also reduce some of the duplication in the macros.

Bug: http://b/179067538
Test: treehugger
Change-Id: I81ab341731b0faad6c7c5f00037feff8576abafb
2021-02-11 12:56:39 -08:00
Mitch Phillips
bfa3688606 Merge "[MemInit] Remove old API, introduce new MemInit API." 2021-02-01 23:32:24 +00:00
Dan Albert
eae41f8eeb Fix __VERSIONER_NO_GUARD cases for availability.
libc++ still depends on these being declared even if they are
unavailable. This results in a worse error message (a link error
rather than a compiler diagnostic) if these functions end up being
used, but without the decl headers like libc++'s math.h can't be
included because it refers to an undeclared function.

For the cases where weak symbols aren't being used, don't annotate
these functions with their availability information.

Also need to avoid using __builtin_available for this case because the
NDK doesn't have __isOSVersionAtLeast yet.

__ANDROID_UNGUARDED_AVAILABILITY__ is being used as a proxy for
"building for the NDK" here because we don't have a good signal for
that which works for both the NDK proper and the NDK-in-the-platform
case.

Test: imported into the NDK, built and tested NDK
Bug: None
Change-Id: I9ef3e19a8fa083bca0be47b80dfef7ba52a94866
2021-02-01 12:53:22 -08:00
Edgar Arriaga
cf81e7ca6a Merge changes from topic "proc_madvise_framework"
* changes:
  Add bionic headers for process_madvise
  Add a flag to distinguish shared VMAs
2021-01-26 19:29:37 +00:00
Mitch Phillips
9cad8424ff [MemInit] Remove old API, introduce new MemInit API.
Introduces new heap-zero-init API. We've realised that it's better to be
able to individually control MTE and heap zero-init. Having
heap-zero-init not be controllable without affecting MTE affects our
ability to turn off heap-zero-init in zygote-forked applications.

Bug: 135772972
Test: On FVP: atest -s localhost:5555 malloc#zero_init \
Test: malloc#disable_mte heap_tagging_level
Change-Id: I8c6722502733259934c699f4f1269eaf1641a09f
2021-01-25 15:19:31 -08:00
Jiyong Park
7cff764f3c Merge changes from topic "future_symbol"
* changes:
  crtbegin_static is built with min_sdk_version: "current"
  Guard __libc_current_sigrtmin/max with __builtin_available
  __INTRODUCED_IN macros add the availability attribute
2021-01-21 16:33:05 +00:00
Edgar Arriaga
128ef8e981 Add bionic headers for process_madvise
Test: atest bionic-unit-tests-static
Bug: 173258203
Change-Id: I396945b95de364055b87cc53321aed4fad4ebc70
2021-01-14 19:34:40 -08:00
Jiyong Park
bb19208d66 Guard __libc_current_sigrtmin/max with __builtin_available
The two APIs were added for the API level 21 and beyond. Currently, its
existence is tested using the null check which is done regardless of the
min sdk version of the compilation unit. (which in turn required us to
mark the API symbol weak regardless of the min sdk version.)

Now, we have a better way of testing the API availability;
__builtin_available. The null check is replaced with the call to the
compiler-provided macro which determines if the code is running in a
version of OS where the API is known to exist.

Bug: 150860940
Bug: 134795810
Test: m
Change-Id: Ib96c78f8d3cc71d7e755d1eab86051517bbbcc44
2021-01-15 10:40:51 +09:00
Jiyong Park
23bfed2a10 __INTRODUCED_IN macros add the availability attribute
__INTRODUCED_IN (and its variants) macro is used to mark the
availability of an API symbol. The macros were used by the versioner
tool for the NDK clients. When the Bionic headers are processed by the
tool, APIs with the macros are guarded with __ANDROID_API__. e.g.,

void foo() __INTRDUCED_IN(30);

is processed into

\#if __ANDROID_API__ >= 30
void foo();
\#endif

by the versioner.

The macros however didn't play a role for other cases, e.g. OS
components.

This is too strict for NDK clients and too loose for the non-NDK
clients. For the former, this completely hides the APIs that are newer
than the min sdk version (__ANDROID_API__). For the latter, a call to
such an API can be made without being guarded.

This change is the first step towards a better way of handling the
native APIs availability. The plan is that every NDK APIs are annotated
with the availability attribute and callers are required to guard their
API calls with a runtime check if the API is newer than the min sdk
version of the caller.

In this change, the macros now emits the availability attribute for the
non-NDK clients (i.e. when not processed by versioner).

Bug: 163288375
Bug: 134795810
Test: m
Change-Id: I6eb2bce2bc2770cbfd69815e6816b6f25b3d6127
2021-01-15 10:40:47 +09:00
Elliott Hughes
446b4dde72 Make "disable memory mitigations" and "set heap tagging level" more available.
These were only available internally via android_mallopt(), but they're
likely to be needed by more code in future, so move them into mallopt().

This change leaves the android_mallopt() options for now, but I plan on
coming back to remove them after I've switched the handful of callers
over to mallopt() instead.

Bug: http://b/135772972
Test: treehugger
Change-Id: Ia154614069a7623c6aca85975a91e6a156f04759
2021-01-14 13:34:20 -08:00
Elliott Hughes
43978a0a34 Fix things so that <features.h> can be used from assembler again.
Bug: https://github.com/android/ndk/issues/1422
Test: builds
Change-Id: I1b94ffe688f3d420533074c94f7ffed606ca923f
2021-01-07 17:32:39 -08:00
Christopher Ferris
32ff3f831c Update to v5.10 kernel headers.
Kernel headers coming from:

Git: https://android.googlesource.com/kernel/common/
Branch: android-mainline
Tag: android-mainline-5.10

Test: Built cuttlefish and flame images. Ran bionic unit tests on both.
Change-Id: I37ffc850970adcce1febbe2269c202632fce763a
2020-12-14 22:37:59 -08:00
Elliott Hughes
439ebbd349 Simplify and improve tempnam() and tmpnam().
They're both obsolescent in POSIX.1-2008, and you really shouldn't be
using them, but since we can't actually delete them...

This change makes them both obey $TMPDIR if set, and fall back to
/data/local/tmp otherwise. That's as good as we've managed for anything
else such as tmpfile(3).

Also add some tests.

Bug: http://b/174682340
Test: treehugger
Change-Id: Ieef99dcc2062f84b2b7cbae046787fdfe975e772
2020-12-08 22:26:06 -08:00
Christopher Ferris
25c18d45cf Update to v5.9 kernel headers.
Kernel headers coming from:

Git: https://android.googlesource.com/kernel/common/
Branch: android-mainline
Tag: android-mainline-5.9

Test: Boots cuttlefish 64bit, passes 32 bit and 64 bit bionic unit tests.
Change-Id: Ib5503355b238ea75595538e63eb000c867d06ef7
2020-10-19 15:48:58 -07:00
Elliott Hughes
7241ac6c07 Merge "Enable BTI in bionic linker" 2020-09-25 16:08:14 +00:00
Peter Collingbourne
978eb16cd4 Copy the M_THREAD_DISABLE_MEM_INIT constant value into malloc.h.
This will allow platform and application developers to use it.

Bug: 163630045
Change-Id: If9a361cb97aaf62d3fa124b60f64d51d609af48d
2020-09-24 17:01:54 +00:00
Tamas Petz
8d55d1872a Enable BTI in bionic linker
This patch adds support to load BTI-enabled objects.

According to the ABI, BTI is recorded in the .note.gnu.property section.
The new parser evaluates the property section, if exists.
It searches for .note section with NT_GNU_PROPERTY_TYPE_0.
Once found it tries to find GNU_PROPERTY_AARCH64_FEATURE_1_AND.
The results are cached.

The main change in linker is when protection of loaded ranges gets
applied. When BTI is requested and the platform also supports it
the prot flags have to be amended with PROT_BTI for executable ranges.
Failing to add PROT_BTI flag would disable BTI protection.
Moreover, adding the new PROT flag for shared objects without BTI
compatibility would break applications.

Kernel does not add PROT_BTI to a loaded ELF which has interpreter.
Linker handles this case too.

Test: 1. Flame boots
      2. Tested on FVP with BTI enabled

Change-Id: Iafdf223b74c6e75d9f17ca90500e6fe42c4c1218
2020-09-23 17:53:28 -07:00
Elliott Hughes
fee514e714 Make it clearer that math.h isn't fdlibm.
It was originally based on fdlibm, but it's been through two different
projects since then, and `git blame` shows basically nothing remaining
from those days. Seems worth leaving something to explain the unusual
copyright header though!

Test: treehugger
Change-Id: I8e7252a755704b866e7f36c8e97adc021fa3cdad
2020-09-17 11:57:50 -07:00
Elliott Hughes
8e5fc5b037 NGREG != ELF_NGREG.
Except they are the same on arm32/arm64, so we hadn't really noticed. x86
and x86-64 are quite different though, presumably by historical accident.

Fix the definitions and add some static asserts.

Bug: https://github.com/android/ndk/issues/1347
Test: treehugger
Change-Id: Ic27b172066cf3443749463b9b73c912d204f9516
2020-09-08 09:27:02 -07:00
Vy Nguyen
d4d7efc1f8 Merge "Add a thread-properties API (Based on proposal at https://sourceware.org/glibc/wiki/ThreadPropertiesAPI)" 2020-08-13 19:58:03 +00:00
Elliott Hughes
aadcb07890 Merge "Cleanup for #inclusivefixit." 2020-08-12 22:13:11 +00:00
Dan Albert
d8f46916b6 Add api-level.h to dac, improve docs.
We don't list most of bionic on dac since it would be overwhelming for
the current layout, but this file in particular seems useful,
especially __ANDROID_API__. Unfortunately, c2devsite doesn't include
macro documentation. Until then, it's still useful to include the
functions defined in this header.

I've also elaborated a bit in the __ANDROID_API__ documentation, since
the existing phrasing led to confusion over whether it was closer to
minSdkVersion or compileSdkVersion. In practice these are identical
for the NDK, but if we switch to weakly-linked APIs via the
availability attribute that would change.

Test: built docs, looked at them
Bug: None
Change-Id: I5cf78a6143b5c15790c369bdf888611e4c1189db
2020-08-11 13:50:04 -07:00
Vy Nguyen
d500751443 Add a thread-properties API
(Based on proposal at https://sourceware.org/glibc/wiki/ThreadPropertiesAPI)

This includes API to:
 - locate static and dynamic TLS
 - register thread-exit and  dynamic TLS creation/destruction callbacks

Change-Id: Icd9d29a5b2f47495395645e19d3b2c96826f19c8
2020-08-11 16:51:43 +00:00
Elliott Hughes
f08e70a0d9 Merge "Reimplement our no-op utmp.h functions more simply." 2020-08-10 15:41:13 +00:00
Elliott Hughes
9a1d3976f1 Reimplement our no-op utmp.h functions more simply.
Now we're being marked down for our poor coverage, we may as well remove
more broken cruft. Despite the amount of effort that seems to have gone
into pututline(), it wasn't working with the other utmp.h functions (in
particular, utmpname()), and wasn't declared in the header file!

Test: treehugger
Change-Id: I1a583984189c751168c11c01431433f96f8c548b
2020-08-07 17:07:31 -07:00
Dan Albert
2dbea434d1 Make swab(3) inline prior to API 28.
Test: make checkbuild
Bug: https://stackoverflow.com/q/54392471/632035
Change-Id: Iaeb55231ea2395d7e1e31be63034f5db19025060
2020-08-07 13:10:51 -07:00
Christopher Ferris
8177cdf178 Update to v5.8 kernel headers.
Kernel headers coming from:

Git: https://android.googlesource.com/kernel/common/
Branch: android-mainline
Tag: android-mainline-5.8

Test: NA
Change-Id: I2231c877589820fc09800a200cf4ac62ba74b04c
2020-08-04 13:50:49 -07:00
Elliott Hughes
cf346532fc More cleanup for #inclusivefixit.
Found manually with grep, since the script seems to miss stuff.

Test: treehugger
Change-Id: I5933cbade9792801d4a0bec1ccb077efa6ad8fbc
2020-07-31 10:35:03 -07:00
Christopher Ferris
8844879212 Add support for new scudo mallopt options.
Bug: 162092537

Test: Ran new unit tests.
Change-Id: I4b7d17a9e98166c03cd153eb9e9d847693914ea3
2020-07-28 18:20:32 -07:00
Elliott Hughes
fce3187088 Cleanup for #inclusivefixit.
This was initially just to try on "pty" and "tty" for size, while
discussing with other projects to try to align on vocabulary, but -- in
the implemention and tests at least -- but these work out so well that
I'm tempted to go with them anyway if we can't come to a concensus. We
can always come back and change them again later.

What I really like is that you pass the pty to functions like ptsname()
and grantpt() with a 'p' in the name, and the tty to functions like
ttyname() and tcsetattr() with just 't's.

The use of "parent" and "child" in forkpty() seems helpful too.

Also fix the documentation of forkpty(), which wasn't quite right.

Test: treehugger
Change-Id: Ic010c4b669f6528591c653e3701f4e41e0d0df9e
2020-07-28 12:12:20 -07:00
Elliott Hughes
68ae6ad12e Changes for #inclusivefixit.
Test: treehugger
Change-Id: I7ff0496c5c2792a41781e74634247f55b0548213
2020-07-21 16:34:58 -07:00
Elliott Hughes
c9889fdf15 strings.h: undef ffs/ffsl/ffsll.
Protect against software that #defines these, such as mesa3d.

Test: treehugger
Change-Id: I22e937423967676ea332956289419d48bb7c2cd3
2020-06-25 08:46:06 -07:00
Treehugger Robot
49f7f10f62 Merge "Add API constant for S." 2020-05-05 00:35:17 +00:00
Tom Cherry
03581d7aa9 Merge changes I6c9c2bf5,I23991692
* changes:
  Tighten pwd/grp iteration tests.
  Cleanup some trivial TODOs.
2020-04-10 23:04:55 +00:00
Tom Cherry
6f2e810198 Cleanup some trivial TODOs.
1) "fix the system properties design" is written for the old protocol,
   so we've already changed the design.  There are no other further
   planned changes.
2) "don't drag in all the macros, just the types." is not likely to
   happen or be particularly impactful.
3) "Find a location suitable for these functions ..." is refering to
   legacy code.  More likely that this code will be removed before we
   find a serious reason to fix this TODO.
4) "(73062966) We still don't have a good way ..." is stale; we fixed
   this bug and added the appropriate mechanism.

Test: n/a
Change-Id: I23991692cdeb81ad00844a6a1680900ff384208b
2020-04-10 11:46:03 -07:00
Christopher Ferris
bb9fcb4636 Update to v5.6 kernel headers.
Kernel headers coming from:

Git: https://android.googlesource.com/kernel/common/
Branch: android-mainline
Tag: android-mainline-5.6

Add a new method for removing structures. This is to deal with the kernel
headers changing some definitions of timeval to __kernel_old_timeval
and itimerval to __kernel_old_itimerval. Remove the __kernel_old_XX
strutures and change the other structures to the previous definitions.

This only works so long as these structures stay the same, if they
diverge, then a different strategy will need to be implemented.

Test: Booted cuttlefish/walleye.
Test: Ran bionic-unit-tests on cuttlefish/walleye.
Change-Id: I0a61f4fa6e4155c602e0414d9b38c2e1637829af
2020-04-10 10:53:48 -07:00
Dan Albert
14dcbf89ce Add API constant for S.
Test: treehugger
Bug: http://b/152037166
Change-Id: I9039377e80574cd59e13726a12072fe3002df67d
2020-04-09 12:38:53 -07:00
Maciej Żenczykowski
666b12e25a icmp6.h - add captive portal and pref64 nd opts
Test: builds
Bug: 150648313
Change-Id: I41bcd4d46c0736b613870dba382ebc079e5759d7
2020-04-01 20:54:45 +00:00
Elliott Hughes
02f9f4cfb6 Add documentation to <dirent.h>.
This was a side-effect of something else I was doing. May as well check
this in now though.

Test: treehugger
Change-Id: Ibe8a3640d309c1980fa6e8ef003d4f255384c9e7
2020-03-30 14:26:35 -07:00
Elliott Hughes
4a6899ce0c Add ffsl(3), ffsll(3).
POSIX added these GNU extensions for issue 8.

I've made these always inline without the usual "until API level X"
proviso because they're single instructions that the compiler can inline
and there's really no point providing these if they add function call
overhead --- everyone should just use __builtin_ffs() and friends
instead in that case.

Bug: https://austingroupbugs.net/view.php?id=617
Test: treehugger
Change-Id: I33fc4b8648ea25917329e81c1b4c60eb9a66d667
2020-03-26 11:43:05 -07:00
Chih-Hung Hsieh
fa658eb094 Fix bugprone-macro-parentheses warnings
Bug: 150783705
Test: WITH_TIDY=1 make
Change-Id: If47b7adaa5f3ba3c518fb0be48f0ffdc81d204b2
2020-03-04 13:22:05 -08:00
Elliott Hughes
33318f5197 Merge "Add a libc wrapper for statx(2)." 2020-02-25 16:37:09 +00:00
Elliott Hughes
521dab3b36 Merge "Make the HWCAP/HWCAP2 constants available from <sys/auxv.h>." 2020-02-25 16:36:26 +00:00
Elliott Hughes
c5d9036f80 Make the HWCAP/HWCAP2 constants available from <sys/auxv.h>.
Noticed by ARM when adding BTI support to the linker.

Test: treehugger
Change-Id: If3b87d0bd4682ff478b7805251fc9a88a7f439f9
2020-02-24 09:52:14 -08:00
Elliott Hughes
733cedd1c4 Add a libc wrapper for statx(2).
Bug: http://b/127675384
Bug: http://b/146676114
Test: treehugger
Change-Id: I844edc12f62717e579870a040cf03dfe60dc280b
2020-02-23 11:36:53 -08:00
Elliott Hughes
5403bd647b Fix wrong link in getauxval(3) doc comment.
Test: treehugger
Change-Id: I8646251edaa07fa8682127428f4fdb1fa0cf80e5
2020-02-21 16:23:33 -08:00
George Burgess IV
db5c45b457 Merge "fortify: simplify strlen for LLVM's new optimization" 2020-02-19 18:12:31 +00:00
Elliott Hughes
36359f47a2 Remove unused declarations.
Test: treehugger
Change-Id: Ia96dc01df0d26e2e3023bebab23de82ca8e389f7
2020-02-18 13:25:22 -08:00
Elliott Hughes
5ac438e5da Clean up mips references in the headers.
Test: treehugger
Change-Id: I1997af980b9e46c7c530f9e6cb1aa407b2d63d76
2020-02-13 18:00:16 -08:00
George Burgess IV
d02e7b131e fortify: simplify strlen for LLVM's new optimization
LLVM now knows how to fold __strlen_chk, so we can make this function a
one-liner.

Also fix strlcat to not double-return while I'm in the area.

Bug: 148189733
Test: TreeHugger
Change-Id: I71ee308defbefe96f3fe6e357a2127309d2f0942
2020-02-13 11:44:20 -08:00
Elliott Hughes
44c01c77d3 Clean up the math headers.
I had hoped that this would then let us remove more of the "introduced
in" annotations, but it looks like that's not really going to happen
until the NDK's minimum supported API is 21.

Also remove a .c file that wasn't referenced anywhere.

Test: treehugger
Change-Id: I8b4a61c082293f8445195a4fa5ee30595d70444e
2020-02-11 08:46:29 -08:00
Elliott Hughes
fd2eb42006 Merge "<ctype.h>: inline the ASCII functions." 2020-02-05 19:37:18 +00:00
George Burgess IV
3f41e145f2 Merge "fortify: remove 'optimizations' for functions that LLVM knows about" 2020-02-05 18:02:08 +00:00
Elliott Hughes
026d3a8fa5 <ctype.h>: inline the ASCII functions.
We've optimized the ctype functions to the point where they're pretty
much all down to one instruction. This change takes the obvious next
step of just inlining them.

On Android these function have only ever been for ASCII. You need the
<wctype.h> functions for non-ASCII.

libc++ currently has its own inlines for the _l variants, so if we want
to just inline them in bionic directly, we'll need to coordinate that.

Bug: http://b/144165498
Test: treehugger plus benchmarks
Change-Id: I4cc8aa96f7994ae710a562cfc9d4f220ab7babd6
2020-02-05 08:18:51 -08:00
George Burgess IV
2f7876596e fortify: remove 'optimizations' for functions that LLVM knows about
Over the last year, LLVM apparently learned how to optimize many
FORTIFY'ed functions. I went through the list of functions it optimizes,
and simplified their implementations here.

This is more than a code health thing; __bos_trivially_ge expands to a
branch that's not eliminated until after inlining, so it can actually
cause some functions (like one of std::string's ctors) to become
uninlineable.

Bug: 148189733
Test: hand-checked the IR we get for each of the changed functions. Many
      get optimized to their non-_chk variant when appropriate. Others
      will get optimized to non-_chk versions when bos == -1. Bug repro
      also now shows all 'inline's.

Change-Id: Ic360818ad9daaeda3958e1282af41087f85122a3
2020-02-04 21:52:36 -08:00
Treehugger Robot
9354f3e9a9 Merge "Fix the libc/include .clang-format." 2020-01-31 01:47:27 +00:00
Elliott Hughes
5f1165c66f versioner: don't require mips headers.
If we remove the mips uapi headers, versioner fails because it assumes
they're available. We'll need a new versioner prebuilt beforre we can
remove the libc/versioner-dependencies/mips* symlinks.

Test: treehugger
Change-Id: Ife6df0cb57938f806a31ec334d648df9694c3d17
2020-01-30 14:35:01 -08:00
Elliott Hughes
3288c2e254 Fix the libc/include .clang-format.
Many of our header files are very sensitive to the order in which
their #includes appear...

Bug: N/A
Test: N/A
Change-Id: I2c21cac5e9bd49b7e80620d14971af8fefa17e91
2020-01-30 13:51:39 -08:00
Elliott Hughes
09e77f35ab _FILE_OFFSET_BITS=64 support for fcntl.
On Android, fcntl is always implemented by fcntl64(2). This means that
an LP32 binary can `fcntl(F_SETLK, struct flock)` (because fcntl64(2)
passes through to the 32-bit fcntl(2) to handle F_SETLK), and it can
also `fcntl(F_SETLK64, struct flock64)`. What it can't do before this
patch is set _FILE_OFFSET_BITS=64 and then `fcntl(F_SETLK, struct
flock)` where that `struct flock` is actually implicitly `struct
flock64`.

Move the kernel uapi structs out of the way, define them ourselves based
on __LP64__ and _FILE_OFFSET_BITS, and fix up the relevant F_ constants.

(Also add a .clang-format to turn off clang-format in libc/include/.)

Bug: N/A
Test: treehugger (and strace!)
Change-Id: Iccd6c83d9133e1efcf93a7b49a6ae0f1bbd3d58b
2020-01-29 19:36:14 -08:00
Elliott Hughes
b070cabea8 elf.h: move all the Android extensions together.
...and document them slightly better.

Test: N/A
Change-Id: I32ad209f4086f617978c093782ac45977561445f
2020-01-27 16:00:19 -08:00
Elliott Hughes
6663f5525d Modernize SHT_RELR support.
Until now we've only supported RELR with our own OS-private-use
constants. Add support for the official numbers (while maintaining
support for the historical numbers).

Add tests to ensure we continue to support both indefinitely.

We can't yet flip the build system over to using the official constants
because the old GNU binutils objcopy we still use in most cases (for the
mini-debug section) only supports the historical constants.

Bug: http://b/147452927
Test: treehugger
Change-Id: If214fce7fade4316115947e90b78ab40864b61f2
2020-01-24 15:39:01 -08:00
Elliott Hughes
f39b0856fe Consistent <termios.h> behavior on all API levels.
Bug: https://issuetracker.google.com/146886722 (where the difference was noticed)
Bug: http://b/69816452 (most recent fixes)
Test: treehugger
Change-Id: I487399c44f63ba276ccde74bf0c4a01e4cd4f4bf
2020-01-09 16:42:15 -08:00
Treehugger Robot
3779d6da40 Merge "Add /system_ext/bin to shell search path" 2020-01-08 03:43:18 +00:00
Justin Yun
580d17d2ad Add /system_ext/bin to shell search path
/system_ext/bin has executable binaries. They must be in the shell
search path.

Bug: 134909174
Bug: 134359158
Test: check PATH in the adb shell
Change-Id: I997a2347fa85c444f2e335bede0d63b7703ba001
2020-01-07 20:39:52 +09:00
Logan Chien
5a750f3cf7 versioner: Add __VERSIONER_FORTIFY_INLINE
This commit adds `__VERSIONER_FORTIFY_INLINE` to fortify overload
functions.  Fortified functions are always overloaded and are likely to
be different from `libc.map.txt`.

Bug: 118991081
Test: source development/vndk/tools/header-checker/android/envsetup.sh && \
      source build/envsetup.sh && \
      lunch aosp_arm64-userdebug && \
      m versioner && \
      ./bionic/tools/versioner/run_tests.py
Change-Id: I28903d0f039d74a07eb2833c754ff017335bac95
2019-12-23 07:22:48 -08:00