about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--nptl/ChangeLog10
-rw-r--r--nptl/Makefile2
-rw-r--r--nptl/sysdeps/ia64/tcb-offsets.sym1
-rw-r--r--nptl/sysdeps/unix/sysv/linux/ia64/clone2.S2
-rw-r--r--nptl/tst-getpid1.c14
-rw-r--r--nptl/tst-getpid2.c2
-rw-r--r--sysdeps/unix/sysv/linux/ia64/clone2.S25
8 files changed, 57 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index bc8ad625e7..ff39287f8e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-12-07  Jakub Jelinek  <jakub@redhat.com>
+
+	* sysdeps/unix/sysv/linux/ia64/clone2.S (__clone2): Add support for
+	NPTL where the PID is stored at userlevel and needs to be reset when
+	CLONE_THREAD is not used.  Restore gp before calling _exit.
+
 2004-12-07  Kaz Kojima  <kkojima@rr.iij4u.or.jp>
 
 	* sysdeps/unix/sysv/linux/sh/clone.S: Clear the frame pointer when
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 94764f1535..4cb92c9d78 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,13 @@
+2004-12-07  Jakub Jelinek  <jakub@redhat.com>
+
+	* sysdeps/ia64/tcb-offsets.sym (TID): Add.
+	* sysdeps/unix/sysv/linux/ia64/clone2.S: New file.
+
+	* Makefile (tests): Add tst-getpid2.
+	* tst-getpid1.c (TEST_CLONE_FLAGS): Define.
+	(do_test): Use it.  Use __clone2 instead of clone on ia64.
+	* tst-getpid2.c: New test.
+
 2004-12-07  Kaz Kojima  <kkojima@rr.iij4u.or.jp>
 
 	* sysdeps/unix/sysv/linux/sh/clone.S: New file.
diff --git a/nptl/Makefile b/nptl/Makefile
index ecd5e52cdb..8149ef5ed4 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -241,7 +241,7 @@ tests = tst-attr1 tst-attr2 tst-attr3 \
 	tst-backtrace1 \
 	tst-oddstacklimit \
 	tst-vfork1 tst-vfork2 tst-vfork1x tst-vfork2x \
-	tst-getpid1
+	tst-getpid1 tst-getpid2
 xtests = tst-setuid1 tst-setuid1-static
 
 # Files which must not be linked with libpthread.
diff --git a/nptl/sysdeps/ia64/tcb-offsets.sym b/nptl/sysdeps/ia64/tcb-offsets.sym
index 09ea70ddc7..f5108e0a9e 100644
--- a/nptl/sysdeps/ia64/tcb-offsets.sym
+++ b/nptl/sysdeps/ia64/tcb-offsets.sym
@@ -2,5 +2,6 @@
 #include <tls.h>
 
 PID			offsetof (struct pthread, pid) - sizeof (struct pthread)
+TID			offsetof (struct pthread, tid) - sizeof (struct pthread)
 MULTIPLE_THREADS_OFFSET offsetof (struct pthread, header.multiple_threads) - sizeof (struct pthread)
 SYSINFO_OFFSET		offsetof (tcbhead_t, private)
diff --git a/nptl/sysdeps/unix/sysv/linux/ia64/clone2.S b/nptl/sysdeps/unix/sysv/linux/ia64/clone2.S
new file mode 100644
index 0000000000..8664056f27
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/ia64/clone2.S
@@ -0,0 +1,2 @@
+#define RESET_PID
+#include <sysdeps/unix/sysv/linux/ia64/clone2.S>
diff --git a/nptl/tst-getpid1.c b/nptl/tst-getpid1.c
index 9d637159c4..061b48d735 100644
--- a/nptl/tst-getpid1.c
+++ b/nptl/tst-getpid1.c
@@ -5,6 +5,10 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
+#ifndef TEST_CLONE_FLAGS
+#define TEST_CLONE_FLAGS 0
+#endif
+
 static int sig;
 
 static int
@@ -35,8 +39,16 @@ do_test (void)
       return 1;
     }
 
+#ifdef __ia64__
+  extern int __clone2 (int (*__fn) (void *__arg), void *__child_stack_base,
+		       size_t __child_stack_size, int __flags,
+		       void *__arg, ...);
+  char st[256 * 1024];
+  pid_t p = __clone2 (f, st, sizeof (st), TEST_CLONE_FLAGS, 0);
+#else
   char st[128 * 1024];
-  pid_t p = clone (f, st + sizeof (st), 0, 0);
+  pid_t p = clone (f, st + sizeof (st), TEST_CLONE_FLAGS, 0);
+#endif
   if (p == -1)
     {
       printf("clone failed: %m\n");
diff --git a/nptl/tst-getpid2.c b/nptl/tst-getpid2.c
new file mode 100644
index 0000000000..fc98cb60db
--- /dev/null
+++ b/nptl/tst-getpid2.c
@@ -0,0 +1,2 @@
+#define TEST_CLONE_FLAGS CLONE_VM
+#include "tst-getpid1.c"
diff --git a/sysdeps/unix/sysv/linux/ia64/clone2.S b/sysdeps/unix/sysv/linux/ia64/clone2.S
index af5e009be4..69c9e05044 100644
--- a/sysdeps/unix/sysv/linux/ia64/clone2.S
+++ b/sysdeps/unix/sysv/linux/ia64/clone2.S
@@ -30,7 +30,7 @@
 
 ENTRY(__clone2)
 	.prologue
-	alloc r2=ar.pfs,8,0,6,0
+	alloc r2=ar.pfs,8,1,6,0
 	cmp.eq p6,p0=0,in0
 	mov r8=EINVAL
 	mov out0=in3		/* Flags are first syscall argument.	*/
@@ -63,15 +63,34 @@ ENTRY(__clone2)
 	cmp.eq CHILD,PARENT=0,r8 /* Are we the child?   */
 (p6)	br.cond.spnt.many __syscall_error
 	;;
-(CHILD)	ld8 out1=[in0],8	/* Retrieve code pointer.	*/
-(CHILD)	mov out0=in4		/* Pass proper argument	to fn */
+(CHILD)	mov loc0=gp
 (PARENT) ret
 	;;
+#ifdef RESET_PID
+	tbit.nz p6,p0=in3,16	/* CLONE_THREAD */
+	tbit.z p7,p10=in3,8	/* CLONE_VM */
+(p6)	br.cond.dptk 1f
+	;;
+	mov r15=SYS_ify (getpid)
+(p10)	addl r8=-1,r0
+(p7)	break __BREAK_SYSCALL
+	;;
+	add r9=PID,r13
+	add r10=TID,r13
+	;;
+	st4 [r9]=r8
+	st4 [r10]=r8
+	;;
+#endif
+1:	ld8 out1=[in0],8	/* Retrieve code pointer.	*/
+	mov out0=in4		/* Pass proper argument	to fn */
+	;;
 	ld8 gp=[in0]		/* Load function gp.		*/
 	mov b6=out1
 	br.call.dptk.many rp=b6	/* Call fn(arg) in the child 	*/
 	;;
 	mov out0=r8		/* Argument to _exit		*/
+	mov gp=loc0
 	.globl HIDDEN_JUMPTARGET(_exit)
 	br.call.dpnt.many rp=HIDDEN_JUMPTARGET(_exit)
 				/* call _exit with result from fn.	*/