diff options
author | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2010-03-26 21:08:35 +0000 |
---|---|---|
committer | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2010-03-26 21:08:35 +0000 |
commit | 30feca091914f8d41f452394367677bfe56b3316 (patch) | |
tree | b9f750862b34524d3bcf230ab749d293e9caebc8 /libc/sysdeps/unix | |
parent | 5c92b8030ed5819dd183df7cc3cfb085317beb16 (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/unix')
-rw-r--r-- | libc/sysdeps/unix/getlogin.c | 8 | ||||
-rw-r--r-- | libc/sysdeps/unix/getlogin_r.c | 7 | ||||
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/clock_getres.c | 8 | ||||
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/clock_gettime.c | 5 | ||||
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/clock_settime.c | 5 | ||||
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/dl-sysdep.c | 8 | ||||
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/getlogin.c | 39 | ||||
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/getlogin_r.c | 100 | ||||
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/ldsodefs.h | 9 | ||||
-rw-r--r-- | libc/sysdeps/unix/sysv/linux/mmap64.c | 21 |
10 files changed, 191 insertions, 19 deletions
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; |