Shave another uninteresting stack frame off aborts.

With this, stack frame 0 is the abort, not tgkill.

arm:

     #00 pc 0001a41c  /system/lib/libc.so (abort+63)

arm64:

     #00 pc 000000000001d75c  /system/lib64/libc.so (abort+120)

Also "include what you use" for <sys/syscall.h>.

Bug: N/A
Test: ran `crasher abort` and `crasher64 abort`
Change-Id: I6517ac67b39b4133e890d52efc115071c812958b
diff --git a/libc/bionic/abort.cpp b/libc/bionic/abort.cpp
index 3ba83d1..f401cab 100644
--- a/libc/bionic/abort.cpp
+++ b/libc/bionic/abort.cpp
@@ -32,6 +32,26 @@
 #include <sys/syscall.h>
 #include <unistd.h>
 
+// We call tgkill(2) directly instead of raise (or even the libc tgkill wrapper), to reduce the
+// number of uninteresting stack frames at the top of a crash.
+static inline __always_inline void inline_tgkill(pid_t pid, pid_t tid, int sig) {
+#if defined(__arm__)
+  register int r0 __asm__("r0") = pid;
+  register int r1 __asm__("r1") = tid;
+  register int r2 __asm__("r2") = sig;
+  register int r7 __asm__("r7") = __NR_tgkill;
+  __asm__("swi #0" : "=r"(r0) : "r"(r0), "r"(r1), "r"(r2), "r"(r7) : "memory");
+#elif defined(__aarch64__)
+  register long x0 __asm__("x0") = pid;
+  register long x1 __asm__("x1") = tid;
+  register long x2 __asm__("x2") = sig;
+  register long x8 __asm__("x8") = __NR_tgkill;
+  __asm__("svc #0" : "=r"(x0) : "r"(x0), "r"(x1), "r"(x2), "r"(x8) : "memory");
+#else
+  syscall(__NR_tgkill, pid, tid, sig);
+#endif
+}
+
 void abort() {
   // Protect ourselves against stale cached PID/TID values by fetching them via syscall.
   // http://b/37769298
@@ -45,8 +65,7 @@
   sigdelset(&mask, SIGABRT);
   sigprocmask(SIG_SETMASK, &mask, NULL);
 
-  // Use tgkill directly instead of raise, to avoid inserting spurious stack frames.
-  tgkill(pid, tid, SIGABRT);
+  inline_tgkill(pid, tid, SIGABRT);
 
   // If SIGABRT ignored, or caught and the handler returns,
   // remove the SIGABRT signal handler and raise SIGABRT again.
@@ -57,7 +76,7 @@
   sigaction(SIGABRT, &sa, &sa);
   sigprocmask(SIG_SETMASK, &mask, NULL);
 
-  tgkill(pid, tid, SIGABRT);
+  inline_tgkill(pid, tid, 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 a4842f6..a339900 100644
--- a/libc/bionic/bionic_arc4random.cpp
+++ b/libc/bionic/bionic_arc4random.cpp
@@ -32,7 +32,6 @@
 #include <stdatomic.h>
 #include <stdlib.h>
 #include <sys/auxv.h>
-#include <syscall.h>
 #include <unistd.h>
 
 #include <async_safe/log.h>
diff --git a/libc/bionic/clone.cpp b/libc/bionic/clone.cpp
index 3a20aa9..d7ce37f 100644
--- a/libc/bionic/clone.cpp
+++ b/libc/bionic/clone.cpp
@@ -30,6 +30,7 @@
 #include <sched.h>
 #include <stdlib.h>
 #include <stdarg.h>
+#include <sys/syscall.h>
 
 #include "pthread_internal.h"
 
diff --git a/libc/bionic/fork.cpp b/libc/bionic/fork.cpp
index 32ea255..efcbb8c 100644
--- a/libc/bionic/fork.cpp
+++ b/libc/bionic/fork.cpp
@@ -27,7 +27,6 @@
  */
 
 #include <unistd.h>
-#include <sys/syscall.h>
 
 #include "pthread_internal.h"
 
diff --git a/libc/bionic/gettid.cpp b/libc/bionic/gettid.cpp
index fe25a4d..eb5cfd6 100644
--- a/libc/bionic/gettid.cpp
+++ b/libc/bionic/gettid.cpp
@@ -27,6 +27,7 @@
  */
 
 #include <unistd.h>
+#include <sys/syscall.h>
 
 #include "pthread_internal.h"
 
diff --git a/tests/dlext_test.cpp b/tests/dlext_test.cpp
index e3ee7d7..b264e53 100644
--- a/tests/dlext_test.cpp
+++ b/tests/dlext_test.cpp
@@ -30,6 +30,7 @@
 
 #include <linux/memfd.h>
 #include <sys/mman.h>
+#include <sys/syscall.h>
 #include <sys/types.h>
 #include <sys/vfs.h>
 #include <sys/wait.h>