+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.
+
2003-02-07 Jakub Jelinek <jakub@redhat.com>
* resolv/res_libc.c (_res): Ensure _res is not common symbol,
/* 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
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));
# 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; \
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"
#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)
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 */