From 64ad80e6d95871f17be4cd01da15581f41ac0b2b Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 27 May 2019 21:10:34 -0700
Subject: [PATCH] riscv: Disable atomic operations

This was ported from what was used with mozjs-60 which was
Signed-off-by: Khem Raj <raj.khem@gmail.com>

Upstream-Status: Inappropriate[old-version]

Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
---
 js/src/jit/AtomicOperations.h                          | 3 ++-
 js/src/jit/shared/AtomicOperations-feeling-lucky-gcc.h | 8 ++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/js/src/jit/AtomicOperations.h b/js/src/jit/AtomicOperations.h
index 0486cba..cf6b91c 100644
--- a/js/src/jit/AtomicOperations.h
+++ b/js/src/jit/AtomicOperations.h
@@ -391,7 +391,8 @@ inline bool AtomicOperations::isLockfreeJS(int32_t size) {
 #elif defined(__ppc__) || defined(__PPC__) || defined(__sparc__) ||     \
     defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) || \
     defined(__PPC64LE__) || defined(__alpha__) || defined(__hppa__) ||  \
-    defined(__sh__) || defined(__s390__) || defined(__s390x__)
+    defined(__sh__) || defined(__s390__) || defined(__s390x__) || \
+    defined(__riscv)
 #  include "jit/shared/AtomicOperations-feeling-lucky.h"
 #else
 #  error "No AtomicOperations support provided for this platform"
diff --git a/js/src/jit/shared/AtomicOperations-feeling-lucky-gcc.h b/js/src/jit/shared/AtomicOperations-feeling-lucky-gcc.h
index f002cd4..14bb5f9 100644
--- a/js/src/jit/shared/AtomicOperations-feeling-lucky-gcc.h
+++ b/js/src/jit/shared/AtomicOperations-feeling-lucky-gcc.h
@@ -77,6 +77,14 @@
 #  endif
 #endif
 
+#ifdef __riscv
+#  ifdef __riscv_xlen == 64
+#    define HAS_64BIT_ATOMICS
+#    define HAS_64BIT_LOCKFREE
+#  endif
+#endif
+
+
 // The default implementation tactic for gcc/clang is to use the newer __atomic
 // intrinsics added for use in C++11 <atomic>.  Where that isn't available, we
 // use GCC's older __sync functions instead.
-- 
2.31.1

