Remove old thread_local.h

This was to work around a clang 9.0.0 bug.  We are on clang 13.  Make
things simpler by removing it.

Change-Id: I4bad16270795bb82b8c498146a4bf7388565a1c7
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/aos/BUILD b/aos/BUILD
index f534e6e..79cd681 100644
--- a/aos/BUILD
+++ b/aos/BUILD
@@ -209,7 +209,6 @@
     target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
-        ":thread_local",
         ":uuid",
         "@com_github_google_glog//:glog",
     ],
@@ -654,15 +653,6 @@
     ],
 )
 
-cc_library(
-    name = "thread_local",
-    hdrs = [
-        "thread_local.h",
-    ],
-    target_compatible_with = ["@platforms//os:linux"],
-    visibility = ["//visibility:public"],
-)
-
 cc_test(
     name = "realtime_test",
     srcs = [
@@ -706,7 +696,6 @@
     target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
-        ":thread_local",
         "@com_github_gflags_gflags//:gflags",
         "@com_github_google_flatbuffers//:flatbuffers",
         "@com_github_google_glog//:glog",
diff --git a/aos/ipc_lib/BUILD b/aos/ipc_lib/BUILD
index 147e0ba..ae02c67 100644
--- a/aos/ipc_lib/BUILD
+++ b/aos/ipc_lib/BUILD
@@ -14,7 +14,6 @@
     deps = [
         ":shm_observers",
         "//aos:macros",
-        "//aos:thread_local",
         "//aos/util:compiler_memory_barrier",
         "@com_github_google_glog//:glog",
         "@com_google_absl//absl/base",
diff --git a/aos/ipc_lib/aos_sync.cc b/aos/ipc_lib/aos_sync.cc
index b8bd7a3..6bf5d8c 100644
--- a/aos/ipc_lib/aos_sync.cc
+++ b/aos/ipc_lib/aos_sync.cc
@@ -33,7 +33,6 @@
 #include "glog/logging.h"
 
 #include "aos/macros.h"
-#include "aos/thread_local.h"
 #include "aos/util/compiler_memory_barrier.h"
 
 using ::aos::linux_code::ipc_lib::RunShmObservers;
@@ -447,7 +446,7 @@
 
 // Starts off at 0 in each new thread (because that's what it gets initialized
 // to in most of them or it gets to reset to 0 after a fork by atfork_child()).
-AOS_THREAD_LOCAL pid_t my_tid = 0;
+thread_local pid_t my_tid = 0;
 
 // Gets called before the fork(2) wrapper function returns in the child.
 void atfork_child() {
@@ -506,7 +505,7 @@
 static_assert(sizeof(aos_robust_list_head) == sizeof(robust_list_head),
               "Our aos_robust_list_head doesn't match the kernel's");
 
-AOS_THREAD_LOCAL aos_robust_list_head robust_head;
+thread_local aos_robust_list_head robust_head;
 
 // Extra offset between mutex values and where we point to for their robust list
 // entries (from SetRobustListOffset).
diff --git a/aos/libc/BUILD b/aos/libc/BUILD
index cc54670..9bfd365 100644
--- a/aos/libc/BUILD
+++ b/aos/libc/BUILD
@@ -10,7 +10,6 @@
     ],
     target_compatible_with = ["@platforms//os:linux"],
     deps = [
-        "//aos:thread_local",
         "@com_github_google_glog//:glog",
     ],
 )
@@ -59,9 +58,6 @@
         "aos_strerror.h",
     ],
     target_compatible_with = ["@platforms//os:linux"],
-    deps = [
-        "//aos:thread_local",
-    ],
 )
 
 cc_test(
diff --git a/aos/libc/aos_strerror.cc b/aos/libc/aos_strerror.cc
index 8c087a8..9d270c0 100644
--- a/aos/libc/aos_strerror.cc
+++ b/aos/libc/aos_strerror.cc
@@ -6,8 +6,6 @@
 #include <cstdio>
 #include <cstring>
 
-#include "aos/thread_local.h"
-
 // This code uses an overloaded function to handle the result from either
 // version of strerror_r correctly without needing a way to get the choice out
 // of the compiler/glibc/whatever explicitly.
@@ -41,7 +39,7 @@
 }  // namespace
 
 const char *aos_strerror(int error) {
-  AOS_THREAD_LOCAL char buffer[kBufferSize];
+  thread_local char buffer[kBufferSize];
 
   // Call the overload for whichever version we're using.
   return aos_strerror_handle_result(
diff --git a/aos/libc/aos_strsignal.cc b/aos/libc/aos_strsignal.cc
index b46e46e..12838b4 100644
--- a/aos/libc/aos_strsignal.cc
+++ b/aos/libc/aos_strsignal.cc
@@ -4,10 +4,8 @@
 
 #include "glog/logging.h"
 
-#include "aos/thread_local.h"
-
 const char *aos_strsignal(int signal) {
-  AOS_THREAD_LOCAL char buffer[512];
+  thread_local char buffer[512];
 
   if (signal >= SIGRTMIN && signal <= SIGRTMAX) {
     CHECK_GT(snprintf(buffer, sizeof(buffer), "Real-time signal %d",
diff --git a/aos/logging/BUILD b/aos/logging/BUILD
index fe8db3a..7e1b5cc 100644
--- a/aos/logging/BUILD
+++ b/aos/logging/BUILD
@@ -22,7 +22,6 @@
         ":sizes",
         "//aos:die",
         "//aos:macros",
-        "//aos:thread_local",
         "//aos/libc:aos_strerror",
         "//aos/stl_mutex",
         "//aos/time",
diff --git a/aos/logging/context.cc b/aos/logging/context.cc
index 02ad3eb..0ffe01c 100644
--- a/aos/logging/context.cc
+++ b/aos/logging/context.cc
@@ -22,7 +22,6 @@
 
 #include "aos/die.h"
 #include "aos/logging/implementations.h"
-#include "aos/thread_local.h"
 
 namespace aos {
 namespace logging {
@@ -69,7 +68,7 @@
 // reason for doing this instead of just deleting them is that tsan (at least)
 // doesn't like it when pthread_atfork handlers do complicated stuff and it's
 // not a great idea anyways.
-AOS_THREAD_LOCAL bool delete_current_context(false);
+thread_local bool delete_current_context(false);
 
 }  // namespace
 
diff --git a/aos/realtime.cc b/aos/realtime.cc
index 94dfa4e..22b864e 100644
--- a/aos/realtime.cc
+++ b/aos/realtime.cc
@@ -18,7 +18,6 @@
 #include "glog/logging.h"
 #include "glog/raw_logging.h"
 
-#include "aos/thread_local.h"
 #include "aos/uuid.h"
 
 DEFINE_bool(
@@ -229,7 +228,7 @@
 namespace {
 // Bool to track if malloc hooks have failed to be configured.
 bool has_malloc_hook = true;
-AOS_THREAD_LOCAL bool is_realtime = false;
+thread_local bool is_realtime = false;
 }  // namespace
 
 bool MarkRealtime(bool realtime) {
diff --git a/aos/testing/BUILD b/aos/testing/BUILD
index 1cff37e..ede1160 100644
--- a/aos/testing/BUILD
+++ b/aos/testing/BUILD
@@ -27,7 +27,6 @@
     visibility = ["//visibility:public"],
     deps = [
         ":googletest",
-        "//aos:thread_local",
         "//aos/logging:implementations",
         "//aos/stl_mutex",
         "@com_google_absl//absl/base",
diff --git a/aos/testing/test_logging.cc b/aos/testing/test_logging.cc
index ad2cc03..a2042e2 100644
--- a/aos/testing/test_logging.cc
+++ b/aos/testing/test_logging.cc
@@ -8,7 +8,6 @@
 
 #include "aos/logging/implementations.h"
 #include "aos/stl_mutex/stl_mutex.h"
-#include "aos/thread_local.h"
 
 using ::aos::logging::LogMessage;
 
diff --git a/aos/thread_local.h b/aos/thread_local.h
deleted file mode 100644
index e8c8854..0000000
--- a/aos/thread_local.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef AOS_THREAD_LOCAL_H_
-#define AOS_THREAD_LOCAL_H_
-
-// Use AOS_THREAD_LOCAL instead of thread_local to pick up specifics for various
-// compilers/platforms.
-
-#ifdef __aarch64__
-// Workaround for https://bugs.llvm.org/show_bug.cgi?id=41527.
-// TODO(Brian): Remove this once we upgrade past LLVM 9.0.0.
-// 9.0.1 might have the fix, but I can't find prebuilt binaries for it, for some
-// reason. Going by release dates, 10.0.0 should definitely have the fix.
-//
-// https://reviews.llvm.org/D53906 broke it, https://reviews.llvm.org/D62055
-// reverted it, https://reviews.llvm.org/D61825 re-enabled it for only Android.
-//
-// Basically, LLD hacks the program header, but fails to change enough of the
-// values to be self-consistent. The resulting values cause glibc's dynamic
-// linker to do something different than lld is expecting, so then things
-// overlap at runtime and break horribly.
-//
-// This workaround ensures that the program header has the alignment lld wants
-// already, which ensures it's set there early enough in lld's processing that
-// it actually gets the proper alignment. This makes the hack a NOP so
-// everything works correctly.
-//
-// To check for the problem, build a binary (a complete binary, not a test
-// binary which references shared objects for all the code) and run `readelf
-// -aW` on it. Look for the TLS program header. If its alignment is 0x40, this
-// workaround is probably needed. Verify its address is aligned mod 0x40 to
-// verify the workaround is effective.
-#define AOS_THREAD_LOCAL __attribute__((aligned(0x40))) thread_local
-#else
-#define AOS_THREAD_LOCAL thread_local
-#endif
-
-#endif  // AOS_THREAD_LOCAL_H_
diff --git a/aos/uuid.h b/aos/uuid.h
index 371eb6d..8dd93d4 100644
--- a/aos/uuid.h
+++ b/aos/uuid.h
@@ -9,8 +9,6 @@
 #include "absl/types/span.h"
 #include "flatbuffers/flatbuffers.h"
 
-#include "aos/thread_local.h"
-
 namespace aos {
 
 // Class to generate and hold a UUID.
@@ -76,7 +74,7 @@
   // Be careful using this. It's mostly useful for low-level tracing of UUIDs
   // through the system.
   const char *thread_local_string() const {
-    AOS_THREAD_LOCAL char buffer[kStringSize + 1];
+    thread_local char buffer[kStringSize + 1];
     CopyTo(buffer);
     return buffer;
   }