X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=include%2FCTypes.h;h=a008e1571d2c59542bb0bce4cac22cc5ce633239;hb=7cd377be38cf40c6fc95d8d7a9774d94a3260808;hp=64abde9afe409a2950c9f66b2c7eb959bc4deffb;hpb=a012d110ff873aab57c27da5337d3a00d4d6e9b2;p=ghc-base.git diff --git a/include/CTypes.h b/include/CTypes.h index 64abde9..a008e15 100644 --- a/include/CTypes.h +++ b/include/CTypes.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: CTypes.h,v 1.4 2002/08/20 10:03:05 simonmar Exp $ + * $Id: CTypes.h,v 1.6 2002/09/04 16:46:40 ross Exp $ * * Dirty CPP hackery for CTypes/CTypesISO * @@ -21,6 +21,7 @@ INSTANCE_NUM(T) ; \ INSTANCE_READ(T) ; \ INSTANCE_SHOW(T) ; \ INSTANCE_ENUM(T) ; \ +INSTANCE_STORABLE(T) ; \ INSTANCE_TYPEABLE0(T,C,S) ; #define INTEGRAL_TYPE(T,C,S,B) \ @@ -158,13 +159,20 @@ instance RealFloat T where { \ isIEEE (T x) = isIEEE x ; \ (T x) `atan2` (T y) = T (x `atan2` y) } +#define INSTANCE_STORABLE(T) \ +instance Storable T where { \ + sizeOf (T x) = sizeOf x ; \ + alignment (T x) = alignment x ; \ + peekElemOff a i = liftM T (peekElemOff (castPtr a) i) ; \ + pokeElemOff a i (T x) = pokeElemOff (castPtr a) i x } + #else /* __GLASGOW_HASKELL__ */ /* GHC can derive any class for a newtype, so we make use of that * here... */ -#define NUMERIC_CLASSES Eq,Ord,Num,Enum +#define NUMERIC_CLASSES Eq,Ord,Num,Enum,Storable #define INTEGRAL_CLASSES Bounded,Real,Integral,Bits #define FLOATING_CLASSES Real,Fractional,Floating,RealFrac,RealFloat