From 6480984e8dd43f2ca4b803efeb19fbe5a331e0ab Mon Sep 17 00:00:00 2001 From: sof Date: Mon, 29 Jun 1998 17:28:42 +0000 Subject: [PATCH] [project @ 1998-06-29 17:28:42 by sof] New interface containing host-specific arch/os info --- ghc/lib/exts/NativeInfo.lhs | 90 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 ghc/lib/exts/NativeInfo.lhs diff --git a/ghc/lib/exts/NativeInfo.lhs b/ghc/lib/exts/NativeInfo.lhs new file mode 100644 index 0000000..b26e805 --- /dev/null +++ b/ghc/lib/exts/NativeInfo.lhs @@ -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} -- 1.7.10.4