Builtin slirp: compilation fixes for VS2019 and Cygwin.

- VS2019 needs C++20 standard to be set.
- Some Cygwin related additions in util.cc.
- slirp_ssize_t definition and usage fixed.
- changed include position of compat.h in slirp.h.
This commit is contained in:
Volker Ruppert 2024-04-25 21:10:48 +02:00
parent 971576e32f
commit c5fd56558f
7 changed files with 20 additions and 4 deletions

View File

@ -20,6 +20,7 @@
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{9EFB2055-35E8-42E9-A274-F4987CB2A655}</ProjectGuid> <ProjectGuid>{9EFB2055-35E8-42E9-A274-F4987CB2A655}</ProjectGuid>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@ -140,6 +141,7 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner> <SuppressStartupBanner>true</SuppressStartupBanner>
<CallingConvention>FastCall</CallingConvention> <CallingConvention>FastCall</CallingConvention>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile> </ClCompile>
<ResourceCompile> <ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>

1
bochs/configure vendored
View File

@ -26536,6 +26536,7 @@ case "$target" in
else else
C_OPT="$C_OPT /EHs-c-" C_OPT="$C_OPT /EHs-c-"
fi fi
C_OPT="$C_OPT /std:c++20"
if test "$bx_plugins" = 1; then if test "$bx_plugins" = 1; then
CFLAGS="/nologo /MD /W3 /DNDEBUG /DWIN32 /D_WINDOWS /D_CRT_SECURE_NO_WARNINGS $C_OPT" CFLAGS="/nologo /MD /W3 /DNDEBUG /DWIN32 /D_WINDOWS /D_CRT_SECURE_NO_WARNINGS $C_OPT"
else else

View File

@ -2907,6 +2907,7 @@ case "$target" in
else else
C_OPT="$C_OPT /EHs-c-" C_OPT="$C_OPT /EHs-c-"
fi fi
C_OPT="$C_OPT /std:c++20"
if test "$bx_plugins" = 1; then if test "$bx_plugins" = 1; then
CFLAGS="/nologo /MD /W3 /DNDEBUG /DWIN32 /D_WINDOWS /D_CRT_SECURE_NO_WARNINGS $C_OPT" CFLAGS="/nologo /MD /W3 /DNDEBUG /DWIN32 /D_WINDOWS /D_CRT_SECURE_NO_WARNINGS $C_OPT"
else else

View File

@ -113,7 +113,7 @@ protected:
} bx_slirp_match; } bx_slirp_match;
static ssize_t send_packet(const void *buf, size_t len, void *opaque) static slirp_ssize_t send_packet(const void *buf, size_t len, void *opaque)
{ {
bx_slirp_pktmover_c *class_ptr = (bx_slirp_pktmover_c *)opaque; bx_slirp_pktmover_c *class_ptr = (bx_slirp_pktmover_c *)opaque;

View File

@ -6,11 +6,12 @@
#ifdef _WIN32 #ifdef _WIN32
#include <winsock2.h> #include <winsock2.h>
typedef Bit64s slirp_ssize_t;
#else #else
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#endif
typedef ssize_t slirp_ssize_t; typedef ssize_t slirp_ssize_t;
#endif
struct Slirp; struct Slirp;
typedef struct Slirp Slirp; typedef struct Slirp Slirp;

View File

@ -9,7 +9,6 @@
#include "config.h" #include "config.h"
#include "slirp_config.h" #include "slirp_config.h"
#include "compat.h"
#ifdef _WIN32 #ifdef _WIN32
@ -152,6 +151,8 @@ void free(void *ptr);
#include <sys/stropts.h> #include <sys/stropts.h>
#endif #endif
#include "compat.h"
#include "debug.h" #include "debug.h"
#include "util.h" #include "util.h"

View File

@ -26,11 +26,17 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#ifdef __CYGWIN__
#define __USE_W32_SOCKETS
#define _WIN32
#endif
#include "config.h" #include "config.h"
#include "util.h"
#if BX_NETWORKING && BX_NETMOD_SLIRP #if BX_NETWORKING && BX_NETMOD_SLIRP
#include "util.h"
#include <fcntl.h> #include <fcntl.h>
#include <stdint.h> #include <stdint.h>
@ -174,7 +180,11 @@ static int socket_error(void)
int slirp_ioctlsocket_wrap(int fd, int req, void *val) int slirp_ioctlsocket_wrap(int fd, int req, void *val)
{ {
int ret; int ret;
#ifdef __CYGWIN__
ret = ioctlsocket(fd, req, (__ms_u_long*)val);
#else
ret = ioctlsocket(fd, req, (u_long*)val); ret = ioctlsocket(fd, req, (u_long*)val);
#endif
if (ret < 0) { if (ret < 0) {
errno = socket_error(); errno = socket_error();
} }