mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-05 06:26:49 +00:00
Start porting to GNU compiler
This commit is contained in:
parent
f91bd80bc2
commit
d8bd34b57e
84 changed files with 654 additions and 506 deletions
|
|
@ -297,17 +297,17 @@ template<typename T> struct Stack : public Array<T>
|
|||
|
||||
~Stack()
|
||||
{
|
||||
Clear();
|
||||
Array<T>::Clear();
|
||||
}
|
||||
|
||||
void Push(const T data) { AddCpy(data); }
|
||||
void Push(const T data) { Array<T>::AddCpy(data); }
|
||||
|
||||
T Pop()
|
||||
{
|
||||
const u32 pos = GetCount() - 1;
|
||||
const u32 pos = Array<T>::GetCount() - 1;
|
||||
|
||||
const T ret = Get(pos);
|
||||
RemoveAt(pos);
|
||||
const T ret = Array<T>::Get(pos);
|
||||
Array<T>::RemoveAt(pos);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -498,4 +498,4 @@ public:
|
|||
delete m_ptr;
|
||||
m_ptr = ptr;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,23 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
#include "Utilities/GNU.h"
|
||||
|
||||
template<typename T, int size = sizeof(T)> struct se_t;
|
||||
template<typename T> struct se_t<T, 1> { static __forceinline void func(T& dst, const T src) { (u8&)dst = (u8&)src; } };
|
||||
template<typename T> struct se_t<T, 2> { static __forceinline void func(T& dst, const T src) { (u16&)dst = _byteswap_ushort((u16&)src); } };
|
||||
template<typename T> struct se_t<T, 4> { static __forceinline void func(T& dst, const T src) { (u32&)dst = _byteswap_ulong((u32&)src); } };
|
||||
template<typename T> struct se_t<T, 8> { static __forceinline void func(T& dst, const T src) { (u64&)dst = _byteswap_uint64((u64&)src); } };
|
||||
|
||||
template<typename T, __int64 _value, int size = sizeof(T)> struct const_se_t;;
|
||||
template<typename T, __int64 _value> struct const_se_t<T, _value, 1>
|
||||
template<typename T, s64 _value, int size = sizeof(T)> struct const_se_t;;
|
||||
template<typename T, s64 _value> struct const_se_t<T, _value, 1>
|
||||
{
|
||||
static const T value = (T)_value;
|
||||
};
|
||||
|
||||
template<typename T, __int64 _value> struct const_se_t<T, _value, 2>
|
||||
template<typename T, s64 _value> struct const_se_t<T, _value, 2>
|
||||
{
|
||||
static const T value = ((_value >> 8) & 0xff) | ((_value << 8) & 0xff00);
|
||||
};
|
||||
|
||||
template<typename T, __int64 _value> struct const_se_t<T, _value, 4>
|
||||
template<typename T, s64 _value> struct const_se_t<T, _value, 4>
|
||||
{
|
||||
static const T value =
|
||||
((_value >> 24) & 0x000000ff) |
|
||||
|
|
@ -26,7 +28,7 @@ template<typename T, __int64 _value> struct const_se_t<T, _value, 4>
|
|||
((_value << 24) & 0xff000000);
|
||||
};
|
||||
|
||||
template<typename T, __int64 _value> struct const_se_t<T, _value, 8>
|
||||
template<typename T, s64 _value> struct const_se_t<T, _value, 8>
|
||||
{
|
||||
static const T value =
|
||||
((_value >> 56) & 0x00000000000000ff) |
|
||||
|
|
|
|||
13
Utilities/GNU.h
Normal file
13
Utilities/GNU.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#if defined(__GNUG__)
|
||||
#include <math.h>
|
||||
#define _fpclass(x) fpclassify(x)
|
||||
#define __forceinline __attribute__((always_inline))
|
||||
#define _byteswap_ushort(x) __builtin_bswap16(x)
|
||||
#define _byteswap_ulong(x) __builtin_bswap32(x)
|
||||
#define _byteswap_uint64(x) __builtin_bswap64(x)
|
||||
#define Sleep(x) usleep(x * 1000)
|
||||
#define mkdir(x) mkdir(x, 0777)
|
||||
#define INFINITE 0xFFFFFFFF
|
||||
#endif
|
||||
|
|
@ -133,4 +133,4 @@ public:
|
|||
if(IDToNum(_id) == IDs.GetCount()-1) Cleanup();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -218,4 +218,4 @@ public:
|
|||
if(wait) WaitForExit();
|
||||
}
|
||||
};
|
||||
*/
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,47 +1,38 @@
|
|||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
using namespace std::chrono;
|
||||
|
||||
class Timer
|
||||
{
|
||||
private:
|
||||
bool stopped;
|
||||
double startTimeInMicroSec;
|
||||
double endTimeInMicroSec;
|
||||
LARGE_INTEGER frequency;
|
||||
LARGE_INTEGER startCycle;
|
||||
LARGE_INTEGER endCycle;
|
||||
high_resolution_clock::time_point start;
|
||||
high_resolution_clock::time_point end;
|
||||
|
||||
public:
|
||||
Timer()
|
||||
Timer() : stopped(false)
|
||||
{
|
||||
QueryPerformanceFrequency(&frequency);
|
||||
startCycle.QuadPart = 0;
|
||||
endCycle.QuadPart = 0;
|
||||
stopped = false;
|
||||
startTimeInMicroSec = 0;
|
||||
endTimeInMicroSec = 0;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
stopped = false;
|
||||
QueryPerformanceCounter(&startCycle);
|
||||
start = high_resolution_clock::now();
|
||||
}
|
||||
|
||||
void Stop()
|
||||
{
|
||||
stopped = true;
|
||||
QueryPerformanceCounter(&endCycle);
|
||||
end = high_resolution_clock::now();
|
||||
}
|
||||
|
||||
double GetElapsedTimeInSec(){return GetElapsedTimeInMicroSec() / 1000000.0;}
|
||||
double GetElapsedTimeInMilliSec(){return GetElapsedTimeInMicroSec() / 1000.0;}
|
||||
double GetElapsedTimeInMicroSec()
|
||||
{
|
||||
if(!stopped) QueryPerformanceCounter(&endCycle);
|
||||
|
||||
startTimeInMicroSec = startCycle.QuadPart * (1000000.0 / frequency.QuadPart);
|
||||
endTimeInMicroSec = endCycle.QuadPart * (1000000.0 / frequency.QuadPart);
|
||||
|
||||
return endTimeInMicroSec - startTimeInMicroSec;
|
||||
if (!stopped)
|
||||
end = high_resolution_clock::now();
|
||||
return duration_cast<microseconds>(end - start).count();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue