Skip to content

Commit

Permalink
Remove Atomic.h
Browse files Browse the repository at this point in the history
The STL has everything we need nowadays.

I have tried to not alter any behavior or semantics with this
change wherever possible. In particular, WriteLow and WriteHigh
in CommandProcessor retain the ability to accidentally undo
another thread's write to the upper half or lower half
respectively. If that should be fixed, it should be done in a
separate commit for clarity. One thing did change: The places
where we were using += on a volatile variable (not an atomic
operation) are now using fetch_add (actually an atomic operation).

Tested with single core and dual core on x86-64 and AArch64.
  • Loading branch information
JosJuice committed May 13, 2021
1 parent 80ac36a commit b93983b
Show file tree
Hide file tree
Showing 13 changed files with 178 additions and 319 deletions.
16 changes: 0 additions & 16 deletions Source/Core/Common/Atomic.h

This file was deleted.

86 changes: 0 additions & 86 deletions Source/Core/Common/Atomic_GCC.h

This file was deleted.

94 changes: 0 additions & 94 deletions Source/Core/Common/Atomic_Win32.h

This file was deleted.

1 change: 0 additions & 1 deletion Source/Core/Common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ add_library(common
Analytics.cpp
Analytics.h
Assert.h
Atomic.h
BitField.h
BitSet.h
BitUtils.h
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Common/ChunkFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ class PointerWrap
template <typename T>
void Do(std::atomic<T>& atomic)
{
T temp = atomic.load();
T temp = atomic.load(std::memory_order_relaxed);
Do(temp);
if (mode == MODE_READ)
atomic.store(temp);
atomic.store(temp, std::memory_order_relaxed);
}

template <typename T>
Expand Down
12 changes: 8 additions & 4 deletions Source/Core/Core/HW/MMIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
#pragma once

#include <array>
#include <atomic>
#include <string>
#include <tuple>
#include <type_traits>

#include "Common/Assert.h"
#include "Common/BitUtils.h"
#include "Common/CommonTypes.h"
#include "Core/ConfigManager.h"
#include "Core/HW/MMIOHandlers.h"
Expand Down Expand Up @@ -79,17 +81,19 @@ inline u16* LowPart(u32* ptr)
{
return (u16*)ptr;
}
inline u16* LowPart(volatile u32* ptr)
inline u16* LowPart(std::atomic<u32>* ptr)
{
return (u16*)ptr;
static_assert(std::atomic<u32>::is_always_lock_free && sizeof(std::atomic<u32>) == sizeof(u32));
return LowPart(Common::BitCast<u32*>(ptr));
}
inline u16* HighPart(u32* ptr)
{
return LowPart(ptr) + 1;
}
inline u16* HighPart(volatile u32* ptr)
inline u16* HighPart(std::atomic<u32>* ptr)
{
return LowPart(ptr) + 1;
static_assert(std::atomic<u32>::is_always_lock_free && sizeof(std::atomic<u32>) == sizeof(u32));
return HighPart(Common::BitCast<u32*>(ptr));
}
} // namespace Utils

Expand Down
1 change: 0 additions & 1 deletion Source/Core/Core/HW/SystemTimers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ IPC_HLE_PERIOD: For the Wii Remote this is the call schedule:
#include <cmath>
#include <cstdlib>

#include "Common/Atomic.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/Thread.h"
Expand Down
3 changes: 0 additions & 3 deletions Source/Core/DolphinLib.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
<ClInclude Include="Common\Align.h" />
<ClInclude Include="Common\Analytics.h" />
<ClInclude Include="Common\Assert.h" />
<ClInclude Include="Common\Atomic_GCC.h" />
<ClInclude Include="Common\Atomic_Win32.h" />
<ClInclude Include="Common\Atomic.h" />
<ClInclude Include="Common\BitField.h" />
<ClInclude Include="Common\BitSet.h" />
<ClInclude Include="Common\BitUtils.h" />
Expand Down
1 change: 0 additions & 1 deletion Source/Core/VideoBackends/OGL/OGLRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <memory>
#include <string>

#include "Common/Atomic.h"
#include "Common/CommonTypes.h"
#include "Common/GL/GLContext.h"
#include "Common/GL/GLUtil.h"
Expand Down
Loading

0 comments on commit b93983b

Please sign in to comment.