Page MenuHomeFreeBSD

D43059.diff
No OneTemporary

D43059.diff

diff --git a/lib/libc/amd64/SYS.h b/lib/libc/amd64/SYS.h
--- a/lib/libc/amd64/SYS.h
+++ b/lib/libc/amd64/SYS.h
@@ -35,17 +35,23 @@
#include <sys/syscall.h>
#include <machine/asm.h>
+#define _SYSCALL(name) \
+ mov $SYS_##name, %eax; \
+ movq %rcx, %r10; \
+ syscall
+
+#define _SYSCALL_BODY(name) \
+ _SYSCALL(name); \
+ jb HIDENAME(cerror); \
+ ret
+
#define RSYSCALL(name) ENTRY(__sys_##name); \
WEAK_REFERENCE(__sys_##name, name); \
WEAK_REFERENCE(__sys_##name, _##name); \
- mov $SYS_##name,%eax; KERNCALL; \
- jb HIDENAME(cerror); ret; \
+ _SYSCALL_BODY(name); \
END(__sys_##name)
#define PSEUDO(name) ENTRY(__sys_##name); \
WEAK_REFERENCE(__sys_##name, _##name); \
- mov $SYS_##name,%eax; KERNCALL; \
- jb HIDENAME(cerror); ret; \
+ _SYSCALL_BODY(name); \
END(__sys_##name)
-
-#define KERNCALL movq %rcx, %r10; syscall
diff --git a/lib/libc/amd64/gen/rfork_thread.S b/lib/libc/amd64/gen/rfork_thread.S
--- a/lib/libc/amd64/gen/rfork_thread.S
+++ b/lib/libc/amd64/gen/rfork_thread.S
@@ -51,8 +51,7 @@
/*
* Prepare and execute the thread creation syscall
*/
- movq $SYS_rfork, %rax
- KERNCALL
+ _SYSCALL(rfork)
jb 2f
/*
@@ -78,8 +77,7 @@
/*
* Exit system call
*/
- movq $SYS_exit, %rax
- KERNCALL
+ _SYSCALL(exit)
/*
* Branch here if the thread creation fails:
diff --git a/lib/libc/amd64/sys/getcontext.S b/lib/libc/amd64/sys/getcontext.S
--- a/lib/libc/amd64/sys/getcontext.S
+++ b/lib/libc/amd64/sys/getcontext.S
@@ -36,8 +36,7 @@
WEAK_REFERENCE(__sys_getcontext, getcontext)
ENTRY(__sys_getcontext)
movq (%rsp),%rsi /* save getcontext return address */
- mov $SYS_getcontext,%rax
- KERNCALL
+ _SYSCALL(getcontext)
jb HIDENAME(cerror)
addq $8,%rsp /* remove stale (setcontext) return address */
jmp *%rsi /* restore return address */
diff --git a/lib/libc/amd64/sys/vfork.S b/lib/libc/amd64/sys/vfork.S
--- a/lib/libc/amd64/sys/vfork.S
+++ b/lib/libc/amd64/sys/vfork.S
@@ -37,8 +37,7 @@
WEAK_REFERENCE(__sys_vfork, vfork)
ENTRY(__sys_vfork)
popq %rsi /* fetch return address (%rsi preserved) */
- mov $SYS_vfork,%rax
- KERNCALL
+ _SYSCALL(vfork)
jb 1f
jmp *%rsi
1:
diff --git a/lib/libc/i386/SYS.h b/lib/libc/i386/SYS.h
--- a/lib/libc/i386/SYS.h
+++ b/lib/libc/i386/SYS.h
@@ -35,17 +35,22 @@
#include <sys/syscall.h>
#include <machine/asm.h>
+#define _SYSCALL(name) \
+ mov $SYS_##name, %eax; \
+ int $0x80
+
+#define _SYSCALL_BODY(name) \
+ _SYSCALL(name); \
+ jb HIDENAME(cerror); \
+ ret
+
#define RSYSCALL(name) ENTRY(__sys_##name); \
WEAK_REFERENCE(__sys_##name, name); \
WEAK_REFERENCE(__sys_##name, _##name); \
- mov $SYS_##name,%eax; KERNCALL; \
- jb HIDENAME(cerror); \
- ret; END(__sys_##name)
+ _SYSCALL_BODY(name); \
+ END(__sys_##name)
#define PSEUDO(name) ENTRY(__sys_##name); \
WEAK_REFERENCE(__sys_##name, _##name); \
- mov $SYS_##name,%eax; KERNCALL; \
- jb HIDENAME(cerror); ret; \
+ _SYSCALL_BODY(name); \
END(__sys_##name)
-
-#define KERNCALL int $0x80
diff --git a/lib/libc/i386/gen/rfork_thread.S b/lib/libc/i386/gen/rfork_thread.S
--- a/lib/libc/i386/gen/rfork_thread.S
+++ b/lib/libc/i386/gen/rfork_thread.S
@@ -64,8 +64,7 @@
*/
pushl 8(%ebp)
pushl $0
- movl $SYS_rfork, %eax
- KERNCALL
+ _SYSCALL(rfork)
jb 2f
/*
@@ -96,8 +95,7 @@
*/
pushl %eax
pushl $0
- movl $SYS_exit, %eax
- KERNCALL
+ _SYSCALL(exit)
/*
* Branch here if the thread creation fails:
diff --git a/lib/libc/i386/sys/getcontext.S b/lib/libc/i386/sys/getcontext.S
--- a/lib/libc/i386/sys/getcontext.S
+++ b/lib/libc/i386/sys/getcontext.S
@@ -36,8 +36,7 @@
WEAK_REFERENCE(__sys_getcontext, getcontext)
ENTRY(__sys_getcontext)
movl (%esp),%ecx /* save getcontext return address */
- mov $SYS_getcontext,%eax
- KERNCALL
+ _SYSCALL(getcontext)
jb HIDENAME(cerror)
addl $4,%esp /* remove stale (setcontext) return address */
jmp *%ecx /* restore return address */
diff --git a/lib/libc/i386/sys/syscall.S b/lib/libc/i386/sys/syscall.S
--- a/lib/libc/i386/sys/syscall.S
+++ b/lib/libc/i386/sys/syscall.S
@@ -37,7 +37,7 @@
pop %ecx /* rta */
pop %eax /* syscall number */
push %ecx
- KERNCALL
+ int $0x80
push %ecx /* need to push a word to keep stack frame intact
upon return; the word must be the return address. */
jb HIDENAME(cerror)
diff --git a/lib/libc/i386/sys/vfork.S b/lib/libc/i386/sys/vfork.S
--- a/lib/libc/i386/sys/vfork.S
+++ b/lib/libc/i386/sys/vfork.S
@@ -37,8 +37,7 @@
WEAK_REFERENCE(__sys_vfork, vfork)
ENTRY(__sys_vfork)
popl %ecx /* my rta into ecx */
- mov $SYS_vfork,%eax
- KERNCALL
+ _SYSCALL(vfork)
jb 1f
jmp *%ecx
1:

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 8:30 AM (21 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14673287
Default Alt Text
D43059.diff (4 KB)

Event Timeline