From: Christopher Dykes Date: Mon, 9 May 2016 18:36:21 +0000 (-0700) Subject: Fix a few issues in the portability headers X-Git-Tag: 2016.07.26~265 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ab239ddffc55d6cbc0d0293f78882d3cdd11d5ef;p=folly.git Fix a few issues in the portability headers Summary: This fixes a few issues in the portability headers for MSVC. Not entirely sure how I managed to cause these in the first place, but this fixes them anyways. Reviewed By: yfeldblum Differential Revision: D3271859 fbshipit-source-id: 11a5d35246f29112563ee9079525aa37ced206ff --- diff --git a/folly/portability/Memory.cpp b/folly/portability/Memory.cpp index a589027d..e5623877 100644 --- a/folly/portability/Memory.cpp +++ b/folly/portability/Memory.cpp @@ -44,7 +44,7 @@ void aligned_free(void* aligned_ptr) { #include // nolint void* aligned_malloc(size_t size, size_t align) { - return _aligned_malloc(size, alignment); + return _aligned_malloc(size, align); } void aligned_free(void* aligned_ptr) { diff --git a/folly/portability/PThread.h b/folly/portability/PThread.h index 4bfecef7..bd382635 100755 --- a/folly/portability/PThread.h +++ b/folly/portability/PThread.h @@ -87,7 +87,8 @@ namespace std { template <> struct hash { std::size_t operator()(const pthread_t& k) const { - return 0 ^ std::hash(k.p) ^ std::hash(k.x); + return 0 ^ std::hash()(k.p) ^ + std::hash()(k.x); } }; } diff --git a/folly/portability/Sockets.cpp b/folly/portability/Sockets.cpp index 380d3863..d96091cb 100755 --- a/folly/portability/Sockets.cpp +++ b/folly/portability/Sockets.cpp @@ -206,7 +206,7 @@ ssize_t recvmsg(int s, struct msghdr* message, int fl) { DWORD bytesReceived; int res = WSARecvMsg(h, &msg, &bytesReceived, nullptr, nullptr); - return res == o ? (ssize_t)bytesReceived : -1; + return res == 0 ? (ssize_t)bytesReceived : -1; } ssize_t send(int s, const void* buf, size_t len, int flags) { diff --git a/folly/portability/Time.cpp b/folly/portability/Time.cpp index 56bfb79a..a9160356 100755 --- a/folly/portability/Time.cpp +++ b/folly/portability/Time.cpp @@ -58,6 +58,7 @@ int clock_getres(clockid_t clk_id, struct timespec* ts) { } #elif defined(_WIN32) #include +#include #include #include @@ -212,7 +213,7 @@ char* asctime_r(const tm* tm, char* buf) { char* ctime_r(const time_t* t, char* buf) { char tmpBuf[64]; - if (ctime_s(tmpBuf, t)) { + if (ctime_s(tmpBuf, 64, t)) { return nullptr; } // Nothing we can do if the buff is to small :( @@ -234,7 +235,7 @@ tm* localtime_r(const time_t* t, tm* o) { } int nanosleep(const struct timespec* request, struct timespec* remain) { - Sleep((DWORD)((request->tv_sec * 1000) + (request->tv_nsec / 1000000)); + Sleep((DWORD)((request->tv_sec * 1000) + (request->tv_nsec / 1000000))); remain->tv_nsec = 0; remain->tv_sec = 0; return 0;