/* * Copyright (c) 2026, Chloe M. * Provided under the BSD-3 clause. * * Description: Atomic operations * Author: Chloe M. */ #ifndef _SDK_ATOMIC_H_ #define _SDK_ATOMIC_H_ 1 #include static inline ULONG AtomicAddLongNv(volatile ULONG *Ptr, ULONG Value) { return __sync_add_and_fetch(Ptr, Value); } static inline UQUAD AtomicAddQuadNv(volatile UQUAD *Ptr, UQUAD Value) { return __sync_add_and_fetch(Ptr, Value); } static inline ULONG AtomicSubLongNv(volatile ULONG *Ptr, ULONG Value) { return __sync_sub_and_fetch(Ptr, Value); } static inline ULONG AtomicSubQuadNv(volatile UQUAD *Ptr, UQUAD Value) { return __sync_sub_and_fetch(Ptr, Value); } /* Atomic increment and fetch operations */ #define AtomicIncLong(P) AtomicAddLongNv((P), 1) #define AtomicIncQuad(P) AtomicAddQuadNv((P), 1) /* Atomic decrement and fetch operations */ #define AtomicDecLong(P) AtomicSubLongNv((P), 1) #define AtomicDecQuad(P) AtomicSubQuadNv((P), 1) #endif /* !_SDK_ATOMIC_H_ */