Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
Commits:
e10dcd65 by Sven Tennie at 2025-10-12T10:24:56+00:00
T22859: Increase threadDelay for small machines
The previously used thread delay led to failures on my RISC-V test
setups.
- - - - -
90cde9c3 by Rodrigo Mesquita at 2025-10-14T09:07:29-04:00
Move code-gen aux symbols from ghc-internal to rts
These symbols were all previously defined in ghc-internal and made the
dependency structure awkward, where the rts may refer to some of these
symbols and had to work around that circular dependency the way
described in #26166.
Moreover, the code generator will produce code that uses these symbols!
Therefore, they should be available in the rts:
PRINCIPLE: If the code generator may produce code which uses this
symbol, then it should be defined in the rts rather than, say,
ghc-internal.
That said, the main motivation is towards fixing #26166.
Towards #26166. Pre-requisite of !14892
- - - - -
20 changed files:
- compiler/GHC/CmmToAsm/Wasm/FromCmm.hs
- hadrian/src/Settings/Packages.hs
- libraries/ghc-internal/ghc-internal.cabal.in
- rts/RtsSymbols.c
- rts/include/stg/Prim.h
- libraries/ghc-internal/cbits/atomic.c → rts/prim/atomic.c
- libraries/ghc-internal/cbits/bitrev.c → rts/prim/bitrev.c
- libraries/ghc-internal/cbits/bswap.c → rts/prim/bswap.c
- libraries/ghc-internal/cbits/clz.c → rts/prim/clz.c
- libraries/ghc-internal/cbits/ctz.c → rts/prim/ctz.c
- libraries/ghc-internal/cbits/int64x2minmax.c → rts/prim/int64x2minmax.c
- libraries/ghc-internal/cbits/longlong.c → rts/prim/longlong.c
- libraries/ghc-internal/cbits/mulIntMayOflo.c → rts/prim/mulIntMayOflo.c
- libraries/ghc-internal/cbits/pdep.c → rts/prim/pdep.c
- libraries/ghc-internal/cbits/pext.c → rts/prim/pext.c
- libraries/ghc-internal/cbits/popcnt.c → rts/prim/popcnt.c
- libraries/ghc-internal/cbits/vectorQuotRem.c → rts/prim/vectorQuotRem.c
- libraries/ghc-internal/cbits/word2float.c → rts/prim/word2float.c
- rts/rts.cabal
- testsuite/tests/rts/T22859.hs
Changes:
=====================================
compiler/GHC/CmmToAsm/Wasm/FromCmm.hs
=====================================
@@ -438,7 +438,7 @@ lower_MO_S_Shr lbl w0 [x, y] = case someWasmTypeFromCmmType (cmmBits w0) of
lower_MO_S_Shr _ _ _ = panic "lower_MO_S_Shr: unreachable"
-- | Lower a 'MO_MulMayOflo' operation. It's translated to a ccall to
--- @hs_mulIntMayOflo@ function in @ghc-prim/cbits/mulIntMayOflo@,
+-- @hs_mulIntMayOflo@ function in @rts/prim/mulIntMayOflo@,
-- otherwise it's quite non-trivial to implement as inline assembly.
lower_MO_MulMayOflo ::
CLabel -> Width -> [CmmExpr] -> WasmCodeGenM w (SomeWasmExpr w)
=====================================
hadrian/src/Settings/Packages.hs
=====================================
@@ -287,9 +287,6 @@ ghcInternalArgs = package ghcInternal ? do
, builder (Cabal Flags) ? flag NeedLibatomic `cabalFlag` "need-atomic"
- , builder (Cc CompileC) ? (not <$> flag CcLlvmBackend) ?
- input "**/cbits/atomic.c" ? arg "-Wno-sync-nand"
-
]
-- | RTS-specific command line arguments.
@@ -413,6 +410,9 @@ rtsPackageArgs = package rts ? do
, input "**/RetainerProfile.c" ? flag CcLlvmBackend ?
arg "-Wno-incompatible-pointer-types"
+
+ , input "**/prim/atomic.c" ? (not <$> flag CcLlvmBackend) ?
+ arg "-Wno-sync-nand"
]
mconcat
=====================================
libraries/ghc-internal/ghc-internal.cabal.in
=====================================
@@ -442,20 +442,7 @@ Library
cbits/sysconf.c
cbits/fs.c
cbits/strerror.c
- cbits/atomic.c
- cbits/bswap.c
- cbits/bitrev.c
- cbits/clz.c
- cbits/ctz.c
cbits/debug.c
- cbits/int64x2minmax.c
- cbits/longlong.c
- cbits/mulIntMayOflo.c
- cbits/pdep.c
- cbits/pext.c
- cbits/popcnt.c
- cbits/vectorQuotRem.c
- cbits/word2float.c
cbits/Stack_c.c
cmm-sources:
=====================================
rts/RtsSymbols.c
=====================================
@@ -1016,6 +1016,116 @@ extern char **environ;
#define RTS_FINI_ARRAY_SYMBOLS
#endif
+#define SymI_HasProtoAllSizes(symbol) \
+ SymI_HasProto(symbol##8) \
+ SymI_HasProto(symbol##16) \
+ SymI_HasProto(symbol##32) \
+ SymI_HasProto(symbol##64)
+
+#if !defined(arm_HOST_ARCH)
+#define RTS_ATOMICS_SYMBOLS \
+ SymI_HasProtoAllSizes(hs_atomic_add) \
+ SymI_HasProtoAllSizes(hs_atomic_sub) \
+ SymI_HasProtoAllSizes(hs_atomic_and) \
+ SymI_HasProtoAllSizes(hs_atomic_nand) \
+ SymI_HasProtoAllSizes(hs_atomic_or) \
+ SymI_HasProtoAllSizes(hs_atomic_xor) \
+ SymI_HasProtoAllSizes(hs_cmpxchg) \
+ SymI_HasProtoAllSizes(hs_xchg) \
+ SymI_HasProtoAllSizes(hs_atomicread) \
+ SymI_HasProtoAllSizes(hs_atomicwrite)
+#else
+// No atomics on arm32. See e9abcad4cc3
+#define RTS_ATOMICS_SYMBOLS
+#endif
+
+// In rts/longlong.c
+#if WORD_SIZE_IN_BITS < 64
+#define RTS_SYMBOLS_LONGLONG \
+ SymI_HasProto(hs_eq64) \
+ SymI_HasProto(hs_ne64) \
+ SymI_HasProto(hs_gtWord64) \
+ SymI_HasProto(hs_geWord64) \
+ SymI_HasProto(hs_ltWord64) \
+ SymI_HasProto(hs_leWord64) \
+ SymI_HasProto(hs_gtInt64) \
+ SymI_HasProto(hs_geInt64) \
+ SymI_HasProto(hs_ltInt64) \
+ SymI_HasProto(hs_leInt64) \
+ SymI_HasProto(hs_neg64) \
+ SymI_HasProto(hs_add64) \
+ SymI_HasProto(hs_sub64) \
+ SymI_HasProto(hs_mul64) \
+ SymI_HasProto(hs_remWord64) \
+ SymI_HasProto(hs_quotWord64) \
+ SymI_HasProto(hs_remInt64) \
+ SymI_HasProto(hs_quotInt64) \
+ SymI_HasProto(hs_and64) \
+ SymI_HasProto(hs_or64) \
+ SymI_HasProto(hs_xor64) \
+ SymI_HasProto(hs_not64) \
+ SymI_HasProto(hs_uncheckedShiftL64) \
+ SymI_HasProto(hs_uncheckedShiftRL64) \
+ SymI_HasProto(hs_uncheckedIShiftRA64) \
+ SymI_HasProto(hs_intToInt64) \
+ SymI_HasProto(hs_int64ToInt) \
+ SymI_HasProto(hs_wordToWord64) \
+ SymI_HasProto(hs_word64ToWord)
+#else
+#define RTS_SYMBOLS_LONGLONG
+#endif
+
+// rts/prim/vectorQuotRem.c and rts/prim/int64x2minmax
+#if defined(__SSE2__)
+#define RTS_SYMBOLS_VECTORQUOTREM \
+ SymI_HasProto(hs_quotInt8X16) \
+ SymI_HasProto(hs_quotInt16X8) \
+ SymI_HasProto(hs_quotInt32X4) \
+ SymI_HasProto(hs_quotInt64X2) \
+ SymI_HasProto(hs_quotWord8X16) \
+ SymI_HasProto(hs_quotWord16X8) \
+ SymI_HasProto(hs_quotWord32X4) \
+ SymI_HasProto(hs_quotWord64X2) \
+ SymI_HasProto(hs_remInt8X16) \
+ SymI_HasProto(hs_remInt16X8) \
+ SymI_HasProto(hs_remInt32X4) \
+ SymI_HasProto(hs_remInt64X2) \
+ SymI_HasProto(hs_remWord8X16) \
+ SymI_HasProto(hs_remWord16X8) \
+ SymI_HasProto(hs_remWord32X4) \
+ SymI_HasProto(hs_remWord64X2)
+#define RTS_SYMBOLS_INT64X2MINMAX \
+ SymI_HasProto(hs_minInt64X2) \
+ SymI_HasProto(hs_maxInt64X2) \
+ SymI_HasProto(hs_minWord64X2) \
+ SymI_HasProto(hs_maxWord64X2)
+#else
+#define RTS_SYMBOLS_VECTORQUOTREM
+#define RTS_SYMBOLS_INT64X2MINMAX
+#endif
+
+// Symbols on files in rts/prim/*
+#define RTS_SYMBOLS_PRIM \
+ RTS_ATOMICS_SYMBOLS \
+ RTS_SYMBOLS_INT64X2MINMAX \
+ RTS_SYMBOLS_LONGLONG \
+ RTS_SYMBOLS_VECTORQUOTREM \
+ SymI_HasProtoAllSizes(hs_bitrev) \
+ SymI_HasProto(hs_bswap16) \
+ SymI_HasProto(hs_bswap32) \
+ SymI_HasProto(hs_bswap64) \
+ SymI_HasProtoAllSizes(hs_clz) \
+ SymI_HasProtoAllSizes(hs_ctz) \
+ SymI_HasProto(hs_mulIntMayOflo) \
+ SymI_HasProtoAllSizes(hs_pdep) \
+ SymI_HasProtoAllSizes(hs_pext) \
+ SymI_HasProtoAllSizes(hs_pext) \
+ SymI_HasProto(hs_popcnt) \
+ SymI_HasProtoAllSizes(hs_popcnt) \
+ SymI_HasProto(hs_word2float32) \
+ SymI_HasProto(hs_word2float64)
+
+
/* entirely bogus claims about types of these symbols */
#define SymI_NeedsProto(vvv) extern void vvv(void);
#define SymI_NeedsDataProto(vvv) extern StgWord vvv[];
@@ -1038,6 +1148,7 @@ RTS_ARCH_LIBGCC_SYMBOLS
RTS_FINI_ARRAY_SYMBOLS
RTS_LIBFFI_SYMBOLS
RTS_ARM_OUTLINE_ATOMIC_SYMBOLS
+RTS_SYMBOLS_PRIM
#undef SymI_NeedsProto
#undef SymI_NeedsDataProto
@@ -1081,6 +1192,7 @@ RtsSymbolVal rtsSyms[] = {
RTS_FINI_ARRAY_SYMBOLS
RTS_LIBFFI_SYMBOLS
RTS_ARM_OUTLINE_ATOMIC_SYMBOLS
+ RTS_SYMBOLS_PRIM
SymI_HasDataProto(nonmoving_write_barrier_enabled)
{ 0, 0, STRENGTH_NORMAL, SYM_TYPE_CODE } /* sentinel */
};
=====================================
rts/include/stg/Prim.h
=====================================
@@ -2,7 +2,10 @@
*
* (c) The GHC Team, 2014-2014
*
- * Declarations for C fallback primitives implemented by 'ghc-internal' package.
+ * This header collects the declarations for all the C fallback implementations
+ * used by the code generator to lower certain primops and sometimes by the RTS.
+ *
+ * Corresponding C files are in rts/prim/
*
* Do not #include this file directly: #include "Rts.h" instead.
*
@@ -13,7 +16,7 @@
#pragma once
-/* libraries/ghc-internal/cbits/atomic.c */
+/* rts/prim/atomic.c */
StgWord hs_atomic_add8(StgWord x, StgWord val);
StgWord hs_atomic_add16(StgWord x, StgWord val);
StgWord hs_atomic_add32(StgWord x, StgWord val);
@@ -55,12 +58,12 @@ StgWord hs_xchg16(StgWord x, StgWord val);
StgWord hs_xchg32(StgWord x, StgWord val);
StgWord64 hs_xchg64(StgWord x, StgWord64 val);
-/* libraries/ghc-internal/cbits/bswap.c */
+/* rts/prim/bswap.c */
StgWord16 hs_bswap16(StgWord16 x);
StgWord32 hs_bswap32(StgWord32 x);
StgWord64 hs_bswap64(StgWord64 x);
-/* libraries/ghc-internal/cbits/bitrev.c
+/* rts/prim/bitrev.c
This was done as part of issue #16164.
See Note [Bit reversal primop] for more details about the implementation.*/
StgWord hs_bitrev8(StgWord x);
@@ -68,7 +71,7 @@ StgWord16 hs_bitrev16(StgWord16 x);
StgWord32 hs_bitrev32(StgWord32 x);
StgWord64 hs_bitrev64(StgWord64 x);
-/* libraries/ghc-internal/cbits/longlong.c */
+/* rts/prim/longlong.c */
#if WORD_SIZE_IN_BITS < 64
StgInt hs_eq64 (StgWord64 a, StgWord64 b);
StgInt hs_ne64 (StgWord64 a, StgWord64 b);
@@ -101,41 +104,75 @@ StgWord64 hs_wordToWord64 (StgWord w);
StgWord hs_word64ToWord (StgWord64 w);
#endif
-/* libraries/ghc-internal/cbits/pdep.c */
+/* rts/prim/pdep.c */
StgWord64 hs_pdep64(StgWord64 src, StgWord64 mask);
StgWord hs_pdep32(StgWord src, StgWord mask);
StgWord hs_pdep16(StgWord src, StgWord mask);
StgWord hs_pdep8(StgWord src, StgWord mask);
-/* libraries/ghc-internal/cbits/pext.c */
+/* rts/prim/pext.c */
StgWord64 hs_pext64(StgWord64 src, StgWord64 mask);
StgWord hs_pext32(StgWord src, StgWord mask);
StgWord hs_pext16(StgWord src, StgWord mask);
StgWord hs_pext8(StgWord src, StgWord mask);
-/* libraries/ghc-internal/cbits/popcnt.c */
+/* rts/prim/popcnt.c */
StgWord hs_popcnt8(StgWord x);
StgWord hs_popcnt16(StgWord x);
StgWord hs_popcnt32(StgWord x);
StgWord hs_popcnt64(StgWord64 x);
StgWord hs_popcnt(StgWord x);
-/* libraries/ghc-internal/cbits/word2float.c */
+/* rts/prim/word2float.c */
StgFloat hs_word2float32(StgWord x);
StgDouble hs_word2float64(StgWord x);
-/* libraries/ghc-internal/cbits/clz.c */
+/* rts/prim/clz.c */
StgWord hs_clz8(StgWord x);
StgWord hs_clz16(StgWord x);
StgWord hs_clz32(StgWord x);
StgWord hs_clz64(StgWord64 x);
-/* libraries/ghc-internal/cbits/ctz.c */
+/* rts/prim/ctz.c */
StgWord hs_ctz8(StgWord x);
StgWord hs_ctz16(StgWord x);
StgWord hs_ctz32(StgWord x);
StgWord hs_ctz64(StgWord64 x);
+/* rts/prim/mulIntMayOflo.c */
+W_ hs_mulIntMayOflo(W_ a, W_ b);
+
+
+/* rts/prim/int64x2minmax and rts/prim/vectorQuotRem */
+#if defined(__SSE2__)
+#include
+#include
+#include
+
+__m128i hs_minInt64X2(__m128i, __m128i);
+__m128i hs_maxInt64X2(__m128i, __m128i);
+__m128i hs_minWord64X2(__m128i, __m128i);
+__m128i hs_maxWord64X2(__m128i, __m128i);
+
+__m128i hs_quotInt8X16(__m128i, __m128i);
+__m128i hs_quotInt16X8(__m128i, __m128i);
+__m128i hs_quotInt32X4(__m128i, __m128i);
+__m128i hs_quotInt64X2(__m128i, __m128i);
+__m128i hs_quotWord8X16(__m128i, __m128i);
+__m128i hs_quotWord16X8(__m128i, __m128i);
+__m128i hs_quotWord32X4(__m128i, __m128i);
+__m128i hs_quotWord64X2(__m128i, __m128i);
+__m128i hs_remInt8X16(__m128i, __m128i);
+__m128i hs_remInt16X8(__m128i, __m128i);
+__m128i hs_remInt32X4(__m128i, __m128i);
+__m128i hs_remInt64X2(__m128i, __m128i);
+__m128i hs_remWord8X16(__m128i, __m128i);
+__m128i hs_remWord16X8(__m128i, __m128i);
+__m128i hs_remWord32X4(__m128i, __m128i);
+__m128i hs_remWord64X2(__m128i, __m128i);
+
+#endif
+
/* bitcasts, instead of creating a new C file we static inline these here. We
* use __builtin_memcpy instead of memcpy from string.h to avoid function
* prototype conflicts that occur in the C backend with the inclusion of
=====================================
libraries/ghc-internal/cbits/atomic.c → rts/prim/atomic.c
=====================================
@@ -12,90 +12,66 @@
// FetchAddByteArrayOp_Int
-extern StgWord hs_atomic_add8(StgWord x, StgWord val);
-StgWord
-hs_atomic_add8(StgWord x, StgWord val)
+StgWord hs_atomic_add8(StgWord x, StgWord val)
{
return __sync_fetch_and_add((volatile StgWord8 *) x, (StgWord8) val);
}
-extern StgWord hs_atomic_add16(StgWord x, StgWord val);
-StgWord
-hs_atomic_add16(StgWord x, StgWord val)
+StgWord hs_atomic_add16(StgWord x, StgWord val)
{
return __sync_fetch_and_add((volatile StgWord16 *) x, (StgWord16) val);
}
-extern StgWord hs_atomic_add32(StgWord x, StgWord val);
-StgWord
-hs_atomic_add32(StgWord x, StgWord val)
+StgWord hs_atomic_add32(StgWord x, StgWord val)
{
return __sync_fetch_and_add((volatile StgWord32 *) x, (StgWord32) val);
}
-extern StgWord64 hs_atomic_add64(StgWord x, StgWord64 val);
-StgWord64
-hs_atomic_add64(StgWord x, StgWord64 val)
+StgWord64 hs_atomic_add64(StgWord x, StgWord64 val)
{
return __sync_fetch_and_add((volatile StgWord64 *) x, val);
}
// FetchSubByteArrayOp_Int
-extern StgWord hs_atomic_sub8(StgWord x, StgWord val);
-StgWord
-hs_atomic_sub8(StgWord x, StgWord val)
+StgWord hs_atomic_sub8(StgWord x, StgWord val)
{
return __sync_fetch_and_sub((volatile StgWord8 *) x, (StgWord8) val);
}
-extern StgWord hs_atomic_sub16(StgWord x, StgWord val);
-StgWord
-hs_atomic_sub16(StgWord x, StgWord val)
+StgWord hs_atomic_sub16(StgWord x, StgWord val)
{
return __sync_fetch_and_sub((volatile StgWord16 *) x, (StgWord16) val);
}
-extern StgWord hs_atomic_sub32(StgWord x, StgWord val);
-StgWord
-hs_atomic_sub32(StgWord x, StgWord val)
+StgWord hs_atomic_sub32(StgWord x, StgWord val)
{
return __sync_fetch_and_sub((volatile StgWord32 *) x, (StgWord32) val);
}
-extern StgWord64 hs_atomic_sub64(StgWord x, StgWord64 val);
-StgWord64
-hs_atomic_sub64(StgWord x, StgWord64 val)
+StgWord64 hs_atomic_sub64(StgWord x, StgWord64 val)
{
return __sync_fetch_and_sub((volatile StgWord64 *) x, val);
}
// FetchAndByteArrayOp_Int
-extern StgWord hs_atomic_and8(StgWord x, StgWord val);
-StgWord
-hs_atomic_and8(StgWord x, StgWord val)
+StgWord hs_atomic_and8(StgWord x, StgWord val)
{
return __sync_fetch_and_and((volatile StgWord8 *) x, (StgWord8) val);
}
-extern StgWord hs_atomic_and16(StgWord x, StgWord val);
-StgWord
-hs_atomic_and16(StgWord x, StgWord val)
+StgWord hs_atomic_and16(StgWord x, StgWord val)
{
return __sync_fetch_and_and((volatile StgWord16 *) x, (StgWord16) val);
}
-extern StgWord hs_atomic_and32(StgWord x, StgWord val);
-StgWord
-hs_atomic_and32(StgWord x, StgWord val)
+StgWord hs_atomic_and32(StgWord x, StgWord val)
{
return __sync_fetch_and_and((volatile StgWord32 *) x, (StgWord32) val);
}
-extern StgWord64 hs_atomic_and64(StgWord x, StgWord64 val);
-StgWord64
-hs_atomic_and64(StgWord x, StgWord64 val)
+StgWord64 hs_atomic_and64(StgWord x, StgWord64 val)
{
return __sync_fetch_and_and((volatile StgWord64 *) x, val);
}
@@ -167,9 +143,7 @@ hs_atomic_and64(StgWord x, StgWord64 val)
#pragma GCC diagnostic ignored "-Wsync-nand"
#endif
-extern StgWord hs_atomic_nand8(StgWord x, StgWord val);
-StgWord
-hs_atomic_nand8(StgWord x, StgWord val)
+StgWord hs_atomic_nand8(StgWord x, StgWord val)
{
#if USE_SYNC_FETCH_AND_NAND
return __sync_fetch_and_nand((volatile StgWord8 *) x, (StgWord8) val);
@@ -178,9 +152,7 @@ hs_atomic_nand8(StgWord x, StgWord val)
#endif
}
-extern StgWord hs_atomic_nand16(StgWord x, StgWord val);
-StgWord
-hs_atomic_nand16(StgWord x, StgWord val)
+StgWord hs_atomic_nand16(StgWord x, StgWord val)
{
#if USE_SYNC_FETCH_AND_NAND
return __sync_fetch_and_nand((volatile StgWord16 *) x, (StgWord16) val);
@@ -189,9 +161,7 @@ hs_atomic_nand16(StgWord x, StgWord val)
#endif
}
-extern StgWord hs_atomic_nand32(StgWord x, StgWord val);
-StgWord
-hs_atomic_nand32(StgWord x, StgWord val)
+StgWord hs_atomic_nand32(StgWord x, StgWord val)
{
#if USE_SYNC_FETCH_AND_NAND
return __sync_fetch_and_nand((volatile StgWord32 *) x, (StgWord32) val);
@@ -200,9 +170,7 @@ hs_atomic_nand32(StgWord x, StgWord val)
#endif
}
-extern StgWord64 hs_atomic_nand64(StgWord x, StgWord64 val);
-StgWord64
-hs_atomic_nand64(StgWord x, StgWord64 val)
+StgWord64 hs_atomic_nand64(StgWord x, StgWord64 val)
{
#if USE_SYNC_FETCH_AND_NAND
return __sync_fetch_and_nand((volatile StgWord64 *) x, val);
@@ -215,96 +183,72 @@ hs_atomic_nand64(StgWord x, StgWord64 val)
// FetchOrByteArrayOp_Int
-extern StgWord hs_atomic_or8(StgWord x, StgWord val);
-StgWord
-hs_atomic_or8(StgWord x, StgWord val)
+StgWord hs_atomic_or8(StgWord x, StgWord val)
{
return __sync_fetch_and_or((volatile StgWord8 *) x, (StgWord8) val);
}
-extern StgWord hs_atomic_or16(StgWord x, StgWord val);
-StgWord
-hs_atomic_or16(StgWord x, StgWord val)
+StgWord hs_atomic_or16(StgWord x, StgWord val)
{
return __sync_fetch_and_or((volatile StgWord16 *) x, (StgWord16) val);
}
-extern StgWord hs_atomic_or32(StgWord x, StgWord val);
-StgWord
-hs_atomic_or32(StgWord x, StgWord val)
+StgWord hs_atomic_or32(StgWord x, StgWord val)
{
return __sync_fetch_and_or((volatile StgWord32 *) x, (StgWord32) val);
}
-extern StgWord64 hs_atomic_or64(StgWord x, StgWord64 val);
-StgWord64
-hs_atomic_or64(StgWord x, StgWord64 val)
+StgWord64 hs_atomic_or64(StgWord x, StgWord64 val)
{
return __sync_fetch_and_or((volatile StgWord64 *) x, val);
}
// FetchXorByteArrayOp_Int
-extern StgWord hs_atomic_xor8(StgWord x, StgWord val);
-StgWord
-hs_atomic_xor8(StgWord x, StgWord val)
+StgWord hs_atomic_xor8(StgWord x, StgWord val)
{
return __sync_fetch_and_xor((volatile StgWord8 *) x, (StgWord8) val);
}
-extern StgWord hs_atomic_xor16(StgWord x, StgWord val);
-StgWord
-hs_atomic_xor16(StgWord x, StgWord val)
+StgWord hs_atomic_xor16(StgWord x, StgWord val)
{
return __sync_fetch_and_xor((volatile StgWord16 *) x, (StgWord16) val);
}
-extern StgWord hs_atomic_xor32(StgWord x, StgWord val);
-StgWord
-hs_atomic_xor32(StgWord x, StgWord val)
+StgWord hs_atomic_xor32(StgWord x, StgWord val)
{
return __sync_fetch_and_xor((volatile StgWord32 *) x, (StgWord32) val);
}
-extern StgWord64 hs_atomic_xor64(StgWord x, StgWord64 val);
-StgWord64
-hs_atomic_xor64(StgWord x, StgWord64 val)
+StgWord64 hs_atomic_xor64(StgWord x, StgWord64 val)
{
return __sync_fetch_and_xor((volatile StgWord64 *) x, val);
}
// CasByteArrayOp_Int
-extern StgWord hs_cmpxchg8(StgWord x, StgWord old, StgWord new);
-StgWord
-hs_cmpxchg8(StgWord x, StgWord old, StgWord new)
+StgWord hs_cmpxchg8(StgWord x, StgWord old, StgWord new)
{
StgWord8 expected = (StgWord8) old;
__atomic_compare_exchange_n((StgWord8 *) x, &expected, (StgWord8) new, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
return expected;
}
-extern StgWord hs_cmpxchg16(StgWord x, StgWord old, StgWord new);
-StgWord
-hs_cmpxchg16(StgWord x, StgWord old, StgWord new)
+StgWord hs_cmpxchg16(StgWord x, StgWord old, StgWord new)
{
StgWord16 expected = (StgWord16) old;
__atomic_compare_exchange_n((StgWord16 *) x, &expected, (StgWord16) new, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
return expected;
}
-extern StgWord hs_cmpxchg32(StgWord x, StgWord old, StgWord new);
-StgWord
-hs_cmpxchg32(StgWord x, StgWord old, StgWord new)
+StgWord hs_cmpxchg32(StgWord x, StgWord old, StgWord new)
{
StgWord32 expected = (StgWord32) old;
__atomic_compare_exchange_n((StgWord32 *) x, &expected, (StgWord32) new, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
return expected;
}
-extern StgWord64 hs_cmpxchg64(StgWord x, StgWord64 old, StgWord64 new);
-StgWord64
-hs_cmpxchg64(StgWord x, StgWord64 old, StgWord64 new)
+StgWord64 hs_cmpxchg64(StgWord x, StgWord64 old, StgWord64 new)
{
StgWord64 expected = (StgWord64) old;
__atomic_compare_exchange_n((StgWord64 *) x, &expected, (StgWord64) new, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
@@ -313,31 +257,23 @@ hs_cmpxchg64(StgWord x, StgWord64 old, StgWord64 new)
// Atomic exchange operations
-extern StgWord hs_xchg8(StgWord x, StgWord val);
-StgWord
-hs_xchg8(StgWord x, StgWord val)
+StgWord hs_xchg8(StgWord x, StgWord val)
{
return (StgWord) __atomic_exchange_n((StgWord8 *) x, (StgWord8) val, __ATOMIC_SEQ_CST);
}
-extern StgWord hs_xchg16(StgWord x, StgWord val);
-StgWord
-hs_xchg16(StgWord x, StgWord val)
+StgWord hs_xchg16(StgWord x, StgWord val)
{
return (StgWord) __atomic_exchange_n((StgWord16 *)x, (StgWord16) val, __ATOMIC_SEQ_CST);
}
-extern StgWord hs_xchg32(StgWord x, StgWord val);
-StgWord
-hs_xchg32(StgWord x, StgWord val)
+StgWord hs_xchg32(StgWord x, StgWord val)
{
return (StgWord) __atomic_exchange_n((StgWord32 *) x, (StgWord32) val, __ATOMIC_SEQ_CST);
}
//GCC provides this even on 32bit, but StgWord is still 32 bits.
-extern StgWord64 hs_xchg64(StgWord x, StgWord64 val);
-StgWord64
-hs_xchg64(StgWord x, StgWord64 val)
+StgWord64 hs_xchg64(StgWord x, StgWord64 val)
{
return (StgWord64) __atomic_exchange_n((StgWord64 *) x, (StgWord64) val, __ATOMIC_SEQ_CST);
}
@@ -352,30 +288,22 @@ hs_xchg64(StgWord x, StgWord64 val)
// primitives which the GCC documentation claims "usually" implies a full
// barrier.
-extern StgWord hs_atomicread8(StgWord x);
-StgWord
-hs_atomicread8(StgWord x)
+StgWord hs_atomicread8(StgWord x)
{
return __atomic_load_n((StgWord8 *) x, __ATOMIC_SEQ_CST);
}
-extern StgWord hs_atomicread16(StgWord x);
-StgWord
-hs_atomicread16(StgWord x)
+StgWord hs_atomicread16(StgWord x)
{
return __atomic_load_n((StgWord16 *) x, __ATOMIC_SEQ_CST);
}
-extern StgWord hs_atomicread32(StgWord x);
-StgWord
-hs_atomicread32(StgWord x)
+StgWord hs_atomicread32(StgWord x)
{
return __atomic_load_n((StgWord32 *) x, __ATOMIC_SEQ_CST);
}
-extern StgWord64 hs_atomicread64(StgWord x);
-StgWord64
-hs_atomicread64(StgWord x)
+StgWord64 hs_atomicread64(StgWord x)
{
return __atomic_load_n((StgWord64 *) x, __ATOMIC_SEQ_CST);
}
@@ -384,30 +312,22 @@ hs_atomicread64(StgWord x)
// Implies a full memory barrier (see compiler/GHC/Builtin/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)
+void hs_atomicwrite8(StgWord x, StgWord val)
{
__atomic_store_n((StgWord8 *) x, (StgWord8) val, __ATOMIC_SEQ_CST);
}
-extern void hs_atomicwrite16(StgWord x, StgWord val);
-void
-hs_atomicwrite16(StgWord x, StgWord val)
+void hs_atomicwrite16(StgWord x, StgWord val)
{
__atomic_store_n((StgWord16 *) x, (StgWord16) val, __ATOMIC_SEQ_CST);
}
-extern void hs_atomicwrite32(StgWord x, StgWord val);
-void
-hs_atomicwrite32(StgWord x, StgWord val)
+void hs_atomicwrite32(StgWord x, StgWord val)
{
__atomic_store_n((StgWord32 *) x, (StgWord32) val, __ATOMIC_SEQ_CST);
}
-extern void hs_atomicwrite64(StgWord x, StgWord64 val);
-void
-hs_atomicwrite64(StgWord x, StgWord64 val)
+void hs_atomicwrite64(StgWord x, StgWord64 val)
{
__atomic_store_n((StgWord64 *) x, (StgWord64) val, __ATOMIC_SEQ_CST);
}
=====================================
libraries/ghc-internal/cbits/bitrev.c → rts/prim/bitrev.c
=====================================
@@ -27,7 +27,6 @@ For more information on how the below bit-twiddling functions came to be, see
page.
*/
-extern StgWord hs_bitrev8(StgWord x);
StgWord
hs_bitrev8(StgWord x)
{
@@ -37,7 +36,6 @@ hs_bitrev8(StgWord x)
return x;
}
-extern StgWord16 hs_bitrev16(StgWord16 x);
StgWord16
hs_bitrev16(StgWord16 x)
{
@@ -48,7 +46,6 @@ hs_bitrev16(StgWord16 x)
return x;
}
-extern StgWord32 hs_bitrev32(StgWord32 x);
StgWord32
hs_bitrev32(StgWord32 x)
{
@@ -60,7 +57,6 @@ hs_bitrev32(StgWord32 x)
return x;
}
-extern StgWord64 hs_bitrev64(StgWord64 x);
StgWord64
hs_bitrev64(StgWord64 x)
{
=====================================
libraries/ghc-internal/cbits/bswap.c → rts/prim/bswap.c
=====================================
@@ -1,13 +1,11 @@
#include "Rts.h"
-extern StgWord16 hs_bswap16(StgWord16 x);
StgWord16
hs_bswap16(StgWord16 x)
{
return ((x >> 8) | (x << 8));
}
-extern StgWord32 hs_bswap32(StgWord32 x);
StgWord32
hs_bswap32(StgWord32 x)
{
@@ -15,7 +13,6 @@ hs_bswap32(StgWord32 x)
(x << 24) | ((x & 0xff00) << 8));
}
-extern StgWord64 hs_bswap64(StgWord64 x);
StgWord64
hs_bswap64(StgWord64 x)
{
=====================================
libraries/ghc-internal/cbits/clz.c → rts/prim/clz.c
=====================================
=====================================
libraries/ghc-internal/cbits/ctz.c → rts/prim/ctz.c
=====================================
=====================================
libraries/ghc-internal/cbits/int64x2minmax.c → rts/prim/int64x2minmax.c
=====================================
@@ -1,4 +1,5 @@
#if defined(__SSE2__)
+#include "Rts.h"
#include
#include
#include
=====================================
libraries/ghc-internal/cbits/longlong.c → rts/prim/longlong.c
=====================================
=====================================
libraries/ghc-internal/cbits/mulIntMayOflo.c → rts/prim/mulIntMayOflo.c
=====================================
=====================================
libraries/ghc-internal/cbits/pdep.c → rts/prim/pdep.c
=====================================
=====================================
libraries/ghc-internal/cbits/pext.c → rts/prim/pext.c
=====================================
=====================================
libraries/ghc-internal/cbits/popcnt.c → rts/prim/popcnt.c
=====================================
@@ -13,14 +13,12 @@ static const unsigned char popcount_tab[] =
3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8,
};
-extern StgWord hs_popcnt8(StgWord x);
StgWord
hs_popcnt8(StgWord x)
{
return popcount_tab[(unsigned char)x];
}
-extern StgWord hs_popcnt16(StgWord x);
StgWord
hs_popcnt16(StgWord x)
{
@@ -28,7 +26,6 @@ hs_popcnt16(StgWord x)
popcount_tab[(unsigned char)(x >> 8)];
}
-extern StgWord hs_popcnt32(StgWord x);
StgWord
hs_popcnt32(StgWord x)
{
@@ -38,7 +35,6 @@ hs_popcnt32(StgWord x)
popcount_tab[(unsigned char)(x >> 24)];
}
-extern StgWord hs_popcnt64(StgWord64 x);
StgWord
hs_popcnt64(StgWord64 x)
{
@@ -54,7 +50,6 @@ hs_popcnt64(StgWord64 x)
#if WORD_SIZE_IN_BITS == 32
-extern StgWord hs_popcnt(StgWord x);
StgWord
hs_popcnt(StgWord x)
{
@@ -66,7 +61,6 @@ hs_popcnt(StgWord x)
#elif WORD_SIZE_IN_BITS == 64
-extern StgWord hs_popcnt(StgWord x);
StgWord
hs_popcnt(StgWord x)
{
=====================================
libraries/ghc-internal/cbits/vectorQuotRem.c → rts/prim/vectorQuotRem.c
=====================================
@@ -1,4 +1,5 @@
#if defined(__SSE2__)
+#include "Rts.h"
#include
#include
#include
=====================================
libraries/ghc-internal/cbits/word2float.c → rts/prim/word2float.c
=====================================
@@ -1,13 +1,11 @@
#include "Rts.h"
-extern StgFloat hs_word2float32(StgWord x);
StgFloat
hs_word2float32(StgWord x)
{
return x;
}
-extern StgDouble hs_word2float64(StgWord x);
StgDouble
hs_word2float64(StgWord x)
{
=====================================
rts/rts.cabal
=====================================
@@ -529,6 +529,19 @@ library
sm/Storage.c
sm/Sweep.c
fs.c
+ prim/atomic.c
+ prim/bitrev.c
+ prim/bswap.c
+ prim/clz.c
+ prim/ctz.c
+ prim/int64x2minmax.c
+ prim/longlong.c
+ prim/mulIntMayOflo.c
+ prim/pdep.c
+ prim/pext.c
+ prim/popcnt.c
+ prim/vectorQuotRem.c
+ prim/word2float.c
-- I wish we had wildcards..., this would be:
-- *.c hooks/**/*.c sm/**/*.c eventlog/**/*.c linker/**/*.c
=====================================
testsuite/tests/rts/T22859.hs
=====================================
@@ -42,7 +42,7 @@ main = do
takeMVar started
readMVar done
hFlush stderr
- threadDelay 1000
+ threadDelay 50000
-- default behaviour:
-- kill it after the limit is exceeded
hPutStrLn stderr "default behaviour"
@@ -68,5 +68,5 @@ main = do
hPutStrLn stderr "kill and log"
setGlobalAllocationLimitHandler KillOnAllocationLimit (Just $ \_ -> hPutStrLn stderr "allocation limit triggered 3")
runWorker
- threadDelay 1000
+ threadDelay 50000
hPutStrLn stderr "done"
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7deec054e6e55f101a032138d8bfa62...
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7deec054e6e55f101a032138d8bfa62...
You're receiving this email because of your account on gitlab.haskell.org.