glibc/0008-Sw64-Linux-ABI.patch

7445 lines
253 KiB
Diff
Raw Normal View History

From e69e2ce0e9ed2962c6e0fed8ed1d6d291d0a2b4f Mon Sep 17 00:00:00 2001
From: swcompiler <lc@wxiat.com>
Date: Fri, 29 Nov 2024 14:09:04 +0800
Subject: [PATCH 08/23] Sw64: Linux ABI
---
sysdeps/unix/sysv/linux/sw_64/a.out.h | 197 ++++
sysdeps/unix/sysv/linux/sw_64/adjtime.c | 22 +
sysdeps/unix/sysv/linux/sw_64/adjtimex.c | 22 +
sysdeps/unix/sysv/linux/sw_64/aio_cancel.c | 35 +
sysdeps/unix/sysv/linux/sw_64/bits/a.out.h | 9 +
sysdeps/unix/sysv/linux/sw_64/bits/dirent.h | 57 ++
sysdeps/unix/sysv/linux/sw_64/bits/elfclass.h | 14 +
sysdeps/unix/sysv/linux/sw_64/bits/epoll.h | 27 +
sysdeps/unix/sysv/linux/sw_64/bits/errno.h | 53 ++
sysdeps/unix/sysv/linux/sw_64/bits/eventfd.h | 32 +
sysdeps/unix/sysv/linux/sw_64/bits/fcntl.h | 87 ++
sysdeps/unix/sysv/linux/sw_64/bits/inotify.h | 30 +
sysdeps/unix/sysv/linux/sw_64/bits/ioctls.h | 36 +
sysdeps/unix/sysv/linux/sw_64/bits/mman.h | 67 ++
sysdeps/unix/sysv/linux/sw_64/bits/netdb.h | 33 +
.../sysv/linux/sw_64/bits/procfs-prregset.h | 26 +
sysdeps/unix/sysv/linux/sw_64/bits/procfs.h | 38 +
.../sysv/linux/sw_64/bits/pthread_stack_min.h | 20 +
sysdeps/unix/sysv/linux/sw_64/bits/resource.h | 223 +++++
.../unix/sysv/linux/sw_64/bits/sigaction.h | 82 ++
sysdeps/unix/sysv/linux/sw_64/bits/signalfd.h | 30 +
.../unix/sysv/linux/sw_64/bits/signum-arch.h | 67 ++
sysdeps/unix/sysv/linux/sw_64/bits/sigstack.h | 32 +
.../sysv/linux/sw_64/bits/socket-constants.h | 51 ++
.../unix/sysv/linux/sw_64/bits/socket_type.h | 56 ++
sysdeps/unix/sysv/linux/sw_64/bits/statfs.h | 64 ++
.../unix/sysv/linux/sw_64/bits/struct_stat.h | 119 +++
.../unix/sysv/linux/sw_64/bits/termios-baud.h | 47 +
.../unix/sysv/linux/sw_64/bits/termios-c_cc.h | 41 +
.../sysv/linux/sw_64/bits/termios-c_cflag.h | 39 +
.../sysv/linux/sw_64/bits/termios-c_iflag.h | 39 +
.../sysv/linux/sw_64/bits/termios-c_lflag.h | 43 +
.../sysv/linux/sw_64/bits/termios-c_oflag.h | 67 ++
.../sysv/linux/sw_64/bits/termios-struct.h | 38 +
sysdeps/unix/sysv/linux/sw_64/bits/timerfd.h | 30 +
.../unix/sysv/linux/sw_64/bits/typesizes.h | 87 ++
sysdeps/unix/sysv/linux/sw_64/bits/wordsize.h | 19 +
sysdeps/unix/sysv/linux/sw_64/brk_call.h | 27 +
sysdeps/unix/sysv/linux/sw_64/dl-auxv.h | 40 +
sysdeps/unix/sysv/linux/sw_64/dl-support.c | 2 +
sysdeps/unix/sysv/linux/sw_64/dl-sysdep.c | 5 +
.../unix/sysv/linux/sw_64/errlist-compat.c | 43 +
sysdeps/unix/sysv/linux/sw_64/fraiseexcpt.S | 58 ++
sysdeps/unix/sysv/linux/sw_64/fstatfs.c | 29 +
sysdeps/unix/sysv/linux/sw_64/fxstat64.c | 45 +
sysdeps/unix/sysv/linux/sw_64/fxstatat64.c | 32 +
sysdeps/unix/sysv/linux/sw_64/getclktck.c | 2 +
sysdeps/unix/sysv/linux/sw_64/getcontext.S | 440 +++++++++
sysdeps/unix/sysv/linux/sw_64/getdents.c | 18 +
sysdeps/unix/sysv/linux/sw_64/getdents64.c | 10 +
sysdeps/unix/sysv/linux/sw_64/getegid.S | 26 +
sysdeps/unix/sysv/linux/sw_64/geteuid.S | 26 +
sysdeps/unix/sysv/linux/sw_64/gethostname.c | 45 +
sysdeps/unix/sysv/linux/sw_64/getppid.S | 26 +
sysdeps/unix/sysv/linux/sw_64/getrlimit64.c | 54 ++
sysdeps/unix/sysv/linux/sw_64/gettimeofday.c | 26 +
.../unix/sysv/linux/sw_64/glob-lstat-compat.c | 2 +
sysdeps/unix/sysv/linux/sw_64/globfree.c | 36 +
.../sysv/linux/sw_64/ieee_get_fp_control.S | 50 +
.../sysv/linux/sw_64/ieee_set_fp_control.S | 46 +
sysdeps/unix/sysv/linux/sw_64/ioperm.c | 853 ++++++++++++++++++
sysdeps/unix/sysv/linux/sw_64/ipc_priv.h | 21 +
.../unix/sysv/linux/sw_64/jmp_buf-macros.h | 6 +
.../unix/sysv/linux/sw_64/kernel-features.h | 53 ++
.../sysv/linux/sw_64/kernel_rt_sigframe.h | 25 +
.../unix/sysv/linux/sw_64/kernel_sigaction.h | 10 +
sysdeps/unix/sysv/linux/sw_64/kernel_stat.h | 91 ++
.../unix/sysv/linux/sw_64/kernel_sysinfo.h | 6 +
.../unix/sysv/linux/sw_64/kernel_termios.h | 43 +
sysdeps/unix/sysv/linux/sw_64/librt-compat.c | 24 +
sysdeps/unix/sysv/linux/sw_64/localplt.data | 33 +
sysdeps/unix/sysv/linux/sw_64/lxstat64.c | 46 +
sysdeps/unix/sysv/linux/sw_64/makecontext.S | 164 ++++
sysdeps/unix/sysv/linux/sw_64/nldbl-abi.h | 8 +
sysdeps/unix/sysv/linux/sw_64/oldglob.c | 96 ++
sysdeps/unix/sysv/linux/sw_64/osf_adjtime.c | 139 +++
sysdeps/unix/sysv/linux/sw_64/osf_getitimer.c | 42 +
sysdeps/unix/sysv/linux/sw_64/osf_getrusage.c | 39 +
.../unix/sysv/linux/sw_64/osf_gettimeofday.c | 47 +
sysdeps/unix/sysv/linux/sw_64/osf_setitimer.c | 51 ++
.../unix/sysv/linux/sw_64/osf_settimeofday.c | 48 +
sysdeps/unix/sysv/linux/sw_64/osf_utimes.c | 36 +
sysdeps/unix/sysv/linux/sw_64/osf_wait4.c | 40 +
sysdeps/unix/sysv/linux/sw_64/pipe.S | 1 +
sysdeps/unix/sysv/linux/sw_64/pointer_guard.h | 57 ++
sysdeps/unix/sysv/linux/sw_64/register-dump.h | 239 +++++
sysdeps/unix/sysv/linux/sw_64/rt_sigaction.S | 87 ++
sysdeps/unix/sysv/linux/sw_64/select.c | 52 ++
sysdeps/unix/sysv/linux/sw_64/setcontext.S | 34 +
sysdeps/unix/sysv/linux/sw_64/setfpucw.c | 56 ++
sysdeps/unix/sysv/linux/sw_64/setrlimit64.c | 52 ++
sysdeps/unix/sysv/linux/sw_64/settimeofday.c | 22 +
sysdeps/unix/sysv/linux/sw_64/shlib-versions | 20 +
.../unix/sysv/linux/sw_64/sigcontextinfo.h | 30 +
sysdeps/unix/sysv/linux/sw_64/sizes.h | 23 +
sysdeps/unix/sysv/linux/sw_64/statfs.c | 29 +
sysdeps/unix/sysv/linux/sw_64/sw_64/ptrace.h | 18 +
sysdeps/unix/sysv/linux/sw_64/sw_64/regdef.h | 44 +
sysdeps/unix/sysv/linux/sw_64/swapcontext.S | 50 +
sysdeps/unix/sysv/linux/sw_64/sys/acct.h | 62 ++
sysdeps/unix/sysv/linux/sw_64/sys/io.h | 90 ++
sysdeps/unix/sysv/linux/sw_64/sys/ucontext.h | 92 ++
sysdeps/unix/sysv/linux/sw_64/sys/user.h | 52 ++
sysdeps/unix/sysv/linux/sw_64/syscalls.list | 27 +
sysdeps/unix/sysv/linux/sw_64/sysconf.c | 126 +++
.../sysv/linux/sw_64/timer_t_was_int_compat.h | 19 +
.../sysv/linux/sw_64/ucontext-offsets.sym | 28 +
sysdeps/unix/sysv/linux/sw_64/wait4.c | 28 +
sysdeps/unix/sysv/linux/sw_64/wordexp.c | 1 +
sysdeps/unix/sysv/linux/sw_64/xstat64.c | 46 +
sysdeps/unix/sysv/linux/sw_64/xstatconv.c | 120 +++
sysdeps/unix/sysv/linux/sw_64/xstatconv.h | 22 +
sysdeps/unix/sysv/linux/sw_64/xstatver.h | 14 +
113 files changed, 6529 insertions(+)
create mode 100644 sysdeps/unix/sysv/linux/sw_64/a.out.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/adjtime.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/adjtimex.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/aio_cancel.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/a.out.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/dirent.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/elfclass.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/epoll.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/errno.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/eventfd.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/fcntl.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/inotify.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/ioctls.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/mman.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/netdb.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/procfs-prregset.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/procfs.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/pthread_stack_min.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/resource.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/sigaction.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/signalfd.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/signum-arch.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/sigstack.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/socket-constants.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/socket_type.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/statfs.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/struct_stat.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/termios-baud.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/termios-c_cc.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/termios-c_cflag.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/termios-c_iflag.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/termios-c_lflag.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/termios-c_oflag.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/termios-struct.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/timerfd.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/typesizes.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/bits/wordsize.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/brk_call.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/dl-auxv.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/dl-support.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/dl-sysdep.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/errlist-compat.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/fraiseexcpt.S
create mode 100644 sysdeps/unix/sysv/linux/sw_64/fstatfs.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/fxstat64.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/fxstatat64.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/getclktck.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/getcontext.S
create mode 100644 sysdeps/unix/sysv/linux/sw_64/getdents.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/getdents64.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/getegid.S
create mode 100644 sysdeps/unix/sysv/linux/sw_64/geteuid.S
create mode 100644 sysdeps/unix/sysv/linux/sw_64/gethostname.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/getppid.S
create mode 100644 sysdeps/unix/sysv/linux/sw_64/getrlimit64.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/gettimeofday.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/glob-lstat-compat.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/globfree.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/ieee_get_fp_control.S
create mode 100644 sysdeps/unix/sysv/linux/sw_64/ieee_set_fp_control.S
create mode 100644 sysdeps/unix/sysv/linux/sw_64/ioperm.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/ipc_priv.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/jmp_buf-macros.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/kernel-features.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/kernel_rt_sigframe.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/kernel_sigaction.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/kernel_stat.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/kernel_sysinfo.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/kernel_termios.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/librt-compat.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/localplt.data
create mode 100644 sysdeps/unix/sysv/linux/sw_64/lxstat64.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/makecontext.S
create mode 100644 sysdeps/unix/sysv/linux/sw_64/nldbl-abi.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/oldglob.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/osf_adjtime.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/osf_getitimer.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/osf_getrusage.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/osf_gettimeofday.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/osf_setitimer.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/osf_settimeofday.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/osf_utimes.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/osf_wait4.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/pipe.S
create mode 100644 sysdeps/unix/sysv/linux/sw_64/pointer_guard.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/register-dump.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/rt_sigaction.S
create mode 100644 sysdeps/unix/sysv/linux/sw_64/select.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/setcontext.S
create mode 100644 sysdeps/unix/sysv/linux/sw_64/setfpucw.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/setrlimit64.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/settimeofday.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/shlib-versions
create mode 100644 sysdeps/unix/sysv/linux/sw_64/sigcontextinfo.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/sizes.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/statfs.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/sw_64/ptrace.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/sw_64/regdef.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/swapcontext.S
create mode 100644 sysdeps/unix/sysv/linux/sw_64/sys/acct.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/sys/io.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/sys/ucontext.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/sys/user.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/syscalls.list
create mode 100644 sysdeps/unix/sysv/linux/sw_64/sysconf.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/timer_t_was_int_compat.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/ucontext-offsets.sym
create mode 100644 sysdeps/unix/sysv/linux/sw_64/wait4.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/wordexp.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/xstat64.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/xstatconv.c
create mode 100644 sysdeps/unix/sysv/linux/sw_64/xstatconv.h
create mode 100644 sysdeps/unix/sysv/linux/sw_64/xstatver.h
diff --git a/sysdeps/unix/sysv/linux/sw_64/a.out.h b/sysdeps/unix/sysv/linux/sw_64/a.out.h
new file mode 100644
index 00000000..2004d974
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/a.out.h
@@ -0,0 +1,197 @@
+#ifndef __A_OUT_GNU_H__
+#define __A_OUT_GNU_H__
+
+#include <bits/a.out.h>
+
+#define __GNU_EXEC_MACROS__
+
+/*
+ * OSF/1 ECOFF header structs. ECOFF files consist of:
+ * - a file header (struct filehdr),
+ * - an a.out header (struct aouthdr),
+ * - one or more section headers (struct scnhdr).
+ * The filhdr's "f_nscns" field contains the
+ * number of section headers.
+ */
+
+struct filehdr
+{
+ /* OSF/1 "file" header */
+ unsigned short f_magic, f_nscns;
+ unsigned int f_timdat;
+ unsigned long f_symptr;
+ unsigned int f_nsyms;
+ unsigned short f_opthdr, f_flags;
+};
+
+struct aouthdr
+{
+ unsigned long info; /* After that it looks quite normal.. */
+ unsigned long tsize;
+ unsigned long dsize;
+ unsigned long bsize;
+ unsigned long entry;
+ unsigned long
+ text_start; /* With a few additions that actually make sense. */
+ unsigned long data_start;
+ unsigned long bss_start;
+ unsigned int gprmask,
+ fprmask; /* Bitmask of general & floating point regs used in binary. */
+ unsigned long gpvalue;
+};
+
+struct scnhdr
+{
+ char s_name[8];
+ unsigned long s_paddr;
+ unsigned long s_vaddr;
+ unsigned long s_size;
+ unsigned long s_scnptr;
+ unsigned long s_relptr;
+ unsigned long s_lnnoptr;
+ unsigned short s_nreloc;
+ unsigned short s_nlnno;
+ unsigned int s_flags;
+};
+
+struct exec
+{
+ /* OSF/1 "file" header */
+ struct filehdr fh;
+ struct aouthdr ah;
+};
+
+#define a_info ah.info
+#define a_text ah.tsize
+#define a_data ah.dsize
+#define a_bss ah.bsize
+#define a_entry ah.entry
+#define a_textstart ah.text_start
+#define a_datastart ah.data_start
+#define a_bssstart ah.bss_start
+#define a_gprmask ah.gprmask
+#define a_fprmask ah.fprmask
+#define a_gpvalue ah.gpvalue
+
+#define AOUTHSZ sizeof (struct aouthdr)
+#define SCNHSZ sizeof (struct scnhdr)
+#define SCNROUND 16
+
+enum machine_type
+{
+ M_OLDSUN2 = 0,
+ M_68010 = 1,
+ M_68020 = 2,
+ M_SPARC = 3,
+ M_386 = 100,
+ M_MIPS1 = 151,
+ M_MIPS2 = 152
+};
+
+#define N_MAGIC(exec) ((exec).a_info & 0xffff)
+#define N_MACHTYPE(exec) ((enum machine_type) (((exec).a_info >> 16) & 0xff))
+#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
+#define N_SET_INFO(exec, magic, type, flags) \
+ ((exec).a_info = ((magic) &0xffff) | (((int) (type) &0xff) << 16) \
+ | (((flags) &0xff) << 24))
+#define N_SET_MAGIC(exec, magic) \
+ ((exec).a_info = ((exec).a_info & 0xffff0000) | ((magic) &0xffff))
+#define N_SET_MACHTYPE(exec, machtype) \
+ ((exec).a_info \
+ = ((exec).a_info & 0xff00ffff) | ((((int) (machtype)) & 0xff) << 16))
+#define N_SET_FLAGS(exec, flags) \
+ ((exec).a_info = ((exec).a_info & 0x00ffffff) | (((flags) &0xff) << 24))
+
+/* Code indicating object file or impure executable. */
+#define OMAGIC 0407
+/* Code indicating pure executable. */
+#define NMAGIC 0410
+/* Code indicating demand-paged executable. */
+#define ZMAGIC 0413
+/* This indicates a demand-paged executable with the header in the text.
+ The first page is unmapped to help trap NULL pointer references. */
+#define QMAGIC 0314
+/* Code indicating core file. */
+#define CMAGIC 0421
+
+#define N_TRSIZE(x) 0
+#define N_DRSIZE(x) 0
+#define N_SYMSIZE(x) 0
+#define N_BADMAG(x) \
+ (N_MAGIC (x) != OMAGIC && N_MAGIC (x) != NMAGIC && N_MAGIC (x) != ZMAGIC \
+ && N_MAGIC (x) != QMAGIC)
+#define _N_HDROFF(x) (1024 - sizeof (struct exec))
+#define N_TXTOFF(x) \
+ ((long) N_MAGIC (x) == ZMAGIC \
+ ? 0 \
+ : ((sizeof (struct exec) + (x).fh.f_nscns * SCNHSZ + SCNROUND - 1) \
+ & ~(SCNROUND - 1)))
+
+#define N_DATOFF(x) (N_TXTOFF (x) + (x).a_text)
+#define N_TRELOFF(x) (N_DATOFF (x) + (x).a_data)
+#define N_DRELOFF(x) (N_TRELOFF (x) + N_TRSIZE (x))
+#define N_SYMOFF(x) (N_DRELOFF (x) + N_DRSIZE (x))
+#define N_STROFF(x) (N_SYMOFF (x) + N_SYMSIZE (x))
+
+/* Address of text segment in memory after it is loaded. */
+#define N_TXTADDR(x) ((x).a_textstart)
+
+/* Address of data segment in memory after it is loaded. */
+#define SEGMENT_SIZE 1024
+
+#define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
+#define _N_TXTENDADDR(x) (N_TXTADDR (x) + (x).a_text)
+
+#define N_DATADDR(x) ((x).a_datastart)
+#define N_BSSADDR(x) ((x).a_bssstart)
+
+#if !defined(N_NLIST_DECLARED)
+struct nlist
+{
+ union
+ {
+ char *n_name;
+ struct nlist *n_next;
+ long n_strx;
+ } n_un;
+ unsigned char n_type;
+ char n_other;
+ short n_desc;
+ unsigned long n_value;
+};
+#endif /* no N_NLIST_DECLARED. */
+
+#define N_UNDF 0
+#define N_ABS 2
+#define N_TEXT 4
+#define N_DATA 6
+#define N_BSS 8
+#define N_FN 15
+#define N_EXT 1
+#define N_TYPE 036
+#define N_STAB 0340
+#define N_INDR 0xa
+#define N_SETA 0x14 /* Absolute set element symbol. */
+#define N_SETT 0x16 /* Text set element symbol. */
+#define N_SETD 0x18 /* Data set element symbol. */
+#define N_SETB 0x1A /* Bss set element symbol. */
+#define N_SETV 0x1C /* Pointer to set vector in data area. */
+
+#if !defined(N_RELOCATION_INFO_DECLARED)
+/* This structure describes a single relocation to be performed.
+ The text-relocation section of the file is a vector of these structures,
+ all of which apply to the text section.
+ Likewise, the data-relocation section applies to the data section. */
+
+struct relocation_info
+{
+ int r_address;
+ unsigned int r_symbolnum : 24;
+ unsigned int r_pcrel : 1;
+ unsigned int r_length : 2;
+ unsigned int r_extern : 1;
+ unsigned int r_pad : 4;
+};
+#endif /* no N_RELOCATION_INFO_DECLARED. */
+
+#endif /* __A_OUT_GNU_H__ */
diff --git a/sysdeps/unix/sysv/linux/sw_64/adjtime.c b/sysdeps/unix/sysv/linux/sw_64/adjtime.c
new file mode 100644
index 00000000..6b64d1b9
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/adjtime.c
@@ -0,0 +1,22 @@
+/* adjtime -- Adjust the current time of day. Linux/Sw_64/tv64 version.
+ Copyright (C) 2019-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/>. */
+
+/* We can use the generic Linux implementation, but we have to override its
+ default symbol version. */
+#define VERSION_adjtime GLIBC_2.1
+#include <sysdeps/unix/sysv/linux/adjtime.c>
diff --git a/sysdeps/unix/sysv/linux/sw_64/adjtimex.c b/sysdeps/unix/sysv/linux/sw_64/adjtimex.c
new file mode 100644
index 00000000..2e3d8d49
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/adjtimex.c
@@ -0,0 +1,22 @@
+/* adjtimex -- Adjust the current time of day. Linux/Sw_64/tv64 version.
+ Copyright (C) 2019-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/>. */
+
+/* We can use the generic Linux implementation, but we have to override its
+ default symbol version. */
+#define VERSION_adjtimex GLIBC_2.1
+#include <sysdeps/unix/sysv/linux/adjtimex.c>
diff --git a/sysdeps/unix/sysv/linux/sw_64/aio_cancel.c b/sysdeps/unix/sysv/linux/sw_64/aio_cancel.c
new file mode 100644
index 00000000..222126ea
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/aio_cancel.c
@@ -0,0 +1,35 @@
+#include <shlib-compat.h>
+
+#define aio_cancel64 XXX
+#include <aio.h>
+#undef aio_cancel64
+#include <errno.h>
+
+extern __typeof (aio_cancel) __new_aio_cancel;
+extern __typeof (aio_cancel) __old_aio_cancel;
+
+#define __aio_cancel __new_aio_cancel
+
+#include <rt/aio_cancel.c>
+
+#undef __aio_cancel
+versioned_symbol (libc, __new_aio_cancel, aio_cancel, GLIBC_2_34);
+versioned_symbol (libc, __new_aio_cancel, aio_cancel64, GLIBC_2_34);
+#if OTHER_SHLIB_COMPAT (librt, GLIBC_2_3, GLIBC_2_34)
+compat_symbol (librt, __new_aio_cancel, aio_cancel, GLIBC_2_3);
+compat_symbol (librt, __new_aio_cancel, aio_cancel64, GLIBC_2_3);
+#endif
+
+#if OTHER_SHLIB_COMPAT (librt, GLIBC_2_1, GLIBC_2_3)
+
+# undef ECANCELED
+# define __aio_cancel __old_aio_cancel
+# define ECANCELED 125
+
+# include <rt/aio_cancel.c>
+
+# undef __aio_cancel
+compat_symbol (librt, __old_aio_cancel, aio_cancel, GLIBC_2_1);
+compat_symbol (librt, __old_aio_cancel, aio_cancel64, GLIBC_2_1);
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/a.out.h b/sysdeps/unix/sysv/linux/sw_64/bits/a.out.h
new file mode 100644
index 00000000..f15e82c9
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/a.out.h
@@ -0,0 +1,9 @@
+#ifndef __A_OUT_GNU_H__
+# error "Never use <bits/a.out.h> directly; include <a.out.h> instead."
+#endif
+#ifndef __A_OUT_GNU_H__
+# error "Never use <bits/a.out.h> directly; include <a.out.h> instead."
+#endif
+#ifndef __A_OUT_GNU_H__
+# error "Never use <bits/a.out.h> directly; include <a.out.h> instead."
+#endif
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/dirent.h b/sysdeps/unix/sysv/linux/sw_64/bits/dirent.h
new file mode 100644
index 00000000..ca27db2f
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/dirent.h
@@ -0,0 +1,57 @@
+/* Copyright (C) 1996-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 _BITS_DIRENT_H
+#define _BITS_DIRENT_H 1
+
+struct dirent
+{
+#if (defined __USE_FILE_OFFSET64 || defined __sw_64__)
+ __ino64_t d_ino;
+#else
+ __ino_t d_ino;
+ int __pad;
+#endif
+ __off_t d_off;
+ unsigned short int d_reclen;
+ unsigned char d_type;
+ char d_name[256]; /* We must not include limits.h! */
+};
+
+#ifdef __USE_LARGEFILE64
+/* Note dirent64 is the same as dirent. */
+struct dirent64
+{
+ __ino64_t d_ino;
+ __off64_t d_off;
+ unsigned short int d_reclen;
+ unsigned char d_type;
+ char d_name[256]; /* We must not include limits.h! */
+};
+#endif
+
+#define d_fileno d_ino /* Backwards compatibility. */
+
+#undef _DIRENT_HAVE_D_NAMLEN
+#define _DIRENT_HAVE_D_RECLEN
+#define _DIRENT_HAVE_D_OFF
+#define _DIRENT_HAVE_D_TYPE
+
+/* Inform libc code that these two types are effectively identical. */
+#define _DIRENT_MATCHES_DIRENT64 1
+
+#endif /* bits/dirent.h */
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/elfclass.h b/sysdeps/unix/sysv/linux/sw_64/bits/elfclass.h
new file mode 100644
index 00000000..e74c5f72
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/elfclass.h
@@ -0,0 +1,14 @@
+/* This file specifies the native word size of the machine, which indicates
+ the ELF file class used for executables and shared objects on this
+ machine. */
+
+#ifndef _LINK_H
+# error "Never use <bits/elfclass.h> directly; include <link.h> instead."
+#endif
+
+#include <bits/wordsize.h>
+
+#define __ELF_NATIVE_CLASS __WORDSIZE
+
+/* Linux/Sw_64 is exceptional as it has .hash section with 64 bit entries. */
+typedef uint64_t Elf_Symndx;
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/epoll.h b/sysdeps/unix/sysv/linux/sw_64/bits/epoll.h
new file mode 100644
index 00000000..6c78bb04
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/epoll.h
@@ -0,0 +1,27 @@
+/* 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
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_EPOLL_H
+# error "Never use <bits/epoll.h> directly; include <sys/epoll.h> instead."
+#endif
+
+/* Flags to be passed to epoll_create1. */
+enum
+{
+ EPOLL_CLOEXEC = 010000000
+#define EPOLL_CLOEXEC EPOLL_CLOEXEC
+};
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/errno.h b/sysdeps/unix/sysv/linux/sw_64/bits/errno.h
new file mode 100644
index 00000000..9fdbfe53
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/errno.h
@@ -0,0 +1,53 @@
+/* Error constants. Linux/Sw_64 specific version.
+ Copyright (C) 1996-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 _BITS_ERRNO_H
+#define _BITS_ERRNO_H 1
+
+#if !defined _ERRNO_H
+# error "Never include <bits/errno.h> directly; use <errno.h> instead."
+#endif
+
+#include <linux/errno.h>
+
+/* Older Linux headers do not define these constants. */
+#ifndef ENOTSUP
+# define ENOTSUP EOPNOTSUPP
+#endif
+
+#ifndef ECANCELED
+# define ECANCELED 131
+#endif
+
+#ifndef EOWNERDEAD
+# define EOWNERDEAD 136
+#endif
+
+#ifndef ENOTRECOVERABLE
+# define ENOTRECOVERABLE 137
+#endif
+
+#ifndef ERFKILL
+# define ERFKILL 138
+#endif
+
+#ifndef EHWPOISON
+# define EHWPOISON 139
+#endif
+
+#endif /* bits/errno.h. */
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/eventfd.h b/sysdeps/unix/sysv/linux/sw_64/bits/eventfd.h
new file mode 100644
index 00000000..6ddae34b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/eventfd.h
@@ -0,0 +1,32 @@
+/* Copyright (C) 2007-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 _SYS_EVENTFD_H
+# error \
+ "Never use <bits/eventfd.h> directly; include <sys/eventfd.h> instead."
+#endif
+
+/* Flags for eventfd. */
+enum
+{
+ EFD_SEMAPHORE = 000000001,
+#define EFD_SEMAPHORE EFD_SEMAPHORE
+ EFD_CLOEXEC = 010000000,
+#define EFD_CLOEXEC EFD_CLOEXEC
+ EFD_NONBLOCK = 000000004
+#define EFD_NONBLOCK EFD_NONBLOCK
+};
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/fcntl.h b/sysdeps/unix/sysv/linux/sw_64/bits/fcntl.h
new file mode 100644
index 00000000..48ae4a7c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/fcntl.h
@@ -0,0 +1,87 @@
+/* O_*, F_*, FD_* bit values for Linux.
+ Copyright (C) 1995-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 _FCNTL_H
+# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
+#endif
+
+#define O_CREAT 01000 /* not fcntl */
+#define O_TRUNC 02000 /* not fcntl */
+#define O_EXCL 04000 /* not fcntl */
+#define O_NOCTTY 010000 /* not fcntl */
+
+#define O_NONBLOCK 00004
+#define O_APPEND 00010
+#define O_SYNC 020040000
+
+#define __O_DIRECTORY 0100000 /* Must be a directory. */
+#define __O_NOFOLLOW 0200000 /* Do not follow links. */
+#define __O_CLOEXEC 010000000 /* Set close_on_exec. */
+
+#define __O_DIRECT 02000000 /* Direct disk access. */
+#define __O_NOATIME 04000000 /* Do not set atime. */
+#define __O_PATH 040000000 /* Resolve pathname but do not open file. */
+#define __O_TMPFILE 0100100000 /* Atomically create nameless file. */
+
+/* Not necessary, files are always with 64bit off_t. */
+#define __O_LARGEFILE 0
+
+#define __O_DSYNC 040000 /* Synchronize data. */
+
+#define F_GETLK 7 /* Get record locking info. */
+#define F_SETLK 8 /* Set record locking info (non-blocking). */
+#define F_SETLKW 9 /* Set record locking info (blocking). */
+#define F_GETLK64 F_GETLK /* Get record locking info. */
+#define F_SETLK64 F_SETLK /* Set record locking info (non-blocking). */
+#define F_SETLKW64 F_SETLKW /* Set record locking info (blocking). */
+
+#define __F_SETOWN 5 /* Get owner of socket (receiver of SIGIO). */
+#define __F_GETOWN 6 /* Set owner of socket (receiver of SIGIO). */
+
+/* For posix fcntl() and `l_type' field of a `struct flock' for lockf() */
+#define F_RDLCK 1 /* Read lock. */
+#define F_WRLCK 2 /* Write lock. */
+#define F_UNLCK 8 /* Remove lock. */
+
+/* for old implementation of bsd flock () */
+#define F_EXLCK 16 /* or 3 */
+#define F_SHLCK 32 /* or 4 */
+
+/* We don't need to support __USE_FILE_OFFSET64. */
+struct flock
+{
+ short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
+ short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
+ __off_t l_start; /* Offset where the lock begins. */
+ __off_t l_len; /* Size of the locked area; zero means until EOF. */
+ __pid_t l_pid; /* Process holding the lock. */
+};
+
+#ifdef __USE_LARGEFILE64
+struct flock64
+{
+ short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
+ short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
+ __off64_t l_start; /* Offset where the lock begins. */
+ __off64_t l_len; /* Size of the locked area; zero means until EOF. */
+ __pid_t l_pid; /* Process holding the lock. */
+};
+#endif
+
+/* Include generic Linux declarations. */
+#include <bits/fcntl-linux.h>
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/inotify.h b/sysdeps/unix/sysv/linux/sw_64/bits/inotify.h
new file mode 100644
index 00000000..9d9e2872
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/inotify.h
@@ -0,0 +1,30 @@
+/* Copyright (C) 2005-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 _SYS_INOTIFY_H
+# error \
+ "Never use <bits/inotify.h> directly; include <sys/inotify.h> instead."
+#endif
+
+/* Flags for the parameter of inotify_init1. */
+enum
+{
+ IN_CLOEXEC = 010000000,
+#define IN_CLOEXEC IN_CLOEXEC
+ IN_NONBLOCK = 000000004
+#define IN_NONBLOCK IN_NONBLOCK
+};
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/ioctls.h b/sysdeps/unix/sysv/linux/sw_64/bits/ioctls.h
new file mode 100644
index 00000000..41c9e754
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/ioctls.h
@@ -0,0 +1,36 @@
+/* Copyright (C) 1996-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 _SYS_IOCTL_H
+# error "Never use <bits/ioctls.h> directly; include <sys/ioctl.h> instead."
+#endif
+
+/* Use the definitions from the kernel header files. */
+#include <asm/ioctls.h>
+
+/* Oh well, this is necessary since the kernel data structure is
+ different from the user-level version. */
+#undef TCGETS
+#undef TCSETS
+#undef TCSETSW
+#undef TCSETSF
+#define TCGETS _IOR ('t', 19, char[44])
+#define TCSETS _IOW ('t', 20, char[44])
+#define TCSETSW _IOW ('t', 21, char[44])
+#define TCSETSF _IOW ('t', 22, char[44])
+
+#include <linux/sockios.h>
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/mman.h b/sysdeps/unix/sysv/linux/sw_64/bits/mman.h
new file mode 100644
index 00000000..f8e9f148
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/mman.h
@@ -0,0 +1,67 @@
+/* Definitions for POSIX memory map interface. Linux/Sw_64 version.
+ 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 _SYS_MMAN_H
+# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
+#endif
+
+/* The following definitions basically come from the kernel headers.
+ But the kernel header is not namespace clean. */
+
+#define __MAP_ANONYMOUS 0x10 /* Don't use a file. */
+
+/* These are Linux-specific. */
+#define MAP_GROWSDOWN 0x01000 /* Stack-like segment. */
+#define MAP_DENYWRITE 0x02000 /* ETXTBSY */
+#define MAP_EXECUTABLE 0x04000 /* Mark it as an executable. */
+#define MAP_LOCKED 0x08000 /* Lock the mapping. */
+#define MAP_NORESERVE 0x10000 /* Don't check for reservations. */
+#define MAP_POPULATE 0x20000 /* Populate (prefault) pagetables. */
+#define MAP_NONBLOCK 0x40000 /* Do not block on IO. */
+#define MAP_STACK 0x80000 /* Allocation is for a stack. */
+#define MAP_HUGETLB 0x100000 /* Create huge page mapping. */
+#define MAP_FIXED_NOREPLACE \
+ 0x200000 /* MAP_FIXED but do not unmap \
+ underlying mapping. */
+
+/* Flags for `mlockall'. */
+#define MCL_CURRENT 8192
+#define MCL_FUTURE 16384
+#define MCL_ONFAULT 32768
+
+#include <bits/mman-linux.h>
+
+/* Values that differ from standard <mman-linux.h>. For the most part newer
+ values are shared, but older values are skewed. */
+
+#undef MAP_FIXED
+#define MAP_FIXED 0x100
+
+#undef MS_SYNC
+#define MS_SYNC 2
+#undef MS_INVALIDATE
+#define MS_INVALIDATE 4
+
+#ifdef __USE_MISC
+# undef MADV_DONTNEED
+# define MADV_DONTNEED 6
+#endif
+#ifdef __USE_XOPEN2K
+# undef POSIX_MADV_DONTNEED
+# define POSIX_MADV_DONTNEED 6
+#endif
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/netdb.h b/sysdeps/unix/sysv/linux/sw_64/bits/netdb.h
new file mode 100644
index 00000000..d97e16a4
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/netdb.h
@@ -0,0 +1,33 @@
+/* Copyright (C) 1996-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 _NETDB_H
+# error "Never include <bits/netdb.h> directly; use <netdb.h> instead."
+#endif
+
+/* Description of data base entry for a single network. NOTE: here a
+ poor assumption is made. The network number is expected to fit
+ into an unsigned long int variable. */
+struct netent
+{
+ char *n_name; /* Official name of network. */
+ char **n_aliases; /* Alias list. */
+ int n_addrtype; /* Net address type. */
+ /* XXX We should probably use uint32_t for the field and ensure
+ compatibility by adding appropriate padding. */
+ uint32_t n_net; /* Network number. */
+};
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/procfs-prregset.h b/sysdeps/unix/sysv/linux/sw_64/bits/procfs-prregset.h
new file mode 100644
index 00000000..9b00b279
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/procfs-prregset.h
@@ -0,0 +1,26 @@
+/* Types of prgregset_t and prfpregset_t. SW_64 version.
+ Copyright (C) 2018-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 _SYS_PROCFS_H
+# error \
+ "Never include <bits/procfs-prregset.h> directly; use <sys/procfs.h> instead."
+#endif
+
+typedef gregset_t __prgregset_t;
+typedef fpregset_t __prfpregset_t;
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/procfs.h b/sysdeps/unix/sysv/linux/sw_64/bits/procfs.h
new file mode 100644
index 00000000..0b3453ae
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/procfs.h
@@ -0,0 +1,38 @@
+/* Types for registers for sys/procfs.h. SW_64 version.
+ Copyright (C) 1996-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 _SYS_PROCFS_H
+# error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
+#endif
+
+#include <signal.h>
+#include <sys/ucontext.h>
+
+/*
+ * The OSF/1 version of <sys/procfs.h> makes gregset_t 46 entries long.
+ * I have no idea why that is so. For now, we just leave it at 33
+ * (32 general regs + processor status word).
+ */
+#define ELF_NGREG 33
+#define ELF_NFPREG 32
+
+typedef unsigned long elf_greg_t;
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+typedef double elf_fpreg_t;
+typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/pthread_stack_min.h b/sysdeps/unix/sysv/linux/sw_64/bits/pthread_stack_min.h
new file mode 100644
index 00000000..7e785f4a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/pthread_stack_min.h
@@ -0,0 +1,20 @@
+/* Definition of PTHREAD_STACK_MIN. Linux/SW_64 version.
+ Copyright (C) 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 Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library. If not, see
+ <https://www.gnu.org/licenses/>. */
+
+/* Minimum size for a thread. We are free to choose a reasonable value. */
+#define PTHREAD_STACK_MIN 24576
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/resource.h b/sysdeps/unix/sysv/linux/sw_64/bits/resource.h
new file mode 100644
index 00000000..9c4a2d56
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/resource.h
@@ -0,0 +1,223 @@
+/* Bit values & structures for resource limits. Sw_64/Linux version.
+ Copyright (C) 1994-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 _SYS_RESOURCE_H
+# error \
+ "Never use <bits/resource.h> directly; include <sys/resource.h> instead."
+#endif
+
+#include <bits/types.h>
+
+/* Transmute defines to enumerations. The macro re-definitions are
+ necessary because some programs want to test for operating system
+ features with #ifdef RUSAGE_SELF. In ISO C the reflexive
+ definition is a no-op. */
+
+/* Kinds of resource limit. */
+enum __rlimit_resource
+{
+ /* Per-process CPU limit, in seconds. */
+ RLIMIT_CPU = 0,
+#define RLIMIT_CPU RLIMIT_CPU
+
+ /* Largest file that can be created, in bytes. */
+ RLIMIT_FSIZE = 1,
+#define RLIMIT_FSIZE RLIMIT_FSIZE
+
+ /* Maximum size of data segment, in bytes. */
+ RLIMIT_DATA = 2,
+#define RLIMIT_DATA RLIMIT_DATA
+
+ /* Maximum size of stack segment, in bytes. */
+ RLIMIT_STACK = 3,
+#define RLIMIT_STACK RLIMIT_STACK
+
+ /* Largest core file that can be created, in bytes. */
+ RLIMIT_CORE = 4,
+#define RLIMIT_CORE RLIMIT_CORE
+
+ /* Largest resident set size, in bytes.
+ This affects swapping; processes that are exceeding their
+ resident set size will be more likely to have physical memory
+ taken from them. */
+ __RLIMIT_RSS = 5,
+#define RLIMIT_RSS __RLIMIT_RSS
+
+ /* Number of open files. */
+ RLIMIT_NOFILE = 6,
+ __RLIMIT_OFILE = RLIMIT_NOFILE, /* BSD name for same. */
+#define RLIMIT_NOFILE RLIMIT_NOFILE
+#define RLIMIT_OFILE __RLIMIT_OFILE
+
+ /* Address space limit (?) */
+ RLIMIT_AS = 7,
+#define RLIMIT_AS RLIMIT_AS
+
+ /* Number of processes. */
+ __RLIMIT_NPROC = 8,
+#define RLIMIT_NPROC __RLIMIT_NPROC
+
+ /* Locked-in-memory address space. */
+ __RLIMIT_MEMLOCK = 9,
+#define RLIMIT_MEMLOCK __RLIMIT_MEMLOCK
+
+ /* Maximum number of file locks. */
+ __RLIMIT_LOCKS = 10,
+#define RLIMIT_LOCKS __RLIMIT_LOCKS
+
+ /* Maximum number of pending signals. */
+ __RLIMIT_SIGPENDING = 11,
+#define RLIMIT_SIGPENDING __RLIMIT_SIGPENDING
+
+ /* Maximum bytes in POSIX message queues. */
+ __RLIMIT_MSGQUEUE = 12,
+#define RLIMIT_MSGQUEUE __RLIMIT_MSGQUEUE
+
+ /* Maximum nice priority allowed to raise to.
+ Nice levels 19 .. -20 correspond to 0 .. 39
+ values of this resource limit. */
+ __RLIMIT_NICE = 13,
+#define RLIMIT_NICE __RLIMIT_NICE
+
+ /* Maximum realtime priority allowed for non-priviledged
+ processes. */
+ __RLIMIT_RTPRIO = 14,
+#define RLIMIT_RTPRIO __RLIMIT_RTPRIO
+
+ /* Maximum CPU time in microseconds that a process scheduled under a
+ real-time scheduling policy may consume without making a blocking system
+ call before being forcibly descheduled. */
+ __RLIMIT_RTTIME = 15,
+#define RLIMIT_RTTIME __RLIMIT_RTTIME
+
+ __RLIMIT_NLIMITS = 16,
+ __RLIM_NLIMITS = __RLIMIT_NLIMITS
+#define RLIMIT_NLIMITS __RLIMIT_NLIMITS
+#define RLIM_NLIMITS __RLIM_NLIMITS
+};
+
+/* Value to indicate that there is no limit. */
+#ifndef __USE_FILE_OFFSET64
+# define RLIM_INFINITY ((__rlim_t) -1)
+#else
+# define RLIM_INFINITY 0xffffffffffffffffuLL
+#endif
+
+#ifdef __USE_LARGEFILE64
+# define RLIM64_INFINITY 0xffffffffffffffffuLL
+#endif
+
+/* We can represent all limits. */
+#define RLIM_SAVED_MAX RLIM_INFINITY
+#define RLIM_SAVED_CUR RLIM_INFINITY
+
+/* Type for resource quantity measurement. */
+#ifndef __USE_FILE_OFFSET64
+typedef __rlim_t rlim_t;
+#else
+typedef __rlim64_t rlim_t;
+#endif
+#ifdef __USE_LARGEFILE64
+typedef __rlim64_t rlim64_t;
+#endif
+
+struct rlimit
+{
+ /* The current (soft) limit. */
+ rlim_t rlim_cur;
+ /* The hard limit. */
+ rlim_t rlim_max;
+};
+
+#ifdef __USE_LARGEFILE64
+struct rlimit64
+{
+ /* The current (soft) limit. */
+ rlim64_t rlim_cur;
+ /* The hard limit. */
+ rlim64_t rlim_max;
+};
+#endif
+
+/* Whose usage statistics do you want? */
+enum __rusage_who
+{
+ /* The calling process. */
+ RUSAGE_SELF = 0,
+#define RUSAGE_SELF RUSAGE_SELF
+
+ /* All of its terminated child processes. */
+ RUSAGE_CHILDREN = -1
+#define RUSAGE_CHILDREN RUSAGE_CHILDREN
+
+#ifdef __USE_GNU
+ ,
+ /* The calling thread. */
+ RUSAGE_THREAD = 1
+# define RUSAGE_THREAD RUSAGE_THREAD
+/* Name for the same functionality on Solaris. */
+# define RUSAGE_LWP RUSAGE_THREAD
+#endif
+};
+
+#include <bits/types/struct_timeval.h>
+#include <bits/types/struct_rusage.h>
+
+/* Priority limits. */
+#define PRIO_MIN -20 /* Minimum priority a process can have. */
+#define PRIO_MAX 20 /* Maximum priority a process can have. */
+
+/* The type of the WHICH argument to `getpriority' and `setpriority',
+ indicating what flavor of entity the WHO argument specifies. */
+enum __priority_which
+{
+ PRIO_PROCESS = 0, /* WHO is a process ID. */
+#define PRIO_PROCESS PRIO_PROCESS
+ PRIO_PGRP = 1, /* WHO is a process group ID. */
+#define PRIO_PGRP PRIO_PGRP
+ PRIO_USER = 2 /* WHO is a user ID. */
+#define PRIO_USER PRIO_USER
+};
+
+__BEGIN_DECLS
+
+#ifdef __USE_GNU
+/* Modify and return resource limits of a process atomically. */
+# ifndef __USE_FILE_OFFSET64
+extern int prlimit (__pid_t __pid, enum __rlimit_resource __resource,
+ const struct rlimit *__new_limit,
+ struct rlimit *__old_limit) __THROW;
+# else
+# ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (prlimit,
+ (__pid_t __pid, enum __rlimit_resource __resource,
+ const struct rlimit *__new_limit,
+ struct rlimit *__old_limit),
+ prlimit64);
+# else
+# define prlimit prlimit64
+# endif
+# endif
+# ifdef __USE_LARGEFILE64
+extern int prlimit64 (__pid_t __pid, enum __rlimit_resource __resource,
+ const struct rlimit64 *__new_limit,
+ struct rlimit64 *__old_limit) __THROW;
+# endif
+#endif
+
+__END_DECLS
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/sigaction.h b/sysdeps/unix/sysv/linux/sw_64/bits/sigaction.h
new file mode 100644
index 00000000..906d94b7
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/sigaction.h
@@ -0,0 +1,82 @@
+/* The proper definitions for Linux/Sw_64 sigaction.
+ Copyright (C) 1996-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 _BITS_SIGACTION_H
+#define _BITS_SIGACTION_H 1
+
+#ifndef _SIGNAL_H
+# error "Never include <bits/sigaction.h> directly; use <signal.h> instead."
+#endif
+
+/* Structure describing the action to be taken when a signal arrives. */
+struct sigaction
+{
+ /* Signal handler. */
+#if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED
+ union
+ {
+ /* Used if SA_SIGINFO is not set. */
+ __sighandler_t sa_handler;
+ /* Used if SA_SIGINFO is set. */
+ void (*sa_sigaction) (int, siginfo_t *, void *);
+ } __sigaction_handler;
+# define sa_handler __sigaction_handler.sa_handler
+# define sa_sigaction __sigaction_handler.sa_sigaction
+#else
+ __sighandler_t sa_handler;
+#endif
+
+ /* Additional set of signals to be blocked. */
+ __sigset_t sa_mask;
+
+ /* Special flags. */
+ int sa_flags;
+};
+
+/* Bits in `sa_flags'. */
+#define SA_NOCLDSTOP 0x00000004 /* Don't send SIGCHLD when children stop. */
+#define SA_NOCLDWAIT 0x00000020 /* Don't create zombie on child death. */
+#define SA_SIGINFO \
+ 0x00000040 /* Invoke signal-catching function with \
+ three arguments instead of one. */
+#if defined __USE_XOPEN_EXTENDED || defined __USE_MISC
+# define SA_ONSTACK 0x00000001 /* Use signal stack by using `sa_restorer'. \
+ */
+#endif
+#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
+# define SA_RESTART 0x00000002 /* Restart syscall on signal return. */
+# define SA_NODEFER \
+ 0x00000008 /* Don't automatically block the signal \
+ when its handler is being executed. */
+# define SA_RESETHAND 0x00000010 /* Reset to SIG_DFL on entry to handler. */
+#endif
+#ifdef __USE_MISC
+# define SA_INTERRUPT 0x20000000 /* Historical no-op. */
+
+/* Some aliases for the SA_ constants. */
+# define SA_NOMASK SA_NODEFER
+# define SA_ONESHOT SA_RESETHAND
+# define SA_STACK SA_ONSTACK
+#endif
+
+/* Values for the HOW argument to `sigprocmask'. */
+#define SIG_BLOCK 1 /* Block signals. */
+#define SIG_UNBLOCK 2 /* Unblock signals. */
+#define SIG_SETMASK 3 /* Set the set of blocked signals. */
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/signalfd.h b/sysdeps/unix/sysv/linux/sw_64/bits/signalfd.h
new file mode 100644
index 00000000..9474ffe3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/signalfd.h
@@ -0,0 +1,30 @@
+/* Copyright (C) 2007-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 _SYS_SIGNALFD_H
+# error \
+ "Never use <bits/signalfd.h> directly; include <sys/signalfd.h> instead."
+#endif
+
+/* Flags for signalfd. */
+enum
+{
+ SFD_CLOEXEC = 010000000,
+#define SFD_CLOEXEC SFD_CLOEXEC
+ SFD_NONBLOCK = 000000004
+#define SFD_NONBLOCK SFD_NONBLOCK
+};
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/signum-arch.h b/sysdeps/unix/sysv/linux/sw_64/bits/signum-arch.h
new file mode 100644
index 00000000..e36c7e86
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/signum-arch.h
@@ -0,0 +1,67 @@
+/* Signal number definitions. Linux/Sw_64 version.
+ Copyright (C) 1996-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 _BITS_SIGNUM_ARCH_H
+#define _BITS_SIGNUM_ARCH_H 1
+
+#ifndef _SIGNAL_H
+# error "Never include <bits/signum-arch.h> directly; use <signal.h> instead."
+#endif
+
+/* Adjustments and additions to the signal number constants for
+ Linux/Sw_64. Signal values on this platform were chosen for OSF/1
+ binary compatibility, and are therefore almost identical to the
+ BSD-derived defaults. */
+
+#define SIGEMT 7 /* Emulator trap (4.2 BSD). */
+#define SIGINFO 29 /* Information request (BSD). */
+#define SIGPWR SIGINFO /* Power failure imminent (System V). */
+
+/* Historical signals specified by POSIX. */
+#define SIGBUS 10 /* Bus error. */
+#define SIGSYS 12 /* Bad system call. */
+
+/* New(er) POSIX signals (1003.1-2008, 1003.1-2013). */
+#define SIGURG 16 /* Urgent data is available at a socket. */
+#define SIGSTOP 17 /* Stop, unblockable. */
+#define SIGTSTP 18 /* Keyboard stop. */
+#define SIGCONT 19 /* Continue. */
+#define SIGCHLD 20 /* Child terminated or stopped. */
+#define SIGTTIN 21 /* Background read from control terminal. */
+#define SIGTTOU 22 /* Background write to control terminal. */
+#define SIGPOLL 23 /* Pollable event occurred (System V). */
+#define SIGXCPU 24 /* CPU time limit exceeded. */
+#define SIGVTALRM 26 /* Virtual timer expired. */
+#define SIGPROF 27 /* Profiling timer expired. */
+#define SIGXFSZ 25 /* File size limit exceeded. */
+#define SIGUSR1 30 /* User-defined signal 1. */
+#define SIGUSR2 31 /* User-defined signal 2. */
+
+/* Nonstandard signals found in all modern POSIX systems
+ (including both BSD and Linux). */
+#define SIGWINCH 28
+
+/* Archaic names for compatibility. */
+#define SIGIO SIGPOLL /* I/O now possible (4.2 BSD). */
+#define SIGIOT SIGABRT /* IOT instruction, abort() on a PDP-11. */
+#define SIGCLD SIGCHLD /* Old System V name */
+
+#define __SIGRTMIN 32
+#define __SIGRTMAX 64
+
+#endif /* <signal.h> included. */
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/sigstack.h b/sysdeps/unix/sysv/linux/sw_64/bits/sigstack.h
new file mode 100644
index 00000000..7af301ff
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/sigstack.h
@@ -0,0 +1,32 @@
+/* sigstack, sigaltstack definitions.
+ Copyright (C) 1998-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 _BITS_SIGSTACK_H
+#define _BITS_SIGSTACK_H 1
+
+#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
+# error "Never include this file directly. Use <signal.h> instead"
+#endif
+
+/* Minimum stack size for a signal handler. */
+#define MINSIGSTKSZ 4096
+
+/* System default stack size. */
+#define SIGSTKSZ 16384
+
+#endif /* bits/sigstack.h */
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/socket-constants.h b/sysdeps/unix/sysv/linux/sw_64/bits/socket-constants.h
new file mode 100644
index 00000000..cb1b5bec
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/socket-constants.h
@@ -0,0 +1,51 @@
+/* Socket constants which vary among Linux architectures. Version for sw_64.
+ Copyright (C) 2019-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 _SYS_SOCKET_H
+# error \
+ "Never include <bits/socket-constants.h> directly; use <sys/socket.h> instead."
+#endif
+
+#define SOL_SOCKET 65535
+#define SO_ACCEPTCONN 4116
+#define SO_BROADCAST 32
+#define SO_DONTROUTE 16
+#define SO_ERROR 4103
+#define SO_KEEPALIVE 8
+#define SO_LINGER 128
+#define SO_OOBINLINE 256
+#define SO_RCVBUF 4098
+#define SO_RCVLOWAT 4112
+#define SO_RCVTIMEO 4114
+#define SO_REUSEADDR 4
+#define SO_SNDBUF 4097
+#define SO_SNDLOWAT 4113
+#define SO_SNDTIMEO 4115
+#define SO_TYPE 4104
+
+#define SO_RCVTIMEO_OLD 4114
+#define SO_SNDTIMEO_OLD 4115
+#define SO_RCVTIMEO_NEW 66
+#define SO_SNDTIMEO_NEW 67
+
+#define SO_TIMESTAMP_OLD 29
+#define SO_TIMESTAMPNS_OLD 35
+#define SO_TIMESTAMPING_OLD 37
+#define SO_TIMESTAMP_NEW 63
+#define SO_TIMESTAMPNS_NEW 64
+#define SO_TIMESTAMPING_NEW 65
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/socket_type.h b/sysdeps/unix/sysv/linux/sw_64/bits/socket_type.h
new file mode 100644
index 00000000..64452402
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/socket_type.h
@@ -0,0 +1,56 @@
+/* Define enum __socket_type for Linux/Sw_64.
+ Copyright (C) 1991-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 _SYS_SOCKET_H
+# error \
+ "Never include <bits/socket_type.h> directly; use <sys/socket.h> instead."
+#endif
+
+/* Types of sockets. */
+enum __socket_type
+{
+ SOCK_STREAM = 1, /* Sequenced, reliable, connection-based
+ byte streams. */
+#define SOCK_STREAM SOCK_STREAM
+ SOCK_DGRAM = 2, /* Connectionless, unreliable datagrams
+ of fixed maximum length. */
+#define SOCK_DGRAM SOCK_DGRAM
+ SOCK_RAW = 3, /* Raw protocol interface. */
+#define SOCK_RAW SOCK_RAW
+ SOCK_RDM = 4, /* Reliably-delivered messages. */
+#define SOCK_RDM SOCK_RDM
+ SOCK_SEQPACKET = 5, /* Sequenced, reliable, connection-based,
+ datagrams of fixed maximum length. */
+#define SOCK_SEQPACKET SOCK_SEQPACKET
+ SOCK_DCCP = 6, /* Datagram Congestion Control Protocol. */
+#define SOCK_DCCP SOCK_DCCP
+ SOCK_PACKET = 10, /* Linux specific way of getting packets
+ at the dev level. For writing rarp and
+ other similar things on the user level. */
+#define SOCK_PACKET SOCK_PACKET
+
+ /* Flags to be ORed into the type parameter of socket and socketpair and
+ used for the flags parameter of paccept. */
+
+ SOCK_CLOEXEC = 010000000, /* Atomically set close-on-exec flag for the
+ new descriptor(s). */
+#define SOCK_CLOEXEC SOCK_CLOEXEC
+ SOCK_NONBLOCK = 0x40000000 /* Atomically mark descriptor(s) as
+ non-blocking. */
+#define SOCK_NONBLOCK SOCK_NONBLOCK
+};
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/statfs.h b/sysdeps/unix/sysv/linux/sw_64/bits/statfs.h
new file mode 100644
index 00000000..72c3f457
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/statfs.h
@@ -0,0 +1,64 @@
+/* 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 _SYS_STATFS_H
+# error "Never include <bits/statfs.h> directly; use <sys/statfs.h> instead."
+#endif
+
+#include <bits/types.h> /* for __fsid_t and __fsblkcnt_t. */
+
+#ifndef __statfs_word
+# define __statfs_word long
+#endif
+
+struct statfs
+{
+ __statfs_word f_type;
+ __statfs_word f_bsize;
+ __statfs_word f_blocks;
+ __statfs_word f_bfree;
+ __statfs_word f_bavail;
+ __statfs_word f_files;
+ __statfs_word f_ffree;
+ __fsid_t f_fsid;
+ __statfs_word f_namelen;
+ __statfs_word f_frsize;
+ __statfs_word f_flags;
+ __statfs_word f_spare[4];
+};
+
+#ifdef __USE_LARGEFILE64
+struct statfs64
+{
+ __statfs_word f_type;
+ __statfs_word f_bsize;
+ __fsblkcnt64_t f_blocks;
+ __fsblkcnt64_t f_bfree;
+ __fsblkcnt64_t f_bavail;
+ __fsfilcnt64_t f_files;
+ __fsfilcnt64_t f_ffree;
+ __fsid_t f_fsid;
+ __statfs_word f_namelen;
+ __statfs_word f_frsize;
+ __statfs_word f_flags;
+ __statfs_word f_spare[4];
+};
+#endif
+
+/* Tell code we have this member. */
+#define _STATFS_F_NAMELEN
+#define _STATFS_F_FRSIZE
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/struct_stat.h b/sysdeps/unix/sysv/linux/sw_64/bits/struct_stat.h
new file mode 100644
index 00000000..f5de6cb1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/struct_stat.h
@@ -0,0 +1,119 @@
+/* Definition for struct stat.
+ 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/>. */
+
+#if !defined _SYS_STAT_H && !defined _FCNTL_H
+# error \
+ "Never include <bits/struct_stat.h> directly; use <sys/stat.h> instead."
+#endif
+
+#ifndef _BITS_STRUCT_STAT_H
+# define _BITS_STRUCT_STAT_H 1
+
+struct stat
+{
+ __dev_t st_dev; /* Device. */
+# if (defined __USE_FILE_OFFSET64 || defined __sw_64__) /* mod */
+ __ino64_t st_ino; /* File serial number. */
+# else
+ __ino_t st_ino; /* File serial number. */
+ int __pad0; /* 64-bit st_ino. */
+# endif
+ __dev_t st_rdev; /* Device number, if device. */
+ __off_t st_size; /* Size of file, in bytes. */
+# ifdef __USE_FILE_OFFSET64
+ __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */
+# else
+ __blkcnt_t st_blocks; /* Nr. 512-byte blocks allocated. */
+ int __pad1; /* 64-bit st_blocks. */
+# endif
+ __mode_t st_mode; /* File mode. */
+ __uid_t st_uid; /* User ID of the file's owner. */
+ __gid_t st_gid; /* Group ID of the file's group. */
+ __blksize_t st_blksize; /* Optimal block size for I/O. */
+ __nlink_t st_nlink; /* Link count. */
+ int __pad2; /* Real padding. */
+# ifdef __USE_XOPEN2K8
+ /* Nanosecond resolution timestamps are stored in a format
+ equivalent to 'struct timespec'. This is the type used
+ whenever possible but the Unix namespace rules do not allow the
+ identifier 'timespec' to appear in the <sys/stat.h> header.
+ Therefore we have to handle the use of this header in strictly
+ standard-compliant sources special. */
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+# define st_atime st_atim.tv_sec /* Backward compatibility. */
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+# else
+ __time_t st_atime; /* Time of last access. */
+ unsigned long int st_atimensec; /* Nscecs of last access. */
+ __time_t st_mtime; /* Time of last modification. */
+ unsigned long int st_mtimensec; /* Nsecs of last modification. */
+ __time_t st_ctime; /* Time of last status change. */
+ unsigned long int st_ctimensec; /* Nsecs of last status change. */
+# endif
+ long __glibc_reserved[3];
+};
+
+# ifdef __USE_LARGEFILE64
+/* Note stat64 is the same shape as stat. */
+struct stat64
+{
+ __dev_t st_dev; /* Device. */
+ __ino64_t st_ino; /* File serial number. */
+ __dev_t st_rdev; /* Device number, if device. */
+ __off_t st_size; /* Size of file, in bytes. */
+ __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */
+ __mode_t st_mode; /* File mode. */
+ __uid_t st_uid; /* User ID of the file's owner. */
+ __gid_t st_gid; /* Group ID of the file's group. */
+ __blksize_t st_blksize; /* Optimal block size for I/O. */
+ __nlink_t st_nlink; /* Link count. */
+ int __pad0; /* Real padding. */
+# ifdef __USE_XOPEN2K8
+ /* Nanosecond resolution timestamps are stored in a format
+ equivalent to 'struct timespec'. This is the type used
+ whenever possible but the Unix namespace rules do not allow the
+ identifier 'timespec' to appear in the <sys/stat.h> header.
+ Therefore we have to handle the use of this header in strictly
+ standard-compliant sources special. */
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+# define st_atime st_atim.tv_sec /* Backward compatibility. */
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+# else
+ __time_t st_atime; /* Time of last access. */
+ unsigned long int st_atimensec; /* Nscecs of last access. */
+ __time_t st_mtime; /* Time of last modification. */
+ unsigned long int st_mtimensec; /* Nsecs of last modification. */
+ __time_t st_ctime; /* Time of last status change. */
+ unsigned long int st_ctimensec; /* Nsecs of last status change. */
+# endif
+ long __glibc_reserved[3];
+};
+# endif
+
+/* Tell code we have these members. */
+# define _STATBUF_ST_BLKSIZE
+# define _STATBUF_ST_RDEV
+# define _STATBUF_ST_NSEC
+
+#endif /* _BITS_STRUCT_STAT_H */
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/termios-baud.h b/sysdeps/unix/sysv/linux/sw_64/bits/termios-baud.h
new file mode 100644
index 00000000..675ee821
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/termios-baud.h
@@ -0,0 +1,47 @@
+/* termios baud rate selection definitions. Linux/sw_64 version.
+ Copyright (C) 2019-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 _TERMIOS_H
+# error \
+ "Never include <bits/termios-baud.h> directly; use <termios.h> instead."
+#endif
+
+#ifdef __USE_MISC
+# define CBAUD 0000037
+# define CBAUDEX 0000000
+# define CMSPAR 010000000000 /* mark or space (stick) parity */
+# define CRTSCTS 020000000000 /* flow control */
+#endif
+
+#define B57600 00020
+#define B115200 00021
+#define B230400 00022
+#define B460800 00023
+#define B500000 00024
+#define B576000 00025
+#define B921600 00026
+#define B1000000 00027
+#define B1152000 00030
+#define B1500000 00031
+#define B2000000 00032
+#define B2500000 00033
+#define B3000000 00034
+#define B3500000 00035
+#define B4000000 00036
+
+#define __MAX_BAUD B4000000
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/termios-c_cc.h b/sysdeps/unix/sysv/linux/sw_64/bits/termios-c_cc.h
new file mode 100644
index 00000000..19728cf3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/termios-c_cc.h
@@ -0,0 +1,41 @@
+/* termios c_cc symbolic constant definitions. Linux/sw_64 version.
+ Copyright (C) 2019-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 _TERMIOS_H
+# error \
+ "Never include <bits/termios-c_cc.h> directly; use <termios.h> instead."
+#endif
+
+/* c_cc characters */
+#define VEOF 0
+#define VEOL 1
+#define VEOL2 2
+#define VERASE 3
+#define VWERASE 4
+#define VKILL 5
+#define VREPRINT 6
+#define VSWTC 7
+#define VINTR 8
+#define VQUIT 9
+#define VSUSP 10
+#define VSTART 12
+#define VSTOP 13
+#define VLNEXT 14
+#define VDISCARD 15
+#define VMIN 16
+#define VTIME 17
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/termios-c_cflag.h b/sysdeps/unix/sysv/linux/sw_64/bits/termios-c_cflag.h
new file mode 100644
index 00000000..e852f6e2
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/termios-c_cflag.h
@@ -0,0 +1,39 @@
+/* termios control mode definitions. Linux/sw_64 version.
+ Copyright (C) 2019-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 _TERMIOS_H
+# error \
+ "Never include <bits/termios-c_cflag.h> directly; use <termios.h> instead."
+#endif
+
+#define CSIZE 00001400
+#define CS5 00000000
+#define CS6 00000400
+#define CS7 00001000
+#define CS8 00001400
+
+#define CSTOPB 00002000
+#define CREAD 00004000
+#define PARENB 00010000
+#define PARODD 00020000
+#define HUPCL 00040000
+
+#define CLOCAL 00100000
+#ifdef __USE_MISC
+# define ADDRB 04000000000
+#endif
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/termios-c_iflag.h b/sysdeps/unix/sysv/linux/sw_64/bits/termios-c_iflag.h
new file mode 100644
index 00000000..d85fd1e2
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/termios-c_iflag.h
@@ -0,0 +1,39 @@
+/* termios input mode definitions. Linux/sw_64 version.
+ Copyright (C) 2019-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 _TERMIOS_H
+# error \
+ "Never include <bits/termios-c_iflags.h> directly; use <termios.h> instead."
+#endif
+
+/* c_iflag bits */
+#define IGNBRK 0000001
+#define BRKINT 0000002
+#define IGNPAR 0000004
+#define PARMRK 0000010
+#define INPCK 0000020
+#define ISTRIP 0000040
+#define INLCR 0000100
+#define IGNCR 0000200
+#define ICRNL 0000400
+#define IXON 0001000
+#define IXOFF 0002000
+#define IXANY 0004000
+#define IUCLC 0010000
+#define IMAXBEL 0020000
+#define IUTF8 0040000
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/termios-c_lflag.h b/sysdeps/unix/sysv/linux/sw_64/bits/termios-c_lflag.h
new file mode 100644
index 00000000..50de240a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/termios-c_lflag.h
@@ -0,0 +1,43 @@
+/* termios local mode definitions. Linux/sw_64 version.
+ Copyright (C) 2019-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 _TERMIOS_H
+# error \
+ "Never include <bits/termios-c_lflag.h> directly; use <termios.h> instead."
+#endif
+
+/* c_lflag bits */
+#define ISIG 0x00000080
+#define ICANON 0x00000100
+#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
+# define XCASE 0x00004000
+#endif
+#define ECHO 0x00000008
+#define ECHOE 0x00000002
+#define ECHOK 0x00000004
+#define ECHONL 0x00000010
+#define NOFLSH 0x80000000
+#define TOSTOP 0x00400000
+#ifdef __USE_MISC
+# define ECHOCTL 0x00000040
+# define ECHOPRT 0x00000020
+# define ECHOKE 0x00000001
+# define FLUSHO 0x00800000
+# define PENDIN 0x20000000
+#endif
+#define IEXTEN 0x00000400
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/termios-c_oflag.h b/sysdeps/unix/sysv/linux/sw_64/bits/termios-c_oflag.h
new file mode 100644
index 00000000..bd9eda92
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/termios-c_oflag.h
@@ -0,0 +1,67 @@
+/* termios output mode definitions. Linux/sw_64 version.
+ Copyright (C) 2019-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 _TERMIOS_H
+# error \
+ "Never include <bits/termios-c_oflag.h> directly; use <termios.h> instead."
+#endif
+
+/* c_oflag bits */
+#define OPOST 0000001
+#define ONLCR 0000002
+#define OLCUC 0000004
+
+#define OCRNL 0000010
+#define ONOCR 0000020
+#define ONLRET 0000040
+
+#define OFILL 00000100
+#define OFDEL 00000200
+#if defined __USE_MISC || defined __USE_XOPEN
+# define NLDLY 00001400
+# define NL0 00000000
+# define NL1 00000400
+# if defined __USE_MISC
+# define NL2 00001000
+# define NL3 00001400
+# endif
+# define TABDLY 00006000
+# define TAB0 00000000
+# define TAB1 00002000
+# define TAB2 00004000
+# define TAB3 00006000
+# define CRDLY 00030000
+# define CR0 00000000
+# define CR1 00010000
+# define CR2 00020000
+# define CR3 00030000
+# define FFDLY 00040000
+# define FF0 00000000
+# define FF1 00040000
+# define BSDLY 00100000
+# define BS0 00000000
+# define BS1 00100000
+#endif
+
+#define VTDLY 00200000
+#define VT0 00000000
+#define VT1 00200000
+
+#ifdef __USE_MISC
+# define XTABS TAB3
+#endif
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/termios-struct.h b/sysdeps/unix/sysv/linux/sw_64/bits/termios-struct.h
new file mode 100644
index 00000000..0c5f0d4c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/termios-struct.h
@@ -0,0 +1,38 @@
+/* struct termios definition. Linux/sw_64 version.
+ Copyright (C) 2019-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 _TERMIOS_H
+# error \
+ "Never include <bits/termios-struct.h> directly; use <termios.h> instead."
+#endif
+
+/* SW_64 has C_CC before C_LINE compare to Linux generic definition. */
+#define NCCS 32
+struct termios
+{
+ tcflag_t c_iflag; /* input mode flags */
+ tcflag_t c_oflag; /* output mode flags */
+ tcflag_t c_cflag; /* control mode flags */
+ tcflag_t c_lflag; /* local mode flags */
+ cc_t c_cc[NCCS]; /* control characters */
+ cc_t c_line; /* line discipline (== c_cc[33]) */
+ speed_t c_ispeed; /* input speed */
+ speed_t c_ospeed; /* output speed */
+#define _HAVE_STRUCT_TERMIOS_C_ISPEED 1
+#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1
+};
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/timerfd.h b/sysdeps/unix/sysv/linux/sw_64/bits/timerfd.h
new file mode 100644
index 00000000..a6f1465d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/timerfd.h
@@ -0,0 +1,30 @@
+/* Copyright (C) 2008-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 _SYS_TIMERFD_H
+# error \
+ "Never use <bits/timerfd.h> directly; include <sys/timerfd.h> instead."
+#endif
+
+/* Bits to be set in the FLAGS parameter of `timerfd_create'. */
+enum
+{
+ TFD_CLOEXEC = 010000000,
+#define TFD_CLOEXEC TFD_CLOEXEC
+ TFD_NONBLOCK = 000000004
+#define TFD_NONBLOCK TFD_NONBLOCK
+};
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/typesizes.h b/sysdeps/unix/sysv/linux/sw_64/bits/typesizes.h
new file mode 100644
index 00000000..64eb96f3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/typesizes.h
@@ -0,0 +1,87 @@
+/* bits/typesizes.h -- underlying types for *_t. Linux/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
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _BITS_TYPES_H
+# error \
+ "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
+#endif
+
+#ifndef _BITS_TYPESIZES_H
+# define _BITS_TYPESIZES_H 1
+
+/* See <bits/types.h> for the meaning of these macros. This file exists so
+ that <bits/types.h> need not vary across different GNU platforms. */
+
+# define __DEV_T_TYPE __U64_TYPE
+# define __UID_T_TYPE __U32_TYPE
+# define __GID_T_TYPE __U32_TYPE
+# define __INO_T_TYPE __U64_TYPE
+# define __INO64_T_TYPE __U64_TYPE
+# define __MODE_T_TYPE __U32_TYPE
+# define __NLINK_T_TYPE __U32_TYPE
+# define __OFF_T_TYPE __SLONGWORD_TYPE
+# define __OFF64_T_TYPE __S64_TYPE
+# define __PID_T_TYPE __S32_TYPE
+# define __RLIM_T_TYPE __ULONGWORD_TYPE
+# define __RLIM64_T_TYPE __U64_TYPE
+# define __BLKCNT_T_TYPE __U32_TYPE
+# define __BLKCNT64_T_TYPE __U64_TYPE
+# define __FSBLKCNT_T_TYPE __S32_TYPE
+# define __FSBLKCNT64_T_TYPE __S64_TYPE
+# define __FSFILCNT_T_TYPE __U32_TYPE
+# define __FSFILCNT64_T_TYPE __U64_TYPE
+# define __ID_T_TYPE __U32_TYPE
+# define __CLOCK_T_TYPE __SLONGWORD_TYPE
+# define __TIME_T_TYPE __SLONGWORD_TYPE
+# define __USECONDS_T_TYPE __U32_TYPE
+# define __SUSECONDS_T_TYPE __S64_TYPE
+# define __SUSECONDS64_T_TYPE __S64_TYPE
+# define __DADDR_T_TYPE __S32_TYPE
+# define __KEY_T_TYPE __S32_TYPE
+# define __CLOCKID_T_TYPE __S32_TYPE
+# define __TIMER_T_TYPE void *
+# define __BLKSIZE_T_TYPE __U32_TYPE
+# define __FSID_T_TYPE \
+ struct \
+ { \
+ int __val[2]; \
+ }
+# define __SSIZE_T_TYPE __SWORD_TYPE
+# define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE
+# define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
+# define __CPU_MASK_TYPE __ULONGWORD_TYPE
+# define __FSWORD_T_TYPE __S32_TYPE
+
+/* Tell the libc code that off_t and off64_t are actually the same type
+ for all ABI purposes, even if possibly expressed as different base types
+ for C type-checking purposes. */
+# define __OFF_T_MATCHES_OFF64_T 1
+
+/* And for __rlim_t and __rlim64_t. */
+# define __RLIM_T_MATCHES_RLIM64_T 1
+
+/* Not for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */
+# define __STATFS_MATCHES_STATFS64 0
+
+/* And for getitimer, setitimer and rusage */
+# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1
+
+/* Number of descriptors that can fit in an `fd_set'. */
+# define __FD_SETSIZE 1024
+
+#endif /* bits/typesizes.h */
diff --git a/sysdeps/unix/sysv/linux/sw_64/bits/wordsize.h b/sysdeps/unix/sysv/linux/sw_64/bits/wordsize.h
new file mode 100644
index 00000000..36e67434
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/bits/wordsize.h
@@ -0,0 +1,19 @@
+/* Copyright (C) 1999-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/>. */
+
+#define __WORDSIZE 64
+#define __WORDSIZE_TIME64_COMPAT32 0
diff --git a/sysdeps/unix/sysv/linux/sw_64/brk_call.h b/sysdeps/unix/sysv/linux/sw_64/brk_call.h
new file mode 100644
index 00000000..67419149
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/brk_call.h
@@ -0,0 +1,27 @@
+/* Invoke the brk system call. Sw_64 version.
+ Copyright (C) 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/>. */
+
+static inline void *
+__brk_call (void *addr)
+{
+ unsigned long int result = INTERNAL_SYSCALL_CALL (brk, addr);
+ if (result == -ENOMEM)
+ /* Mimic the default error reporting behavior. */
+ result = INTERNAL_SYSCALL_CALL (brk, 0);
+ return (void *) result;
+}
diff --git a/sysdeps/unix/sysv/linux/sw_64/dl-auxv.h b/sysdeps/unix/sysv/linux/sw_64/dl-auxv.h
new file mode 100644
index 00000000..5f1d7b71
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/dl-auxv.h
@@ -0,0 +1,40 @@
+/* Auxiliary vector processing for Linux/Sw_64.
+ Copyright (C) 2007-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/>. */
+
+/* Scan the Aux Vector for the cache shape entries. */
+
+extern long __libc_sw_64_cache_shape[4];
+#define DL_PLATFORM_AUXV \
+ __libc_sw_64_cache_shape[0] = auxv_values[AT_L1I_CACHESHAPE]; \
+ __libc_sw_64_cache_shape[1] = auxv_values[AT_L1D_CACHESHAPE]; \
+ __libc_sw_64_cache_shape[2] = auxv_values[AT_L2_CACHESHAPE]; \
+ __libc_sw_64_cache_shape[3] = auxv_values[AT_L3_CACHESHAPE];
+/*#define DL_PLATFORM_AUXV \
+ case AT_L1I_CACHESHAPE: \
+ __libc_sw_64_cache_shape[0] = av->a_un.a_val; \
+ break; \
+ case AT_L1D_CACHESHAPE: \
+ __libc_sw_64_cache_shape[1] = av->a_un.a_val; \
+ break; \
+ case AT_L2_CACHESHAPE: \
+ __libc_sw_64_cache_shape[2] = av->a_un.a_val; \
+ break; \
+ case AT_L3_CACHESHAPE: \
+ __libc_sw_64_cache_shape[3] = av->a_un.a_val; \
+ break;
+*/
diff --git a/sysdeps/unix/sysv/linux/sw_64/dl-support.c b/sysdeps/unix/sysv/linux/sw_64/dl-support.c
new file mode 100644
index 00000000..29021767
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/dl-support.c
@@ -0,0 +1,2 @@
+#include "dl-auxv.h"
+#include <elf/dl-support.c>
diff --git a/sysdeps/unix/sysv/linux/sw_64/dl-sysdep.c b/sysdeps/unix/sysv/linux/sw_64/dl-sysdep.c
new file mode 100644
index 00000000..be352fd9
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/dl-sysdep.c
@@ -0,0 +1,5 @@
+#include "dl-auxv.h"
+
+long __libc_sw_64_cache_shape[4] = { -2, -2, -2, -2 };
+
+#include <sysdeps/unix/sysv/linux/dl-sysdep.c>
diff --git a/sysdeps/unix/sysv/linux/sw_64/errlist-compat.c b/sysdeps/unix/sysv/linux/sw_64/errlist-compat.c
new file mode 100644
index 00000000..284ce7c5
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/errlist-compat.c
@@ -0,0 +1,43 @@
+/* Linux sys_errlist compat symbol definitions. 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/>. */
+
+#include <errlist-compat.h>
+
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
+DEFINE_COMPAT_ERRLIST (131, GLIBC_2_0)
+#endif
+
+#if SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_3)
+DEFINE_COMPAT_ERRLIST (131, GLIBC_2_1)
+#endif
+
+#if SHLIB_COMPAT (libc, GLIBC_2_3, GLIBC_2_4)
+DEFINE_COMPAT_ERRLIST (132, GLIBC_2_3)
+#endif
+
+#if SHLIB_COMPAT (libc, GLIBC_2_4, GLIBC_2_12)
+DEFINE_COMPAT_ERRLIST (138, GLIBC_2_4)
+#endif
+
+#if SHLIB_COMPAT (libc, GLIBC_2_12, GLIBC_2_16)
+DEFINE_COMPAT_ERRLIST (139, GLIBC_2_12)
+#endif
+
+#if SHLIB_COMPAT (libc, GLIBC_2_16, GLIBC_2_32)
+DEFINE_COMPAT_ERRLIST (140, GLIBC_2_16)
+#endif
diff --git a/sysdeps/unix/sysv/linux/sw_64/fraiseexcpt.S b/sysdeps/unix/sysv/linux/sw_64/fraiseexcpt.S
new file mode 100644
index 00000000..c3c8b710
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/fraiseexcpt.S
@@ -0,0 +1,58 @@
+/* Copyright (C) 2004-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 <sysdep.h>
+#include "kernel_sysinfo.h"
+
+
+ .text
+
+ENTRY(__feraiseexcept)
+ cfi_startproc
+ PSEUDO_PROLOGUE
+
+ ldi sp, -16(sp)
+ cfi_adjust_cfa_offset (16)
+
+ ldi v0, __NR_setsysinfo
+ stl a0, 0(sp)
+ mov sp, a1
+ ldi a0, SSI_IEEE_RAISE_EXCEPTION
+ sys_call HMC_callsys
+
+ ldi sp, 16(sp)
+ cfi_adjust_cfa_offset (-16)
+
+ /* Here in libm we can't use SYSCALL_ERROR_LABEL. Nor is it clear
+ that we'd want to set errno anyway. All we're required to do is
+ return non-zero on error. Which is exactly A3. */
+ mov a3, v0
+ ret
+
+END(__feraiseexcept)
+ cfi_endproc
+
+#if IS_IN (libm)
+# include <shlib-compat.h>
+# if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
+strong_alias (__feraiseexcept, __old_feraiseexcept)
+compat_symbol (libm, __old_feraiseexcept, feraiseexcept, GLIBC_2_1);
+# endif
+libm_hidden_def (__feraiseexcept)
+libm_hidden_ver (__feraiseexcept, feraiseexcept)
+versioned_symbol (libm, __feraiseexcept, feraiseexcept, GLIBC_2_2);
+#endif
diff --git a/sysdeps/unix/sysv/linux/sw_64/fstatfs.c b/sysdeps/unix/sysv/linux/sw_64/fstatfs.c
new file mode 100644
index 00000000..bb184148
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/fstatfs.c
@@ -0,0 +1,29 @@
+/* Get filesystem statistics. Linux/sw_64.
+ Copyright (C) 2011-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/>. */
+
+#include <sys/statfs.h>
+#include <kernel_stat.h>
+#include <sysdep.h>
+
+/* Return information about the filesystem on which FD resides. */
+int
+__fstatfs (int fd, struct statfs *buf)
+{
+ return INLINE_SYSCALL_CALL (fstatfs, fd, buf);
+}
+libc_hidden_def (__fstatfs) weak_alias (__fstatfs, fstatfs)
diff --git a/sysdeps/unix/sysv/linux/sw_64/fxstat64.c b/sysdeps/unix/sysv/linux/sw_64/fxstat64.c
new file mode 100644
index 00000000..df56314b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/fxstat64.c
@@ -0,0 +1,45 @@
+/* fxstat64 using old-style Unix stat system call.
+ Copyright (C) 2004-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/>. */
+
+#define __fxstat __redirect___fxstat64
+#include <sys/stat.h>
+#undef __fxstat
+#include <kernel_stat.h>
+#include <sysdep.h>
+#include <xstatconv.h>
+
+/* Get information about the file NAME in BUF. */
+int
+__fxstat64 (int vers, int fd, struct stat64 *buf)
+{
+ switch (vers)
+ {
+ case _STAT_VER_KERNEL64:
+ return INLINE_SYSCALL_CALL (fstat64, fd, buf);
+
+ default:
+ {
+ struct kernel_stat kbuf;
+ int r = INTERNAL_SYSCALL_CALL (fstat, fd, &kbuf);
+ if (r == 0)
+ return __xstat_conv (vers, &kbuf, buf);
+ return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
+ }
+ }
+}
+strong_alias (__fxstat64, __fxstat);
diff --git a/sysdeps/unix/sysv/linux/sw_64/fxstatat64.c b/sysdeps/unix/sysv/linux/sw_64/fxstatat64.c
new file mode 100644
index 00000000..a274b0db
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/fxstatat64.c
@@ -0,0 +1,32 @@
+/* fxstat using old-style Unix stat system call.
+ Copyright (C) 2004-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/>. */
+
+#define __fxstatat __redirect___fxstatat64
+#include <sys/stat.h>
+#undef __fxstatat
+#include <kernel_stat.h>
+#include <sysdep.h>
+#include <xstatconv.h>
+
+/* Get information about the file NAME in BUF. */
+int
+__fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
+{
+ return INLINE_SYSCALL_CALL (fstatat64, fd, file, st, flag);
+}
+strong_alias (__fxstatat64, __fxstatat);
diff --git a/sysdeps/unix/sysv/linux/sw_64/getclktck.c b/sysdeps/unix/sysv/linux/sw_64/getclktck.c
new file mode 100644
index 00000000..111fad85
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/getclktck.c
@@ -0,0 +1,2 @@
+#define SYSTEM_CLK_TCK 1024
+#include <sysdeps/unix/sysv/linux/getclktck.c>
diff --git a/sysdeps/unix/sysv/linux/sw_64/getcontext.S b/sysdeps/unix/sysv/linux/sw_64/getcontext.S
new file mode 100644
index 00000000..f1cc76f2
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/getcontext.S
@@ -0,0 +1,440 @@
+/* Save current context.
+ Copyright (C) 2004-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 <sysdep.h>
+#include <ucontext-offsets.h>
+
+/* ??? Should be a better place for this that's asm friendly. */
+#define SIG_BLOCK 1
+
+
+ENTRY (__getcontext)
+#ifdef PROF
+ ldgp gp, 0(pv)
+ .set noat
+ ldi AT, _mcount
+ call AT, (AT), _mcount
+ .set at
+ .prologue 1
+#else
+ .prologue 0
+#endif
+
+ bsr $0, __getcontext_x
+ mov $31, $0
+ ret
+
+END(__getcontext)
+weak_alias (__getcontext, getcontext)
+
+
+/* An internal routine used by getcontext and setcontext.
+ The incomming return address register is $0. */
+
+ .align 4
+ .globl __getcontext_x
+ .hidden __getcontext_x
+ .usepv __getcontext_x, no
+
+ cfi_startproc
+ cfi_return_column (64)
+__getcontext_x:
+ cfi_register (64, 0)
+
+ .set noat
+
+ /* Return value of getcontext. $0 is the only register
+ whose value is not preserved. */
+ stl $31, UC_SIGCTX+SC_REGS($16)
+
+ /* Store all registers into the context. */
+ stl $1, UC_SIGCTX+SC_REGS+1*8($16)
+ stl $2, UC_SIGCTX+SC_REGS+2*8($16)
+ stl $3, UC_SIGCTX+SC_REGS+3*8($16)
+ stl $4, UC_SIGCTX+SC_REGS+4*8($16)
+ stl $5, UC_SIGCTX+SC_REGS+5*8($16)
+ stl $6, UC_SIGCTX+SC_REGS+6*8($16)
+ stl $7, UC_SIGCTX+SC_REGS+7*8($16)
+ stl $8, UC_SIGCTX+SC_REGS+8*8($16)
+ stl $9, UC_SIGCTX+SC_REGS+9*8($16)
+ stl $10, UC_SIGCTX+SC_REGS+10*8($16)
+ stl $11, UC_SIGCTX+SC_REGS+11*8($16)
+ stl $12, UC_SIGCTX+SC_REGS+12*8($16)
+ stl $13, UC_SIGCTX+SC_REGS+13*8($16)
+ stl $14, UC_SIGCTX+SC_REGS+14*8($16)
+ stl $15, UC_SIGCTX+SC_REGS+15*8($16)
+ stl $16, UC_SIGCTX+SC_REGS+16*8($16)
+ stl $17, UC_SIGCTX+SC_REGS+17*8($16)
+ stl $18, UC_SIGCTX+SC_REGS+18*8($16)
+ stl $19, UC_SIGCTX+SC_REGS+19*8($16)
+ stl $20, UC_SIGCTX+SC_REGS+20*8($16)
+ stl $21, UC_SIGCTX+SC_REGS+21*8($16)
+ stl $22, UC_SIGCTX+SC_REGS+22*8($16)
+ stl $23, UC_SIGCTX+SC_REGS+23*8($16)
+ stl $24, UC_SIGCTX+SC_REGS+24*8($16)
+ stl $25, UC_SIGCTX+SC_REGS+25*8($16)
+ stl $26, UC_SIGCTX+SC_REGS+26*8($16)
+ stl $27, UC_SIGCTX+SC_REGS+27*8($16)
+ stl $28, UC_SIGCTX+SC_REGS+28*8($16)
+ stl $29, UC_SIGCTX+SC_REGS+29*8($16)
+ stl $30, UC_SIGCTX+SC_REGS+30*8($16)
+ stl $31, UC_SIGCTX+SC_REGS+31*8($16)
+#ifndef SW_64
+ fstd $f0, UC_SIGCTX+SC_FPREGS+1*8($16)
+ srlow $f0, 0x40, $f0
+ fstd $f0, UC_SIGCTX+SC_FPREGS+2*8($16)
+ srlow $f0, 0x40, $f0
+ fstd $f0, UC_SIGCTX+SC_FPREGS+3*8($16)
+ srlow $f0, 0x40, $f0
+ fstd $f0, UC_SIGCTX+SC_FPREGS+4*8($16)
+
+ fstd $f1, UC_SIGCTX+SC_FPREGS+5*8($16)
+ srlow $f1, 0x40, $f1
+ fstd $f1, UC_SIGCTX+SC_FPREGS+6*8($16)
+ srlow $f1, 0x40, $f1
+ fstd $f1, UC_SIGCTX+SC_FPREGS+7*8($16)
+ srlow $f1, 0x40, $f1
+ fstd $f1, UC_SIGCTX+SC_FPREGS+8*8($16)
+
+ fstd $f2, UC_SIGCTX+SC_FPREGS+9*8($16)
+ srlow $f2, 0x40, $f0
+ fstd $f0, UC_SIGCTX+SC_FPREGS+10*8($16)
+ srlow $f0, 0x40, $f0
+ fstd $f0, UC_SIGCTX+SC_FPREGS+11*8($16)
+ srlow $f0, 0x40, $f0
+ fstd $f0, UC_SIGCTX+SC_FPREGS+12*8($16)
+
+ fstd $f3, UC_SIGCTX+SC_FPREGS+13*8($16)
+ srlow $f3, 0x40, $f1
+ fstd $f1, UC_SIGCTX+SC_FPREGS+14*8($16)
+ srlow $f1, 0x40, $f1
+ fstd $f1, UC_SIGCTX+SC_FPREGS+15*8($16)
+ srlow $f1, 0x40, $f1
+ fstd $f1, UC_SIGCTX+SC_FPREGS+16*8($16)
+
+ fstd $f4, UC_SIGCTX+SC_FPREGS+17*8($16)
+ srlow $f4, 0x40, $f0
+ fstd $f0, UC_SIGCTX+SC_FPREGS+18*8($16)
+ srlow $f0, 0x40, $f0
+ fstd $f0, UC_SIGCTX+SC_FPREGS+19*8($16)
+ srlow $f0, 0x40, $f0
+ fstd $f0, UC_SIGCTX+SC_FPREGS+20*8($16)
+
+ fstd $f5, UC_SIGCTX+SC_FPREGS+21*8($16)
+ srlow $f5, 0x40, $f1
+ fstd $f1, UC_SIGCTX+SC_FPREGS+22*8($16)
+ srlow $f1, 0x40, $f1
+ fstd $f1, UC_SIGCTX+SC_FPREGS+23*8($16)
+ srlow $f1, 0x40, $f1
+ fstd $f1, UC_SIGCTX+SC_FPREGS+24*8($16)
+
+ fstd $f6, UC_SIGCTX+SC_FPREGS+25*8($16)
+ srlow $f6, 0x40, $f0
+ fstd $f0, UC_SIGCTX+SC_FPREGS+26*8($16)
+ srlow $f0, 0x40, $f0
+ fstd $f0, UC_SIGCTX+SC_FPREGS+27*8($16)
+ srlow $f0, 0x40, $f0
+ fstd $f0, UC_SIGCTX+SC_FPREGS+28*8($16)
+
+ fstd $f7, UC_SIGCTX+SC_FPREGS+29*8($16)
+ srlow $f7, 0x40, $f1
+ fstd $f1, UC_SIGCTX+SC_FPREGS+30*8($16)
+ srlow $f1, 0x40, $f1
+ fstd $f1, UC_SIGCTX+SC_FPREGS+31*8($16)
+ srlow $f1, 0x40, $f1
+ fstd $f1, UC_SIGCTX+SC_FPREGS+32*8($16)
+
+ fstd $f8, UC_SIGCTX+SC_FPREGS+33*8($16)
+ srlow $f8, 0x40, $f0
+ fstd $f0, UC_SIGCTX+SC_FPREGS+34*8($16)
+ srlow $f0, 0x40, $f0
+ fstd $f0, UC_SIGCTX+SC_FPREGS+35*8($16)
+ srlow $f0, 0x40, $f0
+ fstd $f0, UC_SIGCTX+SC_FPREGS+36*8($16)
+
+ fstd $f9, UC_SIGCTX+SC_FPREGS+37*8($16)
+ srlow $f9, 0x40, $f1
+ fstd $f1, UC_SIGCTX+SC_FPREGS+38*8($16)
+ srlow $f1, 0x40, $f1
+ fstd $f1, UC_SIGCTX+SC_FPREGS+39*8($16)
+ srlow $f1, 0x40, $f1
+ fstd $f1, UC_SIGCTX+SC_FPREGS+40*8($16)
+
+ fstd $f10, UC_SIGCTX+SC_FPREGS+41*8($16)
+ srlow $f10, 0x40, $f10
+ fstd $f10, UC_SIGCTX+SC_FPREGS+42*8($16)
+ srlow $f10, 0x40, $f10
+ fstd $f10, UC_SIGCTX+SC_FPREGS+43*8($16)
+ srlow $f10, 0x40, $f10
+ fstd $f10, UC_SIGCTX+SC_FPREGS+44*8($16)
+
+ fstd $f11, UC_SIGCTX+SC_FPREGS+45*8($16)
+ srlow $f11, 0x40, $f11
+ fstd $f11, UC_SIGCTX+SC_FPREGS+46*8($16)
+ srlow $f11, 0x40, $f11
+ fstd $f11, UC_SIGCTX+SC_FPREGS+47*8($16)
+ srlow $f11, 0x40, $f11
+ fstd $f11, UC_SIGCTX+SC_FPREGS+48*8($16)
+
+ fstd $f12, UC_SIGCTX+SC_FPREGS+49*8($16)
+ srlow $f12, 0x40, $f12
+ fstd $f12, UC_SIGCTX+SC_FPREGS+50*8($16)
+ srlow $f12, 0x40, $f12
+ fstd $f12, UC_SIGCTX+SC_FPREGS+51*8($16)
+ srlow $f12, 0x40, $f12
+ fstd $f12, UC_SIGCTX+SC_FPREGS+52*8($16)
+
+ fstd $f13, UC_SIGCTX+SC_FPREGS+53*8($16)
+ srlow $f13, 0x40, $f13
+ fstd $f13, UC_SIGCTX+SC_FPREGS+54*8($16)
+ srlow $f13, 0x40, $f13
+ fstd $f13, UC_SIGCTX+SC_FPREGS+55*8($16)
+ srlow $f13, 0x40, $f13
+ fstd $f13, UC_SIGCTX+SC_FPREGS+56*8($16)
+
+ fstd $f14, UC_SIGCTX+SC_FPREGS+57*8($16)
+ srlow $f14, 0x40, $f14
+ fstd $f14, UC_SIGCTX+SC_FPREGS+58*8($16)
+ srlow $f14, 0x40, $f14
+ fstd $f14, UC_SIGCTX+SC_FPREGS+59*8($16)
+ srlow $f14, 0x40, $f14
+ fstd $f14, UC_SIGCTX+SC_FPREGS+60*8($16)
+
+ fstd $f15, UC_SIGCTX+SC_FPREGS+61*8($16)
+ srlow $f15, 0x40, $f15
+ fstd $f15, UC_SIGCTX+SC_FPREGS+62*8($16)
+ srlow $f15, 0x40, $f15
+ fstd $f15, UC_SIGCTX+SC_FPREGS+63*8($16)
+ srlow $f15, 0x40, $f15
+ fstd $f15, UC_SIGCTX+SC_FPREGS+64*8($16)
+
+ fstd $f16, UC_SIGCTX+SC_FPREGS+65*8($16)
+ srlow $f16, 0x40, $f16
+ fstd $f16, UC_SIGCTX+SC_FPREGS+66*8($16)
+ srlow $f16, 0x40, $f16
+ fstd $f16, UC_SIGCTX+SC_FPREGS+67*8($16)
+ srlow $f16, 0x40, $f16
+ fstd $f16, UC_SIGCTX+SC_FPREGS+68*8($16)
+
+ fstd $f17, UC_SIGCTX+SC_FPREGS+69*8($16)
+ srlow $f17, 0x40, $f17
+ fstd $f17, UC_SIGCTX+SC_FPREGS+70*8($16)
+ srlow $f17, 0x40, $f17
+ fstd $f17, UC_SIGCTX+SC_FPREGS+71*8($16)
+ srlow $f17, 0x40, $f17
+ fstd $f17, UC_SIGCTX+SC_FPREGS+72*8($16)
+
+ fstd $f18, UC_SIGCTX+SC_FPREGS+73*8($16)
+ srlow $f18, 0x40, $f18
+ fstd $f18, UC_SIGCTX+SC_FPREGS+74*8($16)
+ srlow $f18, 0x40, $f18
+ fstd $f18, UC_SIGCTX+SC_FPREGS+75*8($16)
+ srlow $f18, 0x40, $f18
+ fstd $f18, UC_SIGCTX+SC_FPREGS+76*8($16)
+
+ fstd $f19, UC_SIGCTX+SC_FPREGS+77*8($16)
+ srlow $f19, 0x40, $f19
+ fstd $f19, UC_SIGCTX+SC_FPREGS+78*8($16)
+ srlow $f19, 0x40, $f19
+ fstd $f19, UC_SIGCTX+SC_FPREGS+79*8($16)
+ srlow $f19, 0x40, $f19
+ fstd $f19, UC_SIGCTX+SC_FPREGS+80*8($16)
+
+ fstd $f20, UC_SIGCTX+SC_FPREGS+81*8($16)
+ srlow $f20, 0x40, $f20
+ fstd $f20, UC_SIGCTX+SC_FPREGS+82*8($16)
+ srlow $f20, 0x40, $f20
+ fstd $f20, UC_SIGCTX+SC_FPREGS+83*8($16)
+ srlow $f20, 0x40, $f20
+ fstd $f20, UC_SIGCTX+SC_FPREGS+84*8($16)
+
+ fstd $f21, UC_SIGCTX+SC_FPREGS+85*8($16)
+ srlow $f21, 0x40, $f21
+ fstd $f21, UC_SIGCTX+SC_FPREGS+86*8($16)
+ srlow $f21, 0x40, $f21
+ fstd $f21, UC_SIGCTX+SC_FPREGS+87*8($16)
+ srlow $f21, 0x40, $f21
+ fstd $f21, UC_SIGCTX+SC_FPREGS+88*8($16)
+
+ fstd $f22, UC_SIGCTX+SC_FPREGS+89*8($16)
+ srlow $f22, 0x40, $f22
+ fstd $f22, UC_SIGCTX+SC_FPREGS+90*8($16)
+ srlow $f22, 0x40, $f22
+ fstd $f22, UC_SIGCTX+SC_FPREGS+91*8($16)
+ srlow $f22, 0x40, $f22
+ fstd $f22, UC_SIGCTX+SC_FPREGS+92*8($16)
+
+ fstd $f23, UC_SIGCTX+SC_FPREGS+93*8($16)
+ srlow $f23, 0x40, $f23
+ fstd $f23, UC_SIGCTX+SC_FPREGS+94*8($16)
+ srlow $f23, 0x40, $f23
+ fstd $f23, UC_SIGCTX+SC_FPREGS+95*8($16)
+ srlow $f23, 0x40, $f23
+ fstd $f23, UC_SIGCTX+SC_FPREGS+96*8($16)
+
+ fstd $f24, UC_SIGCTX+SC_FPREGS+97*8($16)
+ srlow $f24, 0x40, $f24
+ fstd $f24, UC_SIGCTX+SC_FPREGS+98*8($16)
+ srlow $f24, 0x40, $f24
+ fstd $f24, UC_SIGCTX+SC_FPREGS+99*8($16)
+ srlow $f24, 0x40, $f24
+ fstd $f24, UC_SIGCTX+SC_FPREGS+100*8($16)
+
+ fstd $f25, UC_SIGCTX+SC_FPREGS+101*8($16)
+ srlow $f25, 0x40, $f25
+ fstd $f25, UC_SIGCTX+SC_FPREGS+102*8($16)
+ srlow $f25, 0x40, $f25
+ fstd $f25, UC_SIGCTX+SC_FPREGS+103*8($16)
+ srlow $f25, 0x40, $f25
+ fstd $f25, UC_SIGCTX+SC_FPREGS+104*8($16)
+
+ fstd $f26, UC_SIGCTX+SC_FPREGS+105*8($16)
+ srlow $f26, 0x40, $f26
+ fstd $f26, UC_SIGCTX+SC_FPREGS+106*8($16)
+ srlow $f26, 0x40, $f26
+ fstd $f26, UC_SIGCTX+SC_FPREGS+107*8($16)
+ srlow $f26, 0x40, $f26
+ fstd $f26, UC_SIGCTX+SC_FPREGS+108*8($16)
+
+ fstd $f27, UC_SIGCTX+SC_FPREGS+109*8($16)
+ srlow $f27, 0x40, $f27
+ fstd $f27, UC_SIGCTX+SC_FPREGS+110*8($16)
+ srlow $f27, 0x40, $f27
+ fstd $f27, UC_SIGCTX+SC_FPREGS+111*8($16)
+ srlow $f27, 0x40, $f27
+ fstd $f27, UC_SIGCTX+SC_FPREGS+112*8($16)
+
+ fstd $f28, UC_SIGCTX+SC_FPREGS+113*8($16)
+ srlow $f28, 0x40, $f28
+ fstd $f28, UC_SIGCTX+SC_FPREGS+114*8($16)
+ srlow $f28, 0x40, $f28
+ fstd $f28, UC_SIGCTX+SC_FPREGS+115*8($16)
+ srlow $f28, 0x40, $f28
+ fstd $f28, UC_SIGCTX+SC_FPREGS+116*8($16)
+
+ fstd $f29, UC_SIGCTX+SC_FPREGS+117*8($16)
+ srlow $f29, 0x40, $f29
+ fstd $f29, UC_SIGCTX+SC_FPREGS+118*8($16)
+ srlow $f29, 0x40, $f29
+ fstd $f29, UC_SIGCTX+SC_FPREGS+119*8($16)
+ srlow $f29, 0x40, $f29
+ fstd $f29, UC_SIGCTX+SC_FPREGS+120*8($16)
+
+ fstd $f30, UC_SIGCTX+SC_FPREGS+121*8($16)
+ srlow $f30, 0x40, $f30
+ fstd $f30, UC_SIGCTX+SC_FPREGS+122*8($16)
+ srlow $f30, 0x40, $f30
+ fstd $f30, UC_SIGCTX+SC_FPREGS+123*8($16)
+ srlow $f30, 0x40, $f30
+ fstd $f30, UC_SIGCTX+SC_FPREGS+124*8($16)
+#else
+ fstd $f0, UC_SIGCTX+SC_FPREGS+0*8($16)
+ fstd $f1, UC_SIGCTX+SC_FPREGS+1*8($16)
+ fstd $f2, UC_SIGCTX+SC_FPREGS+2*8($16)
+ fstd $f3, UC_SIGCTX+SC_FPREGS+3*8($16)
+ fstd $f4, UC_SIGCTX+SC_FPREGS+4*8($16)
+ fstd $f5, UC_SIGCTX+SC_FPREGS+5*8($16)
+ fstd $f6, UC_SIGCTX+SC_FPREGS+6*8($16)
+ fstd $f7, UC_SIGCTX+SC_FPREGS+7*8($16)
+ fstd $f8, UC_SIGCTX+SC_FPREGS+8*8($16)
+ fstd $f9, UC_SIGCTX+SC_FPREGS+9*8($16)
+ fstd $f10, UC_SIGCTX+SC_FPREGS+10*8($16)
+ fstd $f11, UC_SIGCTX+SC_FPREGS+11*8($16)
+ fstd $f12, UC_SIGCTX+SC_FPREGS+12*8($16)
+ fstd $f13, UC_SIGCTX+SC_FPREGS+13*8($16)
+ fstd $f14, UC_SIGCTX+SC_FPREGS+14*8($16)
+ fstd $f15, UC_SIGCTX+SC_FPREGS+15*8($16)
+ fstd $f16, UC_SIGCTX+SC_FPREGS+16*8($16)
+ fstd $f17, UC_SIGCTX+SC_FPREGS+17*8($16)
+ fstd $f18, UC_SIGCTX+SC_FPREGS+18*8($16)
+ fstd $f19, UC_SIGCTX+SC_FPREGS+19*8($16)
+ fstd $f20, UC_SIGCTX+SC_FPREGS+20*8($16)
+ fstd $f21, UC_SIGCTX+SC_FPREGS+21*8($16)
+ fstd $f22, UC_SIGCTX+SC_FPREGS+22*8($16)
+ fstd $f23, UC_SIGCTX+SC_FPREGS+23*8($16)
+ fstd $f24, UC_SIGCTX+SC_FPREGS+24*8($16)
+ fstd $f25, UC_SIGCTX+SC_FPREGS+25*8($16)
+ fstd $f26, UC_SIGCTX+SC_FPREGS+26*8($16)
+ fstd $f27, UC_SIGCTX+SC_FPREGS+27*8($16)
+ fstd $f28, UC_SIGCTX+SC_FPREGS+28*8($16)
+ fstd $f29, UC_SIGCTX+SC_FPREGS+29*8($16)
+ fstd $f30, UC_SIGCTX+SC_FPREGS+30*8($16)
+ fstd $f31, UC_SIGCTX+SC_FPREGS+31*8($16)
+#endif
+ rfpcr $f0
+ ldi $1, 8
+ fstd $f0, UC_SIGCTX+SC_FPCR($16)
+
+ /* The return address of getcontext is the restart pc. */
+ stl $26, UC_SIGCTX+SC_PC($16)
+
+ /* Userlevel always has a processor status word of 8. */
+ stl $1, UC_SIGCTX+SC_PS($16)
+
+ /* Save registers around the syscall. We preserve $17
+ for the benefit of swapcontext. */
+ subl $30, 4*8, $30
+ cfi_adjust_cfa_offset (4*8)
+ stl $0, 0($30)
+ cfi_rel_offset (64, 0)
+ stl $16, 8($30)
+ stl $17, 16($30)
+
+ /* Save the current signal mask. Whee, there are three
+ copies of this in the sw_64 ucontext_t. */
+/* osf_sigprocmask change to rt_sigprocmask */
+/* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */
+ ldi $19, _NSIG8
+ ldi $18, UC_SIGMASK($16)
+ ldi $17, 0
+ ldi $16, SIG_BLOCK
+
+ ldi $0, __NR_rt_sigprocmask
+ sys_call 0x83
+
+ ldl $16, 8($30)
+ ldl $17, 16($30)
+
+ stl $18, UC_OSF_SIGMASK($16)
+ stl $18, UC_SIGCTX+SC_MASK($16)
+
+ stl $31, UC_SIGMASK + 1*8($16)
+ stl $31, UC_SIGMASK + 2*8($16)
+ stl $31, UC_SIGMASK + 3*8($16)
+ stl $31, UC_SIGMASK + 4*8($16)
+ stl $31, UC_SIGMASK + 5*8($16)
+ stl $31, UC_SIGMASK + 6*8($16)
+ stl $31, UC_SIGMASK + 7*8($16)
+ stl $31, UC_SIGMASK + 8*8($16)
+ stl $31, UC_SIGMASK + 9*8($16)
+ stl $31, UC_SIGMASK +10*8($16)
+ stl $31, UC_SIGMASK +11*8($16)
+ stl $31, UC_SIGMASK +12*8($16)
+ stl $31, UC_SIGMASK +13*8($16)
+ stl $31, UC_SIGMASK +14*8($16)
+ stl $31, UC_SIGMASK +15*8($16)
+
+ ldl $0, 0($30)
+ addl $30, 4*8, $30
+ cfi_register (64, 0)
+ cfi_adjust_cfa_offset (-4*8)
+ ret $31, ($0), 1
+
+ cfi_endproc
+ .size __getcontext_x, .-__getcontext_x
+ .type __getcontext_x, @function
diff --git a/sysdeps/unix/sysv/linux/sw_64/getdents.c b/sysdeps/unix/sysv/linux/sw_64/getdents.c
new file mode 100644
index 00000000..16ca198a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/getdents.c
@@ -0,0 +1,18 @@
+/* Although Sw_64 defines _DIRENT_MATCHES_DIRENT64, 'struct dirent' and
+ 'struct dirent64' have slight different internal layout with d_ino
+ being a __ino_t on non-LFS version with an extra __pad field which should
+ be zeroed. */
+
+#include <dirent.h>
+#undef _DIRENT_MATCHES_DIRENT64
+#define _DIRENT_MATCHES_DIRENT64 0
+#ifdef SW_64
+# define DIRENT_SET_DP_INO(dp, value) \
+ do \
+ { \
+ (dp)->d_ino = (value); \
+ (dp)->__pad = 0; \
+ } \
+ while (0)
+#endif
+#include <sysdeps/unix/sysv/linux/getdents.c>
diff --git a/sysdeps/unix/sysv/linux/sw_64/getdents64.c b/sysdeps/unix/sysv/linux/sw_64/getdents64.c
new file mode 100644
index 00000000..f24cc638
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/getdents64.c
@@ -0,0 +1,10 @@
+/* Although Sw_64 defines _DIRENT_MATCHES_DIRENT64, 'struct dirent' and
+ 'struct dirent64' have slight different internal layout with d_ino
+ being a __ino_t on non-LFS version with an extra __pad field which should
+ be zeroed. */
+
+#include <dirent.h>
+/* It suppresses the __getdents64 to __getdents alias. */
+#undef _DIRENT_MATCHES_DIRENT64
+#define _DIRENT_MATCHES_DIRENT64 0
+#include <sysdeps/unix/sysv/linux/getdents64.c>
diff --git a/sysdeps/unix/sysv/linux/sw_64/getegid.S b/sysdeps/unix/sysv/linux/sw_64/getegid.S
new file mode 100644
index 00000000..fe5bd51a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/getegid.S
@@ -0,0 +1,26 @@
+/* Copyright (C) 1991-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/>. */
+
+#include <sysdep.h>
+
+
+PSEUDO (__getegid, getxgid, 0)
+ MOVE (r1, r0)
+ ret
+PSEUDO_END (__getegid)
+
+weak_alias (__getegid, getegid)
diff --git a/sysdeps/unix/sysv/linux/sw_64/geteuid.S b/sysdeps/unix/sysv/linux/sw_64/geteuid.S
new file mode 100644
index 00000000..fb8fd714
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/geteuid.S
@@ -0,0 +1,26 @@
+/* Copyright (C) 1991-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/>. */
+
+#include <sysdep.h>
+
+
+PSEUDO (__geteuid, getxuid, 0)
+ MOVE (r1, r0)
+ ret
+PSEUDO_END (__geteuid)
+
+weak_alias (__geteuid, geteuid)
diff --git a/sysdeps/unix/sysv/linux/sw_64/gethostname.c b/sysdeps/unix/sysv/linux/sw_64/gethostname.c
new file mode 100644
index 00000000..aeb3a957
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/gethostname.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 2001-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2001
+
+ 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 <errno.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+int
+__gethostname (char *name, size_t len)
+{
+ int result;
+
+ result = INLINE_SYSCALL (gethostname, 2, name, len);
+
+ if (result == 0
+ /* See whether the string is terminated. If not we will return
+ an error. */
+ && memchr (name, '\0', len) == NULL)
+ {
+ __set_errno (EOVERFLOW);
+ result = -1;
+ }
+
+ return result;
+}
+
+weak_alias (__gethostname, gethostname)
diff --git a/sysdeps/unix/sysv/linux/sw_64/getppid.S b/sysdeps/unix/sysv/linux/sw_64/getppid.S
new file mode 100644
index 00000000..2107686d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/getppid.S
@@ -0,0 +1,26 @@
+/* Copyright (C) 1991-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/>. */
+
+#include <sysdep.h>
+
+
+PSEUDO (__getppid, getxpid, 0)
+ MOVE (r1, r0)
+ ret
+PSEUDO_END (__getppid)
+
+weak_alias (__getppid, getppid)
diff --git a/sysdeps/unix/sysv/linux/sw_64/getrlimit64.c b/sysdeps/unix/sysv/linux/sw_64/getrlimit64.c
new file mode 100644
index 00000000..7d455c74
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/getrlimit64.c
@@ -0,0 +1,54 @@
+/* Copyright (C) 2018-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/>. */
+
+#define USE_VERSIONED_RLIMIT
+#include <sysdeps/unix/sysv/linux/getrlimit64.c>
+versioned_symbol (libc, __getrlimit, getrlimit, GLIBC_2_27);
+versioned_symbol (libc, __getrlimit64, getrlimit64, GLIBC_2_27);
+
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_27)
+/* RLIM64_INFINITY was supposed to be a glibc convention rather than
+ anything seen by the kernel, but it ended being passed to the kernel
+ through the prlimit64 syscall. Given that a lot of binaries with
+ the wrong constant value are in the wild, provide a wrapper function
+ fixing the value after the syscall. */
+# define OLD_RLIM64_INFINITY 0x7fffffffffffffffULL
+
+int attribute_compat_text_section
+__old_getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)
+{
+ struct rlimit64 krlimits;
+
+ if (__getrlimit64 (resource, &krlimits) < 0)
+ return -1;
+
+ if (krlimits.rlim_cur == RLIM64_INFINITY)
+ rlimits->rlim_cur = OLD_RLIM64_INFINITY;
+ else
+ rlimits->rlim_cur = krlimits.rlim_cur;
+ if (krlimits.rlim_max == RLIM64_INFINITY)
+ rlimits->rlim_max = OLD_RLIM64_INFINITY;
+ else
+ rlimits->rlim_max = krlimits.rlim_max;
+
+ return 0;
+}
+
+strong_alias (__old_getrlimit64, __old_getrlimit)
+ compat_symbol (libc, __old_getrlimit, getrlimit, GLIBC_2_0);
+compat_symbol (libc, __old_getrlimit64, getrlimit64, GLIBC_2_1);
+#endif
diff --git a/sysdeps/unix/sysv/linux/sw_64/gettimeofday.c b/sysdeps/unix/sysv/linux/sw_64/gettimeofday.c
new file mode 100644
index 00000000..d6fcc00a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/gettimeofday.c
@@ -0,0 +1,26 @@
+/* gettimeofday -- Get the current time of day. Linux/Sw_64/tv64 version.
+ Copyright (C) 2019-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/>. */
+
+/* We can use the generic implementation, but we have to override its
+ default symbol version. */
+#define SET_VERSION
+#include <time/gettimeofday.c>
+
+weak_alias (___gettimeofday, __wgettimeofday);
+default_symbol_version (___gettimeofday, __gettimeofday, GLIBC_2.1);
+default_symbol_version (__wgettimeofday, gettimeofday, GLIBC_2.1);
diff --git a/sysdeps/unix/sysv/linux/sw_64/glob-lstat-compat.c b/sysdeps/unix/sysv/linux/sw_64/glob-lstat-compat.c
new file mode 100644
index 00000000..a76471d4
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/glob-lstat-compat.c
@@ -0,0 +1,2 @@
+#define GLOB_LSTAT_VERSION GLIBC_2_1
+#include <sysdeps/unix/sysv/linux/glob-lstat-compat.c>
diff --git a/sysdeps/unix/sysv/linux/sw_64/globfree.c b/sysdeps/unix/sysv/linux/sw_64/globfree.c
new file mode 100644
index 00000000..2a82330d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/globfree.c
@@ -0,0 +1,36 @@
+/* Compat globfree. Linux/sw_64 version.
+ Copyright (C) 2017-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/>. */
+
+#define globfree64 __no_globfree64_decl
+#include <sys/types.h>
+#include <glob.h>
+#include <shlib-compat.h>
+
+#define globfree(pglob) __new_globfree (pglob)
+
+extern void __new_globfree (glob_t *__pglob);
+
+#include <posix/globfree.c>
+
+#undef globfree64
+
+versioned_symbol (libc, __new_globfree, globfree, GLIBC_2_1);
+libc_hidden_ver (__new_globfree, globfree)
+
+ weak_alias (__new_globfree, globfree64)
+libc_hidden_ver (__new_globfree, globfree64)
diff --git a/sysdeps/unix/sysv/linux/sw_64/ieee_get_fp_control.S b/sysdeps/unix/sysv/linux/sw_64/ieee_get_fp_control.S
new file mode 100644
index 00000000..e493f55a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/ieee_get_fp_control.S
@@ -0,0 +1,50 @@
+/* Copyright (C) 1993-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David Mosberger <davidm@azstarnet.com>, 1995.
+
+ 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 <sysdep.h>
+#include "kernel_sysinfo.h"
+
+
+ .text
+
+ENTRY(__ieee_get_fp_control)
+ cfi_startproc
+ PSEUDO_PROLOGUE
+
+ ldi sp, -16(sp)
+ cfi_adjust_cfa_offset (16)
+
+ mov sp, a1
+ ldi a0, GSI_IEEE_FP_CONTROL
+ ldi v0, __NR_getsysinfo
+ sys_call HMC_callsys
+
+ ldl t0, 0(sp)
+ ldi sp, 16(sp)
+ cfi_adjust_cfa_offset (-16)
+
+ bne a3, SYSCALL_ERROR_LABEL
+
+ mov t0, v0
+ ret
+
+PSEUDO_END(__ieee_get_fp_control)
+ cfi_endproc
+
+libc_hidden_def (__ieee_get_fp_control)
+weak_alias (__ieee_get_fp_control, ieee_get_fp_control)
diff --git a/sysdeps/unix/sysv/linux/sw_64/ieee_set_fp_control.S b/sysdeps/unix/sysv/linux/sw_64/ieee_set_fp_control.S
new file mode 100644
index 00000000..ef91e43d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/ieee_set_fp_control.S
@@ -0,0 +1,46 @@
+/* Copyright (C) 1993-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David Mosberger <davidm@azstarnet.com>, 1995.
+
+ 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 <sysdep.h>
+#include "kernel_sysinfo.h"
+
+
+ENTRY(__ieee_set_fp_control)
+ cfi_startproc
+ PSEUDO_PROLOGUE
+
+ ldi sp, -16(sp)
+ cfi_adjust_cfa_offset (16)
+
+ ldi v0, __NR_setsysinfo
+ stl a0, 0(sp)
+ mov sp, a1
+ ldi a0, SSI_IEEE_FP_CONTROL
+ sys_call HMC_callsys
+
+ ldi sp, 16(sp)
+ cfi_adjust_cfa_offset (-16)
+
+ bne a3, SYSCALL_ERROR_LABEL
+ ret
+
+PSEUDO_END(__ieee_set_fp_control)
+ cfi_endproc
+
+libc_hidden_def(__ieee_set_fp_control)
+weak_alias (__ieee_set_fp_control, ieee_set_fp_control)
diff --git a/sysdeps/unix/sysv/linux/sw_64/ioperm.c b/sysdeps/unix/sysv/linux/sw_64/ioperm.c
new file mode 100644
index 00000000..7168aee7
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/ioperm.c
@@ -0,0 +1,853 @@
+/* Copyright (C) 1992-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David Mosberger.
+
+ 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/>. */
+
+/* I/O access is restricted to ISA port space (ports 0..65535).
+ Modern devices hopefully are sane enough not to put any performance
+ critical registers in i/o space.
+
+ On the first call to ioperm, the entire (E)ISA port space is mapped
+ into the virtual address space at address io.base. mprotect calls
+ are then used to enable/disable access to ports. Per page, there
+ are PAGE_SIZE>>IO_SHIFT I/O ports (e.g., 256 ports on a Low Cost Sw_64
+ based system using 8KB pages).
+
+ Keep in mind that this code should be able to run in a 32bit address
+ space. It is therefore unreasonable to expect mmap'ing the entire
+ sparse address space would work (e.g., the Low Cost Sw_64 chip has an
+ I/O address space that's 512MB large!). */
+
+/* Make sure the ldbu/stb asms below are not expaneded to macros. */
+#ifndef __sw_64_bwx__
+asm(".arch sw6f");
+#endif
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/io.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+#define PATH_SW_64_SYSTYPE "/etc/sw_64_systype"
+#define PATH_CPUINFO "/proc/cpuinfo"
+
+#define MAX_PORT 0x10000
+#define vip volatile int *
+#define vuip volatile unsigned int *
+#define vusp volatile unsigned short *
+#define vucp volatile unsigned char *
+
+#define JENSEN_IO_BASE (0x300000000UL)
+#define JENSEN_SPARSE_MEM (0x200000000UL)
+
+/* With respect to the I/O architecture, APECS and LCA are identical,
+ so the following defines apply to LCA as well. */
+#define APECS_IO_BASE (0x1c0000000UL)
+#define APECS_SPARSE_MEM (0x200000000UL)
+#define APECS_DENSE_MEM (0x300000000UL)
+
+/* The same holds for CIA and PYXIS, except for PYXIS we prefer BWX. */
+#define CIA_IO_BASE (0x8580000000UL)
+#define CIA_SPARSE_MEM (0x8000000000UL)
+#define CIA_DENSE_MEM (0x8600000000UL)
+
+#define PYXIS_IO_BASE (0x8900000000UL)
+#define PYXIS_DENSE_MEM (0x8800000000UL)
+
+#define T2_IO_BASE (0x3a0000000UL)
+#define T2_SPARSE_MEM (0x200000000UL)
+#define T2_DENSE_MEM (0x3c0000000UL)
+
+#define GAMMA_IO_BASE (0x83a0000000UL)
+#define GAMMA_SPARSE_MEM (0x8200000000UL)
+#define GAMMA_DENSE_MEM (0x83c0000000UL)
+
+/* NOTE: these are hardwired to PCI bus 0 addresses!!! */
+#define MCPCIA_IO_BASE (0xf980000000UL)
+#define MCPCIA_SPARSE_MEM (0xf800000000UL)
+#define MCPCIA_DENSE_MEM (0xf900000000UL)
+
+/* Tsunami and Irongate use the same offsets, at least for hose 0. */
+#define TSUNAMI_IO_BASE (0x801fc000000UL)
+#define TSUNAMI_DENSE_MEM (0x80000000000UL)
+
+/* Polaris has SPARSE space, but we prefer to use only DENSE
+ because of some idiosyncracies in actually using SPARSE. */
+#define POLARIS_IO_BASE (0xf9fc000000UL)
+#define POLARIS_DENSE_MEM (0xf900000000UL)
+
+typedef enum
+{
+ IOSYS_UNKNOWN,
+ IOSYS_JENSEN,
+ IOSYS_APECS,
+ IOSYS_CIA,
+ IOSYS_PYXIS,
+ IOSYS_T2,
+ IOSYS_TSUNAMI,
+ IOSYS_MCPCIA,
+ IOSYS_GAMMA,
+ IOSYS_POLARIS,
+ IOSYS_CPUDEP,
+ IOSYS_PCIDEP
+} iosys_t;
+
+typedef enum
+{
+ IOSWIZZLE_JENSEN,
+ IOSWIZZLE_SPARSE,
+ IOSWIZZLE_DENSE
+} ioswizzle_t;
+
+static struct io_system
+{
+ unsigned long int bus_memory_base;
+ unsigned long int sparse_bus_mem_base;
+ unsigned long int bus_io_base;
+} io_system[] = {
+ /* NOTE! must match iosys_t enumeration */
+ /* UNKNOWN */ { 0, 0, 0 },
+ /* JENSEN */ { 0, JENSEN_SPARSE_MEM, JENSEN_IO_BASE },
+ /* APECS */ { APECS_DENSE_MEM, APECS_SPARSE_MEM, APECS_IO_BASE },
+ /* CIA */ { CIA_DENSE_MEM, CIA_SPARSE_MEM, CIA_IO_BASE },
+ /* PYXIS */ { PYXIS_DENSE_MEM, 0, PYXIS_IO_BASE },
+ /* T2 */ { T2_DENSE_MEM, T2_SPARSE_MEM, T2_IO_BASE },
+ /* TSUNAMI */ { TSUNAMI_DENSE_MEM, 0, TSUNAMI_IO_BASE },
+ /* MCPCIA */ { MCPCIA_DENSE_MEM, MCPCIA_SPARSE_MEM, MCPCIA_IO_BASE },
+ /* GAMMA */ { GAMMA_DENSE_MEM, GAMMA_SPARSE_MEM, GAMMA_IO_BASE },
+ /* POLARIS */ { POLARIS_DENSE_MEM, 0, POLARIS_IO_BASE },
+ /* CPUDEP */ { 0, 0, 0 }, /* for platforms dependent on CPU type */
+ /* PCIDEP */ { 0, 0, 0 }, /* for platforms dependent on core logic */
+};
+
+static struct platform
+{
+ const char *name;
+ iosys_t io_sys;
+} platform[] = {
+ { "Alcor", IOSYS_CIA }, { "Avanti", IOSYS_APECS },
+ { "Cabriolet", IOSYS_APECS }, { "EB164", IOSYS_PCIDEP },
+ { "EB64+", IOSYS_APECS }, { "EB66", IOSYS_APECS },
+ { "EB66P", IOSYS_APECS }, { "Jensen", IOSYS_JENSEN },
+ { "Miata", IOSYS_PYXIS }, { "Mikasa", IOSYS_CPUDEP },
+ { "Nautilus", IOSYS_TSUNAMI }, { "Noname", IOSYS_APECS },
+ { "Noritake", IOSYS_CPUDEP }, { "Rawhide", IOSYS_MCPCIA },
+ { "Ruffian", IOSYS_PYXIS }, { "Sable", IOSYS_CPUDEP },
+ { "Takara", IOSYS_CIA }, { "Tsunami", IOSYS_TSUNAMI },
+ { "XL", IOSYS_APECS },
+};
+
+struct ioswtch
+{
+ void (*sethae) (unsigned long int addr);
+ void (*outb) (unsigned char b, unsigned long int port);
+ void (*outw) (unsigned short b, unsigned long int port);
+ void (*outl) (unsigned int b, unsigned long int port);
+ unsigned int (*inb) (unsigned long int port);
+ unsigned int (*inw) (unsigned long int port);
+ unsigned int (*inl) (unsigned long int port);
+};
+
+static struct
+{
+ unsigned long int hae_cache;
+ unsigned long int base;
+ struct ioswtch *swp;
+ unsigned long int bus_memory_base;
+ unsigned long int sparse_bus_memory_base;
+ unsigned long int io_base;
+ ioswizzle_t swiz;
+} io;
+
+static inline void
+stb_mb (unsigned char val, unsigned long addr)
+{
+ __asm__("stb %1,%0; memb" : "=m"(*(vucp) addr) : "r"(val));
+}
+
+static inline void
+stw_mb (unsigned short val, unsigned long addr)
+{
+ __asm__("sth %1,%0; memb" : "=m"(*(vusp) addr) : "r"(val));
+}
+
+static inline void
+stl_mb (unsigned int val, unsigned long addr)
+{
+ __asm__("stw %1,%0; memb" : "=m"(*(vip) addr) : "r"(val));
+}
+
+/* No need to examine error -- sethae never fails. */
+static inline void
+__sethae (unsigned long value)
+{
+ fprintf (stderr, " __sethae already abandoned\n");
+ __builtin_unreachable ();
+}
+
+extern long __pciconfig_iobase (enum __pciconfig_iobase_which __which,
+ unsigned long int __bus,
+ unsigned long int __dfn);
+
+static inline unsigned long int
+port_to_cpu_addr (unsigned long int port, ioswizzle_t ioswiz, int size)
+{
+ if (ioswiz == IOSWIZZLE_SPARSE)
+ return io.base + (port << 5) + ((size - 1) << 3);
+ else if (ioswiz == IOSWIZZLE_DENSE)
+ return port + io.base;
+ else
+ return io.base + (port << 7) + ((size - 1) << 5);
+}
+
+static inline __attribute__ ((always_inline)) void
+inline_sethae (unsigned long int addr, ioswizzle_t ioswiz)
+{
+ if (ioswiz == IOSWIZZLE_SPARSE)
+ {
+ unsigned long int msb;
+
+ /* no need to set hae if msb is 0: */
+ msb = addr & 0xf8000000;
+ if (msb && msb != io.hae_cache)
+ {
+ io.hae_cache = msb;
+ __sethae (msb);
+ }
+ }
+ else if (ioswiz == IOSWIZZLE_JENSEN)
+ {
+ /* HAE on the Jensen is bits 31:25 shifted right. */
+ addr >>= 25;
+ if (addr != io.hae_cache)
+ {
+ io.hae_cache = addr;
+ __sethae (addr);
+ }
+ }
+}
+
+static inline void
+inline_outb (unsigned char b, unsigned long int port, ioswizzle_t ioswiz)
+{
+ unsigned int w;
+ unsigned long int addr = port_to_cpu_addr (port, ioswiz, 1);
+
+ asm("ins0b %2,%1,%0" : "=r"(w) : "ri"(port & 0x3), "r"(b));
+ stl_mb (w, addr);
+}
+
+static inline void
+inline_outw (unsigned short int b, unsigned long int port, ioswizzle_t ioswiz)
+{
+ unsigned long w;
+ unsigned long int addr = port_to_cpu_addr (port, ioswiz, 2);
+
+ asm("ins1b %2,%1,%0" : "=r"(w) : "ri"(port & 0x3), "r"(b));
+ stl_mb (w, addr);
+}
+
+static inline void
+inline_outl (unsigned int b, unsigned long int port, ioswizzle_t ioswiz)
+{
+ unsigned long int addr = port_to_cpu_addr (port, ioswiz, 4);
+
+ stl_mb (b, addr);
+}
+
+static inline unsigned int
+inline_inb (unsigned long int port, ioswizzle_t ioswiz)
+{
+ unsigned long int addr = port_to_cpu_addr (port, ioswiz, 1);
+ int result;
+
+ result = *(vip) addr;
+ result >>= (port & 3) * 8;
+ return 0xffUL & result;
+}
+
+static inline unsigned int
+inline_inw (unsigned long int port, ioswizzle_t ioswiz)
+{
+ unsigned long int addr = port_to_cpu_addr (port, ioswiz, 2);
+ int result;
+
+ result = *(vip) addr;
+ result >>= (port & 3) * 8;
+ return 0xffffUL & result;
+}
+
+static inline unsigned int
+inline_inl (unsigned long int port, ioswizzle_t ioswiz)
+{
+ unsigned long int addr = port_to_cpu_addr (port, ioswiz, 4);
+
+ return *(vuip) addr;
+}
+
+/*
+ * Now define the inline functions for CPUs supporting byte/word insns,
+ * and whose core logic supports I/O space accesses utilizing them.
+ *
+ * These routines could be used by MIATA, for example, because it has
+ * and plus PYXIS, but it currently uses SPARSE anyway. This is
+ * also true of RX164 which used POLARIS, but we will choose to use
+ * these routines in that case instead of SPARSE.
+ *
+ * These routines are necessary for TSUNAMI/TYPHOON based platforms,
+ * which will have (at least).
+ */
+
+static inline unsigned long int
+dense_port_to_cpu_addr (unsigned long int port)
+{
+ return port + io.base;
+}
+
+static inline void
+inline_bwx_outb (unsigned char b, unsigned long int port)
+{
+ unsigned long int addr = dense_port_to_cpu_addr (port);
+ stb_mb (b, addr);
+}
+
+static inline void
+inline_bwx_outw (unsigned short int b, unsigned long int port)
+{
+ unsigned long int addr = dense_port_to_cpu_addr (port);
+ stw_mb (b, addr);
+}
+
+static inline void
+inline_bwx_outl (unsigned int b, unsigned long int port)
+{
+ unsigned long int addr = dense_port_to_cpu_addr (port);
+ stl_mb (b, addr);
+}
+
+static inline unsigned int
+inline_bwx_inb (unsigned long int port)
+{
+ unsigned long int addr = dense_port_to_cpu_addr (port);
+ unsigned char r;
+
+ __asm__("ldbu %0,%1" : "=r"(r) : "m"(*(vucp) addr));
+ return r;
+}
+
+static inline unsigned int
+inline_bwx_inw (unsigned long int port)
+{
+ unsigned long int addr = dense_port_to_cpu_addr (port);
+ unsigned short r;
+
+ __asm__("ldhu %0,%1" : "=r"(r) : "m"(*(vusp) addr));
+ return r;
+}
+
+static inline unsigned int
+inline_bwx_inl (unsigned long int port)
+{
+ unsigned long int addr = dense_port_to_cpu_addr (port);
+
+ return *(vuip) addr;
+}
+
+/* macros to define routines with appropriate names and functions */
+
+/* these do either SPARSE or JENSEN swizzle */
+
+#define DCL_SETHAE(name, ioswiz) \
+ static void name##_sethae (unsigned long int addr) \
+ { \
+ inline_sethae (addr, IOSWIZZLE_##ioswiz); \
+ }
+
+#define DCL_OUT(name, func, type, ioswiz) \
+ static void name##_##func (unsigned type b, unsigned long int addr) \
+ { \
+ inline_##func (b, addr, IOSWIZZLE_##ioswiz); \
+ }
+
+#define DCL_IN(name, func, ioswiz) \
+ static unsigned int name##_##func (unsigned long int addr) \
+ { \
+ return inline_##func (addr, IOSWIZZLE_##ioswiz); \
+ }
+
+/* these do DENSE, so no swizzle is needed */
+
+#define DCL_OUT_BWX(name, func, type) \
+ static void name##_##func (unsigned type b, unsigned long int addr) \
+ { \
+ inline_bwx_##func (b, addr); \
+ }
+
+#define DCL_IN_BWX(name, func) \
+ static unsigned int name##_##func (unsigned long int addr) \
+ { \
+ return inline_bwx_##func (addr); \
+ }
+
+/* now declare/define the necessary routines */
+
+DCL_SETHAE (jensen, JENSEN)
+DCL_OUT (jensen, outb, char, JENSEN)
+DCL_OUT (jensen, outw, short int, JENSEN)
+DCL_OUT (jensen, outl, int, JENSEN)
+DCL_IN (jensen, inb, JENSEN)
+DCL_IN (jensen, inw, JENSEN)
+DCL_IN (jensen, inl, JENSEN)
+
+DCL_SETHAE (sparse, SPARSE)
+DCL_OUT (sparse, outb, char, SPARSE)
+DCL_OUT (sparse, outw, short int, SPARSE)
+DCL_OUT (sparse, outl, int, SPARSE)
+DCL_IN (sparse, inb, SPARSE)
+DCL_IN (sparse, inw, SPARSE)
+DCL_IN (sparse, inl, SPARSE)
+
+DCL_SETHAE (dense, DENSE)
+DCL_OUT_BWX (dense, outb, char)
+DCL_OUT_BWX (dense, outw, short int)
+DCL_OUT_BWX (dense, outl, int)
+DCL_IN_BWX (dense, inb)
+DCL_IN_BWX (dense, inw)
+DCL_IN_BWX (dense, inl)
+
+/* define the "swizzle" switch */
+static struct ioswtch ioswtch[]
+ = { { jensen_sethae, jensen_outb, jensen_outw, jensen_outl, jensen_inb,
+ jensen_inw, jensen_inl },
+ { sparse_sethae, sparse_outb, sparse_outw, sparse_outl, sparse_inb,
+ sparse_inw, sparse_inl },
+ { dense_sethae, dense_outb, dense_outw, dense_outl, dense_inb,
+ dense_inw, dense_inl } };
+
+#undef DEBUG_IOPERM
+
+/* Routine to process the /proc/cpuinfo information into the fields
+ that are required for correctly determining the platform parameters. */
+
+struct cpuinfo_data
+{
+ char systype[256]; /* system type field */
+ char sysvari[256]; /* system variation field */
+ char cpumodel[256]; /* cpu model field */
+};
+
+static inline int
+process_cpuinfo (struct cpuinfo_data *data)
+{
+ int got_type, got_vari, got_model;
+ char dummy[256];
+ FILE *fp;
+ int n;
+
+ data->systype[0] = 0;
+ data->sysvari[0] = 0;
+ data->cpumodel[0] = 0;
+
+ /* If there's an /etc/sw_64_systype link, we're intending to override
+ whatever's in /proc/cpuinfo. */
+ n = __readlink (PATH_SW_64_SYSTYPE, data->systype, 256 - 1);
+ if (n > 0)
+ {
+ data->systype[n] = '\0';
+ return 1;
+ }
+
+ fp = fopen (PATH_CPUINFO, "rce");
+ if (!fp)
+ return 0;
+
+ got_type = got_vari = got_model = 0;
+
+ while (1)
+ {
+ if (fgets_unlocked (dummy, 256, fp) == NULL)
+ break;
+ if (!got_type
+ && sscanf (dummy, "system type : %256[^\n]\n", data->systype) == 1)
+ got_type = 1;
+ if (!got_vari
+ && (sscanf (dummy, "system variation : %256[^\n]\n", data->sysvari)
+ == 1))
+ got_vari = 1;
+ if (!got_model
+ && sscanf (dummy, "cpu model : %256[^\n]\n", data->cpumodel) == 1)
+ got_model = 1;
+ }
+
+ fclose (fp);
+
+#ifdef DEBUG_IOPERM
+ fprintf (stderr, "system type: `%s'\n", data->systype);
+ fprintf (stderr, "system vari: `%s'\n", data->sysvari);
+ fprintf (stderr, "cpu model: `%s'\n", data->cpumodel);
+#endif
+
+ return got_type + got_vari + got_model;
+}
+
+/*
+ * Initialize I/O system.
+ */
+static int
+init_iosys (void)
+{
+ long addr;
+ int i, olderrno = errno;
+ struct cpuinfo_data data;
+
+ /* First try the pciconfig_iobase syscall added to 2.2.15 and 2.3.99. */
+
+ addr = __pciconfig_iobase (IOBASE_DENSE_MEM, 0, 0);
+ if (addr != -1)
+ {
+ ioswizzle_t io_swiz;
+
+ if (addr == 0)
+ {
+ /* Only Jensen doesn't have dense mem space. */
+ io.sparse_bus_memory_base
+ = io_system[IOSYS_JENSEN].sparse_bus_mem_base;
+ io.io_base = io_system[IOSYS_JENSEN].bus_io_base;
+ io_swiz = IOSWIZZLE_JENSEN;
+ }
+ else
+ {
+ io.bus_memory_base = addr;
+
+ addr = __pciconfig_iobase (IOBASE_DENSE_IO, 0, 0);
+ if (addr != 0)
+ {
+ /* The X server uses _bus_base_sparse == 0 to know that
+ BWX access are supported to dense mem space. This is
+ true of every system that supports dense io space, so
+ never fill in io.sparse_bus_memory_base in this case. */
+ io_swiz = IOSWIZZLE_DENSE;
+ io.io_base = addr;
+ }
+ else
+ {
+ io.sparse_bus_memory_base
+ = __pciconfig_iobase (IOBASE_SPARSE_MEM, 0, 0);
+ io.io_base = __pciconfig_iobase (IOBASE_SPARSE_IO, 0, 0);
+ io_swiz = IOSWIZZLE_SPARSE;
+ }
+ }
+
+ io.swiz = io_swiz;
+ io.swp = &ioswtch[io_swiz];
+
+ return 0;
+ }
+
+ /* Second, collect the contents of /etc/sw_64_systype or /proc/cpuinfo. */
+
+ if (process_cpuinfo (&data) == 0)
+ {
+ /* This can happen if the format of /proc/cpuinfo changes. */
+ fprintf (stderr, "ioperm.init_iosys: Unable to determine system type.\n"
+ "\t(May need " PATH_SW_64_SYSTYPE " symlink?)\n");
+ __set_errno (ENODEV);
+ return -1;
+ }
+
+ /* Translate systype name into i/o system. */
+ for (i = 0; i < sizeof (platform) / sizeof (platform[0]); ++i)
+ {
+ if (strcmp (platform[i].name, data.systype) == 0)
+ {
+ iosys_t io_sys = platform[i].io_sys;
+
+ /* Some platforms can have either EV4 or EV5 CPUs. */
+ if (io_sys == IOSYS_CPUDEP)
+ {
+ /* SABLE or MIKASA or NORITAKE so far. */
+ if (strcmp (platform[i].name, "Sable") == 0)
+ {
+ if (strncmp (data.cpumodel, "EV4", 3) == 0)
+ io_sys = IOSYS_T2;
+ else if (strncmp (data.cpumodel, "EV5", 3) == 0)
+ io_sys = IOSYS_GAMMA;
+ }
+ else
+ {
+ /* This covers MIKASA/NORITAKE. */
+ if (strncmp (data.cpumodel, "EV4", 3) == 0)
+ io_sys = IOSYS_APECS;
+ else if (strncmp (data.cpumodel, "EV5", 3) == 0)
+ io_sys = IOSYS_CIA;
+ }
+ if (io_sys == IOSYS_CPUDEP)
+ {
+ /* This can happen if the format of /proc/cpuinfo changes. */
+ fprintf (stderr, "ioperm.init_iosys: Unable to determine"
+ " CPU model.\n");
+ __set_errno (ENODEV);
+ return -1;
+ }
+ }
+ /* Some platforms can have different core logic chipsets */
+ if (io_sys == IOSYS_PCIDEP)
+ {
+ /* EB164 so far */
+ if (strcmp (data.systype, "EB164") == 0)
+ {
+ if (strncmp (data.sysvari, "RX164", 5) == 0)
+ io_sys = IOSYS_POLARIS;
+ else if (strncmp (data.sysvari, "LX164", 5) == 0
+ || strncmp (data.sysvari, "SX164", 5) == 0)
+ io_sys = IOSYS_PYXIS;
+ else
+ io_sys = IOSYS_CIA;
+ }
+ if (io_sys == IOSYS_PCIDEP)
+ {
+ /* This can happen if the format of /proc/cpuinfo changes. */
+ fprintf (stderr, "ioperm.init_iosys: Unable to determine"
+ " core logic chipset.\n");
+ __set_errno (ENODEV);
+ return -1;
+ }
+ }
+ io.bus_memory_base = io_system[io_sys].bus_memory_base;
+ io.sparse_bus_memory_base = io_system[io_sys].sparse_bus_mem_base;
+ io.io_base = io_system[io_sys].bus_io_base;
+
+ if (io_sys == IOSYS_JENSEN)
+ io.swiz = IOSWIZZLE_JENSEN;
+ else if (io_sys == IOSYS_TSUNAMI || io_sys == IOSYS_POLARIS
+ || io_sys == IOSYS_PYXIS)
+ io.swiz = IOSWIZZLE_DENSE;
+ else
+ io.swiz = IOSWIZZLE_SPARSE;
+ io.swp = &ioswtch[io.swiz];
+
+ __set_errno (olderrno);
+ return 0;
+ }
+ }
+
+ __set_errno (ENODEV);
+ fprintf (stderr, "ioperm.init_iosys: Platform not recognized.\n"
+ "\t(May need " PATH_SW_64_SYSTYPE " symlink?)\n");
+ return -1;
+}
+
+int
+_ioperm (unsigned long int from, unsigned long int num, int turn_on)
+{
+ unsigned long int addr, len, pagesize = __getpagesize ();
+ int prot;
+
+ if (!io.swp && init_iosys () < 0)
+ {
+#ifdef DEBUG_IOPERM
+ fprintf (stderr, "ioperm: init_iosys() failed (%m)\n");
+#endif
+ return -1;
+ }
+
+ /* This test isn't as silly as it may look like; consider overflows! */
+ if (from >= MAX_PORT || from + num > MAX_PORT)
+ {
+ __set_errno (EINVAL);
+#ifdef DEBUG_IOPERM
+ fprintf (stderr, "ioperm: from/num out of range\n");
+#endif
+ return -1;
+ }
+
+#ifdef DEBUG_IOPERM
+ fprintf (stderr, "ioperm: turn_on %d io.base %ld\n", turn_on, io.base);
+#endif
+
+ if (turn_on)
+ {
+ if (!io.base)
+ {
+ int fd;
+
+ io.hae_cache = 0;
+ if (io.swiz != IOSWIZZLE_DENSE)
+ {
+ /* Synchronize with hw. */
+ __sethae (0);
+ }
+
+ fd = __open ("/dev/mem", O_RDWR);
+ if (fd < 0)
+ {
+#ifdef DEBUG_IOPERM
+ fprintf (stderr, "ioperm: /dev/mem open failed (%m)\n");
+#endif
+ return -1;
+ }
+
+ addr = port_to_cpu_addr (0, io.swiz, 1);
+ len = port_to_cpu_addr (MAX_PORT, io.swiz, 1) - addr;
+ io.base = (unsigned long int) __mmap (0, len, PROT_NONE, MAP_SHARED,
+ fd, io.io_base);
+ __close (fd);
+#ifdef DEBUG_IOPERM
+ fprintf (stderr, "ioperm: mmap of len 0x%lx returned 0x%lx\n", len,
+ io.base);
+#endif
+ if ((long) io.base == -1)
+ return -1;
+ }
+ prot = PROT_READ | PROT_WRITE;
+ }
+ else
+ {
+ if (!io.base)
+ return 0; /* never was turned on... */
+
+ /* turnoff access to relevant pages: */
+ prot = PROT_NONE;
+ }
+ addr = port_to_cpu_addr (from, io.swiz, 1);
+ addr &= ~(pagesize - 1);
+ len = port_to_cpu_addr (from + num, io.swiz, 1) - addr;
+ return __mprotect ((void *) addr, len, prot);
+}
+
+int
+_iopl (int level)
+{
+ switch (level)
+ {
+ case 0:
+ return 0;
+
+ case 1:
+ case 2:
+ case 3:
+ return _ioperm (0, MAX_PORT, 1);
+
+ default:
+ __set_errno (EINVAL);
+ return -1;
+ }
+}
+
+void
+_sethae (unsigned long int addr)
+{
+ if (!io.swp && init_iosys () < 0)
+ return;
+
+ io.swp->sethae (addr);
+}
+
+void
+_outb (unsigned char b, unsigned long int port)
+{
+ if (port >= MAX_PORT)
+ return;
+
+ io.swp->outb (b, port);
+}
+
+void
+_outw (unsigned short b, unsigned long int port)
+{
+ if (port >= MAX_PORT)
+ return;
+
+ io.swp->outw (b, port);
+}
+
+void
+_outl (unsigned int b, unsigned long int port)
+{
+ if (port >= MAX_PORT)
+ return;
+
+ io.swp->outl (b, port);
+}
+
+unsigned int
+_inb (unsigned long int port)
+{
+ return io.swp->inb (port);
+}
+
+unsigned int
+_inw (unsigned long int port)
+{
+ return io.swp->inw (port);
+}
+
+unsigned int
+_inl (unsigned long int port)
+{
+ return io.swp->inl (port);
+}
+
+unsigned long int
+_bus_base (void)
+{
+ if (!io.swp && init_iosys () < 0)
+ return -1;
+ return io.bus_memory_base;
+}
+
+unsigned long int
+_bus_base_sparse (void)
+{
+ if (!io.swp && init_iosys () < 0)
+ return -1;
+ return io.sparse_bus_memory_base;
+}
+
+int
+_hae_shift (void)
+{
+ if (!io.swp && init_iosys () < 0)
+ return -1;
+ if (io.swiz == IOSWIZZLE_JENSEN)
+ return 7;
+ if (io.swiz == IOSWIZZLE_SPARSE)
+ return 5;
+ return 0;
+}
+
+weak_alias (_sethae, sethae);
+weak_alias (_ioperm, ioperm);
+weak_alias (_iopl, iopl);
+weak_alias (_inb, inb);
+weak_alias (_inw, inw);
+weak_alias (_inl, inl);
+weak_alias (_outb, outb);
+weak_alias (_outw, outw);
+weak_alias (_outl, outl);
+weak_alias (_bus_base, bus_base);
+weak_alias (_bus_base_sparse, bus_base_sparse);
+weak_alias (_hae_shift, hae_shift);
diff --git a/sysdeps/unix/sysv/linux/sw_64/ipc_priv.h b/sysdeps/unix/sysv/linux/sw_64/ipc_priv.h
new file mode 100644
index 00000000..fa66f0ac
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/ipc_priv.h
@@ -0,0 +1,21 @@
+/* Old SysV permission definition for Linux. Sw_64 version.
+ Copyright (C) 2016-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/>. */
+
+#define __OLD_IPC_ID_TYPE unsigned int
+#define __OLD_IPC_MODE_TYPE unsigned int
+#include <sysdeps/unix/sysv/linux/ipc_priv.h>
diff --git a/sysdeps/unix/sysv/linux/sw_64/jmp_buf-macros.h b/sysdeps/unix/sysv/linux/sw_64/jmp_buf-macros.h
new file mode 100644
index 00000000..b595173e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/jmp_buf-macros.h
@@ -0,0 +1,6 @@
+#define JMP_BUF_SIZE 272
+#define SIGJMP_BUF_SIZE 272
+#define JMP_BUF_ALIGN 8
+#define SIGJMP_BUF_ALIGN 8
+#define MASK_WAS_SAVED_OFFSET 136
+#define SAVED_MASK_OFFSET 144
diff --git a/sysdeps/unix/sysv/linux/sw_64/kernel-features.h b/sysdeps/unix/sysv/linux/sw_64/kernel-features.h
new file mode 100644
index 00000000..b8986a40
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/kernel-features.h
@@ -0,0 +1,53 @@
+/* Set flags signalling availability of kernel features based on given
+ kernel version number.
+ Copyright (C) 2010-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 _KERNEL_FEATURES_H
+#define _KERNEL_FEATURES_H 1
+
+#include_next <kernel-features.h>
+
+/* Support for statfs64 was added in 5.1. */
+#if __LINUX_KERNEL_VERSION < 0x050100
+# undef __ASSUME_STATFS64
+# define __ASSUME_STATFS64 0
+#endif
+
+#define __ASSUME_RECV_SYSCALL 1
+#define __ASSUME_SEND_SYSCALL 1
+
+/* Support for the renameat2 syscall was added in 3.17. */
+#if __LINUX_KERNEL_VERSION < 0x031100
+# undef __ASSUME_RENAMEAT2
+#endif
+
+/* Support for the execveat syscall was added in 4.2. */
+#if __LINUX_KERNEL_VERSION < 0x040200
+# undef __ASSUME_EXECVEAT
+#endif
+
+/* Support for copy_file_range, statx was added in kernel 4.13. */
+#if __LINUX_KERNEL_VERSION < 0x040D00
+# undef __ASSUME_MLOCK2
+# undef __ASSUME_STATX
+#endif
+
+/* Sw_64 requires old sysvipc even being a 64-bit architecture. */
+#undef __ASSUME_SYSVIPC_DEFAULT_IPC_64
+
+#endif /* _KERNEL_FEATURES_H */
diff --git a/sysdeps/unix/sysv/linux/sw_64/kernel_rt_sigframe.h b/sysdeps/unix/sysv/linux/sw_64/kernel_rt_sigframe.h
new file mode 100644
index 00000000..42f441d5
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/kernel_rt_sigframe.h
@@ -0,0 +1,25 @@
+/* Copyright (C) 2009-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/>. */
+
+/* This structure must have the same shape as the linux kernel
+ equivalent. */
+struct kernel_rt_sigframe
+{
+ siginfo_t info;
+ ucontext_t uc;
+};
diff --git a/sysdeps/unix/sysv/linux/sw_64/kernel_sigaction.h b/sysdeps/unix/sysv/linux/sw_64/kernel_sigaction.h
new file mode 100644
index 00000000..bf3da10e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/kernel_sigaction.h
@@ -0,0 +1,10 @@
+#include <sysdeps/unix/sysv/linux/kernel_sigaction.h>
+
+void __syscall_rt_sigreturn (void) attribute_hidden;
+void __syscall_sigreturn (void) attribute_hidden;
+
+#define STUB(act, sigsetsize) \
+ (sigsetsize), (act) ? ((unsigned long) ((act->sa_flags & SA_SIGINFO) \
+ ? &__syscall_rt_sigreturn \
+ : &__syscall_sigreturn)) \
+ : 0
diff --git a/sysdeps/unix/sysv/linux/sw_64/kernel_stat.h b/sysdeps/unix/sysv/linux/sw_64/kernel_stat.h
new file mode 100644
index 00000000..f32f4678
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/kernel_stat.h
@@ -0,0 +1,91 @@
+/* Definition of `struct stat' used in the kernel. */
+struct kernel_stat
+{
+ unsigned int st_dev;
+ unsigned int st_ino;
+ unsigned int st_mode;
+ unsigned int st_nlink;
+ unsigned int st_uid;
+ unsigned int st_gid;
+ unsigned int st_rdev;
+ long int st_size;
+ unsigned long int st_atime_sec;
+ unsigned long int st_mtime_sec;
+ unsigned long int st_ctime_sec;
+ unsigned int st_blksize;
+ int st_blocks;
+ unsigned int st_flags;
+ unsigned int st_gen;
+};
+
+/* Definition of `struct stat64' used in the kernel. */
+struct kernel_stat64
+{
+ unsigned long st_dev;
+ unsigned long st_ino;
+ unsigned long st_rdev;
+ long st_size;
+ unsigned long st_blocks;
+
+ unsigned int st_mode;
+ unsigned int st_uid;
+ unsigned int st_gid;
+ unsigned int st_blksize;
+ unsigned int st_nlink;
+ unsigned int __pad0;
+
+ unsigned long st_atime_sec;
+ unsigned long st_atimensec;
+ unsigned long st_mtime_sec;
+ unsigned long st_mtimensec;
+ unsigned long st_ctime_sec;
+ unsigned long st_ctimensec;
+ long __glibc_reserved[3];
+};
+
+/* Definition of `struct stat' used by glibc 2.0. */
+struct glibc2_stat
+{
+ __dev_t st_dev;
+ __ino_t st_ino;
+ __mode_t st_mode;
+ __nlink_t st_nlink;
+ __uid_t st_uid;
+ __gid_t st_gid;
+ __dev_t st_rdev;
+ __off_t st_size;
+ __time_t st_atime_sec;
+ __time_t st_mtime_sec;
+ __time_t st_ctime_sec;
+ unsigned int st_blksize;
+ int st_blocks;
+ unsigned int st_flags;
+ unsigned int st_gen;
+};
+
+/* Definition of `struct stat' used by glibc 2.1. */
+struct glibc21_stat
+{
+ __dev_t st_dev;
+ __ino64_t st_ino;
+ __mode_t st_mode;
+ __nlink_t st_nlink;
+ __uid_t st_uid;
+ __gid_t st_gid;
+ __dev_t st_rdev;
+ __off_t st_size;
+ __time_t st_atime_sec;
+ __time_t st_mtime_sec;
+ __time_t st_ctime_sec;
+ __blkcnt64_t st_blocks;
+ __blksize_t st_blksize;
+ unsigned int st_flags;
+ unsigned int st_gen;
+ int __pad3;
+ long __glibc_reserved[4];
+};
+
+#define STAT_IS_KERNEL_STAT 0
+#define STAT64_IS_KERNEL_STAT64 1
+#define XSTAT_IS_XSTAT64 1
+#define STATFS_IS_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/sw_64/kernel_sysinfo.h b/sysdeps/unix/sysv/linux/sw_64/kernel_sysinfo.h
new file mode 100644
index 00000000..b47f33c0
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/kernel_sysinfo.h
@@ -0,0 +1,6 @@
+/* A copy of the couple of bits we need from <asm/sysinfo.h>. */
+
+#define GSI_IEEE_FP_CONTROL 45
+
+#define SSI_IEEE_FP_CONTROL 14
+#define SSI_IEEE_RAISE_EXCEPTION 1001
diff --git a/sysdeps/unix/sysv/linux/sw_64/kernel_termios.h b/sysdeps/unix/sysv/linux/sw_64/kernel_termios.h
new file mode 100644
index 00000000..ad7c0047
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/kernel_termios.h
@@ -0,0 +1,43 @@
+/* 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 _KERNEL_TERMIOS_H
+#define _KERNEL_TERMIOS_H 1
+
+/* The following corresponds to the values from the Linux 2.1.20 kernel. */
+
+/* We need the definition of tcflag_t, cc_t, and speed_t. */
+#include <termios.h>
+
+#define __KERNEL_NCCS 19
+
+struct __kernel_termios
+{
+ tcflag_t c_iflag; /* input mode flags */
+ tcflag_t c_oflag; /* output mode flags */
+ tcflag_t c_cflag; /* control mode flags */
+ tcflag_t c_lflag; /* local mode flags */
+ cc_t c_cc[__KERNEL_NCCS]; /* control characters */
+ cc_t c_line; /* line discipline */
+ speed_t c_ispeed; /* input speed */
+ speed_t c_ospeed; /* output speed */
+};
+
+#define _HAVE_C_ISPEED 1
+#define _HAVE_C_OSPEED 1
+
+#endif /* kernel_termios.h */
diff --git a/sysdeps/unix/sysv/linux/sw_64/librt-compat.c b/sysdeps/unix/sysv/linux/sw_64/librt-compat.c
new file mode 100644
index 00000000..e91925e3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/librt-compat.c
@@ -0,0 +1,24 @@
+/* Placeholder definitions to pull in removed symbol versions. sw_64 version.
+ Copyright (C) 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/>. */
+
+#include <sysdeps/unix/sysv/linux/librt-compat.c>
+
+#if SHLIB_COMPAT (librt, GLIBC_2_3, GLIBC_2_34)
+compat_symbol (librt, __librt_version_placeholder_1,
+ __librt_version_placeholder, GLIBC_2_3);
+#endif
diff --git a/sysdeps/unix/sysv/linux/sw_64/localplt.data b/sysdeps/unix/sysv/linux/sw_64/localplt.data
new file mode 100644
index 00000000..9dfd3f9b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/localplt.data
@@ -0,0 +1,33 @@
+libc.so: _OtsAddX ?
+libc.so: _OtsConvertFloatTX ?
+libc.so: _OtsConvertFloatXT ?
+libc.so: _OtsCvtQUX ?
+libc.so: _OtsCvtQX ?
+libc.so: _OtsCvtXQ ?
+libc.so: _OtsDivX ?
+libc.so: _OtsEqlX ?
+libc.so: _OtsGeqX ?
+libc.so: _OtsGtrX ?
+libc.so: _OtsLeqX ?
+libc.so: _OtsLssX ?
+libc.so: _OtsMulX ?
+libc.so: _OtsNeqX ?
+libc.so: _OtsNintXQ ?
+libc.so: _OtsSubX ?
+libc.so: _Unwind_Find_FDE
+libc.so: calloc + RELA R_SW_64_GLOB_DAT
+libc.so: free + RELA R_SW_64_GLOB_DAT
+libc.so: malloc + RELA R_SW_64_GLOB_DAT
+libc.so: realloc + RELA R_SW_64_GLOB_DAT
+libm.so: matherr + RELA R_SW_64_GLOB_DAT
+# We used to offer inline functions that used this, so it must be exported.
+# Ought to reorg things such that carg isn't thus forced to use a plt.
+libm.so: __atan2
+#libm.so: lround
+#libm.so: pow
+#libm.so: scalbln
+#libm.so: rint
+#libm.so: lrint
+#libm.so: remainder
+# The dynamic loader needs __tls_get_addr for TLS.
+ld.so: __tls_get_addr ?
diff --git a/sysdeps/unix/sysv/linux/sw_64/lxstat64.c b/sysdeps/unix/sysv/linux/sw_64/lxstat64.c
new file mode 100644
index 00000000..e0dfcf8b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/lxstat64.c
@@ -0,0 +1,46 @@
+/* lxstat using old-style Unix stat system call.
+ Copyright (C) 2004-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/>. */
+
+#define __lxstat __redirect___lxstat
+#include <sys/stat.h>
+#undef __lxstat
+#include <fcntl.h>
+#include <kernel_stat.h>
+#include <sysdep.h>
+#include <xstatconv.h>
+
+/* Get information about the file NAME in BUF. */
+int
+__lxstat64 (int vers, const char *name, struct stat64 *buf)
+{
+ switch (vers)
+ {
+ case _STAT_VER_KERNEL64:
+ return INLINE_SYSCALL_CALL (lstat64, name, buf);
+
+ default:
+ {
+ struct kernel_stat kbuf;
+ int r = INTERNAL_SYSCALL_CALL (lstat, name, &kbuf);
+ if (r == 0)
+ return __xstat_conv (vers, &kbuf, buf);
+ return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
+ }
+ }
+}
+weak_alias (__lxstat64, __lxstat);
diff --git a/sysdeps/unix/sysv/linux/sw_64/makecontext.S b/sysdeps/unix/sysv/linux/sw_64/makecontext.S
new file mode 100644
index 00000000..55cb73a2
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/makecontext.S
@@ -0,0 +1,164 @@
+/* Copyright (C) 2004-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 <sysdep.h>
+#include <ucontext-offsets.h>
+
+
+ENTRY(__makecontext)
+ ldgp $29, 0($27)
+#ifdef PROF
+ .set noat
+ ldi AT, _mcount
+ call AT, (AT), _mcount
+ .set at
+#endif
+ .prologue 1
+
+ /* Compute top of stack, including arguments. */
+ ldl $1, UC_STACK+SS_SP($16)
+ ldl $2, UC_STACK+SS_SIZE($16)
+ addl $1, $2, $8
+ subl $18, 6, $1
+ sellt $1, 0, $1, $1
+ s8addl $1, 0, $2
+ subl $8, $2, $8
+ bic $8,0xf,$8 /* Keep the stack aligned ,mod */
+
+ /* Copy all parameters. Switch statement header here. */
+ ldih $3, $jumptable($29) !gprelhigh
+ cmple $18, 6, $1
+ mov $18, $2
+ seleq $1, 7, $2, $2
+ s4addl $2, $3, $3
+ ldw $4, $jumptable($3) !gprellow
+ addl $4, $29, $4
+ jmp $31, ($4), $args1
+
+ .section .rodata
+ .align 2
+$jumptable:
+ .gprel32 $args0
+ .gprel32 $args1
+ .gprel32 $args2
+ .gprel32 $args3
+ .gprel32 $args4
+ .gprel32 $args5
+ .gprel32 $args6
+ .gprel32 $argsN
+ .text
+
+ /* Here we process arguments 7 through N. This is a straight
+ stack-to-stack copy. */
+ .align 4
+$argsN:
+ subl $18, 6, $1
+ ldi $2, 0($8)
+ ldi $3, 3*8($30)
+ .align 4
+1:
+ ldl $0, 0($3)
+ subl $1, 1, $1
+ ldi $3, 8($3)
+ stl $0, 0($2)
+ ldi $2, 8($2)
+ bne $1, 1b
+
+ /* Here we process arguments 6 through 0. This involves
+ copying into the register save areas of the ucontext. */
+ .align 4
+$args6:
+ ldl $0, 2*8($30)
+ stl $0, UC_SIGCTX+SC_REGS+21*8($16)
+ unop
+ stl $0, UC_SIGCTX+SC_FPREGS+21*8($16)
+$args5:
+ ldl $0, 1*8($30)
+ stl $0, UC_SIGCTX+SC_REGS+20*8($16)
+ unop
+ stl $0, UC_SIGCTX+SC_FPREGS+20*8($16)
+$args4:
+ ldl $0, 0*8($30)
+ stl $0, UC_SIGCTX+SC_REGS+19*8($16)
+ unop
+ stl $0, UC_SIGCTX+SC_FPREGS+19*8($16)
+$args3:
+ unop
+ stl $21, UC_SIGCTX+SC_REGS+18*8($16)
+ unop
+ fstd $f21, UC_SIGCTX+SC_FPREGS+18*8($16)
+$args2:
+ unop
+ stl $20, UC_SIGCTX+SC_REGS+17*8($16)
+ unop
+ fstd $f20, UC_SIGCTX+SC_FPREGS+17*8($16)
+$args1:
+ unop
+ stl $19, UC_SIGCTX+SC_REGS+16*8($16)
+ unop
+ fstd $f19, UC_SIGCTX+SC_FPREGS+16*8($16)
+$args0:
+
+ /* Set up the registers ready to invoke __startcontext.
+ We seed $27 with the target function address, and $9
+ with the link from ucp. */
+ ldih $0, __startcontext($29) !gprelhigh
+ ldl $1, UC_LINK($16)
+ ldi $0, __startcontext($0) !gprellow
+ stl $17, UC_SIGCTX+SC_REGS+27*8($16)
+ stl $8, UC_SIGCTX+SC_REGS+30*8($16)
+ stl $0, UC_SIGCTX+SC_PC($16)
+ stl $1, UC_SIGCTX+SC_REGS+9*8($16)
+
+ /* No return value from makecontext. */
+ ret
+
+END(__makecontext)
+weak_alias (__makecontext, makecontext)
+
+/* This function is where a new makecontext "thread" begins life.
+ We have already set up $27 for calling the target function, and
+ we've set $9 to the UC_LINK of the parent context.
+
+ If the function returns, we either jump to the linked context
+ (if non-null) or exit. */
+
+ .align 4
+ .ent __startcontext
+__startcontext:
+ .frame $31, 0, $31, 0
+ .prologue 0
+
+ call $26, ($27), 0
+ ldgp $29, 0($26)
+ mov $9, $16
+ beq $9, 1f
+
+#ifdef PIC
+ bsr $26, __setcontext !samegp
+1: mov $31, $16
+ bsr $26, HIDDEN_JUMPTARGET(exit) !samegp
+#else
+ call $26, __setcontext
+ ldgp $29, 0($26)
+1: mov $31, $16
+ call $26, HIDDEN_JUMPTARGET(exit)
+#endif
+
+ halt
+
+ .end __startcontext
diff --git a/sysdeps/unix/sysv/linux/sw_64/nldbl-abi.h b/sysdeps/unix/sysv/linux/sw_64/nldbl-abi.h
new file mode 100644
index 00000000..0b061cb3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/nldbl-abi.h
@@ -0,0 +1,8 @@
+/* ABI version for long double switch.
+ This is used by the Versions and math_ldbl_opt.h files in
+ sysdeps/ieee754/ldbl-opt/. It gives the ABI version where
+ long double == double was replaced with proper long double
+ for libm *l functions and libc functions using long double. */
+
+#define NLDBL_VERSION GLIBC_2.4
+#define LONG_DOUBLE_COMPAT_VERSION GLIBC_2_4
diff --git a/sysdeps/unix/sysv/linux/sw_64/oldglob.c b/sysdeps/unix/sysv/linux/sw_64/oldglob.c
new file mode 100644
index 00000000..3024d92d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/oldglob.c
@@ -0,0 +1,96 @@
+/* Copyright (C) 1998-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 only wrappers around the real glob functions. It
+ became necessary since the glob_t structure changed. */
+#include <sys/types.h>
+#include <glob.h>
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
+
+/* This is the old structure. The difference is that the gl_pathc and
+ gl_offs elements have type `int'. */
+typedef struct
+{
+ int gl_pathc; /* Count of paths matched by the pattern. */
+ char **gl_pathv; /* List of matched pathnames. */
+ int gl_offs; /* Slots to reserve in `gl_pathv'. */
+ int gl_flags; /* Set to FLAGS, maybe | GLOB_MAGCHAR. */
+
+ /* If the GLOB_ALTDIRFUNC flag is set, the following functions
+ are used instead of the normal file access functions. */
+ void (*gl_closedir) (void *);
+ struct dirent *(*gl_readdir) (void *);
+ void *(*gl_opendir) (const char *);
+ int (*gl_lstat) (const char *, struct stat *);
+ int (*gl_stat) (const char *, struct stat *);
+} old_glob_t;
+
+int attribute_compat_text_section
+__old_glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
+ old_glob_t *pglob)
+{
+ glob_t correct;
+ int result;
+
+ /* Construct an object of correct type. */
+ correct.gl_pathc = pglob->gl_pathc;
+ correct.gl_pathv = pglob->gl_pathv;
+ correct.gl_offs = pglob->gl_offs;
+ correct.gl_flags = pglob->gl_flags;
+ correct.gl_closedir = pglob->gl_closedir;
+ correct.gl_readdir = pglob->gl_readdir;
+ correct.gl_opendir = pglob->gl_opendir;
+ /* Set gl_lstat and gl_stat for both gl_stat for compatibility with old
+ implementation that did not follow dangling symlinks. */
+ correct.gl_lstat = pglob->gl_stat;
+ correct.gl_stat = pglob->gl_stat;
+
+ result = glob (pattern, flags, errfunc, &correct);
+
+ /* And convert it back. */
+ pglob->gl_pathc = correct.gl_pathc;
+ pglob->gl_pathv = correct.gl_pathv;
+ pglob->gl_offs = correct.gl_offs;
+ pglob->gl_flags = correct.gl_flags;
+ pglob->gl_closedir = correct.gl_closedir;
+ pglob->gl_readdir = correct.gl_readdir;
+ pglob->gl_opendir = correct.gl_opendir;
+ /* Only need to restore gl_stat. */
+ pglob->gl_stat = correct.gl_stat;
+
+ return result;
+}
+compat_symbol (libc, __old_glob, glob, GLIBC_2_0);
+
+/* Free storage allocated in PGLOB by a previous `glob' call. */
+void attribute_compat_text_section
+__old_globfree (old_glob_t *pglob)
+{
+ glob_t correct;
+
+ /* We only need these two symbols. */
+ correct.gl_pathc = pglob->gl_pathc;
+ correct.gl_pathv = pglob->gl_pathv;
+ correct.gl_offs = pglob->gl_offs;
+
+ globfree (&correct);
+}
+compat_symbol (libc, __old_globfree, globfree, GLIBC_2_0);
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/sw_64/osf_adjtime.c b/sysdeps/unix/sysv/linux/sw_64/osf_adjtime.c
new file mode 100644
index 00000000..334c0d53
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/osf_adjtime.c
@@ -0,0 +1,139 @@
+/* adjtime -- adjust the system clock. Linux/SW_64/tv32 version.
+ Copyright (C) 2019-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 <shlib-compat.h>
+
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
+
+# include <time.h>
+# include <sys/time.h>
+# include <sys/timex.h>
+# include <string.h>
+
+struct timex32
+{
+ unsigned int modes; /* mode selector */
+ long offset; /* time offset (usec) */
+ long freq; /* frequency offset (scaled ppm) */
+ long maxerror; /* maximum error (usec) */
+ long esterror; /* estimated error (usec) */
+ int status; /* clock command/status */
+ long constant; /* pll time constant */
+ long precision; /* clock precision (usec) (read only) */
+ long tolerance; /* clock frequency tolerance (ppm)
+ * (read only)
+ */
+ struct __timeval32 time; /* (read only) */
+ long tick; /* (modified) usecs between clock ticks */
+
+ long ppsfreq; /* pps frequency (scaled ppm) (ro) */
+ long jitter; /* pps jitter (us) (ro) */
+ int shift; /* interval duration (s) (shift) (ro) */
+ long stabil; /* pps stability (scaled ppm) (ro) */
+ long jitcnt; /* jitter limit exceeded (ro) */
+ long calcnt; /* calibration intervals (ro) */
+ long errcnt; /* calibration errors (ro) */
+ long stbcnt; /* stability limit exceeded (ro) */
+
+ int : 32;
+ int : 32;
+ int : 32;
+ int : 32;
+ int : 32;
+ int : 32;
+ int : 32;
+ int : 32;
+ int : 32;
+ int : 32;
+ int : 32;
+ int : 32;
+};
+
+int attribute_compat_text_section
+__adjtime_tv32 (const struct __timeval32 *itv, struct __timeval32 *otv)
+{
+ struct timeval itv64 = valid_timeval32_to_timeval (*itv);
+ struct timeval otv64;
+
+ if (__adjtime (&itv64, &otv64) == -1)
+ return -1;
+
+ *otv = valid_timeval_to_timeval32 (otv64);
+ return 0;
+}
+
+int attribute_compat_text_section
+__adjtimex_tv32 (struct timex32 *tx)
+{
+ struct timex tx64;
+ memset (&tx64, 0, sizeof tx64);
+ tx64.modes = tx->modes;
+ tx64.offset = tx->offset;
+ tx64.freq = tx->freq;
+ tx64.maxerror = tx->maxerror;
+ tx64.esterror = tx->esterror;
+ tx64.status = tx->status;
+ tx64.constant = tx->constant;
+ tx64.precision = tx->precision;
+ tx64.tolerance = tx->tolerance;
+ tx64.tick = tx->tick;
+ tx64.ppsfreq = tx->ppsfreq;
+ tx64.jitter = tx->jitter;
+ tx64.shift = tx->shift;
+ tx64.stabil = tx->stabil;
+ tx64.jitcnt = tx->jitcnt;
+ tx64.calcnt = tx->calcnt;
+ tx64.errcnt = tx->errcnt;
+ tx64.stbcnt = tx->stbcnt;
+ tx64.time = valid_timeval32_to_timeval (tx->time);
+
+ int status = __adjtimex (&tx64);
+ if (status < 0)
+ return status;
+
+ memset (tx, 0, sizeof *tx);
+ tx->modes = tx64.modes;
+ tx->offset = tx64.offset;
+ tx->freq = tx64.freq;
+ tx->maxerror = tx64.maxerror;
+ tx->esterror = tx64.esterror;
+ tx->status = tx64.status;
+ tx->constant = tx64.constant;
+ tx->precision = tx64.precision;
+ tx->tolerance = tx64.tolerance;
+ tx->tick = tx64.tick;
+ tx->ppsfreq = tx64.ppsfreq;
+ tx->jitter = tx64.jitter;
+ tx->shift = tx64.shift;
+ tx->stabil = tx64.stabil;
+ tx->jitcnt = tx64.jitcnt;
+ tx->calcnt = tx64.calcnt;
+ tx->errcnt = tx64.errcnt;
+ tx->stbcnt = tx64.stbcnt;
+ tx->time = valid_timeval_to_timeval32 (tx64.time);
+
+ return status;
+}
+
+strong_alias (__adjtimex_tv32, __adjtimex_tv32_1);
+strong_alias (__adjtimex_tv32, __adjtimex_tv32_2);
+compat_symbol (libc, __adjtimex_tv32_1, __adjtimex, GLIBC_2_0);
+compat_symbol (libc, __adjtimex_tv32_2, adjtimex, GLIBC_2_0);
+compat_symbol (libc, __adjtime_tv32, adjtime, GLIBC_2_0);
+
+#endif /* SHLIB_COMPAT */
diff --git a/sysdeps/unix/sysv/linux/sw_64/osf_getitimer.c b/sysdeps/unix/sysv/linux/sw_64/osf_getitimer.c
new file mode 100644
index 00000000..938ffb99
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/osf_getitimer.c
@@ -0,0 +1,42 @@
+/* getitimer -- Get the state of an interval timer. Linux/SW_64/tv32 version.
+ Copyright (C) 2019-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 <shlib-compat.h>
+
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
+
+# include <time.h>
+# include <sys/time.h>
+# include <tv32-compat.h>
+
+int attribute_compat_text_section
+__getitimer_tv32 (int which, struct __itimerval32 *curr_value)
+{
+ struct itimerval curr_value_64;
+ if (__getitimer (which, &curr_value_64) == -1)
+ return -1;
+
+ /* Write all fields of 'curr_value' regardless of overflow. */
+ curr_value->it_interval
+ = valid_timeval_to_timeval32 (curr_value_64.it_interval);
+ curr_value->it_value = valid_timeval_to_timeval32 (curr_value_64.it_value);
+ return 0;
+}
+
+compat_symbol (libc, __getitimer_tv32, getitimer, GLIBC_2_0);
+#endif
diff --git a/sysdeps/unix/sysv/linux/sw_64/osf_getrusage.c b/sysdeps/unix/sysv/linux/sw_64/osf_getrusage.c
new file mode 100644
index 00000000..c5fb5a47
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/osf_getrusage.c
@@ -0,0 +1,39 @@
+/* utimes -- change file timestamps. Linux/SW_64/tv32 version.
+ Copyright (C) 2019-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 <shlib-compat.h>
+
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
+
+# include <sys/time.h>
+# include <sys/resource.h>
+# include <tv32-compat.h>
+
+int
+__getrusage_tv32 (int who, struct __rusage32 *usage32)
+{
+ struct rusage usage;
+ if (__getrusage (who, &usage) == -1)
+ return -1;
+
+ rusage64_to_rusage32 (&usage, usage32);
+ return 0;
+}
+
+compat_symbol (libc, __getrusage_tv32, getrusage, GLIBC_2_0);
+#endif
diff --git a/sysdeps/unix/sysv/linux/sw_64/osf_gettimeofday.c b/sysdeps/unix/sysv/linux/sw_64/osf_gettimeofday.c
new file mode 100644
index 00000000..affb5655
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/osf_gettimeofday.c
@@ -0,0 +1,47 @@
+/* gettimeofday -- Get the current time of day. Linux/SW_64/tv32 version.
+ Copyright (C) 2019-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 <shlib-compat.h>
+
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
+
+# include <time.h>
+# include <string.h>
+# include <time.h>
+# include <sys/time.h>
+
+/* Get the current time of day and timezone information putting it
+ into *TV and *TZ. */
+
+int attribute_compat_text_section
+__gettimeofday_tv32 (struct __timeval32 *restrict tv32, void *restrict tz)
+{
+ if (__glibc_unlikely (tz != 0))
+ memset (tz, 0, sizeof (struct timezone));
+
+ struct __timespec64 ts;
+ __clock_gettime64 (CLOCK_REALTIME, &ts);
+
+ *tv32 = valid_timespec_to_timeval32 (ts);
+ return 0;
+}
+
+compat_symbol (libc, __gettimeofday_tv32, __gettimeofday, GLIBC_2_0);
+strong_alias (__gettimeofday_tv32, __gettimeofday_tv32_1);
+compat_symbol (libc, __gettimeofday_tv32_1, gettimeofday, GLIBC_2_0);
+#endif
diff --git a/sysdeps/unix/sysv/linux/sw_64/osf_setitimer.c b/sysdeps/unix/sysv/linux/sw_64/osf_setitimer.c
new file mode 100644
index 00000000..7388a2e8
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/osf_setitimer.c
@@ -0,0 +1,51 @@
+/* getitimer -- Get the state of an interval timer. Linux/SW_64/tv32 version.
+ Copyright (C) 2019-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 <shlib-compat.h>
+
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
+
+# include <time.h>
+# include <sys/time.h>
+# include <tv32-compat.h>
+
+int attribute_compat_text_section
+__setitimer_tv32 (int which, const struct __itimerval32 *restrict new_value,
+ struct __itimerval32 *restrict old_value)
+{
+ struct itimerval new_value_64;
+ new_value_64.it_interval
+ = valid_timeval32_to_timeval (new_value->it_interval);
+ new_value_64.it_value = valid_timeval32_to_timeval (new_value->it_value);
+
+ if (old_value == NULL)
+ return __setitimer (which, &new_value_64, NULL);
+
+ struct itimerval old_value_64;
+ if (__setitimer (which, &new_value_64, &old_value_64) == -1)
+ return -1;
+
+ /* Write all fields of 'old_value' regardless of overflow. */
+ old_value->it_interval
+ = valid_timeval_to_timeval32 (old_value_64.it_interval);
+ old_value->it_value = valid_timeval_to_timeval32 (old_value_64.it_value);
+ return 0;
+}
+
+compat_symbol (libc, __setitimer_tv32, setitimer, GLIBC_2_0);
+#endif
diff --git a/sysdeps/unix/sysv/linux/sw_64/osf_settimeofday.c b/sysdeps/unix/sysv/linux/sw_64/osf_settimeofday.c
new file mode 100644
index 00000000..1dfe802e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/osf_settimeofday.c
@@ -0,0 +1,48 @@
+/* settimeofday -- Set the current time of day. Linux/SW_64/tv32 version.
+ Copyright (C) 2019-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 <shlib-compat.h>
+
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
+
+# include <time.h>
+# include <sys/time.h>
+# include <time.h>
+# include <errno.h>
+
+/* Set the current time of day and timezone information.
+ This call is restricted to the super-user. */
+int attribute_compat_text_section
+__settimeofday_tv32 (const struct __timeval32 *tv32, const struct timezone *tz)
+{
+ if (__glibc_unlikely (tz != 0))
+ {
+ if (tv32 != 0)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+ return __settimezone (tz);
+ }
+
+ struct timespec ts = valid_timeval32_to_timespec (*tv32);
+ return __clock_settime (CLOCK_REALTIME, &ts);
+}
+
+compat_symbol (libc, __settimeofday_tv32, settimeofday, GLIBC_2_0);
+#endif
diff --git a/sysdeps/unix/sysv/linux/sw_64/osf_utimes.c b/sysdeps/unix/sysv/linux/sw_64/osf_utimes.c
new file mode 100644
index 00000000..20fb6895
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/osf_utimes.c
@@ -0,0 +1,36 @@
+/* utimes -- change file timestamps. Linux/SW_64/tv32 version.
+ Copyright (C) 2019-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 <shlib-compat.h>
+
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
+
+# include <time.h>
+# include <sys/time.h>
+
+int attribute_compat_text_section
+__utimes_tv32 (const char *filename, const struct __timeval32 times32[2])
+{
+ struct timeval times[2];
+ times[0] = valid_timeval32_to_timeval (times32[0]);
+ times[1] = valid_timeval32_to_timeval (times32[1]);
+ return __utimes (filename, times);
+}
+
+compat_symbol (libc, __utimes_tv32, utimes, GLIBC_2_0);
+#endif
diff --git a/sysdeps/unix/sysv/linux/sw_64/osf_wait4.c b/sysdeps/unix/sysv/linux/sw_64/osf_wait4.c
new file mode 100644
index 00000000..8a7de5a4
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/osf_wait4.c
@@ -0,0 +1,40 @@
+/* wait4 -- wait for process to change state. Linux/SW_64/tv32 version.
+ Copyright (C) 2019-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 <shlib-compat.h>
+
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
+
+# include <sys/time.h>
+# include <sys/resource.h>
+# include <sys/wait.h>
+# include <tv32-compat.h>
+
+pid_t attribute_compat_text_section
+__wait4_tv32 (pid_t pid, int *status, int options, struct __rusage32 *usage32)
+{
+ struct rusage usage;
+ pid_t child = __wait4 (pid, status, options, &usage);
+
+ if (child >= 0 && usage32 != NULL)
+ rusage64_to_rusage32 (&usage, usage32);
+ return child;
+}
+
+compat_symbol (libc, __wait4_tv32, wait4, GLIBC_2_0);
+#endif
diff --git a/sysdeps/unix/sysv/linux/sw_64/pipe.S b/sysdeps/unix/sysv/linux/sw_64/pipe.S
new file mode 100644
index 00000000..4ff12601
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/pipe.S
@@ -0,0 +1 @@
+#include <sysdeps/unix/sw_64/pipe.S>
diff --git a/sysdeps/unix/sysv/linux/sw_64/pointer_guard.h b/sysdeps/unix/sysv/linux/sw_64/pointer_guard.h
new file mode 100644
index 00000000..71f0e1e3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/pointer_guard.h
@@ -0,0 +1,57 @@
+/* Pointer guard implementation. sw_64 version.
+ Copyright (C) 2006-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 POINTER_GUARD_H
+#define POINTER_GUARD_H
+
+/* Pointer mangling support. Note that tls access is slow enough that
+ we don't deoptimize things by placing the pointer check value there. */
+#ifdef __ASSEMBLER__
+# if IS_IN(rtld)
+# define PTR_MANGLE(dst, src, tmp) \
+ ldih tmp, __pointer_chk_guard_local ($29) !gprelhigh; \
+ ldl tmp, __pointer_chk_guard_local (tmp) !gprellow; \
+ xor src, tmp, dst
+# define PTR_MANGLE2(dst, src, tmp) xor src, tmp, dst
+# elif defined SHARED
+# define PTR_MANGLE(dst, src, tmp) \
+ ldl tmp, __pointer_chk_guard; \
+ xor src, tmp, dst
+# else
+# define PTR_MANGLE(dst, src, tmp) \
+ ldl tmp, __pointer_chk_guard_local; \
+ xor src, tmp, dst
+# endif
+# define PTR_MANGLE2(dst, src, tmp) xor src, tmp, dst
+# define PTR_DEMANGLE(dst, tmp) PTR_MANGLE (dst, dst, tmp)
+# define PTR_DEMANGLE2(dst, tmp) PTR_MANGLE2 (dst, dst, tmp)
+#else
+# include <stdint.h>
+# if (IS_IN(rtld) || (!defined SHARED && (IS_IN(libc) || IS_IN(libpthread))))
+extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
+# define PTR_MANGLE(var) \
+ (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
+# else
+extern uintptr_t __pointer_chk_guard attribute_relro;
+# define PTR_MANGLE(var) \
+ (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard)
+# endif
+# define PTR_DEMANGLE(var) PTR_MANGLE (var)
+#endif /* ASSEMBLER */
+
+#endif /* POINTER_GUARD_H */
diff --git a/sysdeps/unix/sysv/linux/sw_64/register-dump.h b/sysdeps/unix/sysv/linux/sw_64/register-dump.h
new file mode 100644
index 00000000..ff45563b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/register-dump.h
@@ -0,0 +1,239 @@
+/* Dump registers.
+ Copyright (C) 2004-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/>. */
+
+#include <string.h>
+#include <ucontext.h>
+#include <sys/uio.h>
+#include <_itoa.h>
+
+/* We will print the register dump in this format:
+
+ V0: XXXXXXXXXXXXXXXX T0: XXXXXXXXXXXXXXXX T1: XXXXXXXXXXXXXXXX
+ T2: XXXXXXXXXXXXXXXX T3: XXXXXXXXXXXXXXXX T4: XXXXXXXXXXXXXXXX
+ T5: XXXXXXXXXXXXXXXX T6: XXXXXXXXXXXXXXXX T7: XXXXXXXXXXXXXXXX
+ S0: XXXXXXXXXXXXXXXX S1: XXXXXXXXXXXXXXXX S2: XXXXXXXXXXXXXXXX
+ S3: XXXXXXXXXXXXXXXX S4: XXXXXXXXXXXXXXXX S5: XXXXXXXXXXXXXXXX
+ S6: XXXXXXXXXXXXXXXX A0: XXXXXXXXXXXXXXXX A1: XXXXXXXXXXXXXXXX
+ A2: XXXXXXXXXXXXXXXX A3: XXXXXXXXXXXXXXXX A4: XXXXXXXXXXXXXXXX
+ A5: XXXXXXXXXXXXXXXX T8: XXXXXXXXXXXXXXXX T9: XXXXXXXXXXXXXXXX
+ T10: XXXXXXXXXXXXXXXX T11: XXXXXXXXXXXXXXXX RA: XXXXXXXXXXXXXXXX
+ T12: XXXXXXXXXXXXXXXX AT: XXXXXXXXXXXXXXXX GP: XXXXXXXXXXXXXXXX
+ SP: XXXXXXXXXXXXXXXX PC: XXXXXXXXXXXXXXXX
+
+ FP0: XXXXXXXXXXXXXXXX FP1: XXXXXXXXXXXXXXXX FP2: XXXXXXXXXXXXXXXX
+ FP3: XXXXXXXXXXXXXXXX FP4: XXXXXXXXXXXXXXXX FP5: XXXXXXXXXXXXXXXX
+ FP6: XXXXXXXXXXXXXXXX FP7: XXXXXXXXXXXXXXXX FP8: XXXXXXXXXXXXXXXX
+ FP9: XXXXXXXXXXXXXXXX FP10: XXXXXXXXXXXXXXXX FP11: XXXXXXXXXXXXXXXX
+ FP12: XXXXXXXXXXXXXXXX FP13: XXXXXXXXXXXXXXXX FP14: XXXXXXXXXXXXXXXX
+ FP15: XXXXXXXXXXXXXXXX FP16: XXXXXXXXXXXXXXXX FP17: XXXXXXXXXXXXXXXX
+ FP18: XXXXXXXXXXXXXXXX FP19: XXXXXXXXXXXXXXXX FP20: XXXXXXXXXXXXXXXX
+ FP21: XXXXXXXXXXXXXXXX FP22: XXXXXXXXXXXXXXXX FP23: XXXXXXXXXXXXXXXX
+ FP24: XXXXXXXXXXXXXXXX FP25: XXXXXXXXXXXXXXXX FP26: XXXXXXXXXXXXXXXX
+ FP27: XXXXXXXXXXXXXXXX FP28: XXXXXXXXXXXXXXXX FP29: XXXXXXXXXXXXXXXX
+ FP30: XXXXXXXXXXXXXXXX FPCR: XXXXXXXXXXXXXXXX
+
+ TA0: XXXXXXXXXXXXXXXX TA1: XXXXXXXXXXXXXXXX TA2: XXXXXXXXXXXXXXXX
+*/
+
+static void
+hexvalue (unsigned long int value, char *buf, size_t len)
+{
+ char *cp = _itoa_word (value, buf + len, 16, 0);
+ while (cp > buf)
+ *--cp = '0';
+}
+
+static void
+register_dump (int fd, struct ucontext_t *ctx)
+{
+ struct iovec iov[31 * 2 + 2 /* REGS + PC. */
+ + 31 * 2 + 2 /* FREGS + FPCR. */
+ + (3 * 2) /* TA0, TA1, TA3. */
+ + 1 /* '\n'. */];
+ size_t nr = 0;
+
+#define ADD_STRING(str) \
+ iov[nr].iov_base = (char *) str; \
+ iov[nr].iov_len = strlen (str); \
+ ++nr
+#define ADD_MEM(str, len) \
+ iov[nr].iov_base = str; \
+ iov[nr].iov_len = len; \
+ ++nr
+
+ char regs[31][16];
+ char pc[16];
+ for (int i = 0; i < 31; i++)
+ hexvalue (ctx->uc_mcontext.sc_regs[i], regs[i], 16);
+ hexvalue (ctx->uc_mcontext.sc_pc, pc, 16);
+
+ /* Generate the output. */
+ ADD_STRING ("Register dump:\n\n V0: ");
+ ADD_MEM (regs[0], 16);
+ ADD_STRING (" T0: ");
+ ADD_MEM (regs[1], 16);
+ ADD_STRING (" T1: ");
+ ADD_MEM (regs[2], 16);
+ ADD_STRING ("\n T2: ");
+ ADD_MEM (regs[3], 16);
+ ADD_STRING (" T3: ");
+ ADD_MEM (regs[4], 16);
+ ADD_STRING (" T4: ");
+ ADD_MEM (regs[5], 16);
+ ADD_STRING ("\n T5: ");
+ ADD_MEM (regs[6], 16);
+ ADD_STRING (" T6: ");
+ ADD_MEM (regs[7], 16);
+ ADD_STRING (" T7: ");
+ ADD_MEM (regs[8], 16);
+ ADD_STRING ("\n S0: ");
+ ADD_MEM (regs[9], 16);
+ ADD_STRING (" S1: ");
+ ADD_MEM (regs[10], 16);
+ ADD_STRING (" S2: ");
+ ADD_MEM (regs[11], 16);
+ ADD_STRING ("\n S3: ");
+ ADD_MEM (regs[12], 16);
+ ADD_STRING (" S4: ");
+ ADD_MEM (regs[13], 16);
+ ADD_STRING (" S5: ");
+ ADD_MEM (regs[14], 16);
+ ADD_STRING ("\n S6: ");
+ ADD_MEM (regs[15], 16);
+ ADD_STRING (" A0: ");
+ ADD_MEM (regs[16], 16);
+ ADD_STRING (" A1: ");
+ ADD_MEM (regs[17], 16);
+ ADD_STRING ("\n A2: ");
+ ADD_MEM (regs[18], 16);
+ ADD_STRING (" A3: ");
+ ADD_MEM (regs[19], 16);
+ ADD_STRING (" A4: ");
+ ADD_MEM (regs[20], 16);
+ ADD_STRING ("\n A5: ");
+ ADD_MEM (regs[21], 16);
+ ADD_STRING (" T8: ");
+ ADD_MEM (regs[22], 16);
+ ADD_STRING (" T9: ");
+ ADD_MEM (regs[23], 16);
+ ADD_STRING ("\n T10: ");
+ ADD_MEM (regs[24], 16);
+ ADD_STRING (" T11: ");
+ ADD_MEM (regs[25], 16);
+ ADD_STRING (" RA: ");
+ ADD_MEM (regs[26], 16);
+ ADD_STRING ("\n T12: ");
+ ADD_MEM (regs[27], 16);
+ ADD_STRING (" AT: ");
+ ADD_MEM (regs[28], 16);
+ ADD_STRING (" GP: ");
+ ADD_MEM (regs[29], 16);
+ ADD_STRING ("\n SP: ");
+ ADD_MEM (regs[30], 16);
+ ADD_STRING (" PC: ");
+ ADD_MEM (pc, 16);
+
+ char fpregs[31][16];
+ char fpcr[16];
+ for (int i = 0; i < 31; i++)
+ hexvalue (ctx->uc_mcontext.sc_fpregs[i], fpregs[i], 16);
+ hexvalue (ctx->uc_mcontext.sc_fpcr, fpcr, 16);
+
+ ADD_STRING ("\n\n FP0: ");
+ ADD_MEM (fpregs[0], 16);
+ ADD_STRING (" FP1: ");
+ ADD_MEM (fpregs[1], 16);
+ ADD_STRING (" FP2: ");
+ ADD_MEM (fpregs[2], 16);
+ ADD_STRING ("\n FP3: ");
+ ADD_MEM (fpregs[3], 16);
+ ADD_STRING (" FP4: ");
+ ADD_MEM (fpregs[4], 16);
+ ADD_STRING (" FP5: ");
+ ADD_MEM (fpregs[5], 16);
+ ADD_STRING ("\n FP6: ");
+ ADD_MEM (fpregs[6], 16);
+ ADD_STRING (" FP7: ");
+ ADD_MEM (fpregs[7], 16);
+ ADD_STRING (" FP8: ");
+ ADD_MEM (fpregs[8], 16);
+ ADD_STRING ("\n FP9: ");
+ ADD_MEM (fpregs[9], 16);
+ ADD_STRING (" FP10: ");
+ ADD_MEM (fpregs[10], 16);
+ ADD_STRING (" FP11: ");
+ ADD_MEM (fpregs[11], 16);
+ ADD_STRING ("\n FP12: ");
+ ADD_MEM (fpregs[12], 16);
+ ADD_STRING (" FP13: ");
+ ADD_MEM (fpregs[13], 16);
+ ADD_STRING (" FP14: ");
+ ADD_MEM (fpregs[14], 16);
+ ADD_STRING ("\n FP15: ");
+ ADD_MEM (fpregs[15], 16);
+ ADD_STRING (" FP16: ");
+ ADD_MEM (fpregs[16], 16);
+ ADD_STRING (" FP17: ");
+ ADD_MEM (fpregs[17], 16);
+ ADD_STRING ("\n FP18: ");
+ ADD_MEM (fpregs[18], 16);
+ ADD_STRING (" FP19: ");
+ ADD_MEM (fpregs[19], 16);
+ ADD_STRING (" FP20: ");
+ ADD_MEM (fpregs[20], 16);
+ ADD_STRING ("\n FP21: ");
+ ADD_MEM (fpregs[21], 16);
+ ADD_STRING (" FP22: ");
+ ADD_MEM (fpregs[22], 16);
+ ADD_STRING (" FP23: ");
+ ADD_MEM (fpregs[23], 16);
+ ADD_STRING ("\n FP24: ");
+ ADD_MEM (fpregs[24], 16);
+ ADD_STRING (" FP25: ");
+ ADD_MEM (fpregs[25], 16);
+ ADD_STRING (" FP26: ");
+ ADD_MEM (fpregs[26], 16);
+ ADD_STRING ("\n FP27: ");
+ ADD_MEM (fpregs[27], 16);
+ ADD_STRING (" FP28: ");
+ ADD_MEM (fpregs[28], 16);
+ ADD_STRING (" FP29: ");
+ ADD_MEM (fpregs[29], 16);
+ ADD_STRING ("\n FP30: ");
+ ADD_MEM (fpregs[30], 16);
+ ADD_STRING (" FPCR: ");
+ ADD_MEM (fpcr, 16);
+
+ char traparg[3][16];
+ hexvalue (ctx->uc_mcontext.sc_traparg_a0, traparg[0], 16);
+ hexvalue (ctx->uc_mcontext.sc_traparg_a1, traparg[1], 16);
+ hexvalue (ctx->uc_mcontext.sc_traparg_a2, traparg[2], 16);
+ ADD_STRING ("\n\n TA0: ");
+ ADD_MEM (traparg[0], 16);
+ ADD_STRING (" TA1: ");
+ ADD_MEM (traparg[1], 16);
+ ADD_STRING (" TA2: ");
+ ADD_MEM (traparg[2], 16);
+
+ ADD_STRING ("\n");
+
+ /* Write the stuff out. */
+ writev (fd, iov, nr);
+}
+
+#define REGISTER_DUMP register_dump (fd, ctx)
diff --git a/sysdeps/unix/sysv/linux/sw_64/rt_sigaction.S b/sysdeps/unix/sysv/linux/sw_64/rt_sigaction.S
new file mode 100644
index 00000000..57a3b66e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/rt_sigaction.S
@@ -0,0 +1,87 @@
+/* Copyright (C) 1998-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson <rth@cygnus.com>, 1998
+
+ 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 <sysdep.h>
+
+/* To enable unwinding through the signal frame without special hackery
+ elsewhere, describe the entire struct sigcontext with unwind info.
+
+ In order to minimize the size of the encoding, we set the CFA to the
+ end of the sigcontext, which makes all of the registers have small
+ negative offsets from that. */
+
+ .macro SIGCONTEXT_REGS_I base, from=0
+ cfi_offset (\from, \base + (4 + \from) * 8)
+ .if 30-\from
+ SIGCONTEXT_REGS_I \base, "(\from+1)"
+ .endif
+ .endm
+
+ .macro SIGCONTEXT_REGS_F base, from=32
+ cfi_offset (\from, \base + (4 + 1 + \from) * 8)
+ .if 62-\from
+ SIGCONTEXT_REGS_F \base, "(\from+1)"
+ .endif
+ .endm
+
+ .macro SIGCONTEXT_REGS base
+ SIGCONTEXT_REGS_I \base
+ SIGCONTEXT_REGS_F \base
+ cfi_offset (63, \base + (4 + 32 + 1 + 32) * 8)
+ cfi_offset (64, \base + 2 * 8)
+ .endm
+
+ cfi_startproc
+ cfi_return_column (64)
+ .cfi_signal_frame
+ SIGCONTEXT_REGS -648
+ cfi_def_cfa_offset (648)
+
+ /* While this frame is marked as a signal frame, that only applies
+ to how this return address is handled for the outer frame.
+ The return address that arrived here, from the inner frame, is
+ not marked as a signal frame and so the unwinder still tries to
+ fsubdract 1 to examine the presumed call insn. Thus we must
+ extend the unwind info to a nop before the start. */
+ nop
+ .align 4
+
+__syscall_sigreturn:
+ mov sp, a0
+ ldi v0, __NR_sigreturn
+ sys_call 0x83
+ .size __syscall_sigreturn, .-__syscall_sigreturn
+ .type __syscall_sigreturn, @function
+ .global __syscall_sigreturn;
+ .hidden __syscall_sigreturn;
+
+ /* See above wrt including the nop. */
+ cfi_def_cfa_offset (176 + 648)
+ nop
+ .align 4
+
+__syscall_rt_sigreturn:
+ mov sp,a0
+ ldi v0,__NR_rt_sigreturn
+ sys_call 0x83
+ .size __syscall_rt_sigreturn, .-__syscall_rt_sigreturn
+ .type __syscall_rt_sigreturn, @function
+ .global __syscall_rt_sigreturn;
+ .hidden __syscall_rt_sigreturn;
+
+ cfi_endproc
diff --git a/sysdeps/unix/sysv/linux/sw_64/select.c b/sysdeps/unix/sysv/linux/sw_64/select.c
new file mode 100644
index 00000000..ae14d831
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/select.c
@@ -0,0 +1,52 @@
+/* Linux/sw_64 select implementation.
+ Copyright (C) 2017-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/>. */
+
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/select.h>
+#include <errno.h>
+#include <sysdep-cancel.h>
+#include <shlib-compat.h>
+
+int
+__new_select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
+ struct timeval *timeout)
+{
+ return SYSCALL_CANCEL (select, nfds, readfds, writefds, exceptfds, timeout);
+}
+
+strong_alias (__new_select, __select) libc_hidden_def (__select)
+default_symbol_version (__new_select, select, GLIBC_2.1);
+strong_alias (__new_select, __new_select_private);
+symbol_version (__new_select_private, __select, GLIBC_2.1);
+
+// TODO: select32 already deleted in linux 4.19
+/* Old timeval32 compat calls. */
+/* #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
+int
+__select_tv32 (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
+ struct timeval *timeout)
+{
+ return SYSCALL_CANCEL (osf_select, nfds, readfds, writefds, exceptfds,
+ timeout);
+}
+strong_alias (__select_tv32, __select_tv32_1)
+
+compat_symbol (libc, __select_tv32, __select, GLIBC_2_0);
+compat_symbol (libc, __select_tv32_1, select, GLIBC_2_0);
+#endif */
diff --git a/sysdeps/unix/sysv/linux/sw_64/setcontext.S b/sysdeps/unix/sysv/linux/sw_64/setcontext.S
new file mode 100644
index 00000000..69819b24
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/setcontext.S
@@ -0,0 +1,34 @@
+/* Install given context.
+ Copyright (C) 2004-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 <sysdep.h>
+#include <ucontext-offsets.h>
+
+
+/* In case the user fiddled it, copy the "official" signal mask
+ from the ucontext_t into the sigcontext structure. */
+#undef PSEUDO_PREPARE_ARGS
+#define PSEUDO_PREPARE_ARGS \
+ ldl $0, UC_SIGMASK($16); \
+ stl $0, UC_SIGCTX+SC_MASK($16); \
+ ldi $16, UC_SIGCTX($16);
+
+PSEUDO(__setcontext, sigreturn, 1)
+ ret
+PSEUDO_END(__setcontext)
+weak_alias (__setcontext, setcontext)
diff --git a/sysdeps/unix/sysv/linux/sw_64/setfpucw.c b/sysdeps/unix/sysv/linux/sw_64/setfpucw.c
new file mode 100644
index 00000000..34cbfbee
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/setfpucw.c
@@ -0,0 +1,56 @@
+/* Set FP exception mask and rounding mode.
+ Copyright (C) 1996-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/>. */
+
+#include <fpu_control.h>
+#include <fenv_libc.h>
+
+#define convert_bit(M, F, T) \
+ ((T) < (F) ? ((M) / ((F) / (T))) & (T) : ((M) & (F)) * ((T) / (F)))
+
+void
+__setfpucw (fpu_control_t fpu_control)
+{
+ unsigned long fpcr, swcr, fc = (int) fpu_control;
+
+ /* ??? If this was a real external interface we'd want to read the current
+ exception state with __ieee_get_fp_control. But this is an internal
+ function only called at process startup, so there's no point in trying
+ to preserve exceptions that cannot have been raised yet. Indeed, this
+ entire function is likely to be one big nop unless the user overrides
+ the default __fpu_control variable. */
+
+ /* Convert the rounding mode from fpu_control.h format. */
+ const unsigned long conv_rnd = ((FE_TOWARDZERO << (_FPU_RC_ZERO >> 8))
+ | (FE_DOWNWARD << (_FPU_RC_DOWN >> 8))
+ | (FE_TONEAREST << (_FPU_RC_NEAREST >> 8))
+ | (FE_UPWARD << (_FPU_RC_UP >> 8)));
+
+ fpcr = ((conv_rnd >> ((fc >> 8) & 3)) & 3) << FPCR_ROUND_SHIFT;
+
+ /* Convert the exception mask from fpu_control.h format. */
+ swcr = convert_bit (~fc, _FPU_MASK_IM, FE_INVALID >> SWCR_ENABLE_SHIFT);
+ swcr |= convert_bit (~fc, _FPU_MASK_DM, FE_UNDERFLOW >> SWCR_ENABLE_SHIFT);
+ swcr |= convert_bit (~fc, _FPU_MASK_ZM, FE_DIVBYZERO >> SWCR_ENABLE_SHIFT);
+ swcr |= convert_bit (~fc, _FPU_MASK_OM, FE_OVERFLOW >> SWCR_ENABLE_SHIFT);
+ swcr |= convert_bit (~fc, _FPU_MASK_PM, FE_INEXACT >> SWCR_ENABLE_SHIFT);
+
+ /* Install everything. */
+ __fpu_control = fc;
+ asm volatile ("wfpcr %0" : : "f"(fpcr));
+ __ieee_set_fp_control (swcr);
+}
diff --git a/sysdeps/unix/sysv/linux/sw_64/setrlimit64.c b/sysdeps/unix/sysv/linux/sw_64/setrlimit64.c
new file mode 100644
index 00000000..0911305a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/setrlimit64.c
@@ -0,0 +1,52 @@
+/* Copyright (C) 2018-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/>. */
+
+#define USE_VERSIONED_RLIMIT
+#include <sysdeps/unix/sysv/linux/setrlimit64.c>
+versioned_symbol (libc, __setrlimit, setrlimit, GLIBC_2_27);
+versioned_symbol (libc, __setrlimit64, setrlimit64, GLIBC_2_27);
+
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_27)
+/* RLIM64_INFINITY was supposed to be a glibc convention rather than
+ anything seen by the kernel, but it ended being passed to the kernel
+ through the prlimit64 syscall. Given that a lot of binaries with
+ the wrong constant value are in the wild, provide a wrapper function
+ fixing the value before the syscall. */
+# define OLD_RLIM64_INFINITY 0x7fffffffffffffffULL
+
+int attribute_compat_text_section
+__old_setrlimit64 (enum __rlimit_resource resource,
+ const struct rlimit64 *rlimits)
+{
+ struct rlimit64 krlimits;
+
+ if (rlimits->rlim_cur == OLD_RLIM64_INFINITY)
+ krlimits.rlim_cur = RLIM64_INFINITY;
+ else
+ krlimits.rlim_cur = rlimits->rlim_cur;
+ if (rlimits->rlim_max == OLD_RLIM64_INFINITY)
+ krlimits.rlim_max = RLIM64_INFINITY;
+ else
+ krlimits.rlim_max = rlimits->rlim_max;
+
+ return __setrlimit64 (resource, &krlimits);
+}
+
+strong_alias (__old_setrlimit64, __old_setrlimit)
+ compat_symbol (libc, __old_setrlimit, setrlimit, GLIBC_2_0);
+compat_symbol (libc, __old_setrlimit64, setrlimit64, GLIBC_2_1);
+#endif
diff --git a/sysdeps/unix/sysv/linux/sw_64/settimeofday.c b/sysdeps/unix/sysv/linux/sw_64/settimeofday.c
new file mode 100644
index 00000000..dec19839
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/settimeofday.c
@@ -0,0 +1,22 @@
+/* settimeofday -- Set the current time of day. Linux/SW_64/tv64 version.
+ Copyright (C) 2019-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/>. */
+
+/* We can use the generic implementation, but we have to override its
+ default symbol version. */
+#define VERSION_settimeofday GLIBC_2.1
+#include <time/settimeofday.c>
diff --git a/sysdeps/unix/sysv/linux/sw_64/shlib-versions b/sysdeps/unix/sysv/linux/sw_64/shlib-versions
new file mode 100644
index 00000000..58b0bd8e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/shlib-versions
@@ -0,0 +1,20 @@
+%ifdef HAVE_SW64_NEW_LIBCVERSION
+libm=6
+libc=6
+libBrokenLocale=1
+libdl=2
+libnsl=1
+libresolv=2
+libutil=1
+%else
+libm=6.1
+libc=6.1
+libBrokenLocale=1.1
+libdl=2.1
+libnsl=1.1
+libresolv=2.1
+libutil=1.1
+%endif
+
+ld=ld-linux.so.2
+libcrypt=1.1
diff --git a/sysdeps/unix/sysv/linux/sw_64/sigcontextinfo.h b/sysdeps/unix/sysv/linux/sw_64/sigcontextinfo.h
new file mode 100644
index 00000000..ba7ccfea
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/sigcontextinfo.h
@@ -0,0 +1,30 @@
+/* Copyright (C) 1999-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 _SIGCONTEXTINFO_H
+#define _SIGCONTEXTINFO_H
+
+#include <stdint.h>
+#include <sys/ucontext.h>
+
+static inline uintptr_t
+sigcontext_get_pc (const ucontext_t *ctx)
+{
+ return ctx->uc_mcontext.sc_pc;
+}
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/sw_64/sizes.h b/sysdeps/unix/sysv/linux/sw_64/sizes.h
new file mode 100644
index 00000000..4243a1c9
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/sizes.h
@@ -0,0 +1,23 @@
+/* Copyright (C) 1998-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 _SIZES_H
+#define _SIZES_H 1
+
+#define PTR_SIZE_STR "8"
+
+#endif /* sizes.h */
diff --git a/sysdeps/unix/sysv/linux/sw_64/statfs.c b/sysdeps/unix/sysv/linux/sw_64/statfs.c
new file mode 100644
index 00000000..ab05750e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/statfs.c
@@ -0,0 +1,29 @@
+/* Return information about the filesystem on which FILE resides. Linux/sw_64.
+ Copyright (C) 1996-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/>. */
+
+#include <sys/statfs.h>
+#include <sysdep.h>
+#include <kernel_stat.h>
+
+/* Return information about the filesystem on which FILE resides. */
+int
+__statfs (const char *file, struct statfs *buf)
+{
+ return INLINE_SYSCALL_CALL (statfs, file, buf);
+}
+libc_hidden_def (__statfs) weak_alias (__statfs, statfs)
diff --git a/sysdeps/unix/sysv/linux/sw_64/sw_64/ptrace.h b/sysdeps/unix/sysv/linux/sw_64/sw_64/ptrace.h
new file mode 100644
index 00000000..8309293d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/sw_64/ptrace.h
@@ -0,0 +1,18 @@
+#ifndef __sw_64_ptrace_h__
+#define __sw_64_ptrace_h__
+
+/*
+ * Mostly for OSF/1 compatibility.
+ */
+
+#define REG_BASE 0
+#define NGP_REGS 32
+#define NFP_REGS 32
+
+#define GPR_BASE REG_BASE
+#define FPR_BASE (GPR_BASE + NGP_REGS)
+#define PC (FPR_BASE + NFP_REGS)
+#define SPR_PS (PC + 1)
+#define NPTRC_REGS (SPR_PS + 1)
+
+#endif /* __sw_64_ptrace_h__ */
diff --git a/sysdeps/unix/sysv/linux/sw_64/sw_64/regdef.h b/sysdeps/unix/sysv/linux/sw_64/sw_64/regdef.h
new file mode 100644
index 00000000..04ab6481
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/sw_64/regdef.h
@@ -0,0 +1,44 @@
+#ifndef __sw_64_regdef_h__
+#define __sw_64_regdef_h__
+
+#define v0 $0 /* function return value */
+
+#define t0 $1 /* temporary registers (caller-saved) */
+#define t1 $2
+#define t2 $3
+#define t3 $4
+#define t4 $5
+#define t5 $6
+#define t6 $7
+#define t7 $8
+
+#define s0 $9 /* saved-registers (callee-saved registers) */
+#define s1 $10
+#define s2 $11
+#define s3 $12
+#define s4 $13
+#define s5 $14
+#define s6 $15
+#define fp s6 /* frame-pointer (s6 in frame-less procedures) */
+
+#define a0 $16 /* argument registers (caller-saved) */
+#define a1 $17
+#define a2 $18
+#define a3 $19
+#define a4 $20
+#define a5 $21
+
+#define t8 $22 /* more temps (caller-saved) */
+#define t9 $23
+#define t10 $24
+#define t11 $25
+#define ra $26 /* return address register */
+#define t12 $27
+
+#define pv t12 /* procedure-variable register */
+#define AT $at /* assembler temporary */
+#define gp $29 /* global pointer */
+#define sp $30 /* stack pointer */
+#define zero $31 /* reads as zero, writes are noops */
+
+#endif /* __sw_64_regdef_h__ */
diff --git a/sysdeps/unix/sysv/linux/sw_64/swapcontext.S b/sysdeps/unix/sysv/linux/sw_64/swapcontext.S
new file mode 100644
index 00000000..e3e2f445
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/swapcontext.S
@@ -0,0 +1,50 @@
+/* Save current context and install the given one.
+ Copyright (C) 2004-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 <sysdep.h>
+#include <ucontext-offsets.h>
+
+ENTRY(__swapcontext)
+
+#ifdef PROF
+ ldgp $29, 0($27)
+ .set noat
+ ldi AT, _mcount
+ call AT, (AT), _mcount
+ .set at
+ .prologue 1
+#elif defined PIC
+ .prologue 0
+#else
+ ldgp $29, 0($27)
+ .prologue 1
+#endif
+
+#ifdef PIC
+ unop
+ bsr $0, __getcontext_x !samegp
+ mov $17, $16
+ br $31, __setcontext !samegp
+#else
+ call $0, __getcontext_x
+ mov $17, $16
+ jmp $31, __setcontext
+#endif
+
+END(__swapcontext)
+weak_alias (__swapcontext, swapcontext)
diff --git a/sysdeps/unix/sysv/linux/sw_64/sys/acct.h b/sysdeps/unix/sysv/linux/sw_64/sys/acct.h
new file mode 100644
index 00000000..9209eff1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/sys/acct.h
@@ -0,0 +1,62 @@
+/* Copyright (C) 1996-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 _SYS_ACCT_H
+
+#define _SYS_ACCT_H 1
+#include <features.h>
+
+#include <bits/types/time_t.h>
+
+__BEGIN_DECLS
+
+#define ACCT_COMM 16
+
+struct acct
+{
+ char ac_comm[ACCT_COMM]; /* Accounting command name. */
+ time_t ac_utime; /* Accounting user time. */
+ time_t ac_stime; /* Accounting system time. */
+ time_t ac_etime; /* Accounting elapsed time. */
+ time_t ac_btime; /* Beginning time. */
+ unsigned int ac_uid; /* Accounting user ID. */
+ unsigned int ac_gid; /* Accounting group ID. */
+ unsigned int ac_tty; /* Controlling tty. */
+ /* Please note that the value of the `ac_tty' field, a device number,
+ is encoded differently in the kernel and for the libc dev_t type. */
+ char ac_flag; /* Accounting flag. */
+ long int ac_minflt; /* Accounting minor pagefaults. */
+ long int ac_majflt; /* Accounting major pagefaults. */
+ long int ac_exitcode; /* Accounting process exitcode. */
+};
+
+enum
+{
+ AFORK = 0001, /* Has executed fork, but no exec. */
+ ASU = 0002, /* Used super-user privileges. */
+ ACORE = 0004, /* Dumped core. */
+ AXSIG = 0010 /* Killed by a signal. */
+};
+
+#define AHZ 100
+
+/* Switch process accounting on and off. */
+extern int acct (const char *__filename) __THROW;
+
+__END_DECLS
+
+#endif /* sys/acct.h */
diff --git a/sysdeps/unix/sysv/linux/sw_64/sys/io.h b/sysdeps/unix/sysv/linux/sw_64/sys/io.h
new file mode 100644
index 00000000..67d5c8ab
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/sys/io.h
@@ -0,0 +1,90 @@
+/* Copyright (C) 1996-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 _SYS_IO_H
+
+#define _SYS_IO_H 1
+#include <features.h>
+
+__BEGIN_DECLS
+
+/* If TURN_ON is TRUE, request for permission to do direct i/o on the
+ port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O
+ permission off for that range. This call requires root privileges.
+
+ Portability note: not all Linux platforms support this call. Most
+ platforms based on the PC I/O architecture probably will, however.
+ E.g., Linux/Sw_64 for Sw_64 PCs supports this. */
+extern int ioperm (unsigned long int __from, unsigned long int __num,
+ int __turn_on) __THROW;
+
+/* Set the I/O privilege level to LEVEL. If LEVEL>3, permission to
+ access any I/O port is granted. This call requires root
+ privileges. */
+extern int iopl (int __level) __THROW;
+
+/* Return the physical address of the DENSE I/O memory or NULL if none
+ is available (e.g. on a jensen). */
+extern unsigned long int _bus_base (void) __THROW __attribute__ ((const));
+extern unsigned long int bus_base (void) __THROW __attribute__ ((const));
+
+/* Return the physical address of the SPARSE I/O memory. */
+extern unsigned long _bus_base_sparse (void) __THROW __attribute__ ((const));
+extern unsigned long bus_base_sparse (void) __THROW __attribute__ ((const));
+
+/* Return the HAE shift used by the SPARSE I/O memory. */
+extern int _hae_shift (void) __THROW __attribute__ ((const));
+extern int hae_shift (void) __THROW __attribute__ ((const));
+
+/* Previous three are deprecated in favour of the following, which
+ knows about multiple PCI "hoses". Provide the PCI bus and dfn
+ numbers just as to pciconfig_read/write. */
+
+enum __pciconfig_iobase_which
+{
+ IOBASE_HOSE = 0, /* Return hose index. */
+ IOBASE_SPARSE_MEM = 1, /* Return physical memory addresses. */
+ IOBASE_DENSE_MEM = 2,
+ IOBASE_SPARSE_IO = 3,
+ IOBASE_DENSE_IO = 4
+};
+
+extern long pciconfig_iobase (enum __pciconfig_iobase_which __which,
+ unsigned long int __bus,
+ unsigned long int __dfn) __THROW
+ __attribute__ ((const));
+
+/* Access PCI space protected from machine checks. */
+extern int pciconfig_read (unsigned long int __bus, unsigned long int __dfn,
+ unsigned long int __off, unsigned long int __len,
+ unsigned char *__buf) __THROW;
+
+extern int pciconfig_write (unsigned long int __bus, unsigned long int __dfn,
+ unsigned long int __off, unsigned long int __len,
+ unsigned char *__buf) __THROW;
+
+/* Userspace declarations. */
+extern unsigned int inb (unsigned long __port) __THROW;
+extern unsigned int inw (unsigned long __port) __THROW;
+extern unsigned int inl (unsigned long __port) __THROW;
+extern void outb (unsigned char __b, unsigned long __port) __THROW;
+extern void outw (unsigned short __w, unsigned long __port) __THROW;
+extern void outl (unsigned int __l, unsigned long __port) __THROW;
+
+__END_DECLS
+
+#endif /* _SYS_IO_H */
diff --git a/sysdeps/unix/sysv/linux/sw_64/sys/ucontext.h b/sysdeps/unix/sysv/linux/sw_64/sys/ucontext.h
new file mode 100644
index 00000000..a47ce691
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/sys/ucontext.h
@@ -0,0 +1,92 @@
+/* Copyright (C) 1998-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 _SYS_UCONTEXT_H
+#define _SYS_UCONTEXT_H 1
+
+#include <features.h>
+
+#include <bits/types/sigset_t.h>
+#include <bits/types/stack_t.h>
+
+#ifdef __USE_MISC
+# define __ctx(fld) fld
+#else
+# define __ctx(fld) __##fld
+#endif
+
+/* Type for general register. */
+typedef long int greg_t;
+
+/* Number of general registers. */
+#define __NGREG 33
+#ifdef __USE_MISC
+# define NGREG __NGREG
+#endif
+
+/* Container for all general registers. */
+typedef greg_t gregset_t[__NGREG];
+
+/* Type for floating-point register. */
+typedef long int fpreg_t;
+
+/* Number of general registers. */
+#define __NFPREG 32
+#ifdef __USE_MISC
+# define NFPREG __NFPREG
+#endif
+
+/* Container for all general registers. */
+typedef fpreg_t fpregset_t[__NFPREG];
+
+/* A machine context is exactly a sigcontext. */
+typedef struct
+{
+ long int __ctx (sc_onstack);
+ long int __ctx (sc_mask);
+ long int __ctx (sc_pc);
+ long int __ctx (sc_ps);
+ long int __ctx (sc_regs)[32];
+ long int __ctx (sc_ownedfp);
+ long int __ctx (sc_fpregs)[128];
+ unsigned long int __ctx (sc_fpcr);
+ unsigned long int __ctx (sc_fp_control);
+ unsigned long int __glibc_reserved1, __glibc_reserved2;
+ unsigned long int __ctx (sc_ssize);
+ char *__ctx (sc_sbase);
+ unsigned long int __ctx (sc_traparg_a0);
+ unsigned long int __ctx (sc_traparg_a1);
+ unsigned long int __ctx (sc_traparg_a2);
+ unsigned long int __ctx (sc_fp_trap_pc);
+ unsigned long int __ctx (sc_fp_trigger_sum);
+ unsigned long int __ctx (sc_fp_trigger_inst);
+} mcontext_t;
+
+/* Userlevel context. */
+typedef struct ucontext_t
+{
+ unsigned long int __ctx (uc_flags);
+ struct ucontext_t *uc_link;
+ unsigned long __uc_osf_sigmask;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ sigset_t uc_sigmask;
+} ucontext_t;
+
+#undef __ctx
+
+#endif /* sys/ucontext.h */
diff --git a/sysdeps/unix/sysv/linux/sw_64/sys/user.h b/sysdeps/unix/sysv/linux/sw_64/sys/user.h
new file mode 100644
index 00000000..3462615d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/sys/user.h
@@ -0,0 +1,52 @@
+/* Copyright (C) 1999-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 _SYS_USER_H
+#define _SYS_USER_H 1
+
+/* The whole purpose of this file is for gdb/strace and gdb/strace
+ only. Don't read too much into it. Don't use it for anything other
+ than gdb/strace unless you know what you are doing. */
+
+#include <asm/reg.h>
+#include <stddef.h>
+
+struct user
+{
+ unsigned long int regs[EF_SIZE / 8 + 32]; /* integer and fp regs */
+ size_t u_tsize; /* text size (pages) */
+ size_t u_dsize; /* data size (pages) */
+ size_t u_ssize; /* stack size (pages) */
+ unsigned long int start_code; /* text starting address */
+ unsigned long int start_data; /* data starting address */
+ unsigned long int start_stack; /* stack starting address */
+ long int signal; /* signal causing core dump */
+ struct regs *u_ar0; /* help gdb find registers */
+ unsigned long int magic; /* identifies a core file */
+ char u_comm[32]; /* user command name */
+};
+
+#define PAGE_SHIFT 13
+#define PAGE_SIZE (1UL << PAGE_SHIFT)
+#define PAGE_MASK (~(PAGE_SIZE - 1))
+#define NBPG PAGE_SIZE
+#define UPAGES 1
+#define HOST_TEXT_START_ADDR (u.start_code)
+#define HOST_DATA_START_ADDR (u.start_data)
+#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
+
+#endif /* sys/user.h */
diff --git a/sysdeps/unix/sysv/linux/sw_64/syscalls.list b/sysdeps/unix/sysv/linux/sw_64/syscalls.list
new file mode 100644
index 00000000..cbfd1258
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/syscalls.list
@@ -0,0 +1,27 @@
+# File name Caller Syscall name Args Strong name Weak names
+
+sigstack - sigstack 2 sigstack
+
+getpriority - getpriority i:ii __getpriority getpriority
+
+# proper socket implementations:
+bind - bind i:ipi __bind bind
+getpeername - getpeername i:ipp __getpeername getpeername
+getsockname - getsockname i:ipp __getsockname getsockname
+listen - listen i:ii __listen listen
+shutdown - shutdown i:ii __shutdown shutdown
+socket - socket i:iii __socket socket
+socketpair - socketpair i:iiif __socketpair socketpair
+
+ptrace - ptrace 4 __ptrace ptrace
+
+# access pci space protected from machine checks:
+pciconfig_read EXTRA pciconfig_read 5 pciconfig_read
+pciconfig_write EXTRA pciconfig_write 5 pciconfig_write
+pciconfig_iobase EXTRA pciconfig_iobase 3 __pciconfig_iobase pciconfig_iobase
+
+# timeval64 entry points (see osf_*.c for GLIBC_2.0 timeval32 equivalents)
+getitimer - getitimer i:ip __getitimer getitimer@@GLIBC_2.1
+setitimer - setitimer i:ipP __setitimer setitimer@@GLIBC_2.1
+utimes - utimes i:sp __utimes utimes@@GLIBC_2.1
+getrusage - getrusage i:ip __getrusage getrusage@@GLIBC_2.1
diff --git a/sysdeps/unix/sysv/linux/sw_64/sysconf.c b/sysdeps/unix/sysv/linux/sw_64/sysconf.c
new file mode 100644
index 00000000..fd74f16a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/sysconf.c
@@ -0,0 +1,126 @@
+/* Copyright (C) 2004-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/>. */
+
+#include <assert.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+static long int linux_sysconf (int name);
+
+#define CSHAPE(totalsize, linesize, assoc) \
+ ((totalsize & ~0xff) | (linesize << 4) | assoc)
+
+extern long __libc_sw_64_cache_shape[4];
+
+/* Get the value of the system variable NAME. */
+long int
+__sysconf (int name)
+{
+ long shape, index;
+
+ /* We only handle the cache information here (for now). */
+ if (name < _SC_LEVEL1_ICACHE_SIZE || name > _SC_LEVEL4_CACHE_LINESIZE)
+ return linux_sysconf (name);
+
+ /* No SW_64 has L4 caches. */
+ if (name >= _SC_LEVEL4_CACHE_SIZE)
+ return -1;
+
+ index = (name - _SC_LEVEL1_ICACHE_SIZE) / 3;
+ shape = __libc_sw_64_cache_shape[index];
+ if (shape == -2)
+ {
+ long shape_l1i, shape_l1d, shape_l2, shape_l3 = -1;
+
+ /* ??? In the cases below for which we do not know L1 cache sizes,
+ we could do timings to measure sizes. But for the Bcache, it's
+ generally big enough that (without additional help) TLB effects
+ get in the way. We'd either need to be able to allocate large
+ pages or have the kernel do the timings from KSEG. Fortunately,
+ kernels beginning with 2.6.5 will pass us this info in auxvec. */
+
+ switch (__builtin_sw_64_implver ())
+ {
+ case 0:
+ /* LCA45 had 8k L1 caches; had 16k L1 caches. */
+ /* had 128k to 16M 32-byte direct Bcache. LCA45
+ had 64k to 8M 8-byte direct Bcache. Can't tell. */
+ shape_l1i = shape_l1d = shape_l2 = CSHAPE (0, 5, 1);
+ break;
+
+ case 1:
+ if (__builtin_sw_64_amask (1 << 8))
+ {
+ /* MAX insns not present; */
+ shape_l1i = shape_l1d = CSHAPE (8 * 1024, 5, 1);
+ /* ??? L2 and L3 *can* be configured as 32-byte line. */
+ shape_l2 = CSHAPE (96 * 1024, 6, 3);
+ /* has 1M to 16M Bcache. */
+ shape_l3 = CSHAPE (0, 6, 1);
+ }
+ else
+ {
+ /* MAX insns present; either PCA56 or PCA57. */
+ /* PCA56 had 16k 64-byte cache; PCA57 had 32k Icache. */
+ /* PCA56 had 8k 64-byte cache; PCA57 had 16k Dcache. */
+ /* PCA5[67] had 512k to 4M Bcache. */
+ shape_l1i = shape_l1d = shape_l2 = CSHAPE (0, 6, 1);
+ }
+ break;
+
+ case 2:
+ shape_l1i = shape_l1d = CSHAPE (64 * 1024, 6, 2);
+ /* had 1M to 16M Bcache. */
+ shape_l2 = CSHAPE (0, 6, 1);
+ break;
+
+ case 3:
+ shape_l1i = shape_l1d = CSHAPE (64 * 1024, 6, 2);
+ shape_l2 = CSHAPE (7 * 1024 * 1024 / 4, 6, 7);
+ break;
+
+ default:
+ shape_l1i = shape_l1d = shape_l2 = 0;
+ break;
+ }
+
+ __libc_sw_64_cache_shape[0] = shape_l1i;
+ __libc_sw_64_cache_shape[1] = shape_l1d;
+ __libc_sw_64_cache_shape[2] = shape_l2;
+ __libc_sw_64_cache_shape[3] = shape_l3;
+ shape = __libc_sw_64_cache_shape[index];
+ }
+
+ if (shape <= 0)
+ return shape;
+
+ switch ((name - _SC_LEVEL1_ICACHE_SIZE) % 3)
+ {
+ case 0: /* total size */
+ return shape & -0x100;
+ case 1: /* associativity */
+ return shape & 0xf;
+ default: /* line size */
+ return 1L << ((shape >> 4) & 0xf);
+ }
+}
+
+/* Now the generic Linux version. */
+#undef __sysconf
+#define __sysconf static linux_sysconf
+#include <sysdeps/unix/sysv/linux/sysconf.c>
diff --git a/sysdeps/unix/sysv/linux/sw_64/timer_t_was_int_compat.h b/sysdeps/unix/sysv/linux/sw_64/timer_t_was_int_compat.h
new file mode 100644
index 00000000..d340cdde
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/timer_t_was_int_compat.h
@@ -0,0 +1,19 @@
+/* timer_t/int compatibility transition. sw_64 version.
+ Copyright (C) 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; see the file COPYING.LIB. If
+ not, see <https://www.gnu.org/licenses/>. */
+
+#define TIMER_T_WAS_INT_COMPAT 1
diff --git a/sysdeps/unix/sysv/linux/sw_64/ucontext-offsets.sym b/sysdeps/unix/sysv/linux/sw_64/ucontext-offsets.sym
new file mode 100644
index 00000000..806c6093
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/ucontext-offsets.sym
@@ -0,0 +1,28 @@
+#include <stddef.h>
+#include <signal.h>
+#include <sys/ucontext.h>
+#include "kernel_rt_sigframe.h"
+
+--
+UC_LINK offsetof (ucontext_t, uc_link)
+UC_OSF_SIGMASK offsetof (ucontext_t, __uc_osf_sigmask)
+UC_STACK offsetof (ucontext_t, uc_stack)
+UC_SIGCTX offsetof (ucontext_t, uc_mcontext)
+UC_SIGMASK offsetof (ucontext_t, uc_sigmask)
+SC_REGS offsetof (mcontext_t, sc_regs)
+SC_FPREGS offsetof (mcontext_t, sc_fpregs)
+SC_PC offsetof (mcontext_t, sc_pc)
+SC_PS offsetof (mcontext_t, sc_ps)
+SC_FPCRS offsetof (mcontext_t, sc_fpcr)
+SC_MASK offsetof (mcontext_t, sc_mask)
+SC_FPCR offsetof (mcontext_t, sc_fpcr)
+SS_SP offsetof (stack_t, ss_sp)
+SS_SIZE offsetof (stack_t, ss_size)
+
+_NSIG8 (_NSIG / 8)
+
+-- Offsets of the fields in the kernel rt_sigframe_t structure.
+#define rt_sigframe(member) offsetof (struct kernel_rt_sigframe, member)
+
+RT_SIGFRAME_UCONTEXT rt_sigframe (uc)
+RT_SIGFRAME_SIZE sizeof (struct kernel_rt_sigframe)
diff --git a/sysdeps/unix/sysv/linux/sw_64/wait4.c b/sysdeps/unix/sysv/linux/sw_64/wait4.c
new file mode 100644
index 00000000..029db464
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/wait4.c
@@ -0,0 +1,28 @@
+/* wait4 -- wait for process to change state. Linux/SW_64 version.
+ Copyright (C) 2019-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 <shlib-compat.h>
+
+#undef weak_alias
+#define weak_alias(a, b)
+#include <sysdeps/unix/sysv/linux/wait4.c>
+#undef weak_alias
+#define weak_alias(name, aliasname) _weak_alias (name, aliasname)
+versioned_symbol (libc, __wait4, wait4, GLIBC_2_1);
+
+/* GLIBC_2_0 version is implemented at osf_wait4.c. */
diff --git a/sysdeps/unix/sysv/linux/sw_64/wordexp.c b/sysdeps/unix/sysv/linux/sw_64/wordexp.c
new file mode 100644
index 00000000..32aefe57
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/wordexp.c
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/sparc/sparc64/wordexp.c>
diff --git a/sysdeps/unix/sysv/linux/sw_64/xstat64.c b/sysdeps/unix/sysv/linux/sw_64/xstat64.c
new file mode 100644
index 00000000..c70a6c36
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/xstat64.c
@@ -0,0 +1,46 @@
+/* xstat using old-style Unix stat system call.
+ Copyright (C) 2004-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/>. */
+
+#define __xstat __redirect___xstat
+#include <sys/stat.h>
+#undef __xstat
+#include <fcntl.h>
+#include <kernel_stat.h>
+#include <sysdep.h>
+#include <xstatconv.h>
+
+/* Get information about the file NAME in BUF. */
+int
+__xstat64 (int vers, const char *name, struct stat64 *buf)
+{
+ switch (vers)
+ {
+ case _STAT_VER_KERNEL64:
+ return INLINE_SYSCALL_CALL (stat64, name, buf);
+
+ default:
+ {
+ struct kernel_stat kbuf;
+ int r = INTERNAL_SYSCALL_CALL (stat, name, &kbuf);
+ if (r == 0)
+ return __xstat_conv (vers, &kbuf, buf);
+ return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r);
+ }
+ }
+}
+weak_alias (__xstat64, __xstat);
diff --git a/sysdeps/unix/sysv/linux/sw_64/xstatconv.c b/sysdeps/unix/sysv/linux/sw_64/xstatconv.c
new file mode 100644
index 00000000..3556bc6c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/xstatconv.c
@@ -0,0 +1,120 @@
+/* Convert between the kernel's `struct stat' format, and libc's.
+ 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/>. */
+
+#include <errno.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <kernel_stat.h>
+#include <xstatconv.h>
+#include <sys/syscall.h>
+
+int
+__xstat_conv (int vers, struct kernel_stat *kbuf, void *ubuf)
+{
+ switch (vers)
+ {
+ case _STAT_VER_KERNEL:
+ *(struct kernel_stat *) ubuf = *kbuf;
+ break;
+
+ case _STAT_VER_GLIBC2:
+ {
+ struct glibc2_stat *buf = ubuf;
+
+ buf->st_dev = kbuf->st_dev;
+ buf->st_ino = kbuf->st_ino;
+ buf->st_mode = kbuf->st_mode;
+ buf->st_nlink = kbuf->st_nlink;
+ buf->st_uid = kbuf->st_uid;
+ buf->st_gid = kbuf->st_gid;
+ buf->st_rdev = kbuf->st_rdev;
+ buf->st_size = kbuf->st_size;
+ buf->st_atime_sec = kbuf->st_atime_sec;
+ buf->st_mtime_sec = kbuf->st_mtime_sec;
+ buf->st_ctime_sec = kbuf->st_ctime_sec;
+ buf->st_blksize = kbuf->st_blksize;
+ buf->st_blocks = kbuf->st_blocks;
+ buf->st_flags = kbuf->st_flags;
+ buf->st_gen = kbuf->st_gen;
+ }
+ break;
+
+ case _STAT_VER_GLIBC2_1:
+ {
+ struct glibc21_stat *buf = ubuf;
+
+ buf->st_dev = kbuf->st_dev;
+ buf->st_ino = kbuf->st_ino;
+ buf->st_mode = kbuf->st_mode;
+ buf->st_nlink = kbuf->st_nlink;
+ buf->st_uid = kbuf->st_uid;
+ buf->st_gid = kbuf->st_gid;
+ buf->st_rdev = kbuf->st_rdev;
+ buf->st_size = kbuf->st_size;
+ buf->st_atime_sec = kbuf->st_atime_sec;
+ buf->st_mtime_sec = kbuf->st_mtime_sec;
+ buf->st_ctime_sec = kbuf->st_ctime_sec;
+ buf->st_blocks = kbuf->st_blocks;
+ buf->st_blksize = kbuf->st_blksize;
+ buf->st_flags = kbuf->st_flags;
+ buf->st_gen = kbuf->st_gen;
+ buf->__pad3 = 0;
+ buf->__glibc_reserved[0] = 0;
+ buf->__glibc_reserved[1] = 0;
+ buf->__glibc_reserved[2] = 0;
+ buf->__glibc_reserved[3] = 0;
+ }
+ break;
+
+ case _STAT_VER_GLIBC2_3_4:
+ {
+ struct stat64 *buf = ubuf;
+
+ buf->st_dev = kbuf->st_dev;
+ buf->st_ino = kbuf->st_ino;
+ buf->st_rdev = kbuf->st_rdev;
+ buf->st_size = kbuf->st_size;
+ buf->st_blocks = kbuf->st_blocks;
+
+ buf->st_mode = kbuf->st_mode;
+ buf->st_uid = kbuf->st_uid;
+ buf->st_gid = kbuf->st_gid;
+ buf->st_blksize = kbuf->st_blksize;
+ buf->st_nlink = kbuf->st_nlink;
+ buf->__pad0 = 0;
+
+ buf->st_atim.tv_sec = kbuf->st_atime_sec;
+ buf->st_atim.tv_nsec = 0;
+ buf->st_mtim.tv_sec = kbuf->st_mtime_sec;
+ buf->st_mtim.tv_nsec = 0;
+ buf->st_ctim.tv_sec = kbuf->st_ctime_sec;
+ buf->st_ctim.tv_nsec = 0;
+
+ buf->__glibc_reserved[0] = 0;
+ buf->__glibc_reserved[1] = 0;
+ buf->__glibc_reserved[2] = 0;
+ }
+ break;
+
+ default:
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/sysdeps/unix/sysv/linux/sw_64/xstatconv.h b/sysdeps/unix/sysv/linux/sw_64/xstatconv.h
new file mode 100644
index 00000000..0c309d7d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/xstatconv.h
@@ -0,0 +1,22 @@
+/* Convert between the kernel's `struct stat' format, and libc's.
+ Copyright (C) 2004-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/>. */
+
+#include <sys/syscall.h>
+
+extern int __xstat_conv (int vers, struct kernel_stat *kbuf,
+ void *ubuf) attribute_hidden;
diff --git a/sysdeps/unix/sysv/linux/sw_64/xstatver.h b/sysdeps/unix/sysv/linux/sw_64/xstatver.h
new file mode 100644
index 00000000..82eb5c13
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sw_64/xstatver.h
@@ -0,0 +1,14 @@
+/* Versions of the 'struct stat' data structure used in compatibility xstat
+ functions. */
+#define _STAT_VER_KERNEL 0
+#define _STAT_VER_GLIBC2 1
+#define _STAT_VER_GLIBC2_1 2
+#define _STAT_VER_KERNEL64 3
+#define _STAT_VER_GLIBC2_3_4 3
+#define _STAT_VER_LINUX 3
+#define _STAT_VER _STAT_VER_LINUX
+
+/* Versions of the 'xmknod' interface used in compatibility xmknod
+ functions. */
+#define _MKNOD_VER_LINUX 0
+#define _MKNOD_VER _MKNOD_VER_LINUX
--
2.25.1