diff options
author | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2007-09-12 16:26:54 +0000 |
---|---|---|
committer | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2007-09-12 16:26:54 +0000 |
commit | 83584a7af898dd93c48600fe850d150c51b10899 (patch) | |
tree | 0affa8ffee374ab83e40501d8d8967a03569c44d /libc/sysdeps/unix | |
parent | 04b4d23592609edcd19fd5a461bbe6d3cc677b5b (diff) |
Merge changes between r2424 and r3467 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@3468 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/sysdeps/unix')
68 files changed, 1186 insertions, 325 deletions
diff --git a/libc/sysdeps/unix/clock_gettime.c b/libc/sysdeps/unix/clock_gettime.c index f698f0151..fbaaf301e 100644 --- a/libc/sysdeps/unix/clock_gettime.c +++ b/libc/sysdeps/unix/clock_gettime.c @@ -1,5 +1,5 @@ /* clock_gettime -- Get the current time from a POSIX clockid_t. Unix version. - Copyright (C) 1999-2004, 2005 Free Software Foundation, Inc. + Copyright (C) 1999-2004, 2005, 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 @@ -93,7 +93,6 @@ int clock_gettime (clockid_t clock_id, struct timespec *tp) { int retval = -1; - struct timeval tv; switch (clock_id) { @@ -103,9 +102,12 @@ clock_gettime (clockid_t clock_id, struct timespec *tp) #ifndef HANDLED_REALTIME case CLOCK_REALTIME: - retval = gettimeofday (&tv, NULL); - if (retval == 0) - TIMEVAL_TO_TIMESPEC (&tv, tp); + { + struct timeval tv; + retval = gettimeofday (&tv, NULL); + if (retval == 0) + TIMEVAL_TO_TIMESPEC (&tv, tp); + } break; #endif diff --git a/libc/sysdeps/unix/clock_settime.c b/libc/sysdeps/unix/clock_settime.c index a93be6349..f3f62cf99 100644 --- a/libc/sysdeps/unix/clock_settime.c +++ b/libc/sysdeps/unix/clock_settime.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1999-2004, 2006 Free Software Foundation, Inc. +/* Copyright (C) 1999-2004, 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 @@ -23,7 +23,7 @@ #include <ldsodefs.h> -#if HP_TIMING_AVAIL +#if HP_TIMING_AVAIL && !defined HANDLED_CPUTIME /* Clock frequency of the processor. We make it a 64-bit variable because some jokers are already playing with processors with more than 4GHz. */ @@ -33,10 +33,8 @@ static hp_timing_t freq; /* This function is defined in the thread library. */ extern void __pthread_clock_settime (clockid_t clock_id, hp_timing_t offset) __attribute__ ((__weak__)); -#endif -#if HP_TIMING_AVAIL static int hp_timing_settime (clockid_t clock_id, const struct timespec *tp) { diff --git a/libc/sysdeps/unix/dirstream.h b/libc/sysdeps/unix/dirstream.h index a1f74473c..8303f07fa 100644 --- a/libc/sysdeps/unix/dirstream.h +++ b/libc/sysdeps/unix/dirstream.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1995, 1996, 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 @@ -17,7 +17,6 @@ 02111-1307 USA. */ #ifndef _DIRSTREAM_H - #define _DIRSTREAM_H 1 #include <sys/types.h> @@ -33,14 +32,16 @@ struct __dirstream { int fd; /* File descriptor. */ - char *data; /* Directory block. */ + __libc_lock_define (, lock) /* Mutex lock for this structure. */ + size_t allocation; /* Space allocated for the block. */ size_t size; /* Total valid data in the block. */ size_t offset; /* Current offset into the block. */ off_t filepos; /* Position of next entry to read. */ - __libc_lock_define (, lock) /* Mutex lock for this structure. */ + /* Directory block. */ + char data[0] __attribute__ ((aligned (__alignof__ (void*)))); }; #define _DIR_dirfd(dirp) ((dirp)->fd) diff --git a/libc/sysdeps/unix/opendir.c b/libc/sysdeps/unix/opendir.c index 59772cda7..0a116247d 100644 --- a/libc/sysdeps/unix/opendir.c +++ b/libc/sysdeps/unix/opendir.c @@ -31,6 +31,7 @@ #include <dirstream.h> #include <not-cancel.h> +#include <kernel-features.h> /* opendir() must not accidentally open something other than a directory. @@ -110,7 +111,11 @@ __opendir (const char *name) } } - int fd = open_not_cancel_2 (name, O_RDONLY|O_NDELAY|EXTRA_FLAGS|O_LARGEFILE); + int flags = O_RDONLY|O_NDELAY|EXTRA_FLAGS|O_LARGEFILE; +#ifdef O_CLOEXEC + flags |= O_CLOEXEC; +#endif + int fd = open_not_cancel_2 (name, flags); if (__builtin_expect (fd, 0) < 0) return NULL; @@ -138,12 +143,33 @@ __opendir (const char *name) weak_alias (__opendir, opendir) +#ifdef __ASSUME_O_CLOEXEC +# define check_have_o_cloexec(fd) 1 +#else +static int +check_have_o_cloexec (int fd) +{ + if (__have_o_cloexec == 0) + __have_o_cloexec = (__fcntl (fd, F_GETFD, 0) & FD_CLOEXEC) == 0 ? -1 : 1; + return __have_o_cloexec > 0; +} +#endif + + DIR * internal_function __alloc_dir (int fd, bool close_fd, const struct stat64 *statp) { - if (__builtin_expect (__fcntl (fd, F_SETFD, FD_CLOEXEC), 0) < 0) - goto lose; + /* We always have to set the close-on-exit flag if the user provided + the file descriptor. Otherwise only if we have no working + O_CLOEXEC support. */ +#ifdef O_CLOEXEC + if (! close_fd || ! check_have_o_cloexec (fd)) +#endif + { + if (__builtin_expect (__fcntl (fd, F_SETFD, FD_CLOEXEC), 0) < 0) + goto lose; + } size_t allocation; #ifdef _STATBUF_ST_BLKSIZE @@ -155,9 +181,7 @@ __alloc_dir (int fd, bool close_fd, const struct stat64 *statp) allocation = (BUFSIZ < sizeof (struct dirent64) ? sizeof (struct dirent64) : BUFSIZ); - const int pad = -sizeof (DIR) % __alignof__ (struct dirent64); - - DIR *dirp = (DIR *) malloc (sizeof (DIR) + allocation + pad); + DIR *dirp = (DIR *) malloc (sizeof (DIR) + allocation); if (dirp == NULL) lose: { @@ -169,14 +193,15 @@ __alloc_dir (int fd, bool close_fd, const struct stat64 *statp) } return NULL; } - memset (dirp, '\0', sizeof (DIR)); - dirp->data = (char *) (dirp + 1) + pad; - dirp->allocation = allocation; - dirp->fd = fd; + dirp->fd = fd; #ifndef NOT_IN_libc __libc_lock_init (dirp->lock); #endif + dirp->allocation = allocation; + dirp->size = 0; + dirp->offset = 0; + dirp->filepos = 0; return dirp; } diff --git a/libc/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h b/libc/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h index f17dc2bdc..b4f49cf63 100644 --- a/libc/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux. - Copyright (C) 1995-2000, 2004, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 1995-2000,2004,2005,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 @@ -50,6 +50,7 @@ # define O_NOFOLLOW 0200000 /* Do not follow links. */ # define O_DIRECT 02000000 /* Direct disk access. */ # define O_NOATIME 04000000 /* Do not set atime. */ +# define O_CLOEXEC 010000000 /* Set close_on_exec. */ #endif #ifdef __USE_LARGEFILE64 diff --git a/libc/sysdeps/unix/sysv/linux/alpha/sysdep.h b/libc/sysdeps/unix/sysv/linux/alpha/sysdep.h index a22da71d6..f0661d162 100644 --- a/libc/sysdeps/unix/sysv/linux/alpha/sysdep.h +++ b/libc/sysdeps/unix/sysv/linux/alpha/sysdep.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 1993, 1995, 1996, 1997, 2002, 2003, 2004 +/* Copyright (C) 1992, 1993, 1995, 1996, 1997, 2002, 2003, 2004, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>, August 1995. @@ -29,6 +29,8 @@ /* There is some commonality. */ #include <sysdeps/unix/alpha/sysdep.h> +#include <tls.h> + /* For Linux we can use the system call table in the header file /usr/include/asm/unistd.h of the kernel. But these symbols do not follow the SYS_* syntax diff --git a/libc/sysdeps/unix/sysv/linux/bits/sched.h b/libc/sysdeps/unix/sysv/linux/bits/sched.h index 31db66f8a..5eaa2fe52 100644 --- a/libc/sysdeps/unix/sysv/linux/bits/sched.h +++ b/libc/sysdeps/unix/sysv/linux/bits/sched.h @@ -104,7 +104,7 @@ struct __sched_param # define __CPU_SETSIZE 1024 # define __NCPUBITS (8 * sizeof (__cpu_mask)) -/* Type for array elements in 'cpu_set'. */ +/* Type for array elements in 'cpu_set_t'. */ typedef unsigned long int __cpu_mask; /* Basic access functions. */ @@ -118,20 +118,72 @@ typedef struct } cpu_set_t; /* Access functions for CPU masks. */ -# define __CPU_ZERO(cpusetp) \ +# if __GNUC_PREREQ (2, 91) +# define __CPU_ZERO_S(setsize, cpusetp) \ + do __builtin_memset (cpusetp, '\0', setsize); while (0) +# else +# define __CPU_ZERO_S(setsize, cpusetp) \ do { \ - unsigned int __i; \ + size_t __i; \ + size_t __imax = (setsize) / sizeof (__cpu_mask); \ cpu_set_t *__arr = (cpusetp); \ - for (__i = 0; __i < sizeof (cpu_set_t) / sizeof (__cpu_mask); ++__i) \ + for (__i = 0; __i < __imax; ++__i) \ __arr->__bits[__i] = 0; \ } while (0) -# define __CPU_SET(cpu, cpusetp) \ - ((cpusetp)->__bits[__CPUELT (cpu)] |= __CPUMASK (cpu)) -# define __CPU_CLR(cpu, cpusetp) \ - ((cpusetp)->__bits[__CPUELT (cpu)] &= ~__CPUMASK (cpu)) -# define __CPU_ISSET(cpu, cpusetp) \ - (((cpusetp)->__bits[__CPUELT (cpu)] & __CPUMASK (cpu)) != 0) -extern int __sched_cpucount (size_t __setsize, cpu_set_t *__setp) __THROW; -# define __CPU_COUNT(cpusetp) \ - __sched_cpucount (sizeof (cpu_set_t), cpusetp) +# endif +# define __CPU_SET_S(cpu, setsize, cpusetp) \ + ({ 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; }) +# define __CPU_ISSET_S(cpu, setsize, cpusetp) \ + ({ 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) + +# if __GNUC_PREREQ (2, 91) +# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \ + (__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; }) +# 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; }) + +# define __CPU_ALLOC_SIZE(count) \ + ((((count) + __NCPUBITS - 1) / __NCPUBITS) * 8) +# define __CPU_ALLOC(count) __sched_cpualloc (count) +# define __CPU_FREE(cpuset) __sched_cpufree (cpuset) + +__BEGIN_DECLS + +extern int __sched_cpucount (size_t __setsize, const cpu_set_t *__setp) + __THROW; +extern cpu_set_t *__sched_cpualloc (size_t __count) __THROW __wur; +extern void __sched_cpufree (cpu_set_t *__set) __THROW; + +__END_DECLS + #endif diff --git a/libc/sysdeps/unix/sysv/linux/bits/socket.h b/libc/sysdeps/unix/sysv/linux/bits/socket.h index 377f589bb..89a9106b2 100644 --- a/libc/sysdeps/unix/sysv/linux/bits/socket.h +++ b/libc/sysdeps/unix/sysv/linux/bits/socket.h @@ -63,7 +63,7 @@ enum __socket_type /* Protocol families. */ #define PF_UNSPEC 0 /* Unspecified. */ #define PF_LOCAL 1 /* Local to host (pipes and file-domain). */ -#define PF_UNIX PF_LOCAL /* Old BSD name for PF_LOCAL. */ +#define PF_UNIX PF_LOCAL /* POSIX name for PF_LOCAL. */ #define PF_FILE PF_LOCAL /* Another non-standard name for PF_LOCAL. */ #define PF_INET 2 /* IP protocol family. */ #define PF_AX25 3 /* Amateur Radio AX.25. */ @@ -90,7 +90,9 @@ enum __socket_type #define PF_PPPOX 24 /* PPPoX sockets. */ #define PF_WANPIPE 25 /* Wanpipe API sockets. */ #define PF_BLUETOOTH 31 /* Bluetooth sockets. */ -#define PF_MAX 32 /* For now.. */ +#define PF_IUCV 32 /* IUCV sockets. */ +#define PF_RXRPC 33 /* RxRPC sockets. */ +#define PF_MAX 34 /* For now.. */ /* Address families. */ #define AF_UNSPEC PF_UNSPEC @@ -122,6 +124,8 @@ enum __socket_type #define AF_PPPOX PF_PPPOX #define AF_WANPIPE PF_WANPIPE #define AF_BLUETOOTH PF_BLUETOOTH +#define AF_IUCV PF_IUCV +#define AF_RXRPC PF_RXRPC #define AF_MAX PF_MAX /* Socket level values. Others are defined in the appropriate headers. @@ -206,8 +210,13 @@ enum #define MSG_ERRQUEUE MSG_ERRQUEUE MSG_NOSIGNAL = 0x4000, /* Do not generate SIGPIPE. */ #define MSG_NOSIGNAL MSG_NOSIGNAL - MSG_MORE = 0x8000 /* Sender will send more. */ + MSG_MORE = 0x8000, /* Sender will send more. */ #define MSG_MORE MSG_MORE + + MSG_CMSG_CLOEXEC = 0x40000000 /* Set close_on_exit for file + descriptor received through + SCM_RIGHTS. */ +#define MSG_CMSG_CLOEXEC MSG_CMSG_CLOEXEC }; diff --git a/libc/sysdeps/unix/sysv/linux/check_pf.c b/libc/sysdeps/unix/sysv/linux/check_pf.c index 46161a806..df7cbb189 100644 --- a/libc/sysdeps/unix/sysv/linux/check_pf.c +++ b/libc/sysdeps/unix/sysv/linux/check_pf.c @@ -41,6 +41,9 @@ #ifndef IFA_F_HOMEADDRESS # define IFA_F_HOMEADDRESS 0 #endif +#ifndef IFA_F_OPTIMISTIC +# define IFA_F_OPTIMISTIC 0 +#endif static int @@ -139,42 +142,77 @@ make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6, if (nlmh->nlmsg_type == RTM_NEWADDR) { struct ifaddrmsg *ifam = (struct ifaddrmsg *) NLMSG_DATA (nlmh); + 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; + case AF_INET: - *seen_ipv4 = true; + local = NULL; + address = NULL; + while (RTA_OK (rta, len)) + { + 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); + } + + if (local != NULL) + { + out_v4: + if (*(const in_addr_t *) (address ?: local) + != htonl (INADDR_LOOPBACK)) + *seen_ipv4 = true; + } break; - case AF_INET6: - *seen_ipv6 = true; - if (ifam->ifa_flags & (IFA_F_DEPRECATED - | IFA_F_TEMPORARY - | IFA_F_HOMEADDRESS)) + case AF_INET6: + local = NULL; + address = NULL; + while (RTA_OK (rta, len)) { - struct rtattr *rta = IFA_RTA (ifam); - size_t len = (nlmh->nlmsg_len - - NLMSG_LENGTH (sizeof (*ifam))); - void *local = NULL; - 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); - break; - } - - rta = RTA_NEXT (rta, len); + 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)) + *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) + newp->info.flags = (((ifam->ifa_flags + & (IFA_F_DEPRECATED + | IFA_F_OPTIMISTIC)) ? in6ai_deprecated : 0) | ((ifam->ifa_flags & IFA_F_TEMPORARY) @@ -203,7 +241,7 @@ make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6, close_not_cancel_no_status (fd); - if (in6ailist != NULL) + if (*seen_ipv6 && in6ailist != NULL) { *in6ai = malloc (in6ailistlen * sizeof (**in6ai)); if (*in6ai == NULL) diff --git a/libc/sysdeps/unix/sysv/linux/clock_gettime.c b/libc/sysdeps/unix/sysv/linux/clock_gettime.c index 5afe20feb..cd536a0fc 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 Free Software Foundation, Inc. + Copyright (C) 2003,2004,2005,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 @@ -133,11 +133,19 @@ maybe_syscall_gettime_cpu (clockid_t clock_id, struct timespec *tp) { if (e == EINVAL) { +# ifdef HAVE_CLOCK_GETRES_VSYSCALL /* Check whether the kernel supports CPU clocks at all. If not, record it for the future. */ r = INTERNAL_VSYSCALL (clock_getres, err, 2, + MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED), + NULL); +# else + /* Check whether the kernel supports CPU clocks at all. + If not, record it for the future. */ + r = INTERNAL_SYSCALL (clock_getres, err, 2, MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED), NULL); +# endif if (INTERNAL_SYSCALL_ERROR_P (r, err)) __libc_missing_posix_cpu_timers = 1; } diff --git a/libc/sysdeps/unix/sysv/linux/dl-osinfo.h b/libc/sysdeps/unix/sysv/linux/dl-osinfo.h index 6a7694ec4..082790f63 100644 --- a/libc/sysdeps/unix/sysv/linux/dl-osinfo.h +++ b/libc/sysdeps/unix/sysv/linux/dl-osinfo.h @@ -1,5 +1,6 @@ /* Operating system specific code for generic dynamic loader functions. Linux. - Copyright (C) 2000,2001,2002,2004,2005,2006 Free Software Foundation, Inc. + Copyright (C) 2000,2001,2002,2004,2005,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 @@ -51,11 +52,9 @@ _dl_discover_osversion (void) static const struct { - ElfW(Word) vendorlen; - ElfW(Word) datalen; - ElfW(Word) type; + ElfW(Nhdr) hdr; char vendor[8]; - } expected_note = { sizeof "Linux", sizeof (ElfW(Word)), 0, "Linux" }; + } expected_note = { { sizeof "Linux", sizeof (ElfW(Word)), 0 }, "Linux" }; const ElfW(Phdr) *const phdr = GLRO(dl_sysinfo_map)->l_phdr; const ElfW(Word) phnum = GLRO(dl_sysinfo_map)->l_phnum; for (uint_fast16_t i = 0; i < phnum; ++i) @@ -63,20 +62,16 @@ _dl_discover_osversion (void) { const ElfW(Addr) start = (phdr[i].p_vaddr + GLRO(dl_sysinfo_map)->l_addr); - const struct - { - ElfW(Word) vendorlen; - ElfW(Word) datalen; - ElfW(Word) type; - } *note = (const void *) start; + const ElfW(Nhdr) *note = (const void *) start; while ((ElfW(Addr)) (note + 1) - start < phdr[i].p_memsz) { if (!memcmp (note, &expected_note, sizeof expected_note)) return *(const ElfW(Word) *) ((const void *) note + sizeof expected_note); -#define ROUND(len) (((len) + sizeof (ElfW(Word)) - 1) & -sizeof (ElfW(Word))) +#define ROUND(len) (((len) + sizeof note->n_type - 1) & -sizeof note->n_type) note = ((const void *) (note + 1) - + ROUND (note->vendorlen) + ROUND (note->datalen)); + + ROUND (note->n_namesz) + ROUND (note->n_descsz)); +#undef ROUND } } } diff --git a/libc/sysdeps/unix/sysv/linux/powerpc/dl-vdso.c b/libc/sysdeps/unix/sysv/linux/dl-vdso.c index e1be09773..28d4bb1d4 100644 --- a/libc/sysdeps/unix/sysv/linux/powerpc/dl-vdso.c +++ b/libc/sysdeps/unix/sysv/linux/dl-vdso.c @@ -1,5 +1,5 @@ /* ELF symbol resolve functions for VDSO objects. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 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 @@ -18,13 +18,12 @@ 02111-1307 USA. */ #include "config.h" -#include <dl-hash.h> #include <ldsodefs.h> void * internal_function -_dl_vdso_vsym (const char *name, const char *version) +_dl_vdso_vsym (const char *name, const struct r_found_version *vers) { struct link_map *map = GLRO (dl_sysinfo_map); void *value = NULL; @@ -37,19 +36,11 @@ _dl_vdso_vsym (const char *name, const char *version) memset (&wsym, 0, sizeof (ElfW (Sym))); wsym.st_info = (unsigned char) ELFW (ST_INFO (STB_WEAK, STT_NOTYPE)); - /* Compute hash value to the version string. */ - struct r_found_version vers; - vers.name = version; - vers.hidden = 1; - vers.hash = _dl_elf_hash (version); - /* We don't have a specific file where the symbol can be found. */ - vers.filename = NULL; - /* Search the scope of the vdso map. */ const ElfW (Sym) *ref = &wsym; lookup_t result = GLRO (dl_lookup_symbol_x) (name, map, &ref, map->l_local_scope, - &vers, 0, 0, NULL); + vers, 0, 0, NULL); if (ref != NULL) value = DL_SYMBOL_ADDRESS (result, ref); diff --git a/libc/sysdeps/unix/sysv/linux/dl-vdso.h b/libc/sysdeps/unix/sysv/linux/dl-vdso.h new file mode 100644 index 000000000..7e433e03a --- /dev/null +++ b/libc/sysdeps/unix/sysv/linux/dl-vdso.h @@ -0,0 +1,49 @@ +/* ELF symbol resolve functions for VDSO objects. + Copyright (C) 2005, 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 _DL_VDSO_H +#define _DL_VDSO_H 1 + +#include <assert.h> +#include <ldsodefs.h> + +#ifdef NDEBUG +# define CHECK_HASH(var) do {} while (0) +#else +# include <dl-hash.h> +# define CHECK_HASH(var) assert (var.hash == _dl_elf_hash (var.name)) +#endif + +/* Create version number record for lookup. */ +#define PREPARE_VERSION(var, vname, vhash) \ + struct r_found_version var; \ + var.name = vname; \ + var.hidden = 1; \ + var.hash = vhash; \ + CHECK_HASH (var); \ + /* We don't have a specific file where the symbol can be found. */ \ + var.filename = NULL + + +/* Functions for resolving symbols in the VDSO link map. */ +extern void *_dl_vdso_vsym (const char *name, + const struct r_found_version *version) + internal_function attribute_hidden; + +#endif /* dl-vdso.h */ diff --git a/libc/sysdeps/unix/sysv/linux/fstatfs64.c b/libc/sysdeps/unix/sysv/linux/fstatfs64.c index 48afd1f4d..79c9adcdc 100644 --- a/libc/sysdeps/unix/sysv/linux/fstatfs64.c +++ b/libc/sysdeps/unix/sysv/linux/fstatfs64.c @@ -1,5 +1,6 @@ /* Return information about the filesystem on which FD resides. - Copyright (C) 1996,1997,1998,1999,2000,2003 Free Software Foundation, Inc. + Copyright (C) 1996,1997,1998,1999,2000,2003,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 @@ -22,6 +23,7 @@ #include <sys/statfs.h> #include <stddef.h> #include <sysdep.h> +#include <kernel-features.h> /* Defined in statfs64.c. */ extern int __no_statfs64 attribute_hidden; diff --git a/libc/sysdeps/unix/sysv/linux/fxstatat.c b/libc/sysdeps/unix/sysv/linux/fxstatat.c index c1c416abd..1b9add40d 100644 --- a/libc/sysdeps/unix/sysv/linux/fxstatat.c +++ b/libc/sysdeps/unix/sysv/linux/fxstatat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005, 2006 Free Software Foundation, Inc. +/* Copyright (C) 2005, 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 @@ -30,6 +30,7 @@ #include <sysdep.h> #include <sys/syscall.h> #include <bp-checks.h> +#include <kernel-features.h> #include <xstatconv.h> diff --git a/libc/sysdeps/unix/sysv/linux/getsysstats.c b/libc/sysdeps/unix/sysv/linux/getsysstats.c index d655ba3b2..6d4c9c06e 100644 --- a/libc/sysdeps/unix/sysv/linux/getsysstats.c +++ b/libc/sysdeps/unix/sysv/linux/getsysstats.c @@ -1,5 +1,5 @@ /* Determine various system internal values, Linux version. - Copyright (C) 1996-2001, 2002, 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 1996-2001, 2002, 2003, 2006, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -21,7 +21,9 @@ #include <alloca.h> #include <assert.h> #include <ctype.h> +#include <dirent.h> #include <errno.h> +#include <fcntl.h> #include <mntent.h> #include <paths.h> #include <stdio.h> @@ -32,6 +34,7 @@ #include <sys/sysinfo.h> #include <atomic.h> +#include <not-cancel.h> /* How we can determine the number of available processors depends on @@ -64,14 +67,15 @@ while (0) #endif + int __get_nprocs () { + /* XXX Here will come a test for the new system call. */ + char buffer[8192]; int result = 1; - /* XXX Here will come a test for the new system call. */ - /* The /proc/stat format is more uniform, use it by default. */ FILE *fp = fopen ("/proc/stat", "rc"); if (fp != NULL) @@ -103,35 +107,56 @@ __get_nprocs () weak_alias (__get_nprocs, get_nprocs) -#ifdef GET_NPROCS_CONF_PARSER /* On some architectures it is possible to distinguish between configured and active cpus. */ int __get_nprocs_conf () { - char buffer[8192]; - int result = 1; - /* XXX Here will come a test for the new system call. */ + /* Try to use the sysfs filesystem. It has actual information about + online processors. */ + DIR *dir = __opendir ("/sys/devices/system/cpu"); + if (dir != NULL) + { + int count = 0; + struct dirent64 *d; + + while ((d = __readdir64 (dir)) != NULL) + /* NB: the sysfs has d_type support. */ + if (d->d_type == DT_DIR && strncmp (d->d_name, "cpu", 3) == 0) + { + char *endp; + unsigned long int nr = strtoul (d->d_name + 3, &endp, 10); + if (nr != ULONG_MAX && endp != d->d_name + 3 && *endp == '\0') + ++count; + } + + __closedir (dir); + + return count; + } + + int result = 1; + +#ifdef GET_NPROCS_CONF_PARSER /* If we haven't found an appropriate entry return 1. */ FILE *fp = fopen ("/proc/cpuinfo", "rc"); if (fp != NULL) { + char buffer[8192]; + /* No threads use this stream. */ __fsetlocking (fp, FSETLOCKING_BYCALLER); GET_NPROCS_CONF_PARSER (fp, buffer, result); fclose (fp); } +#else + result = __get_nprocs (); +#endif return result; } -#else -/* As far as I know Linux has no separate numbers for configured and - available processors. So make the `get_nprocs_conf' function an - alias. */ -strong_alias (__get_nprocs, __get_nprocs_conf) -#endif weak_alias (__get_nprocs_conf, get_nprocs_conf) /* General function to get information about memory status from proc diff --git a/libc/sysdeps/unix/sysv/linux/i386/bits/fcntl.h b/libc/sysdeps/unix/sysv/linux/i386/bits/fcntl.h index 6de33302e..83ca3c286 100644 --- a/libc/sysdeps/unix/sysv/linux/i386/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/i386/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux. - Copyright (C) 1995, 1996, 1997, 1998, 2000, 2004, 2006 + Copyright (C) 1995, 1996, 1997, 1998, 2000, 2004, 2006, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -50,6 +50,7 @@ # define O_DIRECTORY 0200000 /* Must be a directory. */ # define O_NOFOLLOW 0400000 /* Do not follow links. */ # define O_NOATIME 01000000 /* Do not set atime. */ +# define O_CLOEXEC 02000000 /* Set close_on_exec. */ #endif /* For now Linux has synchronisity options for data and read operations. diff --git a/libc/sysdeps/unix/sysv/linux/i386/posix_fallocate.c b/libc/sysdeps/unix/sysv/linux/i386/posix_fallocate.c new file mode 100644 index 000000000..c974d06af --- /dev/null +++ b/libc/sysdeps/unix/sysv/linux/i386/posix_fallocate.c @@ -0,0 +1,58 @@ +/* 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 <kernel-features.h> +#include <sysdep.h> + +#define posix_fallocate static internal_fallocate +#include <sysdeps/posix/posix_fallocate.c> +#undef posix_fallocate + +#if !defined __ASSUME_FALLOCATE && defined __NR_fallocate +int __have_fallocate attribute_hidden; +#endif + +extern int __fallocate64 (int fd, int mode, __off64_t offset, __off64_t len) + attribute_hidden; + +/* Reserve storage for the data of the file associated with FD. */ +int +posix_fallocate (int fd, __off_t offset, __off_t len) +{ +#ifdef __NR_fallocate +# ifndef __ASSUME_FALLOCATE + if (__builtin_expect (__have_fallocate >= 0, 1)) +# endif + { + int res = __fallocate64 (fd, 0, offset, len); + if (! res) + return 0; + +# ifndef __ASSUME_FALLOCATE + if (__builtin_expect (res == ENOSYS, 0)) + __have_fallocate = -1; + else +# endif + if (res != EOPNOTSUPP) + return res; + } +#endif + + return internal_fallocate (fd, offset, len); +} diff --git a/libc/sysdeps/unix/sysv/linux/i386/posix_fallocate64.c b/libc/sysdeps/unix/sysv/linux/i386/posix_fallocate64.c new file mode 100644 index 000000000..d5b4d597c --- /dev/null +++ b/libc/sysdeps/unix/sysv/linux/i386/posix_fallocate64.c @@ -0,0 +1,61 @@ +/* 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 <kernel-features.h> +#include <sysdep.h> + +extern int __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len); +#define __posix_fallocate64_l64 static internal_fallocate64 +#include <sysdeps/posix/posix_fallocate64.c> +#undef __posix_fallocate64_l64 + +#if !defined __ASSUME_FALLOCATE && defined __NR_fallocate +/* Defined in posix_fallocate.c. */ +extern int __have_fallocate attribute_hidden; +#endif + +extern int __fallocate64 (int fd, int mode, __off64_t offset, __off64_t len) + attribute_hidden; + +/* Reserve storage for the data of the file associated with FD. */ +int +__posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len) +{ +#ifdef __NR_fallocate +# ifndef __ASSUME_FALLOCATE + if (__builtin_expect (__have_fallocate >= 0, 1)) +# endif + { + int res = __fallocate64 (fd, 0, offset, len); + + if (! res) + return 0; + +# ifndef __ASSUME_FALLOCATE + if (__builtin_expect (res == ENOSYS, 0)) + __have_fallocate = -1; + else +# endif + if (res != EOPNOTSUPP) + return res; + } +#endif + + return internal_fallocate64 (fd, offset, len); +} diff --git a/libc/sysdeps/unix/sysv/linux/i386/syscalls.list b/libc/sysdeps/unix/sysv/linux/i386/syscalls.list index 3ff3a73aa..324ab3dc1 100644 --- a/libc/sysdeps/unix/sysv/linux/i386/syscalls.list +++ b/libc/sysdeps/unix/sysv/linux/i386/syscalls.list @@ -6,3 +6,4 @@ vm86 - vm86 i:ip __vm86 vm86@@GLIBC_2.3.4 oldgetrlimit EXTRA getrlimit i:ip __old_getrlimit getrlimit@GLIBC_2.0 oldsetrlimit EXTRA setrlimit i:ip __old_setrlimit setrlimit@GLIBC_2.0 waitpid - waitpid Ci:ipi __waitpid waitpid __libc_waitpid +fallocate64 - fallocate Vi:iiiiii __fallocate64 diff --git a/libc/sysdeps/unix/sysv/linux/i386/sysconf.c b/libc/sysdeps/unix/sysv/linux/i386/sysconf.c index 2ffbd5227..78877fb2a 100644 --- a/libc/sysdeps/unix/sysv/linux/i386/sysconf.c +++ b/libc/sysdeps/unix/sysv/linux/i386/sysconf.c @@ -1,5 +1,5 @@ /* Get file-specific information about a file. Linux version. - Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 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 @@ -97,11 +97,13 @@ static const struct intel_02_cache_info { 0x45, _SC_LEVEL2_CACHE_SIZE, 2097152, 4, 32 }, { 0x46, _SC_LEVEL3_CACHE_SIZE, 4194304, 4, 64 }, { 0x47, _SC_LEVEL3_CACHE_SIZE, 8388608, 8, 64 }, + { 0x48, _SC_LEVEL2_CACHE_SIZE, 3145728, 12, 64 }, { 0x49, _SC_LEVEL2_CACHE_SIZE, 4194304, 16, 64 }, { 0x4a, _SC_LEVEL3_CACHE_SIZE, 6291456, 12, 64 }, { 0x4b, _SC_LEVEL3_CACHE_SIZE, 8388608, 16, 64 }, { 0x4c, _SC_LEVEL3_CACHE_SIZE, 12582912, 12, 64 }, { 0x4d, _SC_LEVEL3_CACHE_SIZE, 16777216, 16, 64 }, + { 0x4e, _SC_LEVEL2_CACHE_SIZE, 6291456, 24, 64 }, { 0x60, _SC_LEVEL1_DCACHE_SIZE, 16384, 8, 64 }, { 0x66, _SC_LEVEL1_DCACHE_SIZE, 8192, 4, 64 }, { 0x67, _SC_LEVEL1_DCACHE_SIZE, 16384, 4, 64 }, diff --git a/libc/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h b/libc/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h index ed8c2da9e..8fa96e4e2 100644 --- a/libc/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux/IA64. - Copyright (C) 1999, 2000, 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2004, 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 @@ -49,6 +49,7 @@ # define O_DIRECTORY 0200000 /* must be a directory */ # define O_NOFOLLOW 0400000 /* don't follow links */ # define O_NOATIME 01000000 /* Do not set atime. */ +# define O_CLOEXEC 02000000 /* Set close_on_exec. */ #endif #ifdef __USE_LARGEFILE64 diff --git a/libc/sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h b/libc/sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h index 72c60ec24..34bc3c26a 100644 --- a/libc/sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h +++ b/libc/sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997, 1998, 2000, 2001, 2003, 2004 +/* Copyright (C) 1996, 1997, 1998, 2000, 2001, 2003, 2004, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jes Sorensen <jes@linuxcare.com>, July 2000 @@ -25,6 +25,8 @@ #ifndef _BITS_SIGCONTEXT_H #define _BITS_SIGCONTEXT_H 1 +#define __need_size_t +#include <stddef.h> #include <bits/sigstack.h> struct ia64_fpreg diff --git a/libc/sysdeps/unix/sysv/linux/ia64/sys/ptrace.h b/libc/sysdeps/unix/sysv/linux/ia64/sys/ptrace.h index ff77627a8..c824be2da 100644 --- a/libc/sysdeps/unix/sysv/linux/ia64/sys/ptrace.h +++ b/libc/sysdeps/unix/sysv/linux/ia64/sys/ptrace.h @@ -1,5 +1,5 @@ /* `ptrace' debugger support interface. Linux/ia64 version. - Copyright (C) 2001, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 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 @@ -127,6 +127,28 @@ struct pt_all_user_regs struct ia64_fpreg fr[128]; }; +/* Options set using PTRACE_SETOPTIONS. */ +enum __ptrace_setoptions { + PTRACE_O_TRACESYSGOOD = 0x00000001, + PTRACE_O_TRACEFORK = 0x00000002, + PTRACE_O_TRACEVFORK = 0x00000004, + PTRACE_O_TRACECLONE = 0x00000008, + PTRACE_O_TRACEEXEC = 0x00000010, + PTRACE_O_TRACEVFORKDONE = 0x00000020, + PTRACE_O_TRACEEXIT = 0x00000040, + PTRACE_O_MASK = 0x0000007f +}; + +/* Wait extended result codes for the above trace options. */ +enum __ptrace_eventcodes { + PTRACE_EVENT_FORK = 1, + PTRACE_EVENT_VFORK = 2, + PTRACE_EVENT_CLONE = 3, + PTRACE_EVENT_EXEC = 4, + PTRACE_EVENT_VFORK_DONE = 5, + PTRACE_EVENT_EXIT = 6 +}; + /* Perform process tracing functions. REQUEST is one of the values above, and determines the action to be taken. For all requests except PTRACE_TRACEME, PID specifies the process to be diff --git a/libc/sysdeps/unix/sysv/linux/if_index.c b/libc/sysdeps/unix/sysv/linux/if_index.c index 66f0ac131..6bd6bda3b 100644 --- a/libc/sysdeps/unix/sysv/linux/if_index.c +++ b/libc/sysdeps/unix/sysv/linux/if_index.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005 +/* Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -28,6 +28,7 @@ #include <sys/ioctl.h> #include <bits/libc-lock.h> #include <not-cancel.h> +#include <kernel-features.h> #include "netlinkaccess.h" diff --git a/libc/sysdeps/unix/sysv/linux/ifaddrs.c b/libc/sysdeps/unix/sysv/linux/ifaddrs.c index 02e693553..9aa9abac3 100644 --- a/libc/sysdeps/unix/sysv/linux/ifaddrs.c +++ b/libc/sysdeps/unix/sysv/linux/ifaddrs.c @@ -33,6 +33,7 @@ #include <sysdep.h> #include <time.h> #include <unistd.h> +#include <kernel-features.h> #include "netlinkaccess.h" diff --git a/libc/sysdeps/unix/sysv/linux/init-first.c b/libc/sysdeps/unix/sysv/linux/init-first.c index b061a848c..7b2333d4b 100644 --- a/libc/sysdeps/unix/sysv/linux/init-first.c +++ b/libc/sysdeps/unix/sysv/linux/init-first.c @@ -1,5 +1,5 @@ /* Initialization code run first thing by the ELF startup code. Linux version. - Copyright (C) 1995-2004, 2005 Free Software Foundation, Inc. + Copyright (C) 1995-2004, 2005, 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 @@ -82,6 +82,10 @@ _init (int argc, char **argv, char **envp) _dl_non_dynamic_init (); #endif +#ifdef VDSO_SETUP + VDSO_SETUP (); +#endif + __init_misc (argc, argv, envp); #ifdef USE_NONOPTION_FLAGS diff --git a/libc/sysdeps/unix/sysv/linux/kernel-features.h b/libc/sysdeps/unix/sysv/linux/kernel-features.h index f6bd906f5..aab3df348 100644 --- a/libc/sysdeps/unix/sysv/linux/kernel-features.h +++ b/libc/sysdeps/unix/sysv/linux/kernel-features.h @@ -428,29 +428,37 @@ # define __ASSUME_TMPFS_NAME 1 #endif -/* pselect was introduced just after 2.6.16-rc1. Due to the way the - kernel versions are advertised we can only rely on 2.6.17 to have - the code. */ -#if __LINUX_KERNEL_VERSION >= 0x020611 && !defined __x86_64__ +/* pselect/ppoll were introduced just after 2.6.16-rc1. Due to the way + the kernel versions are advertised we can only rely on 2.6.17 to have + the code. On x86_64 and SH this appeared first in 2.6.19-rc1, + on ia64 in 2.6.22-rc1 and on alpha just after 2.6.22-rc1. */ +#if __LINUX_KERNEL_VERSION >= 0x020611 \ + && ((!defined __x86_64__ && !defined __sh__ && !defined __ia64__ \ + && !defined __alpha__) \ + || (__LINUX_KERNEL_VERSION >= 0x020613 \ + && (defined __x86_64__ || defined __sh__)) \ + || (__LINUX_KERNEL_VERSION >= 0x020616 && defined __ia64__) \ + || (__LINUX_KERNEL_VERSION >= 0x020617 && defined __alpha__)) # define __ASSUME_PSELECT 1 -#endif - -/* ppoll was introduced just after 2.6.16-rc1. Due to the way the - kernel versions are advertised we can only rely on 2.6.17 to have - the code. */ -#if __LINUX_KERNEL_VERSION >= 0x020611 && !defined __x86_64__ -# define __ASSUME_PPOLL 1 +# define __ASSUME_PPOLL 1 #endif /* The *at syscalls were introduced just after 2.6.16-rc1. Due to the way the kernel versions are advertised we can only rely on 2.6.17 to have - the code. */ -#if __LINUX_KERNEL_VERSION >= 0x020611 + the code. On PPC they were introduced in 2.6.17-rc1, on SH in 2.6.19-rc1 + and on Alpha just after 2.6.22-rc1. */ +#if __LINUX_KERNEL_VERSION >= 0x020611 \ + && ((!defined __sh__ && !defined __alpha__) \ + || (__LINUX_KERNEL_VERSION >= 0x020613 && defined __sh__) \ + || (__LINUX_KERNEL_VERSION >= 0x020617 && defined __alpha__)) # define __ASSUME_ATFCTS 1 #endif /* Support for inter-process robust mutexes was added in 2.6.17. */ -#if __LINUX_KERNEL_VERSION >= 0x020611 +#if __LINUX_KERNEL_VERSION >= 0x020611 \ + && ((!defined __sh__ && !defined __alpha__) \ + || (__LINUX_KERNEL_VERSION >= 0x020613 && defined __sh__) \ + || (__LINUX_KERNEL_VERSION >= 0x020617 && defined __alpha__)) # define __ASSUME_SET_ROBUST_LIST 1 #endif @@ -459,8 +467,11 @@ # define __ASSUME_FUTEX_LOCK_PI 1 #endif -/* Support for utimensat syscall was added in 2.6.22. */ -#if __LINUX_KERNEL_VERSION >= 0x020616 +/* Support for utimensat syscall was added in 2.6.22, on alpha and s390 + only after 2.6.22-rc1. */ +#if __LINUX_KERNEL_VERSION >= 0x020616 \ + && ((!defined __sh__ && !defined __alpha__) \ + || __LINUX_KERNEL_VERSION >= 0x020617) # define __ASSUME_UTIMENSAT 1 #endif @@ -468,3 +479,11 @@ #if __LINUX_KERNEL_VERSION >= 0x020616 # define __ASSUME_PRIVATE_FUTEX 1 #endif + +/* Support for fallocate was added in 2.6.23, on s390 + only after 2.6.23-rc1. */ +#if __LINUX_KERNEL_VERSION >= 0x020617 \ + && ((!defined __s390__ && !defined __alpha__) \ + || (__LINUX_KERNEL_VERSION >= 0x020618 && defined __s390__)) +# define __ASSUME_FALLOCATE 1 +#endif diff --git a/libc/sysdeps/unix/sysv/linux/nscd_setup_thread.c b/libc/sysdeps/unix/sysv/linux/nscd_setup_thread.c index 1589c24ea..56e23dc83 100644 --- a/libc/sysdeps/unix/sysv/linux/nscd_setup_thread.c +++ b/libc/sysdeps/unix/sysv/linux/nscd_setup_thread.c @@ -4,8 +4,9 @@ Contributed by Ulrich Drepper <drepper@redhat.com>, 2004. This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as - published by the Free Software Foundation. + it under the terms of the GNU General Public License as published + by the Free Software Foundation; version 2 of the License, or + (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of diff --git a/libc/sysdeps/unix/sysv/linux/posix_fallocate.c b/libc/sysdeps/unix/sysv/linux/posix_fallocate.c new file mode 100644 index 000000000..6944793fa --- /dev/null +++ b/libc/sysdeps/unix/sysv/linux/posix_fallocate.c @@ -0,0 +1,60 @@ +/* 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 <kernel-features.h> +#include <sysdep.h> + +#define posix_fallocate static internal_fallocate +#include <sysdeps/posix/posix_fallocate.c> +#undef posix_fallocate + +#if !defined __ASSUME_FALLOCATE && defined __NR_fallocate +int __have_fallocate attribute_hidden; +#endif + + +/* Reserve storage for the data of the file associated with FD. */ +int +posix_fallocate (int fd, __off_t offset, __off_t len) +{ +#ifdef __NR_fallocate +# ifndef __ASSUME_FALLOCATE + if (__builtin_expect (__have_fallocate >= 0, 1)) +# endif + { + INTERNAL_SYSCALL_DECL (err); + int res = INTERNAL_SYSCALL (fallocate, err, 6, fd, 0, + __LONG_LONG_PAIR (offset >> 31, offset), + __LONG_LONG_PAIR (len >> 31, len)); + + if (! INTERNAL_SYSCALL_ERROR_P (res, err)) + return 0; + +# ifndef __ASSUME_FALLOCATE + if (__builtin_expect (INTERNAL_SYSCALL_ERRNO (res, err) == ENOSYS, 0)) + __have_fallocate = -1; + else +# endif + if (INTERNAL_SYSCALL_ERRNO (res, err) != EOPNOTSUPP) + return INTERNAL_SYSCALL_ERRNO (res, err); + } +#endif + + return internal_fallocate (fd, offset, len); +} diff --git a/libc/sysdeps/unix/sysv/linux/posix_fallocate64.c b/libc/sysdeps/unix/sysv/linux/posix_fallocate64.c new file mode 100644 index 000000000..c5b8a3449 --- /dev/null +++ b/libc/sysdeps/unix/sysv/linux/posix_fallocate64.c @@ -0,0 +1,64 @@ +/* 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 <kernel-features.h> +#include <sysdep.h> + +extern int __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len); +#define __posix_fallocate64_l64 static internal_fallocate64 +#include <sysdeps/posix/posix_fallocate64.c> +#undef __posix_fallocate64_l64 + +#if !defined __ASSUME_FALLOCATE && defined __NR_fallocate +/* Defined in posix_fallocate.c. */ +extern int __have_fallocate attribute_hidden; +#endif + + +/* Reserve storage for the data of the file associated with FD. */ +int +__posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len) +{ +#ifdef __NR_fallocate +# ifndef __ASSUME_FALLOCATE + if (__builtin_expect (__have_fallocate >= 0, 1)) +# endif + { + INTERNAL_SYSCALL_DECL (err); + int res = INTERNAL_SYSCALL (fallocate, err, 6, fd, 0, + __LONG_LONG_PAIR ((long int) (offset >> 32), + (long int) offset), + __LONG_LONG_PAIR ((long int) (len >> 32), + (long int) len)); + + if (! INTERNAL_SYSCALL_ERROR_P (res, err)) + return 0; + +# ifndef __ASSUME_FALLOCATE + if (__builtin_expect (INTERNAL_SYSCALL_ERRNO (res, err) == ENOSYS, 0)) + __have_fallocate = -1; + else +# endif + if (INTERNAL_SYSCALL_ERRNO (res, err) != EOPNOTSUPP) + return INTERNAL_SYSCALL_ERRNO (res, err); + } +#endif + + return internal_fallocate64 (fd, offset, len); +} diff --git a/libc/sysdeps/unix/sysv/linux/powerpc/Makefile b/libc/sysdeps/unix/sysv/linux/powerpc/Makefile index ecd805795..d1281cf46 100644 --- a/libc/sysdeps/unix/sysv/linux/powerpc/Makefile +++ b/libc/sysdeps/unix/sysv/linux/powerpc/Makefile @@ -8,5 +8,5 @@ gen-as-const-headers += ucontext_i.sym endif ifeq ($(subdir),elf) -routines += dl-vdso +sysdep_routines += dl-vdso endif diff --git a/libc/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h b/libc/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h index c4964e0fd..68015dbca 100644 --- a/libc/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux/PowerPC. - Copyright (C) 1995, 1996, 1997, 1998, 2000, 2003, 2004, 2006 + Copyright (C) 1995, 1996, 1997, 1998, 2000, 2003, 2004, 2006, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -50,6 +50,7 @@ # define O_DIRECTORY 040000 /* Must be a directory. */ # define O_NOFOLLOW 0100000 /* Do not follow links. */ # define O_NOATIME 01000000 /* Do not set atime. */ +# define O_CLOEXEC 02000000 /* Set close_on_exec. */ #endif #ifdef __USE_LARGEFILE64 diff --git a/libc/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h b/libc/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h index f20a5a175..746d9ced4 100644 --- a/libc/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h +++ b/libc/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h @@ -23,7 +23,7 @@ #ifdef SHARED -extern void *__vdso_gettimeofday; +extern void *__vdso_gettimeofday attribute_hidden; extern void *__vdso_clock_gettime; diff --git a/libc/sysdeps/unix/sysv/linux/powerpc/init-first.c b/libc/sysdeps/unix/sysv/linux/powerpc/init-first.c new file mode 100644 index 000000000..92dacc761 --- /dev/null +++ b/libc/sysdeps/unix/sysv/linux/powerpc/init-first.c @@ -0,0 +1,49 @@ +/* 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. */ + +#ifdef SHARED +# include <dl-vdso.h> +# undef __gettimeofday +# undef __clock_gettime +# undef __clock_getres +# include <bits/libc-vdso.h> + +void *__vdso_gettimeofday attribute_hidden; +void *__vdso_clock_gettime; +void *__vdso_clock_getres; +void *__vdso_get_tbfreq; + + +static inline void +_libc_vdso_platform_setup (void) +{ + PREPARE_VERSION (linux2615, "LINUX_2.6.15", 123718565); + + __vdso_gettimeofday = _dl_vdso_vsym ("__kernel_gettimeofday", &linux2615); + + __vdso_clock_gettime = _dl_vdso_vsym ("__kernel_clock_gettime", &linux2615); + + __vdso_clock_getres = _dl_vdso_vsym ("__kernel_clock_getres", &linux2615); + + __vdso_get_tbfreq = _dl_vdso_vsym ("__kernel_vdso_get_tbfreq", &linux2615); +} + +# define VDSO_SETUP _libc_vdso_platform_setup +#endif + +#include "../init-first.c" diff --git a/libc/sysdeps/unix/sysv/linux/powerpc/libc-start.c b/libc/sysdeps/unix/sysv/linux/powerpc/libc-start.c index be2480f46..86892aa93 100644 --- a/libc/sysdeps/unix/sysv/linux/powerpc/libc-start.c +++ b/libc/sysdeps/unix/sysv/linux/powerpc/libc-start.c @@ -24,6 +24,7 @@ #include <bp-start.h> #include <bp-sym.h> + int __cache_line_size attribute_hidden; /* The main work is done in the generic function. */ #define LIBC_START_MAIN generic_start_main @@ -41,36 +42,6 @@ struct startup_info void (*fini) (void); }; - -#ifdef SHARED -# include <sys/time.h> -# include <dl-vdso.h> -# undef __gettimeofday -# undef __clock_gettime -# undef __clock_getres -# include <bits/libc-vdso.h> - -void *__vdso_gettimeofday; -void *__vdso_clock_gettime; -void *__vdso_clock_getres; -void *__vdso_get_tbfreq; - -static inline void _libc_vdso_platform_setup (void) - { - __vdso_gettimeofday = _dl_vdso_vsym ("__kernel_gettimeofday", - "LINUX_2.6.15"); - - __vdso_clock_gettime = _dl_vdso_vsym ("__kernel_clock_gettime", - "LINUX_2.6.15"); - - __vdso_clock_getres = _dl_vdso_vsym ("__kernel_clock_getres", - "LINUX_2.6.15"); - - __vdso_get_tbfreq = _dl_vdso_vsym ("__kernel_vdso_get_tbfreq", - "LINUX_2.6.15"); - } -#endif - int /* GKM FIXME: GCC: this should get __BP_ prefix by virtue of the BPs in the arglist of startup_info.main and startup_info.init. */ @@ -130,10 +101,7 @@ int __cache_line_size = av->a_un.a_val; break; } -#ifdef SHARED - /* Resolve and initialize function pointers for VDSO functions. */ - _libc_vdso_platform_setup (); -#endif + return generic_start_main (stinfo->main, argc, ubp_av, auxvec, stinfo->init, stinfo->fini, rtld_fini, stack_on_entry); diff --git a/libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/socket.S b/libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/socket.S index 0bb5bef78..c0e98d9be 100644 --- a/libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/socket.S +++ b/libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/socket.S @@ -1,4 +1,5 @@ -/* Copyright (C) 1995,96,97,99, 2003, 2006 Free Software Foundation, Inc. +/* Copyright (C) 1995-1997, 1999, 2003, 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 @@ -93,7 +94,6 @@ ENTRY(__socket) mflr r9 stw r9,52(r1) cfi_offset (lr, 4) - CGOTSETUP CENABLE stw r3,16(r1) li r3,P(SOCKOP_,socket) @@ -107,7 +107,6 @@ ENTRY(__socket) lwz r4,52(r1) lwz r0,12(r1) lwz r3,8(r1) - CGOTRESTORE mtlr r4 mtcr r0 addi r1,r1,48 diff --git a/libc/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h b/libc/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h index 5d055f67f..23e75fbcf 100644 --- a/libc/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h +++ b/libc/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h @@ -1,5 +1,5 @@ /* `ptrace' debugger support interface. Linux version. - Copyright (C) 2001, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 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 @@ -99,6 +99,28 @@ enum __ptrace_request #define PT_SETSIGINFO PTRACE_SETSIGINFO }; +/* Options set using PTRACE_SETOPTIONS. */ +enum __ptrace_setoptions { + PTRACE_O_TRACESYSGOOD = 0x00000001, + PTRACE_O_TRACEFORK = 0x00000002, + PTRACE_O_TRACEVFORK = 0x00000004, + PTRACE_O_TRACECLONE = 0x00000008, + PTRACE_O_TRACEEXEC = 0x00000010, + PTRACE_O_TRACEVFORKDONE = 0x00000020, + PTRACE_O_TRACEEXIT = 0x00000040, + PTRACE_O_MASK = 0x0000007f +}; + +/* Wait extended result codes for the above trace options. */ +enum __ptrace_eventcodes { + PTRACE_EVENT_FORK = 1, + PTRACE_EVENT_VFORK = 2, + PTRACE_EVENT_CLONE = 3, + PTRACE_EVENT_EXEC = 4, + PTRACE_EVENT_VFORK_DONE = 5, + PTRACE_EVENT_EXIT = 6 +}; + /* Perform process tracing functions. REQUEST is one of the values above, and determines the action to be taken. For all requests except PTRACE_TRACEME, PID specifies the process to be diff --git a/libc/sysdeps/unix/sysv/linux/ppoll.c b/libc/sysdeps/unix/sysv/linux/ppoll.c index cfc86ba80..14eb3111b 100644 --- a/libc/sysdeps/unix/sysv/linux/ppoll.c +++ b/libc/sysdeps/unix/sysv/linux/ppoll.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 Free Software Foundation, Inc. +/* Copyright (C) 2006, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2006. @@ -26,9 +26,11 @@ #ifdef __NR_ppoll +# ifndef __ASSUME_PPOLL static int __generic_ppoll (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, const sigset_t *sigmask); +# endif int diff --git a/libc/sysdeps/unix/sysv/linux/pselect.c b/libc/sysdeps/unix/sysv/linux/pselect.c index 0dd744f52..f39ee920c 100644 --- a/libc/sysdeps/unix/sysv/linux/pselect.c +++ b/libc/sysdeps/unix/sysv/linux/pselect.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2006 Free Software Foundation, Inc. +/* Copyright (C) 2006, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2006. @@ -26,10 +26,12 @@ #ifdef __NR_pselect6 +# ifndef __ASSUME_PSELECT static int __generic_pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timespec *timeout, const sigset_t *sigmask); +# endif int diff --git a/libc/sysdeps/unix/sysv/linux/s390/bits/fcntl.h b/libc/sysdeps/unix/sysv/linux/s390/bits/fcntl.h index c611028f2..848568532 100644 --- a/libc/sysdeps/unix/sysv/linux/s390/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/s390/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux. - Copyright (C) 2000, 2001, 2002, 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2000,2001,2002,2004,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 @@ -50,6 +50,7 @@ # define O_DIRECTORY 0200000 /* Must be a directory. */ # define O_NOFOLLOW 0400000 /* Do not follow links. */ # define O_NOATIME 01000000 /* Do not set atime. */ +# define O_CLOEXEC 02000000 /* Set close_on_exec. */ #endif #ifdef __USE_LARGEFILE64 diff --git a/libc/sysdeps/unix/sysv/linux/s390/dl-procinfo.h b/libc/sysdeps/unix/sysv/linux/s390/dl-procinfo.h new file mode 100644 index 000000000..3eeb52905 --- /dev/null +++ b/libc/sysdeps/unix/sysv/linux/s390/dl-procinfo.h @@ -0,0 +1,43 @@ +/* Linux/s390 version of processor capability information handling macros. + Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2006. + + 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 <sysdeps/s390/dl-procinfo.h> +#include <ldsodefs.h> + + +#undef _dl_procinfo +static inline int +__attribute__ ((unused)) +_dl_procinfo (int word) +{ + /* This table should match the information from arch/s390/kernel/setup.c + in the kernel sources. */ + int i; + + _dl_printf ("AT_HWCAP: "); + + for (i = 0; i < _DL_HWCAP_COUNT; ++i) + if (word & (1UL << i)) + _dl_printf (" %s", GLRO(dl_s390_cap_flags)[i]); + + _dl_printf ("\n"); + + return 0; +} diff --git a/libc/sysdeps/unix/sysv/linux/s390/s390-32/mmap.S b/libc/sysdeps/unix/sysv/linux/s390/s390-32/mmap.S index c0d7cd459..b2db5423c 100644 --- a/libc/sysdeps/unix/sysv/linux/s390/s390-32/mmap.S +++ b/libc/sysdeps/unix/sysv/linux/s390/s390-32/mmap.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2001 Free Software Foundation, Inc. +/* Copyright (C) 2000, 2001, 2007 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU C Library. @@ -18,6 +18,7 @@ 02111-1307 USA. */ #include <sysdep.h> +#include <kernel-features.h> #define EINVAL 22 diff --git a/libc/sysdeps/unix/sysv/linux/s390/s390-32/mmap64.S b/libc/sysdeps/unix/sysv/linux/s390/s390-32/mmap64.S index aba4ac34e..4c3667aaa 100644 --- a/libc/sysdeps/unix/sysv/linux/s390/s390-32/mmap64.S +++ b/libc/sysdeps/unix/sysv/linux/s390/s390-32/mmap64.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2001 Free Software Foundation, Inc. +/* Copyright (C) 2000, 2001, 2007 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU C Library. @@ -18,6 +18,7 @@ 02111-1307 USA. */ #include <sysdep.h> +#include <kernel-features.h> #define EINVAL 22 #define ENOSYS 38 diff --git a/libc/sysdeps/unix/sysv/linux/s390/sys/ptrace.h b/libc/sysdeps/unix/sysv/linux/s390/sys/ptrace.h index 70eb4f822..ac186387f 100644 --- a/libc/sysdeps/unix/sysv/linux/s390/sys/ptrace.h +++ b/libc/sysdeps/unix/sysv/linux/s390/sys/ptrace.h @@ -1,5 +1,5 @@ /* `ptrace' debugger support interface. Linux version. - Copyright (C) 2000, 2006 Free Software Foundation, Inc. + Copyright (C) 2000, 2006, 2007 Free Software Foundation, Inc. Contributed by Denis Joseph Barrow (djbarrow@de.ibm.com). This file is part of the GNU C Library. @@ -138,6 +138,28 @@ enum __ptrace_request #define PT_SETSIGINFO PTRACE_SETSIGINFO }; +/* Options set using PTRACE_SETOPTIONS. */ +enum __ptrace_setoptions { + PTRACE_O_TRACESYSGOOD = 0x00000001, + PTRACE_O_TRACEFORK = 0x00000002, + PTRACE_O_TRACEVFORK = 0x00000004, + PTRACE_O_TRACECLONE = 0x00000008, + PTRACE_O_TRACEEXEC = 0x00000010, + PTRACE_O_TRACEVFORKDONE = 0x00000020, + PTRACE_O_TRACEEXIT = 0x00000040, + PTRACE_O_MASK = 0x0000007f +}; + +/* Wait extended result codes for the above trace options. */ +enum __ptrace_eventcodes { + PTRACE_EVENT_FORK = 1, + PTRACE_EVENT_VFORK = 2, + PTRACE_EVENT_CLONE = 3, + PTRACE_EVENT_EXEC = 4, + PTRACE_EVENT_VFORK_DONE = 5, + PTRACE_EVENT_EXIT = 6 +}; + /* Perform process tracing functions. REQUEST is one of the values above, and determines the action to be taken. For all requests except PTRACE_TRACEME, PID specifies the process to be diff --git a/libc/sysdeps/unix/sysv/linux/sh/bits/fcntl.h b/libc/sysdeps/unix/sysv/linux/sh/bits/fcntl.h index 6de33302e..83ca3c286 100644 --- a/libc/sysdeps/unix/sysv/linux/sh/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/sh/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux. - Copyright (C) 1995, 1996, 1997, 1998, 2000, 2004, 2006 + Copyright (C) 1995, 1996, 1997, 1998, 2000, 2004, 2006, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -50,6 +50,7 @@ # define O_DIRECTORY 0200000 /* Must be a directory. */ # define O_NOFOLLOW 0400000 /* Do not follow links. */ # define O_NOATIME 01000000 /* Do not set atime. */ +# define O_CLOEXEC 02000000 /* Set close_on_exec. */ #endif /* For now Linux has synchronisity options for data and read operations. diff --git a/libc/sysdeps/unix/sysv/linux/sh/clone.S b/libc/sysdeps/unix/sysv/linux/sh/clone.S index 7941c6b3a..f892c475d 100644 --- a/libc/sysdeps/unix/sysv/linux/sh/clone.S +++ b/libc/sysdeps/unix/sysv/linux/sh/clone.S @@ -1,4 +1,4 @@ -/* Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2000, 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 @@ -32,12 +32,12 @@ ENTRY(__clone) /* sanity check arguments. */ tst r4, r4 - bf/s 1f + bt/s 0f tst r5, r5 - bf/s 1f - mov #-EINVAL,r0 + bf 1f +0: bra .Lsyscall_error - nop + mov #-EINVAL,r0 1: /* insert the args onto the new stack */ mov.l r7, @-r5 diff --git a/libc/sysdeps/unix/sysv/linux/shm_open.c b/libc/sysdeps/unix/sysv/linux/shm_open.c index 0d40632e5..92d22cfa7 100644 --- a/libc/sysdeps/unix/sysv/linux/shm_open.c +++ b/libc/sysdeps/unix/sysv/linux/shm_open.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000,2001,2002,2003,2004,2006 Free Software Foundation, Inc. +/* Copyright (C) 2000-2004,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 @@ -46,6 +46,11 @@ static const char defaultdir[] = "/dev/shm/"; __libc_once_define (static, once); +#if defined O_CLOEXEC && !defined __ASSUME_O_CLOEXEC +static bool have_o_cloexec; +#endif + + /* Determine where the shmfs is mounted (if at all). */ static void where_is_shmfs (void) @@ -160,6 +165,10 @@ shm_open (const char *name, int oflag, mode_t mode) __mempcpy (__mempcpy (fname, mountpoint.dir, mountpoint.dirlen), name, namelen + 1); +#ifdef O_CLOEXEC + oflag |= O_CLOEXEC; +#endif + /* And get the file descriptor. XXX Maybe we should test each descriptor whether it really is for a file on the shmfs. If this is what should be done the whole function @@ -168,23 +177,37 @@ shm_open (const char *name, int oflag, mode_t mode) fd = open (fname, oflag | O_NOFOLLOW, mode); if (fd != -1) { - /* We got a descriptor. Now set the FD_CLOEXEC bit. */ - int flags = fcntl (fd, F_GETFD, 0); - - if (__builtin_expect (flags, 0) >= 0) +#if !defined O_CLOEXEC || !defined __ASSUME_O_CLOEXEC +# ifdef O_CLOEXEC + if (have_o_cloexec <= 0) +# endif { - flags |= FD_CLOEXEC; - flags = fcntl (fd, F_SETFD, flags); - } - - if (flags == -1) - { - /* Something went wrong. We cannot return the descriptor. */ - int save_errno = errno; - close (fd); - fd = -1; - __set_errno (save_errno); + /* We got a descriptor. Now set the FD_CLOEXEC bit. */ + int flags = fcntl (fd, F_GETFD, 0); + + if (__builtin_expect (flags, 0) >= 0) + { +# ifdef O_CLOEXEC + if (have_o_cloexec == 0) + have_o_cloexec = (flags & FD_CLOEXEC) == 0 ? -1 : 1; + if (have_o_cloexec < 0) +# endif + { + flags |= FD_CLOEXEC; + flags = fcntl (fd, F_SETFD, flags); + } + } + + if (flags == -1) + { + /* Something went wrong. We cannot return the descriptor. */ + int save_errno = errno; + close (fd); + fd = -1; + __set_errno (save_errno); + } } +#endif } else if (__builtin_expect (errno == EISDIR, 0)) /* It might be better to fold this error with EINVAL since diff --git a/libc/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h b/libc/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h index d68bfeb0e..2307a2353 100644 --- a/libc/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux/SPARC. - Copyright (C) 1995, 1996, 1997, 1998, 2000, 2003, 2004, 2006 + Copyright (C) 1995, 1996, 1997, 1998, 2000, 2003, 2004, 2006, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -49,6 +49,7 @@ # define O_NOFOLLOW 0x20000 /* don't follow links */ # define O_DIRECT 0x100000 /* direct disk access hint */ # define O_NOATIME 0x200000 /* Do not set atime. */ +# define O_CLOEXEC 0x400000 /* Set close_on_exit. */ #endif #ifdef __USE_LARGEFILE64 diff --git a/libc/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S b/libc/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S index f91fc4f62..a64d8e519 100644 --- a/libc/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S +++ b/libc/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997, 1998, 2000, 2003, 2004 +/* Copyright (C) 1996, 1997, 1998, 2000, 2003, 2004, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Richard Henderson (rth@tamu.edu). @@ -41,9 +41,9 @@ ENTRY (__clone) /* sanity check arguments */ orcc %i0,%g0,%g2 - be .Lerror + be .Leinval orcc %i1,%g0,%o1 - be .Lerror + be .Leinval mov %i2,%o0 /* The child_stack is the top of the stack, allocate one @@ -70,9 +70,11 @@ ENTRY (__clone) jmpl %i7 + 8, %g0 restore %o0,%g0,%o0 +.Leinval: + mov EINVAL, %o0 .Lerror: - call __errno_location - or %g0,EINVAL,%i0 + call HIDDEN_JUMPTARGET(__errno_location) + mov %o0, %i0 st %i0,[%o0] jmpl %i7 + 8, %g0 restore %g0,-1,%o0 @@ -99,7 +101,7 @@ __thread_start: mov %g0, %fp /* terminate backtrace */ call %g2 mov %g3,%o0 - call _exit,0 + call HIDDEN_JUMPTARGET(_exit),0 nop cfi_endproc diff --git a/libc/sysdeps/unix/sysv/linux/sparc/sparc64/clone.S b/libc/sysdeps/unix/sysv/linux/sparc/sparc64/clone.S index ebfce9e2c..2bbbd8020 100644 --- a/libc/sysdeps/unix/sysv/linux/sparc/sparc64/clone.S +++ b/libc/sysdeps/unix/sysv/linux/sparc/sparc64/clone.S @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1997, 2000, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Richard Henderson (rth@tamu.edu). @@ -62,33 +62,16 @@ ENTRY (__clone) /* Do the system call */ set __NR_clone, %g1 ta 0x6d - bcs,pn %xcc, 99f + bcs,pn %xcc, 98f nop brnz,pn %o1, __thread_start nop jmpl %i7 + 8, %g0 restore %o0, %g0, %o0 -99: -#ifndef _LIBC_REENTRANT -#ifdef PIC - call 1f - sethi %hi(_GLOBAL_OFFSET_TABLE_-(99b-.)), %l7 -1: or %l7, %lo(_GLOBAL_OFFSET_TABLE_-(99b-.)), %l7 - add %l7, %o7, %l7 - set EINVAL, %i0 - sethi %hi(errno), %g2 - or %g2, %lo(errno), %g2 - st %i0, [%l7+%g2] -#else - sethi %hi(errno), %g2 - set EINVAL, %i0 - st %i0, [%g2+%lo(errno)] -#endif -#else - call __errno_location - nop +99: mov EINVAL, %o0 +98: call HIDDEN_JUMPTARGET(__errno_location) + mov %o0, %i0 st %i0, [%o0] -#endif jmpl %i7 + 8, %g0 restore %g0,-1,%o0 END(__clone) @@ -112,7 +95,7 @@ __thread_start: mov %g0, %fp /* terminate backtrace */ call %g2 mov %g3,%o0 - call _exit,0 + call HIDDEN_JUMPTARGET(_exit),0 nop cfi_endproc diff --git a/libc/sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c b/libc/sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c index 9f4c02c78..71a51ccd8 100644 --- a/libc/sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c +++ b/libc/sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c @@ -1,3 +1,5 @@ +#include <kernel-features.h> + #include "../../i386/xstat.c" #ifdef __NR_stat64 diff --git a/libc/sysdeps/unix/sysv/linux/sparc/sys/ptrace.h b/libc/sysdeps/unix/sysv/linux/sparc/sys/ptrace.h index 17907c4a3..a7b204b33 100644 --- a/libc/sysdeps/unix/sysv/linux/sparc/sys/ptrace.h +++ b/libc/sysdeps/unix/sysv/linux/sparc/sys/ptrace.h @@ -1,5 +1,5 @@ /* `ptrace' debugger support interface. Linux/SPARC version. - Copyright (C) 1996, 1997, 1998, 1999, 2000, 2006 + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2006, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -183,6 +183,28 @@ enum __ptrace_request #define PT_SETSIGINFO PTRACE_SETSIGINFO }; +/* Options set using PTRACE_SETOPTIONS. */ +enum __ptrace_setoptions { + PTRACE_O_TRACESYSGOOD = 0x00000001, + PTRACE_O_TRACEFORK = 0x00000002, + PTRACE_O_TRACEVFORK = 0x00000004, + PTRACE_O_TRACECLONE = 0x00000008, + PTRACE_O_TRACEEXEC = 0x00000010, + PTRACE_O_TRACEVFORKDONE = 0x00000020, + PTRACE_O_TRACEEXIT = 0x00000040, + PTRACE_O_MASK = 0x0000007f +}; + +/* Wait extended result codes for the above trace options. */ +enum __ptrace_eventcodes { + PTRACE_EVENT_FORK = 1, + PTRACE_EVENT_VFORK = 2, + PTRACE_EVENT_CLONE = 3, + PTRACE_EVENT_EXEC = 4, + PTRACE_EVENT_VFORK_DONE = 5, + PTRACE_EVENT_EXIT = 6 +}; + /* Perform process tracing functions. REQUEST is one of the values above, and determines the action to be taken. For all requests except PTRACE_TRACEME, PID specifies the process to be diff --git a/libc/sysdeps/unix/sysv/linux/sparc/sysdep.h b/libc/sysdeps/unix/sysv/linux/sparc/sysdep.h index a60937976..101638a53 100644 --- a/libc/sysdeps/unix/sysv/linux/sparc/sysdep.h +++ b/libc/sysdeps/unix/sysv/linux/sparc/sysdep.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2000, 2002, 2003, 2004, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek <jakub@redhat.com>, 2000. @@ -149,5 +149,8 @@ }) +#ifdef __ASSEMBLER__ +# define JUMPTARGET(sym) sym +#endif #endif /* _LINUX_SPARC_SYSDEP_H */ diff --git a/libc/sysdeps/unix/sysv/linux/statfs64.c b/libc/sysdeps/unix/sysv/linux/statfs64.c index 9ccc7a7d6..c3d17b5ed 100644 --- a/libc/sysdeps/unix/sysv/linux/statfs64.c +++ b/libc/sysdeps/unix/sysv/linux/statfs64.c @@ -1,5 +1,5 @@ /* Return information about the filesystem on which FILE resides. - Copyright (C) 1996-2000,2003,2004 Free Software Foundation, Inc. + Copyright (C) 1996-2000,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 @@ -22,6 +22,7 @@ #include <sys/statfs.h> #include <stddef.h> #include <sysdep.h> +#include <kernel-features.h> # if __ASSUME_STATFS64 == 0 diff --git a/libc/sysdeps/unix/sysv/linux/sys/ptrace.h b/libc/sysdeps/unix/sysv/linux/sys/ptrace.h index 44284cb30..08658f976 100644 --- a/libc/sysdeps/unix/sysv/linux/sys/ptrace.h +++ b/libc/sysdeps/unix/sysv/linux/sys/ptrace.h @@ -1,5 +1,5 @@ /* `ptrace' debugger support interface. Linux version. - Copyright (C) 1996-1999,2000,2006 Free Software Foundation, Inc. + Copyright (C) 1996-1999,2000,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 @@ -129,6 +129,29 @@ enum __ptrace_request #define PT_SETSIGINFO PTRACE_SETSIGINFO }; + +/* Options set using PTRACE_SETOPTIONS. */ +enum __ptrace_setoptions { + PTRACE_O_TRACESYSGOOD = 0x00000001, + PTRACE_O_TRACEFORK = 0x00000002, + PTRACE_O_TRACEVFORK = 0x00000004, + PTRACE_O_TRACECLONE = 0x00000008, + PTRACE_O_TRACEEXEC = 0x00000010, + PTRACE_O_TRACEVFORKDONE = 0x00000020, + PTRACE_O_TRACEEXIT = 0x00000040, + PTRACE_O_MASK = 0x0000007f +}; + +/* Wait extended result codes for the above trace options. */ +enum __ptrace_eventcodes { + PTRACE_EVENT_FORK = 1, + PTRACE_EVENT_VFORK = 2, + PTRACE_EVENT_CLONE = 3, + PTRACE_EVENT_EXEC = 4, + PTRACE_EVENT_VFORK_DONE = 5, + PTRACE_EVENT_EXIT = 6 +}; + /* Perform process tracing functions. REQUEST is one of the values above, and determines the action to be taken. For all requests except PTRACE_TRACEME, PID specifies the process to be diff --git a/libc/sysdeps/unix/sysv/linux/syscalls.list b/libc/sysdeps/unix/sysv/linux/syscalls.list index e16110480..7e5cc7050 100644 --- a/libc/sysdeps/unix/sysv/linux/syscalls.list +++ b/libc/sysdeps/unix/sysv/linux/syscalls.list @@ -43,7 +43,7 @@ munlockall - munlockall i: munlockall nanosleep - nanosleep Ci:pp __libc_nanosleep __nanosleep nanosleep nfsservctl EXTRA nfsservctl i:ipp nfsservctl pause - pause Ci: __libc_pause pause -personality init-first personality i:i __personality personality +personality EXTRA personality i:i __personality personality pipe - pipe i:f __pipe pipe pivot_root EXTRA pivot_root i:ss pivot_root prctl EXTRA prctl i:iiiii __prctl prctl diff --git a/libc/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c b/libc/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c new file mode 100644 index 000000000..151174b47 --- /dev/null +++ b/libc/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c @@ -0,0 +1,59 @@ +/* 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 <kernel-features.h> +#include <sysdep.h> + +#define posix_fallocate static internal_fallocate +#include <sysdeps/posix/posix_fallocate.c> +#undef posix_fallocate + +#if !defined __ASSUME_FALLOCATE && defined __NR_fallocate +static int __have_fallocate; +#endif + + +/* Reserve storage for the data of the file associated with FD. */ +int +posix_fallocate (int fd, __off_t offset, __off_t len) +{ +#ifdef __NR_fallocate +# ifndef __ASSUME_FALLOCATE + if (__builtin_expect (__have_fallocate >= 0, 1)) +# endif + { + INTERNAL_SYSCALL_DECL (err); + int res = INTERNAL_SYSCALL (fallocate, err, 4, fd, 0, offset, len); + + if (! INTERNAL_SYSCALL_ERROR_P (res, err)) + return 0; + +# ifndef __ASSUME_FALLOCATE + if (__builtin_expect (INTERNAL_SYSCALL_ERRNO (res, err) == ENOSYS, 0)) + __have_fallocate = -1; + else +# endif + if (INTERNAL_SYSCALL_ERRNO (res, err) != EOPNOTSUPP) + return INTERNAL_SYSCALL_ERRNO (res, err); + } +#endif + + return internal_fallocate (fd, offset, len); +} +strong_alias (posix_fallocate, posix_fallocate64) diff --git a/libc/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate64.c b/libc/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate64.c new file mode 100644 index 000000000..f466f13e4 --- /dev/null +++ b/libc/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate64.c @@ -0,0 +1 @@ +/* posix_fallocate64 is in posix_fallocate.c */ diff --git a/libc/sysdeps/unix/sysv/linux/x86_64/Makefile b/libc/sysdeps/unix/sysv/linux/x86_64/Makefile index bdad5063d..6e2741a96 100644 --- a/libc/sysdeps/unix/sysv/linux/x86_64/Makefile +++ b/libc/sysdeps/unix/sysv/linux/x86_64/Makefile @@ -13,3 +13,7 @@ endif ifeq ($(subdir),csu) gen-as-const-headers += ucontext_i.sym endif + +ifeq ($(subdir),elf) +sysdep_routines += dl-vdso +endif diff --git a/libc/sysdeps/unix/sysv/linux/x86_64/Versions b/libc/sysdeps/unix/sysv/linux/x86_64/Versions index fd1b3cc29..34c100bfd 100644 --- a/libc/sysdeps/unix/sysv/linux/x86_64/Versions +++ b/libc/sysdeps/unix/sysv/linux/x86_64/Versions @@ -6,4 +6,7 @@ libc { modify_ldt; } + GLIBC_PRIVATE { + __vdso_clock_gettime; + } } diff --git a/libc/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h b/libc/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h index fa1d02bc1..a918a0725 100644 --- a/libc/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux/x86-64. - Copyright (C) 2001, 2002, 2004, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2004, 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 @@ -50,6 +50,7 @@ # define O_DIRECTORY 0200000 /* Must be a directory. */ # define O_NOFOLLOW 0400000 /* Do not follow links. */ # define O_NOATIME 01000000 /* Do not set atime. */ +# define O_CLOEXEC 02000000 /* Set close_on_exec. */ #endif /* For now Linux has synchronisity options for data and read operations. diff --git a/libc/sysdeps/unix/sysv/linux/powerpc/dl-vdso.h b/libc/sysdeps/unix/sysv/linux/x86_64/bits/libc-vdso.h index a7dcb2e5f..6e08d3b20 100644 --- a/libc/sysdeps/unix/sysv/linux/powerpc/dl-vdso.h +++ b/libc/sysdeps/unix/sysv/linux/x86_64/bits/libc-vdso.h @@ -1,5 +1,5 @@ -/* ELF symbol resolve functions for VDSO objects. - Copyright (C) 2005 Free Software Foundation, Inc. +/* Resolve function pointers to VDSO functions. + Copyright (C) 2005, 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 @@ -17,11 +17,19 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef _DL_VDSO_H -#define _DL_VDSO_H 1 +#ifndef _LIBC_VDSO_H +#define _LIBC_VDSO_H -/* Functions for resolving symbols in the VDSO link map. */ -extern void *_dl_vdso_vsym (const char *name, const char *version) - internal_function attribute_hidden; +#include <time.h> +#include <sys/time.h> -#endif /* dl-vdso.h */ +#ifdef SHARED + +extern int (*__vdso_gettimeofday) (struct timeval *, void *) + attribute_hidden; + +extern int (*__vdso_clock_gettime) (clockid_t, struct timespec *); + +#endif + +#endif /* _LIBC_VDSO_H */ diff --git a/libc/sysdeps/unix/sysv/linux/x86_64/gettimeofday.S b/libc/sysdeps/unix/sysv/linux/x86_64/gettimeofday.S index 84a99b040..f618e738b 100644 --- a/libc/sysdeps/unix/sysv/linux/x86_64/gettimeofday.S +++ b/libc/sysdeps/unix/sysv/linux/x86_64/gettimeofday.S @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 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 @@ -28,7 +28,12 @@ ENTRY (__gettimeofday) /* Align stack. */ sub $0x8, %rsp cfi_adjust_cfa_offset(8) +#ifdef SHARED + movq __vdso_gettimeofday(%rip), %rax + PTR_DEMANGLE (%rax) +#else movq $VSYSCALL_ADDR_vgettimeofday, %rax +#endif callq *%rax /* Check error return. */ cmpl $-4095, %eax diff --git a/libc/sysdeps/unix/sysv/linux/x86_64/init-first.c b/libc/sysdeps/unix/sysv/linux/x86_64/init-first.c new file mode 100644 index 000000000..e9cf5646b --- /dev/null +++ b/libc/sysdeps/unix/sysv/linux/x86_64/init-first.c @@ -0,0 +1,51 @@ +/* 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. */ + +#ifdef SHARED +# include <dl-vdso.h> +# include <bits/libc-vdso.h> + +int (*__vdso_gettimeofday) (struct timeval *, void *) attribute_hidden; + +int (*__vdso_clock_gettime) (clockid_t, struct timespec *) + __attribute__ ((nocommon)); +strong_alias (__vdso_clock_gettime, __GI___vdso_clock_gettime attribute_hidden) + + +static inline void +_libc_vdso_platform_setup (void) +{ + PREPARE_VERSION (linux26, "LINUX_2.6", 61765110); + + void *p = _dl_vdso_vsym ("gettimeofday", &linux26); + /* If the vDSO is not available we fall back on the old vsyscall. */ +#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000ul + if (p == NULL) + p = (void *) VSYSCALL_ADDR_vgettimeofday; + PTR_MANGLE (p); + __vdso_gettimeofday = p; + + p = _dl_vdso_vsym ("clock_gettime", &linux26); + PTR_MANGLE (p); + __GI___vdso_clock_gettime = p; +} + +# define VDSO_SETUP _libc_vdso_platform_setup +#endif + +#include "../init-first.c" diff --git a/libc/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S b/libc/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S index 8d74d53a7..a95099062 100644 --- a/libc/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S +++ b/libc/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S @@ -38,7 +38,7 @@ ENTRY (sched_getcpu) movq $VSYSCALL_ADDR_vgetcpu, %rax callq *%rax - cmpq $-4095, %rdi + cmpq $-4095, %rax jae SYSCALL_ERROR_LABEL movl (%rsp), %eax diff --git a/libc/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/libc/sysdeps/unix/sysv/linux/x86_64/sysdep.h index 1d9a68a04..44d565054 100644 --- a/libc/sysdeps/unix/sysv/linux/x86_64/sysdep.h +++ b/libc/sysdeps/unix/sysv/linux/x86_64/sysdep.h @@ -68,14 +68,14 @@ /* We don't want the label for the error handle to be global when we define it here. */ -#ifdef PIC -# define SYSCALL_ERROR_LABEL 0f -#else -# define SYSCALL_ERROR_LABEL syscall_error -#endif +# ifdef PIC +# define SYSCALL_ERROR_LABEL 0f +# else +# define SYSCALL_ERROR_LABEL syscall_error +# endif -#undef PSEUDO -#define PSEUDO(name, syscall_name, args) \ +# undef PSEUDO +# define PSEUDO(name, syscall_name, args) \ .text; \ ENTRY (name) \ DO_CALL (syscall_name, args); \ @@ -83,40 +83,40 @@ jae SYSCALL_ERROR_LABEL; \ L(pseudo_end): -#undef PSEUDO_END -#define PSEUDO_END(name) \ +# undef PSEUDO_END +# define PSEUDO_END(name) \ SYSCALL_ERROR_HANDLER \ END (name) -#undef PSEUDO_NOERRNO -#define PSEUDO_NOERRNO(name, syscall_name, args) \ +# undef PSEUDO_NOERRNO +# define PSEUDO_NOERRNO(name, syscall_name, args) \ .text; \ ENTRY (name) \ DO_CALL (syscall_name, args) -#undef PSEUDO_END_NOERRNO -#define PSEUDO_END_NOERRNO(name) \ +# undef PSEUDO_END_NOERRNO +# define PSEUDO_END_NOERRNO(name) \ END (name) -#define ret_NOERRNO ret +# define ret_NOERRNO ret -#undef PSEUDO_ERRVAL -#define PSEUDO_ERRVAL(name, syscall_name, args) \ +# undef PSEUDO_ERRVAL +# define PSEUDO_ERRVAL(name, syscall_name, args) \ .text; \ ENTRY (name) \ DO_CALL (syscall_name, args); \ negq %rax -#undef PSEUDO_END_ERRVAL -#define PSEUDO_END_ERRVAL(name) \ +# undef PSEUDO_END_ERRVAL +# define PSEUDO_END_ERRVAL(name) \ END (name) -#define ret_ERRVAL ret +# define ret_ERRVAL ret -#ifndef PIC -#define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */ -#elif RTLD_PRIVATE_ERRNO -# define SYSCALL_ERROR_HANDLER \ +# ifndef PIC +# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */ +# elif RTLD_PRIVATE_ERRNO +# define SYSCALL_ERROR_HANDLER \ 0: \ leaq rtld_errno(%rip), %rcx; \ xorl %edx, %edx; \ @@ -124,13 +124,13 @@ movl %edx, (%rcx); \ orq $-1, %rax; \ jmp L(pseudo_end); -#elif USE___THREAD -# ifndef NOT_IN_libc -# define SYSCALL_ERROR_ERRNO __libc_errno -# else -# define SYSCALL_ERROR_ERRNO errno -# endif -# define SYSCALL_ERROR_HANDLER \ +# elif USE___THREAD +# ifndef NOT_IN_libc +# define SYSCALL_ERROR_ERRNO __libc_errno +# else +# define SYSCALL_ERROR_ERRNO errno +# endif +# define SYSCALL_ERROR_HANDLER \ 0: \ movq SYSCALL_ERROR_ERRNO@GOTTPOFF(%rip), %rcx;\ xorl %edx, %edx; \ @@ -138,10 +138,10 @@ movl %edx, %fs:(%rcx); \ orq $-1, %rax; \ jmp L(pseudo_end); -#elif defined _LIBC_REENTRANT +# elif defined _LIBC_REENTRANT /* Store (- %rax) into errno through the GOT. Note that errno occupies only 4 bytes. */ -# define SYSCALL_ERROR_HANDLER \ +# define SYSCALL_ERROR_HANDLER \ 0: \ xorl %edx, %edx; \ subq %rax, %rdx; \ @@ -158,15 +158,15 @@ /* A quick note: it is assumed that the call to `__errno_location' does not modify the stack! */ -#else /* Not _LIBC_REENTRANT. */ -# define SYSCALL_ERROR_HANDLER \ +# else /* Not _LIBC_REENTRANT. */ +# define SYSCALL_ERROR_HANDLER \ 0:movq errno@GOTPCREL(%RIP), %rcx; \ xorl %edx, %edx; \ subq %rax, %rdx; \ movl %edx, (%rcx); \ orq $-1, %rax; \ jmp L(pseudo_end); -#endif /* PIC */ +# endif /* PIC */ /* The Linux/x86-64 kernel expects the system call parameters in registers according to the following table: @@ -204,25 +204,25 @@ Syscalls of more than 6 arguments are not supported. */ -#undef DO_CALL -#define DO_CALL(syscall_name, args) \ +# undef DO_CALL +# define DO_CALL(syscall_name, args) \ DOARGS_##args \ movl $SYS_ify (syscall_name), %eax; \ syscall; -#define DOARGS_0 /* nothing */ -#define DOARGS_1 /* nothing */ -#define DOARGS_2 /* nothing */ -#define DOARGS_3 /* nothing */ -#define DOARGS_4 movq %rcx, %r10; -#define DOARGS_5 DOARGS_4 -#define DOARGS_6 DOARGS_5 +# define DOARGS_0 /* nothing */ +# define DOARGS_1 /* nothing */ +# define DOARGS_2 /* nothing */ +# define DOARGS_3 /* nothing */ +# define DOARGS_4 movq %rcx, %r10; +# define DOARGS_5 DOARGS_4 +# define DOARGS_6 DOARGS_5 #else /* !__ASSEMBLER__ */ /* Define a macro which expands inline into the wrapper code for a system call. */ -#undef INLINE_SYSCALL -#define INLINE_SYSCALL(name, nr, args...) \ +# undef INLINE_SYSCALL +# define INLINE_SYSCALL(name, nr, args...) \ ({ \ unsigned long resultvar = INTERNAL_SYSCALL (name, , nr, args); \ if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \ @@ -232,10 +232,10 @@ } \ (long) resultvar; }) -#undef INTERNAL_SYSCALL_DECL -#define INTERNAL_SYSCALL_DECL(err) do { } while (0) +# undef INTERNAL_SYSCALL_DECL +# define INTERNAL_SYSCALL_DECL(err) do { } while (0) -#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \ +# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \ ({ \ unsigned long resultvar; \ LOAD_ARGS_##nr (args) \ @@ -245,68 +245,126 @@ : "=a" (resultvar) \ : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx"); \ (long) resultvar; }) -#undef INTERNAL_SYSCALL -#define INTERNAL_SYSCALL(name, err, nr, args...) \ +# undef INTERNAL_SYSCALL +# define INTERNAL_SYSCALL(name, err, nr, args...) \ INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args) -#undef INTERNAL_SYSCALL_ERROR_P -#define INTERNAL_SYSCALL_ERROR_P(val, err) \ +# undef INTERNAL_SYSCALL_ERROR_P +# define INTERNAL_SYSCALL_ERROR_P(val, err) \ ((unsigned long) (val) >= -4095L) -#undef INTERNAL_SYSCALL_ERRNO -#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val)) +# undef INTERNAL_SYSCALL_ERRNO +# define INTERNAL_SYSCALL_ERRNO(val, err) (-(val)) + +# ifdef SHARED +# define INLINE_VSYSCALL(name, nr, args...) \ + ({ \ + __label__ out; \ + __label__ iserr; \ + INTERNAL_SYSCALL_DECL (sc_err); \ + long int sc_ret; \ + \ + __typeof (__vdso_##name) vdsop = __vdso_##name; \ + PTR_DEMANGLE (vdsop); \ + if (vdsop != NULL) \ + { \ + sc_ret = vdsop (args); \ + if (!INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \ + goto out; \ + if (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err) != ENOSYS) \ + goto iserr; \ + } \ + \ + sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, ##args); \ + if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \ + { \ + iserr: \ + __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)); \ + sc_ret = -1L; \ + } \ + out: \ + sc_ret; \ + }) +# define INTERNAL_VSYSCALL(name, err, nr, args...) \ + ({ \ + __label__ out; \ + long int v_ret; \ + \ + __typeof (__vdso_##name) vdsop = __vdso_##name; \ + PTR_DEMANGLE (vdsop); \ + if (vdsop != NULL) \ + { \ + v_ret = vdsop (args); \ + if (!INTERNAL_SYSCALL_ERROR_P (v_ret, err) \ + || INTERNAL_SYSCALL_ERRNO (v_ret, err) != ENOSYS) \ + goto out; \ + } \ + v_ret = INTERNAL_SYSCALL (name, err, nr, ##args); \ + out: \ + v_ret; \ + }) + +/* List of system calls which are supported as vsyscalls. */ +# define HAVE_CLOCK_GETTIME_VSYSCALL 1 + +# else +# define INLINE_VSYSCALL(name, nr, args...) \ + INLINE_SYSCALL (name, nr, ##args) +# define INTERNAL_VSYSCALL(name, err, nr, args...) \ + INTERNAL_SYSCALL (name, err, nr, ##args) +# endif -#define LOAD_ARGS_0() -#define LOAD_REGS_0 -#define ASM_ARGS_0 +# define LOAD_ARGS_0() +# define LOAD_REGS_0 +# define ASM_ARGS_0 -#define LOAD_ARGS_1(a1) \ +# define LOAD_ARGS_1(a1) \ long int __arg1 = (long) (a1); \ LOAD_ARGS_0 () -#define LOAD_REGS_1 \ +# define LOAD_REGS_1 \ register long int _a1 asm ("rdi") = __arg1; \ LOAD_REGS_0 -#define ASM_ARGS_1 ASM_ARGS_0, "r" (_a1) +# define ASM_ARGS_1 ASM_ARGS_0, "r" (_a1) -#define LOAD_ARGS_2(a1, a2) \ +# define LOAD_ARGS_2(a1, a2) \ long int __arg2 = (long) (a2); \ LOAD_ARGS_1 (a1) -#define LOAD_REGS_2 \ +# define LOAD_REGS_2 \ register long int _a2 asm ("rsi") = __arg2; \ LOAD_REGS_1 -#define ASM_ARGS_2 ASM_ARGS_1, "r" (_a2) +# define ASM_ARGS_2 ASM_ARGS_1, "r" (_a2) -#define LOAD_ARGS_3(a1, a2, a3) \ +# define LOAD_ARGS_3(a1, a2, a3) \ long int __arg3 = (long) (a3); \ LOAD_ARGS_2 (a1, a2) -#define LOAD_REGS_3 \ +# define LOAD_REGS_3 \ register long int _a3 asm ("rdx") = __arg3; \ LOAD_REGS_2 -#define ASM_ARGS_3 ASM_ARGS_2, "r" (_a3) +# define ASM_ARGS_3 ASM_ARGS_2, "r" (_a3) -#define LOAD_ARGS_4(a1, a2, a3, a4) \ +# define LOAD_ARGS_4(a1, a2, a3, a4) \ long int __arg4 = (long) (a4); \ LOAD_ARGS_3 (a1, a2, a3) -#define LOAD_REGS_4 \ +# define LOAD_REGS_4 \ register long int _a4 asm ("r10") = __arg4; \ LOAD_REGS_3 -#define ASM_ARGS_4 ASM_ARGS_3, "r" (_a4) +# define ASM_ARGS_4 ASM_ARGS_3, "r" (_a4) -#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \ +# define LOAD_ARGS_5(a1, a2, a3, a4, a5) \ long int __arg5 = (long) (a5); \ LOAD_ARGS_4 (a1, a2, a3, a4) -#define LOAD_REGS_5 \ +# define LOAD_REGS_5 \ register long int _a5 asm ("r8") = __arg5; \ LOAD_REGS_4 -#define ASM_ARGS_5 ASM_ARGS_4, "r" (_a5) +# define ASM_ARGS_5 ASM_ARGS_4, "r" (_a5) -#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \ +# define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \ long int __arg6 = (long) (a6); \ LOAD_ARGS_5 (a1, a2, a3, a4, a5) -#define LOAD_REGS_6 \ +# define LOAD_REGS_6 \ register long int _a6 asm ("r9") = __arg6; \ LOAD_REGS_5 -#define ASM_ARGS_6 ASM_ARGS_5, "r" (_a6) +# define ASM_ARGS_6 ASM_ARGS_5, "r" (_a6) #endif /* __ASSEMBLER__ */ diff --git a/libc/sysdeps/unix/sysv/linux/xstatconv.c b/libc/sysdeps/unix/sysv/linux/xstatconv.c index 805e33978..8210798a6 100644 --- a/libc/sysdeps/unix/sysv/linux/xstatconv.c +++ b/libc/sysdeps/unix/sysv/linux/xstatconv.c @@ -1,5 +1,6 @@ /* Convert between the kernel's `struct stat' format, and libc's. - Copyright (C) 1991,1995-1997,2000,2002,2003 Free Software Foundation, Inc. + Copyright (C) 1991,1995-1997,2000,2002,2003,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 @@ -20,6 +21,7 @@ #include <errno.h> #include <sys/stat.h> #include <kernel_stat.h> +#include <kernel-features.h> #ifdef STAT_IS_KERNEL_STAT |