1 /**************************************************************************** 2 ** 3 ** This file is part of GAP, a system for computational discrete algebra. 4 ** 5 ** Copyright of GAP belongs to its developers, whose names are too numerous 6 ** to list here. Please refer to the COPYRIGHT file for details. 7 ** 8 ** SPDX-License-Identifier: GPL-2.0-or-later 9 */ 10 11 #ifndef GAP_ATOMIC_H 12 #define GAP_ATOMIC_H 13 14 #include "system.h" 15 16 #ifndef HPCGAP 17 #error This header is only meant to be used with HPC-GAP 18 #endif 19 20 #ifndef WARD_ENABLED 21 #include <atomic_ops.h> 22 #else 23 typedef size_t AO_t; 24 #endif 25 26 #define MEMBAR_READ() (AO_nop_read()) 27 #define MEMBAR_WRITE() (AO_nop_write()) 28 #define MEMBAR_FULL() (AO_nop_full()) 29 #define COMPARE_AND_SWAP(a,b,c) (AO_compare_and_swap_full((a), (b), (c))) 30 #define ATOMIC_INC(x) (AO_fetch_and_add1((x))) 31 #define ATOMIC_DEC(x) (AO_fetch_and_sub1((x))) 32 33 typedef AO_t AtomicUInt; 34 35 #endif // GAP_ATOMIC_H 36