Merge pull request #3544 from mathieui/common_asterisks

Common: asterisks go against the type name
This commit is contained in:
Pierre Bourdon 2016-01-21 23:10:02 +01:00
commit 338714a3b0
50 changed files with 274 additions and 274 deletions

View File

@ -43,7 +43,7 @@ static bool IsPowerOfTwo(uint64_t x)
#define V8_UINT64_C(x) ((uint64_t)(x)) #define V8_UINT64_C(x) ((uint64_t)(x))
bool IsImmArithmetic(uint64_t input, u32 *val, bool *shift) bool IsImmArithmetic(uint64_t input, u32* val, bool* shift)
{ {
if (input < 4096) if (input < 4096)
{ {
@ -60,7 +60,7 @@ bool IsImmArithmetic(uint64_t input, u32 *val, bool *shift)
return false; return false;
} }
bool IsImmLogical(uint64_t value, unsigned int width, unsigned int *n, unsigned int *imm_s, unsigned int *imm_r) bool IsImmLogical(uint64_t value, unsigned int width, unsigned int* n, unsigned int* imm_s, unsigned int* imm_r)
{ {
//DCHECK((n != NULL) && (imm_s != NULL) && (imm_r != NULL)); //DCHECK((n != NULL) && (imm_s != NULL) && (imm_r != NULL));
// DCHECK((width == kWRegSizeInBits) || (width == kXRegSizeInBits)); // DCHECK((width == kWRegSizeInBits) || (width == kXRegSizeInBits));
@ -1002,7 +1002,7 @@ void ARM64XEmitter::BL(const void* ptr)
EncodeUnconditionalBranchInst(1, ptr); EncodeUnconditionalBranchInst(1, ptr);
} }
void ARM64XEmitter::QuickCallFunction(ARM64Reg scratchreg, const void *func) void ARM64XEmitter::QuickCallFunction(ARM64Reg scratchreg, const void* func)
{ {
s64 distance = (s64)func - (s64)m_code; s64 distance = (s64)func - (s64)m_code;
distance >>= 2; // Can only branch to opcode-aligned (4) addresses distance >>= 2; // Can only branch to opcode-aligned (4) addresses
@ -1097,7 +1097,7 @@ void ARM64XEmitter::_MSR(PStateField field, u8 imm)
EncodeSystemInst(0, op1, 4, imm, op2, WSP); EncodeSystemInst(0, op1, 4, imm, op2, WSP);
} }
static void GetSystemReg(PStateField field, int &o0, int &op1, int &CRn, int &CRm, int &op2) static void GetSystemReg(PStateField field, int& o0, int& op1, int& CRn, int& CRm, int& op2)
{ {
switch (field) switch (field)
{ {
@ -4094,7 +4094,7 @@ float FPImm8ToFloat(uint8_t bits)
return fl; return fl;
} }
bool FPImm8FromFloat(float value, uint8_t *immOut) bool FPImm8FromFloat(float value, uint8_t* immOut)
{ {
uint32_t f; uint32_t f;
memcpy(&f, &value, sizeof(float)); memcpy(&f, &value, sizeof(float));

View File

@ -96,12 +96,12 @@ constexpr ARM64Reg EncodeRegToDouble(ARM64Reg reg) { return static_cast<ARM64Reg
constexpr ARM64Reg EncodeRegToQuad(ARM64Reg reg) { return static_cast<ARM64Reg>(reg | 0xC0); } constexpr ARM64Reg EncodeRegToQuad(ARM64Reg reg) { return static_cast<ARM64Reg>(reg | 0xC0); }
// For AND/TST/ORR/EOR etc // For AND/TST/ORR/EOR etc
bool IsImmLogical(uint64_t value, unsigned int width, unsigned int *n, unsigned int *imm_s, unsigned int *imm_r); bool IsImmLogical(uint64_t value, unsigned int width, unsigned int* n, unsigned int* imm_s, unsigned int* imm_r);
// For ADD/SUB // For ADD/SUB
bool IsImmArithmetic(uint64_t input, u32 *val, bool *shift); bool IsImmArithmetic(uint64_t input, u32* val, bool* shift);
float FPImm8ToFloat(uint8_t bits); float FPImm8ToFloat(uint8_t bits);
bool FPImm8FromFloat(float value, uint8_t *immOut); bool FPImm8FromFloat(float value, uint8_t* immOut);
enum OpType enum OpType
{ {
@ -677,7 +677,7 @@ public:
// Wrapper around MOVZ+MOVK // Wrapper around MOVZ+MOVK
void MOVI2R(ARM64Reg Rd, u64 imm, bool optimize = true); void MOVI2R(ARM64Reg Rd, u64 imm, bool optimize = true);
template <class P> template <class P>
void MOVP2R(ARM64Reg Rd, P *ptr) void MOVP2R(ARM64Reg Rd, P* ptr)
{ {
_assert_msg_(DYNA_REC, Is64Bit(Rd), "Can't store pointers in 32-bit registers"); _assert_msg_(DYNA_REC, Is64Bit(Rd), "Can't store pointers in 32-bit registers");
MOVI2R(Rd, (uintptr_t)ptr); MOVI2R(Rd, (uintptr_t)ptr);
@ -730,10 +730,10 @@ public:
} }
// Plain function call // Plain function call
void QuickCallFunction(ARM64Reg scratchreg, const void *func); void QuickCallFunction(ARM64Reg scratchreg, const void* func);
template <typename T> void QuickCallFunction(ARM64Reg scratchreg, T func) template <typename T> void QuickCallFunction(ARM64Reg scratchreg, T func)
{ {
QuickCallFunction(scratchreg, (const void *)func); QuickCallFunction(scratchreg, (const void*)func);
} }
}; };

View File

@ -188,7 +188,7 @@ void MemChecks::Remove(u32 _Address)
jit->ClearCache(); jit->ClearCache();
} }
TMemCheck *MemChecks::GetMemCheck(u32 address) TMemCheck* MemChecks::GetMemCheck(u32 address)
{ {
for (TMemCheck& bp : m_MemChecks) for (TMemCheck& bp : m_MemChecks)
{ {
@ -207,7 +207,7 @@ TMemCheck *MemChecks::GetMemCheck(u32 address)
return nullptr; return nullptr;
} }
bool TMemCheck::Action(DebugInterface *debug_interface, u32 iValue, u32 addr, bool write, int size, u32 pc) bool TMemCheck::Action(DebugInterface* debug_interface, u32 iValue, u32 addr, bool write, int size, u32 pc)
{ {
if ((write && OnWrite) || (!write && OnRead)) if ((write && OnWrite) || (!write && OnRead))
{ {

View File

@ -41,7 +41,7 @@ struct TMemCheck
u32 numHits; u32 numHits;
// returns whether to break // returns whether to break
bool Action(DebugInterface *dbg_interface, u32 _iValue, u32 addr, bool Action(DebugInterface* dbg_interface, u32 _iValue, u32 addr,
bool write, int size, u32 pc); bool write, int size, u32 pc);
}; };
@ -99,7 +99,7 @@ public:
void Add(const TMemCheck& _rMemoryCheck); void Add(const TMemCheck& _rMemoryCheck);
// memory breakpoint // memory breakpoint
TMemCheck *GetMemCheck(u32 address); TMemCheck* GetMemCheck(u32 address);
void Remove(u32 _Address); void Remove(u32 _Address);
void Clear() { m_MemChecks.clear(); } void Clear() { m_MemChecks.clear(); }

View File

@ -136,7 +136,7 @@ std::vector<std::string> cdio_get_devices()
// checklist: /dev/cdrom, /dev/dvd /dev/hd?, /dev/scd? /dev/sr? // checklist: /dev/cdrom, /dev/dvd /dev/hd?, /dev/scd? /dev/sr?
static struct static struct
{ {
const char * format; const char* format;
unsigned int num_min; unsigned int num_min;
unsigned int num_max; unsigned int num_max;
} checklist[] = } checklist[] =
@ -166,7 +166,7 @@ static bool is_device(const std::string& source_name)
} }
// Check a device to see if it is a DVD/CD-ROM drive // Check a device to see if it is a DVD/CD-ROM drive
static bool is_cdrom(const std::string& drive, char *mnttype) static bool is_cdrom(const std::string& drive, char* mnttype)
{ {
// Check if the device exists // Check if the device exists
if (!is_device(drive)) if (!is_device(drive))
@ -213,7 +213,7 @@ bool cdio_is_cdrom(std::string device)
// Resolve symbolic links. This allows symbolic links to valid // Resolve symbolic links. This allows symbolic links to valid
// drives to be passed from the command line with the -e flag. // drives to be passed from the command line with the -e flag.
char resolved_path[MAX_PATH]; char resolved_path[MAX_PATH];
char *devname = realpath(device.c_str(), resolved_path); char* devname = realpath(device.c_str(), resolved_path);
if (!devname) if (!devname)
return false; return false;
device = devname; device = devname;

View File

@ -311,7 +311,7 @@ private:
} }
__forceinline __forceinline
void DoVoid(void *data, u32 size) void DoVoid(void* data, u32 size)
{ {
switch (mode) switch (mode)
{ {
@ -421,7 +421,7 @@ public:
} }
// Get data // Get data
u8 *ptr = nullptr; u8* ptr = nullptr;
PointerWrap p(&ptr, PointerWrap::MODE_MEASURE); PointerWrap p(&ptr, PointerWrap::MODE_MEASURE);
_class.DoState(p); _class.DoState(p);
size_t const sz = (size_t)ptr; size_t const sz = (size_t)ptr;

View File

@ -21,7 +21,7 @@ private:
virtual void PoisonMemory() = 0; virtual void PoisonMemory() = 0;
protected: protected:
u8 *region; u8* region;
size_t region_size; size_t region_size;
size_t parent_region_size; size_t parent_region_size;
@ -68,7 +68,7 @@ public:
} }
} }
bool IsInSpace(u8 *ptr) const bool IsInSpace(u8* ptr) const
{ {
return (ptr >= region) && (ptr < (region + region_size)); return (ptr >= region) && (ptr < (region + region_size));
} }

View File

@ -74,7 +74,7 @@ void decodeCI8image(u32* dst, u8* src, u16* pal, int width, int height)
{ {
for (int iy = 0; iy < 4; iy++, src += 8) for (int iy = 0; iy < 4; iy++, src += 8)
{ {
u32 *tdst = dst+(y+iy)*width+x; u32* tdst = dst+(y+iy)*width+x;
for (int ix = 0; ix < 8; ix++) for (int ix = 0; ix < 8; ix++)
{ {
// huh, this seems wrong. CI8, not 5A3, no? // huh, this seems wrong. CI8, not 5A3, no?

View File

@ -9,11 +9,11 @@
#include <cstring> #include <cstring>
// Git version number // Git version number
extern const char *scm_desc_str; extern const char* scm_desc_str;
extern const char *scm_branch_str; extern const char* scm_branch_str;
extern const char *scm_rev_str; extern const char* scm_rev_str;
extern const char *scm_rev_git_str; extern const char* scm_rev_git_str;
extern const char *netplay_dolphin_ver; extern const char* netplay_dolphin_ver;
// Force enable logging in the right modes. For some reason, something had changed // Force enable logging in the right modes. For some reason, something had changed
// so that debugfast no longer logged. // so that debugfast no longer logged.

View File

@ -8,17 +8,17 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/Crypto/bn.h" #include "Common/Crypto/bn.h"
static void bn_zero(u8 *d, u32 n) static void bn_zero(u8* d, u32 n)
{ {
memset(d, 0, n); memset(d, 0, n);
} }
static void bn_copy(u8 *d, const u8 *a, u32 n) static void bn_copy(u8* d, const u8* a, u32 n)
{ {
memcpy(d, a, n); memcpy(d, a, n);
} }
int bn_compare(const u8 *a, const u8 *b, u32 n) int bn_compare(const u8* a, const u8* b, u32 n)
{ {
u32 i; u32 i;
@ -32,7 +32,7 @@ int bn_compare(const u8 *a, const u8 *b, u32 n)
return 0; return 0;
} }
void bn_sub_modulus(u8 *a, const u8 *N, u32 n) void bn_sub_modulus(u8* a, const u8* N, u32 n)
{ {
u32 i; u32 i;
u32 dig; u32 dig;
@ -46,7 +46,7 @@ void bn_sub_modulus(u8 *a, const u8 *N, u32 n)
} }
} }
void bn_add(u8 *d, const u8 *a, const u8 *b, const u8 *N, u32 n) void bn_add(u8* d, const u8* a, const u8* b, const u8* N, u32 n)
{ {
u32 i; u32 i;
u32 dig; u32 dig;
@ -66,7 +66,7 @@ void bn_add(u8 *d, const u8 *a, const u8 *b, const u8 *N, u32 n)
bn_sub_modulus(d, N, n); bn_sub_modulus(d, N, n);
} }
void bn_mul(u8 *d, const u8 *a, const u8 *b, const u8 *N, u32 n) void bn_mul(u8* d, const u8* a, const u8* b, const u8* N, u32 n)
{ {
u32 i; u32 i;
u8 mask; u8 mask;
@ -81,7 +81,7 @@ void bn_mul(u8 *d, const u8 *a, const u8 *b, const u8 *N, u32 n)
} }
} }
void bn_exp(u8 *d, const u8 *a, const u8 *N, u32 n, const u8 *e, u32 en) void bn_exp(u8* d, const u8* a, const u8* N, u32 n, const u8* e, u32 en)
{ {
u8 t[512]; u8 t[512];
u32 i; u32 i;
@ -100,7 +100,7 @@ void bn_exp(u8 *d, const u8 *a, const u8 *N, u32 n, const u8 *e, u32 en)
} }
// only for prime N -- stupid but lazy, see if I care // only for prime N -- stupid but lazy, see if I care
void bn_inv(u8 *d, const u8 *a, const u8 *N, u32 n) void bn_inv(u8* d, const u8* a, const u8* N, u32 n)
{ {
u8 t[512], s[512]; u8 t[512], s[512];

View File

@ -8,9 +8,9 @@
// bignum arithmetic // bignum arithmetic
int bn_compare(const u8 *a, const u8 *b, u32 n); int bn_compare(const u8* a, const u8* b, u32 n);
void bn_sub_modulus(u8 *a, const u8 *N, u32 n); void bn_sub_modulus(u8* a, const u8* N, u32 n);
void bn_add(u8 *d, const u8 *a, const u8 *b, const u8 *N, u32 n); void bn_add(u8* d, const u8* a, const u8* b, const u8* N, u32 n);
void bn_mul(u8 *d, const u8 *a, const u8 *b, const u8 *N, u32 n); void bn_mul(u8* d, const u8* a, const u8* b, const u8* N, u32 n);
void bn_inv(u8 *d, const u8 *a, const u8 *N, u32 n); // only for prime N void bn_inv(u8* d, const u8* a, const u8* N, u32 n); // only for prime N
void bn_exp(u8 *d, const u8 *a, const u8 *N, u32 n, const u8 *e, u32 en); void bn_exp(u8* d, const u8* a, const u8* N, u32 n, const u8* e, u32 en);

View File

@ -32,17 +32,17 @@ static const u8 ec_G[60] =
,0x01,0x00,0x6a,0x08,0xa4,0x19,0x03,0x35,0x06,0x78,0xe5,0x85,0x28,0xbe,0xbf ,0x01,0x00,0x6a,0x08,0xa4,0x19,0x03,0x35,0x06,0x78,0xe5,0x85,0x28,0xbe,0xbf
,0x8a,0x0b,0xef,0xf8,0x67,0xa7,0xca,0x36,0x71,0x6f,0x7e,0x01,0xf8,0x10,0x52}; ,0x8a,0x0b,0xef,0xf8,0x67,0xa7,0xca,0x36,0x71,0x6f,0x7e,0x01,0xf8,0x10,0x52};
static void elt_copy(u8 *d, const u8 *a) static void elt_copy(u8* d, const u8* a)
{ {
memcpy(d, a, 30); memcpy(d, a, 30);
} }
static void elt_zero(u8 *d) static void elt_zero(u8* d)
{ {
memset(d, 0, 30); memset(d, 0, 30);
} }
static int elt_is_zero(const u8 *d) static int elt_is_zero(const u8* d)
{ {
u32 i; u32 i;
@ -53,7 +53,7 @@ static int elt_is_zero(const u8 *d)
return 1; return 1;
} }
static void elt_add(u8 *d, const u8 *a, const u8 *b) static void elt_add(u8* d, const u8* a, const u8* b)
{ {
u32 i; u32 i;
@ -61,7 +61,7 @@ static void elt_add(u8 *d, const u8 *a, const u8 *b)
d[i] = a[i] ^ b[i]; d[i] = a[i] ^ b[i];
} }
static void elt_mul_x(u8 *d, const u8 *a) static void elt_mul_x(u8* d, const u8* a)
{ {
u8 carry, x, y; u8 carry, x, y;
u32 i; u32 i;
@ -79,7 +79,7 @@ static void elt_mul_x(u8 *d, const u8 *a)
d[20] ^= carry << 2; d[20] ^= carry << 2;
} }
static void elt_mul(u8 *d, const u8 *a, const u8 *b) static void elt_mul(u8* d, const u8* a, const u8* b)
{ {
u32 i, n; u32 i, n;
u8 mask; u8 mask;
@ -105,7 +105,7 @@ static void elt_mul(u8 *d, const u8 *a, const u8 *b)
static const u8 square[16] = static const u8 square[16] =
{0x00,0x01,0x04,0x05,0x10,0x11,0x14,0x15,0x40,0x41,0x44,0x45,0x50,0x51,0x54,0x55}; {0x00,0x01,0x04,0x05,0x10,0x11,0x14,0x15,0x40,0x41,0x44,0x45,0x50,0x51,0x54,0x55};
static void elt_square_to_wide(u8 *d, const u8 *a) static void elt_square_to_wide(u8* d, const u8* a)
{ {
u32 i; u32 i;
@ -115,7 +115,7 @@ static void elt_square_to_wide(u8 *d, const u8 *a)
} }
} }
static void wide_reduce(u8 *d) static void wide_reduce(u8* d)
{ {
u32 i; u32 i;
u8 x; u8 x;
@ -140,7 +140,7 @@ static void wide_reduce(u8 *d)
d[30] &= 1; d[30] &= 1;
} }
static void elt_square(u8 *d, const u8 *a) static void elt_square(u8* d, const u8* a)
{ {
u8 wide[60]; u8 wide[60];
@ -150,7 +150,7 @@ static void elt_square(u8 *d, const u8 *a)
elt_copy(d, wide + 30); elt_copy(d, wide + 30);
} }
static void itoh_tsujii(u8 *d, const u8 *a, const u8 *b, u32 j) static void itoh_tsujii(u8* d, const u8* a, const u8* b, u32 j)
{ {
u8 t[30]; u8 t[30];
@ -163,7 +163,7 @@ static void itoh_tsujii(u8 *d, const u8 *a, const u8 *b, u32 j)
elt_mul(d, t, b); elt_mul(d, t, b);
} }
static void elt_inv(u8 *d, const u8 *a) static void elt_inv(u8* d, const u8* a)
{ {
u8 t[30]; u8 t[30];
u8 s[30]; u8 s[30];
@ -181,10 +181,10 @@ static void elt_inv(u8 *d, const u8 *a)
elt_square(d, s); elt_square(d, s);
} }
UNUSED static int point_is_on_curve(u8 *p) UNUSED static int point_is_on_curve(u8* p)
{ {
u8 s[30], t[30]; u8 s[30], t[30];
u8 *x, *y; u8* x, *y;
x = p; x = p;
y = p + 30; y = p + 30;
@ -205,16 +205,16 @@ UNUSED static int point_is_on_curve(u8 *p)
return elt_is_zero(s); return elt_is_zero(s);
} }
static int point_is_zero(const u8 *p) static int point_is_zero(const u8* p)
{ {
return elt_is_zero(p) && elt_is_zero(p + 30); return elt_is_zero(p) && elt_is_zero(p + 30);
} }
static void point_double(u8 *r, const u8 *p) static void point_double(u8* r, const u8* p)
{ {
u8 s[30], t[30]; u8 s[30], t[30];
const u8 *px, *py; const u8* px, *py;
u8 *rx, *ry; u8* rx, *ry;
px = p; px = p;
py = p + 30; py = p + 30;
@ -243,11 +243,11 @@ static void point_double(u8 *r, const u8 *p)
elt_add(ry, ry, t); elt_add(ry, ry, t);
} }
static void point_add(u8 *r, const u8 *p, const u8 *q) static void point_add(u8* r, const u8* p, const u8* q)
{ {
u8 s[30], t[30], u[30]; u8 s[30], t[30], u[30];
const u8 *px, *py, *qx, *qy; const u8* px, *py, *qx, *qy;
u8 *rx, *ry; u8* rx, *ry;
px = p; px = p;
py = p + 30; py = p + 30;
@ -297,7 +297,7 @@ static void point_add(u8 *r, const u8 *p, const u8 *q)
elt_add(ry, s, rx); elt_add(ry, s, rx);
} }
static void point_mul(u8 *d, const u8 *a, const u8 *b) // a is bignum static void point_mul(u8* d, const u8* a, const u8* b) // a is bignum
{ {
u32 i; u32 i;
u8 mask; u8 mask;
@ -324,7 +324,7 @@ static void silly_random(u8 * rndArea, u8 count)
} }
} }
void generate_ecdsa(u8 *R, u8 *S, const u8 *k, const u8 *hash) void generate_ecdsa(u8* R, u8* S, const u8* k, const u8* hash)
{ {
u8 e[30]; u8 e[30];
u8 kk[30]; u8 kk[30];
@ -362,7 +362,7 @@ void generate_ecdsa(u8 *R, u8 *S, const u8 *k, const u8 *hash)
bn_mul(S, minv, kk, ec_N, 30); bn_mul(S, minv, kk, ec_N, 30);
} }
UNUSED static int check_ecdsa(u8 *Q, u8 *R, u8 *S, const u8 *hash) UNUSED static int check_ecdsa(u8* Q, u8* R, u8* S, const u8* hash)
{ {
u8 Sinv[30]; u8 Sinv[30];
u8 e[30]; u8 e[30];
@ -388,7 +388,7 @@ UNUSED static int check_ecdsa(u8 *Q, u8 *R, u8 *S, const u8 *hash)
return (bn_compare(r1, R, 30) == 0); return (bn_compare(r1, R, 30) == 0);
} }
void ec_priv_to_pub(const u8 *k, u8 *Q) void ec_priv_to_pub(const u8* k, u8* Q)
{ {
point_mul(Q, k, ec_G); point_mul(Q, k, ec_G);
} }

View File

@ -6,6 +6,6 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
void generate_ecdsa(u8 *R, u8 *S, const u8 *k, const u8 *hash); void generate_ecdsa(u8* R, u8* S, const u8* k, const u8* hash);
void ec_priv_to_pub(const u8 *k, u8 *Q); void ec_priv_to_pub(const u8* k, u8* Q);

View File

@ -14,7 +14,7 @@ protected:
public: public:
virtual std::string Disassemble(unsigned int /*address*/) { return "NODEBUGGER"; } virtual std::string Disassemble(unsigned int /*address*/) { return "NODEBUGGER"; }
virtual void GetRawMemoryString(int /*memory*/, unsigned int /*address*/, char *dest, int /*max_size*/) {strcpy(dest, "NODEBUGGER");} virtual void GetRawMemoryString(int /*memory*/, unsigned int /*address*/, char* dest, int /*max_size*/) {strcpy(dest, "NODEBUGGER");}
virtual int GetInstructionSize(int /*instruction*/) {return 1;} virtual int GetInstructionSize(int /*instruction*/) {return 1;}
virtual bool IsAlive() {return true;} virtual bool IsAlive() {return true;}
virtual bool IsBreakpoint(unsigned int /*address*/) {return false;} virtual bool IsBreakpoint(unsigned int /*address*/) {return false;}

View File

@ -65,7 +65,7 @@ public:
{ {
if (NeedSize) if (NeedSize)
m_size--; m_size--;
ElementPtr *tmpptr = m_read_ptr; ElementPtr* tmpptr = m_read_ptr;
// advance the read pointer // advance the read pointer
m_read_ptr = tmpptr->next.load(); m_read_ptr = tmpptr->next.load();
// set the next element to nullptr to stop the recursive deletion // set the next element to nullptr to stop the recursive deletion
@ -81,7 +81,7 @@ public:
if (NeedSize) if (NeedSize)
m_size--; m_size--;
ElementPtr *tmpptr = m_read_ptr; ElementPtr* tmpptr = m_read_ptr;
m_read_ptr = tmpptr->next.load(std::memory_order_acquire); m_read_ptr = tmpptr->next.load(std::memory_order_acquire);
t = std::move(tmpptr->current); t = std::move(tmpptr->current);
tmpptr->next.store(nullptr); tmpptr->next.store(nullptr);
@ -117,8 +117,8 @@ private:
std::atomic<ElementPtr*> next; std::atomic<ElementPtr*> next;
}; };
ElementPtr *m_write_ptr; ElementPtr* m_write_ptr;
ElementPtr *m_read_ptr; ElementPtr* m_read_ptr;
std::atomic<u32> m_size; std::atomic<u32> m_size;
}; };

View File

@ -58,7 +58,7 @@ namespace File
// Remove any ending forward slashes from directory paths // Remove any ending forward slashes from directory paths
// Modifies argument. // Modifies argument.
static void StripTailDirSlashes(std::string &fname) static void StripTailDirSlashes(std::string& fname)
{ {
if (fname.length() > 1) if (fname.length() > 1)
{ {
@ -68,7 +68,7 @@ static void StripTailDirSlashes(std::string &fname)
} }
// Returns true if file filename exists // Returns true if file filename exists
bool Exists(const std::string &filename) bool Exists(const std::string& filename)
{ {
struct stat64 file_info; struct stat64 file_info;
@ -85,7 +85,7 @@ bool Exists(const std::string &filename)
} }
// Returns true if filename is a directory // Returns true if filename is a directory
bool IsDirectory(const std::string &filename) bool IsDirectory(const std::string& filename)
{ {
struct stat64 file_info; struct stat64 file_info;
@ -110,7 +110,7 @@ bool IsDirectory(const std::string &filename)
// Deletes a given filename, return true on success // Deletes a given filename, return true on success
// Doesn't supports deleting a directory // Doesn't supports deleting a directory
bool Delete(const std::string &filename) bool Delete(const std::string& filename)
{ {
INFO_LOG(COMMON, "Delete: file %s", filename.c_str()); INFO_LOG(COMMON, "Delete: file %s", filename.c_str());
@ -149,7 +149,7 @@ bool Delete(const std::string &filename)
} }
// Returns true if successful, or path already exists. // Returns true if successful, or path already exists.
bool CreateDir(const std::string &path) bool CreateDir(const std::string& path)
{ {
INFO_LOG(COMMON, "CreateDir: directory %s", path.c_str()); INFO_LOG(COMMON, "CreateDir: directory %s", path.c_str());
#ifdef _WIN32 #ifdef _WIN32
@ -181,7 +181,7 @@ bool CreateDir(const std::string &path)
} }
// Creates the full path of fullPath returns true on success // Creates the full path of fullPath returns true on success
bool CreateFullPath(const std::string &fullPath) bool CreateFullPath(const std::string& fullPath)
{ {
int panicCounter = 100; int panicCounter = 100;
INFO_LOG(COMMON, "CreateFullPath: path %s", fullPath.c_str()); INFO_LOG(COMMON, "CreateFullPath: path %s", fullPath.c_str());
@ -220,7 +220,7 @@ bool CreateFullPath(const std::string &fullPath)
// Deletes a directory filename, returns true on success // Deletes a directory filename, returns true on success
bool DeleteDir(const std::string &filename) bool DeleteDir(const std::string& filename)
{ {
INFO_LOG(COMMON, "DeleteDir: directory %s", filename.c_str()); INFO_LOG(COMMON, "DeleteDir: directory %s", filename.c_str());
@ -244,7 +244,7 @@ bool DeleteDir(const std::string &filename)
} }
// renames file srcFilename to destFilename, returns true on success // renames file srcFilename to destFilename, returns true on success
bool Rename(const std::string &srcFilename, const std::string &destFilename) bool Rename(const std::string& srcFilename, const std::string& destFilename)
{ {
INFO_LOG(COMMON, "Rename: %s --> %s", INFO_LOG(COMMON, "Rename: %s --> %s",
srcFilename.c_str(), destFilename.c_str()); srcFilename.c_str(), destFilename.c_str());
@ -271,7 +271,7 @@ bool Rename(const std::string &srcFilename, const std::string &destFilename)
} }
#ifndef _WIN32 #ifndef _WIN32
static void FSyncPath(const char *path) static void FSyncPath(const char* path)
{ {
int fd = open(path, O_RDONLY); int fd = open(path, O_RDONLY);
if (fd != -1) if (fd != -1)
@ -282,7 +282,7 @@ static void FSyncPath(const char *path)
} }
#endif #endif
bool RenameSync(const std::string &srcFilename, const std::string &destFilename) bool RenameSync(const std::string& srcFilename, const std::string& destFilename)
{ {
if (!Rename(srcFilename, destFilename)) if (!Rename(srcFilename, destFilename))
return false; return false;
@ -294,7 +294,7 @@ bool RenameSync(const std::string &srcFilename, const std::string &destFilename)
close(fd); close(fd);
} }
#else #else
char *path = strdup(srcFilename.c_str()); char* path = strdup(srcFilename.c_str());
FSyncPath(path); FSyncPath(path);
FSyncPath(dirname(path)); FSyncPath(dirname(path));
free(path); free(path);
@ -306,7 +306,7 @@ bool RenameSync(const std::string &srcFilename, const std::string &destFilename)
} }
// copies file srcFilename to destFilename, returns true on success // copies file srcFilename to destFilename, returns true on success
bool Copy(const std::string &srcFilename, const std::string &destFilename) bool Copy(const std::string& srcFilename, const std::string& destFilename)
{ {
INFO_LOG(COMMON, "Copy: %s --> %s", INFO_LOG(COMMON, "Copy: %s --> %s",
srcFilename.c_str(), destFilename.c_str()); srcFilename.c_str(), destFilename.c_str());
@ -372,7 +372,7 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
} }
// Returns the size of filename (64bit) // Returns the size of filename (64bit)
u64 GetSize(const std::string &filename) u64 GetSize(const std::string& filename)
{ {
if (!Exists(filename)) if (!Exists(filename))
{ {
@ -417,7 +417,7 @@ u64 GetSize(const int fd)
} }
// Overloaded GetSize, accepts FILE* // Overloaded GetSize, accepts FILE*
u64 GetSize(FILE *f) u64 GetSize(FILE* f)
{ {
// can't use off_t here because it can be 32-bit // can't use off_t here because it can be 32-bit
u64 pos = ftello(f); u64 pos = ftello(f);
@ -440,7 +440,7 @@ u64 GetSize(FILE *f)
} }
// creates an empty file filename, returns true on success // creates an empty file filename, returns true on success
bool CreateEmptyFile(const std::string &filename) bool CreateEmptyFile(const std::string& filename)
{ {
INFO_LOG(COMMON, "CreateEmptyFile: %s", filename.c_str()); INFO_LOG(COMMON, "CreateEmptyFile: %s", filename.c_str());
@ -457,7 +457,7 @@ bool CreateEmptyFile(const std::string &filename)
// Scans the directory tree gets, starting from _Directory and adds the // Scans the directory tree gets, starting from _Directory and adds the
// results into parentEntry. Returns the number of files+directories found // results into parentEntry. Returns the number of files+directories found
FSTEntry ScanDirectoryTree(const std::string &directory, bool recursive) FSTEntry ScanDirectoryTree(const std::string& directory, bool recursive)
{ {
INFO_LOG(COMMON, "ScanDirectoryTree: directory %s", directory.c_str()); INFO_LOG(COMMON, "ScanDirectoryTree: directory %s", directory.c_str());
// How many files + directories we found // How many files + directories we found
@ -482,7 +482,7 @@ FSTEntry ScanDirectoryTree(const std::string &directory, bool recursive)
#else #else
struct dirent dirent, *result = nullptr; struct dirent dirent, *result = nullptr;
DIR *dirp = opendir(directory.c_str()); DIR* dirp = opendir(directory.c_str());
if (!dirp) if (!dirp)
return parent_entry; return parent_entry;
@ -527,7 +527,7 @@ FSTEntry ScanDirectoryTree(const std::string &directory, bool recursive)
// Deletes the given directory and anything under it. Returns true on success. // Deletes the given directory and anything under it. Returns true on success.
bool DeleteDirRecursively(const std::string &directory) bool DeleteDirRecursively(const std::string& directory)
{ {
INFO_LOG(COMMON, "DeleteDirRecursively: %s", directory.c_str()); INFO_LOG(COMMON, "DeleteDirRecursively: %s", directory.c_str());
#ifdef _WIN32 #ifdef _WIN32
@ -547,7 +547,7 @@ bool DeleteDirRecursively(const std::string &directory)
const std::string virtualName(TStrToUTF8(ffd.cFileName)); const std::string virtualName(TStrToUTF8(ffd.cFileName));
#else #else
struct dirent dirent, *result = nullptr; struct dirent dirent, *result = nullptr;
DIR *dirp = opendir(directory.c_str()); DIR* dirp = opendir(directory.c_str());
if (!dirp) if (!dirp)
return false; return false;
@ -600,7 +600,7 @@ bool DeleteDirRecursively(const std::string &directory)
} }
// Create directory and copy contents (does not overwrite existing files) // Create directory and copy contents (does not overwrite existing files)
void CopyDir(const std::string &source_path, const std::string &dest_path) void CopyDir(const std::string& source_path, const std::string& dest_path)
{ {
if (source_path == dest_path) return; if (source_path == dest_path) return;
if (!File::Exists(source_path)) return; if (!File::Exists(source_path)) return;
@ -621,7 +621,7 @@ void CopyDir(const std::string &source_path, const std::string &dest_path)
const std::string virtualName(TStrToUTF8(ffd.cFileName)); const std::string virtualName(TStrToUTF8(ffd.cFileName));
#else #else
struct dirent dirent, *result = nullptr; struct dirent dirent, *result = nullptr;
DIR *dirp = opendir(source_path.c_str()); DIR* dirp = opendir(source_path.c_str());
if (!dirp) return; if (!dirp) return;
while (!readdir_r(dirp, &dirent, &result) && result) while (!readdir_r(dirp, &dirent, &result) && result)
@ -652,7 +652,7 @@ void CopyDir(const std::string &source_path, const std::string &dest_path)
// Returns the current directory // Returns the current directory
std::string GetCurrentDir() std::string GetCurrentDir()
{ {
char *dir; char* dir;
// Get the current working directory (getcwd uses malloc) // Get the current working directory (getcwd uses malloc)
if (!(dir = __getcwd(nullptr, 0))) if (!(dir = __getcwd(nullptr, 0)))
{ {
@ -666,7 +666,7 @@ std::string GetCurrentDir()
} }
// Sets the current directory to the given directory // Sets the current directory to the given directory
bool SetCurrentDir(const std::string &directory) bool SetCurrentDir(const std::string& directory)
{ {
return __chdir(directory.c_str()) == 0; return __chdir(directory.c_str()) == 0;
} }
@ -697,7 +697,7 @@ std::string CreateTempDir()
#endif #endif
} }
std::string GetTempFilenameForAtomicWrite(const std::string &path) std::string GetTempFilenameForAtomicWrite(const std::string& path)
{ {
std::string abs = path; std::string abs = path;
#ifdef _WIN32 #ifdef _WIN32
@ -883,12 +883,12 @@ std::string GetThemeDir(const std::string& theme_name)
return dir; return dir;
} }
bool WriteStringToFile(const std::string &str, const std::string& filename) bool WriteStringToFile(const std::string& str, const std::string& filename)
{ {
return File::IOFile(filename, "wb").WriteBytes(str.data(), str.size()); return File::IOFile(filename, "wb").WriteBytes(str.data(), str.size());
} }
bool ReadFileToString(const std::string& filename, std::string &str) bool ReadFileToString(const std::string& filename, std::string& str)
{ {
File::IOFile file(filename, "rb"); File::IOFile file(filename, "rb");
auto const f = file.GetHandle(); auto const f = file.GetHandle();

View File

@ -70,65 +70,65 @@ struct FSTEntry
}; };
// Returns true if file filename exists // Returns true if file filename exists
bool Exists(const std::string &filename); bool Exists(const std::string& filename);
// Returns true if filename is a directory // Returns true if filename is a directory
bool IsDirectory(const std::string &filename); bool IsDirectory(const std::string& filename);
// Returns the size of filename (64bit) // Returns the size of filename (64bit)
u64 GetSize(const std::string &filename); u64 GetSize(const std::string& filename);
// Overloaded GetSize, accepts file descriptor // Overloaded GetSize, accepts file descriptor
u64 GetSize(const int fd); u64 GetSize(const int fd);
// Overloaded GetSize, accepts FILE* // Overloaded GetSize, accepts FILE*
u64 GetSize(FILE *f); u64 GetSize(FILE* f);
// Returns true if successful, or path already exists. // Returns true if successful, or path already exists.
bool CreateDir(const std::string &filename); bool CreateDir(const std::string& filename);
// Creates the full path of fullPath returns true on success // Creates the full path of fullPath returns true on success
bool CreateFullPath(const std::string &fullPath); bool CreateFullPath(const std::string& fullPath);
// Deletes a given filename, return true on success // Deletes a given filename, return true on success
// Doesn't supports deleting a directory // Doesn't supports deleting a directory
bool Delete(const std::string &filename); bool Delete(const std::string& filename);
// Deletes a directory filename, returns true on success // Deletes a directory filename, returns true on success
bool DeleteDir(const std::string &filename); bool DeleteDir(const std::string& filename);
// renames file srcFilename to destFilename, returns true on success // renames file srcFilename to destFilename, returns true on success
bool Rename(const std::string &srcFilename, const std::string &destFilename); bool Rename(const std::string& srcFilename, const std::string& destFilename);
// ditto, but syncs the source file and, on Unix, syncs the directories after rename // ditto, but syncs the source file and, on Unix, syncs the directories after rename
bool RenameSync(const std::string &srcFilename, const std::string &destFilename); bool RenameSync(const std::string& srcFilename, const std::string& destFilename);
// copies file srcFilename to destFilename, returns true on success // copies file srcFilename to destFilename, returns true on success
bool Copy(const std::string &srcFilename, const std::string &destFilename); bool Copy(const std::string& srcFilename, const std::string& destFilename);
// creates an empty file filename, returns true on success // creates an empty file filename, returns true on success
bool CreateEmptyFile(const std::string &filename); bool CreateEmptyFile(const std::string& filename);
// Recursive or non-recursive list of files under directory. // Recursive or non-recursive list of files under directory.
FSTEntry ScanDirectoryTree(const std::string &directory, bool recursive); FSTEntry ScanDirectoryTree(const std::string& directory, bool recursive);
// deletes the given directory and anything under it. Returns true on success. // deletes the given directory and anything under it. Returns true on success.
bool DeleteDirRecursively(const std::string &directory); bool DeleteDirRecursively(const std::string& directory);
// Returns the current directory // Returns the current directory
std::string GetCurrentDir(); std::string GetCurrentDir();
// Create directory and copy contents (does not overwrite existing files) // Create directory and copy contents (does not overwrite existing files)
void CopyDir(const std::string &source_path, const std::string &dest_path); void CopyDir(const std::string& source_path, const std::string& dest_path);
// Set the current directory to given directory // Set the current directory to given directory
bool SetCurrentDir(const std::string &directory); bool SetCurrentDir(const std::string& directory);
// Creates and returns the path to a new temporary directory. // Creates and returns the path to a new temporary directory.
std::string CreateTempDir(); std::string CreateTempDir();
// Get a filename that can hopefully be atomically renamed to the given path. // Get a filename that can hopefully be atomically renamed to the given path.
std::string GetTempFilenameForAtomicWrite(const std::string &path); std::string GetTempFilenameForAtomicWrite(const std::string& path);
// Gets a set user directory path // Gets a set user directory path
// Don't call prior to setting the base user directory // Don't call prior to setting the base user directory
@ -148,7 +148,7 @@ std::string GetSysDirectory();
std::string GetBundleDirectory(); std::string GetBundleDirectory();
#endif #endif
std::string &GetExeDirectory(); std::string& GetExeDirectory();
bool WriteStringToFile(const std::string& str, const std::string& filename); bool WriteStringToFile(const std::string& str, const std::string& filename);
bool ReadFileToString(const std::string& filename, std::string& str); bool ReadFileToString(const std::string& filename, std::string& str);

View File

@ -16,13 +16,13 @@
template <class T, int N> template <class T, int N>
class FixedSizeQueue class FixedSizeQueue
{ {
T *storage; T* storage;
int head; int head;
int tail; int tail;
int count; // sacrifice 4 bytes for a simpler implementation. may optimize away in the future. int count; // sacrifice 4 bytes for a simpler implementation. may optimize away in the future.
// Make copy constructor private for now. // Make copy constructor private for now.
FixedSizeQueue(FixedSizeQueue &other) {} FixedSizeQueue(FixedSizeQueue& other) {}
public: public:
FixedSizeQueue() FixedSizeQueue()
@ -62,13 +62,13 @@ public:
T pop_front() T pop_front()
{ {
const T &temp = storage[head]; const T& temp = storage[head];
pop(); pop();
return temp; return temp;
} }
T &front() { return storage[head]; } T& front() { return storage[head]; }
const T &front() const { return storage[head]; } const T& front() const { return storage[head]; }
size_t size() const size_t size() const
{ {

View File

@ -9,7 +9,7 @@
#include "Common/Hash.h" #include "Common/Hash.h"
#include "Common/Intrinsics.h" #include "Common/Intrinsics.h"
static u64 (*ptrHashFunction)(const u8 *src, u32 len, u32 samples) = &GetMurmurHash3; static u64 (*ptrHashFunction)(const u8* src, u32 len, u32 samples) = &GetMurmurHash3;
// uint32_t // uint32_t
// WARNING - may read one more byte! // WARNING - may read one more byte!
@ -104,7 +104,7 @@ u32 HashEctor(const u8* ptr, int length)
// Block read - if your platform needs to do endian-swapping or can only // Block read - if your platform needs to do endian-swapping or can only
// handle aligned reads, do the conversion here // handle aligned reads, do the conversion here
inline u64 getblock(const u64 * p, int i) inline u64 getblock(const u64* p, int i)
{ {
return p[i]; return p[i];
} }
@ -149,9 +149,9 @@ inline u64 fmix64(u64 k)
return k; return k;
} }
u64 GetMurmurHash3(const u8 *src, u32 len, u32 samples) u64 GetMurmurHash3(const u8* src, u32 len, u32 samples)
{ {
const u8 * data = (const u8*)src; const u8* data = (const u8*)src;
const int nblocks = len / 16; const int nblocks = len / 16;
u32 Step = (len / 8); u32 Step = (len / 8);
if (samples == 0) if (samples == 0)
@ -170,7 +170,7 @@ u64 GetMurmurHash3(const u8 *src, u32 len, u32 samples)
//---------- //----------
// body // body
const u64 * blocks = (const u64 *)(data); const u64* blocks = (const u64*)(data);
for (int i = 0; i < nblocks; i+=Step) for (int i = 0; i < nblocks; i+=Step)
{ {
@ -183,7 +183,7 @@ u64 GetMurmurHash3(const u8 *src, u32 len, u32 samples)
//---------- //----------
// tail // tail
const u8 * tail = (const u8*)(data + nblocks*16); const u8* tail = (const u8*)(data + nblocks*16);
u64 k1 = 0; u64 k1 = 0;
u64 k2 = 0; u64 k2 = 0;
@ -227,13 +227,13 @@ u64 GetMurmurHash3(const u8 *src, u32 len, u32 samples)
// CRC32 hash using the SSE4.2 instruction // CRC32 hash using the SSE4.2 instruction
u64 GetCRC32(const u8 *src, u32 len, u32 samples) u64 GetCRC32(const u8* src, u32 len, u32 samples)
{ {
#if _M_SSE >= 0x402 || defined(_M_ARM_64) #if _M_SSE >= 0x402 || defined(_M_ARM_64)
u64 h[4] = { len, 0, 0, 0 }; u64 h[4] = { len, 0, 0, 0 };
u32 Step = (len / 8); u32 Step = (len / 8);
const u64 *data = (const u64 *)src; const u64* data = (const u64*)src;
const u64 *end = data + Step; const u64* end = data + Step;
if (samples == 0) if (samples == 0)
samples = std::max(Step, 1u); samples = std::max(Step, 1u);
Step = Step / samples; Step = Step / samples;
@ -333,14 +333,14 @@ u64 GetCRC32(const u8 *src, u32 len, u32 samples)
* changed, make sure this one is still used when the legacy parameter is * changed, make sure this one is still used when the legacy parameter is
* true. * true.
*/ */
u64 GetHashHiresTexture(const u8 *src, u32 len, u32 samples) u64 GetHashHiresTexture(const u8* src, u32 len, u32 samples)
{ {
const u64 m = 0xc6a4a7935bd1e995; const u64 m = 0xc6a4a7935bd1e995;
u64 h = len * m; u64 h = len * m;
const int r = 47; const int r = 47;
u32 Step = (len / 8); u32 Step = (len / 8);
const u64 *data = (const u64 *)src; const u64* data = (const u64*)src;
const u64 *end = data + Step; const u64* end = data + Step;
if (samples == 0) if (samples == 0)
samples = std::max(Step, 1u); samples = std::max(Step, 1u);
Step = Step / samples; Step = Step / samples;
@ -379,13 +379,13 @@ u64 GetHashHiresTexture(const u8 *src, u32 len, u32 samples)
} }
#else #else
// CRC32 hash using the SSE4.2 instruction // CRC32 hash using the SSE4.2 instruction
u64 GetCRC32(const u8 *src, u32 len, u32 samples) u64 GetCRC32(const u8* src, u32 len, u32 samples)
{ {
#if _M_SSE >= 0x402 #if _M_SSE >= 0x402
u32 h = len; u32 h = len;
u32 Step = (len/4); u32 Step = (len/4);
const u32 *data = (const u32 *)src; const u32* data = (const u32 *)src;
const u32 *end = data + Step; const u32* end = data + Step;
if (samples == 0) if (samples == 0)
samples = std::max(Step, 1u); samples = std::max(Step, 1u);
Step = Step / samples; Step = Step / samples;
@ -397,7 +397,7 @@ u64 GetCRC32(const u8 *src, u32 len, u32 samples)
data += Step; data += Step;
} }
const u8 *data2 = (const u8*)end; const u8* data2 = (const u8*)end;
return (u64)_mm_crc32_u32(h, u32(data2[0])); return (u64)_mm_crc32_u32(h, u32(data2[0]));
#else #else
return 0; return 0;
@ -408,7 +408,7 @@ u64 GetCRC32(const u8 *src, u32 len, u32 samples)
// Block read - if your platform needs to do endian-swapping or can only // Block read - if your platform needs to do endian-swapping or can only
// handle aligned reads, do the conversion here // handle aligned reads, do the conversion here
inline u32 getblock(const u32 * p, int i) inline u32 getblock(const u32* p, int i)
{ {
return p[i]; return p[i];
} }
@ -456,7 +456,7 @@ inline void bmix32(u32 & h1, u32 & h2, u32 & k1, u32 & k2, u32 & c1, u32 & c2)
u64 GetMurmurHash3(const u8* src, u32 len, u32 samples) u64 GetMurmurHash3(const u8* src, u32 len, u32 samples)
{ {
const u8 * data = (const u8*)src; const u8* data = (const u8*)src;
u32 out[2]; u32 out[2];
const int nblocks = len / 8; const int nblocks = len / 8;
u32 Step = (len / 4); u32 Step = (len / 4);
@ -475,7 +475,7 @@ u64 GetMurmurHash3(const u8* src, u32 len, u32 samples)
//---------- //----------
// body // body
const u32 * blocks = (const u32 *)(data + nblocks*8); const u32* blocks = (const u32*)(data + nblocks*8);
for (int i = -nblocks; i < 0; i+=Step) for (int i = -nblocks; i < 0; i+=Step)
{ {
@ -488,7 +488,7 @@ u64 GetMurmurHash3(const u8* src, u32 len, u32 samples)
//---------- //----------
// tail // tail
const u8 * tail = (const u8*)(data + nblocks*8); const u8* tail = (const u8*)(data + nblocks*8);
u32 k1 = 0; u32 k1 = 0;
u32 k2 = 0; u32 k2 = 0;
@ -522,7 +522,7 @@ u64 GetMurmurHash3(const u8* src, u32 len, u32 samples)
out[0] = h1; out[0] = h1;
out[1] = h2; out[1] = h2;
return *((u64 *)&out); return *((u64*)&out);
} }
/* /*
@ -530,14 +530,14 @@ u64 GetMurmurHash3(const u8* src, u32 len, u32 samples)
* 64-bit version. Until someone can make a new version of the 32-bit one that * 64-bit version. Until someone can make a new version of the 32-bit one that
* makes identical hashes, this is just a c/p of the 64-bit one. * makes identical hashes, this is just a c/p of the 64-bit one.
*/ */
u64 GetHashHiresTexture(const u8 *src, u32 len, u32 samples) u64 GetHashHiresTexture(const u8* src, u32 len, u32 samples)
{ {
const u64 m = 0xc6a4a7935bd1e995ULL; const u64 m = 0xc6a4a7935bd1e995ULL;
u64 h = len * m; u64 h = len * m;
const int r = 47; const int r = 47;
u32 Step = (len / 8); u32 Step = (len / 8);
const u64 *data = (const u64 *)src; const u64* data = (const u64*)src;
const u64 *end = data + Step; const u64* end = data + Step;
if (samples == 0) if (samples == 0)
samples = std::max(Step, 1u); samples = std::max(Step, 1u);
Step = Step / samples; Step = Step / samples;
@ -554,7 +554,7 @@ u64 GetHashHiresTexture(const u8 *src, u32 len, u32 samples)
h *= m; h *= m;
} }
const u8 * data2 = (const u8*)end; const u8* data2 = (const u8*)end;
switch (len & 7) switch (len & 7)
{ {
@ -576,7 +576,7 @@ u64 GetHashHiresTexture(const u8 *src, u32 len, u32 samples)
} }
#endif #endif
u64 GetHash64(const u8 *src, u32 len, u32 samples) u64 GetHash64(const u8* src, u32 len, u32 samples)
{ {
return ptrHashFunction(src, len, samples); return ptrHashFunction(src, len, samples);
} }

View File

@ -11,8 +11,8 @@
u32 HashFletcher(const u8* data_u8, size_t length); // FAST. Length & 1 == 0. u32 HashFletcher(const u8* data_u8, size_t length); // FAST. Length & 1 == 0.
u32 HashAdler32(const u8* data, size_t len); // Fairly accurate, slightly slower u32 HashAdler32(const u8* data, size_t len); // Fairly accurate, slightly slower
u32 HashEctor(const u8* ptr, int length); // JUNK. DO NOT USE FOR NEW THINGS u32 HashEctor(const u8* ptr, int length); // JUNK. DO NOT USE FOR NEW THINGS
u64 GetCRC32(const u8 *src, u32 len, u32 samples); // SSE4.2 version of CRC32 u64 GetCRC32(const u8* src, u32 len, u32 samples); // SSE4.2 version of CRC32
u64 GetHashHiresTexture(const u8 *src, u32 len, u32 samples = 0); u64 GetHashHiresTexture(const u8* src, u32 len, u32 samples = 0);
u64 GetMurmurHash3(const u8 *src, u32 len, u32 samples); u64 GetMurmurHash3(const u8* src, u32 len, u32 samples);
u64 GetHash64(const u8 *src, u32 len, u32 samples); u64 GetHash64(const u8* src, u32 len, u32 samples);
void SetHash64Function(); void SetHash64Function();

View File

@ -31,7 +31,7 @@ template <typename K, typename V>
class LinearDiskCacheReader class LinearDiskCacheReader
{ {
public: public:
virtual void Read(const K &key, const V *value, u32 value_size) = 0; virtual void Read(const K& key, const V* value, u32 value_size) = 0;
}; };
// Dead simple unsorted key-value store with append functionality. // Dead simple unsorted key-value store with append functionality.
@ -82,7 +82,7 @@ public:
// good header, read some key/value pairs // good header, read some key/value pairs
K key; K key;
V *value = nullptr; V* value = nullptr;
u32 value_size = 0; u32 value_size = 0;
u32 entry_number = 0; u32 entry_number = 0;
@ -142,7 +142,7 @@ public:
} }
// Appends a key-value pair to the store. // Appends a key-value pair to the store.
void Append(const K &key, const V *value, u32 value_size) void Append(const K& key, const V* value, u32 value_size)
{ {
// TODO: Should do a check that we don't already have "key"? (I think each caller does that already.) // TODO: Should do a check that we don't already have "key"? (I think each caller does that already.)
Write(&value_size); Write(&value_size);
@ -167,13 +167,13 @@ private:
} }
template <typename D> template <typename D>
bool Write(const D *data, u32 count = 1) bool Write(const D* data, u32 count = 1)
{ {
return m_file.write((const char*)data, count * sizeof(D)).good(); return m_file.write((const char*)data, count * sizeof(D)).good();
} }
template <typename D> template <typename D>
bool Read(const D *data, u32 count = 1) bool Read(const D* data, u32 count = 1)
{ {
return m_file.read((char*)data, count * sizeof(D)).good(); return m_file.read((char*)data, count * sizeof(D)).good();
} }

View File

@ -12,7 +12,7 @@ public:
ConsoleListener(); ConsoleListener();
~ConsoleListener(); ~ConsoleListener();
void Log(LogTypes::LOG_LEVELS, const char *text) override; void Log(LogTypes::LOG_LEVELS, const char* text) override;
private: private:
bool m_use_color; bool m_use_color;

View File

@ -14,7 +14,7 @@ ConsoleListener::~ConsoleListener()
{ {
} }
void ConsoleListener::Log(LogTypes::LOG_LEVELS level, const char *text) void ConsoleListener::Log(LogTypes::LOG_LEVELS level, const char* text)
{ {
android_LogPriority logLevel = ANDROID_LOG_UNKNOWN; android_LogPriority logLevel = ANDROID_LOG_UNKNOWN;

View File

@ -22,7 +22,7 @@ ConsoleListener::~ConsoleListener()
fflush(nullptr); fflush(nullptr);
} }
void ConsoleListener::Log(LogTypes::LOG_LEVELS level, const char *text) void ConsoleListener::Log(LogTypes::LOG_LEVELS level, const char* text)
{ {
char color_attr[16] = ""; char color_attr[16] = "";
char reset_attr[16] = ""; char reset_attr[16] = "";

View File

@ -14,7 +14,7 @@ ConsoleListener::~ConsoleListener()
{ {
} }
void ConsoleListener::Log(LogTypes::LOG_LEVELS level, const char *text) void ConsoleListener::Log(LogTypes::LOG_LEVELS level, const char* text)
{ {
::OutputDebugStringA(text); ::OutputDebugStringA(text);
} }

View File

@ -73,7 +73,7 @@ static const char LOG_LEVEL_TO_CHAR[7] = "-NEWID";
} // namespace } // namespace
void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
const char *file, int line, const char *fmt, ...) const char* file, int line, const char* fmt, ...)
#ifdef __GNUC__ #ifdef __GNUC__
__attribute__((format(printf, 5, 6))) __attribute__((format(printf, 5, 6)))
#endif #endif

View File

@ -18,7 +18,7 @@
#include "Common/Logging/LogManager.h" #include "Common/Logging/LogManager.h"
void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
const char *file, int line, const char* fmt, ...) const char* file, int line, const char* fmt, ...)
{ {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
@ -28,7 +28,7 @@ void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
va_end(args); va_end(args);
} }
LogManager *LogManager::m_logManager = nullptr; LogManager* LogManager::m_logManager = nullptr;
LogManager::LogManager() LogManager::LogManager()
{ {
@ -115,10 +115,10 @@ LogManager::~LogManager()
} }
void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
const char *file, int line, const char *format, va_list args) const char* file, int line, const char* format, va_list args)
{ {
char temp[MAX_MSGLEN]; char temp[MAX_MSGLEN];
LogContainer *log = m_Log[type]; LogContainer* log = m_Log[type];
if (!log->IsEnabled() || level > log->GetLevel() || !log->HasListeners()) if (!log->IsEnabled() || level > log->GetLevel() || !log->HasListeners())
return; return;
@ -160,7 +160,7 @@ FileLogListener::FileLogListener(const std::string& filename)
SetEnable(true); SetEnable(true);
} }
void FileLogListener::Log(LogTypes::LOG_LEVELS, const char *msg) void FileLogListener::Log(LogTypes::LOG_LEVELS, const char* msg)
{ {
if (!IsEnabled() || !IsValid()) if (!IsEnabled() || !IsValid())
return; return;

View File

@ -24,7 +24,7 @@ class LogListener
public: public:
virtual ~LogListener() {} virtual ~LogListener() {}
virtual void Log(LogTypes::LOG_LEVELS, const char *msg) = 0; virtual void Log(LogTypes::LOG_LEVELS, const char* msg) = 0;
enum LISTENER enum LISTENER
{ {
@ -41,7 +41,7 @@ class FileLogListener : public LogListener
public: public:
FileLogListener(const std::string& filename); FileLogListener(const std::string& filename);
void Log(LogTypes::LOG_LEVELS, const char *msg) override; void Log(LogTypes::LOG_LEVELS, const char* msg) override;
bool IsValid() const { return m_logfile.good(); } bool IsValid() const { return m_logfile.good(); }
bool IsEnabled() const { return m_enable; } bool IsEnabled() const { return m_enable; }
@ -66,7 +66,7 @@ public:
void AddListener(LogListener::LISTENER id) { m_listener_ids[id] = 1; } void AddListener(LogListener::LISTENER id) { m_listener_ids[id] = 1; }
void RemoveListener(LogListener::LISTENER id) { m_listener_ids[id] = 0; } void RemoveListener(LogListener::LISTENER id) { m_listener_ids[id] = 0; }
void Trigger(LogTypes::LOG_LEVELS, const char *msg); void Trigger(LogTypes::LOG_LEVELS, const char* msg);
bool IsEnabled() const { return m_enable; } bool IsEnabled() const { return m_enable; }
void SetEnable(bool enable) { m_enable = enable; } void SetEnable(bool enable) { m_enable = enable; }
@ -95,7 +95,7 @@ class LogManager : NonCopyable
{ {
private: private:
LogContainer* m_Log[LogTypes::NUMBER_OF_LOGS]; LogContainer* m_Log[LogTypes::NUMBER_OF_LOGS];
static LogManager *m_logManager; // Singleton. Ugh. static LogManager* m_logManager; // Singleton. Ugh.
std::array<LogListener*, LogListener::NUMBER_OF_LISTENERS> m_listeners; std::array<LogListener*, LogListener::NUMBER_OF_LISTENERS> m_listeners;
LogManager(); LogManager();
@ -105,7 +105,7 @@ public:
static u32 GetMaxLevel() { return MAX_LOGLEVEL; } static u32 GetMaxLevel() { return MAX_LOGLEVEL; }
void Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, void Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
const char *file, int line, const char *fmt, va_list args); const char* file, int line, const char* fmt, va_list args);
void SetLogLevel(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level) void SetLogLevel(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level)
{ {
@ -132,7 +132,7 @@ public:
return m_Log[type]->GetFullName(); return m_Log[type]->GetFullName();
} }
void RegisterListener(LogListener::LISTENER id, LogListener *listener) void RegisterListener(LogListener::LISTENER id, LogListener* listener)
{ {
m_listeners[id] = listener; m_listeners[id] = listener;
} }
@ -152,7 +152,7 @@ public:
return m_logManager; return m_logManager;
} }
static void SetInstance(LogManager *logManager) static void SetInstance(LogManager* logManager)
{ {
m_logManager = logManager; m_logManager = logManager;
} }

View File

@ -243,7 +243,7 @@ double ApproximateReciprocal(double val)
} // namespace } // namespace
inline void MatrixMul(int n, const float *a, const float *b, float *result) inline void MatrixMul(int n, const float* a, const float* b, float* result)
{ {
for (int i = 0; i < n; ++i) for (int i = 0; i < n; ++i)
{ {
@ -265,7 +265,7 @@ float MathFloatVectorSum(const std::vector<float>& Vec)
return std::accumulate(Vec.begin(), Vec.end(), 0.0f); return std::accumulate(Vec.begin(), Vec.end(), 0.0f);
} }
void Matrix33::LoadIdentity(Matrix33 &mtx) void Matrix33::LoadIdentity(Matrix33& mtx)
{ {
memset(mtx.data, 0, sizeof(mtx.data)); memset(mtx.data, 0, sizeof(mtx.data));
mtx.data[0] = 1.0f; mtx.data[0] = 1.0f;
@ -273,7 +273,7 @@ void Matrix33::LoadIdentity(Matrix33 &mtx)
mtx.data[8] = 1.0f; mtx.data[8] = 1.0f;
} }
void Matrix33::RotateX(Matrix33 &mtx, float rad) void Matrix33::RotateX(Matrix33& mtx, float rad)
{ {
float s = sin(rad); float s = sin(rad);
float c = cos(rad); float c = cos(rad);
@ -284,7 +284,7 @@ void Matrix33::RotateX(Matrix33 &mtx, float rad)
mtx.data[7] = s; mtx.data[7] = s;
mtx.data[8] = c; mtx.data[8] = c;
} }
void Matrix33::RotateY(Matrix33 &mtx, float rad) void Matrix33::RotateY(Matrix33& mtx, float rad)
{ {
float s = sin(rad); float s = sin(rad);
float c = cos(rad); float c = cos(rad);
@ -296,12 +296,12 @@ void Matrix33::RotateY(Matrix33 &mtx, float rad)
mtx.data[8] = c; mtx.data[8] = c;
} }
void Matrix33::Multiply(const Matrix33 &a, const Matrix33 &b, Matrix33 &result) void Matrix33::Multiply(const Matrix33& a, const Matrix33& b, Matrix33& result)
{ {
MatrixMul(3, a.data, b.data, result.data); MatrixMul(3, a.data, b.data, result.data);
} }
void Matrix33::Multiply(const Matrix33 &a, const float vec[3], float result[3]) void Matrix33::Multiply(const Matrix33& a, const float vec[3], float result[3])
{ {
for (int i = 0; i < 3; ++i) for (int i = 0; i < 3; ++i)
{ {
@ -314,7 +314,7 @@ void Matrix33::Multiply(const Matrix33 &a, const float vec[3], float result[3])
} }
} }
void Matrix44::LoadIdentity(Matrix44 &mtx) void Matrix44::LoadIdentity(Matrix44& mtx)
{ {
memset(mtx.data, 0, sizeof(mtx.data)); memset(mtx.data, 0, sizeof(mtx.data));
mtx.data[0] = 1.0f; mtx.data[0] = 1.0f;
@ -323,7 +323,7 @@ void Matrix44::LoadIdentity(Matrix44 &mtx)
mtx.data[15] = 1.0f; mtx.data[15] = 1.0f;
} }
void Matrix44::LoadMatrix33(Matrix44 &mtx, const Matrix33 &m33) void Matrix44::LoadMatrix33(Matrix44& mtx, const Matrix33& m33)
{ {
for (int i = 0; i < 3; ++i) for (int i = 0; i < 3; ++i)
{ {
@ -341,7 +341,7 @@ void Matrix44::LoadMatrix33(Matrix44 &mtx, const Matrix33 &m33)
mtx.data[15] = 1.0f; mtx.data[15] = 1.0f;
} }
void Matrix44::Set(Matrix44 &mtx, const float mtxArray[16]) void Matrix44::Set(Matrix44& mtx, const float mtxArray[16])
{ {
for (int i = 0; i < 16; ++i) for (int i = 0; i < 16; ++i)
{ {
@ -349,7 +349,7 @@ void Matrix44::Set(Matrix44 &mtx, const float mtxArray[16])
} }
} }
void Matrix44::Translate(Matrix44 &mtx, const float vec[3]) void Matrix44::Translate(Matrix44& mtx, const float vec[3])
{ {
LoadIdentity(mtx); LoadIdentity(mtx);
mtx.data[3] = vec[0]; mtx.data[3] = vec[0];
@ -357,14 +357,14 @@ void Matrix44::Translate(Matrix44 &mtx, const float vec[3])
mtx.data[11] = vec[2]; mtx.data[11] = vec[2];
} }
void Matrix44::Shear(Matrix44 &mtx, const float a, const float b) void Matrix44::Shear(Matrix44& mtx, const float a, const float b)
{ {
LoadIdentity(mtx); LoadIdentity(mtx);
mtx.data[2] = a; mtx.data[2] = a;
mtx.data[6] = b; mtx.data[6] = b;
} }
void Matrix44::Multiply(const Matrix44 &a, const Matrix44 &b, Matrix44 &result) void Matrix44::Multiply(const Matrix44& a, const Matrix44& b, Matrix44& result)
{ {
MatrixMul(4, a.data, b.data, result.data); MatrixMul(4, a.data, b.data, result.data);
} }

View File

@ -192,16 +192,16 @@ inline int IntLog2(u64 val)
class Matrix33 class Matrix33
{ {
public: public:
static void LoadIdentity(Matrix33 &mtx); static void LoadIdentity(Matrix33& mtx);
// set mtx to be a rotation matrix around the x axis // set mtx to be a rotation matrix around the x axis
static void RotateX(Matrix33 &mtx, float rad); static void RotateX(Matrix33& mtx, float rad);
// set mtx to be a rotation matrix around the y axis // set mtx to be a rotation matrix around the y axis
static void RotateY(Matrix33 &mtx, float rad); static void RotateY(Matrix33& mtx, float rad);
// set result = a x b // set result = a x b
static void Multiply(const Matrix33 &a, const Matrix33 &b, Matrix33 &result); static void Multiply(const Matrix33& a, const Matrix33& b, Matrix33& result);
static void Multiply(const Matrix33 &a, const float vec[3], float result[3]); static void Multiply(const Matrix33& a, const float vec[3], float result[3]);
float data[9]; float data[9];
}; };
@ -209,14 +209,14 @@ public:
class Matrix44 class Matrix44
{ {
public: public:
static void LoadIdentity(Matrix44 &mtx); static void LoadIdentity(Matrix44& mtx);
static void LoadMatrix33(Matrix44 &mtx, const Matrix33 &m33); static void LoadMatrix33(Matrix44& mtx, const Matrix33& m33);
static void Set(Matrix44 &mtx, const float mtxArray[16]); static void Set(Matrix44& mtx, const float mtxArray[16]);
static void Translate(Matrix44 &mtx, const float vec[3]); static void Translate(Matrix44& mtx, const float vec[3]);
static void Shear(Matrix44 &mtx, const float a, const float b = 0); static void Shear(Matrix44& mtx, const float a, const float b = 0);
static void Multiply(const Matrix44 &a, const Matrix44 &b, Matrix44 &result); static void Multiply(const Matrix44& a, const Matrix44& b, Matrix44& result);
float data[16]; float data[16];
}; };

View File

@ -30,7 +30,7 @@
#ifdef ANDROID #ifdef ANDROID
#define ASHMEM_DEVICE "/dev/ashmem" #define ASHMEM_DEVICE "/dev/ashmem"
static int AshmemCreateFileMapping(const char *name, size_t size) static int AshmemCreateFileMapping(const char* name, size_t size)
{ {
int fd, ret; int fd, ret;
fd = open(ASHMEM_DEVICE, O_RDWR); fd = open(ASHMEM_DEVICE, O_RDWR);
@ -95,12 +95,12 @@ void MemArena::ReleaseSHMSegment()
} }
void *MemArena::CreateView(s64 offset, size_t size, void *base) void* MemArena::CreateView(s64 offset, size_t size, void* base)
{ {
#ifdef _WIN32 #ifdef _WIN32
return MapViewOfFileEx(hMemoryMapping, FILE_MAP_ALL_ACCESS, 0, (DWORD)((u64)offset), size, base); return MapViewOfFileEx(hMemoryMapping, FILE_MAP_ALL_ACCESS, 0, (DWORD)((u64)offset), size, base);
#else #else
void *retval = mmap( void* retval = mmap(
base, size, base, size,
PROT_READ | PROT_WRITE, PROT_READ | PROT_WRITE,
MAP_SHARED | ((base == nullptr) ? 0 : MAP_FIXED), MAP_SHARED | ((base == nullptr) ? 0 : MAP_FIXED),
@ -172,7 +172,7 @@ u8* MemArena::FindMemoryBase()
if (!(a_flags & MV_FAKE_VMEM) && (b_flags & MV_FAKE_VMEM)) \ if (!(a_flags & MV_FAKE_VMEM) && (b_flags & MV_FAKE_VMEM)) \
continue; \ continue; \
static bool Memory_TryBase(u8 *base, MemoryView *views, int num_views, u32 flags, MemArena *arena) static bool Memory_TryBase(u8* base, MemoryView* views, int num_views, u32 flags, MemArena* arena)
{ {
// OK, we know where to find free space. Now grab it! // OK, we know where to find free space. Now grab it!
// We just mimic the popular BAT setup. // We just mimic the popular BAT setup.
@ -223,7 +223,7 @@ static bool Memory_TryBase(u8 *base, MemoryView *views, int num_views, u32 flags
return true; return true;
} }
static u32 MemoryMap_InitializeViews(MemoryView *views, int num_views, u32 flags) static u32 MemoryMap_InitializeViews(MemoryView* views, int num_views, u32 flags)
{ {
u32 shm_position = 0; u32 shm_position = 0;
u32 last_position = 0; u32 last_position = 0;
@ -245,14 +245,14 @@ static u32 MemoryMap_InitializeViews(MemoryView *views, int num_views, u32 flags
return shm_position; return shm_position;
} }
u8 *MemoryMap_Setup(MemoryView *views, int num_views, u32 flags, MemArena *arena) u8* MemoryMap_Setup(MemoryView* views, int num_views, u32 flags, MemArena* arena)
{ {
u32 total_mem = MemoryMap_InitializeViews(views, num_views, flags); u32 total_mem = MemoryMap_InitializeViews(views, num_views, flags);
arena->GrabSHMSegment(total_mem); arena->GrabSHMSegment(total_mem);
// Now, create views in high memory where there's plenty of space. // Now, create views in high memory where there's plenty of space.
u8 *base = MemArena::FindMemoryBase(); u8* base = MemArena::FindMemoryBase();
// This really shouldn't fail - in 64-bit, there will always be enough // This really shouldn't fail - in 64-bit, there will always be enough
// address space. // address space.
if (!Memory_TryBase(base, views, num_views, flags, arena)) if (!Memory_TryBase(base, views, num_views, flags, arena))
@ -265,7 +265,7 @@ u8 *MemoryMap_Setup(MemoryView *views, int num_views, u32 flags, MemArena *arena
return base; return base;
} }
void MemoryMap_Shutdown(MemoryView *views, int num_views, u32 flags, MemArena *arena) void MemoryMap_Shutdown(MemoryView* views, int num_views, u32 flags, MemArena* arena)
{ {
std::set<void*> freeset; std::set<void*> freeset;
for (int i = 0; i < num_views; i++) for (int i = 0; i < num_views; i++)

View File

@ -21,11 +21,11 @@ class MemArena
public: public:
void GrabSHMSegment(size_t size); void GrabSHMSegment(size_t size);
void ReleaseSHMSegment(); void ReleaseSHMSegment();
void *CreateView(s64 offset, size_t size, void *base = nullptr); void* CreateView(s64 offset, size_t size, void* base = nullptr);
void ReleaseView(void *view, size_t size); void ReleaseView(void* view, size_t size);
// This finds 1 GB in 32-bit, 16 GB in 64-bit. // This finds 1 GB in 32-bit, 16 GB in 64-bit.
static u8 *FindMemoryBase(); static u8* FindMemoryBase();
private: private:
#ifdef _WIN32 #ifdef _WIN32
@ -54,5 +54,5 @@ struct MemoryView
// Uses a memory arena to set up an emulator-friendly memory map according to // Uses a memory arena to set up an emulator-friendly memory map according to
// a passed-in list of MemoryView structures. // a passed-in list of MemoryView structures.
u8 *MemoryMap_Setup(MemoryView *views, int num_views, u32 flags, MemArena *arena); u8* MemoryMap_Setup(MemoryView* views, int num_views, u32 flags, MemArena* arena);
void MemoryMap_Shutdown(MemoryView *views, int num_views, u32 flags, MemArena *arena); void MemoryMap_Shutdown(MemoryView* views, int num_views, u32 flags, MemArena* arena);

View File

@ -45,7 +45,7 @@ void* AllocateExecutableMemory(size_t size, bool low)
#if defined(_WIN32) #if defined(_WIN32)
void* ptr = VirtualAlloc(0, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); void* ptr = VirtualAlloc(0, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
#else #else
static char *map_hint = nullptr; static char* map_hint = nullptr;
#if defined(_M_X86_64) && !defined(MAP_32BIT) #if defined(_M_X86_64) && !defined(MAP_32BIT)
// This OS has no flag to enforce allocation below the 4 GB boundary, // This OS has no flag to enforce allocation below the 4 GB boundary,
// but if we hint that we want a low address it is very likely we will // but if we hint that we want a low address it is very likely we will

View File

@ -118,7 +118,7 @@ bool CheckTitleTIK(u64 _titleID, FromWhichRoot from)
return false; return false;
} }
static void CreateReplacementFile(std::string &filename) static void CreateReplacementFile(std::string& filename)
{ {
std::ofstream replace; std::ofstream replace;
OpenFStream(replace, filename, std::ios_base::out); OpenFStream(replace, filename, std::ios_base::out);

View File

@ -62,7 +62,7 @@ const std::string SettingsHandler::GetValue(const std::string& key)
void SettingsHandler::Decrypt() void SettingsHandler::Decrypt()
{ {
const u8 *str = m_buffer; const u8* str = m_buffer;
while (*str != 0) while (*str != 0)
{ {
if (m_position >= SETTINGS_SIZE) if (m_position >= SETTINGS_SIZE)
@ -113,7 +113,7 @@ void SettingsHandler::WriteByte(u8 b)
const std::string SettingsHandler::generateSerialNumber() const std::string SettingsHandler::generateSerialNumber()
{ {
time_t rawtime; time_t rawtime;
tm *timeinfo; tm* timeinfo;
char buffer[12]; char buffer[12];
char serialNumber[12]; char serialNumber[12];

View File

@ -24,7 +24,7 @@ public:
void AddSetting(const std::string& key, const std::string& value); void AddSetting(const std::string& key, const std::string& value);
const u8 *GetData() const; const u8* GetData() const;
const std::string GetValue(const std::string& key); const std::string GetValue(const std::string& key);
void Decrypt(); void Decrypt();

View File

@ -42,7 +42,7 @@ bool AsciiToHex(const std::string& _szValue, u32& result)
// Set errno to a good state. // Set errno to a good state.
errno = 0; errno = 0;
char *endptr = nullptr; char* endptr = nullptr;
const u32 value = strtoul(_szValue.c_str(), &endptr, 16); const u32 value = strtoul(_szValue.c_str(), &endptr, 16);
if (!endptr || *endptr) if (!endptr || *endptr)
@ -120,7 +120,7 @@ std::string StringFromFormat(const char* format, ...)
std::string StringFromFormatV(const char* format, va_list args) std::string StringFromFormatV(const char* format, va_list args)
{ {
char *buf = nullptr; char* buf = nullptr;
#ifdef _WIN32 #ifdef _WIN32
int required = _vscprintf(format, args); int required = _vscprintf(format, args);
buf = new char[required + 1]; buf = new char[required + 1];
@ -145,7 +145,7 @@ std::string StringFromFormatV(const char* format, va_list args)
} }
// For Debugging. Read out an u8 array. // For Debugging. Read out an u8 array.
std::string ArrayToString(const u8 *data, u32 size, int line_len, bool spaces) std::string ArrayToString(const u8* data, u32 size, int line_len, bool spaces)
{ {
std::ostringstream oss; std::ostringstream oss;
oss << std::setfill('0') << std::hex; oss << std::setfill('0') << std::hex;
@ -167,7 +167,7 @@ std::string ArrayToString(const u8 *data, u32 size, int line_len, bool spaces)
} }
// Turns " hej " into "hej". Also handles tabs. // Turns " hej " into "hej". Also handles tabs.
std::string StripSpaces(const std::string &str) std::string StripSpaces(const std::string& str)
{ {
const size_t s = str.find_first_not_of(" \t\r\n"); const size_t s = str.find_first_not_of(" \t\r\n");
@ -188,9 +188,9 @@ std::string StripQuotes(const std::string& s)
return s; return s;
} }
bool TryParse(const std::string &str, u32 *const output) bool TryParse(const std::string& str, u32* const output)
{ {
char *endptr = nullptr; char* endptr = nullptr;
// Reset errno to a value other than ERANGE // Reset errno to a value other than ERANGE
errno = 0; errno = 0;
@ -213,7 +213,7 @@ bool TryParse(const std::string &str, u32 *const output)
return true; return true;
} }
bool TryParse(const std::string &str, bool *const output) bool TryParse(const std::string& str, bool* const output)
{ {
if ("1" == str || !strcasecmp("true", str.c_str())) if ("1" == str || !strcasecmp("true", str.c_str()))
*output = true; *output = true;
@ -292,7 +292,7 @@ void SplitString(const std::string& str, const char delim, std::vector<std::stri
output.pop_back(); output.pop_back();
} }
std::string TabsToSpaces(int tab_size, const std::string &in) std::string TabsToSpaces(int tab_size, const std::string& in)
{ {
const std::string spaces(tab_size, ' '); const std::string spaces(tab_size, ' ');
std::string out(in); std::string out(in);

View File

@ -36,10 +36,10 @@ inline void CharArrayFromFormat(char (& out)[Count], const char* format, ...)
} }
// Good // Good
std::string ArrayToString(const u8 *data, u32 size, int line_len = 20, bool spaces = true); std::string ArrayToString(const u8* data, u32 size, int line_len = 20, bool spaces = true);
std::string StripSpaces(const std::string &s); std::string StripSpaces(const std::string& s);
std::string StripQuotes(const std::string &s); std::string StripQuotes(const std::string& s);
// Thousand separator. Turns 12345678 into 12,345,678 // Thousand separator. Turns 12345678 into 12,345,678
template <typename I> template <typename I>
@ -59,11 +59,11 @@ std::string ThousandSeparate(I value, int spaces = 0)
std::string StringFromInt(int value); std::string StringFromInt(int value);
std::string StringFromBool(bool value); std::string StringFromBool(bool value);
bool TryParse(const std::string &str, bool *output); bool TryParse(const std::string& str, bool* output);
bool TryParse(const std::string &str, u32 *output); bool TryParse(const std::string& str, u32* output);
template <typename N> template <typename N>
static bool TryParse(const std::string &str, N *const output) static bool TryParse(const std::string& str, N* const output)
{ {
std::istringstream iss(str); std::istringstream iss(str);
// is this right? not doing this breaks reading floats on locales that use different decimal separators // is this right? not doing this breaks reading floats on locales that use different decimal separators
@ -99,7 +99,7 @@ bool TryParseVector(const std::string& str, std::vector<N>* output, const char d
// TODO: kill this // TODO: kill this
bool AsciiToHex(const std::string& _szValue, u32& result); bool AsciiToHex(const std::string& _szValue, u32& result);
std::string TabsToSpaces(int tab_size, const std::string &in); std::string TabsToSpaces(int tab_size, const std::string& in);
void SplitString(const std::string& str, char delim, std::vector<std::string>& output); void SplitString(const std::string& str, char delim, std::vector<std::string>& output);

View File

@ -23,7 +23,7 @@ void SymbolDB::List()
INFO_LOG(OSHLE, "%zu functions known in this program above.", functions.size()); INFO_LOG(OSHLE, "%zu functions known in this program above.", functions.size());
} }
void SymbolDB::Clear(const char *prefix) void SymbolDB::Clear(const char* prefix)
{ {
// TODO: honor prefix // TODO: honor prefix
functions.clear(); functions.clear();
@ -50,7 +50,7 @@ Symbol* SymbolDB::GetSymbolFromName(const std::string& name)
return nullptr; return nullptr;
} }
void SymbolDB::AddCompleteSymbol(const Symbol &symbol) void SymbolDB::AddCompleteSymbol(const Symbol& symbol)
{ {
functions.emplace(symbol.address, symbol); functions.emplace(symbol.address, symbol);
} }

View File

@ -79,10 +79,10 @@ protected:
public: public:
SymbolDB() {} SymbolDB() {}
virtual ~SymbolDB() {} virtual ~SymbolDB() {}
virtual Symbol *GetSymbolFromAddr(u32 addr) { return nullptr; } virtual Symbol* GetSymbolFromAddr(u32 addr) { return nullptr; }
virtual Symbol *AddFunction(u32 startAddr) { return nullptr; } virtual Symbol* AddFunction(u32 startAddr) { return nullptr; }
void AddCompleteSymbol(const Symbol &symbol); void AddCompleteSymbol(const Symbol& symbol);
Symbol* GetSymbolFromName(const std::string& name); Symbol* GetSymbolFromName(const std::string& name);
Symbol* GetSymbolFromHash(u32 hash) Symbol* GetSymbolFromHash(u32 hash)
@ -94,10 +94,10 @@ public:
return nullptr; return nullptr;
} }
const XFuncMap &Symbols() const { return functions; } const XFuncMap& Symbols() const { return functions; }
XFuncMap &AccessSymbols() { return functions; } XFuncMap& AccessSymbols() { return functions; }
void Clear(const char *prefix = ""); void Clear(const char* prefix = "");
void List(); void List();
void Index(); void Index();
}; };

View File

@ -81,7 +81,7 @@ bool SysConf::LoadFromFile(const std::string& filename)
return false; return false;
} }
bool SysConf::LoadFromFileInternal(FILE *fh) bool SysConf::LoadFromFileInternal(FILE* fh)
{ {
File::IOFile f(fh); File::IOFile f(fh);
// Fill in infos // Fill in infos
@ -162,7 +162,7 @@ bool SysConf::LoadFromFileInternal(FILE *fh)
} }
// Returns the size of the item in file // Returns the size of the item in file
static unsigned int create_item(SSysConfEntry &item, SysconfType type, const std::string &name, static unsigned int create_item(SSysConfEntry& item, SysconfType type, const std::string& name,
const int data_length, unsigned int offset) const int data_length, unsigned int offset)
{ {
item.offset = offset; item.offset = offset;

View File

@ -173,7 +173,7 @@ public:
void UpdateLocation(); void UpdateLocation();
private: private:
bool LoadFromFileInternal(FILE *fh); bool LoadFromFileInternal(FILE* fh);
void GenerateSysConf(); void GenerateSysConf();
void Clear(); void Clear();

View File

@ -97,7 +97,7 @@ void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask)
{ {
#ifdef __APPLE__ #ifdef __APPLE__
thread_policy_set(pthread_mach_thread_np(thread), thread_policy_set(pthread_mach_thread_np(thread),
THREAD_AFFINITY_POLICY, (integer_t *)&mask, 1); THREAD_AFFINITY_POLICY, (integer_t*)&mask, 1);
#elif (defined __linux__ || defined BSD4_4 || defined __FreeBSD__) && !(defined ANDROID) #elif (defined __linux__ || defined BSD4_4 || defined __FreeBSD__) && !(defined ANDROID)
#ifdef __FreeBSD__ #ifdef __FreeBSD__
cpuset_t cpu_set; cpuset_t cpu_set;

View File

@ -35,6 +35,6 @@ inline void YieldCPU()
std::this_thread::yield(); std::this_thread::yield();
} }
void SetCurrentThreadName(const char *name); void SetCurrentThreadName(const char* name);
} // namespace Common } // namespace Common

View File

@ -75,7 +75,7 @@ EvictFindResult<V> EvictFind(std::unordered_map<K, EvictEntry<V>>& map, const K&
#if DEBUG #if DEBUG
printf("failed to find key '"); printf("failed to find key '");
for (size_t i = 0; i < sizeof(key); i++) { for (size_t i = 0; i < sizeof(key); i++) {
printf("%02x", ((u8 *) &key)[i]); printf("%02x", ((u8*) &key)[i]);
} }
printf("'\n"); printf("'\n");
#endif #endif

View File

@ -13,7 +13,7 @@
#define BUILD_TYPE_STR "" #define BUILD_TYPE_STR ""
#endif #endif
const char *scm_rev_str = "Dolphin " const char* scm_rev_str = "Dolphin "
#if !SCM_IS_MASTER #if !SCM_IS_MASTER
"[" SCM_BRANCH_STR "] " "[" SCM_BRANCH_STR "] "
#endif #endif
@ -25,14 +25,14 @@ const char *scm_rev_str = "Dolphin "
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
const char *netplay_dolphin_ver = SCM_DESC_STR " Win"; const char* netplay_dolphin_ver = SCM_DESC_STR " Win";
#elif __APPLE__ #elif __APPLE__
const char *netplay_dolphin_ver = SCM_DESC_STR " Mac"; const char* netplay_dolphin_ver = SCM_DESC_STR " Mac";
#else #else
const char *netplay_dolphin_ver = SCM_DESC_STR " Lin"; const char* netplay_dolphin_ver = SCM_DESC_STR " Lin";
#endif #endif
const char *scm_rev_git_str = SCM_REV_STR; const char* scm_rev_git_str = SCM_REV_STR;
const char *scm_desc_str = SCM_DESC_STR; const char* scm_desc_str = SCM_DESC_STR;
const char *scm_branch_str = SCM_BRANCH_STR; const char* scm_branch_str = SCM_BRANCH_STR;

View File

@ -8,7 +8,7 @@
#include <Windows.h> #include <Windows.h>
struct PatchInfo { struct PatchInfo {
const wchar_t *module_name; const wchar_t* module_name;
u32 checksum; u32 checksum;
u32 rva; u32 rva;
u32 length; u32 length;
@ -23,7 +23,7 @@ struct PatchInfo {
{ L"ucrtbased.dll", 0x1C1915 , 0x91905, 5 }, { L"ucrtbased.dll", 0x1C1915 , 0x91905, 5 },
}; };
bool ApplyPatch(const PatchInfo &patch) { bool ApplyPatch(const PatchInfo& patch) {
auto module = GetModuleHandleW(patch.module_name); auto module = GetModuleHandleW(patch.module_name);
if (module == nullptr) if (module == nullptr)
{ {
@ -35,7 +35,7 @@ bool ApplyPatch(const PatchInfo &patch) {
return false; return false;
} }
void *patch_addr = (void *)((uintptr_t)module + patch.rva); void* patch_addr = (void*)((uintptr_t)module + patch.rva);
size_t patch_size = patch.length; size_t patch_size = patch.length;
DWORD old_protect; DWORD old_protect;

View File

@ -81,7 +81,7 @@ void XEmitter::ABI_PopRegistersAndAdjustStack(BitSet32 mask, size_t rsp_alignmen
} }
// Common functions // Common functions
void XEmitter::ABI_CallFunction(const void *func) void XEmitter::ABI_CallFunction(const void* func)
{ {
u64 distance = u64(func) - (u64(code) + 5); u64 distance = u64(func) - (u64(code) + 5);
if (distance >= 0x0000000080000000ULL && if (distance >= 0x0000000080000000ULL &&
@ -97,40 +97,40 @@ void XEmitter::ABI_CallFunction(const void *func)
} }
} }
void XEmitter::ABI_CallFunctionC16(const void *func, u16 param1) void XEmitter::ABI_CallFunctionC16(const void* func, u16 param1)
{ {
MOV(32, R(ABI_PARAM1), Imm32((u32)param1)); MOV(32, R(ABI_PARAM1), Imm32((u32)param1));
ABI_CallFunction(func); ABI_CallFunction(func);
} }
void XEmitter::ABI_CallFunctionCC16(const void *func, u32 param1, u16 param2) void XEmitter::ABI_CallFunctionCC16(const void* func, u32 param1, u16 param2)
{ {
MOV(32, R(ABI_PARAM1), Imm32(param1)); MOV(32, R(ABI_PARAM1), Imm32(param1));
MOV(32, R(ABI_PARAM2), Imm32((u32)param2)); MOV(32, R(ABI_PARAM2), Imm32((u32)param2));
ABI_CallFunction(func); ABI_CallFunction(func);
} }
void XEmitter::ABI_CallFunctionC(const void *func, u32 param1) void XEmitter::ABI_CallFunctionC(const void* func, u32 param1)
{ {
MOV(32, R(ABI_PARAM1), Imm32(param1)); MOV(32, R(ABI_PARAM1), Imm32(param1));
ABI_CallFunction(func); ABI_CallFunction(func);
} }
void XEmitter::ABI_CallFunctionCC(const void *func, u32 param1, u32 param2) void XEmitter::ABI_CallFunctionCC(const void* func, u32 param1, u32 param2)
{ {
MOV(32, R(ABI_PARAM1), Imm32(param1)); MOV(32, R(ABI_PARAM1), Imm32(param1));
MOV(32, R(ABI_PARAM2), Imm32(param2)); MOV(32, R(ABI_PARAM2), Imm32(param2));
ABI_CallFunction(func); ABI_CallFunction(func);
} }
void XEmitter::ABI_CallFunctionCP(const void *func, u32 param1, void *param2) void XEmitter::ABI_CallFunctionCP(const void* func, u32 param1, void* param2)
{ {
MOV(32, R(ABI_PARAM1), Imm32(param1)); MOV(32, R(ABI_PARAM1), Imm32(param1));
MOV(64, R(ABI_PARAM2), Imm64((u64)param2)); MOV(64, R(ABI_PARAM2), Imm64((u64)param2));
ABI_CallFunction(func); ABI_CallFunction(func);
} }
void XEmitter::ABI_CallFunctionCCC(const void *func, u32 param1, u32 param2, u32 param3) void XEmitter::ABI_CallFunctionCCC(const void* func, u32 param1, u32 param2, u32 param3)
{ {
MOV(32, R(ABI_PARAM1), Imm32(param1)); MOV(32, R(ABI_PARAM1), Imm32(param1));
MOV(32, R(ABI_PARAM2), Imm32(param2)); MOV(32, R(ABI_PARAM2), Imm32(param2));
@ -138,7 +138,7 @@ void XEmitter::ABI_CallFunctionCCC(const void *func, u32 param1, u32 param2, u32
ABI_CallFunction(func); ABI_CallFunction(func);
} }
void XEmitter::ABI_CallFunctionCCP(const void *func, u32 param1, u32 param2, void *param3) void XEmitter::ABI_CallFunctionCCP(const void* func, u32 param1, u32 param2, void* param3)
{ {
MOV(32, R(ABI_PARAM1), Imm32(param1)); MOV(32, R(ABI_PARAM1), Imm32(param1));
MOV(32, R(ABI_PARAM2), Imm32(param2)); MOV(32, R(ABI_PARAM2), Imm32(param2));
@ -146,7 +146,7 @@ void XEmitter::ABI_CallFunctionCCP(const void *func, u32 param1, u32 param2, voi
ABI_CallFunction(func); ABI_CallFunction(func);
} }
void XEmitter::ABI_CallFunctionCCCP(const void *func, u32 param1, u32 param2, u32 param3, void *param4) void XEmitter::ABI_CallFunctionCCCP(const void* func, u32 param1, u32 param2, u32 param3, void* param4)
{ {
MOV(32, R(ABI_PARAM1), Imm32(param1)); MOV(32, R(ABI_PARAM1), Imm32(param1));
MOV(32, R(ABI_PARAM2), Imm32(param2)); MOV(32, R(ABI_PARAM2), Imm32(param2));
@ -155,14 +155,14 @@ void XEmitter::ABI_CallFunctionCCCP(const void *func, u32 param1, u32 param2, u3
ABI_CallFunction(func); ABI_CallFunction(func);
} }
void XEmitter::ABI_CallFunctionPC(const void *func, void *param1, u32 param2) void XEmitter::ABI_CallFunctionPC(const void* func, void* param1, u32 param2)
{ {
MOV(64, R(ABI_PARAM1), Imm64((u64)param1)); MOV(64, R(ABI_PARAM1), Imm64((u64)param1));
MOV(32, R(ABI_PARAM2), Imm32(param2)); MOV(32, R(ABI_PARAM2), Imm32(param2));
ABI_CallFunction(func); ABI_CallFunction(func);
} }
void XEmitter::ABI_CallFunctionPPC(const void *func, void *param1, void *param2, u32 param3) void XEmitter::ABI_CallFunctionPPC(const void* func, void* param1, void* param2, u32 param3)
{ {
MOV(64, R(ABI_PARAM1), Imm64((u64)param1)); MOV(64, R(ABI_PARAM1), Imm64((u64)param1));
MOV(64, R(ABI_PARAM2), Imm64((u64)param2)); MOV(64, R(ABI_PARAM2), Imm64((u64)param2));
@ -171,7 +171,7 @@ void XEmitter::ABI_CallFunctionPPC(const void *func, void *param1, void *param2,
} }
// Pass a register as a parameter. // Pass a register as a parameter.
void XEmitter::ABI_CallFunctionR(const void *func, X64Reg reg1) void XEmitter::ABI_CallFunctionR(const void* func, X64Reg reg1)
{ {
if (reg1 != ABI_PARAM1) if (reg1 != ABI_PARAM1)
MOV(32, R(ABI_PARAM1), R(reg1)); MOV(32, R(ABI_PARAM1), R(reg1));
@ -179,7 +179,7 @@ void XEmitter::ABI_CallFunctionR(const void *func, X64Reg reg1)
} }
// Pass two registers as parameters. // Pass two registers as parameters.
void XEmitter::ABI_CallFunctionRR(const void *func, X64Reg reg1, X64Reg reg2) void XEmitter::ABI_CallFunctionRR(const void* func, X64Reg reg1, X64Reg reg2)
{ {
MOVTwo(64, ABI_PARAM1, reg1, 0, ABI_PARAM2, reg2); MOVTwo(64, ABI_PARAM1, reg1, 0, ABI_PARAM2, reg2);
ABI_CallFunction(func); ABI_CallFunction(func);
@ -217,7 +217,7 @@ void XEmitter::MOVTwo(int bits, Gen::X64Reg dst1, Gen::X64Reg src1, s32 offset1,
} }
} }
void XEmitter::ABI_CallFunctionAC(int bits, const void *func, const Gen::OpArg &arg1, u32 param2) void XEmitter::ABI_CallFunctionAC(int bits, const void* func, const Gen::OpArg& arg1, u32 param2)
{ {
if (!arg1.IsSimpleReg(ABI_PARAM1)) if (!arg1.IsSimpleReg(ABI_PARAM1))
MOV(bits, R(ABI_PARAM1), arg1); MOV(bits, R(ABI_PARAM1), arg1);
@ -225,7 +225,7 @@ void XEmitter::ABI_CallFunctionAC(int bits, const void *func, const Gen::OpArg &
ABI_CallFunction(func); ABI_CallFunction(func);
} }
void XEmitter::ABI_CallFunctionA(int bits, const void *func, const Gen::OpArg &arg1) void XEmitter::ABI_CallFunctionA(int bits, const void* func, const Gen::OpArg& arg1)
{ {
if (!arg1.IsSimpleReg(ABI_PARAM1)) if (!arg1.IsSimpleReg(ABI_PARAM1))
MOV(bits, R(ABI_PARAM1), arg1); MOV(bits, R(ABI_PARAM1), arg1);

View File

@ -4,9 +4,9 @@
#include "Common/x64Analyzer.h" #include "Common/x64Analyzer.h"
bool DisassembleMov(const unsigned char *codePtr, InstructionInfo *info) bool DisassembleMov(const unsigned char* codePtr, InstructionInfo* info)
{ {
unsigned const char *startCodePtr = codePtr; unsigned const char* startCodePtr = codePtr;
u8 rex = 0; u8 rex = 0;
u32 opcode; u32 opcode;
int opcode_length; int opcode_length;
@ -224,7 +224,7 @@ bool DisassembleMov(const unsigned char *codePtr, InstructionInfo *info)
return true; return true;
} }
bool InstructionInfo::operator==(const InstructionInfo &other) const bool InstructionInfo::operator==(const InstructionInfo& other) const
{ {
return operandSize == other.operandSize && return operandSize == other.operandSize &&
instructionSize == other.instructionSize && instructionSize == other.instructionSize &&

View File

@ -21,7 +21,7 @@ struct InstructionInfo
u64 immediate; u64 immediate;
s32 displacement; s32 displacement;
bool operator==(const InstructionInfo &other) const; bool operator==(const InstructionInfo& other) const;
}; };
struct ModRM struct ModRM
@ -41,4 +41,4 @@ enum AccessType
OP_ACCESS_WRITE = 1 OP_ACCESS_WRITE = 1
}; };
bool DisassembleMov(const unsigned char *codePtr, InstructionInfo *info); bool DisassembleMov(const unsigned char* codePtr, InstructionInfo* info);