bug-gnulib
[Top][All Lists]
Advanced

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

Re: _Atomic


From: Bruno Haible
Subject: Re: _Atomic
Date: Sun, 11 Oct 2020 00:39:20 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-189-generic; KDE/5.18.0; x86_64; ; )

Paul Eggert wrote:
> On 10/10/20 8:04 AM, Marc Nieper-Wißkirchen wrote:
> > #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L &&
> > !defined (__STD_NO_ATOMICS__)
> > 
> > I am asking because there may be non-C11 compilers that nevertheless
> > understand _Atomic.
> 
> I suggest not worrying about this problem until we run into it.

GCC 4.9.x is such a compiler that is non-C11 but supports _Atomic.

With this test program

==================================================================
#include <stdio.h>

#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \
  && !defined (__STD_NO_ATOMICS__)
# define GL_HAMT_THREAD_SAFE 1
#else
# define GL_HAMT_THREAD_SAFE 0
#endif

_Atomic int x;

void increment_x (void)
{
  x++;
}

int main (void)
{
  printf ("GL_HAMT_THREAD_SAFE=%d\n", GL_HAMT_THREAD_SAFE);
  return 0;
}
==================================================================

the results on the various platforms are as follows:

                   GL_HAMT_THREAD_SAFE      _Atomic compiles   _Atomic works
  GCC 4.8                 0                       0                  0
  GCC 4.9                 0                       1                  1
  GCC 5                   1                       1                  1
  GCC 6                   1                       1                  1
  GCC 7                   1                       1                  1
  GCC 8                   1                       1                  1
  GCC 9                   1                       1                  1
  GCC 10                  1                       1                  1
  macOS 10.13             1                       1                  1
  FreeBSD 12              1                       1                  1
  NetBSD 9                1                       1                  1
  OpenBSD 6.7 cc          1                       1                  1
  OpenBSD 6.7 gcc         0                       0                  0
  AIX 7.1 xlc             0                       0                  0
  Solaris 10 cc           0                       0                  0
  Solaris 11.3 cc 12.4    0                       0                  0
  Solaris 11.3 cc 12.5    1                       1                  1
  Solaris 11.3 cc 12.6    1                       1                  1
  MSVC 14                 0                       0                  0

Bruno




reply via email to

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