fix building with system libslirp

This commit is contained in:
Nadia Holmquist Pedersen 2024-08-07 17:23:48 +02:00
parent 8423dae6ff
commit a174901412
3 changed files with 2 additions and 68 deletions

View File

@ -164,9 +164,6 @@ target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../..")
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../../net")
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../../net/libslirp/src")
get_target_property(SLIRP_BINARY_DIR slirp BINARY_DIR)
target_include_directories(melonDS PUBLIC "${SLIRP_BINARY_DIR}") # for libslirp-version.h
if (USE_QT6)
target_include_directories(melonDS PUBLIC ${Qt6Gui_PRIVATE_INCLUDE_DIRS})
else()

View File

@ -23,12 +23,7 @@
#include "FIFO.h"
#include "Platform.h"
#include <libslirp.h>
// "register" is indirectly used by slirp.h but isn't allowed in C++17, this is a workaround
#define register
// Needed for Slirp's definition so we can adjust the opaque pointer in the move constructor
#include <slirp.h>
#include <slirp/libslirp.h>
#ifdef __WIN32__
#include <ws2tcpip.h>
@ -163,63 +158,6 @@ Net_Slirp::Net_Slirp(const Platform::SendPacketCallback& callback) noexcept : Ca
Ctx = slirp_new(&cfg, &cb, this);
}
Net_Slirp::Net_Slirp(Net_Slirp&& other) noexcept
{
RXBuffer = other.RXBuffer;
IPv4ID = other.IPv4ID;
Ctx = other.Ctx;
PollListSize = other.PollListSize;
Callback = std::move(other.Callback);
memcpy(PollList, other.PollList, sizeof(PollList));
other.RXBuffer = {};
other.IPv4ID = 0;
other.Ctx = nullptr;
other.PollListSize = 0;
other.Callback = nullptr;
memset(other.PollList, 0, sizeof(other.PollList));
if (Ctx)
{
Ctx->opaque = this;
// Gotta ensure that the context doesn't try to pass around a dead object
}
}
Net_Slirp& Net_Slirp::operator=(Net_Slirp&& other) noexcept
{
if (this != &other)
{
if (Ctx)
{
slirp_cleanup(Ctx);
}
RXBuffer = other.RXBuffer;
IPv4ID = other.IPv4ID;
Ctx = other.Ctx;
PollListSize = other.PollListSize;
Callback = std::move(other.Callback);
memcpy(PollList, other.PollList, sizeof(PollList));
other.RXBuffer = {};
other.IPv4ID = 0;
other.Ctx = nullptr;
other.PollListSize = 0;
other.Callback = nullptr;
memset(other.PollList, 0, sizeof(other.PollList));
if (Ctx)
{
Ctx->opaque = this;
// Gotta ensure that the context doesn't try to pass around a dead object
}
}
return *this;
}
Net_Slirp::~Net_Slirp() noexcept
{
if (Ctx)
@ -229,7 +167,6 @@ Net_Slirp::~Net_Slirp() noexcept
}
}
void FinishUDPFrame(u8* data, int len)
{
u8* ipheader = &data[0xE];

View File

@ -24,7 +24,7 @@
#include "Platform.h"
#include "NetDriver.h"
#include <libslirp.h>
#include <slirp/libslirp.h>
#ifdef __WIN32__
#include <ws2tcpip.h>