[Git][ghc/ghc][master] ghc-prim: fix hs_cmpxchg64 function prototype

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Tue Feb 28 10:59:29 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
9fa54572 by Cheng Shao at 2023-02-28T05:59:15-05:00
ghc-prim: fix hs_cmpxchg64 function prototype

hs_cmpxchg64 must return a StgWord64, otherwise incorrect runtime
results of 64-bit MO_Cmpxchg will appear in 32-bit unregisterised
builds, which go unnoticed at compile-time due to C implicit casting
in .hc files.

- - - - -


2 changed files:

- libraries/ghc-prim/cbits/atomic.c
- rts/include/stg/Prim.h


Changes:

=====================================
libraries/ghc-prim/cbits/atomic.c
=====================================
@@ -308,8 +308,8 @@ hs_cmpxchg32(StgWord x, StgWord old, StgWord new)
   return __sync_val_compare_and_swap((volatile StgWord32 *) x, (StgWord32) old, (StgWord32) new);
 }
 
-extern StgWord hs_cmpxchg64(StgWord x, StgWord64 old, StgWord64 new);
-StgWord
+extern StgWord64 hs_cmpxchg64(StgWord x, StgWord64 old, StgWord64 new);
+StgWord64
 hs_cmpxchg64(StgWord x, StgWord64 old, StgWord64 new)
 {
   return __sync_val_compare_and_swap((volatile StgWord64 *) x, old, new);


=====================================
rts/include/stg/Prim.h
=====================================
@@ -41,7 +41,7 @@ StgWord64 hs_atomic_xor64(StgWord x, StgWord64 val);
 StgWord hs_cmpxchg8(StgWord x, StgWord old, StgWord new_);
 StgWord hs_cmpxchg16(StgWord x, StgWord old, StgWord new_);
 StgWord hs_cmpxchg32(StgWord x, StgWord old, StgWord new_);
-StgWord hs_cmpxchg64(StgWord x, StgWord64 old, StgWord64 new_);
+StgWord64 hs_cmpxchg64(StgWord x, StgWord64 old, StgWord64 new_);
 StgWord hs_atomicread8(StgWord x);
 StgWord hs_atomicread16(StgWord x);
 StgWord hs_atomicread32(StgWord x);



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9fa545722f9151781344446dd5501db38cb90dd1
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/20230228/695b32be/attachment-0001.html>


More information about the ghc-commits mailing list