fix bsd macro clash

This commit is contained in:
lizzie
2026-08-31 04:00:25 +00:00
parent a08edeeeeb
commit a67f8548af
3 changed files with 104 additions and 104 deletions
+91 -91
View File
@@ -60,11 +60,11 @@ void PutValue(std::span<u8> buffer, const T& t) {
} // Anonymous namespace
void BSD::PollWork::Execute(BSD* bsd) {
void BSD_USA::PollWork::Execute(BSD_USA* bsd) {
std::tie(ret, bsd_errno) = bsd->PollImpl(write_buffer, read_buffer, nfds, timeout);
}
void BSD::PollWork::Response(HLERequestContext& ctx) {
void BSD_USA::PollWork::Response(HLERequestContext& ctx) {
if (write_buffer.size() > 0) {
ctx.WriteBuffer(write_buffer);
}
@@ -75,11 +75,11 @@ void BSD::PollWork::Response(HLERequestContext& ctx) {
rb.PushEnum(bsd_errno);
}
void BSD::AcceptWork::Execute(BSD* bsd) {
void BSD_USA::AcceptWork::Execute(BSD_USA* bsd) {
std::tie(ret, bsd_errno) = bsd->AcceptImpl(fd, write_buffer);
}
void BSD::AcceptWork::Response(HLERequestContext& ctx) {
void BSD_USA::AcceptWork::Response(HLERequestContext& ctx) {
if (write_buffer.size() > 0) {
ctx.WriteBuffer(write_buffer);
}
@@ -91,22 +91,22 @@ void BSD::AcceptWork::Response(HLERequestContext& ctx) {
rb.Push<u32>(static_cast<u32>(write_buffer.size()));
}
void BSD::ConnectWork::Execute(BSD* bsd) {
void BSD_USA::ConnectWork::Execute(BSD_USA* bsd) {
bsd_errno = bsd->ConnectImpl(fd, addr);
}
void BSD::ConnectWork::Response(HLERequestContext& ctx) {
void BSD_USA::ConnectWork::Response(HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 4};
rb.Push(ResultSuccess);
rb.Push<s32>(bsd_errno == Network::Errno::E_SUCCESS ? 0 : -1);
rb.PushEnum(bsd_errno);
}
void BSD::RecvWork::Execute(BSD* bsd) {
void BSD_USA::RecvWork::Execute(BSD_USA* bsd) {
std::tie(ret, bsd_errno) = bsd->RecvImpl(fd, flags, message);
}
void BSD::RecvWork::Response(HLERequestContext& ctx) {
void BSD_USA::RecvWork::Response(HLERequestContext& ctx) {
ctx.WriteBuffer(message);
IPC::ResponseBuilder rb{ctx, 4};
@@ -115,11 +115,11 @@ void BSD::RecvWork::Response(HLERequestContext& ctx) {
rb.PushEnum(bsd_errno);
}
void BSD::RecvFromWork::Execute(BSD* bsd) {
void BSD_USA::RecvFromWork::Execute(BSD_USA* bsd) {
std::tie(ret, bsd_errno) = bsd->RecvFromImpl(fd, flags, message, addr);
}
void BSD::RecvFromWork::Response(HLERequestContext& ctx) {
void BSD_USA::RecvFromWork::Response(HLERequestContext& ctx) {
ctx.WriteBuffer(message, 0);
if (!addr.empty()) {
ctx.WriteBuffer(addr, 1);
@@ -132,29 +132,29 @@ void BSD::RecvFromWork::Response(HLERequestContext& ctx) {
rb.Push<u32>(static_cast<u32>(addr.size()));
}
void BSD::SendWork::Execute(BSD* bsd) {
void BSD_USA::SendWork::Execute(BSD_USA* bsd) {
std::tie(ret, bsd_errno) = bsd->SendImpl(fd, flags, message);
}
void BSD::SendWork::Response(HLERequestContext& ctx) {
void BSD_USA::SendWork::Response(HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 4};
rb.Push(ResultSuccess);
rb.Push<s32>(ret);
rb.PushEnum(bsd_errno);
}
void BSD::SendToWork::Execute(BSD* bsd) {
void BSD_USA::SendToWork::Execute(BSD_USA* bsd) {
std::tie(ret, bsd_errno) = bsd->SendToImpl(fd, flags, message, addr);
}
void BSD::SendToWork::Response(HLERequestContext& ctx) {
void BSD_USA::SendToWork::Response(HLERequestContext& ctx) {
IPC::ResponseBuilder rb{ctx, 4};
rb.Push(ResultSuccess);
rb.Push<s32>(ret);
rb.PushEnum(bsd_errno);
}
void BSD::RegisterClient(HLERequestContext& ctx) {
void BSD_USA::RegisterClient(HLERequestContext& ctx) {
LOG_WARNING(Service, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 3};
@@ -163,7 +163,7 @@ void BSD::RegisterClient(HLERequestContext& ctx) {
rb.Push<s32>(0); // bsd errno
}
void BSD::StartMonitoring(HLERequestContext& ctx) {
void BSD_USA::StartMonitoring(HLERequestContext& ctx) {
LOG_WARNING(Service, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 2};
@@ -171,7 +171,7 @@ void BSD::StartMonitoring(HLERequestContext& ctx) {
rb.Push(ResultSuccess);
}
void BSD::Socket(HLERequestContext& ctx) {
void BSD_USA::Socket(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const u32 domain = rp.Pop<u32>();
const u32 type = rp.Pop<u32>();
@@ -186,7 +186,7 @@ void BSD::Socket(HLERequestContext& ctx) {
rb.PushEnum(bsd_errno);
}
void BSD::SocketExempt(HLERequestContext& ctx) {
void BSD_USA::SocketExempt(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const u32 domain = rp.Pop<u32>();
const u32 type = rp.Pop<u32>();
@@ -205,7 +205,7 @@ void BSD::SocketExempt(HLERequestContext& ctx) {
rb.PushEnum(bsd_errno);
}
void BSD::Select(HLERequestContext& ctx) {
void BSD_USA::Select(HLERequestContext& ctx) {
LOG_DEBUG(Service, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 4};
@@ -215,7 +215,7 @@ void BSD::Select(HLERequestContext& ctx) {
rb.Push<u32>(0); // bsd errno
}
void BSD::Poll(HLERequestContext& ctx) {
void BSD_USA::Poll(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const s32 nfds = rp.Pop<s32>();
const s32 timeout = rp.Pop<s32>();
@@ -230,7 +230,7 @@ void BSD::Poll(HLERequestContext& ctx) {
});
}
void BSD::Accept(HLERequestContext& ctx) {
void BSD_USA::Accept(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const s32 fd = rp.Pop<s32>();
@@ -242,7 +242,7 @@ void BSD::Accept(HLERequestContext& ctx) {
});
}
void BSD::Bind(HLERequestContext& ctx) {
void BSD_USA::Bind(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const s32 fd = rp.Pop<s32>();
@@ -250,7 +250,7 @@ void BSD::Bind(HLERequestContext& ctx) {
BuildErrnoResponse(ctx, BindImpl(fd, ctx.ReadBuffer()));
}
void BSD::Connect(HLERequestContext& ctx) {
void BSD_USA::Connect(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const s32 fd = rp.Pop<s32>();
@@ -262,7 +262,7 @@ void BSD::Connect(HLERequestContext& ctx) {
});
}
void BSD::GetPeerName(HLERequestContext& ctx) {
void BSD_USA::GetPeerName(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const s32 fd = rp.Pop<s32>();
@@ -280,7 +280,7 @@ void BSD::GetPeerName(HLERequestContext& ctx) {
rb.Push<u32>(static_cast<u32>(write_buffer.size()));
}
void BSD::GetSockName(HLERequestContext& ctx) {
void BSD_USA::GetSockName(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const s32 fd = rp.Pop<s32>();
@@ -298,7 +298,7 @@ void BSD::GetSockName(HLERequestContext& ctx) {
rb.Push<u32>(static_cast<u32>(write_buffer.size()));
}
void BSD::GetSockOpt(HLERequestContext& ctx) {
void BSD_USA::GetSockOpt(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const s32 fd = rp.Pop<s32>();
const auto level = Network::SocketLevel(rp.Pop<u32>());
@@ -318,7 +318,7 @@ void BSD::GetSockOpt(HLERequestContext& ctx) {
rb.Push<u32>(static_cast<u32>(optval.size()));
}
void BSD::Listen(HLERequestContext& ctx) {
void BSD_USA::Listen(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const s32 fd = rp.Pop<s32>();
const s32 backlog = rp.Pop<s32>();
@@ -328,7 +328,7 @@ void BSD::Listen(HLERequestContext& ctx) {
BuildErrnoResponse(ctx, ListenImpl(fd, backlog));
}
void BSD::Fcntl(HLERequestContext& ctx) {
void BSD_USA::Fcntl(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const s32 fd = rp.Pop<s32>();
const s32 cmd = rp.Pop<s32>();
@@ -344,7 +344,7 @@ void BSD::Fcntl(HLERequestContext& ctx) {
rb.PushEnum(bsd_errno);
}
void BSD::SetSockOpt(HLERequestContext& ctx) {
void BSD_USA::SetSockOpt(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const s32 fd = rp.Pop<s32>();
@@ -356,7 +356,7 @@ void BSD::SetSockOpt(HLERequestContext& ctx) {
BuildErrnoResponse(ctx, SetSockOptImpl(fd, level, optname, optval));
}
void BSD::Shutdown(HLERequestContext& ctx) {
void BSD_USA::Shutdown(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const s32 fd = rp.Pop<s32>();
@@ -367,7 +367,7 @@ void BSD::Shutdown(HLERequestContext& ctx) {
BuildErrnoResponse(ctx, ShutdownImpl(fd, how));
}
void BSD::Recv(HLERequestContext& ctx) {
void BSD_USA::Recv(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const s32 fd = rp.Pop<s32>();
@@ -382,7 +382,7 @@ void BSD::Recv(HLERequestContext& ctx) {
});
}
void BSD::RecvFrom(HLERequestContext& ctx) {
void BSD_USA::RecvFrom(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const s32 fd = rp.Pop<s32>();
@@ -399,7 +399,7 @@ void BSD::RecvFrom(HLERequestContext& ctx) {
});
}
void BSD::Send(HLERequestContext& ctx) {
void BSD_USA::Send(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const s32 fd = rp.Pop<s32>();
@@ -414,7 +414,7 @@ void BSD::Send(HLERequestContext& ctx) {
});
}
void BSD::SendTo(HLERequestContext& ctx) {
void BSD_USA::SendTo(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const s32 fd = rp.Pop<s32>();
const u32 flags = rp.Pop<u32>();
@@ -430,7 +430,7 @@ void BSD::SendTo(HLERequestContext& ctx) {
});
}
void BSD::Write(HLERequestContext& ctx) {
void BSD_USA::Write(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const s32 fd = rp.Pop<s32>();
@@ -443,7 +443,7 @@ void BSD::Write(HLERequestContext& ctx) {
});
}
void BSD::Read(HLERequestContext& ctx) {
void BSD_USA::Read(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const s32 fd = rp.Pop<s32>();
@@ -455,7 +455,7 @@ void BSD::Read(HLERequestContext& ctx) {
rb.Push<u32>(0); // bsd errno
}
void BSD::Close(HLERequestContext& ctx) {
void BSD_USA::Close(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const s32 fd = rp.Pop<s32>();
@@ -465,7 +465,7 @@ void BSD::Close(HLERequestContext& ctx) {
}
/// @brief Only bsd:s is able to dup()
void BSD::DuplicateSocket(HLERequestContext& ctx) {
void BSD_USA::DuplicateSocket(HLERequestContext& ctx) {
struct InputParameters {
s32 fd;
u64 reserved;
@@ -506,7 +506,7 @@ void BSD::DuplicateSocket(HLERequestContext& ctx) {
}
}
void BSD::EventFd(HLERequestContext& ctx) {
void BSD_USA::EventFd(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const u64 initval = rp.Pop<u64>();
const u32 flags = rp.Pop<u32>();
@@ -517,12 +517,12 @@ void BSD::EventFd(HLERequestContext& ctx) {
}
template <typename Work>
void BSD::ExecuteWork(HLERequestContext& ctx, Work work) {
void BSD_USA::ExecuteWork(HLERequestContext& ctx, Work work) {
work.Execute(this);
work.Response(ctx);
}
std::pair<s32, Network::Errno> BSD::SocketImpl(Network::Domain domain, Network::Type type, Network::Protocol protocol) {
std::pair<s32, Network::Errno> BSD_USA::SocketImpl(Network::Domain domain, Network::Type type, Network::Protocol protocol) {
// user bsd:u has restrictions on SOCK_SEQPACKET and SOCK_RAW
LOG_DEBUG(Network, "domain={},type={},protocol={}", u32(domain), u32(type), u32(protocol));
if (is_user && (type == Network::Type::SEQPACKET || type == Network::Type::RAW)) {
@@ -589,7 +589,7 @@ std::pair<s32, Network::Errno> BSD::SocketImpl(Network::Domain domain, Network::
return {fd, Network::Errno::E_SUCCESS};
}
std::pair<s32, Network::Errno> BSD::PollImpl(std::vector<u8>& write_buffer, std::span<const u8> read_buffer, s32 nfds, s32 timeout) {
std::pair<s32, Network::Errno> BSD_USA::PollImpl(std::vector<u8>& write_buffer, std::span<const u8> read_buffer, s32 nfds, s32 timeout) {
LOG_DEBUG(Network, "nfds={},timeout={}", nfds, timeout);
if (nfds <= 0) {
// When no entries are provided, -1 is returned with errno zero
@@ -643,7 +643,7 @@ std::pair<s32, Network::Errno> BSD::PollImpl(std::vector<u8>& write_buffer, std:
return res;
}
std::pair<s32, Network::Errno> BSD::AcceptImpl(s32 fd, std::vector<u8>& write_buffer) {
std::pair<s32, Network::Errno> BSD_USA::AcceptImpl(s32 fd, std::vector<u8>& write_buffer) {
LOG_DEBUG(Network, "fd={}", fd);
if (!IsFileDescriptorValid(fd)) {
return {-1, Network::Errno::E_BADF};
@@ -670,7 +670,7 @@ std::pair<s32, Network::Errno> BSD::AcceptImpl(s32 fd, std::vector<u8>& write_bu
return {new_fd, Network::Errno::E_SUCCESS};
}
Network::Errno BSD::BindImpl(s32 fd, std::span<const u8> addr) {
Network::Errno BSD_USA::BindImpl(s32 fd, std::span<const u8> addr) {
LOG_DEBUG(Network, "fd={}", fd);
if (!IsFileDescriptorValid(fd)) {
return Network::Errno::E_BADF;
@@ -685,7 +685,7 @@ Network::Errno BSD::BindImpl(s32 fd, std::span<const u8> addr) {
return file_descriptors[fd]->socket->Bind(addr_in);
}
Network::Errno BSD::ConnectImpl(s32 fd, std::span<const u8> addr) {
Network::Errno BSD_USA::ConnectImpl(s32 fd, std::span<const u8> addr) {
LOG_DEBUG(Network, "fd={}", fd);
if (!IsFileDescriptorValid(fd)) {
return Network::Errno::E_BADF;
@@ -707,7 +707,7 @@ Network::Errno BSD::ConnectImpl(s32 fd, std::span<const u8> addr) {
return result;
}
Network::Errno BSD::GetPeerNameImpl(s32 fd, std::vector<u8>& write_buffer) {
Network::Errno BSD_USA::GetPeerNameImpl(s32 fd, std::vector<u8>& write_buffer) {
LOG_DEBUG(Network, "fd={}", fd);
if (!IsFileDescriptorValid(fd)) {
return Network::Errno::E_BADF;
@@ -728,7 +728,7 @@ Network::Errno BSD::GetPeerNameImpl(s32 fd, std::vector<u8>& write_buffer) {
return bsd_errno;
}
Network::Errno BSD::GetSockNameImpl(s32 fd, std::vector<u8>& write_buffer) {
Network::Errno BSD_USA::GetSockNameImpl(s32 fd, std::vector<u8>& write_buffer) {
LOG_DEBUG(Network, "fd={}", fd);
if (!IsFileDescriptorValid(fd)) {
return Network::Errno::E_BADF;
@@ -749,7 +749,7 @@ Network::Errno BSD::GetSockNameImpl(s32 fd, std::vector<u8>& write_buffer) {
return bsd_errno;
}
Network::Errno BSD::ListenImpl(s32 fd, s32 backlog) {
Network::Errno BSD_USA::ListenImpl(s32 fd, s32 backlog) {
LOG_DEBUG(Network, "fd={},backlog={}", fd, backlog);
if (!IsFileDescriptorValid(fd)) {
return Network::Errno::E_BADF;
@@ -761,7 +761,7 @@ Network::Errno BSD::ListenImpl(s32 fd, s32 backlog) {
return file_descriptors[fd]->socket->Listen(backlog);
}
std::pair<s32, Network::Errno> BSD::FcntlImpl(s32 fd, Network::FcntlCmd cmd, s32 arg) {
std::pair<s32, Network::Errno> BSD_USA::FcntlImpl(s32 fd, Network::FcntlCmd cmd, s32 arg) {
LOG_DEBUG(Network, "fd={},cmd={},arg={}", fd, u32(cmd), arg);
if (!IsFileDescriptorValid(fd)) {
return {-1, Network::Errno::E_BADF};
@@ -791,7 +791,7 @@ std::pair<s32, Network::Errno> BSD::FcntlImpl(s32 fd, Network::FcntlCmd cmd, s32
}
}
Network::Errno BSD::GetSockOptImpl(s32 fd, Network::SocketLevel level, Network::OptName optname, std::vector<u8>& optval) {
Network::Errno BSD_USA::GetSockOptImpl(s32 fd, Network::SocketLevel level, Network::OptName optname, std::vector<u8>& optval) {
LOG_DEBUG(Network, "fd={},level={},optname={}", fd, u32(level), u32(optname));
if (!IsFileDescriptorValid(fd)) {
return Network::Errno::E_BADF;
@@ -825,7 +825,7 @@ Network::Errno BSD::GetSockOptImpl(s32 fd, Network::SocketLevel level, Network::
}
}
Network::Errno BSD::SetSockOptImpl(s32 fd, Network::SocketLevel level, Network::OptName optname, std::span<const u8> optval) {
Network::Errno BSD_USA::SetSockOptImpl(s32 fd, Network::SocketLevel level, Network::OptName optname, std::span<const u8> optval) {
LOG_DEBUG(Service, "fd={},level={},optname={}", fd, level, optname);
if (!IsFileDescriptorValid(fd)) {
return Network::Errno::E_BADF;
@@ -839,7 +839,7 @@ Network::Errno BSD::SetSockOptImpl(s32 fd, Network::SocketLevel level, Network::
return socket->SetSockOpt(level, optname, optval);
}
Network::Errno BSD::ShutdownImpl(s32 fd, s32 how) {
Network::Errno BSD_USA::ShutdownImpl(s32 fd, s32 how) {
LOG_DEBUG(Network, "fd={},how={}", fd, how);
if (!IsFileDescriptorValid(fd)) {
return Network::Errno::E_BADF;
@@ -851,7 +851,7 @@ Network::Errno BSD::ShutdownImpl(s32 fd, s32 how) {
return file_descriptors[fd]->socket->Shutdown(Network::ShutdownHow(how));
}
std::pair<s32, Network::Errno> BSD::RecvImpl(s32 fd, u32 flags, std::vector<u8>& message) {
std::pair<s32, Network::Errno> BSD_USA::RecvImpl(s32 fd, u32 flags, std::vector<u8>& message) {
LOG_DEBUG(Network, "fd={},flags={}", fd, flags);
if (!IsFileDescriptorValid(fd)) {
return {-1, Network::Errno::E_BADF};
@@ -874,7 +874,7 @@ std::pair<s32, Network::Errno> BSD::RecvImpl(s32 fd, u32 flags, std::vector<u8>&
return {ret, bsd_errno};
}
std::pair<s32, Network::Errno> BSD::RecvFromImpl(s32 fd, u32 flags, std::vector<u8>& message, std::vector<u8>& addr) {
std::pair<s32, Network::Errno> BSD_USA::RecvFromImpl(s32 fd, u32 flags, std::vector<u8>& message, std::vector<u8>& addr) {
LOG_DEBUG(Network, "fd={},flags={}", fd, flags);
if (!IsFileDescriptorValid(fd)) {
return {-1, Network::Errno::E_BADF};
@@ -918,7 +918,7 @@ std::pair<s32, Network::Errno> BSD::RecvFromImpl(s32 fd, u32 flags, std::vector<
return {ret, bsd_errno};
}
std::pair<s32, Network::Errno> BSD::SendImpl(s32 fd, u32 flags, std::span<const u8> message) {
std::pair<s32, Network::Errno> BSD_USA::SendImpl(s32 fd, u32 flags, std::span<const u8> message) {
LOG_DEBUG(Network, "fd={},flags={}", fd, flags);
if (!IsFileDescriptorValid(fd)) {
return {-1, Network::Errno::E_BADF};
@@ -930,7 +930,7 @@ std::pair<s32, Network::Errno> BSD::SendImpl(s32 fd, u32 flags, std::span<const
return file_descriptors[fd]->socket->Send(message, flags);
}
std::pair<s32, Network::Errno> BSD::SendToImpl(s32 fd, u32 flags, std::span<const u8> message, std::span<const u8> addr) {
std::pair<s32, Network::Errno> BSD_USA::SendToImpl(s32 fd, u32 flags, std::span<const u8> message, std::span<const u8> addr) {
LOG_DEBUG(Network, "fd={},flags={}", fd, flags);
if (!IsFileDescriptorValid(fd)) {
return {-1, Network::Errno::E_BADF};
@@ -952,7 +952,7 @@ std::pair<s32, Network::Errno> BSD::SendToImpl(s32 fd, u32 flags, std::span<cons
return file_descriptors[fd]->socket->SendTo(flags, message, p_addr_in);
}
Network::Errno BSD::CloseImpl(s32 fd) {
Network::Errno BSD_USA::CloseImpl(s32 fd) {
LOG_DEBUG(Network, "fd={}", fd);
if (!IsFileDescriptorValid(fd)) {
return Network::Errno::E_BADF;
@@ -973,7 +973,7 @@ Network::Errno BSD::CloseImpl(s32 fd) {
return bsd_errno;
}
std::variant<s32, Network::Errno> BSD::DuplicateSocketImpl(s32 fd) {
std::variant<s32, Network::Errno> BSD_USA::DuplicateSocketImpl(s32 fd) {
LOG_DEBUG(Network, "fd={}", fd);
if (!IsFileDescriptorValid(fd)) {
return Network::Errno::E_BADF;
@@ -993,7 +993,7 @@ std::variant<s32, Network::Errno> BSD::DuplicateSocketImpl(s32 fd) {
return new_fd;
}
std::optional<std::shared_ptr<Network::SocketBase>> BSD::GetSocket(s32 fd) {
std::optional<std::shared_ptr<Network::SocketBase>> BSD_USA::GetSocket(s32 fd) {
LOG_DEBUG(Network, "fd={}", fd);
if (!IsFileDescriptorValid(fd)) {
return std::nullopt;
@@ -1005,7 +1005,7 @@ std::optional<std::shared_ptr<Network::SocketBase>> BSD::GetSocket(s32 fd) {
return file_descriptors[fd]->socket;
}
s32 BSD::FindFreeFileDescriptorHandle() noexcept {
s32 BSD_USA::FindFreeFileDescriptorHandle() noexcept {
// first three file descriptors are reserved for:
// STDOUT_FILENO, STDIN_FILENO and STDERR_FILENO
for (s32 fd = 0; fd < s32(file_descriptors.size()); ++fd)
@@ -1014,7 +1014,7 @@ s32 BSD::FindFreeFileDescriptorHandle() noexcept {
return -1;
}
bool BSD::IsFileDescriptorValid(s32 fd) const noexcept {
bool BSD_USA::IsFileDescriptorValid(s32 fd) const noexcept {
if (fd < 0 || fd >= s32(file_descriptors.size())) {
LOG_ERROR(Service, "Invalid handle={}", fd);
return false;
@@ -1026,7 +1026,7 @@ bool BSD::IsFileDescriptorValid(s32 fd) const noexcept {
return true;
}
void BSD::BuildErrnoResponse(HLERequestContext& ctx, Network::Errno bsd_errno) const noexcept {
void BSD_USA::BuildErrnoResponse(HLERequestContext& ctx, Network::Errno bsd_errno) const noexcept {
IPC::ResponseBuilder rb{ctx, 4};
rb.Push(ResultSuccess);
@@ -1034,7 +1034,7 @@ void BSD::BuildErrnoResponse(HLERequestContext& ctx, Network::Errno bsd_errno) c
rb.PushEnum(bsd_errno);
}
void BSD::OnProxyPacketReceived(const Network::ProxyPacket& packet) {
void BSD_USA::OnProxyPacketReceived(const Network::ProxyPacket& packet) {
for (auto& optional_descriptor : file_descriptors) {
if (optional_descriptor.has_value()) {
FileDescriptor& descriptor = *optional_descriptor;
@@ -1043,43 +1043,43 @@ void BSD::OnProxyPacketReceived(const Network::ProxyPacket& packet) {
}
}
BSD::BSD(Core::System& system_, const char* name, bool is_user_)
BSD_USA::BSD_USA(Core::System& system_, const char* name, bool is_user_)
: ServiceFramework{system_, name}
, is_user{is_user_} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &BSD::RegisterClient, "RegisterClient"},
{1, &BSD::StartMonitoring, "StartMonitoring"},
{2, &BSD::Socket, "Socket"},
{3, &BSD::SocketExempt, "SocketExempt"},
{0, &BSD_USA::RegisterClient, "RegisterClient"},
{1, &BSD_USA::StartMonitoring, "StartMonitoring"},
{2, &BSD_USA::Socket, "Socket"},
{3, &BSD_USA::SocketExempt, "SocketExempt"},
{4, nullptr, "Open"},
{5, &BSD::Select, "Select"},
{6, &BSD::Poll, "Poll"},
{5, &BSD_USA::Select, "Select"},
{6, &BSD_USA::Poll, "Poll"},
{7, nullptr, "Sysctl"},
{8, &BSD::Recv, "Recv"},
{9, &BSD::RecvFrom, "RecvFrom"},
{10, &BSD::Send, "Send"},
{11, &BSD::SendTo, "SendTo"},
{12, &BSD::Accept, "Accept"},
{13, &BSD::Bind, "Bind"},
{14, &BSD::Connect, "Connect"},
{15, &BSD::GetPeerName, "GetPeerName"},
{16, &BSD::GetSockName, "GetSockName"},
{17, &BSD::GetSockOpt, "GetSockOpt"},
{18, &BSD::Listen, "Listen"},
{8, &BSD_USA::Recv, "Recv"},
{9, &BSD_USA::RecvFrom, "RecvFrom"},
{10, &BSD_USA::Send, "Send"},
{11, &BSD_USA::SendTo, "SendTo"},
{12, &BSD_USA::Accept, "Accept"},
{13, &BSD_USA::Bind, "Bind"},
{14, &BSD_USA::Connect, "Connect"},
{15, &BSD_USA::GetPeerName, "GetPeerName"},
{16, &BSD_USA::GetSockName, "GetSockName"},
{17, &BSD_USA::GetSockOpt, "GetSockOpt"},
{18, &BSD_USA::Listen, "Listen"},
{19, nullptr, "Ioctl"},
{20, &BSD::Fcntl, "Fcntl"},
{21, &BSD::SetSockOpt, "SetSockOpt"},
{22, &BSD::Shutdown, "Shutdown"},
{20, &BSD_USA::Fcntl, "Fcntl"},
{21, &BSD_USA::SetSockOpt, "SetSockOpt"},
{22, &BSD_USA::Shutdown, "Shutdown"},
{23, nullptr, "ShutdownAllSockets"},
{24, &BSD::Write, "Write"},
{25, &BSD::Read, "Read"},
{26, &BSD::Close, "Close"},
{27, &BSD::DuplicateSocket, "DuplicateSocket"},
{24, &BSD_USA::Write, "Write"},
{25, &BSD_USA::Read, "Read"},
{26, &BSD_USA::Close, "Close"},
{27, &BSD_USA::DuplicateSocket, "DuplicateSocket"},
{28, nullptr, "GetResourceStatistics"},
{29, nullptr, "RecvMMsg"}, //3.0.0+
{30, nullptr, "SendMMsg"}, //3.0.0+
{31, &BSD::EventFd, "EventFd"}, //7.0.0+
{31, &BSD_USA::EventFd, "EventFd"}, //7.0.0+
{32, nullptr, "RegisterResourceStatisticsName"}, //7.0.0+
{33, nullptr, "RegisterClientShared"}, //10.0.0+
{34, nullptr, "GetSocketStatistics"}, //15.0.0+
@@ -1107,13 +1107,13 @@ BSD::BSD(Core::System& system_, const char* name, bool is_user_)
}
}
BSD::~BSD() {
BSD_USA::~BSD_USA() {
if (auto room_member = Network::GetRoomMember().lock()) {
room_member->Unbind(proxy_packet_received);
}
}
std::unique_lock<std::mutex> BSD::LockService() noexcept {
std::unique_lock<std::mutex> BSD_USA::LockService() noexcept {
return {};
}
+10 -10
View File
@@ -27,10 +27,10 @@ class Socket;
namespace Service::Sockets {
class BSD final : public ServiceFramework<BSD> {
class BSD_USA final : public ServiceFramework<BSD_USA> {
public:
explicit BSD(Core::System& system_, const char* name, bool is_user);
~BSD() override;
explicit BSD_USA(Core::System& system_, const char* name, bool is_user);
~BSD_USA() override;
// These methods are called from SSL; the first two are also called from
// this class for the corresponding IPC methods.
@@ -50,7 +50,7 @@ private:
};
struct PollWork {
void Execute(BSD* bsd);
void Execute(BSD_USA* bsd);
void Response(HLERequestContext& ctx);
s32 nfds;
@@ -62,7 +62,7 @@ private:
};
struct AcceptWork {
void Execute(BSD* bsd);
void Execute(BSD_USA* bsd);
void Response(HLERequestContext& ctx);
s32 fd;
@@ -72,7 +72,7 @@ private:
};
struct ConnectWork {
void Execute(BSD* bsd);
void Execute(BSD_USA* bsd);
void Response(HLERequestContext& ctx);
s32 fd;
@@ -81,7 +81,7 @@ private:
};
struct RecvWork {
void Execute(BSD* bsd);
void Execute(BSD_USA* bsd);
void Response(HLERequestContext& ctx);
s32 fd;
@@ -92,7 +92,7 @@ private:
};
struct RecvFromWork {
void Execute(BSD* bsd);
void Execute(BSD_USA* bsd);
void Response(HLERequestContext& ctx);
s32 fd;
@@ -104,7 +104,7 @@ private:
};
struct SendWork {
void Execute(BSD* bsd);
void Execute(BSD_USA* bsd);
void Response(HLERequestContext& ctx);
s32 fd;
@@ -115,7 +115,7 @@ private:
};
struct SendToWork {
void Execute(BSD* bsd);
void Execute(BSD_USA* bsd);
void Response(HLERequestContext& ctx);
s32 fd;
+3 -3
View File
@@ -66,9 +66,9 @@ void LoopProcess(Core::System& system) {
server_manager->RegisterNamedService("ethc:c", std::make_shared<ETHC_C>(system));
server_manager->RegisterNamedService("ethc:i", std::make_shared<ETHC_I>(system));
server_manager->RegisterNamedService("bsd:s", std::make_shared<BSD>(system, "bsd:s", false));
server_manager->RegisterNamedService("bsd:u", std::make_shared<BSD>(system, "bsd:u", true));
server_manager->RegisterNamedService("bsd:a", std::make_shared<BSD>(system, "bsd:a", true));
server_manager->RegisterNamedService("bsd:s", std::make_shared<BSD_USA>(system, "bsd:s", false));
server_manager->RegisterNamedService("bsd:u", std::make_shared<BSD_USA>(system, "bsd:u", true));
server_manager->RegisterNamedService("bsd:a", std::make_shared<BSD_USA>(system, "bsd:a", true));
server_manager->RegisterNamedService("bsd:nu", std::make_shared<BSD_NU>(system));
server_manager->RegisterNamedService("bsdcfg", std::make_shared<BSDCFG>(system, "bsdcfg"));
server_manager->RegisterNamedService("ifcfg", std::make_shared<BSDCFG>(system, "ifcfg"));