Commit ffc23270 authored by Daniel Gröber (dxld)'s avatar Daniel Gröber (dxld) Committed by Ben Gamari

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
parent 0d213c18
......@@ -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
......@@ -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*
......
......@@ -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)
......
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment