about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-02-08 02:34:27 +0000
committerUlrich Drepper <drepper@redhat.com>2003-02-08 02:34:27 +0000
commit2a051a7d1af290fee89e8b0a5ba8e5a86f325a25 (patch)
tree8f07fb2a508532e8675705d6c956506c3cece73e /sysdeps
parentd9c734e9cdab99931ddbbbc6de30a109be1483e6 (diff)
downloadglibc-2a051a7d1af290fee89e8b0a5ba8e5a86f325a25.tar.gz
glibc-2a051a7d1af290fee89e8b0a5ba8e5a86f325a25.tar.xz
glibc-2a051a7d1af290fee89e8b0a5ba8e5a86f325a25.zip
Update.
2003-02-07  Kaz Kojima  <kkojima@rr.iij4u.or.jp>

	* elf/tls-macros.h: Add non-PIC TLS macros and fix clobber list
	for SH.
	* sysdeps/unix/sysv/linux/sh/brk.c: Add SYSCALL_INST_PAD
	after the trapa instruction.
	* sysdeps/unix/sysv/linux/sh/clone.S (__clone): Add additional
	parameters.
	* sysdeps/unix/sysv/linux/sh/sh4/sysdep.h: New file.
	(NEED_SYSCALL_INST_PAD): Define.
	* sysdeps/unix/sysv/linux/sh/sys/user.h (start_thread): Undef to
	avoid to use definition for the kernel.
	* sysdeps/unix/sysv/linux/sh/sysdep.h (SYSCALL_ERROR_HANDLER):
	Save and restore the frame pointer.
	(SYSCALL_INST_PAD): Define.
	(INLINE_SYSCALL): Make use of INTERNAL_SYSCALL.
	(INTERNAL_SYSCALL): Make use of ERR parameter. Add SYSCALL_INST_PAD
	after trapa instruction.
	(INTERNAL_SYSCALL_DECL, INTERNAL_SYSCALL_ERRNO,
	INTERNAL_SYSCALL_ERROR_P): Adjust accordingly.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/unix/sysv/linux/sh/brk.c4
-rw-r--r--sysdeps/unix/sysv/linux/sh/clone.S8
-rw-r--r--sysdeps/unix/sysv/linux/sh/sh4/sysdep.h4
-rw-r--r--sysdeps/unix/sysv/linux/sh/sys/user.h4
-rw-r--r--sysdeps/unix/sysv/linux/sh/sysdep.h50
5 files changed, 57 insertions, 13 deletions
diff --git a/sysdeps/unix/sysv/linux/sh/brk.c b/sysdeps/unix/sysv/linux/sh/brk.c
index bf55a61a26..0524478b59 100644
--- a/sysdeps/unix/sysv/linux/sh/brk.c
+++ b/sysdeps/unix/sysv/linux/sh/brk.c
@@ -1,5 +1,5 @@
 /* brk system call for Linux/SH.
-   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
@@ -31,7 +31,7 @@ __brk (void *addr)
   register long r3 asm ("%r3") = SYS_ify (brk);
   register long r4 asm ("%r4") = (long)addr;
 
-  asm volatile ("trapa #0x11"
+  asm volatile ("trapa #0x11\n\t" SYSCALL_INST_PAD
 		: "=z"(newbrk) 
 		: "r" (r3), "r" (r4));
 
diff --git a/sysdeps/unix/sysv/linux/sh/clone.S b/sysdeps/unix/sysv/linux/sh/clone.S
index a6ddcc5336..713b0f9c3b 100644
--- a/sysdeps/unix/sysv/linux/sh/clone.S
+++ b/sysdeps/unix/sysv/linux/sh/clone.S
@@ -23,7 +23,8 @@
 #define _ERRNO_H	1
 #include <bits/errno.h>
 
-/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
+	     pid_t *ptid, void *tls, pid_t *ctid); */
 
         .text
 ENTRY(__clone)
@@ -43,8 +44,11 @@ ENTRY(__clone)
 
 	/* do the system call */
 	mov	r6, r4
+	mov.l	@r15, r6
+	mov.l	@(8,r15), r7
+	mov.l	@(4,r15), r0
 	mov	#+SYS_ify(clone), r3
-	trapa	#0x12
+	trapa	#0x15
 	mov     r0, r1
 	mov	#-12, r2
 	shad	r2, r1
diff --git a/sysdeps/unix/sysv/linux/sh/sh4/sysdep.h b/sysdeps/unix/sysv/linux/sh/sh4/sysdep.h
new file mode 100644
index 0000000000..852f8eed7f
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sh/sh4/sysdep.h
@@ -0,0 +1,4 @@
+/*  4 instruction cycles not accessing cache and TLB are needed after
+    trapa instruction to avoid an SH-4 silicon bug.  */
+#define NEED_SYSCALL_INST_PAD
+#include <sysdeps/unix/sysv/linux/sh/sysdep.h>
diff --git a/sysdeps/unix/sysv/linux/sh/sys/user.h b/sysdeps/unix/sysv/linux/sh/sys/user.h
index 522475f791..7f31bb62dd 100644
--- a/sysdeps/unix/sysv/linux/sh/sys/user.h
+++ b/sysdeps/unix/sysv/linux/sh/sys/user.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 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
@@ -23,4 +23,6 @@
 
 #include <asm/user.h>
 
+#undef start_thread
+
 #endif  /* sys/user.h */
diff --git a/sysdeps/unix/sysv/linux/sh/sysdep.h b/sysdeps/unix/sysv/linux/sh/sysdep.h
index 75557f554e..ea1cffbd86 100644
--- a/sysdeps/unix/sysv/linux/sh/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sh/sysdep.h
@@ -115,19 +115,23 @@
 #  else
 #   define SYSCALL_ERROR_HANDLER \
 	neg r0,r1; \
+	mov.l r14,@-r15; \
 	mov.l r12,@-r15; \
 	mov.l r1,@-r15; \
 	mov.l 0f,r12; \
 	mova 0f,r0; \
 	add r0,r12; \
 	sts.l pr,@-r15; \
+	mov r15,r14; \
 	mov.l 1f,r1; \
 	bsrf r1; \
          nop; \
-     2: lds.l @r15+,pr; \
+     2: mov r14,r15; \
+	lds.l @r15+,pr; \
 	mov.l @r15+,r1; \
 	mov.l r1,@r0; \
 	mov.l @r15+,r12; \
+	mov.l @r15+,r14; \
 	bra .Lpseudo_end; \
 	 mov _IMM1,r0; \
 	.align 2; \
@@ -174,6 +178,13 @@
  1: .long SYS_ify (syscall_name);	\
  2:
 
+# ifdef NEED_SYSCALL_INST_PAD
+#  define SYSCALL_INST_PAD \
+	or r0,r0; or r0,r0; or r0,r0; or r0,r0; or r0,r0
+# else
+#  define SYSCALL_INST_PAD
+# endif
+
 #else /* not __ASSEMBLER__ */
 
 #define SYSCALL_INST_STR0	"trapa #0x10\n\t"
@@ -184,6 +195,13 @@
 #define SYSCALL_INST_STR5	"trapa #0x15\n\t"
 #define SYSCALL_INST_STR6	"trapa #0x16\n\t"
 
+# ifdef NEED_SYSCALL_INST_PAD
+#  define SYSCALL_INST_PAD "\
+	or r0,r0; or r0,r0; or r0,r0; or r0,r0; or r0,r0"
+# else
+#  define SYSCALL_INST_PAD
+# endif
+
 #define ASMFMT_0
 #define ASMFMT_1 \
 	, "r" (r4)
@@ -238,24 +256,40 @@
 	register long r2 asm ("%r2") = (long)(arg7)
 
 #undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...) 			\
+#define INLINE_SYSCALL(name, nr, args...) \
+  ({                                                                          \
+    unsigned int resultvar = INTERNAL_SYSCALL (name, , nr, args);             \
+    if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0))         \
+      {                                                                       \
+        __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, ));                   \
+        resultvar = 0xffffffff;                                               \
+      }                                                                       \
+    (int) resultvar; })
+
+#undef INTERNAL_SYSCALL
+#define INTERNAL_SYSCALL(name, err, nr, args...) \
   ({								\
     unsigned long resultvar;					\
     register long r3 asm ("%r3") = SYS_ify (name);		\
     SUBSTITUTE_ARGS_##nr(args);					\
 								\
-    asm volatile (SYSCALL_INST_STR##nr				\
+    asm volatile (SYSCALL_INST_STR##nr SYSCALL_INST_PAD		\
 		  : "=z" (resultvar)				\
 		  : "r" (r3) ASMFMT_##nr 			\
 		  : "memory");					\
 								\
-    if (resultvar >= 0xfffff001)			        \
-      {							        \
-	__set_errno (-resultvar);				\
-	resultvar = 0xffffffff;					\
-      }								\
     (int) resultvar; })
 
+#undef INTERNAL_SYSCALL_DECL
+#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
+
+#undef INTERNAL_SYSCALL_ERROR_P
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+  ((unsigned int) (val) >= 0xfffff001u)
+
+#undef INTERNAL_SYSCALL_ERRNO
+#define INTERNAL_SYSCALL_ERRNO(val, err)        (-(val))
+
 #endif	/* __ASSEMBLER__ */
 
 #endif /* linux/sh/sysdep.h */