diff mbox series

[20/33] linux-user: Split out getpid, getxpid, lseek

Message ID 20180601073050.8054-21-richard.henderson@linaro.org
State New
Headers show
Series linux-user: Begin splitting do_syscall | expand

Commit Message

Richard Henderson June 1, 2018, 7:30 a.m. UTC
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 linux-user/syscall.c | 45 +++++++++++++++++++++++++++++---------------
 1 file changed, 30 insertions(+), 15 deletions(-)

-- 
2.17.0
diff mbox series

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 6a701ea8f6..b568144369 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8106,6 +8106,21 @@  IMPL(fork)
 }
 #endif
 
+#ifdef TARGET_NR_getpid
+IMPL(getpid)
+{
+    return get_errno(getpid());
+}
+#endif
+
+#if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA)
+IMPL(getxpid)
+{
+    ((CPUAlphaState *)cpu_env)->ir[IR_A4] = getppid();
+    return get_errno(getpid());
+}
+#endif
+
 #ifdef TARGET_NR_link
 IMPL(link)
 {
@@ -8143,6 +8158,14 @@  IMPL(linkat)
 }
 #endif
 
+IMPL(lseek)
+{
+    if (is_hostfd(arg1)) {
+        return -TARGET_EBADF;
+    }
+    return get_errno(lseek(arg1, arg2, arg3));
+}
+
 #ifdef TARGET_NR_mknod
 IMPL(mknod)
 {
@@ -8460,21 +8483,6 @@  IMPL(everything_else)
     char *fn;
 
     switch(num) {
-    case TARGET_NR_lseek:
-        if (is_hostfd(arg1)) {
-            return -TARGET_EBADF;
-        }
-        return get_errno(lseek(arg1, arg2, arg3));
-#if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA)
-    /* Alpha specific */
-    case TARGET_NR_getxpid:
-        ((CPUAlphaState *)cpu_env)->ir[IR_A4] = getppid();
-        return get_errno(getpid());
-#endif
-#ifdef TARGET_NR_getpid
-    case TARGET_NR_getpid:
-        return get_errno(getpid());
-#endif
     case TARGET_NR_mount:
         {
             /* need to look at the data field */
@@ -12869,12 +12877,19 @@  static impl_fn * const syscall_table[] = {
 #ifdef TARGET_NR_fork
     [TARGET_NR_fork] = impl_fork,
 #endif
+#ifdef TARGET_NR_getpid
+    [TARGET_NR_getpid] = impl_getpid,
+#endif
+#if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA)
+    [TARGET_NR_getxpid] = impl_getxpid,
+#endif
 #ifdef TARGET_NR_link
     [TARGET_NR_link] = impl_link,
 #endif
 #if defined(TARGET_NR_linkat)
     [TARGET_NR_linkat] = impl_linkat,
 #endif
+    [TARGET_NR_lseek] = impl_lseek,
 #ifdef TARGET_NR_mknod
     [TARGET_NR_mknod] = impl_mknod,
 #endif