From 92ce384c80999c59672c140057bdbd226f778ec5 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Mon, 11 Jan 2021 19:27:37 +0100 Subject: [PATCH] fix compilation of core/bricks with clang++10 * configure.ac: Call CHECK_ATOMIC after setting the C++ options. This is probably not necessary, but it makes more sense. * m4/l_atomic.m4: Augment the test body with a scenario that actually requires -latomic. --- configure.ac | 8 ++++---- m4/l_atomic.m4 | 30 ++++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index 3ad6f056a..ee32bd21b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2008-2020, Laboratoire de Recherche et Développement +# Copyright (C) 2008-2021, Laboratoire de Recherche et Développement # de l'Epita (LRDE). # Copyright (C) 2003-2007 Laboratoire d'Informatique de Paris 6 # (LIP6), département Systèmes Répartis Coopératifs (SRC), Université @@ -79,9 +79,6 @@ AX_CHECK_COMPILE_FLAG([-std=c11], [CFLAGS="$CFLAGS -std=c11"]) gl_INIT -dnl Check if -latomic is required for -CHECK_ATOMIC - # Use -Werror since using -fvisibility under MinGW is only a warning. # (The option is ignored anyway since this does not make sense under windows). AX_CHECK_COMPILE_FLAG([-Werror -fvisibility=hidden], @@ -145,6 +142,9 @@ else fi fi +dnl Check if -latomic is required for +CHECK_ATOMIC + AX_CHECK_BUDDY AC_CHECK_HEADERS([sys/times.h valgrind/memcheck.h spawn.h]) diff --git a/m4/l_atomic.m4 b/m4/l_atomic.m4 index e423270ea..08e5b4f79 100644 --- a/m4/l_atomic.m4 +++ b/m4/l_atomic.m4 @@ -10,14 +10,28 @@ dnl warranty. # Sourced from http://bugs.debian.org/797228 m4_define([_CHECK_ATOMIC_testbody], [[ - #include - #include - int main() { - std::atomic a{}; - int64_t v = 5; - int64_t r = a.fetch_add(v); - return static_cast(r); - } +#include +#include + +template< typename T > +struct Tagged +{ + T t; + uint32_t _tag; + static const int tag_bits = 16; + void tag( uint32_t v ) { _tag = v; } + uint32_t tag() { return _tag; } + Tagged() noexcept : t(), _tag( 0 ) {} + Tagged( const T &t ) : t( t ), _tag( 0 ) {} +}; + +int main() { + std::atomic a{}; + int64_t v = 5; + int64_t r = a.fetch_add(v); + std::atomic> value; + return static_cast(r) + value.load().t; +} ]]) AC_DEFUN([CHECK_ATOMIC], [