This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
[PATCH] More ppc64 cancel handling fixes
- From: Steven Munroe <sjmunroe at us dot ibm dot com>
- To: libc-alpha at sources dot redhat dot com
- Date: Tue, 14 Jan 2003 15:51:11 -0600
- Subject: [PATCH] More ppc64 cancel handling fixes
- Organization: IBM Linux Developement
- Reply-to: sjmunroe at vnet dot ibm dot com
Following up on Franz Sirl's 01/12 update, modified sysdep.h macros to
add the ERR parameter and added vfork.S source to powerpc64.
This patch against glibc cvs head from 01/13 runs make without error and
only one failure on make check (tst-cancel-wrappers).
This failure (see attachement ppc64-tst-cancel-wrappers.out) seems odd
becuase it calls out functions (pread, pwrite, truncate, ftruncate, ...)
that seem to have the correct cancelation code. See attachment
pread-dump.txt.
So is this a test case problem, or is there something still missing from
the powerpc64 environment? What example what exactly is
tst-cancel-wrappers.sh looking for?
2003-01-14 Steven Munroe <sjmunroe@us.ibm.com>
* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
(INTERNAL_SYSCALL): Make use of ERR parameter.
(INTERNAL_SYSCALL_DECL, INTERNAL_SYSCALL_ERRNO,
INTERNAL_SYSCALL_ERROR_P): Adjust accordingly.
(INLINE_SYSCALL): Make use of INTERNAL_SYSCALL.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S: New file.
*
linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S:
New file.
--
Steven Munroe
sjmunroe@us.ibm.com
Linux on PowerPC-64 Development
GLIBC for PowerPC-64 Development
diff -rupPN libc23-cvstip-20030113/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S libc23/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S
--- libc23-cvstip-20030113/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S 1969-12-31 18:00:00.000000000 -0600
+++ libc23/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S 2003-01-14 08:42:44.000000000 -0600
@@ -0,0 +1,59 @@
+/* Copyright (C) 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
+ 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-cancel.h>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#include <kernel-features.h>
+
+/* Clone the calling process, but without copying the whole address space.
+ The calling process is suspended until the new process exits or is
+ replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
+ and the process ID of the new process to the old process. */
+
+ENTRY (__vfork)
+
+#ifdef __NR_vfork
+
+ SINGLE_THREAD_P
+ bne- HIDDEN_JUMPTARGET(__fork)
+
+ DO_CALL (SYS_ify (vfork));
+
+# ifdef __ASSUME_VFORK_SYSCALL
+ PSEUDO_RET
+# else
+ bnslr+
+ /* Check if vfork syscall is known at all. */
+ cmpdi r3,ENOSYS
+ bne JUMPTARGET(__syscall_error)
+
+# endif
+#endif
+
+#ifndef __ASSUME_VFORK_SYSCALL
+ /* If we don't have vfork, fork is close enough. */
+
+ DO_CALL (SYS_ify (fork));
+ PSEUDO_RET
+#endif
+
+PSEUDO_END (__vfork)
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
diff -rupPN libc23-cvstip-20030113/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h libc23/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
--- libc23-cvstip-20030113/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h 2003-01-12 02:21:28.000000000 -0600
+++ libc23/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h 2003-01-14 08:00:15.000000000 -0600
@@ -74,36 +74,14 @@
behave like function calls as far as register saving. */
#define INLINE_SYSCALL(name, nr, args...) \
({ \
- register long r0 __asm__ ("r0"); \
- register long r3 __asm__ ("r3"); \
- register long r4 __asm__ ("r4"); \
- register long r5 __asm__ ("r5"); \
- register long r6 __asm__ ("r6"); \
- register long r7 __asm__ ("r7"); \
- register long r8 __asm__ ("r8"); \
- long ret, err; \
- LOADARGS_##nr(name, args); \
- __asm __volatile ("sc\n\t" \
- "mfcr %7\n\t" \
- : "=r" (r0), "=r" (r3), "=r" (r4), \
- "=r" (r5), "=r" (r6), "=r" (r7), \
- "=r" (r8), "=r" (err) \
- : ASM_INPUT_##nr \
- : "r9", "r10", "r11", "r12", \
- "fr0", "fr1", "fr2", "fr3", \
- "fr4", "fr5", "fr6", "fr7", \
- "fr8", "fr9", "fr10", "fr11", \
- "fr12", "fr13", \
- "ctr", "lr", \
- "cr0", "cr1", "cr5", "cr6", "cr7", \
- "memory"); \
- ret = r3; \
- if (__builtin_expect ((err & (1 << 28)), 0)) \
- { \
- __set_errno (ret); \
- ret = -1L; \
- } \
- ret; \
+ INTERNAL_SYSCALL_DECL (sc_err); \
+ long sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args); \
+ if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \
+ { \
+ __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)); \
+ sc_ret = -1L; \
+ } \
+ sc_ret; \
})
/* Define a macro which expands inline into the wrapper code for a system
@@ -113,7 +91,7 @@
the negation of the return value in the kernel gets reverted. */
# undef INTERNAL_SYSCALL
-# define INTERNAL_SYSCALL(name, nr, args...) \
+# define INTERNAL_SYSCALL(name, err, nr, args...) \
({ \
register long r0 __asm__ ("r0"); \
register long r3 __asm__ ("r3"); \
@@ -125,8 +103,7 @@
LOADARGS_##nr(name, args); \
__asm__ __volatile__ \
("sc\n\t" \
- "bns+ 0f\n\t" \
- "neg %1,%1\n" \
+ "mfcr %0\n\t" \
"0:" \
: "=&r" (r0), \
"=&r" (r3), "=&r" (r4), "=&r" (r5), \
@@ -134,14 +111,19 @@
: ASM_INPUT_##nr \
: "r9", "r10", "r11", "r12", \
"cr0", "ctr", "memory"); \
- (int) r3; \
+ err = r0; \
+ (int) r3; \
})
+
+# undef INTERNAL_SYSCALL_DECL
+# define INTERNAL_SYSCALL_DECL(err) long err
# undef INTERNAL_SYSCALL_ERROR_P
-# define INTERNAL_SYSCALL_ERROR_P(val) ((unsigned long) (val) >= 0xfffffffffffff001u)
-
+# define INTERNAL_SYSCALL_ERROR_P(val, err) \
+ (__builtin_expect (err & (1 << 28), 0))
+
# undef INTERNAL_SYSCALL_ERRNO
-# define INTERNAL_SYSCALL_ERRNO(val) (-(val))
+# define INTERNAL_SYSCALL_ERRNO(val, err) (val)
#define LOADARGS_0(name, dummy) \
r0 = __NR_##name
diff -rupPN libc23-cvstip-20030113/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S libc23/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S
--- libc23-cvstip-20030113/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S 1969-12-31 18:00:00.000000000 -0600
+++ libc23/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S 2003-01-14 09:00:38.000000000 -0600
@@ -0,0 +1,56 @@
+/* Copyright (C) 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
+ 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>
+#define _ERRNO_H 1
+#include <bits/errno.h>
+#include <kernel-features.h>
+
+/* Clone the calling process, but without copying the whole address space.
+ The calling process is suspended until the new process exits or is
+ replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
+ and the process ID of the new process to the old process. */
+
+ENTRY (__vfork)
+
+#ifdef __NR_vfork
+
+ DO_CALL (SYS_ify (vfork))
+
+# ifdef __ASSUME_VFORK_SYSCALL
+ PSEUDO_RET
+# else
+ bnslr+
+ /* Check if vfork syscall is known at all. */
+ cmpdi r3,ENOSYS
+ bne JUMPTARGET(__syscall_error)
+
+# endif
+#endif
+
+#ifndef __ASSUME_VFORK_SYSCALL
+ /* If we don't have vfork, fork is close enough. */
+
+ DO_CALL (SYS_ify (fork))
+ PSEUDO_RET
+#endif
+
+PSEUDO_END (__vfork)
+libc_hidden_def (__vfork)
+
+weak_alias (__vfork, vfork)
in /home/sjmunroe/work/build-23//libc_pic.a(sigsuspend.os) sigsuspend's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(sigpause.os) sigpause's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(sigwaitinfo.os) sigwaitinfo's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(system.os) system's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(wait.os) wait's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(waitpid.os) waitpid's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(waitid.os) waitid's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(pause.os) pause's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(nanosleep.os) nanosleep's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(pread.os) pread's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(pwrite.os) pwrite's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(pread64.os) pread64's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(pwrite64.os) pwrite64's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(open.os) open's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(open64.os) open64's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(close.os) close's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(read.os) read's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(write.os) write's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(lseek.os) lseek's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(fcntl.os) fcntl's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(creat.os) creat's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(poll.os) poll's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(tcdrain.os) tcdrain's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(readv.os) readv's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(writev.os) writev's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(select.os) select's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(pselect.os) pselect's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(fsync.os) fsync's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(msync.os) msync's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(llseek.os) llseek's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(accept.os) accept's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(connect.os) connect's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(recv.os) recv's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(recvfrom.os) recvfrom's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(recvmsg.os) recvmsg's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(send.os) send's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(sendmsg.os) sendmsg's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(sendto.os) sendto's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(msgsnd.os) msgsnd's cancellation missing
in /home/sjmunroe/work/build-23//libc_pic.a(msgrcv.os) msgrcv's cancellation missing
./posix/pread.os: file format elf64-powerpc
./posix/pread.os
architecture: powerpc:common64, flags 0x00000011:
HAS_RELOC, HAS_SYMS
start address 0x0000000000000000
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 000000f8 0000000000000000 0000000000000000 00000040 2**2
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
1 .data 00000000 0000000000000000 0000000000000000 00000138 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 0000000000000000 0000000000000000 00000138 2**0
ALLOC
3 .debug_abbrev 000002b8 0000000000000000 0000000000000000 00000138 2**0
CONTENTS, READONLY, DEBUGGING
4 .debug_info 000042d7 0000000000000000 0000000000000000 000003f0 2**0
CONTENTS, RELOC, READONLY, DEBUGGING
5 .debug_line 000006e6 0000000000000000 0000000000000000 000046c7 2**0
CONTENTS, RELOC, READONLY, DEBUGGING
6 .toc 00000008 0000000000000000 0000000000000000 00004db0 2**3
CONTENTS, ALLOC, LOAD, RELOC, DATA
7 .opd 00000018 0000000000000000 0000000000000000 00004db8 2**3
CONTENTS, ALLOC, LOAD, RELOC, DATA
8 .debug_frame 00000040 0000000000000000 0000000000000000 00004dd0 2**3
CONTENTS, RELOC, READONLY, DEBUGGING
9 .debug_pubnames 00000023 0000000000000000 0000000000000000 00004e10 2**0
CONTENTS, RELOC, READONLY, DEBUGGING
10 .debug_aranges 00000030 0000000000000000 0000000000000000 00004e33 2**0
CONTENTS, RELOC, READONLY, DEBUGGING
11 .debug_ranges 00000080 0000000000000000 0000000000000000 00004e63 2**0
CONTENTS, READONLY, DEBUGGING
12 .debug_str 0000428b 0000000000000000 0000000000000000 00004ee3 2**0
CONTENTS, READONLY, DEBUGGING
13 .comment 00000028 0000000000000000 0000000000000000 0000916e 2**0
CONTENTS, READONLY
SYMBOL TABLE:
0000000000000000 l df *ABS* 0000000000000000 pread.c
0000000000000000 l d .text 0000000000000000
0000000000000000 l d .data 0000000000000000
0000000000000000 l d .bss 0000000000000000
0000000000000000 l d .debug_abbrev 0000000000000000
0000000000000000 l d .debug_info 0000000000000000
0000000000000000 l d .debug_line 0000000000000000
0000000000000000 l d .toc 0000000000000000
0000000000000000 l d .opd 0000000000000000
0000000000000000 l d .debug_frame 0000000000000000
0000000000000000 l d .debug_pubnames 0000000000000000
0000000000000000 l d .debug_aranges 0000000000000000
0000000000000000 l d .debug_ranges 0000000000000000
0000000000000000 l d .debug_str 0000000000000000
0000000000000000 l d .comment 0000000000000000
0000000000000000 *UND* 0000000000000000 __libc_multiple_threads
0000000000000000 g .opd 0000000000000018 __libc_pread
0000000000000000 g F .text 00000000000000f8 .__libc_pread
0000000000000000 *UND* 0000000000000000 .__GI___errno_location
0000000000000000 *UND* 0000000000000000 .__libc_enable_asynccancel
0000000000000000 *UND* 0000000000000000 .__libc_disable_asynccancel
0000000000000000 g .opd 0000000000000018 __pread
0000000000000000 g F .text 00000000000000f8 .__pread
0000000000000000 w .opd 0000000000000018 pread
0000000000000000 w F .text 00000000000000f8 .pread
Disassembly of section .text:
0000000000000000 <.__libc_pread>:
int fd;
void *buf;
size_t count;
off_t offset;
{
0: 7c 08 02 a6 mflr r0
ssize_t result;
if (SINGLE_THREAD_P)
4: e9 62 00 00 ld r11,0(r2)
6: R_PPC64_TOC16_DS .toc
8: f8 01 00 10 std r0,16(r1)
c: 38 00 00 b3 li r0,179
10: fb 81 ff e0 std r28,-32(r1)
14: 7c 7c 1b 78 mr r28,r3
18: fb a1 ff e8 std r29,-24(r1)
1c: 7c dd 33 78 mr r29,r6
20: fb c1 ff f0 std r30,-16(r1)
24: 7c be 2b 78 mr r30,r5
28: fb e1 ff f8 std r31,-8(r1)
2c: 7c 9f 23 78 mr r31,r4
30: fb 61 ff d8 std r27,-40(r1)
34: f8 21 ff 61 stdu r1,-160(r1)
38: 81 2b 00 00 lwz r9,0(r11)
3c: 2c 09 00 00 cmpwi r9,0
40: 40 82 00 54 bne- 94 <.__libc_pread+0x94>
{
result = INLINE_SYSCALL (pread, 4, fd, CHECK_N (buf, count), count,
offset);
44: 44 00 00 02 sc
48: 7f a0 00 26 mfcr r29
4c: 7b a0 27 e3 rldicl. r0,r29,36,63
50: 7c 7d 1b 78 mr r29,r3
54: 40 82 00 2c bne- 80 <.__libc_pread+0x80>
# if __ASSUME_PREAD_SYSCALL == 0
if (result == -1 && errno == ENOSYS)
/* No system call available. Use the emulation. */
result = __emulate_pread (fd, buf, count, offset);
# endif
return result;
}
int oldtype = LIBC_CANCEL_ASYNC ();
result = INLINE_SYSCALL (pread, 4, fd, CHECK_N (buf, count), count,
offset);
# if __ASSUME_PREAD_SYSCALL == 0
if (result == -1 && errno == ENOSYS)
/* No system call available. Use the emulation. */
result = __emulate_pread (fd, buf, count, offset);
# endif
LIBC_CANCEL_RESET (oldtype);
return result;
}
58: 38 21 00 a0 addi r1,r1,160
5c: e8 01 00 10 ld r0,16(r1)
60: 7f a3 eb 78 mr r3,r29
64: eb 61 ff d8 ld r27,-40(r1)
68: 7c 08 03 a6 mtlr r0
6c: eb 81 ff e0 ld r28,-32(r1)
70: eb a1 ff e8 ld r29,-24(r1)
74: eb c1 ff f0 ld r30,-16(r1)
78: eb e1 ff f8 ld r31,-8(r1)
7c: 4e 80 00 20 blr
80: 48 00 00 01 bl 80 <.__libc_pread+0x80>
80: R_PPC64_REL24 .__GI___errno_location
84: 60 00 00 00 nop
88: 93 a3 00 00 stw r29,0(r3)
8c: 3b a0 ff ff li r29,-1
90: 4b ff ff c8 b 58 <.__libc_pread+0x58>
94: 48 00 00 01 bl 94 <.__libc_pread+0x94>
94: R_PPC64_REL24 .__libc_enable_asynccancel
98: 60 00 00 00 nop
9c: 7f a6 eb 78 mr r6,r29
a0: 7c 7b 1b 78 mr r27,r3
a4: 38 00 00 b3 li r0,179
a8: 7f 83 e3 78 mr r3,r28
ac: 7f e4 fb 78 mr r4,r31
b0: 7f c5 f3 78 mr r5,r30
b4: 44 00 00 02 sc
b8: 7f a0 00 26 mfcr r29
bc: 7b a0 27 e3 rldicl. r0,r29,36,63
c0: 7c 7d 1b 78 mr r29,r3
c4: 40 82 00 14 bne- d8 <.__libc_pread+0xd8>
c8: 7f 63 db 78 mr r3,r27
cc: 48 00 00 01 bl cc <.__libc_pread+0xcc>
cc: R_PPC64_REL24 .__libc_disable_asynccancel
d0: 60 00 00 00 nop
d4: 4b ff ff 84 b 58 <.__libc_pread+0x58>
d8: 48 00 00 01 bl d8 <.__libc_pread+0xd8>
d8: R_PPC64_REL24 .__GI___errno_location
dc: 60 00 00 00 nop
e0: 93 a3 00 00 stw r29,0(r3)
e4: 3b a0 ff ff li r29,-1
e8: 4b ff ff e0 b c8 <.__libc_pread+0xc8>
ec: 00 00 00 00 .long 0x0
f0: 00 00 00 01 .long 0x1
f4: 80 05 00 00 lwz r0,0(r5)