Guard fortify inlines with __ANDROID_API__.
Test: make checkbuild with libc ndk_library patches applied
Change-Id: Ic5e248994c4f2702b0f4d6dfeda787187ea86017
diff --git a/libc/include/unistd.h b/libc/include/unistd.h
index c45a2e6..c792289 100644
--- a/libc/include/unistd.h
+++ b/libc/include/unistd.h
@@ -286,6 +286,7 @@
#if defined(__BIONIC_FORTIFY)
+#if __ANDROID_API__ >= 24
__BIONIC_FORTIFY_INLINE
char* getcwd(char* buf, size_t size) {
size_t bos = __bos(buf);
@@ -316,6 +317,7 @@
return __getcwd_chk(buf, size, bos);
}
+#endif /* __ANDROID_API__ >= 24 */
#if defined(__USE_FILE_OFFSET64)
#define __PREAD_PREFIX(x) __pread64_ ## x
@@ -323,6 +325,7 @@
#define __PREAD_PREFIX(x) __pread_ ## x
#endif
+#if __ANDROID_API__ >= 23
__BIONIC_FORTIFY_INLINE
ssize_t pread(int fd, void* buf, size_t count, off_t offset) {
size_t bos = __bos0(buf);
@@ -372,6 +375,7 @@
return __pread64_chk(fd, buf, count, offset, bos);
}
+#endif /* __ANDROID_API__ >= 23 */
#if defined(__USE_FILE_OFFSET64)
#define __PWRITE_PREFIX(x) __pwrite64_ ## x
@@ -379,6 +383,7 @@
#define __PWRITE_PREFIX(x) __pwrite_ ## x
#endif
+#if __ANDROID_API__ >= 24
__BIONIC_FORTIFY_INLINE
ssize_t pwrite(int fd, const void* buf, size_t count, off_t offset) {
size_t bos = __bos0(buf);
@@ -428,7 +433,9 @@
return __pwrite64_chk(fd, buf, count, offset, bos);
}
+#endif /* __ANDROID_API__ >= 24 */
+#if __ANDROID_API__ >= 21
__BIONIC_FORTIFY_INLINE
ssize_t read(int fd, void* buf, size_t count) {
size_t bos = __bos0(buf);
@@ -453,7 +460,9 @@
return __read_chk(fd, buf, count, bos);
}
+#endif /* __ANDROID_API__ >= 21 */
+#if __ANDROID_API__ >= 24
__BIONIC_FORTIFY_INLINE
ssize_t write(int fd, const void* buf, size_t count) {
size_t bos = __bos0(buf);
@@ -480,6 +489,7 @@
return __write_chk(fd, buf, count, bos);
}
+#endif /* __ANDROID_API__ >= 24 */
__BIONIC_FORTIFY_INLINE
ssize_t readlink(const char* path, char* buf, size_t size) {