Skip to content

Commit 91a5874

Browse files
author
Christian Riis
committed
Windows
1 parent 67a0ed5 commit 91a5874

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

llvm/lib/Support/raw_ostream.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,13 @@
3131
#include <sys/stat.h>
3232

3333
#include <iostream>
34+
#ifdef _WIN32
35+
#include <afunix.h>
36+
#include <winsock2.h>
37+
#else
3438
#include <sys/socket.h>
3539
#include <sys/un.h>
40+
#endif // _WIN32
3641

3742
// <fcntl.h> may provide O_BINARY.
3843
#if defined(HAVE_FCNTL_H)
@@ -61,7 +66,6 @@
6166
#endif
6267

6368
#ifdef _WIN32
64-
#include "raw_ostream.h"
6569
#include "llvm/Support/ConvertUTF.h"
6670
#include "llvm/Support/Signals.h"
6771
#include "llvm/Support/Windows/WindowsSupport.h"
@@ -979,7 +983,9 @@ int raw_socket_stream::MakeServerSocket(StringRef SocketPath,
979983

980984
struct sockaddr_un Addr;
981985
memset(&Addr, 0, sizeof(Addr));
986+
#ifndef _WIN32
982987
Addr.sun_family = AF_UNIX;
988+
#endif // _WIN32
983989
strncpy(Addr.sun_path, SocketPath.str().c_str(), sizeof(Addr.sun_path) - 1);
984990

985991
if (bind(MaybeWinsocket, (struct sockaddr *)&Addr, sizeof(Addr)) == -1) {
@@ -997,10 +1003,7 @@ int raw_socket_stream::MakeServerSocket(StringRef SocketPath,
9971003
return -1;
9981004
}
9991005
#ifdef _WIN32
1000-
return _open_osfhandle(
1001-
MaybeWinsocket,
1002-
0); // flags?
1003-
// https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/open-osfhandle?view=msvc-170
1006+
return _open_osfhandle(MaybeWinsocket, 0);
10041007
#else
10051008
return MaybeWinsocket;
10061009
#endif // _WIN32
@@ -1044,7 +1047,7 @@ static int ServerAccept(int FD) {
10441047
#ifdef _WIN32
10451048
SOCKET WinServerSock = _get_osfhandle(FD);
10461049
SOCKET WinAcceptSock = ::accept(WinServerSock, NULL, NULL);
1047-
AcceptFD = _open_osfhandle(WinAcceptSock, 0); // flags?
1050+
AcceptFD = _open_osfhandle(WinAcceptSock, 0);
10481051
#else
10491052
AcceptFD = ::accept(FD, NULL, NULL);
10501053
#endif //_WIN32

0 commit comments

Comments
 (0)