#2979: better support for FFI C wrappers for macros in system headers
------------------------------+---------------------------------------------
  Reporter:  duncan           |          Owner:                  
      Type:  feature request  |         Status:  new             
  Priority:  normal           |      Milestone:  7.4.1           
 Component:  Compiler (FFI)   |        Version:  6.10.1          
Resolution:                   |       Keywords:                  
  Testcase:                   |      Blockedby:                  
Difficulty:  Unknown          |             Os:  Unknown/Multiple
  Blocking:                   |   Architecture:  Unknown/Multiple
   Failure:  None/Unknown     |  
------------------------------+---------------------------------------------
Changes (by PHO):

  * status:  closed => new
  * resolution:  fixed =>


Comment:

 Unfortunately, the brand-new {{{capi}}} calling convention doesn't work
 well with macros that take pointers as their arguments.

 From {{{libraries/base/System/Posix/Internals.hs}}}:
 {{{
 foreign import capi unsafe "HsBase.h sigaddset"
    c_sigaddset :: Ptr CSigset -> CInt -> IO CInt
 }}}

 This foreign import generates the following C wrapper:
 {{{
 HsInt32 ghc_wrapper_d2kM_sigaddset(HsPtr a1, HsInt32 a2) {return
 sigaddset(a1, a2);}
 }}}

 And yes, sigaddset(3) is actually defined as a macro (at least on Darwin
 9.8.0):
 {{{
 #define sigaddset(set, signo)   (*(set) |= __sigbits(signo), 0)
 }}}

 Since {{{HsPtr}}} is a type synonym of {{{void*}}} defined by
 {{{includes/HsFFI.h}}}, the C wrapper in question end up dereferencing
 {{{void*}}}:
 {{{
 /var/folders/rN/rNbpGijHEzGPi-Ux2JwMgU+++TI/-Tmp-/ghc27760_0/ghc27760_0.c:
 In fu
 nction ‘ghc_wrapper_d2kM_sigaddset’:

 /var/folders/rN/rNbpGijHEzGPi-
 Ux2JwMgU+++TI/-Tmp-/ghc27760_0/ghc27760_0.c:13:0:
      warning: dereferencing ‘void *’ pointer

 /var/folders/rN/rNbpGijHEzGPi-
 Ux2JwMgU+++TI/-Tmp-/ghc27760_0/ghc27760_0.c:13:0:
      error: invalid use of void expression
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2979#comment:14>
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

Reply via email to