From 116297ccd595ae7526ee100e5906b57d15ebd84c Mon Sep 17 00:00:00 2001 From: merry Date: Sun, 3 Apr 2022 15:30:39 +0100 Subject: [PATCH] common: Add atomic Implement atomic or operation on u32 --- src/dynarmic/common/atomic.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/dynarmic/common/atomic.h diff --git a/src/dynarmic/common/atomic.h b/src/dynarmic/common/atomic.h new file mode 100644 index 00000000..d9f00db4 --- /dev/null +++ b/src/dynarmic/common/atomic.h @@ -0,0 +1,20 @@ +/* This file is part of the dynarmic project. + * Copyright (c) 2022 MerryMage + * SPDX-License-Identifier: 0BSD + */ + +#pragma once + +#include "dynarmic/common/common_types.h" + +namespace Dynarmic::Atomic { + +inline void Or(volatile u32* ptr, u32 value) { +#ifdef _MSC_VER + _InterlockedOr(reinterpret_cast(ptr), value); +#else + __atomic_or_fetch(ptr, value, __ATOMIC_SEQ_CST); +#endif +} + +} // namespace Dynarmic::Atomic