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
50 changed files with 274 additions and 274 deletions
+5 -5
View File
@@ -43,7 +43,7 @@ static bool IsPowerOfTwo(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)
{
@@ -60,7 +60,7 @@ bool IsImmArithmetic(uint64_t input, u32 *val, bool *shift)
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((width == kWRegSizeInBits) || (width == kXRegSizeInBits));
@@ -1002,7 +1002,7 @@ void ARM64XEmitter::BL(const void* 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;
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);
}
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)
{
@@ -4094,7 +4094,7 @@ float FPImm8ToFloat(uint8_t bits)
return fl;
}
bool FPImm8FromFloat(float value, uint8_t *immOut)
bool FPImm8FromFloat(float value, uint8_t* immOut)
{
uint32_t f;
memcpy(&f, &value, sizeof(float));
+6 -6
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); }
// 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
bool IsImmArithmetic(uint64_t input, u32 *val, bool *shift);
bool IsImmArithmetic(uint64_t input, u32* val, bool* shift);
float FPImm8ToFloat(uint8_t bits);
bool FPImm8FromFloat(float value, uint8_t *immOut);
bool FPImm8FromFloat(float value, uint8_t* immOut);
enum OpType
{
@@ -677,7 +677,7 @@ public:
// Wrapper around MOVZ+MOVK
void MOVI2R(ARM64Reg Rd, u64 imm, bool optimize = true);
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");
MOVI2R(Rd, (uintptr_t)ptr);
@@ -730,10 +730,10 @@ public:
}
// 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)
{
QuickCallFunction(scratchreg, (const void *)func);
QuickCallFunction(scratchreg, (const void*)func);
}
};
+2 -2
View File
@@ -188,7 +188,7 @@ void MemChecks::Remove(u32 _Address)
jit->ClearCache();
}
TMemCheck *MemChecks::GetMemCheck(u32 address)
TMemCheck* MemChecks::GetMemCheck(u32 address)
{
for (TMemCheck& bp : m_MemChecks)
{
@@ -207,7 +207,7 @@ TMemCheck *MemChecks::GetMemCheck(u32 address)
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))
{
+2 -2
View File
@@ -41,7 +41,7 @@ struct TMemCheck
u32 numHits;
// 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);
};
@@ -99,7 +99,7 @@ public:
void Add(const TMemCheck& _rMemoryCheck);
// memory breakpoint
TMemCheck *GetMemCheck(u32 address);
TMemCheck* GetMemCheck(u32 address);
void Remove(u32 _Address);
void Clear() { m_MemChecks.clear(); }
+3 -3
View File
@@ -136,7 +136,7 @@ std::vector<std::string> cdio_get_devices()
// checklist: /dev/cdrom, /dev/dvd /dev/hd?, /dev/scd? /dev/sr?
static struct
{
const char * format;
const char* format;
unsigned int num_min;
unsigned int num_max;
} 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
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
if (!is_device(drive))
@@ -213,7 +213,7 @@ bool cdio_is_cdrom(std::string device)
// Resolve symbolic links. This allows symbolic links to valid
// drives to be passed from the command line with the -e flag.
char resolved_path[MAX_PATH];
char *devname = realpath(device.c_str(), resolved_path);
char* devname = realpath(device.c_str(), resolved_path);
if (!devname)
return false;
device = devname;
+2 -2
View File
@@ -311,7 +311,7 @@ private:
}
__forceinline
void DoVoid(void *data, u32 size)
void DoVoid(void* data, u32 size)
{
switch (mode)
{
@@ -421,7 +421,7 @@ public:
}
// Get data
u8 *ptr = nullptr;
u8* ptr = nullptr;
PointerWrap p(&ptr, PointerWrap::MODE_MEASURE);
_class.DoState(p);
size_t const sz = (size_t)ptr;
+2 -2
View File
@@ -21,7 +21,7 @@ private:
virtual void PoisonMemory() = 0;
protected:
u8 *region;
u8* region;
size_t 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));
}
+1 -1
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)
{
u32 *tdst = dst+(y+iy)*width+x;
u32* tdst = dst+(y+iy)*width+x;
for (int ix = 0; ix < 8; ix++)
{
// huh, this seems wrong. CI8, not 5A3, no?
+5 -5
View File
@@ -9,11 +9,11 @@
#include <cstring>
// Git version number
extern const char *scm_desc_str;
extern const char *scm_branch_str;
extern const char *scm_rev_str;
extern const char *scm_rev_git_str;
extern const char *netplay_dolphin_ver;
extern const char* scm_desc_str;
extern const char* scm_branch_str;
extern const char* scm_rev_str;
extern const char* scm_rev_git_str;
extern const char* netplay_dolphin_ver;
// Force enable logging in the right modes. For some reason, something had changed
// so that debugfast no longer logged.
+8 -8
View File
@@ -8,17 +8,17 @@
#include "Common/CommonTypes.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);
}
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);
}
int bn_compare(const u8 *a, const u8 *b, u32 n)
int bn_compare(const u8* a, const u8* b, u32 n)
{
u32 i;
@@ -32,7 +32,7 @@ int bn_compare(const u8 *a, const u8 *b, u32 n)
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 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 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);
}
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;
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];
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
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];
+6 -6
View File
@@ -8,9 +8,9 @@
// bignum arithmetic
int bn_compare(const u8 *a, const u8 *b, 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_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_exp(u8 *d, const u8 *a, const u8 *N, u32 n, const u8 *e, u32 en);
int bn_compare(const u8* a, const u8* b, 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_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_exp(u8* d, const u8* a, const u8* N, u32 n, const u8* e, u32 en);
+24 -24
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
,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);
}
static void elt_zero(u8 *d)
static void elt_zero(u8* d)
{
memset(d, 0, 30);
}
static int elt_is_zero(const u8 *d)
static int elt_is_zero(const u8* d)
{
u32 i;
@@ -53,7 +53,7 @@ static int elt_is_zero(const u8 *d)
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;
@@ -61,7 +61,7 @@ static void elt_add(u8 *d, const u8 *a, const u8 *b)
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;
u32 i;
@@ -79,7 +79,7 @@ static void elt_mul_x(u8 *d, const u8 *a)
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;
u8 mask;
@@ -105,7 +105,7 @@ static void elt_mul(u8 *d, const u8 *a, const u8 *b)
static const u8 square[16] =
{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;
@@ -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;
u8 x;
@@ -140,7 +140,7 @@ static void wide_reduce(u8 *d)
d[30] &= 1;
}
static void elt_square(u8 *d, const u8 *a)
static void elt_square(u8* d, const u8* a)
{
u8 wide[60];
@@ -150,7 +150,7 @@ static void elt_square(u8 *d, const u8 *a)
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];
@@ -163,7 +163,7 @@ static void itoh_tsujii(u8 *d, const u8 *a, const u8 *b, u32 j)
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 s[30];
@@ -181,10 +181,10 @@ static void elt_inv(u8 *d, const u8 *a)
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 *x, *y;
u8* x, *y;
x = p;
y = p + 30;
@@ -205,16 +205,16 @@ UNUSED static int point_is_on_curve(u8 *p)
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);
}
static void point_double(u8 *r, const u8 *p)
static void point_double(u8* r, const u8* p)
{
u8 s[30], t[30];
const u8 *px, *py;
u8 *rx, *ry;
const u8* px, *py;
u8* rx, *ry;
px = p;
py = p + 30;
@@ -243,11 +243,11 @@ static void point_double(u8 *r, const u8 *p)
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];
const u8 *px, *py, *qx, *qy;
u8 *rx, *ry;
const u8* px, *py, *qx, *qy;
u8* rx, *ry;
px = p;
py = p + 30;
@@ -297,7 +297,7 @@ static void point_add(u8 *r, const u8 *p, const u8 *q)
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;
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 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);
}
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 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);
}
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);
}
+2 -2
View File
@@ -6,6 +6,6 @@
#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);
+1 -1
View File
@@ -14,7 +14,7 @@ protected:
public:
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 bool IsAlive() {return true;}
virtual bool IsBreakpoint(unsigned int /*address*/) {return false;}
+4 -4
View File
@@ -65,7 +65,7 @@ public:
{
if (NeedSize)
m_size--;
ElementPtr *tmpptr = m_read_ptr;
ElementPtr* tmpptr = m_read_ptr;
// advance the read pointer
m_read_ptr = tmpptr->next.load();
// set the next element to nullptr to stop the recursive deletion
@@ -81,7 +81,7 @@ public:
if (NeedSize)
m_size--;
ElementPtr *tmpptr = m_read_ptr;
ElementPtr* tmpptr = m_read_ptr;
m_read_ptr = tmpptr->next.load(std::memory_order_acquire);
t = std::move(tmpptr->current);
tmpptr->next.store(nullptr);
@@ -117,8 +117,8 @@ private:
std::atomic<ElementPtr*> next;
};
ElementPtr *m_write_ptr;
ElementPtr *m_read_ptr;
ElementPtr* m_write_ptr;
ElementPtr* m_read_ptr;
std::atomic<u32> m_size;
};
+26 -26
View File
@@ -58,7 +58,7 @@ namespace File
// Remove any ending forward slashes from directory paths
// Modifies argument.
static void StripTailDirSlashes(std::string &fname)
static void StripTailDirSlashes(std::string& fname)
{
if (fname.length() > 1)
{
@@ -68,7 +68,7 @@ static void StripTailDirSlashes(std::string &fname)
}
// Returns true if file filename exists
bool Exists(const std::string &filename)
bool Exists(const std::string& filename)
{
struct stat64 file_info;
@@ -85,7 +85,7 @@ bool Exists(const std::string &filename)
}
// Returns true if filename is a directory
bool IsDirectory(const std::string &filename)
bool IsDirectory(const std::string& filename)
{
struct stat64 file_info;
@@ -110,7 +110,7 @@ bool IsDirectory(const std::string &filename)
// Deletes a given filename, return true on success
// 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());
@@ -149,7 +149,7 @@ bool Delete(const std::string &filename)
}
// 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());
#ifdef _WIN32
@@ -181,7 +181,7 @@ bool CreateDir(const std::string &path)
}
// 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;
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
bool DeleteDir(const std::string &filename)
bool DeleteDir(const std::string& filename)
{
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
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",
srcFilename.c_str(), destFilename.c_str());
@@ -271,7 +271,7 @@ bool Rename(const std::string &srcFilename, const std::string &destFilename)
}
#ifndef _WIN32
static void FSyncPath(const char *path)
static void FSyncPath(const char* path)
{
int fd = open(path, O_RDONLY);
if (fd != -1)
@@ -282,7 +282,7 @@ static void FSyncPath(const char *path)
}
#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))
return false;
@@ -294,7 +294,7 @@ bool RenameSync(const std::string &srcFilename, const std::string &destFilename)
close(fd);
}
#else
char *path = strdup(srcFilename.c_str());
char* path = strdup(srcFilename.c_str());
FSyncPath(path);
FSyncPath(dirname(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
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",
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)
u64 GetSize(const std::string &filename)
u64 GetSize(const std::string& filename)
{
if (!Exists(filename))
{
@@ -417,7 +417,7 @@ u64 GetSize(const int fd)
}
// Overloaded GetSize, accepts FILE*
u64 GetSize(FILE *f)
u64 GetSize(FILE* f)
{
// can't use off_t here because it can be 32-bit
u64 pos = ftello(f);
@@ -440,7 +440,7 @@ u64 GetSize(FILE *f)
}
// 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());
@@ -457,7 +457,7 @@ bool CreateEmptyFile(const std::string &filename)
// Scans the directory tree gets, starting from _Directory and adds the
// 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());
// How many files + directories we found
@@ -482,7 +482,7 @@ FSTEntry ScanDirectoryTree(const std::string &directory, bool recursive)
#else
struct dirent dirent, *result = nullptr;
DIR *dirp = opendir(directory.c_str());
DIR* dirp = opendir(directory.c_str());
if (!dirp)
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.
bool DeleteDirRecursively(const std::string &directory)
bool DeleteDirRecursively(const std::string& directory)
{
INFO_LOG(COMMON, "DeleteDirRecursively: %s", directory.c_str());
#ifdef _WIN32
@@ -547,7 +547,7 @@ bool DeleteDirRecursively(const std::string &directory)
const std::string virtualName(TStrToUTF8(ffd.cFileName));
#else
struct dirent dirent, *result = nullptr;
DIR *dirp = opendir(directory.c_str());
DIR* dirp = opendir(directory.c_str());
if (!dirp)
return false;
@@ -600,7 +600,7 @@ bool DeleteDirRecursively(const std::string &directory)
}
// 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 (!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));
#else
struct dirent dirent, *result = nullptr;
DIR *dirp = opendir(source_path.c_str());
DIR* dirp = opendir(source_path.c_str());
if (!dirp) return;
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
std::string GetCurrentDir()
{
char *dir;
char* dir;
// Get the current working directory (getcwd uses malloc)
if (!(dir = __getcwd(nullptr, 0)))
{
@@ -666,7 +666,7 @@ std::string GetCurrentDir()
}
// 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;
}
@@ -697,7 +697,7 @@ std::string CreateTempDir()
#endif
}
std::string GetTempFilenameForAtomicWrite(const std::string &path)
std::string GetTempFilenameForAtomicWrite(const std::string& path)
{
std::string abs = path;
#ifdef _WIN32
@@ -883,12 +883,12 @@ std::string GetThemeDir(const std::string& theme_name)
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());
}
bool ReadFileToString(const std::string& filename, std::string &str)
bool ReadFileToString(const std::string& filename, std::string& str)
{
File::IOFile file(filename, "rb");
auto const f = file.GetHandle();
+18 -18
View File
@@ -70,65 +70,65 @@ struct FSTEntry
};
// 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
bool IsDirectory(const std::string &filename);
bool IsDirectory(const std::string& filename);
// Returns the size of filename (64bit)
u64 GetSize(const std::string &filename);
u64 GetSize(const std::string& filename);
// Overloaded GetSize, accepts file descriptor
u64 GetSize(const int fd);
// Overloaded GetSize, accepts FILE*
u64 GetSize(FILE *f);
u64 GetSize(FILE* f);
// 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
bool CreateFullPath(const std::string &fullPath);
bool CreateFullPath(const std::string& fullPath);
// Deletes a given filename, return true on success
// 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
bool DeleteDir(const std::string &filename);
bool DeleteDir(const std::string& filename);
// 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
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
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
bool CreateEmptyFile(const std::string &filename);
bool CreateEmptyFile(const std::string& filename);
// 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.
bool DeleteDirRecursively(const std::string &directory);
bool DeleteDirRecursively(const std::string& directory);
// Returns the current directory
std::string GetCurrentDir();
// 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
bool SetCurrentDir(const std::string &directory);
bool SetCurrentDir(const std::string& directory);
// Creates and returns the path to a new temporary directory.
std::string CreateTempDir();
// 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
// Don't call prior to setting the base user directory
@@ -148,7 +148,7 @@ std::string GetSysDirectory();
std::string GetBundleDirectory();
#endif
std::string &GetExeDirectory();
std::string& GetExeDirectory();
bool WriteStringToFile(const std::string& str, const std::string& filename);
bool ReadFileToString(const std::string& filename, std::string& str);
+5 -5
View File
@@ -16,13 +16,13 @@
template <class T, int N>
class FixedSizeQueue
{
T *storage;
T* storage;
int head;
int tail;
int count; // sacrifice 4 bytes for a simpler implementation. may optimize away in the future.
// Make copy constructor private for now.
FixedSizeQueue(FixedSizeQueue &other) {}
FixedSizeQueue(FixedSizeQueue& other) {}
public:
FixedSizeQueue()
@@ -62,13 +62,13 @@ public:
T pop_front()
{
const T &temp = storage[head];
const T& temp = storage[head];
pop();
return temp;
}
T &front() { return storage[head]; }
const T &front() const { return storage[head]; }
T& front() { return storage[head]; }
const T& front() const { return storage[head]; }
size_t size() const
{
+26 -26
View File
@@ -9,7 +9,7 @@
#include "Common/Hash.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
// 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
// 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];
}
@@ -149,9 +149,9 @@ inline u64 fmix64(u64 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;
u32 Step = (len / 8);
if (samples == 0)
@@ -170,7 +170,7 @@ u64 GetMurmurHash3(const u8 *src, u32 len, u32 samples)
//----------
// body
const u64 * blocks = (const u64 *)(data);
const u64* blocks = (const u64*)(data);
for (int i = 0; i < nblocks; i+=Step)
{
@@ -183,7 +183,7 @@ u64 GetMurmurHash3(const u8 *src, u32 len, u32 samples)
//----------
// tail
const u8 * tail = (const u8*)(data + nblocks*16);
const u8* tail = (const u8*)(data + nblocks*16);
u64 k1 = 0;
u64 k2 = 0;
@@ -227,13 +227,13 @@ u64 GetMurmurHash3(const u8 *src, u32 len, u32 samples)
// 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)
u64 h[4] = { len, 0, 0, 0 };
u32 Step = (len / 8);
const u64 *data = (const u64 *)src;
const u64 *end = data + Step;
const u64* data = (const u64*)src;
const u64* end = data + Step;
if (samples == 0)
samples = std::max(Step, 1u);
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
* true.
*/
u64 GetHashHiresTexture(const u8 *src, u32 len, u32 samples)
u64 GetHashHiresTexture(const u8* src, u32 len, u32 samples)
{
const u64 m = 0xc6a4a7935bd1e995;
u64 h = len * m;
const int r = 47;
u32 Step = (len / 8);
const u64 *data = (const u64 *)src;
const u64 *end = data + Step;
const u64* data = (const u64*)src;
const u64* end = data + Step;
if (samples == 0)
samples = std::max(Step, 1u);
Step = Step / samples;
@@ -379,13 +379,13 @@ u64 GetHashHiresTexture(const u8 *src, u32 len, u32 samples)
}
#else
// 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
u32 h = len;
u32 Step = (len/4);
const u32 *data = (const u32 *)src;
const u32 *end = data + Step;
const u32* data = (const u32 *)src;
const u32* end = data + Step;
if (samples == 0)
samples = std::max(Step, 1u);
Step = Step / samples;
@@ -397,7 +397,7 @@ u64 GetCRC32(const u8 *src, u32 len, u32 samples)
data += Step;
}
const u8 *data2 = (const u8*)end;
const u8* data2 = (const u8*)end;
return (u64)_mm_crc32_u32(h, u32(data2[0]));
#else
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
// 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];
}
@@ -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)
{
const u8 * data = (const u8*)src;
const u8* data = (const u8*)src;
u32 out[2];
const int nblocks = len / 8;
u32 Step = (len / 4);
@@ -475,7 +475,7 @@ u64 GetMurmurHash3(const u8* src, u32 len, u32 samples)
//----------
// 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)
{
@@ -488,7 +488,7 @@ u64 GetMurmurHash3(const u8* src, u32 len, u32 samples)
//----------
// tail
const u8 * tail = (const u8*)(data + nblocks*8);
const u8* tail = (const u8*)(data + nblocks*8);
u32 k1 = 0;
u32 k2 = 0;
@@ -522,7 +522,7 @@ u64 GetMurmurHash3(const u8* src, u32 len, u32 samples)
out[0] = h1;
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
* 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;
u64 h = len * m;
const int r = 47;
u32 Step = (len / 8);
const u64 *data = (const u64 *)src;
const u64 *end = data + Step;
const u64* data = (const u64*)src;
const u64* end = data + Step;
if (samples == 0)
samples = std::max(Step, 1u);
Step = Step / samples;
@@ -554,7 +554,7 @@ u64 GetHashHiresTexture(const u8 *src, u32 len, u32 samples)
h *= m;
}
const u8 * data2 = (const u8*)end;
const u8* data2 = (const u8*)end;
switch (len & 7)
{
@@ -576,7 +576,7 @@ u64 GetHashHiresTexture(const u8 *src, u32 len, u32 samples)
}
#endif
u64 GetHash64(const u8 *src, u32 len, u32 samples)
u64 GetHash64(const u8* src, u32 len, u32 samples)
{
return ptrHashFunction(src, len, samples);
}
+4 -4
View File
@@ -11,8 +11,8 @@
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 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 GetHashHiresTexture(const u8 *src, u32 len, u32 samples = 0);
u64 GetMurmurHash3(const u8 *src, u32 len, u32 samples);
u64 GetHash64(const u8 *src, u32 len, u32 samples);
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 GetMurmurHash3(const u8* src, u32 len, u32 samples);
u64 GetHash64(const u8* src, u32 len, u32 samples);
void SetHash64Function();

Some files were not shown because too many files have changed in this diff Show More