|
@@ -111,13 +111,8 @@ int __clone2(int (*fn)(void *), void *child_stack_base,
|
|
|
|
|
|
#include "qemu.h"
|
|
|
|
|
|
-#if defined(CONFIG_USE_NPTL)
|
|
|
#define CLONE_NPTL_FLAGS2 (CLONE_SETTLS | \
|
|
|
CLONE_PARENT_SETTID | CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID)
|
|
|
-#else
|
|
|
-/* XXX: Hardcode the above values. */
|
|
|
-#define CLONE_NPTL_FLAGS2 0
|
|
|
-#endif
|
|
|
|
|
|
//#define DEBUG
|
|
|
|
|
@@ -234,12 +229,10 @@ _syscall1(int,exit_group,int,error_code)
|
|
|
#if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address)
|
|
|
_syscall1(int,set_tid_address,int *,tidptr)
|
|
|
#endif
|
|
|
-#if defined(CONFIG_USE_NPTL)
|
|
|
#if defined(TARGET_NR_futex) && defined(__NR_futex)
|
|
|
_syscall6(int,sys_futex,int *,uaddr,int,op,int,val,
|
|
|
const struct timespec *,timeout,int *,uaddr2,int,val3)
|
|
|
#endif
|
|
|
-#endif
|
|
|
#define __NR_sys_sched_getaffinity __NR_sched_getaffinity
|
|
|
_syscall3(int, sys_sched_getaffinity, pid_t, pid, unsigned int, len,
|
|
|
unsigned long *, user_mask_ptr);
|
|
@@ -4227,7 +4220,6 @@ abi_long do_arch_prctl(CPUX86State *env, int code, abi_ulong addr)
|
|
|
|
|
|
#define NEW_STACK_SIZE 0x40000
|
|
|
|
|
|
-#if defined(CONFIG_USE_NPTL)
|
|
|
|
|
|
static pthread_mutex_t clone_lock = PTHREAD_MUTEX_INITIALIZER;
|
|
|
typedef struct {
|
|
@@ -4272,16 +4264,6 @@ static void *clone_func(void *arg)
|
|
|
/* never exits */
|
|
|
return NULL;
|
|
|
}
|
|
|
-#else
|
|
|
-
|
|
|
-static int clone_func(void *arg)
|
|
|
-{
|
|
|
- CPUArchState *env = arg;
|
|
|
- cpu_loop(env);
|
|
|
- /* never exits */
|
|
|
- return 0;
|
|
|
-}
|
|
|
-#endif
|
|
|
|
|
|
/* do_fork() Must return host values and target errnos (unlike most
|
|
|
do_*() functions). */
|
|
@@ -4292,12 +4274,8 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
|
|
|
int ret;
|
|
|
TaskState *ts;
|
|
|
CPUArchState *new_env;
|
|
|
-#if defined(CONFIG_USE_NPTL)
|
|
|
unsigned int nptl_flags;
|
|
|
sigset_t sigmask;
|
|
|
-#else
|
|
|
- uint8_t *new_stack;
|
|
|
-#endif
|
|
|
|
|
|
/* Emulate vfork() with fork() */
|
|
|
if (flags & CLONE_VFORK)
|
|
@@ -4305,10 +4283,9 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
|
|
|
|
|
|
if (flags & CLONE_VM) {
|
|
|
TaskState *parent_ts = (TaskState *)env->opaque;
|
|
|
-#if defined(CONFIG_USE_NPTL)
|
|
|
new_thread_info info;
|
|
|
pthread_attr_t attr;
|
|
|
-#endif
|
|
|
+
|
|
|
ts = g_malloc0(sizeof(TaskState));
|
|
|
init_task_state(ts);
|
|
|
/* we create a new CPU instance. */
|
|
@@ -4321,7 +4298,6 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
|
|
|
new_env->opaque = ts;
|
|
|
ts->bprm = parent_ts->bprm;
|
|
|
ts->info = parent_ts->info;
|
|
|
-#if defined(CONFIG_USE_NPTL)
|
|
|
nptl_flags = flags;
|
|
|
flags &= ~CLONE_NPTL_FLAGS2;
|
|
|
|
|
@@ -4371,17 +4347,6 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
|
|
|
pthread_cond_destroy(&info.cond);
|
|
|
pthread_mutex_destroy(&info.mutex);
|
|
|
pthread_mutex_unlock(&clone_lock);
|
|
|
-#else
|
|
|
- if (flags & CLONE_NPTL_FLAGS2)
|
|
|
- return -EINVAL;
|
|
|
- /* This is probably going to die very quickly, but do it anyway. */
|
|
|
- new_stack = g_malloc0 (NEW_STACK_SIZE);
|
|
|
-#ifdef __ia64__
|
|
|
- ret = __clone2(clone_func, new_stack, NEW_STACK_SIZE, flags, new_env);
|
|
|
-#else
|
|
|
- ret = clone(clone_func, new_stack + NEW_STACK_SIZE, flags, new_env);
|
|
|
-#endif
|
|
|
-#endif
|
|
|
} else {
|
|
|
/* if no CLONE_VM, we consider it is a fork */
|
|
|
if ((flags & ~(CSIGNAL | CLONE_NPTL_FLAGS2)) != 0)
|
|
@@ -4392,7 +4357,6 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
|
|
|
/* Child Process. */
|
|
|
cpu_clone_regs(env, newsp);
|
|
|
fork_end(1);
|
|
|
-#if defined(CONFIG_USE_NPTL)
|
|
|
/* There is a race condition here. The parent process could
|
|
|
theoretically read the TID in the child process before the child
|
|
|
tid is set. This would require using either ptrace
|
|
@@ -4408,7 +4372,6 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
|
|
|
cpu_set_tls (env, newtls);
|
|
|
if (flags & CLONE_CHILD_CLEARTID)
|
|
|
ts->child_tidptr = child_tidptr;
|
|
|
-#endif
|
|
|
} else {
|
|
|
fork_end(0);
|
|
|
}
|
|
@@ -4834,7 +4797,6 @@ static inline abi_long host_to_target_stat64(void *cpu_env,
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
-#if defined(CONFIG_USE_NPTL)
|
|
|
/* ??? Using host futex calls even when target atomic operations
|
|
|
are not really atomic probably breaks things. However implementing
|
|
|
futexes locally would make futexes shared between multiple processes
|
|
@@ -4886,7 +4848,6 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout,
|
|
|
return -TARGET_ENOSYS;
|
|
|
}
|
|
|
}
|
|
|
-#endif
|
|
|
|
|
|
/* Map host to target signal numbers for the wait family of syscalls.
|
|
|
Assume all other status bits are the same. */
|
|
@@ -5132,9 +5093,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
|
|
|
abi_long arg5, abi_long arg6, abi_long arg7,
|
|
|
abi_long arg8)
|
|
|
{
|
|
|
-#ifdef CONFIG_USE_NPTL
|
|
|
CPUState *cpu = ENV_GET_CPU(cpu_env);
|
|
|
-#endif
|
|
|
abi_long ret;
|
|
|
struct stat st;
|
|
|
struct statfs stfs;
|
|
@@ -5148,7 +5107,6 @@ 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.
|
|
@@ -5186,7 +5144,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
|
|
|
g_free(ts);
|
|
|
pthread_exit(NULL);
|
|
|
}
|
|
|
-#endif
|
|
|
#ifdef TARGET_GPROF
|
|
|
_mcleanup();
|
|
|
#endif
|
|
@@ -8687,11 +8644,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
|
|
|
}
|
|
|
break;
|
|
|
#endif
|
|
|
-#if defined(CONFIG_USE_NPTL)
|
|
|
case TARGET_NR_futex:
|
|
|
ret = do_futex(arg1, arg2, arg3, arg4, arg5, arg6);
|
|
|
break;
|
|
|
-#endif
|
|
|
#if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)
|
|
|
case TARGET_NR_inotify_init:
|
|
|
ret = get_errno(sys_inotify_init());
|