7ade7bf0ef4fe992ef5635e17465cd97d66b4737
[haskell-directory.git] / System / Posix / Types.hs
1 {-# OPTIONS_GHC -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 "HsBaseConfig.h"
18
19 module System.Posix.Types (
20
21   -- * POSIX data types
22 #if defined(HTYPE_DEV_T)
23   CDev,
24 #endif
25 #if defined(HTYPE_INO_T)
26   CIno,
27 #endif
28 #if defined(HTYPE_MODE_T)
29   CMode,
30 #endif
31 #if defined(HTYPE_OFF_T)
32   COff,
33 #endif
34 #if defined(HTYPE_PID_T)
35   CPid,
36 #endif
37 #if defined(HTYPE_SSIZE_T)
38   CSsize,
39 #endif
40
41 #if defined(HTYPE_GID_T)
42   CGid,
43 #endif
44 #if defined(HTYPE_NLINK_T)
45   CNlink,
46 #endif
47 #if defined(HTYPE_UID_T)
48   CUid,
49 #endif
50 #if defined(HTYPE_CC_T)
51   CCc,
52 #endif
53 #if defined(HTYPE_SPEED_T)
54   CSpeed,
55 #endif
56 #if defined(HTYPE_TCFLAG_T)
57   CTcflag,
58 #endif
59 #if defined(HTYPE_RLIM_T)
60   CRLim,
61 #endif
62
63   Fd(..),
64
65 #if defined(HTYPE_NLINK_T)
66   LinkCount,
67 #endif
68 #if defined(HTYPE_UID_T)
69   UserID,
70 #endif
71 #if defined(HTYPE_GID_T)
72   GroupID,
73 #endif
74
75   ByteCount,
76   ClockTick,
77   EpochTime,
78   FileOffset,
79   ProcessID,
80   ProcessGroupID,
81   DeviceID,
82   FileID,
83   FileMode,
84   Limit
85  ) where
86
87 import Foreign
88 import Foreign.C
89 import Data.Typeable
90 import Data.Bits
91
92 #ifdef __GLASGOW_HASKELL__
93 import GHC.Base
94 import GHC.Enum
95 import GHC.Num
96 import GHC.Real
97 import GHC.Prim
98 import GHC.Read
99 import GHC.Show
100 #else
101 import Control.Monad
102 #endif
103
104 #include "CTypes.h"
105
106 #if defined(HTYPE_DEV_T)
107 ARITHMETIC_TYPE(CDev,tyConCDev,"CDev",HTYPE_DEV_T)
108 #endif
109 #if defined(HTYPE_INO_T)
110 INTEGRAL_TYPE(CIno,tyConCIno,"CIno",HTYPE_INO_T)
111 #endif
112 #if defined(HTYPE_MODE_T)
113 INTEGRAL_TYPE(CMode,tyConCMode,"CMode",HTYPE_MODE_T)
114 #endif
115 #if defined(HTYPE_OFF_T)
116 INTEGRAL_TYPE(COff,tyConCOff,"COff",HTYPE_OFF_T)
117 #endif
118 #if defined(HTYPE_PID_T)
119 INTEGRAL_TYPE(CPid,tyConCPid,"CPid",HTYPE_PID_T)
120 #endif
121
122 #if defined(HTYPE_SSIZE_T)
123 INTEGRAL_TYPE(CSsize,tyConCSsize,"CSsize",HTYPE_SSIZE_T)
124 #endif
125
126 #if defined(HTYPE_GID_T)
127 INTEGRAL_TYPE(CGid,tyConCGid,"CGid",HTYPE_GID_T)
128 #endif
129 #if defined(HTYPE_NLINK_T)
130 INTEGRAL_TYPE(CNlink,tyConCNlink,"CNlink",HTYPE_NLINK_T)
131 #endif
132
133 #if defined(HTYPE_UID_T)
134 INTEGRAL_TYPE(CUid,tyConCUid,"CUid",HTYPE_UID_T)
135 #endif
136 #if defined(HTYPE_CC_T)
137 ARITHMETIC_TYPE(CCc,tyConCCc,"CCc",HTYPE_CC_T)
138 #endif
139 #if defined(HTYPE_SPEED_T)
140 ARITHMETIC_TYPE(CSpeed,tyConCSpeed,"CSpeed",HTYPE_SPEED_T)
141 #endif
142 #if defined(HTYPE_TCFLAG_T)
143 INTEGRAL_TYPE(CTcflag,tyConCTcflag,"CTcflag",HTYPE_TCFLAG_T)
144 #endif
145 #if defined(HTYPE_RLIM_T)
146 INTEGRAL_TYPE(CRLim,tyConCRlim,"CRLim",HTYPE_RLIM_T)
147 #endif
148
149 -- ToDo: blksize_t, clockid_t, blkcnt_t, fsblkcnt_t, fsfilcnt_t, id_t, key_t
150 -- suseconds_t, timer_t, useconds_t
151
152 -- Make an Fd type rather than using CInt everywhere
153 INTEGRAL_TYPE(Fd,tyConFd,"Fd",CInt)
154
155 -- nicer names, and backwards compatibility with POSIX library:
156 #if defined(HTYPE_NLINK_T)
157 type LinkCount      = CNlink
158 #endif
159 #if defined(HTYPE_UID_T)
160 type UserID         = CUid
161 #endif
162 #if defined(HTYPE_GID_T)
163 type GroupID        = CGid
164 #endif
165
166 type ByteCount      = CSize
167 type ClockTick      = CClock
168 type EpochTime      = CTime
169 type DeviceID       = CDev
170 type FileID         = CIno
171 type FileMode       = CMode
172 type ProcessID      = CPid
173 type FileOffset     = COff
174 type ProcessGroupID = CPid
175 type Limit          = CLong
176