FFI for PBC - Windows and Nixes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

FFI for PBC - Windows and Nixes

Sumit Raja
Hi,

I am stuck with an odd problem that I don't know how to begin to
resolve. I have developed an FFI wrapper around the PBC library. I
have a number of tests thatcheck simple operations and some of the
more simple examples from the PBC C examples.

On FreeBSD and Linux (Mint) all tests pass successfully but on Windows
(mingw64) many fail with what look like data corruption errors. I
suspect it is something to do with alignment or size calculations but
I have no idea how to proceed.

The hsc file is fairly standard:

data PBCPairing = PBCPairing
data PBCElement = PBCElement
data PBCField = PBCField
data PBCPreProcElement = PBCPreProcElement

instance Storable PBCPairing where
  sizeOf _ = #{size struct pairing_s}
  alignment _ = #{alignment struct pairing_s}
  peek = notImplemented
  poke = notImplemented

instance Storable PBCElement where
  sizeOf _ = #{size struct element_s}
  alignment _ = #{alignment struct element_s}
  peek = notImplemented
  poke = notImplemented

instance Storable PBCPreProcElement where
  sizeOf _ = #{size struct element_pp_s}
  alignment _ = #{alignment struct element_pp_s}
  peek = notImplemented
  poke = notImplemented

instance Storable PBCField where
  sizeOf _ = #{size struct field_s}
  alignment _ = #{alignment struct field_s}
  peek = notImplemented
  poke = notImplemented

Generated sizeOf is the same and alignment is 8 across all OSes. I am
using inline-c for the FFI. PBC was built using msys2's version of
mingw64. All the C examples work correctly in the msys2 shell.

Does any one have any ideas on how best to approach this issue?

Thanks

Sumit
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners