public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] vfork fixes
@ 2003-02-10 22:54 Jakub Jelinek
  2003-02-11  6:30 ` Ulrich Drepper
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2003-02-10 22:54 UTC (permalink / raw)
  To: Ulrich Drepper, Roland McGrath; +Cc: Glibc hackers

Hi!

This fixes tst-popen2.c on s390 32-bit, makes it build on sparc*
(did not due to silly typo), adds forgotten .weak on sh and also
changes __pthread_fork checks to pthread_cancel checks on all arches.
For vfork it really matters whether pthread.o got linked in, not ptfork.o.

2003-02-10  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/unix/sysv/linux/alpha/vfork.S (__vfork): Check
	pthread_create existance, not __pthread_fork.
	* sysdeps/unix/sysv/linux/i386/vfork.S (__vfork): Likewise.
	* sysdeps/unix/sysv/linux/ia64/vfork.S (__vfork): Likewise.
	* sysdeps/unix/sysv/linux/m68k/vfork.S (__vfork): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S (__vfork):
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/vfork.S (__vfork): Likewise.
	* sysdeps/unix/sysv/linux/x86_64/vfork.S (__vfork): Likewise.
	* sysdeps/unix/sysv/linux/sh/vfork.S (__vfork): Likewise.
	Add .weak pthread_create.
	* sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S (__vfork): Fix a typo.
	Check pthread_create existance, not __pthread_fork.
	* sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S (__vfork): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/vfork.S (__vfork): Branch to
	__fork whenever libpthread.so is loaded.

--- libc/linuxthreads/sysdeps/unix/sysv/linux/alpha/vfork.S	10 Feb 2003 14:12:31 -0000	1.1.1.4
+++ libc/linuxthreads/sysdeps/unix/sysv/linux/alpha/vfork.S	10 Feb 2003 18:43:50 -0000	1.3
@@ -31,8 +31,8 @@ __LABEL(__vfork)
 	ldq	t0, __libc_pthread_functions(gp) !gprel
 	bne	t0, HIDDEN_JUMPTARGET (__fork) !samegp
 #else
-	.weak	__pthread_fork
-	ldq	t0, __pthread_fork(gp) !literal
+	.weak	pthread_create
+	ldq	t0, pthread_create(gp) !literal
 	bne	t0, $do_fork
 #endif
 
--- libc/linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S	10 Feb 2003 14:12:31 -0000	1.1.1.2
+++ libc/linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S	10 Feb 2003 18:43:50 -0000	1.4
@@ -40,8 +40,8 @@ ENTRY (__vfork)
 	addl	$_GLOBAL_OFFSET_TABLE_, %ecx
 	cmpl	$0, __libc_pthread_functions@GOTOFF(%ecx)
 # else
-	.weak	__pthread_fork
-	movl	$__pthread_fork, %eax
+	.weak	pthread_create
+	movl	$pthread_create, %eax
 	testl	%eax, %eax
 # endif
 	jne	HIDDEN_JUMPTARGET (__fork)
--- libc/linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S	10 Feb 2003 14:12:31 -0000	1.1.1.3
+++ libc/linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S	10 Feb 2003 18:43:50 -0000	1.4
@@ -33,8 +33,8 @@ ENTRY(__vfork)
 #ifdef SHARED
 	addl r14 = @gprel(__libc_pthread_functions#), gp;;
 #else
-	.weak	__pthread_fork
-	addl r14 = @ltoff(@fptr(__pthread_fork#)), gp;;
+	.weak	pthread_create
+	addl r14 = @ltoff(@fptr(pthread_create#)), gp;;
 #endif
 	ld8 r14 = [r14];;
 	cmp.ne p6, p7 = 0, r14
--- libc/linuxthreads/sysdeps/unix/sysv/linux/m68k/vfork.S	10 Feb 2003 14:12:31 -0000	1.1.1.2
+++ libc/linuxthreads/sysdeps/unix/sysv/linux/m68k/vfork.S	10 Feb 2003 18:43:50 -0000	1.2
@@ -32,8 +32,8 @@ ENTRY (__vfork)
 #ifdef SHARED
 	tstl	(__libc_pthread_functions@GOTPC, %pc)
 #else
-	.weak	__pthread_fork
-	movel	#__pthread_fork, %d0
+	.weak	pthread_create
+	movel	#pthread_create, %d0
 #endif
 	jbne	HIDDEN_JUMPTARGET (__fork)
 
--- libc/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S	10 Feb 2003 14:12:31 -0000	1.1.1.3
+++ libc/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S	10 Feb 2003 18:43:50 -0000	1.3
@@ -39,9 +39,9 @@ ENTRY (__vfork)
 	cmpwi	10,0
 	bne-	HIDDEN_JUMPTARGET(__fork)
 # else
-	.weak	__pthread_fork
-	lis	9,__pthread_fork@ha
-	la	9,__pthread_fork@l(9)
+	.weak	pthread_create
+	lis	9,pthread_create@ha
+	la	9,pthread_create@l(9)
 	cmpwi	9,0
 	bne-	.Lhidden_fork
 # endif
--- libc/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-32/vfork.S	29 Jan 2003 13:37:11 -0000	1.1.1.3
+++ libc/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-32/vfork.S	10 Feb 2003 18:43:50 -0000	1.2
@@ -27,8 +27,16 @@
    and the process ID of the new process to the old process.  */
 
 ENTRY (__vfork)
-	SINGLE_THREAD_P(%r1)
-	jne	0f
+	basr	%r1,0
+0:
+#ifdef SHARED
+	al	%r1,4f-0b(%r1)
+	l	%r1,0(%r1)
+	ltr	%r1,%r1
+#else
+	icm	%r1,15,4f-0b(%r1)
+#endif
+	jne	1f
 
 	/* Do vfork system call.  */
 	svc	SYS_ify (vfork)
@@ -40,13 +48,20 @@ ENTRY (__vfork)
 
 	/* Normal return.  */
 	br	%r14
-0:
-	basr	%r1,0
 1:
-	al	%r1,2f-1b(%r1)
-	br	%r1
+	basr	%r1,0
 2:
-	.long	HIDDEN_JUMPTARGET(__fork)-1b
+	al	%r1,3f-2b(%r1)
+	br	%r1
+3:
+	.long	HIDDEN_JUMPTARGET(__fork)-2b
+4:
+#ifdef SHARED
+	.long	__libc_pthread_functions-0b
+#else
+	.weak	pthread_create
+	.long	pthread_create
+#endif
 PSEUDO_END(__vfork)
 
 libc_hidden_def (__vfork)
--- libc/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/vfork.S	10 Feb 2003 14:12:31 -0000	1.1.1.3
+++ libc/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/vfork.S	10 Feb 2003 18:43:50 -0000	1.3
@@ -31,8 +31,8 @@ ENTRY (__vfork)
 	larl	%r1,__libc_pthread_functions
 	lg	%r1,0(%r1)
 #else
-	.weak	__pthread_fork
-	larl	%r1,__pthread_fork
+	.weak	pthread_create
+	larl	%r1,pthread_create
 #endif
 	ltgr	%r1,%r1
 	jgne	HIDDEN_JUMPTARGET(__fork)
--- libc/linuxthreads/sysdeps/unix/sysv/linux/sh/vfork.S	10 Feb 2003 14:12:31 -0000	1.1.1.2
+++ libc/linuxthreads/sysdeps/unix/sysv/linux/sh/vfork.S	10 Feb 2003 18:43:50 -0000	1.2
@@ -30,7 +30,7 @@ ENTRY (__vfork)
 	mov.l	.Lpthread_func, r0
 	mov.l	@(r0,r12), r0
 #else
-	mov.l	.Lpthread_fork, r0
+	mov.l	.Lpthread_create, r0
 #endif
 	tst	r0, r0
 	bf	.Lhidden_fork
@@ -53,8 +53,9 @@ ENTRY (__vfork)
 .Lpthread_func:
 	.long	__libc_pthread_functions@GOTOFF
 #else
-.Lpthread_fork:
-	.long	__pthread_fork
+.Lpthread_create:
+	.weak	pthread_create
+	.long	pthread_create
 #endif
 
 .Lhidden_fork:	
--- libc/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S	10 Feb 2003 14:12:31 -0000	1.1.1.5
+++ libc/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S	10 Feb 2003 18:43:50 -0000	1.4
@@ -23,7 +23,7 @@
 #ifdef SHARED
 .LLGETPC0:
 	retl
-	 addl	%o7, %o0, %o0
+	 add	%o7, %o0, %o0
 #endif
 ENTRY(__vfork)
 #ifdef SHARED
@@ -38,9 +38,9 @@ ENTRY(__vfork)
 	ld	[%o2], %o2
 	cmp	%o2, 0
 #else
-	.weak	__pthread_fork
-	sethi	%hi(__pthread_fork), %o0
-	orcc	%o0, %lo(__pthread_fork), %o0
+	.weak	pthread_create
+	sethi	%hi(pthread_create), %o0
+	orcc	%o0, %lo(pthread_create), %o0
 #endif
 #if defined SHARED && !defined BROKEN_SPARC_WDISP22
 	bne	HIDDEN_JUMPTARGET(__fork)
@@ -48,7 +48,7 @@ ENTRY(__vfork)
 	bne	1f
 #endif
 	 mov	__NR_vfork, %g1
-	ta 0x10;
+	ta	0x10
 	bcs	__syscall_error_handler
 	 nop
 	sub	%o1, 1, %o1
--- libc/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S	10 Feb 2003 14:12:31 -0000	1.1.1.4
+++ libc/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S	10 Feb 2003 18:43:50 -0000	1.4
@@ -22,7 +22,7 @@
 #ifdef SHARED
 .LLGETPC0:
 	retl
-	 addl	%o7, %o0, %o0
+	 add	%o7, %o0, %o0
 #endif
 ENTRY(__vfork)
 #ifdef SHARED
@@ -38,9 +38,9 @@ ENTRY(__vfork)
 	cmp	%o2, 0
 	bne	HIDDEN_JUMPTARGET(__fork)
 #else
-	.weak	__pthread_fork
-	sethi	%hi(__pthread_fork), %o0
-	or	%o0, %lo(__pthread_fork), %o0
+	.weak	pthread_create
+	sethi	%hi(pthread_create), %o0
+	or	%o0, %lo(pthread_create), %o0
 	brnz,pn	%o0, 1f
 #endif
 	 mov	__NR_vfork, %g1
--- libc/linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S	10 Feb 2003 14:12:31 -0000	1.1.1.2
+++ libc/linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S	10 Feb 2003 18:43:50 -0000	1.4
@@ -30,8 +30,8 @@ ENTRY (__vfork)
 #ifdef SHARED
 	cmpq	$0, __libc_pthread_functions(%rip)
 #else
-	.weak	__pthread_fork
-	movq	$__pthread_fork, %rax
+	.weak	pthread_create
+	movq	$pthread_create, %rax
 	testq	%rax, %rax
 #endif
 	jne	HIDDEN_JUMPTARGET (__fork)

	Jakub

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

* Re: [PATCH] vfork fixes
  2003-02-10 22:54 [PATCH] vfork fixes Jakub Jelinek
@ 2003-02-11  6:30 ` Ulrich Drepper
  0 siblings, 0 replies; 4+ messages in thread
From: Ulrich Drepper @ 2003-02-11  6:30 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Roland McGrath, Glibc hackers

Jakub Jelinek wrote:

> This fixes tst-popen2.c on s390 32-bit, makes it build on sparc*
> (did not due to silly typo), adds forgotten .weak on sh and also
> changes __pthread_fork checks to pthread_cancel checks on all arches.
> For vfork it really matters whether pthread.o got linked in, not ptfork.o.

I've applied the patch.  Thanks,

-- 
--------------.                        ,-.            444 Castro Street
Ulrich Drepper \    ,-----------------'   \ Mountain View, CA 94041 USA
Red Hat         `--' drepper at redhat.com `---------------------------

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

* Re: [PATCH] vfork fixes
  2003-01-14 23:48 Jakub Jelinek
@ 2003-01-15  1:06 ` Ulrich Drepper
  0 siblings, 0 replies; 4+ messages in thread
From: Ulrich Drepper @ 2003-01-15  1:06 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Roland McGrath, Glibc hackers

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

Jakub Jelinek wrote:

> This is what Richard was talking about on Alpha, happens on SPARC,
> PPC32 as well. Tested (so far) on Alpha and PPC32 only.

Thanks, I've applied the patch.

- -- 
- --------------.                        ,-.            444 Castro Street
Ulrich Drepper \    ,-----------------'   \ Mountain View, CA 94041 USA
Red Hat         `--' drepper at redhat.com `---------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+JLQs2ijCOnn/RHQRAqAaAJ9EFSnWNmEiicYrjV4NyFT6l9+vSwCfSI5g
+NGgnX4+koTi/EJlM0fJMOI=
=7BEe
-----END PGP SIGNATURE-----

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

* [PATCH] vfork fixes
@ 2003-01-14 23:48 Jakub Jelinek
  2003-01-15  1:06 ` Ulrich Drepper
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2003-01-14 23:48 UTC (permalink / raw)
  To: Ulrich Drepper, Roland McGrath; +Cc: Glibc hackers

Hi!

This is what Richard was talking about on Alpha, happens on SPARC,
PPC32 as well. Tested (so far) on Alpha and PPC32 only.

2003-01-15  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/unix/sysv/linux/alpha/vfork.S (__vfork): Allow
	__fork to be far away from __vfork ifndef SHARED.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S (__vfork):
	Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S (__vfork): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S (__vfork): Likewise.
	Add a missing instruction.
	* sysdeps/unix/sysv/linux/arm/vfork.S (__vfork): Conditionally
	branch to __fork even if __NR_vfork is not defined.

--- libc/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S.jj	2003-01-09 21:27:54.000000000 +0100
+++ libc/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S	2003-01-14 16:09:43.000000000 +0100
@@ -23,7 +23,11 @@
 ENTRY(__vfork)
 	ld	[%g6 + MULTIPLE_THREADS_OFFSET], %o0
 	cmp	%o0, 0
+#ifdef SHARED
 	bne	HIDDEN_JUMPTARGET(__fork)
+#else
+	bne	1f
+#endif
 	 mov	__NR_vfork, %g1
 	ta 0x10;
 	bcs	__syscall_error_handler
@@ -31,6 +35,11 @@ ENTRY(__vfork)
 	sub	%o1, 1, %o1
 	retl
 	 and	%o0, %o1, %o0
+#ifndef SHARED
+1:	mov	%o7, %g1
+	call	HIDDEN_JUMPTARGET(__fork)
+	 mov	%g1, %o7
+#endif
 	SYSCALL_ERROR_HANDLER
 PSEUDO_END (__vfork)
 libc_hidden_def (__vfork)
--- libc/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S.jj	2003-01-09 21:28:07.000000000 +0100
+++ libc/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S	2003-01-14 16:15:13.000000000 +0100
@@ -22,7 +22,12 @@
 	.text
 ENTRY(__vfork)
 	ld	[%g6 + MULTIPLE_THREADS_OFFSET], %o0
+#ifdef SHARED
+	cmp	%o0, 0
 	bne	HIDDEN_JUMPTARGET (__fork)
+#else
+	brnz,pn	%o0, 1f
+#endif
 	 mov	__NR_vfork, %g1
 	ta	0x6d
 	bcs,pn	%xcc, __syscall_error_handler
@@ -30,6 +35,11 @@ ENTRY(__vfork)
 	sub	%o1, 1, %o1
 	retl
 	 and	%o0, %o1, %o0
+#ifndef SHARED
+1:	mov	%o7, %g1
+	call	HIDDEN_JUMPTARGET(__fork)
+	 mov	%g1, %o7
+#endif
 	SYSCALL_ERROR_HANDLER
 PSEUDO_END (__vfork)
 libc_hidden_def (__vfork)
--- libc/linuxthreads/sysdeps/unix/sysv/linux/alpha/vfork.S.jj	2003-01-09 21:28:32.000000000 +0100
+++ libc/linuxthreads/sysdeps/unix/sysv/linux/alpha/vfork.S	2003-01-14 17:09:25.000000000 +0100
@@ -27,11 +27,25 @@ __LABEL(__vfork)
 	.prologue 1
 	PSEUDO_PROF
 	SINGLE_THREAD_P(t0)
+#ifdef SHARED
 	bne	t0, HIDDEN_JUMPTARGET (__fork) !samegp
+#else
+	bne	t0, $hidden_fork
+#endif
 	lda	v0, SYS_ify(vfork)
 	call_pal PAL_callsys
+#ifdef SHARED
 	bne	a3, __syscall_error !samegp
+#else
+	bne	a3, $syscall_error
+#endif
 	ret
+#ifndef SHARED
+$hidden_fork:
+	jmp	zero, HIDDEN_JUMPTARGET (__fork)
+$syscall_error:
+	jmp	zero, __syscall_error
+#endif
 PSEUDO_END(__vfork)
 libc_hidden_def (__vfork)
 
--- libc/linuxthreads/sysdeps/unix/sysv/linux/arm/vfork.S.jj	2003-01-12 10:16:06.000000000 +0100
+++ libc/linuxthreads/sysdeps/unix/sysv/linux/arm/vfork.S	2003-01-14 17:02:54.000000000 +0100
@@ -32,9 +32,9 @@ rocess,
 
 ENTRY (__vfork)
 
-#ifdef __NR_vfork
 	SINGLE_THREAD_P
 	bne	HIDDEN_JUMPTARGET (__fork)
+#ifdef __NR_vfork
 	swi	__NR_vfork
 	cmn	a1, #4096
 	RETINSTR(movcc, pc, lr)
--- libc/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S.jj	2003-01-12 20:31:17.000000000 +0100
+++ libc/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S	2003-01-14 16:44:36.000000000 +0100
@@ -31,7 +31,11 @@ ENTRY (__vfork)
 #ifdef __NR_vfork
 
 	SINGLE_THREAD_P
+# ifdef SHARED
 	bne-	HIDDEN_JUMPTARGET(__fork)
+# else
+	bne-	.Lhidden_fork
+# endif
 
 	DO_CALL (SYS_ify (vfork));
 
@@ -41,7 +45,11 @@ ENTRY (__vfork)
 	bnslr+
 	/* Check if vfork syscall is known at all.  */
 	cmpwi	r3,ENOSYS
+#  ifdef SHARED
 	bne	JUMPTARGET(__syscall_error)
+#  else
+	bne	.Lsyscall_error
+#  endif
 
 # endif
 #endif
@@ -53,6 +61,13 @@ ENTRY (__vfork)
 	PSEUDO_RET
 #endif
 
+# ifndef SHARED
+.Lhidden_fork:
+	b	HIDDEN_JUMPTARGET(__fork)
+.Lsyscall_error:
+	b	JUMPTARGET(__syscall_error)
+# endif
+
 PSEUDO_END (__vfork)
 libc_hidden_def (__vfork)
 

	Jakub

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

end of thread, other threads:[~2003-02-11  6:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-10 22:54 [PATCH] vfork fixes Jakub Jelinek
2003-02-11  6:30 ` Ulrich Drepper
  -- strict thread matches above, loose matches on Subject: below --
2003-01-14 23:48 Jakub Jelinek
2003-01-15  1:06 ` 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).