Fix travis LINT
This commit is contained in:
@@ -24,13 +24,12 @@ constexpr size_t kMaxHandlerCount = 8;
|
||||
// Executed in order.
|
||||
std::pair<ExceptionHandler::Handler, void*> handlers_[kMaxHandlerCount];
|
||||
|
||||
|
||||
void ExceptionHandler::Install(Handler fn, void* data) {
|
||||
//TODO(dougvj) stub
|
||||
// TODO(dougvj) stub
|
||||
}
|
||||
|
||||
void ExceptionHandler::Uninstall(Handler fn, void* data) {
|
||||
//TODO(dougvj) stub
|
||||
// TODO(dougvj) stub
|
||||
}
|
||||
|
||||
} // namespace xe
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
#include "xenia/base/string.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <ftw.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <ftw.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
namespace xe {
|
||||
namespace filesystem {
|
||||
@@ -26,7 +26,6 @@ bool PathExists(const std::wstring& path) {
|
||||
return stat(xe::to_string(path).c_str(), &st) == 0;
|
||||
}
|
||||
|
||||
|
||||
FILE* OpenFile(const std::wstring& path, const char* mode) {
|
||||
auto fixed_path = xe::fix_path_separators(path);
|
||||
return fopen(xe::to_string(fixed_path).c_str(), mode);
|
||||
@@ -36,23 +35,25 @@ bool CreateFolder(const std::wstring& path) {
|
||||
return mkdir(xe::to_string(path).c_str(), 0774);
|
||||
}
|
||||
|
||||
static int removeCallback(const char *fpath, const struct stat* sb,
|
||||
int typeflag, struct FTW* ftwbuf) {
|
||||
static int removeCallback(const char* fpath, const struct stat* sb,
|
||||
int typeflag, struct FTW* ftwbuf) {
|
||||
int rv = remove(fpath);
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool DeleteFolder(const std::wstring& path) {
|
||||
return nftw(xe::to_string(path).c_str(), removeCallback, 64,
|
||||
FTW_DEPTH | FTW_PHYS) == 0 ? true : false;
|
||||
FTW_DEPTH | FTW_PHYS) == 0
|
||||
? true
|
||||
: false;
|
||||
}
|
||||
|
||||
static uint64_t convertUnixtimeToWinFiletime(time_t unixtime) {
|
||||
//Linux uses number of seconds since 1/1/1970, and Windows uses
|
||||
//number of nanoseconds since 1/1/1601
|
||||
//so we convert linux time to nanoseconds and then add the number of
|
||||
//nanoseconds from 1601 to 1970
|
||||
//see https://msdn.microsoft.com/en-us/library/ms724228
|
||||
// Linux uses number of seconds since 1/1/1970, and Windows uses
|
||||
// number of nanoseconds since 1/1/1601
|
||||
// so we convert linux time to nanoseconds and then add the number of
|
||||
// nanoseconds from 1601 to 1970
|
||||
// see https://msdn.microsoft.com/en-us/library/ms724228
|
||||
uint64_t filetime = filetime = (unixtime * 10000000) + 116444736000000000;
|
||||
return filetime;
|
||||
}
|
||||
@@ -60,8 +61,7 @@ static uint64_t convertUnixtimeToWinFiletime(time_t unixtime) {
|
||||
bool IsFolder(const std::wstring& path) {
|
||||
struct stat st;
|
||||
if (stat(xe::to_string(path).c_str(), &st) == 0) {
|
||||
if (S_ISDIR(st.st_mode))
|
||||
return true;
|
||||
if (S_ISDIR(st.st_mode)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -89,11 +89,9 @@ class PosixFileHandle : public FileHandle {
|
||||
}
|
||||
bool Read(size_t file_offset, void* buffer, size_t buffer_length,
|
||||
size_t* out_bytes_read) override {
|
||||
|
||||
ssize_t out = pread(handle_, buffer, buffer_length, file_offset);
|
||||
*out_bytes_read = out;
|
||||
return out >= 0 ? true : false;
|
||||
|
||||
}
|
||||
bool Write(size_t file_offset, const void* buffer, size_t buffer_length,
|
||||
size_t* out_bytes_written) override {
|
||||
@@ -144,8 +142,7 @@ bool GetInfo(const std::wstring& path, FileInfo* out_info) {
|
||||
if (stat(xe::to_string(path).c_str(), &st) == 0) {
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
out_info->type = FileInfo::Type::kDirectory;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
out_info->type = FileInfo::Type::kFile;
|
||||
}
|
||||
out_info->create_timestamp = convertUnixtimeToWinFiletime(st.st_ctime);
|
||||
@@ -186,7 +183,5 @@ std::vector<FileInfo> ListFiles(const std::wstring& path) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
} // namespace filesystem
|
||||
} // namespace xe
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
#define XENIA_BASE_MATH_H_
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
#include <cmath>
|
||||
#include "xenia/base/platform.h"
|
||||
|
||||
#if XE_ARCH_AMD64
|
||||
|
||||
@@ -18,5 +18,4 @@ void LaunchBrowser(const char* url) {
|
||||
system(cmd.c_str());
|
||||
}
|
||||
|
||||
|
||||
} // namespace xe
|
||||
|
||||
@@ -18,15 +18,15 @@
|
||||
|
||||
// Xlib/Xcb is used only for GLX/Vulkan interaction, the window management
|
||||
// and input events are done with gtk/gdk
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xlib-xcb.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xos.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
//Used for window management. Gtk is for GUI and wigets, gdk is for lower
|
||||
//level events like key presses, mouse events, window handles, etc
|
||||
#include <gtk/gtk.h>
|
||||
// Used for window management. Gtk is for GUI and wigets, gdk is for lower
|
||||
// level events like key presses, mouse events, window handles, etc
|
||||
#include <gdk/gdkx.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#endif // XENIA_BASE_PLATFORM_X11_H_
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
#include <climits>
|
||||
#include <condition_variable>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
namespace xe {
|
||||
namespace threading {
|
||||
|
||||
@@ -13,8 +13,5 @@
|
||||
#include <time.h>
|
||||
|
||||
namespace xe {
|
||||
namespace threading {
|
||||
|
||||
|
||||
} // namespace threading
|
||||
namespace threading {} // namespace threading
|
||||
} // namespace xe
|
||||
|
||||
@@ -14,18 +14,16 @@
|
||||
|
||||
#include <pthread.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace xe {
|
||||
namespace threading {
|
||||
|
||||
//TODO(dougvj)
|
||||
void EnableAffinityConfiguration() {
|
||||
|
||||
}
|
||||
// TODO(dougvj)
|
||||
void EnableAffinityConfiguration() {}
|
||||
|
||||
// uint64_t ticks() { return mach_absolute_time(); }
|
||||
|
||||
@@ -46,9 +44,7 @@ void MaybeYield() {
|
||||
__sync_synchronize();
|
||||
}
|
||||
|
||||
void SyncMemory() {
|
||||
__sync_synchronize();
|
||||
}
|
||||
void SyncMemory() { __sync_synchronize(); }
|
||||
|
||||
void Sleep(std::chrono::microseconds duration) {
|
||||
timespec rqtp = {time_t(duration.count() / 1000000),
|
||||
@@ -57,35 +53,28 @@ void Sleep(std::chrono::microseconds duration) {
|
||||
// TODO(benvanik): spin while rmtp >0?
|
||||
}
|
||||
|
||||
//TODO(dougvj) Not sure how to implement the equivalent of this on POSIX.
|
||||
// TODO(dougvj) Not sure how to implement the equivalent of this on POSIX.
|
||||
SleepResult AlertableSleep(std::chrono::microseconds duration) {
|
||||
sleep(duration.count() / 1000);
|
||||
return SleepResult::kSuccess;
|
||||
}
|
||||
|
||||
//TODO(dougvj) We can probably wrap this with pthread_key_t but the type of
|
||||
//TlsHandle probably needs to be refactored
|
||||
TlsHandle AllocateTlsHandle() {
|
||||
assert_always();
|
||||
}
|
||||
// TODO(dougvj) We can probably wrap this with pthread_key_t but the type of
|
||||
// TlsHandle probably needs to be refactored
|
||||
TlsHandle AllocateTlsHandle() { assert_always(); }
|
||||
|
||||
bool FreeTlsHandle(TlsHandle handle) { return true; }
|
||||
|
||||
uintptr_t GetTlsValue(TlsHandle handle) {
|
||||
assert_always();
|
||||
}
|
||||
uintptr_t GetTlsValue(TlsHandle handle) { assert_always(); }
|
||||
|
||||
bool SetTlsValue(TlsHandle handle, uintptr_t value) {
|
||||
assert_always();
|
||||
}
|
||||
bool SetTlsValue(TlsHandle handle, uintptr_t value) { assert_always(); }
|
||||
|
||||
//TODO(dougvj)
|
||||
// TODO(dougvj)
|
||||
class PosixHighResolutionTimer : public HighResolutionTimer {
|
||||
public:
|
||||
PosixHighResolutionTimer(std::function<void()> callback)
|
||||
: callback_(callback) {}
|
||||
~PosixHighResolutionTimer() override {
|
||||
}
|
||||
~PosixHighResolutionTimer() override {}
|
||||
|
||||
bool Initialize(std::chrono::milliseconds period) {
|
||||
assert_always();
|
||||
@@ -111,7 +100,7 @@ std::unique_ptr<HighResolutionTimer> HighResolutionTimer::CreateRepeating(
|
||||
// some more functionality
|
||||
class PosixCondition {
|
||||
public:
|
||||
PosixCondition(): signal_(false) {
|
||||
PosixCondition() : signal_(false) {
|
||||
pthread_mutex_init(&mutex_, NULL);
|
||||
pthread_cond_init(&cond_, NULL);
|
||||
}
|
||||
@@ -135,7 +124,7 @@ class PosixCondition {
|
||||
}
|
||||
|
||||
bool Wait(unsigned int timeout_ms) {
|
||||
//Assume 0 means no timeout, not instant timeout
|
||||
// Assume 0 means no timeout, not instant timeout
|
||||
if (timeout_ms == 0) {
|
||||
Wait();
|
||||
}
|
||||
@@ -143,42 +132,40 @@ class PosixCondition {
|
||||
struct timeval now;
|
||||
gettimeofday(&now, NULL);
|
||||
|
||||
//Add the number of seconds we want to wait to the current time
|
||||
time_to_wait.tv_sec = now.tv_sec + (timeout_ms/1000);
|
||||
//Add the number of nanoseconds we want to wait to the current nanosecond
|
||||
//stride
|
||||
long nsec = (now.tv_usec+(timeout_ms % 1000)) * 1000;
|
||||
//If we overflowed the nanosecond count then we add a second
|
||||
time_to_wait.tv_sec += nsec/1000000000UL;
|
||||
//We only add nanoseconds within the 1 second stride
|
||||
// Add the number of seconds we want to wait to the current time
|
||||
time_to_wait.tv_sec = now.tv_sec + (timeout_ms / 1000);
|
||||
// Add the number of nanoseconds we want to wait to the current nanosecond
|
||||
// stride
|
||||
long nsec = (now.tv_usec + (timeout_ms % 1000)) * 1000;
|
||||
// If we overflowed the nanosecond count then we add a second
|
||||
time_to_wait.tv_sec += nsec / 1000000000UL;
|
||||
// We only add nanoseconds within the 1 second stride
|
||||
time_to_wait.tv_nsec = nsec % 1000000000UL;
|
||||
pthread_mutex_lock(&mutex_);
|
||||
while(!signal_) {
|
||||
while (!signal_) {
|
||||
int status = pthread_cond_timedwait(&cond_, &mutex_, &time_to_wait);
|
||||
if (status == ETIMEDOUT)
|
||||
return false; //We timed out
|
||||
if (status == ETIMEDOUT) return false; // We timed out
|
||||
}
|
||||
pthread_mutex_unlock(&mutex_);
|
||||
return true; //We didn't time out
|
||||
return true; // We didn't time out
|
||||
}
|
||||
|
||||
bool Wait() {
|
||||
pthread_mutex_lock(&mutex_);
|
||||
while(!signal_) {
|
||||
while (!signal_) {
|
||||
pthread_cond_wait(&cond_, &mutex_);
|
||||
}
|
||||
pthread_mutex_unlock(&mutex_);
|
||||
return true; //Did not time out;
|
||||
return true; // Did not time out;
|
||||
}
|
||||
|
||||
private:
|
||||
bool signal_;
|
||||
pthread_cond_t cond_;
|
||||
pthread_mutex_t mutex_;
|
||||
|
||||
};
|
||||
|
||||
//Native posix thread handle
|
||||
// Native posix thread handle
|
||||
template <typename T>
|
||||
class PosixThreadHandle : public T {
|
||||
public:
|
||||
@@ -193,8 +180,8 @@ class PosixThreadHandle : public T {
|
||||
pthread_t handle_;
|
||||
};
|
||||
|
||||
//This is wraps a condition object as our handle because posix has no single
|
||||
//native handle for higher level concurrency constructs such as semaphores
|
||||
// This is wraps a condition object as our handle because posix has no single
|
||||
// native handle for higher level concurrency constructs such as semaphores
|
||||
template <typename T>
|
||||
class PosixConditionHandle : public T {
|
||||
public:
|
||||
@@ -208,10 +195,9 @@ class PosixConditionHandle : public T {
|
||||
PosixCondition handle_;
|
||||
};
|
||||
|
||||
|
||||
// TODO(dougvj)
|
||||
WaitResult Wait(WaitHandle* wait_handle, bool is_alertable,
|
||||
std::chrono::milliseconds timeout) {
|
||||
std::chrono::milliseconds timeout) {
|
||||
assert_always();
|
||||
return WaitResult::kFailed;
|
||||
}
|
||||
@@ -233,15 +219,15 @@ std::pair<WaitResult, size_t> WaitMultiple(WaitHandle* wait_handles[],
|
||||
return std::pair<WaitResult, size_t>(WaitResult::kFailed, 0);
|
||||
}
|
||||
|
||||
|
||||
//TODO(dougvj)
|
||||
class PosixEvent: public PosixConditionHandle<Event> {
|
||||
// TODO(dougvj)
|
||||
class PosixEvent : public PosixConditionHandle<Event> {
|
||||
public:
|
||||
PosixEvent(bool initial_state, int auto_reset) { assert_always(); }
|
||||
~PosixEvent() override = default;
|
||||
void Set() override { assert_always(); }
|
||||
void Reset() override { assert_always(); }
|
||||
void Pulse() override { assert_always(); }
|
||||
|
||||
private:
|
||||
PosixCondition condition_;
|
||||
};
|
||||
@@ -254,7 +240,7 @@ std::unique_ptr<Event> Event::CreateAutoResetEvent(bool initial_state) {
|
||||
return std::make_unique<PosixEvent>(PosixEvent(initial_state, true));
|
||||
}
|
||||
|
||||
//TODO(dougvj)
|
||||
// TODO(dougvj)
|
||||
class PosixSemaphore : public PosixConditionHandle<Semaphore> {
|
||||
public:
|
||||
PosixSemaphore(int initial_count, int maximum_count) { assert_always(); }
|
||||
@@ -270,22 +256,22 @@ std::unique_ptr<Semaphore> Semaphore::Create(int initial_count,
|
||||
return std::make_unique<PosixSemaphore>(initial_count, maximum_count);
|
||||
}
|
||||
|
||||
//TODO(dougvj)
|
||||
// TODO(dougvj)
|
||||
class PosixMutant : public PosixConditionHandle<Mutant> {
|
||||
public:
|
||||
PosixMutant(bool initial_owner) {
|
||||
assert_always();
|
||||
}
|
||||
PosixMutant(bool initial_owner) { assert_always(); }
|
||||
~PosixMutant() = default;
|
||||
bool Release() override { assert_always(); return false; }
|
||||
private:
|
||||
bool Release() override {
|
||||
assert_always();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
std::unique_ptr<Mutant> Mutant::Create(bool initial_owner) {
|
||||
return std::make_unique<PosixMutant>(initial_owner);
|
||||
}
|
||||
|
||||
//TODO(dougvj)
|
||||
// TODO(dougvj)
|
||||
class PosixTimer : public PosixConditionHandle<Timer> {
|
||||
public:
|
||||
PosixTimer(bool manual_reset) { assert_always(); }
|
||||
@@ -305,7 +291,6 @@ class PosixTimer : public PosixConditionHandle<Timer> {
|
||||
assert_always();
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
std::unique_ptr<Timer> Timer::CreateManualResetTimer() {
|
||||
|
||||
Reference in New Issue
Block a user