[Mesa-dev] Fix __atomic* builtins detection for Clang

Jan Beich jbeich at FreeBSD.org
Sat May 13 08:41:58 UTC 2017


Jonathan Gray <jsg at jsg.id.au> writes:

> commit a6a38a038bd62e6d9558905f00bef81b5e7e6fcc
> Author: Grazvydas Ignotas <notasas at gmail.com>
> Date:   Fri Mar 31 01:26:25 2017 +0300
>
>     util/u_atomic: provide 64bit atomics where they're missing
>
> attempts to handle powerpc like situations, though not sync
> builtins being missing entirely.

Not ready for Clang on i386 which has __sync* but not __atomic*.
Teaching configure.ac about 64bit __atomic* isn't enough.

  #include <stdint.h>
  uint64_t v;
  int main() {
  #ifdef USE_GCC_ATOMIC_BUILTINS
      return __atomic_add_fetch(&v, 1, __ATOMIC_ACQ_REL);
  #else
      return __sync_add_and_fetch(&v, (uint64_t)1);
  #endif
  }

leads to

  u_atomic.c:38:1: error: conflicting types for '__sync_add_and_fetch_8'
  __sync_add_and_fetch_8(uint64_t *ptr, uint64_t val)
  ^
  u_atomic.c:38:1: note: '__sync_add_and_fetch_8' is a builtin with type 'long long (volatile long long *, long long, ...)'
  u_atomic.c:38:1: error: definition of builtin function '__sync_add_and_fetch_8'
  __sync_add_and_fetch_8(uint64_t *ptr, uint64_t val)
  ^
  u_atomic.c:51:1: error: conflicting types for '__sync_sub_and_fetch_8'
  __sync_sub_and_fetch_8(uint64_t *ptr, uint64_t val)
  ^
  u_atomic.c:51:1: note: '__sync_sub_and_fetch_8' is a builtin with type 'long long (volatile long long *, long long, ...)'
  u_atomic.c:51:1: error: definition of builtin function '__sync_sub_and_fetch_8'
  __sync_sub_and_fetch_8(uint64_t *ptr, uint64_t val)
  ^
  u_atomic.c:64:1: error: no previous prototype for function '__atomic_fetch_add_8' [-Werror,-Wmissing-prototypes]
  __atomic_fetch_add_8(uint64_t *ptr, uint64_t val, int memorder)
  ^
  u_atomic.c:70:1: error: no previous prototype for function '__atomic_fetch_sub_8' [-Werror,-Wmissing-prototypes]
  __atomic_fetch_sub_8(uint64_t *ptr, uint64_t val, int memorder)
  ^
  6 errors generated.


More information about the mesa-dev mailing list