-{-# OPTIONS -fno-implicit-prelude #-}
+{-# OPTIONS_GHC -fno-implicit-prelude #-}
-----------------------------------------------------------------------------
-- |
-- Module : Foreign.C.Types
, CLong, CULong
, CPtrdiff, CSize, CWchar, CSigAtomic
, CLLong, CULLong
+ , CIntPtr, CUIntPtr
+ , CIntMax, CUIntMax
-- ** Numeric types
-- | These types are are represented as @newtype@s of basic
import GHC.Read
import GHC.Num
#else
-import Control.Monad
-import Foreign.Ptr
+import Control.Monad ( liftM )
#endif
-#include "Typeable.h"
+#ifdef __HUGS__
+import Hugs.Ptr ( castPtr )
+#endif
+
+#include "HsBaseConfig.h"
#include "CTypes.h"
-- | Haskell type representing the C @char@ type.
-- | Haskell type representing the C @jmp_buf@ type.
data CJmpBuf = CJmpBuf
+INTEGRAL_TYPE(CIntPtr,tyConCIntPtr,"CIntPtr",HTYPE_INTPTR_T)
+INTEGRAL_TYPE(CUIntPtr,tyConCUIntPtr,"CUIntPtr",HTYPE_UINTPTR_T)
+INTEGRAL_TYPE(CIntMax,tyConCIntMax,"CIntMax",HTYPE_INTMAX_T)
+INTEGRAL_TYPE(CUIntMax,tyConCUIntMax,"CUIntMax",HTYPE_UINTMAX_T)
+
+{-# RULES
+"fromIntegral/a->CIntPtr" fromIntegral = \x -> CIntPtr (fromIntegral x)
+"fromIntegral/a->CUIntPtr" fromIntegral = \x -> CUIntPtr (fromIntegral x)
+"fromIntegral/a->CIntMax" fromIntegral = \x -> CIntMax (fromIntegral x)
+"fromIntegral/a->CUIntMax" fromIntegral = \x -> CUIntMax (fromIntegral x)
+ #-}
+
-- C99 types which are still missing include:
--- intptr_t, uintptr_t, intmax_t, uintmax_t, wint_t, wctrans_t, wctype_t
+-- wint_t, wctrans_t, wctype_t
{- $ctypes