diff options
author | Moritz Angermann <moritz.angermann@gmail.com> | 2021-02-13 16:51:00 +0800 |
---|---|---|
committer | Moritz Angermann <moritz.angermann@gmail.com> | 2021-02-14 21:04:34 -0500 |
commit | 77d347d147834304a2acc6bebad2d6c8f3ea2c9a (patch) | |
tree | ce0b542399c6d2d297ceb03563de54d78c5e827d | |
parent | a7d22795ed118abfe64f4fc55d96d8561007ce1e (diff) | |
download | haskell-wip/angerman/fix-faststring-sig.tar.gz |
[faststring] fix memcmp and strlen signatureswip/angerman/fix-faststring-sig
int
memcmp(const void *s1, const void *s2, size_t n);
size_t
strlen(const char *s);
-rw-r--r-- | compiler/utils/FastString.hs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/utils/FastString.hs b/compiler/utils/FastString.hs index 3a438ef23e..9efa04c9f2 100644 --- a/compiler/utils/FastString.hs +++ b/compiler/utils/FastString.hs @@ -233,7 +233,7 @@ cmpFS f1@(FastString u1 _ _ _) f2@(FastString u2 _ _ _) = compare (bytesFS f1) (bytesFS f2) foreign import ccall unsafe "memcmp" - memcmp :: Ptr a -> Ptr b -> Int -> IO Int + memcmp :: Ptr a -> Ptr b -> CSize -> IO CInt -- ----------------------------------------------------------------------------- -- Construction @@ -376,7 +376,7 @@ lower-level `sharedCAF` mechanism that relies on Globals.c. -} mkFastString# :: Addr# -> FastString -mkFastString# a# = mkFastStringBytes ptr (ptrStrLength ptr) +mkFastString# a# = mkFastStringBytes ptr (fromIntegral (ptrStrLength ptr)) where ptr = Ptr a# {- Note [Updating the FastString table] @@ -528,7 +528,7 @@ copyBytesToForeignPtr ptr len = do cmpStringPrefix :: Ptr Word8 -> Ptr Word8 -> Int -> IO Bool cmpStringPrefix ptr1 ptr2 len = - do r <- memcmp ptr1 ptr2 len + do r <- memcmp ptr1 ptr2 (fromIntegral len) return (r == 0) hashStr :: Ptr Word8 -> Int -> Int @@ -641,7 +641,7 @@ data PtrString = PtrString !(Ptr Word8) !Int -- | Wrap an unboxed address into a 'PtrString'. mkPtrString# :: Addr# -> PtrString -mkPtrString# a# = PtrString (Ptr a#) (ptrStrLength (Ptr a#)) +mkPtrString# a# = PtrString (Ptr a#) (fromIntegral (ptrStrLength (Ptr a#))) -- | Encode a 'String' into a newly allocated 'PtrString' using Latin-1 -- encoding. The original string must not contain non-Latin-1 characters @@ -677,7 +677,7 @@ lengthPS (PtrString _ n) = n -- under the carpet foreign import ccall unsafe "strlen" - ptrStrLength :: Ptr Word8 -> Int + ptrStrLength :: Ptr Word8 -> CSize {-# NOINLINE sLit #-} sLit :: String -> PtrString |