git: e88e1272792e - main - power*/SYS.h: implement _SYSCALL_BODY() macro

From: Brooks Davis <brooks_at_FreeBSD.org>
Date: Thu, 21 Dec 2023 17:58:57 UTC
The branch main has been updated by brooks:

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

commit e88e1272792e41cbf0a5af1f5f0a858afece0475
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2023-12-21 17:57:14 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2023-12-21 17:57:14 +0000

    power*/SYS.h: implement _SYSCALL_BODY() macro
    
    Add _SYSCALL_BODY() macro which invokes the syscall via _SYCALL() and
    calls cerror as required.  Use to implement PSEUDO() and RSYSCALL().
    
    Reviewed by:    jhibbits
    Sponsored by:   DARPA
    Differential Revision:  https://reviews.freebsd.org/D43056
---
 lib/libc/powerpc/SYS.h   | 13 +++++++------
 lib/libc/powerpc64/SYS.h | 28 ++++++++++------------------
 2 files changed, 17 insertions(+), 24 deletions(-)

diff --git a/lib/libc/powerpc/SYS.h b/lib/libc/powerpc/SYS.h
index 8c47a65735f5..24315f369531 100644
--- a/lib/libc/powerpc/SYS.h
+++ b/lib/libc/powerpc/SYS.h
@@ -40,14 +40,17 @@
 	li	0,(SYS_##name);					\
 	sc
 
+#define	_SYSCALL_BODY(name)					\
+	_SYSCALL(name)						\
+	bnslr;							\
+	b	CNAME(HIDENAME(cerror))
+
 #define	PSEUDO(name)						\
 	.text;							\
 	.align 2;						\
 ENTRY(__sys_##name);						\
 	WEAK_REFERENCE(__sys_##name, _##name);			\
-	_SYSCALL(name);						\
-	bnslr;							\
-	b	CNAME(HIDENAME(cerror));			\
+	_SYSCALL_BODY(name);					\
 END(__sys_##name)
 
 #define	RSYSCALL(name)						\
@@ -56,7 +59,5 @@ END(__sys_##name)
 ENTRY(__sys_##name);						\
 	WEAK_REFERENCE(__sys_##name, name);			\
 	WEAK_REFERENCE(__sys_##name, _##name);			\
-	_SYSCALL(name);						\
-	bnslr;							\
-	b	CNAME(HIDENAME(cerror));			\
+	_SYSCALL_BODY(name);					\
 END(__sys_##name)
diff --git a/lib/libc/powerpc64/SYS.h b/lib/libc/powerpc64/SYS.h
index dccd08b63541..bf8bc6cc0e27 100644
--- a/lib/libc/powerpc64/SYS.h
+++ b/lib/libc/powerpc64/SYS.h
@@ -40,11 +40,7 @@
 	li	0,(SYS_##name);					\
 	sc
 
-#define	PSEUDO(name)						\
-	.text;							\
-	.align 2;						\
-ENTRY(__sys_##name);						\
-	WEAK_REFERENCE(__sys_##name, _##name);			\
+#define _SYSCALL_BODY(name)					\
 	_SYSCALL(name);						\
 	bnslr;							\
 	mflr	%r0;						\
@@ -55,7 +51,14 @@ ENTRY(__sys_##name);						\
 	addi	%r1,%r1,48;					\
 	ld	%r0,16(%r1);					\
 	mtlr	%r0;						\
-	blr;							\
+	blr
+
+#define	PSEUDO(name)						\
+	.text;							\
+	.align 2;						\
+ENTRY(__sys_##name);						\
+	WEAK_REFERENCE(__sys_##name, _##name);			\
+	_SYSCALL_BODY(name);					\
 END(__sys_##name)
 
 #define	RSYSCALL(name)						\
@@ -64,16 +67,5 @@ END(__sys_##name)
 ENTRY(__sys_##name);						\
 	WEAK_REFERENCE(__sys_##name, name);			\
 	WEAK_REFERENCE(__sys_##name, _##name);			\
-	_SYSCALL(name);						\
-	bnslr;							\
-								\
-	mflr	%r0;						\
-	std	%r0,16(%r1);					\
-	stdu	%r1,-48(%r1);					\
-	bl	CNAME(HIDENAME(cerror));			\
-	nop;							\
-	addi	%r1,%r1,48;					\
-	ld	%r0,16(%r1);					\
-	mtlr	%r0;						\
-	blr;							\
+	_SYSCALL_BODY(name);					\
 END(__sys_##name)