diff --git a/ChangeLog b/ChangeLog index 27967ba45d..f89080d2a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2003-01-05 Kaz Kojima + + * 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. + 2003-01-04 Franz Sirl * sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list: Mark diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog index 018667e550..910cb1953a 100644 --- a/linuxthreads/ChangeLog +++ b/linuxthreads/ChangeLog @@ -1,3 +1,7 @@ +2003-01-05 Ulrich Drepper + + * Makefile (libc.so-no-z-defs): Define to yes. + 2003-01-05 Kaz Kojima * sysdeps/sh/tls.h: Include dl-sysdep.h and stdint.h. diff --git a/linuxthreads/Makefile b/linuxthreads/Makefile index ff26e06eea..ef34cda0c3 100644 --- a/linuxthreads/Makefile +++ b/linuxthreads/Makefile @@ -171,6 +171,9 @@ $(objpfx)libc_pic_lite.os: $(objpfx)libc_pic_lite.a $(objpfx)libc-tsd.os $(LINK.o) -nostdlib -nostartfiles -r -o $@ \ $(LDFLAGS-c_pic.os) -Wl,-d -Wl,--whole-archive $^ +# This trick leaves errno and h_errno undefined. +libc.so-no-z-defs = yes + $(objpfx)libc.so: $(elfobjdir)/soinit.os \ $(objpfx)libc_pic_lite.os \ $(elfobjdir)/sofini.os \ diff --git a/nptl/ChangeLog b/nptl/ChangeLog index fcc832f251..8faa0a93aa 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,7 +1,50 @@ +2003-01-05 Ulrich Drepper + + * sysdeps/unix/sysv/linux/jmp-unwind.c: Include . + Use __libc_pthread_functions array if SHARED. + + * pthreadP.h: Move pthread_cond_2_0_t definition to... + * sysdeps/unix/sysv/linux/internaltypes.h: ...here. + + * sysdeps/pthread/bits/libc-lock.h (__libc_ptf_call): New #define. + (__libc_rwlock_rdlock, __libc_rwlock_wrlock, __libc_rwlock_unlock, + __libc_key_create, __libc_getspecific, __libc_setspecific): Use + __libc_ptf_call instead of __libc_maybe_call. + (PTF): New #define. + (__libc_cleanup_region_start): Wrap function name with PTF call. + (__libc_cleanup_region_end): Likewise. + (__libc_cleanup_end): Likewise. + + * pthread_getspecific.c: Add __pthread_getspecific_internal alias. + * pthread_setspecific.c: Add __pthread_setspecific_internal alias. + * pthread_key_create.c: Add __pthread_key_create_internal alias. + * pthreadP.h: Add prototypes. + + * sysdeps/unix/sysv/linux/i386/i486/lowlevelrwlock.S: Add + __pthread_rwlock_rdlock, __pthread_rwlock_wrlock, and + __pthread_rwlock_unlock aliases. + * pthreadP.h: Add prototypes for new aliases. + + * pthreadP.h (struct pthead_functions): Moved to... + * sysdeps/pthread/pthread-functions.h: ...here. New file. + * init.c (pthread_functions): Add initializers for new elements. + + * cleanup_defer.c: Add __pthread_cleanup_push_defer and + __pthread_cleanup_pop_restore aliases. + * pthreadP.h: Add prototypes. + + * cleanup.c: Rename _GI_pthread_cleanup_push to __pthread_cleanup_push + and _GI_pthread_cleanup_pop to __pthread_cleanup_pop. + * sysdeps/unix/sysv/linux/i386/i486/lowlevelcond.S: Adjust caller. + * sysdeps/unix/sysv/linux/i386/pthread_once.S: Likewise. + * sysdeps/unix/sysv/linux/x86_64/pthread_once.S: Likewise. + * pthreadP.h: Adjust prototypes and callers. + 2003-01-04 Ulrich Drepper * Makefile (tests): Add tst-cancel7. (tst-cancel7-ARGS): New variable. + * tst-cancel7.c: New file. * old_pthread_cond_broadcast.c: Optimize initialization a bit to work around gcc defficiencies. 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 +#include #include +#include #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, , August 1995. Changed by Kaz Kojima, . @@ -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