// // C/C++11 Atomic Target Definitions // // Copyright (C) 2011-2019 Green Hills Software // // This program is the property of Green Hills Software // its contents are proprietary information and no part of it // is to be disclosed to anyone except employees of Green Hills // Software, or as agreed in writing signed by the President // of Green Hills Software. // #ifndef __GHS_ATOMIC__H_ #ifdef __ghs__ #pragma ghs startnomisra #endif #define __GHS_ATOMIC__H_ #ifdef __cplusplus extern "C" { #endif #if defined(__ARM__) #include #elif defined(__ppc__) && !defined(__VXWORKS) #include #elif defined(__V800__) #include #elif defined(__Tricore__) #include #elif defined(__RISCV__) #include #elif defined(__i386__) && !defined(__CORE_SISKIYOU_PEAK__) || defined(__ARM64__) #if defined(__Long_Is_64) #define _ATOMIC_MAXBYTES_LOCK_FREE 8 #else #define _ATOMIC_MAXBYTES_LOCK_FREE 4 #endif /* !defined(__Long_Is_64) */ #endif /* CPU list */ #if defined(__GHS_PRAGMAS) #pragma ghs start_cxx_lib_header #pragma ghs startdata #endif #if defined(__ghs) && defined(__ghs_max_pack_value) #pragma pack (push, __ghs_max_pack_value) #endif #if !defined(_ATOMIC_MAXBYTES_LOCK_FREE) #define _ATOMIC_MAXBYTES_LOCK_FREE 0 #endif #if !defined(_ATOMIC_MINBYTES_LOCK_FREE) #define _ATOMIC_MINBYTES_LOCK_FREE 0 #endif #ifndef _GHS_ATOMIC_BARRIER #define _GHS_ATOMIC_BARRIER(x) #if (_ATOMIC_MAXBYTES_LOCK_FREE >= 4) #define _ATOMIC_FENCE_USES_EXCHANGE #else #define _ATOMIC_FENCE_USES_LOCK 1 #endif #endif #ifndef _ATOMIC_FENCE_USES_LOCK #define _ATOMIC_FENCE_USES_LOCK 0 #endif #if (((_ATOMIC_MAXBYTES_LOCK_FREE >= 1) && (_ATOMIC_MINBYTES_LOCK_FREE <= 1)) \ || (_ATOMIC_MAXBYTES_LOCK_FREE >= 4)) #define _ATOMIC_FLAG_USES_LOCK 0 #else #define _ATOMIC_FLAG_USES_LOCK 1 #endif #ifndef _ATOMIC_FLAG_SIZE #if ((_ATOMIC_MAXBYTES_LOCK_FREE >= 1) && (_ATOMIC_MINBYTES_LOCK_FREE <= 1) \ || (_ATOMIC_MAXBYTES_LOCK_FREE < 4)) #define _ATOMIC_FLAG_SIZE 1 #else #define _ATOMIC_FLAG_SIZE 4 #endif #endif #if (_ATOMIC_MAXBYTES_LOCK_FREE >= 1) && (_ATOMIC_MINBYTES_LOCK_FREE <= 1) long __ghs_nonpreemptible_compare_exchange_8(volatile char *__ptr, char __old_val, char __new_val); #define _GHS_COMPARE_EXCHANGE_1(p, o, n) \ __ghs_nonpreemptible_compare_exchange_8((volatile char*)p, o, n) #endif #if (_ATOMIC_MAXBYTES_LOCK_FREE >= 2) && (_ATOMIC_MINBYTES_LOCK_FREE <= 2) long __ghs_nonpreemptible_compare_exchange_16(volatile short *__ptr, short __old_val, short __new_val); #define _GHS_COMPARE_EXCHANGE_2(p, o, n) \ __ghs_nonpreemptible_compare_exchange_16((volatile short*)p, o, n) #endif #if (_ATOMIC_MAXBYTES_LOCK_FREE >= 4) long __ghs_nonpreemptible_compare_exchange_32(volatile int *__ptr, int __old_val, int __new_val); #define _GHS_COMPARE_EXCHANGE_4(p, o, n) \ __ghs_nonpreemptible_compare_exchange_32((volatile int*)p, o, n) #if (_ATOMIC_MINBYTES_LOCK_FREE == 4) long __ghs_nonpreemptible_compare_exchange_32_8(volatile int *__ptr, int __old_val, int __new_val); #define _GHS_COMPARE_EXCHANGE_4_1(p, o, n) \ __ghs_nonpreemptible_compare_exchange_32_8((volatile int*)p, o, n) long __ghs_nonpreemptible_compare_exchange_32_16(volatile int *__ptr, int __old_val, int __new_val); #define _GHS_COMPARE_EXCHANGE_4_2(p, o, n) \ __ghs_nonpreemptible_compare_exchange_32_16((volatile int*)p, o, n) #endif #endif #if (_ATOMIC_MAXBYTES_LOCK_FREE >= 8) long __ghs_nonpreemptible_compare_exchange_64(volatile long long *__ptr, long long __old_val, long long __new_val); #define _GHS_COMPARE_EXCHANGE_8(p, o, n) \ __ghs_nonpreemptible_compare_exchange_64((volatile long long*)p, o, n) #endif #if defined(__ghs) && defined(__ghs_max_pack_value) #pragma pack(pop) #endif #if defined(__GHS_PRAGMAS) #pragma ghs enddata #pragma ghs end_cxx_lib_header #endif #ifdef __cplusplus } #endif #ifdef __ghs__ #pragma ghs endnomisra #endif #endif // #ifndef __GHS_ATOMIC__H_