From: simonmar Date: Thu, 14 Mar 2002 17:09:46 +0000 (+0000) Subject: [project @ 2002-03-14 17:09:46 by simonmar] X-Git-Tag: Approx_11550_changesets_converted~2260 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=6f288c6f963dde473a31cb4404c99c6903729682;hp=ab73ca6160d9083e3c10f674d08ed5a63eac7bdf;p=ghc-hetmet.git [project @ 2002-03-14 17:09:46 by simonmar] The foreign declaration for snprintf was wrong, because we need to give the type of the C function after applying C's type promotion rules. Hence the Float argument should be a Double, because it occurs in the vararg section of the function type. --- diff --git a/glafp-utils/nofib-analyse/Printf.lhs b/glafp-utils/nofib-analyse/Printf.lhs index 1a8aa4d..33b5290 100644 --- a/glafp-utils/nofib-analyse/Printf.lhs +++ b/glafp-utils/nofib-analyse/Printf.lhs @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- --- $Id: Printf.lhs,v 1.4 2001/08/13 10:27:27 simonmar Exp $ +-- $Id: Printf.lhs,v 1.5 2002/03/14 17:09:46 simonmar Exp $ -- (c) Simon Marlow 1997-2001 ----------------------------------------------------------------------------- @@ -32,7 +32,8 @@ #if __GLASGOW_HASKELL__ < 500 > buf <- malloc bUFSIZE -> snprintf buf (fromIntegral bUFSIZE) (packString format) num +> snprintf buf (fromIntegral bUFSIZE) (packString format) +> (realToFrac num) > let s = unpackCString buf > length s `seq` -- urk! need to force the string before we > -- free the buffer. A better solution would @@ -45,7 +46,8 @@ > allocaBytes bUFSIZE $ \buf -> > withCString format $ \cformat -> do -> snprintf buf (fromIntegral bUFSIZE) cformat num +> snprintf buf (fromIntegral bUFSIZE) cformat +> (realToFrac num) > peekCString buf #endif @@ -73,10 +75,10 @@ #if __GLASGOW_HASKELL__ < 500 > type PackedString = ByteArray Int -> foreign import unsafe snprintf :: Addr -> CSize -> PackedString -> Float -> IO () +> foreign import unsafe snprintf :: Addr -> CSize -> PackedString -> Double -> IO () #else -> foreign import unsafe snprintf :: CString -> CSize -> CString -> Float -> IO () +> foreign import unsafe snprintf :: CString -> CSize -> CString -> Double -> IO () #endif