summaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-12-12 18:13:35 +0000
committerJakub Jelinek <jakub@redhat.com>2007-12-12 18:13:35 +0000
commit574e283890a6ca92325a06dafa76ff307a8019a2 (patch)
tree055e44e24a55fb4863e5d9cdc04e320cde52ffe9 /sysdeps
parenta162e5955f7e324be82d9318bbcbe869c66ffb86 (diff)
Updated to fedora-glibc-20071212T1051
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/i386/backtrace.c35
-rw-r--r--sysdeps/i386/i586/memcpy_chk.S1
-rw-r--r--sysdeps/i386/i586/mempcpy_chk.S1
-rw-r--r--sysdeps/i386/i586/memset_chk.S1
-rw-r--r--sysdeps/ia64/backtrace.c25
-rw-r--r--sysdeps/ieee754/dbl-64/sincos.tbl4
-rw-r--r--sysdeps/mach/hurd/bits/fcntl.h9
-rw-r--r--sysdeps/mach/hurd/fcntl.c12
-rw-r--r--sysdeps/mach/hurd/kernel-features.h31
-rw-r--r--sysdeps/posix/getaddrinfo.c441
-rw-r--r--sysdeps/pthread/aio_misc.c8
-rw-r--r--sysdeps/s390/bits/string.h20
-rw-r--r--sysdeps/sparc/dl-procinfo.c4
-rw-r--r--sysdeps/sparc/dl-procinfo.h4
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/sparcv9v2/memcpy.S2
-rw-r--r--sysdeps/sparc/sparc32/sparcv9/sparcv9v2/memset.S2
-rw-r--r--sysdeps/sparc/sparc64/sparcv9v2/memcpy.S743
-rw-r--r--sysdeps/sparc/sparc64/sparcv9v2/memset.S1
-rw-r--r--sysdeps/unix/sysv/linux/Makefile6
-rw-r--r--sysdeps/unix/sysv/linux/adjtime.c24
-rw-r--r--sysdeps/unix/sysv/linux/bits/sched.h56
-rw-r--r--sysdeps/unix/sysv/linux/check_native.c172
-rw-r--r--sysdeps/unix/sysv/linux/check_pf.c124
-rw-r--r--sysdeps/unix/sysv/linux/i386/makecontext.S16
-rw-r--r--sysdeps/unix/sysv/linux/ia64/syscalls.list3
-rw-r--r--sysdeps/unix/sysv/linux/kernel-features.h5
-rw-r--r--sysdeps/unix/sysv/linux/netiucv/iucv.h39
-rw-r--r--sysdeps/unix/sysv/linux/nscd_setup_thread.c8
-rw-r--r--sysdeps/unix/sysv/linux/open64.c23
-rw-r--r--sysdeps/unix/sysv/linux/open64_2.c32
-rw-r--r--sysdeps/unix/sysv/linux/opensock.c7
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list2
-rw-r--r--sysdeps/unix/sysv/linux/readahead.c8
-rw-r--r--sysdeps/unix/sysv/linux/s390/opensock.c2
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list3
-rw-r--r--sysdeps/unix/sysv/linux/s390/sa_len.c2
-rw-r--r--sysdeps/unix/sysv/linux/sa_len.c7
-rw-r--r--sysdeps/unix/sysv/linux/sys/epoll.h4
-rw-r--r--sysdeps/unix/sysv/linux/sys/signalfd.h2
-rw-r--r--sysdeps/unix/sysv/linux/sys/timex.h3
-rw-r--r--sysdeps/unix/sysv/linux/wordsize-64/aio_read.c7
-rw-r--r--sysdeps/unix/sysv/linux/wordsize-64/aio_read64.c1
-rw-r--r--sysdeps/unix/sysv/linux/wordsize-64/aio_write.c7
-rw-r--r--sysdeps/unix/sysv/linux/wordsize-64/aio_write64.c1
-rw-r--r--sysdeps/unix/sysv/linux/wordsize-64/creat64.c1
-rw-r--r--sysdeps/unix/sysv/linux/wordsize-64/getdirentries.c3
-rw-r--r--sysdeps/unix/sysv/linux/wordsize-64/getdirentries64.c1
-rw-r--r--sysdeps/unix/sysv/linux/wordsize-64/lio_listio.c13
-rw-r--r--sysdeps/unix/sysv/linux/wordsize-64/lio_listio64.c1
-rw-r--r--sysdeps/unix/sysv/linux/wordsize-64/open64.c1
-rw-r--r--sysdeps/unix/sysv/linux/wordsize-64/openat.c16
-rw-r--r--sysdeps/unix/sysv/linux/wordsize-64/openat64.c1
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/syscalls.list4
-rw-r--r--sysdeps/wordsize-64/alphasort.c3
-rw-r--r--sysdeps/wordsize-64/alphasort64.c1
-rw-r--r--sysdeps/wordsize-64/fseeko.c3
-rw-r--r--sysdeps/wordsize-64/fseeko64.c1
-rw-r--r--sysdeps/wordsize-64/ftello.c3
-rw-r--r--sysdeps/wordsize-64/ftello64.c1
-rw-r--r--sysdeps/wordsize-64/ftw.c16
-rw-r--r--sysdeps/wordsize-64/ftw64.c1
-rw-r--r--sysdeps/wordsize-64/iofgetpos.c12
-rw-r--r--sysdeps/wordsize-64/iofgetpos64.c1
-rw-r--r--sysdeps/wordsize-64/iofopen.c4
-rw-r--r--sysdeps/wordsize-64/iofopen64.c1
-rw-r--r--sysdeps/wordsize-64/iofsetpos.c12
-rw-r--r--sysdeps/wordsize-64/iofsetpos64.c1
-rw-r--r--sysdeps/wordsize-64/lockf.c3
-rw-r--r--sysdeps/wordsize-64/lockf64.c1
-rw-r--r--sysdeps/wordsize-64/mkostemp.c3
-rw-r--r--sysdeps/wordsize-64/mkostemp64.c1
-rw-r--r--sysdeps/wordsize-64/mkstemp.c3
-rw-r--r--sysdeps/wordsize-64/mkstemp64.c1
-rw-r--r--sysdeps/wordsize-64/scandir.c6
-rw-r--r--sysdeps/wordsize-64/scandir64.c1
-rw-r--r--sysdeps/wordsize-64/tmpfile.c3
-rw-r--r--sysdeps/wordsize-64/tmpfile64.c1
-rw-r--r--sysdeps/wordsize-64/versionsort.c3
-rw-r--r--sysdeps/wordsize-64/versionsort64.c1
-rw-r--r--sysdeps/x86_64/dl-trampoline.S54
-rw-r--r--sysdeps/x86_64/memset.S6
81 files changed, 1762 insertions, 334 deletions
diff --git a/sysdeps/i386/backtrace.c b/sysdeps/i386/backtrace.c
index 8b61913dde..cf3b2719b9 100644
--- a/sysdeps/i386/backtrace.c
+++ b/sysdeps/i386/backtrace.c
@@ -1,5 +1,5 @@
/* Return backtrace of current program state.
- Copyright (C) 1998, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2000, 2003-2005, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@@ -36,21 +36,26 @@ static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *);
static _Unwind_Ptr (*unwind_getip) (struct _Unwind_Context *);
static _Unwind_Ptr (*unwind_getcfa) (struct _Unwind_Context *);
static _Unwind_Ptr (*unwind_getgr) (struct _Unwind_Context *, int);
+static void *libgcc_handle;
static void
init (void)
{
- void *handle = __libc_dlopen ("libgcc_s.so.1");
+ libgcc_handle = __libc_dlopen ("libgcc_s.so.1");
- if (handle == NULL)
+ if (libgcc_handle == NULL)
return;
- unwind_backtrace = __libc_dlsym (handle, "_Unwind_Backtrace");
- unwind_getip = __libc_dlsym (handle, "_Unwind_GetIP");
- unwind_getcfa = __libc_dlsym (handle, "_Unwind_GetCFA");
- unwind_getgr = __libc_dlsym (handle, "_Unwind_GetGR");
+ unwind_backtrace = __libc_dlsym (libgcc_handle, "_Unwind_Backtrace");
+ unwind_getip = __libc_dlsym (libgcc_handle, "_Unwind_GetIP");
+ unwind_getcfa = __libc_dlsym (libgcc_handle, "_Unwind_GetCFA");
+ unwind_getgr = __libc_dlsym (libgcc_handle, "_Unwind_GetGR");
if (unwind_getip == NULL || unwind_getgr == NULL || unwind_getcfa == NULL)
- unwind_backtrace = NULL;
+ {
+ unwind_backtrace = NULL;
+ __libc_dlclose (libgcc_handle);
+ libgcc_handle = NULL;
+ }
}
#else
# define unwind_backtrace _Unwind_Backtrace
@@ -142,3 +147,17 @@ __backtrace (array, size)
}
weak_alias (__backtrace, backtrace)
libc_hidden_def (__backtrace)
+
+
+#ifdef SHARED
+/* Free all resources if necessary. */
+libc_freeres_fn (free_mem)
+{
+ unwind_backtrace = NULL;
+ if (libgcc_handle != NULL)
+ {
+ __libc_dlclose (libgcc_handle);
+ libgcc_handle = NULL;
+ }
+}
+#endif
diff --git a/sysdeps/i386/i586/memcpy_chk.S b/sysdeps/i386/i586/memcpy_chk.S
new file mode 100644
index 0000000000..ab8a95c9b4
--- /dev/null
+++ b/sysdeps/i386/i586/memcpy_chk.S
@@ -0,0 +1 @@
+#include <sysdeps/i386/i686/memcpy_chk.S>
diff --git a/sysdeps/i386/i586/mempcpy_chk.S b/sysdeps/i386/i586/mempcpy_chk.S
new file mode 100644
index 0000000000..9a1de1dfe3
--- /dev/null
+++ b/sysdeps/i386/i586/mempcpy_chk.S
@@ -0,0 +1 @@
+#include <sysdeps/i386/i686/mempcpy_chk.S>
diff --git a/sysdeps/i386/i586/memset_chk.S b/sysdeps/i386/i586/memset_chk.S
new file mode 100644
index 0000000000..09f9d42e0d
--- /dev/null
+++ b/sysdeps/i386/i586/memset_chk.S
@@ -0,0 +1 @@
+#include <sysdeps/i386/i686/memset_chk.S>
diff --git a/sysdeps/ia64/backtrace.c b/sysdeps/ia64/backtrace.c
index 3f2b75ec03..423fed80a8 100644
--- a/sysdeps/ia64/backtrace.c
+++ b/sysdeps/ia64/backtrace.c
@@ -1,5 +1,5 @@
/* Return backtrace of current program state.
- Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
@@ -33,17 +33,18 @@ struct trace_arg
#ifdef SHARED
static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *);
static _Unwind_Ptr (*unwind_getip) (struct _Unwind_Context *);
+static void *libgcc_handle;
static void
init (void)
{
- void *handle = __libc_dlopen ("libgcc_s.so.1");
+ libgcc_handle = __libc_dlopen ("libgcc_s.so.1");
- if (handle == NULL)
+ if (libgcc_handle == NULL)
return;
- unwind_backtrace = __libc_dlsym (handle, "_Unwind_Backtrace");
- unwind_getip = __libc_dlsym (handle, "_Unwind_GetIP");
+ unwind_backtrace = __libc_dlsym (libgcc_handle, "_Unwind_Backtrace");
+ unwind_getip = __libc_dlsym (libgcc_handle, "_Unwind_GetIP");
if (unwind_getip == NULL)
unwind_backtrace = NULL;
}
@@ -91,3 +92,17 @@ __backtrace (array, size)
}
weak_alias (__backtrace, backtrace)
libc_hidden_def (__backtrace)
+
+
+#ifdef SHARED
+/* Free all resources if necessary. */
+libc_freeres_fn (free_mem)
+{
+ unwind_backtrace = NULL;
+ if (libgcc_handle != NULL)
+ {
+ __libc_dlclose (libgcc_handle);
+ libgcc_handle = NULL;
+ }
+}
+#endif
diff --git a/sysdeps/ieee754/dbl-64/sincos.tbl b/sysdeps/ieee754/dbl-64/sincos.tbl
index 9dd5502841..9343f24163 100644
--- a/sysdeps/ieee754/dbl-64/sincos.tbl
+++ b/sysdeps/ieee754/dbl-64/sincos.tbl
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001 Free Software Foundation, Inc.
+ * Copyright (C) 2001, 2007 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -24,7 +24,7 @@
#ifdef BIG_ENDI
-static const union {int4 i[880]; double x[40];}sincos = { .i = {
+static const union {int4 i[880]; double x[440];}sincos = { .i = {
/**/ 0x00000000, 0x00000000,
/**/ 0x00000000, 0x00000000,
/**/ 0x3FF00000, 0x00000000,
diff --git a/sysdeps/mach/hurd/bits/fcntl.h b/sysdeps/mach/hurd/bits/fcntl.h
index 34e6baa049..2f890c1b65 100644
--- a/sysdeps/mach/hurd/bits/fcntl.h
+++ b/sysdeps/mach/hurd/bits/fcntl.h
@@ -71,7 +71,6 @@
#define O_SYNC O_FSYNC
#ifdef __USE_GNU
# define O_NOATIME 0x0800 /* Don't set access time on read (owner). */
-# define O_CLOEXEC 0x00010000 /* Set FD_CLOEXEC. */
#endif
#ifdef __USE_MISC
# define O_SHLOCK 0x00020000 /* Open with shared file lock. */
@@ -118,6 +117,9 @@
once the file has been opened. */
#define O_TRUNC 0x00010000 /* Truncate file to zero length. */
+#ifdef __USE_GNU
+# define O_CLOEXEC 0x00400000 /* Set FD_CLOEXEC. */
+#endif
/* Controlling terminal flags. These are understood only by `open',
@@ -163,6 +165,11 @@
#define F_SETLK 8 /* Set record locking info (non-blocking). */
#define F_SETLKW 9 /* Set record locking info (blocking). */
+#ifdef __USE_GNU
+# define F_DUPFD_CLOEXEC 1030 /* Duplicate, set FD_CLOEXEC on new one. */
+#endif
+
+
/* File descriptor flags used with F_GETFD and F_SETFD. */
#define FD_CLOEXEC 1 /* Close on exec. */
diff --git a/sysdeps/mach/hurd/fcntl.c b/sysdeps/mach/hurd/fcntl.c
index d4e4aa5da1..470614b360 100644
--- a/sysdeps/mach/hurd/fcntl.c
+++ b/sysdeps/mach/hurd/fcntl.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-1997,1999,2000,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1992-1997,1999,2000,2002,2007 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
@@ -50,6 +50,7 @@ __libc_fcntl (int fd, int cmd, ...)
/* First the descriptor-based commands, which do no RPCs. */
case F_DUPFD: /* Duplicate the file descriptor. */
+ case F_DUPFD_CLOEXEC:
{
struct hurd_fd *new;
io_t port, ctty;
@@ -64,6 +65,12 @@ __libc_fcntl (int fd, int cmd, ...)
ctty = _hurd_port_get (&d->ctty, &ctty_ulink);
port = _hurd_port_locked_get (&d->port, &ulink); /* Unlocks D. */
+ if (cmd == F_DUPFD_CLOEXEC)
+ flags |= FD_CLOEXEC;
+ else
+ /* Duplication clears the FD_CLOEXEC flag. */
+ flags &= ~FD_CLOEXEC;
+
/* Get a new file descriptor. The third argument to __fcntl is the
minimum file descriptor number for it. */
new = _hurd_alloc_fd (&result, va_arg (ap, int));
@@ -82,8 +89,7 @@ __libc_fcntl (int fd, int cmd, ...)
/* Install the ports and flags in the new descriptor. */
if (ctty != MACH_PORT_NULL)
_hurd_port_set (&new->ctty, ctty);
- /* Duplication clears the FD_CLOEXEC flag. */
- new->flags = flags & ~FD_CLOEXEC;
+ new->flags = flags;
_hurd_port_locked_set (&new->port, port); /* Unlocks NEW. */
}
diff --git a/sysdeps/mach/hurd/kernel-features.h b/sysdeps/mach/hurd/kernel-features.h
new file mode 100644
index 0000000000..ad159aace8
--- /dev/null
+++ b/sysdeps/mach/hurd/kernel-features.h
@@ -0,0 +1,31 @@
+/* Set flags signalling availability of certain operating system features.
+ Copyright (C) 2007 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. */
+
+/* This file can define __ASSUME_* macros checked by certain source files.
+ Almost none of these are used outside of sysdeps/unix/sysv/linux code.
+ But those referring to POSIX-level features like O_* flags can be. */
+
+#include <fcntl.h>
+
+/* If a system defines the O_CLOEXEC constant but it is sometimes ignored,
+ it must override this file to define __ASSUME_O_CLOEXEC conditionally
+ (or not at all) to indicate when O_CLOEXEC actually works. */
+#ifdef O_CLOEXEC
+# define __ASSUME_O_CLOEXEC 1
+#endif
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 8cf9c6bdfe..e8f4099b7f 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -61,10 +61,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <nscd/nscd-client.h>
#include <nscd/nscd_proto.h>
-#ifdef HAVE_NETLINK_ROUTE
-# include <kernel-features.h>
-#endif
-
#ifdef HAVE_LIBIDN
extern int __idna_to_ascii_lz (const char *input, char **output, int flags);
extern int __idna_to_unicode_lzlz (const char *input, char **output,
@@ -1006,9 +1002,50 @@ struct sort_result
uint8_t source_addr_len;
bool got_source_addr;
uint8_t source_addr_flags;
+ uint8_t prefixlen;
+ uint32_t index;
+ int32_t native;
+};
+
+struct sort_result_combo
+{
+ struct sort_result *results;
+ int nresults;
};
+#if __BYTE_ORDER == __BIG_ENDIAN
+# define htonl_c(n) n
+#else
+# define htonl_c(n) __bswap_constant_32 (n)
+#endif
+
+static const struct scopeentry
+{
+ union
+ {
+ char addr[4];
+ uint32_t addr32;
+ };
+ uint32_t netmask;
+ int32_t scope;
+} default_scopes[] =
+ {
+ /* Link-local addresses: scope 2. */
+ { { { 169, 254, 0, 0 } }, htonl_c (0xffff0000), 2 },
+ { { { 127, 0, 0, 0 } }, htonl_c (0xff000000), 2 },
+ /* Site-local addresses: scope 5. */
+ { { { 10, 0, 0, 0 } }, htonl_c (0xff000000), 5 },
+ { { { 172, 16, 0, 0 } }, htonl_c (0xfff00000), 5 },
+ { { { 192, 168, 0, 0 } }, htonl_c (0xffff0000), 5 },
+ /* Default: scope 14. */
+ { { { 0, 0, 0, 0 } }, htonl_c (0x00000000), 14 }
+ };
+
+/* The label table. */
+static const struct scopeentry *scopes;
+
+
static int
get_scope (const struct sockaddr_storage *ss)
{
@@ -1033,17 +1070,17 @@ get_scope (const struct sockaddr_storage *ss)
else if (ss->ss_family == PF_INET)
{
const struct sockaddr_in *in = (const struct sockaddr_in *) ss;
- const uint8_t *addr = (const uint8_t *) &in->sin_addr;
-
- /* RFC 3484 specifies how to map IPv6 addresses to scopes.
- 169.254/16 and 127/8 are link-local. */
- if ((addr[0] == 169 && addr[1] == 254) || addr[0] == 127)
- scope = 2;
- else if (addr[0] == 10 || (addr[0] == 172 && (addr[1] & 0xf0) == 16)
- || (addr[0] == 192 && addr[1] == 168))
- scope = 5;
- else
- scope = 14;
+
+ size_t cnt = 0;
+ while (1)
+ {
+ if ((in->sin_addr.s_addr & scopes[cnt].netmask)
+ == scopes[cnt].addr32)
+ return scopes[cnt].scope;
+
+ ++cnt;
+ }
+ /* NOTREACHED */
}
else
/* XXX What is a good default? */
@@ -1099,6 +1136,7 @@ static const struct prefixentry default_labels[] =
= { .u6_addr8 = { 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
7, 6 },
+ /* Additional rule for Teredo tunnels. */
{ { .in6_u
= { .u6_addr8 = { 0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } },
@@ -1223,7 +1261,7 @@ static int
fls (uint32_t a)
{
uint32_t mask;
- int n = 0;
+ int n;
for (n = 0, mask = 1 << 31; n < 32; mask >>= 1, ++n)
if ((a & mask) != 0)
break;
@@ -1232,10 +1270,11 @@ fls (uint32_t a)
static int
-rfc3484_sort (const void *p1, const void *p2)
+rfc3484_sort (const void *p1, const void *p2, void *arg)
{
const struct sort_result *a1 = (const struct sort_result *) p1;
const struct sort_result *a2 = (const struct sort_result *) p2;
+ struct sort_result_combo *src = (struct sort_result_combo *) arg;
/* Rule 1: Avoid unusable destinations.
We have the got_source_addr flag set if the destination is reachable. */
@@ -1320,14 +1359,34 @@ rfc3484_sort (const void *p1, const void *p2)
/* Rule 7: Prefer native transport. */
if (a1->got_source_addr)
{
- if (!(a1->source_addr_flags & in6ai_temporary)
- && (a2->source_addr_flags & in6ai_temporary))
- return -1;
- if ((a1->source_addr_flags & in6ai_temporary)
- && !(a2->source_addr_flags & in6ai_temporary))
- return 1;
+ /* The same interface index means the same interface which means
+ there is no difference in transport. This should catch many
+ (most?) cases. */
+ if (a1->index != a2->index)
+ {
+ if (a1->native == -1 || a2->native == -1)
+ {
+ /* If we do not have the information use 'native' as the
+ default. */
+ int a1_native = 0;
+ int a2_native = 0;
+ __check_native (a1->index, &a1_native, a2->index, &a2_native);
+
+ /* Fill in the results in all the records. */
+ for (int i = 0; i < src->nresults; ++i)
+ {
+ if (a1->native == -1 && src->results[i].index == a1->index)
+ src->results[i].native = a1_native;
+ if (a2->native == -1 && src->results[i].index == a2->index)
+ src->results[i].native = a2_native;
+ }
+ }
- /* XXX Do we need to check anything beside temporary addresses? */
+ if (a1->native && !a2->native)
+ return -1;
+ if (!a1->native && a2->native)
+ return 1;
+ }
}
@@ -1350,20 +1409,31 @@ rfc3484_sort (const void *p1, const void *p2)
assert (a1->source_addr.ss_family == PF_INET);
assert (a2->source_addr.ss_family == PF_INET);
- struct sockaddr_in *in1_dst;
- struct sockaddr_in *in1_src;
- struct sockaddr_in *in2_dst;
- struct sockaddr_in *in2_src;
-
- in1_dst = (struct sockaddr_in *) a1->dest_addr->ai_addr;
- in1_src = (struct sockaddr_in *) &a1->source_addr;
- in2_dst = (struct sockaddr_in *) a2->dest_addr->ai_addr;
- in2_src = (struct sockaddr_in *) &a2->source_addr;
-
- bit1 = fls (ntohl (in1_dst->sin_addr.s_addr
- ^ in1_src->sin_addr.s_addr));
- bit2 = fls (ntohl (in2_dst->sin_addr.s_addr
- ^ in2_src->sin_addr.s_addr));
+ /* Outside of subnets, as defined by the network masks,
+ common address prefixes for IPv4 addresses make no sense.
+ So, define a non-zero value only if source and
+ destination address are on the same subnet. */
+ struct sockaddr_in *in1_dst
+ = (struct sockaddr_in *) a1->dest_addr->ai_addr;
+ in_addr_t in1_dst_addr = ntohl (in1_dst->sin_addr.s_addr);
+ struct sockaddr_in *in1_src
+ = (struct sockaddr_in *) &a1->source_addr;
+ in_addr_t in1_src_addr = ntohl (in1_src->sin_addr.s_addr);
+ in_addr_t netmask1 = 0xffffffffu << (32 - a1->prefixlen);
+
+ if ((in1_src_addr & netmask1) == (in1_dst_addr & netmask1))
+ bit1 = fls (in1_dst_addr ^ in1_src_addr);
+
+ struct sockaddr_in *in2_dst
+ = (struct sockaddr_in *) a2->dest_addr->ai_addr;
+ in_addr_t in2_dst_addr = ntohl (in2_dst->sin_addr.s_addr);
+ struct sockaddr_in *in2_src
+ = (struct sockaddr_in *) &a2->source_addr;
+ in_addr_t in2_src_addr = ntohl (in2_src->sin_addr.s_addr);
+ in_addr_t netmask2 = 0xffffffffu << (32 - a2->prefixlen);
+
+ if ((in2_src_addr & netmask2) == (in2_dst_addr & netmask2))
+ bit2 = fls (in2_dst_addr ^ in2_src_addr);
}
else if (a1->dest_addr->ai_family == PF_INET6)
{
@@ -1452,6 +1522,13 @@ libc_freeres_fn(fini)
precedence = default_precedence;
free ((void *) old);
}
+
+ if (scopes != default_scopes)
+ {
+ const struct scopeentry *old = scopes;
+ scopes = default_scopes;
+ free ((void *) old);
+ }
}
@@ -1462,6 +1539,13 @@ struct prefixlist
};
+struct scopelist
+{
+ struct scopeentry entry;
+ struct scopelist *next;
+};
+
+
static void
free_prefixlist (struct prefixlist *list)
{
@@ -1474,6 +1558,18 @@ free_prefixlist (struct prefixlist *list)
}
+static void
+free_scopelist (struct scopelist *list)
+{
+ while (list != NULL)
+ {
+ struct scopelist *oldp = list;
+ list = list->next;
+ free (oldp);
+ }
+}
+
+
static int
prefixcmp (const void *p1, const void *p2)
{
@@ -1488,6 +1584,20 @@ prefixcmp (const void *p1, const void *p2)
}
+static int
+scopecmp (const void *p1, const void *p2)
+{
+ const struct scopeentry *e1 = (const struct scopeentry *) p1;
+ const struct scopeentry *e2 = (const struct scopeentry *) p2;
+
+ if (e1->netmask > e2->netmask)
+ return -1;
+ if (e1->netmask == e2->netmask)
+ return 0;
+ return 1;
+}
+
+
static void
gaiconf_init (void)
{
@@ -1497,6 +1607,9 @@ gaiconf_init (void)
struct prefixlist *precedencelist = NULL;
size_t nprecedencelist = 0;
bool precedencelist_nullbits = false;
+ struct scopelist *scopelist = NULL;
+ size_t nscopelist = 0;
+ bool scopelist_nullbits = false;
FILE *fp = fopen (GAICONF_FNAME, "rc");
if (fp != NULL)
@@ -1587,7 +1700,7 @@ gaiconf_init (void)
|| (bits = strtoul (cp, &endp, 10)) != ULONG_MAX
|| errno != ERANGE)
&& *endp == '\0'
- && bits <= INT_MAX
+ && bits <= 128
&& ((val = strtoul (val2, &endp, 10)) != ULONG_MAX
|| errno != ERANGE)
&& *endp == '\0'
@@ -1621,6 +1734,73 @@ gaiconf_init (void)
}
break;
+ case 7:
+ if (strcmp (cmd, "scopev4") == 0)
+ {
+ struct in6_addr prefix;
+ unsigned long int bits;
+ unsigned long int val;
+ char *endp;
+
+ bits = 32;
+ __set_errno (0);
+ cp = strchr (val1, '/');
+ if (cp != NULL)
+ *cp++ = '\0';
+ if (inet_pton (AF_INET6, val1, &prefix))
+ {
+ if (IN6_IS_ADDR_V4MAPPED (&prefix)
+ && (cp == NULL
+ || (bits = strtoul (cp, &endp, 10)) != ULONG_MAX
+ || errno != ERANGE)
+ && *endp == '\0'
+ && bits >= 96
+ && bits <= 128
+ && ((val = strtoul (val2, &endp, 10)) != ULONG_MAX
+ || errno != ERANGE)
+ && *endp == '\0'
+ && val <= INT_MAX)
+ {
+ struct scopelist *newp;
+ new_scope:
+ newp = malloc (sizeof (*newp));
+ if (newp == NULL)
+ {
+ free (line);
+ fclose (fp);
+ goto no_file;
+ }
+
+ newp->entry.netmask = htonl (bits != 96
+ ? (0xffffffff
+ << (128 - bits))
+ : 0);
+ newp->entry.addr32 = (prefix.s6_addr32[3]
+ & newp->entry.netmask);
+ newp->entry.scope = val;
+ newp->next = scopelist;
+ scopelist = newp;
+ ++nscopelist;
+ scopelist_nullbits |= bits == 96;
+ }
+ }
+ else if (inet_pton (AF_INET, val1, &prefix.s6_addr32[3])
+ && (cp == NULL
+ || (bits = strtoul (cp, &endp, 10)) != ULONG_MAX
+ || errno != ERANGE)
+ && *endp == '\0'
+ && bits <= 32
+ && ((val = strtoul (val2, &endp, 10)) != ULONG_MAX
+ || errno != ERANGE)
+ && *endp == '\0'
+ && val <= INT_MAX)
+ {
+ bits += 96;
+ goto new_scope;
+ }
+ }
+ break;
+
case 10:
if (strcmp (cmd, "precedence") == 0)
{
@@ -1704,12 +1884,52 @@ gaiconf_init (void)
/* Sort the entries so that the most specific ones are at
the beginning. */
- qsort (new_precedence, nprecedencelist, sizeof (*new_labels),
+ qsort (new_precedence, nprecedencelist, sizeof (*new_precedence),
prefixcmp);
}
else
new_precedence = (struct prefixentry *) default_precedence;
+ struct scopeentry *new_scopes;
+ if (nscopelist > 0)
+ {
+ if (!scopelist_nullbits)
+ ++nscopelist;
+ new_scopes = malloc (nscopelist * sizeof (*new_scopes));
+ if (new_scopes == NULL)
+ {
+ if (new_labels != default_labels)
+ free (new_labels);
+ if (new_precedence != default_precedence)
+ free (new_precedence);
+ goto no_file;
+ }
+
+ int i = nscopelist;
+ if (!scopelist_nullbits)
+ {
+ --i;
+ new_scopes[i].addr32 = 0;
+ new_scopes[i].netmask = 0;
+ new_scopes[i].scope = 14;
+ }
+
+ struct scopelist *l = scopelist;
+ while (i-- > 0)
+ {
+ new_scopes[i] = l->entry;
+ l = l->next;
+ }
+ free_scopelist (scopelist);
+
+ /* Sort the entries so that the most specific ones are at
+ the beginning. */
+ qsort (new_scopes, nscopelist, sizeof (*new_scopes),
+ scopecmp);
+ }
+ else
+ new_scopes = (struct scopeentry *) default_scopes;
+
/* Now we are ready to replace the values. */
const struct prefixentry *old = labels;
labels = new_labels;
@@ -1721,6 +1941,11 @@ gaiconf_init (void)
if (old != default_precedence)
free ((void *) old);
+ const struct scopeentry *oldscope = scopes;
+ scopes = new_scopes;
+ if (oldscope != default_scopes)
+ free ((void *) oldscope);
+
gaiconf_mtime = st.st_mtim;
}
else
@@ -1728,6 +1953,7 @@ gaiconf_init (void)
no_file:
free_prefixlist (labellist);
free_prefixlist (precedencelist);
+ free_scopelist (scopelist);
/* If we previously read the file but it is gone now, free the
old data and use the builtin one. Leave the reload flag
@@ -1747,16 +1973,6 @@ gaiconf_reload (void)
}
-#if HAVE_NETLINK_ROUTE
-# if __ASSUME_NETLINK_SUPPORT == 0
-/* Defined in ifaddrs.c. */
-extern int __no_netlink_support attribute_hidden;
-# else
-# define __no_netlink_support 0
-# endif
-#endif
-
-
int
getaddrinfo (const char *name, const char *service,
const struct addrinfo *hints, struct addrinfo **pai)
@@ -1795,71 +2011,12 @@ getaddrinfo (const char *name, const char *service,
size_t in6ailen = 0;
bool seen_ipv4 = false;
bool seen_ipv6 = false;
-#ifdef HAVE_NETLINK_ROUTE
- int sockfd = -1;
- pid_t nl_pid;
-#endif
- /* We might need information about what kind of interfaces are available.
- But even if AI_ADDRCONFIG is not used, if the user requested IPv6
- addresses we have to know whether an address is deprecated or
- temporary. */
- if ((hints->ai_flags & AI_ADDRCONFIG) || hints->ai_family == PF_UNSPEC
- || hints->ai_family == PF_INET6)
- {
- /* Determine whether we have IPv4 or IPv6 interfaces or both. We
- cannot cache the results since new interfaces could be added at
- any time. */
- __check_pf (&seen_ipv4, &seen_ipv6, &in6ai, &in6ailen);
-#ifdef HAVE_NETLINK_ROUTE
- if (! __no_netlink_support)
- {
- sockfd = __socket (PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
-
- struct sockaddr_nl nladdr;
- memset (&nladdr, '\0', sizeof (nladdr));
- nladdr.nl_family = AF_NETLINK;
-
- socklen_t addr_len = sizeof (nladdr);
-
- if (sockfd >= 0
- && __bind (fd, (struct sockaddr *) &nladdr, sizeof (nladdr)) == 0
- && __getsockname (sockfd, (struct sockaddr *) &nladdr,
- &addr_len) == 0
- && make_request (sockfd, nladdr.nl_pid, &seen_ipv4, &seen_ipv6,
- in6ai, in6ailen) == 0)
- {
- /* It worked. */
- nl_pid = nladdr.nl_pid;
- goto got_netlink_socket;
- }
-
- if (sockfd >= 0)
- close_not_cancel_no_status (sockfd);
-
-#if __ASSUME_NETLINK_SUPPORT == 0
- /* Remember that there is no netlink support. */
- if (errno != EMFILE && errno != ENFILE)
- __no_netlink_support = 1;
-#else
- else
- {
- if (errno != EMFILE && errno != ENFILE)
- sockfd = -2;
-
- /* We cannot determine what interfaces are available. Be
- pessimistic. */
- seen_ipv4 = true;
- seen_ipv6 = true;
- return;
- }
-#endif
- }
-#endif
- }
+ /* We might need information about what interfaces are available.
+ Also determine whether we have IPv4 or IPv6 interfaces or both. We
+ cannot cache the results since new interfaces could be added at
+ any time. */
+ __check_pf (&seen_ipv4, &seen_ipv6, &in6ai, &in6ailen);
-#ifdef HAVE_NETLINK_ROUTE
- got_netlink_socket:
-#endif
if (hints->ai_flags & AI_ADDRCONFIG)
{
/* Now make a decision on what we return, if anything. */
@@ -1947,7 +2104,7 @@ getaddrinfo (const char *name, const char *service,
struct addrinfo *last = NULL;
char *canonname = NULL;
- /* If we have information about deprecated and temporary address
+ /* If we have information about deprecated and temporary addresses
sort the array now. */
if (in6ai != NULL)
qsort (in6ai, in6ailen, sizeof (*in6ai), in6aicmp);
@@ -1958,8 +2115,8 @@ getaddrinfo (const char *name, const char *service,
for (i = 0, q = p; q != NULL; ++i, last = q, q = q->ai_next)
{
results[i].dest_addr = q;
- results[i].got_source_addr = false;
results[i].service_order = i;
+ results[i].native = -1;
/* If we just looked up the address for a different
protocol, reuse the result. */
@@ -1971,10 +2128,15 @@ getaddrinfo (const char *name, const char *service,
results[i].source_addr_len = results[i - 1].source_addr_len;
results[i].got_source_addr = results[i - 1].got_source_addr;
results[i].source_addr_flags = results[i - 1].source_addr_flags;
+ results[i].prefixlen = results[i - 1].prefixlen;
+ results[i].index = results[i - 1].index;
}
else
{
+ results[i].got_source_addr = false;
results[i].source_addr_flags = 0;
+ results[i].prefixlen = 0;
+ results[i].index = 0xffffffffu;
/* We overwrite the type with SOCK_DGRAM since we do not
want connect() to connect to the other side. If we
@@ -2005,22 +2167,40 @@ getaddrinfo (const char *name, const char *service,
results[i].source_addr_len = sl;
results[i].got_source_addr = true;
- if (q->ai_family == AF_INET6 && in6ai != NULL)
+ if (in6ai != NULL)
{
/* See whether the source address is on the list of
deprecated or temporary addresses. */
struct in6addrinfo tmp;
- struct sockaddr_in6 *sin6p
- = (struct sockaddr_in6 *) &results[i].source_addr;
- memcpy (tmp.addr, &sin6p->sin6_addr, IN6ADDRSZ);
+
+ if (q->ai_family == AF_INET && af == AF_INET)
+ {
+ struct sockaddr_in *sinp
+ = (struct sockaddr_in *) &results[i].source_addr;
+ tmp.addr[0] = 0;
+ tmp.addr[1] = 0;
+ tmp.addr[2] = htonl (0xffff);
+ tmp.addr[3] = sinp->sin_addr.s_addr;
+ }
+ else
+ {
+ struct sockaddr_in6 *sin6p
+ = (struct sockaddr_in6 *) &results[i].source_addr;
+ memcpy (tmp.addr, &sin6p->sin6_addr, IN6ADDRSZ);
+ }
struct in6addrinfo *found
= bsearch (&tmp, in6ai, in6ailen, sizeof (*in6ai),
in6aicmp);
if (found != NULL)
- results[i].source_addr_flags = found->flags;
+ {
+ results[i].source_addr_flags = found->flags;
+ results[i].prefixlen = found->prefixlen;
+ results[i].index = found->index;
+ }
}
- else if (q->ai_family == AF_INET && af == AF_INET6)
+
+ if (q->ai_family == AF_INET && af == AF_INET6)
{
/* We have to convert the address. The socket is
IPv6 and the request is for IPv4. */
@@ -2029,10 +2209,17 @@ getaddrinfo (const char *name, const char *service,
struct sockaddr_in *sin
= (struct sockaddr_in *) &results[i].source_addr;
assert (IN6_IS_ADDR_V4MAPPED (sin6->sin6_addr.s6_addr32));
+ sin->sin_family = AF_INET;
+ /* We do not have to initialize sin_port since this
+ fields has the same position and size in the IPv6
+ structure. */
+ assert (offsetof (struct sockaddr_in, sin_port)
+ == offsetof (struct sockaddr_in6, sin6_port));
+ assert (sizeof (sin->sin_port)
+ == sizeof (sin6->sin6_port));
memcpy (&sin->sin_addr,
&sin6->sin6_addr.s6_addr32[3], INADDRSZ);
- results[i].source_addr_len = INADDRSZ;
- sin->sin_family = AF_INET;
+ results[i].source_addr_len = sizeof (struct sockaddr_in);
}
}
else if (errno == EAFNOSUPPORT && af == AF_INET6
@@ -2059,6 +2246,8 @@ getaddrinfo (const char *name, const char *service,
/* We got all the source addresses we can get, now sort using
the information. */
+ struct sort_result_combo src
+ = { .results = results, .nresults = nresults };
if (__builtin_expect (gaiconf_reload_flag_ever_set, 0))
{
__libc_lock_define_initialized (static, lock);
@@ -2066,11 +2255,11 @@ getaddrinfo (const char *name, const char *service,
__libc_lock_lock (lock);
if (old_once && gaiconf_reload_flag)
gaiconf_reload ();
- qsort (results, nresults, sizeof (results[0]), rfc3484_sort);
+ qsort_r (results, nresults, sizeof (results[0]), rfc3484_sort, &src);
__libc_lock_unlock (lock);
}
else
- qsort (results, nresults, sizeof (results[0]), rfc3484_sort);
+ qsort_r (results, nresults, sizeof (results[0]), rfc3484_sort, &src);
/* Queue the results up as they come out of sorting. */
q = p = results[0].dest_addr;
diff --git a/sysdeps/pthread/aio_misc.c b/sysdeps/pthread/aio_misc.c
index 3e1dbe9c63..fd3fcbb755 100644
--- a/sysdeps/pthread/aio_misc.c
+++ b/sysdeps/pthread/aio_misc.c
@@ -1,5 +1,5 @@
/* Handle general operations.
- Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2006
+ Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2006, 2007
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -512,7 +512,8 @@ handle_fildes_io (void *arg)
by signals. */
if ((aiocbp->aiocb.aio_lio_opcode & 127) == LIO_READ)
{
- if (aiocbp->aiocb.aio_lio_opcode & 128)
+ if (sizeof (off_t) != sizeof (off64_t)
+ && aiocbp->aiocb.aio_lio_opcode & 128)
aiocbp->aiocb.__return_value =
TEMP_FAILURE_RETRY (__pread64 (fildes, (void *)
aiocbp->aiocb64.aio_buf,
@@ -537,7 +538,8 @@ handle_fildes_io (void *arg)
}
else if ((aiocbp->aiocb.aio_lio_opcode & 127) == LIO_WRITE)
{
- if (aiocbp->aiocb.aio_lio_opcode & 128)
+ if (sizeof (off_t) != sizeof (off64_t)
+ && aiocbp->aiocb.aio_lio_opcode & 128)
aiocbp->aiocb.__return_value =
TEMP_FAILURE_RETRY (__pwrite64 (fildes, (const void *)
aiocbp->aiocb64.aio_buf,
diff --git a/sysdeps/s390/bits/string.h b/sysdeps/s390/bits/string.h
index 87550c5f67..b2a3ba9c98 100644
--- a/sysdeps/s390/bits/string.h
+++ b/sysdeps/s390/bits/string.h
@@ -40,8 +40,10 @@
#define _HAVE_STRING_ARCH_strlen 1
#ifndef _FORCE_INLINES
+#define strlen(str) __strlen_g ((str))
+
__STRING_INLINE size_t
-strlen (__const char *__str)
+__strlen_g (__const char *__str)
{
char *__ptr, *__tmp;
@@ -59,8 +61,10 @@ strlen (__const char *__str)
/* Copy SRC to DEST. */
#define _HAVE_STRING_ARCH_strcpy 1
#ifndef _FORCE_INLINES
+#define strcpy(dest, src) __strcpy_g ((dest), (src))
+
__STRING_INLINE char *
-strcpy (char *__dest, __const char *__src)
+__strcpy_g (char *__dest, __const char *__src)
{
char *tmp = __dest;
@@ -75,8 +79,10 @@ strcpy (char *__dest, __const char *__src)
#define _HAVE_STRING_ARCH_strncpy 1
#ifndef _FORCE_INLINES
+#define strncpy(dest, src, n) __strncpy_g ((dest), (src), (n))
+
__STRING_INLINE char *
-strncpy (char *__dest, __const char *__src, size_t __n)
+__strncpy_g (char *__dest, __const char *__src, size_t __n)
{
char *__ret = __dest;
char *__ptr;
@@ -114,8 +120,10 @@ strncpy (char *__dest, __const char *__src, size_t __n)
/* Append SRC onto DEST. */
#define _HAVE_STRING_ARCH_strcat 1
#ifndef _FORCE_INLINES
+#define strcat(dest, src) __strcat_g ((dest), (src))
+
__STRING_INLINE char *
-strcat(char *__dest, const char *__src)
+__strcat_g(char *__dest, const char *__src)
{
char *__ret = __dest;
char *__ptr, *__tmp;
@@ -142,8 +150,10 @@ strcat(char *__dest, const char *__src)
/* Append no more than N characters from SRC onto DEST. */
#define _HAVE_STRING_ARCH_strncat 1
#ifndef _FORCE_INLINES
+#define strncat(dest, src, n) __strncat_g ((dest), (src), (n))
+
__STRING_INLINE char *
-strncat (char *__dest, __const char *__src, size_t __n)
+__strncat_g (char *__dest, __const char *__src, size_t __n)
{
char *__ret = __dest;
char *__ptr, *__tmp;
diff --git a/sysdeps/sparc/dl-procinfo.c b/sysdeps/sparc/dl-procinfo.c
index 875820fab3..db7e867468 100644
--- a/sysdeps/sparc/dl-procinfo.c
+++ b/sysdeps/sparc/dl-procinfo.c
@@ -47,10 +47,10 @@
#if !defined PROCINFO_DECL && defined SHARED
._dl_sparc_cap_flags
#else
-PROCINFO_CLASS const char _dl_sparc_cap_flags[7][7]
+PROCINFO_CLASS const char _dl_sparc_cap_flags[8][7]
#endif
#ifndef PROCINFO_DECL
- = { "flush", "stbar", "swap", "muldiv", "v9", "ultra3", "v9v" }
+ = { "flush", "stbar", "swap", "muldiv", "v9", "ultra3", "v9v", "v9v2" }
#endif
#if !defined SHARED || defined PROCINFO_DECL
;
diff --git a/sysdeps/sparc/dl-procinfo.h b/sysdeps/sparc/dl-procinfo.h
index dde02b556c..04ebda751b 100644
--- a/sysdeps/sparc/dl-procinfo.h
+++ b/sysdeps/sparc/dl-procinfo.h
@@ -24,7 +24,7 @@
#include <ldsodefs.h>
-#define _DL_HWCAP_COUNT 7
+#define _DL_HWCAP_COUNT 8
static inline int
__attribute__ ((unused))
@@ -66,7 +66,7 @@ _dl_string_hwcap (const char *str)
#include <bits/wordsize.h>
#define HWCAP_IMPORTANT_V9 (__WORDSIZE == 64 ? 0 : HWCAP_SPARC_V9)
#define HWCAP_IMPORTANT (HWCAP_IMPORTANT_V9 | HWCAP_SPARC_ULTRA3 \
- | HWCAP_SPARC_BLKINIT)
+ | HWCAP_SPARC_BLKINIT | HWCAP_SPARC_N2)
/* There are no different platforms defined. */
#define _dl_platform_string(idx) ""
diff --git a/sysdeps/sparc/sparc32/sparcv9/sparcv9v2/memcpy.S b/sysdeps/sparc/sparc32/sparcv9/sparcv9v2/memcpy.S
new file mode 100644
index 0000000000..7f4606037c
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/sparcv9v2/memcpy.S
@@ -0,0 +1,2 @@
+#define XCC icc
+#include <sparc64/sparcv9v2/memcpy.S>
diff --git a/sysdeps/sparc/sparc32/sparcv9/sparcv9v2/memset.S b/sysdeps/sparc/sparc32/sparcv9/sparcv9v2/memset.S
new file mode 100644
index 0000000000..72de7bb0cf
--- /dev/null
+++ b/sysdeps/sparc/sparc32/sparcv9/sparcv9v2/memset.S
@@ -0,0 +1,2 @@
+#define XCC icc
+#include <sparc64/sparcv9v2/memset.S>
diff --git a/sysdeps/sparc/sparc64/sparcv9v2/memcpy.S b/sysdeps/sparc/sparc64/sparcv9v2/memcpy.S
new file mode 100644
index 0000000000..d94dd4701e
--- /dev/null
+++ b/sysdeps/sparc/sparc64/sparcv9v2/memcpy.S
@@ -0,0 +1,743 @@
+/* Copy SIZE bytes from SRC to DEST. For SUN4V Niagara-2.
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David S. Miller (davem@davemloft.net)
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sysdep.h>
+
+#define ASI_BLK_INIT_QUAD_LDD_P 0xe2
+#define ASI_BLK_P 0xf0
+#define ASI_P 0x80
+#define ASI_PNF 0x82
+
+#define FPRS_FEF 0x04
+
+#define VISEntryHalf \
+ rd %fprs, %o5; \
+ wr %g0, FPRS_FEF, %fprs
+
+#define VISExitHalf \
+ and %o5, FPRS_FEF, %o5; \
+ wr %o5, 0x0, %fprs
+
+#define STORE_ASI ASI_BLK_INIT_QUAD_LDD_P
+
+#define LOAD(type,addr,dest) type [addr], dest
+#define LOAD_BLK(addr,dest) ldda [addr] ASI_BLK_P, dest
+#define STORE(type,src,addr) type src, [addr]
+#define STORE_BLK(src,addr) stda src, [addr] ASI_BLK_P
+#define STORE_INIT(src,addr) stxa src, [addr] STORE_ASI
+
+#ifndef XCC
+#define USE_BPR
+#define XCC xcc
+#endif
+
+#define FREG_FROB(x0, x1, x2, x3, x4, x5, x6, x7, x8) \
+ faligndata %x0, %x1, %f0; \
+ faligndata %x1, %x2, %f2; \
+ faligndata %x2, %x3, %f4; \
+ faligndata %x3, %x4, %f6; \
+ faligndata %x4, %x5, %f8; \
+ faligndata %x5, %x6, %f10; \
+ faligndata %x6, %x7, %f12; \
+ faligndata %x7, %x8, %f14;
+
+#define FREG_MOVE_1(x0) \
+ fmovd %x0, %f0;
+#define FREG_MOVE_2(x0, x1) \
+ fmovd %x0, %f0; \
+ fmovd %x1, %f2;
+#define FREG_MOVE_3(x0, x1, x2) \
+ fmovd %x0, %f0; \
+ fmovd %x1, %f2; \
+ fmovd %x2, %f4;
+#define FREG_MOVE_4(x0, x1, x2, x3) \
+ fmovd %x0, %f0; \
+ fmovd %x1, %f2; \
+ fmovd %x2, %f4; \
+ fmovd %x3, %f6;
+#define FREG_MOVE_5(x0, x1, x2, x3, x4) \
+ fmovd %x0, %f0; \
+ fmovd %x1, %f2; \
+ fmovd %x2, %f4; \
+ fmovd %x3, %f6; \
+ fmovd %x4, %f8;
+#define FREG_MOVE_6(x0, x1, x2, x3, x4, x5) \
+ fmovd %x0, %f0; \
+ fmovd %x1, %f2; \
+ fmovd %x2, %f4; \
+ fmovd %x3, %f6; \
+ fmovd %x4, %f8; \
+ fmovd %x5, %f10;
+#define FREG_MOVE_7(x0, x1, x2, x3, x4, x5, x6) \
+ fmovd %x0, %f0; \
+ fmovd %x1, %f2; \
+ fmovd %x2, %f4; \
+ fmovd %x3, %f6; \
+ fmovd %x4, %f8; \
+ fmovd %x5, %f10; \
+ fmovd %x6, %f12;
+#define FREG_MOVE_8(x0, x1, x2, x3, x4, x5, x6, x7) \
+ fmovd %x0, %f0; \
+ fmovd %x1, %f2; \
+ fmovd %x2, %f4; \
+ fmovd %x3, %f6; \
+ fmovd %x4, %f8; \
+ fmovd %x5, %f10; \
+ fmovd %x6, %f12; \
+ fmovd %x7, %f14;
+#define FREG_LOAD_1(base, x0) \
+ LOAD(ldd, base + 0x00, %x0)
+#define FREG_LOAD_2(base, x0, x1) \
+ LOAD(ldd, base + 0x00, %x0); \
+ LOAD(ldd, base + 0x08, %x1);
+#define FREG_LOAD_3(base, x0, x1, x2) \
+ LOAD(ldd, base + 0x00, %x0); \
+ LOAD(ldd, base + 0x08, %x1); \
+ LOAD(ldd, base + 0x10, %x2);
+#define FREG_LOAD_4(base, x0, x1, x2, x3) \
+ LOAD(ldd, base + 0x00, %x0); \
+ LOAD(ldd, base + 0x08, %x1); \
+ LOAD(ldd, base + 0x10, %x2); \
+ LOAD(ldd, base + 0x18, %x3);
+#define FREG_LOAD_5(base, x0, x1, x2, x3, x4) \
+ LOAD(ldd, base + 0x00, %x0); \
+ LOAD(ldd, base + 0x08, %x1); \
+ LOAD(ldd, base + 0x10, %x2); \
+ LOAD(ldd, base + 0x18, %x3); \
+ LOAD(ldd, base + 0x20, %x4);
+#define FREG_LOAD_6(base, x0, x1, x2, x3, x4, x5) \
+ LOAD(ldd, base + 0x00, %x0); \
+ LOAD(ldd, base + 0x08, %x1); \
+ LOAD(ldd, base + 0x10, %x2); \
+ LOAD(ldd, base + 0x18, %x3); \
+ LOAD(ldd, base + 0x20, %x4); \
+ LOAD(ldd, base + 0x28, %x5);
+#define FREG_LOAD_7(base, x0, x1, x2, x3, x4, x5, x6) \
+ LOAD(ldd, base + 0x00, %x0); \
+ LOAD(ldd, base + 0x08, %x1); \
+ LOAD(ldd, base + 0x10, %x2); \
+ LOAD(ldd, base + 0x18, %x3); \
+ LOAD(ldd, base + 0x20, %x4); \
+ LOAD(ldd, base + 0x28, %x5); \
+ LOAD(ldd, base + 0x30, %x6);
+
+ .register %g2,#scratch
+ .register %g3,#scratch
+ .register %g6,#scratch
+
+ .text
+ .align 32
+
+ENTRY(bcopy)
+ sub %o1, %o0, %o4
+ mov %o0, %g4
+ cmp %o4, %o2
+ mov %o1, %o0
+ bgeu,pt %XCC, 100f
+ mov %g4, %o1
+#ifndef USE_BPR
+ srl %o2, 0, %o2
+#endif
+ brnz,pn %o2, 220f
+ add %o0, %o2, %o0
+ retl
+ nop
+END(bcopy)
+
+ .align 32
+ENTRY(memcpy)
+100: /* %o0=dst, %o1=src, %o2=len */
+ mov %o0, %g5
+ cmp %o2, 0
+ be,pn %XCC, 85f
+218: or %o0, %o1, %o3
+ cmp %o2, 16
+ blu,a,pn %XCC, 80f
+ or %o3, %o2, %o3
+
+ /* 2 blocks (128 bytes) is the minimum we can do the block
+ * copy with. We need to ensure that we'll iterate at least
+ * once in the block copy loop. At worst we'll need to align
+ * the destination to a 64-byte boundary which can chew up
+ * to (64 - 1) bytes from the length before we perform the
+ * block copy loop.
+ *
+ * However, the cut-off point, performance wise, is around
+ * 4 64-byte blocks.
+ */
+ cmp %o2, (4 * 64)
+ blu,pt %XCC, 75f
+ andcc %o3, 0x7, %g0
+
+ /* %o0: dst
+ * %o1: src
+ * %o2: len (known to be >= 128)
+ *
+ * The block copy loops can use %o4, %g2, %g3 as
+ * temporaries while copying the data. %o5 must
+ * be preserved between VISEntryHalf and VISExitHalf
+ */
+
+ LOAD(prefetch, %o1 + 0x000, #one_read)
+ LOAD(prefetch, %o1 + 0x040, #one_read)
+ LOAD(prefetch, %o1 + 0x080, #one_read)
+
+ /* Align destination on 64-byte boundary. */
+ andcc %o0, (64 - 1), %o4
+ be,pt %XCC, 2f
+ sub %o4, 64, %o4
+ sub %g0, %o4, %o4 ! bytes to align dst
+ sub %o2, %o4, %o2
+1: subcc %o4, 1, %o4
+ LOAD(ldub, %o1, %g1)
+ STORE(stb, %g1, %o0)
+ add %o1, 1, %o1
+ bne,pt %XCC, 1b
+ add %o0, 1, %o0
+
+2:
+ /* Clobbers o5/g1/g2/g3/g7/icc/xcc. We must preserve
+ * o5 from here until we hit VISExitHalf.
+ */
+ VISEntryHalf
+
+ alignaddr %o1, %g0, %g0
+
+ add %o1, (64 - 1), %o4
+ andn %o4, (64 - 1), %o4
+ andn %o2, (64 - 1), %g1
+ sub %o2, %g1, %o2
+
+ and %o1, (64 - 1), %g2
+ add %o1, %g1, %o1
+ sub %o0, %o4, %g3
+ brz,pt %g2, 190f
+ cmp %g2, 32
+ blu,a 5f
+ cmp %g2, 16
+ cmp %g2, 48
+ blu,a 4f
+ cmp %g2, 40
+ cmp %g2, 56
+ blu 170f
+ nop
+ ba,a,pt %xcc, 180f
+
+4: /* 32 <= low bits < 48 */
+ blu 150f
+ nop
+ ba,a,pt %xcc, 160f
+5: /* 0 < low bits < 32 */
+ blu,a 6f
+ cmp %g2, 8
+ cmp %g2, 24
+ blu 130f
+ nop
+ ba,a,pt %xcc, 140f
+6: /* 0 < low bits < 16 */
+ bgeu 120f
+ nop
+ /* fall through for 0 < low bits < 8 */
+110: sub %o4, 64, %g2
+ LOAD_BLK(%g2, %f0)
+1: STORE_INIT(%g0, %o4 + %g3)
+ LOAD_BLK(%o4, %f16)
+ FREG_FROB(f0, f2, f4, f6, f8, f10, f12, f14, f16)
+ STORE_BLK(%f0, %o4 + %g3)
+ FREG_MOVE_8(f16, f18, f20, f22, f24, f26, f28, f30)
+ subcc %g1, 64, %g1
+ add %o4, 64, %o4
+ bne,pt %XCC, 1b
+ LOAD(prefetch, %o4 + 64, #one_read)
+ ba,pt %xcc, 195f
+ nop
+
+120: sub %o4, 56, %g2
+ FREG_LOAD_7(%g2, f0, f2, f4, f6, f8, f10, f12)
+1: STORE_INIT(%g0, %o4 + %g3)
+ LOAD_BLK(%o4, %f16)
+ FREG_FROB(f0, f2, f4, f6, f8, f10, f12, f16, f18)
+ STORE_BLK(%f0, %o4 + %g3)
+ FREG_MOVE_7(f18, f20, f22, f24, f26, f28, f30)
+ subcc %g1, 64, %g1
+ add %o4, 64, %o4
+ bne,pt %XCC, 1b
+ LOAD(prefetch, %o4 + 64, #one_read)
+ ba,pt %xcc, 195f
+ nop
+
+130: sub %o4, 48, %g2
+ FREG_LOAD_6(%g2, f0, f2, f4, f6, f8, f10)
+1: STORE_INIT(%g0, %o4 + %g3)
+ LOAD_BLK(%o4, %f16)
+ FREG_FROB(f0, f2, f4, f6, f8, f10, f16, f18, f20)
+ STORE_BLK(%f0, %o4 + %g3)
+ FREG_MOVE_6(f20, f22, f24, f26, f28, f30)
+ subcc %g1, 64, %g1
+ add %o4, 64, %o4
+ bne,pt %XCC, 1b
+ LOAD(prefetch, %o4 + 64, #one_read)
+ ba,pt %xcc, 195f
+ nop
+
+140: sub %o4, 40, %g2
+ FREG_LOAD_5(%g2, f0, f2, f4, f6, f8)
+1: STORE_INIT(%g0, %o4 + %g3)
+ LOAD_BLK(%o4, %f16)
+ FREG_FROB(f0, f2, f4, f6, f8, f16, f18, f20, f22)
+ STORE_BLK(%f0, %o4 + %g3)
+ FREG_MOVE_5(f22, f24, f26, f28, f30)
+ subcc %g1, 64, %g1
+ add %o4, 64, %o4
+ bne,pt %XCC, 1b
+ LOAD(prefetch, %o4 + 64, #one_read)
+ ba,pt %xcc, 195f
+ nop
+
+150: sub %o4, 32, %g2
+ FREG_LOAD_4(%g2, f0, f2, f4, f6)
+1: STORE_INIT(%g0, %o4 + %g3)
+ LOAD_BLK(%o4, %f16)
+ FREG_FROB(f0, f2, f4, f6, f16, f18, f20, f22, f24)
+ STORE_BLK(%f0, %o4 + %g3)
+ FREG_MOVE_4(f24, f26, f28, f30)
+ subcc %g1, 64, %g1
+ add %o4, 64, %o4
+ bne,pt %XCC, 1b
+ LOAD(prefetch, %o4 + 64, #one_read)
+ ba,pt %xcc, 195f
+ nop
+
+160: sub %o4, 24, %g2
+ FREG_LOAD_3(%g2, f0, f2, f4)
+1: STORE_INIT(%g0, %o4 + %g3)
+ LOAD_BLK(%o4, %f16)
+ FREG_FROB(f0, f2, f4, f16, f18, f20, f22, f24, f26)
+ STORE_BLK(%f0, %o4 + %g3)
+ FREG_MOVE_3(f26, f28, f30)
+ subcc %g1, 64, %g1
+ add %o4, 64, %o4
+ bne,pt %XCC, 1b
+ LOAD(prefetch, %o4 + 64, #one_read)
+ ba,pt %xcc, 195f
+ nop
+
+170: sub %o4, 16, %g2
+ FREG_LOAD_2(%g2, f0, f2)
+1: STORE_INIT(%g0, %o4 + %g3)
+ LOAD_BLK(%o4, %f16)
+ FREG_FROB(f0, f2, f16, f18, f20, f22, f24, f26, f28)
+ STORE_BLK(%f0, %o4 + %g3)
+ FREG_MOVE_2(f28, f30)
+ subcc %g1, 64, %g1
+ add %o4, 64, %o4
+ bne,pt %XCC, 1b
+ LOAD(prefetch, %o4 + 64, #one_read)
+ ba,pt %xcc, 195f
+ nop
+
+180: sub %o4, 8, %g2
+ FREG_LOAD_1(%g2, f0)
+1: STORE_INIT(%g0, %o4 + %g3)
+ LOAD_BLK(%o4, %f16)
+ FREG_FROB(f0, f16, f18, f20, f22, f24, f26, f28, f30)
+ STORE_BLK(%f0, %o4 + %g3)
+ FREG_MOVE_1(f30)
+ subcc %g1, 64, %g1
+ add %o4, 64, %o4
+ bne,pt %XCC, 1b
+ LOAD(prefetch, %o4 + 64, #one_read)
+ ba,pt %xcc, 195f
+ nop
+
+190:
+1: STORE_INIT(%g0, %o4 + %g3)
+ subcc %g1, 64, %g1
+ LOAD_BLK(%o4, %f0)
+ STORE_BLK(%f0, %o4 + %g3)
+ add %o4, 64, %o4
+ bne,pt %XCC, 1b
+ LOAD(prefetch, %o4 + 64, #one_read)
+
+195:
+ add %o4, %g3, %o0
+ membar #Sync
+
+ VISExitHalf
+
+ /* %o2 contains any final bytes still needed to be copied
+ * over. If anything is left, we copy it one byte at a time.
+ */
+ brz,pt %o2, 85f
+ sub %o0, %o1, %o3
+ ba,a,pt %XCC, 90f
+
+ .align 64
+75: /* 16 < len <= 64 */
+ bne,pn %XCC, 75f
+ sub %o0, %o1, %o3
+
+72:
+ andn %o2, 0xf, %o4
+ and %o2, 0xf, %o2
+1: subcc %o4, 0x10, %o4
+ LOAD(ldx, %o1, %o5)
+ add %o1, 0x08, %o1
+ LOAD(ldx, %o1, %g1)
+ sub %o1, 0x08, %o1
+ STORE(stx, %o5, %o1 + %o3)
+ add %o1, 0x8, %o1
+ STORE(stx, %g1, %o1 + %o3)
+ bgu,pt %XCC, 1b
+ add %o1, 0x8, %o1
+73: andcc %o2, 0x8, %g0
+ be,pt %XCC, 1f
+ nop
+ sub %o2, 0x8, %o2
+ LOAD(ldx, %o1, %o5)
+ STORE(stx, %o5, %o1 + %o3)
+ add %o1, 0x8, %o1
+1: andcc %o2, 0x4, %g0
+ be,pt %XCC, 1f
+ nop
+ sub %o2, 0x4, %o2
+ LOAD(lduw, %o1, %o5)
+ STORE(stw, %o5, %o1 + %o3)
+ add %o1, 0x4, %o1
+1: cmp %o2, 0
+ be,pt %XCC, 85f
+ nop
+ ba,pt %xcc, 90f
+ nop
+
+75:
+ andcc %o0, 0x7, %g1
+ sub %g1, 0x8, %g1
+ be,pn %icc, 2f
+ sub %g0, %g1, %g1
+ sub %o2, %g1, %o2
+
+1: subcc %g1, 1, %g1
+ LOAD(ldub, %o1, %o5)
+ STORE(stb, %o5, %o1 + %o3)
+ bgu,pt %icc, 1b
+ add %o1, 1, %o1
+
+2: add %o1, %o3, %o0
+ andcc %o1, 0x7, %g1
+ bne,pt %icc, 8f
+ sll %g1, 3, %g1
+
+ cmp %o2, 16
+ bgeu,pt %icc, 72b
+ nop
+ ba,a,pt %xcc, 73b
+
+8: mov 64, %o3
+ andn %o1, 0x7, %o1
+ LOAD(ldx, %o1, %g2)
+ sub %o3, %g1, %o3
+ andn %o2, 0x7, %o4
+ sllx %g2, %g1, %g2
+1: add %o1, 0x8, %o1
+ LOAD(ldx, %o1, %g3)
+ subcc %o4, 0x8, %o4
+ srlx %g3, %o3, %o5
+ or %o5, %g2, %o5
+ STORE(stx, %o5, %o0)
+ add %o0, 0x8, %o0
+ bgu,pt %icc, 1b
+ sllx %g3, %g1, %g2
+
+ srl %g1, 3, %g1
+ andcc %o2, 0x7, %o2
+ be,pn %icc, 85f
+ add %o1, %g1, %o1
+ ba,pt %xcc, 90f
+ sub %o0, %o1, %o3
+
+ .align 64
+80: /* 0 < len <= 16 */
+ andcc %o3, 0x3, %g0
+ bne,pn %XCC, 90f
+ sub %o0, %o1, %o3
+
+1:
+ subcc %o2, 4, %o2
+ LOAD(lduw, %o1, %g1)
+ STORE(stw, %g1, %o1 + %o3)
+ bgu,pt %XCC, 1b
+ add %o1, 4, %o1
+
+85: retl
+ mov %g5, %o0
+
+ .align 32
+90:
+ subcc %o2, 1, %o2
+ LOAD(ldub, %o1, %g1)
+ STORE(stb, %g1, %o1 + %o3)
+ bgu,pt %XCC, 90b
+ add %o1, 1, %o1
+ retl
+ mov %g5, %o0
+
+END(memcpy)
+
+#define RMOVE_BIGCHUNK(src, dst, offset, t0, t1, t2, t3) \
+ ldx [%src - offset - 0x20], %t0; \
+ ldx [%src - offset - 0x18], %t1; \
+ ldx [%src - offset - 0x10], %t2; \
+ ldx [%src - offset - 0x08], %t3; \
+ stw %t0, [%dst - offset - 0x1c]; \
+ srlx %t0, 32, %t0; \
+ stw %t0, [%dst - offset - 0x20]; \
+ stw %t1, [%dst - offset - 0x14]; \
+ srlx %t1, 32, %t1; \
+ stw %t1, [%dst - offset - 0x18]; \
+ stw %t2, [%dst - offset - 0x0c]; \
+ srlx %t2, 32, %t2; \
+ stw %t2, [%dst - offset - 0x10]; \
+ stw %t3, [%dst - offset - 0x04]; \
+ srlx %t3, 32, %t3; \
+ stw %t3, [%dst - offset - 0x08];
+
+#define RMOVE_BIGALIGNCHUNK(src, dst, offset, t0, t1, t2, t3) \
+ ldx [%src - offset - 0x20], %t0; \
+ ldx [%src - offset - 0x18], %t1; \
+ ldx [%src - offset - 0x10], %t2; \
+ ldx [%src - offset - 0x08], %t3; \
+ stx %t0, [%dst - offset - 0x20]; \
+ stx %t1, [%dst - offset - 0x18]; \
+ stx %t2, [%dst - offset - 0x10]; \
+ stx %t3, [%dst - offset - 0x08]; \
+ ldx [%src - offset - 0x40], %t0; \
+ ldx [%src - offset - 0x38], %t1; \
+ ldx [%src - offset - 0x30], %t2; \
+ ldx [%src - offset - 0x28], %t3; \
+ stx %t0, [%dst - offset - 0x40]; \
+ stx %t1, [%dst - offset - 0x38]; \
+ stx %t2, [%dst - offset - 0x30]; \
+ stx %t3, [%dst - offset - 0x28];
+
+#define RMOVE_LASTCHUNK(src, dst, offset, t0, t1, t2, t3) \
+ ldx [%src + offset + 0x00], %t0; \
+ ldx [%src + offset + 0x08], %t1; \
+ stw %t0, [%dst + offset + 0x04]; \
+ srlx %t0, 32, %t2; \
+ stw %t2, [%dst + offset + 0x00]; \
+ stw %t1, [%dst + offset + 0x0c]; \
+ srlx %t1, 32, %t3; \
+ stw %t3, [%dst + offset + 0x08];
+
+#define RMOVE_LASTALIGNCHUNK(src, dst, offset, t0, t1) \
+ ldx [%src + offset + 0x00], %t0; \
+ ldx [%src + offset + 0x08], %t1; \
+ stx %t0, [%dst + offset + 0x00]; \
+ stx %t1, [%dst + offset + 0x08];
+
+ .align 32
+228: andcc %o2, 1, %g0
+ be,pt %icc, 2f+4
+1: ldub [%o1 - 1], %o5
+ sub %o1, 1, %o1
+ sub %o0, 1, %o0
+ subcc %o2, 1, %o2
+ be,pn %XCC, 229f
+ stb %o5, [%o0]
+2: ldub [%o1 - 1], %o5
+ sub %o0, 2, %o0
+ ldub [%o1 - 2], %g5
+ sub %o1, 2, %o1
+ subcc %o2, 2, %o2
+ stb %o5, [%o0 + 1]
+ bne,pt %XCC, 2b
+ stb %g5, [%o0]
+229: retl
+ mov %g4, %o0
+out: retl
+ mov %g5, %o0
+
+ .align 32
+ENTRY(memmove)
+ mov %o0, %g5
+#ifndef USE_BPR
+ srl %o2, 0, %o2
+#endif
+ brz,pn %o2, out
+ sub %o0, %o1, %o4
+ cmp %o4, %o2
+ bgeu,pt %XCC, 218b
+ mov %o0, %g4
+ add %o0, %o2, %o0
+220: add %o1, %o2, %o1
+ cmp %o2, 15
+ bleu,pn %XCC, 228b
+ andcc %o0, 7, %g2
+ sub %o0, %o1, %g5
+ andcc %g5, 3, %o5
+ bne,pn %XCC, 232f
+ andcc %o1, 3, %g0
+ be,a,pt %XCC, 236f
+ andcc %o1, 4, %g0
+ andcc %o1, 1, %g0
+ be,pn %XCC, 4f
+ andcc %o1, 2, %g0
+ ldub [%o1 - 1], %g2
+ sub %o1, 1, %o1
+ sub %o0, 1, %o0
+ sub %o2, 1, %o2
+ be,pn %XCC, 5f
+ stb %g2, [%o0]
+4: lduh [%o1 - 2], %g2
+ sub %o1, 2, %o1
+ sub %o0, 2, %o0
+ sub %o2, 2, %o2
+ sth %g2, [%o0]
+5: andcc %o1, 4, %g0
+236: be,a,pn %XCC, 2f
+ andcc %o2, -128, %g6
+ lduw [%o1 - 4], %g5
+ sub %o1, 4, %o1
+ sub %o0, 4, %o0
+ sub %o2, 4, %o2
+ stw %g5, [%o0]
+ andcc %o2, -128, %g6
+2: be,pn %XCC, 235f
+ andcc %o0, 4, %g0
+ be,pn %XCC, 282f + 4
+5: RMOVE_BIGCHUNK(o1, o0, 0x00, g1, g3, g5, o5)
+ RMOVE_BIGCHUNK(o1, o0, 0x20, g1, g3, g5, o5)
+ RMOVE_BIGCHUNK(o1, o0, 0x40, g1, g3, g5, o5)
+ RMOVE_BIGCHUNK(o1, o0, 0x60, g1, g3, g5, o5)
+ subcc %g6, 128, %g6
+ sub %o1, 128, %o1
+ bne,pt %XCC, 5b
+ sub %o0, 128, %o0
+235: andcc %o2, 0x70, %g6
+41: be,pn %XCC, 280f
+ andcc %o2, 8, %g0
+
+279: rd %pc, %o5
+ sll %g6, 1, %g5
+ sub %o1, %g6, %o1
+ sub %o5, %g5, %o5
+ jmpl %o5 + %lo(280f - 279b), %g0
+ sub %o0, %g6, %o0
+ RMOVE_LASTCHUNK(o1, o0, 0x60, g2, g3, g5, o5)
+ RMOVE_LASTCHUNK(o1, o0, 0x50, g2, g3, g5, o5)
+ RMOVE_LASTCHUNK(o1, o0, 0x40, g2, g3, g5, o5)
+ RMOVE_LASTCHUNK(o1, o0, 0x30, g2, g3, g5, o5)
+ RMOVE_LASTCHUNK(o1, o0, 0x20, g2, g3, g5, o5)
+ RMOVE_LASTCHUNK(o1, o0, 0x10, g2, g3, g5, o5)
+ RMOVE_LASTCHUNK(o1, o0, 0x00, g2, g3, g5, o5)
+280: be,pt %XCC, 281f
+ andcc %o2, 4, %g0
+ ldx [%o1 - 8], %g2
+ sub %o0, 8, %o0
+ stw %g2, [%o0 + 4]
+ sub %o1, 8, %o1
+ srlx %g2, 32, %g2
+ stw %g2, [%o0]
+281: be,pt %XCC, 1f
+ andcc %o2, 2, %g0
+ lduw [%o1 - 4], %g2
+ sub %o1, 4, %o1
+ stw %g2, [%o0 - 4]
+ sub %o0, 4, %o0
+1: be,pt %XCC, 1f
+ andcc %o2, 1, %g0
+ lduh [%o1 - 2], %g2
+ sub %o1, 2, %o1
+ sth %g2, [%o0 - 2]
+ sub %o0, 2, %o0
+1: be,pt %XCC, 211f
+ nop
+ ldub [%o1 - 1], %g2
+ stb %g2, [%o0 - 1]
+211: retl
+ mov %g4, %o0
+
+282: RMOVE_BIGALIGNCHUNK(o1, o0, 0x00, g1, g3, g5, o5)
+ RMOVE_BIGALIGNCHUNK(o1, o0, 0x40, g1, g3, g5, o5)
+ subcc %g6, 128, %g6
+ sub %o1, 128, %o1
+ bne,pt %XCC, 282b
+ sub %o0, 128, %o0
+ andcc %o2, 0x70, %g6
+ be,pn %XCC, 284f
+ andcc %o2, 8, %g0
+
+283: rd %pc, %o5
+ sub %o1, %g6, %o1
+ sub %o5, %g6, %o5
+ jmpl %o5 + %lo(284f - 283b), %g0
+ sub %o0, %g6, %o0
+ RMOVE_LASTALIGNCHUNK(o1, o0, 0x60, g2, g3)
+ RMOVE_LASTALIGNCHUNK(o1, o0, 0x50, g2, g3)
+ RMOVE_LASTALIGNCHUNK(o1, o0, 0x40, g2, g3)
+ RMOVE_LASTALIGNCHUNK(o1, o0, 0x30, g2, g3)
+ RMOVE_LASTALIGNCHUNK(o1, o0, 0x20, g2, g3)
+ RMOVE_LASTALIGNCHUNK(o1, o0, 0x10, g2, g3)
+ RMOVE_LASTALIGNCHUNK(o1, o0, 0x00, g2, g3)
+284: be,pt %XCC, 285f
+ andcc %o2, 4, %g0
+ ldx [%o1 - 8], %g2
+ sub %o0, 8, %o0
+ sub %o1, 8, %o1
+ stx %g2, [%o0]
+285: be,pt %XCC, 1f
+ andcc %o2, 2, %g0
+ lduw [%o1 - 4], %g2
+ sub %o0, 4, %o0
+ sub %o1, 4, %o1
+ stw %g2, [%o0]
+1: be,pt %XCC, 1f
+ andcc %o2, 1, %g0
+ lduh [%o1 - 2], %g2
+ sub %o0, 2, %o0
+ sub %o1, 2, %o1
+ sth %g2, [%o0]
+1: be,pt %XCC, 1f
+ nop
+ ldub [%o1 - 1], %g2
+ stb %g2, [%o0 - 1]
+1: retl
+ mov %g4, %o0
+
+232: ldub [%o1 - 1], %g5
+ sub %o1, 1, %o1
+ sub %o0, 1, %o0
+ subcc %o2, 1, %o2
+ bne,pt %XCC, 232b
+ stb %g5, [%o0]
+234: retl
+ mov %g4, %o0
+END(memmove)
+
+#ifdef USE_BPR
+weak_alias (memcpy, __align_cpy_1)
+weak_alias (memcpy, __align_cpy_2)
+weak_alias (memcpy, __align_cpy_4)
+weak_alias (memcpy, __align_cpy_8)
+weak_alias (memcpy, __align_cpy_16)
+#endif
+libc_hidden_builtin_def (memcpy)
+libc_hidden_builtin_def (memmove)
diff --git a/sysdeps/sparc/sparc64/sparcv9v2/memset.S b/sysdeps/sparc/sparc64/sparcv9v2/memset.S
new file mode 100644
index 0000000000..809d3ed9c6
--- /dev/null
+++ b/sysdeps/sparc/sparc64/sparcv9v2/memset.S
@@ -0,0 +1 @@
+#include <sparc64/sparcv9v/memset.S>
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 6ba3a25c84..5f32d1a4a9 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -25,7 +25,7 @@ sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \
sys/quota.h sys/fsuid.h \
scsi/sg.h scsi/scsi.h scsi/scsi_ioctl.h sys/pci.h \
sys/ultrasound.h sys/raw.h sys/personality.h sys/epoll.h \
- bits/a.out.h sys/inotify.h
+ bits/a.out.h sys/inotify.h sys/signalfd.h sys/eventfd.h
install-others += $(inst_includedir)/bits/syscall.h
@@ -122,7 +122,7 @@ ifeq ($(subdir),inet)
sysdep_headers += netinet/if_fddi.h netinet/if_tr.h \
netipx/ipx.h netash/ash.h netax25/ax25.h netatalk/at.h \
netrom/netrom.h netpacket/packet.h netrose/rose.h \
- neteconet/ec.h
+ neteconet/ec.h netiucv/iucv.h
endif
# Don't compile the ctype glue code, since there is no old non-GNU C library.
@@ -138,7 +138,7 @@ endif
ifeq ($(subdir),io)
sysdep_routines += xstatconv internal_statvfs internal_statvfs64 \
- sync_file_range open_2
+ sync_file_range open_2 open64_2
endif
ifeq ($(subdir),elf)
diff --git a/sysdeps/unix/sysv/linux/adjtime.c b/sysdeps/unix/sysv/linux/adjtime.c
index 38ef805cd5..202bb14485 100644
--- a/sysdeps/unix/sysv/linux/adjtime.c
+++ b/sysdeps/unix/sysv/linux/adjtime.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 1997, 1998, 2002, 2004
+/* Copyright (C) 1995, 1996, 1997, 1998, 2002, 2004, 2007
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -22,6 +22,8 @@
#include <sys/time.h>
#include <sys/timex.h>
+#include <kernel-features.h>
+
#define MAX_SEC (INT_MAX / 1000000L - 2)
#define MIN_SEC (INT_MIN / 1000000L + 2)
@@ -69,13 +71,29 @@ ADJTIME (const struct TIMEVAL *itv, struct TIMEVAL *otv)
return -1;
}
tntx.offset = tmp.tv_usec + tmp.tv_sec * 1000000L;
+#ifdef ADJ_OFFSET_SS_READ
+ tntx.modes = ADJ_OFFSET_SS_READ;
+#else
tntx.modes = ADJ_OFFSET_SINGLESHOT;
+#endif
}
else
tntx.modes = 0;
- if (ADJTIMEX (&tntx) < 0)
- return -1;
+#if defined ADJ_OFFSET_SS_READ && !defined __ASSUME_ADJ_OFFSET_SS_READ
+ again:
+#endif
+ if (__builtin_expect (ADJTIMEX (&tntx) < 0, 0))
+ {
+#if defined ADJ_OFFSET_SS_READ && !defined __ASSUME_ADJ_OFFSET_SS_READ
+ if (itv && errno == EINVAL && tntx.modes == ADJ_OFFSET_SS_READ)
+ {
+ tntx.modes = ADJ_OFFSET_SINGLESHOT;
+ goto again;
+ }
+#endif
+ return -1;
+ }
if (otv)
{
diff --git a/sysdeps/unix/sysv/linux/bits/sched.h b/sysdeps/unix/sysv/linux/bits/sched.h
index 5eaa2fe528..5387b9cef0 100644
--- a/sysdeps/unix/sysv/linux/bits/sched.h
+++ b/sysdeps/unix/sysv/linux/bits/sched.h
@@ -132,17 +132,21 @@ typedef struct
} while (0)
# endif
# define __CPU_SET_S(cpu, setsize, cpusetp) \
- ({ size_t __cpu = (cpu); \
- __cpu < 8 * (setsize) \
- ? ((cpusetp)->__bits[__CPUELT (__cpu)] |= __CPUMASK (__cpu)) : 0; })
+ (__extension__ \
+ ({ size_t __cpu = (cpu); \
+ __cpu < 8 * (setsize) \
+ ? ((cpusetp)->__bits[__CPUELT (__cpu)] |= __CPUMASK (__cpu)) : 0; }))
# define __CPU_CLR_S(cpu, setsize, cpusetp) \
- ({ size_t __cpu = (cpu); \
- __cpu < 8 * (setsize) \
- ? ((cpusetp)->__bits[__CPUELT (__cpu)] &= ~__CPUMASK (__cpu)) : 0; })
+ (__extension__ \
+ ({ size_t __cpu = (cpu); \
+ __cpu < 8 * (setsize) \
+ ? ((cpusetp)->__bits[__CPUELT (__cpu)] &= ~__CPUMASK (__cpu)) : 0; }))
# define __CPU_ISSET_S(cpu, setsize, cpusetp) \
- ({ size_t __cpu = (cpu); \
- __cpu < 8 * (setsize) \
- ? (((cpusetp)->__bits[__CPUELT (__cpu)] & __CPUMASK (__cpu))) != 0 : 0; })
+ (__extension__ \
+ ({ size_t __cpu = (cpu); \
+ __cpu < 8 * (setsize) \
+ ? (((cpusetp)->__bits[__CPUELT (__cpu)] & __CPUMASK (__cpu))) != 0 \
+ : 0; }))
# define __CPU_COUNT_S(setsize, cpusetp) \
__sched_cpucount (setsize, cpusetp)
@@ -152,25 +156,27 @@ typedef struct
(__builtin_memcmp (cpusetp1, cpusetp2, setsize) == 0)
# else
# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
- ({ cpu_set_t *__arr1 = (cpusetp1); \
- cpu_set_t *__arr2 = (cpusetp2); \
- size_t __imax = (setsize) / sizeof (__cpu_mask); \
- size_t __i; \
- for (__i = 0; __i < __imax; ++__i) \
- if (__arr1->__bits[__i] != __arr2->__bits[__i]) \
- break; \
- __i == __imax; })
+ (__extension__ \
+ ({ cpu_set_t *__arr1 = (cpusetp1); \
+ cpu_set_t *__arr2 = (cpusetp2); \
+ size_t __imax = (setsize) / sizeof (__cpu_mask); \
+ size_t __i; \
+ for (__i = 0; __i < __imax; ++__i) \
+ if (__arr1->__bits[__i] != __arr2->__bits[__i]) \
+ break; \
+ __i == __imax; }))
# endif
# define __CPU_OP_S(setsize, destset, srcset1, srcset2, op) \
- ({ cpu_set_t *__dest = (destset); \
- cpu_set_t *__arr1 = (srcset1); \
- cpu_set_t *__arr2 = (srcset2); \
- size_t __imax = (setsize) / sizeof (__cpu_mask); \
- size_t __i; \
- for (__i = 0; __i < __imax; ++__i) \
- __dest->__bits[__i] = __arr1->__bits[__i] op __arr2->__bits[__i]; \
- __dest; })
+ (__extension__ \
+ ({ cpu_set_t *__dest = (destset); \
+ cpu_set_t *__arr1 = (srcset1); \
+ cpu_set_t *__arr2 = (srcset2); \
+ size_t __imax = (setsize) / sizeof (__cpu_mask); \
+ size_t __i; \
+ for (__i = 0; __i < __imax; ++__i) \
+ __dest->__bits[__i] = __arr1->__bits[__i] op __arr2->__bits[__i]; \
+ __dest; }))
# define __CPU_ALLOC_SIZE(count) \
((((count) + __NCPUBITS - 1) / __NCPUBITS) * 8)
diff --git a/sysdeps/unix/sysv/linux/check_native.c b/sysdeps/unix/sysv/linux/check_native.c
new file mode 100644
index 0000000000..6e6624abe1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/check_native.c
@@ -0,0 +1,172 @@
+/* Determine whether interfaces use native transport. Linux version.
+ Copyright (C) 2007 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 <assert.h>
+#include <errno.h>
+#include <ifaddrs.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+#include <net/if.h>
+#include <net/if_arp.h>
+#include <sys/ioctl.h>
+
+#include <asm/types.h>
+#include <linux/netlink.h>
+#include <linux/rtnetlink.h>
+
+#include <not-cancel.h>
+
+
+void
+__check_native (uint32_t a1_index, int *a1_native,
+ uint32_t a2_index, int *a2_native)
+{
+ int fd = __socket (PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
+
+ struct sockaddr_nl nladdr;
+ memset (&nladdr, '\0', sizeof (nladdr));
+ nladdr.nl_family = AF_NETLINK;
+
+ socklen_t addr_len = sizeof (nladdr);
+
+ if (fd < 0
+ || __bind (fd, (struct sockaddr *) &nladdr, sizeof (nladdr)) != 0
+ || __getsockname (fd, (struct sockaddr *) &nladdr, &addr_len) != 0)
+ return;
+
+ pid_t pid = nladdr.nl_pid;
+ struct req
+ {
+ struct nlmsghdr nlh;
+ struct rtgenmsg g;
+ /* struct rtgenmsg consists of a single byte. This means there
+ are three bytes of padding included in the REQ definition.
+ We make them explicit here. */
+ char pad[3];
+ } req;
+
+ req.nlh.nlmsg_len = sizeof (req);
+ req.nlh.nlmsg_type = RTM_GETLINK;
+ req.nlh.nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST;
+ req.nlh.nlmsg_pid = 0;
+ req.nlh.nlmsg_seq = time (NULL);
+ req.g.rtgen_family = AF_UNSPEC;
+
+ assert (sizeof (req) - offsetof (struct req, pad) == 3);
+ memset (req.pad, '\0', sizeof (req.pad));
+
+ memset (&nladdr, '\0', sizeof (nladdr));
+ nladdr.nl_family = AF_NETLINK;
+
+#ifdef PAGE_SIZE
+ /* Help the compiler optimize out the malloc call if PAGE_SIZE
+ is constant and smaller or equal to PTHREAD_STACK_MIN/4. */
+ const size_t buf_size = PAGE_SIZE;
+#else
+ const size_t buf_size = __getpagesize ();
+#endif
+ bool use_malloc = false;
+ char *buf;
+
+ if (__libc_use_alloca (buf_size))
+ buf = alloca (buf_size);
+ else
+ {
+ buf = malloc (buf_size);
+ if (buf != NULL)
+ use_malloc = true;
+ else
+ goto out_fail;
+ }
+
+ struct iovec iov = { buf, buf_size };
+
+ if (TEMP_FAILURE_RETRY (__sendto (fd, (void *) &req, sizeof (req), 0,
+ (struct sockaddr *) &nladdr,
+ sizeof (nladdr))) < 0)
+ goto out_fail;
+
+ bool done = false;
+ do
+ {
+ struct msghdr msg =
+ {
+ (void *) &nladdr, sizeof (nladdr),
+ &iov, 1,
+ NULL, 0,
+ 0
+ };
+
+ ssize_t read_len = TEMP_FAILURE_RETRY (__recvmsg (fd, &msg, 0));
+ if (read_len < 0)
+ goto out_fail;
+
+ if (msg.msg_flags & MSG_TRUNC)
+ goto out_fail;
+
+ struct nlmsghdr *nlmh;
+ for (nlmh = (struct nlmsghdr *) buf;
+ NLMSG_OK (nlmh, (size_t) read_len);
+ nlmh = (struct nlmsghdr *) NLMSG_NEXT (nlmh, read_len))
+ {
+ if (nladdr.nl_pid != 0 || (pid_t) nlmh->nlmsg_pid != pid
+ || nlmh->nlmsg_seq != req.nlh.nlmsg_seq)
+ continue;
+
+ if (nlmh->nlmsg_type == RTM_NEWLINK)
+ {
+ struct ifinfomsg *ifim = (struct ifinfomsg *) NLMSG_DATA (nlmh);
+ int native = (ifim->ifi_type != ARPHRD_TUNNEL6
+ && ifim->ifi_type != ARPHRD_TUNNEL
+ && ifim->ifi_type != ARPHRD_SIT);
+
+ if (a1_index == ifim->ifi_index)
+ {
+ *a1_native = native;
+ a1_index = 0xffffffffu;
+ }
+ if (a2_index == ifim->ifi_index)
+ {
+ *a2_native = native;
+ a2_index = 0xffffffffu;
+ }
+
+ if (a1_index == 0xffffffffu
+ && a2_index == 0xffffffffu)
+ goto out;
+ }
+ else if (nlmh->nlmsg_type == NLMSG_DONE)
+ /* We found the end, leave the loop. */
+ done = true;
+ }
+ }
+ while (! done);
+
+ out:
+ close_not_cancel_no_status (fd);
+
+ return;
+
+out_fail:
+ if (use_malloc)
+ free (buf);
+}
diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c
index 06fb1891f0..d66f029ed9 100644
--- a/sysdeps/unix/sysv/linux/check_pf.c
+++ b/sysdeps/unix/sysv/linux/check_pf.c
@@ -32,9 +32,6 @@
#include "netlinkaccess.h"
-#ifndef IFA_F_TEMPORARY
-# define IFA_F_TEMPORARY IFA_F_SECONDARY
-#endif
#ifndef IFA_F_HOMEADDRESS
# define IFA_F_HOMEADDRESS 0
#endif
@@ -142,92 +139,67 @@ make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6,
struct rtattr *rta = IFA_RTA (ifam);
size_t len = nlmh->nlmsg_len - NLMSG_LENGTH (sizeof (*ifam));
- switch (ifam->ifa_family)
- {
- const void *local;
- const void *address;
+ if (ifam->ifa_family != AF_INET
+ && ifam->ifa_family != AF_INET6)
+ continue;
- case AF_INET:
- local = NULL;
- address = NULL;
- while (RTA_OK (rta, len))
+ const void *local = NULL;
+ const void *address = NULL;
+ while (RTA_OK (rta, len))
+ {
+ switch (rta->rta_type)
{
- switch (rta->rta_type)
- {
- case IFA_LOCAL:
- local = RTA_DATA (rta);
- break;
-
- case IFA_ADDRESS:
- address = RTA_DATA (rta);
- goto out_v4;
- }
-
- rta = RTA_NEXT (rta, len);
+ case IFA_LOCAL:
+ local = RTA_DATA (rta);
+ break;
+
+ case IFA_ADDRESS:
+ address = RTA_DATA (rta);
+ goto out;
}
- if (local != NULL)
+ rta = RTA_NEXT (rta, len);
+ }
+
+ if (local != NULL)
+ {
+ address = local;
+ out:
+ if (ifam->ifa_family != AF_INET)
{
- out_v4:
- if (*(const in_addr_t *) (address ?: local)
+ if (*(const in_addr_t *) address
!= htonl (INADDR_LOOPBACK))
*seen_ipv4 = true;
}
- break;
-
- case AF_INET6:
- local = NULL;
- address = NULL;
- while (RTA_OK (rta, len))
+ else
{
- switch (rta->rta_type)
- {
- case IFA_LOCAL:
- local = RTA_DATA (rta);
- break;
-
- case IFA_ADDRESS:
- address = RTA_DATA (rta);
- goto out_v6;
- }
-
- rta = RTA_NEXT (rta, len);
- }
-
- if (local != NULL)
- {
- out_v6:
- if (!IN6_IS_ADDR_LOOPBACK (address ?: local))
+ if (!IN6_IS_ADDR_LOOPBACK (address))
*seen_ipv6 = true;
}
+ }
- if (ifam->ifa_flags & (IFA_F_DEPRECATED
- | IFA_F_TEMPORARY
- | IFA_F_HOMEADDRESS
- | IFA_F_OPTIMISTIC))
- {
- struct in6ailist *newp = alloca (sizeof (*newp));
- newp->info.flags = (((ifam->ifa_flags
- & (IFA_F_DEPRECATED
- | IFA_F_OPTIMISTIC))
- ? in6ai_deprecated : 0)
- | ((ifam->ifa_flags
- & IFA_F_TEMPORARY)
- ? in6ai_temporary : 0)
- | ((ifam->ifa_flags
- & IFA_F_HOMEADDRESS)
- ? in6ai_homeaddress : 0));
- memcpy (newp->info.addr, address ?: local,
- sizeof (newp->info.addr));
- newp->next = in6ailist;
- in6ailist = newp;
- ++in6ailistlen;
- }
- break;
- default:
- /* Ignore. */
- break;
+ struct in6ailist *newp = alloca (sizeof (*newp));
+ newp->info.flags = (((ifam->ifa_flags
+ & (IFA_F_DEPRECATED
+ | IFA_F_OPTIMISTIC))
+ ? in6ai_deprecated : 0)
+ | ((ifam->ifa_flags
+ & IFA_F_HOMEADDRESS)
+ ? in6ai_homeaddress : 0));
+ newp->info.prefixlen = ifam->ifa_prefixlen;
+ newp->info.index = ifam->ifa_index;
+ if (ifam->ifa_family == AF_INET)
+ {
+ newp->info.addr[0] = 0;
+ newp->info.addr[1] = 0;
+ newp->info.addr[2] = htonl (0xffff);
+ newp->info.addr[3] = *(const in_addr_t *) address;
}
+ else
+ memcpy (newp->info.addr, address, sizeof (newp->info.addr));
+ newp->next = in6ailist;
+ in6ailist = newp;
+ ++in6ailistlen;
}
else if (nlmh->nlmsg_type == NLMSG_DONE)
/* We found the end, leave the loop. */
diff --git a/sysdeps/unix/sysv/linux/i386/makecontext.S b/sysdeps/unix/sysv/linux/i386/makecontext.S
index 12ba4e2d67..89be1176f7 100644
--- a/sysdeps/unix/sysv/linux/i386/makecontext.S
+++ b/sysdeps/unix/sysv/linux/i386/makecontext.S
@@ -35,11 +35,6 @@ ENTRY(__makecontext)
movl %ecx, oEIP(%eax)
addl oSS_SIZE(%eax), %edx
- /* Put the next context on the new stack (from the uc_link
- element). */
- movl oLINK(%eax), %ecx
- movl %ecx, -4(%edx)
-
/* Remember the number of parameters for the exit handler since
it has to remove them. We store the number in the EBX register
which the function we will call must preserve. */
@@ -50,9 +45,20 @@ ENTRY(__makecontext)
negl %ecx
leal -8(%edx,%ecx,4), %edx
negl %ecx
+
+ /* Align the stack. */
+ addl $16, %edx
+ andl $0xfffffff0, %edx
+ subl $4, %edx
+
/* Store the future stack pointer. */
movl %edx, oESP(%eax)
+ /* Put the next context on the new stack (from the uc_link
+ element). */
+ movl oLINK(%eax), %eax
+ movl %eax, 4(%edx,%ecx,4)
+
/* Copy all the parameters. */
jecxz 2f
1: movl 12(%esp,%ecx,4), %eax
diff --git a/sysdeps/unix/sysv/linux/ia64/syscalls.list b/sysdeps/unix/sysv/linux/ia64/syscalls.list
index c55c70ef54..582492706e 100644
--- a/sysdeps/unix/sysv/linux/ia64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/ia64/syscalls.list
@@ -4,6 +4,9 @@ umount2 - umount 2 __umount2 umount2
getpriority - getpriority i:ii __getpriority getpriority
+creat - creat Ci:si __libc_creat creat creat64
+open - open Ci:siv __libc_open __open open __open64 open64
+
# semaphore and shm system calls
msgctl - msgctl i:iip __msgctl msgctl
msgget - msgget i:ii __msgget msgget
diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h
index aab3df348e..01baab0903 100644
--- a/sysdeps/unix/sysv/linux/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/kernel-features.h
@@ -487,3 +487,8 @@
|| (__LINUX_KERNEL_VERSION >= 0x020618 && defined __s390__))
# define __ASSUME_FALLOCATE 1
#endif
+
+/* Support for ADJ_OFFSET_SS_READ was added in 2.6.24. */
+#if __LINUX_KERNEL_VERSION >= 0x020618
+# define __ASSUME_ADJ_OFFSET_SS_READ 1
+#endif
diff --git a/sysdeps/unix/sysv/linux/netiucv/iucv.h b/sysdeps/unix/sysv/linux/netiucv/iucv.h
new file mode 100644
index 0000000000..779ebffb10
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/netiucv/iucv.h
@@ -0,0 +1,39 @@
+/* Copyright (C) 2007 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 __NETIUCV_IUCV_H
+#define __NETIUCV_IUCV_H 1
+
+#include <features.h>
+#include <bits/sockaddr.h>
+
+__BEGIN_DECLS
+
+struct sockaddr_iucv
+ {
+ __SOCKADDR_COMMON (siucv_);
+ unsigned short siucv_port; /* Reserved */
+ unsigned int siucv_addr; /* Reserved */
+ char siucv_nodeid[8]; /* Reserved */
+ char siucv_user_id[8]; /* Guest User Id */
+ char siucv_name[8]; /* Application Name */
+ };
+
+__END_DECLS
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/nscd_setup_thread.c b/sysdeps/unix/sysv/linux/nscd_setup_thread.c
index 56e23dc831..c29f972339 100644
--- a/sysdeps/unix/sysv/linux/nscd_setup_thread.c
+++ b/sysdeps/unix/sysv/linux/nscd_setup_thread.c
@@ -23,7 +23,7 @@
#include <sysdep.h>
-void
+int
setup_thread (struct database_dyn *db)
{
#ifdef __NR_set_tid_address
@@ -31,7 +31,7 @@ setup_thread (struct database_dyn *db)
char buf[100];
if (confstr (_CS_GNU_LIBPTHREAD_VERSION, buf, sizeof (buf)) >= sizeof (buf)
|| strncmp (buf, "NPTL", 4) != 0)
- return;
+ return 0;
/* Do not try this at home, kids. We play with the SETTID address
even thought the process is multi-threaded. This can only work
@@ -43,6 +43,8 @@ setup_thread (struct database_dyn *db)
/* We know the kernel can reset this field when nscd terminates.
So, set the field to a nonzero value which indicates that nscd
is certainly running and clients can skip the test. */
- db->head->nscd_certainly_running = 1;
+ return db->head->nscd_certainly_running = 1;
#endif
+
+ return 0;
}
diff --git a/sysdeps/unix/sysv/linux/open64.c b/sysdeps/unix/sysv/linux/open64.c
index c52ce39db1..21b3d0b010 100644
--- a/sysdeps/unix/sysv/linux/open64.c
+++ b/sysdeps/unix/sysv/linux/open64.c
@@ -52,26 +52,3 @@ __libc_open64 (const char *file, int oflag, ...)
weak_alias (__libc_open64, __open64)
libc_hidden_weak (__open64)
weak_alias (__libc_open64, open64)
-
-
-#ifndef PTW
-int
-__open64_2 (file, oflag)
- const char *file;
- int oflag;
-{
- if (oflag & O_CREAT)
- __fortify_fail ("invalid open64 call: O_CREAT without mode");
-
- if (SINGLE_THREAD_P)
- return INLINE_SYSCALL (open, 2, file, oflag | O_LARGEFILE);
-
- int oldtype = LIBC_CANCEL_ASYNC ();
-
- int result = INLINE_SYSCALL (open, 2, file, oflag | O_LARGEFILE);
-
- LIBC_CANCEL_RESET (oldtype);
-
- return result;
-}
-#endif
diff --git a/sysdeps/unix/sysv/linux/open64_2.c b/sysdeps/unix/sysv/linux/open64_2.c
new file mode 100644
index 0000000000..76b65e5217
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/open64_2.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 2007 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 <fcntl.h>
+#include <stdio.h>
+
+
+int
+__open64_2 (file, oflag)
+ const char *file;
+ int oflag;
+{
+ if (oflag & O_CREAT)
+ __fortify_fail ("invalid open64 call: O_CREAT without mode");
+
+ return __open64 (file, oflag);
+}
diff --git a/sysdeps/unix/sysv/linux/opensock.c b/sysdeps/unix/sysv/linux/opensock.c
index 2252980789..95559eb799 100644
--- a/sysdeps/unix/sysv/linux/opensock.c
+++ b/sysdeps/unix/sysv/linux/opensock.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2001, 2002, 2007 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
@@ -53,7 +53,10 @@ __opensock (void)
{ AF_APPLETALK, "net/appletalk" },
{ AF_ECONET, "sys/net/econet" },
{ AF_ASH, "sys/net/ash" },
- { AF_X25, "net/x25" }
+ { AF_X25, "net/x25" },
+#ifdef NEED_AF_IUCV
+ { AF_IUCV, "net/iucv" }
+#endif
};
#define nafs (sizeof (afs) / sizeof (afs[0]))
char fname[sizeof "/proc/" + 14];
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list b/sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list
index aee60bf9d5..320c40da64 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list
@@ -1,3 +1,5 @@
# File name Caller Syscall name # args Strong name Weak names
+creat - creat Ci:si __libc_creat creat creat64
getrlimit - ugetrlimit i:ip __getrlimit getrlimit getrlimit64
+open - open Ci:siv __libc_open __open open __open64 open64
diff --git a/sysdeps/unix/sysv/linux/readahead.c b/sysdeps/unix/sysv/linux/readahead.c
index dc628b2b2c..c280a479c2 100644
--- a/sysdeps/unix/sysv/linux/readahead.c
+++ b/sysdeps/unix/sysv/linux/readahead.c
@@ -1,5 +1,5 @@
/* Provide kernel hint to read ahead.
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2007 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
@@ -30,8 +30,10 @@
ssize_t
__readahead (int fd, off64_t offset, size_t count)
{
- return INLINE_SYSCALL (readahead, 4, fd, (off_t) (offset >> 32),
- (off_t) (offset & 0xffffffff), count);
+ return INLINE_SYSCALL (readahead, 4, fd,
+ __LONG_LONG_PAIR ((off_t) (offset >> 32),
+ (off_t) (offset & 0xffffffff)),
+ count);
}
#else
ssize_t
diff --git a/sysdeps/unix/sysv/linux/s390/opensock.c b/sysdeps/unix/sysv/linux/s390/opensock.c
new file mode 100644
index 0000000000..f099d651ff
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/s390/opensock.c
@@ -0,0 +1,2 @@
+#define NEED_AF_IUCV 1
+#include "../opensock.c"
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
index 791ab9ba52..684999913b 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
@@ -2,6 +2,9 @@
vfork - vfork 0 __vfork vfork
+creat - creat Ci:si __libc_creat creat creat64
+open - open Ci:siv __libc_open __open open __open64 open64
+
# semaphore and shm system calls
msgctl - msgctl i:iip __msgctl msgctl
msgget - msgget i:ii __msgget msgget
diff --git a/sysdeps/unix/sysv/linux/s390/sa_len.c b/sysdeps/unix/sysv/linux/s390/sa_len.c
new file mode 100644
index 0000000000..6575b83e9c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/s390/sa_len.c
@@ -0,0 +1,2 @@
+#define NEED_AF_IUCV 1
+#include "../sa_len.c"
diff --git a/sysdeps/unix/sysv/linux/sa_len.c b/sysdeps/unix/sysv/linux/sa_len.c
index ae5616bf45..1a89b276d4 100644
--- a/sysdeps/unix/sysv/linux/sa_len.c
+++ b/sysdeps/unix/sysv/linux/sa_len.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 1999, 2002, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -26,6 +26,7 @@
#include <netipx/ipx.h>
#include <netpacket/packet.h>
#include <netrose/rose.h>
+#include <netiucv/iucv.h>
#include <sys/un.h>
int
@@ -47,6 +48,10 @@ __libc_sa_len (sa_family_t af)
return sizeof (struct sockaddr_in6);
case AF_IPX:
return sizeof (struct sockaddr_ipx);
+#ifdef NEED_AF_IUCV
+ case AF_IUCV:
+ return sizeof (struct sockaddr_iucv);
+#endif
case AF_LOCAL:
return sizeof (struct sockaddr_un);
case AF_PACKET:
diff --git a/sysdeps/unix/sysv/linux/sys/epoll.h b/sysdeps/unix/sysv/linux/sys/epoll.h
index d8901f7d53..f4e8bda99a 100644
--- a/sysdeps/unix/sysv/linux/sys/epoll.h
+++ b/sysdeps/unix/sysv/linux/sys/epoll.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2006, 2007 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
@@ -53,6 +53,8 @@ enum EPOLL_EVENTS
#define EPOLLERR EPOLLERR
EPOLLHUP = 0x010,
#define EPOLLHUP EPOLLHUP
+ EPOLLRDHUP = 0x2000,
+#define EPOLLRDHUP EPOLLRDHUP
EPOLLONESHOT = (1 << 30),
#define EPOLLONESHOT EPOLLONESHOT
EPOLLET = (1 << 31)
diff --git a/sysdeps/unix/sysv/linux/sys/signalfd.h b/sysdeps/unix/sysv/linux/sys/signalfd.h
index 247b20b9d2..6649bc1d9c 100644
--- a/sysdeps/unix/sysv/linux/sys/signalfd.h
+++ b/sysdeps/unix/sysv/linux/sys/signalfd.h
@@ -51,7 +51,7 @@ __BEGIN_DECLS
/* Request notification for delivery of signals in MASK to be
performed using descriptor FD.*/
extern int signalfd (int __fd, const sigset_t *__mask, int __flags)
- __nonnull (2) __THROW;
+ __nonnull ((2)) __THROW;
__END_DECLS
diff --git a/sysdeps/unix/sysv/linux/sys/timex.h b/sysdeps/unix/sysv/linux/sys/timex.h
index 773a5ab8d0..f7bd6e7929 100644
--- a/sysdeps/unix/sysv/linux/sys/timex.h
+++ b/sysdeps/unix/sysv/linux/sys/timex.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997, 1999, 2007 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
@@ -69,6 +69,7 @@ struct timex
#define ADJ_TIMECONST 0x0020 /* pll time constant */
#define ADJ_TICK 0x4000 /* tick value */
#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */
+#define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */
/* xntp 3.4 compatibility names */
#define MOD_OFFSET ADJ_OFFSET
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/aio_read.c b/sysdeps/unix/sysv/linux/wordsize-64/aio_read.c
new file mode 100644
index 0000000000..d10fc4320b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/wordsize-64/aio_read.c
@@ -0,0 +1,7 @@
+#define aio_read64 __renamed_aio_read64
+
+#include "../../../../pthread/aio_read.c"
+
+#undef aio_read64
+
+weak_alias (aio_read, aio_read64)
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/aio_read64.c b/sysdeps/unix/sysv/linux/wordsize-64/aio_read64.c
new file mode 100644
index 0000000000..6a6a102c8d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/wordsize-64/aio_read64.c
@@ -0,0 +1 @@
+/* Defined in aio_read.c. */
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/aio_write.c b/sysdeps/unix/sysv/linux/wordsize-64/aio_write.c
new file mode 100644
index 0000000000..b0fb469cb2
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/wordsize-64/aio_write.c
@@ -0,0 +1,7 @@
+#define aio_write64 __renamed_aio_write64
+
+#include "../../../../pthread/aio_write.c"
+
+#undef aio_write64
+
+weak_alias (aio_write, aio_write64)
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/aio_write64.c b/sysdeps/unix/sysv/linux/wordsize-64/aio_write64.c
new file mode 100644
index 0000000000..ced07fa273
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/wordsize-64/aio_write64.c
@@ -0,0 +1 @@
+/* Defined in aio_write.c. */
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/creat64.c b/sysdeps/unix/sysv/linux/wordsize-64/creat64.c
new file mode 100644
index 0000000000..c106e2b362
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/wordsize-64/creat64.c
@@ -0,0 +1 @@
+/* Defined as alias for the syscall. */
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/getdirentries.c b/sysdeps/unix/sysv/linux/wordsize-64/getdirentries.c
new file mode 100644
index 0000000000..298d1e9e91
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/wordsize-64/getdirentries.c
@@ -0,0 +1,3 @@
+#include "../getdirentries.c"
+
+weak_alias (getdirentries, getdirentries64)
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/getdirentries64.c b/sysdeps/unix/sysv/linux/wordsize-64/getdirentries64.c
new file mode 100644
index 0000000000..622baf0c87
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/wordsize-64/getdirentries64.c
@@ -0,0 +1 @@
+/* Defined in getdirentries.c. */
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/lio_listio.c b/sysdeps/unix/sysv/linux/wordsize-64/lio_listio.c
new file mode 100644
index 0000000000..25ee5a3507
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/wordsize-64/lio_listio.c
@@ -0,0 +1,13 @@
+#define lio_listio64 __renamed_lio_listio64
+
+#include "../../../../pthread/lio_listio.c"
+
+#undef lio_listio64
+
+#if SHLIB_COMPAT (librt, GLIBC_2_1, GLIBC_2_4)
+strong_alias (__lio_listio_21, __lio_listio64_21)
+compat_symbol (librt, __lio_listio64_21, lio_listio64, GLIBC_2_1);
+#endif
+
+strong_alias (__lio_listio_item_notify, __lio_listio64_item_notify)
+versioned_symbol (librt, __lio_listio64_item_notify, lio_listio64, GLIBC_2_4);
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/lio_listio64.c b/sysdeps/unix/sysv/linux/wordsize-64/lio_listio64.c
new file mode 100644
index 0000000000..1dabae3692
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/wordsize-64/lio_listio64.c
@@ -0,0 +1 @@
+/* Defined in lio_listio.c. */
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/open64.c b/sysdeps/unix/sysv/linux/wordsize-64/open64.c
new file mode 100644
index 0000000000..0abe30ef62
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/wordsize-64/open64.c
@@ -0,0 +1 @@
+/* Defined in open syscall. */
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/openat.c b/sysdeps/unix/sysv/linux/wordsize-64/openat.c
new file mode 100644
index 0000000000..4921fca335
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/wordsize-64/openat.c
@@ -0,0 +1,16 @@
+#define __openat64 __rename___openat64
+#define __openat64_2 __rename___openat64_2
+#define __openat64_nocancel __rename___openat64_nocancel
+#define openat64 __rename_openat64
+
+#include "../openat.c"
+
+#undef __openat64
+#undef __openat64_2
+#undef __openat64_nocancel
+#undef openat64
+
+weak_alias (__openat, __openat64)
+weak_alias (__openat_2, __openat64_2)
+weak_alias (__openat_nocancel, __openat64_nocancel)
+weak_alias (openat, openat64)
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/openat64.c b/sysdeps/unix/sysv/linux/wordsize-64/openat64.c
new file mode 100644
index 0000000000..b4a864b040
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/wordsize-64/openat64.c
@@ -0,0 +1 @@
+/* Defined in openat.c. */
diff --git a/sysdeps/unix/sysv/linux/x86_64/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
index a9d40446db..a3d3d6cf92 100644
--- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
@@ -1,13 +1,13 @@
# File name Caller Syscall name # args Strong name Weak names
arch_prctl EXTRA arch_prctl i:ii __arch_prctl arch_prctl
+creat - creat Ci:si __libc_creat creat creat64
modify_ldt EXTRA modify_ldt i:ipi __modify_ldt modify_ldt
-
-# semaphore and shm system calls
msgctl - msgctl i:iip __msgctl msgctl
msgget - msgget i:ii __msgget msgget
msgrcv - msgrcv Ci:ibnii __msgrcv msgrcv
msgsnd - msgsnd Ci:ibni __msgsnd msgsnd
+open - open Ci:siv __libc_open __open open __open64 open64
shmat - shmat i:ipi __shmat shmat
shmctl - shmctl i:iip __shmctl shmctl
shmdt - shmdt i:s __shmdt shmdt
diff --git a/sysdeps/wordsize-64/alphasort.c b/sysdeps/wordsize-64/alphasort.c
new file mode 100644
index 0000000000..5096166625
--- /dev/null
+++ b/sysdeps/wordsize-64/alphasort.c
@@ -0,0 +1,3 @@
+#include "../../dirent/alphasort.c"
+
+weak_alias (alphasort, alphasort64)
diff --git a/sysdeps/wordsize-64/alphasort64.c b/sysdeps/wordsize-64/alphasort64.c
new file mode 100644
index 0000000000..08509131b6
--- /dev/null
+++ b/sysdeps/wordsize-64/alphasort64.c
@@ -0,0 +1 @@
+/* Defined in alphasort.c. */
diff --git a/sysdeps/wordsize-64/fseeko.c b/sysdeps/wordsize-64/fseeko.c
new file mode 100644
index 0000000000..692885a8be
--- /dev/null
+++ b/sysdeps/wordsize-64/fseeko.c
@@ -0,0 +1,3 @@
+#include "../../libio/fseeko.c"
+
+weak_alias (fseeko, fseeko64)
diff --git a/sysdeps/wordsize-64/fseeko64.c b/sysdeps/wordsize-64/fseeko64.c
new file mode 100644
index 0000000000..73e011afbb
--- /dev/null
+++ b/sysdeps/wordsize-64/fseeko64.c
@@ -0,0 +1 @@
+/* Defined in fseeko.c. */
diff --git a/sysdeps/wordsize-64/ftello.c b/sysdeps/wordsize-64/ftello.c
new file mode 100644
index 0000000000..fa05cfcf02
--- /dev/null
+++ b/sysdeps/wordsize-64/ftello.c
@@ -0,0 +1,3 @@
+#include "../../libio/ftello.c"
+
+weak_alias (ftello, ftello64)
diff --git a/sysdeps/wordsize-64/ftello64.c b/sysdeps/wordsize-64/ftello64.c
new file mode 100644
index 0000000000..2cbbe6320a
--- /dev/null
+++ b/sysdeps/wordsize-64/ftello64.c
@@ -0,0 +1 @@
+/* Defined in ftello.c. */
diff --git a/sysdeps/wordsize-64/ftw.c b/sysdeps/wordsize-64/ftw.c
new file mode 100644
index 0000000000..ca19903799
--- /dev/null
+++ b/sysdeps/wordsize-64/ftw.c
@@ -0,0 +1,16 @@
+#define ftw64 __rename_ftw64
+#define nftw64 __rename_nftw64
+
+#include "../../io/ftw.c"
+
+#undef ftw64
+#undef nftw64
+
+weak_alias (ftw, ftw64)
+strong_alias (__new_nftw, __new_nftw64)
+versioned_symbol (libc, __new_nftw64, nftw64, GLIBC_2_3_3);
+
+#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_3_3)
+strong_alias (__old_nftw, __old_nftw64)
+compat_symbol (libc, __old_nftw64, nftw64, GLIBC_2_1);
+#endif
diff --git a/sysdeps/wordsize-64/ftw64.c b/sysdeps/wordsize-64/ftw64.c
new file mode 100644
index 0000000000..1cfcaadfd1
--- /dev/null
+++ b/sysdeps/wordsize-64/ftw64.c
@@ -0,0 +1 @@
+/* Defined in ftw.c. */
diff --git a/sysdeps/wordsize-64/iofgetpos.c b/sysdeps/wordsize-64/iofgetpos.c
new file mode 100644
index 0000000000..ba8df67c9b
--- /dev/null
+++ b/sysdeps/wordsize-64/iofgetpos.c
@@ -0,0 +1,12 @@
+#define _IO_new_fgetpos64 __renamed__IO_new_fgetpos64
+#define _IO_fgetpos64 __renamed__IO_fgetpos64
+
+#include "../../libio/iofgetpos.c"
+
+#undef _IO_new_fgetpos64
+#undef _IO_fgetpos64
+
+strong_alias (_IO_new_fgetpos, _IO_new_fgetpos64)
+strong_alias (_IO_new_fgetpos64, __new_fgetpos64)
+versioned_symbol (libc, _IO_new_fgetpos64, _IO_fgetpos64, GLIBC_2_2);
+versioned_symbol (libc, __new_fgetpos64, fgetpos64, GLIBC_2_2);
diff --git a/sysdeps/wordsize-64/iofgetpos64.c b/sysdeps/wordsize-64/iofgetpos64.c
new file mode 100644
index 0000000000..1748b810fb
--- /dev/null
+++ b/sysdeps/wordsize-64/iofgetpos64.c
@@ -0,0 +1 @@
+/* Defined in iofgetpos.c. */
diff --git a/sysdeps/wordsize-64/iofopen.c b/sysdeps/wordsize-64/iofopen.c
new file mode 100644
index 0000000000..d8d92ca5ec
--- /dev/null
+++ b/sysdeps/wordsize-64/iofopen.c
@@ -0,0 +1,4 @@
+#include "../../libio/iofopen.c"
+
+weak_alias (_IO_new_fopen, _IO_fopen64)
+weak_alias (_IO_new_fopen, fopen64)
diff --git a/sysdeps/wordsize-64/iofopen64.c b/sysdeps/wordsize-64/iofopen64.c
new file mode 100644
index 0000000000..68315d857d
--- /dev/null
+++ b/sysdeps/wordsize-64/iofopen64.c
@@ -0,0 +1 @@
+/* Defined in iofopen.c. */
diff --git a/sysdeps/wordsize-64/iofsetpos.c b/sysdeps/wordsize-64/iofsetpos.c
new file mode 100644
index 0000000000..f2bb8aec55
--- /dev/null
+++ b/sysdeps/wordsize-64/iofsetpos.c
@@ -0,0 +1,12 @@
+#define _IO_new_fsetpos64 __renamed__IO_new_fsetpos64
+#define _IO_fsetpos64 __renamed__IO_fsetpos64
+
+#include "../../libio/iofsetpos.c"
+
+#undef _IO_new_fsetpos64
+#undef _IO_fsetpos64
+
+strong_alias (_IO_new_fsetpos, _IO_new_fsetpos64)
+strong_alias (_IO_new_fsetpos64, __new_fsetpos64)
+versioned_symbol (libc, __new_fsetpos64, fsetpos64, GLIBC_2_2);
+versioned_symbol (libc, _IO_new_fsetpos64, _IO_fsetpos64, GLIBC_2_2);
diff --git a/sysdeps/wordsize-64/iofsetpos64.c b/sysdeps/wordsize-64/iofsetpos64.c
new file mode 100644
index 0000000000..5fbc7328b5
--- /dev/null
+++ b/sysdeps/wordsize-64/iofsetpos64.c
@@ -0,0 +1 @@
+/* Defined in iofsetpos.c. */
diff --git a/sysdeps/wordsize-64/lockf.c b/sysdeps/wordsize-64/lockf.c
new file mode 100644
index 0000000000..502472d98b
--- /dev/null
+++ b/sysdeps/wordsize-64/lockf.c
@@ -0,0 +1,3 @@
+#include "../../io/lockf.c"
+
+weak_alias (lockf, lockf64)
diff --git a/sysdeps/wordsize-64/lockf64.c b/sysdeps/wordsize-64/lockf64.c
new file mode 100644
index 0000000000..8ef5fc6b46
--- /dev/null
+++ b/sysdeps/wordsize-64/lockf64.c
@@ -0,0 +1 @@
+/* Defined in lockf.c. */
diff --git a/sysdeps/wordsize-64/mkostemp.c b/sysdeps/wordsize-64/mkostemp.c
new file mode 100644
index 0000000000..4f81fdf544
--- /dev/null
+++ b/sysdeps/wordsize-64/mkostemp.c
@@ -0,0 +1,3 @@
+#include "../../misc/mkostemp.c"
+
+weak_alias (mkostemp, mkostemp64)
diff --git a/sysdeps/wordsize-64/mkostemp64.c b/sysdeps/wordsize-64/mkostemp64.c
new file mode 100644
index 0000000000..14bb25023e
--- /dev/null
+++ b/sysdeps/wordsize-64/mkostemp64.c
@@ -0,0 +1 @@
+/* Defined in mkostemp.c. */
diff --git a/sysdeps/wordsize-64/mkstemp.c b/sysdeps/wordsize-64/mkstemp.c
new file mode 100644
index 0000000000..bf6df18485
--- /dev/null
+++ b/sysdeps/wordsize-64/mkstemp.c
@@ -0,0 +1,3 @@
+#include "../../misc/mkstemp.c"
+
+weak_alias (mkstemp, mkstemp64)
diff --git a/sysdeps/wordsize-64/mkstemp64.c b/sysdeps/wordsize-64/mkstemp64.c
new file mode 100644
index 0000000000..e72bb46433
--- /dev/null
+++ b/sysdeps/wordsize-64/mkstemp64.c
@@ -0,0 +1 @@
+/* Defined in mkstemp.c. */
diff --git a/sysdeps/wordsize-64/scandir.c b/sysdeps/wordsize-64/scandir.c
new file mode 100644
index 0000000000..9af7e9b386
--- /dev/null
+++ b/sysdeps/wordsize-64/scandir.c
@@ -0,0 +1,6 @@
+#define scandir64 scandir64_renamed
+
+#include "../../dirent/scandir.c"
+
+#undef scandir64
+weak_alias (scandir, scandir64)
diff --git a/sysdeps/wordsize-64/scandir64.c b/sysdeps/wordsize-64/scandir64.c
new file mode 100644
index 0000000000..3c2c4a1590
--- /dev/null
+++ b/sysdeps/wordsize-64/scandir64.c
@@ -0,0 +1 @@
+/* Defined in scandir.c. */
diff --git a/sysdeps/wordsize-64/tmpfile.c b/sysdeps/wordsize-64/tmpfile.c
new file mode 100644
index 0000000000..449a222d98
--- /dev/null
+++ b/sysdeps/wordsize-64/tmpfile.c
@@ -0,0 +1,3 @@
+#include "../../stdio-common/tmpfile.c"
+
+weak_alias (__new_tmpfile, tmpfile64)
diff --git a/sysdeps/wordsize-64/tmpfile64.c b/sysdeps/wordsize-64/tmpfile64.c
new file mode 100644
index 0000000000..5c124c249b
--- /dev/null
+++ b/sysdeps/wordsize-64/tmpfile64.c
@@ -0,0 +1 @@
+/* Defined in tmpfile.c. */
diff --git a/sysdeps/wordsize-64/versionsort.c b/sysdeps/wordsize-64/versionsort.c
new file mode 100644
index 0000000000..90365a4b25
--- /dev/null
+++ b/sysdeps/wordsize-64/versionsort.c
@@ -0,0 +1,3 @@
+#include "../../dirent/versionsort.c"
+
+weak_alias (versionsort, versionsort64)
diff --git a/sysdeps/wordsize-64/versionsort64.c b/sysdeps/wordsize-64/versionsort64.c
new file mode 100644
index 0000000000..ac6c3c702a
--- /dev/null
+++ b/sysdeps/wordsize-64/versionsort64.c
@@ -0,0 +1 @@
+/* Defined in versionsort.c. */
diff --git a/sysdeps/x86_64/dl-trampoline.S b/sysdeps/x86_64/dl-trampoline.S
index 84fe4724b1..3e2d182758 100644
--- a/sysdeps/x86_64/dl-trampoline.S
+++ b/sysdeps/x86_64/dl-trampoline.S
@@ -62,8 +62,8 @@ _dl_runtime_resolve:
.align 16
cfi_startproc
_dl_runtime_profile:
- subq $80, %rsp
- cfi_adjust_cfa_offset(96) # Incorporate PLT
+ subq $88, %rsp
+ cfi_adjust_cfa_offset(104) # Incorporate PLT
movq %rax, (%rsp) # Preserve registers otherwise clobbered.
movq %rdx, 8(%rsp)
movq %r8, 16(%rsp)
@@ -72,16 +72,16 @@ _dl_runtime_profile:
movq %rsi, 40(%rsp)
movq %rdi, 48(%rsp)
movq %rbp, 56(%rsp) # Information for auditors.
- leaq 96(%rsp), %rax
+ leaq 104(%rsp), %rax
movq %rax, 64(%rsp)
leaq 8(%rsp), %rcx
- movq 96(%rsp), %rdx # Load return address if needed
- movq 88(%rsp), %rsi # Copy args pushed by PLT in register.
+ movq 104(%rsp), %rdx # Load return address if needed
+ movq 96(%rsp), %rsi # Copy args pushed by PLT in register.
movq %rsi,%r11 # Multiply by 24
addq %r11,%rsi
addq %r11,%rsi
shlq $3, %rsi
- movq 80(%rsp), %rdi # %rdi: link_map, %rsi: reloc_offset
+ movq 88(%rsp), %rdi # %rdi: link_map, %rsi: reloc_offset
leaq 72(%rsp), %r8
call _dl_profile_fixup # Call resolver.
movq %rax, %r11 # Save return value
@@ -95,14 +95,15 @@ _dl_runtime_profile:
movq 32(%rsp), %rcx
movq 40(%rsp), %rsi
movq 48(%rsp), %rdi
- addq $96,%rsp # Adjust stack
- cfi_adjust_cfa_offset (-96)
+ addq $104,%rsp # Adjust stack
+ cfi_adjust_cfa_offset (-104)
jmp *%r11 # Jump to function address.
/*
- +96 return address
- +88 PLT2
- +80 PLT1
+ +104 return address
+ +96 PLT2
+ +88 PLT1
+ +80 free
+72 free
+64 %rsp
+56 %rbp
@@ -112,14 +113,14 @@ _dl_runtime_profile:
+24 %r9
+16 %r8
+8 %rdx
- %esp %rax
+ %rsp %rax
*/
- cfi_adjust_cfa_offset (96)
+ cfi_adjust_cfa_offset (104)
1: movq %rbx, 72(%rsp)
- cfi_rel_offset (1, 72)
- leaq 104(%rsp), %rsi
+ cfi_rel_offset (rbx, 72)
+ leaq 112(%rsp), %rsi
movq %rsp, %rbx
- cfi_def_cfa_register (1)
+ cfi_def_cfa_register (%rbx)
movq %r10, %rcx
addq $8, %r10
andq $0xfffffffffffffff0, %r10
@@ -133,7 +134,7 @@ _dl_runtime_profile:
movq 48(%rbx), %rdi
call *%r11
movq %rbx, %rsp
- cfi_def_cfa_register (7)
+ cfi_def_cfa_register (%rsp)
subq $72, %rsp
cfi_adjust_cfa_offset (72)
movq %rsp, %rcx
@@ -147,9 +148,10 @@ _dl_runtime_profile:
fstpt 48(%rcx)
fstpt 64(%rcx)
/*
- +168 return address
- +160 PLT2
- +152 PLT1
+ +176 return address
+ +168 PLT2
+ +160 PLT1
+ +152 free
+144 free
+136 %rsp
+128 %rbp
@@ -164,17 +166,17 @@ _dl_runtime_profile:
+32 %xmm1 result
+16 %xmm0 result
+8 %rdx result
- %esp %rax result
+ %rsp %rax result
*/
leaq 80(%rsp), %rdx
movq 144(%rsp), %rbx
- cfi_restore (1)
- movq 160(%rsp), %rsi # Copy args pushed by PLT in register.
+ cfi_restore (rbx)
+ movq 168(%rsp), %rsi # Copy args pushed by PLT in register.
movq %rsi,%r11 # Multiply by 24
addq %r11,%rsi
addq %r11,%rsi
shlq $3, %rsi
- movq 152(%rsp), %rdi # %rdi: link_map, %rsi: reloc_offset
+ movq 160(%rsp), %rdi # %rdi: link_map, %rsi: reloc_offset
call _dl_call_pltexit
movq (%rsp), %rax
movq 8(%rsp), %rdx
@@ -182,8 +184,8 @@ _dl_runtime_profile:
movups 32(%rsp), %xmm1
fldt 64(%rsp)
fldt 48(%rsp)
- addq $168, %rsp
- cfi_adjust_cfa_offset (-168)
+ addq $176, %rsp
+ cfi_adjust_cfa_offset (-176)
retq
cfi_endproc
.size _dl_runtime_profile, .-_dl_runtime_profile
diff --git a/sysdeps/x86_64/memset.S b/sysdeps/x86_64/memset.S
index db39b09c89..939240600d 100644
--- a/sysdeps/x86_64/memset.S
+++ b/sysdeps/x86_64/memset.S
@@ -30,11 +30,12 @@
.text
#ifndef NOT_IN_libc
-ENTRY(bzero)
+ENTRY(__bzero)
mov %rsi,%rdx /* Adjust parameter. */
xorl %esi,%esi /* Fill with 0s. */
jmp L(memset_entry)
-END(bzero)
+END(__bzero)
+weak_alias (__bzero, bzero)
#endif
#if defined PIC && !defined NOT_IN_libc
@@ -126,6 +127,7 @@ L(memset_entry):
add $0x40,%rcx
dec %rax
jne 11b
+ sfence
jmp 4b
END (memset)