summaryrefslogtreecommitdiff
path: root/libraries/ghc-prim
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ghc-prim')
-rw-r--r--libraries/ghc-prim/.gitignore3
-rw-r--r--libraries/ghc-prim/GHC/Classes.hs94
-rw-r--r--libraries/ghc-prim/GHC/Magic.hs12
-rw-r--r--libraries/ghc-prim/GHC/Types.hs18
-rw-r--r--libraries/ghc-prim/cbits/atomic.c142
-rw-r--r--libraries/ghc-prim/cbits/ctz.c2
-rw-r--r--libraries/ghc-prim/cbits/pdep.c43
-rw-r--r--libraries/ghc-prim/cbits/pext.c39
-rw-r--r--libraries/ghc-prim/changelog.md66
-rw-r--r--libraries/ghc-prim/ghc-prim.cabal18
10 files changed, 384 insertions, 53 deletions
diff --git a/libraries/ghc-prim/.gitignore b/libraries/ghc-prim/.gitignore
index 9ae69e658a..1186a2b3d9 100644
--- a/libraries/ghc-prim/.gitignore
+++ b/libraries/ghc-prim/.gitignore
@@ -1,4 +1,5 @@
/dist/
/dist-install/
/ghc.mk
-/GNUmakefile \ No newline at end of file
+/ghc-prim.buildinfo
+/GNUmakefile
diff --git a/libraries/ghc-prim/GHC/Classes.hs b/libraries/ghc-prim/GHC/Classes.hs
index 4479ac0120..29f1149534 100644
--- a/libraries/ghc-prim/GHC/Classes.hs
+++ b/libraries/ghc-prim/GHC/Classes.hs
@@ -119,6 +119,21 @@ for the types in "GHC.Word" and "GHC.Int".
-- and 'Eq' may be derived for any datatype whose constituents are also
-- instances of 'Eq'.
--
+-- The Haskell Report defines no laws for 'Eq'. However, '==' is customarily
+-- expected to implement an equivalence relationship where two values comparing
+-- equal are indistinguishable by "public" functions, with a "public" function
+-- being one not allowing to see implementation details. For example, for a
+-- type representing non-normalised natural numbers modulo 100, a "public"
+-- function doesn't make the difference between 1 and 201. It is expected to
+-- have the following properties:
+--
+-- [__Reflexivity__]: @x == x@ = 'True'
+-- [__Symmetry__]: @x == y@ = @y == x@
+-- [__Transitivity__]: if @x == y && y == z@ = 'True', then @x == z@ = 'True'
+-- [__Substitutivity__]: if @x == y@ = 'True' and @f@ is a "public" function
+-- whose return type is an instance of 'Eq', then @f x == f y@ = 'True'
+-- [__Negation__]: @x /= y@ = @not (x == y)@
+--
-- Minimal complete definition: either '==' or '/='.
--
class Eq a where
@@ -207,6 +222,18 @@ eqChar, neChar :: Char -> Char -> Bool
(C# x) `eqChar` (C# y) = isTrue# (x `eqChar#` y)
(C# x) `neChar` (C# y) = isTrue# (x `neChar#` y)
+-- | Note that due to the presence of @NaN@, `Float`'s 'Eq' instance does not
+-- satisfy reflexivity.
+--
+-- >>> 0/0 == (0/0 :: Float)
+-- False
+--
+-- Also note that `Float`'s 'Eq' instance does not satisfy substitutivity:
+--
+-- >>> 0 == (-0 :: Float)
+-- True
+-- >>> recip 0 == recip (-0 :: Float)
+-- False
instance Eq Float where
(==) = eqFloat
@@ -215,6 +242,18 @@ instance Eq Float where
eqFloat :: Float -> Float -> Bool
(F# x) `eqFloat` (F# y) = isTrue# (x `eqFloat#` y)
+-- | Note that due to the presence of @NaN@, `Double`'s 'Eq' instance does not
+-- satisfy reflexivity.
+--
+-- >>> 0/0 == (0/0 :: Double)
+-- False
+--
+-- Also note that `Double`'s 'Eq' instance does not satisfy substitutivity:
+--
+-- >>> 0 == (-0 :: Double)
+-- True
+-- >>> recip 0 == recip (-0 :: Double)
+-- False
instance Eq Double where
(==) = eqDouble
@@ -261,11 +300,30 @@ instance Ord TyCon where
-- | The 'Ord' class is used for totally ordered datatypes.
--
--- Instances of 'Ord' can be derived for any user-defined
--- datatype whose constituent types are in 'Ord'. The declared order
--- of the constructors in the data declaration determines the ordering
--- in derived 'Ord' instances. The 'Ordering' datatype allows a single
--- comparison to determine the precise ordering of two objects.
+-- Instances of 'Ord' can be derived for any user-defined datatype whose
+-- constituent types are in 'Ord'. The declared order of the constructors in
+-- the data declaration determines the ordering in derived 'Ord' instances. The
+-- 'Ordering' datatype allows a single comparison to determine the precise
+-- ordering of two objects.
+--
+-- The Haskell Report defines no laws for 'Ord'. However, '<=' is customarily
+-- expected to implement a non-strict partial order and have the following
+-- properties:
+--
+-- [__Transitivity__]: if @x <= y && y <= z@ = 'True', then @x <= z@ = 'True'
+-- [__Reflexivity__]: @x <= x@ = 'True'
+-- [__Antisymmetry__]: if @x <= y && y <= x@ = 'True', then @x == y@ = 'True'
+--
+-- Note that the following operator interactions are expected to hold:
+--
+-- 1. @x >= y@ = @y <= x@
+-- 2. @x < y@ = @x <= y && x /= y@
+-- 3. @x > y@ = @y < x@
+-- 4. @x < y@ = @compare x y == LT@
+-- 5. @x > y@ = @compare x y == GT@
+-- 6. @x == y@ = @compare x y == EQ@
+-- 7. @min x y == if x <= y then x else y@ = 'True'
+-- 8. @max x y == if x >= y then x else y@ = 'True'
--
-- Minimal complete definition: either 'compare' or '<='.
-- Using 'compare' can be more efficient for complex types.
@@ -350,6 +408,19 @@ instance Ord Char where
(C# c1) <= (C# c2) = isTrue# (c1 `leChar#` c2)
(C# c1) < (C# c2) = isTrue# (c1 `ltChar#` c2)
+-- | Note that due to the presence of @NaN@, `Float`'s 'Ord' instance does not
+-- satisfy reflexivity.
+--
+-- >>> 0/0 <= (0/0 :: Float)
+-- False
+--
+-- Also note that, due to the same, `Ord`'s operator interactions are not
+-- respected by `Float`'s instance:
+--
+-- >>> (0/0 :: Float) > 1
+-- False
+-- >>> compare (0/0 :: Float) 1
+-- GT
instance Ord Float where
(F# x) `compare` (F# y)
= if isTrue# (x `ltFloat#` y) then LT
@@ -361,6 +432,19 @@ instance Ord Float where
(F# x) >= (F# y) = isTrue# (x `geFloat#` y)
(F# x) > (F# y) = isTrue# (x `gtFloat#` y)
+-- | Note that due to the presence of @NaN@, `Double`'s 'Ord' instance does not
+-- satisfy reflexivity.
+--
+-- >>> 0/0 <= (0/0 :: Double)
+-- False
+--
+-- Also note that, due to the same, `Ord`'s operator interactions are not
+-- respected by `Double`'s instance:
+--
+-- >>> (0/0 :: Double) > 1
+-- False
+-- >>> compare (0/0 :: Double) 1
+-- GT
instance Ord Double where
(D# x) `compare` (D# y)
= if isTrue# (x <## y) then LT
diff --git a/libraries/ghc-prim/GHC/Magic.hs b/libraries/ghc-prim/GHC/Magic.hs
index 3dbda1dbd4..ae95bfcbf4 100644
--- a/libraries/ghc-prim/GHC/Magic.hs
+++ b/libraries/ghc-prim/GHC/Magic.hs
@@ -3,7 +3,8 @@
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}
-{-# LANGUAGE TypeInType #-}
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
-----------------------------------------------------------------------------
@@ -25,6 +26,10 @@
module GHC.Magic ( inline, noinline, lazy, oneShot, runRW# ) where
+--------------------------------------------------
+-- See Note [magicIds] in MkId.hs
+--------------------------------------------------
+
import GHC.Prim
import GHC.CString ()
import GHC.Types (RuntimeRep, TYPE)
@@ -110,11 +115,10 @@ oneShot f = f
runRW# :: forall (r :: RuntimeRep) (o :: TYPE r).
(State# RealWorld -> o) -> o
--- See Note [runRW magic] in MkId
+-- See Note [runRW magic] in CorePrep
+{-# NOINLINE runRW# #-} -- runRW# is inlined manually in CorePrep
#if !defined(__HADDOCK_VERSION__)
runRW# m = m realWorld#
#else
runRW# = runRW# -- The realWorld# is too much for haddock
#endif
-{-# NOINLINE runRW# #-}
--- This is inlined manually in CorePrep
diff --git a/libraries/ghc-prim/GHC/Types.hs b/libraries/ghc-prim/GHC/Types.hs
index 3756c58827..3275d571d9 100644
--- a/libraries/ghc-prim/GHC/Types.hs
+++ b/libraries/ghc-prim/GHC/Types.hs
@@ -32,7 +32,7 @@ module GHC.Types (
Nat, Symbol,
Any,
type (~~), Coercible,
- TYPE, RuntimeRep(..), Type, type (*), type (★), Constraint,
+ TYPE, RuntimeRep(..), Type, Constraint,
-- The historical type * should ideally be written as
-- `type *`, without the parentheses. But that's a true
-- pain to parse, and for little gain.
@@ -59,12 +59,6 @@ data Constraint
-- | The kind of types with values. For example @Int :: Type@.
type Type = TYPE 'LiftedRep
--- | A backward-compatible (pre-GHC 8.0) synonym for 'Type'
-type * = TYPE 'LiftedRep
-
--- | A unicode backward-compatible (pre-GHC 8.0) synonym for 'Type'
-type ★ = TYPE 'LiftedRep
-
{- *********************************************************************
* *
Nat and Symbol
@@ -122,7 +116,7 @@ data Ordering = LT | EQ | GT
********************************************************************* -}
{- | The character type 'Char' is an enumeration whose values represent
-Unicode (or equivalently ISO\/IEC 10646) characters (see
+Unicode (or equivalently ISO\/IEC 10646) code points (i.e. characters, see
<http://www.unicode.org/> for details). This set extends the ISO 8859-1
(Latin-1) character set (the first 256 characters), which is itself an extension
of the ASCII character set (the first 128 characters). A character literal in
@@ -217,6 +211,12 @@ inside GHC, to change the kind and type.
class a ~~ b
-- See also Note [The equality types story] in TysPrim
+-- | Lifted, homogeneous equality. By lifted, we mean that it
+-- can be bogus (deferred type error). By homogeneous, the two
+-- types @a@ and @b@ must have the sme kinds.
+class a ~ b
+ -- See also Note [The equality types story] in TysPrim
+
-- | @Coercible@ is a two-parameter class that has instances for types @a@ and @b@ if
-- the compiler can infer that they have the same representation. This class
-- does not have regular instances; instead they are created on-the-fly during
@@ -260,7 +260,7 @@ class a ~~ b
-- @type role Set nominal@
--
-- For more details about this feature, please refer to
--- <http://www.cis.upenn.edu/~eir/papers/2014/coercible/coercible.pdf Safe Coercions>
+-- <http://research.microsoft.com/en-us/um/people/simonpj/papers/ext-f/coercible.pdf Safe Coercions>
-- by Joachim Breitner, Richard A. Eisenberg, Simon Peyton Jones and Stephanie Weirich.
--
-- @since 4.7.0.0
diff --git a/libraries/ghc-prim/cbits/atomic.c b/libraries/ghc-prim/cbits/atomic.c
index 2ecbf3461a..0a471b31ad 100644
--- a/libraries/ghc-prim/cbits/atomic.c
+++ b/libraries/ghc-prim/cbits/atomic.c
@@ -107,7 +107,44 @@ hs_atomic_and64(StgWord x, StgWord64 val)
// FetchNandByteArrayOp_Int
-// Workaround for http://llvm.org/bugs/show_bug.cgi?id=8842
+// Note [__sync_fetch_and_nand usage]
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// The __sync_fetch_and_nand builtin is a bit of a disaster. It was introduced
+// in GCC long ago with silly semantics. Specifically:
+//
+// *ptr = ~(tmp & value)
+//
+// Clang introduced the builtin with the same semantics.
+//
+// In GCC 4.4 the operation's semantics were rightly changed to,
+//
+// *ptr = ~tmp & value
+//
+// and the -Wsync-nand warning was added warning users of the operation about
+// the change.
+//
+// Clang took this change as a reason to remove support for the
+// builtin in 2010. Then, in 2014 Clang re-added support with the new
+// semantics. However, the warning flag was given a different name
+// (-Wsync-fetch-and-nand-semantics-changed) for added fun.
+//
+// Consequently, we are left with a bit of a mess: GHC requires GCC >4.4
+// (enforced by the FP_GCC_VERSION autoconf check), so we thankfully don't need
+// to support the operation's older broken semantics. However, we need to take
+// care to explicitly disable -Wsync-nand wherever possible, lest the build
+// fails with -Werror. Furthermore, we need to emulate the operation when
+// building with some Clang versions (shipped by some Mac OS X releases) which
+// lack support for the builtin.
+//
+// In the words of Bob Dylan: everything is broken.
+//
+// See also:
+//
+// * https://bugs.llvm.org/show_bug.cgi?id=8842
+// * https://ghc.haskell.org/trac/ghc/ticket/9678
+//
+
#define CAS_NAND(x, val) \
{ \
__typeof__ (*(x)) tmp = *(x); \
@@ -117,14 +154,33 @@ hs_atomic_and64(StgWord x, StgWord64 val)
return tmp; \
}
+// N.B. __has_builtin is only provided by clang
+#if !defined(__has_builtin)
+#define __has_builtin(x) 0
+#endif
+
+#if defined(__clang__) && !__has_builtin(__sync_fetch_and_nand)
+#define USE_SYNC_FETCH_AND_NAND 0
+#else
+#define USE_SYNC_FETCH_AND_NAND 1
+#endif
+
+// Otherwise this fails with -Werror
+#pragma GCC diagnostic push
+#if defined(__clang__)
+#pragma GCC diagnostic ignored "-Wsync-fetch-and-nand-semantics-changed"
+#elif defined(__GNUC__)
+#pragma GCC diagnostic ignored "-Wsync-nand"
+#endif
+
extern StgWord hs_atomic_nand8(StgWord x, StgWord val);
StgWord
hs_atomic_nand8(StgWord x, StgWord val)
{
-#ifdef __clang__
- CAS_NAND((volatile StgWord8 *) x, (StgWord8) val)
-#else
+#if USE_SYNC_FETCH_AND_NAND
return __sync_fetch_and_nand((volatile StgWord8 *) x, (StgWord8) val);
+#else
+ CAS_NAND((volatile StgWord8 *) x, (StgWord8) val)
#endif
}
@@ -132,10 +188,10 @@ extern StgWord hs_atomic_nand16(StgWord x, StgWord val);
StgWord
hs_atomic_nand16(StgWord x, StgWord val)
{
-#ifdef __clang__
- CAS_NAND((volatile StgWord16 *) x, (StgWord16) val);
-#else
+#if USE_SYNC_FETCH_AND_NAND
return __sync_fetch_and_nand((volatile StgWord16 *) x, (StgWord16) val);
+#else
+ CAS_NAND((volatile StgWord16 *) x, (StgWord16) val);
#endif
}
@@ -143,10 +199,10 @@ extern StgWord hs_atomic_nand32(StgWord x, StgWord val);
StgWord
hs_atomic_nand32(StgWord x, StgWord val)
{
-#ifdef __clang__
- CAS_NAND((volatile StgWord32 *) x, (StgWord32) val);
-#else
+#if USE_SYNC_FETCH_AND_NAND
return __sync_fetch_and_nand((volatile StgWord32 *) x, (StgWord32) val);
+#else
+ CAS_NAND((volatile StgWord32 *) x, (StgWord32) val);
#endif
}
@@ -155,14 +211,16 @@ extern StgWord64 hs_atomic_nand64(StgWord x, StgWord64 val);
StgWord64
hs_atomic_nand64(StgWord x, StgWord64 val)
{
-#ifdef __clang__
- CAS_NAND((volatile StgWord64 *) x, val);
-#else
+#if USE_SYNC_FETCH_AND_NAND
return __sync_fetch_and_nand((volatile StgWord64 *) x, val);
+#else
+ CAS_NAND((volatile StgWord64 *) x, val);
#endif
}
#endif
+#pragma GCC diagnostic pop
+
// FetchOrByteArrayOp_Int
extern StgWord hs_atomic_or8(StgWord x, StgWord val);
@@ -260,61 +318,103 @@ hs_cmpxchg64(StgWord x, StgWord64 old, StgWord64 new)
#endif
// AtomicReadByteArrayOp_Int
+// Implies a full memory barrier (see compiler/prelude/primops.txt.pp)
+// __ATOMIC_SEQ_CST: Full barrier in both directions (hoisting and sinking
+// of code) and synchronizes with acquire loads and release stores in
+// all threads.
+//
+// When we lack C11 atomics support we emulate these using the old GCC __sync
+// primitives which the GCC documentation claims "usually" implies a full
+// barrier.
extern StgWord hs_atomicread8(StgWord x);
StgWord
hs_atomicread8(StgWord x)
{
- return *(volatile StgWord8 *) x;
+#if HAVE_C11_ATOMICS
+ return __atomic_load_n((StgWord8 *) x, __ATOMIC_SEQ_CST);
+#else
+ return __sync_add_and_fetch((StgWord8 *) x, 0);
+#endif
}
extern StgWord hs_atomicread16(StgWord x);
StgWord
hs_atomicread16(StgWord x)
{
- return *(volatile StgWord16 *) x;
+#if HAVE_C11_ATOMICS
+ return __atomic_load_n((StgWord16 *) x, __ATOMIC_SEQ_CST);
+#else
+ return __sync_add_and_fetch((StgWord16 *) x, 0);
+#endif
}
extern StgWord hs_atomicread32(StgWord x);
StgWord
hs_atomicread32(StgWord x)
{
- return *(volatile StgWord32 *) x;
+#if HAVE_C11_ATOMICS
+ return __atomic_load_n((StgWord32 *) x, __ATOMIC_SEQ_CST);
+#else
+ return __sync_add_and_fetch((StgWord32 *) x, 0);
+#endif
}
extern StgWord64 hs_atomicread64(StgWord x);
StgWord64
hs_atomicread64(StgWord x)
{
- return *(volatile StgWord64 *) x;
+#if HAVE_C11_ATOMICS
+ return __atomic_load_n((StgWord64 *) x, __ATOMIC_SEQ_CST);
+#else
+ return __sync_add_and_fetch((StgWord64 *) x, 0);
+#endif
}
// AtomicWriteByteArrayOp_Int
+// Implies a full memory barrier (see compiler/prelude/primops.txt.pp)
+// __ATOMIC_SEQ_CST: Full barrier (see hs_atomicread8 above).
extern void hs_atomicwrite8(StgWord x, StgWord val);
void
hs_atomicwrite8(StgWord x, StgWord val)
{
- *(volatile StgWord8 *) x = (StgWord8) val;
+#if HAVE_C11_ATOMICS
+ __atomic_store_n((StgWord8 *) x, (StgWord8) val, __ATOMIC_SEQ_CST);
+#else
+ while (!__sync_bool_compare_and_swap((StgWord8 *) x, *(StgWord8 *) x, (StgWord8) val));
+#endif
}
extern void hs_atomicwrite16(StgWord x, StgWord val);
void
hs_atomicwrite16(StgWord x, StgWord val)
{
- *(volatile StgWord16 *) x = (StgWord16) val;
+#if HAVE_C11_ATOMICS
+ __atomic_store_n((StgWord16 *) x, (StgWord16) val, __ATOMIC_SEQ_CST);
+#else
+ while (!__sync_bool_compare_and_swap((StgWord16 *) x, *(StgWord16 *) x, (StgWord16) val));
+#endif
}
extern void hs_atomicwrite32(StgWord x, StgWord val);
void
hs_atomicwrite32(StgWord x, StgWord val)
{
- *(volatile StgWord32 *) x = (StgWord32) val;
+#if HAVE_C11_ATOMICS
+ __atomic_store_n((StgWord32 *) x, (StgWord32) val, __ATOMIC_SEQ_CST);
+#else
+ while (!__sync_bool_compare_and_swap((StgWord32 *) x, *(StgWord32 *) x, (StgWord32) val));
+#endif
}
extern void hs_atomicwrite64(StgWord x, StgWord64 val);
void
hs_atomicwrite64(StgWord x, StgWord64 val)
{
- *(volatile StgWord64 *) x = (StgWord64) val;
+#if HAVE_C11_ATOMICS
+ __atomic_store_n((StgWord64 *) x, (StgWord64) val, __ATOMIC_SEQ_CST);
+#else
+ while (!__sync_bool_compare_and_swap((StgWord64 *) x, *(StgWord64 *) x, (StgWord64) val));
+#endif
}
diff --git a/libraries/ghc-prim/cbits/ctz.c b/libraries/ghc-prim/cbits/ctz.c
index 95f327a919..fc98716968 100644
--- a/libraries/ghc-prim/cbits/ctz.c
+++ b/libraries/ghc-prim/cbits/ctz.c
@@ -36,7 +36,7 @@ hs_ctz64(StgWord64 x)
get inlined by GCC but rather a short `__ctzdi2` runtime function
is inserted when needed into compiled object files.
- This workaround forces GCC on 32bit x86 to to express `hs_ctz64` in
+ This workaround forces GCC on 32bit x86 to express `hs_ctz64` in
terms of the 32bit `__builtin_ctz()` (this is no loss, as there's no
64bit BSF instruction on i686 anyway) and thus avoid the problematic
out-of-line runtime function.
diff --git a/libraries/ghc-prim/cbits/pdep.c b/libraries/ghc-prim/cbits/pdep.c
new file mode 100644
index 0000000000..58e8611eca
--- /dev/null
+++ b/libraries/ghc-prim/cbits/pdep.c
@@ -0,0 +1,43 @@
+#include "Rts.h"
+#include "MachDeps.h"
+
+StgWord64
+hs_pdep64(StgWord64 src, StgWord64 mask)
+{
+ uint64_t result = 0;
+
+ while (1) {
+ // Mask out all but the lowest bit
+ const uint64_t lowest = (-mask & mask);
+
+ if (lowest == 0) {
+ break;
+ }
+
+ const uint64_t lsb = (uint64_t)((int64_t)(src << 63) >> 63);
+
+ result |= lsb & lowest;
+ mask &= ~lowest;
+ src >>= 1;
+ }
+
+ return result;
+}
+
+StgWord
+hs_pdep32(StgWord src, StgWord mask)
+{
+ return hs_pdep64(src, mask);
+}
+
+StgWord
+hs_pdep16(StgWord src, StgWord mask)
+{
+ return hs_pdep64(src, mask);
+}
+
+StgWord
+hs_pdep8(StgWord src, StgWord mask)
+{
+ return hs_pdep64(src, mask);
+}
diff --git a/libraries/ghc-prim/cbits/pext.c b/libraries/ghc-prim/cbits/pext.c
new file mode 100644
index 0000000000..9cddedef1a
--- /dev/null
+++ b/libraries/ghc-prim/cbits/pext.c
@@ -0,0 +1,39 @@
+#include "Rts.h"
+#include "MachDeps.h"
+
+StgWord64
+hs_pext64(StgWord64 src, StgWord64 mask)
+{
+ uint64_t result = 0;
+ int offset = 0;
+
+ for (int bit = 0; bit != sizeof(uint64_t) * 8; ++bit) {
+ const uint64_t src_bit = (src >> bit) & 1;
+ const uint64_t mask_bit = (mask >> bit) & 1;
+
+ if (mask_bit) {
+ result |= (uint64_t)(src_bit) << offset;
+ ++offset;
+ }
+ }
+
+ return result;
+}
+
+StgWord
+hs_pext32(StgWord src, StgWord mask)
+{
+ return hs_pext64(src, mask);
+}
+
+StgWord
+hs_pext16(StgWord src, StgWord mask)
+{
+ return hs_pext64(src, mask);
+}
+
+StgWord
+hs_pext8(StgWord src, StgWord mask)
+{
+ return hs_pext64(src, mask);
+}
diff --git a/libraries/ghc-prim/changelog.md b/libraries/ghc-prim/changelog.md
index 0c9ca42fd8..76da3e0b1d 100644
--- a/libraries/ghc-prim/changelog.md
+++ b/libraries/ghc-prim/changelog.md
@@ -1,10 +1,72 @@
-## 0.6.0.0
+## 0.6.0
+
+- Shipped with GHC 8.8.1
+
+- Added to `GHC.Prim`:
+ traveBinaryEvent# :: Addr# -> Int# -> State# s -> State# s
+
+## 0.5.3 (edit as necessary)
+
+- Shipped with GHC 8.6.1
+
+- Added to `GHC.Prim`:
+ addWordC# :: Word# -> Word# -> (# Word#, Int# #)
+
+- `unpackClosure#` can now unpack any valid Haskell closure.
+ Previously it returned empty pointer and non-pointer arrays
+ for thunks.
+
+## 0.5.2.0
+
+- Shipped with GHC 8.4.1
+
+- Added to `GHC.Prim`:
+
+ compareByteArrays# :: ByteArray# -> Int# -> ByteArray# -> Int# -> Int# -> Int#
+
+- Don't allocate a thunk for each unpacked UTF-8 character in `unpackCStringUtf8#`
+
+## 0.5.1.1 *November 2017*
+
+- Shipped with GHC 8.2.2
+
+- Changed strictness properties of `catchRetry#` (#14171)
+
+## 0.5.1.0 *July 2017*
- Shipped with GHC 8.2.1
- Added to `GHC.Prim`:
- isPinnedByteArray# :: MutableByteArray# s -> Int#
+ fabsDouble# :: Double# -> Double#
+ fabsFloat# :: Float# -> Float#
+ isByteArrayPinned# :: ByteArray# -> Int#
+ isMutableByteArrayPinned# :: MutableByteArray# s -> Int#
+ anyToAddr# :: a -> State# (RealWorld) -> (# State# (RealWorld),Addr# #)
+
+- New primitives for compact regions in `GHC.Prim`:
+
+ Compact#
+ compactNew#
+ compactResize#
+ compactContains#
+ compactContainsAny#
+ compactGetFirstBlock#
+ compactGetNextBlock#
+ compactAllocateBlock#
+ compactFixupPointers#
+ compactAdd#
+ compactAddWithSharing#
+ compactSize#
+
+- Generalised `noDuplicate#` from
+
+ noDuplicate# :: State# (RealWorld) -> State# (RealWorld)
+
+ to
+
+ noDuplicate# :: State# s -> State# s
+
## 0.5.0.0
diff --git a/libraries/ghc-prim/ghc-prim.cabal b/libraries/ghc-prim/ghc-prim.cabal
index 00a029efed..a95f1ecaa8 100644
--- a/libraries/ghc-prim/ghc-prim.cabal
+++ b/libraries/ghc-prim/ghc-prim.cabal
@@ -1,13 +1,13 @@
+cabal-version: 2.1
name: ghc-prim
-version: 0.5.1.0
+version: 0.5.3
-- NOTE: Don't forget to update ./changelog.md
-license: BSD3
+license: BSD-3-Clause
license-file: LICENSE
category: GHC
maintainer: libraries@haskell.org
bug-reports: http://ghc.haskell.org/trac/ghc/newticket?component=libraries%20%28other%29&keywords=ghc-prim
synopsis: GHC primitives
-cabal-version: >=1.10
build-type: Custom
description:
This package contains the primitive types and operations supplied by GHC.
@@ -19,10 +19,6 @@ source-repository head
location: http://git.haskell.org/ghc.git
subdir: libraries/ghc-prim
-flag include-ghc-prim
- Description: Include GHC.Prim in exposed-modules
- default: False
-
custom-setup
setup-depends: base >= 4 && < 5, Cabal >= 1.23
@@ -53,6 +49,9 @@ Library
GHC.Tuple
GHC.Types
+ virtual-modules:
+ GHC.Prim
+
-- OS Specific
if os(windows)
-- Windows requires some extra libraries for linking because the RTS
@@ -67,9 +66,6 @@ Library
-- on Windows. Required because of mingw32.
extra-libraries: user32, mingw32, mingwex
- if flag(include-ghc-prim)
- exposed-modules: GHC.Prim
-
c-sources:
cbits/atomic.c
cbits/bswap.c
@@ -77,6 +73,8 @@ Library
cbits/ctz.c
cbits/debug.c
cbits/longlong.c
+ cbits/pdep.c
+ cbits/pext.c
cbits/popcnt.c
cbits/word2float.c