summaryrefslogtreecommitdiff
path: root/libc/sysdeps
diff options
context:
space:
mode:
authorjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2010-03-26 21:08:35 +0000
committerjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2010-03-26 21:08:35 +0000
commit30feca091914f8d41f452394367677bfe56b3316 (patch)
treeb9f750862b34524d3bcf230ab749d293e9caebc8 /libc/sysdeps
parent5c92b8030ed5819dd183df7cc3cfb085317beb16 (diff)
Merge changes between r10031 and r10115 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@10116 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/sysdeps')
-rw-r--r--libc/sysdeps/generic/ldsodefs.h2
-rw-r--r--libc/sysdeps/i386/i686/multiarch/memcmp-ssse3.S15
-rw-r--r--libc/sysdeps/posix/cuserid.c5
-rw-r--r--libc/sysdeps/posix/getaddrinfo.c22
-rw-r--r--libc/sysdeps/unix/getlogin.c8
-rw-r--r--libc/sysdeps/unix/getlogin_r.c7
-rw-r--r--libc/sysdeps/unix/sysv/linux/clock_getres.c8
-rw-r--r--libc/sysdeps/unix/sysv/linux/clock_gettime.c5
-rw-r--r--libc/sysdeps/unix/sysv/linux/clock_settime.c5
-rw-r--r--libc/sysdeps/unix/sysv/linux/dl-sysdep.c8
-rw-r--r--libc/sysdeps/unix/sysv/linux/getlogin.c39
-rw-r--r--libc/sysdeps/unix/sysv/linux/getlogin_r.c100
-rw-r--r--libc/sysdeps/unix/sysv/linux/ldsodefs.h9
-rw-r--r--libc/sysdeps/unix/sysv/linux/mmap64.c21
-rw-r--r--libc/sysdeps/x86_64/multiarch/strpbrk-c.c12
15 files changed, 230 insertions, 36 deletions
diff --git a/libc/sysdeps/generic/ldsodefs.h b/libc/sysdeps/generic/ldsodefs.h
index f6dedc49b..ff5017e28 100644
--- a/libc/sysdeps/generic/ldsodefs.h
+++ b/libc/sysdeps/generic/ldsodefs.h
@@ -756,7 +756,7 @@ extern int _dl_starting_up_internal attribute_hidden;
#endif
/* Random data provided by the kernel. */
-extern void *_dl_random attribute_hidden;
+extern void *_dl_random attribute_hidden attribute_relro;
/* OS-dependent function to open the zero-fill device. */
extern int _dl_sysdep_open_zero_fill (void); /* dl-sysdep.c */
diff --git a/libc/sysdeps/i386/i686/multiarch/memcmp-ssse3.S b/libc/sysdeps/i386/i686/multiarch/memcmp-ssse3.S
index d2f852f72..2e0d15fe5 100644
--- a/libc/sysdeps/i386/i686/multiarch/memcmp-ssse3.S
+++ b/libc/sysdeps/i386/i686/multiarch/memcmp-ssse3.S
@@ -269,6 +269,7 @@ L(shr_1_gobble_loop):
lea 32(%edi), %edi
jz L(shr_1_gobble_loop)
+ pand %xmm0, %xmm3
cmp $0, %ecx
jge L(shr_1_gobble_next)
@@ -352,6 +353,7 @@ L(shr_2_gobble_loop):
lea 32(%edi), %edi
jz L(shr_2_gobble_loop)
+ pand %xmm0, %xmm3
cmp $0, %ecx
jge L(shr_2_gobble_next)
@@ -434,6 +436,7 @@ L(shr_3_gobble_loop):
lea 32(%edi), %edi
jz L(shr_3_gobble_loop)
+ pand %xmm0, %xmm3
cmp $0, %ecx
jge L(shr_3_gobble_next)
@@ -516,6 +519,7 @@ L(shr_4_gobble_loop):
lea 32(%edi), %edi
jz L(shr_4_gobble_loop)
+ pand %xmm0, %xmm3
cmp $0, %ecx
jge L(shr_4_gobble_next)
@@ -598,6 +602,7 @@ L(shr_5_gobble_loop):
lea 32(%edi), %edi
jz L(shr_5_gobble_loop)
+ pand %xmm0, %xmm3
cmp $0, %ecx
jge L(shr_5_gobble_next)
@@ -680,6 +685,7 @@ L(shr_6_gobble_loop):
lea 32(%edi), %edi
jz L(shr_6_gobble_loop)
+ pand %xmm0, %xmm3
cmp $0, %ecx
jge L(shr_6_gobble_next)
@@ -762,6 +768,7 @@ L(shr_7_gobble_loop):
lea 32(%edi), %edi
jz L(shr_7_gobble_loop)
+ pand %xmm0, %xmm3
cmp $0, %ecx
jge L(shr_7_gobble_next)
@@ -844,6 +851,7 @@ L(shr_8_gobble_loop):
lea 32(%edi), %edi
jz L(shr_8_gobble_loop)
+ pand %xmm0, %xmm3
cmp $0, %ecx
jge L(shr_8_gobble_next)
@@ -926,6 +934,7 @@ L(shr_9_gobble_loop):
lea 32(%edi), %edi
jz L(shr_9_gobble_loop)
+ pand %xmm0, %xmm3
cmp $0, %ecx
jge L(shr_9_gobble_next)
@@ -1008,6 +1017,7 @@ L(shr_10_gobble_loop):
lea 32(%edi), %edi
jz L(shr_10_gobble_loop)
+ pand %xmm0, %xmm3
cmp $0, %ecx
jge L(shr_10_gobble_next)
@@ -1090,6 +1100,7 @@ L(shr_11_gobble_loop):
lea 32(%edi), %edi
jz L(shr_11_gobble_loop)
+ pand %xmm0, %xmm3
cmp $0, %ecx
jge L(shr_11_gobble_next)
@@ -1172,6 +1183,7 @@ L(shr_12_gobble_loop):
lea 32(%edi), %edi
jz L(shr_12_gobble_loop)
+ pand %xmm0, %xmm3
cmp $0, %ecx
jge L(shr_12_gobble_next)
@@ -1254,6 +1266,7 @@ L(shr_13_gobble_loop):
lea 32(%edi), %edi
jz L(shr_13_gobble_loop)
+ pand %xmm0, %xmm3
cmp $0, %ecx
jge L(shr_13_gobble_next)
@@ -1336,6 +1349,7 @@ L(shr_14_gobble_loop):
lea 32(%edi), %edi
jz L(shr_14_gobble_loop)
+ pand %xmm0, %xmm3
cmp $0, %ecx
jge L(shr_14_gobble_next)
@@ -1418,6 +1432,7 @@ L(shr_15_gobble_loop):
lea 32(%edi), %edi
jz L(shr_15_gobble_loop)
+ pand %xmm0, %xmm3
cmp $0, %ecx
jge L(shr_15_gobble_next)
diff --git a/libc/sysdeps/posix/cuserid.c b/libc/sysdeps/posix/cuserid.c
index 11c827a68..a74ff8436 100644
--- a/libc/sysdeps/posix/cuserid.c
+++ b/libc/sysdeps/posix/cuserid.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1996, 1998, 1999, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996, 1998, 1999, 2001, 2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -44,5 +44,6 @@ cuserid (s)
if (s == NULL)
s = name;
- return strncpy (s, pwptr->pw_name, L_cuserid);
+ s[L_cuserid - 1] = '\0';
+ return strncpy (s, pwptr->pw_name, L_cuserid - 1);
}
diff --git a/libc/sysdeps/posix/getaddrinfo.c b/libc/sysdeps/posix/getaddrinfo.c
index 62c38f69b..2e0c7248f 100644
--- a/libc/sysdeps/posix/getaddrinfo.c
+++ b/libc/sysdeps/posix/getaddrinfo.c
@@ -702,6 +702,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
while (!no_more)
{
+ no_data = 0;
nss_gethostbyname4_r fct4
= __nss_lookup_function (nip, "gethostbyname4_r");
if (fct4 != NULL)
@@ -816,17 +817,18 @@ gaih_inet (const char *name, const struct gaih_service *service,
canon = name;
}
}
-
- break;
+ status = NSS_STATUS_SUCCESS;
+ }
+ else
+ {
+ /* We can have different states for AF_INET and
+ AF_INET6. Try to find a useful one for both. */
+ if (inet6_status == NSS_STATUS_TRYAGAIN)
+ status = NSS_STATUS_TRYAGAIN;
+ else if (status == NSS_STATUS_UNAVAIL
+ && inet6_status != NSS_STATUS_UNAVAIL)
+ status = inet6_status;
}
-
- /* We can have different states for AF_INET and
- AF_INET6. Try to find a useful one for both. */
- if (inet6_status == NSS_STATUS_TRYAGAIN)
- status = NSS_STATUS_TRYAGAIN;
- else if (status == NSS_STATUS_UNAVAIL
- && inet6_status != NSS_STATUS_UNAVAIL)
- status = inet6_status;
}
else
status = NSS_STATUS_UNAVAIL;
diff --git a/libc/sysdeps/unix/getlogin.c b/libc/sysdeps/unix/getlogin.c
index 4752685f8..b0ad97cfa 100644
--- a/libc/sysdeps/unix/getlogin.c
+++ b/libc/sysdeps/unix/getlogin.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1996, 1997, 2010 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
@@ -25,16 +25,20 @@
#include <utmp.h>
+static char name[UT_NAMESIZE + 1];
+
/* Return the login name of the user, or NULL if it can't be determined.
The returned pointer, if not NULL, is good only until the next call. */
+#ifdef STATIC
+STATIC
+#endif
char *
getlogin (void)
{
char tty_pathname[2 + 2 * NAME_MAX];
char *real_tty_path = tty_pathname;
char *result = NULL;
- static char name[UT_NAMESIZE + 1];
struct utmp *ut, line, buffer;
/* Get name of tty connected to fd 0. Return NULL if not a tty or
diff --git a/libc/sysdeps/unix/getlogin_r.c b/libc/sysdeps/unix/getlogin_r.c
index ba7badd05..bf3c889e1 100644
--- a/libc/sysdeps/unix/getlogin_r.c
+++ b/libc/sysdeps/unix/getlogin_r.c
@@ -1,5 +1,5 @@
/* Reentrant function to return the current login name. Unix version.
- Copyright (C) 1991,92,96,97,98,2002 Free Software Foundation, Inc.
+ Copyright (C) 1991,92,96,97,98,2002,2010 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
@@ -31,6 +31,9 @@
If it cannot be determined or some other error occurred, return the error
code. Otherwise return 0. */
+#ifdef STATIC
+STATIC
+#endif
int
getlogin_r (name, name_len)
char *name;
@@ -96,4 +99,6 @@ getlogin_r (name, name_len)
return result;
}
+#ifndef STATIC
libc_hidden_def (getlogin_r)
+#endif
diff --git a/libc/sysdeps/unix/sysv/linux/clock_getres.c b/libc/sysdeps/unix/sysv/linux/clock_getres.c
index 581ff22c7..933580b60 100644
--- a/libc/sysdeps/unix/sysv/linux/clock_getres.c
+++ b/libc/sysdeps/unix/sysv/linux/clock_getres.c
@@ -1,5 +1,5 @@
/* clock_getres -- Get the resolution of a POSIX clockid_t. Linux version.
- Copyright (C) 2003,2004,2005,2006, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2003,2004,2005,2006,2008,2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -44,6 +44,9 @@
SYSDEP_GETRES_CPUTIME \
case CLOCK_REALTIME: \
case CLOCK_MONOTONIC: \
+ case CLOCK_MONOTONIC_RAW: \
+ case CLOCK_REALTIME_COARSE: \
+ case CLOCK_MONOTONIC_COARSE: \
SYSCALL_GETRES
# define __libc_missing_posix_timers 0
@@ -80,6 +83,9 @@ maybe_syscall_getres (clockid_t clock_id, struct timespec *res)
SYSDEP_GETRES_CPUTIME \
case CLOCK_REALTIME: \
case CLOCK_MONOTONIC: \
+ case CLOCK_MONOTONIC_RAW: \
+ case CLOCK_REALTIME_COARSE: \
+ case CLOCK_MONOTONIC_COARSE: \
retval = maybe_syscall_getres (clock_id, res); \
if (retval == 0) \
break; \
diff --git a/libc/sysdeps/unix/sysv/linux/clock_gettime.c b/libc/sysdeps/unix/sysv/linux/clock_gettime.c
index cd536a0fc..dd3755cce 100644
--- a/libc/sysdeps/unix/sysv/linux/clock_gettime.c
+++ b/libc/sysdeps/unix/sysv/linux/clock_gettime.c
@@ -1,5 +1,5 @@
/* clock_gettime -- Get current time from a POSIX clockid_t. Linux version.
- Copyright (C) 2003,2004,2005,2006,2007 Free Software Foundation, Inc.
+ Copyright (C) 2003,2004,2005,2006,2007,2010 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
@@ -80,6 +80,9 @@ maybe_syscall_gettime (clockid_t clock_id, struct timespec *tp)
SYSDEP_GETTIME_CPUTIME \
case CLOCK_REALTIME: \
case CLOCK_MONOTONIC: \
+ case CLOCK_MONOTONIC_RAW: \
+ case CLOCK_REALTIME_COARSE: \
+ case CLOCK_MONOTONIC_COARSE: \
retval = maybe_syscall_gettime (clock_id, tp); \
if (retval == 0) \
break; \
diff --git a/libc/sysdeps/unix/sysv/linux/clock_settime.c b/libc/sysdeps/unix/sysv/linux/clock_settime.c
index 217ae3f29..8c52456fd 100644
--- a/libc/sysdeps/unix/sysv/linux/clock_settime.c
+++ b/libc/sysdeps/unix/sysv/linux/clock_settime.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2006, 2010 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
@@ -45,7 +45,7 @@ maybe_syscall_settime_cpu (clockid_t clock_id, const struct timespec *tp)
INTERNAL_SYSCALL_DECL (err);
int r = INTERNAL_SYSCALL (clock_settime, err, 2, clock_id, tp);
if (!INTERNAL_SYSCALL_ERROR_P (r, err))
- return 0;
+ return 0;
e = INTERNAL_SYSCALL_ERRNO (r, err);
# ifndef __ASSUME_POSIX_TIMERS
@@ -90,6 +90,7 @@ extern int __libc_missing_posix_timers attribute_hidden;
/* The REALTIME clock might be available. Try the syscall first. */
# define SYSDEP_SETTIME \
case CLOCK_REALTIME: \
+ case CLOCK_REALTIME_COARSE: \
{ \
int e = EINVAL; \
\
diff --git a/libc/sysdeps/unix/sysv/linux/dl-sysdep.c b/libc/sysdeps/unix/sysv/linux/dl-sysdep.c
index 08ae9aa86..34e880892 100644
--- a/libc/sysdeps/unix/sysv/linux/dl-sysdep.c
+++ b/libc/sysdeps/unix/sysv/linux/dl-sysdep.c
@@ -47,12 +47,12 @@ frob_brk (void)
Later Linux kernels have changed this behavior so that the initial
break value is rounded up to the page boundary before we start. */
- extern void *__curbrk attribute_hidden;
- extern void _end attribute_hidden;
- void *const endpage = (void *) 0 + (((__curbrk - (void *) 0)
+ extern char *__curbrk attribute_hidden;
+ extern char _end[] attribute_hidden;
+ char *const endpage = (void *) 0 + (((__curbrk - (char *) 0)
+ GLRO(dl_pagesize) - 1)
& -GLRO(dl_pagesize));
- if (__builtin_expect (__curbrk >= &_end && __curbrk < endpage, 0))
+ if (__builtin_expect (__curbrk >= _end && __curbrk < endpage, 0))
__brk (endpage);
#endif
}
diff --git a/libc/sysdeps/unix/sysv/linux/getlogin.c b/libc/sysdeps/unix/sysv/linux/getlogin.c
new file mode 100644
index 000000000..4d15db093
--- /dev/null
+++ b/libc/sysdeps/unix/sysv/linux/getlogin.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 2010 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 <pwd.h>
+#include <unistd.h>
+#include <not-cancel.h>
+
+#define STATIC static
+#define getlogin getlogin_fd0
+#include <sysdeps/unix/getlogin.c>
+#undef getlogin
+
+
+/* Return the login name of the user, or NULL if it can't be determined.
+ The returned pointer, if not NULL, is good only until the next call. */
+
+char *
+getlogin (void)
+{
+ if (__getlogin_r_loginuid (name, sizeof (name)) == 0)
+ return name;
+
+ return getlogin_fd0 ();
+}
diff --git a/libc/sysdeps/unix/sysv/linux/getlogin_r.c b/libc/sysdeps/unix/sysv/linux/getlogin_r.c
new file mode 100644
index 000000000..d07846ccb
--- /dev/null
+++ b/libc/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -0,0 +1,100 @@
+/* Copyright (C) 2010 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 <pwd.h>
+#include <unistd.h>
+#include <not-cancel.h>
+
+#define STATIC static
+static int getlogin_r_fd0 (char *name, size_t namesize);
+#define getlogin_r getlogin_r_fd0
+#include <sysdeps/unix/getlogin_r.c>
+#undef getlogin_r
+
+
+int
+attribute_hidden
+__getlogin_r_loginuid (name, namesize)
+ char *name;
+ size_t namesize;
+{
+ int fd = open_not_cancel_2 ("/proc/self/loginuid", O_RDONLY);
+ if (fd == -1)
+ return 1;
+
+ ssize_t n = TEMP_FAILURE_RETRY (read_not_cancel (fd, name, namesize));
+ close_not_cancel_no_status (fd);
+
+ uid_t uid;
+ char *endp;
+ if (n <= 0
+ || (uid = strtoul (name, &endp, 10), endp == name || *endp != '\0'))
+ return 1;
+
+ size_t buflen = 1024;
+ char *buf = alloca (buflen);
+ bool use_malloc = false;
+ struct passwd pwd;
+ struct passwd *tpwd;
+ int res;
+
+ while ((res = __getpwuid_r (uid, &pwd, buf, buflen, &tpwd)) != 0)
+ if (__libc_use_alloca (2 * buflen))
+ extend_alloca (buf, buflen, 2 * buflen);
+ else
+ {
+ buflen *= 2;
+ char *newp = realloc (use_malloc ? buf : NULL, buflen);
+ if (newp == NULL)
+ {
+ fail:
+ if (use_malloc)
+ free (buf);
+ return 1;
+ }
+ buf = newp;
+ use_malloc = true;
+ }
+
+ if (tpwd == NULL)
+ goto fail;
+
+ strncpy (name, pwd.pw_name, namesize - 1);
+ name[namesize - 1] = '\0';
+
+ if (use_malloc)
+ free (buf);
+
+ return 0;
+}
+
+
+/* Return the login name of the user, or NULL if it can't be determined.
+ The returned pointer, if not NULL, is good only until the next call. */
+
+int
+getlogin_r (name, namesize)
+ char *name;
+ size_t namesize;
+{
+ if (__getlogin_r_loginuid (name, namesize) == 0)
+ return 0;
+
+ return getlogin_r_fd0 (name, namesize);
+}
+libc_hidden_def (getlogin_r)
diff --git a/libc/sysdeps/unix/sysv/linux/ldsodefs.h b/libc/sysdeps/unix/sysv/linux/ldsodefs.h
index 0965f1496..5d5b1b4c0 100644
--- a/libc/sysdeps/unix/sysv/linux/ldsodefs.h
+++ b/libc/sysdeps/unix/sysv/linux/ldsodefs.h
@@ -1,5 +1,5 @@
/* Run-time dynamic linker data structures for loaded ELF shared objects.
- Copyright (C) 2001, 2002, 2003, 2006, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2003, 2006, 2009, 2010 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
@@ -19,6 +19,7 @@
#ifndef _LDSODEFS_H
+#include <libc-abis.h>
#include <kernel-features.h>
/* Get the real definitions. */
@@ -58,7 +59,8 @@ extern void _dl_non_dynamic_init (void) internal_function;
|| memcmp (hdr, expected2, size) == 0)
#define VALID_ELF_OSABI(osabi) (osabi == ELFOSABI_SYSV \
|| osabi == ELFOSABI_LINUX)
-#define VALID_ELF_ABIVERSION(ver) (ver == 0)
+#define VALID_ELF_ABIVERSION(osabi,ver) \
+ (ver == 0 || (osabi == ELFOSABI_LINUX && ver < LIBC_ABI_MAX))
#define MORE_ELF_HEADER_DATA \
static const unsigned char expected2[EI_PAD] = \
{ \
@@ -69,8 +71,7 @@ extern void _dl_non_dynamic_init (void) internal_function;
[EI_CLASS] = ELFW(CLASS), \
[EI_DATA] = byteorder, \
[EI_VERSION] = EV_CURRENT, \
- [EI_OSABI] = ELFOSABI_LINUX, \
- [EI_ABIVERSION] = 0 \
+ [EI_OSABI] = ELFOSABI_LINUX \
}
#endif /* ldsodefs.h */
diff --git a/libc/sysdeps/unix/sysv/linux/mmap64.c b/libc/sysdeps/unix/sysv/linux/mmap64.c
index d3c68cd10..85c801d50 100644
--- a/libc/sysdeps/unix/sysv/linux/mmap64.c
+++ b/libc/sysdeps/unix/sysv/linux/mmap64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999,2000,2001,2002,2006 Free Software Foundation, Inc.
+/* Copyright (C) 1999,2000,2001,2002,2006,2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>, 1999.
@@ -30,8 +30,13 @@
#ifdef __NR_mmap2
/* This is always 12, even on architectures where PAGE_SHIFT != 12. */
-# ifndef MMAP2_PAGE_SHIFT
-# define MMAP2_PAGE_SHIFT 12
+# if MMAP2_PAGE_SHIFT == -1
+static int page_shift;
+# else
+# ifndef MMAP2_PAGE_SHIFT
+# define MMAP2_PAGE_SHIFT 12
+# endif
+# define page_shift MMAP2_PAGE_SHIFT
# endif
# ifndef __ASSUME_MMAP2_SYSCALL
@@ -44,7 +49,15 @@ void *
__mmap64 (void *addr, size_t len, int prot, int flags, int fd, off64_t offset)
{
#ifdef __NR_mmap2
- if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1))
+# ifdef MMAP2_PAGE_SHIFT == -1
+ if (page_shift == 0)
+ {
+ int page_size = getpagesize ();
+ while ((1 << ++page_shift) != page_size)
+ ;
+ }
+# endif
+ if (offset & ((1 << page_shift) - 1))
{
__set_errno (EINVAL);
return MAP_FAILED;
diff --git a/libc/sysdeps/x86_64/multiarch/strpbrk-c.c b/libc/sysdeps/x86_64/multiarch/strpbrk-c.c
index c58dcb560..bbf5c49d8 100644
--- a/libc/sysdeps/x86_64/multiarch/strpbrk-c.c
+++ b/libc/sysdeps/x86_64/multiarch/strpbrk-c.c
@@ -1,4 +1,8 @@
-#define USE_AS_STRPBRK
-#define STRCSPN_SSE2 __strpbrk_sse2
-#define STRCSPN_SSE42 __strpbrk_sse42
-#include "strcspn-c.c"
+/* Don't define multiple versions for strpbrk in static library since we
+ need strpbrk before the initialization happened. */
+#ifdef SHARED
+# define USE_AS_STRPBRK
+# define STRCSPN_SSE2 __strpbrk_sse2
+# define STRCSPN_SSE42 __strpbrk_sse42
+# include "strcspn-c.c"
+#endif