diff options
author | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2008-05-07 11:51:22 +0000 |
---|---|---|
committer | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2008-05-07 11:51:22 +0000 |
commit | 4645ce7777608cbdb69b3a2ece528eef92df9a1f (patch) | |
tree | 8091b089548712c236439946574c452045db4b01 | |
parent | 3d796b573fb179ae51f6560e2180a79b2955a678 (diff) | |
download | eglibc2-4645ce7777608cbdb69b3a2ece528eef92df9a1f.tar.gz |
Merge changes between r6018 and r6123 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@6124 7b3dc134-2b1b-0410-93df-9e9f96275f8d
24 files changed, 748 insertions, 29 deletions
diff --git a/libc/ChangeLog b/libc/ChangeLog index 6355676a5..cbeb1596c 100644 --- a/libc/ChangeLog +++ b/libc/ChangeLog @@ -1,3 +1,73 @@ +2008-05-05 David S. Miller <davem@davemloft.net> + + * sysdeps/sparc/sparc32/Makefile: Use -mcpu=v7 for initfini.s build. + * sysdeps/sparc/sparc64/Makefile: Use -mcpu=v9 for initfini.s build. + +2007-09-14 Samuel Thibault <samuel.thibault@ens-lyon.org> + + Fix termios bit macros. + Move *DLY definitions where they belong, in termios.h. + Add *[0-3] definitions. + Fixes confusion between VT and FF. + * sysdeps/mach/hurd/bits/ioctls.h (NL0, NL1, TAB0, TAB1, TAB2, CR0, + CR1, CR2, CR3, FF0, FF1, BS0, BS1): Undefine these at start if they + are already defined to avoid collision with termios.h. + (NLDLY, TABDLY, TAB3, CRDLY, VTDLY, BSDLY): Remove macros. + * bits/termios.h [__USE_MISC || __USE_XOPEN] (NL0, NL1, TAB0, + TAB1, TAB2, CR0, CR1, CR2, CR3, FF0, FF1, BS0, BS1): Likewise. + [__USE_BSD || __USE_XOPEN] (OCRNL, ONOCR, ONLRET): New macros. + [__USE_MISC || __USE_XOPEN] (NLDLY, NL0, NL1, TABDLY, TAB0, TAB1, TAB2, + TAB3, CRDLY, CR0, CR1, CR2, CR3, FFDLY, FF0, FF1, BSDLY, BS0, BS1, + VTDLY, VT0, VT1): New macros. + [__USE_GNU] (OLCUC): Change value of macro. + [__USE_XOPEN] (OFILL): New macro. + [__USE_BSD] (CRTSCTS): Change value. + (CRTS_IFLOW, CCTS_OFLOW): Change into compatibility macros. + [__USE_BSD] (CDTRCTS, CHWFLOW): New macros. + (B7200, B14400, B28800, B76800): New macros. + +2008-05-01 David S. Miller <davem@davemloft.net> + + * sysdeps/unix/sysv/linux/sparc/sparc32/ucontext_i.sym: New file. + * sysdeps/unix/sysv/linux/sparc/sparc32/Makefile [$(subdir) = stdlib]: + (gen-as-const-headers): Add it. + * sysdeps/unix/sysv/linux/sparc/sparc32/getcontext.S: New file. + * sysdeps/unix/sysv/linux/sparc/sparc32/makecontext.c: Likewise. + * sysdeps/unix/sysv/linux/sparc/sparc32/setcontext.S: Likewise. + * sysdeps/unix/sysv/linux/sparc/sparc32/swapcontext.S: Likewise. + + * sysdeps/unix/sysv/linux/sparc/sparc32/syscall.S: Add support for + six system call parameters. + * sysdeps/unix/sysv/linux/sparc/sparc64/syscall.S: Likewise. + +2008-04-30 Ulrich Drepper <drepper@redhat.com> + + * sysdeps/unix/sysv/linux/bits/resource.h: Define RUSAGE_THREAD and + RUSAGE_LWP. + * sysdeps/unix/sysv/linux/sparc/bits/resource.h: Likewise. + * sysdeps/unix/sysv/linux/alpha/bits/resource.h: Likewise. + +2008-04-30 Jakub Jelinek <jakub@redhat.com> + + * stdlib/tst-setcontext.c: Include unistd.h. + +2008-04-25 David S. Miller <davem@davemloft.net> + + * sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c (semctl): + Pass "union semun" properly in to sys_ipc, it must be passed + by value, not by reference. + +2008-04-22 Jakub Jelinek <jakub@redhat.com> + + * nscd/Makefile (nscd-cflags): Set back to -fpie. + * nscd/nscd.h (mem_in_flight): Add attribute_tls_model_ie. + * nscd/connections.c (mem_in_flight): Likewise. + + * nscd/nscd.h (dbs): Make hidden. + + * sysdeps/unix/sysv/linux/times.c (__times): Fix check for EFAULT. + Avoid returning -1, return 0 instead. + 2008-04-19 Ulrich Drepper <drepper@redhat.com> * resolv/res_mkquery.c (__res_nopt): Use NS_PUT16 instead of ns_put16. diff --git a/libc/bits/termios.h b/libc/bits/termios.h index 43bb1ce52..4dc0fab91 100644 --- a/libc/bits/termios.h +++ b/libc/bits/termios.h @@ -24,6 +24,50 @@ /* These macros are also defined in some <bits/ioctls.h> files (with numerically identical values), but this serves to shut up cpp's complaining. */ +#if defined __USE_MISC || defined __USE_XOPEN + +# ifdef NL0 +# undef NL0 +# endif +# ifdef NL1 +# undef NL1 +# endif +# ifdef TAB0 +# undef TAB0 +# endif +# ifdef TAB1 +# undef TAB1 +# endif +# ifdef TAB2 +# undef TAB2 +# endif +# ifdef CR0 +# undef CR0 +# endif +# ifdef CR1 +# undef CR1 +# endif +# ifdef CR2 +# undef CR2 +# endif +# ifdef CR3 +# undef CR3 +# endif +# ifdef FF0 +# undef FF0 +# endif +# ifdef FF1 +# undef FF1 +# endif +# ifdef BS0 +# undef BS0 +# endif +# ifdef BS1 +# undef BS1 +# endif + +#endif /* __USE_MISC || __USE_XOPEN */ + #ifdef __USE_BSD # ifdef MDMBUF @@ -93,11 +137,43 @@ struct termios #define OPOST (1 << 0) /* Perform output processing. */ #ifdef __USE_BSD # define ONLCR (1 << 1) /* Map NL to CR-NL on output. */ -# define OXTABS (1 << 2) /* Expand tabs to spaces. */ +# define OXTABS TAB3 /* Expand tabs to spaces. */ # define ONOEOT (1 << 3) /* Discard EOT (^D) on output. */ #endif +#if defined __USE_BSD || defined __USE_XOPEN +# define OCRNL (1 << 4) /* Map CR to NL. */ +# define ONOCR (1 << 5) /* Discard CR's when on column 0. */ +# define ONLRET (1 << 6) /* Move to column 0 on NL. */ +#endif +#if defined __USE_MISC || defined __USE_XOPEN +# define NLDLY (3 << 8) /* NL delay. */ +# define NL0 (0 << 8) /* NL type 0. */ +# define NL1 (1 << 8) /* NL type 1. */ +# define TABDLY (3 << 10) /* TAB delay. */ +# define TAB0 (0 << 10) /* TAB delay type 0. */ +# define TAB1 (1 << 10) /* TAB delay type 1. */ +# define TAB2 (2 << 10) /* TAB delay type 2. */ +# define TAB3 (1 << 2) /* Expand tabs to spaces. */ +# define CRDLY (3 << 12) /* CR delay. */ +# define CR0 (0 << 12) /* CR delay type 0. */ +# define CR1 (1 << 12) /* CR delay type 1. */ +# define CR2 (2 << 12) /* CR delay type 2. */ +# define CR3 (3 << 12) /* CR delay type 3. */ +# define FFDLY (1 << 14) /* FF delay. */ +# define FF0 (0 << 14) /* FF delay type 0. */ +# define FF1 (1 << 14) /* FF delay type 1. */ +# define BSDLY (1 << 15) /* BS delay. */ +# define BS0 (0 << 15) /* BS delay type 0. */ +# define BS1 (1 << 15) /* BS delay type 1. */ +# define VTDLY (1 << 16) /* VT delay. */ +# define VT0 (0 << 16) /* VT delay type 0. */ +# define VT1 (1 << 16) /* VT delay type 1. */ +#endif /* __USE_MISC || __USE_XOPEN */ #ifdef __USE_GNU -# define OLCUC (1 << 9) /* Translate lower case output to upper case */ +# define OLCUC (1 << 17) /* Translate lower case output to upper case */ +#endif +#ifdef __USE_XOPEN +# define OFILL (1 << 18) /* Send fill characters for delays. */ #endif /* Control modes. */ @@ -117,10 +193,12 @@ struct termios #define HUPCL (1 << 14) /* Hang up on last close. */ #define CLOCAL (1 << 15) /* Ignore modem status lines. */ #ifdef __USE_BSD -# define CCTS_OFLOW (1 << 16) /* CTS flow control of output. */ -# define CRTS_IFLOW (1 << 17) /* RTS flow control of input. */ -# define CRTSCTS (CCTS_OFLOW|CRTS_IFLOW) /* CTS/RTS flow control. */ -# define MDMBUF (1 << 20) /* Carrier flow control of output. */ +# define CRTSCTS (1 << 16) /* RTS/CTS flow control. */ +# define CRTS_IFLOW CRTSCTS /* Compatibility. */ +# define CCTS_OFLOW CRTSCTS /* Compatibility. */ +# define CDTRCTS (1 << 17) /* DTR/CTS flow control. */ +# define MDMBUF (1 << 20) /* DTR/DCD flow control. */ +# define CHWFLOW (MDMBUF|CRTSCTS|CDTRCTS) /* All types of flow control. */ #endif /* Local modes. */ @@ -210,13 +288,17 @@ struct termios #define B2400 2400 /* 2400 baud. */ #define B4800 4800 /* 4800 baud. */ #define B9600 9600 /* 9600 baud. */ +#define B7200 7200 /* 7200 baud. */ +#define B14400 14400 /* 14400 baud. */ #define B19200 19200 /* 19200 baud. */ +#define B28800 28800 /* 28800 baud. */ #define B38400 38400 /* 38400 baud. */ #ifdef __USE_MISC # define EXTA 19200 # define EXTB 38400 #endif #define B57600 57600 +#define B76800 76800 #define B115200 115200 #define B230400 230400 #define B460800 460800 diff --git a/libc/nscd/Makefile b/libc/nscd/Makefile index 9cbcfcc00..a0d07d4f5 100644 --- a/libc/nscd/Makefile +++ b/libc/nscd/Makefile @@ -98,8 +98,7 @@ CFLAGS-nscd_initgroups.c = -fexceptions nscd-cflags = -DIS_IN_nscd=1 -D_FORTIFY_SOURCE=2 ifeq (yesyes,$(have-fpie)$(build-shared)) -#nscd-cflags += -fpie -nscd-cflags += -fpic +nscd-cflags += -fpie endif ifeq (yes,$(have-ssp)) nscd-cflags += -fstack-protector diff --git a/libc/nscd/connections.c b/libc/nscd/connections.c index 64c82cb89..15148bdf3 100644 --- a/libc/nscd/connections.c +++ b/libc/nscd/connections.c @@ -226,7 +226,7 @@ static int sock; unsigned long int client_queued; /* Data structure for recording in-flight memory allocation. */ -__thread struct mem_in_flight mem_in_flight; +__thread struct mem_in_flight mem_in_flight attribute_tls_model_ie; /* Global list of the mem_in_flight variables of all the threads. */ struct mem_in_flight *mem_in_flight_list; diff --git a/libc/nscd/nscd.h b/libc/nscd/nscd.h index cbea8e1a9..66813e748 100644 --- a/libc/nscd/nscd.h +++ b/libc/nscd/nscd.h @@ -130,7 +130,7 @@ struct database_dyn /* Global variables. */ -extern struct database_dyn dbs[lastdb]; +extern struct database_dyn dbs[lastdb] attribute_hidden; extern const char *const dbnames[lastdb]; extern const char *const serv2str[LASTREQ]; @@ -201,7 +201,7 @@ extern __thread struct mem_in_flight } block[IDX_last]; struct mem_in_flight *next; -} mem_in_flight; +} mem_in_flight attribute_tls_model_ie; /* Global list of the mem_in_flight variables of all the threads. */ extern struct mem_in_flight *mem_in_flight_list; diff --git a/libc/stdlib/tst-setcontext.c b/libc/stdlib/tst-setcontext.c index 28bf23026..beec23a68 100644 --- a/libc/stdlib/tst-setcontext.c +++ b/libc/stdlib/tst-setcontext.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001,2002,2004,2006 Free Software Foundation, Inc. +/* Copyright (C) 2001,2002,2004,2006,2007,2008 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 @@ -21,6 +21,7 @@ #include <stdlib.h> #include <string.h> #include <ucontext.h> +#include <unistd.h> static ucontext_t ctx[3]; diff --git a/libc/sysdeps/mach/hurd/bits/ioctls.h b/libc/sysdeps/mach/hurd/bits/ioctls.h index c9d313519..8718aacd8 100644 --- a/libc/sysdeps/mach/hurd/bits/ioctls.h +++ b/libc/sysdeps/mach/hurd/bits/ioctls.h @@ -25,6 +25,46 @@ /* These macros are also defined in <bits/termios.h> (with numerically identical values) but this serves to shut up cpp's complaining. */ + +#ifdef NL0 +# undef NL0 +#endif +#ifdef NL1 +# undef NL1 +#endif +#ifdef TAB0 +# undef TAB0 +#endif +#ifdef TAB1 +# undef TAB1 +#endif +#ifdef TAB2 +# undef TAB2 +#endif +#ifdef CR0 +# undef CR0 +#endif +#ifdef CR1 +# undef CR1 +#endif +#ifdef CR2 +# undef CR2 +#endif +#ifdef CR3 +# undef CR3 +#endif +#ifdef FF0 +# undef FF0 +#endif +#ifdef FF1 +# undef FF1 +#endif +#ifdef BS0 +# undef BS0 +#endif +#ifdef BS1 +# undef BS1 +#endif #ifdef MDMBUF # undef MDMBUF #endif @@ -284,31 +324,25 @@ enum __ioctl_datum { IOC_8, IOC_16, IOC_32, IOC_64 }; #define ODDP 0x00000040 /* get/send odd parity */ #define EVENP 0x00000080 /* get/send even parity */ #define ANYP 0x000000c0 /* get any parity/send none */ -#define NLDLY 0x00000300 /* \n delay */ -#define NLDELAY NLDLY /* traditional BSD name */ +#define NLDELAY 0x00000300 /* \n delay */ #define NL0 0x00000000 #define NL1 0x00000100 /* tty 37 */ #define NL2 0x00000200 /* vt05 */ #define NL3 0x00000300 -#define TABDLY 0x00000c00 /* horizontal tab delay */ -#define TBDELAY TABDLY /* traditional BSD name */ +#define TBDELAY 0x00000c00 /* horizontal tab delay */ #define TAB0 0x00000000 #define TAB1 0x00000400 /* tty 37 */ #define TAB2 0x00000800 -#define TAB3 0x00000c00 #define XTABS 0x00000c00 /* expand tabs on output */ -#define CRDLY 0x00003000 /* \r delay */ -#define CRDELAY CRDLY /* traditional BSD name */ +#define CRDELAY 0x00003000 /* \r delay */ #define CR0 0x00000000 #define CR1 0x00001000 /* tn 300 */ #define CR2 0x00002000 /* tty 37 */ #define CR3 0x00003000 /* concept 100 */ -#define VTDLY 0x00004000 /* vertical tab delay */ -#define VTDELAY VTDLY /* traditional BSD name */ +#define VTDELAY 0x00004000 /* vertical tab delay */ #define FF0 0x00000000 #define FF1 0x00004000 /* tty 37 */ -#define BSDLY 0x00008000 /* \b delay */ -#define BSDELAY BSDLY /* traditional BSD name */ +#define BSDELAY 0x00008000 /* \b delay */ #define BS0 0x00000000 #define BS1 0x00008000 #define ALLDELAY (NLDELAY|TBDELAY|CRDELAY|VTDELAY|BSDELAY) diff --git a/libc/sysdeps/sparc/sparc32/Makefile b/libc/sysdeps/sparc/sparc32/Makefile index ed4fba741..6529ad897 100644 --- a/libc/sysdeps/sparc/sparc32/Makefile +++ b/libc/sysdeps/sparc/sparc32/Makefile @@ -20,6 +20,10 @@ ifeq ($(subdir),gnulib) sysdep_routines = dotmul umul $(divrem) alloca endif # gnulib +ifeq ($(subdir),csu) +CFLAGS-initfini.s += -mcpu=v7 +endif + # We distribute these files, even though they are generated, # so as to avoid the need for a functioning m4 to build the library. divrem := sdiv udiv rem urem diff --git a/libc/sysdeps/sparc/sparc64/Makefile b/libc/sysdeps/sparc/sparc64/Makefile index c1df31727..3bb023883 100644 --- a/libc/sysdeps/sparc/sparc64/Makefile +++ b/libc/sysdeps/sparc/sparc64/Makefile @@ -2,3 +2,7 @@ ifeq ($(subdir),csu) sysdep_routines += hp-timing elide-routines.os += hp-timing endif + +ifeq ($(subdir),csu) +CFLAGS-initfini.s += -mcpu=v9 +endif diff --git a/libc/sysdeps/unix/sysv/linux/alpha/bits/resource.h b/libc/sysdeps/unix/sysv/linux/alpha/bits/resource.h index 216374584..92d0199dc 100644 --- a/libc/sysdeps/unix/sysv/linux/alpha/bits/resource.h +++ b/libc/sysdeps/unix/sysv/linux/alpha/bits/resource.h @@ -158,8 +158,16 @@ enum __rusage_who #define RUSAGE_SELF RUSAGE_SELF /* All of its terminated child processes. */ - RUSAGE_CHILDREN = -1 + RUSAGE_CHILDREN = -1, #define RUSAGE_CHILDREN RUSAGE_CHILDREN + +#ifdef __USE_GNU + /* The calling thread. */ + RUSAGE_THREAD = 1 +# define RUSAGE_THREAD RUSAGE_THREAD + /* Name for the same functionality on Solaris. */ +# define RUSAGE_LWP RUSAGE_THREAD +#endif }; #define __need_timeval diff --git a/libc/sysdeps/unix/sysv/linux/bits/resource.h b/libc/sysdeps/unix/sysv/linux/bits/resource.h index 526cdaf53..95d64ed77 100644 --- a/libc/sysdeps/unix/sysv/linux/bits/resource.h +++ b/libc/sysdeps/unix/sysv/linux/bits/resource.h @@ -158,8 +158,16 @@ enum __rusage_who #define RUSAGE_SELF RUSAGE_SELF /* All of its terminated child processes. */ - RUSAGE_CHILDREN = -1 + RUSAGE_CHILDREN = -1, #define RUSAGE_CHILDREN RUSAGE_CHILDREN + +#ifdef __USE_GNU + /* The calling thread. */ + RUSAGE_THREAD = 1 +# define RUSAGE_THREAD RUSAGE_THREAD + /* Name for the same functionality on Solaris. */ +# define RUSAGE_LWP RUSAGE_THREAD +#endif }; #define __need_timeval diff --git a/libc/sysdeps/unix/sysv/linux/sparc/bits/resource.h b/libc/sysdeps/unix/sysv/linux/sparc/bits/resource.h index 3f2c60014..22c087da4 100644 --- a/libc/sysdeps/unix/sysv/linux/sparc/bits/resource.h +++ b/libc/sysdeps/unix/sysv/linux/sparc/bits/resource.h @@ -174,8 +174,16 @@ enum __rusage_who #define RUSAGE_SELF RUSAGE_SELF /* All of its terminated child processes. */ - RUSAGE_CHILDREN = -1 + RUSAGE_CHILDREN = -1, #define RUSAGE_CHILDREN RUSAGE_CHILDREN + +#ifdef __USE_GNU + /* The calling thread. */ + RUSAGE_THREAD = 1 +# define RUSAGE_THREAD RUSAGE_THREAD + /* Name for the same functionality on Solaris. */ +# define RUSAGE_LWP RUSAGE_THREAD +#endif }; #define __need_timeval diff --git a/libc/sysdeps/unix/sysv/linux/sparc/sparc32/Makefile b/libc/sysdeps/unix/sysv/linux/sparc/sparc32/Makefile index cd1b3fb79..8f7e76be2 100644 --- a/libc/sysdeps/unix/sysv/linux/sparc/sparc32/Makefile +++ b/libc/sysdeps/unix/sysv/linux/sparc/sparc32/Makefile @@ -2,6 +2,10 @@ asm-CPPFLAGS = -D__ASSEMBLY__ ASFLAGS-.os += -fPIC LD += -melf32_sparc +ifeq ($(subdir),stdlib) +gen-as-const-headers += ucontext_i.sym +endif + # When I get this to work, this is the right thing ifeq ($(subdir),elf) CFLAGS-rtld.c += -mcpu=v8 diff --git a/libc/sysdeps/unix/sysv/linux/sparc/sparc32/getcontext.S b/libc/sysdeps/unix/sysv/linux/sparc/sparc32/getcontext.S new file mode 100644 index 000000000..f8664a797 --- /dev/null +++ b/libc/sysdeps/unix/sysv/linux/sparc/sparc32/getcontext.S @@ -0,0 +1,85 @@ +/* Save current context. + Copyright (C) 2008 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by David S. Miller <davem@davemloft.net>, 2008. + + 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> + +#include "ucontext_i.h" + +/* int __getcontext (ucontext_t *ucp) + + Saves the machine context in UCP such that when it is activated, + it appears as if __getcontext() returned again. + + This implementation is intended to be used for *synchronous* context + switches only. Therefore, it does not have to save anything + other than the PRESERVED state. */ + + +ENTRY(__getcontext) + save %sp, -112, %sp + st %g0, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_PSR] + + /* In reality, we only use the GREG_PC value when setting + or swapping contexts. But we fill in NPC for completeness. */ + add %i7, 8, %o0 + st %o0, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_PC] + add %o0, 4, %o0 + st %o0, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_NPC] + + rd %y, %o1 + st %o1, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_Y] + + st %g1, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G1] + st %g2, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G2] + st %g3, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G3] + st %g4, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G4] + st %g5, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G5] + st %g6, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G6] + st %g7, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G7] + + mov SIG_BLOCK, %o0 + clr %o1 + add %i0, UC_SIGMASK, %o2 + mov 8, %o3 + mov __NR_rt_sigprocmask, %g1 + ta 0x10 + + /* Zero, success, return value. */ + st %g0, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O0] + st %i1, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O1] + st %i2, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O2] + st %i3, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O3] + st %i4, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O4] + st %i5, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O5] + st %i6, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O6] + st %i7, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O7] + + st %g0, [%i0 + UC_MCONTEXT + MC_GWINS] + + /* Do not save FPU state, it is volatile across calls. */ + stb %g0, [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_EN] + + st %g0, [%i0 + UC_MCONTEXT + MC_XRS + XRS_ID] + st %g0, [%i0 + UC_MCONTEXT + MC_XRS + XRS_PTR] + jmpl %i7 + 8, %g0 + restore %g0, %g0, %o0 +END(__getcontext) + +weak_alias (__getcontext, getcontext) diff --git a/libc/sysdeps/unix/sysv/linux/sparc/sparc32/makecontext.c b/libc/sysdeps/unix/sysv/linux/sparc/sparc32/makecontext.c new file mode 100644 index 000000000..9b48dade6 --- /dev/null +++ b/libc/sysdeps/unix/sysv/linux/sparc/sparc32/makecontext.c @@ -0,0 +1,93 @@ +/* Create new context. + Copyright (C) 2008 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by David S. Miller <davem@davemloft.net>, 2008. + + 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> +#include <stdarg.h> +#include <stdint.h> +#include <ucontext.h> + +/* Sets up the outgoing arguments and the program counter for a user + context for the requested function call. + + Returning to the correct parent context is pretty simple on + Sparc. We only need to link up the register windows correctly. + Since global registers are clobbered by calls, we need not be + concernred about those, and thus is all could be worked out without + using a trampoline. + + Except that we must deal with the signal mask, thus a trampoline + is unavoidable. 32-bit stackframe layout: + +-----------------------------------------+ + | 7th and further parameters | + +-----------------------------------------+ + | backup storage for initial 6 parameters | + +-----------------------------------------+ + | struct return pointer | + +-----------------------------------------+ + | 8 incoming registers | + +-----------------------------------------+ + | 8 local registers | + %sp --> +-----------------------------------------+ + +*/ + +void +__makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...) +{ + extern void __start_context (void); + unsigned long int *sp; + va_list ap; + int i; + + sp = (unsigned long int *) (ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); + sp -= 16 + 7 + argc; + sp = (unsigned long int *) (((uintptr_t) sp) & ~(8 - 1)); + + for (i = 0; i < 8; i++) + sp[i + 8] = ucp->uc_mcontext.gregs[REG_O0 + i]; + + /* The struct return pointer is essentially unused, so we can + place the link there. */ + sp[16] = (unsigned long int) ucp->uc_link; + + va_start (ap, argc); + + /* Fill in outgoing arguments, including those which will + end up being passed on the stack. */ + for (i = 0; i < argc; i++) + { + unsigned long int arg = va_arg (ap, unsigned long int); + if (i < 6) + ucp->uc_mcontext.gregs[REG_O0 + i] = arg; + else + sp[i + 23] = arg; + } + + va_end (ap); + + ucp->uc_mcontext.gregs[REG_O6] = (unsigned long int) sp; + + ucp->uc_mcontext.gregs[REG_O7] = ((unsigned long int) __start_context) - 8; + + ucp->uc_mcontext.gregs[REG_PC] = (unsigned long int) func; + ucp->uc_mcontext.gregs[REG_nPC] = ucp->uc_mcontext.gregs[REG_PC] + 4; +} + +weak_alias (__makecontext, makecontext) diff --git a/libc/sysdeps/unix/sysv/linux/sparc/sparc32/setcontext.S b/libc/sysdeps/unix/sysv/linux/sparc/sparc32/setcontext.S new file mode 100644 index 000000000..33e40ac65 --- /dev/null +++ b/libc/sysdeps/unix/sysv/linux/sparc/sparc32/setcontext.S @@ -0,0 +1,119 @@ +/* Install given context. + Copyright (C) 2008 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by David S. Miller <davem@davemloft.net>, 2008. + + 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> +#include <sys/trap.h> + +#include "ucontext_i.h" + + +/* int __setcontext (const ucontext_t *ucp) + + Restores the machine context in UCP and thereby resumes execution + in that context. + + This implementation is intended to be used for *synchronous* context + switches only. Therefore, it does not have to restore anything + other than the PRESERVED state. */ + +ENTRY(__setcontext) + save %sp, -112, %sp + + mov SIG_SETMASK, %o0 + add %i0, UC_SIGMASK, %o1 + clr %o2 + mov 8, %o3 + mov __NR_rt_sigprocmask, %g1 + ta 0x10 + + /* This is a bit on the expensive side, and we could optimize + the unwind similar to how the 32-bit sparc longjmp code + does if performance of this routine really matters. */ + ta ST_FLUSH_WINDOWS + + ldub [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_EN], %g1 + cmp %g1, 0 + be 1f + nop + ld [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_FSR], %fsr + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D0], %f0 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D2], %f2 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D4], %f4 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D6], %f6 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D8], %f8 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D10], %f10 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D12], %f12 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D14], %f14 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D16], %f16 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D18], %f18 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D20], %f20 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D22], %f22 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D24], %f24 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D26], %f26 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D28], %f28 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D30], %f30 +1: + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_Y], %g1 + wr %g1, 0x0, %y + + /* We specifically do not restore %g1 since we need it here as + a temporary. */ + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G2], %g2 + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G3], %g3 + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G4], %g4 + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G5], %g5 + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G6], %g6 + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G7], %g7 + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O1], %i1 + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O2], %i2 + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O3], %i3 + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O4], %i4 + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O5], %i5 + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O6], %i6 + restore + ld [%o0 + UC_MCONTEXT + MC_GREGS + GREG_O7], %o7 + ld [%o0 + UC_MCONTEXT + MC_GREGS + GREG_PC], %g1 + jmpl %g1, %g0 + ld [%o0 + UC_MCONTEXT + MC_GREGS + GREG_O0], %o0 +END(__setcontext) + +weak_alias (__setcontext, setcontext) + +/* This is the helper code which gets called if a function which is + registered with 'makecontext' returns. In this case we have to + install the context listed in the uc_link element of the context + 'makecontext' manipulated at the time of the 'makecontext' call. + If the pointer is NULL the process must terminate. */ + +ENTRY(__start_context) + ld [%sp + (16 * 4)], %g1 + cmp %g1, 0 + be,a 1f + clr %o0 + call __setcontext + mov %g1, %o0 + /* If this returns (which can happen if the syscall fails) we'll + exit the program with the return error value (-1). */ +1: call exit + nop + /* The 'exit' call should never return. In case it does cause + the process to terminate. */ + unimp +END(__start_context) diff --git a/libc/sysdeps/unix/sysv/linux/sparc/sparc32/swapcontext.S b/libc/sysdeps/unix/sysv/linux/sparc/sparc32/swapcontext.S new file mode 100644 index 000000000..154746689 --- /dev/null +++ b/libc/sysdeps/unix/sysv/linux/sparc/sparc32/swapcontext.S @@ -0,0 +1,119 @@ +/* Save current context and install the given one. + Copyright (C) 2008 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by David S. Miller <davem@davemloft.net>, 2008. + + 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> +#include <sys/trap.h> + +#include "ucontext_i.h" + + +/* int __swapcontext (ucontext_t *oucp, const ucontext_t *ucp); + + Saves the machine context in oucp such that when it is activated, + it appears as if __swapcontext() returned again, restores the + machine context in ucp and thereby resumes execution in that + context. + + This implementation is intended to be used for *synchronous* context + switches only. Therefore, it does not have to save anything + other than the PRESERVED state. */ + +ENTRY(__swapcontext) + save %sp, -112, %sp + ta ST_FLUSH_WINDOWS + st %g0, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_PSR] + add %i7, 8, %o0 + st %o0, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_PC] + add %o0, 4, %o0 + st %o0, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_NPC] + rd %y, %o1 + st %o1, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_Y] + st %g1, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G1] + st %g2, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G2] + st %g3, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G3] + st %g4, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G4] + st %g5, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G5] + st %g6, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G6] + st %g7, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G7] + st %g0, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O0] + st %i1, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O1] + st %i2, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O2] + st %i3, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O3] + st %i4, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O4] + st %i5, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O5] + st %i6, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O6] + st %i7, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O7] + st %g0, [%i0 + UC_MCONTEXT + MC_GWINS] + stb %g0, [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_EN] + st %g0, [%i0 + UC_MCONTEXT + MC_XRS + XRS_ID] + st %g0, [%i0 + UC_MCONTEXT + MC_XRS + XRS_PTR] + + mov SIG_SETMASK, %o0 + add %i1, UC_SIGMASK, %o1 + add %i0, UC_SIGMASK, %o2 + mov 8, %o3 + mov __NR_rt_sigprocmask, %g1 + ta 0x10 + + mov %i1, %i0 + ldub [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_EN], %g1 + cmp %g1, 0 + be 1f + nop + ld [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_FSR], %fsr + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D0], %f0 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D2], %f2 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D4], %f4 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D6], %f6 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D8], %f8 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D10], %f10 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D12], %f12 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D14], %f14 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D16], %f16 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D18], %f18 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D20], %f20 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D22], %f22 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D24], %f24 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D26], %f26 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D28], %f28 + ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D30], %f30 +1: + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_Y], %g1 + wr %g1, 0x0, %y + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G2], %g2 + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G3], %g3 + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G4], %g4 + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G5], %g5 + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G6], %g6 + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G7], %g7 + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O1], %i1 + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O2], %i2 + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O3], %i3 + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O4], %i4 + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O5], %i5 + ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O6], %i6 + restore + ld [%o0 + UC_MCONTEXT + MC_GREGS + GREG_O7], %o7 + ld [%o0 + UC_MCONTEXT + MC_GREGS + GREG_PC], %g1 + jmpl %g1, %g0 + ld [%o0 + UC_MCONTEXT + MC_GREGS + GREG_O0], %o0 +END(__swapcontext) + +weak_alias (__swapcontext, swapcontext) diff --git a/libc/sysdeps/unix/sysv/linux/sparc/sparc32/syscall.S b/libc/sysdeps/unix/sysv/linux/sparc/sparc32/syscall.S index 161074552..5786880f2 100644 --- a/libc/sysdeps/unix/sysv/linux/sparc/sparc32/syscall.S +++ b/libc/sysdeps/unix/sysv/linux/sparc/sparc32/syscall.S @@ -27,6 +27,7 @@ ENTRY(syscall) mov %o3, %o2 mov %o4, %o3 mov %o5, %o4 + ld [%sp + 92], %o5 ta 0x10 bcc 1f mov %o7, %g1 diff --git a/libc/sysdeps/unix/sysv/linux/sparc/sparc32/ucontext_i.sym b/libc/sysdeps/unix/sysv/linux/sparc/sparc32/ucontext_i.sym new file mode 100644 index 000000000..544030ce8 --- /dev/null +++ b/libc/sysdeps/unix/sysv/linux/sparc/sparc32/ucontext_i.sym @@ -0,0 +1,61 @@ +#include <stddef.h> +#include <signal.h> +#include <sys/ucontext.h> + +-- + +SIG_BLOCK +SIG_SETMASK + +UC_FLAGS offsetof (ucontext_t, uc_flags) +UC_LINK offsetof (ucontext_t, uc_link) +UC_SIGMASK offsetof (ucontext_t, uc_sigmask) +UC_STACK offsetof (ucontext_t, uc_stack) +UC_MCONTEXT offsetof (ucontext_t, uc_mcontext) +MC_GREGS offsetof (mcontext_t, gregs) +MC_GWINS offsetof (mcontext_t, gwins) +MC_FPREGS offsetof (mcontext_t, fpregs) +MC_XRS offsetof (mcontext_t, xrs) +MC_FILLER offsetof (mcontext_t, filler) +GREG_PSR (REG_PSR * sizeof(greg_t)) +GREG_PC (REG_PC * sizeof(greg_t)) +GREG_NPC (REG_nPC * sizeof(greg_t)) +GREG_Y (REG_Y * sizeof(greg_t)) +GREG_G1 (REG_G1 * sizeof(greg_t)) +GREG_G2 (REG_G2 * sizeof(greg_t)) +GREG_G3 (REG_G3 * sizeof(greg_t)) +GREG_G4 (REG_G4 * sizeof(greg_t)) +GREG_G5 (REG_G5 * sizeof(greg_t)) +GREG_G6 (REG_G6 * sizeof(greg_t)) +GREG_G7 (REG_G7 * sizeof(greg_t)) +GREG_O0 (REG_O0 * sizeof(greg_t)) +GREG_O1 (REG_O1 * sizeof(greg_t)) +GREG_O2 (REG_O2 * sizeof(greg_t)) +GREG_O3 (REG_O3 * sizeof(greg_t)) +GREG_O4 (REG_O4 * sizeof(greg_t)) +GREG_O5 (REG_O5 * sizeof(greg_t)) +GREG_O6 (REG_O6 * sizeof(greg_t)) +GREG_O7 (REG_O7 * sizeof(greg_t)) +FPU_D0 offsetof (fpregset_t, fpu_fr.fpu_dregs[0]) +FPU_D2 offsetof (fpregset_t, fpu_fr.fpu_dregs[1]) +FPU_D4 offsetof (fpregset_t, fpu_fr.fpu_dregs[2]) +FPU_D6 offsetof (fpregset_t, fpu_fr.fpu_dregs[3]) +FPU_D8 offsetof (fpregset_t, fpu_fr.fpu_dregs[4]) +FPU_D10 offsetof (fpregset_t, fpu_fr.fpu_dregs[5]) +FPU_D12 offsetof (fpregset_t, fpu_fr.fpu_dregs[6]) +FPU_D14 offsetof (fpregset_t, fpu_fr.fpu_dregs[7]) +FPU_D16 offsetof (fpregset_t, fpu_fr.fpu_dregs[8]) +FPU_D18 offsetof (fpregset_t, fpu_fr.fpu_dregs[9]) +FPU_D20 offsetof (fpregset_t, fpu_fr.fpu_dregs[10]) +FPU_D22 offsetof (fpregset_t, fpu_fr.fpu_dregs[11]) +FPU_D24 offsetof (fpregset_t, fpu_fr.fpu_dregs[12]) +FPU_D26 offsetof (fpregset_t, fpu_fr.fpu_dregs[13]) +FPU_D28 offsetof (fpregset_t, fpu_fr.fpu_dregs[14]) +FPU_D30 offsetof (fpregset_t, fpu_fr.fpu_dregs[15]) +FPU_Q offsetof (fpregset_t, fpu_q) +FPU_FSR offsetof (fpregset_t, fpu_fsr) +FPU_QCNT offsetof (fpregset_t, fpu_qcnt) +FPU_Q_ENTRY_SZ offsetof (fpregset_t, fpu_q_entrysize) +FPU_EN offsetof (fpregset_t, fpu_en) +XRS_ID offsetof (xrs_t, xrs_id) +XRS_PTR offsetof (xrs_t, xrs_ptr) diff --git a/libc/sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c b/libc/sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c index 057e28782..4f826b156 100644 --- a/libc/sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c +++ b/libc/sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c @@ -54,5 +54,5 @@ semctl (int semid, int semnum, int cmd, ...) va_end (ap); return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd, - CHECK_SEMCTL (&arg, semid, cmd)); + CHECK_SEMCTL (&arg, semid, cmd)->array); } diff --git a/libc/sysdeps/unix/sysv/linux/sparc/sparc64/syscall.S b/libc/sysdeps/unix/sysv/linux/sparc/sparc64/syscall.S index 27487d8ed..2c89558b2 100644 --- a/libc/sysdeps/unix/sysv/linux/sparc/sparc64/syscall.S +++ b/libc/sysdeps/unix/sysv/linux/sparc/sparc64/syscall.S @@ -27,6 +27,7 @@ ENTRY(syscall) mov %o3,%o2 mov %o4,%o3 mov %o5,%o4 + ldx [%sp + STACK_BIAS + 176],%o5 ta 0x6d diff --git a/libc/sysdeps/unix/sysv/linux/times.c b/libc/sysdeps/unix/sysv/linux/times.c index 2759683b0..42d265dc8 100644 --- a/libc/sysdeps/unix/sysv/linux/times.c +++ b/libc/sysdeps/unix/sysv/linux/times.c @@ -27,7 +27,7 @@ __times (struct tms *buf) INTERNAL_SYSCALL_DECL (err); clock_t ret = INTERNAL_SYSCALL (times, err, 1, buf); if (INTERNAL_SYSCALL_ERROR_P (ret, err) - && __builtin_expect (INTERNAL_SYSCALL_ERRNO (ret, err) == -EFAULT, 0)) + && __builtin_expect (INTERNAL_SYSCALL_ERRNO (ret, err) == EFAULT, 0)) { /* This might be an error or not. For architectures which have no separate return value and error indicators we cannot @@ -49,6 +49,11 @@ __times (struct tms *buf) return an EFAULT error. Return the value given by the kernel. */ } + /* Return value (clock_t) -1 signals an error, but if there wasn't any, + return the following value. */ + if (ret == (clock_t) -1) + return (clock_t) 0; + return ret; } weak_alias (__times, times) diff --git a/ports/ChangeLog.mips b/ports/ChangeLog.mips index b4253d827..398fac9ce 100644 --- a/ports/ChangeLog.mips +++ b/ports/ChangeLog.mips @@ -1,3 +1,8 @@ +2008-05-01 Joseph Myers <joseph@codesourcery.com> + + * sysdeps/unix/sysv/linux/mips/bits/resource.h: Define + RUSAGE_THREAD and RUSAGE_LWP. + 2008-04-21 Daniel Jacobowitz <dan@codesourcery.com> * sysdeps/unix/sysv/linux/mips/bits/shm.h: Fix comment describing diff --git a/ports/sysdeps/unix/sysv/linux/mips/bits/resource.h b/ports/sysdeps/unix/sysv/linux/mips/bits/resource.h index 1c8b99a93..3cfdc5dbe 100644 --- a/ports/sysdeps/unix/sysv/linux/mips/bits/resource.h +++ b/ports/sysdeps/unix/sysv/linux/mips/bits/resource.h @@ -166,8 +166,16 @@ enum __rusage_who #define RUSAGE_SELF RUSAGE_SELF /* All of its terminated child processes. */ - RUSAGE_CHILDREN = -1 + RUSAGE_CHILDREN = -1, #define RUSAGE_CHILDREN RUSAGE_CHILDREN + +#ifdef __USE_GNU + /* The calling thread. */ + RUSAGE_THREAD = 1 +# define RUSAGE_THREAD RUSAGE_THREAD + /* Name for the same functionality on Solaris. */ +# define RUSAGE_LWP RUSAGE_THREAD +#endif }; #define __need_timeval |