qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/5] linux-user: move exit to own function


From: riku . voipio
Subject: [Qemu-devel] [PATCH 1/5] linux-user: move exit to own function
Date: Fri, 12 Oct 2012 21:24:38 +0300

From: Riku Voipio <address@hidden>

In preparations for for refactoring the main switch/case out

Signed-off-by: Riku Voipio <address@hidden>
---
 linux-user/syscall.c |   92 ++++++++++++++++++++++++++------------------------
 1 file changed, 48 insertions(+), 44 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 471d060..0b077e7 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5083,6 +5083,53 @@ static int do_open(void *cpu_env, const char *pathname, 
int flags, mode_t mode)
 
     return get_errno(open(path(pathname), flags, mode));
 }
+static void do_exit(void *, abi_long) __attribute__ ((noreturn));
+static void do_exit(void *cpu_env, abi_long arg1)
+{
+#ifdef CONFIG_USE_NPTL
+    /* In old applications this may be used to implement _exit(2).
+       However in threaded applictions it is used for thread termination,
+       and _exit_group is used for application termination.
+       Do thread termination if we have more then one thread.  */
+    /* FIXME: This probably breaks if a signal arrives.  We should probably
+       be disabling signals.  */
+    if (first_cpu->next_cpu) {
+        TaskState *ts;
+        CPUArchState **lastp;
+        CPUArchState *p;
+
+        cpu_list_lock();
+        lastp = &first_cpu;
+        p = first_cpu;
+        while (p && p != (CPUArchState *)cpu_env) {
+            lastp = &p->next_cpu;
+            p = p->next_cpu;
+        }
+        /* If we didn't find the CPU for this thread then something is
+           horribly wrong.  */
+        if (!p)
+            abort();
+        /* Remove the CPU from the list.  */
+        *lastp = p->next_cpu;
+        cpu_list_unlock();
+        ts = ((CPUArchState *)cpu_env)->opaque;
+        if (ts->child_tidptr) {
+            put_user_u32(0, ts->child_tidptr);
+            sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX,
+                      NULL, NULL, 0);
+        }
+        thread_env = NULL;
+        object_delete(OBJECT(ENV_GET_CPU(cpu_env)));
+        g_free(ts);
+        pthread_exit(NULL);
+    }
+#endif
+#ifdef TARGET_GPROF
+    _mcleanup();
+#endif
+    gdb_exit(cpu_env, arg1);
+    _exit(arg1);
+}
 
 /* do_syscall() should always have a single exit point at the end so
    that actions, such as logging of syscall results, can be performed.
@@ -5105,50 +5152,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long 
arg1,
 
     switch(num) {
     case TARGET_NR_exit:
-#ifdef CONFIG_USE_NPTL
-      /* In old applications this may be used to implement _exit(2).
-         However in threaded applictions it is used for thread termination,
-         and _exit_group is used for application termination.
-         Do thread termination if we have more then one thread.  */
-      /* FIXME: This probably breaks if a signal arrives.  We should probably
-         be disabling signals.  */
-      if (first_cpu->next_cpu) {
-          TaskState *ts;
-          CPUArchState **lastp;
-          CPUArchState *p;
-
-          cpu_list_lock();
-          lastp = &first_cpu;
-          p = first_cpu;
-          while (p && p != (CPUArchState *)cpu_env) {
-              lastp = &p->next_cpu;
-              p = p->next_cpu;
-          }
-          /* If we didn't find the CPU for this thread then something is
-             horribly wrong.  */
-          if (!p)
-              abort();
-          /* Remove the CPU from the list.  */
-          *lastp = p->next_cpu;
-          cpu_list_unlock();
-          ts = ((CPUArchState *)cpu_env)->opaque;
-          if (ts->child_tidptr) {
-              put_user_u32(0, ts->child_tidptr);
-              sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX,
-                        NULL, NULL, 0);
-          }
-          thread_env = NULL;
-          object_delete(OBJECT(ENV_GET_CPU(cpu_env)));
-          g_free(ts);
-          pthread_exit(NULL);
-      }
-#endif
-#ifdef TARGET_GPROF
-        _mcleanup();
-#endif
-        gdb_exit(cpu_env, arg1);
-        _exit(arg1);
-        ret = 0; /* avoid warning */
+        do_exit(cpu_env, arg1);
         break;
     case TARGET_NR_read:
         if (arg3 == 0)
-- 
1.7.9.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]