[mailing list trimmed]
Thanks Simon, Explanation of why GreenCard generates that code attached. Briefly, GreenCard has always marshalled Word8 as a Word32 (and so has Hugs). I'm wondering if a recent change in GHC or in how Win32 is compiled might have changed the way that Word32 is being marshalled. Possibilities: Maybe GHC has started marshalling word32 differently? Maybe a change from ccall to ffi happened and they do different things? Maybe the October 2001 removal of --target ffi Am I right in thinking that ccall was recently removed from GHC so now everything goes through the ffi? Not sure yet what the problem is but it seems a plausible place to look. Hope this triggers some ideas Alastair Simon Marlow says: > the definition of prim_rgb is > DWORD prim_rgb(BYTE arg1,BYTE arg2,BYTE arg3) > but its FFI declaration says > foreign import ccall "prim_rgb" unsafe prim_rgb :: Word32 -> > Word32 -> Word32 -> IO (Word32) > this looks a bit strange - is there a green-card expert out there to > explain what's going on? Why have the BYTEs been turned into > Word32s? GHC's StdDIS.gc looks like this (fptools/green-card/lib/ghc/StdDIS.gc): %dis word8 x = < fromIntegral / fromIntegral > (word32 x) which means: to marshall (convert from Haskell to C) a word8, apply fromIntegral and then marshall as a word32. That seems to be what is going on here. Looking back in the log, this has been the marshalling rule for word8 for as long as there has been one (since January 1998) and it is the current rule for Hugs. Why do we marshall 8 bit ints as 32 bit ints? I think we're promoting 8 bit ints up to 32 bit ints because that's what (we believe) the C compiler does on this platform. Why do this ourselves instead of letting the C compiler do it itself? It probably dates back to the days when GHC's ccall didn't have a marshalling rule for 8 bit ints - no problem, we thought, we know it will just turn into a 32bit int so let's do that manually. But, as recently discussed on the ffi list, C compilers are free _not_ to promote if they have a prototype so _maybe_ some of the C code is being compiled with a prototype and some of it is being compiled without? _______________________________________________ Glasgow-haskell-bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
