diff --git a/sysdeps/csky/nptl/thread_pointer.h b/sysdeps/csky/nptl/thread_pointer.h
new file mode 100644
index 0000000000..c8be0b1e84
--- /dev/null
+++ b/sysdeps/csky/nptl/thread_pointer.h
@@ -0,0 +1,25 @@
+/* __thread_pointer definition.  csky version.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <https://www.gnu.org/licenses/>.  */
+
+static inline void *
+__thread_pointer (void)
+{
+  void *__result;
+  __asm__ volatile ("mov %0, r31" : "=r" (__result));
+  return __result;
+}
diff --git a/sysdeps/hppa/nptl/thread_pointer.h b/sysdeps/hppa/nptl/thread_pointer.h
new file mode 100644
index 0000000000..118b7f9385
--- /dev/null
+++ b/sysdeps/hppa/nptl/thread_pointer.h
@@ -0,0 +1,25 @@
+/* __thread_pointer definition.  hppa version.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <https://www.gnu.org/licenses/>.  */
+
+static inline void *
+__thread_pointer (void)
+{
+  void *__result;
+  __asm__ ("mfctl %%cr27, %0" : "=r" (__result));
+  return __result;
+}
diff --git a/sysdeps/ia64/nptl/thread_pointer.h b/sysdeps/ia64/nptl/thread_pointer.h
new file mode 100644
index 0000000000..412b9f0460
--- /dev/null
+++ b/sysdeps/ia64/nptl/thread_pointer.h
@@ -0,0 +1,19 @@
+/* __thread_pointer definition.  ia64 version.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#define __thread_pointer() ({ register void *__reg asm ("r13"); __reg; })
diff --git a/sysdeps/m68k/nptl/thread_pointer.h b/sysdeps/m68k/nptl/thread_pointer.h
new file mode 100644
index 0000000000..932567fddb
--- /dev/null
+++ b/sysdeps/m68k/nptl/thread_pointer.h
@@ -0,0 +1,20 @@
+/* __thread_pointer definition.  m68k version.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <https://www.gnu.org/licenses/>.  */
+
+extern void * __m68k_read_tp (void);
+#define __thread_pointer() __m68k_read_tp ()
diff --git a/sysdeps/microblaze/nptl/thread_pointer.h b/sysdeps/microblaze/nptl/thread_pointer.h
new file mode 100644
index 0000000000..020c73113a
--- /dev/null
+++ b/sysdeps/microblaze/nptl/thread_pointer.h
@@ -0,0 +1,19 @@
+/* __thread_pointer definition.  microblaze version.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#define __thread_pointer() ({ register void *__reg asm ("r21"); __reg; })
diff --git a/sysdeps/nptl/thread_pointer.h b/sysdeps/nptl/thread_pointer.h
new file mode 100644
index 0000000000..6368b1083e
--- /dev/null
+++ b/sysdeps/nptl/thread_pointer.h
@@ -0,0 +1,19 @@
+/* __thread_pointer definition.  Generic version.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#define __thread_pointer() __builtin_thread_pointer ()
diff --git a/sysdeps/powerpc/nptl/thread_pointer.h b/sysdeps/powerpc/nptl/thread_pointer.h
new file mode 100644
index 0000000000..69943a2f24
--- /dev/null
+++ b/sysdeps/powerpc/nptl/thread_pointer.h
@@ -0,0 +1,23 @@
+/* __thread_pointer definition.  powerpc version.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#ifdef __powerpc64__
+# define __thread_pointer() ({ register void *__reg asm ("r13"); __reg; })
+#else
+# define __thread_pointer() ({ register void *__reg asm ("r2"); __reg; })
+#endif
diff --git a/sysdeps/sparc/nptl/thread_pointer.h b/sysdeps/sparc/nptl/thread_pointer.h
new file mode 100644
index 0000000000..6a176cba28
--- /dev/null
+++ b/sysdeps/sparc/nptl/thread_pointer.h
@@ -0,0 +1,19 @@
+/* __thread_pointer definition.  sparc version.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#define __thread_pointer() ({ register void *__reg asm ("%g7"); __reg; })
diff --git a/sysdeps/x86/nptl/thread_pointer.h b/sysdeps/x86/nptl/thread_pointer.h
new file mode 100644
index 0000000000..d636839ecf
--- /dev/null
+++ b/sysdeps/x86/nptl/thread_pointer.h
@@ -0,0 +1,33 @@
+/* __thread_pointer definition.  x86 version.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#if __GNUC_PREREQ (11, 1)
+# define __thread_pointer() __builtin_thread_pointer ()
+#else
+static inline void *
+__thread_pointer (void)
+{
+  void *__result;
+# ifdef __x86_64__
+  __asm__ volatile ("mov %%fs:0, %0" : "=r" (__result));
+# else
+  __asm__ volatile ("mov %%gs:0, %0" : "=r" (__result));
+#endif
+  return __result;
+}
+#endif
