Ian Lynagh | 2 Apr 2007 00:22
Picon
Gravatar

Re: More on FreeBSD/amd64

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)

Thanks
Ian
Gregory Wright | 2 Apr 2007 17:57
Picon

Re: More on FreeBSD/amd64


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
(Continue reading)

Ian Lynagh | 3 Apr 2007 02:34
Picon
Gravatar

Re: More on FreeBSD/amd64


Hi Gregory,

On Mon, Apr 02, 2007 at 11:57:49AM -0400, Gregory Wright wrote:
> 
> On Apr 1, 2007, at 6:22 PM, Ian Lynagh wrote:
> 
> >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)

Hmm, the foreign import types already look wrong, in both 6.4.2 and the
HEAD. For now I recommend changing the definition in include/HsBase.h to
only take and return HsInt, and to do the casting on the C side.

include/HsBase.h:
# -----------------------------
INLINE HsInt
__hscore_PrelHandle_write( HsInt fd, HsAddr ptr, HsInt off, HsInt sz )
{
(Continue reading)

Bulat Ziganshin | 2 Apr 2007 18:13
Picon

Re[2]: More on FreeBSD/amd64

Hello Gregory,

Monday, April 2, 2007, 7:57:49 PM, you wrote:

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

you may try to call C function with a result of (packCString# s)

--

-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin <at> gmail.com

Gmane