[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v6 16/49] linux-user: Split out exit
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH v6 16/49] linux-user: Split out exit |
Date: |
Sat, 19 Jan 2019 08:30:49 +1100 |
Signed-off-by: Richard Henderson <address@hidden>
---
linux-user/syscall-defs.h | 1 +
linux-user/syscall-proc.inc.c | 61 +++++++++++++++++++++++++++++++++++
linux-user/syscall.c | 38 +---------------------
3 files changed, 63 insertions(+), 37 deletions(-)
create mode 100644 linux-user/syscall-proc.inc.c
diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h
index 88f433e998..88aa1a6bfd 100644
--- a/linux-user/syscall-defs.h
+++ b/linux-user/syscall-defs.h
@@ -17,6 +17,7 @@
*/
SYSCALL_DEF(close, ARG_DEC);
+SYSCALL_DEF(exit, ARG_DEC);
#ifdef TARGET_NR_ipc
SYSCALL_DEF_ARGS(ipc, ARG_HEX, ARG_DEC, ARG_DEC, ARG_HEX, ARG_PTR, ARG_HEX);
#endif
diff --git a/linux-user/syscall-proc.inc.c b/linux-user/syscall-proc.inc.c
new file mode 100644
index 0000000000..96ad363c1a
--- /dev/null
+++ b/linux-user/syscall-proc.inc.c
@@ -0,0 +1,61 @@
+/*
+ * Linux process related syscalls
+ * Copyright (c) 2003 Fabrice Bellard
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+SYSCALL_IMPL(exit)
+{
+ CPUState *cpu = ENV_GET_CPU(cpu_env);
+ int status = arg1;
+
+ /*
+ * 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.
+ */
+ if (block_signals()) {
+ return -TARGET_ERESTARTSYS;
+ }
+
+ cpu_list_lock();
+
+ if (CPU_NEXT(first_cpu)) {
+ TaskState *ts;
+
+ /* Remove the CPU from the list. */
+ QTAILQ_REMOVE_RCU(&cpus, cpu, node);
+
+ cpu_list_unlock();
+
+ ts = cpu->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_cpu = NULL;
+ object_unref(OBJECT(cpu));
+ g_free(ts);
+ rcu_unregister_thread();
+ pthread_exit(NULL);
+ }
+
+ cpu_list_unlock();
+ preexit_cleanup(cpu_env, status);
+ _exit(status);
+}
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 142654a0a0..02010f9ae0 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5626,43 +5626,6 @@ static abi_long do_syscall1(void *cpu_env, int num,
abi_long arg1,
void *p;
switch(num) {
- case TARGET_NR_exit:
- /* 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. */
-
- if (block_signals()) {
- return -TARGET_ERESTARTSYS;
- }
-
- cpu_list_lock();
-
- if (CPU_NEXT(first_cpu)) {
- TaskState *ts;
-
- /* Remove the CPU from the list. */
- QTAILQ_REMOVE_RCU(&cpus, cpu, node);
-
- cpu_list_unlock();
-
- ts = cpu->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_cpu = NULL;
- object_unref(OBJECT(cpu));
- g_free(ts);
- rcu_unregister_thread();
- pthread_exit(NULL);
- }
-
- cpu_list_unlock();
- preexit_cleanup(cpu_env, arg1);
- _exit(arg1);
- return 0; /* avoid warning */
case TARGET_NR_brk:
return do_brk(arg1);
#ifdef TARGET_NR_fork
@@ -9884,6 +9847,7 @@ static abi_long do_syscall1(void *cpu_env, int num,
abi_long arg1,
#include "syscall-file.inc.c"
#include "syscall-ipc.inc.c"
#include "syscall-mem.inc.c"
+#include "syscall-proc.inc.c"
#undef SYSCALL_IMPL
#undef SYSCALL_ARGS
--
2.17.2
- [Qemu-devel] [PATCH v6 06/49] linux-user: Split out readlink, readlinkat, (continued)
- [Qemu-devel] [PATCH v6 06/49] linux-user: Split out readlink, readlinkat, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 08/49] linux-user: Split out read, write, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 03/49] linux-user: Split out open, open_at, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 09/49] linux-user: Reduce regpairs_aligned & target_offset64 ifdefs, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 01/49] linux-user: Setup split syscall infrastructure, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 10/49] linux-user: Split out readv, writev, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 11/49] linux-user: Split out pread64, pwrite64, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 12/49] linux-user: Split out preadv, pwritev, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 13/49] linux-user: Split out name_to_handle_at, open_by_handle_at, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 15/49] linux-user: Split out memory syscalls, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 16/49] linux-user: Split out exit,
Richard Henderson <=
- [Qemu-devel] [PATCH v6 17/49] linux-user: Split out brk, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 14/49] linux-user: Split out ipc syscalls, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 18/49] linux-user: Split out clone, fork, vfork, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 19/49] linux-user: Split out wait4, waitid, waitpid, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 20/49] linux-user: Implement rusage argument to waitid, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 21/49] linux-user: Split out creat, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 26/49] linux-user: Split out chdir, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 22/49] linux-user: Split out link, linkat, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 24/49] linux-user: Split out execve, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 28/49] linux-user: Split out mknod, mknodat, Richard Henderson, 2019/01/18