bug-gnulib
[Top][All Lists]
Advanced

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

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


From: Christian Jullien
Subject: RE: asyncsafe-spin, simple-atomic: Add support for tcc
Date: Thu, 4 Mar 2021 06:38:21 +0100

Hi wouldn't be better to ask tcc maintainers to support mfence for __i386
target?

-----Original Message-----
From: Bruno Haible [mailto:bruno@clisp.org] 
Sent: Thursday, March 04, 2021 02:21
To: bug-gnulib@gnu.org
Cc: Christian Jullien
Subject: Re: asyncsafe-spin, simple-atomic: Add support for tcc

> 2021-03-03  Bruno Haible  <bruno@clisp.org>
> 
>       asyncsafe-spin, simple-atomic: Add support for tcc.

This doesn't work for tcc/x86, because in this configuration the compiler
does
not know about the 'mfence' instruction.


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

        asyncsafe-spin, simple-atomic: Add support for tcc/x86.
        * lib/asyncsafe-spin.c (memory_barrier): With tcc/x86, don't use the
        'mfence' instruction.
        * lib/simple-atomic.c (memory_barrier): Likewise.

diff --git a/lib/asyncsafe-spin.c b/lib/asyncsafe-spin.c
index cece623..d0cdb39 100644
--- a/lib/asyncsafe-spin.c
+++ b/lib/asyncsafe-spin.c
@@ -202,7 +202,12 @@ memory_barrier (void)
 {
 #   if defined __GNUC__ || defined __clang__ || __SUNPRO_C >= 0x590 ||
defined __TINYC__
 #    if defined __i386 || defined __x86_64__
+#     if defined __TINYC__ && defined __i386
+  /* Cannot use the SSE instruction "mfence" with this compiler.  */
+  asm volatile ("lock orl $0,(%esp)");
+#     else
   asm volatile ("mfence");
+#     endif
 #    endif
 #    if defined __sparc
   asm volatile ("membar 2");
diff --git a/lib/simple-atomic.c b/lib/simple-atomic.c
index 4d5a0d8..7c4f7e9 100644
--- a/lib/simple-atomic.c
+++ b/lib/simple-atomic.c
@@ -197,7 +197,12 @@ memory_barrier (void)
 {
 #  if defined __GNUC__ || defined __clang__ || __SUNPRO_C >= 0x590 ||
defined __TINYC__
 #   if defined __i386 || defined __x86_64__
+#    if defined __TINYC__ && defined __i386
+  /* Cannot use the SSE instruction "mfence" with this compiler.  */
+  asm volatile ("lock orl $0,(%esp)");
+#    else
   asm volatile ("mfence");
+#    endif
 #   endif
 #   if defined __sparc
   asm volatile ("membar 2");




reply via email to

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