[Haskell-cafe] advanced cabal configuration
Jonas Scholl
anselm.scholl at tu-harburg.de
Tue May 19 13:59:57 UTC 2015
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Couldn't you write something like this?
foreign import ccall unsafe "sendfile64"
c_sendfile64 :: Fd -> Fd -> Ptr COff -> CSize -> IO (#type ssize_t)
foreign import ccall unsafe "sendfile"
c_sendfile32 :: Fd -> Fd -> Ptr COff -> CSize -> IO (#type ssize_t)
c_sendfile :: Fd -> Fd -> Ptr COff -> CSize -> IO (#type ssize_t)
c_sendfile = case sizeOf (undefined :: COff) of
4 -> c_sendfile32
8 -> c_sendfile64
_ -> error "COff has an unsupported size"
Jonas
On 05/19/2015 02:06 PM, Kazu Yamamoto (????) wrote:
> Hi,
>
> I'm a maintainer of simple-sendfile and need to implement the
> following is to rescue 32bit Linux:
>
> - If the COff size is 8, the following FFI is used:
>
> foreign import ccall unsafe "sendfile64" c_sendfile :: Fd -> Fd ->
> Ptr COff -> CSize -> IO (#type ssize_t)
>
> - Otherwise, the following FFI is used:
>
> foreign import ccall unsafe "sendfile" c_sendfile :: Fd -> Fd ->
> Ptr COff -> CSize -> IO (#type ssize_t)
>
> How can I implement this?
>
> I guess that Setup.hs should evaluate (sizeOf (1 :: COff)) and
> define a C macro, say LARGE_OFFSET and write the following code.
>
> #ifdef LARGE_OFFSET foreign import ccall unsafe "sendfile64" #else
> foreign import ccall unsafe "sendfile" #endif
>
> I have no experience to use Build-Type: other than Simple in cabal
> files. Would someone explain how to implement it concretely or
> suggest examples which implement similar things?
>
> For more informaion, please read:
> https://github.com/yesodweb/wai/issues/372
>
> Thanks.
>
> --Kazu _______________________________________________ Haskell-Cafe
> mailing list Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQEcBAEBCAAGBQJVW0HAAAoJEM0PYZBmfhoBSJUH/A/J1sxInz3sv7KN/qt2jKQN
/qVOrm1tLDPBpIz0D3l5CaO/NrPYkzW+GHF6IxHswuO1suJLHIPJHHptJhLIB8mZ
83NRWtnbQh2nPTvVcj8Ey3BhsX/VEdqAr4fMP9y+NUlMrmHxIhyDPc6p2lvIVmiz
OsnzAcIiRCt2HWhxCaum5c3xHyT0Dd3Zafmv5ygv2FUK9pxlUzdbCFRPP2dPwOE9
m6RM5i9/rl4SP3sJXYINCyP4wX28Y0+iqiL+POK4m0Eq9VvXy8pi/GpBiz8FohaH
PEXdeOdCxyHE+OwsojdpNBy6PJZuh7A2EtBl4EsYMB70fNgV2w4xvNfAWNapdso=
=ZQxj
-----END PGP SIGNATURE-----
More information about the Haskell-Cafe
mailing list