@@ -3313,11 +3313,13 @@ case "$target_arch2" in
;;
sparc)
target_phys_bits=64
+ target_nptl="yes"
;;
sparc64)
TARGET_BASE_ARCH=sparc
target_phys_bits=64
target_long_alignment=8
+ target_nptl="yes"
;;
sparc32plus)
TARGET_ARCH=sparc64
@@ -3325,6 +3327,7 @@ case "$target_arch2" in
TARGET_ABI_DIR=sparc
echo "TARGET_ABI32=y" >> $config_target_mak
target_phys_bits=64
+ target_nptl="yes"
;;
s390x)
target_nptl="yes"
@@ -3961,6 +3961,12 @@ static void *clone_func(void *arg)
/* Wait until the parent has finshed initializing the tls state. */
pthread_mutex_lock(&clone_lock);
pthread_mutex_unlock(&clone_lock);
+
+#ifdef TARGET_SPARC
+ /* Funny calling conventions for Sparc: the new TID is in %o0. */
+ env->regwptr[0] = info->tid;
+#endif
+
cpu_loop(env);
/* never exits */
return NULL;
@@ -4006,8 +4012,12 @@ static int do_fork(CPUState *env, unsigned int flags, abi_ulong newsp,
init_task_state(ts);
/* we create a new CPU instance. */
new_env = cpu_copy(env);
-#if defined(TARGET_I386) || defined(TARGET_SPARC) || defined(TARGET_PPC)
+#if defined(TARGET_I386) || defined(TARGET_PPC)
cpu_reset(new_env);
+#elif defined(TARGET_SPARC)
+ /* Funny calling conventions for Sparc: %o1 == 0 for parent,
+ and == 1 for child. We handle the later in cpu_clone_regs. */
+ env->regwptr[1] = 0;
#endif
/* Init regs that differ from the parent. */
cpu_clone_regs(new_env, newsp);
@@ -675,12 +675,32 @@ static inline int cpu_pil_allowed(CPUState *env1, int pil)
#if defined(CONFIG_USER_ONLY)
static inline void cpu_clone_regs(CPUState *env, target_ulong newsp)
{
- if (newsp)
+ if (newsp) {
+ if (TARGET_VIRT_ADDR_SPACE_BITS == 32) {
+ newsp &= 0xffffffff;
+ }
env->regwptr[22] = newsp;
- env->regwptr[0] = 0;
- /* FIXME: Do we also need to clear CF? */
- /* XXXXX */
- printf ("HELPME: %s:%d\n", __FILE__, __LINE__);
+ }
+
+ /* Glibc tests for syscall error (carry set) before testing for
+ parent or child. We must signal success. */
+#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
+ env->xcc &= ~PSR_CARRY;
+#else
+ env->psr &= ~PSR_CARRY;
+#endif
+
+ /* Indicate child. */
+ env->regwptr[1] = 1;
+
+ /* Next instruction. */
+ env->pc = env->npc;
+ env->npc = env->npc + 4;
+}
+
+static inline void cpu_set_tls(CPUState *env, target_ulong newtls)
+{
+ env->gregs[7] = newtls;
}
#endif