blob: 47e1475e0e5ffeafad2d97089ddab4ea1b2725c5 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001# HG changeset patch
2# User Karsten Merker <merker@debian.org>
3# Date 1523974333 -7200
4# Node ID f47871e2aeb16b39d4f516690e25c81b04d6d05a
5# Parent 776db96f834cb86e8863052201d55f60a2da91cb
6Bug 1308584, Add type definitions for the RISC-V architecture, r=kaie
7
8Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9[ Changes by AF:
10 - Rebase on other Yocto patches
11]
12Upstream-Status: Backport [ https://hg.mozilla.org/projects/nspr/rev/f47871e2aeb1 ]
13
14diff --git a/pr/include/md/_linux.cfg b/pr/include/md/_linux.cfg
15--- a/pr/include/md/_linux.cfg
16+++ b/pr/include/md/_linux.cfg
17@@ -1015,16 +1015,108 @@
18 #define PR_ALIGN_OF_FLOAT 4
19 #define PR_ALIGN_OF_DOUBLE 4
20 #define PR_ALIGN_OF_POINTER 4
21 #define PR_ALIGN_OF_WORD 4
22
23 #define PR_BYTES_PER_WORD_LOG2 2
24 #define PR_BYTES_PER_DWORD_LOG2 3
25
26+#elif defined(__riscv) && (__riscv_xlen == 32)
27+
28+#undef IS_BIG_ENDIAN
29+#define IS_LITTLE_ENDIAN 1
30+#undef IS_64
31+
32+#define PR_BYTES_PER_BYTE 1
33+#define PR_BYTES_PER_SHORT 2
34+#define PR_BYTES_PER_INT 4
35+#define PR_BYTES_PER_INT64 8
36+#define PR_BYTES_PER_LONG 4
37+#define PR_BYTES_PER_FLOAT 4
38+#define PR_BYTES_PER_DOUBLE 8
39+#define PR_BYTES_PER_WORD 4
40+#define PR_BYTES_PER_DWORD 8
41+
42+#define PR_BITS_PER_BYTE 8
43+#define PR_BITS_PER_SHORT 16
44+#define PR_BITS_PER_INT 32
45+#define PR_BITS_PER_INT64 64
46+#define PR_BITS_PER_LONG 32
47+#define PR_BITS_PER_FLOAT 32
48+#define PR_BITS_PER_DOUBLE 64
49+#define PR_BITS_PER_WORD 32
50+
51+#define PR_BITS_PER_BYTE_LOG2 3
52+#define PR_BITS_PER_SHORT_LOG2 4
53+#define PR_BITS_PER_INT_LOG2 5
54+#define PR_BITS_PER_INT64_LOG2 6
55+#define PR_BITS_PER_LONG_LOG2 5
56+#define PR_BITS_PER_FLOAT_LOG2 5
57+#define PR_BITS_PER_DOUBLE_LOG2 6
58+#define PR_BITS_PER_WORD_LOG2 5
59+
60+#define PR_ALIGN_OF_SHORT 2
61+#define PR_ALIGN_OF_INT 4
62+#define PR_ALIGN_OF_LONG 4
63+#define PR_ALIGN_OF_INT64 8
64+#define PR_ALIGN_OF_FLOAT 4
65+#define PR_ALIGN_OF_DOUBLE 8
66+#define PR_ALIGN_OF_POINTER 4
67+#define PR_ALIGN_OF_WORD 4
68+
69+#define PR_BYTES_PER_WORD_LOG2 2
70+#define PR_BYTES_PER_DWORD_LOG2 3
71+
72+#elif defined(__riscv) && (__riscv_xlen == 64)
73+
74+#undef IS_BIG_ENDIAN
75+#define IS_LITTLE_ENDIAN 1
76+#define IS_64
77+
78+#define PR_BYTES_PER_BYTE 1
79+#define PR_BYTES_PER_SHORT 2
80+#define PR_BYTES_PER_INT 4
81+#define PR_BYTES_PER_INT64 8
82+#define PR_BYTES_PER_LONG 8
83+#define PR_BYTES_PER_FLOAT 4
84+#define PR_BYTES_PER_DOUBLE 8
85+#define PR_BYTES_PER_WORD 8
86+#define PR_BYTES_PER_DWORD 8
87+
88+#define PR_BITS_PER_BYTE 8
89+#define PR_BITS_PER_SHORT 16
90+#define PR_BITS_PER_INT 32
91+#define PR_BITS_PER_INT64 64
92+#define PR_BITS_PER_LONG 64
93+#define PR_BITS_PER_FLOAT 32
94+#define PR_BITS_PER_DOUBLE 64
95+#define PR_BITS_PER_WORD 64
96+
97+#define PR_BITS_PER_BYTE_LOG2 3
98+#define PR_BITS_PER_SHORT_LOG2 4
99+#define PR_BITS_PER_INT_LOG2 5
100+#define PR_BITS_PER_INT64_LOG2 6
101+#define PR_BITS_PER_LONG_LOG2 6
102+#define PR_BITS_PER_FLOAT_LOG2 5
103+#define PR_BITS_PER_DOUBLE_LOG2 6
104+#define PR_BITS_PER_WORD_LOG2 6
105+
106+#define PR_ALIGN_OF_SHORT 2
107+#define PR_ALIGN_OF_INT 4
108+#define PR_ALIGN_OF_LONG 8
109+#define PR_ALIGN_OF_INT64 8
110+#define PR_ALIGN_OF_FLOAT 4
111+#define PR_ALIGN_OF_DOUBLE 8
112+#define PR_ALIGN_OF_POINTER 8
113+#define PR_ALIGN_OF_WORD 8
114+
115+#define PR_BYTES_PER_WORD_LOG2 3
116+#define PR_BYTES_PER_DWORD_LOG2 3
117+
118 #else
119
120 #error "Unknown CPU architecture"
121
122 #endif
123
124 #ifndef HAVE_LONG_LONG
125 #define HAVE_LONG_LONG
126diff --git a/pr/include/md/_linux.h b/pr/include/md/_linux.h
127--- a/pr/include/md/_linux.h
128+++ b/pr/include/md/_linux.h
129@@ -54,16 +54,20 @@
130 #elif defined(__avr32__)
131 #define _PR_SI_ARCHITECTURE "avr32"
132 #elif defined(__m32r__)
133 #define _PR_SI_ARCHITECTURE "m32r"
134 #elif defined(__nios2__)
135 #define _PR_SI_ARCHITECTURE "nios2"
136 #elif defined(__or1k__)
137 #define _PR_SI_ARCHITECTURE "or1k"
138+#elif defined(__riscv) && (__riscv_xlen == 32)
139+#define _PR_SI_ARCHITECTURE "riscv32"
140+#elif defined(__riscv) && (__riscv_xlen == 64)
141+#define _PR_SI_ARCHITECTURE "riscv64"
142 #else
143 #error "Unknown CPU architecture"
144 #endif
145 #define PR_DLL_SUFFIX ".so"
146
147 #define _PR_VMBASE 0x30000000
148 #define _PR_STACK_VMBASE 0x50000000
149 #define _MD_DEFAULT_STACK_SIZE 65536L
150