[OE-core] [PATCH 3/4] recipes-support/nspr: Add RISC-V support
Alistair Francis
alistair.francis at wdc.com
Thu Jun 14 19:45:06 UTC 2018
Signed-off-by: Alistair Francis <alistair.francis at wdc.com>
---
.../0003-Add-riscv-architecture-support.patch | 103 ++++++++++++++++++
meta/recipes-support/nspr/nspr_4.19.bb | 1 +
2 files changed, 104 insertions(+)
create mode 100644 meta/recipes-support/nspr/nspr/0003-Add-riscv-architecture-support.patch
diff --git a/meta/recipes-support/nspr/nspr/0003-Add-riscv-architecture-support.patch b/meta/recipes-support/nspr/nspr/0003-Add-riscv-architecture-support.patch
new file mode 100644
index 0000000000..14911440bd
--- /dev/null
+++ b/meta/recipes-support/nspr/nspr/0003-Add-riscv-architecture-support.patch
@@ -0,0 +1,103 @@
+From ff3d77742bd3b0272c48ff7472a45e9c537709f2 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem at gmail.com>
+Date: Wed, 4 Oct 2017 11:55:10 -0700
+Subject: [PATCH] Add riscv architecture support
+
+Signed-off-by: Khem Raj <raj.khem at gmail.com>
+---
+ pr/include/md/_linux.cfg | 46 ++++++++++++++++++++++++++++++++++++++++++++++
+ pr/include/md/_linux.h | 14 ++++++++++++++
+ 2 files changed, 60 insertions(+)
+
+diff --git a/pr/include/md/_linux.cfg b/pr/include/md/_linux.cfg
+index 31296a8..d0dde57 100644
+--- a/pr/include/md/_linux.cfg
++++ b/pr/include/md/_linux.cfg
+@@ -360,6 +360,52 @@
+ #define PR_BYTES_PER_WORD_LOG2 2
+ #define PR_BYTES_PER_DWORD_LOG2 3
+
++#elif defined(__riscv) && __riscv_xlen == 64
++
++#undef IS_BIG_ENDIAN
++#define IS_LITTLE_ENDIAN 1
++#define IS_64
++
++#define PR_BYTES_PER_BYTE 1
++#define PR_BYTES_PER_SHORT 2
++#define PR_BYTES_PER_INT 4
++#define PR_BYTES_PER_INT64 8
++#define PR_BYTES_PER_LONG 8
++#define PR_BYTES_PER_FLOAT 4
++#define PR_BYTES_PER_DOUBLE 8
++#define PR_BYTES_PER_WORD 8
++#define PR_BYTES_PER_DWORD 8
++
++#define PR_BITS_PER_BYTE 8
++#define PR_BITS_PER_SHORT 16
++#define PR_BITS_PER_INT 32
++#define PR_BITS_PER_INT64 64
++#define PR_BITS_PER_LONG 64
++#define PR_BITS_PER_FLOAT 32
++#define PR_BITS_PER_DOUBLE 64
++#define PR_BITS_PER_WORD 64
++
++#define PR_BITS_PER_BYTE_LOG2 3
++#define PR_BITS_PER_SHORT_LOG2 4
++#define PR_BITS_PER_INT_LOG2 5
++#define PR_BITS_PER_INT64_LOG2 6
++#define PR_BITS_PER_LONG_LOG2 6
++#define PR_BITS_PER_FLOAT_LOG2 5
++#define PR_BITS_PER_DOUBLE_LOG2 6
++#define PR_BITS_PER_WORD_LOG2 6
++
++#define PR_ALIGN_OF_SHORT 2
++#define PR_ALIGN_OF_INT 4
++#define PR_ALIGN_OF_INT64 8
++#define PR_ALIGN_OF_LONG 8
++#define PR_ALIGN_OF_FLOAT 4
++#define PR_ALIGN_OF_DOUBLE 8
++#define PR_ALIGN_OF_POINTER 8
++#define PR_ALIGN_OF_WORD 8
++
++#define PR_BYTES_PER_WORD_LOG2 3
++#define PR_BYTES_PER_DWORD_LOG2 3
++
+ #elif defined(__sparc__) && defined (__arch64__)
+
+ #undef IS_LITTLE_ENDIAN
+diff --git a/pr/include/md/_linux.h b/pr/include/md/_linux.h
+index 551918f..3a3cc2e 100644
+--- a/pr/include/md/_linux.h
++++ b/pr/include/md/_linux.h
+@@ -31,6 +31,8 @@
+ #define _PR_SI_ARCHITECTURE "x86-64"
+ #elif defined(__mc68000__)
+ #define _PR_SI_ARCHITECTURE "m68k"
++#elif defined(__riscv) && __riscv_xlen == 64
++#define _PR_SI_ARCHITECTURE "rv64"
+ #elif defined(__sparc__) && defined(__arch64__)
+ #define _PR_SI_ARCHITECTURE "sparc64"
+ #elif defined(__sparc__)
+@@ -151,6 +153,18 @@ extern PRInt32 _PR_x86_64_AtomicSet(PRInt32 *val, PRInt32 newval);
+ #endif
+ #endif
+
++#if defined(__riscv)
++#if defined(__GNUC__)
++/* Use GCC built-in functions */
++#define _PR_HAVE_ATOMIC_OPS
++#define _MD_INIT_ATOMIC()
++#define _MD_ATOMIC_INCREMENT(ptr) __sync_add_and_fetch(ptr, 1)
++#define _MD_ATOMIC_DECREMENT(ptr) __sync_sub_and_fetch(ptr, 1)
++#define _MD_ATOMIC_ADD(ptr, i) __sync_add_and_fetch(ptr, i)
++#define _MD_ATOMIC_SET(ptr, nv) __sync_lock_test_and_set(ptr, nv)
++#endif
++#endif
++
+ #if defined(__powerpc__) && !defined(__powerpc64__)
+ #define _PR_HAVE_ATOMIC_OPS
+ #define _MD_INIT_ATOMIC()
+--
+2.14.2
+
diff --git a/meta/recipes-support/nspr/nspr_4.19.bb b/meta/recipes-support/nspr/nspr_4.19.bb
index de2c87131f..5c37509b1b 100644
--- a/meta/recipes-support/nspr/nspr_4.19.bb
+++ b/meta/recipes-support/nspr/nspr_4.19.bb
@@ -11,6 +11,7 @@ SRC_URI = "http://ftp.mozilla.org/pub/nspr/releases/v${PV}/src/nspr-${PV}.tar.gz
file://remove-srcdir-from-configure-in.patch \
file://0002-Add-nios2-support.patch \
file://0001-md-Fix-build-with-musl.patch \
+ file://0003-Add-riscv-architecture-support.patch \
file://nspr.pc.in \
"
--
2.17.1
More information about the Openembedded-core
mailing list