From 1d96e8cf8df890dee2dfa8b06dbba8cb79dc571c Mon Sep 17 00:00:00 2001 From: Jessica Hamilton Date: Fri, 2 Jun 2023 21:21:02 +1200 Subject: [PATCH 1/3] haiku: depends on libnetwork --- network.cabal | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/network.cabal b/network.cabal index e9bd5403..e98f61ea 100644 --- a/network.cabal +++ b/network.cabal @@ -175,6 +175,10 @@ library build-depends: temporary + if os(haiku) + extra-libraries: + network + if impl(ghc >=8) default-extensions: Strict StrictData From f5b10c44ce788664d2ec6c582d1aafaa7c658b06 Mon Sep 17 00:00:00 2001 From: Jessica Hamilton Date: Wed, 7 Jun 2023 11:49:05 +1200 Subject: [PATCH 2/3] configure: test for IPV6_TCLASS. * Haiku does not define IPV6_TCLASS. --- Network/Socket/Posix/Cmsg.hsc | 4 ++++ configure.ac | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Network/Socket/Posix/Cmsg.hsc b/Network/Socket/Posix/Cmsg.hsc index fed4e7bc..5249f59e 100644 --- a/Network/Socket/Posix/Cmsg.hsc +++ b/Network/Socket/Posix/Cmsg.hsc @@ -64,7 +64,11 @@ pattern CmsgIdIPv4TOS = CmsgId (#const IPPROTO_IP) (#const IP_TOS) -- | The identifier for 'IPv6TClass'. pattern CmsgIdIPv6TClass :: CmsgId +#if defined(IPV6_TCLASS) pattern CmsgIdIPv6TClass = CmsgId (#const IPPROTO_IPV6) (#const IPV6_TCLASS) +#else +pattern CmsgIdIPv6TClass = CmsgId (-1) (-1) +#endif -- | The identifier for 'IPv4PktInfo'. pattern CmsgIdIPv4PktInfo :: CmsgId diff --git a/configure.ac b/configure.ac index c894defe..0859e84d 100644 --- a/configure.ac +++ b/configure.ac @@ -83,7 +83,7 @@ AC_CHECK_FUNCS([gai_strerror gethostent accept4]) AC_CHECK_FUNCS([getpeereid]) AC_CHECK_DECLS([AI_ADDRCONFIG, AI_ALL, AI_NUMERICSERV, AI_V4MAPPED]) -AC_CHECK_DECLS([IPV6_V6ONLY]) +AC_CHECK_DECLS([IPV6_V6ONLY, IPV6_TCLASS]) AC_CHECK_DECLS([IPPROTO_IP, IPPROTO_TCP, IPPROTO_IPV6]) AC_CHECK_DECLS([SO_PEERCRED]) From 576a778516d97ccbd149d118445600af6b58c31c Mon Sep 17 00:00:00 2001 From: Jessica Hamilton Date: Wed, 7 Jun 2023 11:52:26 +1200 Subject: [PATCH 3/3] haiku: add wrappers for ntohl et al. * These are defined as macros. --- cbits/swap.c | 16 ++++++++++++++++ network.cabal | 3 +++ 2 files changed, 19 insertions(+) create mode 100644 cbits/swap.c diff --git a/cbits/swap.c b/cbits/swap.c new file mode 100644 index 00000000..8533880d --- /dev/null +++ b/cbits/swap.c @@ -0,0 +1,16 @@ +#include + +static uint32_t my_htonl(uint32_t x) { return htonl(x); } +static uint16_t my_htons(uint16_t x) { return htons(x); } +static uint32_t my_ntohl(uint32_t x) { return ntohl(x); } +static uint32_t my_ntohs(uint16_t x) { return ntohs(x); } + +#undef htonl +#undef htons +#undef ntohl +#undef ntohs + +uint32_t htonl(uint32_t x) { return my_htonl(x); } +uint32_t htons(uint16_t x) { return my_htons(x); } +uint32_t ntohl(uint32_t x) { return my_ntohl(x); } +uint32_t ntohs(uint16_t x) { return my_ntohs(x); } diff --git a/network.cabal b/network.cabal index e98f61ea..3824e961 100644 --- a/network.cabal +++ b/network.cabal @@ -176,6 +176,9 @@ library temporary if os(haiku) + c-sources: + cbits/swap.c + extra-libraries: network