fix building with system libslirp
This commit is contained in:
parent
8423dae6ff
commit
a174901412
|
@ -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}/../..")
|
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")
|
||||||
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)
|
if (USE_QT6)
|
||||||
target_include_directories(melonDS PUBLIC ${Qt6Gui_PRIVATE_INCLUDE_DIRS})
|
target_include_directories(melonDS PUBLIC ${Qt6Gui_PRIVATE_INCLUDE_DIRS})
|
||||||
else()
|
else()
|
||||||
|
|
|
@ -23,12 +23,7 @@
|
||||||
#include "FIFO.h"
|
#include "FIFO.h"
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
|
||||||
#include <libslirp.h>
|
#include <slirp/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>
|
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
|
@ -163,63 +158,6 @@ Net_Slirp::Net_Slirp(const Platform::SendPacketCallback& callback) noexcept : Ca
|
||||||
Ctx = slirp_new(&cfg, &cb, this);
|
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
|
Net_Slirp::~Net_Slirp() noexcept
|
||||||
{
|
{
|
||||||
if (Ctx)
|
if (Ctx)
|
||||||
|
@ -229,7 +167,6 @@ Net_Slirp::~Net_Slirp() noexcept
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FinishUDPFrame(u8* data, int len)
|
void FinishUDPFrame(u8* data, int len)
|
||||||
{
|
{
|
||||||
u8* ipheader = &data[0xE];
|
u8* ipheader = &data[0xE];
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include "NetDriver.h"
|
#include "NetDriver.h"
|
||||||
|
|
||||||
#include <libslirp.h>
|
#include <slirp/libslirp.h>
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
|
|
Loading…
Reference in New Issue