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