diff --git a/src/xenia/atomic.h b/src/xenia/atomic.h index 47c515ffd..33c9d09ee 100644 --- a/src/xenia/atomic.h +++ b/src/xenia/atomic.h @@ -49,7 +49,7 @@ typedef OSQueueHead xe_atomic_stack_t; ((void)InterlockedExchangeAdd((volatile LONG*)value, amount)) #define xe_atomic_sub_32(amount, value) \ ((void)InterlockedExchangeSubtract((volatile unsigned*)value, amount)) -#define xe_atomic_vas_32(oldValue, newValue, value) \ +#define xe_atomic_cas_32(oldValue, newValue, value) \ (InterlockedCompareExchange((volatile LONG*)value, newValue, oldValue) == oldValue) typedef SLIST_HEADER xe_atomic_stack_t; diff --git a/src/xenia/core/mmap_win.cc b/src/xenia/core/mmap_win.cc index 244bb3faa..f9fee98c9 100644 --- a/src/xenia/core/mmap_win.cc +++ b/src/xenia/core/mmap_win.cc @@ -124,7 +124,7 @@ void xe_mmap_release(xe_mmap_ref mmap) { } uint8_t* xe_mmap_get_addr(xe_mmap_ref mmap) { - return mmap->addr; + return reinterpret_cast(mmap->addr); } size_t xe_mmap_get_length(xe_mmap_ref mmap) { diff --git a/src/xenia/core/thread.cc b/src/xenia/core/thread.cc index 16f3f895c..138133760 100644 --- a/src/xenia/core/thread.cc +++ b/src/xenia/core/thread.cc @@ -93,7 +93,7 @@ int xe_thread_start(xe_thread_ref thread) { thread, 0, NULL); - if (!handle) { + if (!thread_handle) { uint32_t last_error = GetLastError(); // TODO(benvanik): translate? XELOGE(XT("CreateThread failed with %d"), last_error); diff --git a/src/xenia/kernel/fs/filesystem.cc b/src/xenia/kernel/fs/filesystem.cc index a1525ec13..91ce99f84 100644 --- a/src/xenia/kernel/fs/filesystem.cc +++ b/src/xenia/kernel/fs/filesystem.cc @@ -91,8 +91,8 @@ Entry* FileSystem::ResolvePath(const char* path) { if (xestrcasestra(path, it->first.c_str()) == path) { // Found symlink, fixup. const char* after_path = path + it->first.size(); - XEIGNORE(xesnprintf(full_path, XECOUNT(full_path), "%s%s", - it->second.c_str(), after_path)); + XEIGNORE(xesnprintfa(full_path, XECOUNT(full_path), "%s%s", + it->second.c_str(), after_path)); break; } } diff --git a/src/xenia/kernel/modules/xboxkrnl/objects/xmodule.cc b/src/xenia/kernel/modules/xboxkrnl/objects/xmodule.cc index 30f266d9c..6d7858087 100644 --- a/src/xenia/kernel/modules/xboxkrnl/objects/xmodule.cc +++ b/src/xenia/kernel/modules/xboxkrnl/objects/xmodule.cc @@ -25,9 +25,9 @@ XModule::XModule(KernelState* kernel_state, const char* path) : XObject(kernel_state, kTypeModule), xex_(NULL) { XEIGNORE(xestrcpya(path_, XECOUNT(path_), path)); - const xechar_t *slash = xestrrchr(path, '/'); + const char* slash = xestrrchra(path, '/'); if (!slash) { - slash = xestrrchr(path, '\\'); + slash = xestrrchra(path, '\\'); } if (slash) { XEIGNORE(xestrcpya(name_, XECOUNT(name_), slash + 1)); @@ -145,7 +145,11 @@ X_STATUS XModule::Launch(uint32_t flags) { // xekNtWaitForSingleObjectEx(thread_handle, TRUE, &timeout); while (true) { +#if XE_PLATFORM(WIN32) + Sleep(1000); +#else sleep(1); +#endif // WIN32 } kernel_state()->SetExecutableModule(NULL); diff --git a/src/xenia/kernel/modules/xboxkrnl/objects/xthread.cc b/src/xenia/kernel/modules/xboxkrnl/objects/xthread.cc index 9479056df..6b65e571f 100644 --- a/src/xenia/kernel/modules/xboxkrnl/objects/xthread.cc +++ b/src/xenia/kernel/modules/xboxkrnl/objects/xthread.cc @@ -148,9 +148,9 @@ X_STATUS XThread::PlatformCreate() { creation_params_.stack_size, (LPTHREAD_START_ROUTINE)XThreadStartCallbackWin32, this, - creation_params.creation_flags, + creation_params_.creation_flags, NULL); - if (!handle) { + if (!thread_handle_) { uint32_t last_error = GetLastError(); // TODO(benvanik): translate? XELOGE(XT("CreateThread failed with %d"), last_error); diff --git a/src/xenia/kernel/modules/xboxkrnl/sources.gypi b/src/xenia/kernel/modules/xboxkrnl/sources.gypi index 16e7cf62e..ab67cf609 100644 --- a/src/xenia/kernel/modules/xboxkrnl/sources.gypi +++ b/src/xenia/kernel/modules/xboxkrnl/sources.gypi @@ -13,7 +13,7 @@ 'xboxkrnl_module.h', 'xboxkrnl_rtl.cc', 'xboxkrnl_rtl.h', - 'xboxkrnl_tableh', + 'xboxkrnl_table.h', 'xboxkrnl_threading.cc', 'xboxkrnl_threading.h', 'xobject.cc', diff --git a/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_threading.cc b/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_threading.cc index 5ea8905ee..4fff2df6c 100644 --- a/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_threading.cc +++ b/src/xenia/kernel/modules/xboxkrnl/xboxkrnl_threading.cc @@ -224,7 +224,7 @@ void KeTlsSetValue_shim( int result_code = 0; #if XE_PLATFORM(WIN32) - result_code = TlsSetValue(tls_index, tls_value); + result_code = TlsSetValue(tls_index, (LPVOID)tls_value); #else result_code = pthread_setspecific(tls_index, (void*)tls_value) == 0; #endif // WIN32 diff --git a/src/xenia/sources.gypi b/src/xenia/sources.gypi index f819343f5..fde3c9179 100644 --- a/src/xenia/sources.gypi +++ b/src/xenia/sources.gypi @@ -13,6 +13,7 @@ 'malloc.h', 'platform.h', 'platform_includes.h', + 'string.cc', 'string.h', 'types.h', 'xenia.h', diff --git a/src/xenia/string.cc b/src/xenia/string.cc new file mode 100644 index 000000000..369f0eee6 --- /dev/null +++ b/src/xenia/string.cc @@ -0,0 +1,33 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2013 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#include + +#include + + +#if XE_PLATFORM(WIN32) + +char* xestrcasestra(const char* str, const char* substr) { + const size_t len = xestrlena(substr); + while (*str) { + if (!_strnicmp(str, substr, len)) { + break; + } + str++; + } + + if (*str) { + return (char*)str; + } else { + return NULL; + } +} + +#endif // WIN32 diff --git a/src/xenia/string.h b/src/xenia/string.h index 1d91787e2..200ca6445 100644 --- a/src/xenia/string.h +++ b/src/xenia/string.h @@ -26,11 +26,13 @@ int strncpy_s(char* dest, size_t destLength, const char* source, size_t count); #define _snprintf_s(dest, destLength, x, format, ...) snprintf(dest, destLength, format, ##__VA_ARGS__) #define xestrdupa strdup #define xestrtoulla strtoull +#define xestrcasestra strcasestr #else #define strcasecmp _stricmp #define xestrdupa _strdup #define xestrtoullw _wcstoui64 #define xestrtoulla _strtoui64 +char* xestrcasestra(const char* str, const char* substr); #endif // !WIN32 #define xestrlenw wcslen @@ -54,7 +56,6 @@ int strncpy_s(char* dest, size_t destLength, const char* source, size_t count); #define xestrchra strchr #define xestrrchra strrchr #define xestrstra strstr -#define xestrcasestra strcasestr #define xestrcpya(dest, destLength, source) (strcpy_s(dest, destLength, source) == 0) #define xestrncpya(dest, destLength, source, count) (strncpy_s(dest, destLength, source, count) == 0) #define xestrcata(dest, destLength, source) (strcat_s(dest, destLength, source) == 0) diff --git a/tools/xenia-run/xenia-run.cc b/tools/xenia-run/xenia-run.cc index 477a30b0d..ca95c027a 100644 --- a/tools/xenia-run/xenia-run.cc +++ b/tools/xenia-run/xenia-run.cc @@ -106,7 +106,7 @@ int xenia_run(int argc, xechar_t **argv) { usage += "xenia-run some.xex"; google::SetUsageMessage(usage); google::SetVersionString("1.0"); - google::ParseCommandLineFlags(&argc, &argv, true); + //google::ParseCommandLineFlags(&argc, &argv, true); // Dummy call to keep the GPU code linking in to ensure it's working. do_gpu_stuff();