summaryrefslogtreecommitdiff
path: root/libc/sysdeps/unix
diff options
context:
space:
mode:
authorjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2011-05-18 14:30:49 +0000
committerjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2011-05-18 14:30:49 +0000
commite9d94bb485578797a67a3ef6dae7ac9e3635e963 (patch)
tree04991ea2da24b7448dcdddda044c36e1ac9d5189 /libc/sysdeps/unix
parentbc5b8c65ef17547cbab9141d66798bbb3cae9c2a (diff)
Merge changes between r13831 and r13882 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@13883 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/sysdeps/unix')
-rw-r--r--libc/sysdeps/unix/sysv/linux/dl-osinfo.h48
-rw-r--r--libc/sysdeps/unix/sysv/linux/ia64/sysconf.c20
-rw-r--r--libc/sysdeps/unix/sysv/linux/kernel-features.h3
-rw-r--r--libc/sysdeps/unix/sysv/linux/sysconf.c50
-rw-r--r--libc/sysdeps/unix/sysv/linux/x86_64/sys/user.h86
5 files changed, 110 insertions, 97 deletions
diff --git a/libc/sysdeps/unix/sysv/linux/dl-osinfo.h b/libc/sysdeps/unix/sysv/linux/dl-osinfo.h
index df07869bc..eb7fedc07 100644
--- a/libc/sysdeps/unix/sysv/linux/dl-osinfo.h
+++ b/libc/sysdeps/unix/sysv/linux/dl-osinfo.h
@@ -1,5 +1,5 @@
/* Operating system specific code for generic dynamic loader functions. Linux.
- Copyright (C) 2000-2002,2004-2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2000-2002,2004-2009,2011 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,8 +19,10 @@
#include <kernel-features.h>
#include <dl-sysdep.h>
+#include <endian.h>
#include <fcntl.h>
#include <stdint.h>
+#include <not-cancel.h>
#ifndef MIN
# define MIN(a,b) (((a)<(b))?(a):(b))
@@ -62,32 +64,46 @@ dl_fatal (const char *str)
static inline uintptr_t __attribute__ ((always_inline))
_dl_setup_stack_chk_guard (void *dl_random)
{
- uintptr_t ret;
+ union
+ {
+ uintptr_t num;
+ unsigned char bytes[sizeof (uintptr_t)];
+ } ret;
+
#ifndef __ASSUME_AT_RANDOM
if (__builtin_expect (dl_random == NULL, 0))
{
+ const size_t filllen = sizeof (ret.bytes) - 1;
+ ret.num = 0;
# ifdef ENABLE_STACKGUARD_RANDOMIZE
- int fd = __open ("/dev/urandom", O_RDONLY);
+ int fd = open_not_cancel_2 ("/dev/urandom", O_RDONLY);
if (fd >= 0)
{
- ssize_t reslen = __read (fd, &ret, sizeof (ret));
- __close (fd);
- if (reslen == (ssize_t) sizeof (ret))
- return ret;
+ ssize_t reslen = read_not_cancel (fd, ret.bytes + 1, filllen);
+ close_not_cancel_no_status (fd);
+ if (reslen == (ssize_) filllen)
+ return ret.num;
}
# endif
- ret = 0;
- unsigned char *p = (unsigned char *) &ret;
- p[sizeof (ret) - 1] = 255;
- p[sizeof (ret) - 2] = '\n';
+ ret.bytes[filllen - 2] = 255;
+ ret.bytes[filllen - 3] = '\n';
}
else
#endif
- /* We need in the moment only 8 bytes on 32-bit platforms and 16
- bytes on 64-bit platforms. Therefore we can use the data
- directly and not use the kernel-provided data to seed a PRNG. */
- memcpy (&ret, dl_random, sizeof (ret));
- return ret;
+ {
+ /* We need in the moment only 8 bytes on 32-bit platforms and 16
+ bytes on 64-bit platforms. Therefore we can use the data
+ directly and not use the kernel-provided data to seed a PRNG. */
+ memcpy (ret.bytes, dl_random, sizeof (ret));
+#if BYTE_ORDER == LITTLE_ENDIAN
+ ret.num &= ~0xff;
+#elif BYTE_ORDER == BIG_ENDIAN
+ ret.num &= ~(0xff << (8 * (sizeof (ret) - 1)));
+#else
+# error "BYTE_ORDER unknown"
+#endif
+ }
+ return ret.num;
}
static inline uintptr_t __attribute__ ((always_inline))
diff --git a/libc/sysdeps/unix/sysv/linux/ia64/sysconf.c b/libc/sysdeps/unix/sysv/linux/ia64/sysconf.c
index 4b5d1ce2c..67b8251dd 100644
--- a/libc/sysdeps/unix/sysv/linux/ia64/sysconf.c
+++ b/libc/sysdeps/unix/sysv/linux/ia64/sysconf.c
@@ -1,5 +1,5 @@
-/* Get file-specific information about a file. Linux version.
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Get file-specific information about a file. Linux/ia64 version.
+ Copyright (C) 2003, 2004, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -24,22 +24,8 @@
#include "has_cpuclock.c"
+#define HAS_CPUCLOCK() (has_cpuclock () ? _POSIX_VERSION : -1)
-static long int linux_sysconf (int name);
-
-
-/* Get the value of the system variable NAME. */
-long int
-__sysconf (int name)
-{
- if (name == _SC_CPUTIME || name == _SC_THREAD_CPUTIME)
- return has_cpuclock () ? 200112L : -1;
-
- /* Everything else is handled by the more general code. */
- return linux_sysconf (name);
-}
/* Now the generic Linux version. */
-#undef __sysconf
-#define __sysconf static linux_sysconf
#include "../sysconf.c"
diff --git a/libc/sysdeps/unix/sysv/linux/kernel-features.h b/libc/sysdeps/unix/sysv/linux/kernel-features.h
index c220dca94..d78f1015d 100644
--- a/libc/sysdeps/unix/sysv/linux/kernel-features.h
+++ b/libc/sysdeps/unix/sysv/linux/kernel-features.h
@@ -1,6 +1,6 @@
/* Set flags signalling availability of kernel features based on given
kernel version number.
- Copyright (C) 1999-2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 1999-2009, 2010, 2011 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
@@ -496,6 +496,7 @@
# define __ASSUME_PIPE2 1
# define __ASSUME_EVENTFD2 1
# define __ASSUME_SIGNALFD4 1
+# define __ASSUME_DUP3 1
#endif
/* Support for the accept4 syscall was added in 2.6.28. */
diff --git a/libc/sysdeps/unix/sysv/linux/sysconf.c b/libc/sysdeps/unix/sysv/linux/sysconf.c
index 50c5528dd..e44aa994e 100644
--- a/libc/sysdeps/unix/sysv/linux/sysconf.c
+++ b/libc/sysdeps/unix/sysv/linux/sysconf.c
@@ -1,5 +1,5 @@
/* Get file-specific information about a file. Linux version.
- Copyright (C) 2003, 2004, 2006, 2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2003,2004,2006 2008,2009,2011 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
@@ -35,6 +35,34 @@
static long int posix_sysconf (int name);
+#ifndef HAS_CPUCLOCK
+static long int
+has_cpuclock (void)
+{
+# if defined __NR_clock_getres || HP_TIMING_AVAIL
+ /* If we have HP_TIMING, we will fall back on that if the system
+ call does not work, so we support it either way. */
+# if !HP_TIMING_AVAIL
+ /* Check using the clock_getres system call. */
+ struct timespec ts;
+ INTERNAL_SYSCALL_DECL (err);
+ int r = INTERNAL_SYSCALL (clock_getres, err, 2,
+ (name == _SC_CPUTIME
+ ? CLOCK_PROCESS_CPUTIME_ID
+ : CLOCK_THREAD_CPUTIME_ID),
+ &ts);
+ if (INTERNAL_SYSCALL_ERROR_P (r, err))
+ return -1;
+# endif
+ return _POSIX_VERSION;
+# else
+ return -1;
+# endif
+}
+# define HAS_CPUCLOCK() has_cpuclock ()
+#endif
+
+
/* Get the value of the system variable NAME. */
long int
__sysconf (int name)
@@ -56,27 +84,9 @@ __sysconf (int name)
}
#endif
-#if defined __NR_clock_getres || HP_TIMING_AVAIL
case _SC_CPUTIME:
case _SC_THREAD_CPUTIME:
- {
- /* If we have HP_TIMING, we will fall back on that if the system
- call does not work, so we support it either way. */
-# if !HP_TIMING_AVAIL
- /* Check using the clock_getres system call. */
- struct timespec ts;
- INTERNAL_SYSCALL_DECL (err);
- int r = INTERNAL_SYSCALL (clock_getres, err, 2,
- (name == _SC_CPUTIME
- ? CLOCK_PROCESS_CPUTIME_ID
- : CLOCK_THREAD_CPUTIME_ID),
- &ts);
- if (INTERNAL_SYSCALL_ERROR_P (r, err))
- return -1;
-# endif
- return _POSIX_VERSION;
- }
-#endif
+ return HAS_CPUCLOCK ();
case _SC_ARG_MAX:
#if __LINUX_KERNEL_VERSION < 0x020617
diff --git a/libc/sysdeps/unix/sysv/linux/x86_64/sys/user.h b/libc/sysdeps/unix/sysv/linux/x86_64/sys/user.h
index ceadcf478..c54cca80a 100644
--- a/libc/sysdeps/unix/sysv/linux/x86_64/sys/user.h
+++ b/libc/sysdeps/unix/sysv/linux/x86_64/sys/user.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2002, 2004, 2011 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
@@ -29,48 +29,48 @@
struct user_fpregs_struct
{
- __uint16_t cwd;
- __uint16_t swd;
- __uint16_t ftw;
- __uint16_t fop;
- __uint64_t rip;
- __uint64_t rdp;
- __uint32_t mxcsr;
- __uint32_t mxcr_mask;
- __uint32_t st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
- __uint32_t xmm_space[64]; /* 16*16 bytes for each XMM-reg = 256 bytes */
- __uint32_t padding[24];
+ unsigned short int cwd;
+ unsigned short int swd;
+ unsigned short int ftw;
+ unsigned short int fop;
+ unsigned long int rip;
+ unsigned long int rdp;
+ unsigned int mxcsr;
+ unsigned int mxcr_mask;
+ unsigned int st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
+ unsigned int xmm_space[64]; /* 16*16 bytes for each XMM-reg = 256 bytes */
+ unsigned int padding[24];
};
struct user_regs_struct
{
- unsigned long r15;
- unsigned long r14;
- unsigned long r13;
- unsigned long r12;
- unsigned long rbp;
- unsigned long rbx;
- unsigned long r11;
- unsigned long r10;
- unsigned long r9;
- unsigned long r8;
- unsigned long rax;
- unsigned long rcx;
- unsigned long rdx;
- unsigned long rsi;
- unsigned long rdi;
- unsigned long orig_rax;
- unsigned long rip;
- unsigned long cs;
- unsigned long eflags;
- unsigned long rsp;
- unsigned long ss;
- unsigned long fs_base;
- unsigned long gs_base;
- unsigned long ds;
- unsigned long es;
- unsigned long fs;
- unsigned long gs;
+ unsigned long int r15;
+ unsigned long int r14;
+ unsigned long int r13;
+ unsigned long int r12;
+ unsigned long int rbp;
+ unsigned long int rbx;
+ unsigned long int r11;
+ unsigned long int r10;
+ unsigned long int r9;
+ unsigned long int r8;
+ unsigned long int rax;
+ unsigned long int rcx;
+ unsigned long int rdx;
+ unsigned long int rsi;
+ unsigned long int rdi;
+ unsigned long int orig_rax;
+ unsigned long int rip;
+ unsigned long int intcs;
+ unsigned long int eflags;
+ unsigned long int rsp;
+ unsigned long int ss;
+ unsigned long int fs_base;
+ unsigned long int gs_base;
+ unsigned long int ds;
+ unsigned long int es;
+ unsigned long int fs;
+ unsigned long int gs;
};
struct user
@@ -81,8 +81,8 @@ struct user
unsigned long int u_tsize;
unsigned long int u_dsize;
unsigned long int u_ssize;
- unsigned long start_code;
- unsigned long start_stack;
+ unsigned long int start_code;
+ unsigned long int start_stack;
long int signal;
int reserved;
struct user_regs_struct* u_ar0;
@@ -152,8 +152,8 @@ struct user
unsigned long int u_tsize;
unsigned long int u_dsize;
unsigned long int u_ssize;
- unsigned long start_code;
- unsigned long start_stack;
+ unsigned long int start_code;
+ unsigned long int start_stack;
long int signal;
int reserved;
struct user_regs_struct* u_ar0;