#include <unistd.h>
#include <dirent.h>
#include <pthread.h>
+#include <time.h>
#include <semaphore.h>
#include <sys/shm.h>
#include <sys/mman.h>
#include <sys/uio.h>
#include <sys/resource.h>
#include <sys/poll.h>
+#include <sys/wait.h>
+#include <setjmp.h>
#include "../os-windows.h"
#include "../../lib/hweight.h"
{
static LARGE_INTEGER freq = {{0,0}};
LARGE_INTEGER counts;
+ uint64_t t;
QueryPerformanceCounter(&counts);
if (freq.QuadPart == 0)
tp->tv_sec = counts.QuadPart / freq.QuadPart;
/* Get the difference between the number of ns stored
* in 'tv_sec' and that stored in 'counts' */
- uint64_t t = tp->tv_sec * freq.QuadPart;
+ t = tp->tv_sec * freq.QuadPart;
t = counts.QuadPart - t;
/* 't' now contains the number of cycles since the last second.
* We want the number of nanoseconds, so multiply out by 1,000,000,000
return 0;
}
-int posix_fadvise(int fd, off_t offset, off_t len, int advice)
-{
- return 0;
-}
-
int posix_madvise(void *addr, size_t len, int advice)
{
log_err("%s is not implemented\n", __func__);
ssize_t writev(int fildes, const struct iovec *iov, int iovcnt)
{
- log_err("%s is not implemented\n", __func__);
- errno = ENOSYS;
- return -1;
+ int i;
+ DWORD bytes_written = 0;
+ for (i = 0; i < iovcnt; i++)
+ {
+ int len = send((SOCKET)fildes, iov[i].iov_base, iov[i].iov_len, 0);
+ if (len == SOCKET_ERROR)
+ {
+ DWORD err = GetLastError();
+ errno = win_to_posix_error(err);
+ bytes_written = -1;
+ break;
+ }
+ bytes_written += len;
+ }
+
+ return bytes_written;
}
long long strtoll(const char *restrict str, char **restrict endptr,
FD_SET(fds[i].fd, &exceptfds);
}
-
rc = select(nfds, &readfds, &writefds, &exceptfds, to);
if (rc != SOCKET_ERROR) {
fds[i].revents |= POLLHUP;
}
}
-
return rc;
}
return -1;
}
+in_addr_t inet_network(const char *cp)
+{
+ in_addr_t hbo;
+ in_addr_t nbo = inet_addr(cp);
+ hbo = ((nbo & 0xFF) << 24) + ((nbo & 0xFF00) << 8) + ((nbo & 0xFF0000) >> 8) + ((nbo & 0xFF000000) >> 24);
+ return hbo;
+}
+
const char* inet_ntop(int af, const void *restrict src,
char *restrict dst, socklen_t size)
{