summaryrefslogtreecommitdiff
path: root/libc/sysdeps
diff options
context:
space:
mode:
authorjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2007-09-12 16:26:54 +0000
committerjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2007-09-12 16:26:54 +0000
commit83584a7af898dd93c48600fe850d150c51b10899 (patch)
tree0affa8ffee374ab83e40501d8d8967a03569c44d /libc/sysdeps
parent04b4d23592609edcd19fd5a461bbe6d3cc677b5b (diff)
downloadeglibc2-83584a7af898dd93c48600fe850d150c51b10899.tar.gz
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')
-rw-r--r--libc/sysdeps/generic/_G_config.h20
-rw-r--r--libc/sysdeps/generic/inttypes.h65
-rw-r--r--libc/sysdeps/generic/ldconfig.h21
-rw-r--r--libc/sysdeps/generic/ldsodefs.h40
-rw-r--r--libc/sysdeps/generic/unwind-dw2-fde-glibc.c7
-rw-r--r--libc/sysdeps/generic/unwind-dw2-fde.c15
-rw-r--r--libc/sysdeps/generic/unwind-dw2.c22
-rw-r--r--libc/sysdeps/gnu/_G_config.h20
-rw-r--r--libc/sysdeps/i386/dl-trampoline.S19
-rw-r--r--libc/sysdeps/i386/ldbl2mpn.c13
-rw-r--r--libc/sysdeps/ia64/ldbl2mpn.c1
-rw-r--r--libc/sysdeps/ia64/sched_cpucount.c (renamed from libc/sysdeps/unix/sysv/linux/powerpc/dl-vdso.h)12
-rw-r--r--libc/sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c75
-rw-r--r--libc/sysdeps/ieee754/ldbl-128ibm/s_fpclassifyl.c37
-rw-r--r--libc/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c97
-rw-r--r--libc/sysdeps/ieee754/ldbl-128ibm/strtold_l.c11
-rw-r--r--libc/sysdeps/ieee754/ldbl-64-128/strtold_l.c11
-rw-r--r--libc/sysdeps/ieee754/ldbl-96/s_roundl.c4
-rw-r--r--libc/sysdeps/mach/hurd/_G_config.h20
-rw-r--r--libc/sysdeps/mach/hurd/bits/fcntl.h4
-rw-r--r--libc/sysdeps/mach/hurd/bits/ioctls.h18
-rw-r--r--libc/sysdeps/mach/hurd/i386/tls.h6
-rw-r--r--libc/sysdeps/mach/hurd/sigaction.c6
-rw-r--r--libc/sysdeps/mach/hurd/sigsuspend.c5
-rw-r--r--libc/sysdeps/mach/hurd/tls.h4
-rw-r--r--libc/sysdeps/mach/i386/sysdep.h8
-rw-r--r--libc/sysdeps/posix/posix_fallocate64.c3
-rw-r--r--libc/sysdeps/posix/tempname.c18
-rw-r--r--libc/sysdeps/powerpc/powerpc32/power4/memcmp.S1
-rw-r--r--libc/sysdeps/powerpc/powerpc32/power4/memcpy.S1
-rw-r--r--libc/sysdeps/powerpc/powerpc32/power4/memset.S1
-rw-r--r--libc/sysdeps/powerpc/powerpc32/power6/fpu/s_llrint.S1
-rw-r--r--libc/sysdeps/powerpc/powerpc32/power6/memcpy.S1
-rw-r--r--libc/sysdeps/powerpc/powerpc32/power6/memset.S449
-rw-r--r--libc/sysdeps/powerpc/powerpc64/power4/memcmp.S1
-rw-r--r--libc/sysdeps/powerpc/powerpc64/power4/memcpy.S1
-rw-r--r--libc/sysdeps/powerpc/powerpc64/power4/memset.S7
-rw-r--r--libc/sysdeps/powerpc/powerpc64/power6/memset.S274
-rw-r--r--libc/sysdeps/powerpc/sched_cpucount.c23
-rw-r--r--libc/sysdeps/s390/dl-procinfo.c80
-rw-r--r--libc/sysdeps/s390/dl-procinfo.h99
-rw-r--r--libc/sysdeps/sh/bsd-_setjmp.S6
-rw-r--r--libc/sysdeps/sh/bsd-setjmp.S6
-rw-r--r--libc/sysdeps/sparc/fpu/feholdexcpt.c6
-rw-r--r--libc/sysdeps/sparc/fpu/fraiseexcpt.c8
-rw-r--r--libc/sysdeps/sparc/sparc32/dl-machine.h54
-rw-r--r--libc/sysdeps/sparc/sparc32/sparcv9/sparcv9b/memcpy.S (renamed from libc/sysdeps/sparc/sparc32/sparcv9b/memcpy.S)2
-rw-r--r--libc/sysdeps/sparc/sparc32/sparcv9/sparcv9v/memcpy.S (renamed from libc/sysdeps/sparc/sparc32/sparcv9v/memcpy.S)0
-rw-r--r--libc/sysdeps/sparc/sparc32/sparcv9/sparcv9v/memset.S (renamed from libc/sysdeps/sparc/sparc32/sparcv9v/memset.S)0
-rw-r--r--libc/sysdeps/unix/clock_gettime.c12
-rw-r--r--libc/sysdeps/unix/clock_settime.c6
-rw-r--r--libc/sysdeps/unix/dirstream.h9
-rw-r--r--libc/sysdeps/unix/opendir.c45
-rw-r--r--libc/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h3
-rw-r--r--libc/sysdeps/unix/sysv/linux/alpha/sysdep.h4
-rw-r--r--libc/sysdeps/unix/sysv/linux/bits/sched.h78
-rw-r--r--libc/sysdeps/unix/sysv/linux/bits/socket.h15
-rw-r--r--libc/sysdeps/unix/sysv/linux/check_pf.c90
-rw-r--r--libc/sysdeps/unix/sysv/linux/clock_gettime.c10
-rw-r--r--libc/sysdeps/unix/sysv/linux/dl-osinfo.h21
-rw-r--r--libc/sysdeps/unix/sysv/linux/dl-vdso.c (renamed from libc/sysdeps/unix/sysv/linux/powerpc/dl-vdso.c)15
-rw-r--r--libc/sysdeps/unix/sysv/linux/dl-vdso.h49
-rw-r--r--libc/sysdeps/unix/sysv/linux/fstatfs64.c4
-rw-r--r--libc/sysdeps/unix/sysv/linux/fxstatat.c3
-rw-r--r--libc/sysdeps/unix/sysv/linux/getsysstats.c51
-rw-r--r--libc/sysdeps/unix/sysv/linux/i386/bits/fcntl.h3
-rw-r--r--libc/sysdeps/unix/sysv/linux/i386/posix_fallocate.c58
-rw-r--r--libc/sysdeps/unix/sysv/linux/i386/posix_fallocate64.c61
-rw-r--r--libc/sysdeps/unix/sysv/linux/i386/syscalls.list1
-rw-r--r--libc/sysdeps/unix/sysv/linux/i386/sysconf.c4
-rw-r--r--libc/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h3
-rw-r--r--libc/sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h4
-rw-r--r--libc/sysdeps/unix/sysv/linux/ia64/sys/ptrace.h24
-rw-r--r--libc/sysdeps/unix/sysv/linux/if_index.c3
-rw-r--r--libc/sysdeps/unix/sysv/linux/ifaddrs.c1
-rw-r--r--libc/sysdeps/unix/sysv/linux/init-first.c6
-rw-r--r--libc/sysdeps/unix/sysv/linux/kernel-features.h51
-rw-r--r--libc/sysdeps/unix/sysv/linux/nscd_setup_thread.c5
-rw-r--r--libc/sysdeps/unix/sysv/linux/posix_fallocate.c60
-rw-r--r--libc/sysdeps/unix/sysv/linux/posix_fallocate64.c64
-rw-r--r--libc/sysdeps/unix/sysv/linux/powerpc/Makefile2
-rw-r--r--libc/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h3
-rw-r--r--libc/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h2
-rw-r--r--libc/sysdeps/unix/sysv/linux/powerpc/init-first.c49
-rw-r--r--libc/sysdeps/unix/sysv/linux/powerpc/libc-start.c36
-rw-r--r--libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/socket.S5
-rw-r--r--libc/sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h24
-rw-r--r--libc/sysdeps/unix/sysv/linux/ppoll.c4
-rw-r--r--libc/sysdeps/unix/sysv/linux/pselect.c4
-rw-r--r--libc/sysdeps/unix/sysv/linux/s390/bits/fcntl.h3
-rw-r--r--libc/sysdeps/unix/sysv/linux/s390/dl-procinfo.h43
-rw-r--r--libc/sysdeps/unix/sysv/linux/s390/s390-32/mmap.S3
-rw-r--r--libc/sysdeps/unix/sysv/linux/s390/s390-32/mmap64.S3
-rw-r--r--libc/sysdeps/unix/sysv/linux/s390/sys/ptrace.h24
-rw-r--r--libc/sysdeps/unix/sysv/linux/sh/bits/fcntl.h3
-rw-r--r--libc/sysdeps/unix/sysv/linux/sh/clone.S10
-rw-r--r--libc/sysdeps/unix/sysv/linux/shm_open.c55
-rw-r--r--libc/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h3
-rw-r--r--libc/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S14
-rw-r--r--libc/sysdeps/unix/sysv/linux/sparc/sparc64/clone.S29
-rw-r--r--libc/sysdeps/unix/sysv/linux/sparc/sparc64/xstat.c2
-rw-r--r--libc/sysdeps/unix/sysv/linux/sparc/sys/ptrace.h24
-rw-r--r--libc/sysdeps/unix/sysv/linux/sparc/sysdep.h5
-rw-r--r--libc/sysdeps/unix/sysv/linux/statfs64.c3
-rw-r--r--libc/sysdeps/unix/sysv/linux/sys/ptrace.h25
-rw-r--r--libc/sysdeps/unix/sysv/linux/syscalls.list2
-rw-r--r--libc/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c59
-rw-r--r--libc/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate64.c1
-rw-r--r--libc/sysdeps/unix/sysv/linux/x86_64/Makefile4
-rw-r--r--libc/sysdeps/unix/sysv/linux/x86_64/Versions3
-rw-r--r--libc/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h3
-rw-r--r--libc/sysdeps/unix/sysv/linux/x86_64/bits/libc-vdso.h35
-rw-r--r--libc/sysdeps/unix/sysv/linux/x86_64/gettimeofday.S7
-rw-r--r--libc/sysdeps/unix/sysv/linux/x86_64/init-first.c51
-rw-r--r--libc/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S2
-rw-r--r--libc/sysdeps/unix/sysv/linux/x86_64/sysdep.h210
-rw-r--r--libc/sysdeps/unix/sysv/linux/xstatconv.c4
-rw-r--r--libc/sysdeps/wordsize-64/strtol.c2
-rw-r--r--libc/sysdeps/x86_64/cacheinfo.c66
-rw-r--r--libc/sysdeps/x86_64/dl-trampoline.S7
-rw-r--r--libc/sysdeps/x86_64/ldbl2mpn.c1
-rw-r--r--libc/sysdeps/x86_64/sched_cpucount.c26
122 files changed, 2491 insertions, 736 deletions
diff --git a/libc/sysdeps/generic/_G_config.h b/libc/sysdeps/generic/_G_config.h
index a152b070c..4aafe65f6 100644
--- a/libc/sysdeps/generic/_G_config.h
+++ b/libc/sysdeps/generic/_G_config.h
@@ -8,19 +8,15 @@
#include <bits/types.h>
#define __need_size_t
-#define __need_wchar_t
-#define __need_wint_t
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# define __need_wchar_t
+#endif
#define __need_NULL
#include <stddef.h>
-#ifndef _WINT_T
-/* Integral type unchanged by default argument promotions that can
- hold any value corresponding to members of the extended character
- set, as well as at least one value that does not correspond to any
- member of the extended character set. */
-# define _WINT_T
-typedef unsigned int wint_t;
-#endif
#define __need_mbstate_t
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# define __need_wint_t
+#endif
#include <wchar.h>
#define _G_size_t size_t
typedef struct
@@ -41,7 +37,8 @@ typedef struct
#define _G_wchar_t wchar_t
#define _G_wint_t wint_t
#define _G_stat64 stat
-#include <gconv.h>
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# include <gconv.h>
typedef union
{
struct __gconv_info __cd;
@@ -51,6 +48,7 @@ typedef union
struct __gconv_step_data __data;
} __combined;
} _G_iconv_t;
+#endif
typedef int _G_int16_t __attribute__ ((__mode__ (__HI__)));
typedef int _G_int32_t __attribute__ ((__mode__ (__SI__)));
diff --git a/libc/sysdeps/generic/inttypes.h b/libc/sysdeps/generic/inttypes.h
index 3f1b316c0..bf0fffa5c 100644
--- a/libc/sysdeps/generic/inttypes.h
+++ b/libc/sysdeps/generic/inttypes.h
@@ -323,13 +323,11 @@ extern uintmax_t wcstoumax (__const __gwchar_t *__restrict __nptr,
# if __WORDSIZE == 64
-/* Like `strtol' but convert to `intmax_t'. */
-# ifndef __strtol_internal_defined
extern long int __strtol_internal (__const char *__restrict __nptr,
char **__restrict __endptr,
- int __base, int __group) __THROW;
-# define __strtol_internal_defined 1
-# endif
+ int __base, int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `strtol' but convert to `intmax_t'. */
__extern_inline intmax_t
__NTH (strtoimax (__const char *__restrict nptr, char **__restrict endptr,
int base))
@@ -337,14 +335,12 @@ __NTH (strtoimax (__const char *__restrict nptr, char **__restrict endptr,
return __strtol_internal (nptr, endptr, base, 0);
}
-/* Like `strtoul' but convert to `uintmax_t'. */
-# ifndef __strtoul_internal_defined
extern unsigned long int __strtoul_internal (__const char *
__restrict __nptr,
char ** __restrict __endptr,
- int __base, int __group) __THROW;
-# define __strtoul_internal_defined 1
-# endif
+ int __base, int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `strtoul' but convert to `uintmax_t'. */
__extern_inline uintmax_t
__NTH (strtoumax (__const char *__restrict nptr, char **__restrict endptr,
int base))
@@ -352,13 +348,11 @@ __NTH (strtoumax (__const char *__restrict nptr, char **__restrict endptr,
return __strtoul_internal (nptr, endptr, base, 0);
}
-/* Like `wcstol' but convert to `intmax_t'. */
-# ifndef __wcstol_internal_defined
extern long int __wcstol_internal (__const __gwchar_t * __restrict __nptr,
__gwchar_t **__restrict __endptr,
- int __base, int __group) __THROW;
-# define __wcstol_internal_defined 1
-# endif
+ int __base, int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `wcstol' but convert to `intmax_t'. */
__extern_inline intmax_t
__NTH (wcstoimax (__const __gwchar_t *__restrict nptr,
__gwchar_t **__restrict endptr, int base))
@@ -366,16 +360,13 @@ __NTH (wcstoimax (__const __gwchar_t *__restrict nptr,
return __wcstol_internal (nptr, endptr, base, 0);
}
-
-/* Like `wcstoul' but convert to `uintmax_t'. */
-# ifndef __wcstoul_internal_defined
extern unsigned long int __wcstoul_internal (__const __gwchar_t *
__restrict __nptr,
__gwchar_t **
__restrict __endptr,
- int __base, int __group) __THROW;
-# define __wcstoul_internal_defined 1
-# endif
+ int __base, int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `wcstoul' but convert to `uintmax_t'. */
__extern_inline uintmax_t
__NTH (wcstoumax (__const __gwchar_t *__restrict nptr,
__gwchar_t **__restrict endptr, int base))
@@ -385,14 +376,12 @@ __NTH (wcstoumax (__const __gwchar_t *__restrict nptr,
# else /* __WORDSIZE == 32 */
-/* Like `strtol' but convert to `intmax_t'. */
-# ifndef __strtoll_internal_defined
__extension__
extern long long int __strtoll_internal (__const char *__restrict __nptr,
char **__restrict __endptr,
- int __base, int __group) __THROW;
-# define __strtoll_internal_defined 1
-# endif
+ int __base, int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `strtol' but convert to `intmax_t'. */
__extern_inline intmax_t
__NTH (strtoimax (__const char *__restrict nptr, char **__restrict endptr,
int base))
@@ -400,17 +389,15 @@ __NTH (strtoimax (__const char *__restrict nptr, char **__restrict endptr,
return __strtoll_internal (nptr, endptr, base, 0);
}
-/* Like `strtoul' but convert to `uintmax_t'. */
-# ifndef __strtoull_internal_defined
__extension__
extern unsigned long long int __strtoull_internal (__const char *
__restrict __nptr,
char **
__restrict __endptr,
int __base,
- int __group) __THROW;
-# define __strtoull_internal_defined 1
-# endif
+ int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `strtoul' but convert to `uintmax_t'. */
__extern_inline uintmax_t
__NTH (strtoumax (__const char *__restrict nptr, char **__restrict endptr,
int base))
@@ -418,15 +405,13 @@ __NTH (strtoumax (__const char *__restrict nptr, char **__restrict endptr,
return __strtoull_internal (nptr, endptr, base, 0);
}
-/* Like `wcstol' but convert to `intmax_t'. */
-# ifndef __wcstoll_internal_defined
__extension__
extern long long int __wcstoll_internal (__const __gwchar_t *
__restrict __nptr,
__gwchar_t **__restrict __endptr,
- int __base, int __group) __THROW;
-# define __wcstoll_internal_defined 1
-# endif
+ int __base, int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `wcstol' but convert to `intmax_t'. */
__extern_inline intmax_t
__NTH (wcstoimax (__const __gwchar_t *__restrict nptr,
__gwchar_t **__restrict endptr, int base))
@@ -435,17 +420,15 @@ __NTH (wcstoimax (__const __gwchar_t *__restrict nptr,
}
-/* Like `wcstoul' but convert to `uintmax_t'. */
-# ifndef __wcstoull_internal_defined
__extension__
extern unsigned long long int __wcstoull_internal (__const __gwchar_t *
__restrict __nptr,
__gwchar_t **
__restrict __endptr,
int __base,
- int __group) __THROW;
-# define __wcstoull_internal_defined 1
-# endif
+ int __group)
+ __THROW __nonnull ((1)) __wur;
+/* Like `wcstoul' but convert to `uintmax_t'. */
__extern_inline uintmax_t
__NTH (wcstoumax (__const __gwchar_t *__restrict nptr,
__gwchar_t **__restrict endptr, int base))
diff --git a/libc/sysdeps/generic/ldconfig.h b/libc/sysdeps/generic/ldconfig.h
index 9da8d6b3d..fadd5ec37 100644
--- a/libc/sysdeps/generic/ldconfig.h
+++ b/libc/sysdeps/generic/ldconfig.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2000, 2002, 2003, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Andreas Jaeger <aj@suse.de>, 1999.
@@ -35,6 +35,9 @@
#define FLAG_MIPS64_LIBN32 0x0600
#define FLAG_MIPS64_LIBN64 0x0700
+/* Name of auxiliary cache. */
+#define _PATH_LDCONFIG_AUX_CACHE "/var/cache/ldconfig/aux-cache"
+
/* Declared in cache.c. */
extern void print_cache (const char *cache_name);
@@ -45,10 +48,24 @@ extern void save_cache (const char *cache_name);
extern void add_to_cache (const char *path, const char *lib, int flags,
unsigned int osversion, uint64_t hwcap);
+extern void init_aux_cache (void);
+
+extern void load_aux_cache (const char *aux_cache_name);
+
+extern int search_aux_cache (struct stat64 *stat_buf, int *flags,
+ unsigned int *osversion, char **soname);
+
+extern void add_to_aux_cache (struct stat64 *stat_buf, int flags,
+ unsigned int osversion, const char *soname);
+
+extern void save_aux_cache (const char *aux_cache_name);
+
/* Declared in readlib.c. */
extern int process_file (const char *real_file_name, const char *file_name,
const char *lib, int *flag, unsigned int *osversion,
- char **soname, int is_link);
+ char **soname, int is_link, struct stat64 *stat_buf);
+
+extern char *implicit_soname (const char *lib, int flag);
/* Declared in readelflib.c. */
extern int process_elf_file (const char *file_name, const char *lib, int *flag,
diff --git a/libc/sysdeps/generic/ldsodefs.h b/libc/sysdeps/generic/ldsodefs.h
index 5205c4149..aefd105f0 100644
--- a/libc/sysdeps/generic/ldsodefs.h
+++ b/libc/sysdeps/generic/ldsodefs.h
@@ -38,7 +38,6 @@
#include <bits/libc-lock.h>
#include <hp-timing.h>
#include <tls.h>
-#include <rtld-lowlevel.h>
__BEGIN_DECLS
@@ -439,18 +438,18 @@ struct rtld_global
EXTERN void (*_dl_rtld_unlock_recursive) (void *);
#endif
- /* Prevailing state of the stack, PF_X indicating it's executable. */
- EXTERN ElfW(Word) _dl_stack_flags;
-
/* If loading a shared object requires that we make the stack executable
when it was not, we do it by calling this function.
It returns an errno code or zero on success. */
EXTERN int (*_dl_make_stack_executable_hook) (void **) internal_function;
- /* Highest dtv index currently needed. */
- EXTERN size_t _dl_tls_max_dtv_idx;
+ /* Prevailing state of the stack, PF_X indicating it's executable. */
+ EXTERN ElfW(Word) _dl_stack_flags;
+
/* Flag signalling whether there are gaps in the module ID allocation. */
EXTERN bool _dl_tls_dtv_gaps;
+ /* Highest dtv index currently needed. */
+ EXTERN size_t _dl_tls_max_dtv_idx;
/* Information about the dtv slots. */
EXTERN struct dtv_slotinfo_list
{
@@ -488,6 +487,12 @@ struct rtld_global
EXTERN void (*_dl_wait_lookup_done) (void);
+ /* Scopes to free after next THREAD_GSCOPE_WAIT (). */
+ EXTERN struct dl_scope_free_list
+ {
+ size_t count;
+ struct r_scope_elem **list[50];
+ } *_dl_scope_free_list;
#ifdef SHARED
};
# define __rtld_global_attribute__
@@ -534,15 +539,15 @@ struct rtld_global_ro
#define DL_DEBUG_HELP (1 << 9)
#define DL_DEBUG_PRELINK (1 << 10)
- /* Cached value of `getpagesize ()'. */
- EXTERN size_t _dl_pagesize;
-
/* OS version. */
EXTERN unsigned int _dl_osversion;
/* Platform name. */
EXTERN const char *_dl_platform;
EXTERN size_t _dl_platformlen;
+ /* Cached value of `getpagesize ()'. */
+ EXTERN size_t _dl_pagesize;
+
/* Copy of the content of `_dl_main_searchlist' at startup time. */
EXTERN struct r_scope_elem _dl_initial_searchlist;
@@ -571,9 +576,6 @@ struct rtld_global_ro
/* Expected cache ID. */
EXTERN int _dl_correct_cache_id;
- /* 0 if internal pointer values should not be guarded, 1 if they should. */
- EXTERN int _dl_pointer_guard;
-
/* Mask for hardware capabilities that are available. */
EXTERN uint64_t _dl_hwcap;
@@ -657,6 +659,9 @@ struct rtld_global_ro
/* List of auditing interfaces. */
struct audit_ifaces *_dl_audit;
unsigned int _dl_naudit;
+
+ /* 0 if internal pointer values should not be guarded, 1 if they should. */
+ EXTERN int _dl_pointer_guard;
};
# define __rtld_global_attribute__
# ifdef IS_IN_rtld
@@ -840,9 +845,7 @@ enum
DL_LOOKUP_ADD_DEPENDENCY = 1,
/* Return most recent version instead of default version for
unversioned lookup. */
- DL_LOOKUP_RETURN_NEWEST = 2,
- /* Set if the scopr lock in the UNDEF_MAP is taken. */
- DL_LOOKUP_SCOPE_LOCK = 4
+ DL_LOOKUP_RETURN_NEWEST = 2
};
/* Lookup versioned symbol. */
@@ -1050,6 +1053,11 @@ extern void *_dl_open (const char *name, int mode, const void *caller,
Lmid_t nsid, int argc, char *argv[], char *env[])
attribute_hidden;
+/* Free or queue for freeing scope OLD. If other threads might be
+ in the middle of _dl_fixup, _dl_profile_fixup or dl*sym using the
+ old scope, OLD can't be freed until no thread is using it. */
+extern int _dl_scope_free (struct r_scope_elem **old) attribute_hidden;
+
/* Add module to slot information data. */
extern void _dl_add_to_slotinfo (struct link_map *l) attribute_hidden;
@@ -1061,6 +1069,8 @@ extern struct link_map *_dl_update_slotinfo (unsigned long int req_modid);
but never touch anything. Return null if it's not allocated yet. */
extern void *_dl_tls_get_addr_soft (struct link_map *l) internal_function;
+extern int _dl_addr_inside_object (struct link_map *l, const ElfW(Addr) addr)
+ internal_function attribute_hidden;
__END_DECLS
diff --git a/libc/sysdeps/generic/unwind-dw2-fde-glibc.c b/libc/sysdeps/generic/unwind-dw2-fde-glibc.c
index 0038a0cbf..932a97274 100644
--- a/libc/sysdeps/generic/unwind-dw2-fde-glibc.c
+++ b/libc/sysdeps/generic/unwind-dw2-fde-glibc.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
Contributed by Jakub Jelinek <jakub@redhat.com>.
This file is part of the GNU C Library.
@@ -235,10 +235,11 @@ _Unwind_IteratePhdrCallback (struct dl_phdr_info *info, size_t size, void *ptr)
if (data->ret != NULL)
{
unsigned int encoding = get_fde_encoding (data->ret);
+ _Unwind_Ptr func;
read_encoded_value_with_base (encoding,
base_from_cb_data (encoding, data),
- data->ret->pc_begin,
- (_Unwind_Ptr *)&data->func);
+ data->ret->pc_begin, &func);
+ data->func = (void *) func;
}
return 1;
}
diff --git a/libc/sysdeps/generic/unwind-dw2-fde.c b/libc/sysdeps/generic/unwind-dw2-fde.c
index 13945b971..8d62e4611 100644
--- a/libc/sysdeps/generic/unwind-dw2-fde.c
+++ b/libc/sysdeps/generic/unwind-dw2-fde.c
@@ -1,5 +1,5 @@
/* Subroutines needed for unwinding stack frames for exception handling. */
-/* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2006
+/* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2006, 2007
Free Software Foundation, Inc.
Contributed by Jason Merrill <jason@cygnus.com>.
@@ -301,7 +301,8 @@ get_cie_encoding (struct dwarf_cie *cie)
if (aug[0] != 'z')
return DW_EH_PE_absptr;
- p = aug + strlen (aug) + 1; /* Skip the augmentation string. */
+ /* Skip the augmentation string. */
+ p = aug + strlen ((const char *) aug) + 1;
p = read_uleb128 (p, &utmp); /* Skip code alignment. */
p = read_sleb128 (p, &stmp); /* Skip data alignment. */
p++; /* Skip return address column. */
@@ -838,7 +839,7 @@ linear_search_fdes (struct object *ob, fde *this_fde, void *pc)
else
{
_Unwind_Ptr mask;
- const char *p;
+ const unsigned char *p;
p = read_encoded_value_with_base (encoding, base,
this_fde->pc_begin, &pc_begin);
@@ -908,7 +909,7 @@ binary_search_single_encoding_fdes (struct object *ob, void *pc)
size_t i = (lo + hi) / 2;
fde *f = vec->array[i];
_Unwind_Ptr pc_begin, pc_range;
- const char *p;
+ const unsigned char *p;
p = read_encoded_value_with_base (encoding, base, f->pc_begin,
&pc_begin);
@@ -936,7 +937,7 @@ binary_search_mixed_encoding_fdes (struct object *ob, void *pc)
size_t i = (lo + hi) / 2;
fde *f = vec->array[i];
_Unwind_Ptr pc_begin, pc_range;
- const char *p;
+ const unsigned char *p;
int encoding;
encoding = get_fde_encoding (f);
@@ -1046,6 +1047,7 @@ _Unwind_Find_FDE (void *pc, struct dwarf_eh_bases *bases)
if (f)
{
int encoding;
+ _Unwind_Ptr func;
bases->tbase = ob->tbase;
bases->dbase = ob->dbase;
@@ -1054,7 +1056,8 @@ _Unwind_Find_FDE (void *pc, struct dwarf_eh_bases *bases)
if (ob->s.b.mixed_encoding)
encoding = get_fde_encoding (f);
read_encoded_value_with_base (encoding, base_from_object (encoding, ob),
- f->pc_begin, (_Unwind_Ptr *)&bases->func);
+ f->pc_begin, &func);
+ bases->func = (void *) func;
}
return f;
diff --git a/libc/sysdeps/generic/unwind-dw2.c b/libc/sysdeps/generic/unwind-dw2.c
index d818e5dfd..ba5723aa6 100644
--- a/libc/sysdeps/generic/unwind-dw2.c
+++ b/libc/sysdeps/generic/unwind-dw2.c
@@ -1,5 +1,5 @@
/* DWARF2 exception handling and frame unwind runtime interface routines.
- Copyright (C) 1997,1998,1999,2000,2001,2002,2003,2005,2006
+ Copyright (C) 1997,1998,1999,2000,2001,2002,2003,2005,2006,2007
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -309,8 +309,9 @@ extract_cie_info (struct dwarf_cie *cie, struct _Unwind_Context *context,
/* "P" indicates a personality routine in the CIE augmentation. */
else if (aug[0] == 'P')
{
- p = read_encoded_value (context, *p, p + 1,
- (_Unwind_Ptr *) &fs->personality);
+ _Unwind_Ptr personality;
+ p = read_encoded_value (context, *p, p + 1, &personality);
+ fs->personality = (_Unwind_Personality_Fn) personality;
aug += 1;
}
@@ -771,8 +772,12 @@ execute_cfa_program (const unsigned char *insn_ptr,
else switch (insn)
{
case DW_CFA_set_loc:
- insn_ptr = read_encoded_value (context, fs->fde_encoding,
- insn_ptr, (_Unwind_Ptr *) &fs->pc);
+ {
+ _Unwind_Ptr pc;
+ insn_ptr = read_encoded_value (context, fs->fde_encoding,
+ insn_ptr, &pc);
+ fs->pc = (void *) pc;
+ }
break;
case DW_CFA_advance_loc1:
@@ -992,8 +997,11 @@ uw_frame_state_for (struct _Unwind_Context *context, _Unwind_FrameState *fs)
insn = aug + i;
}
if (fs->lsda_encoding != DW_EH_PE_omit)
- aug = read_encoded_value (context, fs->lsda_encoding, aug,
- (_Unwind_Ptr *) &context->lsda);
+ {
+ _Unwind_Ptr lsda;
+ aug = read_encoded_value (context, fs->lsda_encoding, aug, &lsda);
+ context->lsda = (void *) lsda;
+ }
/* Then the insns in the FDE up to our target PC. */
if (insn == NULL)
diff --git a/libc/sysdeps/gnu/_G_config.h b/libc/sysdeps/gnu/_G_config.h
index 83c78f0b9..211d0224b 100644
--- a/libc/sysdeps/gnu/_G_config.h
+++ b/libc/sysdeps/gnu/_G_config.h
@@ -8,19 +8,15 @@
#include <bits/types.h>
#define __need_size_t
-#define __need_wchar_t
-#define __need_wint_t
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# define __need_wchar_t
+#endif
#define __need_NULL
#include <stddef.h>
-#ifndef _WINT_T
-/* Integral type unchanged by default argument promotions that can
- hold any value corresponding to members of the extended character
- set, as well as at least one value that does not correspond to any
- member of the extended character set. */
-# define _WINT_T
-typedef unsigned int wint_t;
-#endif
#define __need_mbstate_t
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# define __need_wint_t
+#endif
#include <wchar.h>
#define _G_size_t size_t
typedef struct
@@ -41,7 +37,8 @@ typedef struct
#define _G_wchar_t wchar_t
#define _G_wint_t wint_t
#define _G_stat64 stat64
-#include <gconv.h>
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# include <gconv.h>
typedef union
{
struct __gconv_info __cd;
@@ -51,6 +48,7 @@ typedef union
struct __gconv_step_data __data;
} __combined;
} _G_iconv_t;
+#endif
typedef int _G_int16_t __attribute__ ((__mode__ (__HI__)));
typedef int _G_int32_t __attribute__ ((__mode__ (__SI__)));
diff --git a/libc/sysdeps/i386/dl-trampoline.S b/libc/sysdeps/i386/dl-trampoline.S
index f991797ee..af9eaf6d5 100644
--- a/libc/sysdeps/i386/dl-trampoline.S
+++ b/libc/sysdeps/i386/dl-trampoline.S
@@ -37,10 +37,10 @@ _dl_runtime_resolve:
call _dl_fixup # Call resolver.
popl %edx # Get register content back.
cfi_adjust_cfa_offset (-4)
- popl %ecx
- cfi_adjust_cfa_offset (-4)
- xchgl %eax, (%esp) # Get %eax contents end store function address.
- ret $8 # Jump to function address.
+ movl (%esp), %ecx
+ movl %eax, (%esp) # Store the function address.
+ movl 4(%esp), %eax
+ ret $12 # Jump to function address.
cfi_endproc
.size _dl_runtime_resolve, .-_dl_runtime_resolve
@@ -83,10 +83,10 @@ _dl_runtime_profile:
cfi_adjust_cfa_offset (-4)
popl %edx # Get register content back.
cfi_adjust_cfa_offset (-4)
- popl %ecx
- cfi_adjust_cfa_offset (-4)
- xchgl %eax, (%esp) # Get %eax contents end store function address.
- ret $16 # Jump to function address.
+ movl (%esp), %ecx
+ movl %eax, (%esp) # Store the function address.
+ movl 4(%esp), %eax
+ ret $20 # Jump to function address.
/*
+32 return address
@@ -111,9 +111,10 @@ _dl_runtime_profile:
cfi_rel_offset (esi, 0)
leal 44(%esp), %esi
movl %ebx, %ecx
+ orl $4, %ebx # Increase frame size if necessary to align
+ # stack for the function call
movl %esp, %edi
subl %ebx, %edi
- andl $0xfffffff0, %edi # Align stack
movl %esp, %ebx
cfi_def_cfa_register (ebx)
movl %edi, %esp
diff --git a/libc/sysdeps/i386/ldbl2mpn.c b/libc/sysdeps/i386/ldbl2mpn.c
index bf4e4ff43..01be77727 100644
--- a/libc/sysdeps/i386/ldbl2mpn.c
+++ b/libc/sysdeps/i386/ldbl2mpn.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997, 2000, 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
@@ -19,7 +19,7 @@
#include "gmp.h"
#include "gmp-impl.h"
#include "longlong.h"
-#include "ieee754.h"
+#include <ieee754.h>
#include <float.h>
#include <stdlib.h>
@@ -46,7 +46,7 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
#elif BITS_PER_MP_LIMB == 64
/* Hopefully the compiler will combine the two bitfield extracts
and this composition into just the original quadword extract. */
- res_ptr[0] = ((unsigned long int) u.ieee.mantissa0 << 32) | u.ieee.mantissa1;
+ res_ptr[0] = ((mp_limb_t) u.ieee.mantissa0 << 32) | u.ieee.mantissa1;
#define N 1
#else
#error "mp_limb size " BITS_PER_MP_LIMB "not accounted for"
@@ -109,6 +109,13 @@ __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
}
}
}
+ else if (u.ieee.exponent < 0x7fff
+#if N == 2
+ && res_ptr[0] == 0
+#endif
+ && res_ptr[N - 1] == 0)
+ /* Pseudo zero. */
+ *expt = 0;
return N;
}
diff --git a/libc/sysdeps/ia64/ldbl2mpn.c b/libc/sysdeps/ia64/ldbl2mpn.c
new file mode 100644
index 000000000..641b789cd
--- /dev/null
+++ b/libc/sysdeps/ia64/ldbl2mpn.c
@@ -0,0 +1 @@
+#include "../i386/ldbl2mpn.c"
diff --git a/libc/sysdeps/unix/sysv/linux/powerpc/dl-vdso.h b/libc/sysdeps/ia64/sched_cpucount.c
index a7dcb2e5f..ff9d8cf2a 100644
--- a/libc/sysdeps/unix/sysv/linux/powerpc/dl-vdso.h
+++ b/libc/sysdeps/ia64/sched_cpucount.c
@@ -1,5 +1,4 @@
-/* ELF symbol resolve functions for VDSO objects.
- Copyright (C) 2005 Free Software Foundation, Inc.
+/* 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
@@ -17,11 +16,6 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#ifndef _DL_VDSO_H
-#define _DL_VDSO_H 1
+#define POPCNT(l) __builtin_popcountl (l)
-/* Functions for resolving symbols in the VDSO link map. */
-extern void *_dl_vdso_vsym (const char *name, const char *version)
- internal_function attribute_hidden;
-
-#endif /* dl-vdso.h */
+#include <posix/sched_cpucount.c>
diff --git a/libc/sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c b/libc/sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c
index 8a2d45e2d..21d1e62da 100644
--- a/libc/sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c
+++ b/libc/sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2002, 2003, 2004, 2006
+/* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2002, 2003, 2004, 2006, 2007
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -31,19 +31,20 @@ long double
__mpn_construct_long_double (mp_srcptr frac_ptr, int expt, int sign)
{
union ibm_extended_long_double u;
- unsigned long hidden2, lzcount;
+ unsigned long lzcount;
unsigned long long hi, lo;
+ int exponent2;
u.ieee.negative = sign;
u.ieee.negative2 = sign;
u.ieee.exponent = expt + IBM_EXTENDED_LONG_DOUBLE_BIAS;
- u.ieee.exponent2 = expt - 53 + IBM_EXTENDED_LONG_DOUBLE_BIAS;
+ u.ieee.exponent2 = 0;
+ exponent2 = expt - 53 + IBM_EXTENDED_LONG_DOUBLE_BIAS;
#if BITS_PER_MP_LIMB == 32
/* The low order 53 bits (52 + hidden) go into the lower double */
lo = frac_ptr[0];
lo |= (frac_ptr[1] & ((1LL << (53 - 32)) - 1)) << 32;
- hidden2 = (frac_ptr[1] >> (52 - 32)) & ((mp_limb_t) 1);
/* The high order 53 bits (52 + hidden) go into the upper double */
hi = (frac_ptr[1] >> (53 - 32)) & ((1 << 11) - 1);
hi |= ((unsigned long long) frac_ptr[2]) << 11;
@@ -51,7 +52,6 @@ __mpn_construct_long_double (mp_srcptr frac_ptr, int expt, int sign)
#elif BITS_PER_MP_LIMB == 64
/* The low order 53 bits (52 + hidden) go into the lower double */
lo = frac_ptr[0] & (((mp_limb_t) 1 << 53) - 1);
- hidden2 = (frac_ptr[0] >> 52) & ((mp_limb_t) 1);
/* The high order 53 bits (52 + hidden) go into the upper double */
hi = (frac_ptr[0] >> 53) & (((mp_limb_t) 1 << 11) - 1);
hi |= (frac_ptr[1] << 11);
@@ -59,14 +59,62 @@ __mpn_construct_long_double (mp_srcptr frac_ptr, int expt, int sign)
#error "mp_limb size " BITS_PER_MP_LIMB "not accounted for"
#endif
+ if ((hi & (1LL << 52)) == 0 && (hi | lo) != 0)
+ {
+ /* denormal number */
+ unsigned long long val = hi ? hi : lo;
+
+ if (sizeof (val) == sizeof (long))
+ lzcount = __builtin_clzl (val);
+ else if ((val >> 32) != 0)
+ lzcount = __builtin_clzl ((long) (val >> 32));
+ else
+ lzcount = __builtin_clzl ((long) val) + 32;
+ if (hi)
+ lzcount = lzcount - 11;
+ else
+ lzcount = lzcount + 42;
+
+ if (lzcount > u.ieee.exponent)
+ {
+ lzcount = u.ieee.exponent;
+ u.ieee.exponent = 0;
+ exponent2 -= lzcount;
+ }
+ else
+ {
+ u.ieee.exponent -= (lzcount - 1);
+ exponent2 -= (lzcount - 1);
+ }
+
+ if (lzcount <= 53)
+ {
+ hi = (hi << lzcount) | (lo >> (53 - lzcount));
+ lo = (lo << lzcount) & ((1LL << 53) - 1);
+ }
+ else
+ {
+ hi = lo << (lzcount - 53);
+ lo = 0;
+ }
+ }
+
if (lo != 0L)
{
/* hidden2 bit of low double controls rounding of the high double.
- If hidden2 is '1' then round up hi and adjust lo (2nd mantissa)
+ If hidden2 is '1' and either the explicit mantissa is non-zero
+ or hi is odd, then round up hi and adjust lo (2nd mantissa)
plus change the sign of the low double to compensate. */
- if (hidden2)
+ if ((lo & (1LL << 52)) != 0
+ && ((hi & 1) != 0 || (lo & ((1LL << 52) - 1))))
{
hi++;
+ if ((hi & ((1LL << 52) - 1)) == 0)
+ {
+ if ((hi & (1LL << 53)) != 0)
+ hi -= 1LL << 52;
+ u.ieee.exponent++;
+ }
u.ieee.negative2 = !sign;
lo = (1LL << 53) - lo;
}
@@ -85,17 +133,18 @@ __mpn_construct_long_double (mp_srcptr frac_ptr, int expt, int sign)
if (lzcount > 0)
{
lo = lo << lzcount;
- u.ieee.exponent2 = u.ieee.exponent2 - lzcount;
+ exponent2 = exponent2 - lzcount;
}
+ if (exponent2 > 0)
+ u.ieee.exponent2 = exponent2;
+ else
+ lo >>= 1 - exponent2;
}
else
- {
- u.ieee.negative2 = 0;
- u.ieee.exponent2 = 0;
- }
+ u.ieee.negative2 = 0;
u.ieee.mantissa3 = lo & 0xffffffffLL;
- u.ieee.mantissa2 = (lo >> 32) & 0xffffff;
+ u.ieee.mantissa2 = (lo >> 32) & 0xfffff;
u.ieee.mantissa1 = hi & 0xffffffffLL;
u.ieee.mantissa0 = (hi >> 32) & ((1LL << (LDBL_MANT_DIG - 86)) - 1);
diff --git a/libc/sysdeps/ieee754/ldbl-128ibm/s_fpclassifyl.c b/libc/sysdeps/ieee754/ldbl-128ibm/s_fpclassifyl.c
index 3ca178a3c..6999abc25 100644
--- a/libc/sysdeps/ieee754/ldbl-128ibm/s_fpclassifyl.c
+++ b/libc/sysdeps/ieee754/ldbl-128ibm/s_fpclassifyl.c
@@ -1,5 +1,5 @@
/* Return classification value corresponding to argument.
- Copyright (C) 1997,1999,2002,2004,2006 Free Software Foundation, Inc.
+ Copyright (C) 1997,1999,2002,2004,2006,2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997 and
Jakub Jelinek <jj@ultra.linux.cz>, 1999.
@@ -30,14 +30,16 @@
* -NaN fffn nnnn nnnn nnnn xxxx xxxx xxxx xxxx
* +Inf 7ff0 0000 0000 0000 xxxx xxxx xxxx xxxx
* -Inf fff0 0000 0000 0000 xxxx xxxx xxxx xxxx
- * +0 0000 0000 0000 0000
- * -0 8000 0000 0000 0000
- * +normal 001n nnnn nnnn nnnn (smallest)
- * -normal 801n nnnn nnnn nnnn (smallest)
- * +normal 7fen nnnn nnnn nnnn (largest)
- * -normal ffen nnnn nnnn nnnn (largest)
- * +denorm 000n nnnn nnnn nnnn
- * -denorm 800n nnnn nnnn nnnn
+ * +0 0000 0000 0000 0000 xxxx xxxx xxxx xxxx
+ * -0 8000 0000 0000 0000 xxxx xxxx xxxx xxxx
+ * +normal 0360 0000 0000 0000 0000 0000 0000 0000 (smallest)
+ * -normal 8360 0000 0000 0000 0000 0000 0000 0000 (smallest)
+ * +normal 7fef ffff ffff ffff 7c8f ffff ffff fffe (largest)
+ * +normal ffef ffff ffff ffff fc8f ffff ffff fffe (largest)
+ * +denorm 0360 0000 0000 0000 8000 0000 0000 0001 (largest)
+ * -denorm 8360 0000 0000 0000 0000 0000 0000 0001 (largest)
+ * +denorm 000n nnnn nnnn nnnn xxxx xxxx xxxx xxxx
+ * -denorm 800n nnnn nnnn nnnn xxxx xxxx xxxx xxxx
*/
int
@@ -59,12 +61,23 @@ ___fpclassifyl (long double x)
/* +/-zero or +/- normal or +/- denormal */
if (hx & 0x7fffffffffffffffULL) {
/* +/- normal or +/- denormal */
- if ((hx & 0x7ff0000000000000ULL) >= 0x0360000000000000ULL) {
+ if ((hx & 0x7ff0000000000000ULL) > 0x0360000000000000ULL) {
/* +/- normal */
retval = FP_NORMAL;
} else {
- /* +/- denormal */
- retval = FP_SUBNORMAL;
+ if ((hx & 0x7ff0000000000000ULL) == 0x0360000000000000ULL) {
+ if ((lx & 0x7fffffffffffffff) /* lower is non-zero */
+ && ((lx^hx) & 0x8000000000000000ULL)) { /* and sign differs */
+ /* +/- denormal */
+ retval = FP_SUBNORMAL;
+ } else {
+ /* +/- normal */
+ retval = FP_NORMAL;
+ }
+ } else {
+ /* +/- denormal */
+ retval = FP_SUBNORMAL;
+ }
}
} else {
/* +/- zero */
diff --git a/libc/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c b/libc/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c
index 4f8aa7dec..39d0e6a5e 100644
--- a/libc/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c
+++ b/libc/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c
@@ -35,7 +35,7 @@ static char rcsid[] = "$NetBSD: $";
long double x,y;
#endif
{
- int64_t hx,hy,ihx,ihy,ilx,ily;
+ int64_t hx,hy,ihx,ihy,ilx;
u_int64_t lx,ly;
GET_LDOUBLE_WORDS64(hx,lx,x);
@@ -43,7 +43,6 @@ static char rcsid[] = "$NetBSD: $";
ihx = hx&0x7fffffffffffffffLL; /* |hx| */
ilx = lx&0x7fffffffffffffffLL; /* |lx| */
ihy = hy&0x7fffffffffffffffLL; /* |hy| */
- ily = ly&0x7fffffffffffffffLL; /* |ly| */
if((((ihx&0x7ff0000000000000LL)==0x7ff0000000000000LL)&&
((ihx&0x000fffffffffffffLL)!=0)) || /* x is nan */
@@ -54,54 +53,66 @@ static char rcsid[] = "$NetBSD: $";
return y; /* x=y, return y */
if(ihx == 0 && ilx == 0) { /* x == 0 */
long double u;
- SET_LDOUBLE_WORDS64(x,hy&0x8000000000000000ULL,1);/* return +-minsubnormal */
- u = math_opt_barrier (u);
+ hy = (hy & 0x8000000000000000ULL) | 1;
+ SET_LDOUBLE_WORDS64(x,hy,0ULL);/* return +-minsubnormal */
+ u = math_opt_barrier (x);
u = u * u;
math_force_eval (u); /* raise underflow flag */
return x;
}
- if(ihx>=0) { /* x > 0 */
- if(ihx>ihy||((ihx==ihy)&&(ilx>ily))) { /* x > y, x -= ulp */
-
- if(ilx==0)
- hx--;
- else
- lx--;
- } else { /* x < y, x += ulp */
- if((hx==0x7fefffffffffffffLL)&&(lx==0x7c8ffffffffffffeLL))
- {
- SET_LDOUBLE_WORDS64(x,0x7ff0000000000000,0x8000000000000000);
- return x;
- }
- else if((hx==0xffefffffffffffffLL)&&(lx==0xfc8ffffffffffffeLL))
- {
- SET_LDOUBLE_WORDS64(x,0xfff0000000000000,0x8000000000000000);
- return x;
- }
- else if((lx&0x7fffffffffffffff)==0) hx++;
- else
- lx++;
+
+ long double u;
+ if(x > y) { /* x > y, x -= ulp */
+ if((hx==0xffefffffffffffffLL)&&(lx==0xfc8ffffffffffffeLL))
+ return x+x; /* overflow, return -inf */
+ if (hx >= 0x7ff0000000000000LL) {
+ SET_LDOUBLE_WORDS64(u,0x7fefffffffffffffLL,0x7c8ffffffffffffeLL);
+ return u;
}
- } else { /* x < 0 */
- if(ihy>=0||ihx>ihy||((ihx==ihy)&&(ilx>ily))){/* x < y, x -= ulp */
- if((lx&0x7fffffffffffffff)==0)
- hx--;
- else
- lx--;
- } else { /* x > y, x += ulp */
- if((lx&0x7fffffffffffffff)==0) hx++;
- else
- lx++;
+ if(ihx <= 0x0360000000000000LL) { /* x <= LDBL_MIN */
+ u = math_opt_barrier (x);
+ x -= __LDBL_DENORM_MIN__;
+ if (ihx < 0x0360000000000000LL
+ || (hx > 0 && (int64_t) lx <= 0)
+ || (hx < 0 && (int64_t) lx > 1)) {
+ u = u * u;
+ math_force_eval (u); /* raise underflow flag */
+ }
+ return x;
}
+ if (ihx < 0x06a0000000000000LL) { /* ulp will denormal */
+ SET_LDOUBLE_WORDS64(u,(hx&0x7ff0000000000000LL),0ULL);
+ u *= 0x1.0000000000000p-105L;
+ } else
+ SET_LDOUBLE_WORDS64(u,(hx&0x7ff0000000000000LL)-0x0690000000000000LL,0ULL);
+ return x - u;
+ } else { /* x < y, x += ulp */
+ if((hx==0x7fefffffffffffffLL)&&(lx==0x7c8ffffffffffffeLL))
+ return x+x; /* overflow, return +inf */
+ if ((u_int64_t) hx >= 0xfff0000000000000ULL) {
+ SET_LDOUBLE_WORDS64(u,0xffefffffffffffffLL,0xfc8ffffffffffffeLL);
+ return u;
+ }
+ if(ihx <= 0x0360000000000000LL) { /* x <= LDBL_MIN */
+ u = math_opt_barrier (x);
+ x += __LDBL_DENORM_MIN__;
+ if (ihx < 0x0360000000000000LL
+ || (hx > 0 && (int64_t) lx < 0 && lx != 0x8000000000000001LL)
+ || (hx < 0 && (int64_t) lx >= 0)) {
+ u = u * u;
+ math_force_eval (u); /* raise underflow flag */
+ }
+ if (x == 0.0L) /* handle negative __LDBL_DENORM_MIN__ case */
+ x = -0.0L;
+ return x;
+ }
+ if (ihx < 0x06a0000000000000LL) { /* ulp will denormal */
+ SET_LDOUBLE_WORDS64(u,(hx&0x7ff0000000000000LL),0ULL);
+ u *= 0x1.0000000000000p-105L;
+ } else
+ SET_LDOUBLE_WORDS64(u,(hx&0x7ff0000000000000LL)-0x0690000000000000LL,0ULL);
+ return x + u;
}
- hy = hx&0x7ff0000000000000LL;
- if(hy==0x7ff0000000000000LL) return x+x;/* overflow */
- if(hy==0) {
- long double u = x * x; /* underflow */
- math_force_eval (u); /* raise underflow flag */
- }
- SET_LDOUBLE_WORDS64(x,hx,lx);
- return x;
}
strong_alias (__nextafterl, __nexttowardl)
long_double_symbol (libm, __nextafterl, nextafterl);
diff --git a/libc/sysdeps/ieee754/ldbl-128ibm/strtold_l.c b/libc/sysdeps/ieee754/ldbl-128ibm/strtold_l.c
index d558b00d4..670d80ce0 100644
--- a/libc/sysdeps/ieee754/ldbl-128ibm/strtold_l.c
+++ b/libc/sysdeps/ieee754/ldbl-128ibm/strtold_l.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 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
@@ -37,6 +37,9 @@ extern long double ____new_strtold_l (const char *, char **, __locale_t);
# define __STRTOF ____new_strtold_l
# define ____STRTOF_INTERNAL ____strtold_l_internal
#endif
+extern __typeof (__STRTOF) STRTOF;
+libc_hidden_proto (__STRTOF)
+libc_hidden_proto (STRTOF)
#define MPN2FLOAT __mpn_construct_long_double
#define FLOAT_HUGE_VAL HUGE_VALL
# define SET_MANTISSA(flt, mant) \
@@ -54,10 +57,12 @@ extern long double ____new_strtold_l (const char *, char **, __locale_t);
#ifdef __LONG_DOUBLE_MATH_OPTIONAL
# include <math_ldbl_opt.h>
# ifdef USE_WIDE_CHAR
-long_double_symbol (libc, __new_wcstold_l, wcstold_l);
+weak_alias (____new_wcstold_l, ___new_wcstold_l);
+long_double_symbol (libc, ___new_wcstold_l, wcstold_l);
long_double_symbol (libc, ____new_wcstold_l, __wcstold_l);
# else
-long_double_symbol (libc, __new_strtold_l, strtold_l);
+weak_alias (____new_strtold_l, ___new_strtold_l);
+long_double_symbol (libc, ___new_strtold_l, strtold_l);
long_double_symbol (libc, ____new_strtold_l, __strtold_l);
# endif
#endif
diff --git a/libc/sysdeps/ieee754/ldbl-64-128/strtold_l.c b/libc/sysdeps/ieee754/ldbl-64-128/strtold_l.c
index ef8fe0575..cdc30983e 100644
--- a/libc/sysdeps/ieee754/ldbl-64-128/strtold_l.c
+++ b/libc/sysdeps/ieee754/ldbl-64-128/strtold_l.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 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
@@ -37,6 +37,9 @@ extern long double ____new_strtold_l (const char *, char **, __locale_t);
# define __STRTOF ____new_strtold_l
# define ____STRTOF_INTERNAL ____strtold_l_internal
#endif
+extern __typeof (__STRTOF) STRTOF;
+libc_hidden_proto (__STRTOF)
+libc_hidden_proto (STRTOF)
#define MPN2FLOAT __mpn_construct_long_double
#define FLOAT_HUGE_VAL HUGE_VALL
#define SET_MANTISSA(flt, mant) \
@@ -54,10 +57,12 @@ extern long double ____new_strtold_l (const char *, char **, __locale_t);
#ifdef __LONG_DOUBLE_MATH_OPTIONAL
# include <math_ldbl_opt.h>
# ifdef USE_WIDE_CHAR
-long_double_symbol (libc, __new_wcstold_l, wcstold_l);
+weak_alias (____new_wcstold_l, ___new_wcstold_l);
+long_double_symbol (libc, ___new_wcstold_l, wcstold_l);
long_double_symbol (libc, ____new_wcstold_l, __wcstold_l);
# else
-long_double_symbol (libc, __new_strtold_l, strtold_l);
+weak_alias (____new_strtold_l, ___new_strtold_l);
+long_double_symbol (libc, ___new_strtold_l, strtold_l);
long_double_symbol (libc, ____new_strtold_l, __strtold_l);
# endif
#endif
diff --git a/libc/sysdeps/ieee754/ldbl-96/s_roundl.c b/libc/sysdeps/ieee754/ldbl-96/s_roundl.c
index 672536d35..f1399cc20 100644
--- a/libc/sysdeps/ieee754/ldbl-96/s_roundl.c
+++ b/libc/sysdeps/ieee754/ldbl-96/s_roundl.c
@@ -1,5 +1,5 @@
/* Round long double to integer away from zero.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -23,7 +23,7 @@
#include "math_private.h"
-static const long double huge = 1.0e4930;
+static const long double huge = 1.0e4930L;
long double
diff --git a/libc/sysdeps/mach/hurd/_G_config.h b/libc/sysdeps/mach/hurd/_G_config.h
index b64305923..db959246e 100644
--- a/libc/sysdeps/mach/hurd/_G_config.h
+++ b/libc/sysdeps/mach/hurd/_G_config.h
@@ -8,19 +8,15 @@
#include <bits/types.h>
#define __need_size_t
-#define __need_wchar_t
-#define __need_wint_t
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# define __need_wchar_t
+#endif
#define __need_NULL
#include <stddef.h>
-#ifndef _WINT_T
-/* Integral type unchanged by default argument promotions that can
- hold any value corresponding to members of the extended character
- set, as well as at least one value that does not correspond to any
- member of the extended character set. */
-# define _WINT_T
-typedef unsigned int wint_t;
-#endif
#define __need_mbstate_t
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# define __need_wint_t
+#endif
#include <wchar.h>
#define _G_size_t size_t
typedef struct
@@ -41,7 +37,8 @@ typedef struct
#define _G_wchar_t wchar_t
#define _G_wint_t wint_t
#define _G_stat64 stat64
-#include <gconv.h>
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# include <gconv.h>
typedef union
{
struct __gconv_info __cd;
@@ -51,6 +48,7 @@ typedef union
struct __gconv_step_data __data;
} __combined;
} _G_iconv_t;
+#endif
typedef int _G_int16_t __attribute__ ((__mode__ (__HI__)));
typedef int _G_int32_t __attribute__ ((__mode__ (__SI__)));
diff --git a/libc/sysdeps/mach/hurd/bits/fcntl.h b/libc/sysdeps/mach/hurd/bits/fcntl.h
index e709cc6fb..34e6baa04 100644
--- a/libc/sysdeps/mach/hurd/bits/fcntl.h
+++ b/libc/sysdeps/mach/hurd/bits/fcntl.h
@@ -1,5 +1,6 @@
/* O_*, F_*, FD_* bit values for GNU.
- Copyright (C) 1993,94,96,97,98,99,2000,01,04 Free Software Foundation, Inc.
+ Copyright (C) 1993,1994,1996,1997,1998,1999,2000,2001,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
@@ -70,6 +71,7 @@
#define O_SYNC O_FSYNC
#ifdef __USE_GNU
# define O_NOATIME 0x0800 /* Don't set access time on read (owner). */
+# define O_CLOEXEC 0x00010000 /* Set FD_CLOEXEC. */
#endif
#ifdef __USE_MISC
# define O_SHLOCK 0x00020000 /* Open with shared file lock. */
diff --git a/libc/sysdeps/mach/hurd/bits/ioctls.h b/libc/sysdeps/mach/hurd/bits/ioctls.h
index 06a73df75..c9d313519 100644
--- a/libc/sysdeps/mach/hurd/bits/ioctls.h
+++ b/libc/sysdeps/mach/hurd/bits/ioctls.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992,93,96,97,98,99,2001 Free Software Foundation, Inc.
+/* Copyright (C) 1992,93,96,97,98,99,2001,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
@@ -284,25 +284,31 @@ enum __ioctl_datum { IOC_8, IOC_16, IOC_32, IOC_64 };
#define ODDP 0x00000040 /* get/send odd parity */
#define EVENP 0x00000080 /* get/send even parity */
#define ANYP 0x000000c0 /* get any parity/send none */
-#define NLDELAY 0x00000300 /* \n delay */
+#define NLDLY 0x00000300 /* \n delay */
+#define NLDELAY NLDLY /* traditional BSD name */
#define NL0 0x00000000
#define NL1 0x00000100 /* tty 37 */
#define NL2 0x00000200 /* vt05 */
#define NL3 0x00000300
-#define TBDELAY 0x00000c00 /* horizontal tab delay */
+#define TABDLY 0x00000c00 /* horizontal tab delay */
+#define TBDELAY TABDLY /* traditional BSD name */
#define TAB0 0x00000000
#define TAB1 0x00000400 /* tty 37 */
#define TAB2 0x00000800
+#define TAB3 0x00000c00
#define XTABS 0x00000c00 /* expand tabs on output */
-#define CRDELAY 0x00003000 /* \r delay */
+#define CRDLY 0x00003000 /* \r delay */
+#define CRDELAY CRDLY /* traditional BSD name */
#define CR0 0x00000000
#define CR1 0x00001000 /* tn 300 */
#define CR2 0x00002000 /* tty 37 */
#define CR3 0x00003000 /* concept 100 */
-#define VTDELAY 0x00004000 /* vertical tab delay */
+#define VTDLY 0x00004000 /* vertical tab delay */
+#define VTDELAY VTDLY /* traditional BSD name */
#define FF0 0x00000000
#define FF1 0x00004000 /* tty 37 */
-#define BSDELAY 0x00008000 /* \b delay */
+#define BSDLY 0x00008000 /* \b delay */
+#define BSDELAY BSDLY /* traditional BSD name */
#define BS0 0x00000000
#define BS1 0x00008000
#define ALLDELAY (NLDELAY|TBDELAY|CRDELAY|VTDELAY|BSDELAY)
diff --git a/libc/sysdeps/mach/hurd/i386/tls.h b/libc/sysdeps/mach/hurd/i386/tls.h
index 972cac57a..d98b485b9 100644
--- a/libc/sysdeps/mach/hurd/i386/tls.h
+++ b/libc/sysdeps/mach/hurd/i386/tls.h
@@ -1,5 +1,5 @@
/* Definitions for thread-local data handling. Hurd/i386 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
@@ -29,7 +29,7 @@
thread pointer points to is unspecified. Allocate the TCB there. */
# define TLS_TCB_AT_TP 1
-# ifndef ASSEMBLER
+# ifndef __ASSEMBLER__
/* Use i386-specific RPCs to arrange that %gs segment register prefix
addresses the TCB in each thread. */
@@ -165,7 +165,7 @@ _hurd_tls_fork (thread_t child, struct i386_thread_state *state)
return err;
}
-# endif /* !ASSEMBLER */
+# endif /* !__ASSEMBLER__ */
#endif /* HAVE_TLS_SUPPORT */
#endif /* i386/tls.h */
diff --git a/libc/sysdeps/mach/hurd/sigaction.c b/libc/sysdeps/mach/hurd/sigaction.c
index 3dc530955..fe452e828 100644
--- a/libc/sysdeps/mach/hurd/sigaction.c
+++ b/libc/sysdeps/mach/hurd/sigaction.c
@@ -1,4 +1,6 @@
-/* Copyright (C) 1991,92,93,94,95,96,97,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2002, 2007
+ Free Software Foundation, Inc.
+
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -68,7 +70,7 @@ __sigaction (sig, act, oact)
__spin_lock (&ss->lock);
pending = ss->pending & ~ss->blocked;
}
- else if (a.sa_handler == SIG_IGN || a.sa_handler == SIG_DFL)
+ else if (act != NULL && (a.sa_handler == SIG_IGN || a.sa_handler == SIG_DFL))
/* We are changing to an action that might be to ignore SIG signals.
If SIG is blocked and pending and the new action is to ignore it, we
must remove it from the pending set now; if the action is changed
diff --git a/libc/sysdeps/mach/hurd/sigsuspend.c b/libc/sysdeps/mach/hurd/sigsuspend.c
index 96b3857c7..7e32472ce 100644
--- a/libc/sysdeps/mach/hurd/sigsuspend.c
+++ b/libc/sysdeps/mach/hurd/sigsuspend.c
@@ -1,4 +1,6 @@
-/* Copyright (C) 1991,92,93,94,95,96,97,98,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2002, 2007
+ Free Software Foundation, Inc.
+
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -80,4 +82,5 @@ __sigsuspend (set)
return -1;
}
libc_hidden_def (__sigsuspend)
+strong_alias (__sigsuspend, sigsuspend_not_cancel)
weak_alias (__sigsuspend, sigsuspend)
diff --git a/libc/sysdeps/mach/hurd/tls.h b/libc/sysdeps/mach/hurd/tls.h
index cce42ef37..8ad3f1a28 100644
--- a/libc/sysdeps/mach/hurd/tls.h
+++ b/libc/sysdeps/mach/hurd/tls.h
@@ -1,5 +1,5 @@
/* Definitions for thread-local data handling. Hurd version.
- Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2003, 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
@@ -20,7 +20,7 @@
#ifndef _TLS_H
#define _TLS_H
-#if defined HAVE_TLS_SUPPORT && !defined ASSEMBLER
+#if defined HAVE_TLS_SUPPORT && !defined __ASSEMBLER__
# include <stddef.h>
# include <stdbool.h>
diff --git a/libc/sysdeps/mach/i386/sysdep.h b/libc/sysdeps/mach/i386/sysdep.h
index 1f138f475..4fc5d50f3 100644
--- a/libc/sysdeps/mach/i386/sysdep.h
+++ b/libc/sysdeps/mach/i386/sysdep.h
@@ -1,4 +1,6 @@
-/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 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
@@ -16,6 +18,10 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+/* Defines RTLD_PRIVATE_ERRNO and USE_DL_SYSINFO. */
+#include <dl-sysdep.h>
+#include <tls.h>
+
#define LOSE asm volatile ("hlt")
#define SNARF_ARGS(entry_sp, argc, argv, envp) \
diff --git a/libc/sysdeps/posix/posix_fallocate64.c b/libc/sysdeps/posix/posix_fallocate64.c
index 64ca9ae83..07e2a00bf 100644
--- a/libc/sysdeps/posix/posix_fallocate64.c
+++ b/libc/sysdeps/posix/posix_fallocate64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2003, 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,6 +93,7 @@ __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len)
return 0;
}
+#undef __posix_fallocate64_l64
#include <shlib-compat.h>
#include <bits/wordsize.h>
diff --git a/libc/sysdeps/posix/tempname.c b/libc/sysdeps/posix/tempname.c
index c8973a085..eab658da3 100644
--- a/libc/sysdeps/posix/tempname.c
+++ b/libc/sysdeps/posix/tempname.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1999, 2000, 2001, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1991-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
@@ -37,9 +37,8 @@
#endif
#ifndef __GT_FILE
# define __GT_FILE 0
-# define __GT_BIGFILE 1
-# define __GT_DIR 2
-# define __GT_NOCREATE 3
+# define __GT_DIR 1
+# define __GT_NOCREATE 2
#endif
#if STDC_HEADERS || _LIBC
@@ -220,12 +219,11 @@ static const char letters[] =
at the time of the call.
__GT_FILE: create the file using open(O_CREAT|O_EXCL)
and return a read-write fd. The file is mode 0600.
- __GT_BIGFILE: same as __GT_FILE but use open64().
__GT_DIR: create a directory, which will be mode 0700.
We use a clever algorithm to get hard-to-predict names. */
int
-__gen_tempname (char *tmpl, int kind)
+__gen_tempname (char *tmpl, int flags, int kind)
{
int len;
char *XXXXXX;
@@ -298,11 +296,9 @@ __gen_tempname (char *tmpl, int kind)
switch (kind)
{
case __GT_FILE:
- fd = __open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
- break;
-
- case __GT_BIGFILE:
- fd = __open64 (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
+ fd = __open (tmpl,
+ (flags & ~ACCESSPERMS)
+ | O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
break;
case __GT_DIR:
diff --git a/libc/sysdeps/powerpc/powerpc32/power4/memcmp.S b/libc/sysdeps/powerpc/powerpc32/power4/memcmp.S
index 471530273..75b328403 100644
--- a/libc/sysdeps/powerpc/powerpc32/power4/memcmp.S
+++ b/libc/sysdeps/powerpc/powerpc32/power4/memcmp.S
@@ -23,6 +23,7 @@
/* int [r3] memcmp (const char *s1 [r3], const char *s2 [r4], size_t size [r5]) */
+ .machine power4
EALIGN (BP_SYM(memcmp), 4, 0)
CALL_MCOUNT
diff --git a/libc/sysdeps/powerpc/powerpc32/power4/memcpy.S b/libc/sysdeps/powerpc/powerpc32/power4/memcpy.S
index c48db2f3d..73020c6da 100644
--- a/libc/sysdeps/powerpc/powerpc32/power4/memcpy.S
+++ b/libc/sysdeps/powerpc/powerpc32/power4/memcpy.S
@@ -34,6 +34,7 @@
possible when both source and destination are word aligned.
Each case has an optimized unrolled loop. */
+ .machine power4
EALIGN (BP_SYM (memcpy), 5, 0)
CALL_MCOUNT
diff --git a/libc/sysdeps/powerpc/powerpc32/power4/memset.S b/libc/sysdeps/powerpc/powerpc32/power4/memset.S
index b07ed3c2d..5dd1d943c 100644
--- a/libc/sysdeps/powerpc/powerpc32/power4/memset.S
+++ b/libc/sysdeps/powerpc/powerpc32/power4/memset.S
@@ -28,6 +28,7 @@
cache line (1024 bits). There is a special case for setting cache lines
to 0, to take advantage of the dcbz instruction. */
+ .machine power4
EALIGN (BP_SYM (memset), 5, 0)
CALL_MCOUNT
diff --git a/libc/sysdeps/powerpc/powerpc32/power6/fpu/s_llrint.S b/libc/sysdeps/powerpc/powerpc32/power6/fpu/s_llrint.S
index bcbc1fc3e..528607602 100644
--- a/libc/sysdeps/powerpc/powerpc32/power6/fpu/s_llrint.S
+++ b/libc/sysdeps/powerpc/powerpc32/power6/fpu/s_llrint.S
@@ -18,6 +18,7 @@
02110-1301 USA. */
#include <sysdep.h>
+#include <math_ldbl_opt.h>
/* long long int[r3, r4] __llrint (double x[fp1]) */
ENTRY (__llrint)
diff --git a/libc/sysdeps/powerpc/powerpc32/power6/memcpy.S b/libc/sysdeps/powerpc/powerpc32/power6/memcpy.S
index e8d56eb13..ba45fd250 100644
--- a/libc/sysdeps/powerpc/powerpc32/power6/memcpy.S
+++ b/libc/sysdeps/powerpc/powerpc32/power6/memcpy.S
@@ -34,6 +34,7 @@
possible when both source and destination are word aligned.
Each case has an optimized unrolled loop. */
+ .machine power6
EALIGN (BP_SYM (memcpy), 5, 0)
CALL_MCOUNT
diff --git a/libc/sysdeps/powerpc/powerpc32/power6/memset.S b/libc/sysdeps/powerpc/powerpc32/power6/memset.S
index 71c1209fa..10fb7b978 100644
--- a/libc/sysdeps/powerpc/powerpc32/power6/memset.S
+++ b/libc/sysdeps/powerpc/powerpc32/power6/memset.S
@@ -1,5 +1,5 @@
-/* Optimized memset implementation for PowerPC64.
- Copyright (C) 1997,99, 2000,02,03, 2006 Free Software Foundation, Inc.
+/* Optimized 32-bit memset implementation for POWER6.
+ Copyright (C) 1997,99, 2000,02,03,06,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,8 @@
cache line (1024 bits). There is a special case for setting cache lines
to 0, to take advantage of the dcbz instruction. */
-EALIGN (BP_SYM (memset), 5, 0)
+ .machine power6
+EALIGN (BP_SYM (memset), 7, 0)
CALL_MCOUNT
#define rTMP r0
@@ -41,15 +42,13 @@ EALIGN (BP_SYM (memset), 5, 0)
#define rMEMP2 r8
#define rNEG64 r8 /* Constant -64 for clearing with dcbz. */
-#define rCLS r8 /* Cache line size (known to be 128). */
-#define rCLM r9 /* Cache line size mask to check for cache alignment. */
+#define rMEMP3 r9 /* Alt mem pointer. */
L(_memset):
/* Take care of case for size <= 4. */
cmplwi cr1, rLEN, 4
andi. rALIGN, rMEMP0, 3
mr rMEMP, rMEMP0
ble- cr1, L(small)
-
/* Align to word boundary. */
cmplwi cr5, rLEN, 31
rlwimi rCHR, rCHR, 8, 16, 23 /* Replicate byte to halfword. */
@@ -82,6 +81,7 @@ L(aligned):
bf 28, L(a1)
stw rCHR, -4(rMEMP2)
stwu rCHR, -8(rMEMP2)
+ nop
L(a1): blt cr1, L(a2)
stw rCHR, -4(rMEMP2)
stw rCHR, -8(rMEMP2)
@@ -90,7 +90,7 @@ L(a1): blt cr1, L(a2)
L(a2): bf 29, L(caligned)
stw rCHR, -4(rMEMP2)
- .align 4
+ .align 3
/* Now aligned to a 32 byte boundary. */
L(caligned):
cmplwi cr1, rCHR, 0
@@ -98,83 +98,394 @@ L(caligned):
mtcrf 0x01, rLEN
beq cr1, L(zloopstart) /* Special case for clearing memory using dcbz. */
L(nondcbz):
- srwi rTMP, rALIGN, 5
- mtctr rTMP
beq L(medium) /* We may not actually get to do a full line. */
- clrlwi. rLEN, rLEN, 27
- add rMEMP, rMEMP, rALIGN
- li rNEG64, -0x40
- bdz L(cloopdone)
+ nop
+/* Storing a non-zero "c" value. We are aligned at a sector (32-byte)
+ boundary may not be at cache line (128-byte) boundary. */
+L(nzloopstart):
+/* memset in 32-byte chunks until we get to a cache line boundary.
+ If rLEN is less then the distance to the next cache-line boundary use
+ cacheAligned1 code to finish the tail. */
+ cmplwi cr1,rLEN,128
+
+ andi. rTMP,rMEMP,127
+ blt cr1,L(cacheAligned1)
+ addi rMEMP3,rMEMP,32
+ beq L(nzCacheAligned)
+ addi rLEN,rLEN,-32
+ stw rCHR,0(rMEMP)
+ stw rCHR,4(rMEMP)
+ stw rCHR,8(rMEMP)
+ stw rCHR,12(rMEMP)
+ stw rCHR,16(rMEMP)
+ stw rCHR,20(rMEMP)
+ addi rMEMP,rMEMP,32
+ andi. rTMP,rMEMP3,127
+ stw rCHR,-8(rMEMP3)
+ stw rCHR,-4(rMEMP3)
+ beq L(nzCacheAligned)
+ addi rLEN,rLEN,-32
+ stw rCHR,0(rMEMP3)
+ stw rCHR,4(rMEMP3)
+ addi rMEMP,rMEMP,32
+ stw rCHR,8(rMEMP3)
+ stw rCHR,12(rMEMP3)
+ andi. rTMP,rMEMP,127
+ stw rCHR,16(rMEMP3)
+ stw rCHR,20(rMEMP3)
+ stw rCHR,24(rMEMP3)
+ stw rCHR,28(rMEMP3)
+
+ beq L(nzCacheAligned)
+ addi rLEN,rLEN,-32
+/* At this point we can overrun the store queue (pipe reject) so it is
+ time to slow things down. The store queue can merge two adjacent
+ stores into a single L1/L2 op, but the L2 is clocked at 1/2 the CPU.
+ So we add "group ending nops" to guarantee that we dispatch only two
+ stores every other cycle. */
+ ori r1,r1,0
+ ori r1,r1,0
+ stw rCHR,32(rMEMP3)
+ stw rCHR,36(rMEMP3)
+ addi rMEMP,rMEMP,32
+ cmplwi cr1,rLEN,128
+ ori r1,r1,0
+ ori r1,r1,0
+ stw rCHR,40(rMEMP3)
+ stw rCHR,44(rMEMP3)
+ ori r1,r1,0
+ ori r1,r1,0
+ stw rCHR,48(rMEMP3)
+ stw rCHR,52(rMEMP3)
+ ori r1,r1,0
+ ori r1,r1,0
+ stw rCHR,56(rMEMP3)
+ stw rCHR,60(rMEMP3)
+ blt cr1,L(cacheAligned1)
+ b L(nzCacheAligned)
+
+/* Now we are aligned to the cache line and can use dcbtst. */
+ .align 5
+L(nzCacheAligned):
+ cmplwi cr1,rLEN,128
+ cmplwi cr6,rLEN,256
+ blt cr1,L(cacheAligned1)
+ blt cr6,L(nzCacheAligned128)
.align 4
-L(c3): dcbtst rNEG64, rMEMP
- stw rCHR, -4(rMEMP)
- stw rCHR, -8(rMEMP)
- stw rCHR, -12(rMEMP)
- stw rCHR, -16(rMEMP)
- stw rCHR, -20(rMEMP)
- stw rCHR, -24(rMEMP)
- stw rCHR, -28(rMEMP)
- stwu rCHR, -32(rMEMP)
- bdnz L(c3)
-L(cloopdone):
- stw rCHR, -4(rMEMP)
- stw rCHR, -8(rMEMP)
- stw rCHR, -12(rMEMP)
- stw rCHR, -16(rMEMP)
- cmplwi cr1, rLEN, 16
- stw rCHR, -20(rMEMP)
- stw rCHR, -24(rMEMP)
- stw rCHR, -28(rMEMP)
- stwu rCHR, -32(rMEMP)
- beqlr
- add rMEMP, rMEMP, rALIGN
- b L(medium_tail2)
+L(nzCacheAligned128):
+ nop
+ addi rMEMP3,rMEMP,64
+ stw rCHR,0(rMEMP)
+ stw rCHR,4(rMEMP)
+ stw rCHR,8(rMEMP)
+ stw rCHR,12(rMEMP)
+ stw rCHR,16(rMEMP)
+ stw rCHR,20(rMEMP)
+ stw rCHR,24(rMEMP)
+ stw rCHR,28(rMEMP)
+ stw rCHR,32(rMEMP)
+ stw rCHR,36(rMEMP)
+ stw rCHR,40(rMEMP)
+ stw rCHR,44(rMEMP)
+ stw rCHR,48(rMEMP)
+ stw rCHR,52(rMEMP)
+ stw rCHR,56(rMEMP)
+ stw rCHR,60(rMEMP)
+ addi rMEMP,rMEMP3,64
+ addi rLEN,rLEN,-128
+/* At this point we can overrun the store queue (pipe reject) so it is
+ time to slow things down. The store queue can merge two adjacent
+ stores into a single L1/L2 op, but the L2 is clocked at 1/2 the CPU.
+ So we add "group ending nops" to guarantee that we dispatch only one
+ store per cycle. */
+ stw rCHR,0(rMEMP3)
+ ori r1,r1,0
+ stw rCHR,4(rMEMP3)
+ ori r1,r1,0
+ stw rCHR,8(rMEMP3)
+ ori r1,r1,0
+ stw rCHR,12(rMEMP3)
+ ori r1,r1,0
+ stw rCHR,16(rMEMP3)
+ ori r1,r1,0
+ stw rCHR,20(rMEMP3)
+ ori r1,r1,0
+ stw rCHR,24(rMEMP3)
+ ori r1,r1,0
+ stw rCHR,28(rMEMP3)
+ ori r1,r1,0
+ stw rCHR,32(rMEMP3)
+ ori r1,r1,0
+ stw rCHR,36(rMEMP3)
+ ori r1,r1,0
+ stw rCHR,40(rMEMP3)
+ ori r1,r1,0
+ stw rCHR,44(rMEMP3)
+ ori r1,r1,0
+ stw rCHR,48(rMEMP3)
+ ori r1,r1,0
+ stw rCHR,52(rMEMP3)
+ ori r1,r1,0
+ stw rCHR,56(rMEMP3)
+ ori r1,r1,0
+ stw rCHR,60(rMEMP3)
+ blt cr6,L(cacheAligned1)
+#ifndef NOT_IN_libc
+ lfd 0,-128(rMEMP)
+#endif
+ b L(nzCacheAligned256)
+ .align 5
+L(nzCacheAligned256):
+ cmplwi cr1,rLEN,256
+ addi rMEMP3,rMEMP,64
+#ifdef NOT_IN_libc
+/* When we are not in libc we should use only GPRs to avoid the FPU lock
+ interrupt. */
+ stw rCHR,0(rMEMP)
+ stw rCHR,4(rMEMP)
+ stw rCHR,8(rMEMP)
+ stw rCHR,12(rMEMP)
+ stw rCHR,16(rMEMP)
+ stw rCHR,20(rMEMP)
+ stw rCHR,24(rMEMP)
+ stw rCHR,28(rMEMP)
+ stw rCHR,32(rMEMP)
+ stw rCHR,36(rMEMP)
+ stw rCHR,40(rMEMP)
+ stw rCHR,44(rMEMP)
+ stw rCHR,48(rMEMP)
+ stw rCHR,52(rMEMP)
+ stw rCHR,56(rMEMP)
+ stw rCHR,60(rMEMP)
+ addi rMEMP,rMEMP3,64
+ addi rLEN,rLEN,-128
+ stw rCHR,0(rMEMP3)
+ stw rCHR,4(rMEMP3)
+ stw rCHR,8(rMEMP3)
+ stw rCHR,12(rMEMP3)
+ stw rCHR,16(rMEMP3)
+ stw rCHR,20(rMEMP3)
+ stw rCHR,24(rMEMP3)
+ stw rCHR,28(rMEMP3)
+ stw rCHR,32(rMEMP3)
+ stw rCHR,36(rMEMP3)
+ stw rCHR,40(rMEMP3)
+ stw rCHR,44(rMEMP3)
+ stw rCHR,48(rMEMP3)
+ stw rCHR,52(rMEMP3)
+ stw rCHR,56(rMEMP3)
+ stw rCHR,60(rMEMP3)
+#else
+/* We are in libc and this is a long memset so we can use FPRs and can afford
+ occasional FPU locked interrupts. */
+ stfd 0,0(rMEMP)
+ stfd 0,8(rMEMP)
+ stfd 0,16(rMEMP)
+ stfd 0,24(rMEMP)
+ stfd 0,32(rMEMP)
+ stfd 0,40(rMEMP)
+ stfd 0,48(rMEMP)
+ stfd 0,56(rMEMP)
+ addi rMEMP,rMEMP3,64
+ addi rLEN,rLEN,-128
+ stfd 0,0(rMEMP3)
+ stfd 0,8(rMEMP3)
+ stfd 0,16(rMEMP3)
+ stfd 0,24(rMEMP3)
+ stfd 0,32(rMEMP3)
+ stfd 0,40(rMEMP3)
+ stfd 0,48(rMEMP3)
+ stfd 0,56(rMEMP3)
+#endif
+ bge cr1,L(nzCacheAligned256)
+ dcbtst 0,rMEMP
+ b L(cacheAligned1)
- .align 5
-/* Clear lines of memory in 128-byte chunks. */
+ .align 4
+/* Storing a zero "c" value. We are aligned at a sector (32-byte)
+ boundary but may not be at cache line (128-byte) boundary. If the
+ remaining length spans a full cache line we can use the Data cache
+ block zero instruction. */
L(zloopstart):
-/* If the remaining length is less the 32 bytes, don't bother getting
- the cache line size. */
+/* memset in 32-byte chunks until we get to a cache line boundary.
+ If rLEN is less then the distance to the next cache-line boundary use
+ cacheAligned1 code to finish the tail. */
+ cmplwi cr1,rLEN,128
beq L(medium)
- li rCLS,128 /* cache line size is 128 */
- dcbt 0,rMEMP
L(getCacheAligned):
- cmplwi cr1,rLEN,32
andi. rTMP,rMEMP,127
- blt cr1,L(handletail32)
+ blt cr1,L(cacheAligned1)
+ addi rMEMP3,rMEMP,32
+ beq L(cacheAligned)
+ addi rLEN,rLEN,-32
+ stw rCHR,0(rMEMP)
+ stw rCHR,4(rMEMP)
+ stw rCHR,8(rMEMP)
+ stw rCHR,12(rMEMP)
+ stw rCHR,16(rMEMP)
+ stw rCHR,20(rMEMP)
+ addi rMEMP,rMEMP,32
+ andi. rTMP,rMEMP3,127
+ stw rCHR,-8(rMEMP3)
+ stw rCHR,-4(rMEMP3)
+L(getCacheAligned2):
beq L(cacheAligned)
+ addi rLEN,rLEN,-32
addi rMEMP,rMEMP,32
+ stw rCHR,0(rMEMP3)
+ stw rCHR,4(rMEMP3)
+ stw rCHR,8(rMEMP3)
+ stw rCHR,12(rMEMP3)
+ andi. rTMP,rMEMP,127
+ nop
+ stw rCHR,16(rMEMP3)
+ stw rCHR,20(rMEMP3)
+ stw rCHR,24(rMEMP3)
+ stw rCHR,28(rMEMP3)
+L(getCacheAligned3):
+ beq L(cacheAligned)
+/* At this point we can overrun the store queue (pipe reject) so it is
+ time to slow things down. The store queue can merge two adjacent
+ stores into a single L1/L2 op, but the L2 is clocked at 1/2 the CPU.
+ So we add "group ending nops" to guarantee that we dispatch only two
+ stores every other cycle. */
addi rLEN,rLEN,-32
- stw rCHR,-32(rMEMP)
- stw rCHR,-28(rMEMP)
- stw rCHR,-24(rMEMP)
- stw rCHR,-20(rMEMP)
- stw rCHR,-16(rMEMP)
- stw rCHR,-12(rMEMP)
- stw rCHR,-8(rMEMP)
- stw rCHR,-4(rMEMP)
- b L(getCacheAligned)
+ ori r1,r1,0
+ ori r1,r1,0
+ stw rCHR,32(rMEMP3)
+ stw rCHR,36(rMEMP3)
+ addi rMEMP,rMEMP,32
+ cmplwi cr1,rLEN,128
+ ori r1,r1,0
+ stw rCHR,40(rMEMP3)
+ stw rCHR,44(rMEMP3)
+ cmplwi cr6,rLEN,256
+ li rMEMP2,128
+ ori r1,r1,0
+ stw rCHR,48(rMEMP3)
+ stw rCHR,52(rMEMP3)
+ ori r1,r1,0
+ ori r1,r1,0
+ stw rCHR,56(rMEMP3)
+ stw rCHR,60(rMEMP3)
+ blt cr1,L(cacheAligned1)
+ blt cr6,L(cacheAligned128)
+ b L(cacheAlignedx)
/* Now we are aligned to the cache line and can use dcbz. */
.align 4
L(cacheAligned):
- cmplw cr1,rLEN,rCLS
- blt cr1,L(handletail32)
+ cmplwi cr1,rLEN,128
+ cmplwi cr6,rLEN,256
+ blt cr1,L(cacheAligned1)
+ li rMEMP2,128
+L(cacheAlignedx):
+ cmpldi cr5,rLEN,640
+ blt cr6,L(cacheAligned128)
+ bgt cr5,L(cacheAligned512)
+ cmplwi cr6,rLEN,512
dcbz 0,rMEMP
- subf rLEN,rCLS,rLEN
- add rMEMP,rMEMP,rCLS
- b L(cacheAligned)
+ cmplwi cr1,rLEN,384
+ dcbz rMEMP2,rMEMP
+ addi rMEMP,rMEMP,256
+ addi rLEN,rLEN,-256
+ blt cr1,L(cacheAligned1)
+ blt cr6,L(cacheAligned128)
+ b L(cacheAligned256)
+ .align 5
+/* A simple loop for the longer (>640 bytes) lengths. This form limits
+ the branch miss-predicted to exactly 1 at loop exit.*/
+L(cacheAligned512):
+ cmpli cr1,rLEN,128
+ blt cr1,L(cacheAligned1)
+ dcbz 0,rMEMP
+ addi rLEN,rLEN,-128
+ addi rMEMP,rMEMP,128
+ b L(cacheAligned512)
+ .align 5
+L(cacheAligned256):
+ cmplwi cr6,rLEN,512
+ dcbz 0,rMEMP
+ cmplwi cr1,rLEN,384
+ dcbz rMEMP2,rMEMP
+ addi rMEMP,rMEMP,256
+ addi rLEN,rLEN,-256
+ bge cr6,L(cacheAligned256)
+ blt cr1,L(cacheAligned1)
+ .align 4
+L(cacheAligned128):
+ dcbz 0,rMEMP
+ addi rMEMP,rMEMP,128
+ addi rLEN,rLEN,-128
+ .align 4
+L(cacheAligned1):
+ cmplwi cr1,rLEN,32
+ blt cr1,L(handletail32)
+ addi rMEMP3,rMEMP,32
+ addi rLEN,rLEN,-32
+ stw rCHR,0(rMEMP)
+ stw rCHR,4(rMEMP)
+ stw rCHR,8(rMEMP)
+ stw rCHR,12(rMEMP)
+ stw rCHR,16(rMEMP)
+ stw rCHR,20(rMEMP)
+ addi rMEMP,rMEMP,32
+ cmplwi cr1,rLEN,32
+ stw rCHR,-8(rMEMP3)
+ stw rCHR,-4(rMEMP3)
+L(cacheAligned2):
+ blt cr1,L(handletail32)
+ addi rLEN,rLEN,-32
+ stw rCHR,0(rMEMP3)
+ stw rCHR,4(rMEMP3)
+ stw rCHR,8(rMEMP3)
+ stw rCHR,12(rMEMP3)
+ addi rMEMP,rMEMP,32
+ cmplwi cr1,rLEN,32
+ stw rCHR,16(rMEMP3)
+ stw rCHR,20(rMEMP3)
+ stw rCHR,24(rMEMP3)
+ stw rCHR,28(rMEMP3)
+ nop
+L(cacheAligned3):
+ blt cr1,L(handletail32)
+/* At this point we can overrun the store queue (pipe reject) so it is
+ time to slow things down. The store queue can merge two adjacent
+ stores into a single L1/L2 op, but the L2 is clocked at 1/2 the CPU.
+ So we add "group ending nops" to guarantee that we dispatch only two
+ stores every other cycle. */
+ ori r1,r1,0
+ ori r1,r1,0
+ addi rMEMP,rMEMP,32
+ addi rLEN,rLEN,-32
+ ori r1,r1,0
+ ori r1,r1,0
+ stw rCHR,32(rMEMP3)
+ stw rCHR,36(rMEMP3)
+ ori r1,r1,0
+ ori r1,r1,0
+ stw rCHR,40(rMEMP3)
+ stw rCHR,44(rMEMP3)
+ ori r1,r1,0
+ ori r1,r1,0
+ stw rCHR,48(rMEMP3)
+ stw rCHR,52(rMEMP3)
+ ori r1,r1,0
+ ori r1,r1,0
+ stw rCHR,56(rMEMP3)
+ stw rCHR,60(rMEMP3)
-/* We are here because the cache line size was set and the remainder
- (rLEN) is less than the actual cache line size.
- So set up the preconditions for L(nondcbz) and go there. */
+/* We are here because the length or remainder (rLEN) is less than the
+ cache line/sector size and does not justify aggressive loop unrolling.
+ So set up the preconditions for L(medium) and go there. */
.align 3
L(handletail32):
- clrrwi. rALIGN, rLEN, 5
- b L(nondcbz)
+ cmplwi cr1,rLEN,0
+ beqlr cr1
+ b L(medium)
- .align 5
+ .align 4
L(small):
/* Memset of 4 bytes or less. */
cmplwi cr5, rLEN, 1
@@ -199,10 +510,10 @@ L(medium_tail):
bt- 31, L(medium_31t)
bt- 30, L(medium_30t)
L(medium_30f):
- bt- 29, L(medium_29t)
+ bt 29, L(medium_29t)
L(medium_29f):
- bge- cr1, L(medium_27t)
- bflr- 28
+ bge cr1, L(medium_27t)
+ bflr 28
stw rCHR, -4(rMEMP)
stw rCHR, -8(rMEMP)
blr
@@ -215,14 +526,14 @@ L(medium_30t):
bf- 29, L(medium_29f)
L(medium_29t):
stwu rCHR, -4(rMEMP)
- blt- cr1, L(medium_27f)
+ blt cr1, L(medium_27f)
L(medium_27t):
stw rCHR, -4(rMEMP)
stw rCHR, -8(rMEMP)
stw rCHR, -12(rMEMP)
stwu rCHR, -16(rMEMP)
L(medium_27f):
- bflr- 28
+ bflr 28
L(medium_28t):
stw rCHR, -4(rMEMP)
stw rCHR, -8(rMEMP)
diff --git a/libc/sysdeps/powerpc/powerpc64/power4/memcmp.S b/libc/sysdeps/powerpc/powerpc64/power4/memcmp.S
index 8f74ca704..a5e0c758d 100644
--- a/libc/sysdeps/powerpc/powerpc64/power4/memcmp.S
+++ b/libc/sysdeps/powerpc/powerpc64/power4/memcmp.S
@@ -23,6 +23,7 @@
/* int [r3] memcmp (const char *s1 [r3], const char *s2 [r4], size_t size [r5]) */
+ .machine power4
EALIGN (BP_SYM(memcmp), 4, 0)
CALL_MCOUNT 3
diff --git a/libc/sysdeps/powerpc/powerpc64/power4/memcpy.S b/libc/sysdeps/powerpc/powerpc64/power4/memcpy.S
index 9910ebda8..56f313b4b 100644
--- a/libc/sysdeps/powerpc/powerpc64/power4/memcpy.S
+++ b/libc/sysdeps/powerpc/powerpc64/power4/memcpy.S
@@ -36,6 +36,7 @@
posible when both source and destination are doubleword aligned.
Each case has a optimized unrolled loop. */
+ .machine power4
EALIGN (BP_SYM (memcpy), 5, 0)
CALL_MCOUNT 3
diff --git a/libc/sysdeps/powerpc/powerpc64/power4/memset.S b/libc/sysdeps/powerpc/powerpc64/power4/memset.S
index 17b2d7695..e7a259acd 100644
--- a/libc/sysdeps/powerpc/powerpc64/power4/memset.S
+++ b/libc/sysdeps/powerpc/powerpc64/power4/memset.S
@@ -22,12 +22,6 @@
#include <bp-sym.h>
#include <bp-asm.h>
- .section ".toc","aw"
-.LC0:
- .tc __cache_line_size[TC],__cache_line_size
- .section ".text"
- .align 2
-
/* __ptr_t [r3] memset (__ptr_t s [r3], int c [r4], size_t n [r5]));
Returns 's'.
@@ -35,6 +29,7 @@
cache line (256 bits). There is a special case for setting cache lines
to 0, to take advantage of the dcbz instruction. */
+ .machine power4
EALIGN (BP_SYM (memset), 5, 0)
CALL_MCOUNT 3
diff --git a/libc/sysdeps/powerpc/powerpc64/power6/memset.S b/libc/sysdeps/powerpc/powerpc64/power6/memset.S
index 6daaa2c36..ea74c117d 100644
--- a/libc/sysdeps/powerpc/powerpc64/power6/memset.S
+++ b/libc/sysdeps/powerpc/powerpc64/power6/memset.S
@@ -1,4 +1,4 @@
-/* Optimized memset implementation for PowerPC64.
+/* Optimized 64-bit memset implementation for POWER6.
Copyright (C) 1997, 1999, 2000, 2002, 2003, 2007
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -22,12 +22,6 @@
#include <bp-sym.h>
#include <bp-asm.h>
- .section ".toc","aw"
-.LC0:
- .tc __cache_line_size[TC],__cache_line_size
- .section ".text"
- .align 2
-
/* __ptr_t [r3] memset (__ptr_t s [r3], int c [r4], size_t n [r5]));
Returns 's'.
@@ -35,7 +29,8 @@
cache line (256 bits). There is a special case for setting cache lines
to 0, to take advantage of the dcbz instruction. */
-EALIGN (BP_SYM (memset), 5, 0)
+ .machine power6
+EALIGN (BP_SYM (memset), 7, 0)
CALL_MCOUNT 3
#define rTMP r0
@@ -53,10 +48,7 @@ EALIGN (BP_SYM (memset), 5, 0)
#endif
#define rALIGN r7 /* Number of bytes we are setting now (when aligning). */
#define rMEMP2 r8
-
-#define rNEG64 r8 /* Constant -64 for clearing with dcbz. */
-#define rCLS r8 /* Cache line size obtained from static. */
-#define rCLM r9 /* Cache line size mask to check for cache alignment. */
+#define rMEMP3 r9 /* Alt mem pointer. */
L(_memset):
#if __BOUNDED_POINTERS__
cmpldi cr1, rRTN, 0
@@ -70,7 +62,7 @@ L(b0):
cmpldi cr1, rLEN, 8
andi. rALIGN, rMEMP0, 7
mr rMEMP, rMEMP0
- ble- cr1, L(small)
+ ble cr1, L(small)
/* Align to doubleword boundary. */
cmpldi cr5, rLEN, 31
@@ -131,75 +123,217 @@ L(caligned):
clrrdi. rALIGN, rLEN, 5
mtcrf 0x01, rLEN
beq cr1, L(zloopstart) /* Special case for clearing memory using dcbz. */
-L(nondcbz):
- srdi rTMP, rALIGN, 5
- mtctr rTMP
beq L(medium) /* We may not actually get to do a full line. */
- clrldi. rLEN, rLEN, 59
- add rMEMP, rMEMP, rALIGN
- li rNEG64, -0x40
- bdz L(cloopdone)
+ .align 4
+/* Storing a non-zero "c" value. We are aligned at a sector (32-byte)
+ boundary may not be at cache line (128-byte) boundary. */
+L(nzloopstart):
+/* memset in 32-byte chunks until we get to a cache line boundary.
+ If rLEN is less then the distance to the next cache-line boundary use
+ cacheAligned1 code to finish the tail. */
+ cmpldi cr1,rLEN,128
- .align 4
-L(c3): dcbtst rNEG64, rMEMP
- std rCHR, -8(rMEMP)
- std rCHR, -16(rMEMP)
- std rCHR, -24(rMEMP)
- stdu rCHR, -32(rMEMP)
- bdnz L(c3)
- .align 4
-L(cloopdone):
- std rCHR, -8(rMEMP)
- std rCHR, -16(rMEMP)
- cmpldi cr1, rLEN, 16
- std rCHR, -24(rMEMP)
- stdu rCHR, -32(rMEMP)
- beqlr
- add rMEMP, rMEMP, rALIGN
- b L(medium_tail2)
+ andi. rTMP,rMEMP,127
+ blt cr1,L(cacheAligned1)
+ addi rMEMP3,rMEMP,32
+ beq L(nzCacheAligned)
+ addi rLEN,rLEN,-32
+ std rCHR,0(rMEMP)
+ std rCHR,8(rMEMP)
+ std rCHR,16(rMEMP)
+ addi rMEMP,rMEMP,32
+ andi. rTMP,rMEMP3,127
+ std rCHR,-8(rMEMP3)
+ beq L(nzCacheAligned)
+ addi rLEN,rLEN,-32
+ std rCHR,0(rMEMP3)
+ addi rMEMP,rMEMP,32
+ std rCHR,8(rMEMP3)
+ andi. rTMP,rMEMP,127
+ std rCHR,16(rMEMP3)
+ std rCHR,24(rMEMP3)
+
+ beq L(nzCacheAligned)
+ addi rLEN,rLEN,-32
+ std rCHR,32(rMEMP3)
+ addi rMEMP,rMEMP,32
+ cmpldi cr1,rLEN,128
+ std rCHR,40(rMEMP3)
+ cmpldi cr6,rLEN,256
+ li rMEMP2,128
+ std rCHR,48(rMEMP3)
+ std rCHR,56(rMEMP3)
+ blt cr1,L(cacheAligned1)
+ b L(nzCacheAligned128)
+
+/* Now we are aligned to the cache line and can use dcbtst. */
+ .align 4
+L(nzCacheAligned):
+ cmpldi cr1,rLEN,128
+ blt cr1,L(cacheAligned1)
+ b L(nzCacheAligned128)
+ .align 5
+L(nzCacheAligned128):
+ cmpldi cr1,rLEN,256
+ addi rMEMP3,rMEMP,64
+ std rCHR,0(rMEMP)
+ std rCHR,8(rMEMP)
+ std rCHR,16(rMEMP)
+ std rCHR,24(rMEMP)
+ std rCHR,32(rMEMP)
+ std rCHR,40(rMEMP)
+ std rCHR,48(rMEMP)
+ std rCHR,56(rMEMP)
+ addi rMEMP,rMEMP3,64
+ addi rLEN,rLEN,-128
+ std rCHR,0(rMEMP3)
+ std rCHR,8(rMEMP3)
+ std rCHR,16(rMEMP3)
+ std rCHR,24(rMEMP3)
+ std rCHR,32(rMEMP3)
+ std rCHR,40(rMEMP3)
+ std rCHR,48(rMEMP3)
+ std rCHR,56(rMEMP3)
+ bge cr1,L(nzCacheAligned128)
+ dcbtst 0,rMEMP
+ b L(cacheAligned1)
.align 5
-/* Clear lines of memory in 128-byte chunks. */
+/* Storing a zero "c" value. We are aligned at a sector (32-byte)
+ boundary but may not be at cache line (128-byte) boundary. If the
+ remaining length spans a full cache line we can use the Data cache
+ block zero instruction. */
L(zloopstart):
-/* If the remaining length is less the 32 bytes, don't bother getting
- the cache line size. */
+/* memset in 32-byte chunks until we get to a cache line boundary.
+ If rLEN is less then the distance to the next cache-line boundary use
+ cacheAligned1 code to finish the tail. */
+ cmpldi cr1,rLEN,128
beq L(medium)
- li rCLS,128 /* cache line size is 128 */
-
-/* Now we know the cache line size, and it is not 32-bytes, but
- we may not yet be aligned to the cache line. May have a partial
- line to fill, so touch it 1st. */
- dcbt 0,rMEMP
L(getCacheAligned):
- cmpldi cr1,rLEN,32
andi. rTMP,rMEMP,127
- blt cr1,L(handletail32)
- beq L(cacheAligned)
+ nop
+ blt cr1,L(cacheAligned1)
+ addi rMEMP3,rMEMP,32
+ beq L(cacheAligned)
+ addi rLEN,rLEN,-32
+ std rCHR,0(rMEMP)
+ std rCHR,8(rMEMP)
+ std rCHR,16(rMEMP)
addi rMEMP,rMEMP,32
+ andi. rTMP,rMEMP3,127
+ std rCHR,-8(rMEMP3)
+L(getCacheAligned2):
+ beq L(cacheAligned)
addi rLEN,rLEN,-32
- std rCHR,-32(rMEMP)
- std rCHR,-24(rMEMP)
- std rCHR,-16(rMEMP)
- std rCHR,-8(rMEMP)
- b L(getCacheAligned)
+ std rCHR,0(rMEMP3)
+ std rCHR,8(rMEMP3)
+ addi rMEMP,rMEMP,32
+ andi. rTMP,rMEMP,127
+ std rCHR,16(rMEMP3)
+ std rCHR,24(rMEMP3)
+L(getCacheAligned3):
+ beq L(cacheAligned)
+ addi rLEN,rLEN,-32
+ std rCHR,32(rMEMP3)
+ addi rMEMP,rMEMP,32
+ cmpldi cr1,rLEN,128
+ std rCHR,40(rMEMP3)
+ cmpldi cr6,rLEN,256
+ li rMEMP2,128
+ std rCHR,48(rMEMP3)
+ std rCHR,56(rMEMP3)
+ blt cr1,L(cacheAligned1)
+ blt cr6,L(cacheAligned128)
+ b L(cacheAlignedx)
/* Now we are aligned to the cache line and can use dcbz. */
- .align 4
+ .align 5
L(cacheAligned):
- cmpld cr1,rLEN,rCLS
- blt cr1,L(handletail32)
+ cmpldi cr1,rLEN,128
+ cmpldi cr6,rLEN,256
+ blt cr1,L(cacheAligned1)
+ li rMEMP2,128
+L(cacheAlignedx):
+ cmpldi cr5,rLEN,640
+ blt cr6,L(cacheAligned128)
+ bgt cr5,L(cacheAligned512)
+ cmpldi cr6,rLEN,512
+ dcbz 0,rMEMP
+ cmpldi cr1,rLEN,384
+ dcbz rMEMP2,rMEMP
+ addi rMEMP,rMEMP,256
+ addi rLEN,rLEN,-256
+ blt cr1,L(cacheAligned1)
+ blt cr6,L(cacheAligned128)
+ b L(cacheAligned256)
+ .align 5
+/* A simple loop for the longer (>640 bytes) lengths. This form limits
+ the branch miss-predicted to exactly 1 at loop exit.*/
+L(cacheAligned512):
+ cmpli cr1,rLEN,128
+ blt cr1,L(cacheAligned1)
+ dcbz 0,rMEMP
+ addi rLEN,rLEN,-128
+ addi rMEMP,rMEMP,128
+ b L(cacheAligned512)
+ .align 5
+L(cacheAligned256):
+
+ cmpldi cr6,rLEN,512
+
dcbz 0,rMEMP
- subf rLEN,rCLS,rLEN
- add rMEMP,rMEMP,rCLS
- b L(cacheAligned)
+ cmpldi cr1,rLEN,384
+ dcbz rMEMP2,rMEMP
+ addi rMEMP,rMEMP,256
+ addi rLEN,rLEN,-256
+
+ bge cr6,L(cacheAligned256)
+
+ blt cr1,L(cacheAligned1)
+ .align 4
+L(cacheAligned128):
+ dcbz 0,rMEMP
+ addi rMEMP,rMEMP,128
+ addi rLEN,rLEN,-128
+ nop
+L(cacheAligned1):
+ cmpldi cr1,rLEN,32
+ blt cr1,L(handletail32)
+ addi rMEMP3,rMEMP,32
+ addi rLEN,rLEN,-32
+ std rCHR,0(rMEMP)
+ std rCHR,8(rMEMP)
+ std rCHR,16(rMEMP)
+ addi rMEMP,rMEMP,32
+ cmpldi cr1,rLEN,32
+ std rCHR,-8(rMEMP3)
+L(cacheAligned2):
+ blt cr1,L(handletail32)
+ addi rLEN,rLEN,-32
+ std rCHR,0(rMEMP3)
+ std rCHR,8(rMEMP3)
+ addi rMEMP,rMEMP,32
+ cmpldi cr1,rLEN,32
+ std rCHR,16(rMEMP3)
+ std rCHR,24(rMEMP3)
+ nop
+L(cacheAligned3):
+ blt cr1,L(handletail32)
+ addi rMEMP,rMEMP,32
+ addi rLEN,rLEN,-32
+ std rCHR,32(rMEMP3)
+ std rCHR,40(rMEMP3)
+ std rCHR,48(rMEMP3)
+ std rCHR,56(rMEMP3)
-/* We are here because the cache line size was set and was not 32-bytes
- and the remainder (rLEN) is less than the actual cache line size.
- So set up the preconditions for L(nondcbz) and go there. */
+/* We are here because the length or remainder (rLEN) is less than the
+ cache line/sector size and does not justify aggressive loop unrolling.
+ So set up the preconditions for L(medium) and go there. */
.align 3
L(handletail32):
- clrrwi. rALIGN, rLEN, 5
- b L(nondcbz)
+ cmpldi cr1,rLEN,0
+ beqlr cr1
+ b L(medium)
.align 5
L(small):
@@ -237,10 +371,10 @@ L(medium_tail):
bt- 31, L(medium_31t)
bt- 30, L(medium_30t)
L(medium_30f):
- bt- 29, L(medium_29t)
+ bt 29, L(medium_29t)
L(medium_29f):
- bge- cr1, L(medium_27t)
- bflr- 28
+ bge cr1, L(medium_27t)
+ bflr 28
std rCHR, -8(rMEMP)
blr
@@ -252,12 +386,12 @@ L(medium_30t):
bf- 29, L(medium_29f)
L(medium_29t):
stwu rCHR, -4(rMEMP)
- blt- cr1, L(medium_27f)
+ blt cr1, L(medium_27f)
L(medium_27t):
std rCHR, -8(rMEMP)
stdu rCHR, -16(rMEMP)
L(medium_27f):
- bflr- 28
+ bflr 28
L(medium_28t):
std rCHR, -8(rMEMP)
blr
diff --git a/libc/sysdeps/powerpc/sched_cpucount.c b/libc/sysdeps/powerpc/sched_cpucount.c
new file mode 100644
index 000000000..f151eed23
--- /dev/null
+++ b/libc/sysdeps/powerpc/sched_cpucount.c
@@ -0,0 +1,23 @@
+/* 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 _ARCH_PWR5
+# define POPCNT(l) __builtin_popcountl (l)
+#endif
+
+#include <posix/sched_cpucount.c>
diff --git a/libc/sysdeps/s390/dl-procinfo.c b/libc/sysdeps/s390/dl-procinfo.c
new file mode 100644
index 000000000..32c6aef95
--- /dev/null
+++ b/libc/sysdeps/s390/dl-procinfo.c
@@ -0,0 +1,80 @@
+/* Data for s390 version of processor capability information.
+ 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. */
+
+/* This information must be kept in sync with the _DL_HWCAP_COUNT and
+ _DL_PLATFORM_COUNT definitions in procinfo.h.
+
+ If anything should be added here check whether the size of each string
+ is still ok with the given array size.
+
+ All the #ifdefs in the definitions are quite irritating but
+ necessary if we want to avoid duplicating the information. There
+ are three different modes:
+
+ - PROCINFO_DECL is defined. This means we are only interested in
+ declarations.
+
+ - PROCINFO_DECL is not defined:
+
+ + if SHARED is defined the file is included in an array
+ initializer. The .element = { ... } syntax is needed.
+
+ + if SHARED is not defined a normal array initialization is
+ needed.
+ */
+
+#ifndef PROCINFO_CLASS
+# define PROCINFO_CLASS
+#endif
+
+#if !defined PROCINFO_DECL && defined SHARED
+ ._dl_s390_cap_flags
+#else
+PROCINFO_CLASS const char _dl_s390_cap_flags[7][6]
+#endif
+#ifndef PROCINFO_DECL
+= {
+ "esan3", "zarch", "stfle", "msa", "ldisp", "eimm", "dfp"
+ }
+#endif
+#if !defined SHARED || defined PROCINFO_DECL
+;
+#else
+,
+#endif
+
+#if !defined PROCINFO_DECL && defined SHARED
+ ._dl_s390_platforms
+#else
+PROCINFO_CLASS const char _dl_s390_platforms[4][7]
+#endif
+#ifndef PROCINFO_DECL
+= {
+ "g5", "z900", "z990", "z9-109"
+ }
+#endif
+#if !defined SHARED || defined PROCINFO_DECL
+;
+#else
+,
+#endif
+
+#undef PROCINFO_DECL
+#undef PROCINFO_CLASS
diff --git a/libc/sysdeps/s390/dl-procinfo.h b/libc/sysdeps/s390/dl-procinfo.h
new file mode 100644
index 000000000..178d7cc01
--- /dev/null
+++ b/libc/sysdeps/s390/dl-procinfo.h
@@ -0,0 +1,99 @@
+/* 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. */
+
+#ifndef _DL_PROCINFO_H
+#define _DL_PROCINFO_H 1
+#include <ldsodefs.h>
+
+#define _DL_HWCAP_COUNT 7
+
+#define _DL_PLATFORMS_COUNT 4
+
+/* The kernel provides up to 32 capability bits with elf_hwcap. */
+#define _DL_FIRST_PLATFORM 32
+/* Mask to filter out platforms. */
+#define _DL_HWCAP_PLATFORM (((1ULL << _DL_PLATFORMS_COUNT) - 1) \
+ << _DL_FIRST_PLATFORM)
+
+/* Hardware capablity bit numbers are derived directly from the
+ facility indications as stored by the "store facility list" (STFL)
+ instruction. */
+
+enum
+{
+ HWCAP_S390_ESAN3 = 1 << 0,
+ HWCAP_S390_ZARCH = 1 << 1,
+ HWCAP_S390_STFLE = 1 << 2,
+ HWCAP_S390_MSA = 1 << 3,
+ HWCAP_S390_LDISP = 1 << 4,
+ HWCAP_S390_EIMM = 1 << 5,
+ HWCAP_S390_DFP = 1 << 6,
+};
+
+#define HWCAP_IMPORTANT (HWCAP_S390_ZARCH | HWCAP_S390_LDISP \
+ | HWCAP_S390_EIMM | HWCAP_S390_DFP)
+
+/* We cannot provide a general printing function. */
+#define _dl_procinfo(word) -1
+
+static inline const char *
+__attribute__ ((unused))
+_dl_hwcap_string (int idx)
+{
+ return GLRO(dl_s390_cap_flags)[idx];
+};
+
+static inline const char *
+__attribute__ ((unused))
+_dl_platform_string (int idx)
+{
+ return GLRO(dl_s390_platforms)[idx - _DL_FIRST_PLATFORM];
+};
+
+static inline int
+__attribute__ ((unused, always_inline))
+_dl_string_hwcap (const char *str)
+{
+ int i;
+
+ for (i = 0; i < _DL_HWCAP_COUNT; i++)
+ {
+ if (strcmp (str, GLRO(dl_s390_cap_flags)[i]) == 0)
+ return i;
+ }
+ return -1;
+};
+
+static inline int
+__attribute__ ((unused, always_inline))
+_dl_string_platform (const char *str)
+{
+ int i;
+
+ if (str != NULL)
+ for (i = 0; i < _DL_PLATFORMS_COUNT; ++i)
+ {
+ if (strcmp (str, GLRO(dl_s390_platforms)[i]) == 0)
+ return _DL_FIRST_PLATFORM + i;
+ }
+ return -1;
+};
+
+#endif /* dl-procinfo.h */
diff --git a/libc/sysdeps/sh/bsd-_setjmp.S b/libc/sysdeps/sh/bsd-_setjmp.S
index 2811fcfd1..dbfd95259 100644
--- a/libc/sysdeps/sh/bsd-_setjmp.S
+++ b/libc/sysdeps/sh/bsd-_setjmp.S
@@ -1,5 +1,5 @@
/* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'. SH version.
- Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2002, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -36,14 +36,14 @@ ENTRY (_setjmp)
mov.l 3f, r1
mov.l @(r0,r1), r1
jmp @r1
- mov #0, r0
+ mov #0, r5
.align 2
3:
.long C_SYMBOL_NAME(__sigsetjmp@GOT)
#else
mov.l 1f, r1
jmp @r1
- mov #0, r0
+ mov #0, r5
.align 2
1:
.long C_SYMBOL_NAME(__sigsetjmp)
diff --git a/libc/sysdeps/sh/bsd-setjmp.S b/libc/sysdeps/sh/bsd-setjmp.S
index e07628442..de226e128 100644
--- a/libc/sysdeps/sh/bsd-setjmp.S
+++ b/libc/sysdeps/sh/bsd-setjmp.S
@@ -1,5 +1,5 @@
/* BSD `setjmp' entry point to `sigsetjmp (..., 1)'. SH version.
- Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 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
@@ -36,14 +36,14 @@ ENTRY (setjmp)
mov.l 3f, r1
mov.l @(r0,r1), r1
jmp @r1
- mov #1, r0
+ mov #1, r5
.align 2
3:
.long C_SYMBOL_NAME(__sigsetjmp@GOT)
#else
mov.l 1f, r1
jmp @r1
- mov #1, r0
+ mov #1, r5
.align 2
1:
.long C_SYMBOL_NAME(__sigsetjmp)
diff --git a/libc/sysdeps/sparc/fpu/feholdexcpt.c b/libc/sysdeps/sparc/fpu/feholdexcpt.c
index 729637ad1..424855e76 100644
--- a/libc/sysdeps/sparc/fpu/feholdexcpt.c
+++ b/libc/sysdeps/sparc/fpu/feholdexcpt.c
@@ -1,5 +1,5 @@
/* Store current floating-point environment and clear exceptions.
- Copyright (C) 1997, 1998, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 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
@@ -26,8 +26,8 @@ feholdexcept (fenv_t *envp)
__fenv_stfsr (*envp);
- /* Set all exceptions to non-stop. */
- tmp = *envp & ~(0x1f << 23);
+ /* Set all exceptions to non-stop and clear all exceptions. */
+ tmp = *envp & ~((0x1f << 23) | FE_ALL_EXCEPT);
__fenv_ldfsr (tmp);
diff --git a/libc/sysdeps/sparc/fpu/fraiseexcpt.c b/libc/sysdeps/sparc/fpu/fraiseexcpt.c
index cbb8be80e..b96eeaed2 100644
--- a/libc/sysdeps/sparc/fpu/fraiseexcpt.c
+++ b/libc/sysdeps/sparc/fpu/fraiseexcpt.c
@@ -1,5 +1,5 @@
/* Raise given exceptions.
- Copyright (C) 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1999, 2000, 2002, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -26,9 +26,9 @@ int
__feraiseexcept (int excepts)
{
static const struct {
- double zero, one, max, min, sixteen, pi;
+ double zero, one, max, min, pi;
} c = {
- 0.0, 1.0, DBL_MAX, DBL_MIN, 16.0, M_PI
+ 0.0, 1.0, DBL_MAX, DBL_MIN, M_PI
};
double d;
@@ -66,7 +66,7 @@ __feraiseexcept (int excepts)
if ((FE_UNDERFLOW & excepts) != 0)
{
__asm ("" : "=e" (d) : "0" (c.min));
- d /= c.sixteen;
+ d *= d;
__asm __volatile ("" : : "e" (d));
}
diff --git a/libc/sysdeps/sparc/sparc32/dl-machine.h b/libc/sysdeps/sparc/sparc32/dl-machine.h
index 19aac6a7f..b3b7852d8 100644
--- a/libc/sysdeps/sparc/sparc32/dl-machine.h
+++ b/libc/sysdeps/sparc/sparc32/dl-machine.h
@@ -1,5 +1,6 @@
/* Machine-dependent ELF dynamic relocation inline functions. SPARC version.
- Copyright (C) 1996-2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1996-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
@@ -155,12 +156,18 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
|| __builtin_expect (l->l_info [VALIDX (DT_GNU_LIBLISTSZ)] != NULL, 0))
{
/* Need to reinitialize .plt to undo prelinking. */
- int do_flush;
Elf32_Rela *rela = (Elf32_Rela *) D_PTR (l, l_info[DT_JMPREL]);
Elf32_Rela *relaend
= (Elf32_Rela *) ((char *) rela
+ l->l_info[DT_PLTRELSZ]->d_un.d_val);
- do_flush = GLRO(dl_hwcap) & HWCAP_SPARC_FLUSH;
+#if !defined RTLD_BOOTSTRAP && !defined __sparc_v9__
+ /* Note that we don't mask the hwcap here, as the flush is
+ essential to functionality on those cpu's that implement it.
+ For sparcv9 we can assume flush is present. */
+ const int do_flush = GLRO(dl_hwcap) & HWCAP_SPARC_FLUSH;
+#else
+ const int do_flush = 1;
+#endif
/* prelink must ensure there are no R_SPARC_NONE relocs left
in .rela.plt. */
@@ -305,20 +312,11 @@ _dl_start_user:\n\
.size _dl_start_user, . - _dl_start_user\n\
.previous");
-static inline Elf32_Addr
+static inline __attribute__ ((always_inline)) Elf32_Addr
sparc_fixup_plt (const Elf32_Rela *reloc, Elf32_Addr *reloc_addr,
- Elf32_Addr value, int t)
+ Elf32_Addr value, int t, int do_flush)
{
Elf32_Sword disp = value - (Elf32_Addr) reloc_addr;
-#ifndef RTLD_BOOTSTRAP
- /* Note that we don't mask the hwcap here, as the flush is essential to
- functionality on those cpu's that implement it. */
- int do_flush = GLRO(dl_hwcap) & HWCAP_SPARC_FLUSH;
-#else
- /* Unfortunately, this is necessary, so that we can ensure
- ld.so will not execute corrupt PLT entry instructions. */
- const int do_flush = 1;
-#endif
if (0 && disp >= -0x800000 && disp < 0x800000)
{
@@ -354,7 +352,15 @@ elf_machine_fixup_plt (struct link_map *map, lookup_t t,
const Elf32_Rela *reloc,
Elf32_Addr *reloc_addr, Elf32_Addr value)
{
- return sparc_fixup_plt (reloc, reloc_addr, value, 1);
+#ifdef __sparc_v9__
+ /* Sparc v9 can assume flush is always present. */
+ const int do_flush = 1;
+#else
+ /* Note that we don't mask the hwcap here, as the flush is essential to
+ functionality on those cpu's that implement it. */
+ const int do_flush = GLRO(dl_hwcap) & HWCAP_SPARC_FLUSH;
+#endif
+ return sparc_fixup_plt (reloc, reloc_addr, value, 1, do_flush);
}
/* Return the final value of a plt relocation. */
@@ -455,9 +461,21 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
*reloc_addr = value;
break;
case R_SPARC_JMP_SLOT:
- /* At this point we don't need to bother with thread safety,
- so we can optimize the first instruction of .plt out. */
- sparc_fixup_plt (reloc, reloc_addr, value, 0);
+ {
+#if !defined RTLD_BOOTSTRAP && !defined __sparc_v9__
+ /* Note that we don't mask the hwcap here, as the flush is
+ essential to functionality on those cpu's that implement
+ it. For sparcv9 we can assume flush is present. */
+ const int do_flush = GLRO(dl_hwcap) & HWCAP_SPARC_FLUSH;
+#else
+ /* Unfortunately, this is necessary, so that we can ensure
+ ld.so will not execute corrupt PLT entry instructions. */
+ const int do_flush = 1;
+#endif
+ /* At this point we don't need to bother with thread safety,
+ so we can optimize the first instruction of .plt out. */
+ sparc_fixup_plt (reloc, reloc_addr, value, 0, do_flush);
+ }
break;
#if (!defined RTLD_BOOTSTRAP || USE___THREAD) \
&& !defined RESOLVE_CONFLICT_FIND_MAP
diff --git a/libc/sysdeps/sparc/sparc32/sparcv9b/memcpy.S b/libc/sysdeps/sparc/sparc32/sparcv9/sparcv9b/memcpy.S
index 1404dead7..61960dce6 100644
--- a/libc/sysdeps/sparc/sparc32/sparcv9b/memcpy.S
+++ b/libc/sysdeps/sparc/sparc32/sparcv9/sparcv9b/memcpy.S
@@ -1,4 +1,2 @@
-#define ASI_PNF 0x82
-#define ASI_BLK_P 0xf0
#define XCC icc
#include <sparc64/sparcv9b/memcpy.S>
diff --git a/libc/sysdeps/sparc/sparc32/sparcv9v/memcpy.S b/libc/sysdeps/sparc/sparc32/sparcv9/sparcv9v/memcpy.S
index 4c05f57bc..4c05f57bc 100644
--- a/libc/sysdeps/sparc/sparc32/sparcv9v/memcpy.S
+++ b/libc/sysdeps/sparc/sparc32/sparcv9/sparcv9v/memcpy.S
diff --git a/libc/sysdeps/sparc/sparc32/sparcv9v/memset.S b/libc/sysdeps/sparc/sparc32/sparcv9/sparcv9v/memset.S
index 5e46c7489..5e46c7489 100644
--- a/libc/sysdeps/sparc/sparc32/sparcv9v/memset.S
+++ b/libc/sysdeps/sparc/sparc32/sparcv9/sparcv9v/memset.S
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/x86_64/bits/libc-vdso.h b/libc/sysdeps/unix/sysv/linux/x86_64/bits/libc-vdso.h
new file mode 100644
index 000000000..6e08d3b20
--- /dev/null
+++ b/libc/sysdeps/unix/sysv/linux/x86_64/bits/libc-vdso.h
@@ -0,0 +1,35 @@
+/* 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
+ 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 _LIBC_VDSO_H
+#define _LIBC_VDSO_H
+
+#include <time.h>
+#include <sys/time.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
diff --git a/libc/sysdeps/wordsize-64/strtol.c b/libc/sysdeps/wordsize-64/strtol.c
index 2e1b22934..ac17bbe4c 100644
--- a/libc/sysdeps/wordsize-64/strtol.c
+++ b/libc/sysdeps/wordsize-64/strtol.c
@@ -11,4 +11,6 @@
strong_alias (__strtol_internal, __strtoll_internal)
libc_hidden_ver (__strtol_internal, __strtoll_internal)
weak_alias (strtol, strtoll)
+libc_hidden_ver (strtol, strtoll)
weak_alias (strtol, strtoq)
+libc_hidden_ver (strtol, strtoq)
diff --git a/libc/sysdeps/x86_64/cacheinfo.c b/libc/sysdeps/x86_64/cacheinfo.c
index f8217a175..793dc2d35 100644
--- a/libc/sysdeps/x86_64/cacheinfo.c
+++ b/libc/sysdeps/x86_64/cacheinfo.c
@@ -55,11 +55,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 },
@@ -257,7 +259,8 @@ handle_amd (int name)
: "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
: "0" (0x80000000));
- if (name >= _SC_LEVEL3_CACHE_SIZE)
+ /* No level 4 cache (yet). */
+ if (name > _SC_LEVEL3_CACHE_LINESIZE)
return 0;
unsigned int fn = 0x80000005 + (name >= _SC_LEVEL2_CACHE_SIZE);
@@ -278,36 +281,87 @@ handle_amd (int name)
{
case _SC_LEVEL1_DCACHE_SIZE:
return (ecx >> 14) & 0x3fc00;
+
case _SC_LEVEL1_DCACHE_ASSOC:
ecx >>= 16;
if ((ecx & 0xff) == 0xff)
/* Fully associative. */
return (ecx << 2) & 0x3fc00;
return ecx & 0xff;
+
case _SC_LEVEL1_DCACHE_LINESIZE:
return ecx & 0xff;
+
case _SC_LEVEL2_CACHE_SIZE:
return (ecx & 0xf000) == 0 ? 0 : (ecx >> 6) & 0x3fffc00;
+
case _SC_LEVEL2_CACHE_ASSOC:
- ecx >>= 12;
- switch (ecx & 0xf)
+ switch ((ecx >> 12) & 0xf)
{
case 0:
case 1:
case 2:
case 4:
- return ecx & 0xf;
+ return (ecx >> 12) & 0xf;
case 6:
return 8;
case 8:
return 16;
- case 0xf:
- return (ecx << 6) & 0x3fffc00;
+ case 10:
+ return 32;
+ case 11:
+ return 48;
+ case 12:
+ return 64;
+ case 13:
+ return 96;
+ case 14:
+ return 128;
+ case 15:
+ return ((ecx >> 6) & 0x3fffc00) / (ecx & 0xff);
default:
return 0;
}
+ /* NOTREACHED */
+
case _SC_LEVEL2_CACHE_LINESIZE:
return (ecx & 0xf000) == 0 ? 0 : ecx & 0xff;
+
+ case _SC_LEVEL3_CACHE_SIZE:
+ return (edx & 0xf000) == 0 ? 0 : (edx & 0x3ffc0000) << 1;
+
+ case _SC_LEVEL3_CACHE_ASSOC:
+ switch ((edx >> 12) & 0xf)
+ {
+ case 0:
+ case 1:
+ case 2:
+ case 4:
+ return (edx >> 12) & 0xf;
+ case 6:
+ return 8;
+ case 8:
+ return 16;
+ case 10:
+ return 32;
+ case 11:
+ return 48;
+ case 12:
+ return 64;
+ case 13:
+ return 96;
+ case 14:
+ return 128;
+ case 15:
+ return ((edx & 0x3ffc0000) << 1) / (edx & 0xff);
+ default:
+ return 0;
+ }
+ /* NOTREACHED */
+
+ case _SC_LEVEL3_CACHE_LINESIZE:
+ return (edx & 0xf000) == 0 ? 0 : edx & 0xff;
+
default:
assert (! "cannot happen");
}
diff --git a/libc/sysdeps/x86_64/dl-trampoline.S b/libc/sysdeps/x86_64/dl-trampoline.S
index c1686dae1..84fe4724b 100644
--- a/libc/sysdeps/x86_64/dl-trampoline.S
+++ b/libc/sysdeps/x86_64/dl-trampoline.S
@@ -1,5 +1,5 @@
/* PLT trampolines. x86-64 version.
- Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 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
@@ -120,13 +120,14 @@ _dl_runtime_profile:
leaq 104(%rsp), %rsi
movq %rsp, %rbx
cfi_def_cfa_register (1)
+ movq %r10, %rcx
+ addq $8, %r10
+ andq $0xfffffffffffffff0, %r10
subq %r10, %rsp
movq %rsp, %rdi
- movq %r10, %rcx
shrq $3, %rcx
rep
movsq
- andq $0xfffffffffffffff0, %rsp
movq 32(%rbx), %rcx
movq 40(%rbx), %rsi
movq 48(%rbx), %rdi
diff --git a/libc/sysdeps/x86_64/ldbl2mpn.c b/libc/sysdeps/x86_64/ldbl2mpn.c
new file mode 100644
index 000000000..641b789cd
--- /dev/null
+++ b/libc/sysdeps/x86_64/ldbl2mpn.c
@@ -0,0 +1 @@
+#include "../i386/ldbl2mpn.c"
diff --git a/libc/sysdeps/x86_64/sched_cpucount.c b/libc/sysdeps/x86_64/sched_cpucount.c
new file mode 100644
index 000000000..63d84a62e
--- /dev/null
+++ b/libc/sysdeps/x86_64/sched_cpucount.c
@@ -0,0 +1,26 @@
+/* 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 __amdfam10
+# define POPCNT(l) \
+ ({ __cpu_mask r; \
+ asm ("popcntq %1, %0" : "=r" (r) : "0" (l)); \
+ r; })
+#endif
+
+#include <posix/sched_cpucount.c>