[project @ 1999-03-02 19:50:12 by sof]
[ghc-hetmet.git] / ghc / lib / exts / NativeInfo.lhs
1 %
2 % (c) The AQUA Project, Glasgow University, 1998
3 %
4 \section[NativeInfo]{Module @NativeInfo@}
5
6 Misc information about the characteristics of the host 
7 architecture/machine lucky enough to run your program.
8
9 \begin{code}
10 #include "MachDeps.h"
11
12 module NativeInfo
13        (
14          isBigEndian        -- :: Bool
15
16        , os                 -- :: String
17        , arch               -- :: String
18
19        , sizeofAddr         -- :: Word32
20        , sizeofDouble       -- :: ""
21        , sizeofFloat
22        , sizeofChar
23        
24        , sizeofWord
25        , sizeofWord8
26        , sizeofWord16
27        , sizeofWord32
28        , sizeofWord64
29
30        , sizeofInt
31        , sizeofInt8
32        , sizeofInt16
33        , sizeofInt32
34        , sizeofInt64
35        
36        ) where
37
38 import Word
39 import Addr
40 import Int
41
42 \end{code}
43
44 Byte-ordering:
45
46 \begin{code}
47 isBigEndian :: Bool
48 isBigEndian = 
49 #ifdef WORDS_BIGENDIAN
50     True
51 #else
52     False
53 #endif
54 \end{code}
55
56 Host architecture and OS info:
57
58 \begin{code}
59 arch :: String
60 arch = HOST_ARCH
61
62 os :: String
63 os = HOST_OS
64 \end{code}
65
66 @sizeofX@ returns the size of the (basic) type X (in 8-bit byte units.)
67
68 (Do not provide a type class for this, since writing out sizeofX is shorter
69 (and more consise) than using an overloaded function that returns the sizeof
70 at a particular type.)
71
72 \begin{code}
73 sizeofAddr :: Word32
74 sizeofAddr = ADDR_SIZE_IN_BYTES
75
76 sizeofDouble :: Word32
77 sizeofDouble = DOUBLE_SIZE_IN_BYTES
78
79 sizeofFloat :: Word32
80 sizeofFloat  = FLOAT_SIZE_IN_BYTES
81
82 sizeofInt   :: Word32
83 sizeofInt     = INT_SIZE_IN_BYTES
84
85 sizeofWord   :: Word32
86 sizeofWord     = WORD_SIZE_IN_BYTES
87
88 sizeofChar  :: Word32
89 sizeofChar    = CHAR_SIZE_IN_BYTES
90 \end{code}