From 24eb626ccebea26987fcb22ea363f905a362b9e6 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Tue, 14 Mar 2017 10:10:30 -0700 Subject: [PATCH] clang compile fixes --- ipc.h | 11 ++++++++++- platform_linux.cc | 16 ++++------------ platform_win.cc | 4 +++- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/ipc.h b/ipc.h index 7b73a5d3..e6c2fe14 100644 --- a/ipc.h +++ b/ipc.h @@ -11,6 +11,7 @@ #include "platform.h" #include "serializer.h" +#include "utils.h" // TODO: We need to add support for payloads larger than the maximum shared memory buffer size. @@ -36,6 +37,14 @@ enum class IpcId : int { WorkspaceSymbolsResponse }; +namespace std { + template <> + struct hash { + size_t operator()(const IpcId& k) const { + return hash()(static_cast(k)); + } + }; +} struct IpcMessage { IpcMessage(IpcId ipc_id) : ipc_id(ipc_id) {} @@ -135,4 +144,4 @@ struct IpcClient { private: IpcDirectionalChannel server_; IpcDirectionalChannel client_; -}; \ No newline at end of file +}; diff --git a/platform_linux.cc b/platform_linux.cc index 90db75fe..d729acab 100644 --- a/platform_linux.cc +++ b/platform_linux.cc @@ -54,7 +54,6 @@ struct PlatformScopedMutexLockLinux : public PlatformScopedMutexLock { struct PlatformSharedMemoryLinux : public PlatformSharedMemory { std::string name_; int fd_; - void* shared_start_real_; PlatformSharedMemoryLinux(const std::string& name) : name_(name) { std::cout << "PlatformSharedMemoryLinux name=" << name << std::endl; @@ -71,11 +70,11 @@ struct PlatformSharedMemoryLinux : public PlatformSharedMemory { // //shmem_size std::cout << "3" << std::endl; - shared_start_real_ = mmap(nullptr /*kernel assigned starting address*/, + shared = mmap(nullptr /*kernel assigned starting address*/, shmem_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd_, 0 /*offset*/); std::cout << "mmap errno=" << errno << std::endl; std::cout << "fd_ = " << fd_ << std::endl; - std::cout << "shared_start_real_ = " << shared_start_real_ << std::endl; + std::cout << "shared = " << shared << std::endl; std::cout << "4" << std::endl; /* @@ -85,18 +84,11 @@ struct PlatformSharedMemoryLinux : public PlatformSharedMemory { sem_init(sem, 1, 1); */ - - std::cout << "4a" << std::endl; - shared_bytes_used = reinterpret_cast(shared_start_real_); - std::cout << "4b" << std::endl; - *shared_bytes_used = 0; - std::cout << "4c" << std::endl; - shared_start = reinterpret_cast(shared_bytes_used + 1); - std::cout << "5" << std::endl; } ~PlatformSharedMemoryLinux() override { - munmap(shared_start_real_, shmem_size); + munmap(shared, shmem_size); + shared = nullptr; shm_unlink(name_.c_str()); } }; diff --git a/platform_win.cc b/platform_win.cc index 0a76484d..fbc01a65 100644 --- a/platform_win.cc +++ b/platform_win.cc @@ -1,3 +1,4 @@ +#ifdef _MSC_VER #include "platform.h" #include @@ -85,4 +86,5 @@ std::string getexepath() { ssize_t count = readlink( "/proc/self/exe", result, PATH_MAX ); return std::string( result, (count > 0) ? count : 0 ); } -*/ \ No newline at end of file +*/ +#endif