Hi Ian,

On Apr 1, 2007, at 6:22 PM, Ian Lynagh wrote:

On Sun, Apr 01, 2007 at 06:10:25PM -0400, Gregory Wright wrote:

Ah, remove the #if/#endif around the definition of "puts", its export,
and the GHC.Pack import in libraries/base/GHC/Handle.hs

No such luck.  I even copied "puts" into libraries/base/GHC/
ForeignPtr.hs
but I still get I cycle because I need withCString to define "puts":

Oh, the 6.4.2 definition is different to the 6.6 definition.

Does the 6.6 one work with 6.4.2?:

puts :: String -> IO ()
puts s = do write_rawBuffer 1 (unsafeCoerce# (packCString# s))
                            0 (fromIntegral (length s))
            return ()

(packCString# come from GHC.Pack)



Still doesn't work.  If I include the definition of write_rawBuffer just
above puts (I can't import GHC.Handle because of the dependency loop)
and dangerously change CInt to Int in the signature (can't import
Foreign.C.Types for the same reason) I still get an error message
saying that "fromInteger" is out of scope.

This is what I have added to libraries/base/GHC/ForeignPtr.hs:

import GHC.List         ( null )
import GHC.Base
import GHC.IOBase
import GHC.List         ( length )
import GHC.Pack                         -- this is new
import GHC.Ptr          ( Ptr(..) )
import GHC.Err
import GHC.Show

foreign import ccall unsafe "__hscore_PrelHandle_write"
   write_rawBuffer :: Int -> RawBuffer -> Int -> Int -> IO Int

puts :: String -> IO ()
puts s = do
        write_rawBuffer 1 (unsafeCoerce# (packCString# s))
                0 (length s)
        return ()


I'm wondering if I should just give up on trying to print anything
out from this deep in the libraries and go back to looking at the
debugger trace.  My guess is still that a FreeBSD libc function
is getting called and somehow storing a 32 bit value in a 64 bit
location, with junk in the high order word.

As always, hints and firm whacks on the side of the head will be
appreciated.

Best Wishes,
Greg



_______________________________________________
Glasgow-haskell-users mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to