From ba0c6046b635798b587253300511ef55ab7c7702 Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Wed, 20 Dec 2017 15:56:04 +0900 Subject: [PATCH 1/5] removing -DCALLCONV. --- network.buildinfo.in | 6 +++--- stack.yaml | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/network.buildinfo.in b/network.buildinfo.in index 39b6cfb1..571b094d 100644 --- a/network.buildinfo.in +++ b/network.buildinfo.in @@ -1,7 +1,7 @@ -ghc-options: -DCALLCONV=@CALLCONV@ @EXTRA_CPPFLAGS@ -ghc-prof-options: -DCALLCONV=@CALLCONV@ @EXTRA_CPPFLAGS@ +ghc-options: @EXTRA_CPPFLAGS@ +ghc-prof-options: @EXTRA_CPPFLAGS@ ld-options: @LDFLAGS@ -cc-options: -DCALLCONV=@CALLCONV@ @EXTRA_CPPFLAGS@ +cc-options: @EXTRA_CPPFLAGS@ c-sources: @EXTRA_SRCS@ extra-libraries: @EXTRA_LIBS@ install-includes: HsNetworkConfig.h diff --git a/stack.yaml b/stack.yaml index bbe64a0e..673a9bb6 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,8 +1,6 @@ resolver: lts-9.18 packages: - '.' -ghc-options: - "*": -DCALLCONV=ccall nix: packages: [ ncurses ] From d9541006bacc91fe02d4e3e31b8fa7e9bec66c72 Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Wed, 20 Dec 2017 16:09:16 +0900 Subject: [PATCH 2/5] defining HsNetDef.h. --- Network/BSD.hsc | 1 + Network/Socket/Types.hsc | 1 + include/HsNet.h | 25 +------------------------ include/HsNetDef.h | 33 +++++++++++++++++++++++++++++++++ network.cabal | 2 +- 5 files changed, 37 insertions(+), 25 deletions(-) create mode 100644 include/HsNetDef.h diff --git a/Network/BSD.hsc b/Network/BSD.hsc index 529e8065..59b4d1de 100644 --- a/Network/BSD.hsc +++ b/Network/BSD.hsc @@ -17,6 +17,7 @@ ----------------------------------------------------------------------------- #include "HsNet.h" +##include "HsNetDef.h" module Network.BSD {-# DEPRECATED "This platform dependent module is no longer supported." #-} ( diff --git a/Network/Socket/Types.hsc b/Network/Socket/Types.hsc index abe2a677..f1370050 100644 --- a/Network/Socket/Types.hsc +++ b/Network/Socket/Types.hsc @@ -3,6 +3,7 @@ {-# LANGUAGE ForeignFunctionInterface #-} #include "HsNet.h" +##include "HsNetDef.h" module Network.Socket.Types ( diff --git a/include/HsNet.h b/include/HsNet.h index 858ce4e0..decae7af 100644 --- a/include/HsNet.h +++ b/include/HsNet.h @@ -7,19 +7,12 @@ #ifndef HSNET_H #define HSNET_H -#include "HsNetworkConfig.h" +#include "HsNetDef.h" #ifdef NEED_WINVER # define WINVER 0x0501 #endif -/* ultra-evil... */ -#undef PACKAGE_BUGREPORT -#undef PACKAGE_NAME -#undef PACKAGE_STRING -#undef PACKAGE_TARNAME -#undef PACKAGE_VERSION - #ifndef INLINE # if defined(_MSC_VER) # define INLINE extern __inline @@ -161,22 +154,6 @@ hsnet_freeaddrinfo(struct addrinfo *ai) } #endif -#if defined(HAVE_WINSOCK2_H) -# define WITH_WINSOCK 1 -#endif - -#if !defined(mingw32_HOST_OS) && !defined(_WIN32) -# define DOMAIN_SOCKET_SUPPORT 1 -#endif - -#if !defined(CALLCONV) -# if defined(WITH_WINSOCK) -# define CALLCONV stdcall -# else -# define CALLCONV ccall -# endif -#endif - #if !defined(IOV_MAX) # define IOV_MAX 1024 #endif diff --git a/include/HsNetDef.h b/include/HsNetDef.h new file mode 100644 index 00000000..5f4e02a3 --- /dev/null +++ b/include/HsNetDef.h @@ -0,0 +1,33 @@ +#ifndef HSNETDEF_H +#define HSNETDEF_H + +#include "HsNetworkConfig.h" + +/* ultra-evil... */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#if defined(HAVE_WINSOCK2_H) +# define WITH_WINSOCK 1 +#endif + +#if !defined(mingw32_HOST_OS) && !defined(_WIN32) +# define DOMAIN_SOCKET_SUPPORT 1 +#endif + +#if defined(WITH_WINSOCK) +# define CALLCONV stdcall +#else +# define CALLCONV ccall +#endif + +#if defined(mingw32_HOST_OS) +# define SAFE_ON_WIN safe +#else +# define SAFE_ON_WIN unsafe +#endif + +#endif /* HSNETDEF_H */ diff --git a/network.cabal b/network.cabal index bb0a3509..eaa45f23 100644 --- a/network.cabal +++ b/network.cabal @@ -24,7 +24,7 @@ extra-source-files: README.md CHANGELOG.md examples/*.hs tests/*.hs config.guess config.sub install-sh configure.ac configure network.buildinfo.in - include/HsNetworkConfig.h.in include/HsNet.h + include/HsNetworkConfig.h.in include/HsNet.h include/HsDef.h -- C sources only used on some systems cbits/ancilData.c cbits/asyncAccept.c cbits/initWinSock.c cbits/winSockErr.c From 91c3dc244945bf1fb3173b4b325188ca439051d0 Mon Sep 17 00:00:00 2001 From: Tamar Christina Date: Sun, 18 Mar 2018 15:09:50 +0000 Subject: [PATCH 3/5] Fix callconv warning on Windows --- include/HsNetDef.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/include/HsNetDef.h b/include/HsNetDef.h index 5f4e02a3..ec3ef9c6 100644 --- a/include/HsNetDef.h +++ b/include/HsNetDef.h @@ -18,12 +18,24 @@ # define DOMAIN_SOCKET_SUPPORT 1 #endif -#if defined(WITH_WINSOCK) -# define CALLCONV stdcall +/* stdcall is for Windows 32. + Haskell FFI does not have a keyword for Windows 64. + If ccall/stdcall is specified on Windows 64, + GHC ignores it and use a proper ABI for Windows 64. + But if stdcall is specified, GHC displays a warning. + So, let's use ccall for Windows 64. + */ +#if defined(mingw32_HOST_OS) +# if defined(i386_HOST_ARCH) +# define CALLCONV stdcall +# elif defined(x86_64_HOST_ARCH) +# define CALLCONV ccall +# else +# error Unknown mingw32 arch +# endif #else # define CALLCONV ccall #endif - #if defined(mingw32_HOST_OS) # define SAFE_ON_WIN safe #else From 54bd3de4517018498da0fa08bd1868de07319f58 Mon Sep 17 00:00:00 2001 From: Tamar Christina Date: Mon, 28 May 2018 14:05:00 +0100 Subject: [PATCH 4/5] network: make it compile using CALLCONV header. --- Network/Socket.hsc | 3 +-- Network/Socket/Internal.hsc | 1 + configure.ac | 6 +----- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Network/Socket.hsc b/Network/Socket.hsc index ac69fcfc..6028d91e 100644 --- a/Network/Socket.hsc +++ b/Network/Socket.hsc @@ -91,8 +91,7 @@ ----------------------------------------------------------------------------- #include "HsNet.h" - --- In order to process this file, you need to have CALLCONV defined. +##include "HsNetDef.h" module Network.Socket ( diff --git a/Network/Socket/Internal.hsc b/Network/Socket/Internal.hsc index b3bc2f26..8904c046 100644 --- a/Network/Socket/Internal.hsc +++ b/Network/Socket/Internal.hsc @@ -19,6 +19,7 @@ ----------------------------------------------------------------------------- #include "HsNet.h" +##include "HsNetDef.h" module Network.Socket.Internal ( diff --git a/configure.ac b/configure.ac index b9a8c315..ab4eb140 100644 --- a/configure.ac +++ b/configure.ac @@ -101,7 +101,7 @@ else fi dnl -------------------------------------------------- -dnl * test for GETPEEREID(3) +dnl * test for GETPEEREID(3) dnl -------------------------------------------------- AC_MSG_CHECKING(for getpeereid in unistd.h) AC_CHECK_FUNC( getpeereid, AC_DEFINE([HAVE_GETPEEREID], [1], [Define to 1 if you have getpeereid.] )) @@ -173,17 +173,13 @@ case "$host" in *-mingw* | *-msys*) EXTRA_SRCS="cbits/initWinSock.c, cbits/winSockErr.c, cbits/asyncAccept.c" EXTRA_LIBS=ws2_32 - CALLCONV=stdcall ;; *-solaris2*) EXTRA_SRCS="cbits/ancilData.c" EXTRA_LIBS="nsl, socket" - CALLCONV=ccall ;; *) EXTRA_SRCS="cbits/ancilData.c" EXTRA_LIBS= - CALLCONV=ccall ;; esac -AC_SUBST([CALLCONV]) AC_SUBST([EXTRA_CPPFLAGS]) AC_SUBST([EXTRA_LIBS]) AC_SUBST([EXTRA_SRCS]) From 7c9a0e1c3d98a10704ee741e247ff241a9575dd0 Mon Sep 17 00:00:00 2001 From: Tamar Christina Date: Tue, 29 May 2018 02:01:48 +0100 Subject: [PATCH 5/5] network: fix configure --- configure.ac | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure.ac b/configure.ac index ab4eb140..0d29f150 100644 --- a/configure.ac +++ b/configure.ac @@ -173,12 +173,15 @@ case "$host" in *-mingw* | *-msys*) EXTRA_SRCS="cbits/initWinSock.c, cbits/winSockErr.c, cbits/asyncAccept.c" EXTRA_LIBS=ws2_32 + ;; *-solaris2*) EXTRA_SRCS="cbits/ancilData.c" EXTRA_LIBS="nsl, socket" + ;; *) EXTRA_SRCS="cbits/ancilData.c" EXTRA_LIBS= + ;; esac AC_SUBST([EXTRA_CPPFLAGS]) AC_SUBST([EXTRA_LIBS])