diff options
author | Jakub Jelinek <jakub@redhat.com> | 2006-01-02 10:52:59 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2006-01-02 10:52:59 +0000 |
commit | 0db2497936950725ae71e997091ef276a3ec43ee (patch) | |
tree | 7d66db137accea00fe402dfabf8e5de3a4af58c6 /sysdeps/unix | |
parent | b9ea6c38033d6ab0bda9dddb34cc7a4c6ff82084 (diff) | |
download | glibc-0db2497936950725ae71e997091ef276a3ec43ee.tar.gz glibc-0db2497936950725ae71e997091ef276a3ec43ee.tar.xz glibc-0db2497936950725ae71e997091ef276a3ec43ee.zip |
Updated to fedora-glibc-20060102T1045
Diffstat (limited to 'sysdeps/unix')
40 files changed, 1867 insertions, 1499 deletions
diff --git a/sysdeps/unix/sh/sysdep.S b/sysdeps/unix/sh/sysdep.S index 6e4798e45a..802d51f3be 100644 --- a/sysdeps/unix/sh/sysdep.S +++ b/sysdeps/unix/sh/sysdep.S @@ -40,14 +40,21 @@ skip: #else mov.l .L3, r1 sts.l pr, @-r15 + cfi_adjust_cfa_offset (4) + cfi_rel_offset (pr, 0) jsr @r1 mov.l r0, @-r15 + cfi_adjust_cfa_offset (4) mov.l @r15+, r1 + cfi_adjust_cfa_offset (-4) lds.l @r15+, pr + cfi_adjust_cfa_offset (-4) mov.l r1, @r0 #endif #else mov.l r12, @-r15 + cfi_adjust_cfa_offset (4) + cfi_rel_offset (r12, 0) #ifndef _LIBC_REENTRANT mov r0, r2 mov.l 0f, r12 @@ -58,7 +65,10 @@ skip: mov.l r2, @r1 #else mov.l r0, @-r15 + cfi_adjust_cfa_offset (4) sts.l pr, @-r15 + cfi_adjust_cfa_offset (4) + cfi_rel_offset (pr, 0) mov.l 0f, r12 mova 0f, r0 add r0, r12 diff --git a/sysdeps/unix/sysv/linux/clock_getres.c b/sysdeps/unix/sysv/linux/clock_getres.c index 2d0136dfeb..44dcccd150 100644 --- a/sysdeps/unix/sysv/linux/clock_getres.c +++ b/sysdeps/unix/sysv/linux/clock_getres.c @@ -1,5 +1,5 @@ /* clock_getres -- Get the resolution of a POSIX clockid_t. Linux version. - Copyright (C) 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005 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 @@ -24,9 +24,17 @@ #include "kernel-features.h" +#ifndef HAVE_CLOCK_GETRES_VSYSCALL +# undef INTERNAL_VSYSCALL +# define INTERNAL_VSYSCALL INTERNAL_SYSCALL +# undef INLINE_VSYSCALL +# define INLINE_VSYSCALL INLINE_SYSCALL +#else +# include <bits/libc-vdso.h> +#endif #define SYSCALL_GETRES \ - retval = INLINE_SYSCALL (clock_getres, 2, clock_id, res); \ + retval = INLINE_VSYSCALL (clock_getres, 2, clock_id, res); \ break #ifdef __ASSUME_POSIX_TIMERS @@ -52,7 +60,7 @@ maybe_syscall_getres (clockid_t clock_id, struct timespec *res) if (!__libc_missing_posix_timers) { INTERNAL_SYSCALL_DECL (err); - int r = INTERNAL_SYSCALL (clock_getres, err, 2, clock_id, res); + int r = INTERNAL_VSYSCALL (clock_getres, err, 2, clock_id, res); if (!INTERNAL_SYSCALL_ERROR_P (r, err)) return 0; @@ -109,7 +117,7 @@ maybe_syscall_getres_cpu (clockid_t clock_id, struct timespec *res) if (!__libc_missing_posix_cpu_timers) { INTERNAL_SYSCALL_DECL (err); - int r = INTERNAL_SYSCALL (clock_getres, err, 2, clock_id, res); + int r = INTERNAL_VSYSCALL (clock_getres, err, 2, clock_id, res); if (!INTERNAL_SYSCALL_ERROR_P (r, err)) return 0; @@ -128,7 +136,7 @@ maybe_syscall_getres_cpu (clockid_t clock_id, struct timespec *res) { /* Check whether the kernel supports CPU clocks at all. If not, record it for the future. */ - r = INTERNAL_SYSCALL (clock_getres, err, 2, + r = INTERNAL_VSYSCALL (clock_getres, err, 2, MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED), NULL); if (INTERNAL_SYSCALL_ERROR_P (r, err)) diff --git a/sysdeps/unix/sysv/linux/clock_gettime.c b/sysdeps/unix/sysv/linux/clock_gettime.c index bd79642dd5..315d595edc 100644 --- a/sysdeps/unix/sysv/linux/clock_gettime.c +++ b/sysdeps/unix/sysv/linux/clock_gettime.c @@ -1,5 +1,5 @@ /* clock_gettime -- Get current time from a POSIX clockid_t. Linux version. - Copyright (C) 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005 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 @@ -23,9 +23,17 @@ #include "kernel-posix-cpu-timers.h" #include "kernel-features.h" +#ifndef HAVE_CLOCK_GETTIME_VSYSCALL +# undef INTERNAL_VSYSCALL +# define INTERNAL_VSYSCALL INTERNAL_SYSCALL +# undef INLINE_VSYSCALL +# define INLINE_VSYSCALL INLINE_SYSCALL +#else +# include <bits/libc-vdso.h> +#endif #define SYSCALL_GETTIME \ - retval = INLINE_SYSCALL (clock_gettime, 2, clock_id, tp); \ + retval = INLINE_VSYSCALL (clock_gettime, 2, clock_id, tp); \ break #ifdef __ASSUME_POSIX_TIMERS @@ -51,7 +59,7 @@ maybe_syscall_gettime (clockid_t clock_id, struct timespec *tp) if (!__libc_missing_posix_timers) { INTERNAL_SYSCALL_DECL (err); - int r = INTERNAL_SYSCALL (clock_gettime, err, 2, clock_id, tp); + int r = INTERNAL_VSYSCALL (clock_gettime, err, 2, clock_id, tp); if (!INTERNAL_SYSCALL_ERROR_P (r, err)) return 0; @@ -108,7 +116,7 @@ maybe_syscall_gettime_cpu (clockid_t clock_id, struct timespec *tp) if (!__libc_missing_posix_cpu_timers) { INTERNAL_SYSCALL_DECL (err); - int r = INTERNAL_SYSCALL (clock_gettime, err, 2, clock_id, tp); + int r = INTERNAL_VSYSCALL (clock_gettime, err, 2, clock_id, tp); if (!INTERNAL_SYSCALL_ERROR_P (r, err)) return 0; @@ -127,7 +135,7 @@ maybe_syscall_gettime_cpu (clockid_t clock_id, struct timespec *tp) { /* Check whether the kernel supports CPU clocks at all. If not, record it for the future. */ - r = INTERNAL_SYSCALL (clock_getres, err, 2, + r = INTERNAL_VSYSCALL (clock_getres, err, 2, MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED), NULL); if (INTERNAL_SYSCALL_ERROR_P (r, err)) diff --git a/sysdeps/unix/sysv/linux/i386/sigaction.c b/sysdeps/unix/sysv/linux/i386/sigaction.c index 9cb5b6e340..299574dac4 100644 --- a/sysdeps/unix/sysv/linux/i386/sigaction.c +++ b/sysdeps/unix/sysv/linux/i386/sigaction.c @@ -1,5 +1,5 @@ /* POSIX.1 `sigaction' call for Linux/i386. - Copyright (C) 1991,1995-2000,02,03, 2004 Free Software Foundation, Inc. + Copyright (C) 1991,1995-2000,2002-2004,2005 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 @@ -154,6 +154,10 @@ __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact) } libc_hidden_def (__libc_sigaction) +#ifdef WRAPPER_INCLUDE +# include WRAPPER_INCLUDE +#endif + #ifndef LIBC_SIGACTION weak_alias (__libc_sigaction, __sigaction) libc_hidden_weak (__sigaction) diff --git a/sysdeps/unix/sysv/linux/ia64/bits/setjmp.h b/sysdeps/unix/sysv/linux/ia64/bits/setjmp.h index 76625753d9..80543976bb 100644 --- a/sysdeps/unix/sysv/linux/ia64/bits/setjmp.h +++ b/sysdeps/unix/sysv/linux/ia64/bits/setjmp.h @@ -1,5 +1,5 @@ /* Define the machine-dependent type `jmp_buf'. Linux/IA-64 version. - Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2003, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by David Mosberger-Tang <davidm@hpl.hp.com>. @@ -34,7 +34,7 @@ typedef long __jmp_buf[_JBLEN] __attribute__ ((aligned (16))); /* guarantees 128 /* Test if longjmp to JMPBUF would unwind the frame containing a local variable at ADDRESS. */ -#define _JMPBUF_UNWINDS(_jmpbuf, _address) \ - ((void *)(_address) < (void *)(((long *)_jmpbuf)[0])) +#define _JMPBUF_UNWINDS(_jmpbuf, _address, _demangle) \ + ((void *) (_address) < (void *) (((long int *) _jmpbuf)[0])) #endif /* bits/setjmp.h */ diff --git a/sysdeps/unix/sysv/linux/ia64/sigaction.c b/sysdeps/unix/sysv/linux/ia64/sigaction.c index 6ec3cb1e61..fdbc93f0ed 100644 --- a/sysdeps/unix/sysv/linux/ia64/sigaction.c +++ b/sysdeps/unix/sysv/linux/ia64/sigaction.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997,1998,1999,2000,2002,2003 Free Software Foundation, Inc. +/* Copyright (C) 1997-2000,2002,2003,2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Linux/IA64 specific sigaction Written by Jes Sorensen, <Jes.Sorensen@cern.ch>, April 1999. @@ -48,6 +48,10 @@ __libc_sigaction (sig, act, oact) } libc_hidden_def (__libc_sigaction) +#ifdef WRAPPER_INCLUDE +# include WRAPPER_INCLUDE +#endif + #ifndef LIBC_SIGACTION weak_alias (__libc_sigaction, __sigaction) libc_hidden_def (__sigaction) diff --git a/sysdeps/unix/sysv/linux/mips/bits/socket.h b/sysdeps/unix/sysv/linux/mips/bits/socket.h index 1dd82eb866..4c70eff421 100644 --- a/sysdeps/unix/sysv/linux/mips/bits/socket.h +++ b/sysdeps/unix/sysv/linux/mips/bits/socket.h @@ -1,5 +1,5 @@ /* System-specific socket constants and types. Linux/MIPS version. - Copyright (C) 1991, 92, 1994-1999, 2000, 2001, 2004 + Copyright (C) 1991, 92, 1994-1999, 2000, 2001, 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -219,7 +219,7 @@ struct msghdr socklen_t msg_namelen; /* Length of address data. */ struct iovec *msg_iov; /* Vector of data to send/receive into. */ - int msg_iovlen; /* Number of elements in the vector. */ + size_t msg_iovlen; /* Number of elements in the vector. */ void *msg_control; /* Ancillary data (eg BSD filedesc passing). */ socklen_t msg_controllen; /* Ancillary data buffer length. */ diff --git a/sysdeps/unix/sysv/linux/powerpc/Makefile b/sysdeps/unix/sysv/linux/powerpc/Makefile index 55d2d0d273..ecd8057951 100644 --- a/sysdeps/unix/sysv/linux/powerpc/Makefile +++ b/sysdeps/unix/sysv/linux/powerpc/Makefile @@ -6,3 +6,7 @@ endif ifeq ($(subdir),stdlib) gen-as-const-headers += ucontext_i.sym endif + +ifeq ($(subdir),elf) +routines += dl-vdso +endif diff --git a/sysdeps/unix/sysv/linux/powerpc/Versions b/sysdeps/unix/sysv/linux/powerpc/Versions new file mode 100644 index 0000000000..1ef53b9e9c --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/Versions @@ -0,0 +1,7 @@ +libc { + GLIBC_PRIVATE { + __vdso_get_tbfreq; + __vdso_clock_gettime; + __vdso_clock_getres; + } +} diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h b/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h new file mode 100644 index 0000000000..f20a5a175c --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h @@ -0,0 +1,36 @@ +/* Resolve function pointers to VDSO functions. + Copyright (C) 2005 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. */ + + +#ifndef _LIBC_VDSO_H +#define _LIBC_VDSO_H + +#ifdef SHARED + +extern void *__vdso_gettimeofday; + +extern void *__vdso_clock_gettime; + +extern void *__vdso_clock_getres; + +extern void *__vdso_get_tbfreq; + +#endif + +#endif /* _LIBC_VDSO_H */ diff --git a/sysdeps/unix/sysv/linux/powerpc/dl-vdso.c b/sysdeps/unix/sysv/linux/powerpc/dl-vdso.c new file mode 100644 index 0000000000..e1be097734 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/dl-vdso.c @@ -0,0 +1,59 @@ +/* ELF symbol resolve functions for VDSO objects. + Copyright (C) 2005 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 "config.h" +#include <dl-hash.h> +#include <ldsodefs.h> + + +void * +internal_function +_dl_vdso_vsym (const char *name, const char *version) +{ + struct link_map *map = GLRO (dl_sysinfo_map); + void *value = NULL; + + + if (map != NULL) + { + /* Use a WEAK REF so we don't error out if the symbol is not found. */ + ElfW (Sym) wsym; + memset (&wsym, 0, sizeof (ElfW (Sym))); + wsym.st_info = (unsigned char) ELFW (ST_INFO (STB_WEAK, STT_NOTYPE)); + + /* Compute hash value to the version string. */ + struct r_found_version vers; + vers.name = version; + vers.hidden = 1; + vers.hash = _dl_elf_hash (version); + /* We don't have a specific file where the symbol can be found. */ + vers.filename = NULL; + + /* Search the scope of the vdso map. */ + const ElfW (Sym) *ref = &wsym; + lookup_t result = GLRO (dl_lookup_symbol_x) (name, map, &ref, + map->l_local_scope, + &vers, 0, 0, NULL); + + if (ref != NULL) + value = DL_SYMBOL_ADDRESS (result, ref); + } + + return value; +} diff --git a/sysdeps/unix/sysv/linux/powerpc/dl-vdso.h b/sysdeps/unix/sysv/linux/powerpc/dl-vdso.h new file mode 100644 index 0000000000..a7dcb2e5ff --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/dl-vdso.h @@ -0,0 +1,27 @@ +/* ELF symbol resolve functions for VDSO objects. + Copyright (C) 2005 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. */ + +#ifndef _DL_VDSO_H +#define _DL_VDSO_H 1 + +/* Functions for resolving symbols in the VDSO link map. */ +extern void *_dl_vdso_vsym (const char *name, const char *version) + internal_function attribute_hidden; + +#endif /* dl-vdso.h */ diff --git a/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c b/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c index ddaff303c5..6d2e766aa4 100644 --- a/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c +++ b/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c @@ -22,14 +22,15 @@ #include <string.h> #include <unistd.h> #include <libc-internal.h> - +#include <sysdep.h> +#include <bits/libc-vdso.h> hp_timing_t __get_clockfreq (void) { /* We read the information from the /proc filesystem. /proc/cpuinfo contains at least one line like: - timebase : 33333333 + timebase : 33333333 We search for this line and convert the number into an integer. */ static hp_timing_t timebase_freq; hp_timing_t result = 0L; @@ -38,67 +39,78 @@ __get_clockfreq (void) if (timebase_freq != 0) return timebase_freq; - int fd = open ("/proc/cpuinfo", O_RDONLY); - if (__builtin_expect (fd != -1, 1)) + /* If we can use the vDSO to obtain the timebase even better. */ +#ifdef SHARED + INTERNAL_SYSCALL_DECL (err); + timebase_freq = INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK (get_tbfreq, err, 0); + if (INTERNAL_SYSCALL_ERROR_P (timebase_freq, err) + && INTERNAL_SYSCALL_ERRNO (timebase_freq, err) == ENOSYS) +#endif { - /* The timebase will be in the 1st 1024 bytes for systems with up - to 8 processors. If the first read returns less then 1024 - bytes read, we have the whole cpuinfo and can start the scan. - Otherwise we will have to read more to insure we have the - timebase value in the scan. */ - char buf[1024]; - ssize_t n; + int fd = open ("/proc/cpuinfo", O_RDONLY); - n = read (fd, buf, sizeof (buf)); - if (n == sizeof (buf)) + if (__builtin_expect (fd != -1, 1)) { - /* We are here because the 1st read returned exactly sizeof - (buf) bytes. This implies that we are not at EOF and may - not have read the timebase value yet. So we need to read - more bytes until we know we have EOF. We copy the lower - half of buf to the upper half and read sizeof (buf)/2 - bytes into the lower half of buf and repeat until we - reach EOF. We can assume that the timebase will be in - the last 512 bytes of cpuinfo, so two 512 byte half_bufs - will be sufficient to contain the timebase and will - handle the case where the timebase spans the half_buf - boundry. */ - const ssize_t half_buf = sizeof (buf) / 2; - while (n >= half_buf) + /* The timebase will be in the 1st 1024 bytes for systems with up + to 8 processors. If the first read returns less then 1024 + bytes read, we have the whole cpuinfo and can start the scan. + Otherwise we will have to read more to insure we have the + timebase value in the scan. */ + char buf[1024]; + ssize_t n; + + n = read (fd, buf, sizeof (buf)); + if (n == sizeof (buf)) { - memcpy (buf, buf + half_buf, half_buf); - n = read (fd, buf + half_buf, half_buf); + /* We are here because the 1st read returned exactly sizeof + (buf) bytes. This implies that we are not at EOF and may + not have read the timebase value yet. So we need to read + more bytes until we know we have EOF. We copy the lower + half of buf to the upper half and read sizeof (buf)/2 + bytes into the lower half of buf and repeat until we + reach EOF. We can assume that the timebase will be in + the last 512 bytes of cpuinfo, so two 512 byte half_bufs + will be sufficient to contain the timebase and will + handle the case where the timebase spans the half_buf + boundry. */ + const ssize_t half_buf = sizeof (buf) / 2; + while (n >= half_buf) + { + memcpy (buf, buf + half_buf, half_buf); + n = read (fd, buf + half_buf, half_buf); + } + if (n >= 0) + n += half_buf; } - if (n >= 0) - n += half_buf; - } - - if (__builtin_expect (n, 1) > 0) - { - char *mhz = memmem (buf, n, "timebase", 7); - if (__builtin_expect (mhz != NULL, 1)) + if (__builtin_expect (n, 1) > 0) { - char *endp = buf + n; - - /* Search for the beginning of the string. */ - while (mhz < endp && (*mhz < '0' || *mhz > '9') && *mhz != '\n') - ++mhz; + char *mhz = memmem (buf, n, "timebase", 7); - while (mhz < endp && *mhz != '\n') + if (__builtin_expect (mhz != NULL, 1)) { - if (*mhz >= '0' && *mhz <= '9') + char *endp = buf + n; + + /* Search for the beginning of the string. */ + while (mhz < endp && (*mhz < '0' || *mhz > '9') + && *mhz != '\n') + ++mhz; + + while (mhz < endp && *mhz != '\n') { - result *= 10; - result += *mhz - '0'; - } + if (*mhz >= '0' && *mhz <= '9') + { + result *= 10; + result += *mhz - '0'; + } - ++mhz; + ++mhz; + } } + timebase_freq = result; } - timebase_freq = result; + close (fd); } - close (fd); } return timebase_freq; diff --git a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c new file mode 100644 index 0000000000..b381baa285 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c @@ -0,0 +1,42 @@ +/* Copyright (C) 2005 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> +#include <bp-checks.h> +#include <stddef.h> +#include <sys/time.h> +#include <time.h> +#include <hp-timing.h> + +#undef __gettimeofday +#include <bits/libc-vdso.h> + +/* Get the current time of day and timezone information, + putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled. + Returns 0 on success, -1 on errors. */ + +int +__gettimeofday (tv, tz) + struct timeval *tv; + struct timezone *tz; +{ + return INLINE_VSYSCALL (gettimeofday, 2, CHECK_1 (tv), CHECK_1 (tz)); +} + +INTDEF (__gettimeofday) +weak_alias (__gettimeofday, gettimeofday) diff --git a/sysdeps/unix/sysv/linux/powerpc/libc-start.c b/sysdeps/unix/sysv/linux/powerpc/libc-start.c new file mode 100644 index 0000000000..a8005c1163 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/libc-start.c @@ -0,0 +1,130 @@ +/* Copyright (C) 1998,2000,2001,2002,2003,2004,2005 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 <stdlib.h> +#include <unistd.h> +#include <ldsodefs.h> +#include <bp-start.h> +#include <bp-sym.h> + +extern int __cache_line_size; +weak_extern (__cache_line_size) +/* The main work is done in the generic function. */ +#define LIBC_START_MAIN generic_start_main +#define LIBC_START_DISABLE_INLINE +#define LIBC_START_MAIN_AUXVEC_ARG +#define MAIN_AUXVEC_ARG +#define INIT_MAIN_ARGS +#include <csu/libc-start.c> + +struct startup_info + { + void *__unbounded sda_base; + int (*main) (int, char **, char **, void *); + int (*init) (int, char **, char **, void *); + void (*fini) (void); + }; + + +#ifdef SHARED +# include <sys/time.h> +# include <dl-vdso.h> +# undef __gettimeofday +# undef __clock_gettime +# undef __clock_getres +# include <bits/libc-vdso.h> + +void *__vdso_gettimeofday; +void *__vdso_clock_gettime; +void *__vdso_clock_getres; +void *__vdso_get_tbfreq; + +static inline void _libc_vdso_platform_setup (void) + { + __vdso_gettimeofday = _dl_vdso_vsym ("__kernel_gettimeofday", + "LINUX_2.6.15"); + + __vdso_clock_gettime = _dl_vdso_vsym ("__kernel_clock_gettime", + "LINUX_2.6.15"); + + __vdso_clock_getres = _dl_vdso_vsym ("__kernel_clock_getres", + "LINUX_2.6.15"); + + __vdso_get_tbfreq = _dl_vdso_vsym ("__kernel_vdso_get_tbfreq", + "LINUX_2.6.15"); + } +#endif + +int +/* GKM FIXME: GCC: this should get __BP_ prefix by virtue of the + BPs in the arglist of startup_info.main and startup_info.init. */ + BP_SYM (__libc_start_main) (int argc, char *__unbounded *__unbounded ubp_av, + char *__unbounded *__unbounded ubp_ev, + ElfW (auxv_t) * __unbounded auxvec, + void (*rtld_fini) (void), + struct startup_info *__unbounded stinfo, + char *__unbounded *__unbounded stack_on_entry) +{ +#if __BOUNDED_POINTERS__ + char **argv; +#else +# define argv ubp_av +#endif + + /* the PPC SVR4 ABI says that the top thing on the stack will + be a NULL pointer, so if not we assume that we're being called + as a statically-linked program by Linux... */ + if (*stack_on_entry != NULL) + { + char *__unbounded * __unbounded temp; + /* ...in which case, we have argc as the top thing on the + stack, followed by argv (NULL-terminated), envp (likewise), + and the auxilary vector. */ + /* 32/64-bit agnostic load from stack */ + argc = *(long int *__unbounded) stack_on_entry; + ubp_av = stack_on_entry + 1; + ubp_ev = ubp_av + argc + 1; +#ifdef HAVE_AUX_VECTOR + temp = ubp_ev; + while (*temp != NULL) + ++temp; + auxvec = (ElfW (auxv_t) *)++ temp; +#endif + rtld_fini = NULL; + } + + /* Initialize the __cache_line_size variable from the aux vector. */ + for (ElfW (auxv_t) * av = auxvec; av->a_type != AT_NULL; ++av) + switch (av->a_type) + { + case AT_DCACHEBSIZE: + { + int *cls = &__cache_line_size; + if (cls != NULL) + *cls = av->a_un.a_val; + } + break; + } +#ifdef SHARED + /* Resolve and initialize function pointers for VDSO functions. */ + _libc_vdso_platform_setup (); +#endif + return generic_start_main (stinfo->main, argc, ubp_av, auxvec, + stinfo->init, stinfo->fini, rtld_fini, + stack_on_entry); +} diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext-common.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext-common.S new file mode 100644 index 0000000000..0e04e4bb59 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext-common.S @@ -0,0 +1,284 @@ +/* Save current context, powerpc32 common. + Copyright (C) 2005 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., 51 Franklin Street, Fifth Floor, Boston MA + 02110-1301 USA. */ + +/* This is the common implementation of getcontext for powerpc32. + It not complete in itself should be included in to a framework that + defines: + __CONTEXT_FUNC_NAME + and if appropriate: + __CONTEXT_ENABLE_FPRS + __CONTEXT_ENABLE_VRS + Any archecture that implements the Vector unit is assumed to also + implement the floating unit. */ + +/* Stack frame offsets. */ +#define _FRAME_BACKCHAIN 0 +#define _FRAME_LR_SAVE 4 +#define _FRAME_PARM_SAVE1 8 +#define _FRAME_PARM_SAVE2 12 +#define _FRAME_PARM_SAVE3 16 +#define _FRAME_PARM_SAVE4 20 + +#ifdef __CONTEXT_ENABLE_VRS + .machine "altivec" +#endif +ENTRY(__CONTEXT_FUNC_NAME) + stwu r1,-16(r1) +/* Insure that the _UC_REGS start on a quadword boundary. */ + stw r3,_FRAME_PARM_SAVE1(r1) + addi r3,r3,_UC_REG_SPACE+12 + clrrwi r3,r3,4 + +/* Save the general purpose registers */ + stw r0,_UC_GREGS+(PT_R0*4)(r3) + mflr r0 + stw r2,_UC_GREGS+(PT_R2*4)(r3) + stw r4,_UC_GREGS+(PT_R4*4)(r3) +/* Set the callers LR_SAVE, and the ucontext LR and NIP to the callers + return address. */ + stw r0,_UC_GREGS+(PT_LNK*4)(r3) + stw r0,_UC_GREGS+(PT_NIP*4)(r3) + stw r0,_FRAME_LR_SAVE+16(r1) + stw r5,_UC_GREGS+(PT_R5*4)(r3) + stw r6,_UC_GREGS+(PT_R6*4)(r3) + stw r7,_UC_GREGS+(PT_R7*4)(r3) + stw r8,_UC_GREGS+(PT_R8*4)(r3) + stw r9,_UC_GREGS+(PT_R9*4)(r3) + stw r10,_UC_GREGS+(PT_R10*4)(r3) + stw r11,_UC_GREGS+(PT_R11*4)(r3) + stw r12,_UC_GREGS+(PT_R12*4)(r3) + stw r13,_UC_GREGS+(PT_R13*4)(r3) + stw r14,_UC_GREGS+(PT_R14*4)(r3) + stw r15,_UC_GREGS+(PT_R15*4)(r3) + stw r16,_UC_GREGS+(PT_R16*4)(r3) + stw r17,_UC_GREGS+(PT_R17*4)(r3) + stw r18,_UC_GREGS+(PT_R18*4)(r3) + stw r19,_UC_GREGS+(PT_R19*4)(r3) + stw r20,_UC_GREGS+(PT_R20*4)(r3) + stw r21,_UC_GREGS+(PT_R21*4)(r3) + stw r22,_UC_GREGS+(PT_R22*4)(r3) + stw r23,_UC_GREGS+(PT_R23*4)(r3) + stw r24,_UC_GREGS+(PT_R24*4)(r3) + stw r25,_UC_GREGS+(PT_R25*4)(r3) + stw r26,_UC_GREGS+(PT_R26*4)(r3) + stw r27,_UC_GREGS+(PT_R27*4)(r3) + stw r28,_UC_GREGS+(PT_R28*4)(r3) + stw r29,_UC_GREGS+(PT_R29*4)(r3) + stw r30,_UC_GREGS+(PT_R30*4)(r3) + stw r31,_UC_GREGS+(PT_R31*4)(r3) +/* Save the value of R1. We had to push the stack before we + had the address of uc_reg_space. So compute the address of + the callers stack pointer and save it as R1. */ + addi r8,r1,16 + li r0,0 +/* Save the count, exception and condition registers. */ + mfctr r11 + mfxer r10 + mfcr r9 + stw r8,_UC_GREGS+(PT_R1*4)(r3) + stw r11,_UC_GREGS+(PT_CTR*4)(r3) + stw r10,_UC_GREGS+(PT_XER*4)(r3) + stw r9,_UC_GREGS+(PT_CCR*4)(r3) +/* Set the return value of getcontext to "success". R3 is the only + register whose value is not preserved in the saved context. */ + stw r0,_UC_GREGS+(PT_R3*4)(r3) + +/* Zero fill fields that can't be set in user state. */ + stw r0,_UC_GREGS+(PT_MSR*4)(r3) + stw r0,_UC_GREGS+(PT_MQ*4)(r3) + +#ifdef __CONTEXT_ENABLE_FPRS +/* Save the floating-point registers */ + stfd fp0,_UC_FREGS+(0*8)(r3) + stfd fp1,_UC_FREGS+(1*8)(r3) + stfd fp2,_UC_FREGS+(2*8)(r3) + stfd fp3,_UC_FREGS+(3*8)(r3) + stfd fp4,_UC_FREGS+(4*8)(r3) + stfd fp5,_UC_FREGS+(5*8)(r3) + stfd fp6,_UC_FREGS+(6*8)(r3) + stfd fp7,_UC_FREGS+(7*8)(r3) + stfd fp8,_UC_FREGS+(8*8)(r3) + stfd fp9,_UC_FREGS+(9*8)(r3) + stfd fp10,_UC_FREGS+(10*8)(r3) + stfd fp11,_UC_FREGS+(11*8)(r3) + stfd fp12,_UC_FREGS+(12*8)(r3) + stfd fp13,_UC_FREGS+(13*8)(r3) + stfd fp14,_UC_FREGS+(14*8)(r3) + stfd fp15,_UC_FREGS+(15*8)(r3) + stfd fp16,_UC_FREGS+(16*8)(r3) + stfd fp17,_UC_FREGS+(17*8)(r3) + stfd fp18,_UC_FREGS+(18*8)(r3) + stfd fp19,_UC_FREGS+(19*8)(r3) + stfd fp20,_UC_FREGS+(20*8)(r3) + stfd fp21,_UC_FREGS+(21*8)(r3) + stfd fp22,_UC_FREGS+(22*8)(r3) + stfd fp23,_UC_FREGS+(23*8)(r3) + stfd fp24,_UC_FREGS+(24*8)(r3) + stfd fp25,_UC_FREGS+(25*8)(r3) + stfd fp26,_UC_FREGS+(26*8)(r3) + stfd fp27,_UC_FREGS+(27*8)(r3) + stfd fp28,_UC_FREGS+(28*8)(r3) + stfd fp29,_UC_FREGS+(29*8)(r3) + mffs fp0 + stfd fp30,_UC_FREGS+(30*8)(r3) + stfd fp31,_UC_FREGS+(31*8)(r3) + stfd fp0,_UC_FREGS+(32*8)(r3) + +# ifdef __CONTEXT_ENABLE_VRS +# ifdef PIC + mflr r8 +# ifdef HAVE_ASM_PPC_REL16 + bcl 20,31,1f +1: mflr r7 + addis r7,r7,_GLOBAL_OFFSET_TABLE_-1b@ha + addi r7,r7,_GLOBAL_OFFSET_TABLE_-1b@l +# else + bl _GLOBAL_OFFSET_TABLE_@local-4 + mflr r7 +# endif +# ifdef SHARED + lwz r7,_rtld_global_ro@got(r7) + mtlr r8 + lwz r7,RTLD_GLOBAL_RO_DL_HWCAP_OFFSET(r7) +# else + lwz r7,_dl_hwcap@got(r7) + mtlr r8 + lwz r7,0(r7) +# endif +# else + lis r7,_dl_hwcap@ha + lwz r7,_dl_hwcap@l(r7) +# endif + andis. r7,r7,(PPC_FEATURE_HAS_ALTIVEC >> 16) + + la r10,(_UC_VREGS)(r3) + la r9,(_UC_VREGS+16)(r3) + + beq 2f /* L(no_vec) */ +/* address of the combined VSCR/VSAVE quadword. */ + la r8,(_UC_VREGS+512)(r3) + +/* Save the vector registers */ + stvx v0,0,r10 + stvx v1,0,r9 + addi r10,r10,32 + addi r9,r9,32 +/* We need to get the Vector Status and Control Register early to avoid + store order problems later with the VSAVE register that shares the + same quadword. */ + mfvscr v0 + + stvx v2,0,r10 + stvx v3,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v0,0,r8 + + stvx v4,0,r10 + stvx v5,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v6,0,r10 + stvx v7,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v8,0,r10 + stvx v9,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v10,0,r10 + stvx v11,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v12,0,r10 + stvx v13,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v14,0,r10 + stvx v15,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v16,0,r10 + stvx v17,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v18,0,r10 + stvx v19,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v20,0,r10 + stvx v21,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v22,0,r10 + stvx v23,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v24,0,r10 + stvx v25,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v26,0,r10 + stvx v27,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v28,0,r10 + stvx v29,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + mfspr r0,VRSAVE + stvx v30,0,r10 + stvx v31,0,r9 + + stw r0,0(r8) + +2: /* L(no_vec): */ +# endif +#endif +/* We need to set up parms and call sigprocmask which will clobber + volatile registers. So before the call we need to retrieve the + original ucontext ptr (parm1) from stack and store the UC_REGS_PTR + (current R3). */ + lwz r12,_FRAME_PARM_SAVE1(r1) + li r4,0 + stw r3,_UC_REGS_PTR(r12) + addi r5,r12,_UC_SIGMASK + li r3,SIG_BLOCK + bl __sigprocmask@local + + lwz r0,_FRAME_LR_SAVE+16(r1) + addi r1,r1,16 + mtlr r0 + blr +END(__CONTEXT_FUNC_NAME) + diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext.S index 10211458d5..dad1074034 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext.S @@ -1,5 +1,5 @@ /* Save current context. - Copyright (C) 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2005 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 @@ -14,369 +14,53 @@ 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. */ + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA + 02110-1301 USA. */ #include <sysdep.h> #include <rtld-global-offsets.h> #include <shlib-compat.h> +#include <kernel-features.h> #define __ASSEMBLY__ #include <asm/ptrace.h> #include "ucontext_i.h" - .machine "altivec" -ENTRY(__getcontext) - stwu r1,-16(r1) -/* Insure that the _UC_REGS start on a quadword boundary. */ - stw r3,_FRAME_PARM_SAVE1(r1) - addi r3,r3,_UC_REG_SPACE+12 - clrrwi r3,r3,4 +#define __CONTEXT_FUNC_NAME __getcontext +#define __CONTEXT_ENABLE_FPRS 1 +#define __CONTEXT_ENABLE_VRS 1 -/* Save the general purpose registers */ - stw r0,_UC_GREGS+(PT_R0*4)(r3) - mflr r0 - stw r2,_UC_GREGS+(PT_R2*4)(r3) - stw r4,_UC_GREGS+(PT_R4*4)(r3) -/* Set the callers LR_SAVE, and the ucontext LR and NIP to the callers - return address. */ - stw r0,_UC_GREGS+(PT_LNK*4)(r3) - stw r0,_UC_GREGS+(PT_NIP*4)(r3) - stw r0,_FRAME_LR_SAVE+16(r1) - stw r5,_UC_GREGS+(PT_R5*4)(r3) - stw r6,_UC_GREGS+(PT_R6*4)(r3) - stw r7,_UC_GREGS+(PT_R7*4)(r3) - stw r8,_UC_GREGS+(PT_R8*4)(r3) - stw r9,_UC_GREGS+(PT_R9*4)(r3) - stw r10,_UC_GREGS+(PT_R10*4)(r3) - stw r11,_UC_GREGS+(PT_R11*4)(r3) - stw r12,_UC_GREGS+(PT_R12*4)(r3) - stw r13,_UC_GREGS+(PT_R13*4)(r3) - stw r14,_UC_GREGS+(PT_R14*4)(r3) - stw r15,_UC_GREGS+(PT_R15*4)(r3) - stw r16,_UC_GREGS+(PT_R16*4)(r3) - stw r17,_UC_GREGS+(PT_R17*4)(r3) - stw r18,_UC_GREGS+(PT_R18*4)(r3) - stw r19,_UC_GREGS+(PT_R19*4)(r3) - stw r20,_UC_GREGS+(PT_R20*4)(r3) - stw r21,_UC_GREGS+(PT_R21*4)(r3) - stw r22,_UC_GREGS+(PT_R22*4)(r3) - stw r23,_UC_GREGS+(PT_R23*4)(r3) - stw r24,_UC_GREGS+(PT_R24*4)(r3) - stw r25,_UC_GREGS+(PT_R25*4)(r3) - stw r26,_UC_GREGS+(PT_R26*4)(r3) - stw r27,_UC_GREGS+(PT_R27*4)(r3) - stw r28,_UC_GREGS+(PT_R28*4)(r3) - stw r29,_UC_GREGS+(PT_R29*4)(r3) - stw r30,_UC_GREGS+(PT_R30*4)(r3) - stw r31,_UC_GREGS+(PT_R31*4)(r3) -/* Save the value of R1. We had to push the stack before we - had the address of uc_reg_space. So compute the address of - the callers stack pointer and save it as R1. */ - addi r8,r1,16 - li r0,0 -/* Save the count, exception and condition registers. */ - mfctr r11 - mfxer r10 - mfcr r9 - stw r8,_UC_GREGS+(PT_R1*4)(r3) - stw r11,_UC_GREGS+(PT_CTR*4)(r3) - stw r10,_UC_GREGS+(PT_XER*4)(r3) - stw r9,_UC_GREGS+(PT_CCR*4)(r3) -/* Set the return value of getcontext to "success". R3 is the only - register whose value is not preserved in the saved context. */ - stw r0,_UC_GREGS+(PT_R3*4)(r3) +/* Size of ucontext in GLIBC_2.3.4 and later. */ +#define _UC_SIZE_2_3_4 1184 -/* Zero fill fields that can't be set in user state. */ - stw r0,_UC_GREGS+(PT_MSR*4)(r3) - stw r0,_UC_GREGS+(PT_MQ*4)(r3) - -/* Save the floating-point registers */ - stfd fp0,_UC_FREGS+(0*8)(r3) - stfd fp1,_UC_FREGS+(1*8)(r3) - stfd fp2,_UC_FREGS+(2*8)(r3) - stfd fp3,_UC_FREGS+(3*8)(r3) - stfd fp4,_UC_FREGS+(4*8)(r3) - stfd fp5,_UC_FREGS+(5*8)(r3) - stfd fp6,_UC_FREGS+(6*8)(r3) - stfd fp7,_UC_FREGS+(7*8)(r3) - stfd fp8,_UC_FREGS+(8*8)(r3) - stfd fp9,_UC_FREGS+(9*8)(r3) - stfd fp10,_UC_FREGS+(10*8)(r3) - stfd fp11,_UC_FREGS+(11*8)(r3) - stfd fp12,_UC_FREGS+(12*8)(r3) - stfd fp13,_UC_FREGS+(13*8)(r3) - stfd fp14,_UC_FREGS+(14*8)(r3) - stfd fp15,_UC_FREGS+(15*8)(r3) - stfd fp16,_UC_FREGS+(16*8)(r3) - stfd fp17,_UC_FREGS+(17*8)(r3) - stfd fp18,_UC_FREGS+(18*8)(r3) - stfd fp19,_UC_FREGS+(19*8)(r3) - stfd fp20,_UC_FREGS+(20*8)(r3) - stfd fp21,_UC_FREGS+(21*8)(r3) - stfd fp22,_UC_FREGS+(22*8)(r3) - stfd fp23,_UC_FREGS+(23*8)(r3) - stfd fp24,_UC_FREGS+(24*8)(r3) - stfd fp25,_UC_FREGS+(25*8)(r3) - stfd fp26,_UC_FREGS+(26*8)(r3) - stfd fp27,_UC_FREGS+(27*8)(r3) - stfd fp28,_UC_FREGS+(28*8)(r3) - stfd fp29,_UC_FREGS+(29*8)(r3) - mffs fp0 - stfd fp30,_UC_FREGS+(30*8)(r3) - stfd fp31,_UC_FREGS+(31*8)(r3) - stfd fp0,_UC_FREGS+(32*8)(r3) - -#ifdef PIC - mflr r8 -# ifdef HAVE_ASM_PPC_REL16 - bcl 20,31,1f -1: mflr r7 - addis r7,r7,_GLOBAL_OFFSET_TABLE_-1b@ha - addi r7,r7,_GLOBAL_OFFSET_TABLE_-1b@l -# else - bl _GLOBAL_OFFSET_TABLE_@local-4 - mflr r7 -# endif -# ifdef SHARED - lwz r7,_rtld_global_ro@got(r7) - mtlr r8 - lwz r7,RTLD_GLOBAL_RO_DL_HWCAP_OFFSET(r7) -# else - lwz r7,_dl_hwcap@got(r7) - mtlr r8 - lwz r7,0(r7) -# endif -#else - lis r7,_dl_hwcap@ha - lwz r7,_dl_hwcap@l(r7) -#endif - andis. r7,r7,(PPC_FEATURE_HAS_ALTIVEC >> 16) - - la r10,(_UC_VREGS)(r3) - la r9,(_UC_VREGS+16)(r3) - - beq L(no_vec) -/* address of the combined VSCR/VSAVE quadword. */ - la r8,(_UC_VREGS+512)(r3) - -/* Save the vector registers */ - stvx v0,0,r10 - stvx v1,0,r9 - addi r10,r10,32 - addi r9,r9,32 -/* We need to get the Vector Status and Control Register early to avoid - store order problems later with the VSAVE register that shares the - same quadword. */ - mfvscr v0 - - stvx v2,0,r10 - stvx v3,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v0,0,r8 - - stvx v4,0,r10 - stvx v5,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v6,0,r10 - stvx v7,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v8,0,r10 - stvx v9,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v10,0,r10 - stvx v11,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v12,0,r10 - stvx v13,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v14,0,r10 - stvx v15,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v16,0,r10 - stvx v17,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v18,0,r10 - stvx v19,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v20,0,r10 - stvx v21,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v22,0,r10 - stvx v23,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v24,0,r10 - stvx v25,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v26,0,r10 - stvx v27,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v28,0,r10 - stvx v29,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - mfspr r0,VRSAVE - stvx v30,0,r10 - stvx v31,0,r9 - - stw r0,0(r8) - -L(no_vec): -/* We need to set up parms and call sigprocmask which will clobber - volatile registers. So before the call we need to retrieve the - original ucontext ptr (parm1) from stack and store the UC_REGS_PTR - (current R3). */ - lwz r12,_FRAME_PARM_SAVE1(r1) +#ifdef __ASSUME_SWAPCONTEXT_SYSCALL + .section ".text"; +ENTRY (__getcontext) li r4,0 - stw r3,_UC_REGS_PTR(r12) - addi r5,r12,_UC_SIGMASK - li r3,SIG_BLOCK - bl __sigprocmask@local - - lwz r0,_FRAME_LR_SAVE+16(r1) - addi r1,r1,16 - mtlr r0 + li r5,_UC_SIZE_2_3_4; + DO_CALL (SYS_ify (swapcontext)); + bso- cr0,1f +/* the kernel does not set the return code for the success case */ + li r3,0 blr +1: + b __syscall_error@local END(__getcontext) +#else +# include "getcontext-common.S" +#endif versioned_symbol (libc, __getcontext, getcontext, GLIBC_2_3_4) #if SHLIB_COMPAT (libc, GLIBC_2_3_3, GLIBC_2_3_4) - compat_text_section -ENTRY(__novec_getcontext) - /* - * Since we are not attempting to save the altivec registers, - * there is no need to get the register storage space - * aligned on a 16-byte boundary. - */ - addi r3,r3,_UC_REG_SPACE - stw r3,_UC_REGS_PTR - _UC_REG_SPACE(r3) - stw r0,_UC_GREGS+(PT_R0*4)(r3) - stw r1,_UC_GREGS+(PT_R1*4)(r3) - mflr r0 - stwu r1,-16(r1) - stw r0,20(r1) - stw r0,_UC_GREGS+(PT_LNK*4)(r3) - stw r0,_UC_GREGS+(PT_NIP*4)(r3) - stw r2,_UC_GREGS+(PT_R2*4)(r3) - stw r4,_UC_GREGS+(PT_R4*4)(r3) - stw r5,_UC_GREGS+(PT_R5*4)(r3) - stw r6,_UC_GREGS+(PT_R6*4)(r3) - stw r7,_UC_GREGS+(PT_R7*4)(r3) - stw r8,_UC_GREGS+(PT_R8*4)(r3) - stw r9,_UC_GREGS+(PT_R9*4)(r3) - stw r10,_UC_GREGS+(PT_R10*4)(r3) - stw r11,_UC_GREGS+(PT_R11*4)(r3) - stw r12,_UC_GREGS+(PT_R12*4)(r3) - stw r13,_UC_GREGS+(PT_R13*4)(r3) - stw r14,_UC_GREGS+(PT_R14*4)(r3) - stw r15,_UC_GREGS+(PT_R15*4)(r3) - stw r16,_UC_GREGS+(PT_R16*4)(r3) - stw r17,_UC_GREGS+(PT_R17*4)(r3) - stw r18,_UC_GREGS+(PT_R18*4)(r3) - stw r19,_UC_GREGS+(PT_R19*4)(r3) - stw r20,_UC_GREGS+(PT_R20*4)(r3) - stw r21,_UC_GREGS+(PT_R21*4)(r3) - stw r22,_UC_GREGS+(PT_R22*4)(r3) - stw r23,_UC_GREGS+(PT_R23*4)(r3) - stw r24,_UC_GREGS+(PT_R24*4)(r3) - stw r25,_UC_GREGS+(PT_R25*4)(r3) - stw r26,_UC_GREGS+(PT_R26*4)(r3) - stw r27,_UC_GREGS+(PT_R27*4)(r3) - stw r28,_UC_GREGS+(PT_R28*4)(r3) - stw r29,_UC_GREGS+(PT_R29*4)(r3) - stw r30,_UC_GREGS+(PT_R30*4)(r3) - stw r31,_UC_GREGS+(PT_R31*4)(r3) - mfctr r0 - stw r0,_UC_GREGS+(PT_CTR*4)(r3) - mfxer r0 - stw r0,_UC_GREGS+(PT_XER*4)(r3) - mfcr r0 - stw r0,_UC_GREGS+(PT_CCR*4)(r3) - - /* Set the return value of getcontext to "success". R3 is the only - register whose value is not preserved in the saved context. */ - li r0,0 - stw r0,_UC_GREGS+(PT_R3*4)(r3) - - /* Zero fill fields that can't be set in user state. */ - stw r0,_UC_GREGS+(PT_MSR*4)(r3) - stw r0,_UC_GREGS+(PT_MQ*4)(r3) - - /* Save the floating-point registers */ - stfd fp0,_UC_FREGS+(0*8)(r3) - stfd fp1,_UC_FREGS+(1*8)(r3) - stfd fp2,_UC_FREGS+(2*8)(r3) - stfd fp3,_UC_FREGS+(3*8)(r3) - stfd fp4,_UC_FREGS+(4*8)(r3) - stfd fp5,_UC_FREGS+(5*8)(r3) - stfd fp6,_UC_FREGS+(6*8)(r3) - stfd fp7,_UC_FREGS+(7*8)(r3) - stfd fp8,_UC_FREGS+(8*8)(r3) - stfd fp9,_UC_FREGS+(9*8)(r3) - stfd fp10,_UC_FREGS+(10*8)(r3) - stfd fp11,_UC_FREGS+(11*8)(r3) - stfd fp12,_UC_FREGS+(12*8)(r3) - stfd fp13,_UC_FREGS+(13*8)(r3) - stfd fp14,_UC_FREGS+(14*8)(r3) - stfd fp15,_UC_FREGS+(15*8)(r3) - stfd fp16,_UC_FREGS+(16*8)(r3) - stfd fp17,_UC_FREGS+(17*8)(r3) - stfd fp18,_UC_FREGS+(18*8)(r3) - stfd fp19,_UC_FREGS+(19*8)(r3) - stfd fp20,_UC_FREGS+(20*8)(r3) - stfd fp21,_UC_FREGS+(21*8)(r3) - stfd fp22,_UC_FREGS+(22*8)(r3) - stfd fp23,_UC_FREGS+(23*8)(r3) - stfd fp24,_UC_FREGS+(24*8)(r3) - stfd fp25,_UC_FREGS+(25*8)(r3) - stfd fp26,_UC_FREGS+(26*8)(r3) - stfd fp27,_UC_FREGS+(27*8)(r3) - stfd fp28,_UC_FREGS+(28*8)(r3) - stfd fp29,_UC_FREGS+(29*8)(r3) - mffs fp0 - stfd fp30,_UC_FREGS+(30*8)(r3) - stfd fp31,_UC_FREGS+(31*8)(r3) - stfd fp0,_UC_FREGS+(32*8)(r3) + +# undef __CONTEXT_FUNC_NAME +# define __CONTEXT_FUNC_NAME __novec_getcontext +# undef __CONTEXT_ENABLE_VRS - addi r5,r3,_UC_SIGMASK - _UC_REG_SPACE - li r4,0 - li r3,SIG_BLOCK - bl __sigprocmask@local +# clude "getcontext-common.S" - lwz r0,20(r1) - addi r1,r1,16 - mtlr r0 - blr -END(__novec_getcontext) .previous compat_symbol (libc, __novec_getcontext, getcontext, GLIBC_2_3_3) @@ -385,8 +69,8 @@ compat_symbol (libc, __novec_getcontext, getcontext, GLIBC_2_3_3) #if SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_3_3) -#define _ERRNO_H 1 -#include <bits/errno.h> +# define _ERRNO_H 1 +# include <bits/errno.h> compat_text_section ENTRY (__getcontext_stub) diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext-common.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext-common.S new file mode 100644 index 0000000000..c71fcd73d5 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext-common.S @@ -0,0 +1,290 @@ +/* Jump to a new context powerpc32 common. + Copyright (C) 2005 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., 51 Franklin Street, Fifth Floor, Boston MA + 02110-1301 USA. */ + +/* This is the common implementation of setcontext for powerpc32. + It not complete in itself should be included in to a framework that + defines: + __CONTEXT_FUNC_NAME + and if appropriate: + __CONTEXT_ENABLE_FPRS + __CONTEXT_ENABLE_VRS + Any archecture that implements the Vector unit is assumed to also + implement the floating unit. */ + +/* Stack frame offsets. */ +#define _FRAME_BACKCHAIN 0 +#define _FRAME_LR_SAVE 4 +#define _FRAME_PARM_SAVE1 8 +#define _FRAME_PARM_SAVE2 12 +#define _FRAME_PARM_SAVE3 16 +#define _FRAME_PARM_SAVE4 20 + +#ifdef __CONTEXT_ENABLE_VRS + .machine "altivec" +#endif +ENTRY(__CONTEXT_FUNC_NAME) + mflr r0 + stwu r1,-16(r1) + stw r0,20(r1) + stw r31,12(r1) + lwz r31,_UC_REGS_PTR(r3) + + /* + * If this ucontext refers to the point where we were interrupted + * by a signal, we have to use the rt_sigreturn system call to + * return to the context so we get both LR and CTR restored. + * + * Otherwise, the context we are restoring is either just after + * a procedure call (getcontext/swapcontext) or at the beginning + * of a procedure call (makecontext), so we don't need to restore + * r0, xer, ctr. We don't restore r2 since it will be used as + * the TLS pointer. + */ + lwz r0,_UC_GREGS+(PT_MSR*4)(r31) + cmpwi r0,0 + bne 4f /* L(do_sigret) */ + + /* Restore the signal mask */ + li r5,0 + addi r4,r3,_UC_SIGMASK + li r3,SIG_SETMASK + bl __sigprocmask@local + cmpwi r3,0 + bne 3f /* L(error_exit) */ + +#ifdef __CONTEXT_ENABLE_FPRS +# ifdef __CONTEXT_ENABLE_VRS +# ifdef PIC + mflr r8 +# ifdef HAVE_ASM_PPC_REL16 + bcl 20,31,1f +1: mflr r7 + addis r7,r7,_GLOBAL_OFFSET_TABLE_-1b@ha + addi r7,r7,_GLOBAL_OFFSET_TABLE_-1b@l +# else + bl _GLOBAL_OFFSET_TABLE_@local-4 + mflr r7 +# endif +# ifdef SHARED + lwz r7,_rtld_global_ro@got(r7) + mtlr r8 + lwz r7,RTLD_GLOBAL_RO_DL_HWCAP_OFFSET(r7) +# else + lwz r7,_dl_hwcap@got(r7) + mtlr r8 + lwz r7,0(r7) +# endif +# else + lis r7,_dl_hwcap@ha + lwz r7,_dl_hwcap@l(r7) +# endif + andis. r7,r7,(PPC_FEATURE_HAS_ALTIVEC >> 16) + la r10,(_UC_VREGS)(r31) + beq 2f /* L(has_no_vec) */ + + lwz r0,(32*16)(r10) + li r9,(32*16) + cmpwi r0,0 + mtspr VRSAVE,r0 + beq 2f /* L(has_no_vec) */ + + lvx v19,r9,r10 + la r9,(16)(r10) + + lvx v0,0,r10 + lvx v1,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + mtvscr v19 + lvx v2,0,r10 + lvx v3,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v4,0,r10 + lvx v5,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v6,0,r10 + lvx v7,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v8,0,r10 + lvx v9,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v10,0,r10 + lvx v11,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v12,0,r10 + lvx v13,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v14,0,r10 + lvx v15,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v16,0,r10 + lvx v17,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v18,0,r10 + lvx v19,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v20,0,r10 + lvx v21,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v22,0,r10 + lvx v23,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v24,0,r10 + lvx v25,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v26,0,r10 + lvx v27,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v28,0,r10 + lvx v29,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v30,0,r10 + lvx v31,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v10,0,r10 + lvx v11,0,r9 + +2: /* L(has_no_vec): */ +# endif /* __CONTEXT_ENABLE_VRS */ + /* Restore the floating-point registers */ + lfd fp31,_UC_FREGS+(32*8)(r31) + lfd fp0,_UC_FREGS+(0*8)(r31) + mtfsf 0xff,fp31 + lfd fp1,_UC_FREGS+(1*8)(r31) + lfd fp2,_UC_FREGS+(2*8)(r31) + lfd fp3,_UC_FREGS+(3*8)(r31) + lfd fp4,_UC_FREGS+(4*8)(r31) + lfd fp5,_UC_FREGS+(5*8)(r31) + lfd fp6,_UC_FREGS+(6*8)(r31) + lfd fp7,_UC_FREGS+(7*8)(r31) + lfd fp8,_UC_FREGS+(8*8)(r31) + lfd fp9,_UC_FREGS+(9*8)(r31) + lfd fp10,_UC_FREGS+(10*8)(r31) + lfd fp11,_UC_FREGS+(11*8)(r31) + lfd fp12,_UC_FREGS+(12*8)(r31) + lfd fp13,_UC_FREGS+(13*8)(r31) + lfd fp14,_UC_FREGS+(14*8)(r31) + lfd fp15,_UC_FREGS+(15*8)(r31) + lfd fp16,_UC_FREGS+(16*8)(r31) + lfd fp17,_UC_FREGS+(17*8)(r31) + lfd fp18,_UC_FREGS+(18*8)(r31) + lfd fp19,_UC_FREGS+(19*8)(r31) + lfd fp20,_UC_FREGS+(20*8)(r31) + lfd fp21,_UC_FREGS+(21*8)(r31) + lfd fp22,_UC_FREGS+(22*8)(r31) + lfd fp23,_UC_FREGS+(23*8)(r31) + lfd fp24,_UC_FREGS+(24*8)(r31) + lfd fp25,_UC_FREGS+(25*8)(r31) + lfd fp26,_UC_FREGS+(26*8)(r31) + lfd fp27,_UC_FREGS+(27*8)(r31) + lfd fp28,_UC_FREGS+(28*8)(r31) + lfd fp29,_UC_FREGS+(29*8)(r31) + lfd fp30,_UC_FREGS+(30*8)(r31) + lfd fp31,_UC_FREGS+(31*8)(r31) +#endif /* __CONTEXT_ENABLE_FPRS */ + + /* Restore LR and CCR, and set CTR to the NIP value */ + lwz r3,_UC_GREGS+(PT_LNK*4)(r31) + lwz r4,_UC_GREGS+(PT_NIP*4)(r31) + lwz r5,_UC_GREGS+(PT_CCR*4)(r31) + mtlr r3 + mtctr r4 + mtcr r5 + + /* Restore the general registers */ + lwz r1,_UC_GREGS+(PT_R1*4)(r31) + lwz r3,_UC_GREGS+(PT_R3*4)(r31) + lwz r4,_UC_GREGS+(PT_R4*4)(r31) + lwz r5,_UC_GREGS+(PT_R5*4)(r31) + lwz r6,_UC_GREGS+(PT_R6*4)(r31) + lwz r7,_UC_GREGS+(PT_R7*4)(r31) + lwz r8,_UC_GREGS+(PT_R8*4)(r31) + lwz r9,_UC_GREGS+(PT_R9*4)(r31) + lwz r10,_UC_GREGS+(PT_R10*4)(r31) + lwz r11,_UC_GREGS+(PT_R11*4)(r31) + lwz r12,_UC_GREGS+(PT_R12*4)(r31) + lwz r13,_UC_GREGS+(PT_R13*4)(r31) + lwz r14,_UC_GREGS+(PT_R14*4)(r31) + lwz r15,_UC_GREGS+(PT_R15*4)(r31) + lwz r16,_UC_GREGS+(PT_R16*4)(r31) + lwz r17,_UC_GREGS+(PT_R17*4)(r31) + lwz r18,_UC_GREGS+(PT_R18*4)(r31) + lwz r19,_UC_GREGS+(PT_R19*4)(r31) + lwz r20,_UC_GREGS+(PT_R20*4)(r31) + lwz r21,_UC_GREGS+(PT_R21*4)(r31) + lwz r22,_UC_GREGS+(PT_R22*4)(r31) + lwz r23,_UC_GREGS+(PT_R23*4)(r31) + lwz r24,_UC_GREGS+(PT_R24*4)(r31) + lwz r25,_UC_GREGS+(PT_R25*4)(r31) + lwz r26,_UC_GREGS+(PT_R26*4)(r31) + lwz r27,_UC_GREGS+(PT_R27*4)(r31) + lwz r28,_UC_GREGS+(PT_R28*4)(r31) + lwz r29,_UC_GREGS+(PT_R29*4)(r31) + lwz r30,_UC_GREGS+(PT_R30*4)(r31) + lwz r31,_UC_GREGS+(PT_R31*4)(r31) + + bctr + +3: /* L(error_exit): */ + lwz r31,12(r1) + lwz r0,20(r1) + addi r1,r1,16 + mtlr r0 + blr + + +4: /* L(do_sigret): */ + addi r1,r3,-0xd0 + li r0,SYS_ify(rt_sigreturn) + sc + /* NOTREACHED */ + +END (__CONTEXT_FUNC_NAME) + diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext.S index eff60f9bbf..7e9213c2d6 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext.S @@ -1,5 +1,5 @@ /* Jump to a new context. - Copyright (C) 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2005 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 @@ -14,8 +14,8 @@ 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. */ + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA + 02110-1301 USA. */ #include <sysdep.h> #include <rtld-global-offsets.h> @@ -25,379 +25,43 @@ #include <asm/ptrace.h> #include "ucontext_i.h" - .machine "altivec" -ENTRY(__setcontext) - mflr r0 - stwu r1,-16(r1) - stw r0,20(r1) - stw r31,12(r1) - lwz r31,_UC_REGS_PTR(r3) - - /* - * If this ucontext refers to the point where we were interrupted - * by a signal, we have to use the rt_sigreturn system call to - * return to the context so we get both LR and CTR restored. - * - * Otherwise, the context we are restoring is either just after - * a procedure call (getcontext/swapcontext) or at the beginning - * of a procedure call (makecontext), so we don't need to restore - * r0, xer, ctr. We don't restore r2 since it will be used as - * the TLS pointer. - */ - lwz r0,_UC_GREGS+(PT_MSR*4)(r31) - cmpwi r0,0 - bne L(do_sigret) - - /* Restore the signal mask */ - li r5,0 - addi r4,r3,_UC_SIGMASK - li r3,SIG_SETMASK - bl __sigprocmask@local - cmpwi r3,0 - bne L(error_exit) - -#ifdef PIC - mflr r8 -# ifdef HAVE_ASM_PPC_REL16 - bcl 20,31,1f -1: mflr r7 - addis r7,r7,_GLOBAL_OFFSET_TABLE_-1b@ha - addi r7,r7,_GLOBAL_OFFSET_TABLE_-1b@l -# else - bl _GLOBAL_OFFSET_TABLE_@local-4 - mflr r7 -# endif -# ifdef SHARED - lwz r7,_rtld_global_ro@got(r7) - mtlr r8 - lwz r7,RTLD_GLOBAL_RO_DL_HWCAP_OFFSET(r7) -# else - lwz r7,_dl_hwcap@got(r7) - mtlr r8 - lwz r7,0(r7) -# endif +#define __CONTEXT_FUNC_NAME __setcontext +#define __CONTEXT_ENABLE_FPRS 1 +#define __CONTEXT_ENABLE_VRS 1 + +/* Size of ucontext in GLIBC_2.3.4 and later. */ +#define _UC_SIZE_2_3_4 1184 + +#ifdef __ASSUME_SWAPCONTEXT_SYSCALL + .section ".text"; +ENTRY (__setcontext) + mr r4,r3 + li r3,0 + li r5,_UC_SIZE_2_3_4; + DO_CALL (SYS_ify (swapcontext)); + bso- cr0,1f +/* the kernel does not set the return code for the success case */ + li r3,0 + blr +1: + b __syscall_error@local +END(__setcontext) #else - lis r7,_dl_hwcap@ha - lwz r7,_dl_hwcap@l(r7) +# include "setcontext-common.S" #endif - andis. r7,r7,(PPC_FEATURE_HAS_ALTIVEC >> 16) - la r10,(_UC_VREGS)(r31) - beq L(has_no_vec) - - lwz r0,(32*16)(r10) - li r9,(32*16) - cmpwi r0,0 - mtspr VRSAVE,r0 - beq L(has_no_vec) - - lvx v19,r9,r10 - la r9,(16)(r10) - - lvx v0,0,r10 - lvx v1,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - mtvscr v19 - lvx v2,0,r10 - lvx v3,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v4,0,r10 - lvx v5,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v6,0,r10 - lvx v7,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v8,0,r10 - lvx v9,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v10,0,r10 - lvx v11,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v12,0,r10 - lvx v13,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v14,0,r10 - lvx v15,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v16,0,r10 - lvx v17,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v18,0,r10 - lvx v19,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v20,0,r10 - lvx v21,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v22,0,r10 - lvx v23,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v24,0,r10 - lvx v25,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v26,0,r10 - lvx v27,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v28,0,r10 - lvx v29,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v30,0,r10 - lvx v31,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v10,0,r10 - lvx v11,0,r9 - -L(has_no_vec): - /* Restore the floating-point registers */ - lfd fp31,_UC_FREGS+(32*8)(r31) - lfd fp0,_UC_FREGS+(0*8)(r31) - mtfsf 0xff,fp31 - lfd fp1,_UC_FREGS+(1*8)(r31) - lfd fp2,_UC_FREGS+(2*8)(r31) - lfd fp3,_UC_FREGS+(3*8)(r31) - lfd fp4,_UC_FREGS+(4*8)(r31) - lfd fp5,_UC_FREGS+(5*8)(r31) - lfd fp6,_UC_FREGS+(6*8)(r31) - lfd fp7,_UC_FREGS+(7*8)(r31) - lfd fp8,_UC_FREGS+(8*8)(r31) - lfd fp9,_UC_FREGS+(9*8)(r31) - lfd fp10,_UC_FREGS+(10*8)(r31) - lfd fp11,_UC_FREGS+(11*8)(r31) - lfd fp12,_UC_FREGS+(12*8)(r31) - lfd fp13,_UC_FREGS+(13*8)(r31) - lfd fp14,_UC_FREGS+(14*8)(r31) - lfd fp15,_UC_FREGS+(15*8)(r31) - lfd fp16,_UC_FREGS+(16*8)(r31) - lfd fp17,_UC_FREGS+(17*8)(r31) - lfd fp18,_UC_FREGS+(18*8)(r31) - lfd fp19,_UC_FREGS+(19*8)(r31) - lfd fp20,_UC_FREGS+(20*8)(r31) - lfd fp21,_UC_FREGS+(21*8)(r31) - lfd fp22,_UC_FREGS+(22*8)(r31) - lfd fp23,_UC_FREGS+(23*8)(r31) - lfd fp24,_UC_FREGS+(24*8)(r31) - lfd fp25,_UC_FREGS+(25*8)(r31) - lfd fp26,_UC_FREGS+(26*8)(r31) - lfd fp27,_UC_FREGS+(27*8)(r31) - lfd fp28,_UC_FREGS+(28*8)(r31) - lfd fp29,_UC_FREGS+(29*8)(r31) - lfd fp30,_UC_FREGS+(30*8)(r31) - lfd fp31,_UC_FREGS+(31*8)(r31) - - /* Restore LR and CCR, and set CTR to the NIP value */ - lwz r3,_UC_GREGS+(PT_LNK*4)(r31) - lwz r4,_UC_GREGS+(PT_NIP*4)(r31) - lwz r5,_UC_GREGS+(PT_CCR*4)(r31) - mtlr r3 - mtctr r4 - mtcr r5 - - /* Restore the general registers */ - lwz r1,_UC_GREGS+(PT_R1*4)(r31) - lwz r3,_UC_GREGS+(PT_R3*4)(r31) - lwz r4,_UC_GREGS+(PT_R4*4)(r31) - lwz r5,_UC_GREGS+(PT_R5*4)(r31) - lwz r6,_UC_GREGS+(PT_R6*4)(r31) - lwz r7,_UC_GREGS+(PT_R7*4)(r31) - lwz r8,_UC_GREGS+(PT_R8*4)(r31) - lwz r9,_UC_GREGS+(PT_R9*4)(r31) - lwz r10,_UC_GREGS+(PT_R10*4)(r31) - lwz r11,_UC_GREGS+(PT_R11*4)(r31) - lwz r12,_UC_GREGS+(PT_R12*4)(r31) - lwz r13,_UC_GREGS+(PT_R13*4)(r31) - lwz r14,_UC_GREGS+(PT_R14*4)(r31) - lwz r15,_UC_GREGS+(PT_R15*4)(r31) - lwz r16,_UC_GREGS+(PT_R16*4)(r31) - lwz r17,_UC_GREGS+(PT_R17*4)(r31) - lwz r18,_UC_GREGS+(PT_R18*4)(r31) - lwz r19,_UC_GREGS+(PT_R19*4)(r31) - lwz r20,_UC_GREGS+(PT_R20*4)(r31) - lwz r21,_UC_GREGS+(PT_R21*4)(r31) - lwz r22,_UC_GREGS+(PT_R22*4)(r31) - lwz r23,_UC_GREGS+(PT_R23*4)(r31) - lwz r24,_UC_GREGS+(PT_R24*4)(r31) - lwz r25,_UC_GREGS+(PT_R25*4)(r31) - lwz r26,_UC_GREGS+(PT_R26*4)(r31) - lwz r27,_UC_GREGS+(PT_R27*4)(r31) - lwz r28,_UC_GREGS+(PT_R28*4)(r31) - lwz r29,_UC_GREGS+(PT_R29*4)(r31) - lwz r30,_UC_GREGS+(PT_R30*4)(r31) - lwz r31,_UC_GREGS+(PT_R31*4)(r31) - - bctr - -L(error_exit): - lwz r31,12(r1) - lwz r0,20(r1) - addi r1,r1,16 - mtlr r0 - blr - -L(do_sigret): - addi r1,r3,-0xd0 - li r0,SYS_ify(rt_sigreturn) - sc - /* NOTREACHED */ - -END (__setcontext) versioned_symbol (libc, __setcontext, setcontext, GLIBC_2_3_4) #if SHLIB_COMPAT (libc, GLIBC_2_3_3, GLIBC_2_3_4) compat_text_section -ENTRY(__novec_setcontext) - mflr r0 - stwu r1,-16(r1) - stw r0,20(r1) - stw r31,12(r1) - lwz r31,_UC_REGS_PTR(r3) - - /* - * If this ucontext refers to the point where we were interrupted - * by a signal, we have to use the rt_sigreturn system call to - * return to the context so we get both LR and CTR restored. - * - * Otherwise, the context we are restoring is either just after - * a procedure call (getcontext/swapcontext) or at the beginning - * of a procedure call (makecontext), so we don't need to restore - * r0, xer, ctr. We don't restore r2 since it will be used as - * the TLS pointer. - */ - lwz r0,_UC_GREGS+(PT_MSR*4)(r31) - cmpwi r0,0 - bne L(novec_do_sigret) - - /* Restore the signal mask */ - li r5,0 - addi r4,r3,_UC_SIGMASK - li r3,SIG_SETMASK - bl __sigprocmask@local - cmpwi r3,0 - bne L(novec_error_exit) - - /* Restore the floating-point registers */ - lfd fp31,_UC_FREGS+(32*8)(r31) - lfd fp0,_UC_FREGS+(0*8)(r31) - mtfsf 0xff,fp31 - lfd fp1,_UC_FREGS+(1*8)(r31) - lfd fp2,_UC_FREGS+(2*8)(r31) - lfd fp3,_UC_FREGS+(3*8)(r31) - lfd fp4,_UC_FREGS+(4*8)(r31) - lfd fp5,_UC_FREGS+(5*8)(r31) - lfd fp6,_UC_FREGS+(6*8)(r31) - lfd fp7,_UC_FREGS+(7*8)(r31) - lfd fp8,_UC_FREGS+(8*8)(r31) - lfd fp9,_UC_FREGS+(9*8)(r31) - lfd fp10,_UC_FREGS+(10*8)(r31) - lfd fp11,_UC_FREGS+(11*8)(r31) - lfd fp12,_UC_FREGS+(12*8)(r31) - lfd fp13,_UC_FREGS+(13*8)(r31) - lfd fp14,_UC_FREGS+(14*8)(r31) - lfd fp15,_UC_FREGS+(15*8)(r31) - lfd fp16,_UC_FREGS+(16*8)(r31) - lfd fp17,_UC_FREGS+(17*8)(r31) - lfd fp18,_UC_FREGS+(18*8)(r31) - lfd fp19,_UC_FREGS+(19*8)(r31) - lfd fp20,_UC_FREGS+(20*8)(r31) - lfd fp21,_UC_FREGS+(21*8)(r31) - lfd fp22,_UC_FREGS+(22*8)(r31) - lfd fp23,_UC_FREGS+(23*8)(r31) - lfd fp24,_UC_FREGS+(24*8)(r31) - lfd fp25,_UC_FREGS+(25*8)(r31) - lfd fp26,_UC_FREGS+(26*8)(r31) - lfd fp27,_UC_FREGS+(27*8)(r31) - lfd fp28,_UC_FREGS+(28*8)(r31) - lfd fp29,_UC_FREGS+(29*8)(r31) - lfd fp30,_UC_FREGS+(30*8)(r31) - lfd fp31,_UC_FREGS+(31*8)(r31) - - /* Restore LR and CCR, and set CTR to the NIP value */ - lwz r3,_UC_GREGS+(PT_LNK*4)(r31) - lwz r4,_UC_GREGS+(PT_NIP*4)(r31) - lwz r5,_UC_GREGS+(PT_CCR*4)(r31) - mtlr r3 - mtctr r4 - mtcr r5 - - /* Restore the general registers */ - lwz r1,_UC_GREGS+(PT_R1*4)(r31) - lwz r3,_UC_GREGS+(PT_R3*4)(r31) - lwz r4,_UC_GREGS+(PT_R4*4)(r31) - lwz r5,_UC_GREGS+(PT_R5*4)(r31) - lwz r6,_UC_GREGS+(PT_R6*4)(r31) - lwz r7,_UC_GREGS+(PT_R7*4)(r31) - lwz r8,_UC_GREGS+(PT_R8*4)(r31) - lwz r9,_UC_GREGS+(PT_R9*4)(r31) - lwz r10,_UC_GREGS+(PT_R10*4)(r31) - lwz r11,_UC_GREGS+(PT_R11*4)(r31) - lwz r12,_UC_GREGS+(PT_R12*4)(r31) - lwz r13,_UC_GREGS+(PT_R13*4)(r31) - lwz r14,_UC_GREGS+(PT_R14*4)(r31) - lwz r15,_UC_GREGS+(PT_R15*4)(r31) - lwz r16,_UC_GREGS+(PT_R16*4)(r31) - lwz r17,_UC_GREGS+(PT_R17*4)(r31) - lwz r18,_UC_GREGS+(PT_R18*4)(r31) - lwz r19,_UC_GREGS+(PT_R19*4)(r31) - lwz r20,_UC_GREGS+(PT_R20*4)(r31) - lwz r21,_UC_GREGS+(PT_R21*4)(r31) - lwz r22,_UC_GREGS+(PT_R22*4)(r31) - lwz r23,_UC_GREGS+(PT_R23*4)(r31) - lwz r24,_UC_GREGS+(PT_R24*4)(r31) - lwz r25,_UC_GREGS+(PT_R25*4)(r31) - lwz r26,_UC_GREGS+(PT_R26*4)(r31) - lwz r27,_UC_GREGS+(PT_R27*4)(r31) - lwz r28,_UC_GREGS+(PT_R28*4)(r31) - lwz r29,_UC_GREGS+(PT_R29*4)(r31) - lwz r30,_UC_GREGS+(PT_R30*4)(r31) - lwz r31,_UC_GREGS+(PT_R31*4)(r31) - - bctr - -L(novec_error_exit): - lwz r31,12(r1) - lwz r0,20(r1) - addi r1,r1,16 - mtlr r0 - blr + +# undef __CONTEXT_FUNC_NAME +# define __CONTEXT_FUNC_NAME __novec_setcontext +# undef __CONTEXT_ENABLE_VRS -L(novec_do_sigret): - addi r1,r3,-0xd0 - li r0,SYS_ify(rt_sigreturn) - sc - /* NOTREACHED */ +# include "setcontext-common.S" -END (__novec_setcontext) .previous compat_symbol (libc, __novec_setcontext, setcontext, GLIBC_2_3_3) @@ -406,8 +70,8 @@ compat_symbol (libc, __novec_setcontext, setcontext, GLIBC_2_3_3) #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_3) -#define _ERRNO_H 1 -#include <bits/errno.h> +# define _ERRNO_H 1 +# include <bits/errno.h> compat_text_section ENTRY (__setcontext_stub) diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext-common.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext-common.S new file mode 100644 index 0000000000..8b2998b8fd --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext-common.S @@ -0,0 +1,516 @@ +/* Save current context and jump to a new context. + Copyright (C) 2005 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., 51 Franklin Street, Fifth Floor, Boston MA + 02110-1301 USA. */ + +/* This is the common implementation of setcontext for powerpc32. + It not complete in itself should be included in to a framework that + defines: + __CONTEXT_FUNC_NAME + and if appropriate: + __CONTEXT_ENABLE_FPRS + __CONTEXT_ENABLE_VRS + Any archecture that implements the Vector unit is assumed to also + implement the floating unit. */ + +/* Stack frame offsets. */ +#define _FRAME_BACKCHAIN 0 +#define _FRAME_LR_SAVE 4 +#define _FRAME_PARM_SAVE1 8 +#define _FRAME_PARM_SAVE2 12 +#define _FRAME_PARM_SAVE3 16 +#define _FRAME_PARM_SAVE4 20 + +#ifdef __CONTEXT_ENABLE_VRS + .machine "altivec" +#endif +ENTRY(__CONTEXT_FUNC_NAME) + stwu r1,-16(r1) +/* Insure that the _UC_REGS start on a quadword boundary. */ + stw r3,_FRAME_PARM_SAVE1(r1) + addi r3,r3,_UC_REG_SPACE+12 + stw r4,_FRAME_PARM_SAVE2(r1) /* new context pointer */ + clrrwi r3,r3,4 + +/* Save the general purpose registers */ + stw r0,_UC_GREGS+(PT_R0*4)(r3) + mflr r0 + stw r2,_UC_GREGS+(PT_R2*4)(r3) + stw r4,_UC_GREGS+(PT_R4*4)(r3) +/* Set the callers LR_SAVE, and the ucontext LR and NIP to the callers + return address. */ + stw r0,_UC_GREGS+(PT_LNK*4)(r3) + stw r0,_UC_GREGS+(PT_NIP*4)(r3) + stw r0,_FRAME_LR_SAVE+16(r1) + stw r5,_UC_GREGS+(PT_R5*4)(r3) + stw r6,_UC_GREGS+(PT_R6*4)(r3) + stw r7,_UC_GREGS+(PT_R7*4)(r3) + stw r8,_UC_GREGS+(PT_R8*4)(r3) + stw r9,_UC_GREGS+(PT_R9*4)(r3) + stw r10,_UC_GREGS+(PT_R10*4)(r3) + stw r11,_UC_GREGS+(PT_R11*4)(r3) + stw r12,_UC_GREGS+(PT_R12*4)(r3) + stw r13,_UC_GREGS+(PT_R13*4)(r3) + stw r14,_UC_GREGS+(PT_R14*4)(r3) + stw r15,_UC_GREGS+(PT_R15*4)(r3) + stw r16,_UC_GREGS+(PT_R16*4)(r3) + stw r17,_UC_GREGS+(PT_R17*4)(r3) + stw r18,_UC_GREGS+(PT_R18*4)(r3) + stw r19,_UC_GREGS+(PT_R19*4)(r3) + stw r20,_UC_GREGS+(PT_R20*4)(r3) + stw r21,_UC_GREGS+(PT_R21*4)(r3) + stw r22,_UC_GREGS+(PT_R22*4)(r3) + stw r23,_UC_GREGS+(PT_R23*4)(r3) + stw r24,_UC_GREGS+(PT_R24*4)(r3) + stw r25,_UC_GREGS+(PT_R25*4)(r3) + stw r26,_UC_GREGS+(PT_R26*4)(r3) + stw r27,_UC_GREGS+(PT_R27*4)(r3) + stw r28,_UC_GREGS+(PT_R28*4)(r3) + stw r29,_UC_GREGS+(PT_R29*4)(r3) + stw r30,_UC_GREGS+(PT_R30*4)(r3) + stw r31,_UC_GREGS+(PT_R31*4)(r3) + +/* Save the value of R1. We had to push the stack before we + had the address of uc_reg_space. So compute the address of + the callers stack pointer and save it as R1. */ + addi r8,r1,16 + li r0,0 +/* Save the count, exception and condition registers. */ + mfctr r11 + mfxer r10 + mfcr r9 + stw r8,_UC_GREGS+(PT_R1*4)(r3) + stw r11,_UC_GREGS+(PT_CTR*4)(r3) + stw r10,_UC_GREGS+(PT_XER*4)(r3) + stw r9,_UC_GREGS+(PT_CCR*4)(r3) +/* Set the return value of getcontext to "success". R3 is the only + register whose value is not preserved in the saved context. */ + stw r0,_UC_GREGS+(PT_R3*4)(r3) + + /* Zero fill fields that can't be set in user state. */ + stw r0,_UC_GREGS+(PT_MSR*4)(r3) + stw r0,_UC_GREGS+(PT_MQ*4)(r3) + +#ifdef __CONTEXT_ENABLE_FPRS + /* Save the floating-point registers */ + stfd fp0,_UC_FREGS+(0*8)(r3) + stfd fp1,_UC_FREGS+(1*8)(r3) + stfd fp2,_UC_FREGS+(2*8)(r3) + stfd fp3,_UC_FREGS+(3*8)(r3) + stfd fp4,_UC_FREGS+(4*8)(r3) + stfd fp5,_UC_FREGS+(5*8)(r3) + stfd fp6,_UC_FREGS+(6*8)(r3) + stfd fp7,_UC_FREGS+(7*8)(r3) + stfd fp8,_UC_FREGS+(8*8)(r3) + stfd fp9,_UC_FREGS+(9*8)(r3) + stfd fp10,_UC_FREGS+(10*8)(r3) + stfd fp11,_UC_FREGS+(11*8)(r3) + stfd fp12,_UC_FREGS+(12*8)(r3) + stfd fp13,_UC_FREGS+(13*8)(r3) + stfd fp14,_UC_FREGS+(14*8)(r3) + stfd fp15,_UC_FREGS+(15*8)(r3) + stfd fp16,_UC_FREGS+(16*8)(r3) + stfd fp17,_UC_FREGS+(17*8)(r3) + stfd fp18,_UC_FREGS+(18*8)(r3) + stfd fp19,_UC_FREGS+(19*8)(r3) + stfd fp20,_UC_FREGS+(20*8)(r3) + stfd fp21,_UC_FREGS+(21*8)(r3) + stfd fp22,_UC_FREGS+(22*8)(r3) + stfd fp23,_UC_FREGS+(23*8)(r3) + stfd fp24,_UC_FREGS+(24*8)(r3) + stfd fp25,_UC_FREGS+(25*8)(r3) + stfd fp26,_UC_FREGS+(26*8)(r3) + stfd fp27,_UC_FREGS+(27*8)(r3) + stfd fp28,_UC_FREGS+(28*8)(r3) + stfd fp29,_UC_FREGS+(29*8)(r3) + mffs fp0 + stfd fp30,_UC_FREGS+(30*8)(r3) + stfd fp31,_UC_FREGS+(31*8)(r3) + stfd fp0,_UC_FREGS+(32*8)(r3) + +# ifdef __CONTEXT_ENABLE_VRS +# ifdef PIC + mflr r8 +# ifdef HAVE_ASM_PPC_REL16 + bcl 20,31,1f +1: mflr r7 + addis r7,r7,_GLOBAL_OFFSET_TABLE_-1b@ha + addi r7,r7,_GLOBAL_OFFSET_TABLE_-1b@l +# else + bl _GLOBAL_OFFSET_TABLE_@local-4 + mflr r7 +# endif +# ifdef SHARED + lwz r7,_rtld_global_ro@got(r7) + mtlr r8 + lwz r7,RTLD_GLOBAL_RO_DL_HWCAP_OFFSET(r7) +# else + lwz r7,_dl_hwcap@got(r7) + mtlr r8 + lwz r7,0(r7) +# endif +# else + lis r7,_dl_hwcap@ha + lwz r7,_dl_hwcap@l(r7) +# endif + andis. r7,r7,(PPC_FEATURE_HAS_ALTIVEC >> 16) + + la r10,(_UC_VREGS)(r3) + la r9,(_UC_VREGS+16)(r3) + +/* beq L(no_vec)*/ + beq 2f +/* address of the combined VSCR/VSAVE quadword. */ + la r8,(_UC_VREGS+512)(r3) + +/* Save the vector registers */ + stvx v0,0,r10 + stvx v1,0,r9 + addi r10,r10,32 + addi r9,r9,32 +/* We need to get the Vector Status and Control Register early to avoid + store order problems later with the VSAVE register that shares the + same quadword. */ + mfvscr v0 + + stvx v2,0,r10 + stvx v3,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v0,0,r8 + + stvx v4,0,r10 + stvx v5,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v6,0,r10 + stvx v7,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v8,0,r10 + stvx v9,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v10,0,r10 + stvx v11,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v12,0,r10 + stvx v13,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v14,0,r10 + stvx v15,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v16,0,r10 + stvx v17,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v18,0,r10 + stvx v19,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v20,0,r10 + stvx v21,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v22,0,r10 + stvx v23,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v24,0,r10 + stvx v25,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v26,0,r10 + stvx v27,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + stvx v28,0,r10 + stvx v29,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + mfvscr v0 + stvx v30,0,r10 + stvx v31,0,r9 + stw r0,0(r8) + +2: /*L(no_vec):*/ +# endif /* __CONTEXT_ENABLE_VRS */ +#endif /* __CONTEXT_ENABLE_FPRS */ + +/* Restore ucontext (parm1) from stack. */ + lwz r12,_FRAME_PARM_SAVE1(r1) + li r4,0 + stw r3,_UC_REGS_PTR(r12) + addi r5,r12,_UC_SIGMASK + li r3,SIG_SETMASK + bl __sigprocmask@local + cmpwi r3,0 + bne 3f /* L(error_exit) */ + + /* + * If the new ucontext refers to the point where we were interrupted + * by a signal, we have to use the rt_sigreturn system call to + * return to the context so we get both LR and CTR restored. + * + * Otherwise, the context we are restoring is either just after + * a procedure call (getcontext/swapcontext) or at the beginning + * of a procedure call (makecontext), so we don't need to restore + * r0, xer, ctr. We don't restore r2 since it will be used as + * the TLS pointer. + */ + lwz r4,_FRAME_PARM_SAVE2(r1) + lwz r31,_UC_REGS_PTR(r4) + lwz r0,_UC_GREGS+(PT_MSR*4)(r31) + cmpwi r0,0 + bne 4f /* L(do_sigret) */ + +#ifdef __CONTEXT_ENABLE_FPRS +# ifdef __CONTEXT_ENABLE_VRS + +# ifdef PIC + mflr r8 +# ifdef HAVE_ASM_PPC_REL16 + bcl 20,31,5f +5: mflr r7 + addis r7,r7,_GLOBAL_OFFSET_TABLE_-1b@ha + addi r7,r7,_GLOBAL_OFFSET_TABLE_-1b@l +# else + bl _GLOBAL_OFFSET_TABLE_@local-4 + mflr r7 +# endif +# ifdef SHARED + lwz r7,_rtld_global_ro@got(r7) + mtlr r8 + lwz r7,RTLD_GLOBAL_RO_DL_HWCAP_OFFSET(r7) +# else + lwz r7,_dl_hwcap@got(r7) + mtlr r8 + lwz r7,0(r7) +# endif +# else + lis r7,_dl_hwcap@ha + lwz r7,_dl_hwcap@l(r7) +# endif + andis. r7,r7,(PPC_FEATURE_HAS_ALTIVEC >> 16) + la r10,(_UC_VREGS)(r31) + beq 6f /* L(has_no_vec) */ + + lwz r0,(32*16)(r10) + li r9,(32*16) + cmpwi r0,0 + mtspr VRSAVE,r0 + beq 6f /* L(has_no_vec) */ + + lvx v19,r9,r10 + la r9,(16)(r10) + + lvx v0,0,r10 + lvx v1,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + mtvscr v19 + lvx v2,0,r10 + lvx v3,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v4,0,r10 + lvx v5,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v6,0,r10 + lvx v7,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v8,0,r10 + lvx v9,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v10,0,r10 + lvx v11,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v12,0,r10 + lvx v13,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v14,0,r10 + lvx v15,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v16,0,r10 + lvx v17,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v18,0,r10 + lvx v19,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v20,0,r10 + lvx v21,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v22,0,r10 + lvx v23,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v24,0,r10 + lvx v25,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v26,0,r10 + lvx v27,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v28,0,r10 + lvx v29,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v30,0,r10 + lvx v31,0,r9 + addi r10,r10,32 + addi r9,r9,32 + + lvx v10,0,r10 + lvx v11,0,r9 + +6: /* L(has_no_vec): */ +# endif /* __CONTEXT_ENABLE_VRS */ + /* Restore the floating-point registers */ + lfd fp31,_UC_FREGS+(32*8)(r31) + lfd fp0,_UC_FREGS+(0*8)(r31) + mtfsf 0xff,fp31 + lfd fp1,_UC_FREGS+(1*8)(r31) + lfd fp2,_UC_FREGS+(2*8)(r31) + lfd fp3,_UC_FREGS+(3*8)(r31) + lfd fp4,_UC_FREGS+(4*8)(r31) + lfd fp5,_UC_FREGS+(5*8)(r31) + lfd fp6,_UC_FREGS+(6*8)(r31) + lfd fp7,_UC_FREGS+(7*8)(r31) + lfd fp8,_UC_FREGS+(8*8)(r31) + lfd fp9,_UC_FREGS+(9*8)(r31) + lfd fp10,_UC_FREGS+(10*8)(r31) + lfd fp11,_UC_FREGS+(11*8)(r31) + lfd fp12,_UC_FREGS+(12*8)(r31) + lfd fp13,_UC_FREGS+(13*8)(r31) + lfd fp14,_UC_FREGS+(14*8)(r31) + lfd fp15,_UC_FREGS+(15*8)(r31) + lfd fp16,_UC_FREGS+(16*8)(r31) + lfd fp17,_UC_FREGS+(17*8)(r31) + lfd fp18,_UC_FREGS+(18*8)(r31) + lfd fp19,_UC_FREGS+(19*8)(r31) + lfd fp20,_UC_FREGS+(20*8)(r31) + lfd fp21,_UC_FREGS+(21*8)(r31) + lfd fp22,_UC_FREGS+(22*8)(r31) + lfd fp23,_UC_FREGS+(23*8)(r31) + lfd fp24,_UC_FREGS+(24*8)(r31) + lfd fp25,_UC_FREGS+(25*8)(r31) + lfd fp26,_UC_FREGS+(26*8)(r31) + lfd fp27,_UC_FREGS+(27*8)(r31) + lfd fp28,_UC_FREGS+(28*8)(r31) + lfd fp29,_UC_FREGS+(29*8)(r31) + lfd fp30,_UC_FREGS+(30*8)(r31) + lfd fp31,_UC_FREGS+(31*8)(r31) +#endif /* __CONTEXT_ENABLE_FPRS */ + + /* Restore LR and CCR, and set CTR to the NIP value */ + lwz r3,_UC_GREGS+(PT_LNK*4)(r31) + lwz r4,_UC_GREGS+(PT_NIP*4)(r31) + lwz r5,_UC_GREGS+(PT_CCR*4)(r31) + mtlr r3 + mtctr r4 + mtcr r5 + + /* Restore the general registers */ + lwz r1,_UC_GREGS+(PT_R1*4)(r31) + lwz r3,_UC_GREGS+(PT_R3*4)(r31) + lwz r4,_UC_GREGS+(PT_R4*4)(r31) + lwz r5,_UC_GREGS+(PT_R5*4)(r31) + lwz r6,_UC_GREGS+(PT_R6*4)(r31) + lwz r7,_UC_GREGS+(PT_R7*4)(r31) + lwz r8,_UC_GREGS+(PT_R8*4)(r31) + lwz r9,_UC_GREGS+(PT_R9*4)(r31) + lwz r10,_UC_GREGS+(PT_R10*4)(r31) + lwz r11,_UC_GREGS+(PT_R11*4)(r31) + lwz r12,_UC_GREGS+(PT_R12*4)(r31) + lwz r13,_UC_GREGS+(PT_R13*4)(r31) + lwz r14,_UC_GREGS+(PT_R14*4)(r31) + lwz r15,_UC_GREGS+(PT_R15*4)(r31) + lwz r16,_UC_GREGS+(PT_R16*4)(r31) + lwz r17,_UC_GREGS+(PT_R17*4)(r31) + lwz r18,_UC_GREGS+(PT_R18*4)(r31) + lwz r19,_UC_GREGS+(PT_R19*4)(r31) + lwz r20,_UC_GREGS+(PT_R20*4)(r31) + lwz r21,_UC_GREGS+(PT_R21*4)(r31) + lwz r22,_UC_GREGS+(PT_R22*4)(r31) + lwz r23,_UC_GREGS+(PT_R23*4)(r31) + lwz r24,_UC_GREGS+(PT_R24*4)(r31) + lwz r25,_UC_GREGS+(PT_R25*4)(r31) + lwz r26,_UC_GREGS+(PT_R26*4)(r31) + lwz r27,_UC_GREGS+(PT_R27*4)(r31) + lwz r28,_UC_GREGS+(PT_R28*4)(r31) + lwz r29,_UC_GREGS+(PT_R29*4)(r31) + lwz r30,_UC_GREGS+(PT_R30*4)(r31) + lwz r31,_UC_GREGS+(PT_R31*4)(r31) + + bctr + +3:/*L(error_exit):*/ + lwz r0,_FRAME_LR_SAVE+16(r1) + addi r1,r1,16 + mtlr r0 + blr + +4:/*L(do_sigret):*/ + addi r1,r4,-0xd0 + li r0,SYS_ify(rt_sigreturn) + sc + /* NOTREACHED */ + +END(__CONTEXT_FUNC_NAME) + diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext.S index 6e46abadb0..0605f3d107 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext.S @@ -1,5 +1,5 @@ /* Save current context and jump to a new context. - Copyright (C) 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2005 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 @@ -14,698 +14,53 @@ 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. */ + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA + 02110-1301 USA. */ #include <sysdep.h> #include <rtld-global-offsets.h> #include <shlib-compat.h> +#include <kernel-features.h> #define __ASSEMBLY__ #include <asm/ptrace.h> #include "ucontext_i.h" - .machine "altivec" -ENTRY(__swapcontext) - stwu r1,-16(r1) -/* Insure that the _UC_REGS start on a quadword boundary. */ - stw r3,_FRAME_PARM_SAVE1(r1) - addi r3,r3,_UC_REG_SPACE+12 - stw r4,_FRAME_PARM_SAVE2(r1) /* new context pointer */ - clrrwi r3,r3,4 - -/* Save the general purpose registers */ - stw r0,_UC_GREGS+(PT_R0*4)(r3) - mflr r0 - stw r2,_UC_GREGS+(PT_R2*4)(r3) - stw r4,_UC_GREGS+(PT_R4*4)(r3) -/* Set the callers LR_SAVE, and the ucontext LR and NIP to the callers - return address. */ - stw r0,_UC_GREGS+(PT_LNK*4)(r3) - stw r0,_UC_GREGS+(PT_NIP*4)(r3) - stw r0,_FRAME_LR_SAVE+16(r1) - stw r5,_UC_GREGS+(PT_R5*4)(r3) - stw r6,_UC_GREGS+(PT_R6*4)(r3) - stw r7,_UC_GREGS+(PT_R7*4)(r3) - stw r8,_UC_GREGS+(PT_R8*4)(r3) - stw r9,_UC_GREGS+(PT_R9*4)(r3) - stw r10,_UC_GREGS+(PT_R10*4)(r3) - stw r11,_UC_GREGS+(PT_R11*4)(r3) - stw r12,_UC_GREGS+(PT_R12*4)(r3) - stw r13,_UC_GREGS+(PT_R13*4)(r3) - stw r14,_UC_GREGS+(PT_R14*4)(r3) - stw r15,_UC_GREGS+(PT_R15*4)(r3) - stw r16,_UC_GREGS+(PT_R16*4)(r3) - stw r17,_UC_GREGS+(PT_R17*4)(r3) - stw r18,_UC_GREGS+(PT_R18*4)(r3) - stw r19,_UC_GREGS+(PT_R19*4)(r3) - stw r20,_UC_GREGS+(PT_R20*4)(r3) - stw r21,_UC_GREGS+(PT_R21*4)(r3) - stw r22,_UC_GREGS+(PT_R22*4)(r3) - stw r23,_UC_GREGS+(PT_R23*4)(r3) - stw r24,_UC_GREGS+(PT_R24*4)(r3) - stw r25,_UC_GREGS+(PT_R25*4)(r3) - stw r26,_UC_GREGS+(PT_R26*4)(r3) - stw r27,_UC_GREGS+(PT_R27*4)(r3) - stw r28,_UC_GREGS+(PT_R28*4)(r3) - stw r29,_UC_GREGS+(PT_R29*4)(r3) - stw r30,_UC_GREGS+(PT_R30*4)(r3) - stw r31,_UC_GREGS+(PT_R31*4)(r3) - -/* Save the value of R1. We had to push the stack before we - had the address of uc_reg_space. So compute the address of - the callers stack pointer and save it as R1. */ - addi r8,r1,16 - li r0,0 -/* Save the count, exception and condition registers. */ - mfctr r11 - mfxer r10 - mfcr r9 - stw r8,_UC_GREGS+(PT_R1*4)(r3) - stw r11,_UC_GREGS+(PT_CTR*4)(r3) - stw r10,_UC_GREGS+(PT_XER*4)(r3) - stw r9,_UC_GREGS+(PT_CCR*4)(r3) -/* Set the return value of getcontext to "success". R3 is the only - register whose value is not preserved in the saved context. */ - stw r0,_UC_GREGS+(PT_R3*4)(r3) - - /* Zero fill fields that can't be set in user state. */ - stw r0,_UC_GREGS+(PT_MSR*4)(r3) - stw r0,_UC_GREGS+(PT_MQ*4)(r3) - - /* Save the floating-point registers */ - stfd fp0,_UC_FREGS+(0*8)(r3) - stfd fp1,_UC_FREGS+(1*8)(r3) - stfd fp2,_UC_FREGS+(2*8)(r3) - stfd fp3,_UC_FREGS+(3*8)(r3) - stfd fp4,_UC_FREGS+(4*8)(r3) - stfd fp5,_UC_FREGS+(5*8)(r3) - stfd fp6,_UC_FREGS+(6*8)(r3) - stfd fp7,_UC_FREGS+(7*8)(r3) - stfd fp8,_UC_FREGS+(8*8)(r3) - stfd fp9,_UC_FREGS+(9*8)(r3) - stfd fp10,_UC_FREGS+(10*8)(r3) - stfd fp11,_UC_FREGS+(11*8)(r3) - stfd fp12,_UC_FREGS+(12*8)(r3) - stfd fp13,_UC_FREGS+(13*8)(r3) - stfd fp14,_UC_FREGS+(14*8)(r3) - stfd fp15,_UC_FREGS+(15*8)(r3) - stfd fp16,_UC_FREGS+(16*8)(r3) - stfd fp17,_UC_FREGS+(17*8)(r3) - stfd fp18,_UC_FREGS+(18*8)(r3) - stfd fp19,_UC_FREGS+(19*8)(r3) - stfd fp20,_UC_FREGS+(20*8)(r3) - stfd fp21,_UC_FREGS+(21*8)(r3) - stfd fp22,_UC_FREGS+(22*8)(r3) - stfd fp23,_UC_FREGS+(23*8)(r3) - stfd fp24,_UC_FREGS+(24*8)(r3) - stfd fp25,_UC_FREGS+(25*8)(r3) - stfd fp26,_UC_FREGS+(26*8)(r3) - stfd fp27,_UC_FREGS+(27*8)(r3) - stfd fp28,_UC_FREGS+(28*8)(r3) - stfd fp29,_UC_FREGS+(29*8)(r3) - mffs fp0 - stfd fp30,_UC_FREGS+(30*8)(r3) - stfd fp31,_UC_FREGS+(31*8)(r3) - stfd fp0,_UC_FREGS+(32*8)(r3) -#ifdef PIC - mflr r8 -# ifdef HAVE_ASM_PPC_REL16 - bcl 20,31,1f -1: mflr r7 - addis r7,r7,_GLOBAL_OFFSET_TABLE_-1b@ha - addi r7,r7,_GLOBAL_OFFSET_TABLE_-1b@l -# else - bl _GLOBAL_OFFSET_TABLE_@local-4 - mflr r7 -# endif -# ifdef SHARED - lwz r7,_rtld_global_ro@got(r7) - mtlr r8 - lwz r7,RTLD_GLOBAL_RO_DL_HWCAP_OFFSET(r7) -# else - lwz r7,_dl_hwcap@got(r7) - mtlr r8 - lwz r7,0(r7) -# endif -#else - lis r7,_dl_hwcap@ha - lwz r7,_dl_hwcap@l(r7) -#endif - andis. r7,r7,(PPC_FEATURE_HAS_ALTIVEC >> 16) - - la r10,(_UC_VREGS)(r3) - la r9,(_UC_VREGS+16)(r3) - - beq L(no_vec) -/* address of the combined VSCR/VSAVE quadword. */ - la r8,(_UC_VREGS+512)(r3) - -/* Save the vector registers */ - stvx v0,0,r10 - stvx v1,0,r9 - addi r10,r10,32 - addi r9,r9,32 -/* We need to get the Vector Status and Control Register early to avoid - store order problems later with the VSAVE register that shares the - same quadword. */ - mfvscr v0 - - stvx v2,0,r10 - stvx v3,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v0,0,r8 - - stvx v4,0,r10 - stvx v5,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v6,0,r10 - stvx v7,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v8,0,r10 - stvx v9,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v10,0,r10 - stvx v11,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v12,0,r10 - stvx v13,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v14,0,r10 - stvx v15,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v16,0,r10 - stvx v17,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v18,0,r10 - stvx v19,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v20,0,r10 - stvx v21,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v22,0,r10 - stvx v23,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v24,0,r10 - stvx v25,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v26,0,r10 - stvx v27,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - stvx v28,0,r10 - stvx v29,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - mfvscr v0 - stvx v30,0,r10 - stvx v31,0,r9 - - stw r0,0(r8) - -L(no_vec): -/* Restore ucontext (parm1) from stack. */ - lwz r12,_FRAME_PARM_SAVE1(r1) - li r4,0 - stw r3,_UC_REGS_PTR(r12) - addi r5,r12,_UC_SIGMASK - li r3,SIG_SETMASK - bl __sigprocmask@local - cmpwi r3,0 - bne L(error_exit) - - /* - * If the new ucontext refers to the point where we were interrupted - * by a signal, we have to use the rt_sigreturn system call to - * return to the context so we get both LR and CTR restored. - * - * Otherwise, the context we are restoring is either just after - * a procedure call (getcontext/swapcontext) or at the beginning - * of a procedure call (makecontext), so we don't need to restore - * r0, xer, ctr. We don't restore r2 since it will be used as - * the TLS pointer. - */ - lwz r4,_FRAME_PARM_SAVE2(r1) - lwz r31,_UC_REGS_PTR(r4) - lwz r0,_UC_GREGS+(PT_MSR*4)(r31) - cmpwi r0,0 - bne L(do_sigret) - -#ifdef PIC - mflr r8 -# ifdef HAVE_ASM_PPC_REL16 - bcl 20,31,1f -1: mflr r7 - addis r7,r7,_GLOBAL_OFFSET_TABLE_-1b@ha - addi r7,r7,_GLOBAL_OFFSET_TABLE_-1b@l -# else - bl _GLOBAL_OFFSET_TABLE_@local-4 - mflr r7 -# endif -# ifdef SHARED - lwz r7,_rtld_global_ro@got(r7) - mtlr r8 - lwz r7,RTLD_GLOBAL_RO_DL_HWCAP_OFFSET(r7) -# else - lwz r7,_dl_hwcap@got(r7) - mtlr r8 - lwz r7,0(r7) -# endif -#else - lis r7,_dl_hwcap@ha - lwz r7,_dl_hwcap@l(r7) -#endif - andis. r7,r7,(PPC_FEATURE_HAS_ALTIVEC >> 16) - la r10,(_UC_VREGS)(r31) - beq L(has_no_vec) - - lwz r0,(32*16)(r10) - li r9,(32*16) - cmpwi r0,0 - mtspr VRSAVE,r0 - beq L(has_no_vec) - - lvx v19,r9,r10 - la r9,(16)(r10) - - lvx v0,0,r10 - lvx v1,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - mtvscr v19 - lvx v2,0,r10 - lvx v3,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v4,0,r10 - lvx v5,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v6,0,r10 - lvx v7,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v8,0,r10 - lvx v9,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v10,0,r10 - lvx v11,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v12,0,r10 - lvx v13,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v14,0,r10 - lvx v15,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v16,0,r10 - lvx v17,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v18,0,r10 - lvx v19,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v20,0,r10 - lvx v21,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v22,0,r10 - lvx v23,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v24,0,r10 - lvx v25,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v26,0,r10 - lvx v27,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v28,0,r10 - lvx v29,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v30,0,r10 - lvx v31,0,r9 - addi r10,r10,32 - addi r9,r9,32 - - lvx v10,0,r10 - lvx v11,0,r9 - -L(has_no_vec): - /* Restore the floating-point registers */ - lfd fp31,_UC_FREGS+(32*8)(r31) - lfd fp0,_UC_FREGS+(0*8)(r31) - mtfsf 0xff,fp31 - lfd fp1,_UC_FREGS+(1*8)(r31) - lfd fp2,_UC_FREGS+(2*8)(r31) - lfd fp3,_UC_FREGS+(3*8)(r31) - lfd fp4,_UC_FREGS+(4*8)(r31) - lfd fp5,_UC_FREGS+(5*8)(r31) - lfd fp6,_UC_FREGS+(6*8)(r31) - lfd fp7,_UC_FREGS+(7*8)(r31) - lfd fp8,_UC_FREGS+(8*8)(r31) - lfd fp9,_UC_FREGS+(9*8)(r31) - lfd fp10,_UC_FREGS+(10*8)(r31) - lfd fp11,_UC_FREGS+(11*8)(r31) - lfd fp12,_UC_FREGS+(12*8)(r31) - lfd fp13,_UC_FREGS+(13*8)(r31) - lfd fp14,_UC_FREGS+(14*8)(r31) - lfd fp15,_UC_FREGS+(15*8)(r31) - lfd fp16,_UC_FREGS+(16*8)(r31) - lfd fp17,_UC_FREGS+(17*8)(r31) - lfd fp18,_UC_FREGS+(18*8)(r31) - lfd fp19,_UC_FREGS+(19*8)(r31) - lfd fp20,_UC_FREGS+(20*8)(r31) - lfd fp21,_UC_FREGS+(21*8)(r31) - lfd fp22,_UC_FREGS+(22*8)(r31) - lfd fp23,_UC_FREGS+(23*8)(r31) - lfd fp24,_UC_FREGS+(24*8)(r31) - lfd fp25,_UC_FREGS+(25*8)(r31) - lfd fp26,_UC_FREGS+(26*8)(r31) - lfd fp27,_UC_FREGS+(27*8)(r31) - lfd fp28,_UC_FREGS+(28*8)(r31) - lfd fp29,_UC_FREGS+(29*8)(r31) - lfd fp30,_UC_FREGS+(30*8)(r31) - lfd fp31,_UC_FREGS+(31*8)(r31) - - /* Restore LR and CCR, and set CTR to the NIP value */ - lwz r3,_UC_GREGS+(PT_LNK*4)(r31) - lwz r4,_UC_GREGS+(PT_NIP*4)(r31) - lwz r5,_UC_GREGS+(PT_CCR*4)(r31) - mtlr r3 - mtctr r4 - mtcr r5 - - /* Restore the general registers */ - lwz r1,_UC_GREGS+(PT_R1*4)(r31) - lwz r3,_UC_GREGS+(PT_R3*4)(r31) - lwz r4,_UC_GREGS+(PT_R4*4)(r31) - lwz r5,_UC_GREGS+(PT_R5*4)(r31) - lwz r6,_UC_GREGS+(PT_R6*4)(r31) - lwz r7,_UC_GREGS+(PT_R7*4)(r31) - lwz r8,_UC_GREGS+(PT_R8*4)(r31) - lwz r9,_UC_GREGS+(PT_R9*4)(r31) - lwz r10,_UC_GREGS+(PT_R10*4)(r31) - lwz r11,_UC_GREGS+(PT_R11*4)(r31) - lwz r12,_UC_GREGS+(PT_R12*4)(r31) - lwz r13,_UC_GREGS+(PT_R13*4)(r31) - lwz r14,_UC_GREGS+(PT_R14*4)(r31) - lwz r15,_UC_GREGS+(PT_R15*4)(r31) - lwz r16,_UC_GREGS+(PT_R16*4)(r31) - lwz r17,_UC_GREGS+(PT_R17*4)(r31) - lwz r18,_UC_GREGS+(PT_R18*4)(r31) - lwz r19,_UC_GREGS+(PT_R19*4)(r31) - lwz r20,_UC_GREGS+(PT_R20*4)(r31) - lwz r21,_UC_GREGS+(PT_R21*4)(r31) - lwz r22,_UC_GREGS+(PT_R22*4)(r31) - lwz r23,_UC_GREGS+(PT_R23*4)(r31) - lwz r24,_UC_GREGS+(PT_R24*4)(r31) - lwz r25,_UC_GREGS+(PT_R25*4)(r31) - lwz r26,_UC_GREGS+(PT_R26*4)(r31) - lwz r27,_UC_GREGS+(PT_R27*4)(r31) - lwz r28,_UC_GREGS+(PT_R28*4)(r31) - lwz r29,_UC_GREGS+(PT_R29*4)(r31) - lwz r30,_UC_GREGS+(PT_R30*4)(r31) - lwz r31,_UC_GREGS+(PT_R31*4)(r31) - - bctr - -L(error_exit): - lwz r0,_FRAME_LR_SAVE+16(r1) - addi r1,r1,16 - mtlr r0 +#define __CONTEXT_FUNC_NAME __swapcontext +#define __CONTEXT_ENABLE_FPRS 1 +#define __CONTEXT_ENABLE_VRS 1 + +/* Size of ucontext in GLIBC_2.3.4 and later. */ +#define _UC_SIZE_2_3_4 1184 + +#ifdef __ASSUME_SWAPCONTEXT_SYSCALL + .section ".text"; +ENTRY (__swapcontext) + li r5,_UC_SIZE_2_3_4; + DO_CALL (SYS_ify (swapcontext)); + bso- cr0,1f +/* the kernel does not set the return code for the success case */ + li r3,0 blr - -L(do_sigret): - addi r1,r4,-0xd0 - li r0,SYS_ify(rt_sigreturn) - sc - /* NOTREACHED */ - +1: + b __syscall_error@local END(__swapcontext) +#else +# include "swapcontext-common.S" +#endif versioned_symbol (libc, __swapcontext, swapcontext, GLIBC_2_3_4) #if SHLIB_COMPAT (libc, GLIBC_2_3_3, GLIBC_2_3_4) compat_text_section -ENTRY(__novec_swapcontext) - /* Save the current context */ - addi r3,r3,_UC_REG_SPACE - stw r3,_UC_REGS_PTR - _UC_REG_SPACE(r3) - stw r0,_UC_GREGS+(PT_R0*4)(r3) - stw r1,_UC_GREGS+(PT_R1*4)(r3) - mflr r0 - stwu r1,-16(r1) - stw r0,20(r1) - stw r31,12(r1) - stw r31,_UC_GREGS+(PT_R31*4)(r3) - mr r31,r4 /* new context pointer */ - stw r0,_UC_GREGS+(PT_LNK*4)(r3) - stw r0,_UC_GREGS+(PT_NIP*4)(r3) - stw r2,_UC_GREGS+(PT_R2*4)(r3) - stw r4,_UC_GREGS+(PT_R4*4)(r3) - stw r5,_UC_GREGS+(PT_R5*4)(r3) - stw r6,_UC_GREGS+(PT_R6*4)(r3) - stw r7,_UC_GREGS+(PT_R7*4)(r3) - stw r8,_UC_GREGS+(PT_R8*4)(r3) - stw r9,_UC_GREGS+(PT_R9*4)(r3) - stw r10,_UC_GREGS+(PT_R10*4)(r3) - stw r11,_UC_GREGS+(PT_R11*4)(r3) - stw r12,_UC_GREGS+(PT_R12*4)(r3) - stw r13,_UC_GREGS+(PT_R13*4)(r3) - stw r14,_UC_GREGS+(PT_R14*4)(r3) - stw r15,_UC_GREGS+(PT_R15*4)(r3) - stw r16,_UC_GREGS+(PT_R16*4)(r3) - stw r17,_UC_GREGS+(PT_R17*4)(r3) - stw r18,_UC_GREGS+(PT_R18*4)(r3) - stw r19,_UC_GREGS+(PT_R19*4)(r3) - stw r20,_UC_GREGS+(PT_R20*4)(r3) - stw r21,_UC_GREGS+(PT_R21*4)(r3) - stw r22,_UC_GREGS+(PT_R22*4)(r3) - stw r23,_UC_GREGS+(PT_R23*4)(r3) - stw r24,_UC_GREGS+(PT_R24*4)(r3) - stw r25,_UC_GREGS+(PT_R25*4)(r3) - stw r26,_UC_GREGS+(PT_R26*4)(r3) - stw r27,_UC_GREGS+(PT_R27*4)(r3) - stw r28,_UC_GREGS+(PT_R28*4)(r3) - stw r29,_UC_GREGS+(PT_R29*4)(r3) - stw r30,_UC_GREGS+(PT_R30*4)(r3) - mfctr r0 - stw r0,_UC_GREGS+(PT_CTR*4)(r3) - mfxer r0 - stw r0,_UC_GREGS+(PT_XER*4)(r3) - mfcr r0 - stw r0,_UC_GREGS+(PT_CCR*4)(r3) - - /* Set the return value of swapcontext to "success". R3 is the only - register whose value is not preserved in the saved context. */ - li r0,0 - stw r0,_UC_GREGS+(PT_R3*4)(r3) - - /* Zero fill fields that can't be set in user state. */ - stw r0,_UC_GREGS+(PT_MSR*4)(r3) - stw r0,_UC_GREGS+(PT_MQ*4)(r3) - - /* Save the floating-point registers */ - stfd fp0,_UC_FREGS+(0*8)(r3) - stfd fp1,_UC_FREGS+(1*8)(r3) - stfd fp2,_UC_FREGS+(2*8)(r3) - stfd fp3,_UC_FREGS+(3*8)(r3) - stfd fp4,_UC_FREGS+(4*8)(r3) - stfd fp5,_UC_FREGS+(5*8)(r3) - stfd fp6,_UC_FREGS+(6*8)(r3) - stfd fp7,_UC_FREGS+(7*8)(r3) - stfd fp8,_UC_FREGS+(8*8)(r3) - stfd fp9,_UC_FREGS+(9*8)(r3) - stfd fp10,_UC_FREGS+(10*8)(r3) - stfd fp11,_UC_FREGS+(11*8)(r3) - stfd fp12,_UC_FREGS+(12*8)(r3) - stfd fp13,_UC_FREGS+(13*8)(r3) - stfd fp14,_UC_FREGS+(14*8)(r3) - stfd fp15,_UC_FREGS+(15*8)(r3) - stfd fp16,_UC_FREGS+(16*8)(r3) - stfd fp17,_UC_FREGS+(17*8)(r3) - stfd fp18,_UC_FREGS+(18*8)(r3) - stfd fp19,_UC_FREGS+(19*8)(r3) - stfd fp20,_UC_FREGS+(20*8)(r3) - stfd fp21,_UC_FREGS+(21*8)(r3) - stfd fp22,_UC_FREGS+(22*8)(r3) - stfd fp23,_UC_FREGS+(23*8)(r3) - stfd fp24,_UC_FREGS+(24*8)(r3) - stfd fp25,_UC_FREGS+(25*8)(r3) - stfd fp26,_UC_FREGS+(26*8)(r3) - stfd fp27,_UC_FREGS+(27*8)(r3) - stfd fp28,_UC_FREGS+(28*8)(r3) - stfd fp29,_UC_FREGS+(29*8)(r3) - mffs fp0 - stfd fp30,_UC_FREGS+(30*8)(r3) - stfd fp31,_UC_FREGS+(31*8)(r3) - stfd fp0,_UC_FREGS+(32*8)(r3) - - addi r5,r3,_UC_SIGMASK - _UC_REG_SPACE - addi r4,r4,_UC_SIGMASK - li r3,SIG_SETMASK - bl __sigprocmask@local - cmpwi r3,0 - bne L(novec_error_exit) - - /* - * If the new ucontext refers to the point where we were interrupted - * by a signal, we have to use the rt_sigreturn system call to - * return to the context so we get both LR and CTR restored. - * - * Otherwise, the context we are restoring is either just after - * a procedure call (getcontext/swapcontext) or at the beginning - * of a procedure call (makecontext), so we don't need to restore - * r0, xer, ctr. We don't restore r2 since it will be used as - * the TLS pointer. - */ - mr r4,r31 - lwz r31,_UC_REGS_PTR(r31) - lwz r0,_UC_GREGS+(PT_MSR*4)(r31) - cmpwi r0,0 - bne L(novec_do_sigret) - - /* Restore the floating-point registers */ - lfd fp31,_UC_FREGS+(32*8)(r31) - lfd fp0,_UC_FREGS+(0*8)(r31) - mtfsf 0xff,fp31 - lfd fp1,_UC_FREGS+(1*8)(r31) - lfd fp2,_UC_FREGS+(2*8)(r31) - lfd fp3,_UC_FREGS+(3*8)(r31) - lfd fp4,_UC_FREGS+(4*8)(r31) - lfd fp5,_UC_FREGS+(5*8)(r31) - lfd fp6,_UC_FREGS+(6*8)(r31) - lfd fp7,_UC_FREGS+(7*8)(r31) - lfd fp8,_UC_FREGS+(8*8)(r31) - lfd fp9,_UC_FREGS+(9*8)(r31) - lfd fp10,_UC_FREGS+(10*8)(r31) - lfd fp11,_UC_FREGS+(11*8)(r31) - lfd fp12,_UC_FREGS+(12*8)(r31) - lfd fp13,_UC_FREGS+(13*8)(r31) - lfd fp14,_UC_FREGS+(14*8)(r31) - lfd fp15,_UC_FREGS+(15*8)(r31) - lfd fp16,_UC_FREGS+(16*8)(r31) - lfd fp17,_UC_FREGS+(17*8)(r31) - lfd fp18,_UC_FREGS+(18*8)(r31) - lfd fp19,_UC_FREGS+(19*8)(r31) - lfd fp20,_UC_FREGS+(20*8)(r31) - lfd fp21,_UC_FREGS+(21*8)(r31) - lfd fp22,_UC_FREGS+(22*8)(r31) - lfd fp23,_UC_FREGS+(23*8)(r31) - lfd fp24,_UC_FREGS+(24*8)(r31) - lfd fp25,_UC_FREGS+(25*8)(r31) - lfd fp26,_UC_FREGS+(26*8)(r31) - lfd fp27,_UC_FREGS+(27*8)(r31) - lfd fp28,_UC_FREGS+(28*8)(r31) - lfd fp29,_UC_FREGS+(29*8)(r31) - lfd fp30,_UC_FREGS+(30*8)(r31) - lfd fp31,_UC_FREGS+(31*8)(r31) - - /* Restore LR and CCR, and set CTR to the NIP value */ - lwz r3,_UC_GREGS+(PT_LNK*4)(r31) - lwz r4,_UC_GREGS+(PT_NIP*4)(r31) - lwz r5,_UC_GREGS+(PT_CCR*4)(r31) - mtlr r3 - mtctr r4 - mtcr r5 - - /* Restore the general registers */ - lwz r1,_UC_GREGS+(PT_R1*4)(r31) - lwz r3,_UC_GREGS+(PT_R3*4)(r31) - lwz r4,_UC_GREGS+(PT_R4*4)(r31) - lwz r5,_UC_GREGS+(PT_R5*4)(r31) - lwz r6,_UC_GREGS+(PT_R6*4)(r31) - lwz r7,_UC_GREGS+(PT_R7*4)(r31) - lwz r8,_UC_GREGS+(PT_R8*4)(r31) - lwz r9,_UC_GREGS+(PT_R9*4)(r31) - lwz r10,_UC_GREGS+(PT_R10*4)(r31) - lwz r11,_UC_GREGS+(PT_R11*4)(r31) - lwz r12,_UC_GREGS+(PT_R12*4)(r31) - lwz r13,_UC_GREGS+(PT_R13*4)(r31) - lwz r14,_UC_GREGS+(PT_R14*4)(r31) - lwz r15,_UC_GREGS+(PT_R15*4)(r31) - lwz r16,_UC_GREGS+(PT_R16*4)(r31) - lwz r17,_UC_GREGS+(PT_R17*4)(r31) - lwz r18,_UC_GREGS+(PT_R18*4)(r31) - lwz r19,_UC_GREGS+(PT_R19*4)(r31) - lwz r20,_UC_GREGS+(PT_R20*4)(r31) - lwz r21,_UC_GREGS+(PT_R21*4)(r31) - lwz r22,_UC_GREGS+(PT_R22*4)(r31) - lwz r23,_UC_GREGS+(PT_R23*4)(r31) - lwz r24,_UC_GREGS+(PT_R24*4)(r31) - lwz r25,_UC_GREGS+(PT_R25*4)(r31) - lwz r26,_UC_GREGS+(PT_R26*4)(r31) - lwz r27,_UC_GREGS+(PT_R27*4)(r31) - lwz r28,_UC_GREGS+(PT_R28*4)(r31) - lwz r29,_UC_GREGS+(PT_R29*4)(r31) - lwz r30,_UC_GREGS+(PT_R30*4)(r31) - lwz r31,_UC_GREGS+(PT_R31*4)(r31) - - bctr - -L(novec_error_exit): - lwz r31,12(r1) - lwz r0,20(r1) - addi r1,r1,16 - mtlr r0 - blr + +# undef __CONTEXT_FUNC_NAME +# define __CONTEXT_FUNC_NAME __novec_swapcontext +# undef __CONTEXT_ENABLE_VRS -L(novec_do_sigret): - addi r1,r4,-0xd0 - li r0,SYS_ify(rt_sigreturn) - sc - /* NOTREACHED */ +# include "swapcontext-common.S" -END(__novec_swapcontext) .previous compat_symbol (libc, __novec_swapcontext, swapcontext, GLIBC_2_3_3) @@ -714,8 +69,8 @@ compat_symbol (libc, __novec_swapcontext, swapcontext, GLIBC_2_3_3) #if SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_3_3) -#define _ERRNO_H 1 -#include <bits/errno.h> +# define _ERRNO_H 1 +# include <bits/errno.h> compat_text_section ENTRY (__swapcontext_stub) diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h index 546e712edc..470da5aa6e 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h @@ -55,6 +55,109 @@ # include <errno.h> +# ifdef SHARED +# define INLINE_VSYSCALL(name, nr, args...) \ + ({ \ + __label__ out; \ + __label__ iserr; \ + INTERNAL_SYSCALL_DECL (sc_err); \ + long int sc_ret; \ + \ + if (__vdso_##name != NULL) \ + { \ + sc_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, sc_err, nr, ##args); \ + if (!INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \ + goto out; \ + if (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err) != ENOSYS) \ + goto iserr; \ + } \ + \ + sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, ##args); \ + if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \ + { \ + iserr: \ + __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)); \ + sc_ret = -1L; \ + } \ + out: \ + sc_ret; \ + }) +# else +# define INLINE_VSYSCALL(name, nr, args...) \ + INLINE_SYSCALL (name, nr, ##args) +# endif + +# ifdef SHARED +# define INTERNAL_VSYSCALL(name, err, nr, args...) \ + ({ \ + __label__ out; \ + long int v_ret; \ + \ + if (__vdso_##name != NULL) \ + { \ + v_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, err, nr, ##args); \ + if (!INTERNAL_SYSCALL_ERROR_P (v_ret, err) \ + || INTERNAL_SYSCALL_ERRNO (v_ret, err) != ENOSYS) \ + goto out; \ + } \ + v_ret = INTERNAL_SYSCALL (name, err, nr, ##args); \ + out: \ + v_ret; \ + }) +# else +# define INTERNAL_VSYSCALL(name, err, nr, args...) \ + INTERNAL_SYSCALL (name, err, nr, ##args) +# endif + +# define INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK(name, err, nr, args...) \ + ({ \ + long int sc_ret = ENOSYS; \ + \ + if (__vdso_##name != NULL) \ + sc_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, err, nr, ##args); \ + else \ + err = 1 << 28; \ + sc_ret; \ + }) + +/* List of system calls which are supported as vsyscalls. */ +# define HAVE_CLOCK_GETRES_VSYSCALL 1 +# define HAVE_CLOCK_GETTIME_VSYSCALL 1 + +/* Define a macro which expands inline into the wrapper code for a VDSO + call. This use is for internal calls that do not need to handle errors + normally. It will never touch errno. + On powerpc a system call basically clobbers the same registers like a + function call, with the exception of LR (which is needed for the + "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal + an error return status). */ +# define INTERNAL_VSYSCALL_NCS(funcptr, err, nr, args...) \ + ({ \ + register void *r0 __asm__ ("r0"); \ + register long int r3 __asm__ ("r3"); \ + register long int r4 __asm__ ("r4"); \ + register long int r5 __asm__ ("r5"); \ + register long int r6 __asm__ ("r6"); \ + register long int r7 __asm__ ("r7"); \ + register long int r8 __asm__ ("r8"); \ + register long int r9 __asm__ ("r9"); \ + register long int r10 __asm__ ("r10"); \ + register long int r11 __asm__ ("r11"); \ + register long int r12 __asm__ ("r12"); \ + LOADARGS_##nr (funcptr, args); \ + __asm__ __volatile__ \ + ("mtctr %0\n\t" \ + "bctrl\n\t" \ + "mfcr %0" \ + : "=&r" (r0), \ + "=&r" (r3), "=&r" (r4), "=&r" (r5), "=&r" (r6), "=&r" (r7), \ + "=&r" (r8), "=&r" (r9), "=&r" (r10), "=&r" (r11), "=&r" (r12) \ + : ASM_INPUT_##nr \ + : "cr0", "ctr", "lr", "memory"); \ + err = (long int) r0; \ + (int) r3; \ + }) + # undef INLINE_SYSCALL # define INLINE_SYSCALL(name, nr, args...) \ ({ \ @@ -93,7 +196,7 @@ register long int r10 __asm__ ("r10"); \ register long int r11 __asm__ ("r11"); \ register long int r12 __asm__ ("r12"); \ - LOADARGS_##nr(name, args); \ + LOADARGS_##nr(name, args); \ __asm__ __volatile__ \ ("sc \n\t" \ "mfcr %0" \ @@ -115,11 +218,11 @@ # undef INTERNAL_SYSCALL_ERRNO # define INTERNAL_SYSCALL_ERRNO(val, err) (val) -# define LOADARGS_0(name, dummy) \ +# define LOADARGS_0(name, dummy) \ r0 = name # define LOADARGS_1(name, __arg1) \ long int arg1 = (long int) (__arg1); \ - LOADARGS_0(name, 0); \ + LOADARGS_0(name, 0); \ extern void __illegally_sized_syscall_arg1 (void); \ if (__builtin_classify_type (__arg1) != 5 && sizeof (__arg1) > 4) \ __illegally_sized_syscall_arg1 (); \ @@ -180,10 +283,13 @@ # define PTR_MANGLE(reg, tmpreg) \ lwz tmpreg,POINTER_GUARD(r2); \ xor reg,tmpreg,reg +# define PTR_MANGLE2(reg, tmpreg) \ + xor reg,tmpreg,reg # define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg) +# define PTR_DEMANGLE2(reg, tmpreg) PTR_MANGLE2 (reg, tmpreg) # else # define PTR_MANGLE(var) \ - (var) = (void *) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ()) + (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ()) # define PTR_DEMANGLE(var) PTR_MANGLE (var) # endif #endif diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/ucontext_i.sym b/sysdeps/unix/sysv/linux/powerpc/powerpc32/ucontext_i.sym index 662c693303..293761f260 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/ucontext_i.sym +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/ucontext_i.sym @@ -7,14 +7,6 @@ SIG_BLOCK SIG_SETMASK --- XXX Do these correspond to some struct? -_FRAME_BACKCHAIN 0 -_FRAME_LR_SAVE 4 -_FRAME_PARM_SAVE1 8 -_FRAME_PARM_SAVE2 12 -_FRAME_PARM_SAVE3 16 -_FRAME_PARM_SAVE4 20 - -- Offsets in ucontext_t. #define ucontext(member) offsetof (ucontext_t, member) _UC_LINK ucontext (uc_link) diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h index 3ece017563..858b5c4757 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h @@ -62,12 +62,118 @@ #ifdef __ASSEMBLER__ /* This seems to always be the case on PPC. */ -#define ALIGNARG(log2) log2 +# define ALIGNARG(log2) log2 /* For ELF we need the `.type' directive to make shared libs work right. */ -#define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg; -#define ASM_SIZE_DIRECTIVE(name) .size name,.-name +# define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg; +# define ASM_SIZE_DIRECTIVE(name) .size name,.-name -#endif /* __ASSEMBLER__ */ +#endif /* __ASSEMBLER__ */ + +/* This version is for kernels that implement system calls that + behave like function calls as far as register saving. + It falls back to the syscall in the case that the vDSO doesn't + exist or fails for ENOSYS */ +#ifdef SHARED +# define INLINE_VSYSCALL(name, nr, args...) \ + ({ \ + __label__ out; \ + __label__ iserr; \ + INTERNAL_SYSCALL_DECL (sc_err); \ + long int sc_ret; \ + \ + if (__vdso_##name != NULL) \ + { \ + sc_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, sc_err, nr, ##args); \ + if (!INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \ + goto out; \ + if (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err) != ENOSYS) \ + goto iserr; \ + } \ + \ + sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, ##args); \ + if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \ + { \ + iserr: \ + __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)); \ + sc_ret = -1L; \ + } \ + out: \ + sc_ret; \ + }) +#else +# define INLINE_VSYSCALL(name, nr, args...) \ + INLINE_SYSCALL (name, nr, ##args) +#endif + +#ifdef SHARED +# define INTERNAL_VSYSCALL(name, err, nr, args...) \ + ({ \ + __label__ out; \ + long int v_ret; \ + \ + if (__vdso_##name != NULL) \ + { \ + v_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, err, nr, ##args); \ + if (!INTERNAL_SYSCALL_ERROR_P (v_ret, err) \ + || INTERNAL_SYSCALL_ERRNO (v_ret, err) != ENOSYS) \ + goto out; \ + } \ + v_ret = INTERNAL_SYSCALL (name, err, nr, ##args); \ + out: \ + v_ret; \ + }) +#else +# define INTERNAL_VSYSCALL(name, err, nr, args...) \ + INTERNAL_SYSCALL (name, err, nr, ##args) +#endif + +/* This version is for internal uses when there is no desire + to set errno */ +#define INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK(name, err, nr, args...) \ + ({ \ + long int sc_ret = ENOSYS; \ + \ + if (__vdso_##name != NULL) \ + sc_ret = INTERNAL_VSYSCALL_NCS (__vdso_##name, err, nr, ##args); \ + else \ + err = 1 << 28; \ + sc_ret; \ + }) + +/* List of system calls which are supported as vsyscalls. */ +#define HAVE_CLOCK_GETRES_VSYSCALL 1 +#define HAVE_CLOCK_GETTIME_VSYSCALL 1 + +/* Define a macro which expands inline into the wrapper code for a system + call. This use is for internal calls that do not need to handle errors + normally. It will never touch errno. This returns just what the kernel + gave back in the non-error (CR0.SO cleared) case, otherwise (CR0.SO set) + the negation of the return value in the kernel gets reverted. */ + +#define INTERNAL_VSYSCALL_NCS(funcptr, err, nr, args...) \ + ({ \ + register void *r0 __asm__ ("r0"); \ + register long int r3 __asm__ ("r3"); \ + register long int r4 __asm__ ("r4"); \ + register long int r5 __asm__ ("r5"); \ + register long int r6 __asm__ ("r6"); \ + register long int r7 __asm__ ("r7"); \ + register long int r8 __asm__ ("r8"); \ + LOADARGS_##nr (funcptr, args); \ + __asm__ __volatile__ \ + ("mtctr %0\n\t" \ + "bctrl\n\t" \ + "mfcr %0\n\t" \ + "0:" \ + : "=&r" (r0), \ + "=&r" (r3), "=&r" (r4), "=&r" (r5), \ + "=&r" (r6), "=&r" (r7), "=&r" (r8) \ + : ASM_INPUT_##nr \ + : "r9", "r10", "r11", "r12", \ + "cr0", "ctr", "lr", "memory"); \ + err = (long int) r0; \ + (int) r3; \ + }) #undef INLINE_SYSCALL @@ -101,7 +207,7 @@ register long int r6 __asm__ ("r6"); \ register long int r7 __asm__ ("r7"); \ register long int r8 __asm__ ("r8"); \ - LOADARGS_##nr(name, args); \ + LOADARGS_##nr (name, ##args); \ __asm__ __volatile__ \ ("sc\n\t" \ "mfcr %0\n\t" \ @@ -116,7 +222,7 @@ (int) r3; \ }) #define INTERNAL_SYSCALL(name, err, nr, args...) \ - INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args) + INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, args) #undef INTERNAL_SYSCALL_DECL #define INTERNAL_SYSCALL_DECL(err) long int err @@ -191,7 +297,10 @@ # define PTR_MANGLE(reg, tmpreg) \ ld tmpreg,POINTER_GUARD(r13); \ xor reg,tmpreg,reg +# define PTR_MANGLE2(reg, tmpreg) \ + xor reg,tmpreg,reg # define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg) +# define PTR_DEMANGLE2(reg, tmpreg) PTR_MANGLE2 (reg, tmpreg) # else # define PTR_MANGLE(var) \ (var) = (void *) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ()) diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sigaction.c b/sysdeps/unix/sysv/linux/s390/s390-64/sigaction.c index 480ebd424c..eff4f17853 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/sigaction.c +++ b/sysdeps/unix/sysv/linux/s390/s390-64/sigaction.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2002, 2003, 2005 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 @@ -44,6 +44,10 @@ __libc_sigaction (sig, act, oact) } libc_hidden_def (__libc_sigaction) +#ifdef WRAPPER_INCLUDE +# include WRAPPER_INCLUDE +#endif + #ifndef LIBC_SIGACTION weak_alias (__libc_sigaction, __sigaction) libc_hidden_weak (__sigaction) diff --git a/sysdeps/unix/sysv/linux/sh/makecontext.S b/sysdeps/unix/sysv/linux/sh/makecontext.S index deb6181750..877d78d396 100644 --- a/sysdeps/unix/sysv/linux/sh/makecontext.S +++ b/sysdeps/unix/sysv/linux/sh/makecontext.S @@ -32,7 +32,6 @@ .text .align 5 - cfi_startproc ENTRY(__makecontext) mov #4, r3 mov.l @(oSS_SP,r4), r1 @@ -140,6 +139,7 @@ ENTRY(__makecontext) .L4: .long HIDDEN_JUMPTARGET(exit) #endif + cfi_startproc PSEUDO_END(__makecontext) weak_alias (__makecontext, makecontext) diff --git a/sysdeps/unix/sysv/linux/sh/sh3/getcontext.S b/sysdeps/unix/sysv/linux/sh/sh3/getcontext.S index 3ea47d4a5c..66b3daaa3b 100644 --- a/sysdeps/unix/sysv/linux/sh/sh3/getcontext.S +++ b/sysdeps/unix/sysv/linux/sh/sh3/getcontext.S @@ -25,7 +25,6 @@ .text .align 5 - cfi_startproc ENTRY(__getcontext) /* Return value of getcontext. R0 is the only register whose @@ -84,7 +83,6 @@ ENTRY(__getcontext) rts nop - cfi_endproc PSEUDO_END(__getcontext) weak_alias (__getcontext, getcontext) diff --git a/sysdeps/unix/sysv/linux/sh/sh3/setcontext.S b/sysdeps/unix/sysv/linux/sh/sh3/setcontext.S index 30fbf7dec3..3136267aca 100644 --- a/sysdeps/unix/sysv/linux/sh/sh3/setcontext.S +++ b/sysdeps/unix/sysv/linux/sh/sh3/setcontext.S @@ -25,7 +25,6 @@ .text .align 5 - cfi_startproc ENTRY(__setcontext) mov r4, r8 @@ -95,7 +94,6 @@ ENTRY(__setcontext) jmp @r0 mov.l @r15+, r0 - cfi_endproc PSEUDO_END(__setcontext) weak_alias (__setcontext, setcontext) diff --git a/sysdeps/unix/sysv/linux/sh/sh3/swapcontext.S b/sysdeps/unix/sysv/linux/sh/sh3/swapcontext.S index aa0129e9ac..64035e5545 100644 --- a/sysdeps/unix/sysv/linux/sh/sh3/swapcontext.S +++ b/sysdeps/unix/sysv/linux/sh/sh3/swapcontext.S @@ -25,7 +25,6 @@ .text .align 5 - cfi_startproc ENTRY(__swapcontext) /* Return value of getcontext. R0 is the only register whose @@ -128,7 +127,6 @@ ENTRY(__swapcontext) jmp @r0 mov.l @r15+, r0 - cfi_endproc PSEUDO_END(__swapcontext) weak_alias (__swapcontext, swapcontext) diff --git a/sysdeps/unix/sysv/linux/sh/sh4/getcontext.S b/sysdeps/unix/sysv/linux/sh/sh4/getcontext.S index 380c4591dd..68bc235bcf 100644 --- a/sysdeps/unix/sysv/linux/sh/sh4/getcontext.S +++ b/sysdeps/unix/sysv/linux/sh/sh4/getcontext.S @@ -25,7 +25,6 @@ .text .align 5 - cfi_startproc ENTRY(__getcontext) /* Return value of getcontext. R0 is the only register whose @@ -127,7 +126,6 @@ ENTRY(__getcontext) rts nop - cfi_endproc PSEUDO_END(__getcontext) weak_alias (__getcontext, getcontext) diff --git a/sysdeps/unix/sysv/linux/sh/sh4/setcontext.S b/sysdeps/unix/sysv/linux/sh/sh4/setcontext.S index 9e98910b4b..2bc546d1a1 100644 --- a/sysdeps/unix/sysv/linux/sh/sh4/setcontext.S +++ b/sysdeps/unix/sysv/linux/sh/sh4/setcontext.S @@ -25,7 +25,6 @@ .text .align 5 - cfi_startproc ENTRY(__setcontext) mov r4, r8 @@ -135,7 +134,6 @@ ENTRY(__setcontext) jmp @r0 mov.l @r15+, r0 - cfi_endproc PSEUDO_END(__setcontext) weak_alias (__setcontext, setcontext) diff --git a/sysdeps/unix/sysv/linux/sh/sh4/swapcontext.S b/sysdeps/unix/sysv/linux/sh/sh4/swapcontext.S index 1d58a40e70..1aeca1b1a7 100644 --- a/sysdeps/unix/sysv/linux/sh/sh4/swapcontext.S +++ b/sysdeps/unix/sysv/linux/sh/sh4/swapcontext.S @@ -25,7 +25,6 @@ .text .align 5 - cfi_startproc ENTRY(__swapcontext) /* Return value of getcontext. R0 is the only register whose @@ -210,7 +209,6 @@ ENTRY(__swapcontext) jmp @r0 mov.l @r15+, r0 - cfi_endproc PSEUDO_END(__swapcontext) weak_alias (__swapcontext, swapcontext) diff --git a/sysdeps/unix/sysv/linux/sh/socket.S b/sysdeps/unix/sysv/linux/sh/socket.S index eb1761b94b..c83b0f2601 100644 --- a/sysdeps/unix/sysv/linux/sh/socket.S +++ b/sysdeps/unix/sysv/linux/sh/socket.S @@ -88,7 +88,6 @@ #endif .globl __socket - cfi_startproc ENTRY (__socket) /* This will not work in the case of a socket call being interrupted by a signal. If the signal handler uses any stack the arguments @@ -169,7 +168,6 @@ ENTRY (__socket) bra .Lsyscall_error nop #endif - cfi_endproc .align 2 .L1: diff --git a/sysdeps/unix/sysv/linux/sh/sysdep.S b/sysdeps/unix/sysv/linux/sh/sysdep.S index 33fdc748b5..176d99aab7 100644 --- a/sysdeps/unix/sysv/linux/sh/sysdep.S +++ b/sysdeps/unix/sysv/linux/sh/sysdep.S @@ -1,4 +1,5 @@ -/* Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2005 + 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 @@ -27,6 +28,7 @@ ENTRY (__syscall_error) neg r4, r0 + cfi_endproc #define __syscall_error __syscall_error_1 #include <sysdeps/unix/sh/sysdep.S> diff --git a/sysdeps/unix/sysv/linux/sh/sysdep.h b/sysdeps/unix/sysv/linux/sh/sysdep.h index 1a412e53db..b41236299d 100644 --- a/sysdeps/unix/sysv/linux/sh/sysdep.h +++ b/sysdeps/unix/sysv/linux/sh/sysdep.h @@ -141,13 +141,22 @@ # define SYSCALL_ERROR_HANDLER \ neg r0,r1; \ mov.l r14,@-r15; \ + cfi_adjust_cfa_offset (4); \ + cfi_rel_offset (r14, 0); \ mov.l r12,@-r15; \ + cfi_adjust_cfa_offset (4); \ + cfi_rel_offset (r12, 0); \ mov.l r1,@-r15; \ + cfi_adjust_cfa_offset (4); \ + cfi_rel_offset (r1, 0); \ mov.l 0f,r12; \ mova 0f,r0; \ add r0,r12; \ sts.l pr,@-r15; \ + cfi_adjust_cfa_offset (4); \ + cfi_rel_offset (pr, 0); \ mov r15,r14; \ + cfi_def_cfa_register (r14); \ mov.l 1f,r1; \ bsrf r1; \ nop; \ diff --git a/sysdeps/unix/sysv/linux/sigaction.c b/sysdeps/unix/sysv/linux/sigaction.c index 91c37824bc..a9ad6b18f3 100644 --- a/sysdeps/unix/sysv/linux/sigaction.c +++ b/sysdeps/unix/sysv/linux/sigaction.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997,1998,1999,2000,2002,2003 Free Software Foundation, Inc. +/* Copyright (C) 1997-2000,2002,2003,2005 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 @@ -129,6 +129,10 @@ __libc_sigaction (sig, act, oact) } libc_hidden_def (__libc_sigaction) +#ifdef WRAPPER_INCLUDE +# include WRAPPER_INCLUDE +#endif + #ifndef LIBC_SIGACTION weak_alias (__libc_sigaction, __sigaction) libc_hidden_weak (__sigaction) diff --git a/sysdeps/unix/sysv/linux/sparc/bits/setjmp.h b/sysdeps/unix/sysv/linux/sparc/bits/setjmp.h index dac9ac5cba..45aa2655ee 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/setjmp.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/setjmp.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1997,1999,2000,2003 Free Software Foundation, Inc. +/* Copyright (C) 1997,1999,2000,2003, 2005 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 @@ -59,8 +59,8 @@ typedef struct __sparc64_jmp_buf /* Test if longjmp to JMPBUF would unwind the frame containing a local variable at ADDRESS. */ -#define _JMPBUF_UNWINDS(jmpbuf, address) \ - ((unsigned long int) (address) < (jmpbuf)->uc_mcontext.mc_fp) +#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \ + ((unsigned long int) (address) < demangle ((jmpbuf)->uc_mcontext.mc_fp)) #else @@ -76,8 +76,8 @@ typedef int __jmp_buf[3]; /* Test if longjmp to JMPBUF would unwind the frame containing a local variable at ADDRESS. */ -#define _JMPBUF_UNWINDS(jmpbuf, address) \ - ((int) (address) < (jmpbuf)[JB_SP]) +#define _JMPBUF_UNWINDS(jmpbuf, address, demangle) \ + ((int) (address) < demangle ((jmpbuf)[JB_SP])) #endif diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c b/sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c index 7fb6459d77..3be801a932 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c @@ -1,5 +1,5 @@ /* POSIX.1 sigaction call for Linux/SPARC. - Copyright (C) 1997,1998,1999,2000,2002,2003 Free Software Foundation, Inc. + Copyright (C) 1997-2000,2002,2003,2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Miguel de Icaza (miguel@nuclecu.unam.mx), 1997. @@ -132,6 +132,10 @@ __libc_sigaction (int sig, __const struct sigaction *act, } libc_hidden_def (__libc_sigaction) +#ifdef WRAPPER_INCLUDE +# include WRAPPER_INCLUDE +#endif + #ifndef LIBC_SIGACTION weak_alias (__libc_sigaction, __sigaction); libc_hidden_weak (__sigaction) diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c b/sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c index 0a2d2c3dde..b5e35f4e40 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c @@ -1,5 +1,5 @@ /* POSIX.1 sigaction call for Linux/SPARC64. - Copyright (C) 1997,1998,1999,2000,2002,2003 Free Software Foundation, Inc. + Copyright (C) 1997-2000,2002,2003,2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Miguel de Icaza (miguel@nuclecu.unam.mx) and Jakub Jelinek (jj@ultra.linux.cz). @@ -65,6 +65,10 @@ __libc_sigaction (int sig, __const struct sigaction *act, } libc_hidden_def (__libc_sigaction) +#ifdef WRAPPER_INCLUDE +# include WRAPPER_INCLUDE +#endif + #ifndef LIBC_SIGACTION weak_alias (__libc_sigaction, __sigaction); libc_hidden_weak (__sigaction) diff --git a/sysdeps/unix/sysv/linux/x86_64/sigaction.c b/sysdeps/unix/sysv/linux/x86_64/sigaction.c index 9123047092..d6f4558cef 100644 --- a/sysdeps/unix/sysv/linux/x86_64/sigaction.c +++ b/sysdeps/unix/sysv/linux/x86_64/sigaction.c @@ -1,5 +1,5 @@ /* POSIX.1 `sigaction' call for Linux/x86-64. - Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2005 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 @@ -79,6 +79,10 @@ __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact) } libc_hidden_def (__libc_sigaction) +#ifdef WRAPPER_INCLUDE +# include WRAPPER_INCLUDE +#endif + #ifndef LIBC_SIGACTION weak_alias (__libc_sigaction, __sigaction) libc_hidden_weak (__sigaction) |