26 #ifndef HAVE_GETTIMEOFDAY
34 tv->tv_sec = (long) tb.time;
35 tv->tv_usec = ((
int) tb.millitm) * 1000;
42 win_read(
int fd,
void *
buf,
unsigned int length)
45 int res = ReadFile((HANDLE) fd, buf, length, &dwBytesRead, NULL);
47 DWORD error = GetLastError();
48 if (error == ERROR_NO_DATA)
56 win_write(
int fd,
void *buf,
unsigned int length)
59 int res = WriteFile((HANDLE) fd, buf, length, &dwBytesWritten, NULL);
61 DWORD error = GetLastError();
62 if (error == ERROR_NO_DATA)
66 return (dwBytesWritten);
70 socketpair(
int d,
int type,
int protocol,
int *sv)
76 sprintf(buf,
"\\\\.\\pipe\\levent-%d", count++);
78 fd = CreateNamedPipe(buf, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_NOWAIT,
79 PIPE_UNLIMITED_INSTANCES, 4096, 4096, 0, NULL);
80 if (fd == INVALID_HANDLE_VALUE)
84 fd = CreateFile(buf, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
85 if (fd == INVALID_HANDLE_VALUE)
88 SetNamedPipeHandleState(fd, &dwMode, NULL, NULL);