[PATCH] cancellation support for linux-mips
Guido Guenther
agx@sigxcpu.org
Mon Jan 20 04:57:00 GMT 2003
Hi,
attached is a first version of cancelation support for linux mips. glibc
passes make check with one additional error:
make[2]: *** [/var/scratch/glibc/linuxthreads/tst-cancel-wrappers.out] Error 1
in /var/scratch/glibc//libc_pic.a(pread.os) pread's cancellation missing
in /var/scratch/glibc//libc_pic.a(pwrite.os) pwrite's cancellation missing
in /var/scratch/glibc//libc_pic.a(pread64.os) pread64's cancellation missing
in /var/scratch/glibc//libc_pic.a(pwrite64.os) pwrite64's cancellation missing
...but I think this is to be expected since I didn't bother to change
these s/u/s/l/mips/p{read,write}{,64}.c files yet.
I had to remove the setting of the global errno in
sysdeps/unix/mips/sysdep.S for the _LIBC_REENTRANT case in order to
avoid an undefined reference - this doesn't seem to cause any visible
problems for linux-mips but I'm not sure about other mips ports (is this
o.k. to do? Shall I better move a copy of this file to
sysdeps/unix/sysv/linux/mips?). Comments welcome.
-- Guido
-------------- next part --------------
--- /dev/null Sat Mar 16 18:32:44 2002
+++ linuxthreads/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h Sun Jan 19 17:12:45 2003
@@ -0,0 +1,135 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Guido Guenther <agx@sigxcpu.org>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+#ifndef __ASSEMBLER__
+# include <linuxthreads/internals.h>
+#endif
+
+#if !defined NOT_IN_libc || defined IS_IN_libpthread
+
+#ifdef __PIC__
+# undef PSEUDO
+# define PSEUDO(name, syscall_name, args) \
+ .align 2; \
+ 99: la t9,__syscall_error; \
+ jr t9; \
+ ENTRY (name) \
+ .set noreorder; \
+ .cpload t9; \
+ .set reorder; \
+ SINGLE_THREAD_P(t0); \
+ bne zero, t0, Lpseudo_cancel; \
+ .set noreorder; \
+ li v0, SYS_ify(syscall_name); \
+ syscall; \
+ .set reorder; \
+ bne a3, zero, SYSCALL_ERROR_LABEL; \
+ ret; \
+ Lpseudo_cancel: \
+ SAVESTK; \
+ sw ra, 28(sp); \
+ sw gp, 32(sp); \
+ PUSHARGS_##args; /* save syscall args */ \
+ CENABLE; \
+ lw gp, 32(sp); \
+ sw v0, 44(sp); /* save mask */ \
+ POPARGS_##args; /* restore syscall args */ \
+ .set noreorder; \
+ li v0, SYS_ify (syscall_name); \
+ syscall; \
+ .set reorder; \
+ sw v0, 36(sp); /* save syscall result */ \
+ sw a3, 40(sp); /* save syscall error flag */ \
+ lw a0, 44(sp); /* pass mask as arg0 */ \
+ CDISABLE; \
+ lw gp, 32(sp); \
+ lw v0, 36(sp); /* restore syscall result */ \
+ lw a3, 40(sp); /* restore syscall error flag */ \
+ lw ra, 28(sp); /* restore return address */ \
+ RESTORESTK; \
+ bne a3, zero, SYSCALL_ERROR_LABEL; \
+ Lpseudo_end:
+#endif
+
+/* -------- sp_old
+44 _ mask _
+40 _ a3_s _
+36 _ v0_s _
+32 _ gp _
+28 _ ra _
+24 _ arg6 _
+20 _ arg5 _
+16 _ arg4 _
+12 _ arg3 _
+ 8 _ arg2 _
+ 4 _ arg1 _
+ 0 _ arg0 _
+ -------- sp */
+
+# define PUSHARGS_0 /* nothing to do */
+# define PUSHARGS_1 PUSHARGS_0 sw a0, 0(sp);
+# define PUSHARGS_2 PUSHARGS_1 sw a1, 4(sp);
+# define PUSHARGS_3 PUSHARGS_2 sw a2, 8(sp);
+# define PUSHARGS_4 PUSHARGS_3 sw a3, 12(sp);
+# define PUSHARGS_5 PUSHARGS_4 lw t0, 64(sp); sw t0, 16(sp);
+# define PUSHARGS_6 PUSHARGS_5 lw t1, 68(sp); sw t1, 20(sp);
+# define PUSHARGS_7 PUSHARGS_6 lw t2, 72(sp); sw,t2, 24(sp);
+
+# define POPARGS_0 /* nothing to do */
+# define POPARGS_1 POPARGS_0 lw a0, 0(sp);
+# define POPARGS_2 POPARGS_1 lw a1, 4(sp);
+# define POPARGS_3 POPARGS_2 lw a2, 8(sp);
+# define POPARGS_4 POPARGS_3 lw a3, 12(sp);
+# define POPARGS_5 POPARGS_4 /* args already in new stackframe */
+# define POPARGS_6 POPARGS_5
+# define POPARGS_7 POPARGS_6
+
+# define SAVESTK subu sp, 48
+# define RESTORESTK addu sp, 48
+
+# ifdef IS_IN_libpthread
+# define CENABLE la t9, __pthread_enable_asynccancel; jalr t9;
+# define CDISABLE la t9, __pthread_disable_asynccancel; jalr t9;
+# define __local_multiple_threads __pthread_multiple_threads
+# else
+# define CENABLE la t9, __libc_enable_asynccancel; jalr t9;
+# define CDISABLE la t9, __libc_disable_asynccancel; jalr t9;
+# define __local_multiple_threads __libc_multiple_threads
+# endif
+
+# if !defined NOT_IN_libc
+# define __local_multiple_threads __libc_multiple_threads
+# else
+# define __local_multiple_threads __pthread_multiple_threads
+# endif
+
+# ifndef __ASSEMBLER__
+extern int __local_multiple_threads attribute_hidden;
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
+# else
+# define SINGLE_THREAD_P(reg) lw reg, __local_multiple_threads
+#endif
+
+#elif !defined __ASSEMBLER__
+
+/* This code should never be used but we define it anyhow. */
+# define SINGLE_THREAD_P (1)
+
+#endif
--- /dev/null Sat Mar 16 18:32:44 2002
+++ linuxthreads/sysdeps/unix/sysv/linux/mips/Makefile Thu Jan 9 16:12:16 2003
@@ -0,0 +1,2 @@
+# pull in __syscall_error routine
+libpthread-routines += sysdep
Index: sysdeps/unix/mips/sysdep.S
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/mips/sysdep.S,v
retrieving revision 1.12
diff -u -u -r1.12 sysdep.S
--- sysdeps/unix/mips/sysdep.S 6 Jul 2001 04:56:11 -0000 1.12
+++ sysdeps/unix/mips/sysdep.S 20 Jan 2003 01:01:27 -0000
@@ -51,9 +56,6 @@
li v0, EAGAIN
skip:
#endif
- /* Store it in the "real" variable ... */
- sw v0, errno
-
/* Find our per-thread errno address */
jal __errno_location
Index: sysdeps/unix/sysv/linux/mips/sysdep.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/mips/sysdep.h,v
retrieving revision 1.3
diff -u -r1.3 sysdep.h
--- sysdeps/unix/sysv/linux/mips/sysdep.h 15 Jan 2003 01:02:03 -0000 1.3
+++ sysdeps/unix/sysv/linux/mips/sysdep.h 20 Jan 2003 01:19:54 -0000
@@ -33,7 +33,15 @@
# define SYS_ify(syscall_name) __NR_/**/syscall_name
#endif
-#ifndef __ASSEMBLER__
+#ifdef __ASSEMBLER__
+
+/* We don't want the label for the error handler to be visible in the symbol
+ table when we define it here. */
+#ifdef __PIC__
+# define SYSCALL_ERROR_LABEL 99b
+#endif
+
+#else /* ! __ASSEMBLER__ */
/* Define a macro which expands into the inline wrapper code for a system
call. */
@@ -269,6 +277,6 @@
#define __SYSCALL_CLOBBERS "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", "$25"
-#endif /* __ASSEMBLER__ */
+#endif /* ! __ASSEMBLER__ */
#endif /* linux/mips/sysdep.h */
More information about the Libc-alpha
mailing list