[commit: base] master: Add Haskell types for C types useconds_t and suseconds_t, which are respectively CUSeconds and CSUSeconds. (5768bb4)
Ian Lynagh
igloo at earth.li
Sun Jun 12 17:21:27 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/5768bb4998b3a45a3bf8149063a3f036a10b204f
>---------------------------------------------------------------
commit 5768bb4998b3a45a3bf8149063a3f036a10b204f
Author: William Knop <william.knop.nospam at gmail.com>
Date: Mon Apr 4 20:24:36 2011 -0400
Add Haskell types for C types useconds_t and suseconds_t, which are respectively CUSeconds and CSUSeconds.
The tv_usec field of struct timeval was incorrectly used as C type time_t; the actual C type is suseconds_t. On OS X, time_t is longer than suseconds_t, which caused garbage bits to be copied as reported in trac #4247 and #4970. This patch is part 1 of 4 to fix those tickets.
>---------------------------------------------------------------
Foreign/C/Types.hs | 10 +++++++---
configure.ac | 2 ++
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/Foreign/C/Types.hs b/Foreign/C/Types.hs
index 98113c8..f6bdec1 100644
--- a/Foreign/C/Types.hs
+++ b/Foreign/C/Types.hs
@@ -49,7 +49,7 @@ module Foreign.C.Types
-- foreign types, and are instances of
-- 'Prelude.Eq', 'Prelude.Ord', 'Prelude.Num', 'Prelude.Read',
-- 'Prelude.Show', 'Prelude.Enum', 'Typeable' and 'Storable'.
- , CClock, CTime
+ , CClock, CTime, CUSeconds, CSUSeconds
-- extracted from CTime, because we don't want this comment in
-- the Haskell 2010 report:
@@ -78,7 +78,7 @@ module Foreign.C.Types
, CLong(..), CULong(..)
, CPtrdiff(..), CSize(..), CWchar(..), CSigAtomic(..)
, CLLong(..), CULLong(..)
- , CClock(..), CTime(..)
+ , CClock(..), CTime(..), CUSeconds(..), CSUSeconds(..)
, CFloat(..), CDouble(..), CLDouble(..)
, CIntPtr(..), CUIntPtr(..), CIntMax(..), CUIntMax(..)
#endif
@@ -217,6 +217,10 @@ ARITHMETIC_TYPE(CClock,tyConCClock,"CClock",HTYPE_CLOCK_T)
-- | Haskell type representing the C @time_t@ type.
--
ARITHMETIC_TYPE(CTime,tyConCTime,"CTime",HTYPE_TIME_T)
+-- | Haskell type representing the C @useconds_t@ type.
+ARITHMETIC_TYPE(CUSeconds,tyConCUSeconds,"CUSeconds",HTYPE_USECONDS_T)
+-- | Haskell type representing the C @suseconds_t@ type.
+ARITHMETIC_TYPE(CSUSeconds,tyConCSUSeconds,"CSUSeconds",HTYPE_SUSECONDS_T)
-- FIXME: Implement and provide instances for Eq and Storable
-- | Haskell type representing the C @FILE@ type.
@@ -291,7 +295,7 @@ import NHC.FFI
, CShort(..), CUShort(..), CInt(..), CUInt(..)
, CLong(..), CULong(..), CLLong(..), CULLong(..)
, CPtrdiff(..), CSize(..), CWchar(..), CSigAtomic(..)
- , CClock(..), CTime(..)
+ , CClock(..), CTime(..), CUSeconds(..), CSUSeconds(..)
, CFloat(..), CDouble(..), CLDouble(..)
, CIntPtr(..), CUIntPtr(..),CIntMax(..), CUIntMax(..)
, CFile, CFpos, CJmpBuf
diff --git a/configure.ac b/configure.ac
index dd6c5c6..65c5a49 100644
--- a/configure.ac
+++ b/configure.ac
@@ -90,6 +90,8 @@ FPTOOLS_CHECK_HTYPE(wchar_t)
FPTOOLS_CHECK_HTYPE(sig_atomic_t, Int32)
FPTOOLS_CHECK_HTYPE(clock_t)
FPTOOLS_CHECK_HTYPE(time_t)
+FPTOOLS_CHECK_HTYPE(useconds_t)
+FPTOOLS_CHECK_HTYPE(suseconds_t)
FPTOOLS_CHECK_HTYPE(dev_t, Word32)
FPTOOLS_CHECK_HTYPE(ino_t)
FPTOOLS_CHECK_HTYPE(mode_t)
More information about the Cvs-libraries
mailing list