Skip to content

Commit

Permalink
Merge pull request #13513 from hrydgard/clean-old-gunk
Browse files Browse the repository at this point in the history
Delete the old Timer.cpp/h. Move some stuff to where it belongs.
  • Loading branch information
hrydgard authored Oct 5, 2020
2 parents dd5a459 + f3a9d04 commit 9cf2c3e
Show file tree
Hide file tree
Showing 50 changed files with 154 additions and 445 deletions.
12 changes: 5 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,10 @@ add_library(Common STATIC
Common/Crypto/sha256.cpp
Common/Crypto/sha256.h
Common/Data/Collections/ConstMap.h
Common/Data/Collections/FixedSizeQueue.h
Common/Data/Collections/Hashmaps.h
Common/Data/Collections/TinySet.h
Common/Data/Collections/ThreadSafeList.h
Common/Data/Color/RGBAUtil.cpp
Common/Data/Color/RGBAUtil.h
Common/Data/Convert/SmallDataConvert.cpp
Expand Down Expand Up @@ -611,10 +614,8 @@ add_library(Common STATIC
Common/ConsoleListener.h
Common/DbgNew.h
Common/FakeEmitter.h
Common/FixedSizeQueue.h
Common/ExceptionHandlerSetup.cpp
Common/ExceptionHandlerSetup.h
Common/Hashmaps.h
Common/Log.h
Common/Log.cpp
Common/LogManager.cpp
Expand All @@ -633,11 +634,6 @@ add_library(Common STATIC
Common/StringUtils.h
Common/SysError.h
Common/SysError.cpp
Common/ThreadPools.cpp
Common/ThreadPools.h
Common/ThreadSafeList.h
Common/Timer.cpp
Common/Timer.h
Common/TimeUtil.cpp
Common/TimeUtil.h
)
Expand Down Expand Up @@ -1775,6 +1771,8 @@ add_library(${CoreLibName} ${CoreLinkType}
Core/System.h
Core/TextureReplacer.cpp
Core/TextureReplacer.h
Core/ThreadPools.cpp
Core/ThreadPools.h
Core/Util/AudioFormat.cpp
Core/Util/AudioFormat.h
Core/Util/AudioFormatNEON.cpp
Expand Down
2 changes: 1 addition & 1 deletion Common/Arm64Emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <cstring>

#include "Common/Arm64Emitter.h"
#include "Common/MathUtil.h"
#include "Common/Math/math_util.h"
#include "Common/CommonTypes.h"
#include "Common/CommonWindows.h"
#include "Common/CPUDetect.h"
Expand Down
11 changes: 3 additions & 8 deletions Common/Common.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,9 @@
<ClInclude Include="BitSet.h" />
<ClInclude Include="Buffer.h" />
<ClInclude Include="Data\Collections\ConstMap.h" />
<ClInclude Include="Data\Collections\FixedSizeQueue.h" />
<ClInclude Include="Data\Collections\Hashmaps.h" />
<ClInclude Include="Data\Collections\ThreadSafeList.h" />
<ClInclude Include="Data\Collections\TinySet.h" />
<ClInclude Include="Data\Color\RGBAUtil.h" />
<ClInclude Include="Data\Convert\SmallDataConvert.h" />
Expand Down Expand Up @@ -479,7 +482,6 @@
<ClInclude Include="Crypto\sha256.h" />
<ClInclude Include="DbgNew.h" />
<ClInclude Include="ExceptionHandlerSetup.h" />
<ClInclude Include="FixedSizeQueue.h" />
<ClInclude Include="GL\GLInterfaceBase.h" />
<ClInclude Include="GL\GLInterface\EGL.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
Expand All @@ -502,12 +504,10 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="GraphicsContext.h" />
<ClInclude Include="Hashmaps.h" />
<ClInclude Include="Log.h" />
<ClInclude Include="LogManager.h" />
<ClInclude Include="MakeUnique.h" />
<ClInclude Include="MachineContext.h" />
<ClInclude Include="MathUtil.h" />
<ClInclude Include="MemArena.h" />
<ClInclude Include="MemoryUtil.h" />
<ClInclude Include="MipsEmitter.h" />
Expand All @@ -519,14 +519,11 @@
<ClInclude Include="System\Display.h" />
<ClInclude Include="System\NativeApp.h" />
<ClInclude Include="System\System.h" />
<ClInclude Include="ThreadPools.h" />
<ClInclude Include="ThreadSafeList.h" />
<ClInclude Include="Thread\Executor.h" />
<ClInclude Include="Thread\PrioritizedWorkQueue.h" />
<ClInclude Include="Thread\ThreadPool.h" />
<ClInclude Include="Thread\ThreadUtil.h" />
<ClInclude Include="Thunk.h" />
<ClInclude Include="Timer.h" />
<ClInclude Include="TimeUtil.h" />
<ClInclude Include="UI\Context.h" />
<ClInclude Include="UI\Root.h" />
Expand Down Expand Up @@ -836,13 +833,11 @@
<ClCompile Include="OSVersion.cpp" />
<ClCompile Include="StringUtils.cpp" />
<ClCompile Include="System\Display.cpp" />
<ClCompile Include="ThreadPools.cpp" />
<ClCompile Include="Thread\Executor.cpp" />
<ClCompile Include="Thread\PrioritizedWorkQueue.cpp" />
<ClCompile Include="Thread\ThreadPool.cpp" />
<ClCompile Include="Thread\ThreadUtil.cpp" />
<ClCompile Include="Thunk.cpp" />
<ClCompile Include="Timer.cpp" />
<ClCompile Include="TimeUtil.cpp" />
<ClCompile Include="UI\Context.cpp" />
<ClCompile Include="UI\Root.cpp" />
Expand Down
17 changes: 9 additions & 8 deletions Common/Common.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@
<ClInclude Include="CommonTypes.h" />
<ClInclude Include="ConsoleListener.h" />
<ClInclude Include="CPUDetect.h" />
<ClInclude Include="FixedSizeQueue.h" />
<ClInclude Include="Log.h" />
<ClInclude Include="LogManager.h" />
<ClInclude Include="MemArena.h" />
<ClInclude Include="MemoryUtil.h" />
<ClInclude Include="StringUtils.h" />
<ClInclude Include="Thunk.h" />
<ClInclude Include="Timer.h" />
<ClInclude Include="x64Analyzer.h" />
<ClInclude Include="x64Emitter.h" />
<ClInclude Include="ArmEmitter.h" />
<ClInclude Include="ThreadPools.h" />
<ClInclude Include="Crypto\md5.h">
<Filter>Crypto</Filter>
</ClInclude>
Expand All @@ -33,12 +30,10 @@
<ClInclude Include="MipsEmitter.h" />
<ClInclude Include="Arm64Emitter.h" />
<ClInclude Include="ArmCommon.h" />
<ClInclude Include="MathUtil.h" />
<ClInclude Include="BitSet.h" />
<ClInclude Include="CodeBlock.h" />
<ClInclude Include="ColorConv.h" />
<ClInclude Include="ColorConvNEON.h" />
<ClInclude Include="ThreadSafeList.h" />
<ClInclude Include="GL\GLInterface\EGL.h">
<Filter>GL\GLInterface</Filter>
</ClInclude>
Expand All @@ -51,7 +46,6 @@
<ClInclude Include="GraphicsContext.h" />
<ClInclude Include="DbgNew.h" />
<ClInclude Include="OSVersion.h" />
<ClInclude Include="Hashmaps.h" />
<ClInclude Include="BitScan.h" />
<ClInclude Include="MakeUnique.h" />
<ClInclude Include="ExceptionHandlerSetup.h" />
Expand Down Expand Up @@ -372,6 +366,15 @@
<ClInclude Include="Render\Text\draw_text_win.h">
<Filter>Render\Text</Filter>
</ClInclude>
<ClInclude Include="Data\Collections\FixedSizeQueue.h">
<Filter>Data\Collections</Filter>
</ClInclude>
<ClInclude Include="Data\Collections\Hashmaps.h">
<Filter>Data\Collections</Filter>
</ClInclude>
<ClInclude Include="Data\Collections\ThreadSafeList.h">
<Filter>Data\Collections</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="ABI.cpp" />
Expand All @@ -381,12 +384,10 @@
<ClCompile Include="MemoryUtil.cpp" />
<ClCompile Include="StringUtils.cpp" />
<ClCompile Include="Thunk.cpp" />
<ClCompile Include="Timer.cpp" />
<ClCompile Include="x64Analyzer.cpp" />
<ClCompile Include="x64Emitter.cpp" />
<ClCompile Include="ArmEmitter.cpp" />
<ClCompile Include="ArmCPUDetect.cpp" />
<ClCompile Include="ThreadPools.cpp" />
<ClCompile Include="Crypto\md5.cpp">
<Filter>Crypto</Filter>
</ClCompile>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Common/GPU/Vulkan/VulkanQueueRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <cstdint>

#include "Common/Hashmaps.h"
#include "Common/Data/Collections/Hashmaps.h"
#include "Common/GPU/Vulkan/VulkanContext.h"
#include "Common/Data/Convert/SmallDataConvert.h"
#include "Common/Data/Collections/TinySet.h"
Expand Down
4 changes: 2 additions & 2 deletions Common/LogManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "Common/LogManager.h"
#include "Common/ConsoleListener.h"
#include "Common/Timer.h"
#include "Common/TimeUtil.h"
#include "Common/File/FileUtil.h"
#include "Common/StringUtils.h"

Expand Down Expand Up @@ -220,7 +220,7 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const
}

std::lock_guard<std::mutex> lk(log_lock_);
Common::Timer::GetTimeFormatted(message.timestamp);
GetTimeFormatted(message.timestamp);

if (hleCurrentThreadName) {
snprintf(message.header, sizeof(message.header), "%-12.12s %c[%s]: %s:%d",
Expand Down
20 changes: 20 additions & 0 deletions Common/Math/math_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,26 @@ inline T clamp_value(T val, T floor, T cap) {
return val;
}

#define ROUND_UP(x, a) (((x) + (a) - 1) & ~((a) - 1))
#define ROUND_DOWN(x, a) ((x) & ~((a) - 1))

template<class T>
inline void Clamp(T* val, const T& min, const T& max)
{
if (*val < min)
*val = min;
else if (*val > max)
*val = max;
}

template<class T>
inline T Clamp(const T val, const T& min, const T& max)
{
T ret = val;
Clamp(&ret, min, max);
return ret;
}

union FP32 {
uint32_t u;
float f;
Expand Down
30 changes: 0 additions & 30 deletions Common/MathUtil.h

This file was deleted.

41 changes: 34 additions & 7 deletions Common/TimeUtil.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
#include <cstdio>
#include <cstdint>
#include <ctime>

#include "ppsspp_config.h"

#include "Common/TimeUtil.h"

#ifdef HAVE_LIBNX
#include <switch.h>
#endif // HAVE_LIBNX

#ifdef _WIN32
#include <windows.h>
#include "CommonWindows.h"
#include <mmsystem.h>
#include <sys/timeb.h>
#else
#include <sys/time.h>
#include <unistd.h>
#endif

#ifdef HAVE_LIBNX
#include <switch.h>
#endif // HAVE_LIBNX

#include "Common/Log.h"

static double curtime = 0;

#ifdef _WIN32
Expand Down Expand Up @@ -64,3 +67,27 @@ void sleep_ms(int ms) {
usleep(ms * 1000);
#endif
}

// Return the current time formatted as Minutes:Seconds:Milliseconds
// in the form 00:00:000.
void GetTimeFormatted(char formattedTime[13]) {
time_t sysTime;
struct tm * gmTime;
char tmp[13];

time(&sysTime);
gmTime = localtime(&sysTime);

strftime(tmp, 6, "%M:%S", gmTime);

// Now tack on the milliseconds
#ifdef _WIN32
struct timeb tp;
(void)::ftime(&tp);
snprintf(formattedTime, 13, "%s:%03i", tmp, tp.millitm);
#else
struct timeval t;
(void)gettimeofday(&t, NULL);
snprintf(formattedTime, 13, "%s:%03d", tmp, (int)(t.tv_usec / 1000));
#endif
}
2 changes: 2 additions & 0 deletions Common/TimeUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ double time_now_d();

// Sleep. Does not necessarily have millisecond granularity, especially on Windows.
void sleep_ms(int ms);

void GetTimeFormatted(char formattedTime[13]);
Loading

0 comments on commit 9cf2c3e

Please sign in to comment.