Windows compat fixes.

This commit is contained in:
Ben Vanik 2013-02-06 10:04:34 -08:00
parent 2521d64615
commit 7435a327f7
12 changed files with 52 additions and 13 deletions

View File

@ -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;

View File

@ -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<uint8_t*>(mmap->addr);
}
size_t xe_mmap_get_length(xe_mmap_ref mmap) {

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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',

View File

@ -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

View File

@ -13,6 +13,7 @@
'malloc.h',
'platform.h',
'platform_includes.h',
'string.cc',
'string.h',
'types.h',
'xenia.h',

33
src/xenia/string.cc Normal file
View File

@ -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 <xenia/string.h>
#include <xenia/common.h>
#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

View File

@ -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)

View File

@ -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();