diff --git a/CMake/switch/asio/include/errno.h b/CMake/switch/asio/include/errno.h new file mode 100644 index 000000000..209a0eae1 --- /dev/null +++ b/CMake/switch/asio/include/errno.h @@ -0,0 +1,5 @@ +#pragma once + +#include_next + +#define ESHUTDOWN (__ELASTERROR + 1) diff --git a/CMake/switch/asio/include/net/if.h b/CMake/switch/asio/include/net/if.h new file mode 100644 index 000000000..d2fa1021f --- /dev/null +++ b/CMake/switch/asio/include/net/if.h @@ -0,0 +1,24 @@ +#ifndef _NET_IF_H +#define _NET_IF_H 1 + +#define IF_NAMESIZE 16 + +struct if_nameindex { + unsigned int if_index; + char *if_name; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +unsigned int if_nametoindex(const char *__ifname); +char *if_indextoname(unsigned int __ifindex, char *__ifname); +struct if_nameindex *if_nameindex(); +void if_freenameindex(struct if_nameindex *__ptr); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/CMake/switch/asio/include/netinet/in.h b/CMake/switch/asio/include/netinet/in.h new file mode 100644 index 000000000..4b1a8f919 --- /dev/null +++ b/CMake/switch/asio/include/netinet/in.h @@ -0,0 +1,8 @@ +#pragma once + +#include_next + +struct ipv6_mreq { + struct in6_addr ipv6mr_multiaddr; + unsigned ipv6mr_interface; +}; diff --git a/CMake/switch/asio/include/sys/uio.h b/CMake/switch/asio/include/sys/uio.h new file mode 100644 index 000000000..4c3761916 --- /dev/null +++ b/CMake/switch/asio/include/sys/uio.h @@ -0,0 +1,10 @@ +#ifndef _SYS_UIO_H +#define _SYS_UIO_H 1 + +#include +#include + +ssize_t readv(int __fd, const struct iovec *__iovec, int __count); +ssize_t writev(int __fd, const struct iovec *__iovec, int __count); + +#endif diff --git a/CMake/switch/asio/include/sys/un.h b/CMake/switch/asio/include/sys/un.h new file mode 100644 index 000000000..12a786d8c --- /dev/null +++ b/CMake/switch/asio/include/sys/un.h @@ -0,0 +1,16 @@ +#ifndef _SYS_UN_H +#define _SYS_UN_H 1 + +#include + +#ifndef _SA_FAMILY_T_DECLARED +typedef __sa_family_t sa_family_t; +#define _SA_FAMILY_T_DECLARED +#endif + +struct sockaddr_un { + sa_family_t sun_family; + char sun_path[108]; +}; + +#endif diff --git a/CMake/switch/asio_defs.cmake b/CMake/switch/asio_defs.cmake new file mode 100644 index 000000000..50451a2d2 --- /dev/null +++ b/CMake/switch/asio_defs.cmake @@ -0,0 +1,5 @@ +# Enables a number of header file definitions required by ASIO +target_compile_definitions(asio INTERFACE _DEFAULT_SOURCE=ON) + +# Missing headers and declarations provided by DevilutionX +target_include_directories(asio BEFORE INTERFACE CMake/switch/asio/include) diff --git a/CMake/switch_defs.cmake b/CMake/switch/switch_defs.cmake similarity index 100% rename from CMake/switch_defs.cmake rename to CMake/switch/switch_defs.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index a7b67c2da..9cd6ad636 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,6 +132,7 @@ if(GPERF) endif() if(NINTENDO_SWITCH) + list(APPEND CMAKE_MODULE_PATH "${DevilutionX_SOURCE_DIR}/CMake/switch") include(switch_defs) endif() @@ -268,6 +269,8 @@ if(NOT NONET AND NOT DISABLE_TCP) ASIO_HAS_UNISTD_H=ON) target_include_directories(asio BEFORE INTERFACE CMake/ctr/asio/include) + elseif(NINTENDO_SWITCH) + include(asio_defs) endif() endif()