[commit: ghc] master: base: Add more POSIX types (fixes #12795) (ffc2327)

git at git.haskell.org git at git.haskell.org
Fri Dec 16 00:56:21 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/ffc2327070dbb664bdb407a804121eacb2a7c734/ghc

>---------------------------------------------------------------

commit ffc2327070dbb664bdb407a804121eacb2a7c734
Author: Daniel Gröber <dxld at darkboxed.org>
Date:   Thu Dec 15 18:58:59 2016 -0500

    base: Add more POSIX types (fixes #12795)
    
    Test Plan: validate
    
    Reviewers: hvr, austin, RyanGlScott, bgamari
    
    Reviewed By: RyanGlScott, bgamari
    
    Subscribers: RyanGlScott, thomie, erikd
    
    Differential Revision: https://phabricator.haskell.org/D2664
    
    GHC Trac Issues: #12795


>---------------------------------------------------------------

ffc2327070dbb664bdb407a804121eacb2a7c734
 libraries/base/System/Posix/Types.hs | 62 ++++++++++++++++++++++++++++++++++--
 libraries/base/changelog.md          |  3 ++
 libraries/base/configure.ac          |  8 +++++
 libraries/base/include/CTypes.h      | 10 ++++--
 4 files changed, 78 insertions(+), 5 deletions(-)

diff --git a/libraries/base/System/Posix/Types.hs b/libraries/base/System/Posix/Types.hs
index 67c38aa..0e9e2ae 100644
--- a/libraries/base/System/Posix/Types.hs
+++ b/libraries/base/System/Posix/Types.hs
@@ -71,6 +71,30 @@ module System.Posix.Types (
 #if defined(HTYPE_RLIM_T)
   CRLim(..),
 #endif
+#if defined(HTYPE_BLKSIZE_T)
+  CBlkSize(..),
+#endif
+#if defined(HTYPE_BLKCNT_T)
+  CBlkCnt(..),
+#endif
+#if defined(HTYPE_CLOCKID_T)
+  CClockId(..),
+#endif
+#if defined(HTYPE_FSBLKCNT_T)
+  CFsBlkCnt(..),
+#endif
+#if defined(HTYPE_FSFILCNT_T)
+  CFsFilCnt(..),
+#endif
+#if defined(HTYPE_ID_T)
+  CId(..),
+#endif
+#if defined(HTYPE_KEY_T)
+  CKey(..),
+#endif
+#if defined(HTYPE_TIMER_T)
+  CTimer(..),
+#endif
 
   Fd(..),
 
@@ -108,6 +132,9 @@ import GHC.Base
 import GHC.Enum
 import GHC.Num
 import GHC.Real
+#if defined(HTYPE_TIMER_T)
+import GHC.Float
+#endif
 -- import GHC.Prim
 import GHC.Read
 import GHC.Show
@@ -157,8 +184,38 @@ INTEGRAL_TYPE(CTcflag,HTYPE_TCFLAG_T)
 INTEGRAL_TYPE(CRLim,HTYPE_RLIM_T)
 #endif
 
--- ToDo: blksize_t, clockid_t, blkcnt_t, fsblkcnt_t, fsfilcnt_t, id_t, key_t
--- suseconds_t, timer_t, useconds_t
+#if defined(HTYPE_BLKSIZE_T)
+-- | @since 4.10.0.0
+INTEGRAL_TYPE_WITH_CTYPE(CBlkSize,blksize_t,HTYPE_BLKSIZE_T)
+#endif
+#if defined(HTYPE_BLKCNT_T)
+-- | @since 4.10.0.0
+INTEGRAL_TYPE_WITH_CTYPE(CBlkCnt,blkcnt_t,HTYPE_BLKCNT_T)
+#endif
+#if defined(HTYPE_CLOCKID_T)
+-- | @since 4.10.0.0
+INTEGRAL_TYPE_WITH_CTYPE(CClockId,clockid_t,HTYPE_CLOCKID_T)
+#endif
+#if defined(HTYPE_FSBLKCNT_T)
+-- | @since 4.10.0.0
+INTEGRAL_TYPE_WITH_CTYPE(CFsBlkCnt,fsblkcnt_t,HTYPE_FSBLKCNT_T)
+#endif
+#if defined(HTYPE_FSFILCNT_T)
+-- | @since 4.10.0.0
+INTEGRAL_TYPE_WITH_CTYPE(CFsFilCnt,fsfilcnt_t,HTYPE_FSFILCNT_T)
+#endif
+#if defined(HTYPE_ID_T)
+-- | @since 4.10.0.0
+INTEGRAL_TYPE_WITH_CTYPE(CId,id_t,HTYPE_ID_T)
+#endif
+#if defined(HTYPE_KEY_T)
+-- | @since 4.10.0.0
+INTEGRAL_TYPE_WITH_CTYPE(CKey,key_t,HTYPE_KEY_T)
+#endif
+#if defined(HTYPE_TIMER_T)
+-- | @since 4.10.0.0
+FLOATING_TYPE_WITH_CTYPE(CTimer,timer_t,HTYPE_TIMER_T)
+#endif
 
 -- Make an Fd type rather than using CInt everywhere
 INTEGRAL_TYPE(Fd,CInt)
@@ -184,4 +241,3 @@ type ProcessID      = CPid
 type FileOffset     = COff
 type ProcessGroupID = CPid
 type Limit          = CLong
-
diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md
index 5039b64..d2e738b 100644
--- a/libraries/base/changelog.md
+++ b/libraries/base/changelog.md
@@ -30,6 +30,9 @@
 
   * Added `Eq1`, `Ord1`, `Read1` and `Show1` instances for `NonEmpty`.
 
+  * Add wrappers for `blksize_t`, `blkcnt_t`, `clockid_t`, `fsblkcnt_t`,
+    `fsfilcnt_t`, `id_t`, `key_t` and `timer_t` to System.Posix.Types (#12795)
+
   * Raw buffer operations in `GHC.IO.FD` are now strict in the buffer, offset, and length operations (#9696)
 
 ## 4.9.0.0  *May 2016*
diff --git a/libraries/base/configure.ac b/libraries/base/configure.ac
index 8098bc7..e6c8a9b 100644
--- a/libraries/base/configure.ac
+++ b/libraries/base/configure.ac
@@ -148,6 +148,14 @@ FPTOOLS_CHECK_HTYPE(tcflag_t)
 FPTOOLS_CHECK_HTYPE(nlink_t)
 FPTOOLS_CHECK_HTYPE(ssize_t)
 FPTOOLS_CHECK_HTYPE(rlim_t)
+FPTOOLS_CHECK_HTYPE(blksize_t)
+FPTOOLS_CHECK_HTYPE(blkcnt_t)
+FPTOOLS_CHECK_HTYPE(clockid_t)
+FPTOOLS_CHECK_HTYPE(fsblkcnt_t)
+FPTOOLS_CHECK_HTYPE(fsfilcnt_t)
+FPTOOLS_CHECK_HTYPE(id_t)
+FPTOOLS_CHECK_HTYPE(key_t)
+FPTOOLS_CHECK_HTYPE(timer_t)
 
 FPTOOLS_CHECK_HTYPE(intptr_t)
 FPTOOLS_CHECK_HTYPE(uintptr_t)
diff --git a/libraries/base/include/CTypes.h b/libraries/base/include/CTypes.h
index 9cee4f7..9fa1e4a 100644
--- a/libraries/base/include/CTypes.h
+++ b/libraries/base/include/CTypes.h
@@ -29,11 +29,17 @@ newtype T = T B deriving (ARITHMETIC_CLASSES, INTEGRAL_CLASSES) \
                 deriving newtype (Read, Show);
 
 #define INTEGRAL_TYPE_WITH_CTYPE(T,THE_CTYPE,B) \
-newtype {-# CTYPE "THE_CTYPE" #-} T = T B deriving (ARITHMETIC_CLASSES, INTEGRAL_CLASSES) \
-                                          deriving newtype (Read, Show);
+newtype {-# CTYPE "THE_CTYPE" #-} T = T B \
+    deriving (ARITHMETIC_CLASSES, INTEGRAL_CLASSES) \
+    deriving newtype (Read, Show);
 
 #define FLOATING_TYPE(T,B) \
 newtype T = T B deriving (ARITHMETIC_CLASSES, FLOATING_CLASSES) \
                 deriving newtype (Read, Show);
 
+#define FLOATING_TYPE_WITH_CTYPE(T,THE_CTYPE,B) \
+newtype {-# CTYPE "THE_CTYPE" #-} T = T B \
+    deriving (ARITHMETIC_CLASSES, FLOATING_CLASSES) \
+    deriving newtype (Read, Show);
+
 #endif



More information about the ghc-commits mailing list