mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-15 22:21:25 +00:00
Minor cleanup
This commit is contained in:
parent
9d8e8028a6
commit
961fc27215
@ -132,5 +132,5 @@ void log_message(Log::LogType type, Log::LogSeverity sev, std::string text);
|
||||
template<typename... Targs>
|
||||
__noinline void log_message(Log::LogType type, Log::LogSeverity sev, const char* fmt, Targs... args)
|
||||
{
|
||||
log_message(type, sev, fmt::detail::format(fmt, fmt::do_unveil(args)...));
|
||||
log_message(type, sev, fmt::Format(fmt, fmt::do_unveil(args)...));
|
||||
}
|
||||
|
@ -70,92 +70,6 @@ std::string fmt::to_sdec(s64 svalue)
|
||||
return std::string(&res[first], sizeof(res) - first);
|
||||
}
|
||||
|
||||
size_t fmt::detail::get_fmt_start(const char* fmt, size_t len)
|
||||
{
|
||||
for (size_t i = 0; i < len; i++)
|
||||
{
|
||||
if (fmt[i] == '%')
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
size_t fmt::detail::get_fmt_len(const char* fmt, size_t len)
|
||||
{
|
||||
assert(len >= 2 && fmt[0] == '%');
|
||||
|
||||
size_t res = 2;
|
||||
|
||||
if (fmt[1] == '.' || fmt[1] == '0')
|
||||
{
|
||||
assert(len >= 4 && fmt[2] - '1' < 9);
|
||||
res += 2;
|
||||
fmt += 2;
|
||||
len -= 2;
|
||||
|
||||
if (fmt[0] == '1')
|
||||
{
|
||||
assert(len >= 3 && fmt[1] - '0' < 7);
|
||||
res++;
|
||||
fmt++;
|
||||
len--;
|
||||
}
|
||||
}
|
||||
|
||||
if (fmt[1] == 'l')
|
||||
{
|
||||
assert(len >= 3);
|
||||
res++;
|
||||
fmt++;
|
||||
len--;
|
||||
}
|
||||
|
||||
if (fmt[1] == 'l')
|
||||
{
|
||||
assert(len >= 3);
|
||||
res++;
|
||||
fmt++;
|
||||
len--;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
size_t fmt::detail::get_fmt_precision(const char* fmt, size_t len)
|
||||
{
|
||||
assert(len >= 2);
|
||||
|
||||
if (fmt[1] == '.' || fmt[1] == '0')
|
||||
{
|
||||
assert(len >= 4 && fmt[2] - '1' < 9);
|
||||
|
||||
if (fmt[2] == '1')
|
||||
{
|
||||
assert(len >= 5 && fmt[3] - '0' < 7);
|
||||
return 10 + fmt[3] - '0';
|
||||
}
|
||||
|
||||
return fmt[2] - '0';
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string fmt::detail::format(const char* fmt)
|
||||
{
|
||||
const size_t len = strlen(fmt);
|
||||
const size_t fmt_start = get_fmt_start(fmt, len);
|
||||
if (fmt_start != len)
|
||||
{
|
||||
throw "Excessive formatting: " + std::string(fmt, len);
|
||||
}
|
||||
|
||||
return std::string(fmt, len);
|
||||
}
|
||||
|
||||
extern const std::string fmt::placeholder = "???";
|
||||
|
||||
std::string fmt::replace_first(const std::string& src, const std::string& from, const std::string& to)
|
||||
|
@ -177,366 +177,6 @@ namespace fmt
|
||||
std::string to_udec(u64 value);
|
||||
std::string to_sdec(s64 value);
|
||||
|
||||
std::string toupper(std::string source);
|
||||
|
||||
namespace detail
|
||||
{
|
||||
size_t get_fmt_start(const char* fmt, size_t len);
|
||||
size_t get_fmt_len(const char* fmt, size_t len);
|
||||
size_t get_fmt_precision(const char* fmt, size_t len);
|
||||
|
||||
template<typename T>
|
||||
struct get_fmt
|
||||
{
|
||||
static_assert(!sizeof(T), "Unsupported fmt::format argument");
|
||||
};
|
||||
|
||||
template<>
|
||||
struct get_fmt<u8>
|
||||
{
|
||||
static std::string text(const char* fmt, size_t len, u8 arg)
|
||||
{
|
||||
if (fmt[len - 1] == 'x')
|
||||
{
|
||||
return to_hex(arg, get_fmt_precision(fmt, len));
|
||||
}
|
||||
else if (fmt[len - 1] == 'X')
|
||||
{
|
||||
return fmt::toupper(to_hex(arg, get_fmt_precision(fmt, len)));
|
||||
}
|
||||
else if (fmt[len - 1] == 'd' || fmt[len - 1] == 'u')
|
||||
{
|
||||
return to_udec(arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw "Invalid formatting (u8): " + std::string(fmt, len);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct get_fmt<u16>
|
||||
{
|
||||
static std::string text(const char* fmt, size_t len, u16 arg)
|
||||
{
|
||||
if (fmt[len - 1] == 'x')
|
||||
{
|
||||
return to_hex(arg, get_fmt_precision(fmt, len));
|
||||
}
|
||||
else if (fmt[len - 1] == 'X')
|
||||
{
|
||||
return fmt::toupper(to_hex(arg, get_fmt_precision(fmt, len)));
|
||||
}
|
||||
else if (fmt[len - 1] == 'd' || fmt[len - 1] == 'u')
|
||||
{
|
||||
return to_udec(arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw "Invalid formatting (u16): " + std::string(fmt, len);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct get_fmt<u32>
|
||||
{
|
||||
static std::string text(const char* fmt, size_t len, u32 arg)
|
||||
{
|
||||
if (fmt[len - 1] == 'x')
|
||||
{
|
||||
return to_hex(arg, get_fmt_precision(fmt, len));
|
||||
}
|
||||
else if (fmt[len - 1] == 'X')
|
||||
{
|
||||
return fmt::toupper(to_hex(arg, get_fmt_precision(fmt, len)));
|
||||
}
|
||||
else if (fmt[len - 1] == 'd' || fmt[len - 1] == 'u')
|
||||
{
|
||||
return to_udec(arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw "Invalid formatting (u32): " + std::string(fmt, len);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef __APPLE__
|
||||
template<>
|
||||
struct get_fmt<unsigned long>
|
||||
{
|
||||
static std::string text(const char* fmt, size_t len, unsigned long arg)
|
||||
{
|
||||
if (fmt[len - 1] == 'x')
|
||||
{
|
||||
return to_hex(arg, get_fmt_precision(fmt, len));
|
||||
}
|
||||
else if (fmt[len - 1] == 'X')
|
||||
{
|
||||
return fmt::toupper(to_hex(arg, get_fmt_precision(fmt, len)));
|
||||
}
|
||||
else if (fmt[len - 1] == 'd' || fmt[len - 1] == 'u')
|
||||
{
|
||||
return to_udec(arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw "Invalid formatting (unsigned long): " + std::string(fmt, len);
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
template<>
|
||||
struct get_fmt<u64>
|
||||
{
|
||||
static std::string text(const char* fmt, size_t len, u64 arg)
|
||||
{
|
||||
if (fmt[len - 1] == 'x')
|
||||
{
|
||||
return to_hex(arg, get_fmt_precision(fmt, len));
|
||||
}
|
||||
else if (fmt[len - 1] == 'X')
|
||||
{
|
||||
return fmt::toupper(to_hex(arg, get_fmt_precision(fmt, len)));
|
||||
}
|
||||
else if (fmt[len - 1] == 'd' || fmt[len - 1] == 'u')
|
||||
{
|
||||
return to_udec(arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw "Invalid formatting (u64): " + std::string(fmt, len);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct get_fmt<s8>
|
||||
{
|
||||
static std::string text(const char* fmt, size_t len, s8 arg)
|
||||
{
|
||||
if (fmt[len - 1] == 'x')
|
||||
{
|
||||
return to_hex((u8)arg, get_fmt_precision(fmt, len));
|
||||
}
|
||||
else if (fmt[len - 1] == 'X')
|
||||
{
|
||||
return fmt::toupper(to_hex((u8)arg, get_fmt_precision(fmt, len)));
|
||||
}
|
||||
else if (fmt[len - 1] == 'd')
|
||||
{
|
||||
return to_sdec(arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw "Invalid formatting (s8): " + std::string(fmt, len);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct get_fmt<s16>
|
||||
{
|
||||
static std::string text(const char* fmt, size_t len, s16 arg)
|
||||
{
|
||||
if (fmt[len - 1] == 'x')
|
||||
{
|
||||
return to_hex((u16)arg, get_fmt_precision(fmt, len));
|
||||
}
|
||||
else if (fmt[len - 1] == 'X')
|
||||
{
|
||||
return fmt::toupper(to_hex((u16)arg, get_fmt_precision(fmt, len)));
|
||||
}
|
||||
else if (fmt[len - 1] == 'd')
|
||||
{
|
||||
return to_sdec(arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw "Invalid formatting (s16): " + std::string(fmt, len);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct get_fmt<s32>
|
||||
{
|
||||
static std::string text(const char* fmt, size_t len, s32 arg)
|
||||
{
|
||||
if (fmt[len - 1] == 'x')
|
||||
{
|
||||
return to_hex((u32)arg, get_fmt_precision(fmt, len));
|
||||
}
|
||||
else if (fmt[len - 1] == 'X')
|
||||
{
|
||||
return fmt::toupper(to_hex((u32)arg, get_fmt_precision(fmt, len)));
|
||||
}
|
||||
else if (fmt[len - 1] == 'd')
|
||||
{
|
||||
return to_sdec(arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw "Invalid formatting (s32): " + std::string(fmt, len);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef __APPLE__
|
||||
template<>
|
||||
struct get_fmt<long>
|
||||
{
|
||||
static std::string text(const char* fmt, size_t len, long arg)
|
||||
{
|
||||
if (fmt[len - 1] == 'x')
|
||||
{
|
||||
return to_hex((u64)arg, get_fmt_precision(fmt, len));
|
||||
}
|
||||
else if (fmt[len - 1] == 'X')
|
||||
{
|
||||
return fmt::toupper(to_hex((u64)arg, get_fmt_precision(fmt, len)));
|
||||
}
|
||||
else if (fmt[len - 1] == 'd')
|
||||
{
|
||||
return to_sdec(arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw "Invalid formatting (long): " + std::string(fmt, len);
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
template<>
|
||||
struct get_fmt<s64>
|
||||
{
|
||||
static std::string text(const char* fmt, size_t len, s64 arg)
|
||||
{
|
||||
if (fmt[len - 1] == 'x')
|
||||
{
|
||||
return to_hex((u64)arg, get_fmt_precision(fmt, len));
|
||||
}
|
||||
else if (fmt[len - 1] == 'X')
|
||||
{
|
||||
return fmt::toupper(to_hex((u64)arg, get_fmt_precision(fmt, len)));
|
||||
}
|
||||
else if (fmt[len - 1] == 'd')
|
||||
{
|
||||
return to_sdec(arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw "Invalid formatting (s64): " + std::string(fmt, len);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct get_fmt<float>
|
||||
{
|
||||
static std::string text(const char* fmt, size_t len, float arg)
|
||||
{
|
||||
if (fmt[len - 1] == 'x')
|
||||
{
|
||||
return to_hex((u32&)arg, get_fmt_precision(fmt, len));
|
||||
}
|
||||
else if (fmt[len - 1] == 'X')
|
||||
{
|
||||
return fmt::toupper(to_hex((u32&)arg, get_fmt_precision(fmt, len)));
|
||||
}
|
||||
else if (fmt[len - 1] == 'f')
|
||||
{
|
||||
return std::to_string(arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw "Invalid formatting (float): " + std::string(fmt, len);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct get_fmt<double>
|
||||
{
|
||||
static std::string text(const char* fmt, size_t len, double arg)
|
||||
{
|
||||
if (fmt[len - 1] == 'x')
|
||||
{
|
||||
return to_hex((u64&)arg, get_fmt_precision(fmt, len));
|
||||
}
|
||||
else if (fmt[len - 1] == 'X')
|
||||
{
|
||||
return fmt::toupper(to_hex((u64&)arg, get_fmt_precision(fmt, len)));
|
||||
}
|
||||
else if (fmt[len - 1] == 'f')
|
||||
{
|
||||
return std::to_string(arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw "Invalid formatting (double): " + std::string(fmt, len);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct get_fmt<bool>
|
||||
{
|
||||
static std::string text(const char* fmt, size_t len, bool arg)
|
||||
{
|
||||
if (fmt[len - 1] == 'x' || fmt[len - 1] == 'X')
|
||||
{
|
||||
return to_hex(arg, get_fmt_precision(fmt, len));
|
||||
}
|
||||
else if (fmt[len - 1] == 'd' || fmt[len - 1] == 'u')
|
||||
{
|
||||
return arg ? "1" : "0";
|
||||
}
|
||||
else if (fmt[len - 1] == 's')
|
||||
{
|
||||
return arg ? "true" : "false";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw "Invalid formatting (bool): " + std::string(fmt, len);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct get_fmt<const char*>
|
||||
{
|
||||
static std::string text(const char* fmt, size_t len, const char* arg)
|
||||
{
|
||||
if (fmt[len - 1] == 's')
|
||||
{
|
||||
return arg;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw "Invalid formatting (const char*): " + std::string(fmt, len);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
std::string format(const char* fmt); // terminator
|
||||
|
||||
template<typename T, typename... Args>
|
||||
std::string format(const char* fmt, const T& arg, Args... args)
|
||||
{
|
||||
const size_t len = strlen(fmt);
|
||||
const size_t fmt_start = get_fmt_start(fmt, len);
|
||||
const size_t fmt_len = get_fmt_len(fmt + fmt_start, len - fmt_start);
|
||||
const size_t fmt_end = fmt_start + fmt_len;
|
||||
|
||||
return std::string(fmt, fmt_start) + get_fmt<T>::text(fmt + fmt_start, fmt_len, arg) + format(fmt + fmt_end, args...);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, bool is_enum = std::is_enum<T>::value>
|
||||
struct unveil
|
||||
{
|
||||
@ -612,24 +252,12 @@ namespace fmt
|
||||
/*
|
||||
fmt::format(const char* fmt, args...)
|
||||
|
||||
Formatting function with very limited functionality (compared to printf-like formatting) and be_t<> support
|
||||
Formatting function with special functionality:
|
||||
|
||||
Supported types:
|
||||
std::string forced to .c_str()
|
||||
be_t<> forced to .value() (fmt::unveil reverts byte order automatically)
|
||||
|
||||
u8, s8 (%x, %d)
|
||||
u16, s16 (%x, %d)
|
||||
u32, s32 (%x, %d)
|
||||
u64, s64 (%x, %d)
|
||||
float (%x, %f)
|
||||
double (%x, %f)
|
||||
bool (%x, %d, %s)
|
||||
char* (%s)
|
||||
|
||||
std::string forced to .c_str() (fmt::unveil)
|
||||
be_t<> of any appropriate type in this list (fmt::unveil)
|
||||
enum of any appropriate type in this list (fmt::unveil)
|
||||
|
||||
External specializations (can be found in another headers):
|
||||
External specializations for fmt::unveil (can be found in another headers):
|
||||
vm::ps3::ptr (fmt::unveil) (vm_ptr.h) (with appropriate address type, using .addr() can be avoided)
|
||||
vm::ps3::bptr (fmt::unveil) (vm_ptr.h)
|
||||
vm::psv::ptr (fmt::unveil) (vm_ptr.h)
|
||||
@ -637,18 +265,11 @@ namespace fmt
|
||||
vm::ps3::bref (fmt::unveil) (vm_ref.h)
|
||||
vm::psv::ref (fmt::unveil) (vm_ref.h)
|
||||
|
||||
Supported formatting:
|
||||
%d - decimal; to_sdec() and to_udec()
|
||||
%x - hexadecimal; to_hex(), %08x - hexadecimal with minimal length (from 02 to 016)
|
||||
%s - string; generates "true" or "false" for bool
|
||||
%f - floating point; only basic std::to_string() functionality
|
||||
|
||||
Other features are not supported.
|
||||
*/
|
||||
template<typename... Args>
|
||||
__forceinline __safebuffers std::string format(const char* fmt, Args... args)
|
||||
{
|
||||
return detail::format(fmt, do_unveil(args)...);
|
||||
return Format(fmt, do_unveil(args)...);
|
||||
}
|
||||
|
||||
//convert a wxString to a std::string encoded in utf8
|
||||
|
@ -28,7 +28,6 @@ PPUThread& GetCurrentPPUThread()
|
||||
|
||||
PPUThread::PPUThread() : CPUThread(CPU_THREAD_PPU)
|
||||
{
|
||||
owned_mutexes = 0;
|
||||
Reset();
|
||||
}
|
||||
|
||||
|
@ -536,7 +536,6 @@ public:
|
||||
//TBR : Time-Base Registers
|
||||
u64 TB; //TBR 0x10C - 0x10D
|
||||
|
||||
u32 owned_mutexes;
|
||||
std::function<void(PPUThread& CPU)> custom_task;
|
||||
|
||||
public:
|
||||
|
@ -20,7 +20,7 @@ class LogBase
|
||||
template<typename... Targs>
|
||||
__noinline void LogPrepare(LogType type, const char* fmt, Targs... args) const
|
||||
{
|
||||
LogOutput(type, fmt::detail::format(fmt, args...));
|
||||
LogOutput(type, fmt::Format(fmt, args...));
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -813,7 +813,7 @@ int cellSailPlayerCancel()
|
||||
|
||||
int cellSailPlayerSetPaused(vm::ptr<CellSailPlayer> pSelf, bool paused)
|
||||
{
|
||||
cellSail.Todo("cellSailPlayerSetPaused(pSelf_addr=0x%x, paused=)", pSelf.addr(), paused);
|
||||
cellSail.Todo("cellSailPlayerSetPaused(pSelf_addr=0x%x, paused=%d)", pSelf.addr(), paused);
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
@ -10,16 +10,8 @@
|
||||
|
||||
SysCallBase sys_ppu_thread("sys_ppu_thread");
|
||||
|
||||
static const u32 PPU_THREAD_ID_INVALID = 0xFFFFFFFFU/*UUUUUUUUUUuuuuuuuuuu~~~~~~~~*/;
|
||||
|
||||
void ppu_thread_exit(PPUThread& CPU, u64 errorcode)
|
||||
{
|
||||
if (CPU.owned_mutexes)
|
||||
{
|
||||
sys_ppu_thread.Error("Owned mutexes found (%d)", CPU.owned_mutexes);
|
||||
CPU.owned_mutexes = 0;
|
||||
}
|
||||
|
||||
CPU.SetExitStatus(errorcode);
|
||||
CPU.Stop();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user