Linux tweaks.
This commit is contained in:
@@ -102,17 +102,17 @@ inline int32_t atomic_dec(volatile int32_t* value) {
|
||||
}
|
||||
|
||||
inline int32_t atomic_exchange(int32_t new_value, volatile int32_t* value) {
|
||||
return __sync_val_compare_and_swap(*value, value, new_value);
|
||||
return __sync_val_compare_and_swap(value, *value, new_value);
|
||||
}
|
||||
inline int64_t atomic_exchange(int64_t new_value, volatile int64_t* value) {
|
||||
return __sync_val_compare_and_swap(*value, value, new_value);
|
||||
return __sync_val_compare_and_swap(value, *value, new_value);
|
||||
}
|
||||
|
||||
inline int32_t atomic_exchange_add(int32_t amount, volatile int32_t* value) {
|
||||
return __sync_fetch_and_add(amount, value);
|
||||
return __sync_fetch_and_add(value, amount);
|
||||
}
|
||||
inline int64_t atomic_exchange_add(int64_t amount, volatile int64_t* value) {
|
||||
return __sync_fetch_and_add(amount, value);
|
||||
return __sync_fetch_and_add(value, amount);
|
||||
}
|
||||
|
||||
inline bool atomic_cas(int32_t old_value, int32_t new_value,
|
||||
|
||||
@@ -31,15 +31,7 @@ namespace xe {
|
||||
do { \
|
||||
} while (false)
|
||||
|
||||
#if XE_COMPILER_GNUC
|
||||
#define XE_LOG_LINE_ATTRIBUTE __attribute__((format(printf, 5, 6)))
|
||||
#else
|
||||
#define XE_LOG_LINE_ATTRIBUTE
|
||||
#endif // XE_COMPILER_GNUC
|
||||
void log_line(const char level_char, const char* fmt,
|
||||
...) XE_LOG_LINE_ATTRIBUTE;
|
||||
#undef XE_LOG_LINE_ATTRIBUTE
|
||||
|
||||
void log_line(const char level_char, const char* fmt, ...);
|
||||
void handle_fatal(const char* fmt, ...);
|
||||
|
||||
#if XE_OPTION_ENABLE_LOGGING
|
||||
|
||||
@@ -39,11 +39,11 @@ std::unique_ptr<MappedMemory> MappedMemory::Open(const std::wstring& path,
|
||||
const char* mode_str;
|
||||
int prot;
|
||||
switch (mode) {
|
||||
case Mode::READ:
|
||||
case Mode::kRead:
|
||||
mode_str = "rb";
|
||||
prot = PROT_READ;
|
||||
break;
|
||||
case Mode::READ_WRITE:
|
||||
case Mode::kReadWrite:
|
||||
mode_str = "r+b";
|
||||
prot = PROT_READ | PROT_WRITE;
|
||||
break;
|
||||
|
||||
@@ -9,20 +9,34 @@
|
||||
|
||||
#include "xenia/base/string.h"
|
||||
|
||||
// TODO(benvanik): when GCC finally gets codecvt, use that.
|
||||
#if XE_PLATFORM_LINUX
|
||||
#define NO_CODECVT 1
|
||||
#else
|
||||
#include <codecvt>
|
||||
#endif // XE_PLATFORM_LINUX
|
||||
|
||||
#include <cstring>
|
||||
#include <locale>
|
||||
|
||||
namespace xe {
|
||||
|
||||
std::string to_string(const std::wstring& source) {
|
||||
static std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
||||
#if NO_CODECVT
|
||||
return std::string(source.begin(), source.end());
|
||||
#else
|
||||
static std::wstring_convert<std::codecvt_utf8_utf16<wchar_t> > converter;
|
||||
return converter.to_bytes(source);
|
||||
#endif // XE_PLATFORM_LINUX
|
||||
}
|
||||
|
||||
std::wstring to_wstring(const std::string& source) {
|
||||
static std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
||||
#if NO_CODECVT
|
||||
return std::wstring(source.begin(), source.end());
|
||||
#else
|
||||
static std::wstring_convert<std::codecvt_utf8_utf16<wchar_t> > converter;
|
||||
return converter.from_bytes(source);
|
||||
#endif // XE_PLATFORM_LINUX
|
||||
}
|
||||
|
||||
std::string::size_type find_first_of_case(const std::string& target,
|
||||
|
||||
21
src/xenia/base/threading_linux.cc
Normal file
21
src/xenia/base/threading_linux.cc
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2015 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "xenia/base/threading.h"
|
||||
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
|
||||
namespace xe {
|
||||
namespace threading {
|
||||
|
||||
void MaybeYield() { pthread_yield(); }
|
||||
|
||||
} // namespace threading
|
||||
} // namespace xe
|
||||
@@ -30,8 +30,6 @@ void set_name(std::thread::native_handle_type handle, const std::string& name) {
|
||||
pthread_setname_np(pthread_self(), name.c_str());
|
||||
}
|
||||
|
||||
void MaybeYield() { pthread_yield_np(); }
|
||||
|
||||
void Sleep(std::chrono::microseconds duration) {
|
||||
timespec rqtp = {duration.count() / 1000000, duration.count() % 1000};
|
||||
nanosleep(&rqtp, nullptr);
|
||||
|
||||
Reference in New Issue
Block a user