[Git][ghc/ghc][wip/T22010] Finally fix atomic_inc64

Jaro Reinders (@Noughtmare) gitlab at gitlab.haskell.org
Thu Jun 15 12:20:19 UTC 2023



Jaro Reinders pushed to branch wip/T22010 at Glasgow Haskell Compiler / GHC


Commits:
f96bfd74 by Jaro Reinders at 2023-06-15T14:20:08+02:00
Finally fix atomic_inc64

- - - - -


1 changed file:

- compiler/cbits/genSym.c


Changes:

=====================================
compiler/cbits/genSym.c
=====================================
@@ -14,6 +14,20 @@ HsWord64 ghc_unique_counter = 0;
 HsInt ghc_unique_inc     = 1;
 #endif
 
+// This function has been added to the RTS. Here we pessimistically assume
+// that a threaded RTS is used. This function is only used for bootstrapping.
+#if !MIN_VERSION_GLASGOW_HASKELL(9,7,0,0)
+EXTERN_INLINE StgWord64
+atomic_inc64(StgWord64 volatile* p, StgWord64 incr)
+{
+#if defined(HAVE_C11_ATOMICS)
+    return __atomic_add_fetch(p, incr, __ATOMIC_SEQ_CST);
+#else
+    return __sync_add_and_fetch(p, incr);
+#endif
+}
+#endif
+
 #define UNIQUE_BITS (sizeof (HsWord64) * 8 - UNIQUE_TAG_BITS)
 #define UNIQUE_MASK ((1ULL << UNIQUE_BITS) - 1)
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f96bfd74d6a743181434e36319fa4caff4abb853

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f96bfd74d6a743181434e36319fa4caff4abb853
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230615/4d09aea5/attachment-0001.html>


More information about the ghc-commits mailing list