about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-01-05 11:26:28 +0000
committerUlrich Drepper <drepper@redhat.com>2003-01-05 11:26:28 +0000
commitbbd1745596d2f0562745dbde8d2a62bc0d1eaaae (patch)
treecffb5e41a80be4b8d55b0e2a21385fd1e5d3cc31 /sysdeps/unix/sysv/linux
parentbdee30cfe40d9c5cfe0b8969877f11857d092359 (diff)
downloadglibc-bbd1745596d2f0562745dbde8d2a62bc0d1eaaae.tar.gz
glibc-bbd1745596d2f0562745dbde8d2a62bc0d1eaaae.tar.xz
glibc-bbd1745596d2f0562745dbde8d2a62bc0d1eaaae.zip
Update.
2003-01-05  Kaz Kojima  <kkojima@rr.iij4u.or.jp>

	* sysdeps/unix/sysv/linux/sh/clone.S (__clone): Use
	SYSCALL_ERROR_HANDLER.
	* sysdeps/unix/sysv/linux/sh/pipe.S (__libc_pipe): Likewise.
	* sysdeps/unix/sysv/linux/sh/socket.S (__socket): Likewise.
	Add support for cancellation handling.
	* sysdeps/unix/sysv/linux/sh/syscall.S (__syscall): Use
	SYSCALL_ERROR_HANDLER.
	* sysdeps/unix/sysv/linux/sh/vfork.S (__vfork): Likewise.
	* sysdeps/unix/sysv/linux/sh/sysdep.h (PSEUDO): Likewise.
	Add support for cancellation handling.
	(SYSCALL_ERROR_HANDLER): Define PIC variants.
Diffstat (limited to 'sysdeps/unix/sysv/linux')
-rw-r--r--sysdeps/unix/sysv/linux/sh/clone.S60
-rw-r--r--sysdeps/unix/sysv/linux/sh/pipe.S35
-rw-r--r--sysdeps/unix/sysv/linux/sh/socket.S71
-rw-r--r--sysdeps/unix/sysv/linux/sh/syscall.S32
-rw-r--r--sysdeps/unix/sysv/linux/sh/sysdep.h131
-rw-r--r--sysdeps/unix/sysv/linux/sh/vfork.S55
6 files changed, 159 insertions, 225 deletions
diff --git a/sysdeps/unix/sysv/linux/sh/clone.S b/sysdeps/unix/sysv/linux/sh/clone.S
index 3a20db0ca7..a6ddcc5336 100644
--- a/sysdeps/unix/sysv/linux/sh/clone.S
+++ b/sysdeps/unix/sysv/linux/sh/clone.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2000, 2003 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
@@ -32,27 +32,9 @@ ENTRY(__clone)
 	bf/s	1f
 	 tst	r5, r5
 	bf/s	1f
-	 mov.l	.L1, r1
-#ifdef SHARED
-	mov.l	r12, @-r15
-	sts.l	pr, @-r15
-        mov.l	.LG, r12
-	mova	.LG, r0
-	add	r0, r12
-	mova	.L1, r0
-	add	r0, r1
-	jsr	@r1
-	 mov	#-EINVAL, r4
-	lds.l	@r15+, pr
-	rts
-	 mov.l	@r15+, r12
-#else
-	jmp	@r1
-	 mov	#-EINVAL, r4
-#endif
-	.align	2
-.L1:
-	.long	PLTJMP(C_SYMBOL_NAME(__syscall_error))
+	 mov	#-EINVAL,r0
+	bra	.Lsyscall_error
+	 nop
 1:
 	/* insert the args onto the new stack */
 	mov.l	r7, @-r5
@@ -68,36 +50,16 @@ ENTRY(__clone)
 	shad	r2, r1
 	not	r1, r1			// r1=0 means r0 = -1 to -4095
 	tst	r1, r1			// i.e. error in linux
-	bf	2f
-	mov.l	.L2, r1
-#ifdef SHARED
-	mov	r0, r4
-	mov.l	r12, @-r15
-	sts.l	pr, @-r15
-        mov.l	.LG, r12
-	mova	.LG, r0
-	add	r0, r12
-	mova	.L2, r0
-	add	r0, r1
-	jsr	@r1
-	 nop
-	lds.l	@r15+, pr
-	rts
-	 mov.l	@r15+, r12
-#else
-	jmp	@r1
-	 mov	r0, r4
-#endif
-	.align	2
-.L2:
-	.long	PLTJMP(C_SYMBOL_NAME(__syscall_error))
-
-2:
+	bf	.Lclone_end
+.Lsyscall_error:	
+	SYSCALL_ERROR_HANDLER
+.Lclone_end:
 	tst	r0, r0
-	bt	3f
+	bt	2f
+.Lpseudo_end:
 	rts
 	 nop
-3:
+2:
 	/* thread starts */
 	mov.l	@r15, r1
 	jsr	@r1
diff --git a/sysdeps/unix/sysv/linux/sh/pipe.S b/sysdeps/unix/sysv/linux/sh/pipe.S
index 80e7280a5c..2b5cf77d16 100644
--- a/sysdeps/unix/sysv/linux/sh/pipe.S
+++ b/sysdeps/unix/sysv/linux/sh/pipe.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2000, 2002, 2003 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
@@ -26,37 +26,16 @@ ENTRY (__libc_pipe)
 	shad	r2, r3
 	not	r3, r3			// r1=0 means r0 = -1 to -4095
 	tst	r3, r3			// i.e. error in linux
-	bf	1f
-	mov.l	.L2, r1
-#ifdef SHARED
-	mov	r0, r4
-	mov.l	r12, @-r15
-	sts.l	pr, @-r15
-        mov.l	0f, r12
-	mova	0f, r0
-	add	r0, r12
-	mova	.L2, r0
-	add	r0, r1
-	jsr	@r1
-	 nop
-	lds.l	@r15+, pr
-	rts
-	 mov.l	@r15+, r12
-	.align 2
-0:
-	.long	_GLOBAL_OFFSET_TABLE_
-#else
-	jmp	@r1
-	 mov	r0, r4
-#endif
-1:
+	bt	1f
 	mov.l	r0, @r4
 	mov.l	r1, @(4, r4)
 	rts
 	 mov	#0, r0
-	.align	2
-.L2:
-	.long	PLTJMP(C_SYMBOL_NAME(__syscall_error))
+1:
+	SYSCALL_ERROR_HANDLER
+.Lpseudo_end:
+	rts
+	 nop
 PSEUDO_END (__libc_pipe)
 
 weak_alias (__libc_pipe, __pipe)
diff --git a/sysdeps/unix/sysv/linux/sh/socket.S b/sysdeps/unix/sysv/linux/sh/socket.S
index 733b9d0c9e..11a2b853eb 100644
--- a/sysdeps/unix/sysv/linux/sh/socket.S
+++ b/sysdeps/unix/sysv/linux/sh/socket.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2000, 2003 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
@@ -16,8 +16,9 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#include <sysdep.h>
+#include <sysdep-cancel.h>
 #include <socketcall.h>
+#include <tls.h>
 
 #define P(a, b) P2(a, b)
 #define P2(a, b) a##b
@@ -63,7 +64,12 @@ ENTRY (__socket)
 	/* Push args onto the stack.  */
 	P(PUSHARGS_,NARGS)
 
-        /* Do the system call trap.  */
+#if defined NEED_CANCELLATION && defined CENABLE
+	SINGLE_THREAD_P
+	bf .Lsocket_cancel	
+#endif
+
+	/* Do the system call trap.  */
 	mov #+P(SOCKOP_,socket), r4
 	mov r15, r5
 	mov.l .L1,r3
@@ -77,39 +83,44 @@ ENTRY (__socket)
 	shad	r2, r1
 	not	r1, r1			// r1=0 means r0 = -1 to -4095
 	tst	r1, r1			// i.e. error in linux
-	bf	1f
-
-	mov.l .L2, r1
-#ifdef SHARED
-	mov	r0, r4
-	mov.l	r12, @-r15
-	sts.l	pr, @-r15
-        mov.l	0f, r12
-	mova	0f, r0
-	add	r0, r12
-	mova	.L2, r0
-	add	r0, r1
-	jsr @r1
-	 nop
-	lds.l	@r15+, pr
-	rts
-	 mov.l	@r15+, r12
-	.align 2
-0:
-	.long	_GLOBAL_OFFSET_TABLE_
-#else
-	jmp @r1
-	 mov	r0, r4
-#endif
-1:
+	bf	.Lpseudo_end
+.Lsyscall_error:
+	SYSCALL_ERROR_HANDLER
+.Lpseudo_end:
 	/* Successful; return the syscall's value.  */
 	rts
 	 nop
+
+#if defined NEED_CANCELLATION && defined CENABLE
+.Lsocket_cancel:
+	/* Enable asynchronous cancellation.  */
+	CENABLE
+
+	/* Do the system call trap.  */
+	mov #+P(SOCKOP_,socket), r4
+	mov r15, r5
+	mov.l .L1,r3
+	trapa #0x12
+
+	mov.l r0,@-r15
+	CDISABLE
+	mov.l @r15+,r0
+
+	/* Pop args off the stack */
+	P(POPARGS_,NARGS)
+
+	mov     r0, r1
+	mov	#-12, r2
+	shad	r2, r1
+	not	r1, r1			// r1=0 means r0 = -1 to -4095
+	tst	r1, r1			// i.e. error in linux
+	bf	.Lpseudo_end
+	bra	.Lsyscall_error
+	 nop
+#endif
 	.align 2
 .L1:
 	.long	SYS_ify(socketcall)
-.L2:
-	.long	PLTJMP(C_SYMBOL_NAME(__syscall_error))
 
 PSEUDO_END (__socket)
 
diff --git a/sysdeps/unix/sysv/linux/sh/syscall.S b/sysdeps/unix/sysv/linux/sh/syscall.S
index 08f2be6978..afa16c2fb9 100644
--- a/sysdeps/unix/sysv/linux/sh/syscall.S
+++ b/sysdeps/unix/sysv/linux/sh/syscall.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2003 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
@@ -33,36 +33,12 @@ ENTRY (__syscall)
 	shad	r2, r1
 	not	r1, r1			// r1=0 means r0 = -1 to -4095
 	tst	r1, r1			// i.e. error in linux
-	bf	1f
-	mov.l	.L2, r1
-#ifdef SHARED
-	mov	r0, r4
-	mov.l	r12, @-r15
-	sts.l	pr, @-r15
-        mov.l	0f, r12
-	mova	0f, r0
-	add	r0, r12
-	mova	.L2, r0
-	add	r0, r1
-	jsr	@r1
-	 nop
-	lds.l	@r15+, pr
-	rts
-	 mov.l	@r15+, r12
-	.align 2
-0:
-	.long	_GLOBAL_OFFSET_TABLE_
-#else
-	jmp	@r1
-	 mov	r0, r4
-#endif
-1:
+	bf	.Lpseudo_end
+	SYSCALL_ERROR_HANDLER
+.Lpseudo_end:
 	rts
 	 nop
 
-	.align	2
-.L2:
-	.long	PLTJMP(C_SYMBOL_NAME(__syscall_error))
 PSEUDO_END (__syscall)
 
 weak_alias (__syscall, syscall)
diff --git a/sysdeps/unix/sysv/linux/sh/sysdep.h b/sysdeps/unix/sysv/linux/sh/sysdep.h
index 7d31378eb5..ee39121755 100644
--- a/sysdeps/unix/sysv/linux/sh/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sh/sysdep.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992,93,95-99,2000,02 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>, August 1995.
    Changed by Kaz Kojima, <kkojima@rr.iij4u.or.jp>.
@@ -45,9 +45,9 @@
    returns a value in -1 .. -4095 as a valid result so we can savely
    test with -4095.  */
 
+#define _IMM1 #-1
 #define _IMM12 #-12
 #undef	PSEUDO
-#ifdef SHARED
 #define	PSEUDO(name, syscall_name, args) \
  .text; \
  ENTRY (name); \
@@ -57,50 +57,99 @@
     shad r2,r1; \
     not r1,r1; \
     tst r1,r1; \
-    bf 1f; \
-    mov r0,r4; \
-    mov.l r12,@-r15; \
-    sts.l pr,@-r15; \
-    mov.l 0f,r12; \
-    mova 0f,r0; \
-    add r0,r12; \
-    mov.l 2f,r1; \
-    mova 2f,r0; \
-    add r0,r1; \
-    jsr @r1; \
-     nop; \
-    lds.l @r15+,pr; \
-    rts; \
-     mov.l @r15+,r12; \
-    .align 2; \
- 2: .long PLTJMP(C_SYMBOL_NAME(__syscall_error)); \
- 0: .long _GLOBAL_OFFSET_TABLE_; \
- 1:
-#else
-#define	PSEUDO(name, syscall_name, args) \
- .text; \
- ENTRY (name); \
-    DO_CALL (syscall_name, args); \
-    mov r0,r1; \
-    mov _IMM12,r2; \
-    shad r2,r1; \
-    not r1,r1; \
-    tst r1,r1; \
-    bf 1f; \
-    mov.l 2f,r1; \
-    jmp @r1; \
-     mov r0, r4; \
-    .align 2; \
- 2: .long PLTJMP(C_SYMBOL_NAME(__syscall_error)); \
- 1:
-#endif
+    bf .Lpseudo_end; \
+    SYSCALL_ERROR_HANDLER; \
+ .Lpseudo_end:
 
 #undef	PSEUDO_END
 #define	PSEUDO_END(name) \
-  SYSCALL_ERROR_HANDLER \
   END (name)
 
-#define SYSCALL_ERROR_HANDLER	/* Nothing here; code in sysdep.S is used.  */
+#ifndef PIC
+# define SYSCALL_ERROR_HANDLER	/* Nothing here; code in sysdep.S is used.  */
+#else
+# if RTLD_PRIVATE_ERRNO
+#  define SYSCALL_ERROR_HANDLER	\
+	neg r0,r1; \
+	mov.l 0f,r12; \
+	mova 0f,r0; \
+	add r0,r12; \
+	mov.l 1f,r0; \
+	mov.l r1,@(r0,r12)
+	bra .Lpseudo_end; \
+	 mov _IMM1,r0; \
+	.align 2; \
+     0: .long _GLOBAL_OFFSET_TABLE_; \
+     1: .long errno@GOTOFF
+
+# elif defined _LIBC_REENTRANT
+
+#  if USE___THREAD
+#   ifndef NOT_IN_libc
+#    define SYSCALL_ERROR_ERRNO __libc_errno
+#   else
+#    define SYSCALL_ERROR_ERRNO errno
+#   endif
+#   define SYSCALL_ERROR_HANDLER \
+	neg r0,r1; \
+	mov r12,r2; \
+	mov.l 0f,r12; \
+	mova 0f,r0; \
+	add r0,r12; \
+	mov.l 1f,r0; \
+	stc gbr, r4; \
+	mov.l @(r0,r12),r0; \
+	mov r2,r12; \
+	add r4,r0; \
+	mov.l r1,@r0; \
+	bra .Lpseudo_end; \
+	 mov _IMM1,r0; \
+	.align 2; \
+     0: .long _GLOBAL_OFFSET_TABLE_; \
+     1: .long SYSCALL_ERROR_ERRNO@GOTTPOFF
+#  else
+#   define SYSCALL_ERROR_HANDLER \
+	neg r0,r1; \
+	mov.l r12,@-r15; \
+	mov.l r1,@-r15; \
+	mov.l 0f,r12; \
+	mova 0f,r0; \
+	add r0,r12; \
+	sts.l pr,@-r15; \
+	mov.l 1f,r1; \
+	bsrf r1; \
+         nop; \
+     2: lds.l @r15+,pr; \
+	mov.l @r15+,r1; \
+	mov.l r1,@r0; \
+	mov.l @r15+,r12; \
+	bra .Lpseudo_end; \
+	 mov _IMM1,r0; \
+	.align 2; \
+     0: .long _GLOBAL_OFFSET_TABLE_; \
+     1: .long PLTJMP(C_SYMBOL_NAME(__errno_location))-(2b+2-.)
+/* A quick note: it is assumed that the call to `__errno_location' does
+   not modify the stack!  */
+#  endif
+# else
+/* Store (-r0) into errno through the GOT.  */
+#  define SYSCALL_ERROR_HANDLER						      \
+	neg r0,r1; \
+	mov r12,r2; \
+	mov.l 0f,r12; \
+	mova 0f,r0; \
+	add r0,r12; \
+	mov.l 1f,r0; \
+	mov.l @(r0,r12),r0; \
+	mov r2,r12; \
+	mov.l r1,@r0; \
+	bra .Lpseudo_end; \
+	 mov _IMM1,r0; \
+	.align 2; \
+     0: .long _GLOBAL_OFFSET_TABLE_; \
+     1: .long errno@GOT
+# endif	/* _LIBC_REENTRANT */
+#endif	/* PIC */
 
 #define SYSCALL_INST0	trapa #0x10
 #define SYSCALL_INST1	trapa #0x11
diff --git a/sysdeps/unix/sysv/linux/sh/vfork.S b/sysdeps/unix/sysv/linux/sh/vfork.S
index 706aa57b50..e926e3b19e 100644
--- a/sysdeps/unix/sysv/linux/sh/vfork.S
+++ b/sysdeps/unix/sysv/linux/sh/vfork.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2000, 2002, 2003 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
@@ -39,28 +39,8 @@ ENTRY (__vfork)
 	mov.w	.L1, r1
 	cmp/eq	r1, r0
 	bt	2f
-	mov.l	.L2, r1
-#ifdef SHARED
-	mov	r0, r4
-	mov.l	r12, @-r15
-	sts.l	pr, @-r15
-	mov.l	0f, r12
-	mova	0f, r0
-	add	r0, r12
-	mova	.L2, r0
-	add	r0, r1
-	jsr	@r1
+	bra	.Lsyscall_error
 	 nop
-	lds.l	@r15+, pr
-	rts
-	 mov.l	@r15+, r12
-	.align	2
-0:
-	.long	_GLOBAL_OFFSET_TABLE_
-#else
-	jmp	@r1
-	 mov	r0, r4
-#endif
 .L1:
 	.word	-ENOSYS
 .L3:	.word	__NR_vfork
@@ -78,33 +58,10 @@ ENTRY (__vfork)
 	shad	r2, r1
 	not	r1, r1			// r1=0 means r0 = -1 to -4095
 	tst	r1, r1			// i.e. error in linux
-	bf	1f
-	mov.l	.L2, r1
-#ifdef SHARED
-	mov	r0, r4
-	mov.l	r12, @-r15
-	sts.l	pr, @-r15
-        mov.l	0f, r12
-	mova	0f, r0
-	add	r0, r12
-	mova	.L2, r0
-	add	r0, r1
-	jsr	@r1
-	 nop
-	lds.l	@r15+, pr
-	rts
-	 mov.l	@r15+, r12
-	.align	2
-0:
-	.long	_GLOBAL_OFFSET_TABLE_
-#else
-	jmp	@r1
-	 mov	r0, r4
-#endif
-	.align	2
-.L2:
-	.long	PLTJMP(C_SYMBOL_NAME(__syscall_error))
-1:
+	bf	.Lpseudo_end
+.Lsyscall_error:	
+	SYSCALL_ERROR_HANDLER
+.Lpseudo_end:
 	rts
 	 nop