Loading scripts/compile_dep.sh +5 −0 Original line number Diff line number Diff line Loading @@ -450,6 +450,11 @@ if check_dependency "mercury" "${DEP_CONFIG[@]}"; then echo "############################################################ Installing: Mercury" CURR=${SOURCE}/mercury prepare_build_dir "${CURR}" cd "${CURR}" if [[ $(cat "${CURR}"/version.txt) == "2.0.1rc3" ]]; then echo "############ applying mercury atomic patch" git apply "${PATCH_DIR}"/mercury_c11_atomic.patch fi cd "${CURR}"/build PKG_CONFIG_PATH=${INSTALL}/lib/pkgconfig $CMAKE \ -DCMAKE_BUILD_TYPE:STRING=Release \ Loading scripts/patches/mercury_c11_atomic.patch 0 → 100644 +44 −0 Original line number Diff line number Diff line diff --git a/src/util/mercury_atomic.h b/src/util/mercury_atomic.h index 63aa54e..b27f270 100644 --- a/src/util/mercury_atomic.h +++ b/src/util/mercury_atomic.h @@ -31,14 +31,34 @@ typedef OPA_int_t hg_atomic_int32_t; typedef OPA_ptr_t hg_atomic_int64_t; /* OPA has only limited 64-bit support */ # define HG_ATOMIC_VAR_INIT(x) OPA_PTR_T_INITIALIZER(x) #elif defined(HG_UTIL_HAS_STDATOMIC_H) -# include <stdatomic.h> + +# ifndef __cplusplus +# include <stdatomic.h> typedef atomic_int hg_atomic_int32_t; -# if (HG_UTIL_ATOMIC_LONG_WIDTH == 8) && !defined(__APPLE__) +# if (HG_UTIL_ATOMIC_LONG_WIDTH == 8) && !defined(__APPLE__) typedef atomic_long hg_atomic_int64_t; -# else +# else typedef atomic_llong hg_atomic_int64_t; -# endif -# define HG_ATOMIC_VAR_INIT(x) ATOMIC_VAR_INIT(x) +# endif +# else +# include <atomic> +# define _Atomic(X) std::atomic< X > +typedef std::atomic<int> hg_atomic_int32_t; +# if (HG_UTIL_ATOMIC_LONG_WIDTH == 8) && !defined(__APPLE__) +typedef std::atomic<long> hg_atomic_int64_t; +# else +typedef std::atomic<long long> hg_atomic_int64_t; +# endif +# define memory_order_release std::memory_order_release +# define memory_order_acquire std::memory_order_acquire +# define memory_order_acq_rel std::memory_order_acq_rel +# define atomic_thread_fence std::atomic_thread_fence +# endif +#define HG_ATOMIC_VAR_INIT(x) ATOMIC_VAR_INIT(x) + + + + #elif defined(__APPLE__) # include <libkern/OSAtomic.h> typedef struct { Loading
scripts/compile_dep.sh +5 −0 Original line number Diff line number Diff line Loading @@ -450,6 +450,11 @@ if check_dependency "mercury" "${DEP_CONFIG[@]}"; then echo "############################################################ Installing: Mercury" CURR=${SOURCE}/mercury prepare_build_dir "${CURR}" cd "${CURR}" if [[ $(cat "${CURR}"/version.txt) == "2.0.1rc3" ]]; then echo "############ applying mercury atomic patch" git apply "${PATCH_DIR}"/mercury_c11_atomic.patch fi cd "${CURR}"/build PKG_CONFIG_PATH=${INSTALL}/lib/pkgconfig $CMAKE \ -DCMAKE_BUILD_TYPE:STRING=Release \ Loading
scripts/patches/mercury_c11_atomic.patch 0 → 100644 +44 −0 Original line number Diff line number Diff line diff --git a/src/util/mercury_atomic.h b/src/util/mercury_atomic.h index 63aa54e..b27f270 100644 --- a/src/util/mercury_atomic.h +++ b/src/util/mercury_atomic.h @@ -31,14 +31,34 @@ typedef OPA_int_t hg_atomic_int32_t; typedef OPA_ptr_t hg_atomic_int64_t; /* OPA has only limited 64-bit support */ # define HG_ATOMIC_VAR_INIT(x) OPA_PTR_T_INITIALIZER(x) #elif defined(HG_UTIL_HAS_STDATOMIC_H) -# include <stdatomic.h> + +# ifndef __cplusplus +# include <stdatomic.h> typedef atomic_int hg_atomic_int32_t; -# if (HG_UTIL_ATOMIC_LONG_WIDTH == 8) && !defined(__APPLE__) +# if (HG_UTIL_ATOMIC_LONG_WIDTH == 8) && !defined(__APPLE__) typedef atomic_long hg_atomic_int64_t; -# else +# else typedef atomic_llong hg_atomic_int64_t; -# endif -# define HG_ATOMIC_VAR_INIT(x) ATOMIC_VAR_INIT(x) +# endif +# else +# include <atomic> +# define _Atomic(X) std::atomic< X > +typedef std::atomic<int> hg_atomic_int32_t; +# if (HG_UTIL_ATOMIC_LONG_WIDTH == 8) && !defined(__APPLE__) +typedef std::atomic<long> hg_atomic_int64_t; +# else +typedef std::atomic<long long> hg_atomic_int64_t; +# endif +# define memory_order_release std::memory_order_release +# define memory_order_acquire std::memory_order_acquire +# define memory_order_acq_rel std::memory_order_acq_rel +# define atomic_thread_fence std::atomic_thread_fence +# endif +#define HG_ATOMIC_VAR_INIT(x) ATOMIC_VAR_INIT(x) + + + + #elif defined(__APPLE__) # include <libkern/OSAtomic.h> typedef struct {