1From 64ad80e6d95871f17be4cd01da15581f41ac0b2b Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Mon, 27 May 2019 21:10:34 -0700
4Subject: [PATCH] riscv: Disable atomic operations
5
6This was ported from what was used with mozjs-60 which was
7Signed-off-by: Khem Raj <raj.khem@gmail.com>
8
9Upstream-Status: Inappropriate[old-version]
10
11Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
12---
13 js/src/jit/AtomicOperations.h                          | 3 ++-
14 js/src/jit/shared/AtomicOperations-feeling-lucky-gcc.h | 8 ++++++++
15 2 files changed, 10 insertions(+), 1 deletion(-)
16
17diff --git a/js/src/jit/AtomicOperations.h b/js/src/jit/AtomicOperations.h
18index 0486cba..cf6b91c 100644
19--- a/js/src/jit/AtomicOperations.h
20+++ b/js/src/jit/AtomicOperations.h
21@@ -391,7 +391,8 @@ inline bool AtomicOperations::isLockfreeJS(int32_t size) {
22 #elif defined(__ppc__) || defined(__PPC__) || defined(__sparc__) ||     \
23     defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) || \
24     defined(__PPC64LE__) || defined(__alpha__) || defined(__hppa__) ||  \
25-    defined(__sh__) || defined(__s390__) || defined(__s390x__)
26+    defined(__sh__) || defined(__s390__) || defined(__s390x__) || \
27+    defined(__riscv)
28 #  include "jit/shared/AtomicOperations-feeling-lucky.h"
29 #else
30 #  error "No AtomicOperations support provided for this platform"
31diff --git a/js/src/jit/shared/AtomicOperations-feeling-lucky-gcc.h b/js/src/jit/shared/AtomicOperations-feeling-lucky-gcc.h
32index f002cd4..14bb5f9 100644
33--- a/js/src/jit/shared/AtomicOperations-feeling-lucky-gcc.h
34+++ b/js/src/jit/shared/AtomicOperations-feeling-lucky-gcc.h
35@@ -77,6 +77,14 @@
36 #  endif
37 #endif
38
39+#ifdef __riscv
40+#  ifdef __riscv_xlen == 64
41+#    define HAS_64BIT_ATOMICS
42+#    define HAS_64BIT_LOCKFREE
43+#  endif
44+#endif
45+
46+
47 // The default implementation tactic for gcc/clang is to use the newer __atomic
48 // intrinsics added for use in C++11 <atomic>.  Where that isn't available, we
49 // use GCC's older __sync functions instead.
50--
512.31.1
52
53