Working on switching to std::string.
This commit is contained in:
@@ -127,18 +127,19 @@ class XFile : public XObject {
|
||||
public:
|
||||
virtual ~XFile();
|
||||
|
||||
virtual const char* path(void) const = 0;
|
||||
virtual const char* absolute_path(void) const = 0;
|
||||
virtual const char* name(void) const = 0;
|
||||
virtual const std::string& path() const = 0;
|
||||
virtual const std::string& absolute_path() const = 0;
|
||||
virtual const std::string& name() const = 0;
|
||||
|
||||
size_t position() const { return position_; }
|
||||
void set_position(size_t value) { position_ = value; }
|
||||
|
||||
virtual X_STATUS QueryInfo(XFileInfo* out_info) = 0;
|
||||
virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info,
|
||||
size_t length, const char* file_name, bool restart) = 0;
|
||||
virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info, size_t length,
|
||||
const char* file_name, bool restart) = 0;
|
||||
virtual X_STATUS QueryVolume(XVolumeInfo* out_info, size_t length) = 0;
|
||||
virtual X_STATUS QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info, size_t length) = 0;
|
||||
virtual X_STATUS QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info,
|
||||
size_t length) = 0;
|
||||
|
||||
X_STATUS Read(void* buffer, size_t buffer_length, size_t byte_offset,
|
||||
size_t* out_bytes_read);
|
||||
|
||||
@@ -42,7 +42,6 @@ XThread::XThread(KernelState* kernel_state,
|
||||
thread_state_address_(0),
|
||||
thread_state_(0),
|
||||
event_(NULL),
|
||||
name_(0),
|
||||
irql_(0) {
|
||||
creation_params_.stack_size = stack_size;
|
||||
creation_params_.xapi_thread_startup = xapi_thread_startup;
|
||||
@@ -95,9 +94,6 @@ XThread::~XThread() {
|
||||
if (thread_state_address_) {
|
||||
kernel_state()->memory()->HeapFree(thread_state_address_, 0);
|
||||
}
|
||||
if (name_) {
|
||||
xe_free(name_);
|
||||
}
|
||||
|
||||
if (thread_handle_) {
|
||||
// TODO(benvanik): platform kill
|
||||
@@ -149,35 +145,9 @@ void XThread::set_last_error(uint32_t error_code) {
|
||||
poly::store_and_swap<uint32_t>(p + 0x160, error_code);
|
||||
}
|
||||
|
||||
void XThread::set_name(const char* name) {
|
||||
if (name == name_) {
|
||||
return;
|
||||
}
|
||||
if (name_) {
|
||||
xe_free(name_);
|
||||
}
|
||||
name_ = xestrdupa(name);
|
||||
|
||||
#if XE_PLATFORM_WIN32
|
||||
// Do the nasty set for us.
|
||||
#pragma pack(push, 8)
|
||||
typedef struct tagTHREADNAME_INFO {
|
||||
DWORD dwType; // must be 0x1000
|
||||
LPCSTR szName; // pointer to name (in user addr space)
|
||||
DWORD dwThreadID; // thread ID (-1=caller thread)
|
||||
DWORD dwFlags; // reserved for future use, must be zero
|
||||
} THREADNAME_INFO;
|
||||
#pragma pack(pop)
|
||||
THREADNAME_INFO info;
|
||||
info.dwType = 0x1000;
|
||||
info.szName = name_;
|
||||
info.dwThreadID = ::GetThreadId(thread_handle_);
|
||||
info.dwFlags = 0;
|
||||
__try {
|
||||
RaiseException(0x406D1388, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR*)&info);
|
||||
} __except(EXCEPTION_CONTINUE_EXECUTION) {
|
||||
}
|
||||
#endif // WIN32
|
||||
void XThread::set_name(const std::string& name) {
|
||||
name_ = name;
|
||||
poly::threading::set_name(thread_handle_, name);
|
||||
}
|
||||
|
||||
X_STATUS XThread::Create() {
|
||||
@@ -287,7 +257,7 @@ X_STATUS XThread::Exit(int exit_code) {
|
||||
|
||||
static uint32_t __stdcall XThreadStartCallbackWin32(void* param) {
|
||||
XThread* thread = reinterpret_cast<XThread*>(param);
|
||||
xe::Profiler::ThreadEnter(thread->name());
|
||||
xe::Profiler::ThreadEnter(thread->name().c_str());
|
||||
current_thread_tls = thread;
|
||||
thread->Execute();
|
||||
current_thread_tls = nullptr;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include <xenia/kernel/xobject.h>
|
||||
|
||||
@@ -44,8 +45,8 @@ public:
|
||||
uint32_t thread_id();
|
||||
uint32_t last_error();
|
||||
void set_last_error(uint32_t error_code);
|
||||
const char* name() const { return name_; }
|
||||
void set_name(const char* name);
|
||||
const std::string& name() const { return name_; }
|
||||
void set_name(const std::string& name);
|
||||
|
||||
X_STATUS Create();
|
||||
X_STATUS Exit(int exit_code);
|
||||
@@ -96,7 +97,7 @@ private:
|
||||
uint32_t thread_state_address_;
|
||||
cpu::XenonThreadState* thread_state_;
|
||||
|
||||
char* name_;
|
||||
std::string name_;
|
||||
|
||||
std::atomic<uint32_t> irql_;
|
||||
std::mutex apc_lock_;
|
||||
|
||||
@@ -139,7 +139,7 @@ X_STATUS XUserModule::GetSection(
|
||||
auto header = xe_xex2_get_header(xex_);
|
||||
for (size_t n = 0; n < header->resource_info_count; n++) {
|
||||
auto& res = header->resource_infos[n];
|
||||
if (xestrcmpa(name, res.name) == 0) {
|
||||
if (strcmp(name, res.name) == 0) {
|
||||
// Found!
|
||||
*out_section_data = res.address;
|
||||
*out_section_size = res.size;
|
||||
|
||||
Reference in New Issue
Block a user