aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/hle/service/sockets
diff options
context:
space:
mode:
authorliamwhite <[email protected]>2023-02-02 15:53:28 -0500
committerGitHub <[email protected]>2023-02-02 15:53:28 -0500
commitb01698775b468a04e4d0a9bdd86035ff00e6decb (patch)
tree88f1784fe7833392caeaf713a7a616772f446b18 /src/core/hle/service/sockets
parent8a33f8bd303221fdcbdebe2579e3fbefa03b385e (diff)
downloadyuzu-mainline-b01698775b468a04e4d0a9bdd86035ff00e6decb.tar.gz
yuzu-mainline-b01698775b468a04e4d0a9bdd86035ff00e6decb.zip
Revert "hle_ipc: Use std::span to avoid heap allocations/copies when calling ReadBuffer"
Diffstat (limited to 'src/core/hle/service/sockets')
-rw-r--r--src/core/hle/service/sockets/bsd.cpp15
-rw-r--r--src/core/hle/service/sockets/bsd.h23
-rw-r--r--src/core/hle/service/sockets/sfdnsres.cpp2
3 files changed, 20 insertions, 20 deletions
diff --git a/src/core/hle/service/sockets/bsd.cpp b/src/core/hle/service/sockets/bsd.cpp
index bdb499268..9e94a462f 100644
--- a/src/core/hle/service/sockets/bsd.cpp
+++ b/src/core/hle/service/sockets/bsd.cpp
@@ -208,6 +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()));
}
@@ -311,7 +312,7 @@ void BSD::SetSockOpt(Kernel::HLERequestContext& ctx) {
const u32 level = rp.Pop<u32>();
const OptName optname = static_cast<OptName>(rp.Pop<u32>());
- const auto buffer = ctx.ReadBuffer();
+ const std::vector<u8> buffer = ctx.ReadBuffer();
const u8* optval = buffer.empty() ? nullptr : buffer.data();
size_t optlen = buffer.size();
@@ -488,7 +489,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::span<const u8> read_buffer,
+std::pair<s32, Errno> BSD::PollImpl(std::vector<u8>& write_buffer, std::vector<u8> read_buffer,
s32 nfds, s32 timeout) {
if (write_buffer.size() < nfds * sizeof(PollFD)) {
return {-1, Errno::INVAL};
@@ -583,7 +584,7 @@ std::pair<s32, Errno> BSD::AcceptImpl(s32 fd, std::vector<u8>& write_buffer) {
return {new_fd, Errno::SUCCESS};
}
-Errno BSD::BindImpl(s32 fd, std::span<const u8> addr) {
+Errno BSD::BindImpl(s32 fd, const std::vector<u8>& addr) {
if (!IsFileDescriptorValid(fd)) {
return Errno::BADF;
}
@@ -594,7 +595,7 @@ Errno BSD::BindImpl(s32 fd, std::span<const u8> addr) {
return Translate(file_descriptors[fd]->socket->Bind(Translate(addr_in)));
}
-Errno BSD::ConnectImpl(s32 fd, std::span<const u8> addr) {
+Errno BSD::ConnectImpl(s32 fd, const std::vector<u8>& addr) {
if (!IsFileDescriptorValid(fd)) {
return Errno::BADF;
}
@@ -799,15 +800,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, std::span<const u8> message) {
+std::pair<s32, Errno> BSD::SendImpl(s32 fd, u32 flags, const std::vector<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, std::span<const u8> message,
- std::span<const u8> addr) {
+std::pair<s32, Errno> BSD::SendToImpl(s32 fd, u32 flags, const std::vector<u8>& message,
+ const std::vector<u8>& addr) {
if (!IsFileDescriptorValid(fd)) {
return {-1, Errno::BADF};
}
diff --git a/src/core/hle/service/sockets/bsd.h b/src/core/hle/service/sockets/bsd.h
index 56bb3f8b1..81e855e0f 100644
--- a/src/core/hle/service/sockets/bsd.h
+++ b/src/core/hle/service/sockets/bsd.h
@@ -4,7 +4,6 @@
#pragma once
#include <memory>
-#include <span>
#include <vector>
#include "common/common_types.h"
@@ -45,7 +44,7 @@ private:
s32 nfds;
s32 timeout;
- std::span<const u8> read_buffer;
+ std::vector<u8> read_buffer;
std::vector<u8> write_buffer;
s32 ret{};
Errno bsd_errno{};
@@ -66,7 +65,7 @@ private:
void Response(Kernel::HLERequestContext& ctx);
s32 fd;
- std::span<const u8> addr;
+ std::vector<u8> addr;
Errno bsd_errno{};
};
@@ -99,7 +98,7 @@ private:
s32 fd;
u32 flags;
- std::span<const u8> message;
+ std::vector<u8> message;
s32 ret{};
Errno bsd_errno{};
};
@@ -110,8 +109,8 @@ private:
s32 fd;
u32 flags;
- std::span<const u8> message;
- std::span<const u8> addr;
+ std::vector<u8> message;
+ std::vector<u8> addr;
s32 ret{};
Errno bsd_errno{};
};
@@ -144,11 +143,11 @@ private:
void ExecuteWork(Kernel::HLERequestContext& ctx, Work work);
std::pair<s32, Errno> SocketImpl(Domain domain, Type type, Protocol protocol);
- std::pair<s32, Errno> PollImpl(std::vector<u8>& write_buffer, std::span<const u8> read_buffer,
+ std::pair<s32, Errno> PollImpl(std::vector<u8>& write_buffer, std::vector<u8> read_buffer,
s32 nfds, s32 timeout);
std::pair<s32, Errno> AcceptImpl(s32 fd, std::vector<u8>& write_buffer);
- Errno BindImpl(s32 fd, std::span<const u8> addr);
- Errno ConnectImpl(s32 fd, std::span<const u8> addr);
+ Errno BindImpl(s32 fd, const std::vector<u8>& addr);
+ Errno ConnectImpl(s32 fd, const std::vector<u8>& addr);
Errno GetPeerNameImpl(s32 fd, std::vector<u8>& write_buffer);
Errno GetSockNameImpl(s32 fd, std::vector<u8>& write_buffer);
Errno ListenImpl(s32 fd, s32 backlog);
@@ -158,9 +157,9 @@ private:
std::pair<s32, Errno> RecvImpl(s32 fd, u32 flags, std::vector<u8>& message);
std::pair<s32, Errno> RecvFromImpl(s32 fd, u32 flags, std::vector<u8>& message,
std::vector<u8>& addr);
- std::pair<s32, Errno> SendImpl(s32 fd, u32 flags, std::span<const u8> message);
- std::pair<s32, Errno> SendToImpl(s32 fd, u32 flags, std::span<const u8> message,
- std::span<const u8> addr);
+ std::pair<s32, Errno> SendImpl(s32 fd, u32 flags, const std::vector<u8>& message);
+ std::pair<s32, Errno> SendToImpl(s32 fd, u32 flags, const std::vector<u8>& message,
+ const std::vector<u8>& addr);
Errno CloseImpl(s32 fd);
s32 FindFreeFileDescriptorHandle() noexcept;
diff --git a/src/core/hle/service/sockets/sfdnsres.cpp b/src/core/hle/service/sockets/sfdnsres.cpp
index e96eda7f3..097c37d7a 100644
--- a/src/core/hle/service/sockets/sfdnsres.cpp
+++ b/src/core/hle/service/sockets/sfdnsres.cpp
@@ -243,4 +243,4 @@ void SFDNSRES::GetAddrInfoRequestWithOptions(Kernel::HLERequestContext& ctx) {
rb.Push(0);
}
-} // namespace Service::Sockets
+} // namespace Service::Sockets \ No newline at end of file