public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] SH: Fixup clone for NPTL
@ 2004-12-07 13:38 Kaz Kojima
  2004-12-07 19:40 ` Ulrich Drepper
  0 siblings, 1 reply; 2+ messages in thread
From: Kaz Kojima @ 2004-12-07 13:38 UTC (permalink / raw)
  To: libc-hacker

Hi,

The appended patch is an SH version of the change done in x86
clone.S.  I've also found that the frame pointer wasn't cleared
at the begining of the new thread.

Regards,
	kaz
--
[nptl/ChangeLog]
2004-12-07  Kaz Kojima  <kkojima@rr.iij4u.or.jp>

	* sysdeps/unix/sysv/linux/sh/clone.S: New file.

[ChangeLog]
2004-12-07  Kaz Kojima  <kkojima@rr.iij4u.or.jp>

	* sysdeps/unix/sysv/linux/sh/clone.S: Clear the frame pointer when
	starting a new thread.  Add support for NPTL where the PID is stored
	at userlevel and needs to be reset when CLONE_THREAD is not used.

diff -u3prN ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/clone.S LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/clone.S
--- ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/clone.S	Thu Jan  1 09:00:00 1970
+++ LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/clone.S	Tue Dec  7 09:40:56 2004
@@ -0,0 +1,2 @@
+#define RESET_PID
+#include <sysdeps/unix/sysv/linux/sh/clone.S>
diff -u3prN ORIG/libc/sysdeps/unix/sysv/linux/sh/clone.S LOCAL/libc/sysdeps/unix/sysv/linux/sh/clone.S
--- ORIG/libc/sysdeps/unix/sysv/linux/sh/clone.S	Tue Feb 11 14:29:43 2003
+++ LOCAL/libc/sysdeps/unix/sysv/linux/sh/clone.S	Tue Dec  7 10:49:02 2004
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -22,11 +22,13 @@
 #include <sysdep.h>
 #define _ERRNO_H	1
 #include <bits/errno.h>
-
+#ifdef RESET_PID
+#include <tcb-offsets.h>
+#endif
 /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
 	     pid_t *ptid, void *tls, pid_t *ctid); */
 
-        .text
+	.text
 ENTRY(__clone)
 	/* sanity check arguments.  */
 	tst	r4, r4
@@ -64,6 +66,31 @@ ENTRY(__clone)
 	rts
 	 nop
 2:
+	/* terminate the stack frame */
+	mov	#0, r14
+#ifdef RESET_PID
+	mov	r4, r0
+	shlr16	r0
+	tst	#1, r0			// CLONE_THREAD = (1 << 16)
+	bf/s	4f
+	 mov	r4, r0
+	/* new pid */
+	shlr8	r0
+	tst	#1, r0			// CLONE_VM = (1 << 8)
+	bf/s	3f
+	 mov	#-1, r0
+	mov	#+SYS_ify(getpid), r3
+	trapa	#0x15
+3:
+	stc	gbr, r1
+	mov.w	.Lpidoff, r2
+	add	r1, r2
+	mov.l	r0, @r2	
+	mov.w	.Ltidoff, r2
+	add	r1, r2
+	mov.l	r0, @r2	
+4:
+#endif
 	/* thread starts */
 	mov.l	@r15, r1
 	jsr	@r1
@@ -94,6 +121,12 @@ ENTRY(__clone)
 	.long	_GLOBAL_OFFSET_TABLE_
 .L3:
 	.long	PLTJMP(C_SYMBOL_NAME(_exit))
+#ifdef RESET_PID
+.Lpidoff:
+	.word	PID - TLS_PRE_TCB_SIZE
+.Ltidoff:
+	.word	TID - TLS_PRE_TCB_SIZE
+#endif
 PSEUDO_END (__clone)
 
 weak_alias (__clone, clone)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] SH: Fixup clone for NPTL
  2004-12-07 13:38 [PATCH] SH: Fixup clone for NPTL Kaz Kojima
@ 2004-12-07 19:40 ` Ulrich Drepper
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Drepper @ 2004-12-07 19:40 UTC (permalink / raw)
  To: Kaz Kojima; +Cc: libc-hacker

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Applied.

- --
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFBtgbi2ijCOnn/RHQRAlG4AJsE5K5e0wDaDV/TUZmupA69CvKOdgCgqwRP
3HM6vyecmDcYuvbiYh8zBQ4=
=U6jD
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-12-07 19:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-07 13:38 [PATCH] SH: Fixup clone for NPTL Kaz Kojima
2004-12-07 19:40 ` Ulrich Drepper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).