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
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 = forall a. Storable a => a -> Int
Storable.sizeOf (forall a. HasCallStack => a
undefined :: Ptr ())
size CPrimType
CFunPtrPT = forall a. Storable a => a -> Int
Storable.sizeOf (forall a. HasCallStack => a
undefined :: FunPtr ())
size CPrimType
CCharPT = Int
1
size CPrimType
CUCharPT = Int
1
size CPrimType
CSCharPT = Int
1
size CPrimType
CIntPT = forall a. Storable a => a -> Int
Storable.sizeOf (forall a. HasCallStack => a
undefined :: CInt)
size CPrimType
CShortPT = forall a. Storable a => a -> Int
Storable.sizeOf (forall a. HasCallStack => a
undefined :: CShort)
size CPrimType
CLongPT = forall a. Storable a => a -> Int
Storable.sizeOf (forall a. HasCallStack => a
undefined :: CLong)
size CPrimType
CLLongPT = forall a. Storable a => a -> Int
Storable.sizeOf (forall a. HasCallStack => a
undefined :: CLLong)
size CPrimType
CUIntPT = forall a. Storable a => a -> Int
Storable.sizeOf (forall a. HasCallStack => a
undefined :: CUInt)
size CPrimType
CUShortPT = forall a. Storable a => a -> Int
Storable.sizeOf (forall a. HasCallStack => a
undefined :: CUShort)
size CPrimType
CULongPT = forall a. Storable a => a -> Int
Storable.sizeOf (forall a. HasCallStack => a
undefined :: CULong)
size CPrimType
CULLongPT = forall a. Storable a => a -> Int
Storable.sizeOf (forall a. HasCallStack => a
undefined :: CLLong)
size CPrimType
CFloatPT = forall a. Storable a => a -> Int
Storable.sizeOf (forall a. HasCallStack => a
undefined :: CFloat)
size CPrimType
CDoublePT = forall a. Storable a => a -> Int
Storable.sizeOf (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 = forall a. Storable a => a -> Int
Storable.alignment (forall a. HasCallStack => a
undefined :: Ptr ())
alignment CPrimType
CFunPtrPT = forall a. Storable a => a -> Int
Storable.alignment (forall a. HasCallStack => a
undefined :: FunPtr ())
alignment CPrimType
CCharPT = Int
1
alignment CPrimType
CUCharPT = Int
1
alignment CPrimType
CSCharPT = Int
1
alignment CPrimType
CIntPT = forall a. Storable a => a -> Int
Storable.alignment (forall a. HasCallStack => a
undefined :: CInt)
alignment CPrimType
CShortPT = forall a. Storable a => a -> Int
Storable.alignment (forall a. HasCallStack => a
undefined :: CShort)
alignment CPrimType
CLongPT = forall a. Storable a => a -> Int
Storable.alignment (forall a. HasCallStack => a
undefined :: CLong)
alignment CPrimType
CLLongPT = forall a. Storable a => a -> Int
Storable.alignment (forall a. HasCallStack => a
undefined :: CLLong)
alignment CPrimType
CUIntPT = forall a. Storable a => a -> Int
Storable.alignment (forall a. HasCallStack => a
undefined :: CUInt)
alignment CPrimType
CUShortPT = forall a. Storable a => a -> Int
Storable.alignment (forall a. HasCallStack => a
undefined :: CUShort)
alignment CPrimType
CULongPT = forall a. Storable a => a -> Int
Storable.alignment (forall a. HasCallStack => a
undefined :: CULong)
alignment CPrimType
CULLongPT = forall a. Storable a => a -> Int
Storable.alignment (forall a. HasCallStack => a
undefined :: CULLong)
alignment CPrimType
CFloatPT = forall a. Storable a => a -> Int
Storable.alignment (forall a. HasCallStack => a
undefined :: CFloat)
alignment CPrimType
CDoublePT = forall a. Storable a => a -> Int
Storable.alignment (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 forall a. Num a => a -> a -> a
- Int
1)
fieldAlignment Int
bs | Bool
bitfieldPadding = - Int
bs
| Bool
otherwise = Int
0