[project @ 2003-09-12 13:05:19 by simonmar]
[haskell-directory.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   Limit
47  ) where
48
49 import Foreign
50 import Foreign.C
51 import Data.Typeable
52 import Data.Bits
53
54 #ifdef __GLASGOW_HASKELL__
55 import GHC.Base
56 import GHC.Enum
57 import GHC.Num
58 import GHC.Real
59 import GHC.Prim
60 import GHC.Read
61 import GHC.Show
62 #else
63 import Control.Monad
64 #endif
65
66 #include "Typeable.h"
67 #include "CTypes.h"
68
69 NUMERIC_TYPE(CDev,tyConCDev,"CDev",HTYPE_DEV_T)
70 INTEGRAL_TYPE(CIno,tyConCIno,"CIno",HTYPE_INO_T)
71 INTEGRAL_TYPE(CMode,tyConCMode,"CMode",HTYPE_MODE_T)
72 INTEGRAL_TYPE(COff,tyConCOff,"COff",HTYPE_OFF_T)
73 INTEGRAL_TYPE(CPid,tyConCPid,"CPid",HTYPE_PID_T)
74
75 #ifdef mingw32_TARGET_OS
76 INTEGRAL_TYPE(CSsize,tyConCSsize,"CSsize",HTYPE_SIZE_T)
77 #else
78 INTEGRAL_TYPE(CSsize,tyConCSsize,"CSsize",HTYPE_SSIZE_T)
79 #endif
80
81 #ifndef mingw32_TARGET_OS
82 INTEGRAL_TYPE(CGid,tyConCGid,"CGid",HTYPE_GID_T)
83 INTEGRAL_TYPE(CNlink,tyConCNlink,"CNlink",HTYPE_NLINK_T)
84 INTEGRAL_TYPE(CUid,tyConCUid,"CUid",HTYPE_UID_T)
85 NUMERIC_TYPE(CCc,tyConCCc,"CCc",HTYPE_CC_T)
86 NUMERIC_TYPE(CSpeed,tyConCSpeed,"CSpeed",HTYPE_SPEED_T)
87 INTEGRAL_TYPE(CTcflag,tyConCTcflag,"CTcflag",HTYPE_TCFLAG_T)
88 INTEGRAL_TYPE(CRLim,tyConCRlim,"CRLim",HTYPE_RLIM_T)
89 #endif
90
91 -- ToDo: blksize_t, clockid_t, blkcnt_t, fsblkcnt_t, fsfilcnt_t, id_t, key_t
92 -- suseconds_t, timer_t, useconds_t
93
94 -- Make an Fd type rather than using CInt everywhere
95 INTEGRAL_TYPE(Fd,tyConFd,"Fd",CInt)
96
97 -- nicer names, and backwards compatibility with POSIX library:
98 #ifndef mingw32_TARGET_OS
99 type LinkCount      = CNlink
100 type UserID         = CUid
101 type GroupID        = CGid
102 #endif
103
104 type ByteCount      = CSize
105 type ClockTick      = CClock
106 type EpochTime      = CTime
107 type DeviceID       = CDev
108 type FileID         = CIno
109 type FileMode       = CMode
110 type ProcessID      = CPid
111 type FileOffset     = COff
112 type ProcessGroupID = CPid
113 type Limit          = CLong
114