Hello community, here is the log from the commit of package ghc-mwc-random for openSUSE:Factory checked in at 2016-02-23 16:57:43 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-mwc-random (Old) and /work/SRC/openSUSE:Factory/.ghc-mwc-random.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-mwc-random" Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-mwc-random/ghc-mwc-random.changes 2015-09-17 09:20:16.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-mwc-random.new/ghc-mwc-random.changes 2016-02-23 16:59:34.000000000 +0100 @@ -1,0 +2,5 @@ +Mon Feb 22 07:27:38 UTC 2016 - mimi...@gmail.com + +- update to 0.13.4.0 + +------------------------------------------------------------------- Old: ---- mwc-random-0.13.3.2.tar.gz New: ---- mwc-random-0.13.4.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-mwc-random.spec ++++++ --- /var/tmp/diff_new_pack.Y50DIv/_old 2016-02-23 16:59:35.000000000 +0100 +++ /var/tmp/diff_new_pack.Y50DIv/_new 2016-02-23 16:59:35.000000000 +0100 @@ -20,7 +20,7 @@ %bcond_with tests Name: ghc-mwc-random -Version: 0.13.3.2 +Version: 0.13.4.0 Release: 0 Summary: Fast, high quality pseudo random number generation Group: System/Libraries ++++++ mwc-random-0.13.3.2.tar.gz -> mwc-random-0.13.4.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mwc-random-0.13.3.2/ChangeLog new/mwc-random-0.13.4.0/ChangeLog --- old/mwc-random-0.13.3.2/ChangeLog 2015-03-29 23:25:02.000000000 +0200 +++ new/mwc-random-0.13.4.0/ChangeLog 2016-02-20 12:34:03.000000000 +0100 @@ -1,3 +1,8 @@ +Changes in 0.13.4.0 + + * withSystemRandom uses RtlGenRandom for seeding generator on windows + + Changes in 0.13.3.1 * primitive-0.6 compatibility diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mwc-random-0.13.3.2/System/Random/MWC/Distributions.hs new/mwc-random-0.13.4.0/System/Random/MWC/Distributions.hs --- old/mwc-random-0.13.3.2/System/Random/MWC/Distributions.hs 2015-03-29 23:25:02.000000000 +0200 +++ new/mwc-random-0.13.4.0/System/Random/MWC/Distributions.hs 2016-02-20 12:34:03.000000000 +0100 @@ -1,4 +1,4 @@ -{-# LANGUAGE BangPatterns, GADTs, FlexibleContexts, ScopedTypeVariables #-} +{-# LANGUAGE BangPatterns, CPP, GADTs, FlexibleContexts, ScopedTypeVariables #-} -- | -- Module : System.Random.MWC.Distributions -- Copyright : (c) 2012 Bryan O'Sullivan @@ -41,7 +41,10 @@ import Control.Monad.Primitive (PrimMonad, PrimState) import Data.Bits ((.&.)) import Data.Foldable (foldl') -import Data.Traversable (Traversable,mapM) +#if !MIN_VERSION_base(4,8,0) +import Data.Traversable (Traversable) +#endif +import Data.Traversable (mapM) import Data.Word (Word32) import System.Random.MWC (Gen, uniform, uniformR) import qualified Data.Vector.Unboxed as I diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mwc-random-0.13.3.2/System/Random/MWC.hs new/mwc-random-0.13.4.0/System/Random/MWC.hs --- old/mwc-random-0.13.3.2/System/Random/MWC.hs 2015-03-29 23:25:02.000000000 +0200 +++ new/mwc-random-0.13.4.0/System/Random/MWC.hs 2016-02-20 12:34:03.000000000 +0100 @@ -1,5 +1,6 @@ {-# LANGUAGE BangPatterns, CPP, DeriveDataTypeable, FlexibleContexts, - MagicHash, Rank2Types, ScopedTypeVariables, TypeFamilies, UnboxedTuples #-} + MagicHash, Rank2Types, ScopedTypeVariables, TypeFamilies, UnboxedTuples, + ForeignFunctionInterface #-} -- | -- Module : System.Random.MWC -- Copyright : (c) 2009-2012 Bryan O'Sullivan @@ -103,14 +104,17 @@ import Control.Monad.Primitive (PrimBase) #endif import Control.Monad.ST (ST) -import Data.Bits (Bits, (.&.), (.|.), shiftL, shiftR, xor) +import Data.Bits ((.&.), (.|.), shiftL, shiftR, xor) import Data.Int (Int8, Int16, Int32, Int64) import Data.IORef (atomicModifyIORef, newIORef) import Data.Ratio ((%), numerator) import Data.Time.Clock.POSIX (getPOSIXTime) import Data.Typeable (Typeable) import Data.Vector.Generic (Vector) -import Data.Word (Word, Word8, Word16, Word32, Word64) +import Data.Word (Word8, Word16, Word32, Word64) +#if !MIN_VERSION_base(4,8,0) +import Data.Word (Word) +#endif import Foreign.Marshal.Alloc (allocaBytes) import Foreign.Marshal.Array (peekArray) import qualified Data.Vector.Generic as G @@ -120,7 +124,10 @@ import System.IO (IOMode(..), hGetBuf, hPutStrLn, stderr, withBinaryFile) import System.IO.Unsafe (unsafePerformIO) import qualified Control.Exception as E - +#if defined(mingw32_HOST_OS) +import Foreign.Ptr +import Foreign.C.Types +#endif -- | The class of types for which we can generate uniformly @@ -409,28 +416,68 @@ let n = fromIntegral (numerator t) :: Word64 return [fromIntegral c, fromIntegral n, fromIntegral (n `shiftR` 32)] --- | Acquire seed from /dev/urandom +-- | Acquire seed from the system entropy source. On Unix machines, +-- this will attempt to use @/dev/urandom@. On Windows, it will internally +-- use @RtlGenRandom@. acquireSeedSystem :: IO [Word32] acquireSeedSystem = do +#if !defined(mingw32_HOST_OS) + -- Read 256 random Word32s from /dev/urandom let nbytes = 1024 random = "/dev/urandom" allocaBytes nbytes $ \buf -> do nread <- withBinaryFile random ReadMode $ \h -> hGetBuf h buf nbytes peekArray (nread `div` 4) buf +#else + let nbytes = 1024 + -- Generate 256 random Word32s from RtlGenRandom + allocaBytes nbytes $ \buf -> do + ok <- c_RtlGenRandom buf (fromIntegral nbytes) + if ok then return () else fail "Couldn't use RtlGenRandom" + peekArray (nbytes `div` 4) buf + +-- Note: on 64-bit Windows, the 'stdcall' calling convention +-- isn't supported, so we use 'ccall' instead. +#if defined(i386_HOST_ARCH) +# define WINDOWS_CCONV stdcall +#elif defined(x86_64_HOST_ARCH) +# define WINDOWS_CCONV ccall +#else +# error Unknown mingw32 architecture! +#endif + +-- Note: On Windows, the typical convention would be to use +-- the CryptoGenRandom API in order to generate random data. +-- However, here we use 'SystemFunction036', AKA RtlGenRandom. +-- +-- This is a commonly used API for this purpose; one bonus is +-- that it avoids having to bring in the CryptoAPI library, +-- and completely sidesteps the initialization cost of CryptoAPI. +-- +-- While this function is technically "subject to change" that is +-- extremely unlikely in practice: rand_s in the Microsoft CRT uses +-- this, and they can't change it easily without also breaking +-- backwards compatibility with e.g. statically linked applications. +-- +-- The name 'SystemFunction036' is the actual link-time name; the +-- display name is just for giggles, I guess. +-- +-- See also: +-- - http://blogs.msdn.com/b/michael_howard/archive/2005/01/14/353379.aspx +-- - https://bugzilla.mozilla.org/show_bug.cgi?id=504270 +-- +foreign import WINDOWS_CCONV unsafe "SystemFunction036" + c_RtlGenRandom :: Ptr a -> CULong -> IO Bool +#endif -- | Seed a PRNG with data from the system's fast source of --- pseudo-random numbers (\"@\/dev\/urandom@\" on Unix-like systems), --- then run the given action. +-- pseudo-random numbers (\"@\/dev\/urandom@\" on Unix-like systems or +-- @RtlGenRandom@ on Windows), then run the given action. -- -- This is a somewhat expensive function, and is intended to be called -- only occasionally (e.g. once per thread). You should use the `Gen` -- it creates to generate many random numbers. --- --- /Note/: on Windows, this code does not yet use the native --- Cryptographic API as a source of random numbers (it uses the system --- clock instead). As a result, the sequences it generates may not be --- highly independent. withSystemRandom :: #if MIN_VERSION_primitive(0,6,0) PrimBase m @@ -442,7 +489,11 @@ seed <- acquireSeedSystem `E.catch` \(_::E.IOException) -> do seen <- atomicModifyIORef warned ((,) True) unless seen $ E.handle (\(_::E.IOException) -> return ()) $ do +#if !defined(mingw32_HOST_OS) hPutStrLn stderr ("Warning: Couldn't open /dev/urandom") +#else + hPutStrLn stderr ("Warning: Couldn't use RtlGenRandom") +#endif hPutStrLn stderr ("Warning: using system clock for seed instead " ++ "(quality will be lower)") acquireSeedTime diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mwc-random-0.13.3.2/benchmarks/tsts.hs new/mwc-random-0.13.4.0/benchmarks/tsts.hs --- old/mwc-random-0.13.3.2/benchmarks/tsts.hs 2015-03-29 23:25:02.000000000 +0200 +++ new/mwc-random-0.13.4.0/benchmarks/tsts.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,65 +0,0 @@ -{-# LANGUAGE BangPatterns #-} -import Control.Monad -import System.Random.MWC -import System.Random.MWC.Distributions - -main = do - withSystemRandom $ \g -> replicateM_ (300*1000) $ do - -- - !n <- normal 0 1 g - !n <- normal 0 2 g - !n <- normal 3 3 g - !n <- normal 2 4 g - !n <- normal 2 5 g - !n <- normal 1 6 g - !n <- normal 3 7 g - !n <- normal 3 8 g - !n <- normal 3 9 g - !n <- normal 3 10 g - -- - !n <- normal 0 1 g - !n <- normal 0 2 g - !n <- normal 3 3 g - !n <- normal 2 4 g - !n <- normal 2 5 g - !n <- normal 1 6 g - !n <- normal 3 7 g - !n <- normal 3 8 g - !n <- normal 3 9 g - !n <- normal 3 10 g - -- - !n <- normal 0 1 g - !n <- normal 0 2 g - !n <- normal 3 3 g - !n <- normal 2 4 g - !n <- normal 2 5 g - !n <- normal 1 6 g - !n <- normal 3 7 g - !n <- normal 3 8 g - !n <- normal 3 9 g - !n <- normal 3 10 g - -- - !n <- normal 0 1 g - !n <- normal 0 2 g - !n <- normal 3 3 g - !n <- normal 2 4 g - !n <- normal 2 5 g - !n <- normal 1 6 g - !n <- normal 3 7 g - !n <- normal 3 8 g - !n <- normal 3 9 g - !n <- normal 3 10 g - -- - !n <- normal 0 1 g - !n <- normal 0 2 g - !n <- normal 3 3 g - !n <- normal 2 4 g - !n <- normal 2 5 g - !n <- normal 1 6 g - !n <- normal 3 7 g - !n <- normal 3 8 g - !n <- normal 3 9 g - !n <- normal 3 10 g - -- - return () :: IO () - \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mwc-random-0.13.3.2/mwc-random.cabal new/mwc-random-0.13.4.0/mwc-random.cabal --- old/mwc-random-0.13.3.2/mwc-random.cabal 2015-03-29 23:25:02.000000000 +0200 +++ new/mwc-random-0.13.4.0/mwc-random.cabal 2016-02-20 12:34:03.000000000 +0100 @@ -1,5 +1,5 @@ name: mwc-random -version: 0.13.3.2 +version: 0.13.4.0 synopsis: Fast, high quality pseudo random number generation description: This package contains code for generating high quality random @@ -24,7 +24,7 @@ copyright: 2009, 2010, 2011 Bryan O'Sullivan category: Math, Statistics build-type: Simple -cabal-version: >= 1.8 +cabal-version: >= 1.8.0.4 extra-source-files: ChangeLog README.markdown