Merge "Finish <stdio_ext.h>."
diff --git a/libc/async_safe/include/async_safe/log.h b/libc/async_safe/include/async_safe/log.h
index 6fdb84f..2f54742 100644
--- a/libc/async_safe/include/async_safe/log.h
+++ b/libc/async_safe/include/async_safe/log.h
@@ -78,14 +78,8 @@
// These functions do return, so callers that want to abort, must do so themselves,
// or use the macro above.
-void async_safe_fatal_no_abort(const char* _Nonnull fmt, ...) __printflike(1, 2);
-#if defined(__arm__) || defined(__aarch64__) || defined(__x86_64__)
-void async_safe_fatal_va_list(
- const char* _Nullable prefix, const char* _Nonnull fmt, va_list);
-#else // defined(__mips__) || defined(__i386__)
-void async_safe_fatal_va_list(
- const char* _Nullable prefix, const char* _Nonnull fmt, va_list _Nonnull);
-#endif
+void async_safe_fatal_no_abort(const char* fmt, ...) __printflike(1, 2);
+void async_safe_fatal_va_list(const char* prefix, const char* fmt, va_list args);
//
// Formatting routines for the C library's internal debugging.
@@ -93,26 +87,13 @@
// These are async signal safe, so they can be called from signal handlers.
//
-int async_safe_format_buffer(char* _Nonnull buf, size_t size, const char* _Nonnull fmt, ...) __printflike(3, 4);
+int async_safe_format_buffer(char* buf, size_t size, const char* fmt, ...) __printflike(3, 4);
+int async_safe_format_buffer_va_list(char* buffer, size_t buffer_size, const char* format, va_list args);
-#if defined(__arm__) || defined(__aarch64__) || defined(__x86_64__)
-int async_safe_format_buffer_va_list(
- char* _Nonnull buffer, size_t buffer_size, const char* _Nonnull format, va_list args);
-#else // defined(__mips__) || defined(__i386__)
-int async_safe_format_buffer_va_list(
- char* _Nonnull buffer, size_t buffer_size, const char* _Nonnull format, va_list _Nonnull args);
-#endif
-
-int async_safe_format_fd(int fd, const char* _Nonnull format , ...) __printflike(2, 3);
-int async_safe_format_log(int pri, const char* _Nonnull tag, const char* _Nonnull fmt, ...) __printflike(3, 4);
-#if defined(__arm__) || defined(__aarch64__) || defined(__x86_64__)
-int async_safe_format_log_va_list(
- int pri, const char* _Nonnull tag, const char* _Nonnull fmt, va_list ap);
-#else // defined(__mips__) || defined(__i386__)
-int async_safe_format_log_va_list(
- int pri, const char* _Nonnull tag, const char* _Nonnull fmt, va_list _Nonnull ap);
-#endif
-int async_safe_write_log(int pri, const char* _Nonnull tag, const char* _Nonnull msg);
+int async_safe_format_fd(int fd, const char* format , ...) __printflike(2, 3);
+int async_safe_format_log(int pri, const char* tag, const char* fmt, ...) __printflike(3, 4);
+int async_safe_format_log_va_list( int pri, const char* tag, const char* fmt, va_list ap);
+int async_safe_write_log(int pri, const char* tag, const char* msg);
#define CHECK(predicate) \
do { \
diff --git a/libc/include/bits/fortify/fcntl.h b/libc/include/bits/fortify/fcntl.h
index 1d3d7bc..3e0a590 100644
--- a/libc/include/bits/fortify/fcntl.h
+++ b/libc/include/bits/fortify/fcntl.h
@@ -48,11 +48,6 @@
int open(const char* pathname, int flags, mode_t modes, ...) __overloadable
__errorattr(__open_too_many_args_error);
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-int open(const char* pathname, int flags) __overloadable
- __enable_if(flags & O_CREAT, __open_too_few_args_error)
- __errorattr(__open_too_few_args_error);
-
/*
* pass_object_size serves two purposes here, neither of which involve __bos: it
* disqualifies this function from having its address taken (so &open works),
@@ -60,30 +55,27 @@
* open(const char *, int, ...).
*/
__BIONIC_FORTIFY_INLINE
-int open(const char* const __pass_object_size pathname,
- int flags) __overloadable {
+int open(const char* const __pass_object_size pathname, int flags)
+ __overloadable
+ __clang_error_if(flags & O_CREAT, "'open' " __open_too_few_args_error) {
return __open_2(pathname, flags);
}
__BIONIC_FORTIFY_INLINE
-int open(const char* const __pass_object_size pathname, int flags, mode_t modes)
- __overloadable {
+int open(const char* const __pass_object_size pathname, int flags, mode_t modes) __overloadable {
return __open_real(pathname, flags, modes);
}
__BIONIC_ERROR_FUNCTION_VISIBILITY
-int openat(int dirfd, const char* pathname, int flags) __overloadable
- __enable_if(flags & O_CREAT, __open_too_few_args_error)
- __errorattr(__open_too_few_args_error);
-
-__BIONIC_ERROR_FUNCTION_VISIBILITY
int openat(int dirfd, const char* pathname, int flags, mode_t modes, ...)
__overloadable
__errorattr(__open_too_many_args_error);
__BIONIC_FORTIFY_INLINE
int openat(int dirfd, const char* const __pass_object_size pathname,
- int flags) __overloadable {
+ int flags)
+ __overloadable
+ __clang_error_if(flags & O_CREAT, "'openat' " __open_too_few_args_error) {
return __openat_2(dirfd, pathname, flags);
}
diff --git a/libc/include/bits/fortify/poll.h b/libc/include/bits/fortify/poll.h
index e9b52c8..8363e35 100644
--- a/libc/include/bits/fortify/poll.h
+++ b/libc/include/bits/fortify/poll.h
@@ -37,42 +37,31 @@
#if defined(__BIONIC_FORTIFY)
#if __ANDROID_API__ >= __ANDROID_API_M__
#if defined(__clang__)
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-int poll(struct pollfd* fds, nfds_t fd_count, int timeout) __overloadable
- __enable_if(__bos(fds) != __BIONIC_FORTIFY_UNKNOWN_SIZE &&
- __bos(fds) < sizeof(*fds) * fd_count,
- "selected when there aren't fd_count fds")
- __errorattr("too many fds specified");
-
__BIONIC_FORTIFY_INLINE
-int poll(struct pollfd* const fds __pass_object_size, nfds_t fd_count,
- int timeout) __overloadable {
+int poll(struct pollfd* const fds __pass_object_size, nfds_t fd_count, int timeout)
+ __overloadable
+ __clang_error_if(__bos(fds) != __BIONIC_FORTIFY_UNKNOWN_SIZE &&
+ __bos(fds) < sizeof(*fds) * fd_count,
+ "in call to 'poll', fd_count is larger than the given buffer") {
size_t bos_fds = __bos(fds);
if (bos_fds == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
- return __call_bypassing_fortify(poll)(fds, fd_count, timeout);
+ return __call_bypassing_fortify(poll)(fds, fd_count, timeout);
}
-
return __poll_chk(fds, fd_count, timeout, bos_fds);
}
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-int ppoll(struct pollfd* fds, nfds_t fd_count, const struct timespec* timeout,
- const sigset_t* mask) __overloadable
- __enable_if(__bos(fds) != __BIONIC_FORTIFY_UNKNOWN_SIZE &&
- __bos(fds) < sizeof(*fds) * fd_count,
- "selected when there aren't fd_count fds")
- __errorattr("too many fds specified");
-
__BIONIC_FORTIFY_INLINE
-int ppoll(struct pollfd* const fds __pass_object_size, nfds_t fd_count,
- const struct timespec* timeout, const sigset_t* mask) __overloadable {
+int ppoll(struct pollfd* const fds __pass_object_size, nfds_t fd_count, const struct timespec* timeout, const sigset_t* mask)
+ __overloadable
+ __clang_error_if(__bos(fds) != __BIONIC_FORTIFY_UNKNOWN_SIZE &&
+ __bos(fds) < sizeof(*fds) * fd_count,
+ "in call to 'ppoll', fd_count is larger than the given buffer") {
size_t bos_fds = __bos(fds);
if (bos_fds == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
- return __call_bypassing_fortify(ppoll)(fds, fd_count, timeout, mask);
+ return __call_bypassing_fortify(ppoll)(fds, fd_count, timeout, mask);
}
-
return __ppoll_chk(fds, fd_count, timeout, mask, bos_fds);
}
#else /* defined(__clang__) */
diff --git a/libc/include/bits/fortify/socket.h b/libc/include/bits/fortify/socket.h
index c9e9436..3e610d6 100644
--- a/libc/include/bits/fortify/socket.h
+++ b/libc/include/bits/fortify/socket.h
@@ -37,64 +37,55 @@
#if defined(__BIONIC_FORTIFY)
-#define __recvfrom_bad_size "recvfrom called with size bigger than buffer"
-#define __sendto_bad_size "sendto called with size bigger than buffer"
+#define __recvfrom_bad_size "'recvfrom' called with size bigger than buffer"
+#define __sendto_bad_size "'sendto' called with size bigger than buffer"
#if defined(__clang__)
#if __ANDROID_API__ >= __ANDROID_API_N__
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-ssize_t recvfrom(int fd, void* const buf __pass_object_size0, size_t len,
- int flags, struct sockaddr* src_addr, socklen_t* addr_len)
- __overloadable
- __enable_if(__bos(buf) != __BIONIC_FORTIFY_UNKNOWN_SIZE &&
- __bos(buf) < len, "selected when the buffer is too small")
- __errorattr(__recvfrom_bad_size);
-
__BIONIC_FORTIFY_INLINE
-ssize_t recvfrom(int fd, void* const buf __pass_object_size0, size_t len,
- int flags, struct sockaddr* src_addr, socklen_t* addr_len)
- __overloadable {
+ssize_t recvfrom(int fd, void* const buf __pass_object_size0, size_t len, int flags, struct sockaddr* src_addr, socklen_t* addr_len)
+ __overloadable
+ __clang_error_if(__bos(buf) != __BIONIC_FORTIFY_UNKNOWN_SIZE && __bos(buf) < len,
+ __recvfrom_bad_size) {
size_t bos = __bos0(buf);
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
- return __call_bypassing_fortify(recvfrom)(fd, buf, len, flags, src_addr,
- addr_len);
+ return __call_bypassing_fortify(recvfrom)(fd, buf, len, flags, src_addr, addr_len);
}
-
return __recvfrom_chk(fd, buf, len, bos, flags, src_addr, addr_len);
}
#endif /* __ANDROID_API__ >= __ANDROID_API_N__ */
#if __ANDROID_API__ >= __ANDROID_API_N_MR1__
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-ssize_t sendto(int fd, const void* buf, size_t len, int flags,
- const struct sockaddr* dest_addr, socklen_t addr_len)
- __overloadable
- __enable_if(__bos0(buf) != __BIONIC_FORTIFY_UNKNOWN_SIZE &&
- __bos0(buf) < len, "selected when the buffer is too small")
- __errorattr(__sendto_bad_size);
-
__BIONIC_FORTIFY_INLINE
-ssize_t sendto(int fd, const void* const buf __pass_object_size0, size_t len,
- int flags, const struct sockaddr* dest_addr, socklen_t addr_len)
- __overloadable {
+ssize_t sendto(int fd, const void* const buf __pass_object_size0, size_t len, int flags, const struct sockaddr* dest_addr, socklen_t addr_len)
+ __overloadable
+ __clang_error_if(__bos0(buf) != __BIONIC_FORTIFY_UNKNOWN_SIZE && __bos0(buf) < len,
+ __sendto_bad_size) {
size_t bos = __bos0(buf);
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
- return __call_bypassing_fortify(sendto)(fd, buf, len, flags, dest_addr,
- addr_len);
+ return __call_bypassing_fortify(sendto)(fd, buf, len, flags, dest_addr, addr_len);
}
-
return __sendto_chk(fd, buf, len, bos, flags, dest_addr, addr_len);
}
-
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-ssize_t send(int socket, const void* buf, size_t len, int flags)
- __overloadable
- __enable_if(__bos0(buf) != __BIONIC_FORTIFY_UNKNOWN_SIZE &&
- __bos0(buf) < len, "selected when the buffer is too small")
- __errorattr("send called with size bigger than buffer");
#endif /* __ANDROID_API__ >= __ANDROID_API_N_MR1__ */
+__BIONIC_FORTIFY_INLINE
+ssize_t recv(int socket, void* const buf __pass_object_size0, size_t len, int flags)
+ __overloadable
+ __clang_error_if(__bos0(buf) != __BIONIC_FORTIFY_UNKNOWN_SIZE && __bos0(buf) < len,
+ "'recv' called with size bigger than buffer") {
+ return recvfrom(socket, buf, len, flags, NULL, 0);
+}
+
+__BIONIC_FORTIFY_INLINE
+ssize_t send(int socket, const void* const buf __pass_object_size0, size_t len, int flags)
+ __overloadable
+ __clang_error_if(__bos0(buf) != __BIONIC_FORTIFY_UNKNOWN_SIZE && __bos0(buf) < len,
+ "'send' called with size bigger than buffer") {
+ return sendto(socket, buf, len, flags, NULL, 0);
+}
+
#else /* defined(__clang__) */
ssize_t __recvfrom_real(int, void*, size_t, int, struct sockaddr*, socklen_t*) __RENAME(recvfrom);
__errordecl(__recvfrom_error, __recvfrom_bad_size);
@@ -147,20 +138,17 @@
}
#endif /* __ANDROID_API__ >= __ANDROID_API_N_MR1__ */
-#endif /* defined(__clang__) */
-#undef __recvfrom_bad_size
-#undef __sendto_bad_size
-
__BIONIC_FORTIFY_INLINE
-ssize_t recv(int socket, void* const buf __pass_object_size0, size_t len,
- int flags) __overloadable {
+ssize_t recv(int socket, void* buf, size_t len, int flags) {
return recvfrom(socket, buf, len, flags, NULL, 0);
}
__BIONIC_FORTIFY_INLINE
-ssize_t send(int socket, const void* const buf __pass_object_size0, size_t len, int flags)
- __overloadable {
+ssize_t send(int socket, const void* buf, size_t len, int flags) {
return sendto(socket, buf, len, flags, NULL, 0);
}
+#endif /* defined(__clang__) */
+#undef __recvfrom_bad_size
+#undef __sendto_bad_size
#endif /* __BIONIC_FORTIFY */
diff --git a/libc/include/bits/fortify/stat.h b/libc/include/bits/fortify/stat.h
index d119e2c..c168c38 100644
--- a/libc/include/bits/fortify/stat.h
+++ b/libc/include/bits/fortify/stat.h
@@ -33,23 +33,17 @@
mode_t __umask_chk(mode_t) __INTRODUCED_IN(18);
#if defined(__BIONIC_FORTIFY)
-#define __umask_invalid_mode_str "umask called with invalid mode"
+#define __umask_invalid_mode_str "'umask' called with invalid mode"
#if defined(__clang__)
#if __ANDROID_API__ >= __ANDROID_API_J_MR2__
-/*
- * Abuse enable_if to make these be seen as overloads of umask, rather than
- * definitions.
- */
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-mode_t umask(mode_t mode) __overloadable
- __enable_if(1, "")
- __enable_if(mode & ~0777, __umask_invalid_mode_str)
- __errorattr(__umask_invalid_mode_str);
-
+/* Abuse enable_if to make this an overload of umask. */
__BIONIC_FORTIFY_INLINE
-mode_t umask(mode_t mode) __enable_if(1, "") __overloadable {
+mode_t umask(mode_t mode)
+ __overloadable
+ __enable_if(1, "")
+ __clang_error_if(mode & ~0777, __umask_invalid_mode_str) {
return __umask_chk(mode);
}
#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR2__ */
diff --git a/libc/include/bits/fortify/stdio.h b/libc/include/bits/fortify/stdio.h
index a36ac32..cfc78d7 100644
--- a/libc/include/bits/fortify/stdio.h
+++ b/libc/include/bits/fortify/stdio.h
@@ -38,14 +38,13 @@
#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
__BIONIC_FORTIFY_INLINE __printflike(3, 0)
-int vsnprintf(char *const __pass_object_size dest, size_t size,
- const char *_Nonnull format, va_list ap) __overloadable {
+int vsnprintf(char* const __pass_object_size dest, size_t size, const char* format, va_list ap)
+ __overloadable {
return __builtin___vsnprintf_chk(dest, size, 0, __bos(dest), format, ap);
}
__BIONIC_FORTIFY_INLINE __printflike(2, 0)
-int vsprintf(char *const __pass_object_size dest, const char *_Nonnull format,
- va_list ap) __overloadable {
+int vsprintf(char* const __pass_object_size dest, const char* format, va_list ap) __overloadable {
return __builtin___vsprintf_chk(dest, 0, __bos(dest), format, ap);
}
#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
@@ -60,14 +59,14 @@
int snprintf(char* dest, size_t size, const char* format)
__overloadable
__enable_if(__bos(dest) != __BIONIC_FORTIFY_UNKNOWN_SIZE &&
- __bos(dest) < __builtin_strlen(format),
+ __bos(dest) < __builtin_strlen(format),
"format string will always overflow destination buffer")
__errorattr("format string will always overflow destination buffer");
__BIONIC_FORTIFY_INLINE
__printflike(3, 4)
-int snprintf(char* const __pass_object_size dest,
- size_t size, const char* format, ...) __overloadable {
+int snprintf(char* const __pass_object_size dest, size_t size, const char* format, ...)
+ __overloadable {
va_list va;
va_start(va, format);
int result = __builtin___vsnprintf_chk(dest, size, 0, __bos(dest), format, va);
@@ -76,7 +75,8 @@
}
__BIONIC_ERROR_FUNCTION_VISIBILITY
-int sprintf(char* dest, const char* format) __overloadable
+int sprintf(char* dest, const char* format)
+ __overloadable
__enable_if(__bos(dest) != __BIONIC_FORTIFY_UNKNOWN_SIZE &&
__bos(dest) < __builtin_strlen(format),
"format string will always overflow destination buffer")
@@ -95,44 +95,27 @@
#if __ANDROID_API__ >= __ANDROID_API_N__
__BIONIC_FORTIFY_INLINE
-size_t fread(void* buf, size_t size, size_t count,
- FILE* stream) __overloadable
- __enable_if(__unsafe_check_mul_overflow(size, count), "size * count overflows")
- __errorattr("size * count overflows");
-
-__BIONIC_FORTIFY_INLINE
-size_t fread(void* buf, size_t size, size_t count, FILE* stream) __overloadable
- __enable_if(!__unsafe_check_mul_overflow(size, count), "no overflow")
- __enable_if(__bos(buf) != __BIONIC_FORTIFY_UNKNOWN_SIZE &&
- size * count > __bos(buf), "size * count is too large")
- __errorattr("size * count is too large");
-
-__BIONIC_FORTIFY_INLINE
-size_t fread(void* const __pass_object_size0 buf, size_t size,
- size_t count, FILE* stream) __overloadable {
+size_t fread(void* const __pass_object_size0 buf, size_t size, size_t count, FILE* stream)
+ __overloadable
+ __clang_error_if(__unsafe_check_mul_overflow(size, count),
+ "in call to 'fread', size * count overflows")
+ __clang_error_if(__bos(buf) != __BIONIC_FORTIFY_UNKNOWN_SIZE && size * count > __bos(buf),
+ "in call to 'fread', size * count is too large for the given buffer") {
size_t bos = __bos0(buf);
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
return __call_bypassing_fortify(fread)(buf, size, count, stream);
}
-
return __fread_chk(buf, size, count, stream, bos);
}
-size_t fwrite(const void* buf, size_t size, size_t count, FILE* stream) __overloadable
- __enable_if(__unsafe_check_mul_overflow(size, count),
- "size * count overflows")
- __errorattr("size * count overflows");
-
-size_t fwrite(const void* buf, size_t size, size_t count, FILE* stream) __overloadable
- __enable_if(!__unsafe_check_mul_overflow(size, count), "no overflow")
- __enable_if(__bos(buf) != __BIONIC_FORTIFY_UNKNOWN_SIZE &&
- size * count > __bos(buf), "size * count is too large")
- __errorattr("size * count is too large");
-
__BIONIC_FORTIFY_INLINE
size_t fwrite(const void* const __pass_object_size0 buf, size_t size, size_t count, FILE* stream)
- __overloadable {
+ __overloadable
+ __clang_error_if(__unsafe_check_mul_overflow(size, count),
+ "in call to 'fwrite', size * count overflows")
+ __clang_error_if(__bos(buf) != __BIONIC_FORTIFY_UNKNOWN_SIZE && size * count > __bos(buf),
+ "in call to 'fwrite', size * count is too large for the given buffer") {
size_t bos = __bos0(buf);
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
@@ -144,19 +127,12 @@
#endif /* __ANDROID_API__ >= __ANDROID_API_N__ */
#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-char *fgets(char* dest, int size, FILE* stream) __overloadable
- __enable_if(size < 0, "size is negative")
- __errorattr("size is negative");
-
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-char *fgets(char* dest, int size, FILE* stream) __overloadable
- __enable_if(size >= 0 && size > __bos(dest),
- "size is larger than the destination buffer")
- __errorattr("size is larger than the destination buffer");
-
__BIONIC_FORTIFY_INLINE
-char *fgets(char* const __pass_object_size dest, int size, FILE* stream) __overloadable {
+char* fgets(char* const __pass_object_size dest, int size, FILE* stream)
+ __overloadable
+ __clang_error_if(size < 0, "in call to 'fgets', size should not be negative")
+ __clang_error_if(size > __bos(dest),
+ "in call to 'fgets', size is larger than the destination buffer") {
size_t bos = __bos(dest);
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
@@ -184,15 +160,13 @@
#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
__BIONIC_FORTIFY_INLINE __printflike(3, 4)
-int snprintf(char* dest, size_t size, const char* _Nonnull format, ...) {
- return __builtin___snprintf_chk(dest, size, 0, __bos(dest), format,
- __builtin_va_arg_pack());
+int snprintf(char* dest, size_t size, const char* format, ...) {
+ return __builtin___snprintf_chk(dest, size, 0, __bos(dest), format, __builtin_va_arg_pack());
}
__BIONIC_FORTIFY_INLINE __printflike(2, 3)
-int sprintf(char* dest, const char* _Nonnull format, ...) {
- return __builtin___sprintf_chk(dest, 0, __bos(dest), format,
- __builtin_va_arg_pack());
+int sprintf(char* dest, const char* format, ...) {
+ return __builtin___sprintf_chk(dest, 0, __bos(dest), format, __builtin_va_arg_pack());
}
#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
diff --git a/libc/include/bits/fortify/stdlib.h b/libc/include/bits/fortify/stdlib.h
index bda1d45..cf4b7ea 100644
--- a/libc/include/bits/fortify/stdlib.h
+++ b/libc/include/bits/fortify/stdlib.h
@@ -32,22 +32,16 @@
#if defined(__BIONIC_FORTIFY)
#define __realpath_buf_too_small_str \
- "realpath output parameter must be NULL or a >= PATH_MAX bytes buffer"
+ "'realpath' output parameter must be NULL or a pointer to a buffer with >= PATH_MAX bytes"
/* PATH_MAX is unavailable without polluting the namespace, but it's always 4096 on Linux */
#define __PATH_MAX 4096
#if defined(__clang__)
-
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-char* realpath(const char* path, char* resolved) __overloadable
- __enable_if(__bos(resolved) != __BIONIC_FORTIFY_UNKNOWN_SIZE &&
- __bos(resolved) < __PATH_MAX, __realpath_buf_too_small_str)
- __errorattr(__realpath_buf_too_small_str);
-
-/* No need for a FORTIFY version; the only things we can catch are at
- * compile-time.
- */
+char* realpath(const char* path, char* resolved)
+ __clang_error_if(__bos(resolved) != __BIONIC_FORTIFY_UNKNOWN_SIZE &&
+ __bos(resolved) < __PATH_MAX, __realpath_buf_too_small_str);
+/* No need for a definition; the only issues we can catch are at compile-time. */
#else /* defined(__clang__) */
diff --git a/libc/include/bits/fortify/string.h b/libc/include/bits/fortify/string.h
index 2fe48d4..0c1999b 100644
--- a/libc/include/bits/fortify/string.h
+++ b/libc/include/bits/fortify/string.h
@@ -30,14 +30,12 @@
#error "Never include this file directly; instead, include <string.h>"
#endif
-void* __memchr_chk(const void* _Nonnull, int, size_t, size_t) __INTRODUCED_IN(23);
-void* __memrchr_chk(const void* _Nonnull, int, size_t, size_t) __INTRODUCED_IN(23);
-char* __stpncpy_chk2(char* _Nonnull, const char* _Nonnull, size_t, size_t, size_t)
- __INTRODUCED_IN(21);
-char* __strncpy_chk2(char* _Nonnull, const char* _Nonnull, size_t, size_t, size_t)
- __INTRODUCED_IN(21);
-size_t __strlcpy_chk(char* _Nonnull, const char* _Nonnull, size_t, size_t) __INTRODUCED_IN(17);
-size_t __strlcat_chk(char* _Nonnull, const char* _Nonnull, size_t, size_t) __INTRODUCED_IN(17);
+void* __memchr_chk(const void*, int, size_t, size_t) __INTRODUCED_IN(23);
+void* __memrchr_chk(const void*, int, size_t, size_t) __INTRODUCED_IN(23);
+char* __stpncpy_chk2(char*, const char*, size_t, size_t, size_t) __INTRODUCED_IN(21);
+char* __strncpy_chk2(char*, const char*, size_t, size_t, size_t) __INTRODUCED_IN(21);
+size_t __strlcpy_chk(char*, const char*, size_t, size_t) __INTRODUCED_IN(17);
+size_t __strlcat_chk(char*, const char*, size_t, size_t) __INTRODUCED_IN(17);
/* Only used with FORTIFY, but some headers that need it undef FORTIFY, so we
* have the definition out here.
@@ -49,47 +47,42 @@
// trickery...
#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
__BIONIC_FORTIFY_INLINE
-void* memcpy(void* _Nonnull const dst __pass_object_size0, const void* _Nonnull src, size_t copy_amount)
+void* memcpy(void* const dst __pass_object_size0, const void* src, size_t copy_amount)
__overloadable {
return __builtin___memcpy_chk(dst, src, copy_amount, __bos0(dst));
}
__BIONIC_FORTIFY_INLINE
-void* memmove(void* const _Nonnull dst __pass_object_size0, const void* _Nonnull src, size_t len)
- __overloadable {
+void* memmove(void* const dst __pass_object_size0, const void* src, size_t len) __overloadable {
return __builtin___memmove_chk(dst, src, len, __bos0(dst));
}
#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
#if __ANDROID_API__ >= __ANDROID_API_L__
__BIONIC_FORTIFY_INLINE
-char* stpcpy(char* _Nonnull const dst __pass_object_size, const char* _Nonnull src)
- __overloadable {
+char* stpcpy(char* const dst __pass_object_size, const char* src) __overloadable {
return __builtin___stpcpy_chk(dst, src, __bos(dst));
}
#endif /* __ANDROID_API__ >= __ANDROID_API_L__ */
#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
__BIONIC_FORTIFY_INLINE
-char* strcpy(char* _Nonnull const dst __pass_object_size, const char* _Nonnull src)
- __overloadable {
+char* strcpy(char* const dst __pass_object_size, const char* src) __overloadable {
return __builtin___strcpy_chk(dst, src, __bos(dst));
}
__BIONIC_FORTIFY_INLINE
-char* strcat(char* _Nonnull const dst __pass_object_size, const char* _Nonnull src)
- __overloadable {
+char* strcat(char* const dst __pass_object_size, const char* src) __overloadable {
return __builtin___strcat_chk(dst, src, __bos(dst));
}
__BIONIC_FORTIFY_INLINE
-char* strncat(char* const _Nonnull dst __pass_object_size, const char* _Nonnull src, size_t n)
- __overloadable {
+char* strncat(char* const dst __pass_object_size, const char* src, size_t n) __overloadable {
return __builtin___strncat_chk(dst, src, n, __bos(dst));
}
__BIONIC_FORTIFY_INLINE
-void* memset(void* const _Nonnull s __pass_object_size0, int c, size_t n) __overloadable {
+void* memset(void* const s __pass_object_size0, int c, size_t n) __overloadable {
return __builtin___memset_chk(s, c, n, __bos0(s));
}
#endif /* __ANDROID_API__ >= __ANDROID_API_J_MR1__ */
@@ -102,10 +95,6 @@
__bos0(dst) < (n), "selected when the buffer is too small") \
__errorattr(#name " called with " what " bigger than buffer")
-/*
- * N.B. _Nonnull isn't necessary on params, since these functions just emit
- * errors.
- */
__BIONIC_ERROR_FUNCTION_VISIBILITY
void* memcpy(void* dst, const void* src, size_t copy_amount) __overloadable
__error_if_overflows_dst(memcpy, dst, copy_amount, "size");
@@ -128,7 +117,7 @@
#if __ANDROID_API__ >= __ANDROID_API_M__
__BIONIC_FORTIFY_INLINE
-void* memchr(const void* const _Nonnull s __pass_object_size, int c, size_t n)
+void* memchr(const void* const s __pass_object_size, int c, size_t n)
__overloadable {
size_t bos = __bos(s);
@@ -140,7 +129,7 @@
}
__BIONIC_FORTIFY_INLINE
-void* memrchr(const void* const _Nonnull s __pass_object_size, int c, size_t n)
+void* memrchr(const void* const s __pass_object_size, int c, size_t n)
__overloadable {
size_t bos = __bos(s);
@@ -154,7 +143,7 @@
#if __ANDROID_API__ >= __ANDROID_API_L__
__BIONIC_FORTIFY_INLINE
-char* stpncpy(char* const _Nonnull dst __pass_object_size, const char* const _Nonnull src __pass_object_size, size_t n)
+char* stpncpy(char* const dst __pass_object_size, const char* const src __pass_object_size, size_t n)
__overloadable {
size_t bos_dst = __bos(dst);
size_t bos_src = __bos(src);
@@ -168,7 +157,7 @@
}
__BIONIC_FORTIFY_INLINE
-char* strncpy(char* const _Nonnull dst __pass_object_size, const char* const _Nonnull src __pass_object_size, size_t n)
+char* strncpy(char* const dst __pass_object_size, const char* const src __pass_object_size, size_t n)
__overloadable {
size_t bos_dst = __bos(dst);
size_t bos_src = __bos(src);
@@ -184,7 +173,7 @@
#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
__BIONIC_FORTIFY_INLINE
-size_t strlcpy(char* const _Nonnull dst __pass_object_size, const char *_Nonnull src, size_t size)
+size_t strlcpy(char* const dst __pass_object_size, const char* src, size_t size)
__overloadable {
size_t bos = __bos(dst);
@@ -196,7 +185,7 @@
}
__BIONIC_FORTIFY_INLINE
-size_t strlcat(char* const _Nonnull dst __pass_object_size, const char* _Nonnull src, size_t size)
+size_t strlcat(char* const dst __pass_object_size, const char* src, size_t size)
__overloadable {
size_t bos = __bos(dst);
@@ -214,14 +203,14 @@
* because it's large.
*/
__BIONIC_FORTIFY_INLINE
-size_t strlen(const char* const _Nonnull s __pass_object_size)
+size_t strlen(const char* const s __pass_object_size)
__overloadable __enable_if(__builtin_strlen(s) != -1ULL,
"enabled if s is a known good string.") {
return __builtin_strlen(s);
}
__BIONIC_FORTIFY_INLINE
-size_t strlen(const char* const _Nonnull s __pass_object_size0)
+size_t strlen(const char* const s __pass_object_size0)
__overloadable {
size_t bos = __bos0(s);
@@ -236,8 +225,7 @@
#if __ANDROID_API__ >= __ANDROID_API_J_MR2__
__BIONIC_FORTIFY_INLINE
-char* strchr(const char* const _Nonnull s __pass_object_size, int c)
- __overloadable {
+char* strchr(const char* const s __pass_object_size, int c) __overloadable {
size_t bos = __bos(s);
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
@@ -248,8 +236,7 @@
}
__BIONIC_FORTIFY_INLINE
-char* strrchr(const char* const _Nonnull s __pass_object_size, int c)
- __overloadable {
+char* strrchr(const char* const s __pass_object_size, int c) __overloadable {
size_t bos = __bos(s);
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
@@ -267,12 +254,12 @@
* but we should also provide a FORTIFY'ed escape hatch.
*/
__BIONIC_ERROR_FUNCTION_VISIBILITY
-void* memset(void* _Nonnull s, int c, size_t n, struct __bionic_zero_size_is_okay_t ok)
+void* memset(void* s, int c, size_t n, struct __bionic_zero_size_is_okay_t ok)
__overloadable
__error_if_overflows_dst(memset, s, n, "size");
__BIONIC_FORTIFY_INLINE
-void* memset(void* const _Nonnull s __pass_object_size0, int c, size_t n, struct __bionic_zero_size_is_okay_t ok __attribute__((unused)))
+void* memset(void* const s __pass_object_size0, int c, size_t n, struct __bionic_zero_size_is_okay_t ok __attribute__((unused)))
__overloadable {
return __builtin___memset_chk(s, c, n, __bos0(s));
}
@@ -282,7 +269,7 @@
* flipping size + count will do nothing.
*/
__BIONIC_ERROR_FUNCTION_VISIBILITY
-void* memset(void* _Nonnull s, int c, size_t n) __overloadable
+void* memset(void* s, int c, size_t n) __overloadable
__enable_if(c && !n, "selected when we'll set zero bytes")
__RENAME_CLANG(memset)
__warnattr_real("will set 0 bytes; maybe the arguments got flipped? "
@@ -305,7 +292,7 @@
#if __ANDROID_API__ >= __ANDROID_API_M__
__BIONIC_FORTIFY_INLINE
-void* memchr(const void *_Nonnull s __pass_object_size, int c, size_t n) {
+void* memchr(const void* s __pass_object_size, int c, size_t n) {
size_t bos = __bos(s);
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
@@ -345,7 +332,7 @@
#if __ANDROID_API__ >= __ANDROID_API_L__
__BIONIC_FORTIFY_INLINE
-char* stpncpy(char* _Nonnull dst, const char* _Nonnull src, size_t n) {
+char* stpncpy(char* dst, const char* src, size_t n) {
size_t bos_dst = __bos(dst);
size_t bos_src = __bos(src);
@@ -366,7 +353,7 @@
}
__BIONIC_FORTIFY_INLINE
-char* strncpy(char* _Nonnull dst, const char* _Nonnull src, size_t n) {
+char* strncpy(char* dst, const char* src, size_t n) {
size_t bos_dst = __bos(dst);
size_t bos_src = __bos(src);
@@ -389,7 +376,7 @@
#if __ANDROID_API__ >= __ANDROID_API_J_MR1__
__BIONIC_FORTIFY_INLINE
-size_t strlcpy(char* _Nonnull dst __pass_object_size, const char* _Nonnull src, size_t size) {
+size_t strlcpy(char* dst __pass_object_size, const char* src, size_t size) {
size_t bos = __bos(dst);
// Compiler doesn't know destination size. Don't call __strlcpy_chk
@@ -407,7 +394,7 @@
}
__BIONIC_FORTIFY_INLINE
-size_t strlcat(char* _Nonnull dst, const char* _Nonnull src, size_t size) {
+size_t strlcat(char* dst, const char* src, size_t size) {
size_t bos = __bos(dst);
// Compiler doesn't know destination size. Don't call __strlcat_chk
@@ -425,7 +412,7 @@
}
__BIONIC_FORTIFY_INLINE
-size_t strlen(const char* _Nonnull s) __overloadable {
+size_t strlen(const char* s) __overloadable {
size_t bos = __bos(s);
// Compiler doesn't know destination size. Don't call __strlen_chk
@@ -444,7 +431,7 @@
#if __ANDROID_API__ >= __ANDROID_API_J_MR2__
__BIONIC_FORTIFY_INLINE
-char* strchr(const char* _Nonnull s, int c) {
+char* strchr(const char* s, int c) {
size_t bos = __bos(s);
// Compiler doesn't know destination size. Don't call __strchr_chk
@@ -461,7 +448,7 @@
}
__BIONIC_FORTIFY_INLINE
-char* strrchr(const char* _Nonnull s, int c) {
+char* strrchr(const char* s, int c) {
size_t bos = __bos(s);
// Compiler doesn't know destination size. Don't call __strrchr_chk
diff --git a/libc/include/bits/fortify/unistd.h b/libc/include/bits/fortify/unistd.h
index 5df67b4..ea5c89d 100644
--- a/libc/include/bits/fortify/unistd.h
+++ b/libc/include/bits/fortify/unistd.h
@@ -60,34 +60,21 @@
#endif
#if defined(__clang__)
-#define __error_if_overflows_ssizet(what) \
- __enable_if(what > SSIZE_MAX, #what " must be <= SSIZE_MAX") \
- __errorattr(#what " must be <= SSIZE_MAX")
+#define __error_if_overflows_ssizet(what, fn) \
+ __clang_error_if((what) > SSIZE_MAX, "in call to '" #fn "', '" #what "' must be <= SSIZE_MAX")
-#define __enable_if_no_overflow_ssizet(what) \
- __enable_if((what) <= SSIZE_MAX, "enabled if " #what " <= SSIZE_MAX")
-
-#define __error_if_overflows_objectsize(what, objsize) \
- __enable_if((objsize) != __BIONIC_FORTIFY_UNKNOWN_SIZE && \
- (what) > (objsize), \
- "'" #what "' bytes overflows the given object") \
- __errorattr("'" #what "' bytes overflows the given object")
-
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-char* getcwd(char* buf, size_t size) __overloadable
- __error_if_overflows_objectsize(size, __bos(buf));
+#define __error_if_overflows_objectsize(what, objsize, fn) \
+ __clang_error_if((objsize) != __BIONIC_FORTIFY_UNKNOWN_SIZE && (what) > (objsize), \
+ "in call to '" #fn "', '" #what "' bytes overflows the given object")
#if __ANDROID_API__ >= __ANDROID_API_N__
__BIONIC_FORTIFY_INLINE
-char* getcwd(char* const __pass_object_size buf, size_t size) __overloadable {
+char* getcwd(char* const __pass_object_size buf, size_t size)
+ __overloadable
+ __error_if_overflows_objectsize(size, __bos(buf), getcwd) {
size_t bos = __bos(buf);
- /*
- * Clang responds bos==0 if buf==NULL
- * (https://llvm.org/bugs/show_bug.cgi?id=23277). Given that NULL is a valid
- * value, we need to handle that.
- */
- if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE || buf == NULL) {
+ if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
return __call_bypassing_fortify(getcwd)(buf, size);
}
@@ -96,18 +83,11 @@
#endif /* __ANDROID_API__ >= __ANDROID_API_N__ */
#if __ANDROID_API__ >= __ANDROID_API_M__
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-ssize_t pread(int fd, void* buf, size_t count, off_t offset) __overloadable
- __error_if_overflows_ssizet(count);
-
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-ssize_t pread(int fd, void* buf, size_t count, off_t offset) __overloadable
- __enable_if_no_overflow_ssizet(count)
- __error_if_overflows_objectsize(count, __bos0(buf));
-
__BIONIC_FORTIFY_INLINE
-ssize_t pread(int fd, void* const __pass_object_size0 buf, size_t count,
- off_t offset) __overloadable {
+ssize_t pread(int fd, void* const __pass_object_size0 buf, size_t count, off_t offset)
+ __overloadable
+ __error_if_overflows_ssizet(count, pread)
+ __error_if_overflows_objectsize(count, __bos0(buf), pread) {
size_t bos = __bos0(buf);
if (count == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
@@ -117,18 +97,11 @@
return __PREAD_PREFIX(chk)(fd, buf, count, offset, bos);
}
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-ssize_t pread64(int fd, void* buf, size_t count, off64_t offset) __overloadable
- __error_if_overflows_ssizet(count);
-
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-ssize_t pread64(int fd, void* buf, size_t count, off64_t offset) __overloadable
- __enable_if_no_overflow_ssizet(count)
- __error_if_overflows_objectsize(count, __bos0(buf));
-
__BIONIC_FORTIFY_INLINE
-ssize_t pread64(int fd, void* const __pass_object_size0 buf, size_t count,
- off64_t offset) __overloadable {
+ssize_t pread64(int fd, void* const __pass_object_size0 buf, size_t count, off64_t offset)
+ __overloadable
+ __error_if_overflows_ssizet(count, pread64)
+ __error_if_overflows_objectsize(count, __bos0(buf), pread64) {
size_t bos = __bos0(buf);
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
@@ -140,20 +113,11 @@
#endif /* __ANDROID_API__ >= __ANDROID_API_M__ */
#if __ANDROID_API__ >= __ANDROID_API_N__
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-ssize_t pwrite(int fd, const void* buf, size_t count, off_t offset)
- __overloadable
- __error_if_overflows_ssizet(count);
-
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-ssize_t pwrite(int fd, const void* buf, size_t count, off_t offset)
- __overloadable
- __enable_if_no_overflow_ssizet(count)
- __error_if_overflows_objectsize(count, __bos0(buf));
-
__BIONIC_FORTIFY_INLINE
-ssize_t pwrite(int fd, const void* const __pass_object_size0 buf, size_t count,
- off_t offset) __overloadable {
+ssize_t pwrite(int fd, const void* const __pass_object_size0 buf, size_t count, off_t offset)
+ __overloadable
+ __error_if_overflows_ssizet(count, pwrite)
+ __error_if_overflows_objectsize(count, __bos0(buf), pwrite) {
size_t bos = __bos0(buf);
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
@@ -163,20 +127,11 @@
return __PWRITE_PREFIX(chk)(fd, buf, count, offset, bos);
}
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-ssize_t pwrite64(int fd, const void* buf, size_t count, off64_t offset)
- __overloadable
- __error_if_overflows_ssizet(count);
-
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-ssize_t pwrite64(int fd, const void* buf, size_t count, off64_t offset)
- __overloadable
- __enable_if_no_overflow_ssizet(count)
- __error_if_overflows_objectsize(count, __bos0(buf));
-
__BIONIC_FORTIFY_INLINE
-ssize_t pwrite64(int fd, const void* const __pass_object_size0 buf,
- size_t count, off64_t offset) __overloadable {
+ssize_t pwrite64(int fd, const void* const __pass_object_size0 buf, size_t count, off64_t offset)
+ __overloadable
+ __error_if_overflows_ssizet(count, pwrite64)
+ __error_if_overflows_objectsize(count, __bos0(buf), pwrite64) {
size_t bos = __bos0(buf);
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
@@ -188,18 +143,11 @@
#endif /* __ANDROID_API__ >= __ANDROID_API_N__ */
#if __ANDROID_API__ >= __ANDROID_API_L__
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-ssize_t read(int fd, void* buf, size_t count) __overloadable
- __error_if_overflows_ssizet(count);
-
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-ssize_t read(int fd, void* buf, size_t count) __overloadable
- __enable_if_no_overflow_ssizet(count)
- __error_if_overflows_objectsize(count, __bos0(buf));
-
__BIONIC_FORTIFY_INLINE
ssize_t read(int fd, void* const __pass_object_size0 buf, size_t count)
- __overloadable {
+ __overloadable
+ __error_if_overflows_ssizet(count, read)
+ __error_if_overflows_objectsize(count, __bos0(buf), read) {
size_t bos = __bos0(buf);
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
@@ -211,18 +159,11 @@
#endif /* __ANDROID_API__ >= __ANDROID_API_L__ */
#if __ANDROID_API__ >= __ANDROID_API_N__
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-ssize_t write(int fd, const void* buf, size_t count) __overloadable
- __error_if_overflows_ssizet(count);
-
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-ssize_t write(int fd, const void* buf, size_t count) __overloadable
- __enable_if_no_overflow_ssizet(count)
- __error_if_overflows_objectsize(count, __bos0(buf));
-
__BIONIC_FORTIFY_INLINE
ssize_t write(int fd, const void* const __pass_object_size0 buf, size_t count)
- __overloadable {
+ __overloadable
+ __error_if_overflows_ssizet(count, write)
+ __error_if_overflows_objectsize(count, __bos0(buf), write) {
size_t bos = __bos0(buf);
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
@@ -234,18 +175,11 @@
#endif /* __ANDROID_API__ >= __ANDROID_API_N__ */
#if __ANDROID_API__ >= __ANDROID_API_M__
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-ssize_t readlink(const char* path, char* buf, size_t size) __overloadable
- __error_if_overflows_ssizet(size);
-
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-ssize_t readlink(const char* path, char* buf, size_t size) __overloadable
- __enable_if_no_overflow_ssizet(size)
- __error_if_overflows_objectsize(size, __bos(buf));
-
__BIONIC_FORTIFY_INLINE
-ssize_t readlink(const char* path, char* const __pass_object_size buf,
- size_t size) __overloadable {
+ssize_t readlink(const char* path, char* const __pass_object_size buf, size_t size)
+ __overloadable
+ __error_if_overflows_ssizet(size, readlink)
+ __error_if_overflows_objectsize(size, __bos(buf), readlink) {
size_t bos = __bos(buf);
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
@@ -255,21 +189,11 @@
return __readlink_chk(path, buf, size, bos);
}
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-ssize_t readlinkat(int dirfd, const char* path, char* buf, size_t size)
- __overloadable
- __error_if_overflows_ssizet(size);
-
-__BIONIC_ERROR_FUNCTION_VISIBILITY
-ssize_t readlinkat(int dirfd, const char* path, char* buf, size_t size)
- __overloadable
- __enable_if_no_overflow_ssizet(size)
- __error_if_overflows_objectsize(size, __bos(buf));
-
__BIONIC_FORTIFY_INLINE
-ssize_t readlinkat(int dirfd, const char* path,
- char* const __pass_object_size buf, size_t size)
- __overloadable {
+ssize_t readlinkat(int dirfd, const char* path, char* const __pass_object_size buf, size_t size)
+ __overloadable
+ __error_if_overflows_ssizet(size, readlinkat)
+ __error_if_overflows_objectsize(size, __bos(buf), readlinkat) {
size_t bos = __bos(buf);
if (bos == __BIONIC_FORTIFY_UNKNOWN_SIZE) {
diff --git a/libc/include/dlfcn.h b/libc/include/dlfcn.h
index 018482d..76bbdb8 100644
--- a/libc/include/dlfcn.h
+++ b/libc/include/dlfcn.h
@@ -34,11 +34,6 @@
__BEGIN_DECLS
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wnullability-completeness"
-#endif
-
typedef struct {
/* Pathname of shared object that contains address. */
const char* dli_fname;
@@ -51,11 +46,11 @@
} Dl_info;
void* dlopen(const char* filename, int flag);
-int dlclose(void* _Nonnull handle);
+int dlclose(void* handle);
char* dlerror(void);
-void* dlsym(void* handle, const char* _Nonnull symbol);
-void* dlvsym(void* handle, const char* _Nonnull symbol, const char* _Nonnull version) __INTRODUCED_IN(24);
-int dladdr(const void* addr, Dl_info* _Nonnull info);
+void* dlsym(void* handle, const char* symbol);
+void* dlvsym(void* handle, const char* symbol, const char* version) __INTRODUCED_IN(24);
+int dladdr(const void* addr, Dl_info* info);
#define RTLD_LOCAL 0
#define RTLD_LAZY 0x00001
@@ -80,10 +75,6 @@
#define RTLD_NEXT __BIONIC_CAST(reinterpret_cast, void*, 0xfffffffe)
#endif
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif
-
__END_DECLS
#endif /* __DLFCN_H */
diff --git a/libc/include/error.h b/libc/include/error.h
index 05ce35d..b145afc 100644
--- a/libc/include/error.h
+++ b/libc/include/error.h
@@ -33,12 +33,12 @@
__BEGIN_DECLS
-extern void (* _Nullable error_print_progname)(void) __INTRODUCED_IN(23);
+extern void (*error_print_progname)(void) __INTRODUCED_IN(23);
extern unsigned int error_message_count __INTRODUCED_IN(23);
extern int error_one_per_line __INTRODUCED_IN(23);
-void error(int, int, const char* _Nonnull, ...) __printflike(3, 4) __INTRODUCED_IN(23);
-void error_at_line(int, int, const char* _Nullable, unsigned int, const char* _Nonnull, ...)
+void error(int, int, const char*, ...) __printflike(3, 4) __INTRODUCED_IN(23);
+void error_at_line(int, int, const char*, unsigned int, const char*, ...)
__printflike(5, 6) __INTRODUCED_IN(23);
__END_DECLS
diff --git a/libc/include/pthread.h b/libc/include/pthread.h
index 7dec3cc..7165738 100644
--- a/libc/include/pthread.h
+++ b/libc/include/pthread.h
@@ -38,11 +38,6 @@
__BEGIN_DECLS
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wnullability-completeness"
-#endif
-
enum {
PTHREAD_MUTEX_NORMAL = 0,
PTHREAD_MUTEX_RECURSIVE = 1,
@@ -90,51 +85,48 @@
int pthread_atfork(void (*)(void), void (*)(void), void (*)(void)) __INTRODUCED_IN(12);
-int pthread_attr_destroy(pthread_attr_t* _Nonnull);
-int pthread_attr_getdetachstate(const pthread_attr_t* _Nonnull, int* _Nonnull);
-int pthread_attr_getguardsize(const pthread_attr_t* _Nonnull, size_t* _Nonnull);
-int pthread_attr_getschedparam(const pthread_attr_t* _Nonnull, struct sched_param* _Nonnull);
-int pthread_attr_getschedpolicy(const pthread_attr_t* _Nonnull, int* _Nonnull);
-int pthread_attr_getscope(const pthread_attr_t* _Nonnull, int* _Nonnull);
-int pthread_attr_getstack(const pthread_attr_t* _Nonnull, void** _Nonnull, size_t* _Nonnull);
-int pthread_attr_getstacksize(const pthread_attr_t* _Nonnull, size_t* _Nonnull);
-int pthread_attr_init(pthread_attr_t* _Nonnull);
-int pthread_attr_setdetachstate(pthread_attr_t* _Nonnull, int);
-int pthread_attr_setguardsize(pthread_attr_t* _Nonnull, size_t);
-int pthread_attr_setschedparam(pthread_attr_t* _Nonnull, const struct sched_param* _Nonnull);
-int pthread_attr_setschedpolicy(pthread_attr_t* _Nonnull, int);
-int pthread_attr_setscope(pthread_attr_t* _Nonnull, int);
-int pthread_attr_setstack(pthread_attr_t* _Nonnull, void*, size_t);
-int pthread_attr_setstacksize(pthread_attr_t* _Nonnull, size_t);
+int pthread_attr_destroy(pthread_attr_t*);
+int pthread_attr_getdetachstate(const pthread_attr_t*, int*);
+int pthread_attr_getguardsize(const pthread_attr_t*, size_t*);
+int pthread_attr_getschedparam(const pthread_attr_t*, struct sched_param*);
+int pthread_attr_getschedpolicy(const pthread_attr_t*, int*);
+int pthread_attr_getscope(const pthread_attr_t*, int*);
+int pthread_attr_getstack(const pthread_attr_t*, void**, size_t*);
+int pthread_attr_getstacksize(const pthread_attr_t*, size_t*);
+int pthread_attr_init(pthread_attr_t*);
+int pthread_attr_setdetachstate(pthread_attr_t*, int);
+int pthread_attr_setguardsize(pthread_attr_t*, size_t);
+int pthread_attr_setschedparam(pthread_attr_t*, const struct sched_param*);
+int pthread_attr_setschedpolicy(pthread_attr_t*, int);
+int pthread_attr_setscope(pthread_attr_t*, int);
+int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
+int pthread_attr_setstacksize(pthread_attr_t*, size_t);
-int pthread_condattr_destroy(pthread_condattr_t* _Nonnull);
-int pthread_condattr_getclock(const pthread_condattr_t* _Nonnull, clockid_t* _Nonnull)
- __INTRODUCED_IN(21);
-int pthread_condattr_getpshared(const pthread_condattr_t* _Nonnull, int* _Nonnull);
-int pthread_condattr_init(pthread_condattr_t* _Nonnull);
-int pthread_condattr_setclock(pthread_condattr_t* _Nonnull, clockid_t) __INTRODUCED_IN(21);
-int pthread_condattr_setpshared(pthread_condattr_t* _Nonnull, int);
+int pthread_condattr_destroy(pthread_condattr_t*);
+int pthread_condattr_getclock(const pthread_condattr_t*, clockid_t*) __INTRODUCED_IN(21);
+int pthread_condattr_getpshared(const pthread_condattr_t*, int*);
+int pthread_condattr_init(pthread_condattr_t*);
+int pthread_condattr_setclock(pthread_condattr_t*, clockid_t) __INTRODUCED_IN(21);
+int pthread_condattr_setpshared(pthread_condattr_t*, int);
-int pthread_cond_broadcast(pthread_cond_t* _Nonnull);
-int pthread_cond_destroy(pthread_cond_t* _Nonnull);
-int pthread_cond_init(pthread_cond_t* _Nonnull, const pthread_condattr_t*);
-int pthread_cond_signal(pthread_cond_t* _Nonnull);
-int pthread_cond_timedwait(pthread_cond_t* _Nonnull, pthread_mutex_t* _Nonnull,
- const struct timespec* _Nonnull);
-int pthread_cond_wait(pthread_cond_t* _Nonnull, pthread_mutex_t* _Nonnull);
+int pthread_cond_broadcast(pthread_cond_t*);
+int pthread_cond_destroy(pthread_cond_t*);
+int pthread_cond_init(pthread_cond_t*, const pthread_condattr_t*);
+int pthread_cond_signal(pthread_cond_t*);
+int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, const struct timespec*);
+int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*);
-int pthread_create(pthread_t* _Nonnull, pthread_attr_t const*,
- void* (* _Nonnull start_routine)(void*), void*);
+int pthread_create(pthread_t*, pthread_attr_t const*, void* (*start_routine)(void*), void*);
int pthread_detach(pthread_t);
void pthread_exit(void*) __noreturn;
int pthread_equal(pthread_t, pthread_t);
-int pthread_getattr_np(pthread_t, pthread_attr_t* _Nonnull);
+int pthread_getattr_np(pthread_t, pthread_attr_t*);
-int pthread_getcpuclockid(pthread_t, clockid_t* _Nonnull);
+int pthread_getcpuclockid(pthread_t, clockid_t*);
-int pthread_getschedparam(pthread_t, int* _Nonnull, struct sched_param* _Nonnull);
+int pthread_getschedparam(pthread_t, int*, struct sched_param*);
void* pthread_getspecific(pthread_key_t);
@@ -142,23 +134,23 @@
int pthread_join(pthread_t, void**);
-int pthread_key_create(pthread_key_t* _Nonnull, void (*)(void*));
+int pthread_key_create(pthread_key_t*, void (*)(void*));
int pthread_key_delete(pthread_key_t);
-int pthread_mutexattr_destroy(pthread_mutexattr_t* _Nonnull);
-int pthread_mutexattr_getpshared(const pthread_mutexattr_t* _Nonnull, int* _Nonnull);
-int pthread_mutexattr_gettype(const pthread_mutexattr_t* _Nonnull, int* _Nonnull);
-int pthread_mutexattr_init(pthread_mutexattr_t* _Nonnull);
-int pthread_mutexattr_setpshared(pthread_mutexattr_t* _Nonnull, int);
-int pthread_mutexattr_settype(pthread_mutexattr_t* _Nonnull, int);
+int pthread_mutexattr_destroy(pthread_mutexattr_t*);
+int pthread_mutexattr_getpshared(const pthread_mutexattr_t*, int*);
+int pthread_mutexattr_gettype(const pthread_mutexattr_t*, int*);
+int pthread_mutexattr_init(pthread_mutexattr_t*);
+int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
+int pthread_mutexattr_settype(pthread_mutexattr_t*, int);
-int pthread_mutex_destroy(pthread_mutex_t* _Nonnull);
-int pthread_mutex_init(pthread_mutex_t* _Nonnull, const pthread_mutexattr_t*);
-int pthread_mutex_lock(pthread_mutex_t* _Nonnull);
-int pthread_mutex_timedlock(pthread_mutex_t* _Nonnull, const struct timespec* _Nonnull)
+int pthread_mutex_destroy(pthread_mutex_t*);
+int pthread_mutex_init(pthread_mutex_t*, const pthread_mutexattr_t*);
+int pthread_mutex_lock(pthread_mutex_t*);
+int pthread_mutex_timedlock(pthread_mutex_t*, const struct timespec* )
__INTRODUCED_IN(21);
-int pthread_mutex_trylock(pthread_mutex_t* _Nonnull);
-int pthread_mutex_unlock(pthread_mutex_t* _Nonnull);
+int pthread_mutex_trylock(pthread_mutex_t*);
+int pthread_mutex_unlock(pthread_mutex_t*);
#if defined(__LP32__) && __ANDROID_API__ < 21
/*
@@ -180,59 +172,59 @@
const struct timespec* reltime);
#endif
-int pthread_once(pthread_once_t* _Nonnull, void (* _Nonnull init_routine)(void));
+int pthread_once(pthread_once_t*, void (*init_routine)(void));
-int pthread_rwlockattr_init(pthread_rwlockattr_t* _Nonnull);
-int pthread_rwlockattr_destroy(pthread_rwlockattr_t* _Nonnull);
-int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t* _Nonnull, int* _Nonnull);
-int pthread_rwlockattr_setpshared(pthread_rwlockattr_t* _Nonnull, int);
-int pthread_rwlockattr_getkind_np(const pthread_rwlockattr_t* _Nonnull, int* _Nonnull)
+int pthread_rwlockattr_init(pthread_rwlockattr_t*);
+int pthread_rwlockattr_destroy(pthread_rwlockattr_t*);
+int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t*, int*);
+int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
+int pthread_rwlockattr_getkind_np(const pthread_rwlockattr_t*, int*)
__INTRODUCED_IN(23);
-int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t* _Nonnull, int) __INTRODUCED_IN(23);
+int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t*, int) __INTRODUCED_IN(23);
-int pthread_rwlock_destroy(pthread_rwlock_t* _Nonnull);
-int pthread_rwlock_init(pthread_rwlock_t* _Nonnull, const pthread_rwlockattr_t*);
-int pthread_rwlock_rdlock(pthread_rwlock_t* _Nonnull);
-int pthread_rwlock_timedrdlock(pthread_rwlock_t* _Nonnull, const struct timespec* _Nonnull);
-int pthread_rwlock_timedwrlock(pthread_rwlock_t* _Nonnull, const struct timespec* _Nonnull);
-int pthread_rwlock_tryrdlock(pthread_rwlock_t* _Nonnull);
-int pthread_rwlock_trywrlock(pthread_rwlock_t* _Nonnull);
-int pthread_rwlock_unlock(pthread_rwlock_t* _Nonnull);
-int pthread_rwlock_wrlock(pthread_rwlock_t* _Nonnull);
+int pthread_rwlock_destroy(pthread_rwlock_t*);
+int pthread_rwlock_init(pthread_rwlock_t*, const pthread_rwlockattr_t*);
+int pthread_rwlock_rdlock(pthread_rwlock_t*);
+int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const struct timespec*);
+int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const struct timespec*);
+int pthread_rwlock_tryrdlock(pthread_rwlock_t*);
+int pthread_rwlock_trywrlock(pthread_rwlock_t*);
+int pthread_rwlock_unlock(pthread_rwlock_t*);
+int pthread_rwlock_wrlock(pthread_rwlock_t*);
#if __ANDROID_API__ >= __ANDROID_API_N__
-int pthread_barrierattr_init(pthread_barrierattr_t* _Nonnull attr) __INTRODUCED_IN(24);
-int pthread_barrierattr_destroy(pthread_barrierattr_t* _Nonnull attr) __INTRODUCED_IN(24);
-int pthread_barrierattr_getpshared(const pthread_barrierattr_t* _Nonnull attr,
- int* _Nonnull pshared) __INTRODUCED_IN(24);
-int pthread_barrierattr_setpshared(pthread_barrierattr_t* _Nonnull attr, int pshared)
+int pthread_barrierattr_init(pthread_barrierattr_t* attr) __INTRODUCED_IN(24);
+int pthread_barrierattr_destroy(pthread_barrierattr_t* attr) __INTRODUCED_IN(24);
+int pthread_barrierattr_getpshared(const pthread_barrierattr_t* attr,
+ int* pshared) __INTRODUCED_IN(24);
+int pthread_barrierattr_setpshared(pthread_barrierattr_t* attr, int pshared)
__INTRODUCED_IN(24);
#endif
#if __ANDROID_API__ >= __ANDROID_API_N__
-int pthread_barrier_init(pthread_barrier_t* _Nonnull, const pthread_barrierattr_t*, unsigned)
+int pthread_barrier_init(pthread_barrier_t*, const pthread_barrierattr_t*, unsigned)
__INTRODUCED_IN(24);
-int pthread_barrier_destroy(pthread_barrier_t* _Nonnull) __INTRODUCED_IN(24);
-int pthread_barrier_wait(pthread_barrier_t* _Nonnull) __INTRODUCED_IN(24);
+int pthread_barrier_destroy(pthread_barrier_t*) __INTRODUCED_IN(24);
+int pthread_barrier_wait(pthread_barrier_t*) __INTRODUCED_IN(24);
#endif
#if __ANDROID_API__ >= __ANDROID_API_N__
-int pthread_spin_destroy(pthread_spinlock_t* _Nonnull) __INTRODUCED_IN(24);
-int pthread_spin_init(pthread_spinlock_t* _Nonnull, int) __INTRODUCED_IN(24);
-int pthread_spin_lock(pthread_spinlock_t* _Nonnull) __INTRODUCED_IN(24);
-int pthread_spin_trylock(pthread_spinlock_t* _Nonnull) __INTRODUCED_IN(24);
-int pthread_spin_unlock(pthread_spinlock_t* _Nonnull) __INTRODUCED_IN(24);
+int pthread_spin_destroy(pthread_spinlock_t*) __INTRODUCED_IN(24);
+int pthread_spin_init(pthread_spinlock_t*, int) __INTRODUCED_IN(24);
+int pthread_spin_lock(pthread_spinlock_t*) __INTRODUCED_IN(24);
+int pthread_spin_trylock(pthread_spinlock_t*) __INTRODUCED_IN(24);
+int pthread_spin_unlock(pthread_spinlock_t*) __INTRODUCED_IN(24);
#endif
pthread_t pthread_self(void) __attribute_const__;
#if defined(__USE_GNU)
-int pthread_getname_np(pthread_t, char* _Nonnull, size_t) __INTRODUCED_IN(26);
+int pthread_getname_np(pthread_t, char*, size_t) __INTRODUCED_IN(26);
#endif
/* TODO: this should be __USE_GNU too. */
-int pthread_setname_np(pthread_t, const char* _Nonnull);
+int pthread_setname_np(pthread_t, const char*);
-int pthread_setschedparam(pthread_t, int, const struct sched_param* _Nonnull);
+int pthread_setschedparam(pthread_t, int, const struct sched_param*);
int pthread_setspecific(pthread_key_t, const void*);
@@ -262,10 +254,6 @@
__pthread_cleanup_pop( &__cleanup, (execute)); \
} while (0); \
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif
-
__END_DECLS
#endif /* _PTHREAD_H_ */
diff --git a/libc/include/signal.h b/libc/include/signal.h
index 1400328..89d85fc 100644
--- a/libc/include/signal.h
+++ b/libc/include/signal.h
@@ -54,11 +54,6 @@
__BEGIN_DECLS
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wnullability-completeness"
-#endif
-
typedef int sig_atomic_t;
/* The arm and x86 kernel header files don't define _NSIG. */
@@ -129,10 +124,10 @@
// Implemented as static inlines before 21.
#endif
-int sigpending(sigset_t* _Nonnull);
+int sigpending(sigset_t*);
int sigprocmask(int, const sigset_t*, sigset_t*);
-int sigsuspend(const sigset_t* _Nonnull);
-int sigwait(const sigset_t* _Nonnull, int* _Nonnull);
+int sigsuspend(const sigset_t*);
+int sigwait(const sigset_t*, int*);
int sighold(int)
__attribute__((deprecated("use sigprocmask() or pthread_sigmask() instead")))
@@ -161,12 +156,8 @@
int pthread_sigmask(int, const sigset_t*, sigset_t*);
int sigqueue(pid_t, int, const union sigval) __INTRODUCED_IN(23);
-int sigtimedwait(const sigset_t* _Nonnull, siginfo_t*, const struct timespec*) __INTRODUCED_IN(23);
-int sigwaitinfo(const sigset_t* _Nonnull, siginfo_t*) __INTRODUCED_IN(23);
-
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif
+int sigtimedwait(const sigset_t*, siginfo_t*, const struct timespec*) __INTRODUCED_IN(23);
+int sigwaitinfo(const sigset_t*, siginfo_t*) __INTRODUCED_IN(23);
__END_DECLS
diff --git a/libc/include/stdio.h b/libc/include/stdio.h
index a9bb124..7e5a976 100644
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
@@ -52,11 +52,6 @@
__BEGIN_DECLS
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wnullability-completeness"
-#endif
-
typedef off_t fpos_t;
typedef off64_t fpos64_t;
@@ -119,12 +114,12 @@
int fgetc(FILE *);
char *fgets(char *, int, FILE *) __overloadable
__RENAME_CLANG(fgets);
-int fprintf(FILE * , const char * _Nonnull, ...) __printflike(2, 3);
+int fprintf(FILE * , const char *, ...) __printflike(2, 3);
int fputc(int, FILE *);
int fputs(const char *, FILE *);
size_t fread(void *, size_t, size_t, FILE *)
__overloadable __RENAME_CLANG(fread);
-int fscanf(FILE *, const char * _Nonnull, ...) __scanflike(2, 3);
+int fscanf(FILE *, const char *, ...) __scanflike(2, 3);
size_t fwrite(const void *, size_t, size_t, FILE *)
__overloadable __RENAME_CLANG(fwrite);
int getc(FILE *);
@@ -133,23 +128,23 @@
ssize_t getline(char**, size_t*, FILE*) __INTRODUCED_IN(18);
void perror(const char *);
-int printf(const char * _Nonnull, ...) __printflike(1, 2);
+int printf(const char *, ...) __printflike(1, 2);
int putc(int, FILE *);
int putchar(int);
int puts(const char *);
int remove(const char *);
void rewind(FILE *);
-int scanf(const char * _Nonnull, ...) __scanflike(1, 2);
+int scanf(const char *, ...) __scanflike(1, 2);
void setbuf(FILE *, char *);
int setvbuf(FILE *, char *, int, size_t);
-int sscanf(const char *, const char * _Nonnull, ...) __scanflike(2, 3);
+int sscanf(const char *, const char *, ...) __scanflike(2, 3);
int ungetc(int, FILE *);
-int vfprintf(FILE *, const char * _Nonnull, va_list) __printflike(2, 0);
-int vprintf(const char * _Nonnull, va_list) __printflike(1, 0);
+int vfprintf(FILE *, const char *, va_list) __printflike(2, 0);
+int vprintf(const char *, va_list) __printflike(1, 0);
#if __ANDROID_API__ >= 21
-int dprintf(int, const char* _Nonnull, ...) __printflike(2, 3) __INTRODUCED_IN(21);
-int vdprintf(int, const char* _Nonnull, va_list) __printflike(2, 0) __INTRODUCED_IN(21);
+int dprintf(int, const char*, ...) __printflike(2, 3) __INTRODUCED_IN(21);
+int vdprintf(int, const char*, va_list) __printflike(2, 0) __INTRODUCED_IN(21);
#else
/*
* Old versions of Android called these fdprintf and vfdprintf out of fears that the glibc names
@@ -158,18 +153,18 @@
* Allow users to just use dprintf and vfdprintf on any version by renaming those calls to their
* legacy equivalents if needed.
*/
-int dprintf(int, const char* _Nonnull, ...) __printflike(2, 3) __RENAME(fdprintf);
-int vdprintf(int, const char* _Nonnull, va_list) __printflike(2, 0) __RENAME(vfdprintf);
+int dprintf(int, const char*, ...) __printflike(2, 3) __RENAME(fdprintf);
+int vdprintf(int, const char*, va_list) __printflike(2, 0) __RENAME(vfdprintf);
#endif
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ < 201112L) || \
(defined(__cplusplus) && __cplusplus <= 201103L)
char* gets(char*) __attribute__((deprecated("gets is unsafe, use fgets instead")));
#endif
-int sprintf(char*, const char* _Nonnull, ...)
+int sprintf(char*, const char*, ...)
__printflike(2, 3) __warnattr_strict("sprintf is often misused; please use snprintf")
__overloadable __RENAME_CLANG(sprintf);
-int vsprintf(char*, const char* _Nonnull, va_list)
+int vsprintf(char*, const char*, va_list)
__overloadable __printflike(2, 0) __RENAME_CLANG(vsprintf)
__warnattr_strict("vsprintf is often misused; please use vsnprintf");
char* tmpnam(char*)
@@ -226,13 +221,13 @@
FILE* tmpfile(void);
FILE* tmpfile64(void) __INTRODUCED_IN(24);
-int snprintf(char*, size_t, const char* _Nonnull, ...)
+int snprintf(char*, size_t, const char*, ...)
__printflike(3, 4) __overloadable __RENAME_CLANG(snprintf);
-int vfscanf(FILE*, const char* _Nonnull, va_list) __scanflike(2, 0);
-int vscanf(const char* _Nonnull , va_list) __scanflike(1, 0);
-int vsnprintf(char*, size_t, const char* _Nonnull, va_list)
+int vfscanf(FILE*, const char*, va_list) __scanflike(2, 0);
+int vscanf(const char* , va_list) __scanflike(1, 0);
+int vsnprintf(char*, size_t, const char*, va_list)
__printflike(3, 0) __overloadable __RENAME_CLANG(vsnprintf);
-int vsscanf(const char* _Nonnull, const char* _Nonnull, va_list) __scanflike(2, 0);
+int vsscanf(const char*, const char*, va_list) __scanflike(2, 0);
#define L_ctermid 1024 /* size for ctermid() */
char* ctermid(char*) __INTRODUCED_IN(26);
@@ -253,12 +248,12 @@
FILE* open_memstream(char**, size_t*) __INTRODUCED_IN(23);
#if defined(__USE_BSD) || defined(__BIONIC__) /* Historically bionic exposed these. */
-int asprintf(char**, const char* _Nonnull, ...) __printflike(2, 3);
+int asprintf(char**, const char*, ...) __printflike(2, 3);
char* fgetln(FILE*, size_t*);
int fpurge(FILE*);
void setbuffer(FILE*, char*, int);
int setlinebuf(FILE*);
-int vasprintf(char**, const char* _Nonnull, va_list) __printflike(2, 0);
+int vasprintf(char**, const char*, va_list) __printflike(2, 0);
void clearerr_unlocked(FILE*) __INTRODUCED_IN(23);
int feof_unlocked(FILE*) __INTRODUCED_IN(23);
int ferror_unlocked(FILE*) __INTRODUCED_IN(23);
@@ -271,10 +266,6 @@
#include <bits/fortify/stdio.h>
#endif
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif
-
__END_DECLS
#endif /* _STDIO_H_ */
diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h
index 55e0fa2..13c9d37 100644
--- a/libc/include/stdlib.h
+++ b/libc/include/stdlib.h
@@ -83,8 +83,7 @@
long atol(const char*) __attribute_pure__;
long long atoll(const char*) __attribute_pure__;
-char * realpath(const char *path, char *resolved) __overloadable
- __RENAME_CLANG(realpath);
+char* realpath(const char* path, char* resolved);
int system(const char *string);
void* bsearch(const void* key, const void* base0, size_t nmemb, size_t size,
diff --git a/libc/include/string.h b/libc/include/string.h
index 8b4fa27..631b3dd 100644
--- a/libc/include/string.h
+++ b/libc/include/string.h
@@ -37,64 +37,52 @@
__BEGIN_DECLS
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wnullability-completeness"
-#endif
-
#if defined(__USE_BSD)
#include <strings.h>
#endif
-void* memccpy(void* _Nonnull, const void* _Nonnull, int, size_t);
-void* memchr(const void* _Nonnull, int, size_t) __attribute_pure__ __overloadable
- __RENAME_CLANG(memchr);
-void* memrchr(const void* _Nonnull, int, size_t) __attribute_pure__ __overloadable
- __RENAME_CLANG(memrchr);
-int memcmp(const void* _Nonnull, const void* _Nonnull, size_t) __attribute_pure__;
-void* memcpy(void* _Nonnull, const void* _Nonnull, size_t)
+void* memccpy(void*, const void*, int, size_t);
+void* memchr(const void*, int, size_t) __attribute_pure__ __overloadable __RENAME_CLANG(memchr);
+void* memrchr(const void*, int, size_t) __attribute_pure__ __overloadable __RENAME_CLANG(memrchr);
+int memcmp(const void*, const void*, size_t) __attribute_pure__;
+void* memcpy(void*, const void*, size_t)
__overloadable __RENAME_CLANG(memcpy);
#if defined(__USE_GNU)
-void* mempcpy(void* _Nonnull, const void* _Nonnull, size_t) __INTRODUCED_IN(23);
+void* mempcpy(void*, const void*, size_t) __INTRODUCED_IN(23);
#endif
-void* memmove(void* _Nonnull, const void* _Nonnull, size_t) __overloadable
- __RENAME_CLANG(memmove);
-void* memset(void* _Nonnull, int, size_t) __overloadable __RENAME_CLANG(memset);
-void* memmem(const void* _Nonnull, size_t, const void* _Nonnull, size_t) __attribute_pure__;
+void* memmove(void*, const void*, size_t) __overloadable __RENAME_CLANG(memmove);
+void* memset(void*, int, size_t) __overloadable __RENAME_CLANG(memset);
+void* memmem(const void*, size_t, const void*, size_t) __attribute_pure__;
-char* strchr(const char* _Nonnull, int) __attribute_pure__ __overloadable
- __RENAME_CLANG(strchr);
-char* __strchr_chk(const char* _Nonnull, int, size_t) __INTRODUCED_IN(18);
+char* strchr(const char*, int) __attribute_pure__ __overloadable __RENAME_CLANG(strchr);
+char* __strchr_chk(const char*, int, size_t) __INTRODUCED_IN(18);
#if defined(__USE_GNU)
#if defined(__cplusplus)
-extern "C++" char* strchrnul(char* _Nonnull, int) __RENAME(strchrnul) __attribute_pure__ __INTRODUCED_IN(24);
-extern "C++" const char* strchrnul(const char* _Nonnull, int) __RENAME(strchrnul) __attribute_pure__ __INTRODUCED_IN(24);
+extern "C++" char* strchrnul(char*, int) __RENAME(strchrnul) __attribute_pure__ __INTRODUCED_IN(24);
+extern "C++" const char* strchrnul(const char*, int) __RENAME(strchrnul) __attribute_pure__ __INTRODUCED_IN(24);
#else
-char* strchrnul(const char* _Nonnull, int) __attribute_pure__ __INTRODUCED_IN(24);
+char* strchrnul(const char*, int) __attribute_pure__ __INTRODUCED_IN(24);
#endif
#endif
-char* strrchr(const char* _Nonnull, int) __attribute_pure__ __overloadable
- __RENAME_CLANG(strrchr);
-char* __strrchr_chk(const char* _Nonnull, int, size_t) __INTRODUCED_IN(18);
+char* strrchr(const char*, int) __attribute_pure__ __overloadable __RENAME_CLANG(strrchr);
+char* __strrchr_chk(const char*, int, size_t) __INTRODUCED_IN(18);
-size_t strlen(const char* _Nonnull) __attribute_pure__ __overloadable
+size_t strlen(const char*) __attribute_pure__ __overloadable
__RENAME_CLANG(strlen);
-size_t __strlen_chk(const char* _Nonnull, size_t) __INTRODUCED_IN(17);
+size_t __strlen_chk(const char*, size_t) __INTRODUCED_IN(17);
-int strcmp(const char* _Nonnull, const char* _Nonnull) __attribute_pure__;
-char* stpcpy(char* _Nonnull, const char* _Nonnull)
- __overloadable __RENAME_CLANG(stpcpy) __INTRODUCED_IN(21);
-char* strcpy(char* _Nonnull, const char* _Nonnull)
+int strcmp(const char*, const char*) __attribute_pure__;
+char* stpcpy(char*, const char*) __overloadable __RENAME_CLANG(stpcpy) __INTRODUCED_IN(21);
+char* strcpy(char*, const char*)
__overloadable __RENAME_CLANG(strcpy);
-char* strcat(char* _Nonnull, const char* _Nonnull)
- __overloadable __RENAME_CLANG(strcat);
-char* strdup(const char* _Nonnull);
+char* strcat(char*, const char*) __overloadable __RENAME_CLANG(strcat);
+char* strdup(const char*);
-char* strstr(const char* _Nonnull, const char* _Nonnull) __attribute_pure__;
-char* strcasestr(const char* _Nonnull, const char* _Nonnull) __attribute_pure__;
-char* strtok(char*, const char* _Nonnull);
-char* strtok_r(char*, const char* _Nonnull, char** _Nonnull);
+char* strstr(const char*, const char*) __attribute_pure__;
+char* strcasestr(const char*, const char*) __attribute_pure__;
+char* strtok(char*, const char*);
+char* strtok_r(char*, const char*, char**);
char* strerror(int);
char* strerror_l(int, locale_t) __INTRODUCED_IN(23);
@@ -104,34 +92,29 @@
int strerror_r(int, char*, size_t);
#endif
-size_t strnlen(const char* _Nonnull, size_t) __attribute_pure__;
-char* strncat(char* _Nonnull, const char* _Nonnull, size_t)
- __overloadable __RENAME_CLANG(strncat);
-char* strndup(const char* _Nonnull, size_t);
-int strncmp(const char* _Nonnull, const char* _Nonnull, size_t) __attribute_pure__;
-char* stpncpy(char* _Nonnull, const char* _Nonnull, size_t)
- __overloadable __RENAME_CLANG(stpncpy) __INTRODUCED_IN(21);
-char* strncpy(char* _Nonnull, const char* _Nonnull, size_t)
- __overloadable __RENAME_CLANG(strncpy);
+size_t strnlen(const char*, size_t) __attribute_pure__;
+char* strncat(char*, const char*, size_t) __overloadable __RENAME_CLANG(strncat);
+char* strndup(const char*, size_t);
+int strncmp(const char*, const char*, size_t) __attribute_pure__;
+char* stpncpy(char*, const char*, size_t) __overloadable __RENAME_CLANG(stpncpy) __INTRODUCED_IN(21);
+char* strncpy(char*, const char*, size_t) __overloadable __RENAME_CLANG(strncpy);
-size_t strlcat(char* _Nonnull, const char* _Nonnull, size_t)
- __overloadable __RENAME_CLANG(strlcat);
-size_t strlcpy(char* _Nonnull, const char* _Nonnull, size_t)
- __overloadable __RENAME_CLANG(strlcpy);
+size_t strlcat(char*, const char*, size_t) __overloadable __RENAME_CLANG(strlcat);
+size_t strlcpy(char*, const char*, size_t) __overloadable __RENAME_CLANG(strlcpy);
-size_t strcspn(const char* _Nonnull, const char* _Nonnull) __attribute_pure__;
-char* strpbrk(const char* _Nonnull, const char* _Nonnull) __attribute_pure__;
-char* strsep(char** _Nonnull, const char* _Nonnull);
-size_t strspn(const char* _Nonnull, const char* _Nonnull);
+size_t strcspn(const char*, const char*) __attribute_pure__;
+char* strpbrk(const char*, const char*) __attribute_pure__;
+char* strsep(char**, const char*);
+size_t strspn(const char*, const char*);
char* strsignal(int);
-int strcoll(const char* _Nonnull, const char* _Nonnull) __attribute_pure__;
-size_t strxfrm(char*, const char* _Nonnull, size_t);
+int strcoll(const char*, const char*) __attribute_pure__;
+size_t strxfrm(char*, const char*, size_t);
#if __ANDROID_API__ >= __ANDROID_API_L__
-int strcoll_l(const char* _Nonnull, const char* _Nonnull, locale_t) __attribute_pure__ __INTRODUCED_IN(21);
-size_t strxfrm_l(char*, const char* _Nonnull, size_t, locale_t) __INTRODUCED_IN(21);
+int strcoll_l(const char*, const char*, locale_t) __attribute_pure__ __INTRODUCED_IN(21);
+size_t strxfrm_l(char*, const char*, size_t, locale_t) __INTRODUCED_IN(21);
#else
// Implemented as static inlines before 21.
#endif
@@ -142,10 +125,10 @@
* It doesn't modify its argument, and in C++ it's const-correct.
*/
#if defined(__cplusplus)
-extern "C++" char* basename(char* _Nonnull) __RENAME(__gnu_basename) __INTRODUCED_IN(23);
-extern "C++" const char* basename(const char* _Nonnull) __RENAME(__gnu_basename) __INTRODUCED_IN(23);
+extern "C++" char* basename(char*) __RENAME(__gnu_basename) __INTRODUCED_IN(23);
+extern "C++" const char* basename(const char*) __RENAME(__gnu_basename) __INTRODUCED_IN(23);
#else
-char* basename(const char* _Nonnull) __RENAME(__gnu_basename) __INTRODUCED_IN(23);
+char* basename(const char*) __RENAME(__gnu_basename) __INTRODUCED_IN(23);
#endif
#endif
@@ -162,87 +145,83 @@
#define __prefer_this_overload __enable_if(true, "preferred overload") __enable_if(true, "")
extern "C++" {
inline __always_inline
-void* __bionic_memchr(const void* const _Nonnull s __pass_object_size, int c, size_t n) {
+void* __bionic_memchr(const void* const s __pass_object_size, int c, size_t n) {
return memchr(s, c, n);
}
inline __always_inline
-const void* memchr(const void* const _Nonnull s __pass_object_size, int c, size_t n)
+const void* memchr(const void* const s __pass_object_size, int c, size_t n)
__prefer_this_overload {
return __bionic_memchr(s, c, n);
}
inline __always_inline
-void* memchr(void* const _Nonnull s __pass_object_size, int c, size_t n) __prefer_this_overload {
+void* memchr(void* const s __pass_object_size, int c, size_t n) __prefer_this_overload {
return __bionic_memchr(s, c, n);
}
inline __always_inline
-char* __bionic_strchr(const char* const _Nonnull s __pass_object_size, int c) {
+char* __bionic_strchr(const char* const s __pass_object_size, int c) {
return strchr(s, c);
}
inline __always_inline
-const char* strchr(const char* const _Nonnull s __pass_object_size, int c)
+const char* strchr(const char* const s __pass_object_size, int c)
__prefer_this_overload {
return __bionic_strchr(s, c);
}
inline __always_inline
-char* strchr(char* const _Nonnull s __pass_object_size, int c)
+char* strchr(char* const s __pass_object_size, int c)
__prefer_this_overload {
return __bionic_strchr(s, c);
}
inline __always_inline
-char* __bionic_strrchr(const char* const _Nonnull s __pass_object_size, int c) {
+char* __bionic_strrchr(const char* const s __pass_object_size, int c) {
return strrchr(s, c);
}
inline __always_inline
-const char* strrchr(const char* const _Nonnull s __pass_object_size, int c) __prefer_this_overload {
+const char* strrchr(const char* const s __pass_object_size, int c) __prefer_this_overload {
return __bionic_strrchr(s, c);
}
inline __always_inline
-char* strrchr(char* const _Nonnull s __pass_object_size, int c) __prefer_this_overload {
+char* strrchr(char* const s __pass_object_size, int c) __prefer_this_overload {
return __bionic_strrchr(s, c);
}
/* Functions with no FORTIFY counterpart. */
inline __always_inline
-char* __bionic_strstr(const char* _Nonnull h, const char* _Nonnull n) { return strstr(h, n); }
+char* __bionic_strstr(const char* h, const char* n) { return strstr(h, n); }
inline __always_inline
-const char* strstr(const char* _Nonnull h, const char* _Nonnull n) __prefer_this_overload {
+const char* strstr(const char* h, const char* n) __prefer_this_overload {
return __bionic_strstr(h, n);
}
inline __always_inline
-char* strstr(char* _Nonnull h, const char* _Nonnull n) __prefer_this_overload {
+char* strstr(char* h, const char* n) __prefer_this_overload {
return __bionic_strstr(h, n);
}
inline __always_inline
-char* __bionic_strpbrk(const char* _Nonnull h, const char* _Nonnull n) { return strpbrk(h, n); }
+char* __bionic_strpbrk(const char* h, const char* n) { return strpbrk(h, n); }
inline __always_inline
-char* strpbrk(char* _Nonnull h, const char* _Nonnull n) __prefer_this_overload {
+char* strpbrk(char* h, const char* n) __prefer_this_overload {
return __bionic_strpbrk(h, n);
}
inline __always_inline
-const char* strpbrk(const char* _Nonnull h, const char* _Nonnull n) __prefer_this_overload {
+const char* strpbrk(const char* h, const char* n) __prefer_this_overload {
return __bionic_strpbrk(h, n);
}
}
#undef __prefer_this_overload
#endif
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif
-
__END_DECLS
#endif /* _STRING_H */
diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h
index 9c662ba..9541520 100644
--- a/libc/include/sys/cdefs.h
+++ b/libc/include/sys/cdefs.h
@@ -111,39 +111,6 @@
#define __unused __attribute__((__unused__))
#define __used __attribute__((__used__))
-/*
- * _Nonnull is similar to the nonnull attribute in that it will instruct
- * compilers to warn the user if it can prove that a null argument is being
- * passed. Unlike the nonnull attribute, this annotation indicated that a value
- * *should not* be null, not that it *cannot* be null, or even that the behavior
- * is undefined. The important distinction is that the optimizer will perform
- * surprising optimizations like the following:
- *
- * void foo(void*) __attribute__(nonnull, 1);
- *
- * int bar(int* p) {
- * foo(p);
- *
- * // The following null check will be elided because nonnull attribute
- * // means that, since we call foo with p, p can be assumed to not be
- * // null. Thus this will crash if we are called with a null pointer.
- * if (p != NULL) {
- * return *p;
- * }
- * return 0;
- * }
- *
- * int main() {
- * return bar(NULL);
- * }
- *
- * http://clang.llvm.org/docs/AttributeReference.html#nonnull
- */
-#if !(defined(__clang__) && __has_feature(nullability))
-#define _Nonnull
-#define _Nullable
-#endif
-
#define __printflike(x, y) __attribute__((__format__(printf, x, y)))
#define __scanflike(x, y) __attribute__((__format__(scanf, x, y)))
diff --git a/libc/include/sys/signalfd.h b/libc/include/sys/signalfd.h
index 79f9490..1e4d464 100644
--- a/libc/include/sys/signalfd.h
+++ b/libc/include/sys/signalfd.h
@@ -36,7 +36,7 @@
__BEGIN_DECLS
-int signalfd(int fd, const sigset_t* _Nonnull mask, int flags) __INTRODUCED_IN(18);
+int signalfd(int fd, const sigset_t* mask, int flags) __INTRODUCED_IN(18);
__END_DECLS
diff --git a/libc/include/sys/statvfs.h b/libc/include/sys/statvfs.h
index 5df4160..0f421a4 100644
--- a/libc/include/sys/statvfs.h
+++ b/libc/include/sys/statvfs.h
@@ -59,10 +59,10 @@
#define ST_NODIRATIME 0x0800
#define ST_RELATIME 0x1000
-int statvfs(const char* _Nonnull, struct statvfs* _Nonnull) __INTRODUCED_IN(19);
-int statvfs64(const char* _Nonnull, struct statvfs64* _Nonnull) __INTRODUCED_IN(21);
-int fstatvfs(int, struct statvfs* _Nonnull) __INTRODUCED_IN(19);
-int fstatvfs64(int, struct statvfs64* _Nonnull) __INTRODUCED_IN(21);
+int statvfs(const char*, struct statvfs*) __INTRODUCED_IN(19);
+int statvfs64(const char*, struct statvfs64*) __INTRODUCED_IN(21);
+int fstatvfs(int, struct statvfs*) __INTRODUCED_IN(19);
+int fstatvfs64(int, struct statvfs64*) __INTRODUCED_IN(21);
__END_DECLS
diff --git a/libc/include/sys/swap.h b/libc/include/sys/swap.h
index 3444736..e79af97 100644
--- a/libc/include/sys/swap.h
+++ b/libc/include/sys/swap.h
@@ -38,8 +38,8 @@
#define SWAP_FLAG_PRIO_MASK 0x7fff
#define SWAP_FLAG_PRIO_SHIFT 0
-int swapon(const char* _Nonnull, int) __INTRODUCED_IN(19);
-int swapoff(const char* _Nonnull) __INTRODUCED_IN(19);
+int swapon(const char*, int) __INTRODUCED_IN(19);
+int swapoff(const char*) __INTRODUCED_IN(19);
__END_DECLS
diff --git a/libc/include/sys/vfs.h b/libc/include/sys/vfs.h
index 1231eb1..3078683 100644
--- a/libc/include/sys/vfs.h
+++ b/libc/include/sys/vfs.h
@@ -137,10 +137,10 @@
#define XENIX_SUPER_MAGIC 0x012FF7B4
#define XFS_SUPER_MAGIC 0x58465342
-int statfs(const char* _Nonnull, struct statfs* _Nonnull);
-int statfs64(const char* _Nonnull, struct statfs64* _Nonnull) __INTRODUCED_IN(21);
-int fstatfs(int, struct statfs* _Nonnull);
-int fstatfs64(int, struct statfs64* _Nonnull) __INTRODUCED_IN(21);
+int statfs(const char*, struct statfs*);
+int statfs64(const char*, struct statfs64*) __INTRODUCED_IN(21);
+int fstatfs(int, struct statfs*);
+int fstatfs64(int, struct statfs64*) __INTRODUCED_IN(21);
__END_DECLS
diff --git a/libc/include/syslog.h b/libc/include/syslog.h
index 4b7eecb..8000f03 100644
--- a/libc/include/syslog.h
+++ b/libc/include/syslog.h
@@ -86,14 +86,10 @@
#define LOG_PERROR 0x20
void closelog(void);
-void openlog(const char* _Nullable, int, int);
+void openlog(const char*, int, int);
int setlogmask(int);
-void syslog(int, const char* _Nonnull, ...) __printflike(2, 3);
-#if defined(__arm__) || defined(__aarch64__) || defined(__x86_64__)
-void vsyslog(int, const char* _Nonnull, va_list) __printflike(2, 0);
-#else /* defined(__mips__) || defined(__i386__) */
-void vsyslog(int, const char* _Nonnull, va_list _Nonnull) __printflike(2, 0);
-#endif
+void syslog(int, const char*, ...) __printflike(2, 3);
+void vsyslog(int, const char*, va_list) __printflike(2, 0);
__END_DECLS
diff --git a/libc/include/wchar.h b/libc/include/wchar.h
index a86c8a9..4494cb0 100644
--- a/libc/include/wchar.h
+++ b/libc/include/wchar.h
@@ -42,11 +42,6 @@
__BEGIN_DECLS
-#if defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wnullability-completeness"
-#endif
-
wint_t btowc(int);
int fwprintf(FILE *, const wchar_t *, ...);
int fwscanf(FILE *, const wchar_t *, ...);
@@ -125,9 +120,9 @@
unsigned long long wcstoull_l(const wchar_t*, wchar_t**, int, locale_t) __INTRODUCED_IN(21);
long double wcstold_l(const wchar_t*, wchar_t**, locale_t) __INTRODUCED_IN(21);
-int wcscoll_l(const wchar_t* _Nonnull, const wchar_t* _Nonnull, locale_t) __attribute_pure__
+int wcscoll_l(const wchar_t*, const wchar_t*, locale_t) __attribute_pure__
__INTRODUCED_IN(21);
-size_t wcsxfrm_l(wchar_t*, const wchar_t* _Nonnull, size_t, locale_t) __INTRODUCED_IN(21);
+size_t wcsxfrm_l(wchar_t*, const wchar_t*, size_t, locale_t) __INTRODUCED_IN(21);
#else
// Implemented as static inlines before 21.
#endif
@@ -139,10 +134,6 @@
wchar_t* wcsdup(const wchar_t*);
size_t wcsnlen(const wchar_t*, size_t);
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif
-
__END_DECLS
#endif /* _WCHAR_H_ */
diff --git a/libc/libstdc++.arm.map b/libc/libstdc++.arm.map
index b6b269d..8ee5863 100644
--- a/libc/libstdc++.arm.map
+++ b/libc/libstdc++.arm.map
@@ -2,14 +2,14 @@
LIBC_O {
global:
_ZSt7nothrow; # var
- _ZdaPv;
- _ZdaPvRKSt9nothrow_t;
- _ZdlPv;
- _ZdlPvRKSt9nothrow_t;
- _Znaj; # arm x86 mips
- _ZnajRKSt9nothrow_t; # arm x86 mips
- _Znwj; # arm x86 mips
- _ZnwjRKSt9nothrow_t; # arm x86 mips
+ _ZdaPv; # weak
+ _ZdaPvRKSt9nothrow_t; # weak
+ _ZdlPv; # weak
+ _ZdlPvRKSt9nothrow_t; # weak
+ _Znaj; # arm x86 mips weak
+ _ZnajRKSt9nothrow_t; # arm x86 mips weak
+ _Znwj; # arm x86 mips weak
+ _ZnwjRKSt9nothrow_t; # arm x86 mips weak
__cxa_guard_abort;
__cxa_guard_acquire;
__cxa_guard_release;
diff --git a/libc/libstdc++.arm64.map b/libc/libstdc++.arm64.map
index d0433c9..cd4f3c3 100644
--- a/libc/libstdc++.arm64.map
+++ b/libc/libstdc++.arm64.map
@@ -2,14 +2,14 @@
LIBC_O {
global:
_ZSt7nothrow; # var
- _ZdaPv;
- _ZdaPvRKSt9nothrow_t;
- _ZdlPv;
- _ZdlPvRKSt9nothrow_t;
- _Znam; # arm64 x86_64 mips64
- _ZnamRKSt9nothrow_t; # arm64 x86_64 mips64
- _Znwm; # arm64 x86_64 mips64
- _ZnwmRKSt9nothrow_t; # arm64 x86_64 mips64
+ _ZdaPv; # weak
+ _ZdaPvRKSt9nothrow_t; # weak
+ _ZdlPv; # weak
+ _ZdlPvRKSt9nothrow_t; # weak
+ _Znam; # arm64 x86_64 mips64 weak
+ _ZnamRKSt9nothrow_t; # arm64 x86_64 mips64 weak
+ _Znwm; # arm64 x86_64 mips64 weak
+ _ZnwmRKSt9nothrow_t; # arm64 x86_64 mips64 weak
__cxa_guard_abort;
__cxa_guard_acquire;
__cxa_guard_release;
diff --git a/libc/libstdc++.map.txt b/libc/libstdc++.map.txt
index 32d5d49..0a242d5 100644
--- a/libc/libstdc++.map.txt
+++ b/libc/libstdc++.map.txt
@@ -1,18 +1,18 @@
LIBC_O {
global:
_ZSt7nothrow; # var
- _ZdaPv;
- _ZdaPvRKSt9nothrow_t;
- _ZdlPv;
- _ZdlPvRKSt9nothrow_t;
- _Znaj; # arm x86 mips
- _ZnajRKSt9nothrow_t; # arm x86 mips
- _Znam; # arm64 x86_64 mips64
- _ZnamRKSt9nothrow_t; # arm64 x86_64 mips64
- _Znwj; # arm x86 mips
- _ZnwjRKSt9nothrow_t; # arm x86 mips
- _Znwm; # arm64 x86_64 mips64
- _ZnwmRKSt9nothrow_t; # arm64 x86_64 mips64
+ _ZdaPv; # weak
+ _ZdaPvRKSt9nothrow_t; # weak
+ _ZdlPv; # weak
+ _ZdlPvRKSt9nothrow_t; # weak
+ _Znaj; # arm x86 mips weak
+ _ZnajRKSt9nothrow_t; # arm x86 mips weak
+ _Znam; # arm64 x86_64 mips64 weak
+ _ZnamRKSt9nothrow_t; # arm64 x86_64 mips64 weak
+ _Znwj; # arm x86 mips weak
+ _ZnwjRKSt9nothrow_t; # arm x86 mips weak
+ _Znwm; # arm64 x86_64 mips64 weak
+ _ZnwmRKSt9nothrow_t; # arm64 x86_64 mips64 weak
__cxa_guard_abort;
__cxa_guard_acquire;
__cxa_guard_release;
diff --git a/libc/libstdc++.mips.map b/libc/libstdc++.mips.map
index b6b269d..8ee5863 100644
--- a/libc/libstdc++.mips.map
+++ b/libc/libstdc++.mips.map
@@ -2,14 +2,14 @@
LIBC_O {
global:
_ZSt7nothrow; # var
- _ZdaPv;
- _ZdaPvRKSt9nothrow_t;
- _ZdlPv;
- _ZdlPvRKSt9nothrow_t;
- _Znaj; # arm x86 mips
- _ZnajRKSt9nothrow_t; # arm x86 mips
- _Znwj; # arm x86 mips
- _ZnwjRKSt9nothrow_t; # arm x86 mips
+ _ZdaPv; # weak
+ _ZdaPvRKSt9nothrow_t; # weak
+ _ZdlPv; # weak
+ _ZdlPvRKSt9nothrow_t; # weak
+ _Znaj; # arm x86 mips weak
+ _ZnajRKSt9nothrow_t; # arm x86 mips weak
+ _Znwj; # arm x86 mips weak
+ _ZnwjRKSt9nothrow_t; # arm x86 mips weak
__cxa_guard_abort;
__cxa_guard_acquire;
__cxa_guard_release;
diff --git a/libc/libstdc++.mips64.map b/libc/libstdc++.mips64.map
index d0433c9..cd4f3c3 100644
--- a/libc/libstdc++.mips64.map
+++ b/libc/libstdc++.mips64.map
@@ -2,14 +2,14 @@
LIBC_O {
global:
_ZSt7nothrow; # var
- _ZdaPv;
- _ZdaPvRKSt9nothrow_t;
- _ZdlPv;
- _ZdlPvRKSt9nothrow_t;
- _Znam; # arm64 x86_64 mips64
- _ZnamRKSt9nothrow_t; # arm64 x86_64 mips64
- _Znwm; # arm64 x86_64 mips64
- _ZnwmRKSt9nothrow_t; # arm64 x86_64 mips64
+ _ZdaPv; # weak
+ _ZdaPvRKSt9nothrow_t; # weak
+ _ZdlPv; # weak
+ _ZdlPvRKSt9nothrow_t; # weak
+ _Znam; # arm64 x86_64 mips64 weak
+ _ZnamRKSt9nothrow_t; # arm64 x86_64 mips64 weak
+ _Znwm; # arm64 x86_64 mips64 weak
+ _ZnwmRKSt9nothrow_t; # arm64 x86_64 mips64 weak
__cxa_guard_abort;
__cxa_guard_acquire;
__cxa_guard_release;
diff --git a/libc/libstdc++.x86.map b/libc/libstdc++.x86.map
index b6b269d..8ee5863 100644
--- a/libc/libstdc++.x86.map
+++ b/libc/libstdc++.x86.map
@@ -2,14 +2,14 @@
LIBC_O {
global:
_ZSt7nothrow; # var
- _ZdaPv;
- _ZdaPvRKSt9nothrow_t;
- _ZdlPv;
- _ZdlPvRKSt9nothrow_t;
- _Znaj; # arm x86 mips
- _ZnajRKSt9nothrow_t; # arm x86 mips
- _Znwj; # arm x86 mips
- _ZnwjRKSt9nothrow_t; # arm x86 mips
+ _ZdaPv; # weak
+ _ZdaPvRKSt9nothrow_t; # weak
+ _ZdlPv; # weak
+ _ZdlPvRKSt9nothrow_t; # weak
+ _Znaj; # arm x86 mips weak
+ _ZnajRKSt9nothrow_t; # arm x86 mips weak
+ _Znwj; # arm x86 mips weak
+ _ZnwjRKSt9nothrow_t; # arm x86 mips weak
__cxa_guard_abort;
__cxa_guard_acquire;
__cxa_guard_release;
diff --git a/libc/libstdc++.x86_64.map b/libc/libstdc++.x86_64.map
index d0433c9..cd4f3c3 100644
--- a/libc/libstdc++.x86_64.map
+++ b/libc/libstdc++.x86_64.map
@@ -2,14 +2,14 @@
LIBC_O {
global:
_ZSt7nothrow; # var
- _ZdaPv;
- _ZdaPvRKSt9nothrow_t;
- _ZdlPv;
- _ZdlPvRKSt9nothrow_t;
- _Znam; # arm64 x86_64 mips64
- _ZnamRKSt9nothrow_t; # arm64 x86_64 mips64
- _Znwm; # arm64 x86_64 mips64
- _ZnwmRKSt9nothrow_t; # arm64 x86_64 mips64
+ _ZdaPv; # weak
+ _ZdaPvRKSt9nothrow_t; # weak
+ _ZdlPv; # weak
+ _ZdlPvRKSt9nothrow_t; # weak
+ _Znam; # arm64 x86_64 mips64 weak
+ _ZnamRKSt9nothrow_t; # arm64 x86_64 mips64 weak
+ _Znwm; # arm64 x86_64 mips64 weak
+ _ZnwmRKSt9nothrow_t; # arm64 x86_64 mips64 weak
__cxa_guard_abort;
__cxa_guard_acquire;
__cxa_guard_release;
diff --git a/libc/upstream-freebsd/lib/libc/stdlib/realpath.c b/libc/upstream-freebsd/lib/libc/stdlib/realpath.c
index 914ecc9..c4bd953 100644
--- a/libc/upstream-freebsd/lib/libc/stdlib/realpath.c
+++ b/libc/upstream-freebsd/lib/libc/stdlib/realpath.c
@@ -48,7 +48,7 @@
* in which case the path which caused trouble is left in (resolved).
*/
char *
-realpath(const char * __restrict path, char * __restrict resolved) __overloadable
+realpath(const char * __restrict path, char * __restrict resolved)
{
struct stat sb;
char *p, *q, *s;
diff --git a/tests/fortify_compilation_test.cpp b/tests/fortify_compilation_test.cpp
index 51074b2..bf577f6 100644
--- a/tests/fortify_compilation_test.cpp
+++ b/tests/fortify_compilation_test.cpp
@@ -169,12 +169,12 @@
// NOLINTNEXTLINE(whitespace/line_length)
// GCC: error: call to '__fgets_too_small_error' declared with attribute error: fgets called with size less than zero
- // CLANG: error: call to unavailable function 'fgets': size is negative
+ // CLANG: error: in call to 'fgets', size should not be negative
fgets(buf, -1, stdin);
// NOLINTNEXTLINE(whitespace/line_length)
// GCC: error: call to '__fgets_too_big_error' declared with attribute error: fgets called with size bigger than buffer
- // CLANG: error: call to unavailable function 'fgets': size is larger than the destination buffer
+ // CLANG: error: in call to 'fgets', size is larger than the destination buffer
fgets(buf, 6, stdin);
}
@@ -183,15 +183,24 @@
sockaddr_in addr;
// NOLINTNEXTLINE(whitespace/line_length)
- // GCC: error: call to '__recvfrom_error' declared with attribute error: recvfrom called with size bigger than buffer
- // CLANG: error: call to unavailable function 'recvfrom': recvfrom called with size bigger than buffer
+ // GCC: error: call to '__recvfrom_error' declared with attribute error: 'recvfrom' called with size bigger than buffer
+ // CLANG: error: 'recvfrom' called with size bigger than buffer
recvfrom(0, buf, 6, 0, reinterpret_cast<sockaddr*>(&addr), NULL);
}
+void test_recv() {
+ char buf[4] = {0};
+
+ // NOLINTNEXTLINE(whitespace/line_length)
+ // GCC: error: call to '__recvfrom_error' declared with attribute error: 'recvfrom' called with size bigger than buffer
+ // CLANG: error: 'recv' called with size bigger than buffer
+ recv(0, buf, 6, 0);
+}
+
void test_umask() {
// NOLINTNEXTLINE(whitespace/line_length)
- // GCC: error: call to '__umask_invalid_mode' declared with attribute error: umask called with invalid mode
- // CLANG: error: call to unavailable function 'umask': umask called with invalid mode
+ // GCC: error: call to '__umask_invalid_mode' declared with attribute error: 'umask' called with invalid mode
+ // CLANG: error: 'umask' called with invalid mode
umask(01777);
}
@@ -199,14 +208,14 @@
char buf[4];
// NOLINTNEXTLINE(whitespace/line_length)
// GCC: error: call to '__read_dest_size_error' declared with attribute error: read called with size bigger than destination
- // CLANG: error: call to unavailable function 'read': 'count' bytes overflows the given object
+ // CLANG: error: in call to 'read', 'count' bytes overflows the given object
read(0, buf, 6);
}
void test_open() {
// NOLINTNEXTLINE(whitespace/line_length)
// GCC: error: call to '__creat_missing_mode' declared with attribute error: called with O_CREAT, but missing mode
- // CLANG: error: call to unavailable function 'open': called with O_CREAT, but missing mode
+ // CLANG: error: 'open' called with O_CREAT, but missing mode
open("/dev/null", O_CREAT);
// NOLINTNEXTLINE(whitespace/line_length)
@@ -219,7 +228,7 @@
pollfd fds[1];
// NOLINTNEXTLINE(whitespace/line_length)
// GCC: error: call to '__poll_too_small_error' declared with attribute error: poll: pollfd array smaller than fd count
- // CLANG: error: call to unavailable function 'poll': too many fds specified
+ // CLANG: error: in call to 'poll', fd_count is larger than the given buffer
poll(fds, 2, 0);
}
@@ -228,7 +237,7 @@
timespec timeout;
// NOLINTNEXTLINE(whitespace/line_length)
// GCC: error: call to '__ppoll_too_small_error' declared with attribute error: ppoll: pollfd array smaller than fd count
- // CLANG: error: call to unavailable function 'ppoll': too many fds specified
+ // CLANG: error: in call to 'ppoll', fd_count is larger than the given buffer
ppoll(fds, 2, &timeout, NULL);
}
@@ -236,7 +245,7 @@
char buf[4];
// NOLINTNEXTLINE(whitespace/line_length)
// GCC: error: call to '__fread_overflow' declared with attribute error: fread called with overflowing size * count
- // CLANG: error: call to unavailable function 'fread': size * count overflows
+ // CLANG: error: in call to 'fread', size * count overflows
fread(buf, 2, (size_t)-1, stdin);
}
@@ -244,7 +253,8 @@
char buf[4];
// NOLINTNEXTLINE(whitespace/line_length)
// GCC: error: call to '__fread_too_big_error' declared with attribute error: fread called with size * count bigger than buffer
- // CLANG: error: call to unavailable function 'fread': size * count is too large
+ // NOLINTNEXTLINE(whitespace/line_length)
+ // CLANG: error: in call to 'fread', size * count is too large for the given buffer
fread(buf, 1, 5, stdin);
}
@@ -252,7 +262,7 @@
char buf[4] = {0};
// NOLINTNEXTLINE(whitespace/line_length)
// GCC: error: call to '__fwrite_overflow' declared with attribute error: fwrite called with overflowing size * count
- // CLANG: error: call to unavailable function 'fwrite': size * count overflows
+ // CLANG: error: in call to 'fwrite', size * count overflows
fwrite(buf, 2, (size_t)-1, stdout);
}
@@ -260,7 +270,8 @@
char buf[4] = {0};
// NOLINTNEXTLINE(whitespace/line_length)
// GCC: error: call to '__fwrite_too_big_error' declared with attribute error: fwrite called with size * count bigger than buffer
- // CLANG: error: call to unavailable function 'fwrite': size * count is too large
+ // NOLINTNEXTLINE(whitespace/line_length)
+ // CLANG: error: in call to 'fwrite', size * count is too large for the given buffer
fwrite(buf, 1, 5, stdout);
}
@@ -268,7 +279,7 @@
char buf[4];
// NOLINTNEXTLINE(whitespace/line_length)
// GCC: error: call to '__getcwd_dest_size_error' declared with attribute error: getcwd called with size bigger than destination
- // CLANG: error: call to unavailable function 'getcwd': 'size' bytes overflows the given object
+ // CLANG: error: in call to 'getcwd', 'size' bytes overflows the given object
getcwd(buf, 5);
}
@@ -276,7 +287,7 @@
char buf[4] = {0};
// NOLINTNEXTLINE(whitespace/line_length)
// GCC: error: call to '__pwrite64_dest_size_error' declared with attribute error: pwrite64 called with size bigger than destination
- // CLANG: error: call to unavailable function 'pwrite64': 'count' bytes overflows the given object
+ // CLANG: error: in call to 'pwrite64', 'count' bytes overflows the given object
pwrite64(STDOUT_FILENO, buf, 5, 0);
}
@@ -292,7 +303,7 @@
char buf[4] = {0};
// NOLINTNEXTLINE(whitespace/line_length)
// GCC: error: call to '__pwrite64_count_toobig_error' declared with attribute error: pwrite64 called with count > SSIZE_MAX
- // CLANG: error: call to unavailable function 'pwrite64': count must be <= SSIZE_MAX
+ // CLANG: error: in call to 'pwrite64', 'count' must be <= SSIZE_MAX
pwrite64(STDOUT_FILENO, buf, SIZE_MAX, 0);
}
@@ -300,7 +311,7 @@
char buf[4] = {0};
// NOLINTNEXTLINE(whitespace/line_length)
// GCC: error: call to '__write_dest_size_error' declared with attribute error: write called with size bigger than destination
- // CLANG: error: call to unavailable function 'write': 'count' bytes overflows the given object
+ // CLANG: error: in call to 'write', 'count' bytes overflows the given object
write(STDOUT_FILENO, buf, 5);
}
@@ -316,8 +327,8 @@
sockaddr_in addr;
// NOLINTNEXTLINE(whitespace/line_length)
- // GCC: error: call to '__sendto_error' declared with attribute error: sendto called with size bigger than buffer
- // CLANG: error: call to unavailable function 'sendto': sendto called with size bigger than buffer
+ // GCC: error: call to '__sendto_error' declared with attribute error: 'sendto' called with size bigger than buffer
+ // CLANG: error: 'sendto' called with size bigger than buffer
sendto(0, buf, 6, 0, reinterpret_cast<sockaddr*>(&addr), sizeof(sockaddr_in));
}
@@ -325,7 +336,22 @@
char buf[4] = {0};
// NOLINTNEXTLINE(whitespace/line_length)
- // GCC: error: call to '__sendto_error' declared with attribute error: sendto called with size bigger than buffer
- // CLANG: error: call to unavailable function 'send': send called with size bigger than buffer
+ // GCC: error: call to '__sendto_error' declared with attribute error: 'sendto' called with size bigger than buffer
+ // CLANG: error: 'send' called with size bigger than buffer
send(0, buf, 6, 0);
}
+
+void test_realpath() {
+ char buf[4] = {0};
+ // NOLINTNEXTLINE(whitespace/line_length)
+ // GCC: error: call to '__realpath_size_error' declared with attribute error: 'realpath' output parameter must be NULL or a pointer to a buffer with >= PATH_MAX bytes
+ // NOLINTNEXTLINE(whitespace/line_length)
+ // CLANG: error: 'realpath' output parameter must be NULL or a pointer to a buffer with >= PATH_MAX bytes
+ realpath(".", buf);
+
+ // This is fine.
+ realpath(".", NULL);
+
+ // FIXME: But we should warn on this.
+ realpath(NULL, buf);
+}