Skip to content

Commit

Permalink
Enable online features for Unix (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
SSimco committed Nov 15, 2022
1 parent 4442efa commit b1c7058
Show file tree
Hide file tree
Showing 2 changed files with 174 additions and 81 deletions.
37 changes: 25 additions & 12 deletions src/Cafe/OS/libs/nlibcurl/nlibcurl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,6 @@ void export_curl_multi_fdset(PPCInterpreter_t* hCPU)
ppcDefineParamMEMPTR(exceptionFd, wu_fd_set, 3);
ppcDefineParamU32BEPtr(maxFd, 4);

#if BOOST_OS_LINUX || BOOST_OS_MACOS
cemuLog_log(LogType::Force, "curl_multi_fdset(...) - todo");

osLib_returnFromFunction(hCPU, 0);
#else
fd_set h_readFd;
fd_set h_writeFd;
fd_set h_exceptionFd;
Expand All @@ -475,17 +470,36 @@ void export_curl_multi_fdset(PPCInterpreter_t* hCPU)
nsysnet::wuResetFD(exceptionFd.GetPtr());

sint32 c_maxFD = -1;
// fd read set
for (uint32 i = 0; i < h_readFd.fd_count; i++)

auto hostFdSet = [&](SOCKET s, wu_fd_set* fds)
{
sint32 wuSocket = nsysnet_getVirtualSocketHandleFromHostHandle(h_readFd.fd_array[i]);
sint32 wuSocket = nsysnet_getVirtualSocketHandleFromHostHandle(s);
if (wuSocket < 0)
wuSocket = nsysnet_createVirtualSocketFromExistingSocket(h_readFd.fd_array[i]);
wuSocket = nsysnet_createVirtualSocketFromExistingSocket(s);
if (wuSocket >= 0)
{
c_maxFD = std::max(wuSocket, c_maxFD);
nsysnet::wuSetFD(readFd.GetPtr(), wuSocket);
nsysnet::wuSetFD(fds, wuSocket);
}
};

#if BOOST_OS_UNIX
for (int s = 0; s < h_maxFd + 1; s++)
{
if(FD_ISSET(s, &h_readFd))
hostFdSet(s, readFd.GetPtr());

if(FD_ISSET(s, &h_writeFd))
hostFdSet(s, writeFd.GetPtr());

if(FD_ISSET(s, &h_exceptionFd))
hostFdSet(s, exceptionFd.GetPtr());
}
#else
// fd read set
for (uint32 i = 0; i < h_readFd.fd_count; i++)
{
hostFdSet(h_readFd.fd_array[i], readFd.GetPtr());
}
// fd write set
for (uint32 i = 0; i < h_writeFd.fd_count; i++)
Expand All @@ -497,11 +511,10 @@ void export_curl_multi_fdset(PPCInterpreter_t* hCPU)
{
cemu_assert_debug(false);
}
#endif

*maxFd = c_maxFD;
osLib_returnFromFunction(hCPU, result);
#endif

}

void export_curl_multi_setopt(PPCInterpreter_t* hCPU)
Expand Down

0 comments on commit b1c7058

Please sign in to comment.