mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2025-06-11 00:47:56 -05:00
bsd: Use std::span for read payloads
Allows the use of HLERequestContext::ReadBufferSpan
This commit is contained in:
@ -186,7 +186,7 @@ void BSD::Poll(Kernel::HLERequestContext& ctx) {
|
||||
ExecuteWork(ctx, PollWork{
|
||||
.nfds = nfds,
|
||||
.timeout = timeout,
|
||||
.read_buffer = ctx.ReadBuffer(),
|
||||
.read_buffer = ctx.ReadBufferSpan(),
|
||||
.write_buffer = std::vector<u8>(ctx.GetWriteBufferSize()),
|
||||
});
|
||||
}
|
||||
@ -208,8 +208,7 @@ void BSD::Bind(Kernel::HLERequestContext& ctx) {
|
||||
const s32 fd = rp.Pop<s32>();
|
||||
|
||||
LOG_DEBUG(Service, "called. fd={} addrlen={}", fd, ctx.GetReadBufferSize());
|
||||
|
||||
BuildErrnoResponse(ctx, BindImpl(fd, ctx.ReadBuffer()));
|
||||
BuildErrnoResponse(ctx, BindImpl(fd, ctx.ReadBufferSpan()));
|
||||
}
|
||||
|
||||
void BSD::Connect(Kernel::HLERequestContext& ctx) {
|
||||
@ -220,7 +219,7 @@ void BSD::Connect(Kernel::HLERequestContext& ctx) {
|
||||
|
||||
ExecuteWork(ctx, ConnectWork{
|
||||
.fd = fd,
|
||||
.addr = ctx.ReadBuffer(),
|
||||
.addr = ctx.ReadBufferSpan(),
|
||||
});
|
||||
}
|
||||
|
||||
@ -312,7 +311,7 @@ void BSD::SetSockOpt(Kernel::HLERequestContext& ctx) {
|
||||
const u32 level = rp.Pop<u32>();
|
||||
const OptName optname = static_cast<OptName>(rp.Pop<u32>());
|
||||
|
||||
const std::vector<u8> buffer = ctx.ReadBuffer();
|
||||
const auto buffer = ctx.ReadBufferSpan();
|
||||
const u8* optval = buffer.empty() ? nullptr : buffer.data();
|
||||
size_t optlen = buffer.size();
|
||||
|
||||
@ -383,7 +382,7 @@ void BSD::Send(Kernel::HLERequestContext& ctx) {
|
||||
ExecuteWork(ctx, SendWork{
|
||||
.fd = fd,
|
||||
.flags = flags,
|
||||
.message = ctx.ReadBuffer(),
|
||||
.message = ctx.ReadBufferSpan(),
|
||||
});
|
||||
}
|
||||
|
||||
@ -398,8 +397,8 @@ void BSD::SendTo(Kernel::HLERequestContext& ctx) {
|
||||
ExecuteWork(ctx, SendToWork{
|
||||
.fd = fd,
|
||||
.flags = flags,
|
||||
.message = ctx.ReadBuffer(0),
|
||||
.addr = ctx.ReadBuffer(1),
|
||||
.message = ctx.ReadBufferSpan(0),
|
||||
.addr = ctx.ReadBufferSpan(1),
|
||||
});
|
||||
}
|
||||
|
||||
@ -412,7 +411,7 @@ void BSD::Write(Kernel::HLERequestContext& ctx) {
|
||||
ExecuteWork(ctx, SendWork{
|
||||
.fd = fd,
|
||||
.flags = 0,
|
||||
.message = ctx.ReadBuffer(),
|
||||
.message = ctx.ReadBufferSpan(),
|
||||
});
|
||||
}
|
||||
|
||||
@ -489,7 +488,7 @@ std::pair<s32, Errno> BSD::SocketImpl(Domain domain, Type type, Protocol protoco
|
||||
return {fd, Errno::SUCCESS};
|
||||
}
|
||||
|
||||
std::pair<s32, Errno> BSD::PollImpl(std::vector<u8>& write_buffer, std::vector<u8> read_buffer,
|
||||
std::pair<s32, Errno> BSD::PollImpl(std::vector<u8>& write_buffer, std::span<const u8> read_buffer,
|
||||
s32 nfds, s32 timeout) {
|
||||
if (write_buffer.size() < nfds * sizeof(PollFD)) {
|
||||
return {-1, Errno::INVAL};
|
||||
@ -584,7 +583,7 @@ std::pair<s32, Errno> BSD::AcceptImpl(s32 fd, std::vector<u8>& write_buffer) {
|
||||
return {new_fd, Errno::SUCCESS};
|
||||
}
|
||||
|
||||
Errno BSD::BindImpl(s32 fd, const std::vector<u8>& addr) {
|
||||
Errno BSD::BindImpl(s32 fd, std::span<const u8> addr) {
|
||||
if (!IsFileDescriptorValid(fd)) {
|
||||
return Errno::BADF;
|
||||
}
|
||||
@ -595,7 +594,7 @@ Errno BSD::BindImpl(s32 fd, const std::vector<u8>& addr) {
|
||||
return Translate(file_descriptors[fd]->socket->Bind(Translate(addr_in)));
|
||||
}
|
||||
|
||||
Errno BSD::ConnectImpl(s32 fd, const std::vector<u8>& addr) {
|
||||
Errno BSD::ConnectImpl(s32 fd, std::span<const u8> addr) {
|
||||
if (!IsFileDescriptorValid(fd)) {
|
||||
return Errno::BADF;
|
||||
}
|
||||
@ -800,15 +799,15 @@ std::pair<s32, Errno> BSD::RecvFromImpl(s32 fd, u32 flags, std::vector<u8>& mess
|
||||
return {ret, bsd_errno};
|
||||
}
|
||||
|
||||
std::pair<s32, Errno> BSD::SendImpl(s32 fd, u32 flags, const std::vector<u8>& message) {
|
||||
std::pair<s32, Errno> BSD::SendImpl(s32 fd, u32 flags, std::span<const u8> message) {
|
||||
if (!IsFileDescriptorValid(fd)) {
|
||||
return {-1, Errno::BADF};
|
||||
}
|
||||
return Translate(file_descriptors[fd]->socket->Send(message, flags));
|
||||
}
|
||||
|
||||
std::pair<s32, Errno> BSD::SendToImpl(s32 fd, u32 flags, const std::vector<u8>& message,
|
||||
const std::vector<u8>& addr) {
|
||||
std::pair<s32, Errno> BSD::SendToImpl(s32 fd, u32 flags, std::span<const u8> message,
|
||||
std::span<const u8> addr) {
|
||||
if (!IsFileDescriptorValid(fd)) {
|
||||
return {-1, Errno::BADF};
|
||||
}
|
||||
|
Reference in New Issue
Block a user