module CInfo (
CPrimType(..), size, alignment,
bitfieldDirection, bitfieldPadding, bitfieldIntSigned, bitfieldAlignment
) where
import Foreign.C
import C2HSConfig (Ptr, FunPtr,
bitfieldDirection, bitfieldPadding, bitfieldIntSigned,
bitfieldAlignment)
import qualified
C2HSConfig as Storable
(Storable(sizeOf, alignment))
data CPrimType = CPtrPT
| CFunPtrPT
| CCharPT
| CUCharPT
| CSCharPT
| CIntPT
| CShortPT
| CLongPT
| CLLongPT
| CUIntPT
| CUShortPT
| CULongPT
| CULLongPT
| CFloatPT
| CDoublePT
| CLDoublePT
| CSFieldPT Int
| CUFieldPT Int
deriving (CPrimType -> CPrimType -> Bool
(CPrimType -> CPrimType -> Bool)
-> (CPrimType -> CPrimType -> Bool) -> Eq CPrimType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CPrimType -> CPrimType -> Bool
$c/= :: CPrimType -> CPrimType -> Bool
== :: CPrimType -> CPrimType -> Bool
$c== :: CPrimType -> CPrimType -> Bool
Eq)
size :: CPrimType -> Int
size :: CPrimType -> Int
size CPrimType
CPtrPT = Ptr () -> Int
forall a. Storable a => a -> Int
Storable.sizeOf (Ptr ()
forall a. HasCallStack => a
undefined :: Ptr ())
size CPrimType
CFunPtrPT = FunPtr () -> Int
forall a. Storable a => a -> Int
Storable.sizeOf (FunPtr ()
forall a. HasCallStack => a
undefined :: FunPtr ())
size CPrimType
CCharPT = Int
1
size CPrimType
CUCharPT = Int
1
size CPrimType
CSCharPT = Int
1
size CPrimType
CIntPT = CInt -> Int
forall a. Storable a => a -> Int
Storable.sizeOf (CInt
forall a. HasCallStack => a
undefined :: CInt)
size CPrimType
CShortPT = CShort -> Int
forall a. Storable a => a -> Int
Storable.sizeOf (CShort
forall a. HasCallStack => a
undefined :: CShort)
size CPrimType
CLongPT = CLong -> Int
forall a. Storable a => a -> Int
Storable.sizeOf (CLong
forall a. HasCallStack => a
undefined :: CLong)
size CPrimType
CLLongPT = CLLong -> Int
forall a. Storable a => a -> Int
Storable.sizeOf (CLLong
forall a. HasCallStack => a
undefined :: CLLong)
size CPrimType
CUIntPT = CUInt -> Int
forall a. Storable a => a -> Int
Storable.sizeOf (CUInt
forall a. HasCallStack => a
undefined :: CUInt)
size CPrimType
CUShortPT = CUShort -> Int
forall a. Storable a => a -> Int
Storable.sizeOf (CUShort
forall a. HasCallStack => a
undefined :: CUShort)
size CPrimType
CULongPT = CULong -> Int
forall a. Storable a => a -> Int
Storable.sizeOf (CULong
forall a. HasCallStack => a
undefined :: CULong)
size CPrimType
CULLongPT = CLLong -> Int
forall a. Storable a => a -> Int
Storable.sizeOf (CLLong
forall a. HasCallStack => a
undefined :: CLLong)
size CPrimType
CFloatPT = CFloat -> Int
forall a. Storable a => a -> Int
Storable.sizeOf (CFloat
forall a. HasCallStack => a
undefined :: CFloat)
size CPrimType
CDoublePT = CDouble -> Int
forall a. Storable a => a -> Int
Storable.sizeOf (CDouble
forall a. HasCallStack => a
undefined :: CDouble)
size (CSFieldPT Int
bs) = -Int
bs
size (CUFieldPT Int
bs) = -Int
bs
alignment :: CPrimType -> Int
alignment :: CPrimType -> Int
alignment CPrimType
CPtrPT = Ptr () -> Int
forall a. Storable a => a -> Int
Storable.alignment (Ptr ()
forall a. HasCallStack => a
undefined :: Ptr ())
alignment CPrimType
CFunPtrPT = FunPtr () -> Int
forall a. Storable a => a -> Int
Storable.alignment (FunPtr ()
forall a. HasCallStack => a
undefined :: FunPtr ())
alignment CPrimType
CCharPT = Int
1
alignment CPrimType
CUCharPT = Int
1
alignment CPrimType
CSCharPT = Int
1
alignment CPrimType
CIntPT = CInt -> Int
forall a. Storable a => a -> Int
Storable.alignment (CInt
forall a. HasCallStack => a
undefined :: CInt)
alignment CPrimType
CShortPT = CShort -> Int
forall a. Storable a => a -> Int
Storable.alignment (CShort
forall a. HasCallStack => a
undefined :: CShort)
alignment CPrimType
CLongPT = CLong -> Int
forall a. Storable a => a -> Int
Storable.alignment (CLong
forall a. HasCallStack => a
undefined :: CLong)
alignment CPrimType
CLLongPT = CLLong -> Int
forall a. Storable a => a -> Int
Storable.alignment (CLLong
forall a. HasCallStack => a
undefined :: CLLong)
alignment CPrimType
CUIntPT = CUInt -> Int
forall a. Storable a => a -> Int
Storable.alignment (CUInt
forall a. HasCallStack => a
undefined :: CUInt)
alignment CPrimType
CUShortPT = CUShort -> Int
forall a. Storable a => a -> Int
Storable.alignment (CUShort
forall a. HasCallStack => a
undefined :: CUShort)
alignment CPrimType
CULongPT = CULong -> Int
forall a. Storable a => a -> Int
Storable.alignment (CULong
forall a. HasCallStack => a
undefined :: CULong)
alignment CPrimType
CULLongPT = CULLong -> Int
forall a. Storable a => a -> Int
Storable.alignment (CULLong
forall a. HasCallStack => a
undefined :: CULLong)
alignment CPrimType
CFloatPT = CFloat -> Int
forall a. Storable a => a -> Int
Storable.alignment (CFloat
forall a. HasCallStack => a
undefined :: CFloat)
alignment CPrimType
CDoublePT = CDouble -> Int
forall a. Storable a => a -> Int
Storable.alignment (CDouble
forall a. HasCallStack => a
undefined :: CDouble)
alignment (CSFieldPT Int
bs) = Int -> Int
fieldAlignment Int
bs
alignment (CUFieldPT Int
bs) = Int -> Int
fieldAlignment Int
bs
fieldAlignment :: Int -> Int
fieldAlignment :: Int -> Int
fieldAlignment Int
0 = - (CPrimType -> Int
size CPrimType
CIntPT Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1)
fieldAlignment Int
bs | Bool
bitfieldPadding = - Int
bs
| Bool
otherwise = Int
0