summaryrefslogtreecommitdiff
path: root/0001-add-loongarch-architecture.patch
blob: efaa7e01354cac3f3af072d57872de6b82ccc5c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
From 6ade473e440b2da11e6ecf6a69c4f1b309ab7624 Mon Sep 17 00:00:00 2001
From: wang--ge <wang__ge@126.com>
Date: Tue, 12 Apr 2022 19:47:14 +0800
Subject: [PATCH] add loongarch architecture

---
 configure.ac               |  2 +-
 include/private/gcconfig.h | 31 +++++++++++++++++++++++++++++++
 os_dep.c                   |  2 +-
 3 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 2bc1282..7cc02a9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -208,7 +208,7 @@ case "$THREADS" in
       *-*-aix* | *-*-android* | *-*-cygwin* | *-*-darwin* | *-*-dragonfly* | \
       *-*-freebsd* | *-*-haiku* | *-*-hpux11* | *-*-irix* | \
       *-*-kfreebsd*-gnu | *-*-gnu* | *-*-*linux* | *-*-msys* | *-*-nacl* | \
-      *-*-netbsd* | *-*-openbsd* | *-*-osf* | *-*-solaris*)
+      *-*-netbsd* | *-*-openbsd* | *-*-osf* | *-*-solaris* | loongarch*)
         AC_DEFINE(GC_THREADS)
         AC_DEFINE([_REENTRANT], [1],
                   [Required define if using POSIX threads.])
diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h
index b4457c1..5826ad5 100644
--- a/include/private/gcconfig.h
+++ b/include/private/gcconfig.h
@@ -226,6 +226,14 @@ EXTERN_C_BEGIN
 #    define VAX
 #    define mach_type_known
 # endif
+# if defined(__loongarch64)
+#    define LOONGARCH64
+#    define mach_type_known
+# endif
+# if defined(__loongarch64)
+#    define LOONGARCH64
+#    define mach_type_known
+# endif
 # if (defined(mips) || defined(__mips) || defined(_mips)) && !defined(__TANDEM)
 #    define MIPS
 #    if defined(nec_ews) || defined(_nec_ews)
@@ -518,6 +526,10 @@ EXTERN_C_BEGIN
 #   define AARCH64
 #   define mach_type_known
 # endif
+# if defined(FREEBSD) && (defined(__loongarch64) )
+#   define LOONGARCH64
+#   define mach_type_known
+# endif
 # if defined(FREEBSD) && (defined(mips) || defined(__mips) || defined(_mips))
 #   define MIPS
 #   define mach_type_known
@@ -1702,6 +1714,25 @@ EXTERN_C_BEGIN
 #   define STACKBOTTOM ((ptr_t)0xfffff000) /* for Encore */
 # endif

+# ifdef LOONGARCH64
+#   define MACH_TYPE "LOONGARCH64"
+#   ifdef LINUX
+#     define OS_TYPE "LINUX"
+#     define DYNAMIC_LOADING
+      extern int _end[];
+#     pragma weak __data_start
+      extern int __data_start[];
+#     define DATASTART ((ptr_t)(__data_start))
+#     define DATAEND ((ptr_t)(_end))
+#     define CPP_WORDSZ 64
+#     define ALIGNMENT (64/8)
+#     ifndef HBLKSIZE
+#       define HBLKSIZE 4096
+#     endif
+#     define LINUX_STACKBOTTOM
+#   endif
+# endif
+
 # ifdef LOONGARCH
 #   define MACH_TYPE "LoongArch"
 #   ifdef LINUX
diff --git a/os_dep.c b/os_dep.c
index e116ad0..947ac7f 100644
--- a/os_dep.c
+++ b/os_dep.c
@@ -3239,7 +3239,7 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void)
 #     ifndef SEGV_ACCERR
 #       define SEGV_ACCERR 2
 #     endif
-#     if defined(AARCH64) || defined(ARM32) || defined(MIPS) \
+#     if defined(AARCH64) || defined(ARM32) || defined(MIPS) || defined(LOONGARCH64) \
          || __FreeBSD__ >= 7
 #       define CODE_OK (si -> si_code == SEGV_ACCERR)
 #     elif defined(POWERPC)
--
2.27.0