ref: 5c872027544071937783af15e73075f66a9a8dca
parent: 60f254d458cd418ade6d34e173007e7c4e3f7aad
author: Lennart Augustsson <lennart@augustsson.net>
date: Sun Sep 29 13:49:01 EDT 2024
Add CTime
--- a/lib/Foreign/C/Types.hs
+++ b/lib/Foreign/C/Types.hs
@@ -9,6 +9,7 @@
CLLong(..), CULLong(..),
CIntPtr(..), CUIntPtr(..),
CFloat(..), CDouble(..),
+ CTime(..),
intToCSize, cSizeToInt,
) where
import Prelude()
@@ -16,6 +17,7 @@
import Data.Bool
import Data.Eq
import Data.Int
+import Data.Integral
import Data.Num
import Data.Ord
import Data.Word
@@ -57,6 +59,10 @@
newtype CUIntPtr = CUIntPtr Word
deriving (Eq, Ord)
+-- XXX This is really platform specific
+newtype CTime = CTime Int
+ deriving (Eq, Ord)
+
-- XXX We really need GND
instance Num CInt where
CInt x + CInt y = CInt (x + y)
@@ -68,6 +74,9 @@
CLong x - CLong y = CLong (x - y)
CLong x * CLong y = CLong (x * y)
fromInteger x = CLong (fromInteger x)
+instance Integral CLong where
+ quotRem (CLong x) (CLong y) = (CLong q, CLong r) where (q, r) = quotRem q r
+ toInteger (CLong x) = toInteger x
-- XXX only one of these is actually correct
newtype CFloat = CFloat FloatW