31
31
#include < sys/stat.h>
32
32
33
33
#include < iostream>
34
+ #ifdef _WIN32
35
+ #include < afunix.h>
36
+ #include < winsock2.h>
37
+ #else
34
38
#include < sys/socket.h>
35
39
#include < sys/un.h>
40
+ #endif // _WIN32
36
41
37
42
// <fcntl.h> may provide O_BINARY.
38
43
#if defined(HAVE_FCNTL_H)
61
66
#endif
62
67
63
68
#ifdef _WIN32
64
- #include " raw_ostream.h"
65
69
#include " llvm/Support/ConvertUTF.h"
66
70
#include " llvm/Support/Signals.h"
67
71
#include " llvm/Support/Windows/WindowsSupport.h"
@@ -979,7 +983,9 @@ int raw_socket_stream::MakeServerSocket(StringRef SocketPath,
979
983
980
984
struct sockaddr_un Addr;
981
985
memset (&Addr, 0 , sizeof (Addr));
986
+ #ifndef _WIN32
982
987
Addr.sun_family = AF_UNIX;
988
+ #endif // _WIN32
983
989
strncpy (Addr.sun_path , SocketPath.str ().c_str (), sizeof (Addr.sun_path ) - 1 );
984
990
985
991
if (bind (MaybeWinsocket, (struct sockaddr *)&Addr, sizeof (Addr)) == -1 ) {
@@ -997,10 +1003,7 @@ int raw_socket_stream::MakeServerSocket(StringRef SocketPath,
997
1003
return -1 ;
998
1004
}
999
1005
#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 );
1004
1007
#else
1005
1008
return MaybeWinsocket;
1006
1009
#endif // _WIN32
@@ -1044,7 +1047,7 @@ static int ServerAccept(int FD) {
1044
1047
#ifdef _WIN32
1045
1048
SOCKET WinServerSock = _get_osfhandle (FD);
1046
1049
SOCKET WinAcceptSock = ::accept (WinServerSock, NULL , NULL );
1047
- AcceptFD = _open_osfhandle (WinAcceptSock, 0 ); // flags?
1050
+ AcceptFD = _open_osfhandle (WinAcceptSock, 0 );
1048
1051
#else
1049
1052
AcceptFD = ::accept (FD, NULL , NULL );
1050
1053
#endif // _WIN32
0 commit comments