Commit ab239ddf authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot 4

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
parent 0759dee4
......@@ -44,7 +44,7 @@ void aligned_free(void* aligned_ptr) {
#include <malloc.h> // 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) {
......
......@@ -87,7 +87,8 @@ namespace std {
template <>
struct hash<pthread_t> {
std::size_t operator()(const pthread_t& k) const {
return 0 ^ std::hash<decltype(k.p)>(k.p) ^ std::hash<decltype(k.x)>(k.x);
return 0 ^ std::hash<decltype(k.p)>()(k.p) ^
std::hash<decltype(k.x)>()(k.x);
}
};
}
......
......@@ -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) {
......
......@@ -58,6 +58,7 @@ int clock_getres(clockid_t clk_id, struct timespec* ts) {
}
#elif defined(_WIN32)
#include <errno.h>
#include <locale.h>
#include <stdint.h>
#include <stdlib.h>
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment