int poll(struct pollfd fds[], nfds_t nfds, int timeout) {
// TODO: Allow both file descriptors and SOCKETs in this.
for (int i = 0; i < nfds; i++) {
int poll(struct pollfd fds[], nfds_t nfds, int timeout) {
// TODO: Allow both file descriptors and SOCKETs in this.
for (int i = 0; i < nfds; i++) {
- fds[i].fd = fd_to_socket(fds[i].fd);
+ fds[i].fd = fd_to_socket((int)fds[i].fd);
}
return ::WSAPoll(fds, (ULONG)nfds, timeout);
}
}
return ::WSAPoll(fds, (ULONG)nfds, timeout);
}
WSABUF wBuf{};
wBuf.buf = (CHAR*)buf;
WSABUF wBuf{};
wBuf.buf = (CHAR*)buf;
WSAMSG wMsg{};
wMsg.dwBufferCount = 1;
wMsg.lpBuffers = &wBuf;
WSAMSG wMsg{};
wMsg.dwBufferCount = 1;
wMsg.lpBuffers = &wBuf;
| (operation & LOCK_NB ? LOCKFILE_FAIL_IMMEDIATELY : 0)
| (operation & LOCK_EX ? LOCKFILE_EXCLUSIVE_LOCK : 0)
;
| (operation & LOCK_NB ? LOCKFILE_FAIL_IMMEDIATELY : 0)
| (operation & LOCK_EX ? LOCKFILE_EXCLUSIVE_LOCK : 0)
;
ret = MapViewOfFileEx(
fmh,
accessFlags,
ret = MapViewOfFileEx(
fmh,
accessFlags,
- (DWORD)((off >> 32) & 0xFFFFFFFF),
+ (DWORD)(0), // off_t is only 32-bit :(
(DWORD)(off & 0xFFFFFFFF),
0,
addr);
(DWORD)(off & 0xFFFFFFFF),
0,
addr);
void* curBase = iov[0].iov_base;
size_t curLen = iov[0].iov_len;
while (curIov < count) {
void* curBase = iov[0].iov_base;
size_t curLen = iov[0].iov_len;
while (curIov < count) {
if (isRead) {
res = read(fd, curBase, (unsigned int)curLen);
if (res == 0 && curLen != 0) {
if (isRead) {
res = read(fd, curBase, (unsigned int)curLen);
if (res == 0 && curLen != 0) {
static void duration_to_ts(
std::chrono::duration<_Rep, _Period> d,
struct timespec* ts) {
static void duration_to_ts(
std::chrono::duration<_Rep, _Period> d,
struct timespec* ts) {
- ts->tv_sec = std::chrono::duration_cast<std::chrono::seconds>(d).count();
- ts->tv_nsec = std::chrono::duration_cast<std::chrono::nanoseconds>(
- d % std::chrono::seconds(1))
- .count();
+ ts->tv_sec =
+ time_t(std::chrono::duration_cast<std::chrono::seconds>(d).count());
+ ts->tv_nsec = long(std::chrono::duration_cast<std::chrono::nanoseconds>(
+ d % std::chrono::seconds(1))
+ .count());
}
#if !FOLLY_HAVE_CLOCK_GETTIME
}
#if !FOLLY_HAVE_CLOCK_GETTIME
const auto unanosToTimespec = [](timespec* tp, unsigned_nanos t) -> int {
static constexpr unsigned_nanos one_sec(std::chrono::seconds(1));
const auto unanosToTimespec = [](timespec* tp, unsigned_nanos t) -> int {
static constexpr unsigned_nanos one_sec(std::chrono::seconds(1));
- tp->tv_sec = std::chrono::duration_cast<std::chrono::seconds>(t).count();
- tp->tv_nsec = (t % one_sec).count();
+ tp->tv_sec =
+ time_t(std::chrono::duration_cast<std::chrono::seconds>(t).count());
+ tp->tv_nsec = long((t % one_sec).count());
int getgid() { return 1; }
int getgid() { return 1; }
-pid_t getpid() { return pid_t(GetCurrentProcessId()); }
+pid_t getpid() { return (pid_t)uint64_t(GetCurrentProcessId()); }
// No major need to implement this, and getting a non-potentially
// stale ID on windows is a bit involved.
// No major need to implement this, and getting a non-potentially
// stale ID on windows is a bit involved.
return wrapPositional(_write, fd, offset, buf, (unsigned int)count);
}
return wrapPositional(_write, fd, offset, buf, (unsigned int)count);
}
-int read(int fh, void* buf, unsigned int mcc) {
+ssize_t read(int fh, void* buf, size_t count) {
if (folly::portability::sockets::is_fh_socket(fh)) {
SOCKET s = (SOCKET)_get_osfhandle(fh);
if (s != INVALID_SOCKET) {
if (folly::portability::sockets::is_fh_socket(fh)) {
SOCKET s = (SOCKET)_get_osfhandle(fh);
if (s != INVALID_SOCKET) {
- auto r = folly::portability::sockets::recv(fh, buf, (size_t)mcc, 0);
+ auto r = folly::portability::sockets::recv(fh, buf, count, 0);
if (r == -1 && WSAGetLastError() == WSAEWOULDBLOCK) {
errno = EAGAIN;
}
return r;
}
}
if (r == -1 && WSAGetLastError() == WSAEWOULDBLOCK) {
errno = EAGAIN;
}
return r;
}
}
- auto r = _read(fh, buf, mcc);
+ auto r = _read(fh, buf, unsigned int(count));
if (r == -1 && GetLastError() == ERROR_NO_DATA) {
// This only happens if the file was non-blocking and
// no data was present. We have to translate the error
if (r == -1 && GetLastError() == ERROR_NO_DATA) {
// This only happens if the file was non-blocking and
// no data was present. We have to translate the error
- DWORD ret = GetFinalPathNameByHandleA(h, buf, buflen - 1, VOLUME_NAME_DOS);
+ DWORD ret =
+ GetFinalPathNameByHandleA(h, buf, DWORD(buflen - 1), VOLUME_NAME_DOS);
if (ret >= buflen || ret >= MAX_PATH || !ret) {
CloseHandle(h);
return -1;
if (ret >= buflen || ret >= MAX_PATH || !ret) {
CloseHandle(h);
return -1;
-int write(int fh, void const* buf, unsigned int count) {
+ssize_t write(int fh, void const* buf, size_t count) {
if (folly::portability::sockets::is_fh_socket(fh)) {
SOCKET s = (SOCKET)_get_osfhandle(fh);
if (s != INVALID_SOCKET) {
if (folly::portability::sockets::is_fh_socket(fh)) {
SOCKET s = (SOCKET)_get_osfhandle(fh);
if (s != INVALID_SOCKET) {
- auto r = _write(fh, buf, count);
+ auto r = _write(fh, buf, unsigned int(count));
if ((r > 0 && r != count) || (r == -1 && errno == ENOSPC)) {
// Writing to a pipe with a full buffer doesn't generate
// any error type, unless it caused us to write exactly 0
if ((r > 0 && r != count) || (r == -1 && errno == ENOSPC)) {
// Writing to a pipe with a full buffer doesn't generate
// any error type, unless it caused us to write exactly 0
int isatty(int fh);
int lockf(int fd, int cmd, off_t len);
long lseek(int fh, long off, int orig);
int isatty(int fh);
int lockf(int fd, int cmd, off_t len);
long lseek(int fh, long off, int orig);
-int read(int fh, void* buf, unsigned int mcc);
+ssize_t read(int fh, void* buf, size_t mcc);
int rmdir(const char* path);
int pipe(int pth[2]);
int pread(int fd, void* buf, size_t count, off_t offset);
int rmdir(const char* path);
int pipe(int pth[2]);
int pread(int fd, void* buf, size_t count, off_t offset);
long tell(int fh);
int truncate(const char* path, off_t len);
int usleep(unsigned int ms);
long tell(int fh);
int truncate(const char* path, off_t len);
int usleep(unsigned int ms);
-int write(int fh, void const* buf, unsigned int mcc);
+ssize_t write(int fh, void const* buf, size_t count);