Merge "Clean up <sys/limits.h> a bit."
diff --git a/libc/Android.bp b/libc/Android.bp
index 094ad5c..05df811 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -779,7 +779,6 @@
                 "arch-arm/generic/bionic/strcpy.S",
                 "arch-arm/generic/bionic/strlen.c",
 
-                "arch-arm/bionic/abort_arm.S",
                 "arch-arm/bionic/atomics_arm.c",
                 "arch-arm/bionic/__bionic_clone.S",
                 "arch-arm/bionic/_exit_with_stack_teardown.S",
@@ -2009,10 +2008,21 @@
 // }
 
 ndk_headers {
-    name: "libc_linux",
-    from: "kernel/uapi/linux",
-    to: "linux",
-    srcs: ["kernel/uapi/linux/**/*.h"],
+    name: "libc_uapi",
+    from: "kernel/uapi",
+    to: "",
+    srcs: [
+        "kernel/uapi/asm-generic/**/*.h",
+        "kernel/uapi/drm/**/*.h",
+        "kernel/uapi/linux/**/*.h",
+        "kernel/uapi/misc/**/*.h",
+        "kernel/uapi/mtd/**/*.h",
+        "kernel/uapi/rdma/**/*.h",
+        "kernel/uapi/scsi/**/*.h",
+        "kernel/uapi/sound/**/*.h",
+        "kernel/uapi/video/**/*.h",
+        "kernel/uapi/xen/**/*.h",
+    ],
     license: "NOTICE",
 }
 
@@ -2025,14 +2035,6 @@
 }
 
 ndk_headers {
-    name: "libc_asm_generic",
-    from: "kernel/uapi/asm-generic",
-    to: "asm-generic",
-    srcs: ["kernel/uapi/asm-generic/**/*.h"],
-    license: "NOTICE",
-}
-
-ndk_headers {
     name: "libc_asm_arm",
     from: "kernel/uapi/asm-arm",
     to: "arm-linux-androideabi",
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index 781d404..f98cc61 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -117,8 +117,8 @@
 int         munlockall()   all
 int         mincore(void*  start, size_t  length, unsigned char*  vec)   all
 int         __ioctl:ioctl(int, int, void*)  all
-int         readv(int, const struct iovec*, int)   all
-int         writev(int, const struct iovec*, int)  all
+ssize_t     readv(int, const struct iovec*, int)   all
+ssize_t     writev(int, const struct iovec*, int)  all
 int         __fcntl64:fcntl64(int, int, void*)  arm,mips,x86
 int         fcntl(int, int, void*)  arm64,mips64,x86_64
 int         flock(int, int)   all
diff --git a/libc/arch-arm/bionic/abort_arm.S b/libc/arch-arm/bionic/abort_arm.S
deleted file mode 100644
index 1039502..0000000
--- a/libc/arch-arm/bionic/abort_arm.S
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <private/bionic_asm.h>
-
-/*
- * Coding the abort function in assembly so that registers are guaranteed to
- * be preserved properly regardless of GCC's assumption on the "noreturn"
- * attribute. When the registers are not properly preserved we won't be able
- * to unwind the stack all the way to the bottom to fully reveal the call
- * sequence when the crash happens.
- */
-ENTRY(abort)
-    stmfd   sp!, {r3, r14}
-    .cfi_def_cfa_offset 8
-    .cfi_rel_offset r3, 0
-    .cfi_rel_offset r14, 4
-    bl      __libc_android_abort
-END(abort)
diff --git a/libc/bionic/abort.cpp b/libc/bionic/abort.cpp
index 75413c6..9aefd44 100644
--- a/libc/bionic/abort.cpp
+++ b/libc/bionic/abort.cpp
@@ -31,12 +31,9 @@
 #include <stdlib.h>
 #include <unistd.h>
 
-#ifdef __arm__
-extern "C" __LIBC_HIDDEN__ void __libc_android_abort()
-#else
-void abort()
-#endif
-{
+extern "C" int tgkill(int tgid, int tid, int sig);
+
+void abort() {
   // Don't block SIGABRT to give any signal handler a chance; we ignore
   // any errors -- X311J doesn't allow abort to return anyway.
   sigset_t mask;
@@ -44,7 +41,7 @@
   sigdelset(&mask, SIGABRT);
   sigprocmask(SIG_SETMASK, &mask, NULL);
 
-  raise(SIGABRT);
+  tgkill(getpid(), gettid(), SIGABRT);
 
   // If SIGABRT ignored, or caught and the handler returns,
   // remove the SIGABRT signal handler and raise SIGABRT again.
@@ -54,6 +51,9 @@
   sigemptyset(&sa.sa_mask);
   sigaction(SIGABRT, &sa, &sa);
   sigprocmask(SIG_SETMASK, &mask, NULL);
-  raise(SIGABRT);
-  _exit(1);
+
+  tgkill(getpid(), gettid(), SIGABRT);
+
+  // If we get this far, just exit.
+  _exit(127);
 }
diff --git a/libc/bionic/bionic_arc4random.cpp b/libc/bionic/bionic_arc4random.cpp
index 4ff18ab..ba3b4e1 100644
--- a/libc/bionic/bionic_arc4random.cpp
+++ b/libc/bionic/bionic_arc4random.cpp
@@ -29,6 +29,7 @@
 #include "private/bionic_arc4random.h"
 
 #include <errno.h>
+#include <stdatomic.h>
 #include <stdlib.h>
 #include <sys/auxv.h>
 #include <syscall.h>
@@ -37,17 +38,20 @@
 #include "private/KernelArgumentBlock.h"
 #include "private/libc_logging.h"
 
-void __libc_safe_arc4random_buf(void* buf, size_t n, KernelArgumentBlock& args) {
+bool __libc_arc4random_has_unlimited_entropy() {
   static bool have_urandom = access("/dev/urandom", R_OK) == 0;
-  static size_t at_random_bytes_consumed = 0;
+  return have_urandom;
+}
 
+void __libc_safe_arc4random_buf(void* buf, size_t n, KernelArgumentBlock& args) {
   // Only call arc4random_buf once we `have_urandom', since in getentropy_getrandom we may fallback
   // to use /dev/urandom, if the kernel entropy pool hasn't been initialized or not enough bytes
-  if (have_urandom) {
+  if (__libc_arc4random_has_unlimited_entropy()) {
     arc4random_buf(buf, n);
     return;
   }
 
+  static size_t at_random_bytes_consumed = 0;
   if (at_random_bytes_consumed + n > 16) {
     __libc_fatal("ran out of AT_RANDOM bytes, have %zu, requested %zu",
                  16 - at_random_bytes_consumed, n);
diff --git a/libc/include/sys/uio.h b/libc/include/sys/uio.h
index 7a009b4..0e56d7d 100644
--- a/libc/include/sys/uio.h
+++ b/libc/include/sys/uio.h
@@ -34,8 +34,8 @@
 
 __BEGIN_DECLS
 
-int readv(int, const struct iovec*, int);
-int writev(int, const struct iovec*, int);
+ssize_t readv(int, const struct iovec*, int);
+ssize_t writev(int, const struct iovec*, int);
 
 #if defined(__USE_GNU)
 #if defined(__USE_FILE_OFFSET64)
diff --git a/libc/private/bionic_arc4random.h b/libc/private/bionic_arc4random.h
index d26a4e7..b51f818 100644
--- a/libc/private/bionic_arc4random.h
+++ b/libc/private/bionic_arc4random.h
@@ -39,7 +39,12 @@
  * created yet. Provide a wrapper function that falls back to AT_RANDOM if
  * we don't have getrandom and /dev/urandom is missing.
  */
-
 void __libc_safe_arc4random_buf(void* buf, size_t n, KernelArgumentBlock& args);
 
+/*
+ * Return true if libc has an unlimited entropy source (something other than
+ * AT_RANDOM), and arc4random* calls will always succeed.
+ */
+bool __libc_arc4random_has_unlimited_entropy();
+
 #endif
diff --git a/libc/zoneinfo/tzdata b/libc/zoneinfo/tzdata
index ce00600..577ede6 100644
--- a/libc/zoneinfo/tzdata
+++ b/libc/zoneinfo/tzdata
Binary files differ
diff --git a/libm/Android.bp b/libm/Android.bp
index 35f5fe4..b1d88d5 100644
--- a/libm/Android.bp
+++ b/libm/Android.bp
@@ -527,7 +527,7 @@
 
     native_coverage: bionic_coverage,
     sanitize: {
-        never: true,
+        address: false,
     },
     stl: "none",
 }