git: 7446514533a4 - main - linux(4): Microoptimize linux_elf.h for future use.

From: Dmitry Chagin <dchagin_at_FreeBSD.org>
Date: Thu, 02 Feb 2023 14:59:04 UTC
The branch main has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=7446514533a40b376eaeb349ea33531ce9c711c2

commit 7446514533a40b376eaeb349ea33531ce9c711c2
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-02-02 14:58:06 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-02-02 14:58:06 +0000

    linux(4): Microoptimize linux_elf.h for future use.
    
    In order to reduce code duplication move coredump support definitions
    into the appropriate header and hide private definitions.
    
    MFC after:              1 week
---
 sys/amd64/linux/linux_sysvec.c     |  1 +
 sys/amd64/linux32/linux32_sysvec.c |  1 +
 sys/arm64/linux/linux_sysvec.c     |  3 +++
 sys/compat/linux/linux_elf.c       | 28 ++++++++++++++++++++++++----
 sys/compat/linux/linux_elf.h       | 30 ++++++++----------------------
 sys/compat/linux/linux_emul.h      |  6 ------
 6 files changed, 37 insertions(+), 32 deletions(-)

diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c
index 2a9e4909340b..3a2757338c89 100644
--- a/sys/amd64/linux/linux_sysvec.c
+++ b/sys/amd64/linux/linux_sysvec.c
@@ -76,6 +76,7 @@ __FBSDID("$FreeBSD$");
 #include <x86/linux/linux_x86.h>
 #include <amd64/linux/linux.h>
 #include <amd64/linux/linux_proto.h>
+#include <compat/linux/linux_elf.h>
 #include <compat/linux/linux_emul.h>
 #include <compat/linux/linux_fork.h>
 #include <compat/linux/linux_ioctl.h>
diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c
index 15caa5a2c2cc..9f681a85647e 100644
--- a/sys/amd64/linux32/linux32_sysvec.c
+++ b/sys/amd64/linux32/linux32_sysvec.c
@@ -82,6 +82,7 @@ __FBSDID("$FreeBSD$");
 #include <x86/linux/linux_x86.h>
 #include <amd64/linux32/linux.h>
 #include <amd64/linux32/linux32_proto.h>
+#include <compat/linux/linux_elf.h>
 #include <compat/linux/linux_emul.h>
 #include <compat/linux/linux_fork.h>
 #include <compat/linux/linux_ioctl.h>
diff --git a/sys/arm64/linux/linux_sysvec.c b/sys/arm64/linux/linux_sysvec.c
index 9a82dc94b6ac..eafdbcbabff8 100644
--- a/sys/arm64/linux/linux_sysvec.c
+++ b/sys/arm64/linux/linux_sysvec.c
@@ -29,6 +29,8 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#define	__ELF_WORD_SIZE	64
+
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/cdefs.h>
@@ -59,6 +61,7 @@ __FBSDID("$FreeBSD$");
 #include <arm64/linux/linux.h>
 #include <arm64/linux/linux_proto.h>
 #include <compat/linux/linux_dtrace.h>
+#include <compat/linux/linux_elf.h>
 #include <compat/linux/linux_emul.h>
 #include <compat/linux/linux_fork.h>
 #include <compat/linux/linux_ioctl.h>
diff --git a/sys/compat/linux/linux_elf.c b/sys/compat/linux/linux_elf.c
index b02b6e2cc777..e73dbdae888e 100644
--- a/sys/compat/linux/linux_elf.c
+++ b/sys/compat/linux/linux_elf.c
@@ -61,11 +61,31 @@ __FBSDID("$FreeBSD$");
 #include <machine/../linux/linux.h>
 #endif
 #include <compat/linux/linux_elf.h>
-#include <compat/linux/linux_emul.h>
-#include <compat/linux/linux_misc.h>
 
-/* This adds "linux32_" and "linux64_" prefixes. */
-#define	__linuxN(x)	__CONCAT(__CONCAT(__CONCAT(linux,__ELF_WORD_SIZE),_),x)
+struct l_elf_siginfo {
+	l_int		si_signo;
+	l_int		si_code;
+	l_int		si_errno;
+};
+
+typedef struct linux_pt_regset l_elf_gregset_t;
+
+struct linux_elf_prstatus {
+	struct l_elf_siginfo pr_info;
+	l_short		pr_cursig;
+	l_ulong		pr_sigpend;
+	l_ulong		pr_sighold;
+	l_pid_t		pr_pid;
+	l_pid_t		pr_ppid;
+	l_pid_t		pr_pgrp;
+	l_pid_t		pr_sid;
+	l_timeval	pr_utime;
+	l_timeval	pr_stime;
+	l_timeval	pr_cutime;
+	l_timeval	pr_cstime;
+	l_elf_gregset_t	pr_reg;
+	l_int		pr_fpvalid;
+};
 
 #define	LINUX_NT_AUXV	6
 
diff --git a/sys/compat/linux/linux_elf.h b/sys/compat/linux/linux_elf.h
index 4bb9318e360b..18d229d8481e 100644
--- a/sys/compat/linux/linux_elf.h
+++ b/sys/compat/linux/linux_elf.h
@@ -28,29 +28,15 @@
 #ifndef _COMPAT_LINUX_ELF_H_
 #define _COMPAT_LINUX_ELF_H_
 
-struct l_elf_siginfo {
-	l_int		si_signo;
-	l_int		si_code;
-	l_int		si_errno;
-};
+struct note_info_list;
 
-typedef struct linux_pt_regset l_elf_gregset_t;
+/* Linux core notes are labeled "CORE" */
+#define	LINUX_ABI_VENDOR	"CORE"
 
-struct linux_elf_prstatus {
-	struct l_elf_siginfo pr_info;
-	l_short		pr_cursig;
-	l_ulong		pr_sigpend;
-	l_ulong		pr_sighold;
-	l_pid_t		pr_pid;
-	l_pid_t		pr_ppid;
-	l_pid_t		pr_pgrp;
-	l_pid_t		pr_sid;
-	l_timeval	pr_utime;
-	l_timeval	pr_stime;
-	l_timeval	pr_cutime;
-	l_timeval	pr_cstime;
-	l_elf_gregset_t	pr_reg;
-	l_int		pr_fpvalid;
-};
+/* This adds "linux32_" and "linux64_" prefixes. */
+#define	__linuxN(x)	__CONCAT(__CONCAT(__CONCAT(linux,__ELF_WORD_SIZE),_),x)
+
+void 	__linuxN(prepare_notes)(struct thread *, struct note_info_list *,
+	    size_t *);
 
 #endif
diff --git a/sys/compat/linux/linux_emul.h b/sys/compat/linux/linux_emul.h
index 9b552ab9c720..fde97c01895f 100644
--- a/sys/compat/linux/linux_emul.h
+++ b/sys/compat/linux/linux_emul.h
@@ -33,10 +33,6 @@
 #define	_LINUX_EMUL_H_
 
 struct image_params;
-struct note_info_list;
-
-/* Linux core notes are labeled "CORE" */
-#define	LINUX_ABI_VENDOR	"CORE"
 
 /*
  * modeled after similar structure in NetBSD
@@ -61,8 +57,6 @@ void	linux_schedtail(struct thread *);
 void	linux_on_exec(struct proc *, struct image_params *);
 void	linux_thread_dtor(struct thread *);
 int	linux_common_execve(struct thread *, struct image_args *);
-void 	linux32_prepare_notes(struct thread *, struct note_info_list *, size_t *);
-void 	linux64_prepare_notes(struct thread *, struct note_info_list *, size_t *);
 
 /* process emuldata flags */
 #define	LINUX_XDEPR_REQUEUEOP	0x00000001	/* uses deprecated