0bd389d9999c372d3c28a0b8b432d11cb2c0534c
[ghc-base.git] / System / Posix / Types.hs
1 {-# OPTIONS -fno-implicit-prelude #-}
2 -----------------------------------------------------------------------------
3 -- |
4 -- Module      :  System.Posix.Types
5 -- Copyright   :  (c) The University of Glasgow 2002
6 -- License     :  BSD-style (see the file libraries/base/LICENSE)
7 -- 
8 -- Maintainer  :  libraries@haskell.org
9 -- Stability   :  provisional
10 -- Portability :  non-portable (requires POSIX)
11 --
12 -- POSIX data types: Haskell equivalents of the types defined by the
13 -- @\<sys\/types.h>@ C header on a POSIX system.
14 --
15 -----------------------------------------------------------------------------
16
17 #include "config.h"
18
19 module System.Posix.Types (
20
21   -- * POSIX data types
22   CDev, CIno, CMode, COff, CPid, CSsize,
23
24 #ifndef mingw32_TARGET_OS
25   CGid, CNlink, CUid, CCc, CSpeed,
26   CTcflag, CRLim,
27 #endif
28
29   Fd(..),
30
31 #ifndef mingw32_TARGET_OS
32   LinkCount,
33   UserID,
34   GroupID,
35 #endif
36
37   ByteCount,
38   ClockTick,
39   EpochTime,
40   FileOffset,
41   ProcessID,
42   ProcessGroupID,
43   DeviceID,
44   FileID,
45   FileMode
46  ) where
47
48 import Foreign
49 import Foreign.C
50 import Data.Dynamic
51 import Data.Bits
52
53 #ifdef __GLASGOW_HASKELL__
54 import GHC.Base
55 import GHC.Enum
56 import GHC.Num
57 import GHC.Real
58 import GHC.Prim
59 import GHC.Read
60 import GHC.Show
61 #else
62 import Control.Monad
63 #endif
64
65 #include "Typeable.h"
66 #include "CTypes.h"
67
68 NUMERIC_TYPE(CDev,tyConCDev,"CDev",HTYPE_DEV_T)
69 INTEGRAL_TYPE(CIno,tyConCIno,"CIno",HTYPE_INO_T)
70 INTEGRAL_TYPE(CMode,tyConCMode,"CMode",HTYPE_MODE_T)
71 INTEGRAL_TYPE(COff,tyConCOff,"COff",HTYPE_OFF_T)
72 INTEGRAL_TYPE(CPid,tyConCPid,"CPid",HTYPE_PID_T)
73
74 #ifdef mingw32_TARGET_OS
75 INTEGRAL_TYPE(CSsize,tyConCSsize,"CSsize",HTYPE_SIZE_T)
76 #else
77 INTEGRAL_TYPE(CSsize,tyConCSsize,"CSsize",HTYPE_SSIZE_T)
78 #endif
79
80 #ifndef mingw32_TARGET_OS
81 INTEGRAL_TYPE(CGid,tyConCGid,"CGid",HTYPE_GID_T)
82 INTEGRAL_TYPE(CNlink,tyConCNlink,"CNlink",HTYPE_NLINK_T)
83 INTEGRAL_TYPE(CUid,tyConCUid,"CUid",HTYPE_UID_T)
84 NUMERIC_TYPE(CCc,tyConCCc,"CCc",HTYPE_CC_T)
85 NUMERIC_TYPE(CSpeed,tyConCSpeed,"CSpeed",HTYPE_SPEED_T)
86 INTEGRAL_TYPE(CTcflag,tyConCTcflag,"CTcflag",HTYPE_TCFLAG_T)
87 INTEGRAL_TYPE(CRLim,tyConCRlim,"CRLim",HTYPE_RLIM_T)
88 #endif
89
90 -- ToDo: blksize_t, clockid_t, blkcnt_t, fsblkcnt_t, fsfilcnt_t, id_t, key_t
91 -- suseconds_t, timer_t, useconds_t
92
93 -- Make an Fd type rather than using CInt everywhere
94 INTEGRAL_TYPE(Fd,tyConFd,"Fd",CInt)
95
96 -- nicer names, and backwards compatibility with POSIX library:
97 #ifndef mingw32_TARGET_OS
98 type LinkCount      = CNlink
99 type UserID         = CUid
100 type GroupID        = CGid
101 #endif
102
103 type ByteCount      = CSize
104 type ClockTick      = CClock
105 type EpochTime      = CTime
106 type DeviceID       = CDev
107 type FileID         = CIno
108 type FileMode       = CMode
109 type ProcessID      = CPid
110 type FileOffset     = COff
111 type ProcessGroupID = CPid