]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
x86: Fix THREAD_GSCOPE_RESET_FLAG build on clang
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 16 Oct 2025 19:30:52 +0000 (16:30 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 28 Oct 2025 16:36:29 +0000 (13:36 -0300)
clang does not support __seg_fs in asm constraint.

sysdeps/x86_64/nptl/tls.h

index abfeb8805453965753d75b3aa9319a9d5f385ac3..809d90875a598811cedf03c0747b7ccf3798fb34 100644 (file)
@@ -198,13 +198,27 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) == 0x80,
 # define THREAD_GSCOPE_FLAG_UNUSED 0
 # define THREAD_GSCOPE_FLAG_USED   1
 # define THREAD_GSCOPE_FLAG_WAIT   2
+
+/* clang does not support __seg_fs in asm constraint.  */
+# ifdef __clang__
+#  define XCHGL_GSCOPE(__r)                                                  \
+   asm volatile ("xchgl %%fs:%c1, %0"                                        \
+                 : "=r" (__r)                                                \
+                 : "i" (offsetof (struct pthread, header.gscope_flag)),              \
+                  "0" (THREAD_GSCOPE_FLAG_UNUSED)                            \
+                : "memory")
+# else
+#  define XCHGL_GSCOPE(__r)                                                  \
+   asm volatile ("xchgl %1, %0"                                                      \
+                : "=r" (__r)                                                 \
+                : "m" (((struct pthread __seg_fs *)0)->header.gscope_flag),  \
+                  "0" (THREAD_GSCOPE_FLAG_UNUSED))
+# endif
+
 # define THREAD_GSCOPE_RESET_FLAG() \
   do                                                                         \
     { int __res;                                                             \
-      asm volatile ("xchgl %1, %0"                                           \
-                   : "=r" (__res)                                            \
-                   : "m" (((struct pthread __seg_fs *)0)->header.gscope_flag), \
-                     "0" (THREAD_GSCOPE_FLAG_UNUSED));                       \
+      XCHGL_GSCOPE (__res);                                                  \
       if (__res == THREAD_GSCOPE_FLAG_WAIT)                                  \
        lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE);    \
     }                                                                        \