#2979: better support for FFI C wrappers for macros in system headers
----------------------------------+-----------------------------------------
Reporter: duncan | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: 7.6.1
Component: Compiler (FFI) | Version: 7.3
Resolution: | Keywords:
Testcase: | Blockedby:
Difficulty: Unknown | Os: Unknown/Multiple
Blocking: 5408 | Architecture: Unknown/Multiple
Failure: Building GHC failed |
----------------------------------+-----------------------------------------
Changes (by igloo):
* type: bug => feature request
* milestone: 7.4.1 => 7.6.1
Comment:
I considered something like (in `deSugar/DsForeign.lhs`):
{{{
showStgType :: Type -> SDoc
showStgType t = case showStgPtrType t of
Just sdoc -> sdoc
Nothing -> text "Hs" <> text (showFFIType t)
showStgPtrType :: Type -> Maybe SDoc
showStgPtrType t = case tcSplitTyConApp_maybe (repType t) of
Just (tc, [arg])
| tyConName tc == ptrTyConName ->
case showStgPtrType arg of
Just sdoc ->
Just (sdoc <> char '*')
Nothing -> Nothing
Just (tc, [])
| tyConName tc `elem` [intTyConName, int8TyConName,
int16TyConName, int32TyConName, int64TyConName, wordTyConName,
word8TyConName, word16TyConName, word32TyConName, word64TyConName] ->
Just (text "Hs" <> text (showFFIType t))
_ -> Nothing
}}}
but (a) this doesn't fix this particular instance of the problem by
itself, as `CSigset = ()` (we could fix that by using hsc2hs, if it's
guaranteed to be a numeric type), and (b) it's a little unsatisfactory in
general as it doesn't handle pointers to structs at all.
Perhaps we should have something like
{{{
foreign import capi unsafe "HsBase.h sigaddset"
c_sigaddset :: {-# CType "sigset_t *" #-} Ptr CSigset -> CInt -> IO
CInt
}}}
For now I've reverted the sigset changes, so the build's going through
again.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2979#comment:17>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs