Sw64: Add Sw64 ISA support

(cherry picked from commit 7c7ae25b26c3c937686ae3f686a768532b14ec36)
This commit is contained in:
swcompiler 2024-12-16 14:02:35 -06:00 committed by openeuler-sync-bot
parent 4155650f66
commit 55189b18b5
24 changed files with 43743 additions and 1 deletions

View File

@ -0,0 +1,26 @@
From 7c6998e5e80b9690bf770ec093c7ae6a4a41a088 Mon Sep 17 00:00:00 2001
From: swcompiler <lc@wxiat.com>
Date: Fri, 29 Nov 2024 13:39:15 +0800
Subject: [PATCH 01/23] Sw64: Add Sw64 entries to config.h.in
---
config.h.in | 3 +++
1 file changed, 3 insertions(+)
diff --git a/config.h.in b/config.h.in
index 0dedc124..dbc566e5 100644
--- a/config.h.in
+++ b/config.h.in
@@ -29,6 +29,9 @@
/* On powerpc*, define if scv should be used for syscalls (when available). */
#undef USE_PPC_SCV
+/* Sw64 new Libc version */
+#undef HAVE_SW64_NEW_LIBCVERSION
+
/* Define if _Unwind_Find_FDE should be exported from glibc. */
#undef EXPORT_UNWIND_FIND_FDE
--
2.25.1

View File

@ -0,0 +1,173 @@
From 2abad8896fef244c5513d266184a1bfa32a5f509 Mon Sep 17 00:00:00 2001
From: swcompiler <lc@wxiat.com>
Date: Fri, 29 Nov 2024 13:39:58 +0800
Subject: [PATCH 02/23] Sw64: Add relocations and ELF flags to elf.h and
script/glibcelf.py
---
elf/elf.h | 79 +++++++++++++++++++++++++++++++++++++++++++++
scripts/glibcelf.py | 10 ++++++
2 files changed, 89 insertions(+)
diff --git a/elf/elf.h b/elf/elf.h
index 89fc8021..33a5e97b 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -371,6 +372,10 @@ typedef struct
chances of collision with official or non-GNU unofficial values. */
#define EM_ALPHA 0x9026
+#define EM_SW_64 0x9916
+
+
+
/* Legal values for e_version (version). */
@@ -2426,6 +2431,80 @@ enum
/* Legal values for d_tag of Elf64_Dyn. */
#define DT_ALPHA_PLTRO (DT_LOPROC + 0)
#define DT_ALPHA_NUM 1
+/* SW_64 specific definitions. */
+
+/* Legal values for e_flags field of Elf64_Ehdr. */
+
+#define EF_SW_64_32BIT 1 /* All addresses must be < 2GB. */
+#define EF_SW_64_CANRELAX 2 /* Relocations for relaxing exist. */
+
+/* Legal values for sh_type field of Elf64_Shdr. */
+
+/* These two are primerily concerned with ECOFF debugging info. */
+#define SHT_SW_64_DEBUG 0x70000001
+#define SHT_SW_64_REGINFO 0x70000002
+
+/* Legal values for sh_flags field of Elf64_Shdr. */
+
+#define SHF_SW_64_GPREL 0x10000000
+
+/* Legal values for st_other field of Elf64_Sym. */
+#define STO_SW_64_NOPV 0x80 /* No PV required. */
+#define STO_SW_64_STD_GPLOAD 0x88 /* PV only used for initial ldgp. */
+
+/* SW_64 relocs. */
+
+#define R_SW_64_NONE 0 /* No reloc */
+#define R_SW_64_REFLONG 1 /* Direct 32 bit */
+#define R_SW_64_REFQUAD 2 /* Direct 64 bit */
+#define R_SW_64_GPREL32 3 /* GP relative 32 bit */
+#define R_SW_64_LITERAL 4 /* GP relative 16 bit w/optimization */
+#define R_SW_64_LITUSE 5 /* Optimization hint for LITERAL */
+#define R_SW_64_GPDISP 6 /* Add displacement to GP */
+#define R_SW_64_BRADDR 7 /* PC+4 relative 23 bit shifted */
+#define R_SW_64_HINT 8 /* PC+4 relative 16 bit shifted */
+#define R_SW_64_SREL16 9 /* PC relative 16 bit */
+#define R_SW_64_SREL32 10 /* PC relative 32 bit */
+#define R_SW_64_SREL64 11 /* PC relative 64 bit */
+#define R_SW_64_GPRELHIGH 17 /* GP relative 32 bit, high 16 bits */
+#define R_SW_64_GPRELLOW 18 /* GP relative 32 bit, low 16 bits */
+#define R_SW_64_GPREL16 19 /* GP relative 16 bit */
+#define R_SW_64_COPY 24 /* Copy symbol at runtime */
+#define R_SW_64_GLOB_DAT 25 /* Create GOT entry */
+#define R_SW_64_JMP_SLOT 26 /* Create PLT entry */
+#define R_SW_64_RELATIVE 27 /* Adjust by program base */
+#define R_SW_64_TLS_GD_HI 28
+#define R_SW_64_TLSGD 29
+#define R_SW_64_TLS_LDM 30
+#define R_SW_64_DTPMOD64 31
+#define R_SW_64_GOTDTPREL 32
+#define R_SW_64_DTPREL64 33
+#define R_SW_64_DTPRELHI 34
+#define R_SW_64_DTPRELLO 35
+#define R_SW_64_DTPREL16 36
+#define R_SW_64_GOTTPREL 37
+#define R_SW_64_TPREL64 38
+#define R_SW_64_TPRELHI 39
+#define R_SW_64_TPRELLO 40
+#define R_SW_64_TPREL16 41
+/* Keep this the last entry. */
+#define R_SW_64_NUM 46
+
+/* Magic values of the LITUSE relocation addend. */
+#define LITUSE_SW_64_ADDR 0
+#define LITUSE_SW_64_BASE 1
+#define LITUSE_SW_64_BYTOFF 2
+#define LITUSE_SW_64_JSR 3
+#define LITUSE_SW_64_TLS_GD 4
+#define LITUSE_SW_64_TLS_LDM 5
+
+/* Legal values for d_tag of Elf64_Dyn. */
+#define DT_SW_64_PLTRO (DT_LOPROC + 0)
+#define DT_SW_64_NUM 1
+
+
+
+
/* PowerPC specific declarations */
diff --git a/scripts/glibcelf.py b/scripts/glibcelf.py
index b52e83d6..2c191afa 100644
--- a/scripts/glibcelf.py
+++ b/scripts/glibcelf.py
@@ -304,6 +304,8 @@ class Sht(_TypedConstant):
prefix = 'SHT_'
class ShtALPHA(Sht):
"""Supplemental SHT_* constants for EM_ALPHA."""
+class ShtSW_64(Sht):
+ """Supplemental SHT_* constants for EM_SW_64."""
class ShtARC(Sht):
"""Supplemental SHT_* constants for EM_ARC."""
class ShtARM(Sht):
@@ -319,6 +321,7 @@ class ShtPARISC(Sht):
class ShtRISCV(Sht):
"""Supplemental SHT_* constants for EM_RISCV."""
_register_elf_h(ShtALPHA, prefix='SHT_ALPHA_', parent=Sht)
+_register_elf_h(ShtSW_64, prefix='SHT_SW_64_', parent=Sht)
_register_elf_h(ShtARC, prefix='SHT_ARC_', parent=Sht)
_register_elf_h(ShtARM, prefix='SHT_ARM_', parent=Sht)
_register_elf_h(ShtCSKY, prefix='SHT_CSKY_', parent=Sht)
@@ -354,6 +357,8 @@ class Shf(_FlagConstant):
prefix = 'SHF_'
class ShfALPHA(Shf):
"""Supplemental SHF_* constants for EM_ALPHA."""
+class ShfSW_64(Shf):
+ """Supplemental SHF_* constants for EM_SW_64."""
class ShfARM(Shf):
"""Supplemental SHF_* constants for EM_ARM."""
class ShfIA_64(Shf):
@@ -363,6 +368,7 @@ class ShfMIPS(Shf):
class ShfPARISC(Shf):
"""Supplemental SHF_* constants for EM_PARISC."""
_register_elf_h(ShfALPHA, prefix='SHF_ALPHA_', parent=Shf)
+_register_elf_h(ShfSW_64, prefix='SHF_SW_64_', parent=Shf)
_register_elf_h(ShfARM, prefix='SHF_ARM_', parent=Shf)
_register_elf_h(ShfIA_64, prefix='SHF_IA_64_', parent=Shf)
_register_elf_h(ShfMIPS, prefix='SHF_MIPS_', parent=Shf)
@@ -425,6 +431,8 @@ class DtAARCH64(Dt):
"""Supplemental DT_* constants for EM_AARCH64."""
class DtALPHA(Dt):
"""Supplemental DT_* constants for EM_ALPHA."""
+class DtSW_64(Dt):
+ """Supplemental DT_* constants for EM_SW_64."""
class DtALTERA_NIOS2(Dt):
"""Supplemental DT_* constants for EM_ALTERA_NIOS2."""
class DtIA_64(Dt):
@@ -446,6 +454,7 @@ DT_VALRNGLO DT_VALRNGHI DT_VALNUM
DT_VERSIONTAGNUM DT_EXTRANUM
DT_AARCH64_NUM
DT_ALPHA_NUM
+DT_SW_64_NUM
DT_IA_64_NUM
DT_MIPS_NUM
DT_PPC_NUM
@@ -454,6 +463,7 @@ DT_SPARC_NUM
'''.strip().split()
_register_elf_h(DtAARCH64, prefix='DT_AARCH64_', skip=_dt_skip, parent=Dt)
_register_elf_h(DtALPHA, prefix='DT_ALPHA_', skip=_dt_skip, parent=Dt)
+_register_elf_h(DtSW_64, prefix='DT_SW_64_', skip=_dt_skip, parent=Dt)
_register_elf_h(DtALTERA_NIOS2, prefix='DT_NIOS2_', skip=_dt_skip, parent=Dt)
_register_elf_h(DtIA_64, prefix='DT_IA_64_', skip=_dt_skip, parent=Dt)
_register_elf_h(DtMIPS, prefix='DT_MIPS_', skip=_dt_skip, parent=Dt)
--
2.25.1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,356 @@
From 20affa072418646ada75247771c28633ac47688c Mon Sep 17 00:00:00 2001
From: swcompiler <lc@wxiat.com>
Date: Fri, 29 Nov 2024 13:55:34 +0800
Subject: [PATCH 04/23] Sw64: Thread-Local Storage Support
---
sysdeps/sw_64/dl-tls.h | 26 ++++++++
sysdeps/sw_64/libc-tls.c | 32 ++++++++++
sysdeps/sw_64/nptl/tls.h | 108 ++++++++++++++++++++++++++++++++++
sysdeps/sw_64/stackinfo.h | 33 +++++++++++
sysdeps/sw_64/sw8a/nptl/tls.h | 106 +++++++++++++++++++++++++++++++++
5 files changed, 305 insertions(+)
create mode 100644 sysdeps/sw_64/dl-tls.h
create mode 100644 sysdeps/sw_64/libc-tls.c
create mode 100644 sysdeps/sw_64/nptl/tls.h
create mode 100644 sysdeps/sw_64/stackinfo.h
create mode 100644 sysdeps/sw_64/sw8a/nptl/tls.h
diff --git a/sysdeps/sw_64/dl-tls.h b/sysdeps/sw_64/dl-tls.h
new file mode 100644
index 00000000..0795a41a
--- /dev/null
+++ b/sysdeps/sw_64/dl-tls.h
@@ -0,0 +1,26 @@
+/* Thread-local storage handling in the ELF dynamic linker. Sw_64 version.
+ Copyright (C) 2002-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* Type used for the representation of TLS information in the GOT. */
+typedef struct
+{
+ unsigned long int ti_module;
+ unsigned long int ti_offset;
+} tls_index;
+
+extern void *__tls_get_addr (tls_index *ti);
diff --git a/sysdeps/sw_64/libc-tls.c b/sysdeps/sw_64/libc-tls.c
new file mode 100644
index 00000000..f268dd08
--- /dev/null
+++ b/sysdeps/sw_64/libc-tls.c
@@ -0,0 +1,32 @@
+/* Thread-local storage handling in the ELF dynamic linker. Sw_64 version.
+ Copyright (C) 2003-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <csu/libc-tls.c>
+#include <dl-tls.h>
+
+/* On Sw_64, linker optimizations are not required, so __tls_get_addr
+ can be called even in statically linked binaries. In this case module
+ must be always 1 and PT_TLS segment exist in the binary, otherwise it
+ would not link. */
+
+void *
+__tls_get_addr (tls_index *ti)
+{
+ dtv_t *dtv = THREAD_DTV ();
+ return (char *) dtv[1].pointer.val + ti->ti_offset;
+}
diff --git a/sysdeps/sw_64/nptl/tls.h b/sysdeps/sw_64/nptl/tls.h
new file mode 100644
index 00000000..8df86916
--- /dev/null
+++ b/sysdeps/sw_64/nptl/tls.h
@@ -0,0 +1,108 @@
+/* Definition for thread-local data handling. NPTL/Sw_64 version.
+ Copyright (C) 2003-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _TLS_H
+#define _TLS_H 1
+
+#include <dl-sysdep.h>
+
+#ifndef __ASSEMBLER__
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+# include <dl-dtv.h>
+
+/* Get system call information. */
+# include <sysdep.h>
+
+/* The TP points to the start of the thread blocks. */
+# define TLS_DTV_AT_TP 1
+# define TLS_TCB_AT_TP 0
+
+/* Get the thread descriptor definition. */
+# include <nptl/descr.h>
+
+typedef struct
+{
+ dtv_t *dtv;
+ void *__private;
+} tcbhead_t;
+
+/* This is the size of the initial TCB. */
+# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
+
+/* This is the size of the TCB. */
+# define TLS_TCB_SIZE sizeof (tcbhead_t)
+
+/* This is the size we need before TCB. */
+# define TLS_PRE_TCB_SIZE sizeof (struct pthread)
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(tcbp, dtvp) (((tcbhead_t *) (tcbp))->dtv = (dtvp) + 1)
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(dtv) (THREAD_DTV () = (dtv))
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(tcbp) (((tcbhead_t *) (tcbp))->dtv)
+
+/* Code to initially initialize the thread pointer. This might need
+ special attention since 'errno' is not yet available and if the
+ operation can cause a failure 'errno' must not be touched. */
+# define TLS_INIT_TP(tcbp) \
+ (__builtin_set_thread_pointer ((void *) (tcbp)), true)
+
+/* Value passed to 'clone' for initialization of the thread register. */
+# define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() (((tcbhead_t *) __builtin_thread_pointer ())->dtv)
+
+/* Return the thread descriptor for the current thread. */
+# define THREAD_SELF ((struct pthread *) __builtin_thread_pointer () - 1)
+
+/* Magic for libthread_db to know how to do THREAD_SELF. */
+# define DB_THREAD_SELF REGISTER (64, 64, 32 * 8, -sizeof (struct pthread))
+
+# include <tcb-access.h>
+
+/* Get and set the global scope generation counter in struct pthread. */
+# define THREAD_GSCOPE_FLAG_UNUSED 0
+# define THREAD_GSCOPE_FLAG_USED 1
+# define THREAD_GSCOPE_FLAG_WAIT 2
+# define THREAD_GSCOPE_RESET_FLAG() \
+ do \
+ { \
+ int __res = atomic_exchange_release ( \
+ &THREAD_SELF->header.gscope_flag, THREAD_GSCOPE_FLAG_UNUSED); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
+ } \
+ while (0)
+# define THREAD_GSCOPE_SET_FLAG() \
+ do \
+ { \
+ THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \
+ atomic_write_barrier (); \
+ } \
+ while (0)
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* tls.h */
diff --git a/sysdeps/sw_64/stackinfo.h b/sysdeps/sw_64/stackinfo.h
new file mode 100644
index 00000000..661a814a
--- /dev/null
+++ b/sysdeps/sw_64/stackinfo.h
@@ -0,0 +1,33 @@
+/* Copyright (C) 2001-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <https://www.gnu.org/licenses/>. */
+
+/* This file contains a bit of information about the stack allocation
+ of the processor. */
+
+#ifndef _STACKINFO_H
+#define _STACKINFO_H 1
+
+#include <elf.h>
+
+/* On Sw_64 the stack grows down. */
+#define _STACK_GROWS_DOWN 1
+
+/* Default to an executable stack. PF_X can be overridden if PT_GNU_STACK is
+ * present, but it is presumed absent. */
+#define DEFAULT_STACK_PERMS (PF_R | PF_W | PF_X)
+
+#endif /* stackinfo.h */
diff --git a/sysdeps/sw_64/sw8a/nptl/tls.h b/sysdeps/sw_64/sw8a/nptl/tls.h
new file mode 100644
index 00000000..d0942c19
--- /dev/null
+++ b/sysdeps/sw_64/sw8a/nptl/tls.h
@@ -0,0 +1,106 @@
+/* Definition for thread-local data handling. NPTL/Sw_64 version.
+ Copyright (C) 2003-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _TLS_H
+#define _TLS_H 1
+
+#include <dl-sysdep.h>
+
+#ifndef __ASSEMBLER__
+# include <stdbool.h>
+# include <stddef.h>
+# include <stdint.h>
+# include <dl-dtv.h>
+
+/* Get system call information. */
+# include <sysdep.h>
+
+/* The TP points to the start of the thread blocks. */
+# define TLS_DTV_AT_TP 1
+# define TLS_TCB_AT_TP 0
+
+/* Get the thread descriptor definition. */
+# include <nptl/descr.h>
+
+typedef struct
+{
+ dtv_t *dtv;
+ void *__private;
+} tcbhead_t;
+
+/* This is the size of the initial TCB. */
+# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
+
+/* This is the size of the TCB. */
+# define TLS_TCB_SIZE sizeof (tcbhead_t)
+
+/* This is the size we need before TCB. */
+# define TLS_PRE_TCB_SIZE sizeof (struct pthread)
+
+/* Install the dtv pointer. The pointer passed is to the element with
+ index -1 which contain the length. */
+# define INSTALL_DTV(tcbp, dtvp) (((tcbhead_t *) (tcbp))->dtv = (dtvp) + 1)
+
+/* Install new dtv for current thread. */
+# define INSTALL_NEW_DTV(dtv) (THREAD_DTV () = (dtv))
+
+/* Return dtv of given thread descriptor. */
+# define GET_DTV(tcbp) (((tcbhead_t *) (tcbp))->dtv)
+
+/* Code to initially initialize the thread pointer. This might need
+ special attention since 'errno' is not yet available and if the
+ operation can cause a failure 'errno' must not be touched. */
+# define TLS_INIT_TP(tcbp) \
+ (__builtin_set_thread_pointer ((void *) (tcbp)), true)
+
+/* Value passed to 'clone' for initialization of the thread register. */
+# define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1
+
+/* Return the address of the dtv for the current thread. */
+# define THREAD_DTV() (((tcbhead_t *) __builtin_thread_pointer ())->dtv)
+
+/* Return the thread descriptor for the current thread. */
+# define THREAD_SELF ((struct pthread *) __builtin_thread_pointer () - 1)
+
+/* Magic for libthread_db to know how to do THREAD_SELF. */
+# define DB_THREAD_SELF REGISTER (64, 64, 32 * 8, -sizeof (struct pthread))
+
+# include <tcb-access.h>
+# define THREAD_GSCOPE_FLAG_UNUSED 0
+# define THREAD_GSCOPE_FLAG_USED 1
+# define THREAD_GSCOPE_FLAG_WAIT 2
+# define THREAD_GSCOPE_RESET_FLAG() \
+ do \
+ { \
+ int __res = atomic_exchange_rel (&THREAD_SELF->header.gscope_flag, \
+ THREAD_GSCOPE_FLAG_UNUSED); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE); \
+ } \
+ while (0)
+# define THREAD_GSCOPE_SET_FLAG() \
+ do \
+ { \
+ THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \
+ atomic_write_barrier (); \
+ } \
+ while (0)
+
+#endif /* __ASSEMBLER__ */
+
+#endif /* tls.h */
--
2.25.1

View File

@ -0,0 +1,356 @@
From cdac1f3a59bcd4bdad675f7c352aefa03d237f96 Mon Sep 17 00:00:00 2001
From: swcompiler <lc@wxiat.com>
Date: Fri, 29 Nov 2024 14:19:24 +0800
Subject: [PATCH 05/23] Sw64: Generic <math.h> and soft-fp Routines
---
sysdeps/sw_64/fpu/bits/fenv.h | 140 ++++++++++++++++++++++++++++++++++
sysdeps/sw_64/local-soft-fp.h | 67 ++++++++++++++++
sysdeps/sw_64/sfp-machine.h | 105 +++++++++++++++++++++++++
sysdeps/sw_64/tininess.h | 1 +
4 files changed, 313 insertions(+)
create mode 100644 sysdeps/sw_64/fpu/bits/fenv.h
create mode 100644 sysdeps/sw_64/local-soft-fp.h
create mode 100644 sysdeps/sw_64/sfp-machine.h
create mode 100644 sysdeps/sw_64/tininess.h
diff --git a/sysdeps/sw_64/fpu/bits/fenv.h b/sysdeps/sw_64/fpu/bits/fenv.h
new file mode 100644
index 00000000..ec5dfb8d
--- /dev/null
+++ b/sysdeps/sw_64/fpu/bits/fenv.h
@@ -0,0 +1,140 @@
+/* Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _FENV_H
+# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
+#endif
+
+/* Define the bits representing the exception.
+
+ Note that these are the bit positions as defined by the OSF/1
+ ieee_{get,set}_control_word interface and not by the hardware fpcr.
+
+ See the Sw_64 Architecture Handbook section 4.7.7.3 for details,
+ but in summary, trap shadows mean the hardware register can acquire
+ extra exception bits so for proper IEEE support the tracking has to
+ be done in software -- in this case with kernel support.
+
+ As to why the system call interface isn't in the same format as
+ the hardware register, only those crazy folks at DEC can tell you. */
+
+enum
+{
+#ifdef __USE_GNU
+ FE_DENORMAL =
+# define FE_DENORMAL (1 << 22)
+ FE_DENORMAL,
+#endif
+
+ FE_INEXACT =
+#define FE_INEXACT (1 << 21)
+ FE_INEXACT,
+
+ FE_UNDERFLOW =
+#define FE_UNDERFLOW (1 << 20)
+ FE_UNDERFLOW,
+
+ FE_OVERFLOW =
+#define FE_OVERFLOW (1 << 19)
+ FE_OVERFLOW,
+
+ FE_DIVBYZERO =
+#define FE_DIVBYZERO (1 << 18)
+ FE_DIVBYZERO,
+
+ FE_INVALID =
+#define FE_INVALID (1 << 17)
+ FE_INVALID,
+
+ FE_ALL_EXCEPT =
+#define FE_ALL_EXCEPT (0x3f << 17)
+ FE_ALL_EXCEPT
+};
+
+/* Sw_64 chips support all four defined rouding modes.
+
+ Note that code must be compiled to use dynamic rounding (/d) instructions
+ to see these changes. For gcc this is -mfp-rounding-mode=d; for DEC cc
+ this is -fprm d. The default for both is static rounding to nearest.
+
+ These are shifted down 58 bits from the hardware fpcr because the
+ functions are declared to take integers. */
+
+enum
+{
+ FE_TOWARDZERO =
+#define FE_TOWARDZERO 0
+ FE_TOWARDZERO,
+
+ FE_DOWNWARD =
+#define FE_DOWNWARD 1
+ FE_DOWNWARD,
+
+ FE_TONEAREST =
+#define FE_TONEAREST 2
+ FE_TONEAREST,
+
+ FE_UPWARD =
+#define FE_UPWARD 3
+ FE_UPWARD,
+};
+
+#ifdef __USE_GNU
+/* On later hardware, and later kernels for earlier hardware, we can forcibly
+ underflow denormal inputs and outputs. This can speed up certain programs
+ significantly, usually without affecting accuracy. */
+enum
+{
+ FE_MAP_DMZ = 1UL << 12, /* Map denorm inputs to zero */
+# define FE_MAP_DMZ FE_MAP_DMZ
+
+ FE_MAP_UMZ = 1UL << 13, /* Map underflowed outputs to zero */
+# define FE_MAP_UMZ FE_MAP_UMZ
+};
+#endif
+
+/* Type representing exception flags. */
+typedef unsigned long int fexcept_t;
+
+/* Type representing floating-point environment. */
+typedef unsigned long int fenv_t;
+
+/* If the default argument is used we use this value. Note that due to
+ architecture-specified page mappings, no user-space pointer will ever
+ have its two high bits set. Co-opt one. */
+#define FE_DFL_ENV ((const fenv_t *) 0x8800000000000000UL)
+
+#ifdef __USE_GNU
+/* Floating-point environment where none of the exceptions are masked. */
+# define FE_NOMASK_ENV ((const fenv_t *) 0x880000000000003eUL)
+
+/* Floating-point environment with (processor-dependent) non-IEEE floating
+ point. In this case, mapping denormals to zero. */
+# define FE_NONIEEE_ENV ((const fenv_t *) 0x8800000000003000UL)
+#endif
+
+/* The system calls to talk to the kernel's FP code. */
+extern unsigned long int __ieee_get_fp_control (void) __THROW;
+extern void __ieee_set_fp_control (unsigned long int __value) __THROW;
+
+#if __GLIBC_USE (IEC_60559_BFP_EXT_C2X)
+/* Type representing floating-point control modes. */
+typedef unsigned long int femode_t;
+
+/* Default floating-point control modes. */
+# define FE_DFL_MODE ((const femode_t *) 0x8800000000000000UL)
+#endif
diff --git a/sysdeps/sw_64/local-soft-fp.h b/sysdeps/sw_64/local-soft-fp.h
new file mode 100644
index 00000000..aab93c30
--- /dev/null
+++ b/sysdeps/sw_64/local-soft-fp.h
@@ -0,0 +1,67 @@
+#include <stdlib.h>
+#include <soft-fp.h>
+#include <quad.h>
+
+/* Helpers for the Ots functions which receive long double arguments
+ in two integer registers, and return values in $16+$17. */
+
+#define AXP_UNPACK_RAW_Q(X, val) \
+ do \
+ { \
+ union _FP_UNION_Q _flo; \
+ _flo.longs.a = val##l; \
+ _flo.longs.b = val##h; \
+ FP_UNPACK_RAW_QP (X, &_flo); \
+ } \
+ while (0)
+
+#define AXP_UNPACK_SEMIRAW_Q(X, val) \
+ do \
+ { \
+ union _FP_UNION_Q _flo; \
+ _flo.longs.a = val##l; \
+ _flo.longs.b = val##h; \
+ FP_UNPACK_SEMIRAW_QP (X, &_flo); \
+ } \
+ while (0)
+
+#define AXP_UNPACK_Q(X, val) \
+ do \
+ { \
+ AXP_UNPACK_RAW_Q (X, val); \
+ _FP_UNPACK_CANONICAL (Q, 2, X); \
+ } \
+ while (0)
+
+#define AXP_PACK_RAW_Q(val, X) FP_PACK_RAW_QP (&val##_flo, X)
+
+#define AXP_PACK_SEMIRAW_Q(val, X) \
+ do \
+ { \
+ _FP_PACK_SEMIRAW (Q, 2, X); \
+ AXP_PACK_RAW_Q (val, X); \
+ } \
+ while (0)
+
+#define AXP_PACK_Q(val, X) \
+ do \
+ { \
+ _FP_PACK_CANONICAL (Q, 2, X); \
+ AXP_PACK_RAW_Q (val, X); \
+ } \
+ while (0)
+
+#define AXP_DECL_RETURN_Q(X) union _FP_UNION_Q X##_flo
+
+/* ??? We don't have a real way to tell the compiler that we're wanting
+ to return values in $16+$17. Instead use a volatile asm to make sure
+ that the values are live, and just hope that nothing kills the values
+ in between here and the end of the function. */
+#define AXP_RETURN_Q(X) \
+ do \
+ { \
+ register long r16 __asm__ ("16") = X##_flo.longs.a; \
+ register long r17 __asm__ ("17") = X##_flo.longs.b; \
+ asm volatile ("" : : "r"(r16), "r"(r17)); \
+ } \
+ while (0)
diff --git a/sysdeps/sw_64/sfp-machine.h b/sysdeps/sw_64/sfp-machine.h
new file mode 100644
index 00000000..119e50fc
--- /dev/null
+++ b/sysdeps/sw_64/sfp-machine.h
@@ -0,0 +1,105 @@
+/* Machine-dependent software floating-point definitions.
+ Sw_64 userland IEEE 128-bit version.
+ Copyright (C) 2004-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com),
+ Jakub Jelinek (jj@ultra.linux.cz) and
+ David S. Miller (davem@redhat.com).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <fenv_libc.h>
+
+#define _FP_W_TYPE_SIZE 64
+#define _FP_W_TYPE unsigned long
+#define _FP_WS_TYPE signed long
+#define _FP_I_TYPE long
+
+#define _FP_MUL_MEAT_S(R, X, Y) _FP_MUL_MEAT_1_imm (_FP_WFRACBITS_S, R, X, Y)
+#define _FP_MUL_MEAT_D(R, X, Y) \
+ _FP_MUL_MEAT_1_wide (_FP_WFRACBITS_D, R, X, Y, umul_ppmm)
+#define _FP_MUL_MEAT_Q(R, X, Y) \
+ _FP_MUL_MEAT_2_wide (_FP_WFRACBITS_Q, R, X, Y, umul_ppmm)
+
+#define _FP_DIV_MEAT_S(R, X, Y) \
+ _FP_DIV_MEAT_1_imm (S, R, X, Y, _FP_DIV_HELP_imm)
+#define _FP_DIV_MEAT_D(R, X, Y) _FP_DIV_MEAT_1_udiv_norm (D, R, X, Y)
+#define _FP_DIV_MEAT_Q(R, X, Y) _FP_DIV_MEAT_2_udiv (Q, R, X, Y)
+
+#define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1)
+#define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1)
+#define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1
+#define _FP_NANSIGN_S 0
+#define _FP_NANSIGN_D 0
+#define _FP_NANSIGN_Q 0
+
+#define _FP_KEEPNANFRACP 1
+#define _FP_QNANNEGATEDP 0
+
+/* Sw_64 Architecture Handbook, 4.7.10.4 sez that we should prefer any
+ type of NaN in Fb, then Fa. */
+#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
+ do \
+ { \
+ R##_s = Y##_s; \
+ _FP_FRAC_COPY_##wc (R, X); \
+ R##_c = FP_CLS_NAN; \
+ } \
+ while (0)
+
+/* Rounding mode settings. */
+#define FP_RND_NEAREST FE_TONEAREST
+#define FP_RND_ZERO FE_TOWARDZERO
+#define FP_RND_PINF FE_UPWARD
+#define FP_RND_MINF FE_DOWNWARD
+
+/* Obtain the current rounding mode. It's given as an argument to
+ all the Ots functions, with 4 meaning "dynamic". */
+#define FP_ROUNDMODE _round
+
+/* Exception flags. */
+#define FP_EX_INVALID FE_INVALID
+#define FP_EX_OVERFLOW FE_OVERFLOW
+#define FP_EX_UNDERFLOW FE_UNDERFLOW
+#define FP_EX_DIVZERO FE_DIVBYZERO
+#define FP_EX_INEXACT FE_INEXACT
+
+#define _FP_TININESS_AFTER_ROUNDING 1
+
+#define FP_INIT_ROUNDMODE \
+ do \
+ { \
+ if (__builtin_expect (_round == 4, 0)) \
+ { \
+ unsigned long t; \
+ __asm__ __volatile__("excb; rfpcr %0" : "=f"(t)); \
+ _round = (t >> FPCR_ROUND_SHIFT) & 3; \
+ } \
+ } \
+ while (0)
+
+/* We copy the libm function into libc for soft-fp. */
+extern int __feraiseexcept (int __excepts) attribute_hidden;
+
+#define FP_HANDLE_EXCEPTIONS \
+ do \
+ { \
+ if (__builtin_expect (_fex, 0)) \
+ __feraiseexcept (_fex); \
+ } \
+ while (0)
+
+#define FP_TRAPPING_EXCEPTIONS \
+ ((__ieee_get_fp_control () & SWCR_ENABLE_MASK) << SWCR_ENABLE_SHIFT)
diff --git a/sysdeps/sw_64/tininess.h b/sysdeps/sw_64/tininess.h
new file mode 100644
index 00000000..90956c35
--- /dev/null
+++ b/sysdeps/sw_64/tininess.h
@@ -0,0 +1 @@
+#define TININESS_AFTER_ROUNDING 1
--
2.25.1

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

7444
0008-Sw64-Linux-ABI.patch Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,706 @@
From bf639b376e38c144df5005a258f0bd2b9c72912f Mon Sep 17 00:00:00 2001
From: swcompiler <lc@wxiat.com>
Date: Fri, 29 Nov 2024 14:14:00 +0800
Subject: [PATCH 10/23] Sw64: Build Infrastructure
---
Makerules | 14 +++
configure | 23 ++++
elf/tst-glibcelf.py | 1 +
scripts/config.guess | 51 +++++++++
scripts/config.sub | 1 +
sysdeps/sw_64/Implies | 5 +
sysdeps/sw_64/Makefile | 70 ++++++++++++
sysdeps/sw_64/Subdirs | 1 +
sysdeps/sw_64/Versions | 23 ++++
sysdeps/sw_64/configure | 26 +++++
sysdeps/sw_64/configure.ac | 18 +++
sysdeps/sw_64/fpu/Versions | 23 ++++
sysdeps/sw_64/preconfigure | 3 +
sysdeps/sw_64/sw6a/Implies | 1 +
sysdeps/sw_64/sw6b/Implies | 1 +
sysdeps/sw_64/sw8a/Implies | 1 +
sysdeps/sw_64/sw8a/nptl/Makefile | 20 ++++
sysdeps/unix/sysv/linux/sw_64/Implies | 5 +
sysdeps/unix/sysv/linux/sw_64/Makefile | 36 ++++++
sysdeps/unix/sysv/linux/sw_64/Versions | 105 ++++++++++++++++++
sysdeps/unix/sysv/linux/sw_64/configure | 5 +
sysdeps/unix/sysv/linux/sw_64/configure.ac | 5 +
sysdeps/unix/sysv/linux/sw_64/fpu/Implies | 2 +
.../unix/sysv/linux/sw_64/sw6a/fpu/Implies | 2 +
.../unix/sysv/linux/sw_64/sw6b/fpu/Implies | 2 +
.../unix/sysv/linux/sw_64/sw8a/fpu/Implies | 2 +
26 files changed, 446 insertions(+)
create mode 100644 sysdeps/sw_64/Implies
create mode 100644 sysdeps/sw_64/Makefile
create mode 100644 sysdeps/sw_64/Subdirs
create mode 100644 sysdeps/sw_64/Versions
create mode 100644 sysdeps/sw_64/configure
create mode 100644 sysdeps/sw_64/configure.ac
create mode 100644 sysdeps/sw_64/fpu/Versions
create mode 100644 sysdeps/sw_64/preconfigure
create mode 100644 sysdeps/sw_64/sw6a/Implies
create mode 100644 sysdeps/sw_64/sw6b/Implies
create mode 100644 sysdeps/sw_64/sw8a/Implies
create mode 100644 sysdeps/sw_64/sw8a/nptl/Makefile
create mode 100644 sysdeps/unix/sysv/linux/sw_64/Implies
create mode 100644 sysdeps/unix/sysv/linux/sw_64/Makefile
create mode 100644 sysdeps/unix/sysv/linux/sw_64/Versions
create mode 100644 sysdeps/unix/sysv/linux/sw_64/configure
create mode 100644 sysdeps/unix/sysv/linux/sw_64/configure.ac
create mode 100644 sysdeps/unix/sysv/linux/sw_64/fpu/Implies
create mode 100644 sysdeps/unix/sysv/linux/sw_64/sw6a/fpu/Implies
create mode 100644 sysdeps/unix/sysv/linux/sw_64/sw6b/fpu/Implies
create mode 100644 sysdeps/unix/sysv/linux/sw_64/sw8a/fpu/Implies
diff --git a/Makerules b/Makerules
index 018780c8..0c37f567 100644
--- a/Makerules
+++ b/Makerules
@@ -981,6 +981,20 @@ ifdef libc.so-version
$(inst_slibdir)/libc.so$(libc.so-version): $(common-objpfx)libc.so $(+force)
$(do-install-program)
+ifeq ($(config-machine),sw_64)
+ echo 'libc.so-version $(libc.so-version)'
+ifeq ($(libc.so-version), .6)
+ ln -sf libc.so.6 $(inst_slibdir)/libc.so.6.1
+ ln -sf libm.so.6 $(inst_slibdir)/libm.so.6.1
+ ln -sf libBrokenLocale.so.1 $(inst_slibdir)/libBrokenLocale.so.1.1
+ ln -sf libdl.so.2 $(inst_slibdir)/libdl.so.2.1
+ ln -sf libnsl.so.1 $(inst_slibdir)/libnsl.so.1.1
+ ln -sf libresolv.so.2 $(inst_slibdir)/libresolv.so.2.1
+ ln -sf libutil.so.1 $(inst_slibdir)/libutil.so.1.1
+endif
+endif
+
+
install: $(inst_slibdir)/libc.so$(libc.so-version)
# This fragment of linker script gives the OUTPUT_FORMAT statement
diff --git a/configure b/configure
index 4ef38714..9d8737ca 100755
--- a/configure
+++ b/configure
@@ -2966,6 +2966,28 @@ host_os=$*
IFS=$ac_save_IFS
case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+#sw_64 start
+if test $host_cpu != ""; then
+ march=$with_cpu
+ if test $march = "sw8a"; then
+ echo "sw_64/$march/nptl
+ unix/sysv/linux/wordsize-64
+ ieee754/ldbl-64-128
+ ieee754/ldbl-opt
+ sw_64/$march
+ " >$srcdir/sysdeps/unix/sysv/linux/sw_64/Implies
+ else
+ echo "sw_64/nptl
+ unix/sysv/linux/wordsize-64
+ ieee754/ldbl-64-128
+ ieee754/ldbl-opt
+ sw_64/$march
+ " >$srcdir/sysdeps/unix/sysv/linux/sw_64/Implies
+ fi
+else
+ as_fn_error $? "you must specified a host cpu name"
+ fi
+ #sw_64 end
@@ -6362,6 +6384,7 @@ fi
if test -z "$machine_used" && test "$machine" != none; then
as_fn_error $? "The $machine is not supported." "$LINENO" 5
fi
+submachine_used=$with_cpu
if test -z "$submachine_used" && test -n "$submachine"; then
as_fn_error $? "The $submachine subspecies of $host_cpu is not supported." "$LINENO" 5
fi
diff --git a/elf/tst-glibcelf.py b/elf/tst-glibcelf.py
index 6142ca28..f078e78c 100644
--- a/elf/tst-glibcelf.py
+++ b/elf/tst-glibcelf.py
@@ -170,6 +170,7 @@ DT_ADDRNUM
DT_ADDRRNGHI
DT_ADDRRNGLO
DT_ALPHA_NUM
+DT_SW_64_NUM
DT_ENCODING
DT_EXTRANUM
DT_HIOS
diff --git a/scripts/config.guess b/scripts/config.guess
index 1817bdce..93babc45 100755
--- a/scripts/config.guess
+++ b/scripts/config.guess
@@ -369,6 +369,41 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
GUESS=$UNAME_MACHINE-dec-osf$OSF_REL
;;
+ sw_64:OSF1:*:*)
+ case $UNAME_RELEASE in
+ *4.0)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ ;;
+ *5.*)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+ ;;
+ esac
+ # According to Compaq, /usr/sbin/psrinfo has been available on
+ # OSF/1 and Tru64 systems produced since 1995. I hope that
+ # covers most systems running today. This code pipes the CPU
+ # types through head -n 1, so we only detect the type of CPU 0.
+ SW_64_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The sw_64 \(.*\) processor.*$/\1/p' | head -n 1`
+ case "$SW_64_CPU_TYPE" in
+ "SW6A (21264)")
+ UNAME_MACHINE=sw_64sw6a ;;
+ "SW6B (21264)")
+ UNAME_MACHINE=sw_64sw6b ;;
+ "SW8A (21264)")
+ UNAME_MACHINE=sw_64sw8a ;;
+ esac
+ # A Pn.n version is a patched version.
+ # A Vn.n version is a released version.
+ # A Tn.n version is a released field test version.
+ # A Xn.n version is an unreleased experimental baselevel.
+ # 1.2 uses "1.2" for uname -r.
+ echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`"
+ # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
+ exitcode=$?
+ trap '' 0
+ exit $exitcode ;;
+
+
+
Amiga*:UNIX_System_V:4.0:*)
GUESS=m68k-unknown-sysv4
;;
@@ -993,6 +1028,21 @@ EOF
arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*)
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
+ sw_64:Linux:*:*)
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+ SW6A) UNAME_MACHINE=sw_64sw6a ;;
+ SW6B) UNAME_MACHINE=sw_64sw6b ;;
+ SW8A) UNAME_MACHINE=sw_64sw8a ;;
+ SW6f) UNAME_MACHINE=sw_64sw6f ;;
+ sw) UNAME_MACHINE=sw_64 ;;
+ esac
+ objdump --private-headers /bin/sh | grep -q ld.so.1
+ if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
+ echo "$UNAME_MACHINE"-sunway-linux-"$LIBC"
+ exit ;;
+ arc:Linux:*:* | arceb:Linux:*:*)
+ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ exit ;;
arm*:Linux:*:*)
set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
@@ -1526,6 +1576,7 @@ EOF
UNAME_MACHINE=`(uname -p) 2>/dev/null`
case $UNAME_MACHINE in
A*) GUESS=alpha-dec-vms ;;
+ S*) GUESS=sw_64-dec-vms ;;
I*) GUESS=ia64-dec-vms ;;
V*) GUESS=vax-dec-vms ;;
esac ;;
diff --git a/scripts/config.sub b/scripts/config.sub
index dba16e84..cf662465 100755
--- a/scripts/config.sub
+++ b/scripts/config.sub
@@ -1267,6 +1267,7 @@ case $cpu-$vendor in
| sparclite \
| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
| spu \
+ | sw_64 | sw_64sw6a | sw_64sw8a \
| tahoe \
| thumbv7* \
| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
diff --git a/sysdeps/sw_64/Implies b/sysdeps/sw_64/Implies
new file mode 100644
index 00000000..f1566581
--- /dev/null
+++ b/sysdeps/sw_64/Implies
@@ -0,0 +1,5 @@
+wordsize-64
+# Sw_64 uses IEEE 754 single, double and quad precision floating point.
+ieee754/ldbl-128
+ieee754/dbl-64
+ieee754/flt-32
diff --git a/sysdeps/sw_64/Makefile b/sysdeps/sw_64/Makefile
new file mode 100644
index 00000000..71e10ed1
--- /dev/null
+++ b/sysdeps/sw_64/Makefile
@@ -0,0 +1,70 @@
+# Copyright (C) 1993-2023 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# Contributed by Brendan Kehoe (brendan@zen.org).
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library. If not, see
+# <https://www.gnu.org/licenses/>.
+
+ifeq ($(subdir),db2)
+CPPFLAGS += -DHAVE_SPINLOCKS=1 -DHAVE_ASSEM_SW_64=1
+endif
+
+ifeq ($(subdir),debug)
+# Consider making this GCC's default...
+CFLAGS-backtrace.c = -fasynchronous-unwind-tables
+endif
+
+ifeq ($(subdir),gmon)
+sysdep_routines += _mcount
+endif
+
+ifeq ($(subdir),gnulib)
+sysdep_routines += divl divlu divq divqu reml remlu remq remqu
+endif
+
+ifeq ($(subdir),string)
+sysdep_routines += stxcpy stxncpy
+endif
+
+ifeq ($(subdir),elf)
+# The ld.so startup code cannot use literals until it self-relocates.
+CFLAGS-rtld.c = -mbuild-constants
+endif
+
+ifeq ($(subdir),math)
+# The fma routines rely on inexact being raised for correct results.
+CFLAGS-s_fma.c = -mieee-with-inexact
+CFLAGS-s_fmaf.c = -mieee-with-inexact
+# This test tries to check for inexact being raised by arithmetic.
+CFLAGS-test-misc.c += -mieee-with-inexact
+# Avoid "conflicting types for built-in function" warnings
+CFLAGS-s_isnan.c += -fno-builtin-isnanf
+endif
+
+# Build everything with full IEEE math support, and with dynamic rounding;
+# there are a number of math routines that are defined to work with the
+# "current" rounding mode, and it's easiest to set this with all of them.
+sysdep-CFLAGS += -mieee -mfp-rounding-mode=d
+
+# Software floating-point emulation.
+
+ifeq ($(subdir),soft-fp)
+sysdep_routines += ots_add ots_sub ots_mul ots_div ots_cmp ots_cmpe \
+ ots_cvtxq ots_cvtqx ots_cvtqux ots_cvttx ots_cvtxt ots_nintxq \
+ fraiseexcpt
+endif
+
+ifeq ($(subdir),math)
+CPPFLAGS += -I../soft-fp
+endif
diff --git a/sysdeps/sw_64/Subdirs b/sysdeps/sw_64/Subdirs
new file mode 100644
index 00000000..87eadf30
--- /dev/null
+++ b/sysdeps/sw_64/Subdirs
@@ -0,0 +1 @@
+soft-fp
diff --git a/sysdeps/sw_64/Versions b/sysdeps/sw_64/Versions
new file mode 100644
index 00000000..85ac8e80
--- /dev/null
+++ b/sysdeps/sw_64/Versions
@@ -0,0 +1,23 @@
+libc {
+ GLIBC_2.0 {
+ # functions with special/multiple interfaces
+ __divlu; __remlu; __divls; __remls; __divwu; __remwu; __divws;
+ __remws; __divw; __remw; __divl; __reml; __divlu; __remlu;
+ }
+ GLIBC_2.3.4 {
+ _OtsAddX; _OtsSubX; _OtsMulX; _OtsDivX;
+ _OtsEqlX; _OtsNeqX; _OtsLssX; _OtsLeqX; _OtsGtrX; _OtsGeqX;
+ _OtsCvtQX; _OtsCvtQUX; _OtsCvtXQ; _OtsNintXQ;
+ _OtsConvertFloatTX; _OtsConvertFloatXT;
+ }
+}
+libm {
+ GLIBC_2.0 {
+ # used in inline functions.
+ __atan2;
+ }
+ GLIBC_2.18 {
+ # forgotten when the symbols were added to glibc 2.15 for other targets
+ __sqrt_finite; __sqrtf_finite; __sqrtl_finite;
+ }
+}
diff --git a/sysdeps/sw_64/configure b/sysdeps/sw_64/configure
new file mode 100644
index 00000000..3f78f570
--- /dev/null
+++ b/sysdeps/sw_64/configure
@@ -0,0 +1,26 @@
+# This file is generated from configure.ac by Autoconf. DO NOT EDIT!
+ # Local configure fragment for sysdeps/sw_64.
+
+# With required gcc+binutils, we can always access static and hidden
+# symbols in a position independent way.
+printf "%s\n" "#define PIE_UNSUPPORTED 1" >>confdefs.h
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sw64 libc new version" >&5
+$as_echo_n "checking for sw64 libc new version... " >&6; }
+if ${libc_cv_sw64_newver+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ if test $with_cpu = "sw8a"; then
+ libc_cv_sw64_newver=yes
+ else
+ libc_cv_sw64_newver=no
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_sw64_newver" >&5
+$as_echo "$libc_cv_sw64_newver" >&6; }
+if test $libc_cv_sw64_newver = yes; then
+ $as_echo "#define HAVE_SW64_NEW_LIBCVERSION 1" >>confdefs.h
+
+fi
+# work around problem with autoconf and empty lines at the end of files
diff --git a/sysdeps/sw_64/configure.ac b/sysdeps/sw_64/configure.ac
new file mode 100644
index 00000000..285ae696
--- /dev/null
+++ b/sysdeps/sw_64/configure.ac
@@ -0,0 +1,18 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/sw_64.
+
+# With required gcc+binutils, we can always access static and hidden
+# symbols in a position independent way.
+AC_DEFINE(PI_STATIC_AND_HIDDEN)
+
+AC_CACHE_CHECK([for sw64 libc new version],
+ [libc_cv_sw64_newver],[
+ if test $with_cpu = "sw8a"; then
+ libc_cv_sw64_newver=yes
+ else
+ libc_cv_sw64_newver=no
+ fi])
+if test $libc_cv_sw64_newver = yes; then
+ AC_DEFINE(HAVE_SW64_NEW_LIBCVERSION)
+fi
+# work around problem with autoconf and empty lines at the end of files
diff --git a/sysdeps/sw_64/fpu/Versions b/sysdeps/sw_64/fpu/Versions
new file mode 100644
index 00000000..c9b0e03a
--- /dev/null
+++ b/sysdeps/sw_64/fpu/Versions
@@ -0,0 +1,23 @@
+libc {
+ GLIBC_2.0 {
+ # functions used in other libraries
+ __ieee_get_fp_control; __ieee_set_fp_control;
+ }
+}
+libm {
+ GLIBC_2.3.4 {
+ # functions implementing old complex float abi
+ __c1_cabsf; __c1_cacosf; __c1_cacoshf; __c1_cargf; __c1_casinf;
+ __c1_casinhf; __c1_catanf; __c1_catanhf; __c1_ccosf; __c1_ccoshf;
+ __c1_cexpf; __c1_cimagf; __c1_clog10f; __c1_clogf; __c1_conjf;
+ __c1_cpowf; __c1_cprojf; __c1_crealf; __c1_csinf; __c1_csinhf;
+ __c1_csqrtf; __c1_ctanf; __c1_ctanhf;
+
+ # functions implementing new complex float abi
+ cabsf; cacosf; cacoshf; cargf; casinf;
+ casinhf; catanf; catanhf; ccosf; ccoshf;
+ cexpf; cimagf; clog10f; clogf; conjf;
+ cpowf; cprojf; crealf; csinf; csinhf;
+ csqrtf; ctanf; ctanhf;
+ }
+}
diff --git a/sysdeps/sw_64/preconfigure b/sysdeps/sw_64/preconfigure
new file mode 100644
index 00000000..62b74ab5
--- /dev/null
+++ b/sysdeps/sw_64/preconfigure
@@ -0,0 +1,3 @@
+case "$machine" in
+sw_64*) base_machine=sw_64 machine=sw_64/$machine
+esac
diff --git a/sysdeps/sw_64/sw6a/Implies b/sysdeps/sw_64/sw6a/Implies
new file mode 100644
index 00000000..b34962bb
--- /dev/null
+++ b/sysdeps/sw_64/sw6a/Implies
@@ -0,0 +1 @@
+sw_64/sw6a
diff --git a/sysdeps/sw_64/sw6b/Implies b/sysdeps/sw_64/sw6b/Implies
new file mode 100644
index 00000000..cc08aefa
--- /dev/null
+++ b/sysdeps/sw_64/sw6b/Implies
@@ -0,0 +1 @@
+sw_64/sw6b
diff --git a/sysdeps/sw_64/sw8a/Implies b/sysdeps/sw_64/sw8a/Implies
new file mode 100644
index 00000000..4192bd22
--- /dev/null
+++ b/sysdeps/sw_64/sw8a/Implies
@@ -0,0 +1 @@
+sw_64/sw8a
diff --git a/sysdeps/sw_64/sw8a/nptl/Makefile b/sysdeps/sw_64/sw8a/nptl/Makefile
new file mode 100644
index 00000000..6b60d20f
--- /dev/null
+++ b/sysdeps/sw_64/sw8a/nptl/Makefile
@@ -0,0 +1,20 @@
+# Copyright (C) 2003-2023 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library. If not, see
+# <http://www.gnu.org/licenses/>.
+
+ifeq ($(subdir),csu)
+gen-as-const-headers += tcb-offsets.sym
+endif
diff --git a/sysdeps/unix/sysv/linux/sw_64/Implies b/sysdeps/unix/sysv/linux/sw_64/Implies
new file mode 100644
index 00000000..bc5e8080
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/Implies
@@ -0,0 +1,5 @@
+sw_64/nptl
+ unix/sysv/linux/wordsize-64
+ ieee754/ldbl-64-128
+ ieee754/ldbl-opt
+ sw_64/
diff --git a/sysdeps/unix/sysv/linux/sw_64/Makefile b/sysdeps/unix/sysv/linux/sw_64/Makefile
new file mode 100644
index 00000000..f18a7692
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/Makefile
@@ -0,0 +1,36 @@
+ifeq ($(subdir),stdlib)
+gen-as-const-headers += ucontext-offsets.sym
+endif
+
+ifeq ($(subdir),misc)
+sysdep_headers += sw_64/ptrace.h sw_64/regdef.h sys/io.h
+
+sysdep_routines += ieee_get_fp_control ieee_set_fp_control \
+ ioperm
+
+# Support old timeval32 entry points
+sysdep_routines += osf_adjtime osf_gettimeofday osf_settimeofday \
+ osf_getitimer osf_setitimer osf_utimes \
+ osf_getrusage osf_wait4
+
+CFLAGS-ioperm.c = -Wa,-msw6a
+endif
+
+ifeq ($(subdir),signal)
+sysdep_routines += rt_sigaction
+endif
+
+ifeq ($(subdir),math)
+# These 2 routines are normally in libgcc{.a,_s.so.1}.
+# However, sw_64 -mlong-double-128 libgcc relies on
+# glibc providing _Ots* routines and without these files
+# glibc relies on __multc3/__divtc3 only provided
+# by libgcc if configured with -mlong-double-128.
+# Provide these routines here as well.
+libm-routines += multc3 divtc3
+endif # math
+
+ifeq ($(subdir),conform)
+# For bug 21260.
+conformtest-xfail-conds += sw_64-linux
+endif
diff --git a/sysdeps/unix/sysv/linux/sw_64/Versions b/sysdeps/unix/sysv/linux/sw_64/Versions
new file mode 100644
index 00000000..050a8d0e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/Versions
@@ -0,0 +1,105 @@
+libc {
+ GLIBC_2.0 {
+ _sys_errlist; sys_errlist; _sys_nerr; sys_nerr;
+
+ # Unfortunately in wider use.
+ _inb; _inw; _inl; _outb; _outw; _outl; _bus_base; _bus_base_sparse;
+ _hae_shift;
+
+ # Exception handling support functions from libgcc
+ __register_frame; __register_frame_table; __deregister_frame;
+ __frame_state_for; __register_frame_info_table;
+
+ # b*
+ bus_base; bus_base_sparse;
+
+ # h*
+ hae_shift;
+
+ # i*
+ inb; inl; inw; ioperm; iopl;
+
+ # o*
+ outb; outl; outw;
+
+ # p*
+ pciconfig_read; pciconfig_write; sethae;
+ }
+ GLIBC_2.1 {
+ _sys_errlist; sys_errlist; _sys_nerr; sys_nerr;
+
+ # Linux/Sw_64 64-bit timeval functions.
+ __select; select;
+ adjtime; adjtimex; __adjtimex;
+ __gettimeofday;
+
+ # glob interface change
+ glob; globfree;
+
+ # limit type change
+ getrusage;
+
+ # time type change
+ gettimeofday; getitimer;
+
+ # i*
+ ieee_get_fp_control; ieee_set_fp_control;
+
+ # s*
+ setitimer; settimeofday;
+
+ # u*
+ utimes;
+
+ # w*
+ wait4;
+ }
+ GLIBC_2.1.4 {
+ pciconfig_iobase;
+ }
+ GLIBC_2.2.2 {
+ # w*
+ wordexp;
+ }
+ GLIBC_2.3 {
+ _sys_errlist;
+ _sys_nerr;
+ aio_cancel64;
+ aio_cancel;
+ sys_errlist;
+ sys_nerr;
+ }
+ GLIBC_2.3.3 {
+ # Changed PTHREAD_STACK_MIN.
+ pthread_attr_setstack;
+ pthread_attr_setstacksize;
+ }
+ GLIBC_2.4 {
+ _sys_errlist; sys_errlist; _sys_nerr; sys_nerr;
+ }
+ GLIBC_2.12 {
+ _sys_errlist; sys_errlist; _sys_nerr; sys_nerr;
+ }
+ GLIBC_2.16 {
+ _sys_errlist; sys_errlist; _sys_nerr; sys_nerr;
+ }
+ GLIBC_2.27 {
+ getrlimit; setrlimit; getrlimit64; setrlimit64;
+ }
+ GLIBC_2.34 {
+ aio_cancel64;
+ }
+ GLIBC_PRIVATE {
+ __libc_sw_64_cache_shape;
+ }
+}
+ld {
+ GLIBC_PRIVATE {
+ __libc_sw_64_cache_shape;
+ }
+}
+librt {
+ GLIBC_2.3 {
+ __librt_version_placeholder;
+ }
+}
diff --git a/sysdeps/unix/sysv/linux/sw_64/configure b/sysdeps/unix/sysv/linux/sw_64/configure
new file mode 100644
index 00000000..a8d00a78
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/configure
@@ -0,0 +1,5 @@
+# This file is generated from configure.ac by Autoconf. DO NOT EDIT!
+ # Local configure fragment for sysdeps/unix/sysv/linux/sw_64
+
+# We did historically export the unwinder from glibc.
+libc_cv_gcc_unwind_find_fde=yes
diff --git a/sysdeps/unix/sysv/linux/sw_64/configure.ac b/sysdeps/unix/sysv/linux/sw_64/configure.ac
new file mode 100644
index 00000000..d837c72e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/configure.ac
@@ -0,0 +1,5 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/unix/sysv/linux/sw_64
+
+# We did historically export the unwinder from glibc.
+libc_cv_gcc_unwind_find_fde=yes
diff --git a/sysdeps/unix/sysv/linux/sw_64/fpu/Implies b/sysdeps/unix/sysv/linux/sw_64/fpu/Implies
new file mode 100644
index 00000000..7fda688c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/fpu/Implies
@@ -0,0 +1,2 @@
+# Override ldbl-opt with sw_64 specific routines.
+sw_64/fpu
diff --git a/sysdeps/unix/sysv/linux/sw_64/sw6a/fpu/Implies b/sysdeps/unix/sysv/linux/sw_64/sw6a/fpu/Implies
new file mode 100644
index 00000000..ac8c23c4
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/sw6a/fpu/Implies
@@ -0,0 +1,2 @@
+# Override ldbl-opt with sw_64 specific routines.
+sw_64/sw6a/fpu
diff --git a/sysdeps/unix/sysv/linux/sw_64/sw6b/fpu/Implies b/sysdeps/unix/sysv/linux/sw_64/sw6b/fpu/Implies
new file mode 100644
index 00000000..f50c6641
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/sw6b/fpu/Implies
@@ -0,0 +1,2 @@
+# Override ldbl-opt with sw_64 specific routines.
+sw_64/sw6b/fpu
diff --git a/sysdeps/unix/sysv/linux/sw_64/sw8a/fpu/Implies b/sysdeps/unix/sysv/linux/sw_64/sw8a/fpu/Implies
new file mode 100644
index 00000000..e042578c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/sw8a/fpu/Implies
@@ -0,0 +1,2 @@
+# Override ldbl-opt with sw_64 specific routines.
+sw_64/sw8a/fpu
--
2.25.1

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

5002
0013-Sw64-math-support.patch Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,725 @@
From 08fc38c7c5d764a69899f2305a0b5211675de02c Mon Sep 17 00:00:00 2001
From: swcompiler <lc@wxiat.com>
Date: Fri, 29 Nov 2024 14:24:53 +0800
Subject: [PATCH 14/23] Sw64: float128 Implementation
---
sysdeps/sw_64/e_sqrtl.c | 48 +++++++++++++++++++++++
sysdeps/sw_64/ots_add.c | 40 +++++++++++++++++++
sysdeps/sw_64/ots_cmp.c | 63 ++++++++++++++++++++++++++++++
sysdeps/sw_64/ots_cmpe.c | 78 ++++++++++++++++++++++++++++++++++++++
sysdeps/sw_64/ots_cvtqux.c | 39 +++++++++++++++++++
sysdeps/sw_64/ots_cvtqx.c | 38 +++++++++++++++++++
sysdeps/sw_64/ots_cvttx.c | 47 +++++++++++++++++++++++
sysdeps/sw_64/ots_cvtxq.c | 41 ++++++++++++++++++++
sysdeps/sw_64/ots_cvtxt.c | 43 +++++++++++++++++++++
sysdeps/sw_64/ots_div.c | 40 +++++++++++++++++++
sysdeps/sw_64/ots_mul.c | 40 +++++++++++++++++++
sysdeps/sw_64/ots_nintxq.c | 53 ++++++++++++++++++++++++++
sysdeps/sw_64/ots_sub.c | 40 +++++++++++++++++++
13 files changed, 610 insertions(+)
create mode 100644 sysdeps/sw_64/e_sqrtl.c
create mode 100644 sysdeps/sw_64/ots_add.c
create mode 100644 sysdeps/sw_64/ots_cmp.c
create mode 100644 sysdeps/sw_64/ots_cmpe.c
create mode 100644 sysdeps/sw_64/ots_cvtqux.c
create mode 100644 sysdeps/sw_64/ots_cvtqx.c
create mode 100644 sysdeps/sw_64/ots_cvttx.c
create mode 100644 sysdeps/sw_64/ots_cvtxq.c
create mode 100644 sysdeps/sw_64/ots_cvtxt.c
create mode 100644 sysdeps/sw_64/ots_div.c
create mode 100644 sysdeps/sw_64/ots_mul.c
create mode 100644 sysdeps/sw_64/ots_nintxq.c
create mode 100644 sysdeps/sw_64/ots_sub.c
diff --git a/sysdeps/sw_64/e_sqrtl.c b/sysdeps/sw_64/e_sqrtl.c
new file mode 100644
index 00000000..13cc1f0e
--- /dev/null
+++ b/sysdeps/sw_64/e_sqrtl.c
@@ -0,0 +1,48 @@
+/* long double square root in software floating-point emulation.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <stdlib.h>
+#include <soft-fp.h>
+#include <quad.h>
+#include <shlib-compat.h>
+
+long double
+__ieee754_sqrtl (const long double a)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (A);
+ FP_DECL_Q (C);
+ long double c;
+ long _round = 4; /* dynamic rounding */
+
+ FP_INIT_ROUNDMODE;
+ FP_UNPACK_Q (A, a);
+ FP_SQRT_Q (C, A);
+ FP_PACK_Q (c, C);
+ FP_HANDLE_EXCEPTIONS;
+ return c;
+}
+
+/* ??? We forgot to add this symbol in 2.15. Getting this into 2.18 isn't as
+ straight-forward as just adding the alias, since a generic Versions file
+ includes the 2.15 version and the linker uses the first one it sees. */
+#if SHLIB_COMPAT (libm, GLIBC_2_15, GLIBC_2_18)
+compat_symbol (libm, __ieee754_sqrtl, __sqrtl_finite, GLIBC_2_18);
+#endif
diff --git a/sysdeps/sw_64/ots_add.c b/sysdeps/sw_64/ots_add.c
new file mode 100644
index 00000000..4e3f160c
--- /dev/null
+++ b/sysdeps/sw_64/ots_add.c
@@ -0,0 +1,40 @@
+/* Software floating-point emulation: addition.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+
+void
+_OtsAddX (long al, long ah, long bl, long bh, long _round)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (A);
+ FP_DECL_Q (B);
+ FP_DECL_Q (C);
+ AXP_DECL_RETURN_Q (c);
+
+ FP_INIT_ROUNDMODE;
+ AXP_UNPACK_SEMIRAW_Q (A, a);
+ AXP_UNPACK_SEMIRAW_Q (B, b);
+ FP_ADD_Q (C, A, B);
+ AXP_PACK_SEMIRAW_Q (c, C);
+ FP_HANDLE_EXCEPTIONS;
+
+ AXP_RETURN_Q (c);
+}
diff --git a/sysdeps/sw_64/ots_cmp.c b/sysdeps/sw_64/ots_cmp.c
new file mode 100644
index 00000000..42766f23
--- /dev/null
+++ b/sysdeps/sw_64/ots_cmp.c
@@ -0,0 +1,63 @@
+/* Software floating-point emulation: comparison.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+
+static long
+internal_equality (long al, long ah, long bl, long bh, long neq)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (A);
+ FP_DECL_Q (B);
+ long r;
+
+ AXP_UNPACK_RAW_Q (A, a);
+ AXP_UNPACK_RAW_Q (B, b);
+
+ if ((A_e == _FP_EXPMAX_Q && !_FP_FRAC_ZEROP_2 (A))
+ || (B_e == _FP_EXPMAX_Q && !_FP_FRAC_ZEROP_2 (B)))
+ {
+ /* EQ and NE signal invalid operation only if either operand is SNaN. */
+ if (FP_ISSIGNAN_Q (A) || FP_ISSIGNAN_Q (B))
+ {
+ FP_SET_EXCEPTION (FP_EX_INVALID);
+ FP_HANDLE_EXCEPTIONS;
+ }
+ return -1;
+ }
+
+ r = (A_e == B_e && _FP_FRAC_EQ_2 (A, B)
+ && (A_s == B_s || (!A_e && _FP_FRAC_ZEROP_2 (A))));
+ r ^= neq;
+
+ return r;
+}
+
+long
+_OtsEqlX (long al, long ah, long bl, long bh)
+{
+ return internal_equality (al, ah, bl, bh, 0);
+}
+
+long
+_OtsNeqX (long al, long ah, long bl, long bh)
+{
+ return internal_equality (al, ah, bl, bh, 1);
+}
diff --git a/sysdeps/sw_64/ots_cmpe.c b/sysdeps/sw_64/ots_cmpe.c
new file mode 100644
index 00000000..7604e94e
--- /dev/null
+++ b/sysdeps/sw_64/ots_cmpe.c
@@ -0,0 +1,78 @@
+/* Software floating-point emulation: comparison.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+
+static long
+internal_compare (long al, long ah, long bl, long bh)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (A);
+ FP_DECL_Q (B);
+ long r;
+
+ AXP_UNPACK_RAW_Q (A, a);
+ AXP_UNPACK_RAW_Q (B, b);
+ FP_CMP_Q (r, A, B, 2, 2);
+
+ FP_HANDLE_EXCEPTIONS;
+
+ return r;
+}
+
+long
+_OtsLssX (long al, long ah, long bl, long bh)
+{
+ long r = internal_compare (al, ah, bl, bh);
+ if (r == 2)
+ return -1;
+ else
+ return r < 0;
+}
+
+long
+_OtsLeqX (long al, long ah, long bl, long bh)
+{
+ long r = internal_compare (al, ah, bl, bh);
+ if (r == 2)
+ return -1;
+ else
+ return r <= 0;
+}
+
+long
+_OtsGtrX (long al, long ah, long bl, long bh)
+{
+ long r = internal_compare (al, ah, bl, bh);
+ if (r == 2)
+ return -1;
+ else
+ return r > 0;
+}
+
+long
+_OtsGeqX (long al, long ah, long bl, long bh)
+{
+ long r = internal_compare (al, ah, bl, bh);
+ if (r == 2)
+ return -1;
+ else
+ return r >= 0;
+}
diff --git a/sysdeps/sw_64/ots_cvtqux.c b/sysdeps/sw_64/ots_cvtqux.c
new file mode 100644
index 00000000..283bbe19
--- /dev/null
+++ b/sysdeps/sw_64/ots_cvtqux.c
@@ -0,0 +1,39 @@
+/* Software floating-point emulation: unsigned integer to float conversion.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+
+/* Should never actually be used, since we've more bits of precision
+ than the incomming long, but needed for linkage. */
+#undef FP_ROUNDMODE
+#define FP_ROUNDMODE FP_RND_ZERO
+
+void
+_OtsCvtQUX (unsigned long a)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (C);
+ AXP_DECL_RETURN_Q (c);
+
+ FP_FROM_INT_Q (C, a, 64, unsigned long);
+ AXP_PACK_RAW_Q (c, C);
+
+ AXP_RETURN_Q (c);
+}
diff --git a/sysdeps/sw_64/ots_cvtqx.c b/sysdeps/sw_64/ots_cvtqx.c
new file mode 100644
index 00000000..dd51eb27
--- /dev/null
+++ b/sysdeps/sw_64/ots_cvtqx.c
@@ -0,0 +1,38 @@
+/* Software floating-point emulation: signed integer to float conversion.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+
+/* Should never actually be used, since we've more bits of precision
+ than the incomming long, but needed for linkage. */
+#undef FP_ROUNDMODE
+#define FP_ROUNDMODE FP_RND_ZERO
+
+void
+_OtsCvtQX (long a)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (C);
+ AXP_DECL_RETURN_Q (c);
+
+ FP_FROM_INT_Q (C, a, 64, unsigned long);
+ AXP_PACK_RAW_Q (c, C);
+ AXP_RETURN_Q (c);
+}
diff --git a/sysdeps/sw_64/ots_cvttx.c b/sysdeps/sw_64/ots_cvttx.c
new file mode 100644
index 00000000..4defb56d
--- /dev/null
+++ b/sysdeps/sw_64/ots_cvttx.c
@@ -0,0 +1,47 @@
+/* Software floating-point emulation: floating point extension.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+#include "double.h"
+
+/* Should never actually be used, since we're extending, but needed
+ for linkage. */
+#undef FP_ROUNDMODE
+#define FP_ROUNDMODE FP_RND_ZERO
+
+void
+_OtsConvertFloatTX (double a)
+{
+ FP_DECL_EX;
+ FP_DECL_D (A);
+ FP_DECL_Q (C);
+ AXP_DECL_RETURN_Q (c);
+
+ FP_UNPACK_RAW_D (A, a);
+#if _FP_W_TYPE_SIZE < 64
+ FP_EXTEND (Q, D, 4, 2, C, A);
+#else
+ FP_EXTEND (Q, D, 2, 1, C, A);
+#endif
+ AXP_PACK_RAW_Q (c, C);
+ FP_HANDLE_EXCEPTIONS;
+
+ AXP_RETURN_Q (c);
+}
diff --git a/sysdeps/sw_64/ots_cvtxq.c b/sysdeps/sw_64/ots_cvtxq.c
new file mode 100644
index 00000000..e88adf14
--- /dev/null
+++ b/sysdeps/sw_64/ots_cvtxq.c
@@ -0,0 +1,41 @@
+/* Software floating-point emulation: float to integer conversion.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+
+long
+_OtsCvtXQ (long al, long ah, long _round)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (A);
+ unsigned long r;
+ long s;
+
+ /* If bit 3 is set, then integer overflow detection is requested. */
+ s = _round & 8 ? 1 : -1;
+ _round = _round & 3;
+
+ FP_INIT_ROUNDMODE;
+ AXP_UNPACK_RAW_Q (A, a);
+ FP_TO_INT_Q (r, A, 64, s);
+ FP_HANDLE_EXCEPTIONS;
+
+ return r;
+}
diff --git a/sysdeps/sw_64/ots_cvtxt.c b/sysdeps/sw_64/ots_cvtxt.c
new file mode 100644
index 00000000..a20db3a7
--- /dev/null
+++ b/sysdeps/sw_64/ots_cvtxt.c
@@ -0,0 +1,43 @@
+/* Software floating-point emulation: floating point truncation.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+#include "double.h"
+
+double
+_OtsConvertFloatXT (long al, long ah, long _round)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (A);
+ FP_DECL_D (R);
+ double r;
+
+ FP_INIT_ROUNDMODE;
+ AXP_UNPACK_SEMIRAW_Q (A, a);
+#if _FP_W_TYPE_SIZE < 64
+ FP_TRUNC (D, Q, 2, 4, R, A);
+#else
+ FP_TRUNC (D, Q, 1, 2, R, A);
+#endif
+ FP_PACK_SEMIRAW_D (r, R);
+ FP_HANDLE_EXCEPTIONS;
+
+ return r;
+}
diff --git a/sysdeps/sw_64/ots_div.c b/sysdeps/sw_64/ots_div.c
new file mode 100644
index 00000000..af0e7d60
--- /dev/null
+++ b/sysdeps/sw_64/ots_div.c
@@ -0,0 +1,40 @@
+/* Software floating-point emulation: division.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+
+void
+_OtsDivX (long al, long ah, long bl, long bh, long _round)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (A);
+ FP_DECL_Q (B);
+ FP_DECL_Q (C);
+ AXP_DECL_RETURN_Q (c);
+
+ FP_INIT_ROUNDMODE;
+ AXP_UNPACK_Q (A, a);
+ AXP_UNPACK_Q (B, b);
+ FP_DIV_Q (C, A, B);
+ AXP_PACK_Q (c, C);
+ FP_HANDLE_EXCEPTIONS;
+
+ AXP_RETURN_Q (c);
+}
diff --git a/sysdeps/sw_64/ots_mul.c b/sysdeps/sw_64/ots_mul.c
new file mode 100644
index 00000000..41dba23d
--- /dev/null
+++ b/sysdeps/sw_64/ots_mul.c
@@ -0,0 +1,40 @@
+/* Software floating-point emulation: multiplication.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+
+void
+_OtsMulX (long al, long ah, long bl, long bh, long _round)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (A);
+ FP_DECL_Q (B);
+ FP_DECL_Q (C);
+ AXP_DECL_RETURN_Q (c);
+
+ FP_INIT_ROUNDMODE;
+ AXP_UNPACK_Q (A, a);
+ AXP_UNPACK_Q (B, b);
+ FP_MUL_Q (C, A, B);
+ AXP_PACK_Q (c, C);
+ FP_HANDLE_EXCEPTIONS;
+
+ AXP_RETURN_Q (c);
+}
diff --git a/sysdeps/sw_64/ots_nintxq.c b/sysdeps/sw_64/ots_nintxq.c
new file mode 100644
index 00000000..ac4c610a
--- /dev/null
+++ b/sysdeps/sw_64/ots_nintxq.c
@@ -0,0 +1,53 @@
+/* Software floating-point emulation: convert to fortran nearest.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+
+long
+_OtsNintXQ (long al, long ah, long _round)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (A);
+ FP_DECL_Q (B);
+ FP_DECL_Q (C);
+ unsigned long r;
+ long s;
+
+ /* If bit 3 is set, then integer overflow detection is requested. */
+ s = _round & 8 ? 1 : -1;
+ _round = _round & 3;
+
+ FP_INIT_ROUNDMODE;
+ AXP_UNPACK_SEMIRAW_Q (A, a);
+
+ /* Build 0.5 * sign(A) */
+ B_e = _FP_EXPBIAS_Q;
+ __FP_FRAC_SET_2 (B, 0, 0);
+ B_s = A_s;
+
+ FP_ADD_Q (C, A, B);
+ _FP_FRAC_SRL_2 (C, _FP_WORKBITS);
+ _FP_FRAC_HIGH_RAW_Q (C) &= ~(_FP_W_TYPE) _FP_IMPLBIT_Q;
+ FP_TO_INT_Q (r, C, 64, s);
+ if (s > 0 && (_fex &= FP_EX_INVALID))
+ FP_HANDLE_EXCEPTIONS;
+
+ return r;
+}
diff --git a/sysdeps/sw_64/ots_sub.c b/sysdeps/sw_64/ots_sub.c
new file mode 100644
index 00000000..c0bc573e
--- /dev/null
+++ b/sysdeps/sw_64/ots_sub.c
@@ -0,0 +1,40 @@
+/* Software floating-point emulation: subtraction.
+ Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson (rth@cygnus.com) and
+ Jakub Jelinek (jj@ultra.linux.cz).
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "local-soft-fp.h"
+
+void
+_OtsSubX (long al, long ah, long bl, long bh, long _round)
+{
+ FP_DECL_EX;
+ FP_DECL_Q (A);
+ FP_DECL_Q (B);
+ FP_DECL_Q (C);
+ AXP_DECL_RETURN_Q (c);
+
+ FP_INIT_ROUNDMODE;
+ AXP_UNPACK_SEMIRAW_Q (A, a);
+ AXP_UNPACK_SEMIRAW_Q (B, b);
+ FP_SUB_Q (C, A, B);
+ AXP_PACK_SEMIRAW_Q (c, C);
+ FP_HANDLE_EXCEPTIONS;
+
+ AXP_RETURN_Q (c);
+}
--
2.25.1

View File

@ -0,0 +1,54 @@
From 089f8816df1cbcb0519083f72f3fd51a5072bd9a Mon Sep 17 00:00:00 2001
From: swcompiler <lc@wxiat.com>
Date: Fri, 29 Nov 2024 17:18:04 +0800
Subject: [PATCH 15/23] Sw64: Add get_rounding_mode
---
sysdeps/sw_64/fpu/get-rounding-mode.h | 35 +++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
create mode 100644 sysdeps/sw_64/fpu/get-rounding-mode.h
diff --git a/sysdeps/sw_64/fpu/get-rounding-mode.h b/sysdeps/sw_64/fpu/get-rounding-mode.h
new file mode 100644
index 00000000..d7fb29a2
--- /dev/null
+++ b/sysdeps/sw_64/fpu/get-rounding-mode.h
@@ -0,0 +1,35 @@
+/* Determine floating-point rounding mode within libc. Sw_64 version.
+ Copyright (C) 2012-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef SW_64_GET_ROUNDING_MODE_H
+#define SW_64_GET_ROUNDING_MODE_H 1
+
+#include <fenv.h>
+#include <fenv_libc.h>
+
+/* Return the floating-point rounding mode. */
+
+static inline int
+get_rounding_mode (void)
+{
+ unsigned long fpcr;
+ __asm__ __volatile__("excb; rfpcr %0" : "=f"(fpcr));
+ return (fpcr >> FPCR_ROUND_SHIFT) & 3;
+}
+
+#endif /* get-rounding-mode.h */
--
2.25.1

View File

@ -0,0 +1,63 @@
From 55d695990a490cf2e615ac767cbdcef378155ee0 Mon Sep 17 00:00:00 2001
From: swcompiler <lc@wxiat.com>
Date: Fri, 29 Nov 2024 17:18:43 +0800
Subject: [PATCH 16/23] Sw64: Add specific math difinitons
---
sysdeps/sw_64/bits/mathdef.h | 44 ++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
create mode 100644 sysdeps/sw_64/bits/mathdef.h
diff --git a/sysdeps/sw_64/bits/mathdef.h b/sysdeps/sw_64/bits/mathdef.h
new file mode 100644
index 00000000..8d753376
--- /dev/null
+++ b/sysdeps/sw_64/bits/mathdef.h
@@ -0,0 +1,44 @@
+/* Copyright (C) 1997-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _COMPLEX_H
+# error "Never use <bits/mathdef.h> directly; include <complex.h> instead"
+#endif
+
+#if defined _COMPLEX_H && !defined _COMPLEX_H_MATHDEF
+# define _COMPLEX_H_MATHDEF 1
+# if defined(__GNUC__) && !__GNUC_PREREQ(3, 4)
+
+/* Due to an ABI change, we need to remap the complex float symbols. */
+# define _Mdouble_ float
+# define __MATHCALL(function, args) \
+ __MATHDECL (_Complex float, function, args)
+# define __MATHDECL(type, function, args) \
+ __MATHDECL_1 (type, function##f, args, __c1_##function##f); \
+ __MATHDECL_1 (type, __##function##f, args, __c1_##function##f)
+# define __MATHDECL_1(type, function, args, alias) \
+ extern type function args __asm__(#alias) __THROW
+
+# include <bits/cmathcalls.h>
+
+# undef _Mdouble_
+# undef __MATHCALL
+# undef __MATHDECL
+# undef __MATHDECL_1
+
+# endif /* GNUC before 3.4 */
+#endif /* COMPLEX_H */
--
2.25.1

View File

@ -0,0 +1,40 @@
From b88a3af5562fe7e316b02f489821ee4dd3309490 Mon Sep 17 00:00:00 2001
From: swcompiler <lc@wxiat.com>
Date: Fri, 29 Nov 2024 17:19:07 +0800
Subject: [PATCH 17/23] Sw64: Introduce <elf-initfini.h> and ELF_INITFINI for
sw64
---
sysdeps/sw_64/elf-initfini.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
create mode 100644 sysdeps/sw_64/elf-initfini.h
diff --git a/sysdeps/sw_64/elf-initfini.h b/sysdeps/sw_64/elf-initfini.h
new file mode 100644
index 00000000..54a8d7cc
--- /dev/null
+++ b/sysdeps/sw_64/elf-initfini.h
@@ -0,0 +1,20 @@
+/* Determine DT_INIT/DT_FINI support in the dynamic loader. Sw_64 version.
+ Copyright (C) 2020-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+/* Enable DT_INIT/DT_FINI support. */
+#define ELF_INITFINI 1
--
2.25.1

View File

@ -0,0 +1,40 @@
From aac63ca99c04641807e20132ae96e351c57ea90b Mon Sep 17 00:00:00 2001
From: swcompiler <lc@wxiat.com>
Date: Fri, 29 Nov 2024 17:21:55 +0800
Subject: [PATCH 18/23] Sw64: Type definitions for nscd on sw64
---
sysdeps/sw_64/nscd-types.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 sysdeps/sw_64/nscd-types.h
diff --git a/sysdeps/sw_64/nscd-types.h b/sysdeps/sw_64/nscd-types.h
new file mode 100644
index 00000000..6bbee289
--- /dev/null
+++ b/sysdeps/sw_64/nscd-types.h
@@ -0,0 +1,21 @@
+/* Types for the NSCD implementation. Sw_64 version.
+ Copyright (c) 2000-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdint.h>
+
+typedef int64_t nscd_ssize_t;
--
2.25.1

View File

@ -0,0 +1,40 @@
From 3e80bd4c5ee9a026b0a143c808271779dd4d215d Mon Sep 17 00:00:00 2001
From: swcompiler <lc@wxiat.com>
Date: Fri, 29 Nov 2024 17:22:32 +0800
Subject: [PATCH 19/23] Sw64: GCC frame desciption for sw64
---
sysdeps/sw_64/gccframe.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 sysdeps/sw_64/gccframe.h
diff --git a/sysdeps/sw_64/gccframe.h b/sysdeps/sw_64/gccframe.h
new file mode 100644
index 00000000..1c9572bb
--- /dev/null
+++ b/sysdeps/sw_64/gccframe.h
@@ -0,0 +1,21 @@
+/* Definition of object in frame unwind info. sw_64 version.
+ Copyright (C) 2001-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define FIRST_PSEUDO_REGISTER 64
+
+#include <sysdeps/generic/gccframe.h>
--
2.25.1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,233 @@
From 46d5d9e55be7604efec5bfedfb963da94faba543 Mon Sep 17 00:00:00 2001
From: swcompiler <lc@wxiat.com>
Date: Fri, 29 Nov 2024 17:24:01 +0800
Subject: [PATCH 21/23] Sw64: Add test_numdouble.h and test_numfloat.h
---
sysdeps/sw_64/include/test_numdouble.h | 106 +++++++++++++++++++++++++
sysdeps/sw_64/include/test_numfloat.h | 100 +++++++++++++++++++++++
2 files changed, 206 insertions(+)
create mode 100644 sysdeps/sw_64/include/test_numdouble.h
create mode 100644 sysdeps/sw_64/include/test_numfloat.h
diff --git a/sysdeps/sw_64/include/test_numdouble.h b/sysdeps/sw_64/include/test_numdouble.h
new file mode 100644
index 00000000..30131862
--- /dev/null
+++ b/sysdeps/sw_64/include/test_numdouble.h
@@ -0,0 +1,106 @@
+
+#ifndef _TEST_NUMDOUBLE_H
+
+typedef double DATATYPE;
+
+typedef unsigned long _TYPE; // 8 byte
+// typedef unsigned int _TYPE; //4 byte
+
+# define _EXP_BITS 11
+# define _Fraction_BITS 52
+
+// The highest bit in the decimal part is used to distinguish between QNaN and SNaN
+# define FRACTION_HIGH_BIT \
+ (((_TYPE) 1) << (sizeof (_TYPE) * 8 - _EXP_BITS - 2))
+// Significant bits
+# define DIGITS_BITS (sizeof (_TYPE) * 8 - _EXP_BITS)
+// exponent offset
+# define FLOAT_EXP_OFF ((((int) 1) << (_EXP_BITS - 1)) - 1)
+
+// IEEE 754 double format
+typedef struct
+{
+ _TYPE m_nFraction : sizeof (_TYPE) * 8 - _EXP_BITS - 1;
+ _TYPE m_nExp : _EXP_BITS;
+ _TYPE m_nSign : 1;
+} _DATA;
+
+// +0.0 and -0.0
+DATATYPE
+Zero (int sign)
+{
+ DATATYPE rv = 0.0;
+ _DATA *p = (_DATA *) &rv;
+ p->m_nSign = sign;
+ p->m_nExp = 0;
+ p->m_nFraction = 0;
+
+ return rv;
+}
+
+//+subnormal and -subnormal
+DATATYPE
+SubNormal (int sign)
+{
+ DATATYPE rv = 0.0;
+ _DATA *p = (_DATA *) &rv;
+ p->m_nSign = sign;
+ p->m_nExp = 0;
+ p->m_nFraction = 1;
+
+ return rv;
+}
+
+// quiet NaN
+DATATYPE
+QNaN ()
+{
+ DATATYPE rv = 0.0;
+ _DATA *p = (_DATA *) &rv;
+ p->m_nSign = 0;
+ p->m_nExp = -1;
+ p->m_nFraction = FRACTION_HIGH_BIT;
+
+ return rv;
+}
+
+// Signal NaN
+DATATYPE
+CQNaN ()
+{
+ DATATYPE rv = 0.0;
+ _DATA *p = (_DATA *) &rv;
+ p->m_nSign = 1;
+ p->m_nExp = -1;
+ p->m_nFraction = 1;
+
+ return rv;
+}
+
+// +infinite and -infinite
+DATATYPE
+Infinite (int sign)
+{
+ DATATYPE rv = 0.0;
+ _DATA *p = (_DATA *) &rv;
+ p->m_nSign = sign;
+ p->m_nExp = -1;
+ p->m_nFraction = 0;
+
+ return rv;
+}
+
+// get any float
+/*DATATYPE anyf(int nSign,int nExp,long nFraction)
+{
+ DATATYPE rv=0.0;
+ _DATA *p=(_DATA *)&rv;
+ p->m_nSign = nSign;
+ p->m_nExp = nExp;
+ p->m_nFraction = nFraction;
+
+ return rv;
+
+}*/
+
+#endif
diff --git a/sysdeps/sw_64/include/test_numfloat.h b/sysdeps/sw_64/include/test_numfloat.h
new file mode 100644
index 00000000..82a99773
--- /dev/null
+++ b/sysdeps/sw_64/include/test_numfloat.h
@@ -0,0 +1,100 @@
+typedef float DATATYPE;
+
+// typedef unsigned long _TYPE; //8 byte
+typedef unsigned int _TYPE; // 4 byte
+
+#define _EXP_BITS 8
+#define _Fraction_BITS 23
+
+// The highest bit in the decimal part is used to distinguish between QNaN and SNaN
+#define FRACTION_HIGH_BIT (((_TYPE) 1) << (sizeof (_TYPE) * 8 - _EXP_BITS - 2))
+// Significant bits
+#define DIGITS_BITS (sizeof (_TYPE) * 8 - _EXP_BITS)
+// exponent offset
+#define FLOAT_EXP_OFF ((((int) 1) << (_EXP_BITS - 1)) - 1)
+
+// IEEE 754 float format
+typedef struct
+{
+ _TYPE m_nFraction : sizeof (_TYPE) * 8 - _EXP_BITS - 1;
+ _TYPE m_nExp : _EXP_BITS;
+ _TYPE m_nSign : 1;
+} _DATA;
+
+// +0.0 and -0.0
+DATATYPE
+Zero (int sign)
+{
+ DATATYPE rv = 0.0;
+ _DATA *p = (_DATA *) &rv;
+ p->m_nSign = sign;
+ p->m_nExp = 0;
+ p->m_nFraction = 0;
+
+ return rv;
+}
+
+// +subnormal and-subnormal
+DATATYPE
+SubNormal (int sign)
+{
+ DATATYPE rv = 0.0;
+ _DATA *p = (_DATA *) &rv;
+ p->m_nSign = sign;
+ p->m_nExp = 0;
+ p->m_nFraction = 1;
+
+ return rv;
+}
+
+// quiet NaN
+DATATYPE
+QNaN ()
+{
+ DATATYPE rv = 0.0;
+ _DATA *p = (_DATA *) &rv;
+ p->m_nSign = 0;
+ p->m_nExp = -1;
+ p->m_nFraction = FRACTION_HIGH_BIT;
+
+ return rv;
+}
+
+// Signal NaN
+DATATYPE
+CQNaN ()
+{
+ DATATYPE rv = 0.0;
+ _DATA *p = (_DATA *) &rv;
+ p->m_nSign = 1;
+ p->m_nExp = -1;
+ p->m_nFraction = 1;
+
+ return rv;
+}
+
+// +infinite and -infinite
+DATATYPE
+Infinite (int sign)
+{
+ DATATYPE rv = 0.0;
+ _DATA *p = (_DATA *) &rv;
+ p->m_nSign = sign;
+ p->m_nExp = -1;
+ p->m_nFraction = 0;
+
+ return rv;
+}
+
+// build a float
+DATATYPE
+anyf (int nSign, int nExp, long nFraction)
+{
+ DATATYPE rv = 0.0;
+ _DATA *p = (_DATA *) &rv;
+ p->m_nSign = nSign;
+ p->m_nExp = nExp;
+ p->m_nFraction = nFraction;
+
+ return rv;
+}
--
2.25.1

View File

@ -0,0 +1,25 @@
From f020ed47e591b8323bb14c11e56c1b3e6fcb738d Mon Sep 17 00:00:00 2001
From: swcompiler <lc@wxiat.com>
Date: Fri, 29 Nov 2024 17:26:01 +0800
Subject: [PATCH 22/23] Sw64: Fix posix/tst-glob_lstat_compat on sw64
---
posix/tst-glob_lstat_compat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/posix/tst-glob_lstat_compat.c b/posix/tst-glob_lstat_compat.c
index 937ad77d..74cd0286 100644
--- a/posix/tst-glob_lstat_compat.c
+++ b/posix/tst-glob_lstat_compat.c
@@ -36,7 +36,7 @@ __typeof (glob) glob;
/* On alpha glob exists in version GLIBC_2_0, GLIBC_2_1, and GLIBC_2_27.
This test needs to access the version prior to GLIBC_2_27, which is
GLIBC_2_1 on alpha, GLIBC_2_0 elsewhere. */
-#ifdef __alpha__
+#if defined(__alpha__) || defined(__sw_64__)
compat_symbol_reference (libc, glob, glob, GLIBC_2_1);
#else
compat_symbol_reference (libc, glob, glob, GLIBC_2_0);
--
2.25.1

View File

@ -0,0 +1,32 @@
From 25fb8c292c498ad0eaeb62ccb443f0e034da7c10 Mon Sep 17 00:00:00 2001
From: swcompiler <lc@wxiat.com>
Date: Fri, 29 Nov 2024 17:27:15 +0800
Subject: [PATCH 23/23] Sw64: add getopt weak alias
---
posix/getopt1.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/posix/getopt1.c b/posix/getopt1.c
index 49323aa8..ee2e7510 100644
--- a/posix/getopt1.c
+++ b/posix/getopt1.c
@@ -64,6 +64,15 @@ _getopt_long_only_r (int argc, char **argv, const char *options,
1, d, 0);
}
+#ifndef SW_64
+int getopt_long_only (int argc, char *__getopt_argv_const *argv,
+ const char *options,
+ const struct option *long_options,
+ int *opt_index) __attribute__ ((weak));
+int _getopt_long_only_r (int argc, char **argv, const char *options,
+ const struct option *long_options, int *opt_index,
+ struct _getopt_data *d) __attribute__ ((weak));
+#endif
#ifdef TEST
--
2.25.1

View File

@ -67,7 +67,7 @@
############################################################################## ##############################################################################
Name: glibc Name: glibc
Version: 2.38 Version: 2.38
Release: 47 Release: 48
Summary: The GNU libc libraries Summary: The GNU libc libraries
License: %{all_license} License: %{all_license}
URL: http://www.gnu.org/software/glibc/ URL: http://www.gnu.org/software/glibc/
@ -264,6 +264,31 @@ Patch9008: 0001-fix-glibc-build-error-on-x86.patch
Patch9010: add-Wl-z-noseparate-code-for-so.patch Patch9010: add-Wl-z-noseparate-code-for-so.patch
# Sw64 Port glibc
Patch9011: 0001-Sw64-Add-Sw64-entries-to-config.h.in.patch
Patch9012: 0002-Sw64-Add-relocations-and-ELF-flags-to-elf.h-and-scri.patch
Patch9013: 0003-Sw64-ABI-Implementation.patch
Patch9014: 0004-Sw64-Thread-Local-Storage-Support.patch
Patch9015: 0005-Sw64-Generic-math.h-and-soft-fp-Routines.patch
Patch9016: 0006-Sw64-Atomic-and-Locking-Implementation.patch
Patch9017: 0007-Sw64-Linux-Syscall-Interface.patch
Patch9018: 0008-Sw64-Linux-ABI.patch
Patch9019: 0009-Sw64-Add-ABI-Lists.patch
Patch9020: 0010-Sw64-Build-Infrastructure.patch
Patch9021: 0011-Sw64-Integer-Operation-Support.patch
Patch9022: 0012-Sw64-Memory-and-String-Implementation.patch
Patch9023: 0013-Sw64-math-support.patch
Patch9024: 0014-Sw64-float128-Implementation.patch
Patch9025: 0015-Sw64-Add-get_rounding_mode.patch
Patch9026: 0016-Sw64-Add-specific-math-difinitons.patch
Patch9027: 0017-Sw64-Introduce-elf-initfini.h-and-ELF_INITFINI-for-s.patch
Patch9028: 0018-Sw64-Type-definitions-for-nscd-on-sw64.patch
Patch9029: 0019-Sw64-GCC-frame-desciption-for-sw64.patch
Patch9030: 0020-Sw64-Update-libm-test-ulps.patch
Patch9031: 0021-Sw64-Add-test_numdouble.h-and-test_numfloat.h.patch
Patch9032: 0022-Sw64-Fix-posix-tst-glob_lstat_compat-on-sw64.patch
Patch9033: 0023-Sw64-add-getopt-weak-alias.patch
Provides: ldconfig rtld(GNU_HASH) bundled(gnulib) Provides: ldconfig rtld(GNU_HASH) bundled(gnulib)
BuildRequires: audit-libs-devel >= 1.1.3, sed >= 3.95, libcap-devel, gettext BuildRequires: audit-libs-devel >= 1.1.3, sed >= 3.95, libcap-devel, gettext
@ -1440,6 +1465,9 @@ fi
%endif %endif
%changelog %changelog
* Mon Dec 16 2024 swcompiler <lc@wxiat.com> - 2.38-48
- Add Sw64 ISA support
* Tue Dec 10 2024 taoyuxiang <taoyuxiang2@huawei.com> - 2.38-47 * Tue Dec 10 2024 taoyuxiang <taoyuxiang2@huawei.com> - 2.38-47
- Change Inner-Net to Inner-Net-2.0 - Change Inner-Net to Inner-Net-2.0