[project @ 1998-06-29 17:28:42 by sof]
authorsof <unknown>
Mon, 29 Jun 1998 17:28:42 +0000 (17:28 +0000)
committersof <unknown>
Mon, 29 Jun 1998 17:28:42 +0000 (17:28 +0000)
New interface containing host-specific arch/os info

ghc/lib/exts/NativeInfo.lhs [new file with mode: 0644]

diff --git a/ghc/lib/exts/NativeInfo.lhs b/ghc/lib/exts/NativeInfo.lhs
new file mode 100644 (file)
index 0000000..b26e805
--- /dev/null
@@ -0,0 +1,90 @@
+%
+% (c) The AQUA Project, Glasgow University, 1998
+%
+\section[NativeInfo]{Module @NativeInfo@}
+
+Misc information about the characteristics of the host 
+architecture/machine lucky enough to run your program.
+
+\begin{code}
+#include "MachDeps.h"
+
+module NativeInfo
+       (
+        isBigEndian        -- :: Bool
+
+       , os                -- :: String
+       , arch              -- :: String
+
+       , sizeofAddr         -- :: Word32
+       , sizeofDouble      -- :: ""
+       , sizeofFloat
+       , sizeofChar
+       
+       , sizeofWord
+       , sizeofWord8
+       , sizeofWord16
+       , sizeofWord32
+       , sizeofWord64
+
+       , sizeofInt
+       , sizeofInt8
+       , sizeofInt16
+       , sizeofInt32
+       , sizeofInt64
+       
+       ) where
+
+import Word
+import Addr
+import Int
+
+\end{code}
+
+Byte-ordering:
+
+\begin{code}
+isBigEndian :: Bool
+isBigEndian = 
+#ifdef WORDS_BIGENDIAN
+    True
+#else
+    False
+#endif
+\end{code}
+
+Host architecture and OS info:
+
+\begin{code}
+arch :: String
+arch = HOST_ARCH
+
+os :: String
+os = HOST_OS
+\end{code}
+
+@sizeofX@ returns the size of the (basic) type X (in 8-bit byte units.)
+
+(Do not provide a type class for this, since writing out sizeofX is shorter
+(and more consise) than using an overloaded function that returns the sizeof
+at a particular type.)
+
+\begin{code}
+sizeofAddr :: Word32
+sizeofAddr = ADDR_SIZE_IN_BYTES
+
+sizeofDouble :: Word32
+sizeofDouble = DOUBLE_SIZE_IN_BYTES
+
+sizeofFloat :: Word32
+sizeofFloat  = FLOAT_SIZE_IN_BYTES
+
+sizeofInt   :: Word32
+sizeofInt     = INT_SIZE_IN_BYTES
+
+sizeofWord   :: Word32
+sizeofWord     = WORD_SIZE_IN_BYTES
+
+sizeofChar  :: Word32
+sizeofChar    = CHAR_SIZE_IN_BYTES
+\end{code}