Skip to content

Commit

Permalink
Minimal changes for 7.4.1
Browse files Browse the repository at this point in the history
Standalone tests not checked, but 'cabal install -ftest' compiles OK,
even if then the tests fail with my version of the Linux mpi libs.
  • Loading branch information
Mikolaj committed Feb 10, 2012
1 parent 5cbebe0 commit d8a9cc8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
1 change: 0 additions & 1 deletion haskell-mpi.cabal
Expand Up @@ -114,7 +114,6 @@ Library
src
build-depends:
base > 3 && <= 5,
haskell98,
bytestring,
cereal,
extensible-exceptions,
Expand Down
36 changes: 18 additions & 18 deletions src/C2HS.hs
Expand Up @@ -4,19 +4,19 @@
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
--
-- 1. Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
-- this list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- documentation and/or other materials provided with the distribution.
-- 3. The name of the author may not be used to endorse or promote products
-- derived from this software without specific prior written permission.
-- derived from this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
-- NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-- NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
Expand All @@ -28,19 +28,19 @@
--
-- Language: Haskell 98
--
-- This module provides the marshaling routines for Haskell files produced by
-- This module provides the marshaling routines for Haskell files produced by
-- C->Haskell for binding to C library interfaces. It exports all of the
-- low-level FFI (language-independent plus the C-specific parts) together
-- with the C->HS-specific higher-level marshalling routines.
--

module C2HS (

-- * Re-export the language-independent component of the FFI
-- * Re-export the language-independent component of the FFI
module Foreign,

-- * Re-export the C language component of the FFI
module CForeign,
module Foreign.C,

-- * Composite marshalling functions
withCStringLenIntConv, peekCStringLenIntConv, withIntConv, withFloatConv,
Expand All @@ -54,16 +54,16 @@ module C2HS (

-- * Conversion between C and Haskell types
cIntConv, cFloatConv, cToBool, cFromBool, cToEnum, cFromEnum
) where
) where


import Foreign
hiding (Word)
-- Should also hide the Foreign.Marshal.Pool exports in
-- compilers that export them
import CForeign
import Foreign.C

import Monad (liftM)
import Control.Monad (liftM)


-- Composite marshalling functions
Expand All @@ -79,19 +79,19 @@ peekCStringLenIntConv (s, n) = peekCStringLen (s, cIntConv n)
-- Marshalling of numerals
--

withIntConv :: (Storable b, Integral a, Integral b)
withIntConv :: (Storable b, Integral a, Integral b)
=> a -> (Ptr b -> IO c) -> IO c
withIntConv = with . cIntConv

withFloatConv :: (Storable b, RealFloat a, RealFloat b)
withFloatConv :: (Storable b, RealFloat a, RealFloat b)
=> a -> (Ptr b -> IO c) -> IO c
withFloatConv = with . cFloatConv

peekIntConv :: (Storable a, Integral a, Integral b)
peekIntConv :: (Storable a, Integral a, Integral b)
=> Ptr a -> IO b
peekIntConv = liftM cIntConv . peek

peekFloatConv :: (Storable a, RealFloat a, RealFloat b)
peekFloatConv :: (Storable a, RealFloat a, RealFloat b)
=> Ptr a -> IO b
peekFloatConv = liftM cFloatConv . peek

Expand Down Expand Up @@ -179,7 +179,7 @@ bits `containsBitMask` bm = let bm' = fromIntegral . fromEnum $ bm
-- produced.
--
extractBitMasks :: (Bits a, Enum b, Bounded b) => a -> [b]
extractBitMasks bits =
extractBitMasks bits =
[bm | bm <- [minBound..maxBound], bits `containsBitMask` bm]


Expand All @@ -196,7 +196,7 @@ cIntConv = fromIntegral
cFloatConv :: (RealFloat a, RealFloat b) => a -> b
cFloatConv = realToFrac
-- As this conversion by default goes via `Rational', it can be very slow...
{-# RULES
{-# RULES
"cFloatConv/Float->Float" forall (x::Float). cFloatConv x = x;
"cFloatConv/Double->Double" forall (x::Double). cFloatConv x = x
#-}
Expand All @@ -208,7 +208,7 @@ cFromBool = fromBool

-- |Obtain Haskell 'Bool' from C value.
--
cToBool :: Num a => a -> Bool
cToBool :: Eq a => Num a => a -> Bool
cToBool = toBool

-- |Convert a C enumeration to Haskell.
Expand Down
2 changes: 1 addition & 1 deletion test/CompileRunClean.hs
Expand Up @@ -22,7 +22,7 @@

module Main where

import System (getArgs)
import System.Environment (getArgs)
import System.Cmd (system)
import System.Exit (ExitCode (..), exitWith)
import Control.Monad (when)
Expand Down

0 comments on commit d8a9cc8

Please sign in to comment.