blob: 814deff0933137bc2cf35d942ac2a803b101c006 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CApiFFI #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE UnliftedFFITypes #-}
module Main where
import qualified Data.ByteString.Short.Internal as SBS
import Foreign.C.Types
import GHC.Exts
foreign import capi unsafe "string.h strlen"
c_strlen_capi :: ByteArray# -> IO CSize
foreign import capi unsafe "string.h memset"
c_memset_capi :: MutableByteArray# s -> CInt -> CSize -> IO ()
main :: IO ()
main = do
n <- c_strlen_capi ba#
print (n == 13)
where
!(SBS.SBS ba#) = "Hello FFI!!!!\NUL"
|