bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

asyncsafe-spin, simple-atomic: Add support for tcc


From: Bruno Haible
Subject: asyncsafe-spin, simple-atomic: Add support for tcc
Date: Wed, 03 Mar 2021 13:37:20 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-203-generic; KDE/5.18.0; x86_64; ; )

Compiling a gnulib testdir with tcc 0.9.27, nearly all tests pass. The only
failures are:

FAIL: test-asyncsafe-spin2
FAIL: test-simple-atomic

This patch fixes them.


2021-03-03  Bruno Haible  <bruno@clisp.org>

        asyncsafe-spin, simple-atomic: Add support for tcc.
        * lib/asyncsafe-spin.c (memory_barrier, atomic_compare_and_swap): On
        i386 and x86_64, treat tcc like older GCC or clang.
        * lib/simple-atomic.c (memory_barrier, atomic_compare_and_swap,
        atomic_compare_and_swap_ptr): Likewise.

diff --git a/lib/asyncsafe-spin.c b/lib/asyncsafe-spin.c
index ba22b9c..cece623 100644
--- a/lib/asyncsafe-spin.c
+++ b/lib/asyncsafe-spin.c
@@ -190,7 +190,7 @@ do_unlock (asyncsafe_spinlock_t *lock)
     abort ();
 }
 
-#  elif (defined __GNUC__ || defined __clang__ || defined __SUNPRO_C) && 
(defined __sparc || defined __i386 || defined __x86_64__)
+#  elif ((defined __GNUC__ || defined __clang__ || defined __SUNPRO_C) && 
(defined __sparc || defined __i386 || defined __x86_64__)) || (defined 
__TINYC__ && (defined __i386 || defined __x86_64__))
 /* For older versions of GCC or clang, use inline assembly.
    GCC, clang, and the Oracle Studio C 12 compiler understand GCC's extended
    asm syntax, but the plain Oracle Studio C 11 compiler understands only
@@ -200,7 +200,7 @@ do_unlock (asyncsafe_spinlock_t *lock)
 static void
 memory_barrier (void)
 {
-#   if defined __GNUC__ || defined __clang__ || __SUNPRO_C >= 0x590
+#   if defined __GNUC__ || defined __clang__ || __SUNPRO_C >= 0x590 || defined 
__TINYC__
 #    if defined __i386 || defined __x86_64__
   asm volatile ("mfence");
 #    endif
@@ -223,7 +223,7 @@ static unsigned int
 atomic_compare_and_swap (volatile unsigned int *vp, unsigned int cmp,
                          unsigned int newval)
 {
-#   if defined __GNUC__ || defined __clang__ || __SUNPRO_C >= 0x590
+#   if defined __GNUC__ || defined __clang__ || __SUNPRO_C >= 0x590 || defined 
__TINYC__
   unsigned int oldval;
 #    if defined __i386 || defined __x86_64__
   asm volatile (" lock\n cmpxchgl %3,(%1)"
diff --git a/lib/simple-atomic.c b/lib/simple-atomic.c
index 17625fb..4d5a0d8 100644
--- a/lib/simple-atomic.c
+++ b/lib/simple-atomic.c
@@ -186,7 +186,7 @@ atomic_compare_and_swap_ptr (uintptr_t volatile *vp,
   return oldval;
 }
 
-# elif (defined __GNUC__ || defined __clang__ || defined __SUNPRO_C) && 
(defined __sparc || defined __i386 || defined __x86_64__)
+# elif ((defined __GNUC__ || defined __clang__ || defined __SUNPRO_C) && 
(defined __sparc || defined __i386 || defined __x86_64__)) || (defined 
__TINYC__ && (defined __i386 || defined __x86_64__))
 /* For older versions of GCC or clang, use inline assembly.
    GCC, clang, and the Oracle Studio C 12 compiler understand GCC's extended
    asm syntax, but the plain Oracle Studio C 11 compiler understands only
@@ -195,7 +195,7 @@ atomic_compare_and_swap_ptr (uintptr_t volatile *vp,
 void
 memory_barrier (void)
 {
-#  if defined __GNUC__ || defined __clang__ || __SUNPRO_C >= 0x590
+#  if defined __GNUC__ || defined __clang__ || __SUNPRO_C >= 0x590 || defined 
__TINYC__
 #   if defined __i386 || defined __x86_64__
   asm volatile ("mfence");
 #   endif
@@ -217,7 +217,7 @@ atomic_compare_and_swap (unsigned int volatile *vp,
                          unsigned int cmp,
                          unsigned int newval)
 {
-#  if defined __GNUC__ || defined __clang__ || __SUNPRO_C >= 0x590
+#  if defined __GNUC__ || defined __clang__ || __SUNPRO_C >= 0x590 || defined 
__TINYC__
   unsigned int oldval;
 #   if defined __i386 || defined __x86_64__
   asm volatile (" lock\n cmpxchgl %3,(%1)"
@@ -251,7 +251,7 @@ atomic_compare_and_swap_ptr (uintptr_t volatile *vp,
                              uintptr_t cmp,
                              uintptr_t newval)
 {
-#  if defined __GNUC__ || defined __clang__ || __SUNPRO_C >= 0x590
+#  if defined __GNUC__ || defined __clang__ || __SUNPRO_C >= 0x590 || defined 
__TINYC__
   uintptr_t oldval;
 #   if defined __x86_64__
   asm volatile (" lock\n cmpxchgq %3,(%1)"




reply via email to

[Prev in Thread] Current Thread [Next in Thread]