remove external __syscall function and last remaining users
authorRich Felker <dalias@aerifal.cx>
Thu, 11 Apr 2019 00:11:19 +0000 (20:11 -0400)
committerRich Felker <dalias@aerifal.cx>
Thu, 11 Apr 2019 00:11:19 +0000 (20:11 -0400)
the weak version of __syscall_cp_c was using a tail call to __syscall
to avoid duplicating the 6-argument syscall code inline in small
static-linked programs, but now that __syscall no longer exists, the
inline expansion is no longer duplication.

the syscall.h machinery suppported up to 7 syscall arguments, only via
an external __syscall function, but we presently have no syscall call
points that actually make use of that many, and the kernel only
defines 7-argument calling conventions for arm, powerpc (32-bit), and
sh. if it turns out we need them in the future, they can easily be
added.

18 files changed:
src/internal/aarch64/syscall.s [deleted file]
src/internal/arm/syscall.s [deleted file]
src/internal/i386/syscall.s [deleted file]
src/internal/m68k/syscall.s [deleted file]
src/internal/microblaze/syscall.s [deleted file]
src/internal/mips/syscall.s [deleted file]
src/internal/mips64/syscall.s [deleted file]
src/internal/mipsn32/syscall.s [deleted file]
src/internal/or1k/syscall.s [deleted file]
src/internal/powerpc/syscall.s [deleted file]
src/internal/powerpc64/syscall.s [deleted file]
src/internal/s390x/syscall.s [deleted file]
src/internal/sh/syscall.s [deleted file]
src/internal/syscall.c [deleted file]
src/internal/syscall.h
src/internal/x32/syscall.s [deleted file]
src/internal/x86_64/syscall.s [deleted file]
src/thread/__syscall_cp.c

diff --git a/src/internal/aarch64/syscall.s b/src/internal/aarch64/syscall.s
deleted file mode 100644 (file)
index 845986b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-.global __syscall
-.hidden __syscall
-.type __syscall,%function
-__syscall:
-       uxtw x8,w0
-       mov x0,x1
-       mov x1,x2
-       mov x2,x3
-       mov x3,x4
-       mov x4,x5
-       mov x5,x6
-       mov x6,x7
-       svc 0
-       ret
diff --git a/src/internal/arm/syscall.s b/src/internal/arm/syscall.s
deleted file mode 100644 (file)
index 64dba2f..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-.syntax unified
-.global __syscall
-.hidden __syscall
-.type __syscall,%function
-__syscall:
-       mov ip,sp
-       stmfd sp!,{r4,r5,r6,r7}
-       mov r7,r0
-       mov r0,r1
-       mov r1,r2
-       mov r2,r3
-       ldmfd ip,{r3,r4,r5,r6}
-       svc 0
-       ldmfd sp!,{r4,r5,r6,r7}
-       bx lr
diff --git a/src/internal/i386/syscall.s b/src/internal/i386/syscall.s
deleted file mode 100644 (file)
index 004ddfe..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-.global __syscall
-.hidden __syscall
-.type __syscall,@function
-__syscall:
-       push %ebx
-       push %esi
-       push %edi
-       push %ebp
-       mov 20(%esp),%eax
-       mov 24(%esp),%ebx
-       mov 28(%esp),%ecx
-       mov 32(%esp),%edx
-       mov 36(%esp),%esi
-       mov 40(%esp),%edi
-       mov 44(%esp),%ebp
-       call *%gs:16
-       pop %ebp
-       pop %edi
-       pop %esi
-       pop %ebx
-       ret
diff --git a/src/internal/m68k/syscall.s b/src/internal/m68k/syscall.s
deleted file mode 100644 (file)
index 9972a34..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-.global __syscall
-.hidden __syscall
-.type __syscall,%function
-__syscall:
-       movem.l %d2-%d5,-(%sp)
-       movem.l 20(%sp),%d0-%d5/%a0
-       trap #0
-       movem.l (%sp)+,%d2-%d5
-       rts
diff --git a/src/internal/microblaze/syscall.s b/src/internal/microblaze/syscall.s
deleted file mode 100644 (file)
index e0312e7..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-.global __syscall
-.hidden __syscall
-.type   __syscall,@function
-__syscall:
-       addi    r12, r5, 0              # Save the system call number
-       add     r5, r6, r0              # Shift the arguments, arg1
-       add     r6, r7, r0              # arg2
-       add     r7, r8, r0              # arg3
-       add     r8, r9, r0              # arg4
-       add     r9, r10, r0             # arg5
-       lwi     r10, r1, 28             # Get arg6.
-       brki    r14, 0x8                # syscall
-       rtsd    r15, 8
-       nop
diff --git a/src/internal/mips/syscall.s b/src/internal/mips/syscall.s
deleted file mode 100644 (file)
index 5d0def5..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-.set    noreorder
-
-.global __syscall
-.hidden __syscall
-.type   __syscall,@function
-__syscall:
-       move    $2, $4
-       move    $4, $5
-       move    $5, $6
-       move    $6, $7
-       lw      $7, 16($sp)
-       lw      $8, 20($sp)
-       lw      $9, 24($sp)
-       lw      $10,28($sp)
-       subu    $sp, $sp, 32
-       sw      $8, 16($sp)
-       sw      $9, 20($sp)
-       sw      $10,24($sp)
-       sw      $2 ,28($sp)
-       lw      $2, 28($sp)
-       syscall
-       beq     $7, $0, 1f
-       addu    $sp, $sp, 32
-       subu    $2, $0, $2
-1:     jr      $ra
-       nop
diff --git a/src/internal/mips64/syscall.s b/src/internal/mips64/syscall.s
deleted file mode 100644 (file)
index 9844866..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-.set   noreorder
-.global        __syscall
-.hidden        __syscall
-.type  __syscall,@function
-__syscall:
-       move    $2, $4
-       move    $4, $5
-       move    $5, $6
-       move    $6, $7
-       move    $7, $8
-       move    $8, $9
-       move    $9, $10
-       move    $10, $11
-       syscall
-       beq     $7, $0, 1f
-       nop
-       dsubu   $2, $0, $2
-1:     jr      $ra
-       nop
diff --git a/src/internal/mipsn32/syscall.s b/src/internal/mipsn32/syscall.s
deleted file mode 100644 (file)
index 510a6fa..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-.set   noreorder
-.global        __syscall
-.hidden        __syscall
-.type  __syscall,@function
-__syscall:
-       move    $2, $4
-       move    $4, $5
-       move    $5, $6
-       move    $6, $7
-       move    $7, $8
-       move    $8, $9
-       move    $9, $10
-       move    $10, $11
-       syscall
-       beq     $7, $0, 1f
-       nop
-       subu    $2, $0, $2
-1:     jr      $ra
-       nop
diff --git a/src/internal/or1k/syscall.s b/src/internal/or1k/syscall.s
deleted file mode 100644 (file)
index 177964e..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-.global __syscall
-.hidden __syscall
-.type   __syscall,@function
-__syscall:
-       l.ori   r11, r3, 0
-       l.lwz   r3, 0(r1)
-       l.lwz   r4, 4(r1)
-       l.lwz   r5, 8(r1)
-       l.lwz   r6, 12(r1)
-       l.lwz   r7, 16(r1)
-       l.lwz   r8, 20(r1)
-       l.sys   1
-       l.jr    r9
-        l.nop
diff --git a/src/internal/powerpc/syscall.s b/src/internal/powerpc/syscall.s
deleted file mode 100644 (file)
index 5b16b8f..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-       .global __syscall
-       .hidden __syscall
-       .type   __syscall,@function
-__syscall:
-       mr      0, 3                  # Save the system call number
-       mr      3, 4                  # Shift the arguments: arg1
-       mr      4, 5                  # arg2
-       mr      5, 6                  # arg3
-       mr      6, 7                  # arg4
-       mr      7, 8                  # arg5
-       mr      8, 9                  # arg6
-       sc
-       bnslr+ # return if not summary overflow
-       #else error:
-       # return negated value.
-       neg 3, 3
-       blr
-       .end    __syscall
-       .size   __syscall, .-__syscall
diff --git a/src/internal/powerpc64/syscall.s b/src/internal/powerpc64/syscall.s
deleted file mode 100644 (file)
index fe21f9e..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-       .global __syscall
-       .hidden __syscall
-       .type   __syscall,@function
-__syscall:
-       mr      0, 3                  # Save the system call number
-       mr      3, 4                  # Shift the arguments: arg1
-       mr      4, 5                  # arg2
-       mr      5, 6                  # arg3
-       mr      6, 7                  # arg4
-       mr      7, 8                  # arg5
-       mr      8, 9                  # arg6
-       sc
-       bnslr+       # return if not summary overflow
-       neg     3, 3 # otherwise error: return negated value.
-       blr
-       .end    __syscall
-       .size   __syscall, .-__syscall
diff --git a/src/internal/s390x/syscall.s b/src/internal/s390x/syscall.s
deleted file mode 100644 (file)
index 2322bc3..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-.global __syscall
-.hidden __syscall
-.type   __syscall, %function
-__syscall:
-       stg %r7, 56(%r15)
-       lgr %r1, %r2
-       lgr %r2, %r3
-       lgr %r3, %r4
-       lgr %r4, %r5
-       lgr %r5, %r6
-       lg  %r6, 160(%r15)
-       lg  %r7, 168(%r15)
-       svc 0
-       lg  %r7, 56(%r15)
-       br  %r14
diff --git a/src/internal/sh/syscall.s b/src/internal/sh/syscall.s
deleted file mode 100644 (file)
index 331918a..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-.global __syscall
-.hidden __syscall
-.type   __syscall, @function
-__syscall:
-       ! The kernel syscall entry point documents that the trap number indicates
-       ! the number of arguments being passed, but it then ignores that information.
-       ! Since we do not actually know how many arguments are being passed, we will
-       ! say there are six, since that is the maximum we support here.
-       mov r4, r3
-       mov r5, r4
-       mov r6, r5
-       mov r7, r6
-       mov.l @r15, r7
-       mov.l @(4,r15), r0
-       mov.l @(8,r15), r1
-       trapa #31
-       or r0, r0
-       or r0, r0
-       or r0, r0
-       or r0, r0
-       or r0, r0
-       rts
-        nop
diff --git a/src/internal/syscall.c b/src/internal/syscall.c
deleted file mode 100644 (file)
index e69de29..0000000
index 06c5527f7d934854735869cace2f71ddfe8074b4..2e810db058c633193e22f936a668ab3387eb6c76 100644 (file)
 typedef long syscall_arg_t;
 #endif
 
-hidden long __syscall_ret(unsigned long), __syscall(syscall_arg_t, ...),
+hidden long __syscall_ret(unsigned long),
        __syscall_cp(syscall_arg_t, syscall_arg_t, syscall_arg_t, syscall_arg_t,
                     syscall_arg_t, syscall_arg_t, syscall_arg_t);
 
-#ifdef SYSCALL_NO_INLINE
-#define __syscall0(n) (__syscall)(n)
-#define __syscall1(n,a) (__syscall)(n,__scc(a))
-#define __syscall2(n,a,b) (__syscall)(n,__scc(a),__scc(b))
-#define __syscall3(n,a,b,c) (__syscall)(n,__scc(a),__scc(b),__scc(c))
-#define __syscall4(n,a,b,c,d) (__syscall)(n,__scc(a),__scc(b),__scc(c),__scc(d))
-#define __syscall5(n,a,b,c,d,e) (__syscall)(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e))
-#define __syscall6(n,a,b,c,d,e,f) (__syscall)(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f))
-#else
 #define __syscall1(n,a) __syscall1(n,__scc(a))
 #define __syscall2(n,a,b) __syscall2(n,__scc(a),__scc(b))
 #define __syscall3(n,a,b,c) __syscall3(n,__scc(a),__scc(b),__scc(c))
 #define __syscall4(n,a,b,c,d) __syscall4(n,__scc(a),__scc(b),__scc(c),__scc(d))
 #define __syscall5(n,a,b,c,d,e) __syscall5(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e))
 #define __syscall6(n,a,b,c,d,e,f) __syscall6(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f))
-#endif
-#define __syscall7(n,a,b,c,d,e,f,g) (__syscall)(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f),__scc(g))
 
 #define __SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n
 #define __SYSCALL_NARGS(...) __SYSCALL_NARGS_X(__VA_ARGS__,7,6,5,4,3,2,1,0,)
diff --git a/src/internal/x32/syscall.s b/src/internal/x32/syscall.s
deleted file mode 100644 (file)
index c4bee80..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-.global __syscall
-.hidden __syscall
-.type __syscall,@function
-__syscall:
-       movq %rdi,%rax
-       movq %rsi,%rdi
-       movq %rdx,%rsi
-       movq %rcx,%rdx
-       movq %r8,%r10
-       movq %r9,%r8
-       movq 8(%rsp),%r9
-       syscall
-       ret
diff --git a/src/internal/x86_64/syscall.s b/src/internal/x86_64/syscall.s
deleted file mode 100644 (file)
index c4bee80..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-.global __syscall
-.hidden __syscall
-.type __syscall,@function
-__syscall:
-       movq %rdi,%rax
-       movq %rsi,%rdi
-       movq %rdx,%rsi
-       movq %rcx,%rdx
-       movq %r8,%r10
-       movq %r9,%r8
-       movq 8(%rsp),%r9
-       syscall
-       ret
index af666f06824545fc97691865b1cba76c8b3781db..42a01674bf40d7b3888e0af65cdf3de5a85e5db4 100644 (file)
@@ -7,7 +7,7 @@ static long sccp(syscall_arg_t nr,
                  syscall_arg_t u, syscall_arg_t v, syscall_arg_t w,
                  syscall_arg_t x, syscall_arg_t y, syscall_arg_t z)
 {
-       return (__syscall)(nr, u, v, w, x, y, z);
+       return __syscall(nr, u, v, w, x, y, z);
 }
 
 weak_alias(sccp, __syscall_cp_c);