X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Foreign%2FC%2FTypes.hs;h=5d896ea133f5fbdd93fe2c4b14e11983a9e7bd6e;hb=b21d4af465d575d0072ddf97e178e0e9545f77ba;hp=d2f3bc8ffdf7d58a270e8d200073545508362d52;hpb=acd78d6dbda0108ffa899cb585114a21c5ed7499;p=ghc-base.git diff --git a/Foreign/C/Types.hs b/Foreign/C/Types.hs index d2f3bc8..5d896ea 100644 --- a/Foreign/C/Types.hs +++ b/Foreign/C/Types.hs @@ -58,12 +58,11 @@ import NHC.FFI ) #else -import Foreign.C.TypesISO import Foreign.Storable import Data.Bits ( Bits(..) ) import Data.Int ( Int8, Int16, Int32, Int64 ) import Data.Word ( Word8, Word16, Word32, Word64 ) -import Data.Dynamic +import Data.Typeable #ifdef __GLASGOW_HASKELL__ import GHC.Base @@ -128,4 +127,32 @@ FLOATING_TYPE(CDouble,tyConCDouble,"CDouble",HTYPE_DOUBLE) -- HACK: Currently no long double in the FFI, so we simply re-use double FLOATING_TYPE(CLDouble,tyConCLDouble,"CLDouble",HTYPE_DOUBLE) +INTEGRAL_TYPE(CPtrdiff,tyConCPtrdiff,"CPtrdiff",HTYPE_PTRDIFF_T) +INTEGRAL_TYPE(CSize,tyConCSize,"CSize",HTYPE_SIZE_T) +INTEGRAL_TYPE(CWchar,tyConCWchar,"CWchar",HTYPE_WCHAR_T) +INTEGRAL_TYPE(CSigAtomic,tyConCSigAtomic,"CSigAtomic",HTYPE_SIG_ATOMIC_T) + +{-# RULES +"fromIntegral/a->CPtrdiff" fromIntegral = \x -> CPtrdiff (fromIntegral x) +"fromIntegral/a->CSize" fromIntegral = \x -> CSize (fromIntegral x) +"fromIntegral/a->CWchar" fromIntegral = \x -> CWchar (fromIntegral x) +"fromIntegral/a->CSigAtomic" fromIntegral = \x -> CSigAtomic (fromIntegral x) + +"fromIntegral/CPtrdiff->a" fromIntegral = \(CPtrdiff x) -> fromIntegral x +"fromIntegral/CSize->a" fromIntegral = \(CSize x) -> fromIntegral x +"fromIntegral/CWchar->a" fromIntegral = \(CWchar x) -> fromIntegral x +"fromIntegral/CSigAtomic->a" fromIntegral = \(CSigAtomic x) -> fromIntegral x + #-} + +INTEGRAL_TYPE(CClock,tyConCClock,"CClock",HTYPE_CLOCK_T) +INTEGRAL_TYPE(CTime,tyConCTime,"CTime",HTYPE_TIME_T) + +-- FIXME: Implement and provide instances for Eq and Storable +data CFile = CFile +data CFpos = CFpos +data CJmpBuf = CJmpBuf + +-- C99 types which are still missing include: +-- intptr_t, uintptr_t, intmax_t, uintmax_t, wint_t, wctrans_t, wctype_t + #endif